langgraph-api 0.2.17__py3-none-any.whl → 0.2.19__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.2.17"
1
+ __version__ = "0.2.19"
@@ -24,119 +24,6 @@ def set_custom_spec(spec: dict):
24
24
  CUSTOM_OPENAPI_SPEC = spec
25
25
 
26
26
 
27
- def get_mcp_openapi_paths() -> dict:
28
- """Returns the OpenAPI path definitions for the /mcp/ endpoint."""
29
- return {
30
- "/mcp/": {
31
- "get": {
32
- "operationId": "get_mcp",
33
- "summary": "MCP Get",
34
- "description": (
35
- "Implemented according to the Streamable HTTP Transport "
36
- "specification."
37
- ),
38
- "responses": {
39
- "405": {
40
- "description": "GET method not allowed; streaming not "
41
- "supported.",
42
- }
43
- },
44
- "tags": ["MCP"],
45
- },
46
- "post": {
47
- "operationId": "post_mcp",
48
- "summary": "MCP Post",
49
- "description": (
50
- "Implemented according to the Streamable HTTP Transport "
51
- "specification.\n"
52
- "Sends a JSON-RPC 2.0 message to the server.\n\n"
53
- "- **Request**: Provide an object with `jsonrpc`, `id`, `method`, "
54
- "and optional `params`.\n"
55
- "- **Response**: Returns a JSON-RPC response or acknowledgment.\n\n"
56
- "**Notes:**\n"
57
- "- Stateless: Sessions are not persisted across requests.\n"
58
- ),
59
- "parameters": [
60
- {
61
- "name": "Accept",
62
- "in": "header",
63
- "required": True,
64
- "schema": {
65
- "type": "string",
66
- "enum": [
67
- "application/json, text/event-stream",
68
- ],
69
- },
70
- "description": (
71
- "Accept header must include both "
72
- "'application/json' and 'text/event-stream' "
73
- "media types."
74
- ),
75
- }
76
- ],
77
- "requestBody": {
78
- "required": True,
79
- "content": {
80
- "application/json": {
81
- "schema": {"type": "object"},
82
- "description": "A JSON-RPC 2.0 request, notification, "
83
- "or response object.",
84
- "example": {
85
- "jsonrpc": "2.0",
86
- "id": "1",
87
- "method": "initialize",
88
- "params": {
89
- "clientInfo": {
90
- "name": "test_client",
91
- "version": "1.0.0",
92
- },
93
- "protocolVersion": "2024-11-05",
94
- "capabilities": {},
95
- },
96
- },
97
- }
98
- },
99
- },
100
- "responses": {
101
- "200": {
102
- "description": "Successful JSON-RPC response.",
103
- "content": {"application/json": {"schema": {"type": "object"}}},
104
- },
105
- "202": {
106
- "description": "Notification or response accepted; no content "
107
- "body.",
108
- },
109
- "400": {
110
- "description": "Bad request: invalid JSON or message format, "
111
- "or unacceptable Accept header.",
112
- },
113
- "405": {
114
- "description": "HTTP method not allowed.",
115
- },
116
- "500": {
117
- "description": "Internal server error or unexpected failure.",
118
- },
119
- },
120
- "tags": ["MCP"],
121
- },
122
- "delete": {
123
- "operationId": "delete_mcp",
124
- "summary": "Terminate Session",
125
- "description": (
126
- "Implemented according to the Streamable HTTP Transport "
127
- "specification.\n"
128
- "Terminate an MCP session. The server implementation is stateless, "
129
- "so this is a no-op.\n\n"
130
- ),
131
- "responses": {
132
- "404": {},
133
- },
134
- "tags": ["MCP"],
135
- },
136
- }
137
- }
138
-
139
-
140
27
  @lru_cache(maxsize=1)
141
28
  def get_openapi_spec() -> str:
142
29
  # patch the graph_id enums
@@ -201,10 +88,9 @@ def get_openapi_spec() -> str:
201
88
 
202
89
  MCP_ENABLED = HTTP_CONFIG is None or not HTTP_CONFIG.get("disable_mcp")
203
90
 
