@astermind/cybernetic-chatbot-client 1.0.6 → 1.0.15
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 +321 -1
- package/dist/CyberneticClient.d.ts +45 -0
- 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/config.d.ts +38 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/cybernetic-chatbot-client-full.esm.js +2121 -23
- 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 +2121 -24
- package/dist/cybernetic-chatbot-client-full.umd.js.map +1 -1
- package/dist/cybernetic-chatbot-client.esm.js +2130 -23
- 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 +2131 -24
- 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 +7 -2
- 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 +163 -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)
|
|
@@ -241,6 +243,86 @@ For licensing questions, contact support@astermind.ai.
|
|
|
241
243
|
|
|
242
244
|
## Configuration
|
|
243
245
|
|
|
246
|
+
All configuration is done in **your own project**—you never need to modify `node_modules` or the package source code.
|
|
247
|
+
|
|
248
|
+
### Multi-Method Configuration
|
|
249
|
+
|
|
250
|
+
The client supports multiple configuration methods with a priority-based fallback chain. This allows you to use the most appropriate method for your hosting environment.
|
|
251
|
+
|
|
252
|
+
**Priority Order (highest to lowest):**
|
|
253
|
+
|
|
254
|
+
1. **Constructor config** - Direct configuration passed to `CyberneticClient` or `createClient()`
|
|
255
|
+
2. **Environment variables** - `VITE_ASTERMIND_RAG_API_KEY`, `REACT_APP_ASTERMIND_RAG_API_KEY`, etc.
|
|
256
|
+
3. **SSR-injected config** - `window.__ASTERMIND_CONFIG__` (for server-side rendering)
|
|
257
|
+
4. **Global object** - `window.astermindConfig`
|
|
258
|
+
5. **Script data attributes** - `data-astermind-key`, `data-astermind-url`
|
|
259
|
+
|
|
260
|
+
#### Environment Variables
|
|
261
|
+
|
|
262
|
+
For bundled applications (Vite, Create React App, etc.), you can configure the client using environment variables:
|
|
263
|
+
|
|
264
|
+
**Vite:**
|
|
265
|
+
```env
|
|
266
|
+
VITE_ASTERMIND_RAG_API_KEY=am_your_api_key
|
|
267
|
+
VITE_ASTERMIND_RAG_API_SERVER_URL=https://api.astermind.ai
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**Create React App:**
|
|
271
|
+
```env
|
|
272
|
+
REACT_APP_ASTERMIND_RAG_API_KEY=am_your_api_key
|
|
273
|
+
REACT_APP_ASTERMIND_RAG_API_SERVER_URL=https://api.astermind.ai
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Node.js / Server:**
|
|
277
|
+
```env
|
|
278
|
+
ASTERMIND_RAG_API_KEY=am_your_api_key
|
|
279
|
+
ASTERMIND_RAG_API_SERVER_URL=https://api.astermind.ai
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
#### Auto-Loading Configuration
|
|
283
|
+
|
|
284
|
+
Use `loadConfig()` to automatically detect configuration from available sources:
|
|
285
|
+
|
|
286
|
+
```typescript
|
|
287
|
+
import { loadConfig, createClient } from '@astermind/cybernetic-chatbot-client';
|
|
288
|
+
|
|
289
|
+
// Auto-detect configuration (throws if no API key found)
|
|
290
|
+
const config = loadConfig();
|
|
291
|
+
const client = createClient(config);
|
|
292
|
+
|
|
293
|
+
// Or suppress errors and handle missing config gracefully
|
|
294
|
+
const config = loadConfig({ throwOnMissingKey: false });
|
|
295
|
+
if (config) {
|
|
296
|
+
const client = createClient(config);
|
|
297
|
+
} else {
|
|
298
|
+
console.log('Chatbot not configured');
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
#### SSR / Runtime Injection
|
|
303
|
+
|
|
304
|
+
For server-side rendered applications, inject configuration at runtime:
|
|
305
|
+
|
|
306
|
+
```html
|
|
307
|
+
<!-- In your SSR template -->
|
|
308
|
+
<script>
|
|
309
|
+
window.__ASTERMIND_CONFIG__ = {
|
|
310
|
+
apiKey: '<%= process.env.ASTERMIND_RAG_API_KEY %>',
|
|
311
|
+
apiUrl: '<%= process.env.ASTERMIND_RAG_API_SERVER_URL %>'
|
|
312
|
+
};
|
|
313
|
+
</script>
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
#### Configuration Source Debugging
|
|
317
|
+
|
|
318
|
+
The loaded configuration includes a `_source` field for debugging:
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
const config = loadConfig();
|
|
322
|
+
console.log(config._source);
|
|
323
|
+
// 'env' | 'vite' | 'window' | 'data-attr' | 'props'
|
|
324
|
+
```
|
|
325
|
+
|
|
244
326
|
### Full Configuration Interface
|
|
245
327
|
|
|
246
328
|
```typescript
|
|
@@ -287,6 +369,12 @@ interface CyberneticConfig {
|
|
|
287
369
|
|
|
288
370
|
/** Agentic capabilities configuration (requires full bundle) */
|
|
289
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;
|
|
290
378
|
}
|
|
291
379
|
|
|
292
380
|
type ConnectionStatus = 'online' | 'offline' | 'connecting' | 'error';
|
|
@@ -323,7 +411,7 @@ interface AgenticConfig {
|
|
|
323
411
|
|
|
324
412
|
### Offline-First Architecture
|
|
325
413
|
|
|
326
|
-
The client
|
|
414
|
+
The client includes **built-in offline fallback** with IndexedDB caching and TF-IDF local search—no additional setup required. When the server is unreachable, the client automatically serves cached responses:
|
|
327
415
|
|
|
328
416
|
```typescript
|
|
329
417
|
const client = new CyberneticClient({
|
|
@@ -358,6 +446,134 @@ await client.clearCache();
|
|
|
358
446
|
|
|
359
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.
|
|
360
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
|
+
|
|
361
577
|
### Streaming Responses
|
|
362
578
|
|
|
363
579
|
Real-time token streaming via Server-Sent Events (SSE):
|
|
@@ -491,6 +707,110 @@ const intent = classifier.classify('take me to the settings page');
|
|
|
491
707
|
- **Rate Limiting**: Maximum actions per minute (default: 5)
|
|
492
708
|
- **Confirmation Flow**: Optional user approval before action execution
|
|
493
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
|
+
|
|
494
814
|
### Maintenance Mode Support
|
|
495
815
|
|
|
496
816
|
The client handles backend maintenance mode gracefully (per ADR-200):
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CyberneticOfflineStorage } from './CyberneticOfflineStorage.js';
|
|
1
2
|
import { LicenseManager } from './license/index.js';
|
|
2
3
|
import type { CyberneticConfig, CyberneticResponse, CyberneticError, ConnectionStatus, AskOptions, StreamCallbacks, CacheStatus, SystemSettings, AgenticConfig } from './types.js';
|
|
3
4
|
import type { LicenseState } from './license/types.js';
|
|
@@ -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
|
|
@@ -116,6 +120,46 @@ export declare class CyberneticClient {
|
|
|
116
120
|
error?: string;
|
|
117
121
|
};
|
|
118
122
|
}>;
|
|
123
|
+
/**
|
|
124
|
+
* Initialize offline vector support
|
|
125
|
+
* Loads pre-exported vectors from URL or inline data
|
|
126
|
+
*/
|
|
127
|
+
private initializeOffline;
|
|
128
|
+
/**
|
|
129
|
+
* Initialize Omega RAG module
|
|
130
|
+
*/
|
|
131
|
+
private initializeOmega;
|
|
132
|
+
/**
|
|
133
|
+
* Manually reload offline vectors
|
|
134
|
+
* Clears cache and re-fetches from configured source
|
|
135
|
+
*/
|
|
136
|
+
reloadOfflineVectors(): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Check if Omega offline RAG is enabled and ready
|
|
139
|
+
*/
|
|
140
|
+
isOmegaOfflineEnabled(): boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Get offline model info (if Omega is loaded)
|
|
143
|
+
*/
|
|
144
|
+
getOfflineModelInfo(): {
|
|
145
|
+
version: string;
|
|
146
|
+
savedAt: string;
|
|
147
|
+
documentCount: number;
|
|
148
|
+
vocabularySize: number;
|
|
149
|
+
} | null;
|
|
150
|
+
/**
|
|
151
|
+
* Get local RAG export status
|
|
152
|
+
*/
|
|
153
|
+
getLocalRAGStatus(): {
|
|
154
|
+
loaded: boolean;
|
|
155
|
+
loadedFromExport: boolean;
|
|
156
|
+
documentCount: number;
|
|
157
|
+
exportVersion?: string;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Get offline storage instance for advanced operations
|
|
161
|
+
*/
|
|
162
|
+
getOfflineStorage(): CyberneticOfflineStorage | null;
|
|
119
163
|
/**
|
|
120
164
|
* Send a message to the chatbot
|
|
121
165
|
* Always returns a response, never throws
|
|
@@ -181,6 +225,7 @@ export declare class CyberneticClient {
|
|
|
181
225
|
private apiWithRetry;
|
|
182
226
|
/**
|
|
183
227
|
* Fallback to local RAG processing
|
|
228
|
+
* Uses Omega RAG if available, falls back to simple TF-IDF
|
|
184
229
|
*/
|
|
185
230
|
private fallbackAsk;
|
|
186
231
|
/**
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"CyberneticClient.d.ts","sourceRoot":"","sources":["../src/CyberneticClient.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,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,EAIhB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAChC,iDAAiD;IAEjD,KAAK,EAAE,GAAG,CAAC;IACX,4DAA4D;IAE5D,gBAAgB,CAAC,EAAE,GAAG,CAAC;CAC1B;AA0BD;;;;;GAKG;AACH,qBAAa,gBAAgB;IACzB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAA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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,CA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,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,k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AkB,EAAE;IAIrC;;OAEG;IACH,gBAAgB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAIzC;;OAEG;IACH,SAAS,IAAI,OAAO;CAGvB"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,10 +1,45 @@
|
|
|
1
|
-
import type { CyberneticConfig } from './types.js';
|
|
1
|
+
import type { CyberneticConfig, ConfigOptions } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Validate configuration
|
|
4
4
|
*/
|
|
5
5
|
export declare function validateConfig(config: unknown): config is CyberneticConfig;
|
|
6
6
|
/**
|
|
7
|
-
* Load config from
|
|
7
|
+
* Load config from Node.js process.env (for bundlers that replace process.env)
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
declare function loadFromProcessEnv(): CyberneticConfig | null;
|
|
10
|
+
/**
|
|
11
|
+
* Load config from Vite's import.meta.env (browser environment)
|
|
12
|
+
* Note: This only works at build time when Vite replaces the variables
|
|
13
|
+
*/
|
|
14
|
+
declare function loadFromViteEnv(): CyberneticConfig | null;
|
|
15
|
+
/**
|
|
16
|
+
* Load config from window.astermindConfig global object
|
|
17
|
+
*/
|
|
18
|
+
declare function loadFromGlobalObject(): CyberneticConfig | null;
|
|
19
|
+
/**
|
|
20
|
+
* Load config from script tag data attributes
|
|
21
|
+
*/
|
|
22
|
+
declare function loadFromScriptAttributes(): CyberneticConfig | null;
|
|
23
|
+
/**
|
|
24
|
+
* Load config using priority-based fallback chain:
|
|
25
|
+
* 1. Environment variables (process.env - for bundlers/Node.js)
|
|
26
|
+
* 2. Vite environment variables (import.meta.env or window.__ASTERMIND_CONFIG__)
|
|
27
|
+
* 3. Global object (window.astermindConfig)
|
|
28
|
+
* 4. Script data attributes (data-astermind-key, data-astermind-url)
|
|
29
|
+
*
|
|
30
|
+
* @param options - Configuration options
|
|
31
|
+
* @param options.throwOnMissingKey - If true (default), throws when no API key found. If false, returns null and logs a warning.
|
|
32
|
+
* @returns Configuration object or null if not found and throwOnMissingKey is false
|
|
33
|
+
*/
|
|
34
|
+
export declare function loadConfig(options?: ConfigOptions): CyberneticConfig | null;
|
|
35
|
+
/**
|
|
36
|
+
* Export individual loaders for testing and advanced use cases
|
|
37
|
+
*/
|
|
38
|
+
export declare const configLoaders: {
|
|
39
|
+
loadFromProcessEnv: typeof loadFromProcessEnv;
|
|
40
|
+
loadFromViteEnv: typeof loadFromViteEnv;
|
|
41
|
+
loadFromGlobalObject: typeof loadFromGlobalObject;
|
|
42
|
+
loadFromScriptAttributes: typeof loadFromScriptAttributes;
|
|
43
|
+
};
|
|
44
|
+
export {};
|
|
10
45
|
//# sourceMappingURL=config.d.ts.map
|