@langchain/langgraph-api 1.1.17 → 1.2.1

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.
Files changed (52) hide show
  1. package/dist/api/protocol.d.mts +7 -0
  2. package/dist/api/protocol.mjs +157 -0
  3. package/dist/api/runs.mjs +15 -4
  4. package/dist/command.mjs +1 -1
  5. package/dist/experimental/embed/constants.d.mts +3 -0
  6. package/dist/experimental/embed/constants.mjs +11 -0
  7. package/dist/experimental/embed/protocol.d.mts +9 -0
  8. package/dist/experimental/embed/protocol.mjs +453 -0
  9. package/dist/experimental/embed/runs.d.mts +8 -0
  10. package/dist/experimental/embed/runs.mjs +202 -0
  11. package/dist/experimental/embed/threads.d.mts +8 -0
  12. package/dist/experimental/embed/threads.mjs +151 -0
  13. package/dist/experimental/embed/types.d.mts +77 -0
  14. package/dist/experimental/embed/types.mjs +1 -0
  15. package/dist/experimental/embed/utils.d.mts +29 -0
  16. package/dist/experimental/embed/utils.mjs +62 -0
  17. package/dist/experimental/embed.d.mts +11 -31
  18. package/dist/experimental/embed.mjs +19 -399
  19. package/dist/graph/load.d.mts +2 -2
  20. package/dist/graph/load.utils.mjs +13 -3
  21. package/dist/protocol/constants.d.mts +7 -0
  22. package/dist/protocol/constants.mjs +7 -0
  23. package/dist/protocol/service.d.mts +101 -0
  24. package/dist/protocol/service.mjs +568 -0
  25. package/dist/protocol/session/event-normalizers.d.mts +52 -0
  26. package/dist/protocol/session/event-normalizers.mjs +162 -0
  27. package/dist/protocol/session/index.d.mts +261 -0
  28. package/dist/protocol/session/index.mjs +826 -0
  29. package/dist/protocol/session/internal-types.d.mts +67 -0
  30. package/dist/protocol/session/internal-types.mjs +28 -0
  31. package/dist/protocol/session/metadata.d.mts +24 -0
  32. package/dist/protocol/session/metadata.mjs +95 -0
  33. package/dist/protocol/session/namespace.d.mts +47 -0
  34. package/dist/protocol/session/namespace.mjs +62 -0
  35. package/dist/protocol/session/state-normalizers.d.mts +57 -0
  36. package/dist/protocol/session/state-normalizers.mjs +430 -0
  37. package/dist/protocol/session/tool-calls.d.mts +27 -0
  38. package/dist/protocol/session/tool-calls.mjs +59 -0
  39. package/dist/protocol/types.d.mts +121 -0
  40. package/dist/protocol/types.mjs +1 -0
  41. package/dist/queue.mjs +8 -2
  42. package/dist/schemas.d.mts +58 -58
  43. package/dist/semver/index.mjs +19 -1
  44. package/dist/server.mjs +22 -3
  45. package/dist/state.mjs +1 -1
  46. package/dist/storage/ops.mjs +17 -5
  47. package/dist/storage/persist.mjs +1 -1
  48. package/dist/storage/types.d.mts +10 -1
  49. package/dist/stream.d.mts +25 -4
  50. package/dist/stream.mjs +203 -11
  51. package/dist/utils/serde.mjs +1 -1
  52. package/package.json +16 -14
@@ -334,25 +334,25 @@ export declare const Cron: z.ZodObject<{
334
334
  updated_at: z.ZodString;
335
335
  payload: z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>;
336
336
  }, "strip", z.ZodTypeAny, {
337
+ thread_id: string;
337
338
  created_at: string;
338
339
  updated_at: string;
339
- thread_id: string;
340
- cron_id: string;
341
- end_time: string;
342
- schedule: string;
343
340
  payload: {} & {
344
341
  [k: string]: any;
345
342
  };
346
- }, {
347
- created_at: string;
348
- updated_at: string;
349
- thread_id: string;
350
343
  cron_id: string;
351
344
  end_time: string;
352
345
  schedule: string;
346
+ }, {
347
+ thread_id: string;
348
+ created_at: string;
349
+ updated_at: string;
353
350
  payload: {} & {
354
351
  [k: string]: any;
355
352
  };
353
+ cron_id: string;
354
+ end_time: string;
355
+ schedule: string;
356
356
  }>;