204
- if MCP_ENABLED:
205
- # Add the MCP paths to the OpenAPI spec
206
- mcp_path = get_mcp_openapi_paths()
207
- final["paths"]["/mcp/"] = mcp_path["/mcp/"]
91
+ if not MCP_ENABLED:
92
+ # Remove the MCP paths from the OpenAPI spec
93
+ final["paths"].pop("/mcp/", None)
208
94
 
209
95
  return orjson.dumps(final)
210
96
 
@@ -1,3 +1,8 @@
1
+ # ruff: noqa: E402
2
+ import truststore # noqa: F401
3
+
4
+ truststore.inject_into_ssl() # noqa: F401
5
+
1
6
  import asyncio
2
7
  import http.server
3
8
  import json
langgraph_api/server.py CHANGED
@@ -1,4 +1,5 @@
1
1
  # MONKEY PATCH: Patch Starlette to fix an error in the library
2
+ # ruff: noqa: E402
2
3
  import langgraph_api.patch # noqa: F401,I001
3
4
  import sys
4
5
 
@@ -6,34 +7,37 @@ import sys
6
7
  # patches an error in the Starlette library.
7
8
  import logging
8
9
  import typing
10
+ import truststore # noqa: F401
11
+
12
+ truststore.inject_into_ssl() # noqa: F401
13
+
14
+ from contextlib import asynccontextmanager
9
15
 
10
16
  import jsonschema_rs
11
17
  import structlog
12
- from contextlib import asynccontextmanager
13
18
  from langgraph.errors import EmptyInputError, InvalidUpdateError
19
+ from langgraph_sdk.client import configure_loopback_transports
14
20
  from starlette.applications import Starlette
15
21
  from starlette.middleware import Middleware
16
22
  from starlette.middleware.cors import CORSMiddleware
17
-
18
- from langgraph_api.api.openapi import set_custom_spec
23
+ from starlette.routing import Mount
19
24
  from starlette.types import Receive, Scope, Send
20
25
 
21
26
  import langgraph_api.config as config
22
- from langgraph_api.api import routes, meta_routes, user_router
23
- from starlette.routing import Mount
27
+ from langgraph_api.api import meta_routes, routes, user_router
28
+ from langgraph_api.api.openapi import set_custom_spec
24
29
  from langgraph_api.errors import (
25
30
  overloaded_error_handler,
26
31
  validation_error_handler,
27
32
  value_error_handler,
28
33
  )
29
- from langgraph_runtime.lifespan import lifespan
34
+ from langgraph_api.js.base import is_js_path
30
35
  from langgraph_api.middleware.http_logger import AccessLoggerMiddleware
31
36
  from langgraph_api.middleware.private_network import PrivateNetworkMiddleware
32
37
  from langgraph_api.middleware.request_id import RequestIdMiddleware
33
38
  from langgraph_api.utils import SchemaGenerator
39
+ from langgraph_runtime.lifespan import lifespan
34
40
  from langgraph_runtime.retry import OVERLOADED_EXCEPTIONS
35
- from langgraph_api.js.base import is_js_path
36
- from langgraph_sdk.client import configure_loopback_transports
37
41
 
38
42
  logging.captureWarnings(True)
39
43
  logger = structlog.stdlib.get_logger(__name__)
