@langchain/react 0.1.2 → 0.2.0

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 (214) hide show
  1. package/README.md +225 -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 +6 -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 +0 -1
  17. package/dist/stream.cjs.map +1 -1
  18. package/dist/stream.custom.cjs +23 -3
  19. package/dist/stream.custom.cjs.map +1 -1
  20. package/dist/stream.custom.js +23 -2
  21. package/dist/stream.custom.js.map +1 -1
  22. package/dist/stream.d.cts +8 -6
  23. package/dist/stream.d.cts.map +1 -1
  24. package/dist/stream.d.ts +8 -6
  25. package/dist/stream.d.ts.map +1 -1
  26. package/dist/stream.js.map +1 -1
  27. package/dist/stream.lgp.cjs +12 -3
  28. package/dist/stream.lgp.cjs.map +1 -1
  29. package/dist/stream.lgp.js +13 -3
  30. package/dist/stream.lgp.js.map +1 -1
  31. package/dist/suspense-stream.cjs +187 -0
  32. package/dist/suspense-stream.cjs.map +1 -0
  33. package/dist/suspense-stream.d.cts +62 -0
  34. package/dist/suspense-stream.d.cts.map +1 -0
  35. package/dist/suspense-stream.d.ts +62 -0
  36. package/dist/suspense-stream.d.ts.map +1 -0
  37. package/dist/suspense-stream.js +186 -0
  38. package/dist/suspense-stream.js.map +1 -0
  39. package/dist/thread.cjs +0 -1
  40. package/dist/thread.cjs.map +1 -1
  41. package/dist/types.d.cts +18 -2
  42. package/dist/types.d.cts.map +1 -1
  43. package/dist/types.d.ts +18 -2
  44. package/dist/types.d.ts.map +1 -1
  45. package/package.json +7 -37
  46. package/dist/_virtual/_rolldown/runtime.cjs +0 -23
  47. 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
  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.map +0 -1
  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.ts +0 -83
  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.map +0 -1
  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/constants.d.cts +0 -42
  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.map +0 -1
  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.ts +0 -42
  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.map +0 -1
  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/graph/zod/index.d.cts +0 -2
  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.ts +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/meta.d.cts +0 -109
  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.map +0 -1
  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.ts +0 -109
  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.map +0 -1
  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/plugin.d.cts +0 -31
  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.map +0 -1
  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.ts +0 -31
  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.map +0 -1
  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/zod-registry.d.cts +0 -49
  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.map +0 -1
  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.ts +0 -49
  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.map +0 -1
  69. 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
  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.ts +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/index.d.cts +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.ts +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/middleware/contextEditing.d.cts +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.ts +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/dynamicSystemPrompt.d.cts +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.ts +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/hitl.d.cts +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.ts +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/llmToolSelector.d.cts +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.ts +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/modelCallLimit.d.cts +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.ts +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/modelFallback.d.cts +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.ts +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/modelRetry.d.cts +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.ts +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/pii.d.cts +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.ts +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/piiRedaction.d.cts +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.ts +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/provider/anthropic/promptCaching.d.cts +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.ts +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/openai/moderation.d.cts +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.ts +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/summarization.d.cts +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.ts +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/todoListMiddleware.d.cts +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.ts +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/toolCallLimit.d.cts +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.ts +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/toolEmulator.d.cts +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.ts +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/toolRetry.d.cts +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.ts +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/types.d.cts +0 -2
  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.ts +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.d.cts +0 -1
  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.ts +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/types.d.cts +0 -2
  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.ts +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/index.d.cts +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.ts +0 -2
  113. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/ZodError.d.cts +0 -155
  114. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/ZodError.d.cts.map +0 -1
  115. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/ZodError.d.ts +0 -155
  116. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/ZodError.d.ts.map +0 -1
  117. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/errorUtil.d.cts +0 -13
  118. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/errorUtil.d.cts.map +0 -1
  119. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/errorUtil.d.ts +0 -13
  120. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/errorUtil.d.ts.map +0 -1
  121. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/parseUtil.d.cts +0 -63
  122. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/parseUtil.d.cts.map +0 -1
  123. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/parseUtil.d.ts +0 -63
  124. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/parseUtil.d.ts.map +0 -1
  125. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/typeAliases.d.cts +0 -5
  126. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/typeAliases.d.cts.map +0 -1
  127. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/typeAliases.d.ts +0 -5
  128. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/typeAliases.d.ts.map +0 -1
  129. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/util.d.cts +0 -64
  130. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/util.d.cts.map +0 -1
  131. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/util.d.ts +0 -64
  132. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/helpers/util.d.ts.map +0 -1
  133. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/standard-schema.d.cts +0 -106
  134. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/standard-schema.d.cts.map +0 -1
  135. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/standard-schema.d.ts +0 -106
  136. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/standard-schema.d.ts.map +0 -1
  137. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/types.d.cts +0 -291
  138. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/types.d.cts.map +0 -1
  139. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/types.d.ts +0 -291
  140. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v3/types.d.ts.map +0 -1
  141. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.d.cts +0 -29
  142. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.d.cts.map +0 -1
  143. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.d.ts +0 -29
  144. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.d.ts.map +0 -1
  145. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.d.cts +0 -29
  146. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.d.cts.map +0 -1
  147. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.d.ts +0 -29
  148. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.d.ts.map +0 -1
  149. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.d.cts +0 -105
  150. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.d.cts.map +0 -1
  151. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.d.ts +0 -105
  152. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.d.ts.map +0 -1
  153. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema.d.cts +0 -70
  154. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema.d.cts.map +0 -1
  155. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema.d.ts +0 -70
  156. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema.d.ts.map +0 -1
  157. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.d.cts +0 -24
  158. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.d.cts.map +0 -1
  159. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.d.ts +0 -24
  160. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.d.ts.map +0 -1
  161. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.d.cts +0 -97
  162. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.d.cts.map +0 -1
  163. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.d.ts +0 -97
  164. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.d.ts.map +0 -1
  165. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/standard-schema.d.cts +0 -79
  166. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/standard-schema.d.cts.map +0 -1
  167. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/standard-schema.d.ts +0 -79
  168. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/standard-schema.d.ts.map +0 -1
  169. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.d.cts +0 -52
  170. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.d.cts.map +0 -1
  171. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.d.ts +0 -52
  172. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.d.ts.map +0 -1
  173. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.d.cts +0 -17
  174. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.d.cts.map +0 -1
  175. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.d.ts +0 -17
  176. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.d.ts.map +0 -1
  177. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.d.cts +0 -9
  178. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.d.cts.map +0 -1
  179. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.d.ts +0 -9
  180. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.d.ts.map +0 -1
  181. package/dist/react-ui/client.cjs +0 -136
  182. package/dist/react-ui/client.cjs.map +0 -1
  183. package/dist/react-ui/client.d.cts +0 -84
  184. package/dist/react-ui/client.d.cts.map +0 -1
  185. package/dist/react-ui/client.d.ts +0 -84
  186. package/dist/react-ui/client.d.ts.map +0 -1
  187. package/dist/react-ui/client.js +0 -130
  188. package/dist/react-ui/client.js.map +0 -1
  189. package/dist/react-ui/index.cjs +0 -14
  190. package/dist/react-ui/index.cjs.map +0 -1
  191. package/dist/react-ui/index.d.cts +0 -3
  192. package/dist/react-ui/index.d.ts +0 -3
  193. package/dist/react-ui/index.js +0 -8
  194. package/dist/react-ui/index.js.map +0 -1
  195. package/dist/react-ui/server/index.cjs +0 -5
  196. package/dist/react-ui/server/index.d.cts +0 -3
  197. package/dist/react-ui/server/index.d.ts +0 -3
  198. package/dist/react-ui/server/index.js +0 -3
  199. package/dist/react-ui/server/server.cjs +0 -56
  200. package/dist/react-ui/server/server.cjs.map +0 -1
  201. package/dist/react-ui/server/server.d.cts +0 -54
  202. package/dist/react-ui/server/server.d.cts.map +0 -1
  203. package/dist/react-ui/server/server.d.ts +0 -54
  204. package/dist/react-ui/server/server.d.ts.map +0 -1
  205. package/dist/react-ui/server/server.js +0 -55
  206. package/dist/react-ui/server/server.js.map +0 -1
  207. package/dist/react-ui/types.cjs +0 -37
  208. package/dist/react-ui/types.cjs.map +0 -1
  209. package/dist/react-ui/types.d.cts +0 -25
  210. package/dist/react-ui/types.d.cts.map +0 -1
  211. package/dist/react-ui/types.d.ts +0 -25
  212. package/dist/react-ui/types.d.ts.map +0 -1
  213. package/dist/react-ui/types.js +0 -35
  214. 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,138 @@ 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). See [`useStream` Options](#usestream-options) above.
146
+
147
+ ### Return Values
148
+
149
+ The return type is identical to `useStream` except:
150
+
151
+ | Removed | Reason |
152
+ |---|---|
153
+ | `isLoading` | Replaced by `isStreaming`; initial loading is handled by Suspense. |
154
+ | `error` | Thrown to the nearest Error Boundary instead. |
155
+ | `isThreadLoading` | Handled by Suspense (the component suspends until the thread is ready). |
156
+
157
+ | Added | Type | Description |
158
+ |---|---|---|
159
+ | `isStreaming` | `boolean` | `true` while the stream is receiving data. The component is never suspended during streaming. |
160
+
161
+ All other properties (`messages`, `submit`, `stop`, `interrupt`, `branch`, `switchThread`, `queue`, etc.) are unchanged.
162
+
163
+ ### Thread-switching with Suspense
164
+
165
+ `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:
166
+
167
+ ```tsx
168
+ function App() {
169
+ const [threadId, setThreadId] = useState<string | null>(null);
170
+
171
+ return (
172
+ <div className="flex">
173
+ <ThreadSidebar onSelect={setThreadId} />
174
+
175
+ <Suspense fallback={<ThreadSkeleton />}>
176
+ <ChatPanel threadId={threadId} />
177
+ </Suspense>
178
+ </div>
179
+ );
180
+ }
181
+
182
+ function ChatPanel({ threadId }: { threadId: string | null }) {
183
+ const { messages, submit, isStreaming } = useSuspenseStream({
184
+ assistantId: "agent",
185
+ apiUrl: "http://localhost:2024",
186
+ threadId,
187
+ });
188
+
189
+ return <MessageList messages={messages} />;
190
+ }
191
+ ```
192
+
193
+ ### Error recovery
194
+
195
+ 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:
196
+
197
+ ```tsx
198
+ import { invalidateSuspenseCache } from "@langchain/react";
199
+
200
+ <ErrorBoundary
201
+ onReset={() => invalidateSuspenseCache()}
202
+ fallbackRender={({ error, resetErrorBoundary }) => (
203
+ <div>
204
+ <p>{error.message}</p>
205
+ <button onClick={resetErrorBoundary}>Retry</button>
206
+ </div>
207
+ )}
208
+ >
209
+ <Suspense fallback={<Spinner />}>
210
+ <Chat />
211
+ </Suspense>
212
+ </ErrorBoundary>
213
+ ```
214
+
83
215
  ## Type Safety
84
216
 
85
217
  ### With `createAgent`
@@ -327,31 +459,110 @@ function Chat() {
327
459
  }
328
460
  ```
329
461
 
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.
462
+ 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`.
463
+
464
+ ## Sharing State with `StreamProvider`
465
+
466
+ 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:
467
+
468
+ ```tsx
469
+ import { StreamProvider, useStreamContext } from "@langchain/react";
470
+
471
+ function App() {
472
+ return (
473
+ <StreamProvider assistantId="agent" apiUrl="http://localhost:2024">
474
+ <ChatHeader />
475
+ <MessageList />
476
+ <MessageInput />
477
+ </StreamProvider>
478
+ );
479
+ }
480
+
481
+ function ChatHeader() {
482
+ const { isLoading, error } = useStreamContext();
483
+ return (
484
+ <header>
485
+ <h1>Chat</h1>
486
+ {isLoading && <span>Thinking...</span>}
487
+ {error != null && <span>Error occurred</span>}
488
+ </header>
489
+ );
490
+ }
491
+
492
+ function MessageList() {
493
+ const { messages, getMessagesMetadata } = useStreamContext();
494
+ return (
495
+ <div>
496
+ {messages.map((msg, i) => (
497
+ <div key={msg.id ?? i}>{msg.content}</div>
498
+ ))}
499
+ </div>
500
+ );
501
+ }
331
502
 
332
- ## React UI (Advanced)
503
+ function MessageInput() {
504
+ const { submit, isLoading } = useStreamContext();
505
+ return (
506
+ <button
507
+ disabled={isLoading}
508
+ onClick={() =>
509
+ void submit({
510
+ messages: [{ type: "human", content: "Hello!" }],
511
+ })
512
+ }
513
+ >
514
+ Send
515
+ </button>
516
+ );
517
+ }
518
+ ```
333
519
 
334
- The `@langchain/react/react-ui` sub-package provides utilities for rendering server-defined UI components:
520
+ ### Type Safety with `StreamProvider`
521
+
522
+ Pass agent or state types to both `StreamProvider` and `useStreamContext`:
335
523
 
336
524
  ```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";
525
+ import type { agent } from "./agent";
526
+
527
+ function App() {
528
+ return (
529
+ <StreamProvider<typeof agent>
530
+ assistantId="agent"
531
+ apiUrl="http://localhost:2024"
532
+ >
533
+ <Chat />
534
+ </StreamProvider>
535
+ );
536
+ }
537
+
538
+ function Chat() {
539
+ const { toolCalls } = useStreamContext<typeof agent>();
540
+ // toolCalls are fully typed from the agent's tools
541
+ }
340
542
  ```
341
543
 
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
544
+ ### Multiple Agents
345
545
 
346
- A server-side helper is also available:
546
+ Nest providers for multi-agent scenarios each subtree gets its own isolated stream:
347
547
 
348
548
  ```tsx
349
- import { typedUi } from "@langchain/react/react-ui/server";
549
+ function MultiAgentApp() {
550
+ return (
551
+ <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr" }}>
552
+ <StreamProvider assistantId="researcher" apiUrl="http://localhost:2024">
553
+ <ResearchPanel />
554
+ </StreamProvider>
555
+ <StreamProvider assistantId="writer" apiUrl="http://localhost:2024">
556
+ <WriterPanel />
557
+ </StreamProvider>
558
+ </div>
559
+ );
560
+ }
350
561
  ```
351
562
 
352
563
  ## Playground
353
564
 
354
- For complete end-to-end examples with full agentic UIs, visit the [LangGraph Playground](https://github.com/langchain-ai/langgraphjs).
565
+ For complete end-to-end examples with full agentic UIs, visit the [LangChain UI Playground](https://docs.langchain.com/playground).
355
566
 
356
567
  ## License
357
568
 
@@ -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"}