{"name":"@langchain/langgraph-checkpoint","version":"0.1.3","author":"LangChain","license":"MIT","_id":"@langchain/langgraph-checkpoint@0.1.3","maintainers":[{"name":"lc-oss-admin","email":"oss-admin@langchain.dev"},{"name":"langchain-security","email":"infra@langchain.dev"}],"dist":{"shasum":"f34fab62a38487d6bd8c2a2c1a7fc15f1c16b75f","tarball":"http://registry-npm.ywwl.com/@langchain/langgraph-checkpoint/download/@langchain/langgraph-checkpoint-0.1.3.tgz","fileCount":76,"integrity":"sha512-hCfCqvbAS5iAbKxEtSEQVSQSEkeoAOvDumVZ1RwCFGi5CxV1/3dTnHpQn2DcvKm+M4fchhV7mq++Ej2GB/hSdQ==","signatures":[{"sig":"MEYCIQCN3hoFjgdNEZ77XAaqz8f6YrEawmgP7t4thh+xAVXvhgIhAMkQSrE2UEIVsZhPwMgoKLhJFzSBIYob6hZ/wEGamhep","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEQCIGXNhb355/VF+ciJ69dlvoUU6hcqeIowen5STODWgVgoAiBu1Dm9P299gwZc+wu4lugLkLO8w4uqL3FfUKRXZAWLGQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":231615,"size":39933,"noattachment":false,"key":"/@langchain/langgraph-checkpoint/-/@langchain/langgraph-checkpoint-0.1.3.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":"18b4a6e6df678f42131256189d0f5648f9bece46","scripts":{"lint":"yarn lint:eslint && yarn lint:dpdm","test":"vitest run","build":"yarn turbo:command build:internal --filter=@langchain/langgraph-checkpoint","clean":"rm -rf dist/ dist-cjs/ .turbo/","format":"prettier --config .prettierrc --write \"src\"","prepack":"yarn build","lint:fix":"yarn lint:eslint --fix && yarn lint:dpdm","test:int":"vitest run --mode int","lint:dpdm":"dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts","test:watch":"vitest watch","lint:eslint":"NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/","format:check":"prettier --config .prettierrc --check \"src\"","build:internal":"yarn clean && yarn lc_build --create-entrypoints --pre --tree-shaking"},"_npmUser":{"name":"lc-oss-admin","email":"oss-admin@langchain.dev"},"repository":{"url":"git@github.com:langchain-ai/langgraphjs.git","type":"git"},"description":"Library with base interfaces for LangGraph checkpoint savers.","directories":{},"dependencies":{"uuid":"^10.0.0"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.3","dpdm":"^3.12.0","dotenv":"^16.3.1","eslint":"^8.33.0","rollup":"^4.37.0","vitest":"^3.1.2","prettier":"^2.8.3","typescript":"^4.9.5 || ^5.4.5","@types/uuid":"^10","@langchain/scripts":">=0.1.3 <0.2.0","eslint-plugin-import":"^2.29.1","@tsconfig/recommended":"^1.0.3","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.31 <0.4.0 || ^1.0.0-alpha"},"_npmOperationalInternal":{"tmp":"tmp/langgraph-checkpoint_0.1.3_1787182905074_0.08173650068087612","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":1787182905167,"_cnpm_publish_time":1787182905167,"dist-tags":{"latest":"1.2.2","next":"1.0.0"}}