@soulcraft/brainy 3.20.1 → 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.
Files changed (91) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/bin/brainy-interactive.js +2 -2
  3. package/dist/brainy.d.ts +1 -1
  4. package/dist/mcp/brainyMCPAdapter.d.ts +1 -1
  5. package/dist/mcp/brainyMCPService.d.ts +1 -1
  6. package/dist/neural/embeddedPatterns.d.ts +1 -1
  7. package/dist/neural/embeddedPatterns.js +1 -1
  8. package/dist/shared/default-augmentations.d.ts +1 -1
  9. package/dist/types/{brainyDataInterface.js → brainyInterface.js} +1 -1
  10. package/dist/vfs/VirtualFileSystem.d.ts +1 -0
  11. package/dist/vfs/VirtualFileSystem.js +108 -69
  12. package/package.json +1 -1
  13. package/dist/augmentationFactory.d.ts +0 -86
  14. package/dist/augmentationFactory.js +0 -342
  15. package/dist/augmentationRegistry.d.ts +0 -38
  16. package/dist/augmentationRegistry.js +0 -54
  17. package/dist/augmentationRegistryLoader.d.ts +0 -146
  18. package/dist/augmentationRegistryLoader.js +0 -213
  19. package/dist/augmentations/KnowledgeAugmentation.d.ts +0 -40
  20. package/dist/augmentations/KnowledgeAugmentation.js +0 -251
  21. package/dist/augmentations/intelligentVerbScoring.d.ts +0 -158
  22. package/dist/augmentations/intelligentVerbScoring.js +0 -377
  23. package/dist/augmentations/marketplace/AugmentationMarketplace.d.ts +0 -168
  24. package/dist/augmentations/marketplace/AugmentationMarketplace.js +0 -329
  25. package/dist/augmentations/marketplace/cli.d.ts +0 -47
  26. package/dist/augmentations/marketplace/cli.js +0 -265
  27. package/dist/augmentations/memoryAugmentations.d.ts +0 -72
  28. package/dist/augmentations/memoryAugmentations.js +0 -280
  29. package/dist/augmentations/serverSearchAugmentations.d.ts +0 -190
  30. package/dist/augmentations/serverSearchAugmentations.js +0 -586
  31. package/dist/brainy-unified.d.ts +0 -106
  32. package/dist/brainy-unified.js +0 -327
  33. package/dist/brainyData.d.ts +0 -1832
  34. package/dist/brainyData.js +0 -6443
  35. package/dist/brainyDataV3.d.ts +0 -186
  36. package/dist/brainyDataV3.js +0 -337
  37. package/dist/config/distributedPresets-new.d.ts +0 -118
  38. package/dist/config/distributedPresets-new.js +0 -318
  39. package/dist/config/modelPrecisionManager.d.ts +0 -42
  40. package/dist/config/modelPrecisionManager.js +0 -98
  41. package/dist/connectors/interfaces/IConnector.d.ts +0 -143
  42. package/dist/connectors/interfaces/IConnector.js +0 -8
  43. package/dist/demo.d.ts +0 -106
  44. package/dist/demo.js +0 -201
  45. package/dist/embeddings/SingletonModelManager.d.ts +0 -95
  46. package/dist/embeddings/SingletonModelManager.js +0 -220
  47. package/dist/embeddings/lightweight-embedder.d.ts +0 -22
  48. package/dist/embeddings/lightweight-embedder.js +0 -128
  49. package/dist/embeddings/model-manager.d.ts +0 -39
  50. package/dist/embeddings/model-manager.js +0 -245
  51. package/dist/embeddings/universal-memory-manager.d.ts +0 -38
  52. package/dist/embeddings/universal-memory-manager.js +0 -166
  53. package/dist/embeddings/worker-embedding.d.ts +0 -7
  54. package/dist/embeddings/worker-embedding.js +0 -73
  55. package/dist/embeddings/worker-manager.d.ts +0 -28
  56. package/dist/embeddings/worker-manager.js +0 -162
  57. package/dist/examples/basicUsage.d.ts +0 -4
  58. package/dist/examples/basicUsage.js +0 -121
  59. package/dist/indices/fieldIndex.d.ts +0 -76
  60. package/dist/indices/fieldIndex.js +0 -357
  61. package/dist/mcp/brainyMCPBroadcast.d.ts +0 -82
  62. package/dist/mcp/brainyMCPBroadcast.js +0 -303
  63. package/dist/mcp/brainyMCPClient.d.ts +0 -92
  64. package/dist/mcp/brainyMCPClient.js +0 -258
  65. package/dist/scripts/precomputePatternEmbeddings.d.ts +0 -19
  66. package/dist/scripts/precomputePatternEmbeddings.js +0 -100
  67. package/dist/utils/cacheAutoConfig.d.ts +0 -63
  68. package/dist/utils/cacheAutoConfig.js +0 -261
  69. package/dist/utils/hybridModelManager.d.ts +0 -64
  70. package/dist/utils/hybridModelManager.js +0 -95
  71. package/dist/utils/statistics.d.ts +0 -28
  72. package/dist/utils/statistics.js +0 -25
  73. package/dist/vfs/ConceptSystem.d.ts +0 -203
  74. package/dist/vfs/ConceptSystem.js +0 -545
  75. package/dist/vfs/EntityManager.d.ts +0 -75
  76. package/dist/vfs/EntityManager.js +0 -216
  77. package/dist/vfs/EventRecorder.d.ts +0 -84
  78. package/dist/vfs/EventRecorder.js +0 -269
  79. package/dist/vfs/GitBridge.d.ts +0 -167
  80. package/dist/vfs/GitBridge.js +0 -537
  81. package/dist/vfs/KnowledgeAugmentation.d.ts +0 -104
  82. package/dist/vfs/KnowledgeAugmentation.js +0 -146
  83. package/dist/vfs/KnowledgeLayer.d.ts +0 -35
  84. package/dist/vfs/KnowledgeLayer.js +0 -443
  85. package/dist/vfs/PersistentEntitySystem.d.ts +0 -165
  86. package/dist/vfs/PersistentEntitySystem.js +0 -503
  87. package/dist/vfs/SemanticVersioning.d.ts +0 -105
  88. package/dist/vfs/SemanticVersioning.js +0 -309
  89. package/dist/vfs/VFSHealthCheck.d.ts +0 -78
  90. package/dist/vfs/VFSHealthCheck.js +0 -299
  91. /package/dist/types/{brainyDataInterface.d.ts → brainyInterface.d.ts} +0 -0
