langgraph-api 0.4.47__py3-none-any.whl → 0.5.0__py3-none-any.whl

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.

Potentially problematic release.


This version of langgraph-api might be problematic. Click here for more details.

langgraph_api/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.4.47"
1
+ __version__ = "0.5.0"
langgraph_api/config.py CHANGED
@@ -128,6 +128,45 @@ class StoreConfig(TypedDict, total=False):
128
128
  ttl: TTLConfig
129
129
 
130
130
 
131
+ class SerdeConfig(TypedDict, total=False):
132
+ """Configuration for the built-in serde, which handles checkpointing of state.
133
+
134
+ If omitted, no serde is set up (the object store will still be present, however)."""
135
+
136
+ allowed_json_modules: list[list[str]] | Literal[True] | None
137
+ """Optional. List of allowed python modules to de-serialize custom objects from.
138
+
139
+ If provided, only the specified modules will be allowed to be deserialized.
140
+ If omitted, no modules are allowed, and the object returned will simply be a json object OR
141
+ a deserialized langchain object.
142
+
143
+ Example:
144
+ {...
145
+ "serde": {
146
+ "allowed_json_modules": [
147
+ ["my_agent", "my_file", "SomeType"],
148
+ ]
149
+ }
150
+ }
151
+
152
+ If you set this to True, any module will be allowed to be deserialized.
153
+
154
+ Example:
155
+ {...
156
+ "serde": {
157
+ "allowed_json_modules": true
158
+ }
159
+ }
160
+
161
+ """
162
+ pickle_fallback: bool
163
+ """Optional. Whether to allow pickling as a fallback for deserialization.
164
+
165
+ If True, pickling will be allowed as a fallback for deserialization.
166
+ If False, pickling will not be allowed as a fallback for deserialization.
167
+ Defaults to True if not configured."""
168
+
169
+
131
170
  class CheckpointerConfig(TypedDict, total=False):
132
171
  """Configuration for the built-in checkpointer, which handles checkpointing of state.
133
172
 
@@ -140,6 +179,8 @@ class CheckpointerConfig(TypedDict, total=False):
140
179
  If provided, the checkpointer will apply TTL settings according to the configuration.
141
180
  If omitted, no TTL behavior is configured.
142
181
  """
182
+ serde: SerdeConfig | None
183
+ """Optional. Defines the configuration for how checkpoints are serialized."""
143
184
 
144
185
 
145
186
  class SecurityConfig(TypedDict, total=False):
@@ -339,6 +380,11 @@ def _parse_thread_ttl(value: str | None) -> ThreadTTLConfig | None:
339
380
  CHECKPOINTER_CONFIG = env(
340
381
  "LANGGRAPH_CHECKPOINTER", cast=_parse_schema(CheckpointerConfig), default=None
341
382
  )
383
+ SERDE: SerdeConfig | None = (
384
+ CHECKPOINTER_CONFIG["serde"]
385
+ if CHECKPOINTER_CONFIG and "serde" in CHECKPOINTER_CONFIG
386
+ else None
387
+ )
342
388
  THREAD_TTL: ThreadTTLConfig | None = env(
343
389
  "LANGGRAPH_THREAD_TTL", cast=_parse_thread_ttl, default=None
344
390
  )
@@ -6,7 +6,7 @@ import warnings
6
6
  from . import core_api_pb2 as core__api__pb2
7
7
  from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
8
8
 
9
- GRPC_GENERATED_VERSION = '1.76.0'
9
+ GRPC_GENERATED_VERSION = '1.75.1'
10
10
  GRPC_VERSION = grpc.__version__
11
11
  _version_not_supported = False
12
12
 
@@ -19,7 +19,7 @@ except ImportError:
19
19
  if _version_not_supported:
