@soulcraft/brainy 0.9.5
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/LICENSE +21 -0
- package/README.demo.md +59 -0
- package/README.md +1257 -0
- package/brainy.png +0 -0
- package/cli-wrapper.js +56 -0
- package/dist/augmentationFactory.d.ts +87 -0
- package/dist/augmentationPipeline.d.ts +205 -0
- package/dist/augmentationRegistry.d.ts +48 -0
- package/dist/augmentationRegistryLoader.d.ts +147 -0
- package/dist/augmentations/conduitAugmentations.d.ts +173 -0
- package/dist/augmentations/memoryAugmentations.d.ts +71 -0
- package/dist/augmentations/serverSearchAugmentations.d.ts +168 -0
- package/dist/brainy.js +116929 -0
- package/dist/brainy.min.js +16107 -0
- package/dist/brainyData.d.ts +507 -0
- package/dist/cli.d.ts +7 -0
- package/dist/coreTypes.d.ts +131 -0
- package/dist/examples/basicUsage.d.ts +5 -0
- package/dist/hnsw/hnswIndex.d.ts +96 -0
- package/dist/hnsw/hnswIndexOptimized.d.ts +167 -0
- package/dist/index.d.ts +49 -0
- package/dist/mcp/brainyMCPAdapter.d.ts +69 -0
- package/dist/mcp/brainyMCPService.d.ts +99 -0
- package/dist/mcp/index.d.ts +14 -0
- package/dist/mcp/mcpAugmentationToolset.d.ts +68 -0
- package/dist/pipeline.d.ts +281 -0
- package/dist/sequentialPipeline.d.ts +114 -0
- package/dist/storage/fileSystemStorage.d.ts +123 -0
- package/dist/storage/opfsStorage.d.ts +244 -0
- package/dist/storage/s3CompatibleStorage.d.ts +158 -0
- package/dist/types/augmentations.d.ts +324 -0
- package/dist/types/augmentations.d.ts.map +1 -0
- package/dist/types/brainyDataInterface.d.ts +51 -0
- package/dist/types/brainyDataInterface.d.ts.map +1 -0
- package/dist/types/fileSystemTypes.d.ts +6 -0
- package/dist/types/fileSystemTypes.d.ts.map +1 -0
- package/dist/types/graphTypes.d.ts +134 -0
- package/dist/types/graphTypes.d.ts.map +1 -0
- package/dist/types/mcpTypes.d.ts +140 -0
- package/dist/types/mcpTypes.d.ts.map +1 -0
- package/dist/types/pipelineTypes.d.ts +27 -0
- package/dist/types/pipelineTypes.d.ts.map +1 -0
- package/dist/types/tensorflowTypes.d.ts +7 -0
- package/dist/types/tensorflowTypes.d.ts.map +1 -0
- package/dist/unified.d.ts +12 -0
- package/dist/unified.js +117122 -0
- package/dist/unified.min.js +16107 -0
- package/dist/utils/distance.d.ts +32 -0
- package/dist/utils/embedding.d.ts +55 -0
- package/dist/utils/environment.d.ts +28 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/version.d.ts +6 -0
- package/dist/utils/workerUtils.d.ts +28 -0
- package/package.json +156 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Pipeline
|
|
3
|
+
*
|
|
4
|
+
* This module combines the functionality of the primary augmentation pipeline and the streamlined pipeline
|
|
5
|
+
* into a single, unified pipeline system. It provides both the registry functionality of the primary pipeline
|
|
6
|
+
* and the simplified execution API of the streamlined pipeline.
|
|
7
|
+
*/
|
|
8
|
+
import { IAugmentation, AugmentationType, AugmentationResponse, IWebSocketSupport, BrainyAugmentations } from './types/augmentations.js';
|
|
9
|
+
import { IPipeline } from './types/pipelineTypes.js';
|
|
10
|
+
/**
|
|
11
|
+
* Execution mode for the pipeline
|
|
12
|
+
*/
|
|
13
|
+
export declare enum ExecutionMode {
|
|
14
|
+
SEQUENTIAL = "sequential",
|
|
15
|
+
PARALLEL = "parallel",
|
|
16
|
+
FIRST_SUCCESS = "firstSuccess",
|
|
17
|
+
FIRST_RESULT = "firstResult",
|
|
18
|
+
THREADED = "threaded"
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for pipeline execution
|
|
22
|
+
*/
|
|
23
|
+
export interface PipelineOptions {
|
|
24
|
+
mode?: ExecutionMode;
|
|
25
|
+
timeout?: number;
|
|
26
|
+
stopOnError?: boolean;
|
|
27
|
+
forceThreading?: boolean;
|
|
28
|
+
disableThreading?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Result of a pipeline execution
|
|
32
|
+
*/
|
|
33
|
+
export interface PipelineResult<T> {
|
|
34
|
+
results: AugmentationResponse<T>[];
|
|
35
|
+
errors: Error[];
|
|
36
|
+
successful: AugmentationResponse<T>[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Pipeline class
|
|
40
|
+
*
|
|
41
|
+
* Manages multiple augmentations of each type and provides methods to execute them.
|
|
42
|
+
* Implements the IPipeline interface to avoid circular dependencies.
|
|
43
|
+
*/
|
|
44
|
+
export declare class Pipeline implements IPipeline {
|
|
45
|
+
private registry;
|
|
46
|
+
/**
|
|
47
|
+
* Register an augmentation with the pipeline
|
|
48
|
+
*
|
|
49
|
+
* @param augmentation The augmentation to register
|
|
50
|
+
* @returns The pipeline instance for chaining
|
|
51
|
+
*/
|
|
52
|
+
register<T extends IAugmentation>(augmentation: T): Pipeline;
|
|
53
|
+
/**
|
|
54
|
+
* Unregister an augmentation from the pipeline
|
|
55
|
+
*
|
|
56
|
+
* @param augmentationName The name of the augmentation to unregister
|
|
57
|
+
* @returns The pipeline instance for chaining
|
|
58
|
+
*/
|
|
59
|
+
unregister(augmentationName: string): Pipeline;
|
|
60
|
+
/**
|
|
61
|
+
* Initialize all registered augmentations
|
|
62
|
+
*
|
|
63
|
+
* @returns A promise that resolves when all augmentations are initialized
|
|
64
|
+
*/
|
|
65
|
+
initialize(): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Shut down all registered augmentations
|
|
68
|
+
*
|
|
69
|
+
* @returns A promise that resolves when all augmentations are shut down
|
|
70
|
+
*/
|
|
71
|
+
shutDown(): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Get all registered augmentations
|
|
74
|
+
*
|
|
75
|
+
* @returns An array of all registered augmentations
|
|
76
|
+
*/
|
|
77
|
+
getAllAugmentations(): IAugmentation[];
|
|
78
|
+
/**
|
|
79
|
+
* Get all augmentations of a specific type
|
|
80
|
+
*
|
|
81
|
+
* @param type The type of augmentation to get
|
|
82
|
+
* @returns An array of all augmentations of the specified type
|
|
83
|
+
*/
|
|
84
|
+
getAugmentationsByType(type: AugmentationType): IAugmentation[];
|
|
85
|
+
/**
|
|
86
|
+
* Get all available augmentation types
|
|
87
|
+
*
|
|
88
|
+
* @returns An array of all augmentation types that have at least one registered augmentation
|
|
89
|
+
*/
|
|
90
|
+
getAvailableAugmentationTypes(): AugmentationType[];
|
|
91
|
+
/**
|
|
92
|
+
* Get all WebSocket-supporting augmentations
|
|
93
|
+
*
|
|
94
|
+
* @returns An array of all augmentations that support WebSocket connections
|
|
95
|
+
*/
|
|
96
|
+
getWebSocketAugmentations(): IWebSocketSupport[];
|
|
97
|
+
/**
|
|
98
|
+
* Check if an augmentation is of a specific type
|
|
99
|
+
*
|
|
100
|
+
* @param augmentation The augmentation to check
|
|
101
|
+
* @param methods The methods that should be present on the augmentation
|
|
102
|
+
* @returns True if the augmentation is of the specified type
|
|
103
|
+
*/
|
|
104
|
+
private isAugmentationType;
|
|
105
|
+
/**
|
|
106
|
+
* Determines if threading should be used based on options and environment
|
|
107
|
+
*
|
|
108
|
+
* @param options The pipeline options
|
|
109
|
+
* @returns True if threading should be used, false otherwise
|
|
110
|
+
*/
|
|
111
|
+
private shouldUseThreading;
|
|
112
|
+
/**
|
|
113
|
+
* Executes a method on multiple augmentations using the specified execution mode
|
|
114
|
+
*
|
|
115
|
+
* @param augmentations The augmentations to execute the method on
|
|
116
|
+
* @param method The method to execute
|
|
117
|
+
* @param args The arguments to pass to the method
|
|
118
|
+
* @param options Options for the execution
|
|
119
|
+
* @returns A promise that resolves with the results
|
|
120
|
+
*/
|
|
121
|
+
execute<T>(augmentations: IAugmentation[], method: string, args?: any[], options?: PipelineOptions): Promise<PipelineResult<T>>;
|
|
122
|
+
/**
|
|
123
|
+
* Executes a method on augmentations of a specific type
|
|
124
|
+
*
|
|
125
|
+
* @param type The type of augmentations to execute the method on
|
|
126
|
+
* @param method The method to execute
|
|
127
|
+
* @param args The arguments to pass to the method
|
|
128
|
+
* @param options Options for the execution
|
|
129
|
+
* @returns A promise that resolves with the results
|
|
130
|
+
*/
|
|
131
|
+
executeByType<T>(type: AugmentationType, method: string, args?: any[], options?: PipelineOptions): Promise<PipelineResult<T>>;
|
|
132
|
+
/**
|
|
133
|
+
* Executes a method on a single augmentation with automatic error handling
|
|
134
|
+
*
|
|
135
|
+
* @param augmentation The augmentation to execute the method on
|
|
136
|
+
* @param method The method to execute
|
|
137
|
+
* @param args The arguments to pass to the method
|
|
138
|
+
* @returns A promise that resolves with the result
|
|
139
|
+
*/
|
|
140
|
+
executeSingle<T>(augmentation: IAugmentation, method: string, ...args: any[]): Promise<AugmentationResponse<T>>;
|
|
141
|
+
/**
|
|
142
|
+
* Process static data through a pipeline of augmentations
|
|
143
|
+
*
|
|
144
|
+
* @param data The data to process
|
|
145
|
+
* @param pipeline An array of processing steps, each with an augmentation, method, and optional args transformer
|
|
146
|
+
* @param options Options for the execution
|
|
147
|
+
* @returns A promise that resolves with the final result
|
|
148
|
+
*/
|
|
149
|
+
processStaticData<T, R = any>(data: T, pipeline: Array<{
|
|
150
|
+
augmentation: IAugmentation;
|
|
151
|
+
method: string;
|
|
152
|
+
transformArgs?: (data: any, prevResult?: any) => any[];
|
|
153
|
+
}>, options?: PipelineOptions): Promise<AugmentationResponse<R>>;
|
|
154
|
+
/**
|
|
155
|
+
* Process streaming data through a pipeline of augmentations
|
|
156
|
+
*
|
|
157
|
+
* @param source The source augmentation that provides the data stream
|
|
158
|
+
* @param sourceMethod The method on the source augmentation that provides the data stream
|
|
159
|
+
* @param sourceArgs The arguments to pass to the source method
|
|
160
|
+
* @param pipeline An array of processing steps, each with an augmentation, method, and optional args transformer
|
|
161
|
+
* @param callback Function to call with the results of processing each data item
|
|
162
|
+
* @param options Options for the execution
|
|
163
|
+
* @returns A promise that resolves when the pipeline is set up
|
|
164
|
+
*/
|
|
165
|
+
processStreamingData<T>(source: IAugmentation, sourceMethod: string, sourceArgs: any[], pipeline: Array<{
|
|
166
|
+
augmentation: IAugmentation;
|
|
167
|
+
method: string;
|
|
168
|
+
transformArgs?: (data: any, prevResult?: any) => any[];
|
|
169
|
+
}>, callback: (result: AugmentationResponse<T>) => void, options?: PipelineOptions): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Create a reusable pipeline for processing data
|
|
172
|
+
*
|
|
173
|
+
* @param pipeline An array of processing steps
|
|
174
|
+
* @param options Options for the execution
|
|
175
|
+
* @returns A function that processes data through the pipeline
|
|
176
|
+
*/
|
|
177
|
+
createPipeline<T, R>(pipeline: Array<{
|
|
178
|
+
augmentation: IAugmentation;
|
|
179
|
+
method: string;
|
|
180
|
+
transformArgs?: (data: any, prevResult?: any) => any[];
|
|
181
|
+
}>, options?: PipelineOptions): (data: T) => Promise<AugmentationResponse<R>>;
|
|
182
|
+
/**
|
|
183
|
+
* Create a reusable streaming pipeline
|
|
184
|
+
*
|
|
185
|
+
* @param source The source augmentation
|
|
186
|
+
* @param sourceMethod The method on the source augmentation
|
|
187
|
+
* @param pipeline An array of processing steps
|
|
188
|
+
* @param options Options for the execution
|
|
189
|
+
* @returns A function that sets up the streaming pipeline
|
|
190
|
+
*/
|
|
191
|
+
createStreamingPipeline<T, R>(source: IAugmentation, sourceMethod: string, pipeline: Array<{
|
|
192
|
+
augmentation: IAugmentation;
|
|
193
|
+
method: string;
|
|
194
|
+
transformArgs?: (data: any, prevResult?: any) => any[];
|
|
195
|
+
}>, options?: PipelineOptions): (sourceArgs: any[], callback: (result: AugmentationResponse<R>) => void) => Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Execute a sense pipeline (legacy method)
|
|
198
|
+
*/
|
|
199
|
+
executeSensePipeline<M extends keyof BrainyAugmentations.ISenseAugmentation & string, R extends BrainyAugmentations.ISenseAugmentation[M] extends (...args: any[]) => AugmentationResponse<infer U> ? U : never>(method: M & (BrainyAugmentations.ISenseAugmentation[M] extends (...args: any[]) => any ? M : never), args: Parameters<Extract<BrainyAugmentations.ISenseAugmentation[M], (...args: any[]) => any>>, options?: PipelineOptions): Promise<Promise<{
|
|
200
|
+
success: boolean;
|
|
201
|
+
data: R;
|
|
202
|
+
error?: string;
|
|
203
|
+
}>[]>;
|
|
204
|
+
/**
|
|
205
|
+
* Execute a conduit pipeline (legacy method)
|
|
206
|
+
*/
|
|
207
|
+
executeConduitPipeline<M extends keyof BrainyAugmentations.IConduitAugmentation & string, R extends BrainyAugmentations.IConduitAugmentation[M] extends (...args: any[]) => AugmentationResponse<infer U> ? U : never>(method: M & (BrainyAugmentations.IConduitAugmentation[M] extends (...args: any[]) => any ? M : never), args: Parameters<Extract<BrainyAugmentations.IConduitAugmentation[M], (...args: any[]) => any>>, options?: PipelineOptions): Promise<Promise<{
|
|
208
|
+
success: boolean;
|
|
209
|
+
data: R;
|
|
210
|
+
error?: string;
|
|
211
|
+
}>[]>;
|
|
212
|
+
/**
|
|
213
|
+
* Execute a cognition pipeline (legacy method)
|
|
214
|
+
*/
|
|
215
|
+
executeCognitionPipeline<M extends keyof BrainyAugmentations.ICognitionAugmentation & string, R extends BrainyAugmentations.ICognitionAugmentation[M] extends (...args: any[]) => AugmentationResponse<infer U> ? U : never>(method: M & (BrainyAugmentations.ICognitionAugmentation[M] extends (...args: any[]) => any ? M : never), args: Parameters<Extract<BrainyAugmentations.ICognitionAugmentation[M], (...args: any[]) => any>>, options?: PipelineOptions): Promise<Promise<{
|
|
216
|
+
success: boolean;
|
|
217
|
+
data: R;
|
|
218
|
+
error?: string;
|
|
219
|
+
}>[]>;
|
|
220
|
+
/**
|
|
221
|
+
* Execute a memory pipeline (legacy method)
|
|
222
|
+
*/
|
|
223
|
+
executeMemoryPipeline<M extends keyof BrainyAugmentations.IMemoryAugmentation & string, R extends BrainyAugmentations.IMemoryAugmentation[M] extends (...args: any[]) => AugmentationResponse<infer U> ? U : never>(method: M & (BrainyAugmentations.IMemoryAugmentation[M] extends (...args: any[]) => any ? M : never), args: Parameters<Extract<BrainyAugmentations.IMemoryAugmentation[M], (...args: any[]) => any>>, options?: PipelineOptions): Promise<Promise<{
|
|
224
|
+
success: boolean;
|
|
225
|
+
data: R;
|
|
226
|
+
error?: string;
|
|
227
|
+
}>[]>;
|
|
228
|
+
/**
|
|
229
|
+
* Execute a perception pipeline (legacy method)
|
|
230
|
+
*/
|
|
231
|
+
executePerceptionPipeline<M extends keyof BrainyAugmentations.IPerceptionAugmentation & string, R extends BrainyAugmentations.IPerceptionAugmentation[M] extends (...args: any[]) => AugmentationResponse<infer U> ? U : never>(method: M & (BrainyAugmentations.IPerceptionAugmentation[M] extends (...args: any[]) => any ? M : never), args: Parameters<Extract<BrainyAugmentations.IPerceptionAugmentation[M], (...args: any[]) => any>>, options?: PipelineOptions): Promise<Promise<{
|
|
232
|
+
success: boolean;
|
|
233
|
+
data: R;
|
|
234
|
+
error?: string;
|
|
235
|
+
}>[]>;
|
|
236
|
+
/**
|
|
237
|
+
* Execute a dialog pipeline (legacy method)
|
|
238
|
+
*/
|
|
239
|
+
executeDialogPipeline<M extends keyof BrainyAugmentations.IDialogAugmentation & string, R extends BrainyAugmentations.IDialogAugmentation[M] extends (...args: any[]) => AugmentationResponse<infer U> ? U : never>(method: M & (BrainyAugmentations.IDialogAugmentation[M] extends (...args: any[]) => any ? M : never), args: Parameters<Extract<BrainyAugmentations.IDialogAugmentation[M], (...args: any[]) => any>>, options?: PipelineOptions): Promise<Promise<{
|
|
240
|
+
success: boolean;
|
|
241
|
+
data: R;
|
|
242
|
+
error?: string;
|
|
243
|
+
}>[]>;
|
|
244
|
+
/**
|
|
245
|
+
* Execute an activation pipeline (legacy method)
|
|
246
|
+
*/
|
|
247
|
+
executeActivationPipeline<M extends keyof BrainyAugmentations.IActivationAugmentation & string, R extends BrainyAugmentations.IActivationAugmentation[M] extends (...args: any[]) => AugmentationResponse<infer U> ? U : never>(method: M & (BrainyAugmentations.IActivationAugmentation[M] extends (...args: any[]) => any ? M : never), args: Parameters<Extract<BrainyAugmentations.IActivationAugmentation[M], (...args: any[]) => any>>, options?: PipelineOptions): Promise<Promise<{
|
|
248
|
+
success: boolean;
|
|
249
|
+
data: R;
|
|
250
|
+
error?: string;
|
|
251
|
+
}>[]>;
|
|
252
|
+
}
|
|
253
|
+
export declare const pipeline: Pipeline;
|
|
254
|
+
export declare const augmentationPipeline: Pipeline;
|
|
255
|
+
export declare const executeStreamlined: <T>(augmentations: IAugmentation[], method: string, args?: any[], options?: PipelineOptions) => Promise<PipelineResult<T>>;
|
|
256
|
+
export declare const executeByType: <T>(type: AugmentationType, method: string, args?: any[], options?: PipelineOptions) => Promise<PipelineResult<T>>;
|
|
257
|
+
export declare const executeSingle: <T>(augmentation: IAugmentation, method: string, ...args: any[]) => Promise<AugmentationResponse<T>>;
|
|
258
|
+
export declare const processStaticData: <T, R = any>(data: T, pipelineSteps: Array<{
|
|
259
|
+
augmentation: IAugmentation;
|
|
260
|
+
method: string;
|
|
261
|
+
transformArgs?: (data: any, prevResult?: any) => any[];
|
|
262
|
+
}>, options?: PipelineOptions) => Promise<AugmentationResponse<R>>;
|
|
263
|
+
export declare const processStreamingData: <T>(source: IAugmentation, sourceMethod: string, sourceArgs: any[], pipelineSteps: Array<{
|
|
264
|
+
augmentation: IAugmentation;
|
|
265
|
+
method: string;
|
|
266
|
+
transformArgs?: (data: any, prevResult?: any) => any[];
|
|
267
|
+
}>, callback: (result: AugmentationResponse<T>) => void, options?: PipelineOptions) => Promise<void>;
|
|
268
|
+
export declare const createPipeline: <T, R>(pipelineSteps: Array<{
|
|
269
|
+
augmentation: IAugmentation;
|
|
270
|
+
method: string;
|
|
271
|
+
transformArgs?: (data: any, prevResult?: any) => any[];
|
|
272
|
+
}>, options?: PipelineOptions) => (data: T) => Promise<AugmentationResponse<R>>;
|
|
273
|
+
export declare const createStreamingPipeline: <T, R>(source: IAugmentation, sourceMethod: string, pipelineSteps: Array<{
|
|
274
|
+
augmentation: IAugmentation;
|
|
275
|
+
method: string;
|
|
276
|
+
transformArgs?: (data: any, prevResult?: any) => any[];
|
|
277
|
+
}>, options?: PipelineOptions) => (sourceArgs: any[], callback: (result: AugmentationResponse<R>) => void) => Promise<void>;
|
|
278
|
+
export declare const StreamlinedExecutionMode: typeof ExecutionMode;
|
|
279
|
+
export type StreamlinedPipelineOptions = PipelineOptions;
|
|
280
|
+
export type StreamlinedPipelineResult<T> = PipelineResult<T>;
|
|
281
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sequential Augmentation Pipeline
|
|
3
|
+
*
|
|
4
|
+
* This module provides a pipeline for executing augmentations in a specific sequence:
|
|
5
|
+
* ISense -> IMemory -> ICognition -> IConduit -> IActivation -> IPerception
|
|
6
|
+
*
|
|
7
|
+
* It supports high-performance streaming data from WebSockets without blocking.
|
|
8
|
+
* Optimized for Node.js 23.11+ using native WebStreams API.
|
|
9
|
+
*/
|
|
10
|
+
import { AugmentationResponse, WebSocketConnection } from './types/augmentations.js';
|
|
11
|
+
import { BrainyData } from './brainyData.js';
|
|
12
|
+
/**
|
|
13
|
+
* Options for sequential pipeline execution
|
|
14
|
+
*/
|
|
15
|
+
export interface SequentialPipelineOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Timeout for each augmentation execution in milliseconds
|
|
18
|
+
*/
|
|
19
|
+
timeout?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Whether to stop execution if an error occurs
|
|
22
|
+
*/
|
|
23
|
+
stopOnError?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* BrainyData instance to use for storage
|
|
26
|
+
*/
|
|
27
|
+
brainyData?: BrainyData;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Result of a pipeline execution
|
|
31
|
+
*/
|
|
32
|
+
export interface PipelineResult<T> {
|
|
33
|
+
/**
|
|
34
|
+
* Whether the pipeline execution was successful
|
|
35
|
+
*/
|
|
36
|
+
success: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The data returned by the pipeline
|
|
39
|
+
*/
|
|
40
|
+
data: T;
|
|
41
|
+
/**
|
|
42
|
+
* Error message if the pipeline execution failed
|
|
43
|
+
*/
|
|
44
|
+
error?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Results from each stage of the pipeline
|
|
47
|
+
*/
|
|
48
|
+
stageResults: {
|
|
49
|
+
sense?: AugmentationResponse<unknown>;
|
|
50
|
+
memory?: AugmentationResponse<unknown>;
|
|
51
|
+
cognition?: AugmentationResponse<unknown>;
|
|
52
|
+
conduit?: AugmentationResponse<unknown>;
|
|
53
|
+
activation?: AugmentationResponse<unknown>;
|
|
54
|
+
perception?: AugmentationResponse<unknown>;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* SequentialPipeline class
|
|
59
|
+
*
|
|
60
|
+
* Executes augmentations in a specific sequence:
|
|
61
|
+
* ISense -> IMemory -> ICognition -> IConduit -> IActivation -> IPerception
|
|
62
|
+
*/
|
|
63
|
+
export declare class SequentialPipeline {
|
|
64
|
+
private brainyData;
|
|
65
|
+
/**
|
|
66
|
+
* Create a new sequential pipeline
|
|
67
|
+
*
|
|
68
|
+
* @param options Options for the pipeline
|
|
69
|
+
*/
|
|
70
|
+
constructor(options?: SequentialPipelineOptions);
|
|
71
|
+
/**
|
|
72
|
+
* Ensure stream classes are initialized
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
private ensureStreamClassesInitialized;
|
|
76
|
+
/**
|
|
77
|
+
* Initialize the pipeline
|
|
78
|
+
*
|
|
79
|
+
* @returns A promise that resolves when initialization is complete
|
|
80
|
+
*/
|
|
81
|
+
initialize(): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Process data through the sequential pipeline
|
|
84
|
+
*
|
|
85
|
+
* @param rawData The raw data to process
|
|
86
|
+
* @param dataType The type of data (e.g., 'text', 'image', 'audio')
|
|
87
|
+
* @param options Options for pipeline execution
|
|
88
|
+
* @returns A promise that resolves with the pipeline result
|
|
89
|
+
*/
|
|
90
|
+
processData(rawData: Buffer | string, dataType: string, options?: SequentialPipelineOptions): Promise<PipelineResult<unknown>>;
|
|
91
|
+
/**
|
|
92
|
+
* Process WebSocket data through the sequential pipeline
|
|
93
|
+
*
|
|
94
|
+
* @param connection The WebSocket connection
|
|
95
|
+
* @param dataType The type of data (e.g., 'text', 'image', 'audio')
|
|
96
|
+
* @param options Options for pipeline execution
|
|
97
|
+
* @returns A function to handle incoming WebSocket messages
|
|
98
|
+
*/
|
|
99
|
+
createWebSocketHandler(connection: WebSocketConnection, dataType: string, options?: SequentialPipelineOptions): Promise<(data: unknown) => void>;
|
|
100
|
+
/**
|
|
101
|
+
* Set up a WebSocket connection to process data through the pipeline
|
|
102
|
+
*
|
|
103
|
+
* @param url The WebSocket URL to connect to
|
|
104
|
+
* @param dataType The type of data (e.g., 'text', 'image', 'audio')
|
|
105
|
+
* @param options Options for pipeline execution
|
|
106
|
+
* @returns A promise that resolves with the WebSocket connection and associated streams
|
|
107
|
+
*/
|
|
108
|
+
setupWebSocketPipeline(url: string, dataType: string, options?: SequentialPipelineOptions): Promise<WebSocketConnection & {
|
|
109
|
+
readableStream?: ReadableStream<unknown>;
|
|
110
|
+
writableStream?: WritableStream<unknown>;
|
|
111
|
+
}>;
|
|
112
|
+
}
|
|
113
|
+
export declare const sequentialPipeline: SequentialPipeline;
|
|
114
|
+
//# sourceMappingURL=sequentialPipeline.d.ts.map
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { GraphVerb, HNSWNoun, StorageAdapter } from '../coreTypes.js';
|
|
2
|
+
/**
|
|
3
|
+
* File system storage adapter for Node.js environments
|
|
4
|
+
*/
|
|
5
|
+
export declare class FileSystemStorage implements StorageAdapter {
|
|
6
|
+
private rootDir;
|
|
7
|
+
private nounsDir;
|
|
8
|
+
private verbsDir;
|
|
9
|
+
private metadataDir;
|
|
10
|
+
private personDir;
|
|
11
|
+
private placeDir;
|
|
12
|
+
private thingDir;
|
|
13
|
+
private eventDir;
|
|
14
|
+
private conceptDir;
|
|
15
|
+
private contentDir;
|
|
16
|
+
private defaultDir;
|
|
17
|
+
private isInitialized;
|
|
18
|
+
constructor(rootDirectory?: string);
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the storage adapter
|
|
21
|
+
*/
|
|
22
|
+
init(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Save a node to storage
|
|
25
|
+
*/
|
|
26
|
+
saveNoun(noun: HNSWNoun): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Get a node from storage
|
|
29
|
+
*/
|
|
30
|
+
getNoun(id: string): Promise<HNSWNoun | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Get nodes by noun type
|
|
33
|
+
* @param nounType The noun type to filter by
|
|
34
|
+
* @returns Promise that resolves to an array of nodes of the specified noun type
|
|
35
|
+
*/
|
|
36
|
+
getNounsByNounType(nounType: string): Promise<HNSWNoun[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Get all nodes from storage
|
|
39
|
+
*/
|
|
40
|
+
getAllNouns(): Promise<HNSWNoun[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Read a node from a file
|
|
43
|
+
*/
|
|
44
|
+
private readNodeFromFile;
|
|
45
|
+
/**
|
|
46
|
+
* Delete a node from storage
|
|
47
|
+
*/
|
|
48
|
+
deleteNoun(id: string): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Save an edge to storage
|
|
51
|
+
*/
|
|
52
|
+
saveVerb(verb: GraphVerb): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Get an edge from storage
|
|
55
|
+
*/
|
|
56
|
+
getVerb(id: string): Promise<GraphVerb | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Get all edges from storage
|
|
59
|
+
*/
|
|
60
|
+
getAllVerbs(): Promise<GraphVerb[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Get edges by source node ID
|
|
63
|
+
*/
|
|
64
|
+
getVerbsBySource(sourceId: string): Promise<GraphVerb[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Get edges by target node ID
|
|
67
|
+
*/
|
|
68
|
+
getVerbsByTarget(targetId: string): Promise<GraphVerb[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Get edges by type
|
|
71
|
+
*/
|
|
72
|
+
getVerbsByType(type: string): Promise<GraphVerb[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Delete an edge from storage
|
|
75
|
+
*/
|
|
76
|
+
deleteVerb(id: string): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Save metadata to storage
|
|
79
|
+
*/
|
|
80
|
+
saveMetadata(id: string, metadata: any): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Get metadata from storage
|
|
83
|
+
*/
|
|
84
|
+
getMetadata(id: string): Promise<any | null>;
|
|
85
|
+
/**
|
|
86
|
+
* Clear all data from storage
|
|
87
|
+
*/
|
|
88
|
+
clear(): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Ensure the storage adapter is initialized
|
|
91
|
+
*/
|
|
92
|
+
private ensureInitialized;
|
|
93
|
+
/**
|
|
94
|
+
* Ensure a directory exists, creating it if necessary
|
|
95
|
+
*/
|
|
96
|
+
private ensureDirectoryExists;
|
|
97
|
+
/**
|
|
98
|
+
* Delete a directory and all its contents recursively
|
|
99
|
+
*/
|
|
100
|
+
private deleteDirectory;
|
|
101
|
+
/**
|
|
102
|
+
* Count the number of JSON files in a directory
|
|
103
|
+
*/
|
|
104
|
+
private countFilesInDirectory;
|
|
105
|
+
/**
|
|
106
|
+
* Convert a Map to a plain object for serialization
|
|
107
|
+
*/
|
|
108
|
+
private mapToObject;
|
|
109
|
+
/**
|
|
110
|
+
* Get the appropriate directory for a node based on its metadata
|
|
111
|
+
*/
|
|
112
|
+
private getNodeDirectory;
|
|
113
|
+
/**
|
|
114
|
+
* Get information about storage usage and capacity
|
|
115
|
+
*/
|
|
116
|
+
getStorageStatus(): Promise<{
|
|
117
|
+
type: string;
|
|
118
|
+
used: number;
|
|
119
|
+
quota: number | null;
|
|
120
|
+
details?: Record<string, any>;
|
|
121
|
+
}>;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=fileSystemStorage.d.ts.map
|