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
This commit is contained in:
parent
f65455fb22
commit
8ff382ca3b
895 changed files with 143654 additions and 28268 deletions
|
|
@ -0,0 +1,66 @@
|
|||
import { isNode } from './environment.js';
|
||||
// Simplified TextEncoder/TextDecoder utilities for Node.js compatibility
|
||||
// No longer needs complex TensorFlow.js patches - only basic TextEncoder/TextDecoder
|
||||
/**
|
||||
* Flag to track if the patch has been applied
|
||||
*/
|
||||
let patchApplied = false;
|
||||
/**
|
||||
* Apply TextEncoder/TextDecoder patches for Node.js compatibility
|
||||
* Simplified version for Transformers.js/ONNX Runtime
|
||||
*/
|
||||
export async function applyTensorFlowPatch() {
|
||||
// Apply patches for all non-browser environments that might need TextEncoder/TextDecoder
|
||||
const isBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
||||
if (isBrowserEnv || patchApplied) {
|
||||
return; // Browser environments don't need these patches, and don't patch twice
|
||||
}
|
||||
if (!isNode()) {
|
||||
return; // Only patch Node.js environments
|
||||
}
|
||||
try {
|
||||
console.log('Brainy: Applying TextEncoder/TextDecoder patch for Node.js');
|
||||
// Get the appropriate global object
|
||||
const globalObj = (() => {
|
||||
if (typeof globalThis !== 'undefined')
|
||||
return globalThis;
|
||||
if (typeof global !== 'undefined')
|
||||
return global;
|
||||
return {};
|
||||
})();
|
||||
// Make sure TextEncoder and TextDecoder are available globally
|
||||
if (!globalObj.TextEncoder) {
|
||||
globalObj.TextEncoder = TextEncoder;
|
||||
}
|
||||
if (!globalObj.TextDecoder) {
|
||||
globalObj.TextDecoder = TextDecoder;
|
||||
}
|
||||
// Also set them on the global object for older code
|
||||
if (typeof global !== 'undefined') {
|
||||
if (!global.TextEncoder) {
|
||||
global.TextEncoder = TextEncoder;
|
||||
}
|
||||
if (!global.TextDecoder) {
|
||||
global.TextDecoder = TextDecoder;
|
||||
}
|
||||
}
|
||||
patchApplied = true;
|
||||
console.log('Brainy: TextEncoder/TextDecoder patches applied successfully');
|
||||
}
|
||||
catch (error) {
|
||||
console.warn('Brainy: Failed to apply TextEncoder/TextDecoder patch:', error);
|
||||
}
|
||||
}
|
||||
export function getTextEncoder() {
|
||||
return new TextEncoder();
|
||||
}
|
||||
export function getTextDecoder() {
|
||||
return new TextDecoder();
|
||||
}
|
||||
// Apply patch immediately if in Node.js
|
||||
if (isNode()) {
|
||||
applyTensorFlowPatch().catch((error) => {
|
||||
console.warn('Failed to apply TextEncoder/TextDecoder patch at module load:', error);
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=textEncoding.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue