**chore: streamline documentation, refine shims, and update dependencies**

- **Documentation Updates**:
  - Simplified server functionality details in `README.md`, removing cloud-specific deployment sections and focusing on core features for broader usability.

- **Shim Enhancements**:
  - Improved `util` shim in `rollup.config.js` to include `TextEncoder`/`TextDecoder` support and enhanced `types` checks (e.g., `isFloat32Array`, `isUint8Array`).

- **Dependency Updates**:
  - Added new dev dependencies (`@vitest/ui`, `jsdom`, `happy-dom`).
  - Updated `package-lock.json` with additional dependency resolutions and metadata for better compatibility and maintainability.

This commit aligns documentation with current project focus, enhances cross-platform support via refined shims, and ensures updated dependencies for development and testing environments.
This commit is contained in:
David Snelling 2025-07-15 11:53:26 -07:00
parent 8460865398
commit d7150dbc30
4 changed files with 1748 additions and 55 deletions

View file

@ -933,8 +933,7 @@ the augmentation pipeline as tools:
Environment compatibility:
- **BrainyMCPAdapter** and **MCPAugmentationToolset** can run in any environment (browser, Node.js, server)
- **BrainyMCPService** core functionality works in any environment, but server functionality (WebSocket/REST) is in the
cloud-wrapper project
- **BrainyMCPService** core functionality works in any environment
For detailed documentation and usage examples, see the [MCP documentation](src/mcp/README.md).
@ -984,46 +983,6 @@ Works in all modern browsers:
For browsers without OPFS support, falls back to in-memory storage.
## Cloud Deployment
Brainy can be deployed as a standalone web service on various cloud platforms using the included cloud wrapper:
- **AWS Lambda and API Gateway**: Deploy as a serverless function with API Gateway
- **Google Cloud Run**: Deploy as a containerized service
- **Cloudflare Workers**: Deploy as a serverless function on the edge
The cloud wrapper provides both RESTful and WebSocket APIs for all Brainy operations, enabling both request-response and
real-time communication patterns. It supports multiple storage backends and can be configured via environment variables.
Key features of the cloud wrapper:
- RESTful API for standard CRUD operations
- WebSocket API for real-time updates and subscriptions
- Model Control Protocol (MCP) service for external model access
- Support for multiple storage backends (Memory, FileSystem, S3)
- Configurable via environment variables
- Deployment scripts for AWS, Google Cloud, and Cloudflare
### Deploying to the Cloud
You can deploy the cloud wrapper to various cloud platforms using the following npm scripts from the root directory:
```bash
# Deploy to AWS Lambda and API Gateway
npm run deploy:cloud:aws
# Deploy to Google Cloud Run
npm run deploy:cloud:gcp
# Deploy to Cloudflare Workers
npm run deploy:cloud:cloudflare
# Show available deployment options
npm run deploy:cloud
```
Before deploying, make sure to configure the appropriate environment variables in the `cloud-wrapper/.env` file. See
the [Cloud Wrapper README](cloud-wrapper/README.md) for detailed configuration instructions and API documentation.
## Related Projects

1697
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,7 @@
"types": "dist/unified.d.ts",
"type": "module",
"sideEffects": [
"./dist/setup.js",
"./dist/setup.js",
"./dist/utils/textEncoding.js",
"./src/setup.ts",
"./src/utils/textEncoding.ts"
@ -67,14 +67,16 @@
"prepare": "npm run build",
"deploy": "npm run build && npm publish && node scripts/create-github-release.js",
"deploy:cli": "node scripts/generate-version.js && cd cli-package && npm run build && npm publish",
"deploy:cloud:aws": "cd cloud-wrapper && npm run build && npm run deploy:aws",
"deploy:cloud:gcp": "cd cloud-wrapper && npm run build && npm run deploy:gcp",
"deploy:cloud:cloudflare": "cd cloud-wrapper && npm run build && npm run deploy:cloudflare",
"deploy:cloud": "echo 'Please use one of the following commands to deploy to a specific cloud provider:' && echo ' npm run deploy:cloud:aws' && echo ' npm run deploy:cloud:gcp' && echo ' npm run deploy:cloud:cloudflare'",
"postinstall": "echo 'Note: If you encounter dependency conflicts with TensorFlow.js packages, please use: npm install --legacy-peer-deps'",
"dry-run": "npm pack --dry-run",
"test:cli": "node scripts/test-cli-locally.js",
"test": "node scripts/comprehensive-test.js"
"test": "vitest run",
"test:watch": "vitest",
"test:ui": "vitest --ui",
"test:node": "vitest run tests/environment.node.test.ts tests/core.test.ts tests/vector-operations.test.ts tests/tensorflow-patch.test.ts",
"test:browser": "vitest run tests/environment.browser.test.ts",
"test:core": "vitest run tests/core.test.ts",
"test:coverage": "vitest run --coverage",
"test:all": "npm run build && vitest run"
},
"keywords": [
"vector-database",
@ -122,16 +124,21 @@
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-typescript": "^11.1.6",
"@types/jsdom": "^21.1.7",
"@types/node": "^20.11.30",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"@vitest/ui": "^3.2.4",
"eslint": "^8.57.0",
"happy-dom": "^18.0.1",
"jsdom": "^26.1.0",
"puppeteer": "^22.5.0",
"rollup": "^4.13.0",
"rollup-plugin-terser": "^7.0.2",
"tslib": "^2.6.2",
"typescript": "^5.4.5"
"typescript": "^5.4.5",
"vitest": "^3.2.4"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.540.0",

View file

@ -31,11 +31,43 @@ const nodeModuleShims = () => {
return null
},
load(id) {
// If this is one of our shims, return an empty module
// If this is one of our shims, return an appropriate module
if (id.startsWith('\0') && id.endsWith('-shim')) {
const moduleName = id.slice(1, -5)
console.log(
`Providing empty shim for Node.js module: ${id.slice(1, -5)}`
`Providing shim for Node.js module: ${moduleName}`
)
// Special handling for util module to include TextEncoder/TextDecoder
if (moduleName === 'util' || moduleName === 'node:util') {
return `
// Util shim with TextEncoder/TextDecoder support
const TextEncoder = globalThis.TextEncoder || (typeof global !== 'undefined' && global.TextEncoder) || class TextEncoder {
encode(input) {
return new Uint8Array(Buffer.from(input, 'utf8'));
}
};
const TextDecoder = globalThis.TextDecoder || (typeof global !== 'undefined' && global.TextDecoder) || class TextDecoder {
decode(input) {
return Buffer.from(input).toString('utf8');
}
};
const types = {
isFloat32Array: (arr) => arr instanceof Float32Array,
isInt32Array: (arr) => arr instanceof Int32Array,
isUint8Array: (arr) => arr instanceof Uint8Array,
isUint8ClampedArray: (arr) => arr instanceof Uint8ClampedArray
};
export default { TextEncoder, TextDecoder, types };
export { TextEncoder, TextDecoder, types };
export const promises = {};
`
}
// Default empty shim for other modules
return 'export default {}; export const promises = {};'
}
return null
@ -241,7 +273,7 @@ const workerConfig = {
'fs',
'path'
]
};
}
// Export both configurations
export default [mainConfig, workerConfig];
export default [mainConfig, workerConfig]