@astermind/cybernetic-chatbot-client 2.3.12 → 2.3.21
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/CyberneticClient.d.ts +9 -0
- package/dist/CyberneticClient.d.ts.map +1 -1
- package/dist/agentic/CyberneticIntentClassifier.d.ts.map +1 -1
- package/dist/agentic/SiteMapDiscovery.d.ts.map +1 -1
- package/dist/cybernetic-chatbot-client-full.esm.js +53 -30
- package/dist/cybernetic-chatbot-client-full.esm.js.map +1 -1
- package/dist/cybernetic-chatbot-client-full.min.js +1 -1
- package/dist/cybernetic-chatbot-client-full.min.js.map +1 -1
- package/dist/cybernetic-chatbot-client-full.umd.js +53 -30
- package/dist/cybernetic-chatbot-client-full.umd.js.map +1 -1
- package/dist/cybernetic-chatbot-client.esm.js +53 -30
- package/dist/cybernetic-chatbot-client.esm.js.map +1 -1
- package/dist/cybernetic-chatbot-client.min.js +1 -1
- package/dist/cybernetic-chatbot-client.min.js.map +1 -1
- package/dist/cybernetic-chatbot-client.umd.js +53 -30
- package/dist/cybernetic-chatbot-client.umd.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/types.d.ts +24 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -900,7 +900,7 @@ class CyberneticLocalRAG {
|
|
|
900
900
|
this.loadedFromExport = true;
|
|
901
901
|
this.exportVersion = exportData.version;
|
|
902
902
|
this.exportedAt = exportData.meta.exportedAt;
|
|
903
|
-
|
|
903
|
+
// Debug: loaded ${this.documents.length} documents from export
|
|
904
904
|
}
|
|
905
905
|
/**
|
|
906
906
|
* Get export status information
|
|
@@ -1051,7 +1051,7 @@ class CyberneticOfflineStorage {
|
|
|
1051
1051
|
type: exportData.type,
|
|
1052
1052
|
data: exportData
|
|
1053
1053
|
});
|
|
1054
|
-
|
|
1054
|
+
// Debug: stored chunks
|
|
1055
1055
|
}
|
|
1056
1056
|
/**
|
|
1057
1057
|
* Retrieve vector export from IndexedDB
|
|
@@ -1116,7 +1116,7 @@ class CyberneticOfflineStorage {
|
|
|
1116
1116
|
async clear() {
|
|
1117
1117
|
const db = await this.getDB();
|
|
1118
1118
|
await db.clear('vectors');
|
|
1119
|
-
|
|
1119
|
+
// Debug: cache cleared
|
|
1120
1120
|
}
|
|
1121
1121
|
/**
|
|
1122
1122
|
* Get the database connection
|
|
@@ -1337,7 +1337,7 @@ class WebSocketTransport {
|
|
|
1337
1337
|
}
|
|
1338
1338
|
const delay = this.reconnectDelay * Math.pow(2, this.reconnectAttempts);
|
|
1339
1339
|
this.reconnectAttempts++;
|
|
1340
|
-
|
|
1340
|
+
// Reconnection is logged only in debug mode (via CyberneticClient)
|
|
1341
1341
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
1342
1342
|
// Ensure old connection is cleaned up
|
|
1343
1343
|
if (this.ws) {
|
|
@@ -2613,6 +2613,13 @@ async function createLicenseManager(config) {
|
|
|
2613
2613
|
* Always returns a response, never throws exceptions.
|
|
2614
2614
|
*/
|
|
2615
2615
|
class CyberneticClient {
|
|
2616
|
+
/** Debug logger — only outputs when config.debug is true */
|
|
2617
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2618
|
+
log(...args) {
|
|
2619
|
+
if (this.config.debug) {
|
|
2620
|
+
console.log(...args);
|
|
2621
|
+
}
|
|
2622
|
+
}
|
|
2616
2623
|
constructor(config) {
|
|
2617
2624
|
this.wsTransport = null;
|
|
2618
2625
|
this.status = 'connecting';
|
|
@@ -2662,7 +2669,8 @@ class CyberneticClient {
|
|
|
2662
2669
|
maxSources: config.sources?.maxSources ?? 5
|
|
2663
2670
|
},
|
|
2664
2671
|
onStatusChange: config.onStatusChange || (() => { }),
|
|
2665
|
-
onError: config.onError || (() => { })
|
|
2672
|
+
onError: config.onError || (() => { }),
|
|
2673
|
+
debug: config.debug ?? false,
|
|
2666
2674
|
};
|
|
2667
2675
|
// Initialize components
|
|
2668
2676
|
this.apiClient = new ApiClient(this.config.apiUrl, this.config.apiKey);
|
|
@@ -2688,7 +2696,7 @@ class CyberneticClient {
|
|
|
2688
2696
|
// Initialize WebSocket transport if configured and not forced to REST
|
|
2689
2697
|
if (wsUrl && transport !== 'rest' && typeof WebSocket !== 'undefined') {
|
|
2690
2698
|
this.wsTransport = new WebSocketTransport(wsUrl, config.apiKey, config.websocket);
|
|
2691
|
-
|
|
2699
|
+
this.log(`[Cybernetic] WebSocket transport enabled: ${wsUrl}`);
|
|
2692
2700
|
}
|
|
2693
2701
|
// Monitor connection status
|
|
2694
2702
|
this.monitorConnection();
|
|
@@ -2723,7 +2731,6 @@ class CyberneticClient {
|
|
|
2723
2731
|
*/
|
|
2724
2732
|
registerAgentic(capabilities) {
|
|
2725
2733
|
this.agenticCapabilities = capabilities;
|
|
2726
|
-
console.log('[Cybernetic] Agentic capabilities registered');
|
|
2727
2734
|
}
|
|
2728
2735
|
/**
|
|
2729
2736
|
* Check if agentic capabilities are available and enabled
|
|
@@ -2856,11 +2863,11 @@ class CyberneticClient {
|
|
|
2856
2863
|
if (this.offlineStorage && storageMode !== 'memory') {
|
|
2857
2864
|
const cacheId = 'default';
|
|
2858
2865
|
if (await this.offlineStorage.isValid(cacheId, maxAge)) {
|
|
2859
|
-
|
|
2866
|
+
this.log('[Cybernetic] Loading vectors from IndexedDB cache');
|
|
2860
2867
|
const cached = await this.offlineStorage.retrieve(cacheId);
|
|
2861
2868
|
if (cached) {
|
|
2862
2869
|
await this.localRAG.loadFromExport(cached);
|
|
2863
|
-
|
|
2870
|
+
this.log('[Cybernetic] Loaded vectors from IndexedDB cache');
|
|
2864
2871
|
return;
|
|
2865
2872
|
}
|
|
2866
2873
|
}
|
|
@@ -2883,7 +2890,7 @@ class CyberneticClient {
|
|
|
2883
2890
|
if (config.omega?.enabled) {
|
|
2884
2891
|
await this.initializeOmega(config);
|
|
2885
2892
|
}
|
|
2886
|
-
|
|
2893
|
+
this.log('[Cybernetic] Loaded vectors from URL:', config.vectorFileUrl);
|
|
2887
2894
|
return;
|
|
2888
2895
|
}
|
|
2889
2896
|
catch (error) {
|
|
@@ -2897,7 +2904,7 @@ class CyberneticClient {
|
|
|
2897
2904
|
if (config.omega?.enabled) {
|
|
2898
2905
|
await this.initializeOmega(config);
|
|
2899
2906
|
}
|
|
2900
|
-
|
|
2907
|
+
this.log('[Cybernetic] Loaded inline vector data');
|
|
2901
2908
|
return;
|
|
2902
2909
|
}
|
|
2903
2910
|
// No vectors available - log warning (one-time)
|
|
@@ -2931,7 +2938,7 @@ class CyberneticClient {
|
|
|
2931
2938
|
// Convert our type to the astermind type
|
|
2932
2939
|
await this.omegaRAG.loadModel(config.omega.modelData);
|
|
2933
2940
|
}
|
|
2934
|
-
|
|
2941
|
+
this.log('[Cybernetic] Omega RAG initialized');
|
|
2935
2942
|
}
|
|
2936
2943
|
catch (error) {
|
|
2937
2944
|
console.warn('[Cybernetic] Failed to initialize Omega RAG:', error);
|
|
@@ -3094,7 +3101,7 @@ class CyberneticClient {
|
|
|
3094
3101
|
// Check maintenance mode before API call (ADR-200)
|
|
3095
3102
|
const settings = await this.checkSystemStatus();
|
|
3096
3103
|
if (settings.maintenanceMode || settings.forceOfflineClients) {
|
|
3097
|
-
|
|
3104
|
+
this.log('[Cybernetic] Maintenance mode active, using cached data');
|
|
3098
3105
|
// Return maintenance response if no cached data
|
|
3099
3106
|
if (!this.isCacheValid()) {
|
|
3100
3107
|
return {
|
|
@@ -3176,7 +3183,7 @@ class CyberneticClient {
|
|
|
3176
3183
|
// Check maintenance mode before API call (ADR-200)
|
|
3177
3184
|
const settings = await this.checkSystemStatus();
|
|
3178
3185
|
if (settings.maintenanceMode || settings.forceOfflineClients) {
|
|
3179
|
-
|
|
3186
|
+
this.log('[Cybernetic] Maintenance mode active, falling back to offline');
|
|
3180
3187
|
const response = await this.fallbackAsk(message);
|
|
3181
3188
|
callbacks.onComplete?.(response);
|
|
3182
3189
|
return;
|
|
@@ -3295,7 +3302,6 @@ class CyberneticClient {
|
|
|
3295
3302
|
if (docs.length > 0) {
|
|
3296
3303
|
await this.cache.store(docs);
|
|
3297
3304
|
await this.localRAG.index(docs);
|
|
3298
|
-
console.log(`[Cybernetic] Cache synced: ${docs.length} documents`);
|
|
3299
3305
|
}
|
|
3300
3306
|
this.setStatus('online');
|
|
3301
3307
|
}
|
|
@@ -3385,6 +3391,28 @@ class CyberneticClient {
|
|
|
3385
3391
|
};
|
|
3386
3392
|
}
|
|
3387
3393
|
}
|
|
3394
|
+
/**
|
|
3395
|
+
* Fetch widget configuration (including persona) from the backend.
|
|
3396
|
+
* Requires apiKey and apiUrl to be configured.
|
|
3397
|
+
* Returns null on any error (network, auth, server) — callers should
|
|
3398
|
+
* fall back to static config when null is returned.
|
|
3399
|
+
*/
|
|
3400
|
+
async fetchConfig() {
|
|
3401
|
+
try {
|
|
3402
|
+
const response = await fetch(`${this.config.apiUrl}/api/external/config`, {
|
|
3403
|
+
headers: {
|
|
3404
|
+
'X-API-Key': this.config.apiKey,
|
|
3405
|
+
'Accept': 'application/json',
|
|
3406
|
+
},
|
|
3407
|
+
});
|
|
3408
|
+
if (!response.ok)
|
|
3409
|
+
return null;
|
|
3410
|
+
return await response.json();
|
|
3411
|
+
}
|
|
3412
|
+
catch {
|
|
3413
|
+
return null;
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3388
3416
|
/**
|
|
3389
3417
|
* Check if maintenance mode is active
|
|
3390
3418
|
*/
|
|
@@ -3763,7 +3791,7 @@ class SiteMapDiscovery {
|
|
|
3763
3791
|
const cachedEntries = this.loadFromLocalStorage();
|
|
3764
3792
|
if (cachedEntries) {
|
|
3765
3793
|
this.discoveredEntries = cachedEntries;
|
|
3766
|
-
|
|
3794
|
+
// Debug: [SiteMapDiscovery] Loaded ${cachedEntries.length} entries from cache`);
|
|
3767
3795
|
// Still run discovery in background to refresh cache
|
|
3768
3796
|
this.refreshInBackground();
|
|
3769
3797
|
return;
|
|
@@ -3796,8 +3824,7 @@ class SiteMapDiscovery {
|
|
|
3796
3824
|
}
|
|
3797
3825
|
// Set up popstate listener for SPA navigation
|
|
3798
3826
|
this.setupPopstateListener();
|
|
3799
|
-
|
|
3800
|
-
console.log(`[SiteMapDiscovery] Initialized with ${total} total entries (${this.staticEntries.length} static, ${this.discoveredEntries.length} discovered, ${this.backendEntries.length} backend)`);
|
|
3827
|
+
// Debug: [SiteMapDiscovery] Initialized with ${this.staticEntries.length + this.discoveredEntries.length + this.backendEntries.length} total entries`);
|
|
3801
3828
|
}
|
|
3802
3829
|
/**
|
|
3803
3830
|
* Wait for DOM to be ready before scanning
|
|
@@ -3996,7 +4023,7 @@ class SiteMapDiscovery {
|
|
|
3996
4023
|
entries.push(this.enhanceEntry(entry, 'discovery'));
|
|
3997
4024
|
}
|
|
3998
4025
|
}
|
|
3999
|
-
|
|
4026
|
+
// Debug: [SiteMapDiscovery] Discovered ${entries.length} routes from ${framework}`);
|
|
4000
4027
|
}
|
|
4001
4028
|
catch (error) {
|
|
4002
4029
|
console.warn('[SiteMapDiscovery] Framework discovery failed:', error);
|
|
@@ -4210,7 +4237,7 @@ class SiteMapDiscovery {
|
|
|
4210
4237
|
// Invalid selector - skip
|
|
4211
4238
|
}
|
|
4212
4239
|
}
|
|
4213
|
-
|
|
4240
|
+
// Debug: [SiteMapDiscovery] DOM scan found ${routes.length} routes (limit: ${maxLinks})`);
|
|
4214
4241
|
return routes;
|
|
4215
4242
|
}
|
|
4216
4243
|
// ==================== SOURCE 3: BACKEND API ====================
|
|
@@ -4254,7 +4281,7 @@ class SiteMapDiscovery {
|
|
|
4254
4281
|
fetchedAt: Date.now(),
|
|
4255
4282
|
expiresAt: Date.now() + ttl
|
|
4256
4283
|
};
|
|
4257
|
-
|
|
4284
|
+
// Debug: [SiteMapDiscovery] Loaded ${entries.length} routes from backend`);
|
|
4258
4285
|
return {
|
|
4259
4286
|
entries,
|
|
4260
4287
|
source: 'backend',
|
|
@@ -4506,10 +4533,6 @@ class CyberneticIntentClassifier {
|
|
|
4506
4533
|
// Initialize multi-source sitemap discovery
|
|
4507
4534
|
if (siteMapConfig) {
|
|
4508
4535
|
this.siteMapDiscovery = new SiteMapDiscovery(siteMapConfig, apiUrl, apiKey);
|
|
4509
|
-
// Log zero-config mode activation
|
|
4510
|
-
if (!config.siteMapConfig && config.enabled) {
|
|
4511
|
-
console.log('[CyberneticIntentClassifier] Zero-config mode: auto-discovery enabled');
|
|
4512
|
-
}
|
|
4513
4536
|
}
|
|
4514
4537
|
}
|
|
4515
4538
|
/**
|
|
@@ -5069,7 +5092,7 @@ class CyberneticIntentClassifier {
|
|
|
5069
5092
|
if (exportData.sitemap) {
|
|
5070
5093
|
this.loadSitemapEntries(exportData.sitemap);
|
|
5071
5094
|
}
|
|
5072
|
-
|
|
5095
|
+
// Debug: [CyberneticIntentClassifier] Trained with ${this.categories.length} categories, ${this.topicKeywords.size} topics`);
|
|
5073
5096
|
}
|
|
5074
5097
|
/**
|
|
5075
5098
|
* Load sitemap from configuration
|
|
@@ -5129,7 +5152,7 @@ class CyberneticIntentClassifier {
|
|
|
5129
5152
|
this.siteMapIndex.set(key, siteMapEntry);
|
|
5130
5153
|
}
|
|
5131
5154
|
}
|
|
5132
|
-
|
|
5155
|
+
// Debug: [CyberneticIntentClassifier] Loaded ${entries.length} sitemap entries`);
|
|
5133
5156
|
}
|
|
5134
5157
|
/**
|
|
5135
5158
|
* Extract topics and keywords from document content
|
|
@@ -5215,13 +5238,13 @@ class CyberneticIntentClassifier {
|
|
|
5215
5238
|
*/
|
|
5216
5239
|
async initializeDiscovery() {
|
|
5217
5240
|
if (!this.siteMapDiscovery) {
|
|
5218
|
-
|
|
5241
|
+
// Debug: [CyberneticIntentClassifier] No siteMapConfig provided, skipping discovery');
|
|
5219
5242
|
return;
|
|
5220
5243
|
}
|
|
5221
5244
|
try {
|
|
5222
5245
|
await this.siteMapDiscovery.initialize();
|
|
5223
5246
|
this.rebuildIndexesFromDiscovery();
|
|
5224
|
-
|
|
5247
|
+
// Debug: [CyberneticIntentClassifier] Discovery complete, indexed ${this.siteMapIndex.size} entries`);
|
|
5225
5248
|
}
|
|
5226
5249
|
catch (error) {
|
|
5227
5250
|
console.error('[CyberneticIntentClassifier] Discovery initialization failed:', error);
|
|
@@ -5298,7 +5321,7 @@ class CyberneticIntentClassifier {
|
|
|
5298
5321
|
*/
|
|
5299
5322
|
async refreshSiteMap() {
|
|
5300
5323
|
if (!this.siteMapDiscovery) {
|
|
5301
|
-
|
|
5324
|
+
// Debug: [CyberneticIntentClassifier] No siteMapConfig provided, cannot refresh');
|
|
5302
5325
|
return;
|
|
5303
5326
|
}
|
|
5304
5327
|
await this.siteMapDiscovery.refresh();
|