@burtson-labs/bandit-engine 2.0.35 → 2.0.37

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.
Files changed (43) hide show
  1. package/README.md +6 -5
  2. package/dist/{aiProviderStore-3YS2BZU3.mjs → aiProviderStore-UJRDUYOF.mjs} +2 -2
  3. package/dist/{chat-2LYIZNWZ.mjs → chat-SZK3EBDO.mjs} +5 -5
  4. package/dist/chat-provider.js +227 -11
  5. package/dist/chat-provider.js.map +1 -1
  6. package/dist/chat-provider.mjs +4 -4
  7. package/dist/{chunk-6PQRG6W4.mjs → chunk-2ZZA2IFL.mjs} +3 -3
  8. package/dist/{chunk-GBANNFRD.mjs → chunk-ED5NNDKO.mjs} +3 -3
  9. package/dist/{chunk-XD5VJCFN.mjs → chunk-FJO5ZWYU.mjs} +3 -3
  10. package/dist/{chunk-XXMCI2WK.mjs → chunk-G4OXOTNJ.mjs} +41 -8
  11. package/dist/{chunk-XXMCI2WK.mjs.map → chunk-G4OXOTNJ.mjs.map} +1 -1
  12. package/dist/{chunk-LG2JCTOE.mjs → chunk-PLNFTIGX.mjs} +4 -4
  13. package/dist/{chunk-7RLN6ZGT.mjs → chunk-S635Q6OQ.mjs} +3 -3
  14. package/dist/{chunk-IGD4KGB5.mjs → chunk-ZAVV2AT5.mjs} +4 -4
  15. package/dist/{chunk-IHJPVIGB.mjs → chunk-ZNNOTDRD.mjs} +208 -1
  16. package/dist/chunk-ZNNOTDRD.mjs.map +1 -0
  17. package/dist/cli/cli.js +1104 -68
  18. package/dist/cli/cli.js.map +1 -1
  19. package/dist/{gateway-BiHRHJMM.d.ts → gateway-Ckf_KusF.d.mts} +4 -4
  20. package/dist/{gateway-BiHRHJMM.d.mts → gateway-Ckf_KusF.d.ts} +4 -4
  21. package/dist/index.d.mts +2 -2
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.js +318 -69
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +8 -8
  26. package/dist/management/management.js +316 -67
  27. package/dist/management/management.js.map +1 -1
  28. package/dist/management/management.mjs +6 -6
  29. package/dist/modals/chat-modal/chat-modal.js +236 -20
  30. package/dist/modals/chat-modal/chat-modal.js.map +1 -1
  31. package/dist/modals/chat-modal/chat-modal.mjs +4 -4
  32. package/dist/public-types.d.mts +1 -1
  33. package/dist/public-types.d.ts +1 -1
  34. package/package.json +1 -1
  35. package/dist/chunk-IHJPVIGB.mjs.map +0 -1
  36. /package/dist/{aiProviderStore-3YS2BZU3.mjs.map → aiProviderStore-UJRDUYOF.mjs.map} +0 -0
  37. /package/dist/{chat-2LYIZNWZ.mjs.map → chat-SZK3EBDO.mjs.map} +0 -0
  38. /package/dist/{chunk-6PQRG6W4.mjs.map → chunk-2ZZA2IFL.mjs.map} +0 -0
  39. /package/dist/{chunk-GBANNFRD.mjs.map → chunk-ED5NNDKO.mjs.map} +0 -0
  40. /package/dist/{chunk-XD5VJCFN.mjs.map → chunk-FJO5ZWYU.mjs.map} +0 -0
  41. /package/dist/{chunk-LG2JCTOE.mjs.map → chunk-PLNFTIGX.mjs.map} +0 -0
  42. /package/dist/{chunk-7RLN6ZGT.mjs.map → chunk-S635Q6OQ.mjs.map} +0 -0
  43. /package/dist/{chunk-IGD4KGB5.mjs.map → chunk-ZAVV2AT5.mjs.map} +0 -0
@@ -12,11 +12,11 @@ var __export = (target, all) => {
12
12
  for (var name in all)
13
13
  __defProp(target, name, { get: all[name], enumerable: true });
14
14
  };
15
- var __copyProps = (to, from8, except, desc) => {
16
- if (from8 && typeof from8 === "object" || typeof from8 === "function") {
17
- for (let key of __getOwnPropNames(from8))
15
+ var __copyProps = (to, from9, except, desc) => {
16
+ if (from9 && typeof from9 === "object" || typeof from9 === "function") {
17
+ for (let key of __getOwnPropNames(from9))
18
18
  if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from8[key], enumerable: !(desc = __getOwnPropDesc(from8, key)) || desc.enumerable });
19
+ __defProp(to, key, { get: () => from9[key], enumerable: !(desc = __getOwnPropDesc(from9, key)) || desc.enumerable });
20
20
  }
21
21
  return to;
22
22
  };
@@ -2797,6 +2797,216 @@ var init_playground_provider = __esm({
2797
2797
  }
2798
2798
  });
2799
2799
 
