@astermind/cybernetic-chatbot-client 2.3.15 → 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
|
@@ -902,7 +902,7 @@
|
|
|
902
902
|
this.loadedFromExport = true;
|
|
903
903
|
this.exportVersion = exportData.version;
|
|
904
904
|
this.exportedAt = exportData.meta.exportedAt;
|
|
905
|
-
|
|
905
|
+
// Debug: loaded ${this.documents.length} documents from export
|
|
906
906
|
}
|
|
907
907
|
/**
|
|
908
908
|
* Get export status information
|
|
@@ -1053,7 +1053,7 @@
|
|
|
1053
1053
|
type: exportData.type,
|
|
1054
1054
|
data: exportData
|
|
1055
1055
|
});
|
|
1056
|
-
|
|
1056
|
+
// Debug: stored chunks
|
|
1057
1057
|
}
|
|
1058
1058
|
/**
|
|
1059
1059
|
* Retrieve vector export from IndexedDB
|
|
@@ -1118,7 +1118,7 @@
|
|
|
1118
1118
|
async clear() {
|
|
1119
1119
|
const db = await this.getDB();
|
|
1120
1120
|
await db.clear('vectors');
|
|
1121
|
-
|
|
1121
|
+
// Debug: cache cleared
|
|
1122
1122
|
}
|
|
1123
1123
|
/**
|
|
1124
1124
|
* Get the database connection
|
|
@@ -1339,7 +1339,7 @@
|
|
|
1339
1339
|
}
|
|
1340
1340
|
const delay = this.reconnectDelay * Math.pow(2, this.reconnectAttempts);
|
|
1341
1341
|
this.reconnectAttempts++;
|
|
1342
|
-
|
|
1342
|
+
// Reconnection is logged only in debug mode (via CyberneticClient)
|
|
1343
1343
|
await new Promise(resolve => setTimeout(resolve, delay));
|
|
1344
1344
|
// Ensure old connection is cleaned up
|
|
1345
1345
|
if (this.ws) {
|
|
@@ -2615,6 +2615,13 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
2615
2615
|
* Always returns a response, never throws exceptions.
|
|
2616
2616
|
*/
|
|
2617
2617
|
class CyberneticClient {
|
|
2618
|
+
/** Debug logger — only outputs when config.debug is true */
|
|
2619
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2620
|
+
log(...args) {
|
|
2621
|
+
if (this.config.debug) {
|
|
2622
|
+
console.log(...args);
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2618
2625
|
constructor(config) {
|
|
2619
2626
|
this.wsTransport = null;
|
|
2620
2627
|
this.status = 'connecting';
|
|
@@ -2664,7 +2671,8 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
2664
2671
|
maxSources: config.sources?.maxSources ?? 5
|
|
2665
2672
|
},
|
|
2666
2673
|
onStatusChange: config.onStatusChange || (() => { }),
|
|
2667
|
-
onError: config.onError || (() => { })
|
|
2674
|
+
onError: config.onError || (() => { }),
|
|
2675
|
+
debug: config.debug ?? false,
|
|
2668
2676
|
};
|
|
2669
2677
|
// Initialize components
|
|
2670
2678
|
this.apiClient = new ApiClient(this.config.apiUrl, this.config.apiKey);
|
|
@@ -2690,7 +2698,7 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
2690
2698
|
// Initialize WebSocket transport if configured and not forced to REST
|
|
2691
2699
|
if (wsUrl && transport !== 'rest' && typeof WebSocket !== 'undefined') {
|
|
2692
2700
|
this.wsTransport = new WebSocketTransport(wsUrl, config.apiKey, config.websocket);
|
|
2693
|
-
|
|
2701
|
+
this.log(`[Cybernetic] WebSocket transport enabled: ${wsUrl}`);
|
|
2694
2702
|
}
|
|
2695
2703
|
// Monitor connection status
|
|
2696
2704
|
this.monitorConnection();
|
|
@@ -2725,7 +2733,6 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
2725
2733
|
*/
|
|
2726
2734
|
registerAgentic(capabilities) {
|
|
2727
2735
|
this.agenticCapabilities = capabilities;
|
|
2728
|
-
console.log('[Cybernetic] Agentic capabilities registered');
|
|
2729
2736
|
}
|
|
2730
2737
|
/**
|
|
2731
2738
|
* Check if agentic capabilities are available and enabled
|
|
@@ -2858,11 +2865,11 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
2858
2865
|
if (this.offlineStorage && storageMode !== 'memory') {
|
|
2859
2866
|
const cacheId = 'default';
|
|
2860
2867
|
if (await this.offlineStorage.isValid(cacheId, maxAge)) {
|
|
2861
|
-
|
|
2868
|
+
this.log('[Cybernetic] Loading vectors from IndexedDB cache');
|
|
2862
2869
|
const cached = await this.offlineStorage.retrieve(cacheId);
|
|
2863
2870
|
if (cached) {
|
|
2864
2871
|
await this.localRAG.loadFromExport(cached);
|
|
2865
|
-
|
|
2872
|
+
this.log('[Cybernetic] Loaded vectors from IndexedDB cache');
|
|
2866
2873
|
return;
|
|
2867
2874
|
}
|
|
2868
2875
|
}
|
|
@@ -2885,7 +2892,7 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
2885
2892
|
if (config.omega?.enabled) {
|
|
2886
2893
|
await this.initializeOmega(config);
|
|
2887
2894
|
}
|
|
2888
|
-
|
|
2895
|
+
this.log('[Cybernetic] Loaded vectors from URL:', config.vectorFileUrl);
|
|
2889
2896
|
return;
|
|
2890
2897
|
}
|
|
2891
2898
|
catch (error) {
|
|
@@ -2899,7 +2906,7 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
2899
2906
|
if (config.omega?.enabled) {
|
|
2900
2907
|
await this.initializeOmega(config);
|
|
2901
2908
|
}
|
|
2902
|
-
|
|
2909
|
+
this.log('[Cybernetic] Loaded inline vector data');
|
|
2903
2910
|
return;
|
|
2904
2911
|
}
|
|
2905
2912
|
// No vectors available - log warning (one-time)
|
|
@@ -2933,7 +2940,7 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
2933
2940
|
// Convert our type to the astermind type
|
|
2934
2941
|
await this.omegaRAG.loadModel(config.omega.modelData);
|
|
2935
2942
|
}
|
|
2936
|
-
|
|
2943
|
+
this.log('[Cybernetic] Omega RAG initialized');
|
|
2937
2944
|
}
|
|
2938
2945
|
catch (error) {
|
|
2939
2946
|
console.warn('[Cybernetic] Failed to initialize Omega RAG:', error);
|
|
@@ -3096,7 +3103,7 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
3096
3103
|
// Check maintenance mode before API call (ADR-200)
|
|
3097
3104
|
const settings = await this.checkSystemStatus();
|
|
3098
3105
|
if (settings.maintenanceMode || settings.forceOfflineClients) {
|
|
3099
|
-
|
|
3106
|
+
this.log('[Cybernetic] Maintenance mode active, using cached data');
|
|
3100
3107
|
// Return maintenance response if no cached data
|
|
3101
3108
|
if (!this.isCacheValid()) {
|
|
3102
3109
|
return {
|
|
@@ -3178,7 +3185,7 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
3178
3185
|
// Check maintenance mode before API call (ADR-200)
|
|
3179
3186
|
const settings = await this.checkSystemStatus();
|
|
3180
3187
|
if (settings.maintenanceMode || settings.forceOfflineClients) {
|
|
3181
|
-
|
|
3188
|
+
this.log('[Cybernetic] Maintenance mode active, falling back to offline');
|
|
3182
3189
|
const response = await this.fallbackAsk(message);
|
|
3183
3190
|
callbacks.onComplete?.(response);
|
|
3184
3191
|
return;
|
|
@@ -3297,7 +3304,6 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
3297
3304
|
if (docs.length > 0) {
|
|
3298
3305
|
await this.cache.store(docs);
|
|
3299
3306
|
await this.localRAG.index(docs);
|
|
3300
|
-
console.log(`[Cybernetic] Cache synced: ${docs.length} documents`);
|
|
3301
3307
|
}
|
|
3302
3308
|
this.setStatus('online');
|
|
3303
3309
|
}
|
|
@@ -3387,6 +3393,28 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
3387
3393
|
};
|
|
3388
3394
|
}
|
|
3389
3395
|
}
|
|
3396
|
+
/**
|
|
3397
|
+
* Fetch widget configuration (including persona) from the backend.
|
|
3398
|
+
* Requires apiKey and apiUrl to be configured.
|
|
3399
|
+
* Returns null on any error (network, auth, server) — callers should
|
|
3400
|
+
* fall back to static config when null is returned.
|
|
3401
|
+
*/
|
|
3402
|
+
async fetchConfig() {
|
|
3403
|
+
try {
|
|
3404
|
+
const response = await fetch(`${this.config.apiUrl}/api/external/config`, {
|
|
3405
|
+
headers: {
|
|
3406
|
+
'X-API-Key': this.config.apiKey,
|
|
3407
|
+
'Accept': 'application/json',
|
|
3408
|
+
},
|
|
3409
|
+
});
|
|
3410
|
+
if (!response.ok)
|
|
3411
|
+
return null;
|
|
3412
|
+
return await response.json();
|
|
3413
|
+
}
|
|
3414
|
+
catch {
|
|
3415
|
+
return null;
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3390
3418
|
/**
|
|
3391
3419
|
* Check if maintenance mode is active
|
|
3392
3420
|
*/
|
|
@@ -3765,7 +3793,7 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
3765
3793
|
const cachedEntries = this.loadFromLocalStorage();
|
|
3766
3794
|
if (cachedEntries) {
|
|
3767
3795
|
this.discoveredEntries = cachedEntries;
|
|
3768
|
-
|
|
3796
|
+
// Debug: [SiteMapDiscovery] Loaded ${cachedEntries.length} entries from cache`);
|
|
3769
3797
|
// Still run discovery in background to refresh cache
|
|
3770
3798
|
this.refreshInBackground();
|
|
3771
3799
|
return;
|
|
@@ -3798,8 +3826,7 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
3798
3826
|
}
|
|
3799
3827
|
// Set up popstate listener for SPA navigation
|
|
3800
3828
|
this.setupPopstateListener();
|
|
3801
|
-
|
|
3802
|
-
console.log(`[SiteMapDiscovery] Initialized with ${total} total entries (${this.staticEntries.length} static, ${this.discoveredEntries.length} discovered, ${this.backendEntries.length} backend)`);
|
|
3829
|
+
// Debug: [SiteMapDiscovery] Initialized with ${this.staticEntries.length + this.discoveredEntries.length + this.backendEntries.length} total entries`);
|
|
3803
3830
|
}
|
|
3804
3831
|
/**
|
|
3805
3832
|
* Wait for DOM to be ready before scanning
|
|
@@ -3998,7 +4025,7 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
3998
4025
|
entries.push(this.enhanceEntry(entry, 'discovery'));
|
|
3999
4026
|
}
|
|
4000
4027
|
}
|
|
4001
|
-
|
|
4028
|
+
// Debug: [SiteMapDiscovery] Discovered ${entries.length} routes from ${framework}`);
|
|
4002
4029
|
}
|
|
4003
4030
|
catch (error) {
|
|
4004
4031
|
console.warn('[SiteMapDiscovery] Framework discovery failed:', error);
|
|
@@ -4212,7 +4239,7 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
4212
4239
|
// Invalid selector - skip
|
|
4213
4240
|
}
|
|
4214
4241
|
}
|
|
4215
|
-
|
|
4242
|
+
// Debug: [SiteMapDiscovery] DOM scan found ${routes.length} routes (limit: ${maxLinks})`);
|
|
4216
4243
|
return routes;
|
|
4217
4244
|
}
|
|
4218
4245
|
// ==================== SOURCE 3: BACKEND API ====================
|
|
@@ -4256,7 +4283,7 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
4256
4283
|
fetchedAt: Date.now(),
|
|
4257
4284
|
expiresAt: Date.now() + ttl
|
|
4258
4285
|
};
|
|
4259
|
-
|
|
4286
|
+
// Debug: [SiteMapDiscovery] Loaded ${entries.length} routes from backend`);
|
|
4260
4287
|
return {
|
|
4261
4288
|
entries,
|
|
4262
4289
|
source: 'backend',
|
|
@@ -4508,10 +4535,6 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
4508
4535
|
// Initialize multi-source sitemap discovery
|
|
4509
4536
|
if (siteMapConfig) {
|
|
4510
4537
|
this.siteMapDiscovery = new SiteMapDiscovery(siteMapConfig, apiUrl, apiKey);
|
|
4511
|
-
// Log zero-config mode activation
|
|
4512
|
-
if (!config.siteMapConfig && config.enabled) {
|
|
4513
|
-
console.log('[CyberneticIntentClassifier] Zero-config mode: auto-discovery enabled');
|
|
4514
|
-
}
|
|
4515
4538
|
}
|
|
4516
4539
|
}
|
|
4517
4540
|
/**
|
|
@@ -5071,7 +5094,7 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
5071
5094
|
if (exportData.sitemap) {
|
|
5072
5095
|
this.loadSitemapEntries(exportData.sitemap);
|
|
5073
5096
|
}
|
|
5074
|
-
|
|
5097
|
+
// Debug: [CyberneticIntentClassifier] Trained with ${this.categories.length} categories, ${this.topicKeywords.size} topics`);
|
|
5075
5098
|
}
|
|
5076
5099
|
/**
|
|
5077
5100
|
* Load sitemap from configuration
|
|
@@ -5131,7 +5154,7 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
5131
5154
|
this.siteMapIndex.set(key, siteMapEntry);
|
|
5132
5155
|
}
|
|
5133
5156
|
}
|
|
5134
|
-
|
|
5157
|
+
// Debug: [CyberneticIntentClassifier] Loaded ${entries.length} sitemap entries`);
|
|
5135
5158
|
}
|
|
5136
5159
|
/**
|
|
5137
5160
|
* Extract topics and keywords from document content
|
|
@@ -5217,13 +5240,13 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
5217
5240
|
*/
|
|
5218
5241
|
async initializeDiscovery() {
|
|
5219
5242
|
if (!this.siteMapDiscovery) {
|
|
5220
|
-
|
|
5243
|
+
// Debug: [CyberneticIntentClassifier] No siteMapConfig provided, skipping discovery');
|
|
5221
5244
|
return;
|
|
5222
5245
|
}
|
|
5223
5246
|
try {
|
|
5224
5247
|
await this.siteMapDiscovery.initialize();
|
|
5225
5248
|
this.rebuildIndexesFromDiscovery();
|
|
5226
|
-
|
|
5249
|
+
// Debug: [CyberneticIntentClassifier] Discovery complete, indexed ${this.siteMapIndex.size} entries`);
|
|
5227
5250
|
}
|
|
5228
5251
|
catch (error) {
|
|
5229
5252
|
console.error('[CyberneticIntentClassifier] Discovery initialization failed:', error);
|
|
@@ -5300,7 +5323,7 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
|
|
|
5300
5323
|
*/
|
|
5301
5324
|
async refreshSiteMap() {
|
|
5302
5325
|
if (!this.siteMapDiscovery) {
|
|
5303
|
-
|
|
5326
|
+
// Debug: [CyberneticIntentClassifier] No siteMapConfig provided, cannot refresh');
|
|
5304
5327
|
return;
|
|
5305
5328
|
}
|
|
5306
5329
|
await this.siteMapDiscovery.refresh();
|