@langchain/react 0.3.4 → 0.4.0-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.
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/index.cjs +1 -56
- package/dist/index.d.cts +3 -5
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/libs/langgraph-core/dist/channels/base.d.cts +83 -0
- package/dist/libs/langgraph-core/dist/channels/base.d.cts.map +1 -0
- package/dist/libs/langgraph-core/dist/channels/base.d.ts +83 -0
- package/dist/libs/langgraph-core/dist/channels/base.d.ts.map +1 -0
- package/dist/libs/langgraph-core/dist/constants.d.cts +42 -0
- package/dist/libs/langgraph-core/dist/constants.d.cts.map +1 -0
- package/dist/libs/langgraph-core/dist/constants.d.ts +42 -0
- package/dist/libs/langgraph-core/dist/constants.d.ts.map +1 -0
- package/dist/libs/langgraph-core/dist/graph/zod/index.d.cts +2 -0
- package/dist/libs/langgraph-core/dist/graph/zod/index.d.ts +2 -0
- package/dist/libs/langgraph-core/dist/graph/zod/meta.d.cts +109 -0
- package/dist/libs/langgraph-core/dist/graph/zod/meta.d.cts.map +1 -0
- package/dist/libs/langgraph-core/dist/graph/zod/meta.d.ts +109 -0
- package/dist/libs/langgraph-core/dist/graph/zod/meta.d.ts.map +1 -0
- package/dist/libs/langgraph-core/dist/graph/zod/zod-registry.d.cts +49 -0
- package/dist/libs/langgraph-core/dist/graph/zod/zod-registry.d.cts.map +1 -0
- package/dist/libs/langgraph-core/dist/graph/zod/zod-registry.d.ts +49 -0
- package/dist/libs/langgraph-core/dist/graph/zod/zod-registry.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/ReactAgent.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/ReactAgent.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/index.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/index.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/contextEditing.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/contextEditing.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/dynamicSystemPrompt.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/dynamicSystemPrompt.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/hitl.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/hitl.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/llmToolSelector.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/llmToolSelector.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/modelCallLimit.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/modelCallLimit.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/modelFallback.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/modelFallback.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/modelRetry.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/modelRetry.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/pii.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/pii.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/piiRedaction.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/piiRedaction.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/provider/anthropic/promptCaching.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/provider/anthropic/promptCaching.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/provider/openai/moderation.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/provider/openai/moderation.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/summarization.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/summarization.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/todoListMiddleware.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/todoListMiddleware.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/toolCallLimit.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/toolCallLimit.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/toolEmulator.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/toolEmulator.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/toolRetry.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/toolRetry.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/types.d.cts +2 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware/types.d.ts +2 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware.d.cts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/middleware.d.ts +1 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/types.d.cts +2 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/agents/types.d.ts +2 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/index.d.cts +2 -0
- package/dist/node_modules/.pnpm/langchain@1.2.33-dev-1773786580575_@langchain_core@1.1.32_@opentelemetry_api@1.9.0_open_a3480def1aaae3092a33e9a20fdaa4bd/node_modules/langchain/dist/index.d.ts +2 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.d.cts +29 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.d.ts +29 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.d.cts +29 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.d.ts +29 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.d.cts +105 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.d.ts +105 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema.d.cts +70 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema.d.ts +70 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/json-schema.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.d.cts +24 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.d.ts +24 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/registries.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.d.cts +97 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.d.ts +97 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/standard-schema.d.cts +79 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/standard-schema.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/standard-schema.d.ts +79 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/standard-schema.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.d.cts +52 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.d.ts +52 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.d.cts +17 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.d.ts +17 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.d.ts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.d.cts +9 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.d.ts +9 -0
- package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/versions.d.ts.map +1 -0
- package/dist/react-ui/client.cjs +136 -0
- package/dist/react-ui/client.cjs.map +1 -0
- package/dist/react-ui/client.d.cts +88 -0
- package/dist/react-ui/client.d.cts.map +1 -0
- package/dist/react-ui/client.d.ts +88 -0
- package/dist/react-ui/client.d.ts.map +1 -0
- package/dist/react-ui/client.js +130 -0
- package/dist/react-ui/client.js.map +1 -0
- package/dist/react-ui/index.cjs +14 -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 +8 -0
- package/dist/react-ui/index.js.map +1 -0
- package/dist/react-ui/server/index.cjs +5 -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 +3 -0
- package/dist/react-ui/server/server.cjs +56 -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 +55 -0
- package/dist/react-ui/server/server.js.map +1 -0
- package/dist/react-ui/types.cjs +37 -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 +4 -5
- package/dist/stream.cjs.map +1 -1
- package/dist/stream.custom.cjs +28 -38
- package/dist/stream.custom.cjs.map +1 -1
- package/dist/stream.custom.js +29 -40
- package/dist/stream.custom.js.map +1 -1
- package/dist/stream.d.cts +49 -5
- package/dist/stream.d.cts.map +1 -1
- package/dist/stream.d.ts +49 -5
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +3 -5
- package/dist/stream.js.map +1 -1
- package/dist/stream.lgp.cjs +31 -40
- package/dist/stream.lgp.cjs.map +1 -1
- package/dist/stream.lgp.js +32 -42
- package/dist/stream.lgp.js.map +1 -1
- package/dist/thread.cjs +1 -0
- package/dist/thread.cjs.map +1 -1
- package/dist/thread.js.map +1 -1
- package/dist/types.d.cts +3 -19
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.ts +3 -19
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -15
- package/LICENSE +0 -21
- package/dist/context.cjs +0 -108
- package/dist/context.cjs.map +0 -1
- package/dist/context.d.cts +0 -109
- package/dist/context.d.cts.map +0 -1
- package/dist/context.d.ts +0 -109
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js +0 -107
- package/dist/context.js.map +0 -1
- package/dist/suspense-stream.cjs +0 -203
- package/dist/suspense-stream.cjs.map +0 -1
- package/dist/suspense-stream.d.cts +0 -81
- package/dist/suspense-stream.d.cts.map +0 -1
- package/dist/suspense-stream.d.ts +0 -81
- package/dist/suspense-stream.d.ts.map +0 -1
- package/dist/suspense-stream.js +0 -201
- package/dist/suspense-stream.js.map +0 -1
package/dist/thread.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread.js","names":[],"sources":["../src/thread.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, useRef, useCallback } from \"react\";\n\nexport const useControllableThreadId = (options?: {\n threadId?: string | null;\n onThreadId?: (threadId: string) => void;\n}): [string | null, (threadId: string | null) => void] => {\n const [localThreadId, _setLocalThreadId] = useState<string | null>(\n options?.threadId ?? null
|
|
1
|
+
{"version":3,"file":"thread.js","names":[],"sources":["../src/thread.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, useRef, useCallback } from \"react\";\n\nexport const useControllableThreadId = (options?: {\n threadId?: string | null;\n onThreadId?: (threadId: string) => void;\n}): [string | null, (threadId: string | null) => void] => {\n const [localThreadId, _setLocalThreadId] = useState<string | null>(\n options?.threadId ?? null,\n );\n\n const onThreadIdRef = useRef(options?.onThreadId);\n onThreadIdRef.current = options?.onThreadId;\n\n const setThreadId = useCallback((threadId: string | null) => {\n _setLocalThreadId(threadId);\n if (threadId != null) onThreadIdRef.current?.(threadId);\n }, []);\n\n if (!options || !(\"threadId\" in options)) {\n return [localThreadId, setThreadId];\n }\n\n return [options.threadId ?? null, setThreadId];\n};\n"],"mappings":";;;AAIA,MAAa,2BAA2B,YAGkB;CACxD,MAAM,CAAC,eAAe,qBAAqB,SACzC,SAAS,YAAY,KACtB;CAED,MAAM,gBAAgB,OAAO,SAAS,WAAW;AACjD,eAAc,UAAU,SAAS;CAEjC,MAAM,cAAc,aAAa,aAA4B;AAC3D,oBAAkB,SAAS;AAC3B,MAAI,YAAY,KAAM,eAAc,UAAU,SAAS;IACtD,EAAE,CAAC;AAEN,KAAI,CAAC,WAAW,EAAE,cAAc,SAC9B,QAAO,CAAC,eAAe,YAAY;AAGrC,QAAO,CAAC,QAAQ,YAAY,MAAM,YAAY"}
|
package/dist/types.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseMessage } from "@langchain/core/messages";
|
|
2
2
|
import { BagTemplate, Client, StreamEvent, StreamMode, ThreadState, ToolProgress } from "@langchain/langgraph-sdk";
|
|
3
|
-
import { CustomSubmitOptions, DefaultSubagentStates, GetConfigurableType, GetInterruptType, GetToolCallsType, GetUpdateType, MessageMetadata, QueueInterface, Sequence, StreamBase, SubagentStream, SubagentStreamInterface, SubmitOptions, UseStreamCustomOptions
|
|
3
|
+
import { CustomSubmitOptions, DefaultSubagentStates, GetConfigurableType, GetInterruptType, GetToolCallsType, GetUpdateType, MessageMetadata as MessageMetadata$1, QueueInterface, Sequence, StreamBase, SubagentStream, SubagentStreamInterface as SubagentStreamInterface$1, SubmitOptions, UseStreamCustomOptions } from "@langchain/langgraph-sdk/ui";
|
|
4
4
|
|
|
5
5
|
//#region src/types.d.ts
|
|
6
6
|
interface UseStream<StateType extends Record<string, unknown> = Record<string, unknown>, Bag extends BagTemplate = BagTemplate, SubagentStates extends Record<string, unknown> = DefaultSubagentStates> extends Omit<StreamBase<StateType, GetToolCallsType<StateType>, GetInterruptType<Bag>, SubagentStates>, "messages"> {
|
|
@@ -45,7 +45,7 @@ interface UseStream<StateType extends Record<string, unknown> = Record<string, u
|
|
|
45
45
|
* @param index - The index of the message in the thread.
|
|
46
46
|
* @returns The metadata for the message.
|
|
47
47
|
*/
|
|
48
|
-
getMessagesMetadata: (message: BaseMessage, index?: number) => MessageMetadata<StateType> | undefined;
|
|
48
|
+
getMessagesMetadata: (message: BaseMessage, index?: number) => MessageMetadata$1<StateType> | undefined;
|
|
49
49
|
/**
|
|
50
50
|
* Progress of tool executions during streaming.
|
|
51
51
|
*/
|
|
@@ -80,22 +80,6 @@ interface UseStream<StateType extends Record<string, unknown> = Record<string, u
|
|
|
80
80
|
*/
|
|
81
81
|
queue: QueueInterface<StateType, SubmitOptions<StateType, GetConfigurableType<Bag>>>;
|
|
82
82
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Return type for {@link useSuspenseStream}.
|
|
85
|
-
*
|
|
86
|
-
* Identical to {@link UseStream} but without `isLoading`, `error`, and
|
|
87
|
-
* `isThreadLoading` (those states are handled by Suspense / Error Boundaries).
|
|
88
|
-
* An `isStreaming` flag is provided instead to indicate whether tokens are
|
|
89
|
-
* currently being received from the server.
|
|
90
|
-
*/
|
|
91
|
-
type UseSuspenseStream<StateType extends Record<string, unknown> = Record<string, unknown>, Bag extends BagTemplate = BagTemplate, SubagentStates extends Record<string, unknown> = DefaultSubagentStates> = Omit<UseStream<StateType, Bag, SubagentStates>, "isLoading" | "error" | "isThreadLoading"> & {
|
|
92
|
-
/**
|
|
93
|
-
* Whether the stream is currently receiving data from the server.
|
|
94
|
-
* Unlike Suspense-based loading, streaming is incremental and the
|
|
95
|
-
* component stays rendered throughout.
|
|
96
|
-
*/
|
|
97
|
-
isStreaming: boolean;
|
|
98
|
-
};
|
|
99
83
|
type UseStreamCustom<StateType extends Record<string, unknown> = Record<string, unknown>, Bag extends BagTemplate = BagTemplate, SubagentStates extends Record<string, unknown> = DefaultSubagentStates> = Pick<UseStream<StateType, Bag, SubagentStates>, "values" | "error" | "isLoading" | "stop" | "interrupt" | "interrupts" | "messages" | "toolCalls" | "getToolCalls" | "getMessagesMetadata" | "branch" | "setBranch" | "subagents" | "activeSubagents" | "getSubagent" | "getSubagentsByType" | "getSubagentsByMessage"> & {
|
|
100
84
|
submit: (values: GetUpdateType<Bag, StateType> | null | undefined, options?: CustomSubmitOptions<StateType, GetConfigurableType<Bag>>) => Promise<void>;
|
|
101
85
|
switchThread: (newThreadId: string | null) => void;
|
|
@@ -105,5 +89,5 @@ type UseStreamCustom<StateType extends Record<string, unknown> = Record<string,
|
|
|
105
89
|
queue: QueueInterface<StateType, CustomSubmitOptions<StateType, GetConfigurableType<Bag>>>;
|
|
106
90
|
};
|
|
107
91
|
//#endregion
|
|
108
|
-
export { type SubagentStream, type SubagentStreamInterface, UseStream, UseStreamCustom, type UseStreamCustomOptions
|
|
92
|
+
export { type SubagentStream, type SubagentStreamInterface$1 as SubagentStreamInterface, type SubmitOptions, UseStream, UseStreamCustom, type UseStreamCustomOptions };
|
|
109
93
|
//# sourceMappingURL=types.d.cts.map
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.tsx"],"mappings":";;;;;UAgFiB,SAAA,mBACG,MAAA,oBAA0B,MAAA,+BAChC,WAAA,GAAc,WAAA,yBACH,MAAA,oBAA0B,qBAAA,UACzC,IAAA,CACR,UAAA,CACE,SAAA,EACA,gBAAA,CAAiB,SAAA,GACjB,gBAAA,CAAiB,GAAA,GACjB,cAAA;EATa;;;EAgBf,QAAA,EAAU,WAAA;EAfkC;;;EAoB5C,eAAA;EAlBiD;;;EAuBjD,IAAA,QAAY,OAAA;EAlBO;;;EAuBnB,MAAA,GACE,MAAA,EAAQ,aAAA,CAAc,GAAA,EAAK,SAAA,sBAC3B,OAAA,GAAU,aAAA,CAAc,SAAA,EAAW,mBAAA,CAAoB,GAAA,OACpD,OAAA;EAlBK;;;EAuBV,MAAA;EAPU;;;EAYV,SAAA,GAAY,MAAA;EAXA;;;EAgBZ,OAAA,EAAS,WAAA,CAAY,SAAA;EAMa;;;;EAAlC,uBAAA,EAAyB,QAAA,CAAS,SAAA;EAkBpB;;;;;;;;EARd,mBAAA,GACE,OAAA,EAAS,WAAA,EACT,KAAA,cACG,
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.tsx"],"mappings":";;;;;UAgFiB,SAAA,mBACG,MAAA,oBAA0B,MAAA,+BAChC,WAAA,GAAc,WAAA,yBACH,MAAA,oBAA0B,qBAAA,UACzC,IAAA,CACR,UAAA,CACE,SAAA,EACA,gBAAA,CAAiB,SAAA,GACjB,gBAAA,CAAiB,GAAA,GACjB,cAAA;EATa;;;EAgBf,QAAA,EAAU,WAAA;EAfkC;;;EAoB5C,eAAA;EAlBiD;;;EAuBjD,IAAA,QAAY,OAAA;EAlBO;;;EAuBnB,MAAA,GACE,MAAA,EAAQ,aAAA,CAAc,GAAA,EAAK,SAAA,sBAC3B,OAAA,GAAU,aAAA,CAAc,SAAA,EAAW,mBAAA,CAAoB,GAAA,OACpD,OAAA;EAlBK;;;EAuBV,MAAA;EAPU;;;EAYV,SAAA,GAAY,MAAA;EAXA;;;EAgBZ,OAAA,EAAS,WAAA,CAAY,SAAA;EAMa;;;;EAAlC,uBAAA,EAAyB,QAAA,CAAS,SAAA;EAkBpB;;;;;;;;EARd,mBAAA,GACE,OAAA,EAAS,WAAA,EACT,KAAA,cACG,iBAAA,CAAgB,SAAA;EA6CM;;;EAxC3B,YAAA,EAAc,YAAA;EArEF;;;EA0EZ,MAAA,EAAQ,MAAA;EA7EoC;;;EAkF5C,WAAA;EAhFA;;;EAqFA,UAAA,GACE,KAAA,UACA,WAAA,WACA,OAAA;IACE,UAAA,GAAa,UAAA,GAAa,UAAA;IAC1B,MAAA,IAAU,KAAA;MACR,EAAA;MACA,KAAA,EAAO,WAAA;MACP,IAAA;IAAA;EAAA,MAGD,OAAA;EAnFL;;;;EAyFA,YAAA,GAAe,WAAA;EA1Ef;;;;EAgFA,KAAA,EAAO,cAAA,CACL,SAAA,EACA,aAAA,CAAc,SAAA,EAAW,mBAAA,CAAoB,GAAA;AAAA;AAAA,KAIrC,eAAA,mBACQ,MAAA,oBAA0B,MAAA,+BAChC,WAAA,GAAc,WAAA,yBACH,MAAA,oBAA0B,qBAAA,IAC/C,IAAA,CACF,SAAA,CAAU,SAAA,EAAW,GAAA,EAAK,cAAA;EAmB1B,MAAA,GACE,MAAA,EAAQ,aAAA,CAAc,GAAA,EAAK,SAAA,sBAC3B,OAAA,GAAU,mBAAA,CAAoB,SAAA,EAAW,mBAAA,CAAoB,GAAA,OAC1D,OAAA;EAEL,YAAA,GAAe,WAAA;EAjHb;;;EAsHF,KAAA,EAAO,cAAA,CACL,SAAA,EACA,mBAAA,CAAoB,SAAA,EAAW,mBAAA,CAAoB,GAAA;AAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomSubmitOptions, DefaultSubagentStates, GetConfigurableType, GetInterruptType, GetToolCallsType, GetUpdateType, MessageMetadata, QueueInterface, Sequence, StreamBase, SubagentStream, SubagentStreamInterface, SubmitOptions, UseStreamCustomOptions
|
|
1
|
+
import { CustomSubmitOptions, DefaultSubagentStates, GetConfigurableType, GetInterruptType, GetToolCallsType, GetUpdateType, MessageMetadata as MessageMetadata$1, QueueInterface, Sequence, StreamBase, SubagentStream, SubagentStreamInterface as SubagentStreamInterface$1, SubmitOptions, UseStreamCustomOptions } from "@langchain/langgraph-sdk/ui";
|
|
2
2
|
import { BagTemplate, Client, StreamEvent, StreamMode, ThreadState, ToolProgress } from "@langchain/langgraph-sdk";
|
|
3
3
|
import { BaseMessage } from "@langchain/core/messages";
|
|
4
4
|
|
|
@@ -45,7 +45,7 @@ interface UseStream<StateType extends Record<string, unknown> = Record<string, u
|
|
|
45
45
|
* @param index - The index of the message in the thread.
|
|
46
46
|
* @returns The metadata for the message.
|
|
47
47
|
*/
|
|
48
|
-
getMessagesMetadata: (message: BaseMessage, index?: number) => MessageMetadata<StateType> | undefined;
|
|
48
|
+
getMessagesMetadata: (message: BaseMessage, index?: number) => MessageMetadata$1<StateType> | undefined;
|
|
49
49
|
/**
|
|
50
50
|
* Progress of tool executions during streaming.
|
|
51
51
|
*/
|
|
@@ -80,22 +80,6 @@ interface UseStream<StateType extends Record<string, unknown> = Record<string, u
|
|
|
80
80
|
*/
|
|
81
81
|
queue: QueueInterface<StateType, SubmitOptions<StateType, GetConfigurableType<Bag>>>;
|
|
82
82
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Return type for {@link useSuspenseStream}.
|
|
85
|
-
*
|
|
86
|
-
* Identical to {@link UseStream} but without `isLoading`, `error`, and
|
|
87
|
-
* `isThreadLoading` (those states are handled by Suspense / Error Boundaries).
|
|
88
|
-
* An `isStreaming` flag is provided instead to indicate whether tokens are
|
|
89
|
-
* currently being received from the server.
|
|
90
|
-
*/
|
|
91
|
-
type UseSuspenseStream<StateType extends Record<string, unknown> = Record<string, unknown>, Bag extends BagTemplate = BagTemplate, SubagentStates extends Record<string, unknown> = DefaultSubagentStates> = Omit<UseStream<StateType, Bag, SubagentStates>, "isLoading" | "error" | "isThreadLoading"> & {
|
|
92
|
-
/**
|
|
93
|
-
* Whether the stream is currently receiving data from the server.
|
|
94
|
-
* Unlike Suspense-based loading, streaming is incremental and the
|
|
95
|
-
* component stays rendered throughout.
|
|
96
|
-
*/
|
|
97
|
-
isStreaming: boolean;
|
|
98
|
-
};
|
|
99
83
|
type UseStreamCustom<StateType extends Record<string, unknown> = Record<string, unknown>, Bag extends BagTemplate = BagTemplate, SubagentStates extends Record<string, unknown> = DefaultSubagentStates> = Pick<UseStream<StateType, Bag, SubagentStates>, "values" | "error" | "isLoading" | "stop" | "interrupt" | "interrupts" | "messages" | "toolCalls" | "getToolCalls" | "getMessagesMetadata" | "branch" | "setBranch" | "subagents" | "activeSubagents" | "getSubagent" | "getSubagentsByType" | "getSubagentsByMessage"> & {
|
|
100
84
|
submit: (values: GetUpdateType<Bag, StateType> | null | undefined, options?: CustomSubmitOptions<StateType, GetConfigurableType<Bag>>) => Promise<void>;
|
|
101
85
|
switchThread: (newThreadId: string | null) => void;
|
|
@@ -105,5 +89,5 @@ type UseStreamCustom<StateType extends Record<string, unknown> = Record<string,
|
|
|
105
89
|
queue: QueueInterface<StateType, CustomSubmitOptions<StateType, GetConfigurableType<Bag>>>;
|
|
106
90
|
};
|
|
107
91
|
//#endregion
|
|
108
|
-
export { type SubagentStream, type SubagentStreamInterface, UseStream, UseStreamCustom, type UseStreamCustomOptions
|
|
92
|
+
export { type SubagentStream, type SubagentStreamInterface$1 as SubagentStreamInterface, type SubmitOptions, UseStream, UseStreamCustom, type UseStreamCustomOptions };
|
|
109
93
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.tsx"],"mappings":";;;;;UAgFiB,SAAA,mBACG,MAAA,oBAA0B,MAAA,+BAChC,WAAA,GAAc,WAAA,yBACH,MAAA,oBAA0B,qBAAA,UACzC,IAAA,CACR,UAAA,CACE,SAAA,EACA,gBAAA,CAAiB,SAAA,GACjB,gBAAA,CAAiB,GAAA,GACjB,cAAA;EATa;;;EAgBf,QAAA,EAAU,WAAA;EAfkC;;;EAoB5C,eAAA;EAlBiD;;;EAuBjD,IAAA,QAAY,OAAA;EAlBO;;;EAuBnB,MAAA,GACE,MAAA,EAAQ,aAAA,CAAc,GAAA,EAAK,SAAA,sBAC3B,OAAA,GAAU,aAAA,CAAc,SAAA,EAAW,mBAAA,CAAoB,GAAA,OACpD,OAAA;EAlBK;;;EAuBV,MAAA;EAPU;;;EAYV,SAAA,GAAY,MAAA;EAXA;;;EAgBZ,OAAA,EAAS,WAAA,CAAY,SAAA;EAMa;;;;EAAlC,uBAAA,EAAyB,QAAA,CAAS,SAAA;EAkBpB;;;;;;;;EARd,mBAAA,GACE,OAAA,EAAS,WAAA,EACT,KAAA,cACG,
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.tsx"],"mappings":";;;;;UAgFiB,SAAA,mBACG,MAAA,oBAA0B,MAAA,+BAChC,WAAA,GAAc,WAAA,yBACH,MAAA,oBAA0B,qBAAA,UACzC,IAAA,CACR,UAAA,CACE,SAAA,EACA,gBAAA,CAAiB,SAAA,GACjB,gBAAA,CAAiB,GAAA,GACjB,cAAA;EATa;;;EAgBf,QAAA,EAAU,WAAA;EAfkC;;;EAoB5C,eAAA;EAlBiD;;;EAuBjD,IAAA,QAAY,OAAA;EAlBO;;;EAuBnB,MAAA,GACE,MAAA,EAAQ,aAAA,CAAc,GAAA,EAAK,SAAA,sBAC3B,OAAA,GAAU,aAAA,CAAc,SAAA,EAAW,mBAAA,CAAoB,GAAA,OACpD,OAAA;EAlBK;;;EAuBV,MAAA;EAPU;;;EAYV,SAAA,GAAY,MAAA;EAXA;;;EAgBZ,OAAA,EAAS,WAAA,CAAY,SAAA;EAMa;;;;EAAlC,uBAAA,EAAyB,QAAA,CAAS,SAAA;EAkBpB;;;;;;;;EARd,mBAAA,GACE,OAAA,EAAS,WAAA,EACT,KAAA,cACG,iBAAA,CAAgB,SAAA;EA6CM;;;EAxC3B,YAAA,EAAc,YAAA;EArEF;;;EA0EZ,MAAA,EAAQ,MAAA;EA7EoC;;;EAkF5C,WAAA;EAhFA;;;EAqFA,UAAA,GACE,KAAA,UACA,WAAA,WACA,OAAA;IACE,UAAA,GAAa,UAAA,GAAa,UAAA;IAC1B,MAAA,IAAU,KAAA;MACR,EAAA;MACA,KAAA,EAAO,WAAA;MACP,IAAA;IAAA;EAAA,MAGD,OAAA;EAnFL;;;;EAyFA,YAAA,GAAe,WAAA;EA1Ef;;;;EAgFA,KAAA,EAAO,cAAA,CACL,SAAA,EACA,aAAA,CAAc,SAAA,EAAW,mBAAA,CAAoB,GAAA;AAAA;AAAA,KAIrC,eAAA,mBACQ,MAAA,oBAA0B,MAAA,+BAChC,WAAA,GAAc,WAAA,yBACH,MAAA,oBAA0B,qBAAA,IAC/C,IAAA,CACF,SAAA,CAAU,SAAA,EAAW,GAAA,EAAK,cAAA;EAmB1B,MAAA,GACE,MAAA,EAAQ,aAAA,CAAc,GAAA,EAAK,SAAA,sBAC3B,OAAA,GAAU,mBAAA,CAAoB,SAAA,EAAW,mBAAA,CAAoB,GAAA,OAC1D,OAAA;EAEL,YAAA,GAAe,WAAA;EAjHb;;;EAsHF,KAAA,EAAO,cAAA,CACL,SAAA,EACA,mBAAA,CAAoB,SAAA,EAAW,mBAAA,CAAoB,GAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-0",
|
|
4
4
|
"description": "React integration for LangGraph & LangChain",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"clean": "rm -rf dist/ dist-cjs/",
|
|
8
|
+
"build": "pnpm turbo build:internal --filter=@langchain/react",
|
|
9
|
+
"build:internal": "pnpm --filter @langchain/build compile @langchain/react",
|
|
10
|
+
"prepublish": "pnpm build",
|
|
11
|
+
"lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js,.jsx,.tsx src/",
|
|
12
|
+
"test": "vitest run"
|
|
13
|
+
},
|
|
6
14
|
"license": "MIT",
|
|
7
15
|
"repository": {
|
|
8
16
|
"type": "git",
|
|
@@ -10,11 +18,14 @@
|
|
|
10
18
|
"directory": "libs/sdk-react"
|
|
11
19
|
},
|
|
12
20
|
"dependencies": {
|
|
13
|
-
"@langchain/langgraph-sdk": "^1.
|
|
21
|
+
"@langchain/langgraph-sdk": "^1.9.11"
|
|
14
22
|
},
|
|
15
23
|
"devDependencies": {
|
|
16
24
|
"@hono/node-server": "^1.19.13",
|
|
17
25
|
"@langchain/core": "^1.1.40",
|
|
26
|
+
"@langchain/langgraph": "^1.3.3",
|
|
27
|
+
"@langchain/langgraph-api": "^1.2.4",
|
|
28
|
+
"@langchain/langgraph-checkpoint": "^1.0.4",
|
|
18
29
|
"@types/node": "^25.4.0",
|
|
19
30
|
"@types/react": "^19.2.14",
|
|
20
31
|
"@vitejs/plugin-react": "^5.1.4",
|
|
@@ -28,10 +39,7 @@
|
|
|
28
39
|
"vitest": "^4.0.18",
|
|
29
40
|
"vitest-browser-react": "^2.0.5",
|
|
30
41
|
"webdriverio": "^9.25.0",
|
|
31
|
-
"zod": "^4.3.6"
|
|
32
|
-
"@langchain/langgraph": "^1.2.9",
|
|
33
|
-
"@langchain/langgraph-api": "^1.1.17",
|
|
34
|
-
"@langchain/langgraph-checkpoint": "^1.0.1"
|
|
42
|
+
"zod": "^4.3.6"
|
|
35
43
|
},
|
|
36
44
|
"peerDependencies": {
|
|
37
45
|
"@langchain/core": "^1.1.27",
|
|
@@ -57,12 +65,5 @@
|
|
|
57
65
|
"files": [
|
|
58
66
|
"dist/"
|
|
59
67
|
],
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
"build": "pnpm turbo build:internal --filter=@langchain/react",
|
|
63
|
-
"build:internal": "pnpm --filter @langchain/build compile @langchain/react",
|
|
64
|
-
"prepublish": "pnpm build",
|
|
65
|
-
"lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js,.jsx,.tsx src/",
|
|
66
|
-
"test": "vitest run"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
68
|
+
"packageManager": "pnpm@10.33.2+sha512.a90faf6feeab71ad6c6e57f94e0fe1a12f5dcc22cd754db40ae9593eb6a3e0b6b12e3540218bb37ae083404b1f2ce6db2a4121e979829b4aff94b99f49da1cf8"
|
|
69
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 LangChain
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
package/dist/context.cjs
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
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
|
package/dist/context.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/context.d.cts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
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
|
package/dist/context.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/context.d.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
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
|
package/dist/context.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/context.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useStream } from "./stream.js";
|
|
3
|
-
import { createContext, useContext } from "react";
|
|
4
|
-
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
//#region src/context.tsx
|
|
6
|
-
const StreamContext = 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 = useStream(options);
|
|
68
|
-
return /* @__PURE__ */ 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 = 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
|
-
export { StreamProvider, useStreamContext };
|
|
106
|
-
|
|
107
|
-
//# sourceMappingURL=context.js.map
|