@langchain/react 0.0.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.
- package/LICENSE +21 -0
- package/README.md +301 -0
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/index.cjs +38 -0
- package/dist/index.d.cts +12 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/channels/base.d.cts +83 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/channels/base.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/channels/base.d.ts +83 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/channels/base.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/graph/zod/index.d.cts +3 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/graph/zod/index.d.ts +3 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/graph/zod/meta.d.cts +108 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/graph/zod/meta.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/graph/zod/meta.d.ts +108 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/graph/zod/meta.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/graph/zod/plugin.d.cts +31 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/graph/zod/plugin.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/graph/zod/plugin.d.ts +31 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/graph/zod/plugin.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/graph/zod/zod-registry.d.cts +49 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/graph/zod/zod-registry.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/graph/zod/zod-registry.d.ts +49 -0
- package/dist/node_modules/.pnpm/@langchain_langgraph@1.1.5_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___z_0d5e45651b6fb9f696195862204d53c7/node_modules/@langchain/langgraph/dist/graph/zod/zod-registry.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/ReactAgent.d.cts +3 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/ReactAgent.d.ts +3 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/index.d.cts +4 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/index.d.ts +4 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/contextEditing.d.cts +3 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/contextEditing.d.ts +3 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/dynamicSystemPrompt.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/dynamicSystemPrompt.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/hitl.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/hitl.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/llmToolSelector.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/llmToolSelector.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/modelCallLimit.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/modelCallLimit.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/modelFallback.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/modelFallback.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/modelRetry.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/modelRetry.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/pii.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/pii.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/piiRedaction.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/piiRedaction.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/provider/anthropic/promptCaching.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/provider/anthropic/promptCaching.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/provider/openai/moderation.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/provider/openai/moderation.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/summarization.d.cts +2 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/summarization.d.ts +2 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/todoListMiddleware.d.cts +2 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/todoListMiddleware.d.ts +2 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/toolCallLimit.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/toolCallLimit.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/toolEmulator.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/toolEmulator.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/toolRetry.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/toolRetry.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/types.d.cts +3 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware/types.d.ts +3 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware.d.cts +2 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/middleware.d.ts +2 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/types.d.cts +3 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/agents/types.d.ts +3 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/index.d.cts +23 -0
- package/dist/node_modules/.pnpm/langchain@1.2.27_@langchain_core@1.1.28_openai@6.16.0_ws@8.19.0_zod@4.3.5___openai@6.16_37b31122102851880bcc0afaeba68edd/node_modules/langchain/dist/index.d.ts +23 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/ZodError.d.cts +155 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/ZodError.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/ZodError.d.ts +155 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/ZodError.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/errorUtil.d.cts +13 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/errorUtil.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/errorUtil.d.ts +13 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/errorUtil.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/parseUtil.d.cts +63 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/parseUtil.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/parseUtil.d.ts +63 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/parseUtil.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/typeAliases.d.cts +5 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/typeAliases.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/typeAliases.d.ts +5 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/typeAliases.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/util.d.cts +64 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/util.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/util.d.ts +64 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/helpers/util.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/standard-schema.d.cts +106 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/standard-schema.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/standard-schema.d.ts +106 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/standard-schema.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/types.d.cts +291 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/types.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/types.d.ts +291 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v3/types.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/checks.d.cts +29 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/checks.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/checks.d.ts +29 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/checks.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/core.d.cts +29 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/core.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/core.d.ts +29 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/core.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/errors.d.cts +105 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/errors.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/errors.d.ts +105 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/errors.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/json-schema.d.cts +70 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/json-schema.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/json-schema.d.ts +70 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/json-schema.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/registries.d.cts +24 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/registries.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/registries.d.ts +24 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/registries.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/schemas.d.cts +97 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/schemas.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/schemas.d.ts +97 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/schemas.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/standard-schema.d.cts +79 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/standard-schema.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/standard-schema.d.ts +79 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/standard-schema.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/to-json-schema.d.cts +52 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/to-json-schema.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/to-json-schema.d.ts +52 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/to-json-schema.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/util.d.cts +17 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/util.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/util.d.ts +17 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/util.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/versions.d.cts +9 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/versions.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/versions.d.ts +9 -0
- package/dist/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/versions.d.ts.map +1 -0
- package/dist/react-ui/client.cjs +138 -0
- package/dist/react-ui/client.cjs.map +1 -0
- package/dist/react-ui/client.d.cts +80 -0
- package/dist/react-ui/client.d.cts.map +1 -0
- package/dist/react-ui/client.d.ts +80 -0
- package/dist/react-ui/client.d.ts.map +1 -0
- package/dist/react-ui/client.js +132 -0
- package/dist/react-ui/client.js.map +1 -0
- package/dist/react-ui/index.cjs +15 -0
- package/dist/react-ui/index.cjs.map +1 -0
- package/dist/react-ui/index.d.cts +3 -0
- package/dist/react-ui/index.d.ts +3 -0
- package/dist/react-ui/index.js +9 -0
- package/dist/react-ui/index.js.map +1 -0
- package/dist/react-ui/server/index.cjs +6 -0
- package/dist/react-ui/server/index.d.cts +3 -0
- package/dist/react-ui/server/index.d.ts +3 -0
- package/dist/react-ui/server/index.js +4 -0
- package/dist/react-ui/server/server.cjs +57 -0
- package/dist/react-ui/server/server.cjs.map +1 -0
- package/dist/react-ui/server/server.d.cts +54 -0
- package/dist/react-ui/server/server.d.cts.map +1 -0
- package/dist/react-ui/server/server.d.ts +54 -0
- package/dist/react-ui/server/server.d.ts.map +1 -0
- package/dist/react-ui/server/server.js +56 -0
- package/dist/react-ui/server/server.js.map +1 -0
- package/dist/react-ui/types.cjs +38 -0
- package/dist/react-ui/types.cjs.map +1 -0
- package/dist/react-ui/types.d.cts +25 -0
- package/dist/react-ui/types.d.cts.map +1 -0
- package/dist/react-ui/types.d.ts +25 -0
- package/dist/react-ui/types.d.ts.map +1 -0
- package/dist/react-ui/types.js +35 -0
- package/dist/react-ui/types.js.map +1 -0
- package/dist/stream.cjs +18 -0
- package/dist/stream.cjs.map +1 -0
- package/dist/stream.custom.cjs +162 -0
- package/dist/stream.custom.cjs.map +1 -0
- package/dist/stream.custom.d.cts +3 -0
- package/dist/stream.custom.d.ts +4 -0
- package/dist/stream.custom.js +161 -0
- package/dist/stream.custom.js.map +1 -0
- package/dist/stream.d.cts +193 -0
- package/dist/stream.d.cts.map +1 -0
- package/dist/stream.d.ts +193 -0
- package/dist/stream.d.ts.map +1 -0
- package/dist/stream.js +17 -0
- package/dist/stream.js.map +1 -0
- package/dist/stream.lgp.cjs +623 -0
- package/dist/stream.lgp.cjs.map +1 -0
- package/dist/stream.lgp.js +622 -0
- package/dist/stream.lgp.js.map +1 -0
- package/dist/thread.cjs +21 -0
- package/dist/thread.cjs.map +1 -0
- package/dist/thread.js +20 -0
- package/dist/thread.js.map +1 -0
- package/dist/types.d.cts +93 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +93 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +106 -0
|
@@ -0,0 +1,623 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
4
|
+
const require_thread = require('./thread.cjs');
|
|
5
|
+
let react = require("react");
|
|
6
|
+
let _langchain_langgraph_sdk_client = require("@langchain/langgraph-sdk/client");
|
|
7
|
+
let _langchain_langgraph_sdk_ui = require("@langchain/langgraph-sdk/ui");
|
|
8
|
+
let _langchain_langgraph_sdk_utils = require("@langchain/langgraph-sdk/utils");
|
|
9
|
+
|
|
10
|
+
//#region src/stream.lgp.tsx
|
|
11
|
+
function getFetchHistoryKey(client, threadId, limit) {
|
|
12
|
+
return [
|
|
13
|
+
(0, _langchain_langgraph_sdk_client.getClientConfigHash)(client),
|
|
14
|
+
threadId,
|
|
15
|
+
limit
|
|
16
|
+
].join(":");
|
|
17
|
+
}
|
|
18
|
+
function fetchHistory(client, threadId, options) {
|
|
19
|
+
if (options?.limit === false) return client.threads.getState(threadId).then((state) => {
|
|
20
|
+
if (state.checkpoint == null) return [];
|
|
21
|
+
return [state];
|
|
22
|
+
});
|
|
23
|
+
const limit = typeof options?.limit === "number" ? options.limit : 10;
|
|
24
|
+
return client.threads.getHistory(threadId, { limit });
|
|
25
|
+
}
|
|
26
|
+
function useThreadHistory(client, threadId, limit, options) {
|
|
27
|
+
const key = getFetchHistoryKey(client, threadId, limit);
|
|
28
|
+
const [state, setState] = (0, react.useState)(() => ({
|
|
29
|
+
key: void 0,
|
|
30
|
+
data: void 0,
|
|
31
|
+
error: void 0,
|
|
32
|
+
isLoading: threadId != null
|
|
33
|
+
}));
|
|
34
|
+
const clientRef = (0, react.useRef)(client);
|
|
35
|
+
clientRef.current = client;
|
|
36
|
+
const onErrorRef = (0, react.useRef)(options?.onError);
|
|
37
|
+
onErrorRef.current = options?.onError;
|
|
38
|
+
const fetcher = (0, react.useCallback)((threadId, limit) => {
|
|
39
|
+
if (options.passthrough) return Promise.resolve([]);
|
|
40
|
+
const client = clientRef.current;
|
|
41
|
+
const key = getFetchHistoryKey(client, threadId, limit);
|
|
42
|
+
if (threadId != null) {
|
|
43
|
+
setState((state) => {
|
|
44
|
+
if (state.key === key) return {
|
|
45
|
+
...state,
|
|
46
|
+
isLoading: true
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
key,
|
|
50
|
+
data: void 0,
|
|
51
|
+
error: void 0,
|
|
52
|
+
isLoading: true
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
return fetchHistory(client, threadId, { limit }).then((data) => {
|
|
56
|
+
setState((state) => {
|
|
57
|
+
if (state.key !== key) return state;
|
|
58
|
+
return {
|
|
59
|
+
key,
|
|
60
|
+
data,
|
|
61
|
+
error: void 0,
|
|
62
|
+
isLoading: false
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
return data;
|
|
66
|
+
}, (error) => {
|
|
67
|
+
setState((state) => {
|
|
68
|
+
if (state.key !== key) return state;
|
|
69
|
+
return {
|
|
70
|
+
key,
|
|
71
|
+
data: state.data,
|
|
72
|
+
error,
|
|
73
|
+
isLoading: false
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
onErrorRef.current?.(error);
|
|
77
|
+
return Promise.reject(error);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
setState({
|
|
81
|
+
key,
|
|
82
|
+
data: void 0,
|
|
83
|
+
error: void 0,
|
|
84
|
+
isLoading: false
|
|
85
|
+
});
|
|
86
|
+
return Promise.resolve([]);
|
|
87
|
+
}, [options.passthrough]);
|
|
88
|
+
(0, react.useEffect)(() => {
|
|
89
|
+
if (options.submittingRef.current != null && options.submittingRef.current === threadId) return;
|
|
90
|
+
fetcher(threadId, limit);
|
|
91
|
+
}, [fetcher, key]);
|
|
92
|
+
return {
|
|
93
|
+
data: state.data,
|
|
94
|
+
error: state.error,
|
|
95
|
+
isLoading: state.isLoading,
|
|
96
|
+
mutate: (mutateId) => fetcher(mutateId ?? threadId, limit)
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function useTrackStreamMode() {
|
|
100
|
+
const trackStreamModeRef = (0, react.useRef)([]);
|
|
101
|
+
return [trackStreamModeRef, (0, react.useCallback)((...mode) => {
|
|
102
|
+
const ref = trackStreamModeRef.current;
|
|
103
|
+
for (const m of mode) if (!ref.includes(m)) ref.push(m);
|
|
104
|
+
}, [])];
|
|
105
|
+
}
|
|
106
|
+
function useCallbackStreamMode(options) {
|
|
107
|
+
const hasUpdateListener = options.onUpdateEvent != null;
|
|
108
|
+
const hasCustomListener = options.onCustomEvent != null;
|
|
109
|
+
const hasLangChainListener = options.onLangChainEvent != null;
|
|
110
|
+
const hasDebugListener = options.onDebugEvent != null;
|
|
111
|
+
const hasCheckpointListener = options.onCheckpointEvent != null;
|
|
112
|
+
const hasTaskListener = options.onTaskEvent != null;
|
|
113
|
+
return (0, react.useMemo)(() => {
|
|
114
|
+
const modes = [];
|
|
115
|
+
if (hasUpdateListener) modes.push("updates");
|
|
116
|
+
if (hasCustomListener) modes.push("custom");
|
|
117
|
+
if (hasLangChainListener) modes.push("events");
|
|
118
|
+
if (hasDebugListener) modes.push("debug");
|
|
119
|
+
if (hasCheckpointListener) modes.push("checkpoints");
|
|
120
|
+
if (hasTaskListener) modes.push("tasks");
|
|
121
|
+
return modes;
|
|
122
|
+
}, [
|
|
123
|
+
hasUpdateListener,
|
|
124
|
+
hasCustomListener,
|
|
125
|
+
hasLangChainListener,
|
|
126
|
+
hasDebugListener,
|
|
127
|
+
hasCheckpointListener,
|
|
128
|
+
hasTaskListener
|
|
129
|
+
]);
|
|
130
|
+
}
|
|
131
|
+
function useStreamLGP(options) {
|
|
132
|
+
const reconnectOnMountRef = (0, react.useRef)(options.reconnectOnMount);
|
|
133
|
+
const runMetadataStorage = (0, react.useMemo)(() => {
|
|
134
|
+
if (typeof window === "undefined") return null;
|
|
135
|
+
const storage = reconnectOnMountRef.current;
|
|
136
|
+
if (storage === true) return window.sessionStorage;
|
|
137
|
+
if (typeof storage === "function") return storage();
|
|
138
|
+
return null;
|
|
139
|
+
}, []);
|
|
140
|
+
const client = (0, react.useMemo)(() => options.client ?? new _langchain_langgraph_sdk_client.Client({
|
|
141
|
+
apiUrl: options.apiUrl,
|
|
142
|
+
apiKey: options.apiKey,
|
|
143
|
+
callerOptions: options.callerOptions,
|
|
144
|
+
defaultHeaders: options.defaultHeaders
|
|
145
|
+
}), [
|
|
146
|
+
options.client,
|
|
147
|
+
options.apiKey,
|
|
148
|
+
options.apiUrl,
|
|
149
|
+
options.callerOptions,
|
|
150
|
+
options.defaultHeaders
|
|
151
|
+
]);
|
|
152
|
+
const [messageManager] = (0, react.useState)(() => new _langchain_langgraph_sdk_ui.MessageTupleManager());
|
|
153
|
+
const [stream] = (0, react.useState)(() => new _langchain_langgraph_sdk_ui.StreamManager(messageManager, {
|
|
154
|
+
throttle: options.throttle ?? false,
|
|
155
|
+
subagentToolNames: options.subagentToolNames,
|
|
156
|
+
filterSubagentMessages: options.filterSubagentMessages,
|
|
157
|
+
toMessage: options.toMessage ?? _langchain_langgraph_sdk_ui.toMessageClass
|
|
158
|
+
}));
|
|
159
|
+
const [pendingRuns] = (0, react.useState)(() => new _langchain_langgraph_sdk_ui.PendingRunsTracker());
|
|
160
|
+
(0, react.useSyncExternalStore)(pendingRuns.subscribe, pendingRuns.getSnapshot, pendingRuns.getSnapshot);
|
|
161
|
+
const [trackStreamModeRef, trackStreamMode] = useTrackStreamMode();
|
|
162
|
+
const callbackStreamMode = useCallbackStreamMode(options);
|
|
163
|
+
const getMessages = (value) => {
|
|
164
|
+
const messagesKey = options.messagesKey ?? "messages";
|
|
165
|
+
return Array.isArray(value[messagesKey]) ? value[messagesKey] : [];
|
|
166
|
+
};
|
|
167
|
+
const setMessages = (current, messages) => {
|
|
168
|
+
const messagesKey = options.messagesKey ?? "messages";
|
|
169
|
+
return {
|
|
170
|
+
...current,
|
|
171
|
+
[messagesKey]: messages
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
(0, react.useSyncExternalStore)(stream.subscribe, stream.getSnapshot, stream.getSnapshot);
|
|
175
|
+
const [threadId, onThreadId] = require_thread.useControllableThreadId(options);
|
|
176
|
+
const threadIdRef = (0, react.useRef)(threadId);
|
|
177
|
+
const threadIdStreamingRef = (0, react.useRef)(null);
|
|
178
|
+
(0, react.useEffect)(() => {
|
|
179
|
+
if (threadIdRef.current !== threadId) {
|
|
180
|
+
threadIdRef.current = threadId;
|
|
181
|
+
stream.clear();
|
|
182
|
+
}
|
|
183
|
+
}, [threadId, stream]);
|
|
184
|
+
const switchThread = (0, react.useCallback)((newThreadId) => {
|
|
185
|
+
if (newThreadId !== threadIdRef.current) {
|
|
186
|
+
const prevThreadId = threadIdRef.current;
|
|
187
|
+
threadIdRef.current = newThreadId;
|
|
188
|
+
stream.clear();
|
|
189
|
+
const removed = pendingRuns.removeAll();
|
|
190
|
+
if (prevThreadId && removed.length > 0) Promise.all(removed.map((e) => client.runs.cancel(prevThreadId, e.id)));
|
|
191
|
+
onThreadId(newThreadId);
|
|
192
|
+
}
|
|
193
|
+
}, [
|
|
194
|
+
stream,
|
|
195
|
+
pendingRuns,
|
|
196
|
+
onThreadId,
|
|
197
|
+
client
|
|
198
|
+
]);
|
|
199
|
+
const historyLimit = typeof options.fetchStateHistory === "object" && options.fetchStateHistory != null ? options.fetchStateHistory.limit ?? false : options.fetchStateHistory ?? false;
|
|
200
|
+
const builtInHistory = useThreadHistory(client, threadId, historyLimit, {
|
|
201
|
+
passthrough: options.thread != null,
|
|
202
|
+
submittingRef: threadIdStreamingRef,
|
|
203
|
+
onError: options.onError
|
|
204
|
+
});
|
|
205
|
+
const history = options.thread ?? builtInHistory;
|
|
206
|
+
const [branch, setBranch] = (0, react.useState)("");
|
|
207
|
+
const branchContext = (0, _langchain_langgraph_sdk_ui.getBranchContext)(branch, history.data ?? void 0);
|
|
208
|
+
const [toolProgressMap, setToolProgressMap] = (0, react.useState)(/* @__PURE__ */ new Map());
|
|
209
|
+
const handleToolEvent = (0, react.useCallback)((data) => {
|
|
210
|
+
setToolProgressMap((prev) => {
|
|
211
|
+
const next = new Map(prev);
|
|
212
|
+
const key = data.toolCallId ?? data.name;
|
|
213
|
+
const existing = next.get(key);
|
|
214
|
+
switch (data.event) {
|
|
215
|
+
case "on_tool_start":
|
|
216
|
+
next.set(key, {
|
|
217
|
+
toolCallId: data.toolCallId,
|
|
218
|
+
name: data.name,
|
|
219
|
+
state: "starting",
|
|
220
|
+
input: data.input
|
|
221
|
+
});
|
|
222
|
+
break;
|
|
223
|
+
case "on_tool_event":
|
|
224
|
+
if (existing) next.set(key, {
|
|
225
|
+
...existing,
|
|
226
|
+
state: "running",
|
|
227
|
+
data: data.data
|
|
228
|
+
});
|
|
229
|
+
break;
|
|
230
|
+
case "on_tool_end":
|
|
231
|
+
if (existing) next.set(key, {
|
|
232
|
+
...existing,
|
|
233
|
+
state: "completed",
|
|
234
|
+
result: data.output
|
|
235
|
+
});
|
|
236
|
+
break;
|
|
237
|
+
case "on_tool_error":
|
|
238
|
+
if (existing) next.set(key, {
|
|
239
|
+
...existing,
|
|
240
|
+
state: "error",
|
|
241
|
+
error: data.error
|
|
242
|
+
});
|
|
243
|
+
break;
|
|
244
|
+
default: throw new Error(`Unexpected tool event: ${data.event}`);
|
|
245
|
+
}
|
|
246
|
+
return next;
|
|
247
|
+
});
|
|
248
|
+
}, []);
|
|
249
|
+
const historyValues = branchContext.threadHead?.values ?? options.initialValues ?? {};
|
|
250
|
+
const historyMessages = getMessages(historyValues);
|
|
251
|
+
const shouldReconstructSubagents = options.filterSubagentMessages && !stream.isLoading && !history.isLoading && historyMessages.length > 0;
|
|
252
|
+
(0, react.useEffect)(() => {
|
|
253
|
+
if (shouldReconstructSubagents) stream.reconstructSubagents(historyMessages, { skipIfPopulated: true });
|
|
254
|
+
}, [shouldReconstructSubagents, historyMessages.length]);
|
|
255
|
+
const historyError = (() => {
|
|
256
|
+
const error = branchContext.threadHead?.tasks?.at(-1)?.error;
|
|
257
|
+
if (error == null) return void 0;
|
|
258
|
+
try {
|
|
259
|
+
const parsed = JSON.parse(error);
|
|
260
|
+
if (_langchain_langgraph_sdk_ui.StreamError.isStructuredError(parsed)) return new _langchain_langgraph_sdk_ui.StreamError(parsed);
|
|
261
|
+
return parsed;
|
|
262
|
+
} catch {}
|
|
263
|
+
return error;
|
|
264
|
+
})();
|
|
265
|
+
const messageMetadata = (0, _langchain_langgraph_sdk_ui.getMessagesMetadataMap)({
|
|
266
|
+
initialValues: options.initialValues,
|
|
267
|
+
history: history.data,
|
|
268
|
+
getMessages,
|
|
269
|
+
branchContext
|
|
270
|
+
});
|
|
271
|
+
const stop = () => stream.stop(historyValues, { onStop: (args) => {
|
|
272
|
+
if (runMetadataStorage && threadId) {
|
|
273
|
+
const runId = runMetadataStorage.getItem(`lg:stream:${threadId}`);
|
|
274
|
+
if (runId) client.runs.cancel(threadId, runId);
|
|
275
|
+
runMetadataStorage.removeItem(`lg:stream:${threadId}`);
|
|
276
|
+
}
|
|
277
|
+
options.onStop?.(args);
|
|
278
|
+
} });
|
|
279
|
+
const submitDirect = async (values, submitOptions) => {
|
|
280
|
+
setToolProgressMap(/* @__PURE__ */ new Map());
|
|
281
|
+
const checkpointId = submitOptions?.checkpoint?.checkpoint_id;
|
|
282
|
+
setBranch(checkpointId != null ? branchContext.branchByCheckpoint[checkpointId]?.branch ?? "" : "");
|
|
283
|
+
const includeImplicitBranch = historyLimit === true || typeof historyLimit === "number";
|
|
284
|
+
const shouldRefetch = options.onFinish != null || includeImplicitBranch;
|
|
285
|
+
let callbackMeta;
|
|
286
|
+
let rejoinKey;
|
|
287
|
+
let usableThreadId = threadId;
|
|
288
|
+
const shouldAbortPrevious = (submitOptions?.multitaskStrategy === "interrupt" || submitOptions?.multitaskStrategy === "rollback") && stream.isLoading;
|
|
289
|
+
await stream.start(async (signal) => {
|
|
290
|
+
stream.setStreamValues((values) => {
|
|
291
|
+
const prev = {
|
|
292
|
+
...historyValues,
|
|
293
|
+
...values
|
|
294
|
+
};
|
|
295
|
+
if (submitOptions?.optimisticValues != null) return {
|
|
296
|
+
...prev,
|
|
297
|
+
...typeof submitOptions.optimisticValues === "function" ? submitOptions.optimisticValues(prev) : submitOptions.optimisticValues
|
|
298
|
+
};
|
|
299
|
+
return { ...prev };
|
|
300
|
+
});
|
|
301
|
+
if (!usableThreadId) {
|
|
302
|
+
usableThreadId = (await client.threads.create({
|
|
303
|
+
threadId: submitOptions?.threadId,
|
|
304
|
+
metadata: submitOptions?.metadata,
|
|
305
|
+
signal
|
|
306
|
+
})).thread_id;
|
|
307
|
+
threadIdRef.current = usableThreadId;
|
|
308
|
+
threadIdStreamingRef.current = usableThreadId;
|
|
309
|
+
onThreadId(usableThreadId);
|
|
310
|
+
}
|
|
311
|
+
if (!usableThreadId) throw new Error("Failed to obtain valid thread ID.");
|
|
312
|
+
threadIdStreamingRef.current = usableThreadId;
|
|
313
|
+
const streamMode = (0, _langchain_langgraph_sdk_ui.unique)([
|
|
314
|
+
...submitOptions?.streamMode ?? [],
|
|
315
|
+
...trackStreamModeRef.current,
|
|
316
|
+
...callbackStreamMode
|
|
317
|
+
]);
|
|
318
|
+
let checkpoint = submitOptions?.checkpoint ?? (includeImplicitBranch ? branchContext.threadHead?.checkpoint : void 0) ?? void 0;
|
|
319
|
+
if (submitOptions?.checkpoint === null) checkpoint = void 0;
|
|
320
|
+
if (checkpoint != null) delete checkpoint.thread_id;
|
|
321
|
+
const streamResumable = submitOptions?.streamResumable ?? !!runMetadataStorage;
|
|
322
|
+
return client.runs.stream(usableThreadId, options.assistantId, {
|
|
323
|
+
input: values,
|
|
324
|
+
config: submitOptions?.config,
|
|
325
|
+
context: submitOptions?.context,
|
|
326
|
+
command: submitOptions?.command,
|
|
327
|
+
interruptBefore: submitOptions?.interruptBefore,
|
|
328
|
+
interruptAfter: submitOptions?.interruptAfter,
|
|
329
|
+
metadata: submitOptions?.metadata,
|
|
330
|
+
multitaskStrategy: submitOptions?.multitaskStrategy,
|
|
331
|
+
onCompletion: submitOptions?.onCompletion,
|
|
332
|
+
onDisconnect: submitOptions?.onDisconnect ?? (streamResumable ? "continue" : "cancel"),
|
|
333
|
+
signal,
|
|
334
|
+
checkpoint,
|
|
335
|
+
streamMode,
|
|
336
|
+
streamSubgraphs: submitOptions?.streamSubgraphs,
|
|
337
|
+
streamResumable,
|
|
338
|
+
durability: submitOptions?.durability,
|
|
339
|
+
onRunCreated(params) {
|
|
340
|
+
callbackMeta = {
|
|
341
|
+
run_id: params.run_id,
|
|
342
|
+
thread_id: params.thread_id ?? usableThreadId
|
|
343
|
+
};
|
|
344
|
+
if (runMetadataStorage) {
|
|
345
|
+
rejoinKey = `lg:stream:${usableThreadId}`;
|
|
346
|
+
runMetadataStorage.setItem(rejoinKey, callbackMeta.run_id);
|
|
347
|
+
}
|
|
348
|
+
options.onCreated?.(callbackMeta);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
}, {
|
|
352
|
+
getMessages,
|
|
353
|
+
setMessages,
|
|
354
|
+
initialValues: historyValues,
|
|
355
|
+
callbacks: {
|
|
356
|
+
...options,
|
|
357
|
+
onToolEvent: (data, opts) => {
|
|
358
|
+
handleToolEvent(data);
|
|
359
|
+
options.onToolEvent?.(data, opts);
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
async onSuccess() {
|
|
363
|
+
if (rejoinKey) runMetadataStorage?.removeItem(rejoinKey);
|
|
364
|
+
if (shouldRefetch) {
|
|
365
|
+
const lastHead = (await history.mutate(usableThreadId))?.at(0);
|
|
366
|
+
if (lastHead) {
|
|
367
|
+
options.onFinish?.(lastHead, callbackMeta);
|
|
368
|
+
return null;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
onError(error) {
|
|
373
|
+
options.onError?.(error, callbackMeta);
|
|
374
|
+
},
|
|
375
|
+
onFinish() {
|
|
376
|
+
threadIdStreamingRef.current = null;
|
|
377
|
+
}
|
|
378
|
+
}, { abortPrevious: shouldAbortPrevious });
|
|
379
|
+
};
|
|
380
|
+
const submitDirectRef = (0, react.useRef)(submitDirect);
|
|
381
|
+
submitDirectRef.current = submitDirect;
|
|
382
|
+
const submittingRef = (0, react.useRef)(false);
|
|
383
|
+
const submit = async (values, submitOptions) => {
|
|
384
|
+
if (stream.isLoading || submittingRef.current) {
|
|
385
|
+
if (submitOptions?.multitaskStrategy === "interrupt" || submitOptions?.multitaskStrategy === "rollback") {
|
|
386
|
+
submittingRef.current = true;
|
|
387
|
+
try {
|
|
388
|
+
await submitDirect(values, submitOptions);
|
|
389
|
+
} finally {
|
|
390
|
+
submittingRef.current = false;
|
|
391
|
+
}
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
const usableThreadId = threadIdRef.current ?? threadId;
|
|
395
|
+
if (usableThreadId) {
|
|
396
|
+
const run = await client.runs.create(usableThreadId, options.assistantId, {
|
|
397
|
+
input: values,
|
|
398
|
+
config: submitOptions?.config,
|
|
399
|
+
context: submitOptions?.context,
|
|
400
|
+
command: submitOptions?.command,
|
|
401
|
+
interruptBefore: submitOptions?.interruptBefore,
|
|
402
|
+
interruptAfter: submitOptions?.interruptAfter,
|
|
403
|
+
metadata: submitOptions?.metadata,
|
|
404
|
+
multitaskStrategy: "enqueue",
|
|
405
|
+
streamResumable: true,
|
|
406
|
+
streamSubgraphs: submitOptions?.streamSubgraphs,
|
|
407
|
+
durability: submitOptions?.durability
|
|
408
|
+
});
|
|
409
|
+
pendingRuns.add({
|
|
410
|
+
id: run.run_id,
|
|
411
|
+
values,
|
|
412
|
+
options: submitOptions,
|
|
413
|
+
createdAt: new Date(run.created_at)
|
|
414
|
+
});
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
submittingRef.current = true;
|
|
419
|
+
try {
|
|
420
|
+
await submitDirect(values, submitOptions);
|
|
421
|
+
} finally {
|
|
422
|
+
submittingRef.current = false;
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
const joinStream = async (runId, lastEventId, joinOptions) => {
|
|
426
|
+
setToolProgressMap(/* @__PURE__ */ new Map());
|
|
427
|
+
lastEventId ??= "-1";
|
|
428
|
+
if (!threadId) return;
|
|
429
|
+
const callbackMeta = {
|
|
430
|
+
thread_id: threadId,
|
|
431
|
+
run_id: runId
|
|
432
|
+
};
|
|
433
|
+
await stream.start(async (signal) => {
|
|
434
|
+
threadIdStreamingRef.current = threadId;
|
|
435
|
+
const stream = client.runs.joinStream(threadId, runId, {
|
|
436
|
+
signal,
|
|
437
|
+
lastEventId,
|
|
438
|
+
streamMode: joinOptions?.streamMode
|
|
439
|
+
});
|
|
440
|
+
return joinOptions?.filter != null ? (0, _langchain_langgraph_sdk_ui.filterStream)(stream, joinOptions.filter) : stream;
|
|
441
|
+
}, {
|
|
442
|
+
getMessages,
|
|
443
|
+
setMessages,
|
|
444
|
+
initialValues: historyValues,
|
|
445
|
+
callbacks: {
|
|
446
|
+
...options,
|
|
447
|
+
onToolEvent: (data, opts) => {
|
|
448
|
+
handleToolEvent(data);
|
|
449
|
+
options.onToolEvent?.(data, opts);
|
|
450
|
+
}
|
|
451
|
+
},
|
|
452
|
+
async onSuccess() {
|
|
453
|
+
runMetadataStorage?.removeItem(`lg:stream:${threadId}`);
|
|
454
|
+
const lastHead = (await history.mutate(threadId))?.at(0);
|
|
455
|
+
if (lastHead) options.onFinish?.(lastHead, callbackMeta);
|
|
456
|
+
},
|
|
457
|
+
onError(error) {
|
|
458
|
+
options.onError?.(error, callbackMeta);
|
|
459
|
+
},
|
|
460
|
+
onFinish() {
|
|
461
|
+
threadIdStreamingRef.current = null;
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
};
|
|
465
|
+
const joinStreamRef = (0, react.useRef)(joinStream);
|
|
466
|
+
joinStreamRef.current = joinStream;
|
|
467
|
+
(0, react.useEffect)(() => {
|
|
468
|
+
if (!stream.isLoading && !submittingRef.current && pendingRuns.size > 0) {
|
|
469
|
+
const next = pendingRuns.shift();
|
|
470
|
+
if (next) {
|
|
471
|
+
submittingRef.current = true;
|
|
472
|
+
joinStreamRef.current(next.id).finally(() => {
|
|
473
|
+
submittingRef.current = false;
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}, [stream.isLoading, pendingRuns.size]);
|
|
478
|
+
const reconnectKey = (0, react.useMemo)(() => {
|
|
479
|
+
if (!runMetadataStorage || stream.isLoading) return void 0;
|
|
480
|
+
if (typeof window === "undefined") return void 0;
|
|
481
|
+
const runId = runMetadataStorage?.getItem(`lg:stream:${threadId}`);
|
|
482
|
+
if (!runId) return void 0;
|
|
483
|
+
return {
|
|
484
|
+
runId,
|
|
485
|
+
threadId
|
|
486
|
+
};
|
|
487
|
+
}, [
|
|
488
|
+
runMetadataStorage,
|
|
489
|
+
stream.isLoading,
|
|
490
|
+
threadId
|
|
491
|
+
]);
|
|
492
|
+
const shouldReconnect = !!runMetadataStorage;
|
|
493
|
+
const reconnectRef = (0, react.useRef)({
|
|
494
|
+
threadId,
|
|
495
|
+
shouldReconnect
|
|
496
|
+
});
|
|
497
|
+
(0, react.useEffect)(() => {
|
|
498
|
+
if (reconnectRef.current.threadId !== threadId) reconnectRef.current = {
|
|
499
|
+
threadId,
|
|
500
|
+
shouldReconnect
|
|
501
|
+
};
|
|
502
|
+
}, [threadId, shouldReconnect]);
|
|
503
|
+
(0, react.useEffect)(() => {
|
|
504
|
+
if (reconnectKey && reconnectRef.current.shouldReconnect) {
|
|
505
|
+
reconnectRef.current.shouldReconnect = false;
|
|
506
|
+
joinStreamRef.current?.(reconnectKey.runId);
|
|
507
|
+
}
|
|
508
|
+
}, [reconnectKey]);
|
|
509
|
+
const error = stream.error ?? historyError ?? history.error;
|
|
510
|
+
const values = stream.values ?? historyValues;
|
|
511
|
+
return {
|
|
512
|
+
get values() {
|
|
513
|
+
trackStreamMode("values");
|
|
514
|
+
return values;
|
|
515
|
+
},
|
|
516
|
+
client,
|
|
517
|
+
assistantId: options.assistantId,
|
|
518
|
+
error,
|
|
519
|
+
isLoading: stream.isLoading,
|
|
520
|
+
stop,
|
|
521
|
+
submit,
|
|
522
|
+
switchThread,
|
|
523
|
+
joinStream,
|
|
524
|
+
branch,
|
|
525
|
+
setBranch,
|
|
526
|
+
get history() {
|
|
527
|
+
if (historyLimit === false) throw new Error("`fetchStateHistory` must be set to `true` to use `history`");
|
|
528
|
+
return branchContext.flatHistory;
|
|
529
|
+
},
|
|
530
|
+
isThreadLoading: history.isLoading && history.data == null,
|
|
531
|
+
get experimental_branchTree() {
|
|
532
|
+
if (historyLimit === false) throw new Error("`fetchStateHistory` must be set to `true` to use `experimental_branchTree`");
|
|
533
|
+
return branchContext.branchTree;
|
|
534
|
+
},
|
|
535
|
+
get interrupts() {
|
|
536
|
+
if (values != null && "__interrupt__" in values && Array.isArray(values.__interrupt__)) {
|
|
537
|
+
const valueInterrupts = values.__interrupt__;
|
|
538
|
+
if (valueInterrupts.length === 0) return [{ when: "breakpoint" }];
|
|
539
|
+
return valueInterrupts;
|
|
540
|
+
}
|
|
541
|
+
if (stream.isLoading) return [];
|
|
542
|
+
const allInterrupts = (branchContext.threadHead?.tasks ?? []).flatMap((t) => t.interrupts ?? []);
|
|
543
|
+
if (allInterrupts.length > 0) return allInterrupts;
|
|
544
|
+
if (!(branchContext.threadHead?.next ?? []).length || error != null) return [];
|
|
545
|
+
return [{ when: "breakpoint" }];
|
|
546
|
+
},
|
|
547
|
+
get interrupt() {
|
|
548
|
+
return (0, _langchain_langgraph_sdk_ui.extractInterrupts)(values, {
|
|
549
|
+
error,
|
|
550
|
+
isLoading: stream.isLoading,
|
|
551
|
+
threadState: branchContext.threadHead
|
|
552
|
+
});
|
|
553
|
+
},
|
|
554
|
+
get messages() {
|
|
555
|
+
trackStreamMode("messages-tuple", "values");
|
|
556
|
+
return getMessages(values);
|
|
557
|
+
},
|
|
558
|
+
get toolCalls() {
|
|
559
|
+
trackStreamMode("messages-tuple", "values");
|
|
560
|
+
return (0, _langchain_langgraph_sdk_utils.getToolCallsWithResults)(getMessages(values));
|
|
561
|
+
},
|
|
562
|
+
get toolProgress() {
|
|
563
|
+
trackStreamMode("tools");
|
|
564
|
+
return Array.from(toolProgressMap.values());
|
|
565
|
+
},
|
|
566
|
+
getToolCalls(message) {
|
|
567
|
+
trackStreamMode("messages-tuple", "values");
|
|
568
|
+
return (0, _langchain_langgraph_sdk_utils.getToolCallsWithResults)(getMessages(values)).filter((tc) => tc.aiMessage.id === message.id);
|
|
569
|
+
},
|
|
570
|
+
getMessagesMetadata(message, index) {
|
|
571
|
+
trackStreamMode("values");
|
|
572
|
+
const streamMetadata = messageManager.get(message.id)?.metadata;
|
|
573
|
+
const historyMetadata = messageMetadata?.find((m) => m.messageId === (message.id ?? index));
|
|
574
|
+
if (streamMetadata != null || historyMetadata != null) return {
|
|
575
|
+
...historyMetadata,
|
|
576
|
+
streamMetadata
|
|
577
|
+
};
|
|
578
|
+
},
|
|
579
|
+
get subagents() {
|
|
580
|
+
trackStreamMode("updates", "messages-tuple");
|
|
581
|
+
return stream.getSubagents();
|
|
582
|
+
},
|
|
583
|
+
get activeSubagents() {
|
|
584
|
+
trackStreamMode("updates", "messages-tuple");
|
|
585
|
+
return stream.getActiveSubagents();
|
|
586
|
+
},
|
|
587
|
+
getSubagent(toolCallId) {
|
|
588
|
+
trackStreamMode("updates", "messages-tuple");
|
|
589
|
+
return stream.getSubagent(toolCallId);
|
|
590
|
+
},
|
|
591
|
+
getSubagentsByType(type) {
|
|
592
|
+
trackStreamMode("updates", "messages-tuple");
|
|
593
|
+
return stream.getSubagentsByType(type);
|
|
594
|
+
},
|
|
595
|
+
getSubagentsByMessage(messageId) {
|
|
596
|
+
trackStreamMode("updates", "messages-tuple");
|
|
597
|
+
return stream.getSubagentsByMessage(messageId);
|
|
598
|
+
},
|
|
599
|
+
queue: {
|
|
600
|
+
get entries() {
|
|
601
|
+
return pendingRuns.entries;
|
|
602
|
+
},
|
|
603
|
+
get size() {
|
|
604
|
+
return pendingRuns.size;
|
|
605
|
+
},
|
|
606
|
+
async cancel(id) {
|
|
607
|
+
const usableThreadId = threadIdRef.current ?? threadId;
|
|
608
|
+
const removed = pendingRuns.remove(id);
|
|
609
|
+
if (removed && usableThreadId) await client.runs.cancel(usableThreadId, id);
|
|
610
|
+
return removed;
|
|
611
|
+
},
|
|
612
|
+
async clear() {
|
|
613
|
+
const usableThreadId = threadIdRef.current ?? threadId;
|
|
614
|
+
const removed = pendingRuns.removeAll();
|
|
615
|
+
if (usableThreadId && removed.length > 0) await Promise.all(removed.map((e) => client.runs.cancel(usableThreadId, e.id)));
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
//#endregion
|
|
622
|
+
exports.useStreamLGP = useStreamLGP;
|
|
623
|
+
//# sourceMappingURL=stream.lgp.cjs.map
|