@soulcraft/brainy 3.20.2 → 3.20.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/CHANGELOG.md +9 -0
- package/bin/brainy-interactive.js +2 -2
- package/dist/brainy.d.ts +1 -1
- package/dist/mcp/brainyMCPAdapter.d.ts +1 -1
- package/dist/mcp/brainyMCPService.d.ts +1 -1
- package/dist/neural/embeddedPatterns.d.ts +1 -1
- package/dist/neural/embeddedPatterns.js +1 -1
- package/dist/shared/default-augmentations.d.ts +1 -1
- package/dist/types/{brainyDataInterface.js → brainyInterface.js} +1 -1
- package/package.json +1 -1
- package/dist/augmentationFactory.d.ts +0 -86
- package/dist/augmentationFactory.js +0 -342
- package/dist/augmentationRegistry.d.ts +0 -38
- package/dist/augmentationRegistry.js +0 -54
- package/dist/augmentationRegistryLoader.d.ts +0 -146
- package/dist/augmentationRegistryLoader.js +0 -213
- package/dist/augmentations/KnowledgeAugmentation.d.ts +0 -40
- package/dist/augmentations/KnowledgeAugmentation.js +0 -251
- package/dist/augmentations/intelligentVerbScoring.d.ts +0 -158
- package/dist/augmentations/intelligentVerbScoring.js +0 -377
- package/dist/augmentations/marketplace/AugmentationMarketplace.d.ts +0 -168
- package/dist/augmentations/marketplace/AugmentationMarketplace.js +0 -329
- package/dist/augmentations/marketplace/cli.d.ts +0 -47
- package/dist/augmentations/marketplace/cli.js +0 -265
- package/dist/augmentations/memoryAugmentations.d.ts +0 -72
- package/dist/augmentations/memoryAugmentations.js +0 -280
- package/dist/augmentations/serverSearchAugmentations.d.ts +0 -190
- package/dist/augmentations/serverSearchAugmentations.js +0 -586
- package/dist/brainy-unified.d.ts +0 -106
- package/dist/brainy-unified.js +0 -327
- package/dist/brainyData.d.ts +0 -1832
- package/dist/brainyData.js +0 -6443
- package/dist/brainyDataV3.d.ts +0 -186
- package/dist/brainyDataV3.js +0 -337
- package/dist/config/distributedPresets-new.d.ts +0 -118
- package/dist/config/distributedPresets-new.js +0 -318
- package/dist/config/modelPrecisionManager.d.ts +0 -42
- package/dist/config/modelPrecisionManager.js +0 -98
- package/dist/connectors/interfaces/IConnector.d.ts +0 -143
- package/dist/connectors/interfaces/IConnector.js +0 -8
- package/dist/demo.d.ts +0 -106
- package/dist/demo.js +0 -201
- package/dist/embeddings/SingletonModelManager.d.ts +0 -95
- package/dist/embeddings/SingletonModelManager.js +0 -220
- package/dist/embeddings/lightweight-embedder.d.ts +0 -22
- package/dist/embeddings/lightweight-embedder.js +0 -128
- package/dist/embeddings/model-manager.d.ts +0 -39
- package/dist/embeddings/model-manager.js +0 -245
- package/dist/embeddings/universal-memory-manager.d.ts +0 -38
- package/dist/embeddings/universal-memory-manager.js +0 -166
- package/dist/embeddings/worker-embedding.d.ts +0 -7
- package/dist/embeddings/worker-embedding.js +0 -73
- package/dist/embeddings/worker-manager.d.ts +0 -28
- package/dist/embeddings/worker-manager.js +0 -162
- package/dist/examples/basicUsage.d.ts +0 -4
- package/dist/examples/basicUsage.js +0 -121
- package/dist/indices/fieldIndex.d.ts +0 -76
- package/dist/indices/fieldIndex.js +0 -357
- package/dist/mcp/brainyMCPBroadcast.d.ts +0 -82
- package/dist/mcp/brainyMCPBroadcast.js +0 -303
- package/dist/mcp/brainyMCPClient.d.ts +0 -92
- package/dist/mcp/brainyMCPClient.js +0 -258
- package/dist/scripts/precomputePatternEmbeddings.d.ts +0 -19
- package/dist/scripts/precomputePatternEmbeddings.js +0 -100
- package/dist/utils/cacheAutoConfig.d.ts +0 -63
- package/dist/utils/cacheAutoConfig.js +0 -261
- package/dist/utils/hybridModelManager.d.ts +0 -64
- package/dist/utils/hybridModelManager.js +0 -95
- package/dist/utils/statistics.d.ts +0 -28
- package/dist/utils/statistics.js +0 -25
- package/dist/vfs/ConceptSystem.d.ts +0 -203
- package/dist/vfs/ConceptSystem.js +0 -545
- package/dist/vfs/EntityManager.d.ts +0 -75
- package/dist/vfs/EntityManager.js +0 -216
- package/dist/vfs/EventRecorder.d.ts +0 -84
- package/dist/vfs/EventRecorder.js +0 -269
- package/dist/vfs/GitBridge.d.ts +0 -167
- package/dist/vfs/GitBridge.js +0 -537
- package/dist/vfs/KnowledgeAugmentation.d.ts +0 -104
- package/dist/vfs/KnowledgeAugmentation.js +0 -146
- package/dist/vfs/KnowledgeLayer.d.ts +0 -35
- package/dist/vfs/KnowledgeLayer.js +0 -443
- package/dist/vfs/PersistentEntitySystem.d.ts +0 -165
- package/dist/vfs/PersistentEntitySystem.js +0 -503
- package/dist/vfs/SemanticVersioning.d.ts +0 -105
- package/dist/vfs/SemanticVersioning.js +0 -309
- package/dist/vfs/VFSHealthCheck.d.ts +0 -78
- package/dist/vfs/VFSHealthCheck.js +0 -299
- /package/dist/types/{brainyDataInterface.d.ts → brainyInterface.d.ts} +0 -0
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { AugmentationType, IMemoryAugmentation, AugmentationResponse } from '../types/augmentations.js';
|
|
2
|
-
import { StorageAdapter } from '../coreTypes.js';
|
|
3
|
-
/**
|
|
4
|
-
* Base class for memory augmentations that wrap a StorageAdapter
|
|
5
|
-
*/
|
|
6
|
-
declare abstract class BaseMemoryAugmentation implements IMemoryAugmentation {
|
|
7
|
-
readonly name: string;
|
|
8
|
-
readonly description: string;
|
|
9
|
-
enabled: boolean;
|
|
10
|
-
protected storage: StorageAdapter;
|
|
11
|
-
protected isInitialized: boolean;
|
|
12
|
-
constructor(name: string, storage: StorageAdapter);
|
|
13
|
-
initialize(): Promise<void>;
|
|
14
|
-
shutDown(): Promise<void>;
|
|
15
|
-
getStatus(): Promise<'active' | 'inactive' | 'error'>;
|
|
16
|
-
storeData(key: string, data: unknown, options?: Record<string, unknown>): Promise<AugmentationResponse<boolean>>;
|
|
17
|
-
retrieveData(key: string, options?: Record<string, unknown>): Promise<AugmentationResponse<unknown>>;
|
|
18
|
-
updateData(key: string, data: unknown, options?: Record<string, unknown>): Promise<AugmentationResponse<boolean>>;
|
|
19
|
-
deleteData(key: string, options?: Record<string, unknown>): Promise<AugmentationResponse<boolean>>;
|
|
20
|
-
listDataKeys(pattern?: string, options?: Record<string, unknown>): Promise<AugmentationResponse<string[]>>;
|
|
21
|
-
/**
|
|
22
|
-
* Searches for data in the storage using vector similarity.
|
|
23
|
-
* Implements the findNearest functionality by calculating distances client-side.
|
|
24
|
-
* @param query The query vector or data to search for
|
|
25
|
-
* @param k Number of results to return (default: 10)
|
|
26
|
-
* @param options Optional search options
|
|
27
|
-
*/
|
|
28
|
-
search(query: unknown, k?: number, options?: Record<string, unknown>): Promise<AugmentationResponse<Array<{
|
|
29
|
-
id: string;
|
|
30
|
-
score: number;
|
|
31
|
-
data: unknown;
|
|
32
|
-
}>>>;
|
|
33
|
-
protected ensureInitialized(): Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Memory augmentation that uses in-memory storage
|
|
37
|
-
*/
|
|
38
|
-
export declare class MemoryStorageAugmentation extends BaseMemoryAugmentation {
|
|
39
|
-
readonly description = "Memory augmentation that stores data in memory";
|
|
40
|
-
enabled: boolean;
|
|
41
|
-
constructor(name: string);
|
|
42
|
-
getType(): AugmentationType;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Memory augmentation that uses file system storage
|
|
46
|
-
*/
|
|
47
|
-
export declare class FileSystemStorageAugmentation extends BaseMemoryAugmentation {
|
|
48
|
-
readonly description = "Memory augmentation that stores data in the file system";
|
|
49
|
-
enabled: boolean;
|
|
50
|
-
private rootDirectory;
|
|
51
|
-
constructor(name: string, rootDirectory?: string);
|
|
52
|
-
initialize(): Promise<void>;
|
|
53
|
-
getType(): AugmentationType;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Memory augmentation that uses OPFS (Origin Private File System) storage
|
|
57
|
-
*/
|
|
58
|
-
export declare class OPFSStorageAugmentation extends BaseMemoryAugmentation {
|
|
59
|
-
readonly description = "Memory augmentation that stores data in the Origin Private File System";
|
|
60
|
-
enabled: boolean;
|
|
61
|
-
constructor(name: string);
|
|
62
|
-
getType(): AugmentationType;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Factory function to create the appropriate memory augmentation based on the environment
|
|
66
|
-
*/
|
|
67
|
-
export declare function createMemoryAugmentation(name: string, options?: {
|
|
68
|
-
storageType?: 'memory' | 'filesystem' | 'opfs';
|
|
69
|
-
rootDirectory?: string;
|
|
70
|
-
requestPersistentStorage?: boolean;
|
|
71
|
-
}): Promise<IMemoryAugmentation>;
|
|
72
|
-
export {};
|
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
import { AugmentationType } from '../types/augmentations.js';
|
|
2
|
-
import { MemoryStorage, OPFSStorage } from '../storage/storageFactory.js';
|
|
3
|
-
// FileSystemStorage will be dynamically imported when needed to avoid fs imports in browser
|
|
4
|
-
import { cosineDistance } from '../utils/distance.js';
|
|
5
|
-
/**
|
|
6
|
-
* Base class for memory augmentations that wrap a StorageAdapter
|
|
7
|
-
*/
|
|
8
|
-
class BaseMemoryAugmentation {
|
|
9
|
-
constructor(name, storage) {
|
|
10
|
-
this.description = 'Base memory augmentation';
|
|
11
|
-
this.enabled = true;
|
|
12
|
-
this.isInitialized = false;
|
|
13
|
-
this.name = name;
|
|
14
|
-
this.storage = storage;
|
|
15
|
-
}
|
|
16
|
-
async initialize() {
|
|
17
|
-
if (this.isInitialized) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
await this.storage.init();
|
|
22
|
-
this.isInitialized = true;
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
console.error(`Failed to initialize ${this.name}:`, error);
|
|
26
|
-
throw new Error(`Failed to initialize ${this.name}: ${error}`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
async shutDown() {
|
|
30
|
-
this.isInitialized = false;
|
|
31
|
-
}
|
|
32
|
-
async getStatus() {
|
|
33
|
-
return this.isInitialized ? 'active' : 'inactive';
|
|
34
|
-
}
|
|
35
|
-
async storeData(key, data, options) {
|
|
36
|
-
await this.ensureInitialized();
|
|
37
|
-
try {
|
|
38
|
-
await this.storage.saveMetadata(key, data);
|
|
39
|
-
return { success: true, data: true };
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
console.error(`Failed to store data for key ${key}:`, error);
|
|
43
|
-
return {
|
|
44
|
-
success: false,
|
|
45
|
-
data: false,
|
|
46
|
-
error: `Failed to store data: ${error}`
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
async retrieveData(key, options) {
|
|
51
|
-
await this.ensureInitialized();
|
|
52
|
-
try {
|
|
53
|
-
const data = await this.storage.getMetadata(key);
|
|
54
|
-
return {
|
|
55
|
-
success: true,
|
|
56
|
-
data
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
console.error(`Failed to retrieve data for key ${key}:`, error);
|
|
61
|
-
return {
|
|
62
|
-
success: false,
|
|
63
|
-
data: null,
|
|
64
|
-
error: `Failed to retrieve data: ${error}`
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
async updateData(key, data, options) {
|
|
69
|
-
await this.ensureInitialized();
|
|
70
|
-
try {
|
|
71
|
-
await this.storage.saveMetadata(key, data);
|
|
72
|
-
return { success: true, data: true };
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
console.error(`Failed to update data for key ${key}:`, error);
|
|
76
|
-
return {
|
|
77
|
-
success: false,
|
|
78
|
-
data: false,
|
|
79
|
-
error: `Failed to update data: ${error}`
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
async deleteData(key, options) {
|
|
84
|
-
await this.ensureInitialized();
|
|
85
|
-
try {
|
|
86
|
-
// There's no direct deleteMetadata method, so we save null
|
|
87
|
-
await this.storage.saveMetadata(key, null);
|
|
88
|
-
return { success: true, data: true };
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
console.error(`Failed to delete data for key ${key}:`, error);
|
|
92
|
-
return {
|
|
93
|
-
success: false,
|
|
94
|
-
data: false,
|
|
95
|
-
error: `Failed to delete data: ${error}`
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
async listDataKeys(pattern, options) {
|
|
100
|
-
// This is a limitation of the current StorageAdapter interface
|
|
101
|
-
// It doesn't provide a way to list all metadata keys
|
|
102
|
-
// We could implement this in the future by extending the StorageAdapter interface
|
|
103
|
-
return {
|
|
104
|
-
success: false,
|
|
105
|
-
data: [],
|
|
106
|
-
error: 'listDataKeys is not supported by this storage adapter'
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Searches for data in the storage using vector similarity.
|
|
111
|
-
* Implements the findNearest functionality by calculating distances client-side.
|
|
112
|
-
* @param query The query vector or data to search for
|
|
113
|
-
* @param k Number of results to return (default: 10)
|
|
114
|
-
* @param options Optional search options
|
|
115
|
-
*/
|
|
116
|
-
async search(query, k = 10, options) {
|
|
117
|
-
await this.ensureInitialized();
|
|
118
|
-
try {
|
|
119
|
-
// Check if query is a vector
|
|
120
|
-
let queryVector;
|
|
121
|
-
if (Array.isArray(query) && query.every(item => typeof item === 'number')) {
|
|
122
|
-
queryVector = query;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
// If query is not a vector, we can't perform vector search
|
|
126
|
-
return {
|
|
127
|
-
success: false,
|
|
128
|
-
data: [],
|
|
129
|
-
error: 'Query must be a vector (array of numbers) for vector search'
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
// Process nodes in batches to avoid loading everything into memory
|
|
133
|
-
const allResults = [];
|
|
134
|
-
let hasMore = true;
|
|
135
|
-
let cursor;
|
|
136
|
-
while (hasMore) {
|
|
137
|
-
// Get a batch of nodes
|
|
138
|
-
const batchResult = await this.storage.getNouns({
|
|
139
|
-
pagination: { limit: 100, cursor }
|
|
140
|
-
});
|
|
141
|
-
// Process this batch
|
|
142
|
-
for (const noun of batchResult.items) {
|
|
143
|
-
// Skip nodes that don't have a vector
|
|
144
|
-
if (!noun.vector || !Array.isArray(noun.vector)) {
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
// Get metadata for the node
|
|
148
|
-
const metadata = await this.storage.getMetadata(noun.id);
|
|
149
|
-
// Calculate distance between query vector and node vector
|
|
150
|
-
const distance = cosineDistance(queryVector, noun.vector);
|
|
151
|
-
// Convert distance to similarity score (1 - distance for cosine)
|
|
152
|
-
// This way higher scores are better (more similar)
|
|
153
|
-
const score = 1 - distance;
|
|
154
|
-
allResults.push({
|
|
155
|
-
id: noun.id,
|
|
156
|
-
score,
|
|
157
|
-
data: metadata
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
// Update pagination state
|
|
161
|
-
hasMore = batchResult.hasMore;
|
|
162
|
-
cursor = batchResult.nextCursor;
|
|
163
|
-
}
|
|
164
|
-
// Sort results by score (descending) and take top k
|
|
165
|
-
allResults.sort((a, b) => b.score - a.score);
|
|
166
|
-
const topResults = allResults.slice(0, k);
|
|
167
|
-
return {
|
|
168
|
-
success: true,
|
|
169
|
-
data: topResults
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
catch (error) {
|
|
173
|
-
console.error(`Failed to search in storage:`, error);
|
|
174
|
-
return {
|
|
175
|
-
success: false,
|
|
176
|
-
data: [],
|
|
177
|
-
error: `Failed to search in storage: ${error}`
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
async ensureInitialized() {
|
|
182
|
-
if (!this.isInitialized) {
|
|
183
|
-
await this.initialize();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Memory augmentation that uses in-memory storage
|
|
189
|
-
*/
|
|
190
|
-
export class MemoryStorageAugmentation extends BaseMemoryAugmentation {
|
|
191
|
-
constructor(name) {
|
|
192
|
-
super(name, new MemoryStorage());
|
|
193
|
-
this.description = 'Memory augmentation that stores data in memory';
|
|
194
|
-
this.enabled = true;
|
|
195
|
-
}
|
|
196
|
-
getType() {
|
|
197
|
-
return AugmentationType.MEMORY;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Memory augmentation that uses file system storage
|
|
202
|
-
*/
|
|
203
|
-
export class FileSystemStorageAugmentation extends BaseMemoryAugmentation {
|
|
204
|
-
constructor(name, rootDirectory) {
|
|
205
|
-
// Temporarily use MemoryStorage, will be replaced in initialize()
|
|
206
|
-
super(name, new MemoryStorage());
|
|
207
|
-
this.description = 'Memory augmentation that stores data in the file system';
|
|
208
|
-
this.enabled = true;
|
|
209
|
-
this.rootDirectory = rootDirectory || '.';
|
|
210
|
-
}
|
|
211
|
-
async initialize() {
|
|
212
|
-
try {
|
|
213
|
-
// Dynamically import FileSystemStorage
|
|
214
|
-
const { FileSystemStorage } = await import('../storage/adapters/fileSystemStorage.js');
|
|
215
|
-
this.storage = new FileSystemStorage(this.rootDirectory);
|
|
216
|
-
await super.initialize();
|
|
217
|
-
}
|
|
218
|
-
catch (error) {
|
|
219
|
-
console.error('Failed to load FileSystemStorage:', error);
|
|
220
|
-
throw new Error(`Failed to initialize FileSystemStorage: ${error}`);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
getType() {
|
|
224
|
-
return AugmentationType.MEMORY;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Memory augmentation that uses OPFS (Origin Private File System) storage
|
|
229
|
-
*/
|
|
230
|
-
export class OPFSStorageAugmentation extends BaseMemoryAugmentation {
|
|
231
|
-
constructor(name) {
|
|
232
|
-
super(name, new OPFSStorage());
|
|
233
|
-
this.description = 'Memory augmentation that stores data in the Origin Private File System';
|
|
234
|
-
this.enabled = true;
|
|
235
|
-
}
|
|
236
|
-
getType() {
|
|
237
|
-
return AugmentationType.MEMORY;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Factory function to create the appropriate memory augmentation based on the environment
|
|
242
|
-
*/
|
|
243
|
-
export async function createMemoryAugmentation(name, options = {}) {
|
|
244
|
-
// If a specific storage type is requested, use that
|
|
245
|
-
if (options.storageType) {
|
|
246
|
-
switch (options.storageType) {
|
|
247
|
-
case 'memory':
|
|
248
|
-
return new MemoryStorageAugmentation(name);
|
|
249
|
-
case 'filesystem':
|
|
250
|
-
return new FileSystemStorageAugmentation(name, options.rootDirectory);
|
|
251
|
-
case 'opfs':
|
|
252
|
-
return new OPFSStorageAugmentation(name);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
// Otherwise, select based on environment
|
|
256
|
-
// Use the global isNode variable from the environment detection
|
|
257
|
-
const isNodeEnv = globalThis.__ENV__?.isNode || (typeof process !== 'undefined' &&
|
|
258
|
-
process.versions != null &&
|
|
259
|
-
process.versions.node != null);
|
|
260
|
-
if (isNodeEnv) {
|
|
261
|
-
// In Node.js, use FileSystemStorage
|
|
262
|
-
return new FileSystemStorageAugmentation(name, options.rootDirectory);
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
// In browser, try OPFS first
|
|
266
|
-
const opfsStorage = new OPFSStorage();
|
|
267
|
-
if (opfsStorage.isOPFSAvailable()) {
|
|
268
|
-
// Request persistent storage if specified
|
|
269
|
-
if (options.requestPersistentStorage) {
|
|
270
|
-
await opfsStorage.requestPersistentStorage();
|
|
271
|
-
}
|
|
272
|
-
return new OPFSStorageAugmentation(name);
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
// Fall back to memory storage
|
|
276
|
-
return new MemoryStorageAugmentation(name);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
//# sourceMappingURL=memoryAugmentations.js.map
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server Search Augmentations
|
|
3
|
-
*
|
|
4
|
-
* This file implements conduit and activation augmentations for browser-server search functionality.
|
|
5
|
-
* It allows Brainy to search a server-hosted instance and store results locally.
|
|
6
|
-
*/
|
|
7
|
-
import { AugmentationResponse, WebSocketConnection } from '../types/augmentations.js';
|
|
8
|
-
import { BaseAugmentation } from '../augmentations/brainyAugmentation.js';
|
|
9
|
-
import { BrainyDataInterface } from '../types/brainyDataInterface.js';
|
|
10
|
-
/**
|
|
11
|
-
* ServerSearchConduitAugmentation
|
|
12
|
-
*
|
|
13
|
-
* A specialized conduit augmentation that provides functionality for searching
|
|
14
|
-
* a server-hosted Brainy instance and storing results locally.
|
|
15
|
-
*/
|
|
16
|
-
export declare class ServerSearchConduitAugmentation extends BaseAugmentation {
|
|
17
|
-
readonly name = "server-search-conduit";
|
|
18
|
-
readonly timing: "after";
|
|
19
|
-
readonly metadata: "readonly";
|
|
20
|
-
operations: ("addNoun" | "delete" | "addVerb")[];
|
|
21
|
-
readonly priority = 20;
|
|
22
|
-
private localDb;
|
|
23
|
-
constructor(name?: string);
|
|
24
|
-
/**
|
|
25
|
-
* Initialize the augmentation
|
|
26
|
-
*/
|
|
27
|
-
protected onInitialize(): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Set the local Brainy instance
|
|
30
|
-
* @param db The Brainy instance to use for local storage
|
|
31
|
-
*/
|
|
32
|
-
setLocalDb(db: BrainyDataInterface): void;
|
|
33
|
-
/**
|
|
34
|
-
* Stub method for performing search operations via WebSocket
|
|
35
|
-
* TODO: Implement proper WebSocket communication
|
|
36
|
-
*/
|
|
37
|
-
private performSearch;
|
|
38
|
-
/**
|
|
39
|
-
* Stub method for performing write operations via WebSocket
|
|
40
|
-
* TODO: Implement proper WebSocket communication
|
|
41
|
-
*/
|
|
42
|
-
private performWrite;
|
|
43
|
-
/**
|
|
44
|
-
* Get the local Brainy instance
|
|
45
|
-
* @returns The local Brainy instance
|
|
46
|
-
*/
|
|
47
|
-
getLocalDb(): BrainyDataInterface | null;
|
|
48
|
-
/**
|
|
49
|
-
* Execute method - required by BaseAugmentation
|
|
50
|
-
*/
|
|
51
|
-
execute<T = any>(operation: string, params: any, next: () => Promise<T>): Promise<T>;
|
|
52
|
-
/**
|
|
53
|
-
* Search the server-hosted Brainy instance and store results locally
|
|
54
|
-
* @param connectionId The ID of the established connection
|
|
55
|
-
* @param query The search query
|
|
56
|
-
* @param limit Maximum number of results to return
|
|
57
|
-
* @returns Search results
|
|
58
|
-
*/
|
|
59
|
-
searchServer(connectionId: string, query: string, limit?: number): Promise<AugmentationResponse<unknown>>;
|
|
60
|
-
/**
|
|
61
|
-
* Search the local Brainy instance
|
|
62
|
-
* @param query The search query
|
|
63
|
-
* @param limit Maximum number of results to return
|
|
64
|
-
* @returns Search results
|
|
65
|
-
*/
|
|
66
|
-
searchLocal(query: string, limit?: number): Promise<AugmentationResponse<unknown>>;
|
|
67
|
-
/**
|
|
68
|
-
* Search both server and local instances, combine results, and store server results locally
|
|
69
|
-
* @param connectionId The ID of the established connection
|
|
70
|
-
* @param query The search query
|
|
71
|
-
* @param limit Maximum number of results to return
|
|
72
|
-
* @returns Combined search results
|
|
73
|
-
*/
|
|
74
|
-
searchCombined(connectionId: string, query: string, limit?: number): Promise<AugmentationResponse<unknown>>;
|
|
75
|
-
/**
|
|
76
|
-
* Add data to both local and server instances
|
|
77
|
-
* @param connectionId The ID of the established connection
|
|
78
|
-
* @param data Text or vector to add
|
|
79
|
-
* @param metadata Metadata for the data
|
|
80
|
-
* @returns ID of the added data
|
|
81
|
-
*/
|
|
82
|
-
addToBoth(connectionId: string, data: string | any[], metadata?: any): Promise<AugmentationResponse<string>>;
|
|
83
|
-
/**
|
|
84
|
-
* Establish connection to remote server
|
|
85
|
-
* @param serverUrl Server URL to connect to
|
|
86
|
-
* @param options Connection options
|
|
87
|
-
* @returns Connection promise
|
|
88
|
-
*/
|
|
89
|
-
establishConnection(serverUrl: string, options?: any): Promise<any>;
|
|
90
|
-
/**
|
|
91
|
-
* Close WebSocket connection
|
|
92
|
-
* @param connectionId Connection ID to close
|
|
93
|
-
* @returns Promise that resolves when connection is closed
|
|
94
|
-
*/
|
|
95
|
-
closeWebSocket(connectionId: string): Promise<void>;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* ServerSearchActivationAugmentation
|
|
99
|
-
*
|
|
100
|
-
* An activation augmentation that provides actions for server search functionality.
|
|
101
|
-
*/
|
|
102
|
-
export declare class ServerSearchActivationAugmentation extends BaseAugmentation {
|
|
103
|
-
readonly name = "server-search-activation";
|
|
104
|
-
readonly timing: "after";
|
|
105
|
-
readonly metadata: "readonly";
|
|
106
|
-
operations: ("search" | "addNoun")[];
|
|
107
|
-
readonly priority = 20;
|
|
108
|
-
private conduitAugmentation;
|
|
109
|
-
private connections;
|
|
110
|
-
constructor(name?: string);
|
|
111
|
-
protected onInitialize(): Promise<void>;
|
|
112
|
-
protected onShutdown(): Promise<void>;
|
|
113
|
-
execute<T = any>(operation: string, params: any, next: () => Promise<T>): Promise<T>;
|
|
114
|
-
/**
|
|
115
|
-
* Set the conduit augmentation to use for server search
|
|
116
|
-
* @param conduit The ServerSearchConduitAugmentation to use
|
|
117
|
-
*/
|
|
118
|
-
setConduitAugmentation(conduit: ServerSearchConduitAugmentation): void;
|
|
119
|
-
/**
|
|
120
|
-
* Store a connection for later use
|
|
121
|
-
* @param connectionId The ID to use for the connection
|
|
122
|
-
* @param connection The WebSocket connection
|
|
123
|
-
*/
|
|
124
|
-
storeConnection(connectionId: string, connection: WebSocketConnection): void;
|
|
125
|
-
/**
|
|
126
|
-
* Get a stored connection
|
|
127
|
-
* @param connectionId The ID of the connection to retrieve
|
|
128
|
-
* @returns The WebSocket connection
|
|
129
|
-
*/
|
|
130
|
-
getConnection(connectionId: string): WebSocketConnection | undefined;
|
|
131
|
-
/**
|
|
132
|
-
* Trigger an action based on a processed command or internal state
|
|
133
|
-
* @param actionName The name of the action to trigger
|
|
134
|
-
* @param parameters Optional parameters for the action
|
|
135
|
-
*/
|
|
136
|
-
triggerAction(actionName: string, parameters?: Record<string, unknown>): AugmentationResponse<unknown>;
|
|
137
|
-
/**
|
|
138
|
-
* Handle the connectToServer action
|
|
139
|
-
* @param parameters Action parameters
|
|
140
|
-
*/
|
|
141
|
-
private handleConnectToServer;
|
|
142
|
-
/**
|
|
143
|
-
* Handle the searchServer action
|
|
144
|
-
* @param parameters Action parameters
|
|
145
|
-
*/
|
|
146
|
-
private handleSearchServer;
|
|
147
|
-
/**
|
|
148
|
-
* Handle the searchLocal action
|
|
149
|
-
* @param parameters Action parameters
|
|
150
|
-
*/
|
|
151
|
-
private handleSearchLocal;
|
|
152
|
-
/**
|
|
153
|
-
* Handle the searchCombined action
|
|
154
|
-
* @param parameters Action parameters
|
|
155
|
-
*/
|
|
156
|
-
private handleSearchCombined;
|
|
157
|
-
/**
|
|
158
|
-
* Handle the addToBoth action
|
|
159
|
-
* @param parameters Action parameters
|
|
160
|
-
*/
|
|
161
|
-
private handleAddToBoth;
|
|
162
|
-
/**
|
|
163
|
-
* Generates an expressive output or response from Brainy
|
|
164
|
-
* @param knowledgeId The identifier of the knowledge to express
|
|
165
|
-
* @param format The desired output format (e.g., 'text', 'json')
|
|
166
|
-
*/
|
|
167
|
-
generateOutput(knowledgeId: string, format: string): AugmentationResponse<string | Record<string, unknown>>;
|
|
168
|
-
/**
|
|
169
|
-
* Interacts with an external system or API
|
|
170
|
-
* @param systemId The identifier of the external system
|
|
171
|
-
* @param payload The data to send to the external system
|
|
172
|
-
*/
|
|
173
|
-
interactExternal(systemId: string, payload: Record<string, unknown>): AugmentationResponse<unknown>;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Factory function to create server search augmentations
|
|
177
|
-
* @param serverUrl The URL of the server to connect to
|
|
178
|
-
* @param options Additional options
|
|
179
|
-
* @returns An object containing the created augmentations
|
|
180
|
-
*/
|
|
181
|
-
export declare function createServerSearchAugmentations(serverUrl: string, options?: {
|
|
182
|
-
conduitName?: string;
|
|
183
|
-
activationName?: string;
|
|
184
|
-
protocols?: string | string[];
|
|
185
|
-
localDb?: BrainyDataInterface;
|
|
186
|
-
}): Promise<{
|
|
187
|
-
conduit: ServerSearchConduitAugmentation;
|
|
188
|
-
activation: ServerSearchActivationAugmentation;
|
|
189
|
-
connection: WebSocketConnection;
|
|
190
|
-
}>;
|