tasq/node_modules/@claude-flow/embeddings/dist/neural-integration.d.ts

203 lines
5.2 KiB
TypeScript

/**
* Neural Substrate Integration
*
* Integrates agentic-flow's neural embedding features:
* - Semantic drift detection
* - Memory physics (hippocampal dynamics)
* - Embedding state machine
* - Swarm coordination
* - Coherence monitoring
*
* These features treat embeddings as a synthetic nervous system.
*/
export interface DriftResult {
distance: number;
velocity: number;
acceleration: number;
trend: 'stable' | 'drifting' | 'accelerating' | 'recovering';
shouldEscalate: boolean;
shouldTriggerReasoning: boolean;
}
export interface MemoryEntry {
id: string;
embedding: Float32Array;
content: string;
strength: number;
timestamp: number;
accessCount: number;
associations: string[];
}
export interface AgentState {
id: string;
position: Float32Array;
velocity: Float32Array;
attention: Float32Array;
energy: number;
lastUpdate: number;
}
export interface CoherenceResult {
isCoherent: boolean;
anomalyScore: number;
stabilityScore: number;
driftDirection: Float32Array | null;
warnings: string[];
}
export interface SubstrateHealth {
memoryCount: number;
activeAgents: number;
avgDrift: number;
avgCoherence: number;
lastConsolidation: number;
uptime: number;
}
export interface NeuralSubstrateConfig {
dimension?: number;
driftThreshold?: number;
decayRate?: number;
}
/**
* Lazy-loaded Neural Substrate wrapper
*
* Wraps agentic-flow's NeuralSubstrate with graceful fallback
*/
export declare class NeuralEmbeddingService {
private config;
private substrate;
private initialized;
private available;
constructor(config?: NeuralSubstrateConfig);
/**
* Initialize neural substrate
*/
init(): Promise<boolean>;
/**
* Check if neural features are available
*/
isAvailable(): boolean;
/**
* Detect semantic drift from baseline
*/
detectDrift(input: string): Promise<DriftResult | null>;
/**
* Set baseline for drift detection
*/
setDriftBaseline(context: string): Promise<void>;
/**
* Store memory with interference detection
*/
storeMemory(id: string, content: string): Promise<{
stored: boolean;
interference: string[];
} | null>;
/**
* Recall memories by similarity
*/
recallMemories(query: string, topK?: number): Promise<Array<MemoryEntry & {
relevance: number;
}> | null>;
/**
* Consolidate memories (merge similar, forget weak)
*/
consolidateMemories(): {
merged: number;
forgotten: number;
remaining: number;
} | null;
/**
* Register agent for state tracking
*/
registerAgent(id: string, role: string): Promise<AgentState | null>;
/**
* Update agent state based on observation
*/
updateAgentState(agentId: string, observation: string): Promise<{
newState: AgentState;
nearestRegion: string;
regionProximity: number;
} | null>;
/**
* Get agent state
*/
getAgentState(agentId: string): AgentState | null;
/**
* Coordinate swarm for task
*/
coordinateSwarm(task: string): Promise<Array<{
agentId: string;
taskAlignment: number;
bestCollaborator: string | null;
collaborationScore: number;
}> | null>;
/**
* Add agent to swarm
*/
addSwarmAgent(id: string, role: string): Promise<AgentState | null>;
/**
* Calibrate coherence monitor
*/
calibrateCoherence(goodOutputs: string[]): Promise<{
calibrated: boolean;
sampleCount: number;
} | null>;
/**
* Check output coherence
*/
checkCoherence(output: string): Promise<CoherenceResult | null>;
/**
* Process input through full neural substrate
*/
process(input: string, context?: {
agentId?: string;
memoryId?: string;
checkCoherence?: boolean;
}): Promise<{
drift: DriftResult;
state?: {
nearestRegion: string;
regionProximity: number;
};
coherence?: CoherenceResult;
stored?: boolean;
} | null>;
/**
* Get substrate health
*/
health(): SubstrateHealth | null;
/**
* Full consolidation pass
*/
consolidate(): {
memory: {
merged: number;
forgotten: number;
remaining: number;
};
} | null;
}
/**
* Create neural embedding service
*/
export declare function createNeuralService(config?: NeuralSubstrateConfig): NeuralEmbeddingService;
/**
* Check if neural features are available
*/
export declare function isNeuralAvailable(): Promise<boolean>;
/**
* List available ONNX embedding models
*/
export declare function listEmbeddingModels(): Promise<Array<{
id: string;
dimension: number;
size: string;
quantized: boolean;
downloaded: boolean;
}>>;
/**
* Download embedding model
*/
export declare function downloadEmbeddingModel(modelId: string, targetDir?: string, onProgress?: (progress: {
percent: number;
bytesDownloaded: number;
totalBytes: number;
}) => void): Promise<string>;
//# sourceMappingURL=neural-integration.d.ts.map