@burtson-labs/bandit-engine 2.0.22 → 2.0.24

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  chat_default
3
- } from "./chunk-ZRTP2N7E.mjs";
3
+ } from "./chunk-IGD4KGB5.mjs";
4
4
  import "./chunk-ONQMRE2G.mjs";
5
5
  import "./chunk-RTQDQ6TC.mjs";
6
6
  import "./chunk-GBANNFRD.mjs";
@@ -12,4 +12,4 @@ import "./chunk-BJTO5JO5.mjs";
12
12
  export {
13
13
  chat_default as default
14
14
  };
15
- //# sourceMappingURL=chat-VOVYLTMX.mjs.map
15
+ //# sourceMappingURL=chat-2LYIZNWZ.mjs.map
@@ -9123,58 +9123,63 @@ var AIProviderInitService = class _AIProviderInitService {
9123
9123
  hasAiProvider: !!settings.aiProvider,
9124
9124
  ollamaUrl: settings.ollamaUrl
9125
9125
  });
9126
- try {
9127
- const savedConfig = await indexedDBService_default.get(
9128
- "banditConfig",
9129
- 1,
9130
- "config",
9131
- "aiProvider",
9132
- [{ name: "config", keyPath: "id" }]
9133
- );
9134
- if (savedConfig) {
9135
- debugLogger.info("AI Provider Init: Found saved config in IndexedDB", { type: savedConfig.type });
9136
- const { id: _id, ...configWithoutId } = savedConfig;
9137
- providerConfig = { ...configWithoutId };
9138
- if ((providerConfig.type === "ollama" /* OLLAMA */ || providerConfig.type === "gateway" /* GATEWAY */) && !providerConfig.tokenFactory) {
9139
- providerConfig.tokenFactory = () => {
9140
- let token = authenticationService.getToken();
9141
- if (!token) {
9142
- token = localStorage.getItem("authToken");
9143
- }
9144
- if (!token) {
9126
+ const isPlaygroundEnvironment = settings.playgroundMode === true || settings.aiProvider?.type === "playground" /* PLAYGROUND */ || (settings.gatewayApiUrl?.toLowerCase()?.startsWith("playground://") ?? false) || typeof window !== "undefined" && window.location.pathname.includes("/playground");
9127
+ if (isPlaygroundEnvironment) {
9128
+ debugLogger.info("AI Provider Init: Playground environment detected, bypassing saved provider config");
9129
+ } else {
9130
+ try {
9131
+ const savedConfig = await indexedDBService_default.get(
9132
+ "banditConfig",
9133
+ 1,
9134
+ "config",
9135
+ "aiProvider",
9136
+ [{ name: "config", keyPath: "id" }]
9137
+ );
9138
+ if (savedConfig) {
9139
+ debugLogger.info("AI Provider Init: Found saved config in IndexedDB", { type: savedConfig.type });
9140
+ const { id: _id, ...configWithoutId } = savedConfig;
9141
+ providerConfig = { ...configWithoutId };
9142
+ if ((providerConfig.type === "ollama" /* OLLAMA */ || providerConfig.type === "gateway" /* GATEWAY */) && !providerConfig.tokenFactory) {
9143
+ providerConfig.tokenFactory = () => {
9144
+ let token = authenticationService.getToken();
9145
+ if (!token) {
9146
+ token = localStorage.getItem("authToken");
9147
+ }
9148
+ if (!token) {
9149
+ try {
9150
+ const { useAuthenticationStore: useAuthenticationStore2 } = require("../../store/authenticationStore");
9151
+ const authStore = useAuthenticationStore2.getState();
9152
+ token = authStore.token;
9153
+ } catch (e) {
9154
+ }
9155
+ }
9156
+ debugLogger.info("AI Provider Init: IndexedDB config token factory", {
9157
+ hasToken: !!token
9158
+ });
9159
+ return token;
9160
+ };
9161
+ }
9162
+ try {
9163
+ const { createProvider } = useAIProviderStore.getState();
9164
+ createProvider(providerConfig);
9165
+ const provider = useAIProviderStore.getState().provider;
9166
+ if (provider) {
9145
9167
  try {
9146
- const { useAuthenticationStore: useAuthenticationStore2 } = require("../../store/authenticationStore");
9147
- const authStore = useAuthenticationStore2.getState();
9148
- token = authStore.token;
9149
- } catch (e) {
9168
+ await provider.validateServiceAvailability({ timeoutMs: 5e3 });
9169
+ debugLogger.info(`AI Provider initialized and validated from IndexedDB: ${providerConfig.type}`);
9170
+ } catch (validationError) {
9171
+ debugLogger.warn(`AI Provider created but validation failed`, { error: validationError });
9150
9172
  }
9151
9173
  }
9152
- debugLogger.info("AI Provider Init: IndexedDB config token factory", {
9153
- hasToken: !!token
9154
- });
9155
- return token;
9156
- };
9157
- }
9158
- try {
9159
- const { createProvider } = useAIProviderStore.getState();
9160
- createProvider(providerConfig);
9161
- const provider = useAIProviderStore.getState().provider;
9162
- if (provider) {
9163
- try {
9164
- await provider.validateServiceAvailability({ timeoutMs: 5e3 });
9165
- debugLogger.info(`AI Provider initialized and validated from IndexedDB: ${providerConfig.type}`);
9166
- } catch (validationError) {
9167
- debugLogger.warn(`AI Provider created but validation failed`, { error: validationError });
9168
- }
9174
+ return;
9175
+ } catch (error) {
9176
+ debugLogger.error("Failed to initialize saved provider config, falling back to package settings", { error });
9169
9177
  }
9170
- return;
9171
- } catch (error) {
9172
- debugLogger.error("Failed to initialize saved provider config, falling back to package settings", { error });
9173
9178
  }
9179
+ debugLogger.info("AI Provider Init: No saved config found, using package settings");
9180
+ } catch (error) {
9181
+ debugLogger.warn("AI Provider Init: Failed to load from IndexedDB, using package settings", { error });
9174
9182
  }
9175
- debugLogger.info("AI Provider Init: No saved config found, using package settings");
9176
- } catch (error) {
9177
- debugLogger.warn("AI Provider Init: Failed to load from IndexedDB, using package settings", { error });
9178
9183
  }
9179
9184
  if (settings.aiProvider) {
9180
9185
  providerConfig = { ...settings.aiProvider };