2800
+ // src/services/ai-provider/providers/xai.provider.ts
2801
+ var import_rxjs9, XAIProvider;
2802
+ var init_xai_provider = __esm({
2803
+ "src/services/ai-provider/providers/xai.provider.ts"() {
2804
+ "use strict";
2805
+ import_rxjs9 = require("rxjs");
2806
+ init_common_types();
2807
+ init_debugLogger();
2808
+ XAIProvider = class {
2809
+ config;
2810
+ baseUrl;
2811
+ constructor(config) {
2812
+ this.config = config;
2813
+ this.baseUrl = config.baseUrl || "https://api.x.ai/v1";
2814
+ }
2815
+ chat(request) {
2816
+ const url = `${this.baseUrl}/chat/completions`;
2817
+ const payload = {
2818
+ model: request.model,
2819
+ messages: request.messages,
2820
+ stream: Boolean(request.stream),
2821
+ temperature: request.temperature,
2822
+ max_tokens: request.maxTokens
2823
+ };
2824
+ if (request.stream) {
2825
+ return this.streamChatRequest(url, payload);
2826
+ } else {
2827
+ return this.nonStreamChatRequest(url, payload);
2828
+ }
2829
+ }
2830
+ generate(request) {
2831
+ const chatRequest = {
2832
+ model: request.model,
2833
+ messages: [{ role: "user", content: request.prompt }],
2834
+ stream: request.stream,
2835
+ options: request.options
2836
+ };
2837
+ return this.chat(chatRequest).pipe(
2838
+ (0, import_rxjs9.map)((response) => ({
2839
+ response: response.message.content,
2840
+ done: response.done
2841
+ }))
2842
+ );
2843
+ }
2844
+ listModels() {
2845
+ const url = `${this.baseUrl}/models`;
2846
+ return (0, import_rxjs9.from)(fetch(url, {
2847
+ headers: this.getHeaders()
2848
+ })).pipe(
2849
+ (0, import_rxjs9.switchMap)((response) => {
2850
+ if (!response.ok) {
2851
+ return (0, import_rxjs9.throwError)(() => new Error(`Failed to list models: ${response.status}`));
2852
+ }
2853
+ return (0, import_rxjs9.from)(response.json());
2854
+ }),
2855
+ (0, import_rxjs9.map)(
2856
+ (data) => data.data.map((model) => ({
2857
+ name: model.id,
2858
+ details: {
2859
+ format: "xai",
2860
+ family: model.object
2861
+ }
2862
+ }))
2863
+ )
2864
+ );
2865
+ }
2866
+ async validateServiceAvailability(args) {
2867
+ try {
2868
+ const controller = new AbortController();
2869
+ const timeoutId = setTimeout(() => controller.abort(), args.timeoutMs);
2870
+ const response = await fetch(`${this.baseUrl}/models`, {
2871
+ headers: this.getHeaders(),
2872
+ signal: controller.signal
2873
+ });
2874
+ clearTimeout(timeoutId);
2875
+ return {
2876
+ url: this.baseUrl,
2877
+ isAvailable: response.ok
2878
+ };
2879
+ } catch (error) {
2880
+ if (args.fallbackUrl) {
2881
+ try {
2882
+ const controller = new AbortController();
2883
+ const timeoutId = setTimeout(() => controller.abort(), args.timeoutMs);
2884
+ const response = await fetch(`${args.fallbackUrl}/models`, {
2885
+ headers: this.getHeaders(),
2886
+ signal: controller.signal
2887
+ });
2888
+ clearTimeout(timeoutId);
2889
+ if (response.ok) {
2890
+ this.baseUrl = args.fallbackUrl;
2891
+ return {
2892
+ url: args.fallbackUrl,
2893
+ isAvailable: true
2894
+ };
2895
+ }
2896
+ } catch (fallbackError) {
2897
+ debugLogger.warn("xAI fallback validation failed", { error: fallbackError });
2898
+ }
2899
+ }
2900
+ return {
2901
+ url: this.baseUrl,
2902
+ isAvailable: false
2903
+ };
2904
+ }
2905
+ }
2906
+ getProviderType() {
2907
+ return "xai" /* XAI */;
2908
+ }
2909
+ getConfig() {
2910
+ return this.config;
2911
+ }
2912
+ streamChatRequest(url, payload) {
2913
+ return new import_rxjs9.Observable((observer) => {
2914
+ const task = fetch(url, {
2915
+ method: "POST",
2916
+ headers: {
2917
+ ...this.getHeaders(),
2918
+ "Content-Type": "application/json"
2919
+ },
2920
+ body: JSON.stringify(payload)
2921
+ });
2922
+ task.then((response) => {
2923
+ if (!response.ok) {
2924
+ observer.error(new Error(`xAI request failed: ${response.status}`));
2925
+ return;
2926
+ }
2927
+ const reader = response.body?.getReader();
2928
+ const decoder = new TextDecoder();
2929
+ let buffer = "";
2930
+ const read = () => {
2931
+ reader?.read().then(({ done, value }) => {
2932
+ if (done) {
2933
+ observer.next({
2934
+ message: { content: "", role: "assistant" },
2935
+ done: true
2936
+ });
2937
+ observer.complete();
2938
+ return;
2939
+ }
2940
+ buffer += decoder.decode(value, { stream: true });
2941
+ const lines = buffer.split("\n");
2942
+ buffer = lines.pop() ?? "";
2943
+ for (const line of lines) {
2944
+ if (line.trim() && line.startsWith("data: ")) {
2945
+ const data = line.slice(6).trim();
2946
+ if (data === "[DONE]") {
2947
+ observer.next({
2948
+ message: { content: "", role: "assistant" },
2949
+ done: true
2950
+ });
2951
+ observer.complete();
2952
+ return;
2953
+ }
2954
+ try {
2955
+ const parsed = JSON.parse(data);
2956
+ const content = parsed.choices?.[0]?.delta?.content ?? "";
2957
+ if (content) {
2958
+ observer.next({
2959
+ message: { content, role: "assistant" },
2960
+ done: false
2961
+ });
2962
+ }
2963
+ } catch (err) {
2964
+ debugLogger.error("Error parsing xAI stream data:", { data, error: err });
2965
+ }
2966
+ }
2967
+ }
2968
+ read();
2969
+ }).catch((err) => observer.error(err));
2970
+ };
2971
+ read();
2972
+ }).catch((err) => observer.error(err));
2973
+ });
2974
+ }
2975
+ nonStreamChatRequest(url, payload) {
2976
+ return (0, import_rxjs9.from)(fetch(url, {
2977
+ method: "POST",
2978
+ headers: {
2979
+ ...this.getHeaders(),
2980
+ "Content-Type": "application/json"
2981
+ },
2982
+ body: JSON.stringify(payload)
2983
+ })).pipe(
2984
+ (0, import_rxjs9.switchMap)((response) => {
2985
+ if (!response.ok) {
2986
+ return (0, import_rxjs9.throwError)(() => new Error(`xAI request failed: ${response.status}`));
2987
+ }
2988
+ return (0, import_rxjs9.from)(response.json());
2989
+ }),
2990
+ (0, import_rxjs9.map)((data) => ({
2991
+ message: {
2992
+ content: data.choices?.[0]?.message?.content ?? "",
2993
+ role: "assistant"
2994
+ },
2995
+ done: true
2996
+ }))
2997
+ );
2998
+ }
2999
+ getHeaders() {
3000
+ const headers = {};
3001
+ if (this.config.apiKey) {
3002
+ headers["Authorization"] = `Bearer ${this.config.apiKey}`;
3003
+ }
3004
+ return headers;
3005
+ }
3006
+ };
3007
+ }
3008
+ });
3009
+
2800
3010
  // src/services/ai-provider/ai-provider.factory.ts
