@langchain/react 0.1.3 → 0.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 (215) hide show
  1. package/README.md +246 -14
  2. package/dist/context.cjs +108 -0
  3. package/dist/context.cjs.map +1 -0
  4. package/dist/context.d.cts +109 -0
  5. package/dist/context.d.cts.map +1 -0
  6. package/dist/context.d.ts +109 -0
  7. package/dist/context.d.ts.map +1 -0
  8. package/dist/context.js +107 -0
  9. package/dist/context.js.map +1 -0
  10. package/dist/index.cjs +7 -1
  11. package/dist/index.d.cts +4 -2
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.ts +4 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +3 -1
  16. package/dist/stream.cjs +5 -4
  17. package/dist/stream.cjs.map +1 -1
  18. package/dist/stream.custom.cjs +22 -2
  19. package/dist/stream.custom.cjs.map +1 -1
  20. package/dist/stream.custom.js +22 -1
  21. package/dist/stream.custom.js.map +1 -1
  22. package/dist/stream.d.cts +3 -3
  23. package/dist/stream.d.cts.map +1 -1
  24. package/dist/stream.d.ts +3 -3
  25. package/dist/stream.d.ts.map +1 -1
  26. package/dist/stream.js +5 -3
  27. package/dist/stream.js.map +1 -1
  28. package/dist/stream.lgp.cjs +11 -2
  29. package/dist/stream.lgp.cjs.map +1 -1
  30. package/dist/stream.lgp.js +11 -1
  31. package/dist/stream.lgp.js.map +1 -1
  32. package/dist/suspense-stream.cjs +203 -0
  33. package/dist/suspense-stream.cjs.map +1 -0
  34. package/dist/suspense-stream.d.cts +81 -0
  35. package/dist/suspense-stream.d.cts.map +1 -0
  36. package/dist/suspense-stream.d.ts +81 -0
  37. package/dist/suspense-stream.d.ts.map +1 -0
  38. package/dist/suspense-stream.js +201 -0
  39. package/dist/suspense-stream.js.map +1 -0
  40. package/dist/thread.cjs +0 -1
  41. package/dist/thread.cjs.map +1 -1
  42. package/dist/types.d.cts +18 -2
  43. package/dist/types.d.cts.map +1 -1
  44. package/dist/types.d.ts +18 -2
  45. package/dist/types.d.ts.map +1 -1
  46. package/package.json +7 -37
  47. package/dist/_virtual/_rolldown/runtime.cjs +0 -23
  48. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/channels/base.d.cts +0 -83
  49. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/channels/base.d.cts.map +0 -1
  50. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/channels/base.d.ts +0 -83
  51. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/channels/base.d.ts.map +0 -1
  52. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/constants.d.cts +0 -42
  53. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/constants.d.cts.map +0 -1
  54. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/constants.d.ts +0 -42
  55. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/constants.d.ts.map +0 -1
  56. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/graph/zod/index.d.cts +0 -2
  57. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/graph/zod/index.d.ts +0 -2
  58. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/graph/zod/meta.d.cts +0 -109
  59. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/graph/zod/meta.d.cts.map +0 -1
  60. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/graph/zod/meta.d.ts +0 -109
  61. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/graph/zod/meta.d.ts.map +0 -1
  62. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/graph/zod/plugin.d.cts +0 -31
  63. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/graph/zod/plugin.d.cts.map +0 -1
  64. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/graph/zod/plugin.d.ts +0 -31
  65. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/graph/zod/plugin.d.ts.map +0 -1
  66. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/graph/zod/zod-registry.d.cts +0 -49
  67. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/graph/zod/zod-registry.d.cts.map +0 -1
  68. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/graph/zod/zod-registry.d.ts +0 -49
  69. package/dist/node_modules/.pnpm/@langchain_langgraph@1.2.1_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___z_dc6decfb18baf112a7d3c3203e2e3228/node_modules/@langchain/langgraph/dist/graph/zod/zod-registry.d.ts.map +0 -1
  70. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/ReactAgent.d.cts +0 -1
  71. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/ReactAgent.d.ts +0 -1
  72. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/index.d.cts +0 -1
  73. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/index.d.ts +0 -1
  74. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/contextEditing.d.cts +0 -1
  75. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/contextEditing.d.ts +0 -1
  76. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/dynamicSystemPrompt.d.cts +0 -1
  77. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/dynamicSystemPrompt.d.ts +0 -1
  78. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/hitl.d.cts +0 -1
  79. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/hitl.d.ts +0 -1
  80. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/llmToolSelector.d.cts +0 -1
  81. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/llmToolSelector.d.ts +0 -1
  82. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/modelCallLimit.d.cts +0 -1
  83. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/modelCallLimit.d.ts +0 -1
  84. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/modelFallback.d.cts +0 -1
  85. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/modelFallback.d.ts +0 -1
  86. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/modelRetry.d.cts +0 -1
  87. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/modelRetry.d.ts +0 -1
  88. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/pii.d.cts +0 -1
  89. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/pii.d.ts +0 -1
  90. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/piiRedaction.d.cts +0 -1
  91. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/piiRedaction.d.ts +0 -1
  92. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/provider/anthropic/promptCaching.d.cts +0 -1
  93. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/provider/anthropic/promptCaching.d.ts +0 -1
  94. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/provider/openai/moderation.d.cts +0 -1
  95. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/provider/openai/moderation.d.ts +0 -1
  96. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/summarization.d.cts +0 -1
  97. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/summarization.d.ts +0 -1
  98. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/todoListMiddleware.d.cts +0 -1
  99. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/todoListMiddleware.d.ts +0 -1
  100. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/toolCallLimit.d.cts +0 -1
  101. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/toolCallLimit.d.ts +0 -1
  102. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/toolEmulator.d.cts +0 -1
  103. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/toolEmulator.d.ts +0 -1
  104. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/toolRetry.d.cts +0 -1
  105. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/toolRetry.d.ts +0 -1
  106. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/types.d.cts +0 -2
  107. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware/types.d.ts +0 -2
  108. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware.d.cts +0 -1
  109. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/middleware.d.ts +0 -1
  110. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/types.d.cts +0 -2
  111. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/agents/types.d.ts +0 -2
  112. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/index.d.cts +0 -2
  113. package/dist/node_modules/.pnpm/langchain@1.2.30_@langchain_core@1.1.31_openai@6.27.0_ws@8.19.0_zod@4.3.6___openai@6.27_afd3ba7574abac8ef5d4f1eb16ab2ab0/node_modules/langchain/dist/index.d.ts +0 -2
  114. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/ZodError.d.cts +0 -155
  115. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/ZodError.d.cts.map +0 -1
  116. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/ZodError.d.ts +0 -155
  117. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/ZodError.d.ts.map +0 -1
  118. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/errorUtil.d.cts +0 -13
  119. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/errorUtil.d.cts.map +0 -1
  120. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/errorUtil.d.ts +0 -13
  121. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/errorUtil.d.ts.map +0 -1
  122. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/parseUtil.d.cts +0 -63
  123. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/parseUtil.d.cts.map +0 -1
  124. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/parseUtil.d.ts +0 -63
  125. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/parseUtil.d.ts.map +0 -1
  126. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/typeAliases.d.cts +0 -5
  127. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/typeAliases.d.cts.map +0 -1
  128. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/typeAliases.d.ts +0 -5
  129. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/typeAliases.d.ts.map +0 -1
  130. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/util.d.cts +0 -64
  131. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/util.d.cts.map +0 -1
  132. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/util.d.ts +0 -64
  133. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/util.d.ts.map +0 -1
  134. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/standard-schema.d.cts +0 -106
  135. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/standard-schema.d.cts.map +0 -1
  136. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/standard-schema.d.ts +0 -106
  137. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/standard-schema.d.ts.map +0 -1
  138. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/types.d.cts +0 -291
  139. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/types.d.cts.map +0 -1
  140. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/types.d.ts +0 -291
  141. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/types.d.ts.map +0 -1
  142. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.d.cts +0 -29
  143. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.d.cts.map +0 -1
  144. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.d.ts +0 -29
  145. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.d.ts.map +0 -1
  146. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.d.cts +0 -29
  147. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.d.cts.map +0 -1
  148. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.d.ts +0 -29
  149. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.d.ts.map +0 -1
  150. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.d.cts +0 -105
  151. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.d.cts.map +0 -1
  152. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.d.ts +0 -105
  153. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.d.ts.map +0 -1
  154. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema.d.cts +0 -70
  155. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema.d.cts.map +0 -1
  156. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema.d.ts +0 -70
  157. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema.d.ts.map +0 -1
  158. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.d.cts +0 -24
  159. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.d.cts.map +0 -1
  160. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.d.ts +0 -24
  161. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.d.ts.map +0 -1
  162. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.d.cts +0 -97
  163. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.d.cts.map +0 -1
  164. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.d.ts +0 -97
  165. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.d.ts.map +0 -1
  166. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/standard-schema.d.cts +0 -79
  167. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/standard-schema.d.cts.map +0 -1
  168. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/standard-schema.d.ts +0 -79
  169. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/standard-schema.d.ts.map +0 -1
  170. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.d.cts +0 -52
  171. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.d.cts.map +0 -1
  172. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.d.ts +0 -52
  173. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.d.ts.map +0 -1
  174. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.d.cts +0 -17
  175. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.d.cts.map +0 -1
  176. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.d.ts +0 -17
  177. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.d.ts.map +0 -1
  178. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.d.cts +0 -9
  179. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.d.cts.map +0 -1
  180. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.d.ts +0 -9
  181. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.d.ts.map +0 -1
  182. package/dist/react-ui/client.cjs +0 -136
  183. package/dist/react-ui/client.cjs.map +0 -1
  184. package/dist/react-ui/client.d.cts +0 -88
  185. package/dist/react-ui/client.d.cts.map +0 -1
  186. package/dist/react-ui/client.d.ts +0 -88
  187. package/dist/react-ui/client.d.ts.map +0 -1
  188. package/dist/react-ui/client.js +0 -130
  189. package/dist/react-ui/client.js.map +0 -1
  190. package/dist/react-ui/index.cjs +0 -14
  191. package/dist/react-ui/index.cjs.map +0 -1
  192. package/dist/react-ui/index.d.cts +0 -3
  193. package/dist/react-ui/index.d.ts +0 -3
  194. package/dist/react-ui/index.js +0 -8
  195. package/dist/react-ui/index.js.map +0 -1
  196. package/dist/react-ui/server/index.cjs +0 -5
  197. package/dist/react-ui/server/index.d.cts +0 -3
  198. package/dist/react-ui/server/index.d.ts +0 -3
  199. package/dist/react-ui/server/index.js +0 -3
  200. package/dist/react-ui/server/server.cjs +0 -56
  201. package/dist/react-ui/server/server.cjs.map +0 -1
  202. package/dist/react-ui/server/server.d.cts +0 -54
  203. package/dist/react-ui/server/server.d.cts.map +0 -1
  204. package/dist/react-ui/server/server.d.ts +0 -54
  205. package/dist/react-ui/server/server.d.ts.map +0 -1
  206. package/dist/react-ui/server/server.js +0 -55
  207. package/dist/react-ui/server/server.js.map +0 -1
  208. package/dist/react-ui/types.cjs +0 -37
  209. package/dist/react-ui/types.cjs.map +0 -1
  210. package/dist/react-ui/types.d.cts +0 -25
  211. package/dist/react-ui/types.d.cts.map +0 -1
  212. package/dist/react-ui/types.d.ts +0 -25
  213. package/dist/react-ui/types.d.ts.map +0 -1
  214. package/dist/react-ui/types.js +0 -35
  215. package/dist/react-ui/types.js.map +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @langchain/react
