Commit graph

8 commits

Author SHA1 Message Date
36336c5180 **refactor(mcpService): use enum for MCP request type**
### Changes:
- **mcpService.ts**:
  - Updated `type` in `/mcp/tools` route to use `MCPRequestType.SYSTEM_INFO` enum instead of hardcoded string `'SYSTEM_INFO'`.
  - Removed redundant `infoType: 'availableTools'` from the MCP request payload.
  - Added `MCPRequestType` import from `@soulcraft/brainy`.

### Purpose:
Replaced hardcoded request type string with an enum for improved type safety and maintainability. Removed unnecessary `infoType` parameter, aligning the request payload with updated requirements.
2025-06-23 10:58:56 -07:00
c641467854 **feat: add MCP service integration and enhance environment detection**
### Changes:
- Introduced `initializeMCPService` in `cloud-wrapper/src/index.ts` to support initializing Model Control Protocol (MCP) services.
  - Enabled configuration for WebSocket and REST APIs with customizable options like ports, authentication, rate limiting, and CORS.
- Exported MCP modules, types, and services (`BrainyMCPAdapter`, `BrainyMCPService`, etc.) in `src/index.ts`.
- Enhanced `unified.ts` to include global environment detection by populating `globalThis.__ENV__`.
  - Added environment-specific logging for browser, Node.js, and serverless scenarios.
  - Improved the structure of `environment` object and its global accessibility.

### Purpose:
Implemented MCP service integration to expand Brainy's external compatibility via WebSocket and REST interfaces. Enhanced environment detection provides better global access and debugging insights, ensuring robust operation across various runtime environments.
2025-06-20 10:57:31 -07:00
2e8e947adc **feat: implement Model Control Protocol (MCP) for Brainy with WebSocket and REST interfaces**
### Changes:
- **Core MCP Components**:
  - Introduced `BrainyMCPAdapter`, `BrainyMCPService`, and `MCPAugmentationToolset` for handling data access, tool execution, system information, and authentication via MCP.
  - Added asynchronous handlers to process requests for Brainy data, augmentations, and relationships.
  - Built pipelines to expose Brainy augmentation capabilities as tools.

- **Server Implementations**:
  - Added WebSocket and REST interfaces in `initializeMCPService` for external MCP requests.
  - Included rate limiting, authentication, and CORS support for REST API.

- **Type Definitions**:
  - Defined MCP-related types such as `MCPRequestType`, `MCPResponse`, and `MCPToolExecutionRequest` in `src/types/mcpTypes.ts`.
  - Incorporated augmentation-type-specific methods from `augmentationPipeline`.

- **Exports**:
  - Exposed MCP modules (`BrainyMCPAdapter`, `BrainyMCPService`, `MCPAugmentationToolset`) via `src/mcp/index.ts`.

### Purpose:
Introduced a Model Control Protocol (MCP) framework to enable seamless integration of Brainy data and augmentation tools with external models. The implementation provides structured, scalable access to data and tools through both WebSocket and REST APIs.
2025-06-20 10:56:21 -07:00
0cf4a0eee8 **refactor: improve imports, route handling, and environment detection**
### Changes:
- Added explicit `.js` extensions to imports in `cloud-wrapper/src/index.ts` for Node.js compatibility.
- Refactored `setupRoutes` usage by introducing an `apiRouter` variable for clarity and consistency in middleware.
- Simplified environment detection in `src/unified.ts` by delegating it to build-time logic:
  - Removed inline environment detection (`isBrowser`, `isNode`, `isServerless`).
  - Updated `environment` export with build-generated properties.

### Purpose:
Enhanced compatibility with Node.js module resolution, improved code clarity in route handling, and streamlined environment detection by consolidating it into the build process. These changes reduce redundancy, improve maintainability, and align with modern JavaScript practices.
2025-06-19 16:03:31 -07:00
1b78e5425a **refactor: add async error handler utility and standardize route handlers**
### Changes:
- Introduced `asyncHandler` utility to simplify error handling in asynchronous route handlers.
- Updated all route definitions in `cloud-wrapper/src/routes.ts` to use the new `asyncHandler` wrapper:
  - Standardized error management across CRUD operations for nouns, verbs, and search functionality.
  - Replaced redundant `try-catch` blocks with the `asyncHandler` wrapper to streamline code.
- Added `NextFunction` and adjusted TypeScript typings for improved clarity and error handling.

### Purpose:
Refactored route handlers to enhance maintainability, readability, and consistency by centralizing asynchronous error handling with a reusable `asyncHandler` utility. This reduces redundancy and simplifies debugging for API routes.
2025-06-19 16:03:04 -07:00
487bfa473b **feat: enhance BrainyData storage configuration with support for custom S3 endpoints and extended types**
### Changes:
- Introduced `ExtendedBrainyDataConfig` interface to include `rootDirectory` in the storage configuration.
- Enhanced S3 storage setup:
  - Added support for `customS3Storage` when `S3_ENDPOINT` is provided.
  - Retained standard `s3Storage` configuration for AWS S3 without custom endpoints.
- Updated fallback logic for default storage types (`filesystem`, `memory`) with consistent handling for `rootDirectory`.
- Refined `initializeBrainy` function to improve readability and configuration extensibility.
- Updated TypeScript typings for improved clarity and maintainability.

### Purpose:
Improved the `initializeBrainy` function by extending storage configuration capabilities, allowing seamless integration of custom S3 endpoints alongside standard AWS S3 settings. Enhanced overall code readability and adaptability for diverse storage configurations.
2025-06-19 15:12:51 -07:00
126fe08379 **refactor: streamline initializeBrainy embedding configuration and cleanup code style**
### Changes:
- Removed conditional configuration for `USE_SIMPLE_EMBEDDING` as Universal Sentence Encoder is now the sole embedding option.
- Updated comments to reflect the exclusive use of TensorFlow.js for embedding functionality.
- Cleaned up unnecessary blank lines and whitespace for improved code readability.

### Purpose:
Simplified the `initializeBrainy` function by consolidating embedding configuration and eliminating outdated options. This refinement aligns with the project's transition to TensorFlow-based embeddings and improves code clarity.
2025-06-19 15:02:53 -07:00
e00f1a92ce feat: add WebSocket API, REST API routes, and server setup for Brainy
Implemented a WebSocket API for real-time communication and REST API routes for CRUD operations on nouns and verbs. Added a server initialization script with WebSocket server integration and improved application structure with modularized routing and services.
2025-06-06 09:09:07 -07:00