-
-
Notifications
You must be signed in to change notification settings - Fork 555
feat(mongodb): implement complete MongoDB memory adapter #1000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
UmeshpJadhav
wants to merge
8
commits into
VoltAgent:main
Choose a base branch
from
UmeshpJadhav:feat/mongodb-memory-storage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
911d3be
feat(mongodb): implement complete MongoDB memory adapter
UmeshpJadhav d59ad0e
fix: fixed the build failure and the implemented code review comments
UmeshpJadhav 6185353
chore: resolve lockfile conflict with upstream
UmeshpJadhav ef863b8
fix: handle race condition in createConversation
UmeshpJadhav 76dab7a
fix: explicitly externalize dependencies in tsup build
UmeshpJadhav be1fd71
fix: implement missing StorageAdapter methods
UmeshpJadhav 545a62a
fix: resolve security vulnerability in deleteMessages and implement m…
UmeshpJadhav 7d0eb68
fix: refactor ID handling, update logic, and tests
UmeshpJadhav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@voltagent/mongodb": minor | ||
| --- | ||
|
|
||
| Initial release of MongoDB memory storage adapter | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # @voltagent/mongodb | ||
|
|
||
| MongoDB storage adapter for VoltAgent memory. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| npm install @voltagent/mongodb | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```typescript | ||
| import { MongoDBMemoryAdapter } from "@voltagent/mongodb"; | ||
| import { Memory } from "@voltagent/core"; | ||
|
|
||
| const memory = new Memory({ | ||
| storage: new MongoDBMemoryAdapter({ | ||
| connection: process.env.MONGO_URI, | ||
| database: "voltagent", // optional | ||
| collectionPrefix: "voltagent_memory", // optional | ||
| }), | ||
| }); | ||
| ``` | ||
|
|
||
| ## Features | ||
|
|
||
| - **Persistent Storage**: Stores messages, conversations, and workflow states in MongoDB. | ||
| - **Efficient Queries**: Indexed for fast retrieval by user, conversation, or date. | ||
| - **Type Safe**: Fully typed implementation of the VoltAgent StorageAdapter interface. | ||
| - **Workflow Support**: Native support for resuming suspended workflows. | ||
|
|
||
| ## Configuration | ||
|
|
||
| | Option | Type | Default | Description | | ||
| | ------------------ | --------- | -------------------- | ---------------------- | | ||
| | `connection` | `string` | required | MongoDB connection URI | | ||
| | `database` | `string` | `"voltagent"` | Database name | | ||
| | `collectionPrefix` | `string` | `"voltagent_memory"` | Prefix for collections | | ||
| | `debug` | `boolean` | `false` | Enable debug logging | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| services: | ||
| mongodb-test: | ||
| image: mongo:7.0 | ||
| container_name: 'voltagent-mongodb-test' | ||
| ports: | ||
| - '27017:27017' | ||
| environment: | ||
| MONGO_INITDB_DATABASE: voltagent_test | ||
| volumes: | ||
| - test_mongodb_data:/data/db | ||
| healthcheck: | ||
| test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"] | ||
| interval: 2s | ||
| timeout: 5s | ||
| retries: 10 | ||
|
|
||
| volumes: | ||
| test_mongodb_data: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| { | ||
| "name": "@voltagent/mongodb", | ||
| "description": "VoltAgent MongoDB - MongoDB Memory provider integration for VoltAgent", | ||
| "version": "2.0.2", | ||
| "dependencies": { | ||
| "mongodb": "^7.0.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@vitest/coverage-v8": "^3.2.4", | ||
| "@voltagent/core": "^2.0.2", | ||
| "ai": "^6.0.0" | ||
| }, | ||
| "exports": { | ||
| ".": { | ||
| "import": { | ||
| "types": "./dist/index.d.mts", | ||
| "default": "./dist/index.mjs" | ||
| }, | ||
| "require": { | ||
| "types": "./dist/index.d.ts", | ||
| "default": "./dist/index.js" | ||
| } | ||
| } | ||
| }, | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "license": "MIT", | ||
| "main": "dist/index.js", | ||
| "module": "dist/index.mjs", | ||
| "peerDependencies": { | ||
| "@voltagent/core": "^2.0.0", | ||
| "ai": "^6.0.0" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/VoltAgent/voltagent.git", | ||
| "directory": "packages/mongodb" | ||
| }, | ||
| "scripts": { | ||
| "attw": "attw --pack", | ||
| "build": "tsup", | ||
| "dev": "tsup --watch", | ||
| "lint": "biome check .", | ||
| "lint:fix": "biome check . --write", | ||
| "publint": "publint --strict", | ||
| "test": "vitest", | ||
| "test:coverage": "vitest run --coverage", | ||
| "test:integration": "npm run test:integration:setup && vitest run --config vitest.integration.config.mts && npm run test:integration:teardown", | ||
| "test:integration:ci": "vitest run --config vitest.integration.config.mts", | ||
| "test:integration:setup": "docker compose -f docker-compose.test.yaml up -d && sleep 10", | ||
| "test:integration:teardown": "docker compose -f docker-compose.test.yaml down -v" | ||
| }, | ||
| "types": "dist/index.d.ts" | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add minimal usage example?