@astermind/cybernetic-chatbot-client 1.0.9 → 2.2.3
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/README.md +240 -0
- package/dist/CyberneticClient.d.ts +59 -1
- package/dist/CyberneticClient.d.ts.map +1 -1
- package/dist/CyberneticLocalRAG.d.ts +24 -1
- package/dist/CyberneticLocalRAG.d.ts.map +1 -1
- package/dist/CyberneticOfflineStorage.d.ts +63 -0
- package/dist/CyberneticOfflineStorage.d.ts.map +1 -0
- package/dist/agentic/CyberneticIntentClassifier.d.ts +40 -0
- package/dist/agentic/CyberneticIntentClassifier.d.ts.map +1 -1
- package/dist/cybernetic-chatbot-client-full.esm.js +2011 -10
- 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 +2011 -11
- package/dist/cybernetic-chatbot-client-full.umd.js.map +1 -1
- package/dist/cybernetic-chatbot-client.esm.js +2011 -10
- 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 +2011 -11
- package/dist/cybernetic-chatbot-client.umd.js.map +1 -1
- package/dist/full.d.ts +7 -2
- package/dist/full.d.ts.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/omega/OmegaOfflineRAG.d.ts +50 -0
- package/dist/omega/OmegaOfflineRAG.d.ts.map +1 -0
- package/dist/omega/index.d.ts +3 -0
- package/dist/omega/index.d.ts.map +1 -0
- package/dist/omega/types.d.ts +118 -0
- package/dist/omega/types.d.ts.map +1 -0
- package/dist/types.d.ts +177 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -29,9 +29,11 @@ Cybernetic Chatbot Client is the official JavaScript SDK for integrating [AsterM
|
|
|
29
29
|
- [Configuration](#configuration)
|
|
30
30
|
- [Features](#features)
|
|
31
31
|
- [Offline-First Architecture](#offline-first-architecture)
|
|
32
|
+
- [Pre-computed Vector Export (Advanced)](#pre-computed-vector-export-advanced)
|
|
32
33
|
- [Streaming Responses](#streaming-responses)
|
|
33
34
|
- [Session Management](#session-management)
|
|
34
35
|
- [Agentic Capabilities](#agentic-capabilities)
|
|
36
|
+
- [Sitemap Configuration](#sitemap-configuration)
|
|
35
37
|
- [Maintenance Mode Support](#maintenance-mode-support)
|
|
36
38
|
- [Bundle Options](#bundle-options)
|
|
37
39
|
- [API Reference](#api-reference)
|
|
@@ -367,6 +369,12 @@ interface CyberneticConfig {
|
|
|
367
369
|
|
|
368
370
|
/** Agentic capabilities configuration (requires full bundle) */
|
|
369
371
|
agentic?: AgenticConfig;
|
|
372
|
+
|
|
373
|
+
/** Offline vector export configuration (see Pre-computed Vector Export section) */
|
|
374
|
+
offline?: OfflineConfig;
|
|
375
|
+
|
|
376
|
+
/** Sitemap configuration for agentic navigation (see Sitemap Configuration section) */
|
|
377
|
+
sitemap?: SiteMapConfig;
|
|
370
378
|
}
|
|
371
379
|
|
|
372
380
|
type ConnectionStatus = 'online' | 'offline' | 'connecting' | 'error';
|
|
@@ -438,6 +446,134 @@ await client.clearCache();
|
|
|
438
446
|
|
|
439
447
|
**Cache Validation**: The server controls cache retention via `cacheRetentionHours` (default: 168 hours / 7 days). The client respects this setting and marks responses as stale when appropriate.
|
|
440
448
|
|
|
449
|
+
### Pre-computed Vector Export (Advanced)
|
|
450
|
+
|
|
451
|
+
For enhanced offline performance, the client supports loading pre-computed TF-IDF vectors exported from the AsterMind admin panel. This eliminates client-side vector computation and provides faster, more consistent offline search results.
|
|
452
|
+
|
|
453
|
+
#### Exporting Vectors from Admin
|
|
454
|
+
|
|
455
|
+
1. Navigate to your AsterMind admin panel
|
|
456
|
+
2. Go to **Settings > Vector Export** (or **Documents > Export**)
|
|
457
|
+
3. Click **Export Vectors for Offline Use**
|
|
458
|
+
4. Download the JSON export file or note the export URL
|
|
459
|
+
|
|
460
|
+
The export file contains pre-computed TF-IDF vectors, document metadata, and optionally sitemap and category information for agentic navigation.
|
|
461
|
+
|
|
462
|
+
#### Configuring Offline Vectors
|
|
463
|
+
|
|
464
|
+
```typescript
|
|
465
|
+
import { CyberneticClient } from '@astermind/cybernetic-chatbot-client';
|
|
466
|
+
|
|
467
|
+
const client = new CyberneticClient({
|
|
468
|
+
apiUrl: 'https://api.astermind.ai',
|
|
469
|
+
apiKey: 'am_your_api_key',
|
|
470
|
+
|
|
471
|
+
// Offline vector configuration
|
|
472
|
+
offline: {
|
|
473
|
+
enabled: true,
|
|
474
|
+
vectorFileUrl: 'https://your-cdn.com/vectors/export.json', // URL to exported vectors
|
|
475
|
+
storageMode: 'indexeddb', // 'memory' | 'indexeddb' | 'hybrid'
|
|
476
|
+
maxCacheAge: 604800000, // 7 days in milliseconds
|
|
477
|
+
autoRefresh: true, // Auto-refresh when new export available
|
|
478
|
+
|
|
479
|
+
// Optional: Omega advanced RAG (requires @astermind/astermind-community)
|
|
480
|
+
omega: {
|
|
481
|
+
enabled: true,
|
|
482
|
+
modelUrl: 'https://your-cdn.com/models/omega-model.json'
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
#### Inline Vector Data
|
|
489
|
+
|
|
490
|
+
You can also provide vector data directly in the configuration:
|
|
491
|
+
|
|
492
|
+
```typescript
|
|
493
|
+
const client = new CyberneticClient({
|
|
494
|
+
apiUrl: 'https://api.astermind.ai',
|
|
495
|
+
apiKey: 'am_your_api_key',
|
|
496
|
+
offline: {
|
|
497
|
+
enabled: true,
|
|
498
|
+
vectorData: exportedVectorObject, // Loaded from file or bundled
|
|
499
|
+
storageMode: 'memory'
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
#### Offline Configuration Options
|
|
505
|
+
|
|
506
|
+
```typescript
|
|
507
|
+
interface OfflineConfig {
|
|
508
|
+
/** Enable offline vector support */
|
|
509
|
+
enabled: boolean;
|
|
510
|
+
|
|
511
|
+
/** URL to fetch vector export JSON */
|
|
512
|
+
vectorFileUrl?: string;
|
|
513
|
+
|
|
514
|
+
/** Inline vector data (alternative to URL) */
|
|
515
|
+
vectorData?: OfflineVectorExport;
|
|
516
|
+
|
|
517
|
+
/** Storage mode for cached vectors */
|
|
518
|
+
storageMode?: 'memory' | 'indexeddb' | 'hybrid';
|
|
519
|
+
|
|
520
|
+
/** Maximum cache age in milliseconds (default: 7 days) */
|
|
521
|
+
maxCacheAge?: number;
|
|
522
|
+
|
|
523
|
+
/** Auto-refresh vectors when new export available */
|
|
524
|
+
autoRefresh?: boolean;
|
|
525
|
+
|
|
526
|
+
/** Omega advanced RAG configuration */
|
|
527
|
+
omega?: {
|
|
528
|
+
enabled: boolean;
|
|
529
|
+
modelUrl?: string;
|
|
530
|
+
modelData?: SerializedModel;
|
|
531
|
+
config?: {
|
|
532
|
+
topK?: number;
|
|
533
|
+
rerankerTopK?: number;
|
|
534
|
+
minScore?: number;
|
|
535
|
+
};
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
#### Checking Offline Status
|
|
541
|
+
|
|
542
|
+
```typescript
|
|
543
|
+
// Get local RAG status
|
|
544
|
+
const ragStatus = client.getLocalRAGStatus();
|
|
545
|
+
console.log(ragStatus);
|
|
546
|
+
// {
|
|
547
|
+
// loaded: true,
|
|
548
|
+
// loadedFromExport: true,
|
|
549
|
+
// documentCount: 150,
|
|
550
|
+
// chunkCount: 1200,
|
|
551
|
+
// exportVersion: '1.0.0',
|
|
552
|
+
// exportedAt: '2024-01-15T10:30:00Z'
|
|
553
|
+
// }
|
|
554
|
+
|
|
555
|
+
// Check if Omega is enabled and ready
|
|
556
|
+
if (client.isOmegaOfflineEnabled()) {
|
|
557
|
+
const modelInfo = client.getOfflineModelInfo();
|
|
558
|
+
console.log('Omega model:', modelInfo);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// Force reload vectors
|
|
562
|
+
await client.reloadOfflineVectors();
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
#### Console Warning
|
|
566
|
+
|
|
567
|
+
When `offline.enabled` is `true` but no vectors are loaded (missing URL, network error, or invalid data), the client logs a one-time console warning:
|
|
568
|
+
|
|
569
|
+
```
|
|
570
|
+
[CyberneticClient] Warning: Offline mode enabled but no vectors loaded.
|
|
571
|
+
Configure 'offline.vectorFileUrl' or provide 'offline.vectorData' for offline support.
|
|
572
|
+
Falling back to standard caching mode.
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
This helps identify configuration issues without disrupting functionality.
|
|
576
|
+
|
|
441
577
|
### Streaming Responses
|
|
442
578
|
|
|
443
579
|
Real-time token streaming via Server-Sent Events (SSE):
|
|
@@ -571,6 +707,110 @@ const intent = classifier.classify('take me to the settings page');
|
|
|
571
707
|
- **Rate Limiting**: Maximum actions per minute (default: 5)
|
|
572
708
|
- **Confirmation Flow**: Optional user approval before action execution
|
|
573
709
|
|
|
710
|
+
### Sitemap Configuration
|
|
711
|
+
|
|
712
|
+
The sitemap enables intelligent navigation by mapping user intent to application routes. You can configure it statically or load it from the vector export:
|
|
713
|
+
|
|
714
|
+
#### Static Sitemap Configuration
|
|
715
|
+
|
|
716
|
+
```typescript
|
|
717
|
+
const client = new CyberneticClient({
|
|
718
|
+
apiUrl: 'https://api.astermind.ai',
|
|
719
|
+
apiKey: 'am_your_api_key',
|
|
720
|
+
|
|
721
|
+
// Static sitemap configuration
|
|
722
|
+
sitemap: {
|
|
723
|
+
enabled: true,
|
|
724
|
+
entries: [
|
|
725
|
+
{
|
|
726
|
+
path: '/dashboard',
|
|
727
|
+
name: 'Dashboard',
|
|
728
|
+
description: 'Main dashboard with analytics',
|
|
729
|
+
aliases: ['home', 'main', 'overview'],
|
|
730
|
+
keywords: ['stats', 'metrics', 'analytics']
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
path: '/settings',
|
|
734
|
+
name: 'Settings',
|
|
735
|
+
description: 'User and application settings',
|
|
736
|
+
aliases: ['preferences', 'config', 'options'],
|
|
737
|
+
keywords: ['account', 'profile', 'configuration']
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
path: '/products',
|
|
741
|
+
name: 'Products',
|
|
742
|
+
description: 'Product catalog and management',
|
|
743
|
+
aliases: ['catalog', 'inventory'],
|
|
744
|
+
keywords: ['items', 'shop', 'store']
|
|
745
|
+
}
|
|
746
|
+
]
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
#### Loading Sitemap from Vector Export
|
|
752
|
+
|
|
753
|
+
When using pre-computed vectors, the sitemap can be included in the export and loaded automatically:
|
|
754
|
+
|
|
755
|
+
```typescript
|
|
756
|
+
const client = new CyberneticClient({
|
|
757
|
+
apiUrl: 'https://api.astermind.ai',
|
|
758
|
+
apiKey: 'am_your_api_key',
|
|
759
|
+
offline: {
|
|
760
|
+
enabled: true,
|
|
761
|
+
vectorFileUrl: 'https://your-cdn.com/vectors/export.json'
|
|
762
|
+
},
|
|
763
|
+
sitemap: {
|
|
764
|
+
enabled: true,
|
|
765
|
+
loadFromExport: true // Load sitemap from vector export
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
#### Sitemap Configuration Options
|
|
771
|
+
|
|
772
|
+
```typescript
|
|
773
|
+
interface SiteMapConfig {
|
|
774
|
+
/** Enable sitemap-based navigation */
|
|
775
|
+
enabled: boolean;
|
|
776
|
+
|
|
777
|
+
/** Static sitemap entries */
|
|
778
|
+
entries?: SiteMapEntry[];
|
|
779
|
+
|
|
780
|
+
/** Load sitemap from vector export (requires offline.enabled) */
|
|
781
|
+
loadFromExport?: boolean;
|
|
782
|
+
|
|
783
|
+
/** URL to fetch sitemap JSON separately */
|
|
784
|
+
sitemapUrl?: string;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
interface SiteMapEntry {
|
|
788
|
+
/** Route path (e.g., '/dashboard') */
|
|
789
|
+
path: string;
|
|
790
|
+
|
|
791
|
+
/** Display name */
|
|
792
|
+
name: string;
|
|
793
|
+
|
|
794
|
+
/** Description for context matching */
|
|
795
|
+
description?: string;
|
|
796
|
+
|
|
797
|
+
/** Alternative names/phrases */
|
|
798
|
+
aliases?: string[];
|
|
799
|
+
|
|
800
|
+
/** Related keywords for matching */
|
|
801
|
+
keywords?: string[];
|
|
802
|
+
|
|
803
|
+
/** Authentication required */
|
|
804
|
+
requiresAuth?: boolean;
|
|
805
|
+
|
|
806
|
+
/** Required user roles */
|
|
807
|
+
roles?: string[];
|
|
808
|
+
|
|
809
|
+
/** Child routes */
|
|
810
|
+
children?: SiteMapEntry[];
|
|
811
|
+
}
|
|
812
|
+
```
|
|
813
|
+
|
|
574
814
|
### Maintenance Mode Support
|
|
575
815
|
|
|
576
816
|
The client handles backend maintenance mode gracefully (per ADR-200):
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { CyberneticOfflineStorage } from './CyberneticOfflineStorage.js';
|
|
1
2
|
import { LicenseManager } from './license/index.js';
|
|
2
|
-
import type { CyberneticConfig, CyberneticResponse, CyberneticError, ConnectionStatus, AskOptions, StreamCallbacks, CacheStatus, SystemSettings, AgenticConfig } from './types.js';
|
|
3
|
+
import type { CyberneticConfig, CyberneticResponse, CyberneticError, ConnectionStatus, AskOptions, StreamCallbacks, CacheStatus, SystemSettings, AgenticConfig, SourcesConfig } from './types.js';
|
|
3
4
|
import type { LicenseState } from './license/types.js';
|
|
4
5
|
/**
|
|
5
6
|
* Interface for agentic capabilities registration
|
|
@@ -29,6 +30,9 @@ export declare class CyberneticClient {
|
|
|
29
30
|
private readonly SETTINGS_CHECK_INTERVAL;
|
|
30
31
|
private agenticCapabilities;
|
|
31
32
|
private licenseManager;
|
|
33
|
+
private offlineStorage;
|
|
34
|
+
private omegaRAG;
|
|
35
|
+
private offlineWarningShown;
|
|
32
36
|
constructor(config: CyberneticConfig);
|
|
33
37
|
/**
|
|
34
38
|
* Register agentic capabilities
|
|
@@ -54,6 +58,19 @@ export declare class CyberneticClient {
|
|
|
54
58
|
* Get agentic configuration
|
|
55
59
|
*/
|
|
56
60
|
getAgenticConfig(): AgenticConfig | null;
|
|
61
|
+
/**
|
|
62
|
+
* Get sources configuration
|
|
63
|
+
* Returns merged configuration with all defaults applied
|
|
64
|
+
*/
|
|
65
|
+
getSourcesConfig(): SourcesConfig;
|
|
66
|
+
/**
|
|
67
|
+
* Check if a specific source feature is available
|
|
68
|
+
* Takes into account configuration, connection status, and requirements
|
|
69
|
+
*
|
|
70
|
+
* @param feature - The feature to check ('summary' or 'download')
|
|
71
|
+
* @returns Whether the feature is available
|
|
72
|
+
*/
|
|
73
|
+
isSourceFeatureAvailable(feature: 'summary' | 'download'): boolean;
|
|
57
74
|
/**
|
|
58
75
|
* Classify user message intent for agentic action
|
|
59
76
|
* Only works if agentic capabilities are registered and enabled
|
|
@@ -116,6 +133,46 @@ export declare class CyberneticClient {
|
|
|
116
133
|
error?: string;
|
|
117
134
|
};
|
|
118
135
|
}>;
|
|
136
|
+
/**
|
|
137
|
+
* Initialize offline vector support
|
|
138
|
+
* Loads pre-exported vectors from URL or inline data
|
|
139
|
+
*/
|
|
140
|
+
private initializeOffline;
|
|
141
|
+
/**
|
|
142
|
+
* Initialize Omega RAG module
|
|
143
|
+
*/
|
|
144
|
+
private initializeOmega;
|
|
145
|
+
/**
|
|
146
|
+
* Manually reload offline vectors
|
|
147
|
+
* Clears cache and re-fetches from configured source
|
|
148
|
+
*/
|
|
149
|
+
reloadOfflineVectors(): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Check if Omega offline RAG is enabled and ready
|
|
152
|
+
*/
|
|
153
|
+
isOmegaOfflineEnabled(): boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Get offline model info (if Omega is loaded)
|
|
156
|
+
*/
|
|
157
|
+
getOfflineModelInfo(): {
|
|
158
|
+
version: string;
|
|
159
|
+
savedAt: string;
|
|
160
|
+
documentCount: number;
|
|
161
|
+
vocabularySize: number;
|
|
162
|
+
} | null;
|
|
163
|
+
/**
|
|
164
|
+
* Get local RAG export status
|
|
165
|
+
*/
|
|
166
|
+
getLocalRAGStatus(): {
|
|
167
|
+
loaded: boolean;
|
|
168
|
+
loadedFromExport: boolean;
|
|
169
|
+
documentCount: number;
|
|
170
|
+
exportVersion?: string;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Get offline storage instance for advanced operations
|
|
174
|
+
*/
|
|
175
|
+
getOfflineStorage(): CyberneticOfflineStorage | null;
|
|
119
176
|
/**
|
|
120
177
|
* Send a message to the chatbot
|
|
121
178
|
* Always returns a response, never throws
|
|
@@ -181,6 +238,7 @@ export declare class CyberneticClient {
|
|
|
181
238
|
private apiWithRetry;
|
|
182
239
|
/**
|
|
183
240
|
* Fallback to local RAG processing
|
|
241
|
+
* Uses Omega RAG if available, falls back to simple TF-IDF
|
|
184
242
|
*/
|
|
185
243
|
private fallbackAsk;
|
|
186
244
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CyberneticClient.d.ts","sourceRoot":"","sources":["../src/CyberneticClient.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EACR,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EAChB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"CyberneticClient.d.ts","sourceRoot":"","sources":["../src/CyberneticClient.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,wBAA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G,IAAI,CAAC;QACtC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;KAChC;IAUD;;OAEG;IACH,iBAAiB,IAAI,cAAc;IAInC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAazC;;;OAGG;IACG,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC;IA8BlD;;OAEG;IACH,iBAAiB,IAAI,OAAO;IAI5B;;OAEG;IACH,qBAAqB,IAAI,MAAM,GAAG,SAAS;IAI3C;;OAEG;IACH,YAAY,IAAI,OAAO;IAevB;;OAEG;YACW,YAAY;IAuC1B;;;OAGG;YACW,WAAW;IAgIzB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAiBzB;;OAEG;IACH,OAAO,CAAC,SAAS;IAOjB;;OAEG;IACH,OAAO,CAAC,cAAc;IA0CtB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAc3B;;OAEG;IACH,OAAO,CAAC,KAAK;CAGhB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CachedDocument } from './types.js';
|
|
1
|
+
import type { CachedDocument, OfflineVectorExport } from './types.js';
|
|
2
2
|
interface LocalRAGResult {
|
|
3
3
|
answer: string;
|
|
4
4
|
sources: Array<{
|
|
@@ -14,10 +14,22 @@ interface LocalRAGResult {
|
|
|
14
14
|
* Provides offline fallback when backend is unavailable.
|
|
15
15
|
* Uses simple TF-IDF for document matching (no vector embeddings).
|
|
16
16
|
*/
|
|
17
|
+
export interface ExportStatus {
|
|
18
|
+
loaded: boolean;
|
|
19
|
+
loadedFromExport: boolean;
|
|
20
|
+
documentCount: number;
|
|
21
|
+
chunkCount: number;
|
|
22
|
+
exportVersion?: string;
|
|
23
|
+
exportedAt?: string;
|
|
24
|
+
}
|
|
17
25
|
export declare class CyberneticLocalRAG {
|
|
18
26
|
private documents;
|
|
19
27
|
private idf;
|
|
20
28
|
private indexed;
|
|
29
|
+
private loadedFromExport;
|
|
30
|
+
private exportVersion?;
|
|
31
|
+
private exportedAt?;
|
|
32
|
+
private vocabulary;
|
|
21
33
|
/**
|
|
22
34
|
* Check if documents are indexed
|
|
23
35
|
*/
|
|
@@ -34,6 +46,17 @@ export declare class CyberneticLocalRAG {
|
|
|
34
46
|
* Reset the index
|
|
35
47
|
*/
|
|
36
48
|
reset(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Load pre-computed vectors from an export file
|
|
51
|
+
* This skips client-side TF-IDF computation by using pre-computed values
|
|
52
|
+
*
|
|
53
|
+
* @param exportData - The offline vector export data
|
|
54
|
+
*/
|
|
55
|
+
loadFromExport(exportData: OfflineVectorExport): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Get export status information
|
|
58
|
+
*/
|
|
59
|
+
getExportStatus(): ExportStatus;
|
|
37
60
|
/**
|
|
38
61
|
* Tokenize text into words
|
|
39
62
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CyberneticLocalRAG.d.ts","sourceRoot":"","sources":["../src/CyberneticLocalRAG.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"CyberneticLocalRAG.d.ts","sourceRoot":"","sources":["../src/CyberneticLocalRAG.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtE,UAAU,cAAc;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,KAAK,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,QAAQ,EAAE,MAAM,CAAC;CACpB;AAUD;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,GAAG,CAAkC;IAC7C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,aAAa,CAAC,CAAS;IAC/B,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,UAAU,CAAkC;IAEpD;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACG,KAAK,CAAC,SAAS,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA4CvD;;OAEG;IACG,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAsDjD;;OAEG;IACH,KAAK,IAAI,IAAI;IAUb;;;;;OAKG;IACG,cAAc,CAAC,UAAU,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IA2CpE;;OAEG;IACH,eAAe,IAAI,YAAY;IAa/B;;OAEG;IACH,OAAO,CAAC,QAAQ;IAQhB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAiB5B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAsBxB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAyB9B;;OAEG;IACH,OAAO,CAAC,UAAU;CAarB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { OfflineVectorExport } from './types.js';
|
|
2
|
+
export interface OfflineStorageMeta {
|
|
3
|
+
version: string;
|
|
4
|
+
exportedAt: string;
|
|
5
|
+
documentCount: number;
|
|
6
|
+
chunkCount: number;
|
|
7
|
+
type: 'general' | 'tenant' | 'combined';
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* IndexedDB storage for offline vector exports
|
|
11
|
+
* Provides persistent caching of pre-computed TF-IDF vectors
|
|
12
|
+
*/
|
|
13
|
+
export declare class CyberneticOfflineStorage {
|
|
14
|
+
private db;
|
|
15
|
+
private dbPromise;
|
|
16
|
+
private readonly dbName;
|
|
17
|
+
private readonly dbVersion;
|
|
18
|
+
/**
|
|
19
|
+
* Initialize IndexedDB for vector storage
|
|
20
|
+
*/
|
|
21
|
+
private initDB;
|
|
22
|
+
/**
|
|
23
|
+
* Store vector export in IndexedDB
|
|
24
|
+
*/
|
|
25
|
+
store(id: string, exportData: OfflineVectorExport): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Retrieve vector export from IndexedDB
|
|
28
|
+
*/
|
|
29
|
+
retrieve(id: string): Promise<OfflineVectorExport | null>;
|
|
30
|
+
/**
|
|
31
|
+
* Check if cached vectors are valid (not expired)
|
|
32
|
+
*/
|
|
33
|
+
isValid(id: string, maxAge: number): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Get cached export metadata without loading full data
|
|
36
|
+
*/
|
|
37
|
+
getMeta(id: string): Promise<OfflineStorageMeta | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Check if any cached vectors exist
|
|
40
|
+
*/
|
|
41
|
+
hasData(): Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* Get all cached export IDs
|
|
44
|
+
*/
|
|
45
|
+
getStoredIds(): Promise<string[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Clear specific cached vectors
|
|
48
|
+
*/
|
|
49
|
+
delete(id: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Clear all cached vectors
|
|
52
|
+
*/
|
|
53
|
+
clear(): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Get the database connection
|
|
56
|
+
*/
|
|
57
|
+
private getDB;
|
|
58
|
+
/**
|
|
59
|
+
* Close database connection
|
|
60
|
+
*/
|
|
61
|
+
close(): void;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=CyberneticOfflineStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CyberneticOfflineStorage.d.ts","sourceRoot":"","sources":["../src/CyberneticOfflineStorage.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAetD,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;CAC3C;AAED;;;GAGG;AACH,qBAAa,wBAAwB;IACjC,OAAO,CAAC,EAAE,CAA+C;IACzD,OAAO,CAAC,SAAS,CAAwD;IACzE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgC;IACvD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAK;IAE/B;;OAEG;YACW,MAAM;IAqBpB;;OAEG;IACG,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAYvE;;OAEG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAM/D;;OAEG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAS3D;;OAEG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAc7D;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAMjC;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAKvC;;OAEG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAM5B;;OAEG;YACW,KAAK;IAOnB;;OAEG;IACH,KAAK,IAAI,IAAI;CAOhB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IntentClassification, AgentConfig } from './types.js';
|
|
2
|
+
import type { OfflineVectorExport, SiteMapConfig, CategoryDefinition } from '../types.js';
|
|
2
3
|
/**
|
|
3
4
|
* Intent classifier for agentic actions
|
|
4
5
|
*
|
|
@@ -10,6 +11,8 @@ export declare class CyberneticIntentClassifier {
|
|
|
10
11
|
private siteMapIndex;
|
|
11
12
|
private formIndex;
|
|
12
13
|
private modalIndex;
|
|
14
|
+
private categories;
|
|
15
|
+
private topicKeywords;
|
|
13
16
|
constructor(config: AgentConfig);
|
|
14
17
|
/**
|
|
15
18
|
* Build search indexes from configuration
|
|
@@ -74,5 +77,42 @@ export declare class CyberneticIntentClassifier {
|
|
|
74
77
|
* Get configuration
|
|
75
78
|
*/
|
|
76
79
|
getConfig(): AgentConfig;
|
|
80
|
+
/**
|
|
81
|
+
* Train classifier from exported documents
|
|
82
|
+
* Extracts topics and keywords for better intent classification
|
|
83
|
+
*
|
|
84
|
+
* @param exportData - The offline vector export data
|
|
85
|
+
*/
|
|
86
|
+
trainFromExport(exportData: OfflineVectorExport): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Load sitemap from configuration
|
|
89
|
+
*
|
|
90
|
+
* @param config - Sitemap configuration with URL or inline data
|
|
91
|
+
*/
|
|
92
|
+
loadSitemap(config: SiteMapConfig): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Load sitemap entries into the index
|
|
95
|
+
*/
|
|
96
|
+
private loadSitemapEntries;
|
|
97
|
+
/**
|
|
98
|
+
* Extract topics and keywords from document content
|
|
99
|
+
*/
|
|
100
|
+
private extractTopicsFromDocuments;
|
|
101
|
+
/**
|
|
102
|
+
* Check if word is a stop word
|
|
103
|
+
*/
|
|
104
|
+
private isStopWord;
|
|
105
|
+
/**
|
|
106
|
+
* Get loaded categories
|
|
107
|
+
*/
|
|
108
|
+
getCategories(): CategoryDefinition[];
|
|
109
|
+
/**
|
|
110
|
+
* Get topic keywords
|
|
111
|
+
*/
|
|
112
|
+
getTopicKeywords(): Map<string, string[]>;
|
|
113
|
+
/**
|
|
114
|
+
* Check if classifier has been trained
|
|
115
|
+
*/
|
|
116
|
+
isTrained(): boolean;
|
|
77
117
|
}
|
|
78
118
|
//# sourceMappingURL=CyberneticIntentClassifier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CyberneticIntentClassifier.d.ts","sourceRoot":"","sources":["../../src/agentic/CyberneticIntentClassifier.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,oBAAoB,EAIpB,WAAW,EACd,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"CyberneticIntentClassifier.d.ts","sourceRoot":"","sources":["../../src/agentic/CyberneticIntentClassifier.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,oBAAoB,EAIpB,WAAW,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACR,mBAAmB,EACnB,aAAa,EAEb,kBAAkB,EACrB,MAAM,aAAa,CAAC;AAoCrB;;;;;GAKG;AACH,qBAAa,0BAA0B;IACnC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,SAAS,CAA+B;IAChD,OAAO,CAAC,UAAU,CAAkC;IACpD,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,aAAa,CAAoC;gBAE7C,MAAM,EAAE,WAAW;IAU/B;;OAEG;IACH,OAAO,CAAC,YAAY;IA6CpB;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB;IA6C/C;;OAEG;IACH,OAAO,CAAC,WAAW;IAwLnB;;OAEG;IACH,OAAO,CAAC,aAAa;IAUrB;;O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