{"name":"@langchain/langgraph-checkpoint","version":"0.0.0","author":{"name":"LangChain"},"license":"MIT","_id":"@langchain/langgraph-checkpoint@0.0.0","maintainers":[{"name":"maddyadams","email":"madelyn.adams1@gmail.com"},{"name":"sam_noyes","email":"sam@langchain.dev"},{"name":"vbarda","email":"vadym@langchain.dev"},{"name":"davidduong","email":"david@duong.cz"},{"name":"andrewnguonly","email":"andrewnguonly@gmail.com"},{"name":"basproul","email":"braceasproul@gmail.com"},{"name":"jacoblee93","email":"jacoblee93@gmail.com"},{"name":"nfcampos","email":"nuno@boringbits.io"},{"name":"sullivan-sean","email":"ssullivan61198@gmail.com"},{"name":"hwchase17","email":"hw.chase.17@gmail.com"}],"homepage":"https://github.com/langchain-ai/langgraphjs#readme","bugs":{"url":"https://github.com/langchain-ai/langgraphjs/issues"},"dist":{"shasum":"cbbf879241359f8d6e3783b607d99a411e9217ad","tarball":"http://registry-npm.ywwl.com/@langchain/langgraph-checkpoint/download/@langchain/langgraph-checkpoint-0.0.0.tgz","fileCount":28,"integrity":"sha512-NelJVnzY7EeipPx3Bl4qukhGFkNMlDyRX5ltkBLXwbADzg8AAULZAXi60ppN1+GrXo2StMssCfdrovLH4xwARA==","signatures":[{"sig":"MEYCIQC4vjJ1KsY9TE0YU3eseQ6tOT31QvtqQOenlIiDCYCz0gIhAIND32UpMi9UC69yfjQ1mbaW3Ay9nIDgHhCHXn4FwiWx","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":39492,"size":8459,"noattachment":false,"key":"/@langchain/langgraph-checkpoint/-/@langchain/langgraph-checkpoint-0.0.0.tgz"},"main":"./index.js","type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":{"import":"./index.d.ts","default":"./index.d.ts","require":"./index.d.cts"},"import":"./index.js","require":"./index.cjs"},"./package.json":"./package.json"},"gitHead":"6603b09f53df5a5a43aa32637b527887dd103888","scripts":{"lint":"yarn lint:eslint && yarn lint:dpdm","test":"NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%","build":"yarn turbo:command build:internal --filter=@langchain/langgraph-checkpoint","format":"prettier --config .prettierrc --write \"src\"","prepack":"yarn build","lint:fix":"yarn lint:eslint --fix && yarn lint:dpdm","test:int":"NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%","lint:dpdm":"dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts","test:watch":"NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts","lint:eslint":"NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/","test:single":"NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000","format:check":"prettier --config .prettierrc --check \"src\"","build:internal":"yarn lc_build_v2 --create-entrypoints --pre --tree-shaking"},"_npmUser":{"name":"jacoblee93","email":"jacoblee93@gmail.com"},"repository":{"url":"git+ssh://git@github.com/langchain-ai/langgraphjs.git","type":"git"},"_npmVersion":"10.5.2","description":"Library with base interfaces for LangGraph checkpoint savers.","directories":{},"_nodeVersion":"20.13.1","dependencies":{"uuid":"^10.0.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.7.0","dpdm":"^3.12.0","jest":"^29.5.0","dotenv":"^16.3.1","eslint":"^8.33.0","rollup":"^4.5.2","ts-jest":"^29.1.0","prettier":"^2.8.3","@swc/core":"^1.3.90","@swc/jest":"^0.2.29","release-it":"^17.6.0","typescript":"^4.9.5 || ^5.4.5","@types/uuid":"^10","@jest/globals":"^29.5.0","@langchain/scripts":"^0.0.22","eslint-plugin-jest":"^28.8.0","eslint-plugin-import":"^2.29.1","@tsconfig/recommended":"^1.0.3","jest-environment-node":"^29.6.4","eslint-config-prettier":"^8.6.0","eslint-plugin-prettier":"^4.2.1","@typescript-eslint/parser":"^6.12.0","eslint-config-airbnb-base":"^15.0.0","eslint-plugin-no-instanceof":"^1.0.1","@typescript-eslint/eslint-plugin":"^6.12.0"},"peerDependencies":{"@langchain/core":">=0.2.20 <0.3.0"},"_npmOperationalInternal":{"tmp":"tmp/langgraph-checkpoint_0.0.0_1724322686419_0.5888246326484776","host":"s3://npm-registry-packages"},"readme":"# @langchain/langgraph-checkpoint\n\nThis library defines the base interface for [LangGraph.js](https://github.com/langchain-ai/langgraphjs) checkpointers. Checkpointers provide persistence layer for LangGraph. They allow you to interact with and manage the graph's state. When you use a graph with a checkpointer, the checkpointer saves a _checkpoint_ of the graph state at every superstep, enabling several powerful capabilities like human-in-the-loop, \"memory\" between interactions and more.\n\n## Key concepts\n\n### Checkpoint\n\nCheckpoint is a snapshot of the graph state at a given point in time. Checkpoint tuple refers to an object containing checkpoint and the associated config, metadata and pending writes.\n\n### Thread\n\nThreads enable the checkpointing of multiple different runs, making them essential for multi-tenant chat applications and other scenarios where maintaining separate states is necessary. A thread is a unique ID assigned to a series of checkpoints saved by a checkpointer. When using a checkpointer, you must specify a `thread_id` and optionally `checkpoint_id` when running the graph.\n\n- `thread_id` is simply the ID of a thread. This is always required\n- `checkpoint_id` can optionally be passed. This identifier refers to a specific checkpoint within a thread. This can be used to kick of a run of a graph from some point halfway through a thread.\n\nYou must pass these when invoking the graph as part of the configurable part of the config, e.g.\n\n```ts\n{ configurable: { thread_id: \"1\" } }  // valid config\n{ configurable: { thread_id: \"1\", checkpoint_id: \"0c62ca34-ac19-445d-bbb0-5b4984975b2a\" } }  // also valid config\n```\n\n### Serde\n\n`@langchain/langgraph-checkpoint` also defines protocol for serialization/deserialization (serde) and provides an default implementation that handles a range of types.\n\n### Pending writes\n\nWhen a graph node fails mid-execution at a given superstep, LangGraph stores pending checkpoint writes from any other nodes that completed successfully at that superstep, so that whenever we resume graph execution from that superstep we don't re-run the successful nodes.\n\n### When are checkpoints persisted\n\nBy default (`durability: \"async\"`) checkpoint writes are dispatched in the background while the graph keeps executing, which keeps runs fast. Regardless of the `durability` mode, LangGraph **awaits all outstanding checkpointer writes before `invoke()` / `stream()` resolves**, `invoke()` fully drains the underlying stream, and the stream awaits every pending checkpointer promise before it completes.\n\nIn practice this means:\n\n- If you `await graph.invoke(...)` (or fully consume `for await (... of graph.stream(...))`), persistence is guaranteed to be complete by the time the call returns. You do **not** need to keep the process/runtime alive for any trailing background writes.\n- On serverless/edge runtimes (e.g. Cloudflare Workers) you therefore do not need `ctx.waitUntil()` to flush checkpoints, just make sure you `await` the run before returning a response. The only way to orphan writes is to start a stream and never consume it (e.g. piping `graph.stream()` into a detached, un-awaited task).\n\n> Note: this guarantees the *write was issued and awaited*, not that your database driver works in a given runtime. See the runtime-compatibility notes in the [Postgres](../checkpoint-postgres/README.md#edge--serverless-runtimes-cloudflare-workers-etc) and [Redis](../checkpoint-redis/README.md#edge--serverless-runtimes-cloudflare-workers-etc) checkpointer READMEs.\n\n## Interface\n\nEach checkpointer should conform to `BaseCheckpointSaver` interface and must implement the following methods:\n\n- `.put` - Store a checkpoint with its configuration and metadata.\n- `.putWrites` - Store intermediate writes linked to a checkpoint (i.e. pending writes).\n- `.getTuple` - Fetch a checkpoint tuple using for a given configuration (`thread_id` and `thread_ts`).\n- `.list` - List checkpoints that match a given configuration and filter criteria.\n\n## Usage\n\n```ts\nimport { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n\nconst writeConfig = {\n  configurable: {\n    thread_id: \"1\",\n    checkpoint_ns: \"\"\n  }\n};\nconst readConfig = {\n  configurable: {\n    thread_id: \"1\"\n  }\n};\n\nconst checkpointer = new MemorySaver();\nconst checkpoint = {\n  v: 1,\n  ts: \"2024-07-31T20:14:19.804150+00:00\",\n  id: \"1ef4f797-8335-6428-8001-8a1503f9b875\",\n  channel_values: {\n    my_key: \"meow\",\n    node: \"node\"\n  },\n  channel_versions: {\n    __start__: 2,\n    my_key: 3,\n    \"start:node\": 3,\n    node: 3\n  },\n  versions_seen: {\n    __input__: {},\n    __start__: {\n      __start__: 1\n    },\n    node: {\n      \"start:node\": 2\n    }\n  },\n  pending_sends: [],\n}\n\n// store checkpoint\nawait checkpointer.put(writeConfig, checkpoint, {}, {})\n\n// load checkpoint\nawait checkpointer.get(readConfig)\n\n// list checkpoints\nfor await (const checkpoint of checkpointer.list(readConfig)) {\n  console.log(checkpoint);\n}\n```\n","publish_time":1724322686650,"_cnpm_publish_time":1724322686650,"dist-tags":{"latest":"1.2.2","next":"1.0.0"}}