@bonginkan/maria 3.6.1 → 3.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -22,9 +22,9 @@ var Anthropic = require('@anthropic-ai/sdk');
22
22
  var generativeAi = require('@google/generative-ai');
23
23
  var toml = require('toml');
24
24
  var inquirer = require('inquirer');
25
- var zod = require('zod');
26
25
  var process$1 = require('process');
27
26
  var ora = require('ora');
27
+ var zod = require('zod');
28
28
  var crypto = require('crypto');
29
29
  var perf_hooks = require('perf_hooks');
30
30
  var commander = require('commander');
@@ -128,8 +128,8 @@ var init_conversation_persistence = __esm({
128
128
  try {
129
129
  const configDir = path6__namespace.dirname(this.sessionFile);
130
130
  await fs4.promises.mkdir(configDir, { recursive: true });
131
- } catch (error2) {
132
- console.warn("Failed to create config directory:", error2);
131
+ } catch (error) {
132
+ console.warn("Failed to create config directory:", error);
133
133
  }
134
134
  }
135
135
  /**
@@ -176,8 +176,8 @@ var init_conversation_persistence = __esm({
176
176
  }
177
177
  };
178
178
  await fs4.promises.writeFile(this.sessionFile, JSON.stringify(session, null, 2));
179
- } catch (error2) {
180
- console.warn("Failed to save conversation history:", error2);
179
+ } catch (error) {
180
+ console.warn("Failed to save conversation history:", error);
181
181
  }
182
182
  }
183
183
  /**
@@ -203,7 +203,7 @@ var init_conversation_persistence = __esm({
203
203
  newestMessage: messages[messages.length - 1]?.timestamp,
204
204
  fileSize: stats.size
205
205
  };
206
- } catch (error2) {
206
+ } catch (error) {
207
207
  return {
208
208
  totalMessages: 0
209
209
  };
@@ -400,10 +400,10 @@ var init_chat_context_service = __esm({
400
400
  };
401
401
  await fs6__namespace.writeFile(sessionFile, JSON.stringify(sessionData, null, 2));
402
402
  this.emit("session-persisted", sessionFile);
403
- } catch (error2) {
403
+ } catch (error) {
404
404
  this.emit(
405
405
  "persist-error",
406
- error2 instanceof Error ? error2 : new Error(String(error2))
406
+ error instanceof Error ? error : new Error(String(error))
407
407
  );
408
408
  }
409
409
  }
@@ -1100,14 +1100,14 @@ var init_telemetry_collector = __esm({
1100
1100
  /**
1101
1101
  * Track errors
1102
1102
  */
1103
- trackError(error2, context2) {
1103
+ trackError(error, context2) {
1104
1104
  this.addEvent({
1105
1105
  timestamp: Date.now(),
1106
1106
  eventType: "error_occurred",
1107
1107
  sessionId: this.sessionId,
1108
1108
  data: {
1109
- message: error2.message,
1110
- stack: error2.stack,
1109
+ message: error.message,
1110
+ stack: error.stack,
1111
1111
  ...context2
1112
1112
  }
1113
1113
  });
@@ -1134,8 +1134,8 @@ var init_telemetry_collector = __esm({
1134
1134
  } else {
1135
1135
  this.storeLocally(eventsToFlush);
1136
1136
  }
1137
- } catch (error2) {
1138
- console.error("[Telemetry] Failed to flush events:", error2);
1137
+ } catch (error) {
1138
+ console.error("[Telemetry] Failed to flush events:", error);
1139
1139
  this.events.unshift(...eventsToFlush);
1140
1140
  }
1141
1141
  }
@@ -3230,10 +3230,10 @@ var require_ponyfill_es2018 = __commonJS({
3230
3230
  });
3231
3231
  return promise;
3232
3232
  }
3233
- function WritableStreamDealWithRejection(stream, error2) {
3233
+ function WritableStreamDealWithRejection(stream, error) {
3234
3234
  const state = stream._state;
3235
3235
  if (state === "writable") {
3236
- WritableStreamStartErroring(stream, error2);
3236
+ WritableStreamStartErroring(stream, error);
3237
3237
  return;
3238
3238
  }
3239
3239
  WritableStreamFinishErroring(stream);
@@ -3284,10 +3284,10 @@ var require_ponyfill_es2018 = __commonJS({
3284
3284
  stream._inFlightWriteRequest._resolve(void 0);
3285
3285
  stream._inFlightWriteRequest = void 0;
3286
3286
  }
3287
- function WritableStreamFinishInFlightWriteWithError(stream, error2) {
3288
- stream._inFlightWriteRequest._reject(error2);
3287
+ function WritableStreamFinishInFlightWriteWithError(stream, error) {
3288
+ stream._inFlightWriteRequest._reject(error);
3289
3289
  stream._inFlightWriteRequest = void 0;
3290
- WritableStreamDealWithRejection(stream, error2);
3290
+ WritableStreamDealWithRejection(stream, error);
3291
3291
  }
3292
3292
  function WritableStreamFinishInFlightClose(stream) {
3293
3293
  stream._inFlightCloseRequest._resolve(void 0);
@@ -3306,14 +3306,14 @@ var require_ponyfill_es2018 = __commonJS({
3306
3306
  defaultWriterClosedPromiseResolve(writer);
3307
3307
  }
3308
3308
  }
3309
- function WritableStreamFinishInFlightCloseWithError(stream, error2) {
3310
- stream._inFlightCloseRequest._reject(error2);
3309
+ function WritableStreamFinishInFlightCloseWithError(stream, error) {
3310
+ stream._inFlightCloseRequest._reject(error);
3311
3311
  stream._inFlightCloseRequest = void 0;
3312
3312
  if (stream._pendingAbortRequest !== void 0) {
3313
- stream._pendingAbortRequest._reject(error2);
3313
+ stream._pendingAbortRequest._reject(error);
3314
3314
  stream._pendingAbortRequest = void 0;
3315
3315
  }
3316
- WritableStreamDealWithRejection(stream, error2);
3316
+ WritableStreamDealWithRejection(stream, error);
3317
3317
  }
3318
3318
  function WritableStreamCloseQueuedOrInFlight(stream) {
3319
3319
  if (stream._closeRequest === void 0 && stream._inFlightCloseRequest === void 0) {
@@ -3530,18 +3530,18 @@ var require_ponyfill_es2018 = __commonJS({
3530
3530
  }
3531
3531
  return WritableStreamDefaultWriterClose(writer);
3532
3532
  }
3533
- function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error2) {
3533
+ function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error) {
3534
3534
  if (writer._closedPromiseState === "pending") {
3535
- defaultWriterClosedPromiseReject(writer, error2);
3535
+ defaultWriterClosedPromiseReject(writer, error);
3536
3536
  } else {
3537
- defaultWriterClosedPromiseResetToRejected(writer, error2);
3537
+ defaultWriterClosedPromiseResetToRejected(writer, error);
3538
3538
  }
3539
3539
  }
3540
- function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error2) {
3540
+ function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error) {
3541
3541
  if (writer._readyPromiseState === "pending") {
3542
- defaultWriterReadyPromiseReject(writer, error2);
3542
+ defaultWriterReadyPromiseReject(writer, error);
3543
3543
  } else {
3544
- defaultWriterReadyPromiseResetToRejected(writer, error2);
3544
+ defaultWriterReadyPromiseResetToRejected(writer, error);
3545
3545
  }
3546
3546
  }
3547
3547
  function WritableStreamDefaultWriterGetDesiredSize(writer) {
@@ -3776,9 +3776,9 @@ var require_ponyfill_es2018 = __commonJS({
3776
3776
  WritableStreamDefaultControllerProcessWrite(controller, value);
3777
3777
  }
3778
3778
  }
3779
- function WritableStreamDefaultControllerErrorIfNeeded(controller, error2) {
3779
+ function WritableStreamDefaultControllerErrorIfNeeded(controller, error) {
3780
3780
  if (controller._controlledWritableStream._state === "writable") {
3781
- WritableStreamDefaultControllerError(controller, error2);
3781
+ WritableStreamDefaultControllerError(controller, error);
3782
3782
  }
3783
3783
  }
3784
3784
  function WritableStreamDefaultControllerProcessClose(controller) {
@@ -3821,10 +3821,10 @@ var require_ponyfill_es2018 = __commonJS({
3821
3821
  const desiredSize = WritableStreamDefaultControllerGetDesiredSize(controller);
3822
3822
  return desiredSize <= 0;
3823
3823
  }
3824
- function WritableStreamDefaultControllerError(controller, error2) {
3824
+ function WritableStreamDefaultControllerError(controller, error) {
3825
3825
  const stream = controller._controlledWritableStream;
3826
3826
  WritableStreamDefaultControllerClearAlgorithms(controller);
3827
- WritableStreamStartErroring(stream, error2);
3827
+ WritableStreamStartErroring(stream, error);
3828
3828
  }
3829
3829
  function streamBrandCheckException$2(name2) {
3830
3830
  return new TypeError(`WritableStream.prototype.${name2} can only be used on a WritableStream`);
@@ -3968,12 +3968,12 @@ var require_ponyfill_es2018 = __commonJS({
3968
3968
  let abortAlgorithm;
3969
3969
  if (signal !== void 0) {
3970
3970
  abortAlgorithm = () => {
3971
- const error2 = signal.reason !== void 0 ? signal.reason : new DOMException2("Aborted", "AbortError");
3971
+ const error = signal.reason !== void 0 ? signal.reason : new DOMException2("Aborted", "AbortError");
3972
3972
  const actions = [];
3973
3973
  if (!preventAbort) {
3974
3974
  actions.push(() => {
3975
3975
  if (dest._state === "writable") {
3976
- return WritableStreamAbort(dest, error2);
3976
+ return WritableStreamAbort(dest, error);
3977
3977
  }
3978
3978
  return promiseResolvedWith(void 0);
3979
3979
  });
@@ -3981,12 +3981,12 @@ var require_ponyfill_es2018 = __commonJS({
3981
3981
  if (!preventCancel) {
3982
3982
  actions.push(() => {
3983
3983
  if (source._state === "readable") {
3984
- return ReadableStreamCancel(source, error2);
3984
+ return ReadableStreamCancel(source, error);
3985
3985
  }
3986
3986
  return promiseResolvedWith(void 0);
3987
3987
  });
3988
3988
  }
3989
- shutdownWithAction(() => Promise.all(actions.map((action) => action())), true, error2);
3989
+ shutdownWithAction(() => Promise.all(actions.map((action) => action())), true, error);
3990
3990
  };
3991
3991
  if (signal.aborted) {
3992
3992
  abortAlgorithm();
@@ -4089,25 +4089,25 @@ var require_ponyfill_es2018 = __commonJS({
4089
4089
  return null;
4090
4090
  }
4091
4091
  }
4092
- function shutdown(isError, error2) {
4092
+ function shutdown(isError, error) {
4093
4093
  if (shuttingDown) {
4094
4094
  return;
4095
4095
  }
4096
4096
  shuttingDown = true;
4097
4097
  if (dest._state === "writable" && !WritableStreamCloseQueuedOrInFlight(dest)) {
4098
- uponFulfillment(waitForWritesToFinish(), () => finalize(isError, error2));
4098
+ uponFulfillment(waitForWritesToFinish(), () => finalize(isError, error));
4099
4099
  } else {
4100
- finalize(isError, error2);
4100
+ finalize(isError, error);
4101
4101
  }
4102
4102
  }
4103
- function finalize(isError, error2) {
4103
+ function finalize(isError, error) {
4104
4104
  WritableStreamDefaultWriterRelease(writer);
4105
4105
  ReadableStreamReaderGenericRelease(reader2);
4106
4106
  if (signal !== void 0) {
4107
4107
  signal.removeEventListener("abort", abortAlgorithm);
4108
4108
  }
4109
4109
  if (isError) {
4110
- reject(error2);
4110
+ reject(error);
4111
4111
  } else {
4112
4112
  resolve2(void 0);
4113
4113
  }
@@ -5502,8 +5502,8 @@ var require_ponyfill_es2018 = __commonJS({
5502
5502
  const stream = controller._controlledTransformStream;
5503
5503
  const readableController = stream._readable._readableStreamController;
5504
5504
  ReadableStreamDefaultControllerClose(readableController);
5505
- const error2 = new TypeError("TransformStream terminated");
5506
- TransformStreamErrorWritableAndUnblockWrite(stream, error2);
5505
+ const error = new TypeError("TransformStream terminated");
5506
+ TransformStreamErrorWritableAndUnblockWrite(stream, error);
5507
5507
  }
5508
5508
  function TransformStreamDefaultSinkWriteAlgorithm(stream, chunk) {
5509
5509
  const controller = stream._transformStreamController;
@@ -5660,11 +5660,11 @@ var require_streams = __commonJS({
5660
5660
  };
5661
5661
  Object.assign(globalThis, __require("stream/web"));
5662
5662
  process2.emitWarning = emitWarning;
5663
- } catch (error2) {
5663
+ } catch (error) {
5664
5664
  process2.emitWarning = emitWarning;
5665
- throw error2;
5665
+ throw error;
5666
5666
  }
5667
- } catch (error2) {
5667
+ } catch (error) {
5668
5668
  Object.assign(globalThis, require_ponyfill_es2018());
5669
5669
  }
5670
5670
  }
@@ -5688,7 +5688,7 @@ var require_streams = __commonJS({
5688
5688
  });
5689
5689
  };
5690
5690
  }
5691
- } catch (error2) {
5691
+ } catch (error) {
5692
5692
  }
5693
5693
  }
5694
5694
  });
@@ -6563,15 +6563,15 @@ async function consumeBody(data2) {
6563
6563
  try {
6564
6564
  for await (const chunk of body) {
6565
6565
  if (data2.size > 0 && accumBytes + chunk.length > data2.size) {
6566
- const error2 = new FetchError(`content size at ${data2.url} over limit: ${data2.size}`, "max-size");
6567
- body.destroy(error2);
6568
- throw error2;
6566
+ const error = new FetchError(`content size at ${data2.url} over limit: ${data2.size}`, "max-size");
6567
+ body.destroy(error);
6568
+ throw error;
6569
6569
  }
6570
6570
  accumBytes += chunk.length;
6571
6571
  accum.push(chunk);
6572
6572
  }
6573
- } catch (error2) {
6574
- const error_ = error2 instanceof FetchBaseError ? error2 : new FetchError(`Invalid response body while trying to fetch ${data2.url}: ${error2.message}`, "system", error2);
6573
+ } catch (error) {
6574
+ const error_ = error instanceof FetchBaseError ? error : new FetchError(`Invalid response body while trying to fetch ${data2.url}: ${error.message}`, "system", error);
6575
6575
  throw error_;
6576
6576
  }
6577
6577
  if (body.readableEnded === true || body._readableState.ended === true) {
@@ -6580,8 +6580,8 @@ async function consumeBody(data2) {
6580
6580
  return buffer.Buffer.from(accum.join(""));
6581
6581
  }
6582
6582
  return buffer.Buffer.concat(accum, accumBytes);
6583
- } catch (error2) {
6584
- throw new FetchError(`Could not create Buffer from response body for ${data2.url}: ${error2.message}`, "system", error2);
6583
+ } catch (error) {
6584
+ throw new FetchError(`Could not create Buffer from response body for ${data2.url}: ${error.message}`, "system", error);
6585
6585
  }
6586
6586
  } else {
6587
6587
  throw new FetchError(`Premature close of server response while trying to fetch ${data2.url}`);
@@ -6632,8 +6632,8 @@ var init_body = __esm({
6632
6632
  this.size = size;
6633
6633
  if (body instanceof Stream__default.default) {
6634
6634
  body.on("error", (error_) => {
6635
- const error2 = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
6636
- this[INTERNALS].error = error2;
6635
+ const error = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
6636
+ this[INTERNALS].error = error;
6637
6637
  });
6638
6638
  }
6639
6639
  }
@@ -6816,16 +6816,16 @@ var init_headers = __esm({
6816
6816
  "node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/headers.js"() {
6817
6817
  validateHeaderName = typeof http__default.default.validateHeaderName === "function" ? http__default.default.validateHeaderName : (name2) => {
6818
6818
  if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name2)) {
6819
- const error2 = new TypeError(`Header name must be a valid HTTP token [${name2}]`);
6820
- Object.defineProperty(error2, "code", { value: "ERR_INVALID_HTTP_TOKEN" });
6821
- throw error2;
6819
+ const error = new TypeError(`Header name must be a valid HTTP token [${name2}]`);
6820
+ Object.defineProperty(error, "code", { value: "ERR_INVALID_HTTP_TOKEN" });
6821
+ throw error;
6822
6822
  }
6823
6823
  };
6824
6824
  validateHeaderValue = typeof http__default.default.validateHeaderValue === "function" ? http__default.default.validateHeaderValue : (name2, value) => {
6825
6825
  if (/[^\t\u0020-\u007E\u0080-\u00FF]/.test(value)) {
6826
- const error2 = new TypeError(`Invalid character in header content ["${name2}"]`);
6827
- Object.defineProperty(error2, "code", { value: "ERR_INVALID_CHAR" });
6828
- throw error2;
6826
+ const error = new TypeError(`Invalid character in header content ["${name2}"]`);
6827
+ Object.defineProperty(error, "code", { value: "ERR_INVALID_CHAR" });
6828
+ throw error;
6829
6829
  }
6830
6830
  };
6831
6831
  Headers = class _Headers extends URLSearchParams {
@@ -7523,15 +7523,15 @@ async function fetch2(url, options_) {
7523
7523
  const { signal } = request;
7524
7524
  let response2 = null;
7525
7525
  const abort = () => {
7526
- const error2 = new AbortError("The operation was aborted.");
7527
- reject(error2);
7526
+ const error = new AbortError("The operation was aborted.");
7527
+ reject(error);
7528
7528
  if (request.body && request.body instanceof Stream__default.default.Readable) {
7529
- request.body.destroy(error2);
7529
+ request.body.destroy(error);
7530
7530
  }
7531
7531
  if (!response2 || !response2.body) {
7532
7532
  return;
7533
7533
  }
7534
- response2.body.emit("error", error2);
7534
+ response2.body.emit("error", error);
7535
7535
  };
7536
7536
  if (signal && signal.aborted) {
7537
7537
  abort();
@@ -7551,13 +7551,13 @@ async function fetch2(url, options_) {
7551
7551
  signal.removeEventListener("abort", abortAndFinalize);
7552
7552
  }
7553
7553
  };
7554
- request_.on("error", (error2) => {
7555
- reject(new FetchError(`request to ${request.url} failed, reason: ${error2.message}`, "system", error2));
7554
+ request_.on("error", (error) => {
7555
+ reject(new FetchError(`request to ${request.url} failed, reason: ${error.message}`, "system", error));
7556
7556
  finalize();
7557
7557
  });
7558
- fixResponseChunkedTransferBadEnding(request_, (error2) => {
7558
+ fixResponseChunkedTransferBadEnding(request_, (error) => {
7559
7559
  if (response2 && response2.body) {
7560
- response2.body.destroy(error2);
7560
+ response2.body.destroy(error);
7561
7561
  }
7562
7562
  });
7563
7563
  if (process.version < "v14") {
@@ -7568,9 +7568,9 @@ async function fetch2(url, options_) {
7568
7568
  });
7569
7569
  s2.prependListener("close", (hadError) => {
7570
7570
  if (response2 && endedWithEventsCount < s2._eventsCount && !hadError) {
7571
- const error2 = new Error("Premature close");
7572
- error2.code = "ERR_STREAM_PREMATURE_CLOSE";
7573
- response2.body.emit("error", error2);
7571
+ const error = new Error("Premature close");
7572
+ error.code = "ERR_STREAM_PREMATURE_CLOSE";
7573
+ response2.body.emit("error", error);
7574
7574
  }
7575
7575
  });
7576
7576
  });
@@ -7651,9 +7651,9 @@ async function fetch2(url, options_) {
7651
7651
  signal.removeEventListener("abort", abortAndFinalize);
7652
7652
  });
7653
7653
  }
7654
- let body = Stream.pipeline(response_, new Stream.PassThrough(), (error2) => {
7655
- if (error2) {
7656
- reject(error2);
7654
+ let body = Stream.pipeline(response_, new Stream.PassThrough(), (error) => {
7655
+ if (error) {
7656
+ reject(error);
7657
7657
  }
7658
7658
  });
7659
7659
  if (process.version < "v12.10") {
@@ -7679,9 +7679,9 @@ async function fetch2(url, options_) {
7679
7679
  finishFlush: zlib__default.default.Z_SYNC_FLUSH
7680
7680
  };
7681
7681
  if (codings === "gzip" || codings === "x-gzip") {
7682
- body = Stream.pipeline(body, zlib__default.default.createGunzip(zlibOptions), (error2) => {
7683
- if (error2) {
7684
- reject(error2);
7682
+ body = Stream.pipeline(body, zlib__default.default.createGunzip(zlibOptions), (error) => {
7683
+ if (error) {
7684
+ reject(error);
7685
7685
  }
7686
7686
  });
7687
7687
  response2 = new Response(body, responseOptions);
@@ -7689,22 +7689,22 @@ async function fetch2(url, options_) {
7689
7689
  return;
7690
7690
  }
7691
7691
  if (codings === "deflate" || codings === "x-deflate") {
7692
- const raw = Stream.pipeline(response_, new Stream.PassThrough(), (error2) => {
7693
- if (error2) {
7694
- reject(error2);
7692
+ const raw = Stream.pipeline(response_, new Stream.PassThrough(), (error) => {
7693
+ if (error) {
7694
+ reject(error);
7695
7695
  }
7696
7696
  });
7697
7697
  raw.once("data", (chunk) => {
7698
7698
  if ((chunk[0] & 15) === 8) {
7699
- body = Stream.pipeline(body, zlib__default.default.createInflate(), (error2) => {
7700
- if (error2) {
7701
- reject(error2);
7699
+ body = Stream.pipeline(body, zlib__default.default.createInflate(), (error) => {
7700
+ if (error) {
7701
+ reject(error);
7702
7702
  }
7703
7703
  });
7704
7704
  } else {
7705
- body = Stream.pipeline(body, zlib__default.default.createInflateRaw(), (error2) => {
7706
- if (error2) {
7707
- reject(error2);
7705
+ body = Stream.pipeline(body, zlib__default.default.createInflateRaw(), (error) => {
7706
+ if (error) {
7707
+ reject(error);
7708
7708
  }
7709
7709
  });
7710
7710
  }
@@ -7720,9 +7720,9 @@ async function fetch2(url, options_) {
7720
7720
  return;
7721
7721
  }
7722
7722
  if (codings === "br") {
7723
- body = Stream.pipeline(body, zlib__default.default.createBrotliDecompress(), (error2) => {
7724
- if (error2) {
7725
- reject(error2);
7723
+ body = Stream.pipeline(body, zlib__default.default.createBrotliDecompress(), (error) => {
7724
+ if (error) {
7725
+ reject(error);
7726
7726
  }
7727
7727
  });
7728
7728
  response2 = new Response(body, responseOptions);
@@ -7747,9 +7747,9 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
7747
7747
  request.on("socket", (socket) => {
7748
7748
  const onSocketClose = () => {
7749
7749
  if (isChunkedTransfer && !properLastChunkReceived) {
7750
- const error2 = new Error("Premature close");
7751
- error2.code = "ERR_STREAM_PREMATURE_CLOSE";
7752
- errorCallback(error2);
7750
+ const error = new Error("Premature close");
7751
+ error.code = "ERR_STREAM_PREMATURE_CLOSE";
7752
+ errorCallback(error);
7753
7753
  }
7754
7754
  };
7755
7755
  const onData = (buf) => {
@@ -7810,11 +7810,11 @@ var init_base_provider = __esm({
7810
7810
  latencyMs,
7811
7811
  timestamp: Date.now()
7812
7812
  };
7813
- } catch (error2) {
7813
+ } catch (error) {
7814
7814
  return {
7815
7815
  ok: false,
7816
7816
  latencyMs: Date.now() - startTime,
7817
- reason: error2 instanceof Error ? error2.message : "Unknown error",
7817
+ reason: error instanceof Error ? error.message : "Unknown error",
7818
7818
  timestamp: Date.now()
7819
7819
  };
7820
7820
  }
@@ -7843,9 +7843,9 @@ var init_base_provider = __esm({
7843
7843
  );
7844
7844
  }
7845
7845
  return response2.json();
7846
- } catch (error2) {
7846
+ } catch (error) {
7847
7847
  clearTimeout(timeoutId);
7848
- throw error2;
7848
+ throw error;
7849
7849
  }
7850
7850
  }
7851
7851
  // Helper method for streaming requests
@@ -7872,9 +7872,9 @@ var init_base_provider = __esm({
7872
7872
  );
7873
7873
  }
7874
7874
  return this.parseStreamResponse(response2);
7875
- } catch (error2) {
7875
+ } catch (error) {
7876
7876
  clearTimeout(timeoutId);
7877
- throw error2;
7877
+ throw error;
7878
7878
  }
7879
7879
  }
7880
7880
  // Default stream parsing - override in subclasses for provider-specific logic
@@ -7917,10 +7917,10 @@ var init_base_provider = __esm({
7917
7917
  for (let attempt = 0; attempt < maxRetries; attempt++) {
7918
7918
  try {
7919
7919
  return await operation();
7920
- } catch (error2) {
7921
- lastError = error2;
7922
- if (this.isNonRetryableError(error2)) {
7923
- throw error2;
7920
+ } catch (error) {
7921
+ lastError = error;
7922
+ if (this.isNonRetryableError(error)) {
7923
+ throw error;
7924
7924
  }
7925
7925
  if (attempt < maxRetries - 1) {
7926
7926
  const delay = Math.pow(2, attempt) * 1e3;
@@ -7931,8 +7931,8 @@ var init_base_provider = __esm({
7931
7931
  throw lastError;
7932
7932
  }
7933
7933
  // Check if error should not be retried
7934
- isNonRetryableError(error2) {
7935
- const message = error2?.message?.toLowerCase() || "";
7934
+ isNonRetryableError(error) {
7935
+ const message = error?.message?.toLowerCase() || "";
7936
7936
  return message.includes("invalid api key") || message.includes("unauthorized") || message.includes("forbidden") || message.includes("not found");
7937
7937
  }
7938
7938
  };
@@ -8059,10 +8059,10 @@ var init_manager = __esm({
8059
8059
  async ([id, provider2]) => {
8060
8060
  try {
8061
8061
  health[id] = await provider2.health();
8062
- } catch (error2) {
8062
+ } catch (error) {
8063
8063
  health[id] = {
8064
8064
  ok: false,
8065
- reason: error2 instanceof Error ? error2.message : "Unknown error",
8065
+ reason: error instanceof Error ? error.message : "Unknown error",
8066
8066
  timestamp: Date.now()
8067
8067
  };
8068
8068
  }
@@ -8085,10 +8085,10 @@ var init_manager = __esm({
8085
8085
  if (health.ok) {
8086
8086
  this.availableProviders.add(id);
8087
8087
  }
8088
- } catch (error2) {
8088
+ } catch (error) {
8089
8089
  this.healthCache.set(id, {
8090
8090
  ok: false,
8091
- reason: error2 instanceof Error ? error2.message : "Health check failed",
8091
+ reason: error instanceof Error ? error.message : "Health check failed",
8092
8092
  timestamp: Date.now()
8093
8093
  });
8094
8094
  }
@@ -8149,10 +8149,10 @@ var init_manager = __esm({
8149
8149
  const health = await provider2.health();
8150
8150
  this.healthCache.set(id, health);
8151
8151
  return health;
8152
- } catch (error2) {
8152
+ } catch (error) {
8153
8153
  const health = {
8154
8154
  ok: false,
8155
- reason: error2 instanceof Error ? error2.message : "Health check failed",
8155
+ reason: error instanceof Error ? error.message : "Health check failed",
8156
8156
  timestamp: now
8157
8157
  };
8158
8158
  this.healthCache.set(id, health);
@@ -9394,7 +9394,7 @@ var init_ai_response_service = __esm({
9394
9394
  await this.modernProviderManager.initialize();
9395
9395
  }
9396
9396
  this.initialized = true;
9397
- } catch (error2) {
9397
+ } catch (error) {
9398
9398
  try {
9399
9399
  await this.legacyProviderFactory.initializeFromEnvironment();
9400
9400
  this.initialized = true;
@@ -9415,7 +9415,7 @@ var init_ai_response_service = __esm({
9415
9415
  } else {
9416
9416
  try {
9417
9417
  return await this.modernProviderManager.pick(DEFAULT_PROVIDER2);
9418
- } catch (error2) {
9418
+ } catch (error) {
9419
9419
  return this.legacyProviderFactory.getActiveProvider();
9420
9420
  }
9421
9421
  }
@@ -9744,8 +9744,8 @@ var init_SlashCommandHandler = __esm({
9744
9744
  return await this.executeWithTimeout(command, context2, options.timeout);
9745
9745
  }
9746
9746
  return await command.execute(context2);
9747
- } catch (error2) {
9748
- if (error2 instanceof Error && error2.name === "AbortError") {
9747
+ } catch (error) {
9748
+ if (error instanceof Error && error.name === "AbortError") {
9749
9749
  return {
9750
9750
  success: false,
9751
9751
  error: "Command execution timed out",
@@ -9754,7 +9754,7 @@ var init_SlashCommandHandler = __esm({
9754
9754
  }
9755
9755
  return {
9756
9756
  success: false,
9757
- error: error2 instanceof Error ? error2.message : "Unknown error",
9757
+ error: error instanceof Error ? error.message : "Unknown error",
9758
9758
  messages: []
9759
9759
  };
9760
9760
  }
@@ -9773,9 +9773,9 @@ var init_SlashCommandHandler = __esm({
9773
9773
  const result = await command.execute(contextWithSignal);
9774
9774
  clearTimeout(timeoutId);
9775
9775
  return result;
9776
- } catch (error2) {
9776
+ } catch (error) {
9777
9777
  clearTimeout(timeoutId);
9778
- throw error2;
9778
+ throw error;
9779
9779
  }
9780
9780
  }
9781
9781
  /**
@@ -9842,7 +9842,7 @@ var init_SlashCommandHandler = __esm({
9842
9842
  });
9843
9843
 
9844
9844
  // src/shared/adapters/LegacySlashCommandAdapter.ts
9845
- var LegacySlashCommandAdapter, SlashCommandHandler;
9845
+ var LegacySlashCommandAdapter, SlashCommandHandler2;
9846
9846
  var init_LegacySlashCommandAdapter = __esm({
9847
9847
  "src/shared/adapters/LegacySlashCommandAdapter.ts"() {
9848
9848
  init_SlashCommandHandler();
@@ -9882,10 +9882,10 @@ var init_LegacySlashCommandAdapter = __esm({
9882
9882
  error: result.error,
9883
9883
  messages: result.messages || []
9884
9884
  };
9885
- } catch (error2) {
9885
+ } catch (error) {
9886
9886
  return {
9887
9887
  success: false,
9888
- error: error2 instanceof Error ? error2.message : "Unknown error",
9888
+ error: error instanceof Error ? error.message : "Unknown error",
9889
9889
  messages: []
9890
9890
  };
9891
9891
  }
@@ -9905,10 +9905,10 @@ var init_LegacySlashCommandAdapter = __esm({
9905
9905
  success: true,
9906
9906
  messages: [{ role: "assistant", content: result }]
9907
9907
  };
9908
- } catch (error2) {
9908
+ } catch (error) {
9909
9909
  return {
9910
9910
  success: false,
9911
- error: error2 instanceof Error ? error2.message : "Command execution failed",
9911
+ error: error instanceof Error ? error.message : "Command execution failed",
9912
9912
  messages: []
9913
9913
  };
9914
9914
  }
@@ -9923,7 +9923,7 @@ var init_LegacySlashCommandAdapter = __esm({
9923
9923
  return this.handler;
9924
9924
  }
9925
9925
  };
9926
- SlashCommandHandler = LegacySlashCommandAdapter;
9926
+ SlashCommandHandler2 = LegacySlashCommandAdapter;
9927
9927
  }
9928
9928
  });
9929
9929
 
@@ -11289,7 +11289,7 @@ function getVersion() {
11289
11289
  const packageJson2 = getPackageJson();
11290
11290
  _cachedVersion = packageJson2.version;
11291
11291
  return _cachedVersion;
11292
- } catch (error2) {
11292
+ } catch (error) {
11293
11293
  _cachedVersion = "latest";
11294
11294
  return _cachedVersion;
11295
11295
  }
@@ -11347,8 +11347,8 @@ function getPackageJson() {
11347
11347
  const packageJsonContent = fs4.readFileSync(packageJsonPath, "utf-8");
11348
11348
  _cachedPackageJson = JSON.parse(packageJsonContent);
11349
11349
  return _cachedPackageJson;
11350
- } catch (error2) {
11351
- throw new Error(`Failed to read package.json: ${error2}`);
11350
+ } catch (error) {
11351
+ throw new Error(`Failed to read package.json: ${error}`);
11352
11352
  }
11353
11353
  }
11354
11354
  var _cachedVersion, _cachedPackageJson;
@@ -14099,14 +14099,13 @@ var ProviderSelector;
14099
14099
  var init_provider_selector = __esm({
14100
14100
  "src/services/provider-selector.ts"() {
14101
14101
  init_providers();
14102
- init_manager();
14103
14102
  ProviderSelector = class {
14104
14103
  config;
14105
14104
  modernProviderManager;
14106
14105
  legacyProviderManager;
14107
14106
  constructor(_config) {
14108
14107
  this.config = _config;
14109
- this.modernProviderManager = new UnifiedAIProviderManager2();
14108
+ this.modernProviderManager = new UnifiedAIProviderManager();
14110
14109
  this.legacyProviderManager = new UnifiedAIProviderManager2(_config);
14111
14110
  }
14112
14111
  async initialize() {
@@ -14373,653 +14372,16 @@ To use ${provider2.name}, you need to:`));
14373
14372
  }
14374
14373
  });
14375
14374
 
14376
- // src/utils/import-helper.ts
14377
- var import_helper_exports = {};
14378
- __export(import_helper_exports, {
14379
- canImport: () => canImport,
14380
- importNodeBuiltin: () => importNodeBuiltin,
14381
- importReactComponent: () => importReactComponent,
14382
- safeDynamicImport: () => safeDynamicImport
14383
- });
14384
- async function safeDynamicImport(specifier) {
14385
- try {
14386
- const _module = await import(specifier);
14387
- return _module.default || _module;
14388
- } catch (importError) {
14389
- try {
14390
- const _require = global.__require || globalThis._require || process.mainModule?._require;
14391
- if (!_require) {
14392
- throw new Error("CommonJS _require not available");
14393
- }
14394
- return _require(specifier);
14395
- } catch (requireError) {
14396
- throw importError;
14397
- }
14398
- }
14399
- }
14400
- async function importNodeBuiltin(moduleName) {
14401
- return safeDynamicImport(`node:${moduleName}`).catch(
14402
- () => safeDynamicImport(moduleName)
14403
- );
14404
- }
14405
- async function importReactComponent(specifier) {
14406
- try {
14407
- const _module = await safeDynamicImport(specifier);
14408
- return _module;
14409
- } catch (error2) {
14410
- console.warn(`Failed to load React component ${specifier}:`, error2);
14411
- throw new Error(
14412
- `React component ${specifier} is not available in this environment`
14413
- );
14414
- }
14415
- }
14416
- async function canImport(specifier) {
14417
- try {
14418
- await safeDynamicImport(specifier);
14419
- return true;
14420
- } catch {
14421
- return false;
14422
- }
14423
- }
14424
- var init_import_helper = __esm({
14425
- "src/utils/import-helper.ts"() {
14375
+ // src/config/models.ts
14376
+ var init_models = __esm({
14377
+ "src/config/models.ts"() {
14426
14378
  }
14427
14379
  });
14428
- function deepMerge(target, source) {
14429
- const result = { ...target };
14430
- for (const key2 in source) {
14431
- if (source[key2] === void 0) continue;
14432
- const sourceValue = source[key2];
14433
- const targetValue = result[key2];
14434
- if (Array.isArray(sourceValue)) {
14435
- result[key2] = [...sourceValue];
14436
- } else if (sourceValue && typeof sourceValue === "object" && targetValue && typeof targetValue === "object" && !Array.isArray(targetValue)) {
14437
- result[key2] = deepMerge(targetValue, sourceValue);
14438
- } else {
14439
- result[key2] = sourceValue;
14440
- }
14441
- }
14442
- return result;
14443
- }
14444
- var PROVIDER_MODELS, ConfigValidationError, ConfigLoadError, PriorityModeSchema, ApiKeysSchema, LocalProvidersSchema, ProviderConfigSchema, ConfigSchema, ConfigManagerV2;
14445
- var init_config_manager = __esm({
14446
- "src/config/config-manager.ts"() {
14447
- PROVIDER_MODELS = {
14448
- openai: [
14449
- "gpt-5-mini-2025-08-07",
14450
- "gpt-5-mini",
14451
- "gpt-5",
14452
- "gpt-4o",
14453
- "gpt-4o-mini",
14454
- "gpt-4-turbo",
14455
- "o1-preview",
14456
- "o1-mini"
14457
- ],
14458
- anthropic: [
14459
- "claude-3-opus-20240229",
14460
- "claude-3-sonnet-20240229",
14461
- "claude-3-haiku-20240307",
14462
- "claude-3-5-sonnet-20241022"
14463
- ],
14464
- google: ["gemini-2.0-flash-exp", "gemini-1.5-pro", "gemini-1.5-flash"],
14465
- groq: [
14466
- "llama-3.1-70b-versatile",
14467
- "llama-3.1-8b-instant",
14468
- "mixtral-8x7b-32768"
14469
- ],
14470
- grok: ["grok-beta", "grok-vision-beta"],
14471
- lmstudio: ["*"],
14472
- // Local models - accept any
14473
- ollama: ["*"],
14474
- // Local models - accept any
14475
- vllm: ["*"]
14476
- // Local models - accept any
14477
- };
14478
- ConfigValidationError = class extends Error {
14479
- constructor(message, field, value, suggestion) {
14480
- super(message);
14481
- this.field = field;
14482
- this.value = value;
14483
- this.suggestion = suggestion;
14484
- this.name = "ConfigValidationError";
14485
- }
14486
- };
14487
- ConfigLoadError = class extends Error {
14488
- constructor(message, cause) {
14489
- super(message);
14490
- this.cause = cause;
14491
- this.name = "ConfigLoadError";
14492
- }
14493
- };
14494
- PriorityModeSchema = zod.z.enum(["privacy-first", "performance", "cost-effective", "auto"]).default("privacy-first");
14495
- ApiKeysSchema = zod.z.object({
14496
- OPENAI_API_KEY: zod.z.string().optional(),
14497
- ANTHROPIC_API_KEY: zod.z.string().optional(),
14498
- GOOGLE_API_KEY: zod.z.string().optional(),
14499
- GROQ_API_KEY: zod.z.string().optional(),
14500
- GROK_API_KEY: zod.z.string().optional()
14501
- }).partial().default({});
14502
- LocalProvidersSchema = zod.z.object({
14503
- lmstudio: zod.z.boolean().default(false),
14504
- ollama: zod.z.boolean().default(false),
14505
- vllm: zod.z.boolean().default(false)
14506
- }).default({ lmstudio: false, ollama: false, vllm: false });
14507
- ProviderConfigSchema = zod.z.object({
14508
- enabled: zod.z.boolean().default(false),
14509
- apiKey: zod.z.string().optional(),
14510
- apiBase: zod.z.string().url().optional(),
14511
- models: zod.z.record(zod.z.any()).default({})
14512
- }).default({ enabled: false, models: Record });
14513
- ConfigSchema = zod.z.object({
14514
- priority: PriorityModeSchema,
14515
- providers: zod.z.record(ProviderConfigSchema).default({}),
14516
- autoStart: zod.z.boolean().default(true),
14517
- healthMonitoring: zod.z.boolean().default(true),
14518
- language: zod.z.string().default("auto"),
14519
- offlineMode: zod.z.boolean().default(false),
14520
- // Extended configuration
14521
- model: zod.z.string().default("gpt-5-mini"),
14522
- provider: zod.z.string().default("openai"),
14523
- apiKeys: ApiKeysSchema.optional(),
14524
- localProviders: LocalProvidersSchema.optional(),
14525
- enabledProviders: zod.z.array(zod.z.string()).optional(),
14526
- // Advanced settings
14527
- maxRetries: zod.z.number().min(0).max(10).default(3),
14528
- timeout: zod.z.number().min(1e3).max(3e5).default(3e4),
14529
- // 30s default
14530
- concurrentRequests: zod.z.number().min(1).max(20).default(5),
14531
- cacheEnabled: zod.z.boolean().default(true),
14532
- logLevel: zod.z.enum(["error", "warn", "info", "debug"]).default("info"),
14533
- telemetryEnabled: zod.z.boolean().default(true)
14534
- }).strip();
14535
- ConfigManagerV2 = class _ConfigManagerV2 {
14536
- config;
14537
- sourceMap;
14538
- constructor(initialConfig = {}, source = "defaults") {
14539
- try {
14540
- this.config = this.validateAndTransform(this.loadDefaultConfig());
14541
- this.sourceMap = this.initializeSourceMap();
14542
- if (Object.keys(initialConfig).length > 0) {
14543
- this.mergeAndValidate(initialConfig, source);
14544
- }
14545
- } catch (error2) {
14546
- throw new ConfigLoadError(
14547
- `Failed to initialize ConfigManager: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
14548
- error2 instanceof Error ? error2 : void 0
14549
- );
14550
- }
14551
- }
14552
- // Utility function for parsing boolean values from environment variables
14553
- static parseBool(value, defaultValue = false) {
14554
- if (!value) return defaultValue;
14555
- return /^(1|true|yes|on)$/i.test(value.trim());
14556
- }
14557
- static parseNumber(value, defaultValue) {
14558
- if (!value) return defaultValue;
14559
- const parsed = parseInt(value, 10);
14560
- return isNaN(parsed) ? defaultValue : parsed;
14561
- }
14562
- loadDefaultConfig() {
14563
- return {
14564
- priority: "privacy-first",
14565
- providers: {},
14566
- autoStart: true,
14567
- healthMonitoring: true,
14568
- language: "auto",
14569
- offlineMode: false,
14570
- model: "gpt-5-mini",
14571
- provider: "openai",
14572
- maxRetries: 3,
14573
- timeout: 3e4,
14574
- concurrentRequests: 5,
14575
- cacheEnabled: true,
14576
- logLevel: "info",
14577
- telemetryEnabled: true
14578
- };
14579
- }
14580
- initializeSourceMap() {
14581
- const keys = Object.keys(this.config);
14582
- return keys.reduce(
14583
- (map, key2) => ({ ...map, [key2]: "defaults" }),
14584
- {}
14585
- );
14586
- }
14587
- // Validate and transform configuration using Zod schema
14588
- validateAndTransform(config2) {
14589
- try {
14590
- const validated = ConfigSchema.parse(config2);
14591
- this.validateProviderModelConsistency(validated);
14592
- return validated;
14593
- } catch (innerError) {
14594
- if (error instanceof zod.z.ZodError) {
14595
- const firstError = error.errors[0];
14596
- throw new ConfigValidationError(
14597
- `Configuration validation failed: ${firstError.message}`,
14598
- firstError.path.join("."),
14599
- firstError.received,
14600
- this.getSuggestionForError(firstError)
14601
- );
14602
- }
14603
- throw error;
14604
- }
14605
- }
14606
- // Custom provider/model consistency validation
14607
- validateProviderModelConsistency(config2) {
14608
- const { provider: provider2, model } = config2;
14609
- if (provider2 && model) {
14610
- const allowedModels = PROVIDER_MODELS[provider2];
14611
- if (allowedModels && !allowedModels.includes("*") && !allowedModels.includes(model)) {
14612
- throw new ConfigValidationError(
14613
- `Model "${model}" is not supported by provider "${provider2}"`,
14614
- "model",
14615
- model,
14616
- `Available models for ${provider2}: ${allowedModels.join(", ")}`
14617
- );
14618
- }
14619
- }
14620
- }
14621
- // Provide helpful suggestions for validation errors
14622
- getSuggestionForError(error2) {
14623
- switch (error2.code) {
14624
- case "invalid_enum_value":
14625
- return `Valid options: ${error2.options.join(", ")}`;
14626
- case "too_small":
14627
- return `Minimum value: ${error2.minimum}`;
14628
- case "too_big":
14629
- return `Maximum value: ${error2.maximum}`;
14630
- case "invalid_type":
14631
- return `Expected ${error2.expected}, got ${error2.received}`;
14632
- case "invalid_string":
14633
- if (error2.validation === "url") {
14634
- return "Must be a valid URL (e.g., https://api.example.com)";
14635
- }
14636
- return "Invalid string format";
14637
- default:
14638
- return "Please check the configuration documentation";
14639
- }
14640
- }
14641
- // Phase 2: Advanced merge with validation and source tracking
14642
- mergeAndValidate(newConfig, source = "defaults") {
14643
- try {
14644
- const mergedConfig = deepMerge(
14645
- this.config,
14646
- newConfig
14647
- );
14648
- const validatedConfig = this.validateAndTransform(mergedConfig);
14649
- this.updateSourceMap(newConfig, source);
14650
- this.config = validatedConfig;
14651
- } catch (error2) {
14652
- throw new ConfigValidationError(
14653
- `Failed to merge configuration: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
14654
- "merge",
14655
- newConfig,
14656
- "Check configuration format and values"
14657
- );
14658
- }
14659
- }
14660
- updateSourceMap(newConfig, source) {
14661
- for (const key2 of Object.keys(newConfig)) {
14662
- if (key2 in this.sourceMap) {
14663
- this.sourceMap[key2] = source;
14664
- }
14665
- }
14666
- }
14667
- get(key2, defaultValue) {
14668
- const value = this.config[key2];
14669
- return value !== void 0 ? value : defaultValue;
14670
- }
14671
- // Type-safe set method with validation
14672
- set(key2, value, source = "manual") {
14673
- try {
14674
- const updatedConfig = { ...this.config, [key2]: value };
14675
- const validatedConfig = this.validateAndTransform(updatedConfig);
14676
- this.config = validatedConfig;
14677
- this.sourceMap[key2] = source;
14678
- } catch (innerError) {
14679
- throw new ConfigValidationError(
14680
- `Failed to set ${String(key2)}: ${error instanceof Error ? error.message : "Invalid value"}`,
14681
- String(key2),
14682
- value,
14683
- error instanceof ConfigValidationError ? error.suggestion : void 0
14684
- );
14685
- }
14686
- }
14687
- // Bulk update with validation
14688
- update(updates, source = "manual") {
14689
- this.mergeAndValidate(updates, source);
14690
- }
14691
- // Get configuration source information
14692
- getSource(key2) {
14693
- return this.sourceMap[key2];
14694
- }
14695
- // Get all source mappings
14696
- getSourceMap() {
14697
- return { ...this.sourceMap };
14698
- }
14699
- // Validate current configuration
14700
- validate() {
14701
- try {
14702
- this.validateAndTransform(this.config);
14703
- return { isValid: true, errors: [] };
14704
- } catch (error2) {
14705
- const errors = [];
14706
- if (error2 instanceof ConfigValidationError) {
14707
- errors.push(`${error2.field}: ${error2.message}`);
14708
- } else {
14709
- errors.push(
14710
- error2 instanceof Error ? error2.message : "Unknown validation error"
14711
- );
14712
- }
14713
- return { isValid: false, errors };
14714
- }
14715
- }
14716
- getAll(options) {
14717
- const configCopy = { ...this.config };
14718
- if (options?.maskSensitive && configCopy.apiKeys) {
14719
- configCopy.apiKeys = Object.fromEntries(
14720
- Object.entries(configCopy.apiKeys).map(([key2, value]) => [
14721
- key2,
14722
- value ? "***MASKED***" : value
14723
- ])
14724
- );
14725
- }
14726
- const result = options?.includeSourceMap ? { config: configCopy, sources: this.sourceMap } : configCopy;
14727
- if (options?.format) {
14728
- switch (options.format) {
14729
- case "json":
14730
- return JSON.stringify(result, null, 2);
14731
- case "yaml":
14732
- return this.toYamlLike(result);
14733
- default:
14734
- return result;
14735
- }
14736
- }
14737
- return result;
14738
- }
14739
- toYamlLike(obj, indent = 0) {
14740
- const spaces = " ".repeat(indent);
14741
- let result = "";
14742
- for (const [key2, value] of Object.entries(obj)) {
14743
- if (typeof value === "object" && value !== null && !Array.isArray(value)) {
14744
- result += `${spaces}${key2}:
14745
- ${this.toYamlLike(value, indent + 1)}`;
14746
- } else if (Array.isArray(value)) {
14747
- result += `${spaces}${key2}:
14748
- `;
14749
- for (const _item of value) {
14750
- result += `${spaces} - ${_item}
14751
- `;
14752
- }
14753
- } else {
14754
- result += `${spaces}${key2}: ${value}
14755
- `;
14756
- }
14757
- }
14758
- return result;
14759
- }
14760
- // Phase 2: Enhanced environment loading with comprehensive hierarchy
14761
- static fromEnvironment() {
14762
- const envConfig = {
14763
- priority: process.env["MARIA_PRIORITY"] || void 0,
14764
- provider: process.env["MARIA_PROVIDER"] || process.env["PROVIDER"] || void 0,
14765
- model: process.env["MARIA_MODEL"] || process.env["MODEL"] || void 0,
14766
- language: process.env["MARIA_LANGUAGE"] || process.env["LANGUAGE"] || void 0,
14767
- offlineMode: _ConfigManagerV2.parseBool(process.env["MARIA_OFFLINE_MODE"]),
14768
- apiKeys: {
14769
- OPENAI_API_KEY: process.env["OPENAI_API_KEY"] || void 0,
14770
- ANTHROPIC_API_KEY: process.env["ANTHROPIC_API_KEY"] || void 0,
14771
- GOOGLE_API_KEY: process.env["GOOGLE_AI_API_KEY"] || process.env["GOOGLE_API_KEY"] || process.env["GEMINI_API_KEY"] || void 0,
14772
- GROQ_API_KEY: process.env["GROQ_API_KEY"] || void 0,
14773
- GROK_API_KEY: process.env["GROK_API_KEY"] || process.env["XAI_API_KEY"] || void 0
14774
- },
14775
- localProviders: {
14776
- lmstudio: _ConfigManagerV2.parseBool(
14777
- process.env["LMSTUDIO_ENABLED"],
14778
- true
14779
- ),
14780
- ollama: _ConfigManagerV2.parseBool(process.env["OLLAMA_ENABLED"], true),
14781
- vllm: _ConfigManagerV2.parseBool(process.env["VLLM_ENABLED"], true)
14782
- },
14783
- autoStart: _ConfigManagerV2.parseBool(
14784
- process.env["AUTO_START_LLMS"],
14785
- true
14786
- ),
14787
- healthMonitoring: _ConfigManagerV2.parseBool(
14788
- process.env["HEALTH_MONITORING"],
14789
- true
14790
- ),
14791
- // Advanced environment settings
14792
- maxRetries: _ConfigManagerV2.parseNumber(process.env["MARIA_MAX_RETRIES"]),
14793
- timeout: _ConfigManagerV2.parseNumber(process.env["MARIA_TIMEOUT"]),
14794
- concurrentRequests: _ConfigManagerV2.parseNumber(
14795
- process.env["MARIA_CONCURRENT_REQUESTS"]
14796
- ),
14797
- cacheEnabled: _ConfigManagerV2.parseBool(
14798
- process.env["MARIA_CACHE_ENABLED"]
14799
- ),
14800
- logLevel: process.env["MARIA_LOG_LEVEL"] || process.env["LOG_LEVEL"] || void 0,
14801
- telemetryEnabled: _ConfigManagerV2.parseBool(
14802
- process.env["MARIA_TELEMETRY"],
14803
- true
14804
- )
14805
- };
14806
- const cleanedConfig = _ConfigManagerV2.removeUndefined(envConfig);
14807
- return new _ConfigManagerV2(cleanedConfig, "env");
14808
- }
14809
- // Configuration hierarchy: defaults < file < env < CLI
14810
- static async loadHierarchical(options = {}) {
14811
- try {
14812
- const manager = new _ConfigManagerV2({}, "defaults");
14813
- try {
14814
- const fileConfig = await _ConfigManagerV2.loadFromFile(
14815
- options.configPath
14816
- );
14817
- if (fileConfig) {
14818
- manager.mergeAndValidate(fileConfig, "file");
14819
- }
14820
- } catch (innerError) {
14821
- console.warn(
14822
- `Warning: Could not load config file - ${error instanceof Error ? error.message : "Unknown error"}`
14823
- );
14824
- }
14825
- const envManager = _ConfigManagerV2.fromEnvironment();
14826
- manager.mergeAndValidate(envManager.config, "env");
14827
- if (options.cliOptions && Object.keys(options.cliOptions).length > 0) {
14828
- manager.mergeAndValidate(options.cliOptions, "cli");
14829
- }
14830
- return manager;
14831
- } catch (error2) {
14832
- throw new ConfigLoadError(
14833
- `Failed to load hierarchical configuration: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
14834
- error2 instanceof Error ? error2 : void 0
14835
- );
14836
- }
14837
- }
14838
- static removeUndefined(obj) {
14839
- const result = {};
14840
- for (const [key2, value] of Object.entries(obj)) {
14841
- if (value !== void 0) {
14842
- if (typeof value === "object" && value !== null && !Array.isArray(value)) {
14843
- const nested = _ConfigManagerV2.removeUndefined(value);
14844
- if (Object.keys(nested).length > 0) {
14845
- result[key2] = nested;
14846
- }
14847
- } else {
14848
- result[key2] = value;
14849
- }
14850
- }
14851
- }
14852
- return result;
14853
- }
14854
- static async loadFromFile(configPath) {
14855
- const { importNodeBuiltin: importNodeBuiltin2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
14856
- const fs7 = await importNodeBuiltin2("fs");
14857
- const _path = await importNodeBuiltin2("_path");
14858
- const os5 = await importNodeBuiltin2("os");
14859
- const targetPath = configPath || _path.join(os5.homedir(), ".maria", "config.json");
14860
- try {
14861
- const data2 = await fs7.promises.readFile(targetPath, "utf-8");
14862
- return JSON.parse(data2);
14863
- } catch (innerError) {
14864
- if (error?.code === "ENOENT") {
14865
- return null;
14866
- }
14867
- throw new ConfigLoadError(
14868
- `Failed to load config from ${targetPath}: ${error instanceof Error ? error.message : "Unknown error"}`,
14869
- error instanceof Error ? error : void 0
14870
- );
14871
- }
14872
- }
14873
- async save(configPath, options) {
14874
- const { importNodeBuiltin: importNodeBuiltin2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
14875
- const fs7 = await importNodeBuiltin2("fs");
14876
- const _path = await importNodeBuiltin2("_path");
14877
- const os5 = await importNodeBuiltin2("os");
14878
- const targetPath = configPath || _path.join(os5.homedir(), ".maria", "config.json");
14879
- try {
14880
- if (options?.backup) {
14881
- try {
14882
- await fs7.promises.access(targetPath);
14883
- const backupPath = `${targetPath}.backup.${Date.now()}`;
14884
- await fs7.promises.copyFile(targetPath, backupPath);
14885
- } catch {
14886
- }
14887
- }
14888
- await fs7.promises.mkdir(_path.dirname(targetPath), { recursive: true });
14889
- const dataToSave = this.getAll({
14890
- maskSensitive: options?.maskSensitive ?? true,
14891
- includeSourceMap: options?.includeSourceMap ?? false
14892
- });
14893
- await fs7.promises.writeFile(
14894
- targetPath,
14895
- JSON.stringify(dataToSave, null, 2),
14896
- { mode: 384 }
14897
- );
14898
- console.log(`\u2705 Configuration saved to ${targetPath}`);
14899
- } catch (error2) {
14900
- throw new ConfigLoadError(
14901
- `Failed to save configuration to ${targetPath}: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
14902
- error2 instanceof Error ? error2 : void 0
14903
- );
14904
- }
14905
- }
14906
- // Enhanced loading with automatic fallback chain
14907
- static async load(configPath) {
14908
- try {
14909
- return await _ConfigManagerV2.loadHierarchical({ configPath });
14910
- } catch (innerError) {
14911
- console.warn(
14912
- "Hierarchical config loading failed, falling back to environment:",
14913
- error
14914
- );
14915
- return _ConfigManagerV2.fromEnvironment();
14916
- }
14917
- }
14918
- // Export configuration in various formats
14919
- async export(format, outputPath) {
14920
- const config2 = this.getAll({ maskSensitive: false });
14921
- let content;
14922
- switch (format) {
14923
- case "json":
14924
- content = JSON.stringify(config2, null, 2);
14925
- break;
14926
- case "yaml":
14927
- content = this.toYamlLike(config2);
14928
- break;
14929
- case "env":
14930
- content = this.toEnvFormat(config2);
14931
- break;
14932
- default:
14933
- throw new Error(`Unsupported export format: ${format}`);
14934
- }
14935
- if (outputPath) {
14936
- const { importNodeBuiltin: importNodeBuiltin2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
14937
- const fs7 = await importNodeBuiltin2("fs");
14938
- const _path = await importNodeBuiltin2(
14939
- "_path"
14940
- );
14941
- await fs7.promises.mkdir(_path.dirname(outputPath), { recursive: true });
14942
- await fs7.promises.writeFile(outputPath, content, "utf-8");
14943
- console.log(`\u2705 Configuration exported to ${outputPath}`);
14944
- }
14945
- return content;
14946
- }
14947
- toEnvFormat(config2) {
14948
- const envVars = [];
14949
- const flatten = (obj, prefix = "") => {
14950
- for (const [key2, value] of Object.entries(obj)) {
14951
- const envKey = prefix ? `${prefix}_${key2.toUpperCase()}` : key2.toUpperCase();
14952
- if (typeof value === "object" && value !== null && !Array.isArray(value)) {
14953
- flatten(value, envKey);
14954
- } else if (Array.isArray(value)) {
14955
- envVars.push(`${envKey}=${value.join(",")}`);
14956
- } else {
14957
- envVars.push(`${envKey}=${value}`);
14958
- }
14959
- }
14960
- };
14961
- flatten(config2, "MARIA");
14962
- return envVars.join("\n");
14963
- }
14964
- // Configuration diff and merge preview
14965
- previewMerge(newConfig) {
14966
- const changes = [];
14967
- const warnings = [];
14968
- try {
14969
- const mergedConfig = deepMerge(this.config, newConfig);
14970
- const compareObjects = (current, updated, _path = "") => {
14971
- const allKeys = /* @__PURE__ */ new Set([
14972
- ...Object.keys(current || object),
14973
- ...Object.keys(updated || object)
14974
- ]);
14975
- for (const key2 of allKeys) {
14976
- const fieldPath = _path ? `${_path}.${key2}` : key2;
14977
- const currentValue = current?.[key2];
14978
- const updatedValue = updated?.[key2];
14979
- if (currentValue === void 0 && updatedValue !== void 0) {
14980
- changes.push({
14981
- field: fieldPath,
14982
- current: void 0,
14983
- new: updatedValue,
14984
- action: "add"
14985
- });
14986
- } else if (currentValue !== void 0 && updatedValue === void 0) {
14987
- changes.push({
14988
- field: fieldPath,
14989
- current: currentValue,
14990
- new: void 0,
14991
- action: "remove"
14992
- });
14993
- } else if (JSON.stringify(currentValue) !== JSON.stringify(updatedValue)) {
14994
- if (typeof currentValue === "object" && typeof updatedValue === "object") {
14995
- compareObjects(currentValue, updatedValue, fieldPath);
14996
- } else {
14997
- changes.push({
14998
- field: fieldPath,
14999
- current: currentValue,
15000
- new: updatedValue,
15001
- action: "update"
15002
- });
15003
- }
15004
- }
15005
- }
15006
- };
15007
- compareObjects(this.config, mergedConfig);
15008
- try {
15009
- this.validateAndTransform(mergedConfig);
15010
- } catch (error2) {
15011
- if (error2 instanceof ConfigValidationError) {
15012
- warnings.push(`Validation warning: ${error2.message}`);
15013
- }
15014
- }
15015
- } catch (innerError) {
15016
- warnings.push(
15017
- `Merge preview failed: ${error instanceof Error ? error.message : "Unknown error"}`
15018
- );
15019
- }
15020
- return { changes, warnings };
15021
- }
15022
- };
14380
+
14381
+ // src/config/index.ts
14382
+ var init_config3 = __esm({
14383
+ "src/config/index.ts"() {
14384
+ init_models();
15023
14385
  }
15024
14386
  });
15025
14387
 
@@ -18365,8 +17727,8 @@ var init_SessionStateMachine = __esm({
18365
17727
  this.controller = void 0;
18366
17728
  return this.to("Completed");
18367
17729
  }
18368
- fail(error2) {
18369
- this._ctx.meta = { ...this._ctx.meta || {}, error: error2 };
17730
+ fail(error) {
17731
+ this._ctx.meta = { ...this._ctx.meta || {}, error };
18370
17732
  this.inflight = false;
18371
17733
  this.clearDeadline();
18372
17734
  this.controller = void 0;
@@ -18400,32 +17762,32 @@ var init_SessionStateMachine = __esm({
18400
17762
  });
18401
17763
 
18402
17764
  // src/services/interactive-session/types/errors.ts
18403
- function isSessionError(error2) {
18404
- return error2 instanceof SessionError;
17765
+ function isSessionError(error) {
17766
+ return error instanceof SessionError;
18405
17767
  }
18406
- function isRecoverableError(error2) {
18407
- if (isSessionError(error2)) {
18408
- return error2.recoverable;
17768
+ function isRecoverableError(error) {
17769
+ if (isSessionError(error)) {
17770
+ return error.recoverable;
18409
17771
  }
18410
17772
  return false;
18411
17773
  }
18412
- function toSessionError(error2) {
18413
- if (isSessionError(error2)) {
18414
- return error2;
17774
+ function toSessionError(error) {
17775
+ if (isSessionError(error)) {
17776
+ return error;
18415
17777
  }
18416
- if (error2 instanceof Error) {
18417
- if (error2.message.includes("cancel") || error2.message.includes("abort")) {
18418
- return new UserCancelError(error2.message);
17778
+ if (error instanceof Error) {
17779
+ if (error.message.includes("cancel") || error.message.includes("abort")) {
17780
+ return new UserCancelError(error.message);
18419
17781
  }
18420
- if (error2.message.includes("timeout") || error2.message.includes("deadline")) {
18421
- return new DeadlineError(error2.message, 15e3);
17782
+ if (error.message.includes("timeout") || error.message.includes("deadline")) {
17783
+ return new DeadlineError(error.message, 15e3);
18422
17784
  }
18423
- if (error2.message.includes("network") || error2.message.includes("fetch")) {
18424
- return new NetworkError(error2.message);
17785
+ if (error.message.includes("network") || error.message.includes("fetch")) {
17786
+ return new NetworkError(error.message);
18425
17787
  }
18426
- return new InternalError(error2.message, error2);
17788
+ return new InternalError(error.message, error);
18427
17789
  }
18428
- return new InternalError(String(error2), error2);
17790
+ return new InternalError(String(error), error);
18429
17791
  }
18430
17792
  var SessionError, UserCancelError, DeadlineError, InternalError, NetworkError;
18431
17793
  var init_errors = __esm({
@@ -18501,8 +17863,8 @@ var init_SessionManager = __esm({
18501
17863
  while (this.running) {
18502
17864
  try {
18503
17865
  await this.runTurn();
18504
- } catch (error2) {
18505
- const sessionError = toSessionError(error2);
17866
+ } catch (error) {
17867
+ const sessionError = toSessionError(error);
18506
17868
  this.display.error(`Session error: ${sessionError.message}`);
18507
17869
  if (!isRecoverableError(sessionError)) {
18508
17870
  this.display.error("Fatal error, ending session");
@@ -18589,12 +17951,12 @@ var init_SessionManager = __esm({
18589
17951
  );
18590
17952
  }
18591
17953
  this.fsm.send({ type: "STREAM_DONE" });
18592
- } catch (error2) {
17954
+ } catch (error) {
18593
17955
  if (this.currentSpinnerId) {
18594
17956
  this.display.stopSpinner(this.currentSpinnerId);
18595
17957
  this.currentSpinnerId = void 0;
18596
17958
  }
18597
- const sessionError = toSessionError(error2);
17959
+ const sessionError = toSessionError(error);
18598
17960
  metric.errorCode = sessionError.code;
18599
17961
  if (sessionError instanceof DeadlineError) {
18600
17962
  metric.deadline = true;
@@ -18623,11 +17985,11 @@ var init_SessionManager = __esm({
18623
17985
  return null;
18624
17986
  }
18625
17987
  return input4.trim();
18626
- } catch (error2) {
17988
+ } catch (error) {
18627
17989
  if (this.fsm.signal?.aborted) {
18628
17990
  throw new DeadlineError("Input timeout", this.options.deadlineMs);
18629
17991
  }
18630
- throw error2;
17992
+ throw error;
18631
17993
  }
18632
17994
  }
18633
17995
  /**
@@ -18893,9 +18255,9 @@ var init_ChalkAdapter = __esm({
18893
18255
  if (signal?.aborted) break;
18894
18256
  process.stdout.write(chunk);
18895
18257
  }
18896
- } catch (error2) {
18258
+ } catch (error) {
18897
18259
  if (!signal?.aborted) {
18898
- throw error2;
18260
+ throw error;
18899
18261
  }
18900
18262
  } finally {
18901
18263
  process.stdout.write("\n");
@@ -21066,10 +20428,10 @@ var init_MemoryService = __esm({
21066
20428
  }
21067
20429
  });
21068
20430
  this.warmupInBackground();
21069
- } catch (error2) {
20431
+ } catch (error) {
21070
20432
  this._initialized = false;
21071
20433
  this._initializationPromise = null;
21072
- throw new Error(`Memory system initialization failed: ${error2}`);
20434
+ throw new Error(`Memory system initialization failed: ${error}`);
21073
20435
  }
21074
20436
  }
21075
20437
  /**
@@ -21081,8 +20443,8 @@ var init_MemoryService = __esm({
21081
20443
  try {
21082
20444
  this._engine?.loadInitialContext();
21083
20445
  this._engine?.preloadCache();
21084
- } catch (error2) {
21085
- console.warn("Memory warmup warning:", error2);
20446
+ } catch (error) {
20447
+ console.warn("Memory warmup warning:", error);
21086
20448
  }
21087
20449
  });
21088
20450
  }
@@ -21289,7 +20651,7 @@ var init_ConfigService = __esm({
21289
20651
  try {
21290
20652
  const configFile = await fs6__namespace.readFile(this._configPath, "utf-8");
21291
20653
  return JSON.parse(configFile);
21292
- } catch (error2) {
20654
+ } catch (error) {
21293
20655
  return {};
21294
20656
  }
21295
20657
  }
@@ -21300,7 +20662,7 @@ var init_ConfigService = __esm({
21300
20662
  try {
21301
20663
  const configFile = await fs6__namespace.readFile(this._userConfigPath, "utf-8");
21302
20664
  return JSON.parse(configFile);
21303
- } catch (error2) {
20665
+ } catch (error) {
21304
20666
  return {};
21305
20667
  }
21306
20668
  }
@@ -21325,11 +20687,11 @@ var init_ConfigService = __esm({
21325
20687
  validateConfig() {
21326
20688
  try {
21327
20689
  SessionConfigSchema.parse(this._config);
21328
- } catch (error2) {
21329
- if (error2 instanceof zod.z.ZodError) {
21330
- throw new Error(`Configuration validation failed: ${error2.message}`);
20690
+ } catch (error) {
20691
+ if (error instanceof zod.z.ZodError) {
20692
+ throw new Error(`Configuration validation failed: ${error.message}`);
21331
20693
  }
21332
- throw error2;
20694
+ throw error;
21333
20695
  }
21334
20696
  }
21335
20697
  /**
@@ -21408,8 +20770,8 @@ var init_ConfigService = __esm({
21408
20770
  "utf-8"
21409
20771
  );
21410
20772
  this._isDirty = false;
21411
- } catch (error2) {
21412
- throw new Error(`Failed to save configuration: ${error2}`);
20773
+ } catch (error) {
20774
+ throw new Error(`Failed to save configuration: ${error}`);
21413
20775
  }
21414
20776
  }
21415
20777
  /**
@@ -21420,8 +20782,8 @@ var init_ConfigService = __esm({
21420
20782
  clearTimeout(this._saveDebounceTimer);
21421
20783
  }
21422
20784
  this._saveDebounceTimer = setTimeout(() => {
21423
- this.save().catch((error2) => {
21424
- console.error("Auto-save failed:", error2);
20785
+ this.save().catch((error) => {
20786
+ console.error("Auto-save failed:", error);
21425
20787
  });
21426
20788
  }, 5e3);
21427
20789
  }
@@ -21674,8 +21036,8 @@ var init_RouterService = __esm({
21674
21036
  ),
21675
21037
  metadata: analysis2.metadata
21676
21038
  };
21677
- } catch (error2) {
21678
- console.warn("Intelligent routing failed:", error2);
21039
+ } catch (error) {
21040
+ console.warn("Intelligent routing failed:", error);
21679
21041
  return {
21680
21042
  type: "conversation",
21681
21043
  confidence: 0.3
@@ -22049,11 +21411,11 @@ var init_ValidationService = __esm({
22049
21411
  valid: true,
22050
21412
  value: result
22051
21413
  };
22052
- } catch (error2) {
22053
- if (error2 instanceof zod.z.ZodError) {
21414
+ } catch (error) {
21415
+ if (error instanceof zod.z.ZodError) {
22054
21416
  return {
22055
21417
  valid: false,
22056
- errors: error2.errors.map((e2) => ({
21418
+ errors: error.errors.map((e2) => ({
22057
21419
  field: e2.path.join("."),
22058
21420
  message: e2.message,
22059
21421
  code: e2.code,
@@ -22098,11 +21460,11 @@ var init_ValidationService = __esm({
22098
21460
  valid: true,
22099
21461
  value: result
22100
21462
  };
22101
- } catch (error2) {
22102
- if (error2 instanceof zod.z.ZodError) {
21463
+ } catch (error) {
21464
+ if (error instanceof zod.z.ZodError) {
22103
21465
  return {
22104
21466
  valid: false,
22105
- errors: error2.errors.map((e2) => ({
21467
+ errors: error.errors.map((e2) => ({
22106
21468
  field: "path",
22107
21469
  message: e2.message,
22108
21470
  code: e2.code,
@@ -22149,7 +21511,7 @@ var init_ValidationService = __esm({
22149
21511
  valid: true,
22150
21512
  value: result
22151
21513
  };
22152
- } catch (error2) {
21514
+ } catch (error) {
22153
21515
  return {
22154
21516
  valid: false,
22155
21517
  errors: [
@@ -22174,7 +21536,7 @@ var init_ValidationService = __esm({
22174
21536
  valid: true,
22175
21537
  value: result
22176
21538
  };
22177
- } catch (error2) {
21539
+ } catch (error) {
22178
21540
  return {
22179
21541
  valid: false,
22180
21542
  errors: [
@@ -24987,9 +24349,9 @@ var init_CommandRegistry = __esm({
24987
24349
  });
24988
24350
  clearTimeout(timer);
24989
24351
  return result;
24990
- } catch (error2) {
24352
+ } catch (error) {
24991
24353
  clearTimeout(timer);
24992
- throw error2;
24354
+ throw error;
24993
24355
  }
24994
24356
  }
24995
24357
  return registration.handler.execute(context2);
@@ -25224,9 +24586,9 @@ var init_SpinnerManager = __esm({
25224
24586
  const result = await fn();
25225
24587
  this.stop(spinnerId, "success");
25226
24588
  return result;
25227
- } catch (error2) {
24589
+ } catch (error) {
25228
24590
  this.stop(spinnerId, "fail");
25229
- throw error2;
24591
+ throw error;
25230
24592
  }
25231
24593
  }
25232
24594
  /**
@@ -25608,9 +24970,9 @@ var init_DisplayManager = __esm({
25608
24970
  process.on("exit", cleanup);
25609
24971
  process.on("SIGINT", cleanup);
25610
24972
  process.on("SIGTERM", cleanup);
25611
- process.on("uncaughtException", (error2) => {
24973
+ process.on("uncaughtException", (error) => {
25612
24974
  cleanup();
25613
- console.error("Uncaught exception:", error2);
24975
+ console.error("Uncaught exception:", error);
25614
24976
  process.exit(1);
25615
24977
  });
25616
24978
  }
@@ -26145,10 +25507,10 @@ export { generated };`;
26145
25507
  requiresInput: false
26146
25508
  // Important: prevent re-dispatch
26147
25509
  };
26148
- } catch (error2) {
25510
+ } catch (error) {
26149
25511
  return {
26150
25512
  ok: false,
26151
- message: chalk13__default.default.red(`Code generation failed: ${error2}`)
25513
+ message: chalk13__default.default.red(`Code generation failed: ${error}`)
26152
25514
  };
26153
25515
  }
26154
25516
  }
@@ -26869,9 +26231,9 @@ var init_SessionOrchestrator = __esm({
26869
26231
  await this.setupCommandRegistry();
26870
26232
  await this.initializeSessionManager();
26871
26233
  this._initialized = true;
26872
- } catch (error2) {
26234
+ } catch (error) {
26873
26235
  await this.cleanup();
26874
- throw new Error(`SessionOrchestrator initialization failed: ${error2}`);
26236
+ throw new Error(`SessionOrchestrator initialization failed: ${error}`);
26875
26237
  }
26876
26238
  }
26877
26239
  /**
@@ -27015,9 +26377,9 @@ var init_SessionOrchestrator = __esm({
27015
26377
  if (this._sessionManager) {
27016
26378
  await this._sessionManager.start();
27017
26379
  }
27018
- } catch (error2) {
26380
+ } catch (error) {
27019
26381
  this._running = false;
27020
- throw error2;
26382
+ throw error;
27021
26383
  }
27022
26384
  }
27023
26385
  /**
@@ -27034,8 +26396,8 @@ var init_SessionOrchestrator = __esm({
27034
26396
  }
27035
26397
  await this.showGoodbye();
27036
26398
  await this.cleanup();
27037
- } catch (error2) {
27038
- console.error("Error during session stop:", error2);
26399
+ } catch (error) {
26400
+ console.error("Error during session stop:", error);
27039
26401
  }
27040
26402
  }
27041
26403
  /**
@@ -27218,10 +26580,10 @@ var init_interactive_session = __esm({
27218
26580
  message: `Command ${command} is being migrated to the new system`
27219
26581
  };
27220
26582
  }
27221
- } catch (error2) {
26583
+ } catch (error) {
27222
26584
  return {
27223
26585
  ok: false,
27224
- message: `Error executing command: ${error2}`
26586
+ message: `Error executing command: ${error}`
27225
26587
  };
27226
26588
  }
27227
26589
  }
@@ -27305,7 +26667,7 @@ var init_package = __esm({
27305
26667
  "package.json"() {
27306
26668
  package_default = {
27307
26669
  name: "@bonginkan/maria",
27308
- version: "3.6.1",
26670
+ version: "3.6.2",
27309
26671
  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.",
27310
26672
  keywords: [
27311
26673
  "ai",
@@ -27754,7 +27116,7 @@ var init_maria_ai = __esm({
27754
27116
  "src/maria-ai.ts"() {
27755
27117
  init_startup_display();
27756
27118
  init_provider_selector();
27757
- init_config_manager();
27119
+ init_config3();
27758
27120
  init_IntelligentRouterService();
27759
27121
  init_interactive_session();
27760
27122
  init_package();
@@ -27764,7 +27126,7 @@ var init_maria_ai = __esm({
27764
27126
  router;
27765
27127
  session;
27766
27128
  constructor() {
27767
- this.config = new ConfigManagerV2();
27129
+ this.config = new ConfigManager();
27768
27130
  this.providerSelector = new ProviderSelector(this.config);
27769
27131
  }
27770
27132
  async initialize() {
@@ -27791,8 +27153,8 @@ var init_maria_ai = __esm({
27791
27153
  );
27792
27154
  this.session = createInteractiveSession(this);
27793
27155
  await this.session.start();
27794
- } catch (error2) {
27795
- console.error(chalk13__default.default.red("\n\u274C Initialization failed:"), error2);
27156
+ } catch (error) {
27157
+ console.error(chalk13__default.default.red("\n\u274C Initialization failed:"), error);
27796
27158
  process.exit(1);
27797
27159
  }
27798
27160
  }
@@ -27817,7 +27179,7 @@ async function initializeServices() {
27817
27179
  conversationPersistence = new ConversationPersistence();
27818
27180
  chatContext = ChatContextService.getInstance();
27819
27181
  aiResponseService = new AIResponseService();
27820
- slashCommandHandler = SlashCommandHandler.getInstance();
27182
+ slashCommandHandler = SlashCommandHandler2.getInstance();
27821
27183
  providerManager = new UnifiedAIProviderManager2();
27822
27184
  try {
27823
27185
  await providerManager.initialize();
@@ -27867,8 +27229,8 @@ async function initializeServices() {
27867
27229
  sessionMemory.push(msg);
27868
27230
  }
27869
27231
  return true;
27870
- } catch (error2) {
27871
- console.error(chalk13__default.default.red("\u274C Service initialization failed:"), error2);
27232
+ } catch (error) {
27233
+ console.error(chalk13__default.default.red("\u274C Service initialization failed:"), error);
27872
27234
  return false;
27873
27235
  }
27874
27236
  }
@@ -27989,10 +27351,10 @@ async function startInteractiveSession() {
27989
27351
  const errorMessage = result.message || result._message || "Command failed";
27990
27352
  console.log(chalk13__default.default.red(`\u274C ${errorMessage}`));
27991
27353
  }
27992
- } catch (error2) {
27354
+ } catch (error) {
27993
27355
  console.error(
27994
27356
  chalk13__default.default.red("\u274C Command error:"),
27995
- error2?.message || error2
27357
+ error?.message || error
27996
27358
  );
27997
27359
  }
27998
27360
  }
@@ -28078,10 +27440,10 @@ async function startInteractiveSession() {
28078
27440
  console.log();
28079
27441
  continue;
28080
27442
  }
28081
- } catch (error2) {
27443
+ } catch (error) {
28082
27444
  console.error(
28083
27445
  chalk13__default.default.red("\u274C SlashCommand error:"),
28084
- error2?.message || error2
27446
+ error?.message || error
28085
27447
  );
28086
27448
  console.log();
28087
27449
  continue;
@@ -28123,7 +27485,7 @@ async function startInteractiveSession() {
28123
27485
  if (conversationPersistence) {
28124
27486
  await conversationPersistence.addMessage(assistantMessage);
28125
27487
  }
28126
- } catch (error2) {
27488
+ } catch (error) {
28127
27489
  console.log(
28128
27490
  chalk13__default.default.gray(
28129
27491
  "\u26A0\uFE0F Persistent memory save failed, using session memory only"
@@ -28132,22 +27494,22 @@ async function startInteractiveSession() {
28132
27494
  }
28133
27495
  }
28134
27496
  console.log();
28135
- } catch (error2) {
28136
- if (error2?.code === "ABORT_ERR" || error2?.name === "AbortError") {
27497
+ } catch (error) {
27498
+ if (error?.code === "ABORT_ERR" || error?.name === "AbortError") {
28137
27499
  console.log(chalk13__default.default.cyan("\n\nGoodbye! \u{1F44B}"));
28138
27500
  await stopAll();
28139
27501
  return;
28140
27502
  }
28141
27503
  console.error(
28142
27504
  chalk13__default.default.red("\u274C An error occurred:"),
28143
- error2?.message || error2
27505
+ error?.message || error
28144
27506
  );
28145
27507
  }
28146
27508
  }
28147
27509
  }
28148
27510
  function createCLI2() {
28149
27511
  const program2 = new commander.Command();
28150
- 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) => {
27512
+ 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) => {
28151
27513
  const { displayFinalStartupScreen: displayFinalStartupScreen2 } = await Promise.resolve().then(() => (init_startup_display(), startup_display_exports));
28152
27514
  displayFinalStartupScreen2();
28153
27515
  const useV3 = options.v3Session || process.env.MARIA_USE_V3_SESSION === "1";
@@ -28214,7 +27576,7 @@ var init_cli = __esm({
28214
27576
  init_ai_response_service();
28215
27577
  init_LegacySlashCommandAdapter();
28216
27578
  init_interactive_cli();
28217
- init_manager();
27579
+ init_providers();
28218
27580
  init_env_loader();
28219
27581
  init_version();
28220
27582
  packageJson = { version: getVersion() };