{"name":"@langchain/langgraph-checkpoint","version":"1.2.1","author":{"name":"LangChain"},"license":"MIT","_id":"@langchain/langgraph-checkpoint@1.2.1","maintainers":[{"name":"lc-oss-admin","email":"oss-admin@langchain.dev"},{"name":"langchain-security","email":"infra@langchain.dev"}],"homepage":"https://github.com/langchain-ai/langgraphjs#readme","bugs":{"url":"https://github.com/langchain-ai/langgraphjs/issues"},"dist":{"shasum":"14d0784ae7729d93000e4aa0f54cd94eb29ba5d5","tarball":"http://registry-npm.ywwl.com/@langchain/langgraph-checkpoint/download/@langchain/langgraph-checkpoint-1.2.1.tgz","fileCount":101,"integrity":"sha512-RD01mi9fYfpIq5fWrW/j2iY7MRUoqKvh1Nj6TMRDBoTGE18E2du75zKDugNxb57N8FWCojaiWGB9Enssnx9Hyg==","signatures":[{"sig":"MEQCIBGx4m+n1+y5FpsBQ5QyKrYxNPnYLqQwt/5S2eAItG8CAiAMMzVrHdve6qB805b80OuC18B2JxQUIzMpACL/q9lQ5w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQC9rgeUXVpJGVju3HObXcxSKxYi30C9RStobz3qHFJ2DAIhAMb56hX1ce8f6j20f1kqf3QdPNklFMtdWBMO4JCHx07i","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@langchain%2flanggraph-checkpoint@1.2.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":515651,"size":132210,"noattachment":false,"key":"/@langchain/langgraph-checkpoint/-/@langchain/langgraph-checkpoint-1.2.1.tgz"},"main":"./dist/index.js","type":"module","_from":"file:langchain-langgraph-checkpoint-1.2.1.tgz","types":"./dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"input":"./src/index.ts","import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"},"typedoc":"./src/index.ts"},"./package.json":"./package.json"},"scripts":{"test":"vitest run","build":"pnpm turbo build:internal --filter=@langchain/langgraph-checkpoint","clean":"rm -rf dist/ dist-cjs/ .turbo/","test:int":"vitest run --mode int","lint:dpdm":"dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts","prepublish":"pnpm build","test:watch":"vitest watch","lint:eslint":"NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/","build:internal":"pnpm --filter @langchain/build compile @langchain/langgraph-checkpoint"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"5e1643bb-9c20-43c5-bbed-a84f51ed265c"}},"_resolved":"/tmp/0baa59aad363eb43eb17aadfd87469e7/langchain-langgraph-checkpoint-1.2.1.tgz","_integrity":"sha512-RD01mi9fYfpIq5fWrW/j2iY7MRUoqKvh1Nj6TMRDBoTGE18E2du75zKDugNxb57N8FWCojaiWGB9Enssnx9Hyg==","repository":{"url":"git+ssh://git@github.com/langchain-ai/langgraphjs.git","type":"git","directory":"libs/checkpoint"},"_npmVersion":"11.19.0","description":"Library with base interfaces for LangGraph checkpoint savers.","directories":{},"_nodeVersion":"24.21.0","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.3","dpdm":"^3.12.0","dotenv":"^16.3.1","rollup":"^4.62.3","vitest":"^4.1.11","typescript":"^4.9.5 || ^5.4.5","@langchain/scripts":">=0.1.3 <0.2.0","@tsconfig/recommended":"^1.0.3"},"peerDependencies":{"@langchain/core":"^1.1.48"},"_npmOperationalInternal":{"tmp":"tmp/langgraph-checkpoint_1.2.1_1792611813667_0.862065214171299","host":"s3://npm-registry-packages-npm-production"},"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":1792611813782,"_cnpm_publish_time":1792611813782,"dist-tags":{"latest":"1.2.2","next":"1.0.0"}}