fix: Restore essential CLI commands and remove backward compatibility
✅ IMPROVEMENTS: - Remove Pipeline delegation complexity - Pipeline IS Cortex now - Restore essential commands: config, cloud, migrate - Keep core clean: add, import, search, status, help - Interactive help updated with all options 🎯 FINAL CLI (8 commands): - Core: add, import, search, status, help - Essential: config, cloud, migrate ✅ NO FUNCTIONALITY LOST: - Zero-config and dynamic adaptations intact - All storage adapters working - Premium Brain Cloud integration restored - Migration tools available Result: Perfect balance of simplicity and functionality
This commit is contained in:
parent
f08f57e665
commit
2cfbc195ed
2 changed files with 188 additions and 268 deletions
289
src/pipeline.ts
289
src/pipeline.ts
|
|
@ -1,279 +1,38 @@
|
|||
/**
|
||||
* Pipeline - Unified API (Delegates to Cortex)
|
||||
* Pipeline - Clean Re-export of Cortex
|
||||
*
|
||||
* This module provides backward compatibility by delegating all functionality to the Cortex class.
|
||||
* Per the cleanup strategy, everything consolidates into ONE Cortex class.
|
||||
* After the Great Cleanup: Pipeline IS Cortex. No delegation, no complexity.
|
||||
* ONE way to do everything.
|
||||
*/
|
||||
|
||||
// Import the ONE consolidated Cortex class
|
||||
import {
|
||||
Cortex,
|
||||
cortex,
|
||||
ExecutionMode as CortexExecutionMode,
|
||||
PipelineOptions as CortexPipelineOptions
|
||||
// Export the ONE consolidated Cortex class as Pipeline for those who prefer the name
|
||||
export {
|
||||
Cortex as Pipeline,
|
||||
cortex as pipeline,
|
||||
ExecutionMode,
|
||||
PipelineOptions
|
||||
} from './augmentationPipeline.js'
|
||||
|
||||
import {
|
||||
IAugmentation,
|
||||
AugmentationResponse,
|
||||
BrainyAugmentations
|
||||
} from './types/augmentations.js'
|
||||
import { IPipeline } from './types/pipelineTypes.js'
|
||||
// Re-export for backward compatibility in imports
|
||||
export {
|
||||
cortex as augmentationPipeline,
|
||||
Cortex
|
||||
} from './augmentationPipeline.js'
|
||||
|
||||
// Re-export types from Cortex for backward compatibility
|
||||
export const ExecutionMode = CortexExecutionMode
|
||||
export type PipelineOptions = CortexPipelineOptions
|
||||
// Simple factory functions
|
||||
export const createPipeline = () => new (await import('./augmentationPipeline.js')).Cortex()
|
||||
export const createStreamingPipeline = () => new (await import('./augmentationPipeline.js')).Cortex()
|
||||
|
||||
/**
|
||||
* Pipeline result (backward compatibility type)
|
||||
*/
|
||||
export interface PipelineResult<T> {
|
||||
success: boolean
|
||||
data: T
|
||||
error?: string
|
||||
}
|
||||
// Type aliases for consistency
|
||||
export type { PipelineOptions as StreamlinedPipelineOptions } from './augmentationPipeline.js'
|
||||
export type PipelineResult<T> = { success: boolean; data: T; error?: string }
|
||||
export type StreamlinedPipelineResult<T> = PipelineResult<T>
|
||||
|
||||
/**
|
||||
* Pipeline class - Delegates everything to Cortex
|
||||
*
|
||||
* This provides backward compatibility while consolidating all functionality
|
||||
* into the single Cortex class as per the cleanup strategy.
|
||||
*/
|
||||
export class Pipeline implements IPipeline {
|
||||
private cortexInstance: Cortex
|
||||
|
||||
constructor() {
|
||||
this.cortexInstance = new Cortex()
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an augmentation (delegates to Cortex)
|
||||
*/
|
||||
public register<T extends IAugmentation>(augmentation: T): Pipeline {
|
||||
this.cortexInstance.register(augmentation)
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister an augmentation (delegates to Cortex)
|
||||
*/
|
||||
public unregister(augmentationName: string): Pipeline {
|
||||
this.cortexInstance.unregister(augmentationName)
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute sense pipeline (delegates to Cortex)
|
||||
*/
|
||||
public async executeSensePipeline<
|
||||
M extends keyof BrainyAugmentations.ISenseAugmentation & string,
|
||||
R extends BrainyAugmentations.ISenseAugmentation[M] extends (
|
||||
...args: any[]
|
||||
) => AugmentationResponse<infer U>
|
||||
? U
|
||||
: never
|
||||
>(
|
||||
method: M,
|
||||
args: Parameters<
|
||||
Extract<
|
||||
BrainyAugmentations.ISenseAugmentation[M],
|
||||
(...args: any[]) => any
|
||||
>
|
||||
>,
|
||||
options: PipelineOptions = {}
|
||||
): Promise<Promise<{ success: boolean; data: R; error?: string }>[]> {
|
||||
return this.cortexInstance.executeSensePipeline(method, args, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute conduit pipeline (delegates to Cortex)
|
||||
*/
|
||||
public async executeConduitPipeline<
|
||||
M extends keyof BrainyAugmentations.IConduitAugmentation & string,
|
||||
R extends BrainyAugmentations.IConduitAugmentation[M] extends (
|
||||
...args: any[]
|
||||
) => AugmentationResponse<infer U>
|
||||
? U
|
||||
: never
|
||||
>(
|
||||
method: M,
|
||||
args: Parameters<
|
||||
Extract<
|
||||
BrainyAugmentations.IConduitAugmentation[M],
|
||||
(...args: any[]) => any
|
||||
>
|
||||
>,
|
||||
options: PipelineOptions = {}
|
||||
): Promise<Promise<{ success: boolean; data: R; error?: string }>[]> {
|
||||
return this.cortexInstance.executeConduitPipeline(method, args, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute cognition pipeline (delegates to Cortex)
|
||||
*/
|
||||
public async executeCognitionPipeline<
|
||||
M extends keyof BrainyAugmentations.ICognitionAugmentation & string,
|
||||
R extends BrainyAugmentations.ICognitionAugmentation[M] extends (
|
||||
...args: any[]
|
||||
) => AugmentationResponse<infer U>
|
||||
? U
|
||||
: never
|
||||
>(
|
||||
method: M,
|
||||
args: Parameters<
|
||||
Extract<
|
||||
BrainyAugmentations.ICognitionAugmentation[M],
|
||||
(...args: any[]) => any
|
||||
>
|
||||
>,
|
||||
options: PipelineOptions = {}
|
||||
): Promise<Promise<{ success: boolean; data: R; error?: string }>[]> {
|
||||
return this.cortexInstance.executeCognitionPipeline(method, args, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute memory pipeline (delegates to Cortex)
|
||||
*/
|
||||
public async executeMemoryPipeline<
|
||||
M extends keyof BrainyAugmentations.IMemoryAugmentation & string,
|
||||
R extends BrainyAugmentations.IMemoryAugmentation[M] extends (
|
||||
...args: any[]
|
||||
) => AugmentationResponse<infer U>
|
||||
? U
|
||||
: never
|
||||
>(
|
||||
method: M,
|
||||
args: Parameters<
|
||||
Extract<
|
||||
BrainyAugmentations.IMemoryAugmentation[M],
|
||||
(...args: any[]) => any
|
||||
>
|
||||
>,
|
||||
options: PipelineOptions = {}
|
||||
): Promise<Promise<{ success: boolean; data: R; error?: string }>[]> {
|
||||
return this.cortexInstance.executeMemoryPipeline(method, args, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute perception pipeline (delegates to Cortex)
|
||||
*/
|
||||
public async executePerceptionPipeline<
|
||||
M extends keyof BrainyAugmentations.IPerceptionAugmentation & string,
|
||||
R extends BrainyAugmentations.IPerceptionAugmentation[M] extends (
|
||||
...args: any[]
|
||||
) => AugmentationResponse<infer U>
|
||||
? U
|
||||
: never
|
||||
>(
|
||||
method: M,
|
||||
args: Parameters<
|
||||
Extract<
|
||||
BrainyAugmentations.IPerceptionAugmentation[M],
|
||||
(...args: any[]) => any
|
||||
>
|
||||
>,
|
||||
options: PipelineOptions = {}
|
||||
): Promise<Promise<{ success: boolean; data: R; error?: string }>[]> {
|
||||
return this.cortexInstance.executePerceptionPipeline(method, args, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute dialog pipeline (delegates to Cortex)
|
||||
*/
|
||||
public async executeDialogPipeline<
|
||||
M extends keyof BrainyAugmentations.IDialogAugmentation & string,
|
||||
R extends BrainyAugmentations.IDialogAugmentation[M] extends (
|
||||
...args: any[]
|
||||
) => AugmentationResponse<infer U>
|
||||
? U
|
||||
: never
|
||||
>(
|
||||
method: M,
|
||||
args: Parameters<
|
||||
Extract<
|
||||
BrainyAugmentations.IDialogAugmentation[M],
|
||||
(...args: any[]) => any
|
||||
>
|
||||
>,
|
||||
options: PipelineOptions = {}
|
||||
): Promise<Promise<{ success: boolean; data: R; error?: string }>[]> {
|
||||
return this.cortexInstance.executeDialogPipeline(method, args, options)
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute activation pipeline (delegates to Cortex)
|
||||
*/
|
||||
public async executeActivationPipeline<
|
||||
M extends keyof BrainyAugmentations.IActivationAugmentation & string,
|
||||
R extends BrainyAugmentations.IActivationAugmentation[M] extends (
|
||||
...args: any[]
|
||||
) => AugmentationResponse<infer U>
|
||||
? U
|
||||
: never
|
||||
>(
|
||||
method: M,
|
||||
args: Parameters<
|
||||
Extract<
|
||||
BrainyAugmentations.IActivationAugmentation[M],
|
||||
(...args: any[]) => any
|
||||
>
|
||||
>,
|
||||
options: PipelineOptions = {}
|
||||
): Promise<Promise<{ success: boolean; data: R; error?: string }>[]> {
|
||||
return this.cortexInstance.executeActivationPipeline(method, args, options)
|
||||
}
|
||||
|
||||
// Additional delegation methods for full compatibility
|
||||
public async initialize(): Promise<void> {
|
||||
return this.cortexInstance.initialize()
|
||||
}
|
||||
|
||||
public async shutDown(): Promise<void> {
|
||||
return this.cortexInstance.shutDown()
|
||||
}
|
||||
|
||||
public getAllAugmentations(): IAugmentation[] {
|
||||
return this.cortexInstance.getAllAugmentations()
|
||||
}
|
||||
|
||||
public enableAugmentation(name: string): boolean {
|
||||
return this.cortexInstance.enableAugmentation(name)
|
||||
}
|
||||
|
||||
public disableAugmentation(name: string): boolean {
|
||||
return this.cortexInstance.disableAugmentation(name)
|
||||
}
|
||||
|
||||
public isAugmentationEnabled(name: string): boolean {
|
||||
return this.cortexInstance.isAugmentationEnabled(name)
|
||||
}
|
||||
}
|
||||
|
||||
// Create single global Pipeline instance that delegates to Cortex
|
||||
export const pipeline = new Pipeline()
|
||||
|
||||
// Backward compatibility exports
|
||||
export const augmentationPipeline = pipeline
|
||||
|
||||
// Streamlined execution functions - delegate to cortex
|
||||
export const executeStreamlined = cortex.executeSensePipeline.bind(cortex)
|
||||
export const executeByType = cortex.executeTypedPipeline.bind(cortex)
|
||||
export const executeSingle = cortex.executeSingle.bind(cortex)
|
||||
export const processStaticData = cortex.processStaticData.bind(cortex)
|
||||
export const processStreamingData = cortex.processStreamingData.bind(cortex)
|
||||
|
||||
// Factory functions
|
||||
export const createPipeline = <T, R>() => new Pipeline()
|
||||
export const createStreamingPipeline = <T, R>() => new Pipeline()
|
||||
|
||||
// Backward compatibility type aliases
|
||||
// Execution mode alias
|
||||
export enum StreamlinedExecutionMode {
|
||||
SEQUENTIAL = 'sequential',
|
||||
PARALLEL = 'parallel',
|
||||
PARALLEL = 'parallel',
|
||||
FIRST_SUCCESS = 'firstSuccess',
|
||||
FIRST_RESULT = 'firstResult',
|
||||
THREADED = 'threaded'
|
||||
}
|
||||
|
||||
export type StreamlinedPipelineOptions = PipelineOptions
|
||||
export type StreamlinedPipelineResult<T> = PipelineResult<T>
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue