brainy/.recovery-workspace/dist-backup-20250910-141917/worker.js
David Snelling 8ff382ca3b chore: recovery checkpoint - v3.0 API successfully recovered
CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB

Recovery Status:
- Successfully recovered brainy.ts from compiled JavaScript
- All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.)
- Neural subsystem intact (562KB embedded patterns, NLP working)
- Augmentation pipeline operational (20+ augmentations)
- HNSW clustering system complete
- Triple Intelligence compiled (needs constructor fix)
- Test suite validates functionality

Changes preserved:
- 898 files with changes from last 3 days
- 144,475 insertions
- All augmentation improvements
- All test coverage enhancements
- Complete v3.0 feature set

This is a LOCAL checkpoint only - contains recovered work after corruption incident.
Created backup in .backups/brainy-full-20250910-151314.tar.gz

Branch: recovery-checkpoint-20250910-151433
Date: Wed Sep 10 03:18:04 PM PDT 2025
2025-09-10 15:18:04 -07:00

54 lines
No EOL
2.3 KiB
JavaScript

// Brainy Worker Script
// This script is used by the workerUtils.js file to execute functions in a separate thread
// Note: TensorFlow.js platform patch is applied in setup.ts
// Worker scripts should import setup.ts if they need TensorFlow.js functionality
// Log that the worker has started
console.log('Brainy Worker: Started');
// Define the message handler with proper TypeScript typing
self.onmessage = function (e) {
try {
console.log('Brainy Worker: Received message', e.data ? 'with data' : 'without data');
if (!e.data || !e.data.fnString) {
throw new Error('Invalid message: missing function string');
}
console.log('Brainy Worker: Creating function from string');
// Use Function constructor to create a function from the string
let fn;
try {
// First try with 'return' prefix
fn = new Function('return ' + e.data.fnString)();
}
catch (functionError) {
console.warn('Brainy Worker: Error creating function with return syntax, trying alternative approaches', functionError);
try {
// Try wrapping in parentheses for function expressions
fn = new Function('return (' + e.data.fnString + ')')();
}
catch (wrapError) {
console.warn('Brainy Worker: Error creating function with parentheses wrapping', wrapError);
try {
// Try direct approach for named functions
fn = new Function(e.data.fnString)();
}
catch (directError) {
console.error('Brainy Worker: All approaches to create function failed', directError);
throw new Error('Failed to create function from string: ' +
functionError.message);
}
}
}
console.log('Brainy Worker: Executing function with args');
const result = fn(e.data.args);
console.log('Brainy Worker: Function executed successfully, posting result');
self.postMessage({ result: result });
}
catch (error) {
console.error('Brainy Worker: Error executing function', error);
self.postMessage({
error: error.message,
stack: error.stack
});
}
};
export {};
//# sourceMappingURL=worker.js.map