2
2
 
3
- React SDK for building AI-powered applications with [LangChain](https://js.langchain.com/) and [LangGraph](https://langchain-ai.github.io/langgraphjs/). Provides a `useStream` hook that manages streaming, state, branching, and interrupts out of the box.
3
+ React SDK for building AI-powered applications with [Deep Agents](https://docs.langchain.com/oss/javascript/deepagents/overview), [LangChain](https://docs.langchain.com/oss/javascript/langchain/overview) and [LangGraph](https://docs.langchain.com/oss/javascript/langgraph/overview). It provides a `useStream` hook that manages streaming, state, branching, and interrupts out of the box.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,7 +8,7 @@ React SDK for building AI-powered applications with [LangChain](https://js.langc
8
8
  npm install @langchain/react @langchain/core
9
9
  ```
10
10
 
11
- **Peer dependencies:** `react` (^18 || ^19), `react-dom` (^18 || ^19), `@langchain/core` (^1.0.1)
11
+ **Peer dependencies:** `react` (^18 || ^19), `@langchain/core` (^1.1.27)
12
12
 
13
13
  ## Quick Start
14
14
 
@@ -80,6 +80,159 @@ function Chat() {
80
80
  | `queue.cancel(id)` | `(id: string) => Promise<boolean>` | Cancel a pending run on the server by its run ID. |
81
81
  | `queue.clear()` | `() => Promise<void>` | Cancel all pending runs on the server. |
82
82
 
83
+ ## `useSuspenseStream`
84
+
85
+ `useSuspenseStream` is a companion hook to `useStream` that integrates with React's [Suspense](https://react.dev/reference/react/Suspense) and [Error Boundary](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary) protocols. Instead of handling loading and error states inside your component, you declare them in parent boundaries:
86
+
87
+ ```tsx
88
+ import { Suspense } from "react";
89
+ import { ErrorBoundary } from "react-error-boundary";
90
+ import { useSuspenseStream } from "@langchain/react";
91
+
92
+ function App() {
93
+ return (
94
+ <ErrorBoundary
95
+ fallback={({ error, resetErrorBoundary }) => (
96
+ <div>
97
+ <p>{error.message}</p>
98
+ <button onClick={resetErrorBoundary}>Retry</button>
99
+ </div>
100
+ )}
101
+ >
102
+ <Suspense fallback={<Spinner />}>
103
+ <Chat />
104
+ </Suspense>
105
+ </ErrorBoundary>
106
+ );
107
+ }
108
+
109
+ function Chat() {
110
+ // No isLoading/error checks needed — Suspense and ErrorBoundary handle them.
111
+ const { messages, submit, isStreaming } = useSuspenseStream({
112
+ assistantId: "agent",
113
+ apiUrl: "http://localhost:2024",
114
+ });
115
+
116
+ return (
117
+ <div>
118
+ {messages.map((msg, i) => (
119
+ <div key={msg.id ?? i}>{msg.content}</div>
120
+ ))}
121
+ {isStreaming && <TypingIndicator />}
122
+
123
+ <button
124
+ onClick={() =>
125
+ void submit({
126
+ messages: [{ type: "human", content: "Hello!" }],
127
+ })
128
+ }
129
+ >
130
+ Send
131
+ </button>
132
+ </div>
133
+ );
134
+ }
135
+ ```
136
+
137
+ ### How it works
138
+
139
+ - **Suspends** while the initial thread history is loading (e.g. when a `threadId` is provided and the thread data is being fetched). The nearest `<Suspense>` boundary renders its fallback during this time.
140
+ - **Throws errors** to the nearest Error Boundary when the stream encounters an error outside of active streaming.
141
+ - **Does not suspend during streaming.** Streaming is incremental — messages arrive progressively and the UI must update in real time. The `isStreaming` flag indicates whether tokens are currently arriving.
142
+
143
+ ### Options
144
+
145
+ `useSuspenseStream` accepts the same options as `useStream` (LangGraph Platform mode), plus:
146
+
147
+ | Option | Type | Description |
148
+ |---|---|---|
149
+ | `suspenseCache` | `SuspenseCache` | Optional cache instance for Suspense history prefetching. Useful in tests to avoid cross-test cache sharing. |
150
+
151
+ ### Return Values
152
+
153
+ The return type is identical to `useStream` except:
154
+
155
+ | Removed | Reason |
156
+ |---|---|
157
+ | `isLoading` | Replaced by `isStreaming`; initial loading is handled by Suspense. |
158
+ | `error` | Thrown to the nearest Error Boundary instead. |
159
+ | `isThreadLoading` | Handled by Suspense (the component suspends until the thread is ready). |
160
+
161
+ | Added | Type | Description |
162
+ |---|---|---|
163
+ | `isStreaming` | `boolean` | `true` while the stream is receiving data. The component is never suspended during streaming. |
164
+
165
+ All other properties (`messages`, `submit`, `stop`, `interrupt`, `branch`, `switchThread`, `queue`, etc.) are unchanged.
166
+
167
+ ### Thread-switching with Suspense
168
+
169
+ `useSuspenseStream` works naturally with thread switching. When the `threadId` changes, the component suspends while the new thread's history loads, and `<Suspense>` shows a smooth skeleton/fallback transition:
170
+
171
+ ```tsx
172
+ function App() {
173
+ const [threadId, setThreadId] = useState<string | null>(null);
174
+
175
+ return (
176
+ <div className="flex">
177
+ <ThreadSidebar onSelect={setThreadId} />
178
+
179
+ <Suspense fallback={<ThreadSkeleton />}>
180
+ <ChatPanel threadId={threadId} />
181
+ </Suspense>
182
+ </div>
183
+ );
184
+ }
185
+
186
+ function ChatPanel({ threadId }: { threadId: string | null }) {
187
+ const { messages, submit, isStreaming } = useSuspenseStream({
188
+ assistantId: "agent",
189
+ apiUrl: "http://localhost:2024",
190
+ threadId,
191
+ });
192
+
193
+ return <MessageList messages={messages} />;
194
+ }
195
+ ```
196
+
197
+ ### Error recovery
198
+
199
+ When an error is thrown to an Error Boundary, call `invalidateSuspenseCache()` in the boundary's reset handler so the retry triggers a fresh data fetch:
200
+
201
+ ```tsx
202
+ import { invalidateSuspenseCache } from "@langchain/react";
203
+
204
+ <ErrorBoundary
205
+ onReset={() => invalidateSuspenseCache()}
206
+ fallbackRender={({ error, resetErrorBoundary }) => (
207
+ <div>
208
+ <p>{error.message}</p>
209
+ <button onClick={resetErrorBoundary}>Retry</button>
210
+ </div>
211
+ )}
212
+ >
213
+ <Suspense fallback={<Spinner />}>
214
+ <Chat />
215
+ </Suspense>
216
+ </ErrorBoundary>
217
+ ```
218
+
219
+ For test isolation, you can create and pass a dedicated cache instance:
220
+
221
+ ```tsx
222
+ import { createSuspenseCache, useSuspenseStream } from "@langchain/react";
223
+
224
+ const suspenseCache = createSuspenseCache();
225
+
226
+ function Chat() {
227
+ const stream = useSuspenseStream({
228
+ assistantId: "agent",
229
+ apiUrl: "http://localhost:2024",
230
+ suspenseCache,
231
+ });
232
+ // ...
233
+ }
234
+ ```
235
+
83
236
  ## Type Safety
84
237
 
85
238
  ### With `createAgent`
@@ -327,31 +480,110 @@ function Chat() {
327
480
  }
328
481
  ```
329
482
 
330
- The custom transport interface returns the same properties as the standard `useStream` hook, including `getMessagesMetadata`, `branch`, `setBranch`, `switchThread`, and all message/interrupt/subagent helpers. When using a custom transport, `getMessagesMetadata` returns stream metadata sent alongside messages during streaming; `branch` and `setBranch` provide local branch state management.
483
+ The custom transport interface returns the same properties as the standard `useStream` hook, including `getMessagesMetadata`, `branch`, `setBranch`, `switchThread`, and all message/interrupt/subagent helpers. When using a custom transport, `getMessagesMetadata` returns stream metadata sent alongside messages during streaming; `branch` and `setBranch` provide local branch state management. `onFinish` is also supported and receives a synthetic `ThreadState` built from the final locally streamed values; the run metadata argument is `undefined`.
331
484
 
332
- ## React UI (Advanced)
485
+ ## Sharing State with `StreamProvider`
333
486
 
334
- The `@langchain/react/react-ui` sub-package provides utilities for rendering server-defined UI components:
487
+ When multiple components in a tree need access to the same stream (a message list, a header with loading status, an input bar), use `StreamProvider` and `useStreamContext` to avoid prop drilling:
335
488
 
336
489
  ```tsx
337
- import { useStreamContext, LoadExternalComponent } from "@langchain/react/react-ui";
338
- import { uiMessageReducer } from "@langchain/react/react-ui";
339
- import type { UIMessage } from "@langchain/react/react-ui";
490
+ import { StreamProvider, useStreamContext } from "@langchain/react";
491
+
492
+ function App() {
493
+ return (
494
+ <StreamProvider assistantId="agent" apiUrl="http://localhost:2024">
495
+ <ChatHeader />
496
+ <MessageList />
497
+ <MessageInput />
498
+ </StreamProvider>
499
+ );
500
+ }
501
+
502
+ function ChatHeader() {
503
+ const { isLoading, error } = useStreamContext();
504
+ return (
505
+ <header>
506
+ <h1>Chat</h1>
507
+ {isLoading && <span>Thinking...</span>}
508
+ {error != null && <span>Error occurred</span>}
509
+ </header>
510
+ );
511
+ }
512
+
513
+ function MessageList() {
514
+ const { messages, getMessagesMetadata } = useStreamContext();
515
+ return (
516
+ <div>
517
+ {messages.map((msg, i) => (
518
+ <div key={msg.id ?? i}>{msg.content}</div>
519
+ ))}
520
+ </div>
521
+ );
522
+ }
523
+
524
+ function MessageInput() {
525
+ const { submit, isLoading } = useStreamContext();
526
+ return (
527
+ <button
528
+ disabled={isLoading}
529
+ onClick={() =>
530
+ void submit({
531
+ messages: [{ type: "human", content: "Hello!" }],
532
+ })
533
+ }
534
+ >
535
+ Send
536
+ </button>
537
+ );
538
+ }
539
+ ```
540
+
541
+ ### Type Safety with `StreamProvider`
542
+
543
+ Pass agent or state types to both `StreamProvider` and `useStreamContext`:
544
+
545
+ ```tsx
546
+ import type { agent } from "./agent";
547
+
548
+ function App() {
549
+ return (
550
+ <StreamProvider<typeof agent>
551
+ assistantId="agent"
552
+ apiUrl="http://localhost:2024"
553
+ >
554
+ <Chat />
555
+ </StreamProvider>
556
+ );
557
+ }
558
+
559
+ function Chat() {
560
+ const { toolCalls } = useStreamContext<typeof agent>();
561
+ // toolCalls are fully typed from the agent's tools
562
+ }
340
563
  ```
341
564
 
342
- - **`useStreamContext`** - Access the stream context from deeply nested components
343
- - **`LoadExternalComponent`** - Render UI components defined by the server
344
- - **`uiMessageReducer`** - Reducer for managing UI message state
565
+ ### Multiple Agents
345
566
 
346
- A server-side helper is also available:
567
+ Nest providers for multi-agent scenarios each subtree gets its own isolated stream:
347
568
 
348
569
  ```tsx
349
- import { typedUi } from "@langchain/react/react-ui/server";
570
+ function MultiAgentApp() {
571
+ return (
572
+ <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr" }}>
573
+ <StreamProvider assistantId="researcher" apiUrl="http://localhost:2024">
574
+ <ResearchPanel />
575
+ </StreamProvider>
576
+ <StreamProvider assistantId="writer" apiUrl="http://localhost:2024">
577
+ <WriterPanel />
578
+ </StreamProvider>
579
+ </div>
580
+ );
581
+ }
350
582
  ```
351
583
 
352
584
  ## Playground
353
585
 
354
- For complete end-to-end examples with full agentic UIs, visit the [LangGraph Playground](https://github.com/langchain-ai/langgraphjs).
586
+ For complete end-to-end examples with full agentic UIs, visit the [LangChain UI Playground](https://docs.langchain.com/playground).
355
587
 
356
588
  ## License
357
589
 
@@ -0,0 +1,108 @@
1
+ "use client";
2
+ const require_stream = require("./stream.cjs");
3
+ let react = require("react");
4
+ let react_jsx_runtime = require("react/jsx-runtime");
5
+ //#region src/context.tsx
6
+ const StreamContext = (0, react.createContext)(null);
7
+ /**
8
+ * Provides a shared `useStream` instance to all descendants via React Context.
9
+ *
10
+ * Use `StreamProvider` when multiple components in a subtree need access to the
11
+ * same stream state (messages, loading status, errors, interrupts, etc.) without
12
+ * prop drilling.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * import { StreamProvider, useStreamContext } from "@langchain/react";
17
+ *
18
+ * function App() {
19
+ * return (
20
+ * <StreamProvider assistantId="agent" apiUrl="http://localhost:2024">
21
+ * <ChatHeader />
22
+ * <MessageList />
23
+ * <MessageInput />
24
+ * </StreamProvider>
25
+ * );
26
+ * }
27
+ *
28
+ * function ChatHeader() {
29
+ * const { isLoading, error } = useStreamContext();
30
+ * return (
31
+ * <header>
32
+ * {isLoading && <span>Thinking...</span>}
33
+ * {error && <span>Error</span>}
34
+ * </header>
35
+ * );
36
+ * }
37
+ *
38
+ * function MessageList() {
39
+ * const { messages } = useStreamContext();
40
+ * return messages.map((msg, i) => <div key={msg.id ?? i}>{msg.content}</div>);
41
+ * }
42
+ *
43
+ * function MessageInput() {
44
+ * const { submit } = useStreamContext();
45
+ * return (
46
+ * <button onClick={() => submit({ messages: [{ type: "human", content: "Hi" }] })}>
47
+ * Send
48
+ * </button>
49
+ * );
50
+ * }
51
+ * ```
52
+ *
53
+ * Multiple providers can be nested for multi-agent scenarios:
54
+ *
55
+ * @example
56
+ * ```tsx
57
+ * <StreamProvider assistantId="researcher" apiUrl="http://localhost:2024">
58
+ * <ResearchPanel />
59
+ * </StreamProvider>
60
+ * <StreamProvider assistantId="writer" apiUrl="http://localhost:2024">
61
+ * <WriterPanel />
62
+ * </StreamProvider>
63
+ * ```
64
+ */
65
+ function StreamProvider(props) {
66
+ const { children, ...options } = props;
67
+ const stream = require_stream.useStream(options);
68
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StreamContext.Provider, {
69
+ value: stream,
70
+ children
71
+ });
72
+ }
73
+ /**
74
+ * Accesses the shared stream instance from the nearest `StreamProvider`.
75
+ *
76
+ * Throws if called outside of a `StreamProvider`.
77
+ *
78
+ * @example
79
+ * ```tsx
80
+ * function MessageList() {
81
+ * const { messages, getMessagesMetadata } = useStreamContext();
82
+ * return messages.map((msg, i) => {
83
+ * const metadata = getMessagesMetadata(msg, i);
84
+ * return <div key={msg.id ?? i}>{msg.content}</div>;
85
+ * });
86
+ * }
87
+ * ```
88
+ *
89
+ * @example With type parameters for full type safety:
90
+ * ```tsx
91
+ * import type { agent } from "./agent";
92
+ *
93
+ * function Chat() {
94
+ * const { toolCalls } = useStreamContext<typeof agent>();
95
+ * // toolCalls are fully typed from the agent's tools
96
+ * }
97
+ * ```
98
+ */
99
+ function useStreamContext() {
100
+ const context = (0, react.useContext)(StreamContext);
101
+ if (context === null) throw new Error("useStreamContext must be used within a <StreamProvider>. Wrap your component tree with <StreamProvider> or use useStream() directly.");
102
+ return context;
103
+ }
104
+ //#endregion
105
+ exports.StreamProvider = StreamProvider;
106
+ exports.useStreamContext = useStreamContext;
107
+
108
+ //# sourceMappingURL=context.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.cjs","names":["useStream"],"sources":["../src/context.tsx"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\n\"use client\";\n\nimport { createContext, useContext, type ReactNode } from \"react\";\nimport type { BagTemplate } from \"@langchain/langgraph-sdk\";\nimport type {\n ResolveStreamOptions,\n InferBag,\n InferStateType,\n UseStreamCustomOptions,\n} from \"@langchain/langgraph-sdk/ui\";\nimport { useStream } from \"./stream.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst StreamContext = createContext<any | null>(null);\n\n/**\n * Props for the StreamProvider component.\n * Accepts all `useStream` options plus `children`.\n */\nexport type StreamProviderProps<\n T = Record<string, unknown>,\n Bag extends BagTemplate = BagTemplate,\n> = ResolveStreamOptions<T, InferBag<T, Bag>> & { children: ReactNode };\n\n/**\n * Props for the StreamProvider component when using a custom transport.\n * Accepts all `useStream` custom options plus `children`.\n */\nexport type StreamProviderCustomProps<\n T = Record<string, unknown>,\n Bag extends BagTemplate = BagTemplate,\n> = UseStreamCustomOptions<InferStateType<T>, InferBag<T, Bag>> & {\n children: ReactNode;\n};\n\n/**\n * Provides a shared `useStream` instance to all descendants via React Context.\n *\n * Use `StreamProvider` when multiple components in a subtree need access to the\n * same stream state (messages, loading status, errors, interrupts, etc.) without\n * prop drilling.\n *\n * @example\n * ```tsx\n * import { StreamProvider, useStreamContext } from \"@langchain/react\";\n *\n * function App() {\n * return (\n * <StreamProvider assistantId=\"agent\" apiUrl=\"http://localhost:2024\">\n * <ChatHeader />\n * <MessageList />\n * <MessageInput />\n * </StreamProvider>\n * );\n * }\n *\n * function ChatHeader() {\n * const { isLoading, error } = useStreamContext();\n * return (\n * <header>\n * {isLoading && <span>Thinking...</span>}\n * {error && <span>Error</span>}\n * </header>\n * );\n * }\n *\n * function MessageList() {\n * const { messages } = useStreamContext();\n * return messages.map((msg, i) => <div key={msg.id ?? i}>{msg.content}</div>);\n * }\n *\n * function MessageInput() {\n * const { submit } = useStreamContext();\n * return (\n * <button onClick={() => submit({ messages: [{ type: \"human\", content: \"Hi\" }] })}>\n * Send\n * </button>\n * );\n * }\n * ```\n *\n * Multiple providers can be nested for multi-agent scenarios:\n *\n * @example\n * ```tsx\n * <StreamProvider assistantId=\"researcher\" apiUrl=\"http://localhost:2024\">\n * <ResearchPanel />\n * </StreamProvider>\n * <StreamProvider assistantId=\"writer\" apiUrl=\"http://localhost:2024\">\n * <WriterPanel />\n * </StreamProvider>\n * ```\n */\nexport function StreamProvider<\n T = Record<string, unknown>,\n Bag extends BagTemplate = BagTemplate,\n>(\n props: StreamProviderProps<T, Bag> | StreamProviderCustomProps<T, Bag>,\n): ReactNode {\n const { children, ...options } = props;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const stream = useStream<T, Bag>(options as any);\n\n return (\n <StreamContext.Provider value={stream}>{children}</StreamContext.Provider>\n );\n}\n\n/**\n * Accesses the shared stream instance from the nearest `StreamProvider`.\n *\n * Throws if called outside of a `StreamProvider`.\n *\n * @example\n * ```tsx\n * function MessageList() {\n * const { messages, getMessagesMetadata } = useStreamContext();\n * return messages.map((msg, i) => {\n * const metadata = getMessagesMetadata(msg, i);\n * return <div key={msg.id ?? i}>{msg.content}</div>;\n * });\n * }\n * ```\n *\n * @example With type parameters for full type safety:\n * ```tsx\n * import type { agent } from \"./agent\";\n *\n * function Chat() {\n * const { toolCalls } = useStreamContext<typeof agent>();\n * // toolCalls are fully typed from the agent's tools\n * }\n * ```\n */\nexport function useStreamContext<\n T = Record<string, unknown>,\n Bag extends BagTemplate = BagTemplate,\n>(): ReturnType<typeof useStream<T, Bag>> {\n const context = useContext(StreamContext);\n if (context === null) {\n throw new Error(\n \"useStreamContext must be used within a <StreamProvider>. \" +\n \"Wrap your component tree with <StreamProvider> or use useStream() directly.\",\n );\n }\n return context;\n}\n"],"mappings":";;;;;AAeA,MAAM,iBAAA,GAAA,MAAA,eAA0C,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFrD,SAAgB,eAId,OACW;CACX,MAAM,EAAE,UAAU,GAAG,YAAY;CAEjC,MAAM,SAASA,eAAAA,UAAkB,QAAe;AAEhD,QACE,iBAAA,GAAA,kBAAA,KAAC,cAAc,UAAf;EAAwB,OAAO;EAAS;EAAkC,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8B9E,SAAgB,mBAG0B;CACxC,MAAM,WAAA,GAAA,MAAA,YAAqB,cAAc;AACzC,KAAI,YAAY,KACd,OAAM,IAAI,MACR,uIAED;AAEH,QAAO"}
@@ -0,0 +1,109 @@
1
+ import { useStream } from "./stream.cjs";
2
+ import { BagTemplate } from "@langchain/langgraph-sdk";
3
+ import { InferBag, InferStateType, ResolveStreamOptions, UseStreamCustomOptions } from "@langchain/langgraph-sdk/ui";
4
+ import { ReactNode } from "react";
5
+
6
+ //#region src/context.d.ts
7
+ /**
8
+ * Props for the StreamProvider component.
9
+ * Accepts all `useStream` options plus `children`.
10
+ */
11
+ type StreamProviderProps<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate> = ResolveStreamOptions<T, InferBag<T, Bag>> & {
12
+ children: ReactNode;
13
+ };
14
+ /**
15
+ * Props for the StreamProvider component when using a custom transport.
16
+ * Accepts all `useStream` custom options plus `children`.
17
+ */
18
+ type StreamProviderCustomProps<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate> = UseStreamCustomOptions<InferStateType<T>, InferBag<T, Bag>> & {
19
+ children: ReactNode;
20
+ };
21
+ /**
22
+ * Provides a shared `useStream` instance to all descendants via React Context.
23
+ *
24
+ * Use `StreamProvider` when multiple components in a subtree need access to the
25
+ * same stream state (messages, loading status, errors, interrupts, etc.) without
26
+ * prop drilling.
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * import { StreamProvider, useStreamContext } from "@langchain/react";
31
+ *
32
+ * function App() {
33
+ * return (
34
+ * <StreamProvider assistantId="agent" apiUrl="http://localhost:2024">
35
+ * <ChatHeader />
36
+ * <MessageList />
37
+ * <MessageInput />
38
+ * </StreamProvider>
39
+ * );
40
+ * }
41
+ *
42
+ * function ChatHeader() {
43
+ * const { isLoading, error } = useStreamContext();
44
+ * return (
45
+ * <header>
46
+ * {isLoading && <span>Thinking...</span>}
47
+ * {error && <span>Error</span>}
48
+ * </header>
49
+ * );
50
+ * }
51
+ *
52
+ * function MessageList() {
53
+ * const { messages } = useStreamContext();
54
+ * return messages.map((msg, i) => <div key={msg.id ?? i}>{msg.content}</div>);
55
+ * }
56
+ *
57
+ * function MessageInput() {
58
+ * const { submit } = useStreamContext();
59
+ * return (
60
+ * <button onClick={() => submit({ messages: [{ type: "human", content: "Hi" }] })}>
61
+ * Send
62
+ * </button>
63
+ * );
64
+ * }
65
+ * ```
66
+ *
67
+ * Multiple providers can be nested for multi-agent scenarios:
68
+ *
69
+ * @example
70
+ * ```tsx
71
+ * <StreamProvider assistantId="researcher" apiUrl="http://localhost:2024">
72
+ * <ResearchPanel />
73
+ * </StreamProvider>
74
+ * <StreamProvider assistantId="writer" apiUrl="http://localhost:2024">
75
+ * <WriterPanel />
76
+ * </StreamProvider>
77
+ * ```
78
+ */
79
+ declare function StreamProvider<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate>(props: StreamProviderProps<T, Bag> | StreamProviderCustomProps<T, Bag>): ReactNode;
80
+ /**
81
+ * Accesses the shared stream instance from the nearest `StreamProvider`.
82
+ *
83
+ * Throws if called outside of a `StreamProvider`.
84
+ *
85
+ * @example
86
+ * ```tsx
87
+ * function MessageList() {
88
+ * const { messages, getMessagesMetadata } = useStreamContext();
89
+ * return messages.map((msg, i) => {
90
+ * const metadata = getMessagesMetadata(msg, i);
91
+ * return <div key={msg.id ?? i}>{msg.content}</div>;
92
+ * });
93
+ * }
94
+ * ```
95
+ *
96
+ * @example With type parameters for full type safety:
97
+ * ```tsx
98
+ * import type { agent } from "./agent";
99
+ *
100
+ * function Chat() {
101
+ * const { toolCalls } = useStreamContext<typeof agent>();
102
+ * // toolCalls are fully typed from the agent's tools
103
+ * }
104
+ * ```
105
+ */
106
+ declare function useStreamContext<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate>(): ReturnType<typeof useStream<T, Bag>>;
107
+ //#endregion
108
+ export { StreamProvider, StreamProviderCustomProps, StreamProviderProps, useStreamContext };
109
+ //# sourceMappingURL=context.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.cts","names":[],"sources":["../src/context.tsx"],"mappings":";;;;;;;;AAqBA;;KAAY,mBAAA,KACN,MAAA,+BACQ,WAAA,GAAc,WAAA,IACxB,oBAAA,CAAqB,CAAA,EAAG,QAAA,CAAS,CAAA,EAAG,GAAA;EAAU,QAAA,EAAU,SAAA;AAAA;;;;;KAMhD,yBAAA,KACN,MAAA,+BACQ,WAAA,GAAc,WAAA,IACxB,sBAAA,CAAuB,cAAA,CAAe,CAAA,GAAI,QAAA,CAAS,CAAA,EAAG,GAAA;EACxD,QAAA,EAAU,SAAA;AAAA;;;;;;;;;;;;;;;;;AAJZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA;;;;;;;;;;;;iBAAgB,cAAA,KACV,MAAA,+BACQ,WAAA,GAAc,WAAA,CAAA,CAE1B,KAAA,EAAO,mBAAA,CAAoB,CAAA,EAAG,GAAA,IAAO,yBAAA,CAA0B,CAAA,EAAG,GAAA,IACjE,SAAA;;;;;;;;;;;;;;;;;;AAoCH;;;;;;;;;iBAAgB,gBAAA,KACV,MAAA,+BACQ,WAAA,GAAc,WAAA,CAAA,CAAA,GACvB,UAAA,QAAkB,SAAA,CAAU,CAAA,EAAG,GAAA"}
@@ -0,0 +1,109 @@
1
+ import { useStream } from "./stream.js";
2
+ import { ReactNode } from "react";
3
+ import { InferBag, InferStateType, ResolveStreamOptions, UseStreamCustomOptions } from "@langchain/langgraph-sdk/ui";
4
+ import { BagTemplate } from "@langchain/langgraph-sdk";
5
+
6
+ //#region src/context.d.ts
7
+ /**
8
+ * Props for the StreamProvider component.
9
+ * Accepts all `useStream` options plus `children`.
10
+ */
11
+ type StreamProviderProps<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate> = ResolveStreamOptions<T, InferBag<T, Bag>> & {
12
+ children: ReactNode;
13
+ };
14
+ /**
15
+ * Props for the StreamProvider component when using a custom transport.
16
+ * Accepts all `useStream` custom options plus `children`.
17
+ */
18
+ type StreamProviderCustomProps<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate> = UseStreamCustomOptions<InferStateType<T>, InferBag<T, Bag>> & {
19
+ children: ReactNode;
20
+ };
21
+ /**
22
+ * Provides a shared `useStream` instance to all descendants via React Context.
23
+ *
24
+ * Use `StreamProvider` when multiple components in a subtree need access to the
25
+ * same stream state (messages, loading status, errors, interrupts, etc.) without
26
+ * prop drilling.
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * import { StreamProvider, useStreamContext } from "@langchain/react";
31
+ *
32
+ * function App() {
33
+ * return (
34
+ * <StreamProvider assistantId="agent" apiUrl="http://localhost:2024">
35
+ * <ChatHeader />
36
+ * <MessageList />
37
+ * <MessageInput />
38
+ * </StreamProvider>
39
+ * );
40
+ * }
41
+ *
42
+ * function ChatHeader() {
43
+ * const { isLoading, error } = useStreamContext();
44
+ * return (
45
+ * <header>
46
+ * {isLoading && <span>Thinking...</span>}
47
+ * {error && <span>Error</span>}
48
+ * </header>
49
+ * );
50
+ * }
51
+ *
52
+ * function MessageList() {
53
+ * const { messages } = useStreamContext();
54
+ * return messages.map((msg, i) => <div key={msg.id ?? i}>{msg.content}</div>);
55
+ * }
56
+ *
57
+ * function MessageInput() {
58
+ * const { submit } = useStreamContext();
59
+ * return (
60
+ * <button onClick={() => submit({ messages: [{ type: "human", content: "Hi" }] })}>
61
+ * Send
62
+ * </button>
63
+ * );
64
+ * }
65
+ * ```
66
+ *
67
+ * Multiple providers can be nested for multi-agent scenarios:
68
+ *
69
+ * @example
70
+ * ```tsx
71
+ * <StreamProvider assistantId="researcher" apiUrl="http://localhost:2024">
72
+ * <ResearchPanel />
73
+ * </StreamProvider>
74
+ * <StreamProvider assistantId="writer" apiUrl="http://localhost:2024">
75
+ * <WriterPanel />
76
+ * </StreamProvider>
77
+ * ```
78
+ */
79
+ declare function StreamProvider<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate>(props: StreamProviderProps<T, Bag> | StreamProviderCustomProps<T, Bag>): ReactNode;
80
+ /**
81
+ * Accesses the shared stream instance from the nearest `StreamProvider`.
82
+ *
83
+ * Throws if called outside of a `StreamProvider`.
84
+ *
85
+ * @example
86
+ * ```tsx
87
+ * function MessageList() {
88
+ * const { messages, getMessagesMetadata } = useStreamContext();
89
+ * return messages.map((msg, i) => {
90
+ * const metadata = getMessagesMetadata(msg, i);
91
+ * return <div key={msg.id ?? i}>{msg.content}</div>;
92
+ * });
93
+ * }
94
+ * ```
95
+ *
96
+ * @example With type parameters for full type safety:
97
+ * ```tsx
98
+ * import type { agent } from "./agent";
99
+ *
100
+ * function Chat() {
101
+ * const { toolCalls } = useStreamContext<typeof agent>();
102
+ * // toolCalls are fully typed from the agent's tools
103
+ * }
104
+ * ```
105
+ */
106
+ declare function useStreamContext<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate>(): ReturnType<typeof useStream<T, Bag>>;
107
+ //#endregion
108
+ export { StreamProvider, StreamProviderCustomProps, StreamProviderProps, useStreamContext };
109
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","names":[],"sources":["../src/context.tsx"],"mappings":";;;;;;;;AAqBA;;KAAY,mBAAA,KACN,MAAA,+BACQ,WAAA,GAAc,WAAA,IACxB,oBAAA,CAAqB,CAAA,EAAG,QAAA,CAAS,CAAA,EAAG,GAAA;EAAU,QAAA,EAAU,SAAA;AAAA;;;;;KAMhD,yBAAA,KACN,MAAA,+BACQ,WAAA,GAAc,WAAA,IACxB,sBAAA,CAAuB,cAAA,CAAe,CAAA,GAAI,QAAA,CAAS,CAAA,EAAG,GAAA;EACxD,QAAA,EAAU,SAAA;AAAA;;;;;;;;;;;;;;;;;AAJZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA;;;;;;;;;;;;iBAAgB,cAAA,KACV,MAAA,+BACQ,WAAA,GAAc,WAAA,CAAA,CAE1B,KAAA,EAAO,mBAAA,CAAoB,CAAA,EAAG,GAAA,IAAO,yBAAA,CAA0B,CAAA,EAAG,GAAA,IACjE,SAAA;;;;;;;;;;;;;;;;;;AAoCH;;;;;;;;;iBAAgB,gBAAA,KACV,MAAA,+BACQ,WAAA,GAAc,WAAA,CAAA,CAAA,GACvB,UAAA,QAAkB,SAAA,CAAU,CAAA,EAAG,GAAA"}