@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
package/brainy.png
ADDED
|
Binary file
|
package/cli-wrapper.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CLI Wrapper Script
|
|
5
|
+
*
|
|
6
|
+
* This script serves as a wrapper for the Brainy CLI, ensuring that command-line arguments
|
|
7
|
+
* are properly passed to the CLI when invoked through npm scripts.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { spawn } from 'child_process'
|
|
11
|
+
import { fileURLToPath } from 'url'
|
|
12
|
+
import { dirname, join } from 'path'
|
|
13
|
+
import fs from 'fs'
|
|
14
|
+
|
|
15
|
+
// Get the directory of the current module
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
17
|
+
const __dirname = dirname(__filename)
|
|
18
|
+
|
|
19
|
+
// Path to the actual CLI script
|
|
20
|
+
const cliPath = join(__dirname, 'dist', 'cli.js')
|
|
21
|
+
|
|
22
|
+
// Check if the CLI script exists
|
|
23
|
+
if (!fs.existsSync(cliPath)) {
|
|
24
|
+
console.error(`Error: CLI script not found at ${cliPath}`)
|
|
25
|
+
console.error('Make sure you have built the project with "npm run build"')
|
|
26
|
+
process.exit(1)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Special handling for version flags
|
|
30
|
+
if (process.argv.includes('--version') || process.argv.includes('-V')) {
|
|
31
|
+
// Read version directly from package.json to ensure it's always correct
|
|
32
|
+
try {
|
|
33
|
+
const packageJsonPath = join(__dirname, 'package.json')
|
|
34
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
|
|
35
|
+
console.log(packageJson.version)
|
|
36
|
+
process.exit(0)
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error('Error loading version information:', error.message)
|
|
39
|
+
process.exit(1)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Forward all arguments to the CLI script
|
|
44
|
+
const args = process.argv.slice(2)
|
|
45
|
+
|
|
46
|
+
// Check if npm is passing --force flag
|
|
47
|
+
// When npm runs with --force, it sets the npm_config_force environment variable
|
|
48
|
+
if (process.env.npm_config_force === 'true' && args.includes('clear') && !args.includes('--force') && !args.includes('-f')) {
|
|
49
|
+
args.push('--force')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const cli = spawn('node', [cliPath, ...args], { stdio: 'inherit' })
|
|
53
|
+
|
|
54
|
+
cli.on('close', (code) => {
|
|
55
|
+
process.exit(code)
|
|
56
|
+
})
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Augmentation Factory
|
|
3
|
+
*
|
|
4
|
+
* This module provides a simplified factory for creating augmentations with minimal boilerplate.
|
|
5
|
+
* It reduces the complexity of creating and using augmentations by providing a fluent API
|
|
6
|
+
* and handling common patterns automatically.
|
|
7
|
+
*/
|
|
8
|
+
import { IAugmentation, AugmentationResponse, ISenseAugmentation, IConduitAugmentation, IMemoryAugmentation, IWebSocketSupport, WebSocketConnection } from './types/augmentations.js';
|
|
9
|
+
/**
|
|
10
|
+
* Options for creating an augmentation
|
|
11
|
+
*/
|
|
12
|
+
export interface AugmentationOptions {
|
|
13
|
+
name: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
autoRegister?: boolean;
|
|
17
|
+
autoInitialize?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Factory for creating sense augmentations
|
|
21
|
+
*/
|
|
22
|
+
export declare function createSenseAugmentation(options: AugmentationOptions & {
|
|
23
|
+
processRawData?: (rawData: Buffer | string, dataType: string) => Promise<AugmentationResponse<{
|
|
24
|
+
nouns: string[];
|
|
25
|
+
verbs: string[];
|
|
26
|
+
}>> | AugmentationResponse<{
|
|
27
|
+
nouns: string[];
|
|
28
|
+
verbs: string[];
|
|
29
|
+
}>;
|
|
30
|
+
listenToFeed?: (feedUrl: string, callback: (data: {
|
|
31
|
+
nouns: string[];
|
|
32
|
+
verbs: string[];
|
|
33
|
+
}) => void) => Promise<void>;
|
|
34
|
+
}): ISenseAugmentation;
|
|
35
|
+
/**
|
|
36
|
+
* Factory for creating conduit augmentations
|
|
37
|
+
*/
|
|
38
|
+
export declare function createConduitAugmentation(options: AugmentationOptions & {
|
|
39
|
+
establishConnection?: (targetSystemId: string, config: Record<string, unknown>) => Promise<AugmentationResponse<WebSocketConnection>> | AugmentationResponse<WebSocketConnection>;
|
|
40
|
+
readData?: (query: Record<string, unknown>, options?: Record<string, unknown>) => Promise<AugmentationResponse<unknown>> | AugmentationResponse<unknown>;
|
|
41
|
+
writeData?: (data: Record<string, unknown>, options?: Record<string, unknown>) => Promise<AugmentationResponse<unknown>> | AugmentationResponse<unknown>;
|
|
42
|
+
monitorStream?: (streamId: string, callback: (data: unknown) => void) => Promise<void>;
|
|
43
|
+
}): IConduitAugmentation;
|
|
44
|
+
/**
|
|
45
|
+
* Factory for creating memory augmentations
|
|
46
|
+
*/
|
|
47
|
+
export declare function createMemoryAugmentation(options: AugmentationOptions & {
|
|
48
|
+
storeData?: (key: string, data: unknown, options?: Record<string, unknown>) => Promise<AugmentationResponse<boolean>> | AugmentationResponse<boolean>;
|
|
49
|
+
retrieveData?: (key: string, options?: Record<string, unknown>) => Promise<AugmentationResponse<unknown>> | AugmentationResponse<unknown>;
|
|
50
|
+
updateData?: (key: string, data: unknown, options?: Record<string, unknown>) => Promise<AugmentationResponse<boolean>> | AugmentationResponse<boolean>;
|
|
51
|
+
deleteData?: (key: string, options?: Record<string, unknown>) => Promise<AugmentationResponse<boolean>> | AugmentationResponse<boolean>;
|
|
52
|
+
listDataKeys?: (pattern?: string, options?: Record<string, unknown>) => Promise<AugmentationResponse<string[]>> | AugmentationResponse<string[]>;
|
|
53
|
+
search?: (query: unknown, k?: number, options?: Record<string, unknown>) => Promise<AugmentationResponse<Array<{
|
|
54
|
+
id: string;
|
|
55
|
+
score: number;
|
|
56
|
+
data: unknown;
|
|
57
|
+
}>>> | AugmentationResponse<Array<{
|
|
58
|
+
id: string;
|
|
59
|
+
score: number;
|
|
60
|
+
data: unknown;
|
|
61
|
+
}>>;
|
|
62
|
+
}): IMemoryAugmentation;
|
|
63
|
+
/**
|
|
64
|
+
* Factory for creating WebSocket-enabled augmentations
|
|
65
|
+
* This can be combined with other augmentation factories to create WebSocket-enabled versions
|
|
66
|
+
*/
|
|
67
|
+
export declare function addWebSocketSupport<T extends IAugmentation>(augmentation: T, options: {
|
|
68
|
+
connectWebSocket?: (url: string, protocols?: string | string[]) => Promise<WebSocketConnection>;
|
|
69
|
+
sendWebSocketMessage?: (connectionId: string, data: unknown) => Promise<void>;
|
|
70
|
+
onWebSocketMessage?: (connectionId: string, callback: (data: unknown) => void) => Promise<void>;
|
|
71
|
+
offWebSocketMessage?: (connectionId: string, callback: (data: unknown) => void) => Promise<void>;
|
|
72
|
+
closeWebSocket?: (connectionId: string, code?: number, reason?: string) => Promise<void>;
|
|
73
|
+
}): T & IWebSocketSupport;
|
|
74
|
+
/**
|
|
75
|
+
* Simplified function to execute an augmentation method with automatic error handling
|
|
76
|
+
* This provides a more concise way to execute augmentation methods compared to the full pipeline
|
|
77
|
+
*/
|
|
78
|
+
export declare function executeAugmentation<T, R>(augmentation: IAugmentation, method: string, ...args: any[]): Promise<AugmentationResponse<R>>;
|
|
79
|
+
/**
|
|
80
|
+
* Dynamically load augmentations from a module at runtime
|
|
81
|
+
* This allows for lazy-loading augmentations when needed instead of at build time
|
|
82
|
+
*/
|
|
83
|
+
export declare function loadAugmentationModule(modulePromise: Promise<any>, options?: {
|
|
84
|
+
autoRegister?: boolean;
|
|
85
|
+
autoInitialize?: boolean;
|
|
86
|
+
}): Promise<IAugmentation[]>;
|
|
87
|
+
//# sourceMappingURL=augmentationFactory.d.ts.map
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Augmentation Event Pipeline
|
|
3
|
+
*
|
|
4
|
+
* This module provides a pipeline for managing and executing multiple augmentations
|
|
5
|
+
* of each type. It allows registering multiple augmentations and executing them
|
|
6
|
+
* in sequence or in parallel.
|
|
7
|
+
*/
|
|
8
|
+
import { BrainyAugmentations, IAugmentation, IWebSocketSupport, AugmentationResponse, AugmentationType } from './types/augmentations.js';
|
|
9
|
+
/**
|
|
10
|
+
* Execution mode for the pipeline
|
|
11
|
+
*/
|
|
12
|
+
export declare enum ExecutionMode {
|
|
13
|
+
SEQUENTIAL = "sequential",
|
|
14
|
+
PARALLEL = "parallel",
|
|
15
|
+
FIRST_SUCCESS = "firstSuccess",
|
|
16
|
+
FIRST_RESULT = "firstResult",
|
|
17
|
+
THREADED = "threaded"
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Options for pipeline execution
|
|
21
|
+
*/
|
|
22
|
+
export interface PipelineOptions {
|
|
23
|
+
mode?: ExecutionMode;
|
|
24
|
+
timeout?: number;
|
|
25
|
+
stopOnError?: boolean;
|
|
26
|
+
forceThreading?: boolean;
|
|
27
|
+
disableThreading?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* AugmentationPipeline class
|
|
31
|
+
*
|
|
32
|
+
* Manages multiple augmentations of each type and provides methods to execute them.
|
|
33
|
+
*/
|
|
34
|
+
export declare class AugmentationPipeline {
|
|
35
|
+
private registry;
|
|
36
|
+
/**
|
|
37
|
+
* Register an augmentation with the pipeline
|
|
38
|
+
*
|
|
39
|
+
* @param augmentation The augmentation to register
|
|
40
|
+
* @returns The pipeline instance for chaining
|
|
41
|
+
*/
|
|
42
|
+
register<T extends IAugmentation>(augmentation: T): AugmentationPipeline;
|
|
43
|
+
/**
|
|
44
|
+
* Unregister an augmentation from the pipeline
|
|
45
|
+
*
|
|
46
|
+
* @param augmentationName The name of the augmentation to unregister
|
|
47
|
+
* @returns The pipeline instance for chaining
|
|
48
|
+
*/
|
|
49
|
+
unregister(augmentationName: string): AugmentationPipeline;
|
|
50
|
+
/**
|
|
51
|
+
* Initialize all registered augmentations
|
|
52
|
+
*
|
|
53
|
+
* @returns A promise that resolves when all augmentations are initialized
|
|
54
|
+
*/
|
|
55
|
+
initialize(): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Shut down all registered augmentations
|
|
58
|
+
*
|
|
59
|
+
* @returns A promise that resolves when all augmentations are shut down
|
|
60
|
+
*/
|
|
61
|
+
shutDown(): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Execute a sense pipeline
|
|
64
|
+
*
|
|
65
|
+
* @param method The method to execute on each sense augmentation
|
|
66
|
+
* @param args The arguments to pass to the method
|
|
67
|
+
* @param options The pipeline execution options
|
|
68
|
+
* @returns A promise that resolves with the results from all augmentations
|
|
69
|
+
*/
|
|
70
|
+
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<{
|
|
71
|
+
success: boolean;
|
|
72
|
+
data: R;
|
|
73
|
+
error?: string;
|
|
74
|
+
}>[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Execute a conduit pipeline
|
|
77
|
+
*
|
|
78
|
+
* @param method The method to execute on each conduit augmentation
|
|
79
|
+
* @param args The arguments to pass to the method
|
|
80
|
+
* @param options The pipeline execution options
|
|
81
|
+
* @returns A promise that resolves with the results from all augmentations
|
|
82
|
+
*/
|
|
83
|
+
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<{
|
|
84
|
+
success: boolean;
|
|
85
|
+
data: R;
|
|
86
|
+
error?: string;
|
|
87
|
+
}>[]>;
|
|
88
|
+
/**
|
|
89
|
+
* Execute a cognition pipeline
|
|
90
|
+
*
|
|
91
|
+
* @param method The method to execute on each cognition augmentation
|
|
92
|
+
* @param args The arguments to pass to the method
|
|
93
|
+
* @param options The pipeline execution options
|
|
94
|
+
* @returns A promise that resolves with the results from all augmentations
|
|
95
|
+
*/
|
|
96
|
+
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<{
|
|
97
|
+
success: boolean;
|
|
98
|
+
data: R;
|
|
99
|
+
error?: string;
|
|
100
|
+
}>[]>;
|
|
101
|
+
/**
|
|
102
|
+
* Execute a memory pipeline
|
|
103
|
+
*
|
|
104
|
+
* @param method The method to execute on each memory augmentation
|
|
105
|
+
* @param args The arguments to pass to the method
|
|
106
|
+
* @param options The pipeline execution options
|
|
107
|
+
* @returns A promise that resolves with the results from all augmentations
|
|
108
|
+
*/
|
|
109
|
+
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<{
|
|
110
|
+
success: boolean;
|
|
111
|
+
data: R;
|
|
112
|
+
error?: string;
|
|
113
|
+
}>[]>;
|
|
114
|
+
/**
|
|
115
|
+
* Execute a perception pipeline
|
|
116
|
+
*
|
|
117
|
+
* @param method The method to execute on each perception augmentation
|
|
118
|
+
* @param args The arguments to pass to the method
|
|
119
|
+
* @param options The pipeline execution options
|
|
120
|
+
* @returns A promise that resolves with the results from all augmentations
|
|
121
|
+
*/
|
|
122
|
+
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<{
|
|
123
|
+
success: boolean;
|
|
124
|
+
data: R;
|
|
125
|
+
error?: string;
|
|
126
|
+
}>[]>;
|
|
127
|
+
/**
|
|
128
|
+
* Execute a dialog pipeline
|
|
129
|
+
*
|
|
130
|
+
* @param method The method to execute on each dialog augmentation
|
|
131
|
+
* @param args The arguments to pass to the method
|
|
132
|
+
* @param options The pipeline execution options
|
|
133
|
+
* @returns A promise that resolves with the results from all augmentations
|
|
134
|
+
*/
|
|
135
|
+
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<{
|
|
136
|
+
success: boolean;
|
|
137
|
+
data: R;
|
|
138
|
+
error?: string;
|
|
139
|
+
}>[]>;
|
|
140
|
+
/**
|
|
141
|
+
* Execute an activation pipeline
|
|
142
|
+
*
|
|
143
|
+
* @param method The method to execute on each activation augmentation
|
|
144
|
+
* @param args The arguments to pass to the method
|
|
145
|
+
* @param options The pipeline execution options
|
|
146
|
+
* @returns A promise that resolves with the results from all augmentations
|
|
147
|
+
*/
|
|
148
|
+
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<{
|
|
149
|
+
success: boolean;
|
|
150
|
+
data: R;
|
|
151
|
+
error?: string;
|
|
152
|
+
}>[]>;
|
|
153
|
+
/**
|
|
154
|
+
* Get all registered augmentations
|
|
155
|
+
*
|
|
156
|
+
* @returns An array of all registered augmentations
|
|
157
|
+
*/
|
|
158
|
+
getAllAugmentations(): IAugmentation[];
|
|
159
|
+
/**
|
|
160
|
+
* Get all augmentations of a specific type
|
|
161
|
+
*
|
|
162
|
+
* @param type The type of augmentation to get
|
|
163
|
+
* @returns An array of all augmentations of the specified type
|
|
164
|
+
*/
|
|
165
|
+
getAugmentationsByType(type: AugmentationType): IAugmentation[];
|
|
166
|
+
/**
|
|
167
|
+
* Get all available augmentation types
|
|
168
|
+
*
|
|
169
|
+
* @returns An array of all augmentation types that have at least one registered augmentation
|
|
170
|
+
*/
|
|
171
|
+
getAvailableAugmentationTypes(): AugmentationType[];
|
|
172
|
+
/**
|
|
173
|
+
* Get all WebSocket-supporting augmentations
|
|
174
|
+
*
|
|
175
|
+
* @returns An array of all augmentations that support WebSocket connections
|
|
176
|
+
*/
|
|
177
|
+
getWebSocketAugmentations(): IWebSocketSupport[];
|
|
178
|
+
/**
|
|
179
|
+
* Check if an augmentation is of a specific type
|
|
180
|
+
*
|
|
181
|
+
* @param augmentation The augmentation to check
|
|
182
|
+
* @param methods The methods that should be present on the augmentation
|
|
183
|
+
* @returns True if the augmentation is of the specified type
|
|
184
|
+
*/
|
|
185
|
+
private isAugmentationType;
|
|
186
|
+
/**
|
|
187
|
+
* Determines if threading should be used based on options and environment
|
|
188
|
+
*
|
|
189
|
+
* @param options The pipeline options
|
|
190
|
+
* @returns True if threading should be used, false otherwise
|
|
191
|
+
*/
|
|
192
|
+
private shouldUseThreading;
|
|
193
|
+
/**
|
|
194
|
+
* Execute a pipeline for a specific augmentation type
|
|
195
|
+
*
|
|
196
|
+
* @param augmentations The augmentations to execute
|
|
197
|
+
* @param method The method to execute on each augmentation
|
|
198
|
+
* @param args The arguments to pass to the method
|
|
199
|
+
* @param options The pipeline execution options
|
|
200
|
+
* @returns A promise that resolves with the results from all augmentations
|
|
201
|
+
*/
|
|
202
|
+
private executeTypedPipeline;
|
|
203
|
+
}
|
|
204
|
+
export declare const augmentationPipeline: AugmentationPipeline;
|
|
205
|
+
//# sourceMappingURL=augmentationPipeline.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Augmentation Registry
|
|
3
|
+
*
|
|
4
|
+
* This module provides a registry for augmentations that are loaded at build time.
|
|
5
|
+
* It replaces the dynamic loading mechanism in pluginLoader.ts.
|
|
6
|
+
*/
|
|
7
|
+
import { IPipeline } from './types/pipelineTypes.js';
|
|
8
|
+
import { AugmentationType, IAugmentation } from './types/augmentations.js';
|
|
9
|
+
/**
|
|
10
|
+
* Sets the default pipeline instance
|
|
11
|
+
* This function should be called from pipeline.ts after the pipeline is created
|
|
12
|
+
*/
|
|
13
|
+
export declare function setDefaultPipeline(pipeline: IPipeline): void;
|
|
14
|
+
/**
|
|
15
|
+
* Registry of all available augmentations
|
|
16
|
+
*/
|
|
17
|
+
export declare const availableAugmentations: IAugmentation[];
|
|
18
|
+
/**
|
|
19
|
+
* Registers an augmentation with the registry
|
|
20
|
+
*
|
|
21
|
+
* @param augmentation The augmentation to register
|
|
22
|
+
* @returns The augmentation that was registered
|
|
23
|
+
*/
|
|
24
|
+
export declare function registerAugmentation<T extends IAugmentation>(augmentation: T): T;
|
|
25
|
+
/**
|
|
26
|
+
* Initializes the augmentation pipeline with all registered augmentations
|
|
27
|
+
*
|
|
28
|
+
* @param pipeline Optional custom pipeline to use instead of the default
|
|
29
|
+
* @returns The pipeline that was initialized
|
|
30
|
+
* @throws Error if no pipeline is provided and the default pipeline hasn't been set
|
|
31
|
+
*/
|
|
32
|
+
export declare function initializeAugmentationPipeline(pipelineInstance?: IPipeline): IPipeline;
|
|
33
|
+
/**
|
|
34
|
+
* Enables or disables an augmentation by name
|
|
35
|
+
*
|
|
36
|
+
* @param name The name of the augmentation to enable/disable
|
|
37
|
+
* @param enabled Whether to enable or disable the augmentation
|
|
38
|
+
* @returns True if the augmentation was found and updated, false otherwise
|
|
39
|
+
*/
|
|
40
|
+
export declare function setAugmentationEnabled(name: string, enabled: boolean): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Gets all augmentations of a specific type
|
|
43
|
+
*
|
|
44
|
+
* @param type The type of augmentation to get
|
|
45
|
+
* @returns An array of all augmentations of the specified type
|
|
46
|
+
*/
|
|
47
|
+
export declare function getAugmentationsByType(type: AugmentationType): IAugmentation[];
|
|
48
|
+
//# sourceMappingURL=augmentationRegistry.d.ts.map
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Augmentation Registry Loader
|
|
3
|
+
*
|
|
4
|
+
* This module provides functionality for loading augmentation registrations
|
|
5
|
+
* at build time. It's designed to be used with build tools like webpack or rollup
|
|
6
|
+
* to automatically discover and register augmentations.
|
|
7
|
+
*/
|
|
8
|
+
import { IAugmentation } from './types/augmentations.js';
|
|
9
|
+
/**
|
|
10
|
+
* Options for the augmentation registry loader
|
|
11
|
+
*/
|
|
12
|
+
export interface AugmentationRegistryLoaderOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Whether to automatically initialize the augmentations after loading
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
autoInitialize?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether to log debug information during loading
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
debug?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Result of loading augmentations
|
|
26
|
+
*/
|
|
27
|
+
export interface AugmentationLoadResult {
|
|
28
|
+
/**
|
|
29
|
+
* The augmentations that were loaded
|
|
30
|
+
*/
|
|
31
|
+
augmentations: IAugmentation[];
|
|
32
|
+
/**
|
|
33
|
+
* Any errors that occurred during loading
|
|
34
|
+
*/
|
|
35
|
+
errors: Error[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Loads augmentations from the specified modules
|
|
39
|
+
*
|
|
40
|
+
* This function is designed to be used with build tools like webpack or rollup
|
|
41
|
+
* to automatically discover and register augmentations.
|
|
42
|
+
*
|
|
43
|
+
* @param modules An object containing modules with augmentations to register
|
|
44
|
+
* @param options Options for the loader
|
|
45
|
+
* @returns A promise that resolves with the result of loading the augmentations
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // webpack.config.js
|
|
50
|
+
* const { AugmentationRegistryPlugin } = require('brainy/dist/webpack');
|
|
51
|
+
*
|
|
52
|
+
* module.exports = {
|
|
53
|
+
* // ... other webpack config
|
|
54
|
+
* plugins: [
|
|
55
|
+
* new AugmentationRegistryPlugin({
|
|
56
|
+
* // Pattern to match files containing augmentations
|
|
57
|
+
* pattern: /augmentation\.js$/,
|
|
58
|
+
* // Options for the loader
|
|
59
|
+
* options: {
|
|
60
|
+
* autoInitialize: true,
|
|
61
|
+
* debug: true
|
|
62
|
+
* }
|
|
63
|
+
* })
|
|
64
|
+
* ]
|
|
65
|
+
* };
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function loadAugmentationsFromModules(modules: Record<string, any>, options?: AugmentationRegistryLoaderOptions): Promise<AugmentationLoadResult>;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a webpack plugin for automatically loading augmentations
|
|
71
|
+
*
|
|
72
|
+
* @param options Options for the plugin
|
|
73
|
+
* @returns A webpack plugin
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* // webpack.config.js
|
|
78
|
+
* const { createAugmentationRegistryPlugin } = require('brainy/dist/webpack');
|
|
79
|
+
*
|
|
80
|
+
* module.exports = {
|
|
81
|
+
* // ... other webpack config
|
|
82
|
+
* plugins: [
|
|
83
|
+
* createAugmentationRegistryPlugin({
|
|
84
|
+
* pattern: /augmentation\.js$/,
|
|
85
|
+
* options: {
|
|
86
|
+
* autoInitialize: true,
|
|
87
|
+
* debug: true
|
|
88
|
+
* }
|
|
89
|
+
* })
|
|
90
|
+
* ]
|
|
91
|
+
* };
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare function createAugmentationRegistryPlugin(options: {
|
|
95
|
+
/**
|
|
96
|
+
* Pattern to match files containing augmentations
|
|
97
|
+
*/
|
|
98
|
+
pattern: RegExp;
|
|
99
|
+
/**
|
|
100
|
+
* Options for the loader
|
|
101
|
+
*/
|
|
102
|
+
options?: AugmentationRegistryLoaderOptions;
|
|
103
|
+
}): {
|
|
104
|
+
name: string;
|
|
105
|
+
pattern: RegExp;
|
|
106
|
+
options: AugmentationRegistryLoaderOptions;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Creates a rollup plugin for automatically loading augmentations
|
|
110
|
+
*
|
|
111
|
+
* @param options Options for the plugin
|
|
112
|
+
* @returns A rollup plugin
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* // rollup.config.js
|
|
117
|
+
* import { createAugmentationRegistryRollupPlugin } from 'brainy/dist/rollup';
|
|
118
|
+
*
|
|
119
|
+
* export default {
|
|
120
|
+
* // ... other rollup config
|
|
121
|
+
* plugins: [
|
|
122
|
+
* createAugmentationRegistryRollupPlugin({
|
|
123
|
+
* pattern: /augmentation\.js$/,
|
|
124
|
+
* options: {
|
|
125
|
+
* autoInitialize: true,
|
|
126
|
+
* debug: true
|
|
127
|
+
* }
|
|
128
|
+
* })
|
|
129
|
+
* ]
|
|
130
|
+
* };
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare function createAugmentationRegistryRollupPlugin(options: {
|
|
134
|
+
/**
|
|
135
|
+
* Pattern to match files containing augmentations
|
|
136
|
+
*/
|
|
137
|
+
pattern: RegExp;
|
|
138
|
+
/**
|
|
139
|
+
* Options for the loader
|
|
140
|
+
*/
|
|
141
|
+
options?: AugmentationRegistryLoaderOptions;
|
|
142
|
+
}): {
|
|
143
|
+
name: string;
|
|
144
|
+
pattern: RegExp;
|
|
145
|
+
options: AugmentationRegistryLoaderOptions;
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=augmentationRegistryLoader.d.ts.map
|