@@ -1,213 +0,0 @@
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 { registerAugmentation } from './augmentationRegistry.js';
9
- /**
10
- * Default options for the augmentation registry loader
11
- */
12
- const DEFAULT_OPTIONS = {
13
- autoInitialize: false,
14
- debug: false
15
- };
16
- /**
17
- * Loads augmentations from the specified modules
18
- *
19
- * This function is designed to be used with build tools like webpack or rollup
20
- * to automatically discover and register augmentations.
21
- *
22
- * @param modules An object containing modules with augmentations to register
23
- * @param options Options for the loader
24
- * @returns A promise that resolves with the result of loading the augmentations
25
- *
26
- * @example
27
- * ```typescript
28
- * // webpack.config.js
29
- * const { AugmentationRegistryPlugin } = require('brainy/dist/webpack');
30
- *
31
- * module.exports = {
32
- * // ... other webpack config
33
- * plugins: [
34
- * new AugmentationRegistryPlugin({
35
- * // Pattern to match files containing augmentations
36
- * pattern: /augmentation\.js$/,
37
- * // Options for the loader
38
- * options: {
39
- * autoInitialize: true,
40
- * debug: true
41
- * }
42
- * })
43
- * ]
44
- * };
45
- * ```
46
- */
47
- export async function loadAugmentationsFromModules(modules, options = {}) {
48
- const opts = { ...DEFAULT_OPTIONS, ...options };
49
- const result = {
50
- augmentations: [],
51
- errors: []
52
- };
53
- if (opts.debug) {
54
- console.log(`[AugmentationRegistryLoader] Loading augmentations from ${Object.keys(modules).length} modules`);
55
- }
56
- // Process each module
57
- for (const [modulePath, module] of Object.entries(modules)) {
58
- try {
59
- if (opts.debug) {
60
- console.log(`[AugmentationRegistryLoader] Processing module: ${modulePath}`);
61
- }
62
- // Extract augmentations from the module
63
- const augmentations = extractAugmentationsFromModule(module);
64
- if (augmentations.length === 0) {
65
- if (opts.debug) {
66
- console.log(`[AugmentationRegistryLoader] No augmentations found in module: ${modulePath}`);
67
- }
68
- continue;
69
- }
70
- // Register each augmentation
71
- for (const augmentation of augmentations) {
72
- try {
73
- const registered = registerAugmentation(augmentation);
74
- result.augmentations.push(registered);
75
- if (opts.debug) {
76
- console.log(`[AugmentationRegistryLoader] Registered augmentation: ${registered.name}`);
77
- }
78
- }
79
- catch (error) {
80
- const err = error instanceof Error ? error : new Error(String(error));
81
- result.errors.push(err);
82
- if (opts.debug) {
83
- console.error(`[AugmentationRegistryLoader] Failed to register augmentation: ${err.message}`);
84
- }
85
- }
86
- }
87
- }
88
- catch (error) {
89
- const err = error instanceof Error ? error : new Error(String(error));
90
- result.errors.push(err);
91
- if (opts.debug) {
92
- console.error(`[AugmentationRegistryLoader] Error processing module ${modulePath}: ${err.message}`);
93
- }
94
- }
95
- }
96
- if (opts.debug) {
97
- console.log(`[AugmentationRegistryLoader] Loaded ${result.augmentations.length} augmentations with ${result.errors.length} errors`);
98
- }
99
- return result;
100
- }
101
- /**
102
- * Extracts augmentations from a module
103
- *
104
- * @param module The module to extract augmentations from
105
- * @returns An array of augmentations found in the module
106
- */
107
- function extractAugmentationsFromModule(module) {
108
- const augmentations = [];
109
- // If the module itself is an augmentation, add it
110
- if (isAugmentation(module)) {
111
- augmentations.push(module);
112
- }
113
- // Check for exported augmentations
114
- if (module && typeof module === 'object') {
115
- for (const key of Object.keys(module)) {
116
- const exported = module[key];
117
- // Skip non-objects and null
118
- if (!exported || typeof exported !== 'object') {
119
- continue;
120
- }
121
- // If the exported value is an augmentation, add it
122
- if (isAugmentation(exported)) {
123
- augmentations.push(exported);
124
- }
125
- // If the exported value is an array of augmentations, add them
126
- if (Array.isArray(exported) && exported.every(isAugmentation)) {
127
- augmentations.push(...exported);
128
- }
129
- }
130
- }
131
- return augmentations;
132
- }
133
- /**
134
- * Checks if an object is an augmentation
135
- *
136
- * @param obj The object to check
137
- * @returns True if the object is an augmentation
138
- */
139
- function isAugmentation(obj) {
140
- return (obj &&
141
- typeof obj === 'object' &&
142
- typeof obj.name === 'string' &&
143
- typeof obj.initialize === 'function' &&
144
- typeof obj.shutDown === 'function' &&
145
- typeof obj.getStatus === 'function');
146
- }
147
- /**
148
- * Creates a webpack plugin for automatically loading augmentations
149
- *
150
- * @param options Options for the plugin
151
- * @returns A webpack plugin
152
- *
153
- * @example
154
- * ```typescript
155
- * // webpack.config.js
156
- * const { createAugmentationRegistryPlugin } = require('brainy/dist/webpack');
157
- *
158
- * module.exports = {
159
- * // ... other webpack config
160
- * plugins: [
161
- * createAugmentationRegistryPlugin({
162
- * pattern: /augmentation\.js$/,
163
- * options: {
164
- * autoInitialize: true,
165
- * debug: true
166
- * }
167
- * })
168
- * ]
169
- * };
170
- * ```
171
- */
172
- export function createAugmentationRegistryPlugin(options) {
173
- // This is just a placeholder - the actual implementation would depend on the build tool
174
- return {
175
- name: 'AugmentationRegistryPlugin',
176
- pattern: options.pattern,
177
- options: options.options || {}
178
- };
179
- }
180
- /**
181
- * Creates a rollup plugin for automatically loading augmentations
182
- *
183
- * @param options Options for the plugin
184
- * @returns A rollup plugin
185
- *
186
- * @example
187
- * ```typescript
188
- * // rollup.config.js
189
- * import { createAugmentationRegistryRollupPlugin } from 'brainy/dist/rollup';
190
- *
191
- * export default {
192
- * // ... other rollup config
193
- * plugins: [
194
- * createAugmentationRegistryRollupPlugin({
195
- * pattern: /augmentation\.js$/,
196
- * options: {
197
- * autoInitialize: true,
198
- * debug: true
199
- * }
200
- * })
201
- * ]
202
- * };
203
- * ```
204
- */
205
- export function createAugmentationRegistryRollupPlugin(options) {
206
- // This is just a placeholder - the actual implementation would depend on the build tool
207
- return {
208
- name: 'augmentation-registry-rollup-plugin',
209
- pattern: options.pattern,
210
- options: options.options || {}
211
- };
212
- }
213
- //# sourceMappingURL=augmentationRegistryLoader.js.map
@@ -1,40 +0,0 @@
1
- /**
2
- * Knowledge Layer Augmentation for VFS
3
- *
4
- * Adds intelligent features to VFS without modifying core functionality:
5
- * - Event recording for all operations
6
- * - Semantic versioning based on content changes
7
- * - Entity and concept extraction
8
- * - Git bridge for import/export
9
- *
10
- * This is a TRUE augmentation - VFS works perfectly without it
11
- */
12
- import { Brainy } from '../brainy.js';
13
- import { BaseAugmentation } from './brainyAugmentation.js';
14
- export declare class KnowledgeAugmentation extends BaseAugmentation {
15
- name: string;
16
- timing: 'after';
17
- metadata: 'none';
18
- operations: any;
19
- priority: number;
20
- constructor(config?: any);
21
- execute<T = any>(operation: string, params: any, next: () => Promise<T>): Promise<T>;
22
- private eventRecorder?;
23
- private semanticVersioning?;
24
- private entitySystem?;
25
- private conceptSystem?;
26
- private gitBridge?;
27
- private originalMethods;
28
- initialize(context: any): Promise<void>;
29
- augment(brain: Brainy): Promise<void>;
30
- /**
31
- * Wrap a VFS method to add Knowledge Layer functionality
32
- */
33
- private wrapMethod;
34
- /**
35
- * Add Knowledge Layer methods to VFS
36
- */
37
- private addKnowledgeMethods;
38
- private isSemanticChange;
39
- cleanup(brain: Brainy): Promise<void>;
40
- }
@@ -1,251 +0,0 @@
1
- /**
2
- * Knowledge Layer Augmentation for VFS
3
- *
4
- * Adds intelligent features to VFS without modifying core functionality:
5
- * - Event recording for all operations
6
- * - Semantic versioning based on content changes
7
- * - Entity and concept extraction
8
- * - Git bridge for import/export
9
- *
10
- * This is a TRUE augmentation - VFS works perfectly without it
11
- */
12
- import { BaseAugmentation } from './brainyAugmentation.js';
13
- import { EventRecorder } from '../vfs/EventRecorder.js';
14
- import { SemanticVersioning } from '../vfs/SemanticVersioning.js';
15
- import { PersistentEntitySystem } from '../vfs/PersistentEntitySystem.js';
16
- import { ConceptSystem } from '../vfs/ConceptSystem.js';
17
- import { GitBridge } from '../vfs/GitBridge.js';
18
- export class KnowledgeAugmentation extends BaseAugmentation {
19
- constructor(config = {}) {
20
- super(config);
21
- this.name = 'knowledge';
22
- this.timing = 'after'; // Process after VFS operations
23
- this.metadata = 'none'; // No metadata access needed
24
- this.operations = []; // VFS-specific augmentation, no operation interception
25
- this.priority = 100; // Run last
26
- this.originalMethods = new Map();
27
- }
28
- async execute(operation, params, next) {
29
- // Pass through - this augmentation works at VFS level, not operation level
30
- return await next();
31
- }
32
- async initialize(context) {
33
- await this.augment(context.brain);
34
- }
35
- async augment(brain) {
36
- // Only augment if VFS exists
37
- const vfs = brain.vfs?.();
38
- if (!vfs) {
39
- console.warn('KnowledgeAugmentation: VFS not found, skipping');
40
- return;
41
- }
42
- // Initialize Knowledge Layer components
43
- this.eventRecorder = new EventRecorder(brain);
44
- this.semanticVersioning = new SemanticVersioning(brain);
45
- this.entitySystem = new PersistentEntitySystem(brain);
46
- this.conceptSystem = new ConceptSystem(brain);
47
- this.gitBridge = new GitBridge(vfs, brain);
48
- // Wrap VFS methods to add intelligence WITHOUT slowing them down
49
- this.wrapMethod(vfs, 'writeFile', async (original, path, data, options) => {
50
- // Call original first (stays fast)
51
- const result = await original.call(vfs, path, data, options);
52
- // Knowledge processing in background (non-blocking)
53
- setImmediate(async () => {
54
- try {
55
- // Record event
56
- if (this.eventRecorder) {
57
- await this.eventRecorder.recordEvent({
58
- type: 'write',
59
- path,
60
- content: data,
61
- size: data.length,
62
- author: options?.author || 'system'
63
- });
64
- }
65
- // Check for semantic versioning
66
- if (this.semanticVersioning) {
67
- const existingContent = await vfs.readFile(path).catch(() => null);
68
- const shouldVersion = existingContent && this.isSemanticChange(existingContent, data);
69
- if (shouldVersion) {
70
- await this.semanticVersioning.createVersion(path, data, {
71
- message: 'Automatic semantic version'
72
- });
73
- }
74
- }
75
- // Extract concepts
76
- if (this.conceptSystem && options?.extractConcepts !== false) {
77
- await this.conceptSystem.extractAndLinkConcepts(path, data);
78
- }
79
- // Extract entities
80
- if (this.entitySystem && options?.extractEntities !== false) {
81
- await this.entitySystem.extractEntities(data.toString('utf8'), data);
82
- }
83
- }
84
- catch (error) {
85
- // Knowledge Layer errors should not affect VFS operations
86
- console.debug('KnowledgeLayer background processing error:', error);
87
- }
88
- });
89
- return result;
90
- });
91
- this.wrapMethod(vfs, 'unlink', async (original, path) => {
92
- const result = await original.call(vfs, path);
93
- // Record deletion event
94
- setImmediate(async () => {
95
- if (this.eventRecorder) {
96
- await this.eventRecorder.recordEvent({
97
- type: 'delete',
98
- path,
99
- author: 'system'
100
- });
101
- }
102
- });
103
- return result;
104
- });
105
- this.wrapMethod(vfs, 'rename', async (original, oldPath, newPath) => {
106
- const result = await original.call(vfs, oldPath, newPath);
107
- // Record rename event
108
- setImmediate(async () => {
109
- if (this.eventRecorder) {
110
- await this.eventRecorder.recordEvent({
111
- type: 'rename',
112
- path: oldPath,
113
- metadata: { newPath },
114
- author: 'system'
115
- });
116
- }
117
- });
118
- return result;
119
- });
120
- // Add Knowledge Layer methods to VFS
121
- this.addKnowledgeMethods(vfs);
122
- console.log('✨ Knowledge Layer augmentation enabled');
123
- }
124
- /**
125
- * Wrap a VFS method to add Knowledge Layer functionality
126
- */
127
- wrapMethod(vfs, methodName, wrapper) {
128
- const original = vfs[methodName];
129
- if (!original)
130
- return;
131
- // Store original for cleanup
132
- this.originalMethods.set(methodName, original);
133
- // Replace with wrapped version
134
- vfs[methodName] = async (...args) => {
135
- return await wrapper(original, ...args);
136
- };
137
- }
138
- /**
139
- * Add Knowledge Layer methods to VFS
140
- */
141
- addKnowledgeMethods(vfs) {
142
- // Event history
143
- vfs.getHistory = async (path, options) => {
144
- if (!this.eventRecorder)
145
- throw new Error('Knowledge Layer not initialized');
146
- return await this.eventRecorder.getHistory(path, options);
147
- };
148
- vfs.reconstructAtTime = async (path, timestamp) => {
149
- if (!this.eventRecorder)
150
- throw new Error('Knowledge Layer not initialized');
151
- return await this.eventRecorder.reconstructFileAtTime(path, timestamp);
152
- };
153
- // Semantic versioning
154
- vfs.getVersions = async (path) => {
155
- if (!this.semanticVersioning)
156
- throw new Error('Knowledge Layer not initialized');
157
- return await this.semanticVersioning.getVersions(path);
158
- };
159
- vfs.restoreVersion = async (path, versionId) => {
160
- if (!this.semanticVersioning)
161
- throw new Error('Knowledge Layer not initialized');
162
- const version = await this.semanticVersioning.getVersion(path, versionId);
163
- if (version) {
164
- await vfs.writeFile(path, version);
165
- }
166
- };
167
- // Entities
168
- vfs.findEntity = async (query) => {
169
- if (!this.entitySystem)
170
- throw new Error('Knowledge Layer not initialized');
171
- return await this.entitySystem.findEntity(query);
172
- };
173
- vfs.getEntityAppearances = async (entityId) => {
174
- if (!this.entitySystem)
175
- throw new Error('Knowledge Layer not initialized');
176
- return await this.entitySystem.getEvolution(entityId);
177
- };
178
- // Concepts
179
- vfs.getConcepts = async (path) => {
180
- if (!this.conceptSystem)
181
- throw new Error('Knowledge Layer not initialized');
182
- const concepts = await this.conceptSystem.findConcepts({ manifestedIn: path });
183
- return concepts;
184
- };
185
- vfs.getConceptGraph = async (options) => {
186
- if (!this.conceptSystem)
187
- throw new Error('Knowledge Layer not initialized');
188
- return await this.conceptSystem.getConceptGraph(options);
189
- };
190
- // Git bridge
191
- vfs.exportToGit = async (vfsPath, gitPath) => {
192
- if (!this.gitBridge)
193
- throw new Error('Knowledge Layer not initialized');
194
- return await this.gitBridge.exportToGit(vfsPath, gitPath);
195
- };
196
- vfs.importFromGit = async (gitPath, vfsPath) => {
197
- if (!this.gitBridge)
198
- throw new Error('Knowledge Layer not initialized');
199
- return await this.gitBridge.importFromGit(gitPath, vfsPath);
200
- };
201
- // Temporal coupling
202
- vfs.findTemporalCoupling = async (path, windowMs) => {
203
- if (!this.eventRecorder)
204
- throw new Error('Knowledge Layer not initialized');
205
- return await this.eventRecorder.findTemporalCoupling(path, windowMs);
206
- };
207
- }
208
- isSemanticChange(oldContent, newContent) {
209
- // Simple heuristic - significant size change or different content
210
- const oldStr = oldContent.toString('utf8');
211
- const newStr = newContent.toString('utf8');
212
- // Check for significant size change (>10%)
213
- const sizeDiff = Math.abs(oldStr.length - newStr.length) / oldStr.length;
214
- if (sizeDiff > 0.1)
215
- return true;
216
- // Check for structural changes (simplified)
217
- const oldLines = oldStr.split('\n').filter(l => l.trim());
218
- const newLines = newStr.split('\n').filter(l => l.trim());
219
- // Different number of non-empty lines
220
- return Math.abs(oldLines.length - newLines.length) > 5;
221
- }
222
- async cleanup(brain) {
223
- const vfs = brain.vfs?.();
224
- if (!vfs)
225
- return;
226
- // Restore original methods
227
- for (const [methodName, original] of this.originalMethods) {
228
- vfs[methodName] = original;
229
- }
230
- // Remove added methods
231
- delete vfs.getHistory;
232
- delete vfs.reconstructAtTime;
233
- delete vfs.getVersions;
234
- delete vfs.restoreVersion;
235
- delete vfs.findEntity;
236
- delete vfs.getEntityAppearances;
237
- delete vfs.getConcepts;
238
- delete vfs.getConceptGraph;
239
- delete vfs.exportToGit;
240
- delete vfs.importFromGit;
241
- delete vfs.findTemporalCoupling;
242
- // Clean up components
243
- this.eventRecorder = undefined;
244
- this.semanticVersioning = undefined;
245
- this.entitySystem = undefined;
246
- this.conceptSystem = undefined;
247
- this.gitBridge = undefined;
248
- console.log('Knowledge Layer augmentation removed');
249
- }
250
- }
251
- //# sourceMappingURL=KnowledgeAugmentation.js.map
@@ -1,158 +0,0 @@
1
- import { ICognitionAugmentation, AugmentationResponse } from '../types/augmentations.js';
2
- /**
3
- * Configuration options for the Intelligent Verb Scoring augmentation
4
- */
5
- export interface IVerbScoringConfig {
6
- /** Enable semantic proximity scoring based on entity embeddings */
7
- enableSemanticScoring: boolean;
8
- /** Enable frequency-based weight amplification */
9
- enableFrequencyAmplification: boolean;
10
- /** Enable temporal decay for weights */
11
- enableTemporalDecay: boolean;
12
- /** Decay rate per day for temporal scoring (0-1) */
13
- temporalDecayRate: number;
14
- /** Minimum weight threshold */
15
- minWeight: number;
16
- /** Maximum weight threshold */
17
- maxWeight: number;
18
- /** Base confidence score for new relationships */
19
- baseConfidence: number;
20
- /** Learning rate for adaptive scoring (0-1) */
21
- learningRate: number;
22
- }
23
- /**
24
- * Default configuration for the Intelligent Verb Scoring augmentation
25
- */
26
- export declare const DEFAULT_VERB_SCORING_CONFIG: IVerbScoringConfig;
27
- /**
28
- * Relationship statistics for learning and adaptation
29
- */
30
- interface RelationshipStats {
31
- count: number;
32
- totalWeight: number;
33
- averageWeight: number;
34
- lastSeen: Date;
35
- firstSeen: Date;
36
- semanticSimilarity?: number;
37
- }
38
- /**
39
- * Intelligent Verb Scoring Cognition Augmentation
40
- *
41
- * Automatically generates intelligent weight and confidence scores for verb relationships
42
- * using semantic analysis, frequency patterns, and temporal factors.
43
- */
44
- export declare class IntelligentVerbScoring implements ICognitionAugmentation {
45
- readonly name = "intelligent-verb-scoring";
46
- readonly description = "Automatically generates intelligent weight and confidence scores for verb relationships";
47
- enabled: boolean;
48
- private config;
49
- private relationshipStats;
50
- private brainyInstance;
51
- private isInitialized;
52
- constructor(config?: Partial<IVerbScoringConfig>);
53
- initialize(): Promise<void>;
54
- shutDown(): Promise<void>;
55
- getStatus(): Promise<'active' | 'inactive' | 'error'>;
56
- /**
57
- * Set reference to the BrainyData instance for accessing graph data
58
- */
59
- setBrainyInstance(instance: any): void;
60
- /**
61
- * Main reasoning method for generating intelligent verb scores
62
- */
63
- reason(query: string, context?: Record<string, unknown>): AugmentationResponse<{
64
- inference: string;
65
- confidence: number;
66
- }>;
67
- infer(dataSubset: Record<string, unknown>): AugmentationResponse<Record<string, unknown>>;
68
- executeLogic(ruleId: string, input: Record<string, unknown>): AugmentationResponse<boolean>;
69
- /**
70
- * Generate intelligent weight and confidence scores for a verb relationship
71
- *
72
- * @param sourceId - ID of the source entity
73
- * @param targetId - ID of the target entity
74
- * @param verbType - Type of the relationship
75
- * @param existingWeight - Existing weight if any
76
- * @param metadata - Additional metadata about the relationship
77
- * @returns Computed weight and confidence scores
78
- */
79
- computeVerbScores(sourceId: string, targetId: string, verbType: string, existingWeight?: number, metadata?: any): Promise<{
80
- weight: number;
81
- confidence: number;
82
- reasoning: string[];
83
- }>;
84
- /**
85
- * Calculate semantic similarity between two entities using their embeddings
86
- */
87
- private calculateSemanticScore;
88
- /**
89
- * Calculate frequency-based boost for repeated relationships
90
- */
91
- private calculateFrequencyBoost;
92
- /**
93
- * Calculate temporal decay factor based on recency
94
- */
95
- private calculateTemporalFactor;
96
- /**
97
- * Calculate learning-based adjustment using historical patterns
98
- */
99
- private calculateLearningAdjustment;
100
- /**
101
- * Update relationship statistics for learning
102
- */
103
- private updateRelationshipStats;
104
- /**
105
- * Blend two scores using a weighted average
106
- */
107
- private blendScores;
108
- /**
109
- * Get current configuration
110
- */
111
- getConfig(): IVerbScoringConfig;
112
- /**
113
- * Update configuration
114
- */
115
- updateConfig(newConfig: Partial<IVerbScoringConfig>): void;
116
- /**
117
- * Get relationship statistics (for debugging/monitoring)
118
- */
119
- getRelationshipStats(): Map<string, RelationshipStats>;
120
- /**
121
- * Clear relationship statistics
122
- */
123
- clearStats(): void;
124
- /**
125
- * Provide feedback to improve future scoring
126
- * This allows the system to learn from user corrections or validation
127
- *
128
- * @param sourceId - Source entity ID
129
- * @param targetId - Target entity ID
130
- * @param verbType - Relationship type
131
- * @param feedbackWeight - The corrected/validated weight (0-1)
132
- * @param feedbackConfidence - The corrected/validated confidence (0-1)
133
- * @param feedbackType - Type of feedback ('correction', 'validation', 'enhancement')
134
- */
135
- provideFeedback(sourceId: string, targetId: string, verbType: string, feedbackWeight: number, feedbackConfidence?: number, feedbackType?: 'correction' | 'validation' | 'enhancement'): Promise<void>;
136
- /**
137
- * Get learning statistics for monitoring and debugging
138
- */
139
- getLearningStats(): {
140
- totalRelationships: number;
141
- averageConfidence: number;
142
- feedbackCount: number;
143
- topRelationships: Array<{
144
- relationship: string;
145
- count: number;
146
- averageWeight: number;
147
- }>;
148
- };
149
- /**
150
- * Export learning data for backup or analysis
151
- */
152
- exportLearningData(): string;
153
- /**
154
- * Import learning data from backup
155
- */
156
- importLearningData(jsonData: string): void;
157
- }
158
- export {};