357
357
  export declare const CheckpointSchema: z.ZodObject<{
358
358
  checkpoint_id: z.ZodOptional<z.ZodString>;
@@ -419,8 +419,9 @@ export declare const CronCreate: z.ZodObject<{
419
419
  interrupt_after: z.ZodOptional<z.ZodUnion<[z.ZodEnum<["*"]>, z.ZodArray<z.ZodString, "many">]>>;
420
420
  multitask_strategy: z.ZodOptional<z.ZodEnum<["reject", "rollback", "interrupt", "enqueue"]>>;
421
421
  }, "strip", z.ZodTypeAny, {
422
- assistant_id: string;
423
422
  thread_id: string;
423
+ assistant_id: string;
424
+ input?: z.objectOutputType<{}, z.ZodAny, "strip">[] | z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
424
425
  context?: unknown;
425
426
  config?: z.objectOutputType<{
426
427
  tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -437,15 +438,15 @@ export declare const CronCreate: z.ZodObject<{
437
438
  }, z.ZodUnknown, "strip">>>;
438
439
  }, z.ZodUnknown, "strip"> | undefined;
439
440
  metadata?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
440
- input?: z.objectOutputType<{}, z.ZodAny, "strip">[] | z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
441
441
  interrupt_before?: string[] | "*" | undefined;
442
442
  interrupt_after?: string[] | "*" | undefined;
443
443
  webhook?: string | undefined;
444
444
  checkpoint_id?: string | undefined;
445
445
  multitask_strategy?: "reject" | "rollback" | "interrupt" | "enqueue" | undefined;
446
446
  }, {
447
- assistant_id: string;
448
447
  thread_id: string;
448
+ assistant_id: string;
449
+ input?: z.objectInputType<{}, z.ZodAny, "strip">[] | z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
449
450
  context?: unknown;
450
451
  config?: z.objectInputType<{
451
452
  tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -462,7 +463,6 @@ export declare const CronCreate: z.ZodObject<{
462
463
  }, z.ZodUnknown, "strip">>>;
463
464
  }, z.ZodUnknown, "strip"> | undefined;
464
465
  metadata?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
465
- input?: z.objectInputType<{}, z.ZodAny, "strip">[] | z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
466
466
  interrupt_before?: string[] | "*" | undefined;
467
467
  interrupt_after?: string[] | "*" | undefined;
468
468
  webhook?: string | undefined;
@@ -475,13 +475,13 @@ export declare const CronSearch: z.ZodObject<{
475
475
  limit: z.ZodOptional<z.ZodNumber>;
476
476
  offset: z.ZodOptional<z.ZodNumber>;
477
477
  }, "strip", z.ZodTypeAny, {
478
- assistant_id?: string | undefined;
479
478
  thread_id?: string | undefined;
479
+ assistant_id?: string | undefined;
480
480
  limit?: number | undefined;
481
481
  offset?: number | undefined;
482
482
  }, {
483
- assistant_id?: string | undefined;
484
483
  thread_id?: string | undefined;
484
+ assistant_id?: string | undefined;
485
485
  limit?: number | undefined;
486
486
  offset?: number | undefined;
487
487
  }>;
@@ -523,29 +523,29 @@ export declare const Run: z.ZodObject<{
523
523
  kwargs: z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>;
524
524
  multitask_strategy: z.ZodEnum<["reject", "rollback", "interrupt", "enqueue"]>;
525
525
  }, "strip", z.ZodTypeAny, {
526
- status: "error" | "interrupted" | "pending" | "running" | "success" | "timeout";
526
+ run_id: string;
527
+ thread_id: string;
528
+ status: "success" | "error" | "running" | "interrupted" | "pending" | "timeout";
527
529
  assistant_id: string;
528
530
  created_at: string;
529
531
  updated_at: string;
530
532
  metadata: {} & {
531
533
  [k: string]: any;
532
534
  };
533
- thread_id: string;
534
- run_id: string;
535
535
  multitask_strategy: "reject" | "rollback" | "interrupt" | "enqueue";
536
536
  kwargs: {} & {
537
537
  [k: string]: any;
538
538
  };
539
539
  }, {
540
- status: "error" | "interrupted" | "pending" | "running" | "success" | "timeout";
540
+ run_id: string;
541
+ thread_id: string;
542
+ status: "success" | "error" | "running" | "interrupted" | "pending" | "timeout";
541
543
  assistant_id: string;
542
544
  created_at: string;
543
545
  updated_at: string;
544
546
  metadata: {} & {
545
547
  [k: string]: any;
546
548
  };
547
- thread_id: string;
548
- run_id: string;
549
549
  multitask_strategy: "reject" | "rollback" | "interrupt" | "enqueue";
550
550
  kwargs: {} & {
551
551
  [k: string]: any;
@@ -574,8 +574,8 @@ export declare const CommandSchema: z.ZodObject<{
574
574
  update: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodUnknown], null>, "many">]>>;
575
575
  resume: z.ZodOptional<z.ZodUnknown>;
576
576
  }, "strip", z.ZodTypeAny, {
577
- resume?: unknown;
578
577
  update?: Record<string, unknown> | [string, unknown][] | undefined;
578
+ resume?: unknown;
579
579
  goto?: string | {
580
580
  node: string;
581
581
  input?: unknown;
@@ -584,8 +584,8 @@ export declare const CommandSchema: z.ZodObject<{
584
584
  input?: unknown;
585
585
  })[] | undefined;
586
586
  }, {
587
- resume?: unknown;
588
587
  update?: Record<string, unknown> | [string, unknown][] | undefined;
588
+ resume?: unknown;
589
589
  goto?: string | {
590
590
  node: string;
591
591
  input?: unknown;
@@ -644,8 +644,8 @@ export declare const RunCreate: z.ZodObject<{
644
644
  update: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodUnknown], null>, "many">]>>;
645
645
  resume: z.ZodOptional<z.ZodUnknown>;
646
646
  }, "strip", z.ZodTypeAny, {
647
- resume?: unknown;
648
647
  update?: Record<string, unknown> | [string, unknown][] | undefined;
648
+ resume?: unknown;
649
649
  goto?: string | {
650
650
  node: string;
651
651
  input?: unknown;
@@ -654,8 +654,8 @@ export declare const RunCreate: z.ZodObject<{
654
654
  input?: unknown;
655
655
  })[] | undefined;
656
656
  }, {
657
- resume?: unknown;
658
657
  update?: Record<string, unknown> | [string, unknown][] | undefined;
658
+ resume?: unknown;
659
659
  goto?: string | {
660
660
  node: string;
661
661
  input?: unknown;
@@ -731,6 +731,7 @@ export declare const RunCreate: z.ZodObject<{
731
731
  }, "strip", z.ZodTypeAny, {
732
732
  assistant_id: string;
733
733
  on_disconnect: "cancel" | "continue";
734
+ input?: unknown;
734
735
  context?: unknown;
735
736
  config?: z.objectOutputType<{
736
737
  tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -747,10 +748,9 @@ export declare const RunCreate: z.ZodObject<{
747
748
  }, z.ZodUnknown, "strip">>>;
748
749
  }, z.ZodUnknown, "strip"> | undefined;
749
750
  metadata?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
750
- input?: unknown;
751
751
  command?: {
752
- resume?: unknown;
753
752
  update?: Record<string, unknown> | [string, unknown][] | undefined;
753
+ resume?: unknown;
754
754
  goto?: string | {
755
755
  node: string;
756
756
  input?: unknown;
@@ -759,7 +759,7 @@ export declare const RunCreate: z.ZodObject<{
759
759
  input?: unknown;
760
760
  })[] | undefined;
761
761
  } | undefined;
762
- stream_mode?: "values" | "debug" | "messages" | "messages-tuple" | "custom" | "updates" | "events" | "tasks" | "checkpoints" | "tools" | ("values" | "debug" | "messages" | "messages-tuple" | "custom" | "updates" | "events" | "tasks" | "checkpoints" | "tools")[] | undefined;
762
+ stream_mode?: "values" | "updates" | "messages" | "tools" | "checkpoints" | "tasks" | "custom" | "debug" | "messages-tuple" | "events" | ("values" | "updates" | "messages" | "tools" | "checkpoints" | "tasks" | "custom" | "debug" | "messages-tuple" | "events")[] | undefined;
763
763
  interrupt_before?: string[] | "*" | undefined;
764
764
  interrupt_after?: string[] | "*" | undefined;
765
765
  webhook?: string | undefined;
@@ -782,6 +782,7 @@ export declare const RunCreate: z.ZodObject<{
782
782
  } | undefined;
783
783
  }, {
784
784
  assistant_id: string;
785
+ input?: unknown;
785
786
  context?: unknown;
786
787
  config?: z.objectInputType<{
787
788
  tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -798,10 +799,9 @@ export declare const RunCreate: z.ZodObject<{
798
799
  }, z.ZodUnknown, "strip">>>;
799
800
  }, z.ZodUnknown, "strip"> | undefined;
800
801
  metadata?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
801
- input?: unknown;
802
802
  command?: {
803
- resume?: unknown;
804
803
  update?: Record<string, unknown> | [string, unknown][] | undefined;
804
+ resume?: unknown;
805
805
  goto?: string | {
806
806
  node: string;
807
807
  input?: unknown;
@@ -810,7 +810,7 @@ export declare const RunCreate: z.ZodObject<{
810
810
  input?: unknown;
811
811
  })[] | undefined;
812
812
  } | undefined;
813
- stream_mode?: "values" | "debug" | "messages" | "messages-tuple" | "custom" | "updates" | "events" | "tasks" | "checkpoints" | "tools" | ("values" | "debug" | "messages" | "messages-tuple" | "custom" | "updates" | "events" | "tasks" | "checkpoints" | "tools")[] | undefined;
813
+ stream_mode?: "values" | "updates" | "messages" | "tools" | "checkpoints" | "tasks" | "custom" | "debug" | "messages-tuple" | "events" | ("values" | "updates" | "messages" | "tools" | "checkpoints" | "tasks" | "custom" | "debug" | "messages-tuple" | "events")[] | undefined;
814
814
  interrupt_before?: string[] | "*" | undefined;
815
815
  interrupt_after?: string[] | "*" | undefined;
816
816
  webhook?: string | undefined;
@@ -873,8 +873,8 @@ export declare const RunBatchCreate: z.ZodArray<z.ZodObject<{
873
873
  update: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodUnknown], null>, "many">]>>;
874
874
  resume: z.ZodOptional<z.ZodUnknown>;
875
875
  }, "strip", z.ZodTypeAny, {
876
- resume?: unknown;
877
876
  update?: Record<string, unknown> | [string, unknown][] | undefined;
877
+ resume?: unknown;
878
878
  goto?: string | {
879
879
  node: string;
880
880
  input?: unknown;
@@ -883,8 +883,8 @@ export declare const RunBatchCreate: z.ZodArray<z.ZodObject<{
883
883
  input?: unknown;
884
884
  })[] | undefined;
885
885
  }, {
886
- resume?: unknown;
887
886
  update?: Record<string, unknown> | [string, unknown][] | undefined;
887
+ resume?: unknown;
888
888
  goto?: string | {
889
889
  node: string;
890
890
  input?: unknown;
@@ -960,6 +960,7 @@ export declare const RunBatchCreate: z.ZodArray<z.ZodObject<{
960
960
  }, "strip", z.ZodTypeAny, {
961
961
  assistant_id: string;
962
962
  on_disconnect: "cancel" | "continue";
963
+ input?: unknown;
963
964
  context?: unknown;
964
965
  config?: z.objectOutputType<{
965
966
  tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -976,10 +977,9 @@ export declare const RunBatchCreate: z.ZodArray<z.ZodObject<{
976
977
  }, z.ZodUnknown, "strip">>>;
977
978
  }, z.ZodUnknown, "strip"> | undefined;
978
979
  metadata?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
979
- input?: unknown;
980
980
  command?: {
981
- resume?: unknown;
982
981
  update?: Record<string, unknown> | [string, unknown][] | undefined;
982
+ resume?: unknown;
983
983
  goto?: string | {
984
984
  node: string;
985
985
  input?: unknown;
@@ -988,7 +988,7 @@ export declare const RunBatchCreate: z.ZodArray<z.ZodObject<{
988
988
  input?: unknown;
989
989
  })[] | undefined;
990
990
  } | undefined;
991
- stream_mode?: "values" | "debug" | "messages" | "messages-tuple" | "custom" | "updates" | "events" | "tasks" | "checkpoints" | "tools" | ("values" | "debug" | "messages" | "messages-tuple" | "custom" | "updates" | "events" | "tasks" | "checkpoints" | "tools")[] | undefined;
991
+ stream_mode?: "values" | "updates" | "messages" | "tools" | "checkpoints" | "tasks" | "custom" | "debug" | "messages-tuple" | "events" | ("values" | "updates" | "messages" | "tools" | "checkpoints" | "tasks" | "custom" | "debug" | "messages-tuple" | "events")[] | undefined;
992
992
  interrupt_before?: string[] | "*" | undefined;
993
993
  interrupt_after?: string[] | "*" | undefined;
994
994
  webhook?: string | undefined;
@@ -1011,6 +1011,7 @@ export declare const RunBatchCreate: z.ZodArray<z.ZodObject<{
1011
1011
  } | undefined;
1012
1012
  }, {
1013
1013
  assistant_id: string;
1014
+ input?: unknown;
1014
1015
  context?: unknown;
1015
1016
  config?: z.objectInputType<{
1016
1017
  tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -1027,10 +1028,9 @@ export declare const RunBatchCreate: z.ZodArray<z.ZodObject<{
1027
1028
  }, z.ZodUnknown, "strip">>>;
1028
1029
  }, z.ZodUnknown, "strip"> | undefined;
1029
1030
  metadata?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
1030
- input?: unknown;
1031
1031
  command?: {
1032
- resume?: unknown;
1033
1032
  update?: Record<string, unknown> | [string, unknown][] | undefined;
1033
+ resume?: unknown;
1034
1034
  goto?: string | {
1035
1035
  node: string;
1036
1036
  input?: unknown;
@@ -1039,7 +1039,7 @@ export declare const RunBatchCreate: z.ZodArray<z.ZodObject<{
1039
1039
  input?: unknown;
1040
1040
  })[] | undefined;
1041
1041
  } | undefined;
1042
- stream_mode?: "values" | "debug" | "messages" | "messages-tuple" | "custom" | "updates" | "events" | "tasks" | "checkpoints" | "tools" | ("values" | "debug" | "messages" | "messages-tuple" | "custom" | "updates" | "events" | "tasks" | "checkpoints" | "tools")[] | undefined;
1042
+ stream_mode?: "values" | "updates" | "messages" | "tools" | "checkpoints" | "tasks" | "custom" | "debug" | "messages-tuple" | "events" | ("values" | "updates" | "messages" | "tools" | "checkpoints" | "tasks" | "custom" | "debug" | "messages-tuple" | "events")[] | undefined;
1043
1043
  interrupt_before?: string[] | "*" | undefined;
1044
1044
  interrupt_after?: string[] | "*" | undefined;
1045
1045
  webhook?: string | undefined;
@@ -1122,11 +1122,11 @@ export declare const ThreadCountRequest: z.ZodObject<{
1122
1122
  values: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1123
1123
  }, "strip", z.ZodTypeAny, {
1124
1124
  values?: Record<string, unknown> | undefined;
1125
- status?: "error" | "idle" | "busy" | "interrupted" | undefined;
1125
+ status?: "error" | "interrupted" | "idle" | "busy" | undefined;
1126
1126
  metadata?: Record<string, unknown> | undefined;
1127
1127
  }, {
1128
1128
  values?: Record<string, unknown> | undefined;
1129
- status?: "error" | "idle" | "busy" | "interrupted" | undefined;
1129
+ status?: "error" | "interrupted" | "idle" | "busy" | undefined;
1130
1130
  metadata?: Record<string, unknown> | undefined;
1131
1131
  }>;
1132
1132
  export declare const ThreadSearchRequest: z.ZodObject<{
@@ -1141,21 +1141,21 @@ export declare const ThreadSearchRequest: z.ZodObject<{
1141
1141
  select: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1142
1142
  }, "strip", z.ZodTypeAny, {
1143
1143
  values?: Record<string, unknown> | undefined;
1144
- status?: "error" | "idle" | "busy" | "interrupted" | undefined;
1144
+ status?: "error" | "interrupted" | "idle" | "busy" | undefined;
1145
1145
  metadata?: Record<string, unknown> | undefined;
1146
1146
  limit?: number | undefined;
1147
1147
  offset?: number | undefined;
1148
- sort_by?: "status" | "created_at" | "updated_at" | "thread_id" | undefined;
1148
+ sort_by?: "thread_id" | "status" | "created_at" | "updated_at" | undefined;
1149
1149
  sort_order?: "asc" | "desc" | undefined;
1150
1150
  select?: string[] | undefined;
1151
1151
  ids?: string[] | undefined;
1152
1152
  }, {
1153
1153
  values?: Record<string, unknown> | undefined;
1154
- status?: "error" | "idle" | "busy" | "interrupted" | undefined;
1154
+ status?: "error" | "interrupted" | "idle" | "busy" | undefined;
1155
1155
  metadata?: Record<string, unknown> | undefined;
1156
1156
  limit?: number | undefined;
1157
1157
  offset?: number | undefined;
1158
- sort_by?: "status" | "created_at" | "updated_at" | "thread_id" | undefined;
1158
+ sort_by?: "thread_id" | "status" | "created_at" | "updated_at" | undefined;
1159
1159
  sort_order?: "asc" | "desc" | undefined;
1160
1160
  select?: string[] | undefined;
1161
1161
  ids?: string[] | undefined;
@@ -1167,16 +1167,16 @@ export declare const Thread: z.ZodObject<{
1167
1167
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1168
1168
  status: z.ZodOptional<z.ZodEnum<["idle", "busy", "interrupted", "error"]>>;
1169
1169
  }, "strip", z.ZodTypeAny, {
1170
+ thread_id: string;
1170
1171
  created_at: string;
1171
1172
  updated_at: string;
1172
- thread_id: string;
1173
- status?: "error" | "idle" | "busy" | "interrupted" | undefined;
1173
+ status?: "error" | "interrupted" | "idle" | "busy" | undefined;
1174
1174
  metadata?: Record<string, unknown> | undefined;
1175
1175
  }, {
1176
+ thread_id: string;
1176
1177
  created_at: string;
1177
1178
  updated_at: string;
1178
- thread_id: string;
1179
- status?: "error" | "idle" | "busy" | "interrupted" | undefined;
1179
+ status?: "error" | "interrupted" | "idle" | "busy" | undefined;
1180
1180
  metadata?: Record<string, unknown> | undefined;
1181
1181
  }>;
1182
1182
  export declare const ThreadCreate: z.ZodObject<{
@@ -1206,8 +1206,8 @@ export declare const ThreadCreate: z.ZodObject<{
1206
1206
  update: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodArray<z.ZodTuple<[z.ZodString, z.ZodUnknown], null>, "many">]>>;
1207
1207
  resume: z.ZodOptional<z.ZodUnknown>;
1208
1208
  }, "strip", z.ZodTypeAny, {
1209
- resume?: unknown;
1210
1209
  update?: Record<string, unknown> | [string, unknown][] | undefined;
1210
+ resume?: unknown;
1211
1211
  goto?: string | {
1212
1212
  node: string;
1213
1213
  input?: unknown;
@@ -1216,8 +1216,8 @@ export declare const ThreadCreate: z.ZodObject<{
1216
1216
  input?: unknown;
1217
1217
  })[] | undefined;
1218
1218
  }, {
1219
- resume?: unknown;
1220
1219
  update?: Record<string, unknown> | [string, unknown][] | undefined;
1220
+ resume?: unknown;
1221
1221
  goto?: string | {
1222
1222
  node: string;
1223
1223
  input?: unknown;
@@ -1231,8 +1231,8 @@ export declare const ThreadCreate: z.ZodObject<{
1231
1231
  as_node: string;
1232
1232
  values?: unknown;
1233
1233
  command?: {
1234
- resume?: unknown;
1235
1234
  update?: Record<string, unknown> | [string, unknown][] | undefined;
1235
+ resume?: unknown;
1236
1236
  goto?: string | {
1237
1237
  node: string;
1238
1238
  input?: unknown;
@@ -1245,8 +1245,8 @@ export declare const ThreadCreate: z.ZodObject<{
1245
1245
  as_node: string;
1246
1246
  values?: unknown;
1247
1247
  command?: {
1248
- resume?: unknown;
1249
1248
  update?: Record<string, unknown> | [string, unknown][] | undefined;
1249
+ resume?: unknown;
1250
1250
  goto?: string | {
1251
1251
  node: string;
1252
1252
  input?: unknown;
@@ -1261,8 +1261,8 @@ export declare const ThreadCreate: z.ZodObject<{
1261
1261
  as_node: string;
1262
1262
  values?: unknown;
1263
1263
  command?: {
1264
- resume?: unknown;
1265
1264
  update?: Record<string, unknown> | [string, unknown][] | undefined;
1265
+ resume?: unknown;
1266
1266
  goto?: string | {
1267
1267
  node: string;
1268
1268
  input?: unknown;
@@ -1277,8 +1277,8 @@ export declare const ThreadCreate: z.ZodObject<{
1277
1277
  as_node: string;
1278
1278
  values?: unknown;
1279
1279
  command?: {
1280
- resume?: unknown;
1281
1280
  update?: Record<string, unknown> | [string, unknown][] | undefined;
1281
+ resume?: unknown;
1282
1282
  goto?: string | {
1283
1283
  node: string;
1284
1284
  input?: unknown;
@@ -1293,16 +1293,16 @@ export declare const ThreadCreate: z.ZodObject<{
1293
1293
  metadata: z.ZodOptional<z.ZodObject<{}, "strip", z.ZodAny, z.objectOutputType<{}, z.ZodAny, "strip">, z.objectInputType<{}, z.ZodAny, "strip">>>;
1294
1294
  if_exists: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"raise">, z.ZodLiteral<"do_nothing">]>>;
1295
1295
  }, "strip", z.ZodTypeAny, {
1296
- metadata?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
1297
1296
  thread_id?: string | undefined;
1297
+ metadata?: z.objectOutputType<{}, z.ZodAny, "strip"> | undefined;
1298
1298
  if_exists?: "raise" | "do_nothing" | undefined;
1299
1299
  supersteps?: {
1300
1300
  updates: {
1301
1301
  as_node: string;
1302
1302
  values?: unknown;
1303
1303
  command?: {
1304
- resume?: unknown;
1305
1304
  update?: Record<string, unknown> | [string, unknown][] | undefined;
1305
+ resume?: unknown;
1306
1306
  goto?: string | {
1307
1307
  node: string;
1308
1308
  input?: unknown;
@@ -1314,16 +1314,16 @@ export declare const ThreadCreate: z.ZodObject<{
1314
1314
  }[];
1315
1315
  }[] | undefined;
1316
1316
  }, {
1317
- metadata?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
1318
1317
  thread_id?: string | undefined;
1318
+ metadata?: z.objectInputType<{}, z.ZodAny, "strip"> | undefined;
1319
1319
  if_exists?: "raise" | "do_nothing" | undefined;
1320
1320
  supersteps?: {
1321
1321
  updates: {
1322
1322
  as_node: string;
1323
1323
  values?: unknown;
1324
1324
  command?: {
1325
- resume?: unknown;
1326
1325
  update?: Record<string, unknown> | [string, unknown][] | undefined;
1326
+ resume?: unknown;
1327
1327
  goto?: string | {
1328
1328
  node: string;
1329
1329
  input?: unknown;
@@ -10,10 +10,28 @@ export async function checkSemver(packages) {
10
10
  const required = peerDependencies[pkg.name];
11
11
  if (!required)
12
12
  return [];
13
- const satisfies = semver.satisfies(pkg.version, required);
13
+ const satisfies = satisfiesPeerRange(pkg.version, required);
14
14
  return { ...pkg, required, satisfies };
15
15
  });
16
16
  }
17
+ function satisfiesPeerRange(version, required) {
18
+ if (semver.satisfies(version, required, { includePrerelease: true })) {
19
+ return true;
20
+ }
21
+ const parsed = semver.parse(version);
22
+ if (parsed == null || parsed.prerelease.length === 0) {
23
+ return false;
24
+ }
25
+ // CI often installs internal dev builds such as
26
+ // `1.1.44-dev-<timestamp>`. Semver orders those below the final
27
+ // `1.1.44`, so `^1.1.44` does not match directly even though the
28
+ // build targets that release line. Validate the release tuple as a
29
+ // compatibility check while still rejecting prereleases below range.
30
+ const releaseVersion = `${parsed.major}.${parsed.minor}.${parsed.patch}`;
31
+ return semver.satisfies(releaseVersion, required, {
32
+ includePrerelease: true,
33
+ });
34
+ }
17
35
  export async function checkLangGraphSemver() {
18
36
  const resolveVersion = async (name) => {
19
37
  let version = "0.0.0";
package/dist/server.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { serve } from "@hono/node-server";
2
+ import { createNodeWebSocket } from "@hono/node-ws";
2
3
  import { Hono } from "hono";
3
4
  import { contextStorage } from "hono/context-storage";
4
5
  import { registerFromEnv } from "./graph/load.mjs";
@@ -7,6 +8,7 @@ import threads from "./api/threads.mjs";
7
8
  import assistants from "./api/assistants.mjs";
8
9
  import store from "./api/store.mjs";
9
10
  import meta from "./api/meta.mjs";
11
+ import protocol from "./api/protocol.mjs";
10
12
  import { zValidator } from "@hono/zod-validator";
11
13
  import { z } from "zod/v3";
12
14
  import { queue } from "./queue.mjs";
@@ -71,7 +73,7 @@ export async function startServer(options, storage) {
71
73
  ])));
72
74
  }
73
75
  logger.info(`Initializing storage...`);
74
- let initCalls = [
76
+ const initCalls = [
75
77
  checkpointer.initialize(options.cwd),
76
78
  graphStore.initialize(options.cwd),
77
79
  ];
@@ -88,9 +90,11 @@ export async function startServer(options, storage) {
88
90
  ops = new FileSystemOps(opsConn);
89
91
  }
90
92
  const callbacks = await Promise.all(initCalls);
93
+ let closeServer;
91
94
  const cleanup = async () => {
92
95
  logger.info(`Flushing to persistent storage, exiting...`);
93
96
  await Promise.all(callbacks.map((c) => c.flush()));
97
+ await closeServer?.();
94
98
  };
95
99
  // Register global logger that can be consumed via SDK
96
100
  // We need to do this before we load the graphs in-case the logger is obtained at top-level.
@@ -120,6 +124,7 @@ export async function startServer(options, storage) {
120
124
  return info;
121
125
  });
122
126
  const app = new Hono();
127
+ const { injectWebSocket, upgradeWebSocket } = createNodeWebSocket({ app });
123
128
  app.use(contextStorage());
124
129
  app.use(async (c, next) => {
125
130
  c.set("LANGGRAPH_OPS", ops);
@@ -161,6 +166,8 @@ export async function startServer(options, storage) {
161
166
  app.route("/", threads);
162
167
  if (!options.http?.disable_store)
163
168
  app.route("/", store);
169
+ if (!options.http?.disable_runs)
170
+ app.route("/", protocol(upgradeWebSocket, ops));
164
171
  if (options.ui) {
165
172
  logger.info(`Registering UI from ${options.cwd}`);
166
173
  const { api, registerGraphUi } = await import("./ui/load.mjs");
@@ -173,9 +180,21 @@ export async function startServer(options, storage) {
173
180
  logger.info(`Starting ${options.nWorkers} workers`);
174
181
  for (let i = 0; i < options.nWorkers; i++)
175
182
  queue(ops);
176
- return new Promise((resolve) => {
177
- serve({ fetch: app.fetch, port: options.port, hostname: options.host }, (c) => {
183
+ return new Promise((resolve, reject) => {
184
+ const server = serve({ fetch: app.fetch, port: options.port, hostname: options.host }, (c) => {
178
185
  resolve({ host: `${c.address}:${c.port}`, cleanup });
179
186
  });
187
+ closeServer = async () => await new Promise((resolveClose, rejectClose) => {
188
+ server.closeAllConnections();
189
+ server.close((error) => {
190
+ if (error) {
191
+ rejectClose(error);
192
+ return;
193
+ }
194
+ resolveClose();
195
+ });
196
+ });
197
+ server.once("error", reject);
198
+ injectWebSocket(server);
180
199
  });
181
200
  }
package/dist/state.mjs CHANGED
@@ -15,7 +15,7 @@ export const stateSnapshotToThreadState = (state) => {
15
15
  path: task.path,
16
16
  // TODO: too many type assertions, check if this is actually correct
17
17
  checkpoint: task.state != null && "configurable" in task.state
18
- ? task.state.configurable ?? null
18
+ ? (task.state.configurable ?? null)
19
19
  : null,
20
20
  state: task.state != null && isStateSnapshot(task.state)
21
21
  ? stateSnapshotToThreadState(task.state)
@@ -165,7 +165,7 @@ export class FileSystemAssistants {
165
165
  offset: options.offset,
166
166
  });
167
167
  yield* this.conn.withGenerator(async function* (STORE) {
168
- let filtered = Object.values(STORE.assistants)
168
+ const filtered = Object.values(STORE.assistants)
169
169
  .filter((assistant) => {
170
170
  if (options.graph_id != null &&
171
171
  assistant["graph_id"] !== options.graph_id) {
@@ -1010,7 +1010,7 @@ export class FileSystemRuns {
1010
1010
  kwargs: Object.assign({}, kwargs, {
1011
1011
  config: Object.assign({}, assistant.config, config, { configurable }, { metadata: mergedMetadata }),
1012
1012
  context: typeof assistant.context !== "object" && assistant.context != null
1013
- ? assistant.context ?? kwargs.context
1013
+ ? (assistant.context ?? kwargs.context)
1014
1014
  : Object.assign({}, assistant.context, kwargs.context),
1015
1015
  }),
1016
1016
  multitask_strategy: multitaskStrategy,
@@ -1197,7 +1197,7 @@ export class FileSystemRuns {
1197
1197
  const runs = this.runs;
1198
1198
  yield* conn.withGenerator(async function* (STORE) {
1199
1199
  // TODO: what if we're joining an already completed run? Should we check before?
1200
- const signal = options?.cancelOnDisconnect;
1200
+ const signal = options?.signal;
1201
1201
  const queue = StreamManager.getQueue(runId, {
1202
1202
  ifNotFound: "create",
1203
1203
  resumable: options.lastEventId != null,
@@ -1231,7 +1231,14 @@ export class FileSystemRuns {
1231
1231
  }
1232
1232
  else {
1233
1233
  const streamTopic = message.topic.substring(`run:${runId}:stream:`.length);
1234
- yield { id, event: streamTopic, data: message.data };
1234
+ yield {
1235
+ id,
1236
+ event: streamTopic,
1237
+ data: message.data,
1238
+ ...(message.normalized != null
1239
+ ? { normalized: message.normalized }
1240
+ : {}),
1241
+ };
1235
1242
  }
1236
1243
  }
1237
1244
  catch (error) {
@@ -1248,7 +1255,9 @@ export class FileSystemRuns {
1248
1255
  }
1249
1256
  }
1250
1257
  }
1251
- if (signal?.aborted && threadId != null) {
1258
+ if (signal?.aborted &&
1259
+ options?.cancelOnDisconnect &&
1260
+ threadId != null) {
1252
1261
  await runs.cancel(threadId, [runId], { action: "interrupt" }, auth);
1253
1262
  }
1254
1263
  });
@@ -1261,6 +1270,9 @@ export class FileSystemRuns {
1261
1270
  queue.push({
1262
1271
  topic: `run:${payload.runId}:stream:${payload.event}`,
1263
1272
  data: payload.data,
1273
+ ...(payload.normalized != null
1274
+ ? { normalized: payload.normalized }
1275
+ : {}),
1264
1276
  });
1265
1277
  }
1266
1278
  };
@@ -68,7 +68,7 @@ export class FileSystemPersistence {
68
68
  throw new Error(`${this.name} not initialized`);
69
69
  }
70
70
  let shouldPersist = false;
71
- let schedulePersist = () => void (shouldPersist = true);
71
+ const schedulePersist = () => void (shouldPersist = true);
72
72
  try {
73
73
  const gen = typeof fn === "function" ? fn(this.data, { schedulePersist }) : fn;
74
74
  yield* gen;
@@ -85,6 +85,14 @@ export interface Store {
85
85
  export interface Message {
86
86
  topic: `run:${string}:stream:${string}`;
87
87
  data: unknown;
88
+ /**
89
+ * Marks payloads that have already been converted to their protocol
90
+ * shape by the in-process streaming layer
91
+ * (e.g. `convertToProtocolEvent({ mode: "custom", ... })` output).
92
+ * Carried through the run-queue so downstream consumers (protocol session)
93
+ * can skip re-wrapping the payload.
94
+ */
95
+ normalized?: boolean;
88
96
  }
89
97
  export interface Thread {
90
98
  thread_id: string;
@@ -170,7 +178,8 @@ export interface RunsRepo {
170
178
  export interface RunsStreamRepo {
171
179
  join(runId: string, threadId: string | undefined, options: {
172
180
  ignore404?: boolean;
173
- cancelOnDisconnect?: AbortSignal;
181
+ signal?: AbortSignal;
182
+ cancelOnDisconnect?: boolean;
174
183
  lastEventId: string | undefined;
175
184
  }, auth: AuthContext | undefined): AsyncGenerator<{
176
185
  id?: string;