20
20
  raise RuntimeError(
21
21
  f'The grpc package installed is at version {GRPC_VERSION},'
22
- + ' but the generated code in core_api_pb2_grpc.py depends on'
22
+ + f' but the generated code in core_api_pb2_grpc.py depends on'
23
23
  + f' grpcio>={GRPC_GENERATED_VERSION}.'
24
24
  + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
25
25
  + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
@@ -18,7 +18,7 @@
18
18
  "@typescript/vfs": "^1.6.0",
19
19
  "dedent": "^1.5.3",
20
20
  "exit-hook": "^4.0.0",
21
- "hono": "^4.10.2",
21
+ "hono": "^4.10.3",
22
22
  "p-queue": "^8.0.1",
23
23
  "p-retry": "^6.2.0",
24
24
  "tsx": "^4.19.3",
@@ -971,10 +971,10 @@ has-flag@^4.0.0:
971
971
  resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
972
972
  integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
973
973
 
974
- hono@^4.10.2, hono@^4.5.4:
975
- version "4.10.2"
976
- resolved "https://registry.yarnpkg.com/hono/-/hono-4.10.2.tgz#a78d322f2c5fabebb1887f7ae1632a6524513e74"
977
- integrity sha512-p6fyzl+mQo6uhESLxbF5WlBOAJMDh36PljwlKtP5V1v09NxlqGru3ShK+4wKhSuhuYf8qxMmrivHOa/M7q0sMg==
974
+ hono@^4.10.3, hono@^4.5.4:
975
+ version "4.10.3"
976
+ resolved "https://registry.yarnpkg.com/hono/-/hono-4.10.3.tgz#4e4063eebaac2b735ca4c7455b4d7a6339afc251"
977
+ integrity sha512-2LOYWUbnhdxdL8MNbNg9XZig6k+cZXm5IjHn2Aviv7honhBMOHb+jxrKIeJRZJRmn+htUCKhaicxwXuUDlchRA==
978
978
 
979
979
  icss-utils@^5.0.0, icss-utils@^5.1.0:
980
980
  version "5.1.0"
langgraph_api/serde.py CHANGED
@@ -3,7 +3,7 @@ import re
3
3
  import uuid
4
4
  from base64 import b64encode
5
5
  from collections import deque
6
- from collections.abc import Mapping
6
+ from collections.abc import Callable, Mapping
7
7
  from datetime import timedelta, timezone
8
8
  from decimal import Decimal
9
9
  from ipaddress import (
@@ -16,7 +16,7 @@ from ipaddress import (
16
16
  )
17
17
  from pathlib import Path
18
18
  from re import Pattern
19
- from typing import Any, NamedTuple, cast
19
+ from typing import Any, Literal, NamedTuple, cast
20
20
  from zoneinfo import ZoneInfo
21
21
 
22
22
  import cloudpickle
@@ -123,6 +123,14 @@ def _sanitise(o: Any) -> Any:
123
123
  if isinstance(o, Mapping):
124
124
  return {_sanitise(k): _sanitise(v) for k, v in o.items()}
125
125
  if isinstance(o, list | tuple | set):
126
+ if (
127
+ isinstance(o, tuple)
128
+ and hasattr(o, "_asdict")
129
+ and callable(o._asdict)
130
+ and hasattr(o, "_fields")
131
+ and isinstance(o._fields, tuple)
132
+ ): # named tuple
133
+ return {f: _sanitise(ov) for f, ov in zip(o._fields, o, strict=True)}
126
134
  ctor = list if isinstance(o, list) else type(o)
127
135
  return ctor(_sanitise(x) for x in o)
128
136
  return o
@@ -158,18 +166,46 @@ async def ajson_loads(content: bytes | Fragment) -> Any:
158
166
 
159
167
 
160
168
  class Serializer(JsonPlusSerializer):
169
+ def __init__(
170
+ self,
171
+ __unpack_ext_hook__: Callable[[int, bytes], Any] | None = None,
172
+ pickle_fallback: bool | None = None,
173
+ ):
174
+ from langgraph_api.config import SERDE
175
+
176
+ allowed_json_modules: list[tuple[str, ...]] | Literal[True] | None = None
177
+ if SERDE and "allowed_json_modules" in SERDE:
178
+ allowed_ = SERDE["allowed_json_modules"]
179
+ if allowed_ is True:
180
+ allowed_json_modules = True
181
+ elif allowed_ is None:
182
+ allowed_json_modules = None
183
+ else:
184
+ allowed_json_modules = [tuple(x) for x in allowed_]
185
+ if pickle_fallback is None:
186
+ if SERDE and "pickle_fallback" in SERDE:
187
+ pickle_fallback = SERDE["pickle_fallback"]
188
+ else:
189
+ pickle_fallback = True
190
+
191
+ super().__init__(
192
+ allowed_json_modules=allowed_json_modules,
193
+ __unpack_ext_hook__=__unpack_ext_hook__,
194
+ )
195
+ self.pickle_fallback = pickle_fallback
196
+
161
197
  def dumps_typed(self, obj: Any) -> tuple[str, bytes]:
162
198
  try:
163
199
  return super().dumps_typed(obj)
164
200
  except TypeError:
165
201
  return "pickle", cloudpickle.dumps(obj)
166
202
 
167
- def dumps(self, obj: Any) -> bytes:
168
- # See comment above (in json_dumpb)
169
- return super().dumps(obj).replace(rb"\\u0000", b"").replace(rb"\u0000", b"")
170
-
171
203
  def loads_typed(self, data: tuple[str, bytes]) -> Any:
172
204
  if data[0] == "pickle":
205
+ if not self.pickle_fallback:
206
+ raise ValueError(
207
+ "Pickle fallback is disabled. Cannot deserialize pickled object."
208
+ )
173
209
  try:
174
210
  return cloudpickle.loads(data[1])
175
211
  except Exception as e:
@@ -177,8 +213,16 @@ class Serializer(JsonPlusSerializer):
177
213
  "Failed to unpickle object, replacing w None", exc_info=e
178
214
  )
179
215
  return None
180
- return super().loads_typed(data)
181
-
182
-
183
- mpack_keys = {"method", "value"}
184
- SERIALIZER = Serializer()
216
+ try:
217
+ return super().loads_typed(data)
218
+ except Exception:
219
+ if data[0] == "json":
220
+ logger.exception(
221
+ "Heads up! There was a deserialization error of an item stored using 'json'-type serialization."
222
+ ' For security reasons, starting in langgraph-api version 0.5.0, we no longer serialize objects using the "json" type.'
223
+ " If you would like to retain the ability to deserialize old checkpoints saved in this format, "
224
+ 'please set the "allowed_json_modules" option in your langgraph.json configuration to add the'
225
+ " necessary module and type paths to an allow-list to be deserialized. You can alkso retain the"
226
+ ' ability to insecurely deserialize custom types by setting it to "true".'
227
+ )
228
+ raise
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langgraph-api
3
- Version: 0.4.47
4
- Author-email: Nuno Campos <nuno@langchain.dev>, Will Fu-Hinthorn <will@langchain.dev>
3
+ Version: 0.5.0
4
+ Author-email: Will Fu-Hinthorn <will@langchain.dev>, Josh Rogers <josh@langchain.dev>, Parker Rule <parker@langchain.dev>
5
5
  License: Elastic-2.0
6
6
  License-File: LICENSE
7
7
  Requires-Python: >=3.11
@@ -12,10 +12,10 @@ Requires-Dist: grpcio<2.0.0,>=1.75.0
12
12
  Requires-Dist: httpx>=0.25.0
13
13
  Requires-Dist: jsonschema-rs<0.30,>=0.20.0
14
14
  Requires-Dist: langchain-core>=0.3.64
15
- Requires-Dist: langgraph-checkpoint>=2.0.23
16
- Requires-Dist: langgraph-runtime-inmem<0.15.0,>=0.14.0
15
+ Requires-Dist: langgraph-checkpoint<4,>=3
16
+ Requires-Dist: langgraph-runtime-inmem<0.16.0,>=0.15.0
17
17
  Requires-Dist: langgraph-sdk>=0.2.0
18
- Requires-Dist: langgraph>=0.4.0
18
+ Requires-Dist: langgraph<2,>=0.4.10
19
19
  Requires-Dist: langsmith>=0.3.45
20
20
  Requires-Dist: opentelemetry-api>=1.37.0
21
21
  Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.37.0
@@ -1,9 +1,9 @@
1
- langgraph_api/__init__.py,sha256=LTTXCAiugz9gXBwbBhE-nz6e-HjwqO9hh9Ca7XLyWSQ,23
1
+ langgraph_api/__init__.py,sha256=LBK46heutvn3KmsCrKIYu8RQikbfnjZaj2xFrXaeCzQ,22
2
2
  langgraph_api/asgi_transport.py,sha256=XtiLOu4WWsd-xizagBLzT5xUkxc9ZG9YqwvETBPjBFE,5161
3
3
  langgraph_api/asyncio.py,sha256=FEEkLm_N-15cbElo4vQ309MkDKBZuRqAYV8VJ1DocNw,9860
4
4
  langgraph_api/cli.py,sha256=aEI2pfztEEziIwUk2imiLkNVK1LapMp_3dxvcar1org,18341
5
5
  langgraph_api/command.py,sha256=Bh-rvuTLwdHCqFWryCjB1M8oWxPBwRBUjMNj_04KPxM,852
6
- langgraph_api/config.py,sha256=79efOb8cBNNT1geUfVsUPJFycjUBXnIxWwMkMsbl36A,15292
6
+ langgraph_api/config.py,sha256=dETbZVXB7PRsJm1ZNDBSdcsMQGIl3KcltnavVTi2cz4,16791
7
7
  langgraph_api/cron_scheduler.py,sha256=25wYzEQrhPEivZrAPYOmzLPDOQa-aFogU37mTXc9TJk,2566
8
8
  langgraph_api/errors.py,sha256=zlnl3xXIwVG0oGNKKpXf1an9Rn_SBDHSyhe53hU6aLw,1858
9
9
  langgraph_api/executor_entrypoint.py,sha256=CaX813ygtf9CpOaBkfkQXJAHjFtmlScCkrOvTDmu4Aw,750
@@ -20,7 +20,7 @@ langgraph_api/route.py,sha256=EBhELuJ1He-ZYcAnR5YTImcIeDtWthDae5CHELBxPkM,5056
20
20
  langgraph_api/schema.py,sha256=spZ_XPT4AMJfw2YatsdnMZZLzgB9Sm3YR8n0SlgGdJ8,8480
21
21
  langgraph_api/self_hosted_logs.py,sha256=9ljOz3KH3O1SwsD7eTKnreyJ80NbeR7nj7SuxBlrmCc,4422
22
22
  langgraph_api/self_hosted_metrics.py,sha256=3FFezxjU0Vs-bsH39f4Dcwn7fporTLHV9REQ3UQ315A,14004
23
- langgraph_api/serde.py,sha256=Jkww6ixP5o2YZmnXtM7ihuAYC6YSuNDNPvE-8ILoqVo,5499
23
+ langgraph_api/serde.py,sha256=gNnTO98OVcIsfXJr60bG7GPioKUhTDZYqIWHc97Uyz4,7658
24
24
  langgraph_api/server.py,sha256=PExNHgem0tY_KkRFiFzj8m8Np6TrP4M0XJsEw6O2SAU,10112
25
25
  langgraph_api/sse.py,sha256=SLdtZmTdh5D8fbWrQjuY9HYLd2dg8Rmi6ZMmFMVc2iE,4204
26
26
  langgraph_api/state.py,sha256=AjkLbUQakIwK7oGzJ8oqubazRsXxG3vDMnRa0s0mzDM,4716
@@ -55,7 +55,7 @@ langgraph_api/grpc_ops/ops.py,sha256=OHU1ikDMKJXRSTU7zWDXorEuB6o9czLErijh3mhDYh0
55
55
  langgraph_api/grpc_ops/generated/__init__.py,sha256=dRiB_iGscPKdMpuLp9ueLwAmIfRaNjNXC64ABtb4cg8,135
56
56
  langgraph_api/grpc_ops/generated/core_api_pb2.py,sha256=l209i8cIazfs-zPTlt2jUg_og82oiDT4QMQCYAhU0P4,42262
57
57
  langgraph_api/grpc_ops/generated/core_api_pb2.pyi,sha256=6fnrjKRdN1-jJfHagLHhdlVog1cLkLoAc9fvTBzeFdM,49429
58
- langgraph_api/grpc_ops/generated/core_api_pb2_grpc.py,sha256=K_bHjM6BDzqIc1N8lc1SaxRLGFp1GUTpSiQEr5-70Oo,52466
58
+ langgraph_api/grpc_ops/generated/core_api_pb2_grpc.py,sha256=Qav2DuCMUSmR8nP4-fVtUBbY0Vc42jqjCs3L4LdIl-0,52467
59
59
  langgraph_api/js/.gitignore,sha256=l5yI6G_V6F1600I1IjiUKn87f4uYIrBAYU1MOyBBhg4,59
60
60
  langgraph_api/js/.prettierrc,sha256=0es3ovvyNIqIw81rPQsdt1zCQcOdBqyR_DMbFE4Ifms,19
61
61
  langgraph_api/js/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -65,14 +65,14 @@ langgraph_api/js/client.http.mts,sha256=FeVM53vduTPCyMPaYs__kmB3iWcz0k0om811DG0J
65
65
  langgraph_api/js/client.mts,sha256=8T5wp_114c2wGPfktY77StTnejhYL3ZWBmLwaUvp5XU,32333
66
66
  langgraph_api/js/errors.py,sha256=Cm1TKWlUCwZReDC5AQ6SgNIVGD27Qov2xcgHyf8-GXo,361
67
67
  langgraph_api/js/global.d.ts,sha256=j4GhgtQSZ5_cHzjSPcHgMJ8tfBThxrH-pUOrrJGteOU,196
68
- langgraph_api/js/package.json,sha256=besBq5s3c370nNWhHXy8ZxD0X350Xbzx4FNUDxhG-Pk,1330
68
+ langgraph_api/js/package.json,sha256=i6LBt4R-bi70FuMC3lIkZAuWZVJnlDE_CpI0mnArrOA,1330
69
69
  langgraph_api/js/remote.py,sha256=gBk273R7esmXg8aR6InxasNFc5E6Qju2bv2DhmmGJyU,38676
70
70
  langgraph_api/js/schema.py,sha256=M4fLtr50O1jck8H1hm_0W4cZOGYGdkrB7riLyCes4oY,438
71
71
  langgraph_api/js/sse.py,sha256=hHkbncnYnXNIbHhAWneGWYkHp4UhhhGB7-MYtDrY264,4141
72
72
  langgraph_api/js/traceblock.mts,sha256=QtGSN5VpzmGqDfbArrGXkMiONY94pMQ5CgzetT_bKYg,761
73
73
  langgraph_api/js/tsconfig.json,sha256=imCYqVnqFpaBoZPx8k1nO4slHIWBFsSlmCYhO73cpBs,341
74
74
  langgraph_api/js/ui.py,sha256=l9regrvKIxLOjH5SIYE2nhr8QCKLK1Q_1pZgxdL71X4,2488
75
- langgraph_api/js/yarn.lock,sha256=eWe1iuI634accFo7tumAcG8I7gLrcYKe7OyX0TMfK_s,83943
75
+ langgraph_api/js/yarn.lock,sha256=CV3hl-TyqWBKPLYvnWcn42-95nxVlDJRvUuPcC-CQuo,83943
76
76
  langgraph_api/js/src/graph.mts,sha256=9zTQNdtanI_CFnOwNRoamoCVHHQHGbNlbm91aRxDeOc,2675
77
77
  langgraph_api/js/src/load.hooks.mjs,sha256=xNVHq75W0Lk6MUKl1pQYrx-wtQ8_neiUyI6SO-k0ecM,2235
78
78
  langgraph_api/js/src/preload.mjs,sha256=8m3bYkf9iZLCQzKAYAdU8snxUwAG3dVLwGvAjfGfgIc,959
@@ -110,8 +110,8 @@ langgraph_runtime/store.py,sha256=7mowndlsIroGHv3NpTSOZDJR0lCuaYMBoTnTrewjslw,11
110
110
  LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
111
111
  logging.json,sha256=3RNjSADZmDq38eHePMm1CbP6qZ71AmpBtLwCmKU9Zgo,379
112
112
  openapi.json,sha256=Oi2tU1b8PsXb-6XNHafQvcZv934vLNQhBNPYXr9e2nU,172620
113
- langgraph_api-0.4.47.dist-info/METADATA,sha256=Eg-ZE0e8ulDNYt7HYdEUEpmKwOLN7PWCoJAcgXT4EHc,4149
114
- langgraph_api-0.4.47.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
115
- langgraph_api-0.4.47.dist-info/entry_points.txt,sha256=hGedv8n7cgi41PypMfinwS_HfCwA7xJIfS0jAp8htV8,78
116
- langgraph_api-0.4.47.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
117
- langgraph_api-0.4.47.dist-info/RECORD,,
113
+ langgraph_api-0.5.0.dist-info/METADATA,sha256=d7BUiRTQvo_lZiqlTNbgpgVeEQBnItS9VqQGp1QeMEQ,4186
114
+ langgraph_api-0.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
115
+ langgraph_api-0.5.0.dist-info/entry_points.txt,sha256=hGedv8n7cgi41PypMfinwS_HfCwA7xJIfS0jAp8htV8,78
116
+ langgraph_api-0.5.0.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
117
+ langgraph_api-0.5.0.dist-info/RECORD,,