@langchain/langgraph-checkpoint-mongodb 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +66 -0
  3. package/package.json +90 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2024 LangChain
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # @langchain/langgraph-checkpoint-mongodb
2
+
3
+ Implementation of a [LangGraph.js](https://github.com/langchain-ai/langgraphjs) CheckpointSaver that uses a MongoDB instance.
4
+
5
+ ## Usage
6
+
7
+ ```ts
8
+ import { MongoClient } from "mongodb";
9
+ import { MongoDBSaver } from "@langchain/langgraph-checkpoint-mongodb";
10
+
11
+ const writeConfig = {
12
+ configurable: {
13
+ thread_id: "1",
14
+ checkpoint_ns: ""
15
+ }
16
+ };
17
+ const readConfig = {
18
+ configurable: {
19
+ thread_id: "1"
20
+ }
21
+ };
22
+
23
+
24
+ const client = new MongoClient(process.env.MONGODB_URL);
25
+
26
+ const checkpointer = new MongoDBSaver({ client });
27
+ const checkpoint = {
28
+ v: 1,
29
+ ts: "2024-07-31T20:14:19.804150+00:00",
30
+ id: "1ef4f797-8335-6428-8001-8a1503f9b875",
31
+ channel_values: {
32
+ my_key: "meow",
33
+ node: "node"
34
+ },
35
+ channel_versions: {
36
+ __start__: 2,
37
+ my_key: 3,
38
+ start:node: 3,
39
+ node: 3
40
+ },
41
+ versions_seen: {
42
+ __input__: {},
43
+ __start__: {
44
+ __start__: 1
45
+ },
46
+ node: {
47
+ start:node: 2
48
+ }
49
+ },
50
+ pending_sends: [],
51
+ current_tasks: {}
52
+ }
53
+
54
+ // store checkpoint
55
+ await checkpointer.put(writeConfig, checkpoint, {}, {});
56
+
57
+ // load checkpoint
58
+ await checkpointer.get(readConfig);
59
+
60
+ // list checkpoints
61
+ for await (const checkpoint of checkpointer.list(readConfig)) {
62
+ console.log(checkpoint);
63
+ }
64
+
65
+ await client.close();
66
+ ```
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@langchain/langgraph-checkpoint-mongodb",
3
+ "version": "0.0.1",
4
+ "description": "LangGraph",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=18"
8
+ },
9
+ "main": "./index.js",
10
+ "types": "./index.d.ts",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git@github.com:langchain-ai/langgraphjs.git"
14
+ },
15
+ "scripts": {
16
+ "build": "yarn turbo:command build:internal --filter=@langchain/langgraph-checkpoint-sqlite",
17
+ "build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking",
18
+ "lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
19
+ "lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
20
+ "lint": "yarn lint:eslint && yarn lint:dpdm",
21
+ "lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
22
+ "prepack": "yarn build",
23
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
24
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
25
+ "test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
26
+ "test:int": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
27
+ "format": "prettier --config .prettierrc --write \"src\"",
28
+ "format:check": "prettier --config .prettierrc --check \"src\""
29
+ },
30
+ "author": "LangChain",
31
+ "license": "MIT",
32
+ "dependencies": {
33
+ "mongodb": "^6.8.0"
34
+ },
35
+ "peerDependencies": {
36
+ "@langchain/core": ">=0.2.20 <0.3.0",
37
+ "@langchain/langgraph-checkpoint": "~0.0.1"
38
+ },
39
+ "devDependencies": {
40
+ "@jest/globals": "^29.5.0",
41
+ "@langchain/scripts": "^0.0.22",
42
+ "@swc/core": "^1.3.90",
43
+ "@swc/jest": "^0.2.29",
44
+ "@tsconfig/recommended": "^1.0.3",
45
+ "@types/better-sqlite3": "^7.6.9",
46
+ "@types/uuid": "^10",
47
+ "@typescript-eslint/eslint-plugin": "^6.12.0",
48
+ "@typescript-eslint/parser": "^6.12.0",
49
+ "dotenv": "^16.3.1",
50
+ "dpdm": "^3.12.0",
51
+ "eslint": "^8.33.0",
52
+ "eslint-config-airbnb-base": "^15.0.0",
53
+ "eslint-config-prettier": "^8.6.0",
54
+ "eslint-plugin-import": "^2.29.1",
55
+ "eslint-plugin-jest": "^28.8.0",
56
+ "eslint-plugin-no-instanceof": "^1.0.1",
57
+ "eslint-plugin-prettier": "^4.2.1",
58
+ "jest": "^29.5.0",
59
+ "jest-environment-node": "^29.6.4",
60
+ "prettier": "^2.8.3",
61
+ "release-it": "^17.6.0",
62
+ "rollup": "^4.5.2",
63
+ "ts-jest": "^29.1.0",
64
+ "tsx": "^4.7.0",
65
+ "typescript": "^4.9.5 || ^5.4.5"
66
+ },
67
+ "publishConfig": {
68
+ "access": "public",
69
+ "registry": "https://registry.npmjs.org/"
70
+ },
71
+ "exports": {
72
+ ".": {
73
+ "types": {
74
+ "import": "./index.d.ts",
75
+ "require": "./index.d.cts",
76
+ "default": "./index.d.ts"
77
+ },
78
+ "import": "./index.js",
79
+ "require": "./index.cjs"
80
+ },
81
+ "./package.json": "./package.json"
82
+ },
83
+ "files": [
84
+ "dist/",
85
+ "index.cjs",
86
+ "index.js",
87
+ "index.d.ts",
88
+ "index.d.cts"
89
+ ]
90
+ }