@burtson-labs/bandit-engine 2.0.22 → 2.0.23

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/index.mjs CHANGED
@@ -3,15 +3,15 @@ import {
3
3
  } from "./chunk-ZRTP2N7E.mjs";
4
4
  import {
5
5
  chat_provider_default
6
- } from "./chunk-XVWKFDTD.mjs";
6
+ } from "./chunk-6PQRG6W4.mjs";
7
7
  import "./chunk-ONQMRE2G.mjs";
8
8
  import {
9
9
  management_default,
10
10
  useGatewayHealth,
11
11
  useGatewayMemory,
12
12
  useGatewayModels
13
- } from "./chunk-LB7QYC56.mjs";
14
- import "./chunk-N3G5XPCA.mjs";
13
+ } from "./chunk-JTZL6WJJ.mjs";
14
+ import "./chunk-7RLN6ZGT.mjs";
15
15
  import "./chunk-RTQDQ6TC.mjs";
16
16
  import {
17
17
  defineCustomElement
@@ -37574,58 +37574,63 @@ var AIProviderInitService = class _AIProviderInitService {
37574
37574
  hasAiProvider: !!settings.aiProvider,
37575
37575
  ollamaUrl: settings.ollamaUrl
37576
37576
  });
37577
- try {
37578
- const savedConfig = await indexedDBService_default.get(
37579
- "banditConfig",
37580
- 1,
37581
- "config",
37582
- "aiProvider",
37583
- [{ name: "config", keyPath: "id" }]
37584
- );
37585
- if (savedConfig) {
37586
- debugLogger.info("AI Provider Init: Found saved config in IndexedDB", { type: savedConfig.type });
37587
- const { id: _id, ...configWithoutId } = savedConfig;
37588
- providerConfig = { ...configWithoutId };
37589
- if ((providerConfig.type === "ollama" /* OLLAMA */ || providerConfig.type === "gateway" /* GATEWAY */) && !providerConfig.tokenFactory) {
37590
- providerConfig.tokenFactory = () => {
37591
- let token = authenticationService.getToken();
37592
- if (!token) {
37593
- token = localStorage.getItem("authToken");
37594
- }
37595
- if (!token) {
37577
+ const isPlaygroundEnvironment = settings.playgroundMode === true || settings.aiProvider?.type === "playground" /* PLAYGROUND */ || (settings.gatewayApiUrl?.toLowerCase()?.startsWith("playground://") ?? false) || typeof window !== "undefined" && window.location.pathname.includes("/playground");
37578
+ if (isPlaygroundEnvironment) {
37579
+ debugLogger.info("AI Provider Init: Playground environment detected, bypassing saved provider config");
37580
+ } else {
37581
+ try {
37582
+ const savedConfig = await indexedDBService_default.get(
37583
+ "banditConfig",
37584
+ 1,
37585
+ "config",
37586
+ "aiProvider",
37587
+ [{ name: "config", keyPath: "id" }]
37588
+ );
37589
+ if (savedConfig) {
37590
+ debugLogger.info("AI Provider Init: Found saved config in IndexedDB", { type: savedConfig.type });
37591
+ const { id: _id, ...configWithoutId } = savedConfig;
37592
+ providerConfig = { ...configWithoutId };
37593
+ if ((providerConfig.type === "ollama" /* OLLAMA */ || providerConfig.type === "gateway" /* GATEWAY */) && !providerConfig.tokenFactory) {
37594
+ providerConfig.tokenFactory = () => {
37595
+ let token = authenticationService.getToken();
37596
+ if (!token) {
37597
+ token = localStorage.getItem("authToken");
37598
+ }
37599
+ if (!token) {
37600
+ try {
37601
+ const { useAuthenticationStore: useAuthenticationStore2 } = require("../../store/authenticationStore");
37602
+ const authStore = useAuthenticationStore2.getState();
37603
+ token = authStore.token;
37604
+ } catch (e) {
37605
+ }
37606
+ }
37607
+ debugLogger.info("AI Provider Init: IndexedDB config token factory", {
37608
+ hasToken: !!token
37609
+ });
37610
+ return token;
37611
+ };
37612
+ }
37613
+ try {
37614
+ const { createProvider } = useAIProviderStore.getState();
37615
+ createProvider(providerConfig);
37616
+ const provider = useAIProviderStore.getState().provider;
37617
+ if (provider) {
37596
37618
  try {
37597
- const { useAuthenticationStore: useAuthenticationStore2 } = require("../../store/authenticationStore");
37598
- const authStore = useAuthenticationStore2.getState();
37599
- token = authStore.token;
37600
- } catch (e) {
37619
+ await provider.validateServiceAvailability({ timeoutMs: 5e3 });
37620
+ debugLogger.info(`AI Provider initialized and validated from IndexedDB: ${providerConfig.type}`);
37621
+ } catch (validationError) {
37622
+ debugLogger.warn(`AI Provider created but validation failed`, { error: validationError });
37601
37623
  }
37602
37624
  }
37603
- debugLogger.info("AI Provider Init: IndexedDB config token factory", {
37604
- hasToken: !!token
37605
- });
37606
- return token;
37607
- };
37608
- }
37609
- try {
37610
- const { createProvider } = useAIProviderStore.getState();
37611
- createProvider(providerConfig);
37612
- const provider = useAIProviderStore.getState().provider;
37613
- if (provider) {
37614
- try {
37615
- await provider.validateServiceAvailability({ timeoutMs: 5e3 });
37616
- debugLogger.info(`AI Provider initialized and validated from IndexedDB: ${providerConfig.type}`);
37617
- } catch (validationError) {
37618
- debugLogger.warn(`AI Provider created but validation failed`, { error: validationError });
37619
- }
37625
+ return;
37626
+ } catch (error) {
37627
+ debugLogger.error("Failed to initialize saved provider config, falling back to package settings", { error });
37620
37628
  }
37621
- return;
37622
- } catch (error) {
37623
- debugLogger.error("Failed to initialize saved provider config, falling back to package settings", { error });
37624
37629
  }
37630
+ debugLogger.info("AI Provider Init: No saved config found, using package settings");
37631
+ } catch (error) {
37632
+ debugLogger.warn("AI Provider Init: Failed to load from IndexedDB, using package settings", { error });
37625
37633
  }
37626
- debugLogger.info("AI Provider Init: No saved config found, using package settings");
37627
- } catch (error) {
37628
- debugLogger.warn("AI Provider Init: Failed to load from IndexedDB, using package settings", { error });
37629
37634
  }
37630
37635
  if (settings.aiProvider) {
37631
37636
  providerConfig = { ...settings.aiProvider };