langgraph_api/stream.py CHANGED
@@ -163,6 +163,7 @@ async def astream_state(
163
163
  ns, mode, chunk = event["data"]["chunk"]
164
164
  else:
165
165
  mode, chunk = event["data"]["chunk"]
166
+ ns = None
166
167
  # --- begin shared logic with astream ---
167
168
  if mode == "debug":
168
169
  if chunk["type"] == "checkpoint":
@@ -172,7 +173,10 @@ async def astream_state(
172
173
  on_task_result(chunk["payload"])
173
174
  if mode == "messages":
174
175
  if "messages-tuple" in stream_mode:
175
- yield "messages", chunk
176
+ if subgraphs and ns:
177
+ yield f"messages|{'|'.join(ns)}", chunk
178
+ else:
179
+ yield "messages", chunk
176
180
  else:
177
181
  msg, meta = cast(tuple[BaseMessage, dict[str, Any]], chunk)
178
182
  if msg.id in messages:
@@ -214,6 +218,7 @@ async def astream_state(
214
218
  ns, mode, chunk = event
215
219
  else:
216
220
  mode, chunk = event
221
+ ns = None
217
222
  # --- begin shared logic with astream_events ---
218
223
  if mode == "debug":
219
224
  if chunk["type"] == "checkpoint":
@@ -223,7 +228,10 @@ async def astream_state(
223
228
  on_task_result(chunk["payload"])
224
229
  if mode == "messages":
225
230
  if "messages-tuple" in stream_mode:
226
- yield "messages", chunk
231
+ if subgraphs and ns:
232
+ yield f"messages|{'|'.join(ns)}", chunk
233
+ else:
234
+ yield "messages", chunk
227
235
  else:
228
236
  msg, meta = cast(tuple[BaseMessage, dict[str, Any]], chunk)
229
237
  if msg.id in messages:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: langgraph-api
3
- Version: 0.2.17
3
+ Version: 0.2.19
4
4
  Summary:
5
5
  License: Elastic-2.0
6
6
  Author: Nuno Campos
@@ -27,6 +27,7 @@ Requires-Dist: sse-starlette (>=2.1.0,<2.2.0)
27
27
  Requires-Dist: starlette (>=0.38.6)
28
28
  Requires-Dist: structlog (>=24.1.0,<26)
29
29
  Requires-Dist: tenacity (>=8.0.0)
30
+ Requires-Dist: truststore (>=0.1)
30
31
  Requires-Dist: uvicorn (>=0.26.0)
31
32
  Requires-Dist: watchfiles (>=0.13)
32
33
  Description-Content-Type: text/markdown
@@ -1,10 +1,10 @@
1
1
  LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
2
- langgraph_api/__init__.py,sha256=Qi17SZ8BBtfJyUgJ1-dmlKGJmEwoMRO4CvqGYPFRAhw,23
2
+ langgraph_api/__init__.py,sha256=VZ7jBWhGCupQczZf5QIzaN_QnESJ96jWOGwTAhYaIwY,23
3
3
  langgraph_api/api/__init__.py,sha256=YVzpbn5IQotvuuLG9fhS9QMrxXfP4s4EpEMG0n4q3Nw,5625
4
4
  langgraph_api/api/assistants.py,sha256=mcKaVeNG8hQAV4IQDhaukS7FgVqTIVQNTyti3GfK2KI,14649
5
5
  langgraph_api/api/mcp.py,sha256=RvRYgANqRzNQzSmgjNkq4RlKTtoEJYil04ot9lsmEtE,14352
6
6
  langgraph_api/api/meta.py,sha256=sTgkhE-DaFWpERG6F7KelZfDsmJAiVc4j5dg50tDkSo,2950
7
- langgraph_api/api/openapi.py,sha256=WYpkjwsVV056qBkBVbGjhh-TfU9-IgZMY2au1s1PhZ4,15953
7
+ langgraph_api/api/openapi.py,sha256=362m6Ny8wOwZ6HrDK9JAVUzPkyLYWKeV1E71hPOaA0U,11278
8
8
  langgraph_api/api/runs.py,sha256=ys8X3g2EGbuF_OF1htM4jcLu4Mqztd8v7ttosmIbdsw,17972
9
9
  langgraph_api/api/store.py,sha256=G4Fm8hgFLlJUW5_ekLS_IOgCfpFy-TK9uq5r9QTOELQ,5447
10
10
  langgraph_api/api/threads.py,sha256=ogMKmEoiycuaV3fa5kpupDohJ7fwUOfVczt6-WSK4FE,9322
@@ -78,14 +78,14 @@ langgraph_api/middleware/request_id.py,sha256=jBaL-zRLIYuGkYBz1poSH35ld_GDRuiMR5
78
78
  langgraph_api/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
79
79
  langgraph_api/models/run.py,sha256=kVdxF239sVmdvXUZNBL-GV0-euZO-Ca2Jz8qseNycKM,13362
80
80
  langgraph_api/patch.py,sha256=Dgs0PXHytekX4SUL6KsjjN0hHcOtGLvv1GRGbh6PswU,1408
81
- langgraph_api/queue_entrypoint.py,sha256=gjtajZfnDXhsi7JElfmkY-p0ENBiKBDJ4Ugiw-exapw,1839
81
+ langgraph_api/queue_entrypoint.py,sha256=IdEkmBma9VTx8RTVNAGXMk2dO6b6F6uAq6uiyB23Yjg,1935
82
82
  langgraph_api/route.py,sha256=uN311KjIugyNHG3rmVw_ms61QO1W1l16jJx03rf0R_s,4630
83
83
  langgraph_api/schema.py,sha256=2711t4PIBk5dky4gmMndrTRC9CVvAgH47C9FKDxhkBo,5444
84
84
  langgraph_api/serde.py,sha256=TVsx2QQtepf8Wsgsabcku1NV4Vbugu4Oujmdnq4qMS0,3964
85
- langgraph_api/server.py,sha256=CzBeOr8fjaVSbdmBNysx3zACSxTV8DrmeU7EQvZrlDE,6742
85
+ langgraph_api/server.py,sha256=4P7GpXbE9m-sAV7rBQ4Gd3oFk6htNbL-tRQfICAFc2k,6837
86
86
  langgraph_api/sse.py,sha256=3jG_FZj8FI9r7xGWTqaAyDkmqf6P1NOu0EzGrcSOGYc,4033
87
87
  langgraph_api/state.py,sha256=8jx4IoTCOjTJuwzuXJKKFwo1VseHjNnw_CCq4x1SW14,2284
88
- langgraph_api/stream.py,sha256=a4sjBm3XhHK6NC4OD1dHey53t6czKodvrlxh9rfjfSA,11718
88
+ langgraph_api/stream.py,sha256=BEDhdpoXIL6CpSOEUSYG5ZZC8b4DnyThHX5rHB3xGa4,12088
89
89
  langgraph_api/thread_ttl.py,sha256=-Ox8NFHqUH3wGNdEKMIfAXUubY5WGifIgCaJ7npqLgw,1762
90
90
  langgraph_api/tunneling/cloudflare.py,sha256=iKb6tj-VWPlDchHFjuQyep2Dpb-w2NGfJKt-WJG9LH0,3650
91
91
  langgraph_api/utils.py,sha256=92mSti9GfGdMRRWyESKQW5yV-75Z9icGHnIrBYvdypU,3619
@@ -96,9 +96,9 @@ langgraph_license/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
96
96
  langgraph_license/validation.py,sha256=ZKraAVJArAABKqrmHN-EN18ncoNUmRm500Yt1Sc7tUA,537
97
97
  langgraph_runtime/__init__.py,sha256=O4GgSmu33c-Pr8Xzxj_brcK5vkm70iNTcyxEjICFZxA,1075
98
98
  logging.json,sha256=3RNjSADZmDq38eHePMm1CbP6qZ71AmpBtLwCmKU9Zgo,379
99
- openapi.json,sha256=GefWJwBrbrN_jNDAEFlwNEXx1ottRtvjOmKBi965KLU,133756
100
- langgraph_api-0.2.17.dist-info/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
101
- langgraph_api-0.2.17.dist-info/METADATA,sha256=qkB425B5OjMnlTsmEE8t_KzoaQblgohDR_qomjXRgE4,4241
102
- langgraph_api-0.2.17.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
103
- langgraph_api-0.2.17.dist-info/entry_points.txt,sha256=3EYLgj89DfzqJHHYGxPH4A_fEtClvlRbWRUHaXO7hj4,77
104
- langgraph_api-0.2.17.dist-info/RECORD,,
99
+ openapi.json,sha256=h2zgGTQD9houdruwRdNwZuAFo-w3eP_f6huQ6jRFp84,133801
100
+ langgraph_api-0.2.19.dist-info/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
101
+ langgraph_api-0.2.19.dist-info/METADATA,sha256=7hAk2NlP1M_FSYz6CVxxV4lUHXZJZq8WVwLfY0Htwgo,4275
102
+ langgraph_api-0.2.19.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
103
+ langgraph_api-0.2.19.dist-info/entry_points.txt,sha256=3EYLgj89DfzqJHHYGxPH4A_fEtClvlRbWRUHaXO7hj4,77
104
+ langgraph_api-0.2.19.dist-info/RECORD,,