langchain-protocol 0.0.8__tar.gz

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.
@@ -0,0 +1,143 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ lerna-debug.log*
8
+
9
+ # Diagnostic reports (https://nodejs.org/api/report.html)
10
+ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11
+
12
+ # Runtime data
13
+ pids
14
+ *.pid
15
+ *.seed
16
+ *.pid.lock
17
+
18
+ # Directory for instrumented libs generated by jscoverage/JSCover
19
+ lib-cov
20
+
21
+ # Coverage directory used by tools like istanbul
22
+ coverage
23
+ *.lcov
24
+
25
+ # nyc test coverage
26
+ .nyc_output
27
+
28
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29
+ .grunt
30
+
31
+ # Bower dependency directory (https://bower.io/)
32
+ bower_components
33
+
34
+ # node-waf configuration
35
+ .lock-wscript
36
+
37
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
38
+ build/Release
39
+
40
+ # Dependency directories
41
+ node_modules/
42
+ jspm_packages/
43
+
44
+ # Snowpack dependency directory (https://snowpack.dev/)
45
+ web_modules/
46
+
47
+ # TypeScript cache
48
+ *.tsbuildinfo
49
+
50
+ # Optional npm cache directory
51
+ .npm
52
+
53
+ # Optional eslint cache
54
+ .eslintcache
55
+
56
+ # Optional stylelint cache
57
+ .stylelintcache
58
+
59
+ # Optional REPL history
60
+ .node_repl_history
61
+
62
+ # Output of 'npm pack'
63
+ *.tgz
64
+
65
+ # Yarn Integrity file
66
+ .yarn-integrity
67
+
68
+ # dotenv environment variable files
69
+ .env
70
+ .env.*
71
+ !.env.example
72
+
73
+ # parcel-bundler cache (https://parceljs.org/)
74
+ .cache
75
+ .parcel-cache
76
+
77
+ # Next.js build output
78
+ .next
79
+ out
80
+
81
+ # Nuxt.js build / generate output
82
+ .nuxt
83
+ dist
84
+
85
+ # Gatsby files
86
+ .cache/
87
+ # Comment in the public line in if your project uses Gatsby and not Next.js
88
+ # https://nextjs.org/blog/next-9-1#public-directory-support
89
+ # public
90
+
91
+ # vuepress build output
92
+ .vuepress/dist
93
+
94
+ # vuepress v2.x temp and cache directory
95
+ .temp
96
+ .cache
97
+
98
+ # Sveltekit cache directory
99
+ .svelte-kit/
100
+
101
+ # vitepress build output
102
+ **/.vitepress/dist
103
+
104
+ # vitepress cache directory
105
+ **/.vitepress/cache
106
+
107
+ # Docusaurus cache and generated files
108
+ .docusaurus
109
+
110
+ # Serverless directories
111
+ .serverless/
112
+
113
+ # FuseBox cache
114
+ .fusebox/
115
+
116
+ # DynamoDB Local files
117
+ .dynamodb/
118
+
119
+ # Firebase cache directory
120
+ .firebase/
121
+
122
+ # TernJS port file
123
+ .tern-port
124
+
125
+ # Stores VSCode versions used for testing VSCode extensions
126
+ .vscode-test
127
+
128
+ # yarn v3
129
+ .pnp.*
130
+ .yarn/*
131
+ !.yarn/patches
132
+ !.yarn/plugins
133
+ !.yarn/releases
134
+ !.yarn/sdks
135
+ !.yarn/versions
136
+
137
+ # Vite logs files
138
+ vite.config.js.timestamp-*
139
+ vite.config.ts.timestamp-*
140
+ .DS_Store
141
+
142
+ # Python
143
+ __pycache__/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 LangChain, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,59 @@
1
+ Metadata-Version: 2.4
2
+ Name: langchain-protocol
3
+ Version: 0.0.8
4
+ Summary: Python bindings for the LangChain agent streaming protocol
5
+ Project-URL: Repository, https://github.com/langchain-ai/protocol
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: <4.0.0,>=3.10.0
20
+ Requires-Dist: typing-extensions<5.0.0,>=4.7.0
21
+ Description-Content-Type: text/markdown
22
+
23
+ # langchain-protocol
24
+
25
+ Python bindings for the LangChain agent streaming protocol.
26
+
27
+ The canonical schema lives in [`../protocol.cddl`](../protocol.cddl), and the
28
+ definitions in [`langchain_protocol/protocol.py`](./langchain_protocol/protocol.py)
29
+ are generated from that schema.
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ pip install langchain-protocol
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ ```python
40
+ from langchain_protocol import Command, SessionOpenParams
41
+
42
+ params: SessionOpenParams = {
43
+ "protocol_version": "0.3.0",
44
+ }
45
+
46
+ open_command: Command = {
47
+ "id": 1,
48
+ "method": "session.open",
49
+ "params": params,
50
+ }
51
+ ```
52
+
53
+ ## What this package includes
54
+
55
+ - `TypedDict` definitions for commands, events, results, and payload shapes
56
+ - `Literal` and union aliases for protocol enums and tagged unions
57
+
58
+ This package does not include a runtime client, transport, or helper APIs.
59
+ It is intended as a source of generated typing primitives only.
@@ -0,0 +1,37 @@
1
+ # langchain-protocol
2
+
3
+ Python bindings for the LangChain agent streaming protocol.
4
+
5
+ The canonical schema lives in [`../protocol.cddl`](../protocol.cddl), and the
6
+ definitions in [`langchain_protocol/protocol.py`](./langchain_protocol/protocol.py)
7
+ are generated from that schema.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install langchain-protocol
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```python
18
+ from langchain_protocol import Command, SessionOpenParams
19
+
20
+ params: SessionOpenParams = {
21
+ "protocol_version": "0.3.0",
22
+ }
23
+
24
+ open_command: Command = {
25
+ "id": 1,
26
+ "method": "session.open",
27
+ "params": params,
28
+ }
29
+ ```
30
+
31
+ ## What this package includes
32
+
33
+ - `TypedDict` definitions for commands, events, results, and payload shapes
34
+ - `Literal` and union aliases for protocol enums and tagged unions
35
+
36
+ This package does not include a runtime client, transport, or helper APIs.
37
+ It is intended as a source of generated typing primitives only.
@@ -0,0 +1,3 @@
1
+ """Python bindings for the LangChain agent streaming protocol."""
2
+
3
+ from langchain_protocol.protocol import * # noqa: F403
@@ -0,0 +1,539 @@
1
+ # compiled with https://www.npmjs.com/package/cddl2py v0.2.2
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Annotated, Any, Literal, Union
6
+ from typing_extensions import NotRequired, TypedDict
7
+
8
+ JsInt = int
9
+
10
+ JsUint = int
11
+
12
+ Namespace = list[str]
13
+
14
+ Extensible = dict[str, Any]
15
+
16
+ Timestamp = int
17
+
18
+ MetadataScalar = Union[None, bool, int, float, str]
19
+
20
+ MessageRole = Union[Literal["ai"], Literal["human"], Literal["system"]]
21
+
22
+ class MessageMetadata(TypedDict, extra_items=MetadataScalar):
23
+ provider: NotRequired[str]
24
+ model: NotRequired[str]
25
+ model_type: NotRequired[str]
26
+ run_id: NotRequired[str]
27
+ thread_id: NotRequired[str]
28
+ system_fingerprint: NotRequired[str]
29
+ service_tier: NotRequired[str]
30
+
31
+ class TextBlock(TypedDict):
32
+ type: str
33
+ text: str
34
+ id: NotRequired[str]
35
+ index: NotRequired[JsInt]
36
+ annotations: NotRequired[list[Annotation]]
37
+
38
+ class ReasoningBlock(TypedDict):
39
+ type: Literal["reasoning"]
40
+ reasoning: str
41
+ id: NotRequired[str]
42
+ index: NotRequired[JsInt]
43
+ signature: NotRequired[str]
44
+ redacted: NotRequired[bool]
45
+
46
+ class ToolCallBlock(TypedDict):
47
+ type: Literal["tool_call"]
48
+ id: str
49
+ name: str
50
+ args: Any
51
+
52
+ class ToolCallChunkBlock(TypedDict):
53
+ type: Literal["tool_call_chunk"]
54
+ id: NotRequired[str]
55
+ name: NotRequired[str]
56
+ args: NotRequired[str] # Partial JSON string
57
+ index: NotRequired[JsInt]
58
+
59
+ class InvalidToolCallBlock(TypedDict):
60
+ type: Literal["invalid_tool_call"]
61
+ id: NotRequired[str]
62
+ name: NotRequired[str]
63
+ args: NotRequired[str]
64
+ error: NotRequired[str]
65
+
66
+ class ServerToolCallBlock(TypedDict):
67
+ type: Literal["server_tool_call"]
68
+ id: str
69
+ name: str
70
+ args: Any
71
+
72
+ class ServerToolCallChunkBlock(TypedDict):
73
+ type: Literal["server_tool_call_chunk"]
74
+ id: NotRequired[str]
75
+ name: NotRequired[str]
76
+ args: NotRequired[str]
77
+
78
+ class ServerToolCallResultBlock(TypedDict):
79
+ type: Literal["server_tool_call_result"]
80
+ tool_call_id: str
81
+ status: Union[Literal["success"], Literal["error"]]
82
+ output: Any
83
+
84
+ class ImageBlock(TypedDict):
85
+ type: Literal["image"]
86
+ id: NotRequired[str]
87
+ url: NotRequired[str]
88
+ data: NotRequired[str] # Base64-encoded image data
89
+ mime_type: NotRequired[str]
90
+ width: NotRequired[int]
91
+ height: NotRequired[int]
92
+
93
+ class AudioBlock(TypedDict):
94
+ type: Literal["audio"]
95
+ id: NotRequired[str]
96
+ url: NotRequired[str]
97
+ data: NotRequired[str] # Base64-encoded audio data
98
+ mime_type: NotRequired[str]
99
+ transcript: NotRequired[str]
100
+
101
+ class VideoBlock(TypedDict):
102
+ type: Literal["video"]
103
+ id: NotRequired[str]
104
+ url: NotRequired[str]
105
+ data: NotRequired[str] # Base64-encoded video data
106
+ mime_type: NotRequired[str]
107
+
108
+ class FileBlock(TypedDict):
109
+ type: Literal["file"]
110
+ id: NotRequired[str]
111
+ url: NotRequired[str]
112
+ data: NotRequired[str] # Base64-encoded file data
113
+ mime_type: NotRequired[str]
114
+ filename: NotRequired[str]
115
+
116
+ class NonStandardBlock(TypedDict):
117
+ type: Literal["non_standard"]
118
+ value: dict[str, Any]
119
+ id: NotRequired[str]
120
+
121
+ ContentBlock = Union[TextBlock, ReasoningBlock, ToolCallBlock, ToolCallChunkBlock, InvalidToolCallBlock, ServerToolCallBlock, ServerToolCallChunkBlock, ServerToolCallResultBlock, ImageBlock, AudioBlock, VideoBlock, FileBlock, NonStandardBlock]
122
+
123
+ FinalizedContentBlock = Union[TextBlock, ReasoningBlock, ToolCallBlock, InvalidToolCallBlock, ServerToolCallBlock, ServerToolCallResultBlock, ImageBlock, AudioBlock, VideoBlock, FileBlock, NonStandardBlock]
124
+
125
+ class Citation(TypedDict):
126
+ type: Literal["citation"]
127
+ url: NotRequired[str]
128
+ title: NotRequired[str]
129
+ start_index: NotRequired[int]
130
+ end_index: NotRequired[int]
131
+
132
+ Annotation = Union[Citation, ContentBlock]
133
+
134
+ class RunInput(TypedDict):
135
+ method: Literal["run.input"]
136
+ params: RunInputParams
137
+
138
+ class SubscriptionSubscribe(TypedDict):
139
+ method: Literal["subscription.subscribe"]
140
+ params: SubscribeParams
141
+
142
+ class SubscriptionUnsubscribe(TypedDict):
143
+ method: Literal["subscription.unsubscribe"]
144
+ params: UnsubscribeParams
145
+
146
+ class SubscriptionReconnect(TypedDict):
147
+ method: Literal["subscription.reconnect"]
148
+ params: ReconnectParams
149
+
150
+ SubscriptionCommand = Union[SubscriptionSubscribe, SubscriptionUnsubscribe, SubscriptionReconnect]
151
+
152
+ class FlowSetCapacity(TypedDict):
153
+ method: Literal["flow.setCapacity"]
154
+ params: FlowCapacityParams
155
+
156
+ class AgentGetTree(TypedDict):
157
+ method: Literal["agent.getTree"]
158
+ params: AgentGetTreeParams
159
+
160
+ class InputRespond(TypedDict):
161
+ method: Literal["input.respond"]
162
+ params: InputRespondParams
163
+
164
+ class InputInject(TypedDict):
165
+ method: Literal["input.inject"]
166
+ params: InputInjectParams
167
+
168
+ InputCommand = Union[InputRespond, InputInject]
169
+
170
+ class StateGet(TypedDict):
171
+ method: Literal["state.get"]
172
+ params: StateGetParams
173
+
174
+ class StateListCheckpoints(TypedDict):
175
+ method: Literal["state.listCheckpoints"]
176
+ params: ListCheckpointsParams
177
+
178
+ class StateFork(TypedDict):
179
+ method: Literal["state.fork"]
180
+ params: StateForkParams
181
+
182
+ StateCommand = Union[StateGet, StateListCheckpoints, StateFork]
183
+
184
+ class _CommandFields(TypedDict):
185
+ id: JsUint
186
+
187
+ class _CommandVariant1(_CommandFields, SubscriptionSubscribe):
188
+ pass
189
+
190
+ class _CommandVariant2(_CommandFields, SubscriptionUnsubscribe):
191
+ pass
192
+
193
+ class _CommandVariant3(_CommandFields, SubscriptionReconnect):
194
+ pass
195
+
196
+ class _CommandVariant6(_CommandFields, InputRespond):
197
+ pass
198
+
199
+ class _CommandVariant7(_CommandFields, InputInject):
200
+ pass
201
+
202
+ class _CommandVariant8(_CommandFields, StateGet):
203
+ pass
204
+
205
+ class _CommandVariant9(_CommandFields, StateListCheckpoints):
206
+ pass
207
+
208
+ class _CommandVariant10(_CommandFields, StateFork):
209
+ pass
210
+
211
+ class CommandResponse(TypedDict):
212
+ type: Literal["success"]
213
+ id: JsUint
214
+ result: ResultData
215
+ meta: NotRequired[ResponseMeta]
216
+
217
+ class ErrorResponse(TypedDict):
218
+ type: Literal["error"]
219
+ id: Union[JsUint, None]
220
+ error: ErrorCode
221
+ message: str
222
+ stacktrace: NotRequired[str]
223
+ meta: NotRequired[ResponseMeta]
224
+
225
+ class LifecycleEvent(TypedDict):
226
+ method: Literal["lifecycle"]
227
+ params: dict[str, Any]
228
+
229
+ class MessagesEvent(TypedDict):
230
+ method: Literal["messages"]
231
+ params: dict[str, Any]
232
+
233
+ class ToolsEvent(TypedDict):
234
+ method: Literal["tools"]
235
+ params: dict[str, Any]
236
+
237
+ class InputEvent(TypedDict):
238
+ method: Literal["input.requested"]
239
+ params: dict[str, Any]
240
+
241
+ class ValuesEvent(TypedDict):
242
+ method: Literal["values"]
243
+ params: dict[str, Any]
244
+
245
+ class UpdatesEvent(TypedDict):
246
+ method: Literal["updates"]
247
+ params: dict[str, Any]
248
+
249
+ class CustomEvent(TypedDict):
250
+ method: Literal["custom"]
251
+ params: dict[str, Any]
252
+
253
+ class DebugEvent(TypedDict):
254
+ method: Literal["debug"]
255
+ params: dict[str, Any]
256
+
257
+ class CheckpointsEvent(TypedDict):
258
+ method: Literal["checkpoints"]
259
+ params: dict[str, Any]
260
+
261
+ class TasksEvent(TypedDict):
262
+ method: Literal["tasks"]
263
+ params: dict[str, Any]
264
+
265
+ EventData = Union[LifecycleEvent, MessagesEvent, ToolsEvent, InputEvent, ValuesEvent, UpdatesEvent, CustomEvent, DebugEvent, CheckpointsEvent, TasksEvent]
266
+
267
+ class _EventFields(TypedDict):
268
+ type: Literal["event"]
269
+ event_id: NotRequired[str] # Unique ID for reconnection (maps to SSE id:)
270
+ seq: NotRequired[JsUint] # Monotonic sequence number for ordering
271
+
272
+ class _EventVariant0(_EventFields, LifecycleEvent):
273
+ pass
274
+
275
+ class _EventVariant1(_EventFields, MessagesEvent):
276
+ pass
277
+
278
+ class _EventVariant2(_EventFields, ToolsEvent):
279
+ pass
280
+
281
+ class _EventVariant3(_EventFields, InputEvent):
282
+ pass
283
+
284
+ class _EventVariant4(_EventFields, ValuesEvent):
285
+ pass
286
+
287
+ class _EventVariant5(_EventFields, UpdatesEvent):
288
+ pass
289
+
290
+ class _EventVariant6(_EventFields, CustomEvent):
291
+ pass
292
+
293
+ class _EventVariant7(_EventFields, DebugEvent):
294
+ pass
295
+
296
+ class _EventVariant8(_EventFields, CheckpointsEvent):
297
+ pass
298
+
299
+ class _EventVariant9(_EventFields, TasksEvent):
300
+ pass
301
+
302
+ Event = Union[_EventVariant0, _EventVariant1, _EventVariant2, _EventVariant3, _EventVariant4, _EventVariant5, _EventVariant6, _EventVariant7, _EventVariant8, _EventVariant9]
303
+
304
+ Message = Union[CommandResponse, ErrorResponse, Event]
305
+
306
+ class RunResult(TypedDict):
307
+ run_id: NotRequired[str] # ID of the started or resumed run
308
+
309
+ class SubscribeResult(TypedDict):
310
+ subscription_id: str
311
+ replayed_events: NotRequired[int] # Events replayed from buffer
312
+
313
+ class ReconnectResult(TypedDict):
314
+ restored: bool
315
+ missed_events: NotRequired[int]
316
+ current_namespaces: NotRequired[list[AgentStatusEntry]]
317
+
318
+ class EmptyResult(TypedDict):
319
+ pass
320
+
321
+ class AgentResult(TypedDict):
322
+ tree: AgentTreeNode
323
+
324
+ class StateGetResult(TypedDict):
325
+ values: dict[str, Any]
326
+ checkpoint: NotRequired[CheckpointRef]
327
+
328
+ class ListCheckpointsResult(TypedDict):
329
+ checkpoints: list[CheckpointSummary]
330
+
331
+ class StateForkResult(TypedDict):
332
+ run_id: str
333
+ thread_id: str
334
+
335
+ ErrorCode = Union[Literal["invalid_argument"], Literal["unknown_command"], Literal["unknown_error"], Literal["no_such_run"], Literal["no_such_subscription"], Literal["no_such_namespace"], Literal["no_such_interrupt"], Literal["no_such_checkpoint"], Literal["permission_denied"], Literal["not_supported"]]
336
+
337
+ class ResponseMeta(TypedDict):
338
+ applied_through_seq: NotRequired[JsUint]
339
+
340
+ RunCommand = RunInput
341
+
342
+ class _CommandVariant0(_CommandFields, RunCommand):
343
+ pass
344
+
345
+ class RunInputParams(TypedDict):
346
+ assistant_id: str # Deployed graph/agent to run
347
+ input: Any # Graph input, resume value, or injected message
348
+ config: NotRequired[dict[str, Any]] # Per-run config overrides
349
+ metadata: NotRequired[dict[str, Any]] # Per-run metadata
350
+
351
+ Channel = Union[Literal["values"], Literal["updates"], Literal["messages"], Literal["tools"], Literal["lifecycle"], Literal["input"], Literal["debug"], Literal["checkpoints"], Literal["tasks"], Literal["custom"], Annotated[str, "custom:.+"]]
352
+
353
+ class EventStreamRequest(TypedDict):
354
+ channels: list[Channel]
355
+ namespaces: NotRequired[list[Namespace]] # Prefix-match these namespace paths
356
+ depth: NotRequired[int] # Max depth below namespace prefix
357
+ since: NotRequired[JsUint] # Replay events after this seq number
358
+
359
+ class SubscribeParams(TypedDict):
360
+ channels: list[Channel]
361
+ namespaces: NotRequired[list[Namespace]] # Prefix-match these namespace paths
362
+ depth: NotRequired[int] # Max depth below namespace prefix
363
+
364
+ class UnsubscribeParams(TypedDict):
365
+ subscription_id: str
366
+
367
+ class ReconnectParams(TypedDict):
368
+ run_id: str
369
+ last_event_id: NotRequired[str] # Last event the client processed
370
+ subscriptions: NotRequired[list[str]] # Subscription IDs to restore
371
+
372
+ class AgentStatusEntry(TypedDict):
373
+ namespace: Namespace
374
+ status: AgentStatus
375
+
376
+ SubscriptionResult = Union[SubscribeResult, ReconnectResult, EmptyResult]
377
+
378
+ FlowCommand = FlowSetCapacity
379
+
380
+ class _CommandVariant4(_CommandFields, FlowCommand):
381
+ pass
382
+
383
+ class FlowCapacityParams(TypedDict):
384
+ max_buffer_size: int
385
+ strategy: FlowStrategy
386
+
387
+ FlowStrategy = Union[Literal["drop-oldest"], Literal["pause-producer"], Literal["sample"]]
388
+
389
+ AgentCommand = AgentGetTree
390
+
391
+ CommandData = Union[RunCommand, SubscriptionCommand, FlowCommand, AgentCommand, InputCommand, StateCommand]
392
+
393
+ class _CommandVariant5(_CommandFields, AgentCommand):
394
+ pass
395
+
396
+ Command = Union[_CommandVariant0, _CommandVariant1, _CommandVariant2, _CommandVariant3, _CommandVariant4, _CommandVariant5, _CommandVariant6, _CommandVariant7, _CommandVariant8, _CommandVariant9, _CommandVariant10]
397
+
398
+ class AgentGetTreeParams(TypedDict):
399
+ run_id: NotRequired[str]
400
+
401
+ class AgentTreeNode(TypedDict):
402
+ namespace: Namespace
403
+ status: AgentStatus
404
+ graph_name: str
405
+ children: NotRequired[list[AgentTreeNode]]
406
+ metadata: NotRequired[dict[str, Any]]
407
+
408
+ AgentStatus = Union[Literal["started"], Literal["running"], Literal["completed"], Literal["failed"], Literal["interrupted"]]
409
+
410
+ class LifecycleData(TypedDict):
411
+ event: AgentStatus
412
+ graph_name: NotRequired[str]
413
+ trigger_call_id: NotRequired[str] # Call on parent namespace that started this subgraph
414
+ error: NotRequired[str]
415
+ checkpoint: NotRequired[CheckpointRef] # Checkpoint reference for time-travel
416
+
417
+ class MessageStartData(TypedDict):
418
+ event: Literal["message-start"]
419
+ role: MessageRole # Author role for this message
420
+ message_id: NotRequired[str] # Unique ID for this message
421
+ metadata: NotRequired[MessageMetadata] # Concise provider/model metadata for AI messages
422
+
423
+ class ContentBlockStartData(TypedDict):
424
+ event: Literal["content-block-start"]
425
+ index: int # Positional index within the message
426
+ content_block: ContentBlock
427
+
428
+ class ContentBlockDeltaData(TypedDict):
429
+ event: Literal["content-block-delta"]
430
+ index: int
431
+ content_block: ContentBlock
432
+
433
+ class ContentBlockFinishData(TypedDict):
434
+ event: Literal["content-block-finish"]
435
+ index: int
436
+ content_block: FinalizedContentBlock
437
+
438
+ class MessageFinishData(TypedDict):
439
+ event: Literal["message-finish"]
440
+ reason: FinishReason
441
+ usage: NotRequired[UsageInfo] # Token usage for AI-authored messages
442
+ metadata: NotRequired[dict[str, Any]]
443
+
444
+ class MessageErrorData(TypedDict):
445
+ event: Literal["error"]
446
+ message: str
447
+ code: NotRequired[str]
448
+
449
+ MessagesData = Union[MessageStartData, ContentBlockStartData, ContentBlockDeltaData, ContentBlockFinishData, MessageFinishData, MessageErrorData]
450
+
451
+ FinishReason = Union[Literal["stop"], Literal["length"], Literal["tool_use"], Literal["content_filter"]]
452
+
453
+ class UsageInfo(TypedDict):
454
+ input_tokens: NotRequired[int]
455
+ output_tokens: NotRequired[int]
456
+ total_tokens: NotRequired[int]
457
+ cached_tokens: NotRequired[int]
458
+
459
+ class ToolStartedData(TypedDict):
460
+ event: Literal["tool-started"]
461
+ tool_call_id: str
462
+ tool_name: str
463
+ input: NotRequired[Any] # Tool input arguments
464
+
465
+ class ToolOutputDeltaData(TypedDict):
466
+ event: Literal["tool-output-delta"]
467
+ tool_call_id: str
468
+ delta: str
469
+
470
+ class ToolFinishedData(TypedDict):
471
+ event: Literal["tool-finished"]
472
+ tool_call_id: str
473
+ output: Any
474
+
475
+ class ToolErrorData(TypedDict):
476
+ event: Literal["tool-error"]
477
+ tool_call_id: str
478
+ message: str
479
+ code: NotRequired[str]
480
+
481
+ ToolsData = Union[ToolStartedData, ToolOutputDeltaData, ToolFinishedData, ToolErrorData]
482
+
483
+ class InputRespondParams(TypedDict):
484
+ namespace: Namespace
485
+ interrupt_id: str
486
+ response: Any
487
+
488
+ class InputInjectParams(TypedDict):
489
+ namespace: Namespace
490
+ message: InputMessage
491
+
492
+ class InputMessage(TypedDict):
493
+ role: Union[Literal["user"], Literal["system"]]
494
+ content: str
495
+ name: NotRequired[str]
496
+
497
+ InputResult = EmptyResult
498
+
499
+ class InputRequestedData(TypedDict):
500
+ interrupt_id: str # Correlates this request with input.respond
501
+ payload: Any # Opaque interrupt value from runtime; application-defined shape
502
+
503
+ class StateGetParams(TypedDict):
504
+ namespace: Namespace
505
+ keys: NotRequired[list[str]] # Specific state keys, or omit for all
506
+
507
+ class ListCheckpointsParams(TypedDict):
508
+ namespace: NotRequired[Namespace]
509
+ limit: NotRequired[int]
510
+ before: NotRequired[str] # Cursor for pagination
511
+
512
+ class CheckpointSummary(TypedDict):
513
+ id: str
514
+ timestamp: str # ISO 8601
515
+ step: int
516
+ node_name: NotRequired[str] # Node that produced this checkpoint
517
+ metadata: NotRequired[dict[str, Any]]
518
+
519
+ class CheckpointRef(TypedDict):
520
+ id: str
521
+ ns: NotRequired[str]
522
+
523
+ class StateForkParams(TypedDict):
524
+ checkpoint_id: str
525
+ input: NotRequired[Any] # Input for the forked run
526
+ config: NotRequired[dict[str, Any]] # Config overrides
527
+
528
+ StateResult = Union[StateGetResult, ListCheckpointsResult, StateForkResult, EmptyResult]
529
+
530
+ ResultData = Union[RunResult, SubscriptionResult, AgentResult, InputResult, StateResult, EmptyResult]
531
+
532
+ class UpdatesData(TypedDict):
533
+ node: NotRequired[str] # Graph node that produced this update
534
+ values: dict[str, Any] # State delta
535
+
536
+ class CustomData(TypedDict):
537
+ name: NotRequired[str] # Custom event name for dispatch
538
+ payload: Any # User-defined payload
539
+
File without changes
@@ -0,0 +1,30 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "langchain-protocol"
7
+ description = "Python bindings for the LangChain agent streaming protocol"
8
+ license = { text = "MIT" }
9
+ readme = "README.md"
10
+ version = "0.0.8"
11
+ requires-python = ">=3.10.0,<4.0.0"
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Developers",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Programming Language :: Python :: 3.14",
22
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
23
+ "Topic :: Software Development :: Libraries :: Python Modules",
24
+ ]
25
+ dependencies = [
26
+ "typing-extensions>=4.7.0,<5.0.0",
27
+ ]
28
+
29
+ [project.urls]
30
+ Repository = "https://github.com/langchain-ai/protocol"