2801
3011
  var AIProviderFactory;
2802
3012
  var init_ai_provider_factory = __esm({
@@ -2809,6 +3019,7 @@ var init_ai_provider_factory = __esm({
2809
3019
  init_anthropic_provider();
2810
3020
  init_gateway_provider();
2811
3021
  init_playground_provider();
3022
+ init_xai_provider();
2812
3023
  AIProviderFactory = class {
2813
3024
  static createProvider(config) {
2814
3025
  switch (config.type) {
@@ -2820,6 +3031,8 @@ var init_ai_provider_factory = __esm({
2820
3031
  return new AzureOpenAIProvider(config);
2821
3032
  case "anthropic" /* ANTHROPIC */:
2822
3033
  return new AnthropicProvider(config);
3034
+ case "xai" /* XAI */:
3035
+ return new XAIProvider(config);
2823
3036
  case "gateway" /* GATEWAY */:
2824
3037
  return new GatewayProvider(config);
2825
3038
  case "playground" /* PLAYGROUND */:
@@ -2834,6 +3047,7 @@ var init_ai_provider_factory = __esm({
2834
3047
  "openai" /* OPENAI */,
2835
3048
  "azure-openai" /* AZURE_OPENAI */,
2836
3049
  "anthropic" /* ANTHROPIC */,
3050
+ "xai" /* XAI */,
2837
3051
  "gateway" /* GATEWAY */,
2838
3052
  "playground" /* PLAYGROUND */
2839
3053
  ];
@@ -2849,6 +3063,8 @@ var init_ai_provider_factory = __esm({
2849
3063
  return !!(config.baseUrl && config.apiKey && config.apiVersion && config.deploymentName);
2850
3064
  case "anthropic" /* ANTHROPIC */:
2851
3065
  return !!config.apiKey;
3066
+ case "xai" /* XAI */:
3067
+ return !!config.apiKey;
2852
3068
  case "gateway" /* GATEWAY */:
2853
3069
  return !!(config.gatewayUrl && config.provider);
2854
3070
  case "playground" /* PLAYGROUND */:
@@ -3222,11 +3438,11 @@ var init_notificationService = __esm({
3222
3438
  });
3223
3439
 
3224
3440
  // src/services/prompts/conversationStarters.ts
3225
- var import_rxjs9, generateConversationStarters;
3441
+ var import_rxjs10, generateConversationStarters;
3226
3442
  var init_conversationStarters = __esm({
3227
3443
  "src/services/prompts/conversationStarters.ts"() {
3228
3444
  "use strict";
3229
- import_rxjs9 = require("rxjs");
3445
+ import_rxjs10 = require("rxjs");
3230
3446
  init_aiProviderStore();
3231
3447
  init_packageSettingsStore();
3232
3448
  init_getStableQuestionPrompt();
@@ -3247,13 +3463,13 @@ var init_conversationStarters = __esm({
3247
3463
  stream: false,
3248
3464
  options: { temperature: 1.5, num_predict: 250 }
3249
3465
  });
3250
- const questions$ = data$.pipe((0, import_rxjs9.map)((d) => {
3466
+ const questions$ = data$.pipe((0, import_rxjs10.map)((d) => {
3251
3467
  const lines = d.response.split("\n").map((line) => line.trim()).filter((line) => {
3252
3468
  return line.length > 10 && !line.toLowerCase().includes("sorry") && !line.toLowerCase().includes("i cannot") && !line.toLowerCase().includes("i can't") && !line.toLowerCase().includes("unable to") && !line.toLowerCase().startsWith("as an ai") && line.includes("?");
3253
3469
  });
3254
3470
  return lines;
3255
3471
  }));
3256
- const starters = await (0, import_rxjs9.lastValueFrom)(questions$);
3472
+ const starters = await (0, import_rxjs10.lastValueFrom)(questions$);
3257
3473
  if (starters.length === 0) {
3258
3474
  debugLogger.warn("No meaningful conversation starters generated");
3259
3475
  return [];
@@ -3269,11 +3485,11 @@ var init_conversationStarters = __esm({
3269
3485
  });
3270
3486
 
3271
3487
  // src/services/prompts/moodDetection.ts
3272
- var import_rxjs10, detectMessageMood;
3488
+ var import_rxjs11, detectMessageMood;
3273
3489
  var init_moodDetection = __esm({
3274
3490
  "src/services/prompts/moodDetection.ts"() {
3275
3491
  "use strict";
3276
- import_rxjs10 = require("rxjs");
3492
+ import_rxjs11 = require("rxjs");
3277
3493
  init_aiProviderStore();
3278
3494
  init_packageSettingsStore();
3279
3495
  init_debugLogger();
@@ -3304,8 +3520,8 @@ Response:`;
3304
3520
  options: { temperature: 0.3, num_predict: 10 }
3305
3521
  });
3306
3522
  const chunks$ = response$.pipe(
3307
- (0, import_rxjs10.map)((chunk) => chunk.response.trim().toLowerCase()),
3308
- (0, import_rxjs10.toArray)()
3523
+ (0, import_rxjs11.map)((chunk) => chunk.response.trim().toLowerCase()),
3524
+ (0, import_rxjs11.toArray)()
3309
3525
  );
3310
3526
  const result = await chunks$.toPromise();
3311
3527
  const finalResult = (result || []).join("").trim();
@@ -3322,11 +3538,11 @@ Response:`;
3322
3538
  });
3323
3539
 
3324
3540
  // src/services/prompts/detectUserInterestAndExcitement.ts
3325
- var import_rxjs11, detectUserInterestAndExcitement;
3541
+ var import_rxjs12, detectUserInterestAndExcitement;
3326
3542
  var init_detectUserInterestAndExcitement = __esm({
3327
3543
  "src/services/prompts/detectUserInterestAndExcitement.ts"() {
3328
3544
  "use strict";
3329
- import_rxjs11 = require("rxjs");
3545
+ import_rxjs12 = require("rxjs");
3330
3546
  init_aiProviderStore();
3331
3547
  init_packageSettingsStore();
3332
3548
  init_debugLogger();
@@ -3373,10 +3589,10 @@ var init_detectUserInterestAndExcitement = __esm({
3373
3589
  options: { temperature: 0.1, num_predict: 5 }
3374
3590
  });
3375
3591
  const chunks$ = response$.pipe(
3376
- (0, import_rxjs11.map)((chunk) => chunk.response.trim().toUpperCase()),
3377
- (0, import_rxjs11.toArray)()
3592
+ (0, import_rxjs12.map)((chunk) => chunk.response.trim().toUpperCase()),
3593
+ (0, import_rxjs12.toArray)()
3378
3594
  );
3379
- const result = await (0, import_rxjs11.lastValueFrom)(chunks$);
3595
+ const result = await (0, import_rxjs12.lastValueFrom)(chunks$);
3380
3596
  const decision = result.join("").trim();
3381
3597
  debugLogger.llmDebug("detectUserInterestAndExcitement result", { decision });
3382
3598
  return decision.includes("YES");
@@ -3389,11 +3605,11 @@ var init_detectUserInterestAndExcitement = __esm({
3389
3605
  });
3390
3606
 
3391
3607
  // src/services/prompts/documentSummarization.ts
3392
- var import_rxjs12, summarizeDocument;
3608
+ var import_rxjs13, summarizeDocument;
3393
3609
  var init_documentSummarization = __esm({
3394
3610
  "src/services/prompts/documentSummarization.ts"() {
3395
3611
  "use strict";
3396
- import_rxjs12 = require("rxjs");
3612
+ import_rxjs13 = require("rxjs");
3397
3613
  init_aiProviderStore();
3398
3614
  init_packageSettingsStore();
3399
3615
  init_debugLogger();
@@ -3421,8 +3637,8 @@ ${content.slice(0, 4e3)}
3421
3637
  stream: false,
3422
3638
  options: { temperature: 0.3, num_predict: 100 }
3423
3639
  });
3424
- const summary$ = data$.pipe((0, import_rxjs12.map)((d) => d.response.trim()));
3425
- const summary = await (0, import_rxjs12.lastValueFrom)(summary$);
3640
+ const summary$ = data$.pipe((0, import_rxjs13.map)((d) => d.response.trim()));
3641
+ const summary = await (0, import_rxjs13.lastValueFrom)(summary$);
3426
3642
  debugLogger.ragDebug("summarizeDocument result", { name, summary });
3427
3643
  return summary || `Document summary for ${name}`;
3428
3644
  } catch (error) {
@@ -3434,11 +3650,11 @@ ${content.slice(0, 4e3)}
3434
3650
  });
3435
3651
 
3436
3652
  // src/services/prompts/documentRelevance.ts
3437
- var import_rxjs13, determineRelevantDocuments;
3653
+ var import_rxjs14, determineRelevantDocuments;
3438
3654
  var init_documentRelevance = __esm({
3439
3655
  "src/services/prompts/documentRelevance.ts"() {
3440
3656
  "use strict";
3441
- import_rxjs13 = require("rxjs");
3657
+ import_rxjs14 = require("rxjs");
3442
3658
  init_aiProviderStore();
3443
3659
  init_packageSettingsStore();
3444
3660
  init_debugLogger();
@@ -3479,10 +3695,10 @@ Response:`;
3479
3695
  options: { temperature: 0.2, num_predict: 50 }
3480
3696
  });
3481
3697
  const chunks$ = response$.pipe(
3482
- (0, import_rxjs13.map)((chunk) => chunk.response.trim()),
3483
- (0, import_rxjs13.toArray)()
3698
+ (0, import_rxjs14.map)((chunk) => chunk.response.trim()),
3699
+ (0, import_rxjs14.toArray)()
3484
3700
  );
3485
- const result = await (0, import_rxjs13.lastValueFrom)(chunks$);
3701
+ const result = await (0, import_rxjs14.lastValueFrom)(chunks$);
3486
3702
  const vetResult = result.join("").trim().toLowerCase();
3487
3703
  debugLogger.ragDebug("determineRelevantDocuments result", { vetResult });
3488
3704
  if (vetResult.includes("none") || !vetResult) {
@@ -10766,11 +10982,11 @@ var init_ttsSanitizer = __esm({
10766
10982
  });
10767
10983
 
10768
10984
  // src/services/tts/tts-client.ts
10769
- var import_rxjs14, getOrAppendAuthHeader;
10985
+ var import_rxjs15, getOrAppendAuthHeader;
10770
10986
  var init_tts_client = __esm({
10771
10987
  "src/services/tts/tts-client.ts"() {
10772
10988
  "use strict";
10773
- import_rxjs14 = require("rxjs");
10989
+ import_rxjs15 = require("rxjs");
10774
10990
  init_authenticationService();
10775
10991
  init_voiceStore();
10776
10992
  init_ttsSanitizer();
@@ -10790,11 +11006,11 @@ var init_tts_client = __esm({
10790
11006
  });
10791
11007
 
10792
11008
  // src/services/tts/streaming-tts.ts
10793
- var import_rxjs15, StreamingTTSClient, getStreamingTTSClient, speakStream, stopTTS;
11009
+ var import_rxjs16, StreamingTTSClient, getStreamingTTSClient, speakStream, stopTTS;
10794
11010
  var init_streaming_tts = __esm({
10795
11011
  "src/services/tts/streaming-tts.ts"() {
10796
11012
  "use strict";
10797
- import_rxjs15 = require("rxjs");
11013
+ import_rxjs16 = require("rxjs");
10798
11014
  init_debugLogger();
10799
11015
  init_packageSettingsStore();
10800
11016
  init_tts_client();
@@ -10806,8 +11022,8 @@ var init_streaming_tts = __esm({
10806
11022
  // Store event handler references for proper cleanup
10807
11023
  audioHandlers = /* @__PURE__ */ new Map();
10808
11024
  // State management
10809
- stateSubject = new import_rxjs15.BehaviorSubject("IDLE" /* IDLE */);
10810
- progressSubject = new import_rxjs15.Subject();
11025
+ stateSubject = new import_rxjs16.BehaviorSubject("IDLE" /* IDLE */);
11026
+ progressSubject = new import_rxjs16.Subject();
10811
11027
  constructor() {
10812
11028
  }
10813
11029
  static getInstance() {
@@ -10838,7 +11054,7 @@ var init_streaming_tts = __esm({
10838
11054
  * Speak text with simple streaming
10839
11055
  */
10840
11056
  speakStream(text, voice, options = {}) {
10841
- return new import_rxjs15.Observable((subscriber) => {
11057
+ return new import_rxjs16.Observable((subscriber) => {
10842
11058
  this.performSimpleStreaming(text, voice, options, subscriber);
10843
11059
  });
10844
11060
  }
@@ -19235,28 +19451,28 @@ var init_create_audio_blob = __esm({
19235
19451
  });
19236
19452
 
19237
19453
  // src/services/stt/sound-recorder.service.ts
19238
- var import_rxjs19, SoundRecorderService;
19454
+ var import_rxjs20, SoundRecorderService;
19239
19455
  var init_sound_recorder_service = __esm({
19240
19456
  "src/services/stt/sound-recorder.service.ts"() {
19241
19457
  "use strict";
19242
- import_rxjs19 = require("rxjs");
19458
+ import_rxjs20 = require("rxjs");
19243
19459
  init_create_audio_blob();
19244
19460
  SoundRecorderService = class {
19245
19461
  _mediaRecorder;
19246
19462
  start() {
19247
- const mediaStream = (0, import_rxjs19.from)(navigator.mediaDevices.getUserMedia({ audio: true }));
19248
- this._mediaRecorder = mediaStream.pipe((0, import_rxjs19.map)((stream) => {
19463
+ const mediaStream = (0, import_rxjs20.from)(navigator.mediaDevices.getUserMedia({ audio: true }));
19464
+ this._mediaRecorder = mediaStream.pipe((0, import_rxjs20.map)((stream) => {
19249
19465
  const rec = new MediaRecorder(stream);
19250
19466
  rec.start();
19251
19467
  return rec;
19252
- }), (0, import_rxjs19.shareReplay)(1));
19468
+ }), (0, import_rxjs20.shareReplay)(1));
19253
19469
  const dataAvailableEvent = this._mediaRecorder.pipe(
19254
- (0, import_rxjs19.switchMap)((recorder) => (0, import_rxjs19.fromEvent)(recorder, "dataavailable"))
19470
+ (0, import_rxjs20.switchMap)((recorder) => (0, import_rxjs20.fromEvent)(recorder, "dataavailable"))
19255
19471
  );
19256
19472
  const blob = dataAvailableEvent.pipe(
19257
- (0, import_rxjs19.first)(),
19258
- (0, import_rxjs19.map)((event) => createAudioBlob(event.data)),
19259
- (0, import_rxjs19.shareReplay)(1)
19473
+ (0, import_rxjs20.first)(),
19474
+ (0, import_rxjs20.map)((event) => createAudioBlob(event.data)),
19475
+ (0, import_rxjs20.shareReplay)(1)
19260
19476
  );
19261
19477
  return blob;
19262
19478
  }
@@ -19264,7 +19480,7 @@ var init_sound_recorder_service = __esm({
19264
19480
  if (!this._mediaRecorder) {
19265
19481
  return;
19266
19482
  }
19267
- this._mediaRecorder.pipe((0, import_rxjs19.first)()).subscribe((recorder) => {
19483
+ this._mediaRecorder.pipe((0, import_rxjs20.first)()).subscribe((recorder) => {
19268
19484
  recorder.stop();
19269
19485
  });
19270
19486
  }
@@ -19384,7 +19600,7 @@ var init_stt_client = __esm({
19384
19600
  });
19385
19601
 
19386
19602
  // src/services/stt/transcriber.tsx
19387
- var import_react38, import_Mic, import_Check6, import_Close7, import_material31, import_rxjs20, import_jsx_runtime31, initialButtonStyles, Transcriber, transcriber_default;
19603
+ var import_react38, import_Mic, import_Check6, import_Close7, import_material31, import_rxjs21, import_jsx_runtime31, initialButtonStyles, Transcriber, transcriber_default;
19388
19604
  var init_transcriber = __esm({
19389
19605
  "src/services/stt/transcriber.tsx"() {
19390
19606
  "use strict";
@@ -19395,7 +19611,7 @@ var init_transcriber = __esm({
19395
19611
  init_sound_recorder_service();
19396
19612
  init_stt_client();
19397
19613
  import_material31 = require("@mui/material");
19398
- import_rxjs20 = require("rxjs");
19614
+ import_rxjs21 = require("rxjs");
19399
19615
  init_debugLogger();
19400
19616
  import_jsx_runtime31 = require("react/jsx-runtime");
19401
19617
  initialButtonStyles = (badgeBackground, fileText, hoverBadgeBackground) => ({
@@ -19414,14 +19630,14 @@ var init_transcriber = __esm({
19414
19630
  const [status, setStatus] = (0, import_react38.useState)("IDLE");
19415
19631
  const recorderRef = (0, import_react38.useRef)(new SoundRecorderService());
19416
19632
  const [iconButtonStyles] = (0, import_react38.useState)(() => initialButtonStyles(badgeBackground, fileText, hoverBadgeBackground));
19417
- const [recordingSub, setRecordingSub] = (0, import_react38.useState)(() => new import_rxjs20.Subscription());
19633
+ const [recordingSub, setRecordingSub] = (0, import_react38.useState)(() => new import_rxjs21.Subscription());
19418
19634
  const start = () => {
19419
19635
  recordingSub.unsubscribe();
19420
19636
  const recording = recorderRef.current.start();
19421
19637
  const text = recording.pipe(
19422
- (0, import_rxjs20.switchMap)((blob) => {
19638
+ (0, import_rxjs21.switchMap)((blob) => {
19423
19639
  debugLogger.debug("Processing audio blob for transcription");
19424
- return (0, import_rxjs20.from)(STTClient.transcribe(blob));
19640
+ return (0, import_rxjs21.from)(STTClient.transcribe(blob));
19425
19641
  })
19426
19642
  );
19427
19643
  const sub = text.subscribe({
@@ -20293,11 +20509,11 @@ ${sanitize(
20293
20509
  });
20294
20510
 
20295
20511
  // src/chat/hooks/useMemoryEnhancer.tsx
20296
- var import_rxjs21, MEMORY_LIMIT, MIN_MEMORY_WORDS, MERGE_THRESHOLD, REJECT_ECHO_THRESHOLD, REJECT_DUPLICATE_THRESHOLD, CONTEXTUAL_DIVERGENCE_THRESHOLD, normalizeText, isStructurallyDuplicate, isAboutBandit, hasEngagementValue, isMemoryTooShortOrGeneric, isPersonalText, mergeMemory, isVoiceShifted, sanitizeMemory, sanitizeMemoryText, shouldAcceptMemory, isContextuallyDivergent, useMemoryEnhancer;
20512
+ var import_rxjs22, MEMORY_LIMIT, MIN_MEMORY_WORDS, MERGE_THRESHOLD, REJECT_ECHO_THRESHOLD, REJECT_DUPLICATE_THRESHOLD, CONTEXTUAL_DIVERGENCE_THRESHOLD, normalizeText, isStructurallyDuplicate, isAboutBandit, hasEngagementValue, isMemoryTooShortOrGeneric, isPersonalText, mergeMemory, isVoiceShifted, sanitizeMemory, sanitizeMemoryText, shouldAcceptMemory, isContextuallyDivergent, useMemoryEnhancer;
20297
20513
  var init_useMemoryEnhancer = __esm({
20298
20514
  "src/chat/hooks/useMemoryEnhancer.tsx"() {
20299
20515
  "use strict";
20300
- import_rxjs21 = require("rxjs");
20516
+ import_rxjs22 = require("rxjs");
20301
20517
  init_memoryStore();
20302
20518
  init_aiProviderStore();
20303
20519
  init_packageSettingsStore();
@@ -20689,8 +20905,8 @@ var init_useMemoryEnhancer = __esm({
20689
20905
  stream: false,
20690
20906
  options: { temperature: 0.1, num_predict: 150 }
20691
20907
  });
20692
- const suggestion = await (0, import_rxjs21.lastValueFrom)(
20693
- result$.pipe((0, import_rxjs21.map)((chunk) => chunk.response))
20908
+ const suggestion = await (0, import_rxjs22.lastValueFrom)(
20909
+ result$.pipe((0, import_rxjs22.map)((chunk) => chunk.response))
20694
20910
  );
20695
20911
  debugLogger.memoryDebug(`LLM memory suggestion received (${attempt})`, {
20696
20912
  suggestion: typeof suggestion === "string" ? suggestion.slice(0, 200) : suggestion,
@@ -26283,14 +26499,14 @@ var init_chat_app_bar = __esm({
26283
26499
  });
26284
26500
 
26285
26501
  // src/chat/hooks/useConversationNameGenerator.tsx
26286
- var import_rxjs22, import_operators5, useConversationNameGenerator;
26502
+ var import_rxjs23, import_operators5, useConversationNameGenerator;
26287
26503
  var init_useConversationNameGenerator = __esm({
26288
26504
  "src/chat/hooks/useConversationNameGenerator.tsx"() {
26289
26505
  "use strict";
26290
26506
  init_aiProviderStore();
26291
26507
  init_packageSettingsStore();
26292
26508
  init_debugLogger();
26293
- import_rxjs22 = require("rxjs");
26509
+ import_rxjs23 = require("rxjs");
26294
26510
  import_operators5 = require("rxjs/operators");
26295
26511
  init_conversationStore();
26296
26512
  useConversationNameGenerator = () => {
@@ -26326,7 +26542,7 @@ Respond with just the title and nothing else.
26326
26542
  num_predict: 20
26327
26543
  }
26328
26544
  });
26329
- const title = await (0, import_rxjs22.lastValueFrom)(
26545
+ const title = await (0, import_rxjs23.lastValueFrom)(
26330
26546
  result$.pipe((0, import_operators5.map)((d) => d.response?.trim().replace(/["']/g, "")))
26331
26547
  );
26332
26548
  if (title && title.length > 0) {
@@ -28511,7 +28727,7 @@ init_modelStore();
28511
28727
  init_ai_response_text_field();
28512
28728
  init_memory_modal();
28513
28729
  init_streaming_tts();
28514
- var import_rxjs16 = require("rxjs");
28730
+ var import_rxjs17 = require("rxjs");
28515
28731
  init_debugLogger();
28516
28732
  init_util();
28517
28733
  var import_jsx_runtime10 = require("react/jsx-runtime");
@@ -28540,7 +28756,7 @@ var AIQueriesDrawer = ({ drawerOpen, onClose, onClearComplete, onNavigateToMain
28540
28756
  const [memoryModalOpen, setMemoryModalOpen] = (0, import_react15.useState)(false);
28541
28757
  const [contextMode, setContextMode] = (0, import_react15.useState)("local");
28542
28758
  const [expandedSections, setExpandedSections] = (0, import_react15.useState)(/* @__PURE__ */ new Set(["history", "voice"]));
28543
- const [audioSub, setAudioSub] = (0, import_react15.useState)(new import_rxjs16.Subscription());
28759
+ const [audioSub, setAudioSub] = (0, import_react15.useState)(new import_rxjs17.Subscription());
28544
28760
  const [isContextSwitching, setIsContextSwitching] = (0, import_react15.useState)(false);
28545
28761
  const [isDrawerLoading, setIsDrawerLoading] = (0, import_react15.useState)(false);
28546
28762
  (0, import_react15.useEffect)(() => {
@@ -30203,7 +30419,7 @@ init_debugLogger();
30203
30419
  init_banditTheme();
30204
30420
  init_themeMap();
30205
30421
  init_useTTS();
30206
- var import_rxjs17 = require("rxjs");
30422
+ var import_rxjs18 = require("rxjs");
30207
30423
  var import_jsx_runtime15 = require("react/jsx-runtime");
30208
30424
  var FULL_SCREEN_THRESHOLD = 100;
30209
30425
  var CDN_BASE = "https://cdn.burtson.ai/";
@@ -30270,7 +30486,7 @@ var ChatModal = ({
30270
30486
  const [modalLogo, setModalLogo] = (0, import_react22.useState)("https://cdn.burtson.ai/logos/bandit-ai-logo.png");
30271
30487
  const [modelAnchorEl, setModelAnchorEl] = (0, import_react22.useState)(null);
30272
30488
  const [voiceAnchorEl, setVoiceAnchorEl] = (0, import_react22.useState)(null);
30273
- const [audioSub, setAudioSub] = (0, import_react22.useState)(new import_rxjs17.Subscription());
30489
+ const [audioSub, setAudioSub] = (0, import_react22.useState)(new import_rxjs18.Subscription());
30274
30490
  const [selectedTheme, setSelectedTheme] = (0, import_react22.useState)(null);
30275
30491
  const [themeLoading, setThemeLoading] = (0, import_react22.useState)(true);
30276
30492
  const [autoFullscreenTriggered, setAutoFullscreenTriggered] = (0, import_react22.useState)(false);
@@ -32811,7 +33027,7 @@ init_conversationSyncStore();
32811
33027
 
32812
33028
  // src/hooks/useGatewayQueries.ts
32813
33029
  var import_react25 = require("react");
32814
- var import_rxjs18 = require("rxjs");
33030
+ var import_rxjs19 = require("rxjs");
32815
33031
  var import_react_query = require("@tanstack/react-query");
32816
33032
  init_packageSettingsStore();
32817
33033
  init_gateway_service();
@@ -32842,7 +33058,7 @@ var useGatewayHealth = (options) => {
32842
33058
  if (!service) {
32843
33059
  throw new Error("Gateway service is not configured");
32844
33060
  }
32845
- return (0, import_rxjs18.lastValueFrom)(service.getHealth());
33061
+ return (0, import_rxjs19.lastValueFrom)(service.getHealth());
32846
33062
  },
32847
33063
  enabled
32848
33064
  });
@@ -37915,6 +38131,13 @@ var ProviderTab = () => {
37915
38131
  apiKey: ""
37916
38132
  });
37917
38133
  break;
38134
+ case "xai" /* XAI */:
38135
+ setProviderConfig({
38136
+ ...baseConfig,
38137
+ baseUrl: "https://api.x.ai/v1",
38138
+ apiKey: ""
38139
+ });
38140
+ break;
37918
38141
  case "gateway" /* GATEWAY */:
37919
38142
  setProviderConfig({
37920
38143
  ...baseConfig,
@@ -38047,6 +38270,7 @@ var ProviderTab = () => {
38047
38270
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_material25.MenuItem, { value: "openai", children: "OpenAI" }),
38048
38271
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_material25.MenuItem, { value: "azure-openai", children: "Azure OpenAI" }),
38049
38272
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_material25.MenuItem, { value: "anthropic", children: "Anthropic" }),
38273
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_material25.MenuItem, { value: "xai", children: "xAI" }),
38050
38274
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_material25.MenuItem, { value: "playground", children: "Playground (Mock Demo)" })
38051
38275
  ]
38052
38276
  }
@@ -38079,7 +38303,8 @@ var ProviderTab = () => {
38079
38303
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_material25.MenuItem, { value: "openai", children: "OpenAI" }),
38080
38304
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_material25.MenuItem, { value: "azure-openai", children: "Azure OpenAI" }),
38081
38305
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_material25.MenuItem, { value: "anthropic", children: "Anthropic" }),
38082
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_material25.MenuItem, { value: "ollama", children: "Ollama" })
38306
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_material25.MenuItem, { value: "ollama", children: "Ollama" }),
38307
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_material25.MenuItem, { value: "xai", children: "xAI" })
38083
38308
  ]
38084
38309
  }
38085
38310
  )
@@ -38163,6 +38388,30 @@ var ProviderTab = () => {
38163
38388
  }
38164
38389
  )
38165
38390
  ] }),
38391
+ providerConfig.type === "xai" && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_material25.Box, { children: [
38392
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
38393
+ import_material25.TextField,
38394
+ {
38395
+ label: "API Base URL",
38396
+ value: providerConfig.baseUrl || "",
38397
+ onChange: (e) => setProviderConfig({ ...providerConfig, baseUrl: e.target.value }),
38398
+ fullWidth: true,
38399
+ sx: { mb: 2 },
38400
+ placeholder: "https://api.x.ai/v1"
38401
+ }
38402
+ ),
38403
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
38404
+ import_material25.TextField,
38405
+ {
38406
+ label: "API Key",
38407
+ type: "password",
38408
+ value: providerConfig.apiKey || "",
38409
+ onChange: (e) => setProviderConfig({ ...providerConfig, apiKey: e.target.value }),
38410
+ fullWidth: true,
38411
+ placeholder: "xai-..."
38412
+ }
38413
+ )
38414
+ ] }),
38166
38415
  providerConfig.type === "anthropic" && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_material25.Box, { children: [
38167
38416
  /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
38168
38417
  import_material25.TextField,
@@ -38391,20 +38640,20 @@ var MCPToolsTabV2 = () => {
38391
38640
  }
38392
38641
  }, [isLoaded]);
38393
38642
  const localEnabledMap = (0, import_react34.useMemo)(() => {
38394
- const map20 = /* @__PURE__ */ new Map();
38643
+ const map21 = /* @__PURE__ */ new Map();
38395
38644
  const sortedTools = [...localTools].sort((a, b) => {
38396
38645
  if (a.isBuiltIn && !b.isBuiltIn) return -1;
38397
38646
  if (!a.isBuiltIn && b.isBuiltIn) return 1;
38398
38647
  return a.id.length - b.id.length;
38399
38648
  });
38400
38649
  sortedTools.forEach((t) => {
38401
- map20.set(t.function.name, t.enabled);
38402
- map20.set(t.id, t.enabled);
38650
+ map21.set(t.function.name, t.enabled);
38651
+ map21.set(t.id, t.enabled);
38403
38652
  if (t.name) {
38404
- map20.set(t.name, t.enabled);
38653
+ map21.set(t.name, t.enabled);
38405
38654
  }
38406
38655
  });
38407
- return map20;
38656
+ return map21;
38408
38657
  }, [localTools]);
38409
38658
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_material26.Box, { children: [
38410
38659
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_material26.Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2 }, children: [