@langchain/react 0.3.5 → 1.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.
Files changed (98) hide show
  1. package/README.md +48 -523
  2. package/dist/context.cjs +12 -30
  3. package/dist/context.cjs.map +1 -1
  4. package/dist/context.d.cts +22 -39
  5. package/dist/context.d.cts.map +1 -1
  6. package/dist/context.d.ts +22 -39
  7. package/dist/context.d.ts.map +1 -1
  8. package/dist/context.js +11 -29
  9. package/dist/context.js.map +1 -1
  10. package/dist/index.cjs +29 -30
  11. package/dist/index.d.cts +10 -7
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.ts +10 -7
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +10 -6
  16. package/dist/selectors.cjs +178 -0
  17. package/dist/selectors.cjs.map +1 -0
  18. package/dist/selectors.d.cts +183 -0
  19. package/dist/selectors.d.cts.map +1 -0
  20. package/dist/selectors.d.ts +183 -0
  21. package/dist/selectors.d.ts.map +1 -0
  22. package/dist/selectors.js +168 -0
  23. package/dist/selectors.js.map +1 -0
  24. package/dist/suspense-stream.cjs +34 -159
  25. package/dist/suspense-stream.cjs.map +1 -1
  26. package/dist/suspense-stream.d.cts +15 -71
  27. package/dist/suspense-stream.d.cts.map +1 -1
  28. package/dist/suspense-stream.d.ts +15 -71
  29. package/dist/suspense-stream.d.ts.map +1 -1
  30. package/dist/suspense-stream.js +35 -158
  31. package/dist/suspense-stream.js.map +1 -1
  32. package/dist/use-audio-player.cjs +679 -0
  33. package/dist/use-audio-player.cjs.map +1 -0
  34. package/dist/use-audio-player.d.cts +161 -0
  35. package/dist/use-audio-player.d.cts.map +1 -0
  36. package/dist/use-audio-player.d.ts +161 -0
  37. package/dist/use-audio-player.d.ts.map +1 -0
  38. package/dist/use-audio-player.js +679 -0
  39. package/dist/use-audio-player.js.map +1 -0
  40. package/dist/use-media-url.cjs +49 -0
  41. package/dist/use-media-url.cjs.map +1 -0
  42. package/dist/use-media-url.d.cts +28 -0
  43. package/dist/use-media-url.d.cts.map +1 -0
  44. package/dist/use-media-url.d.ts +28 -0
  45. package/dist/use-media-url.d.ts.map +1 -0
  46. package/dist/use-media-url.js +49 -0
  47. package/dist/use-media-url.js.map +1 -0
  48. package/dist/use-projection.cjs +41 -0
  49. package/dist/use-projection.cjs.map +1 -0
  50. package/dist/use-projection.d.cts +27 -0
  51. package/dist/use-projection.d.cts.map +1 -0
  52. package/dist/use-projection.d.ts +27 -0
  53. package/dist/use-projection.d.ts.map +1 -0
  54. package/dist/use-projection.js +41 -0
  55. package/dist/use-projection.js.map +1 -0
  56. package/dist/use-stream.cjs +185 -0
  57. package/dist/use-stream.cjs.map +1 -0
  58. package/dist/use-stream.d.cts +184 -0
  59. package/dist/use-stream.d.cts.map +1 -0
  60. package/dist/use-stream.d.ts +184 -0
  61. package/dist/use-stream.d.ts.map +1 -0
  62. package/dist/use-stream.js +183 -0
  63. package/dist/use-stream.js.map +1 -0
  64. package/dist/use-video-player.cjs +218 -0
  65. package/dist/use-video-player.cjs.map +1 -0
  66. package/dist/use-video-player.d.cts +65 -0
  67. package/dist/use-video-player.d.cts.map +1 -0
  68. package/dist/use-video-player.d.ts +65 -0
  69. package/dist/use-video-player.d.ts.map +1 -0
  70. package/dist/use-video-player.js +218 -0
  71. package/dist/use-video-player.js.map +1 -0
  72. package/package.json +9 -8
  73. package/dist/stream.cjs +0 -18
  74. package/dist/stream.cjs.map +0 -1
  75. package/dist/stream.custom.cjs +0 -209
  76. package/dist/stream.custom.cjs.map +0 -1
  77. package/dist/stream.custom.d.cts +0 -3
  78. package/dist/stream.custom.d.ts +0 -3
  79. package/dist/stream.custom.js +0 -209
  80. package/dist/stream.custom.js.map +0 -1
  81. package/dist/stream.d.cts +0 -174
  82. package/dist/stream.d.cts.map +0 -1
  83. package/dist/stream.d.ts +0 -174
  84. package/dist/stream.d.ts.map +0 -1
  85. package/dist/stream.js +0 -18
  86. package/dist/stream.js.map +0 -1
  87. package/dist/stream.lgp.cjs +0 -671
  88. package/dist/stream.lgp.cjs.map +0 -1
  89. package/dist/stream.lgp.js +0 -671
  90. package/dist/stream.lgp.js.map +0 -1
  91. package/dist/thread.cjs +0 -18
  92. package/dist/thread.cjs.map +0 -1
  93. package/dist/thread.js +0 -18
  94. package/dist/thread.js.map +0 -1
  95. package/dist/types.d.cts +0 -109
  96. package/dist/types.d.cts.map +0 -1
  97. package/dist/types.d.ts +0 -109
  98. package/dist/types.d.ts.map +0 -1
package/dist/context.cjs CHANGED
@@ -1,15 +1,16 @@
1
1
  "use client";
2
- const require_stream = require("./stream.cjs");
2
+ const require_use_stream = require("./use-stream.cjs");
3
3
  let react = require("react");
4
4
  let react_jsx_runtime = require("react/jsx-runtime");
5
5
  //#region src/context.tsx
6
6
  const StreamContext = (0, react.createContext)(null);
7
7
  /**
8
- * Provides a shared `useStream` instance to all descendants via React Context.
8
+ * Provides a shared {@link useStream} instance to all descendants via
9
+ * React Context.
9
10
  *
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.
11
+ * Use `StreamProvider` when multiple components in a subtree need
12
+ * access to the same stream state (messages, loading status, errors,
13
+ * interrupts, …) without prop drilling.
13
14
  *
14
15
  * @example
15
16
  * ```tsx
@@ -34,20 +35,6 @@ const StreamContext = (0, react.createContext)(null);
34
35
  * </header>
35
36
  * );
36
37
  * }
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
38
  * ```
52
39
  *
53
40
  * Multiple providers can be nested for multi-agent scenarios:
@@ -64,35 +51,30 @@ const StreamContext = (0, react.createContext)(null);
64
51
  */
65
52
  function StreamProvider(props) {
66
53
  const { children, ...options } = props;
67
- const stream = require_stream.useStream(options);
54
+ const stream = require_use_stream.useStream(options);
68
55
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StreamContext.Provider, {
69
56
  value: stream,
70
57
  children
71
58
  });
72
59
  }
73
60
  /**
74
- * Accesses the shared stream instance from the nearest `StreamProvider`.
75
- *
76
- * Throws if called outside of a `StreamProvider`.
61
+ * Accesses the shared stream instance from the nearest
62
+ * {@link StreamProvider}. Throws if called outside of one.
77
63
  *
78
64
  * @example
79
65
  * ```tsx
80
66
  * 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
- * });
67
+ * const { messages } = useStreamContext();
68
+ * return messages.map((m, i) => <div key={m.id ?? i}>{String(m.content)}</div>);
86
69
  * }
87
70
  * ```
88
71
  *
89
- * @example With type parameters for full type safety:
72
+ * @example With a type parameter for full type safety:
90
73
  * ```tsx
91
74
  * import type { agent } from "./agent";
92
75
  *
93
76
  * function Chat() {
94
77
  * const { toolCalls } = useStreamContext<typeof agent>();
95
- * // toolCalls are fully typed from the agent's tools
96
78
  * }
97
79
  * ```
98
80
  */
@@ -1 +1 @@
1
- {"version":3,"file":"context.cjs","names":["useStream"],"sources":["../src/context.tsx"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\n\"use client\";\n\nimport { createContext, useContext, type ReactNode } from \"react\";\nimport type { BagTemplate } from \"@langchain/langgraph-sdk\";\nimport type {\n ResolveStreamOptions,\n InferBag,\n InferStateType,\n UseStreamCustomOptions,\n} from \"@langchain/langgraph-sdk/ui\";\nimport { useStream } from \"./stream.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst StreamContext = createContext<any | null>(null);\n\n/**\n * Props for the StreamProvider component.\n * Accepts all `useStream` options plus `children`.\n */\nexport type StreamProviderProps<\n T = Record<string, unknown>,\n Bag extends BagTemplate = BagTemplate,\n> = ResolveStreamOptions<T, InferBag<T, Bag>> & { children: ReactNode };\n\n/**\n * Props for the StreamProvider component when using a custom transport.\n * Accepts all `useStream` custom options plus `children`.\n */\nexport type StreamProviderCustomProps<\n T = Record<string, unknown>,\n Bag extends BagTemplate = BagTemplate,\n> = UseStreamCustomOptions<InferStateType<T>, InferBag<T, Bag>> & {\n children: ReactNode;\n};\n\n/**\n * Provides a shared `useStream` instance to all descendants via React Context.\n *\n * Use `StreamProvider` when multiple components in a subtree need access to the\n * same stream state (messages, loading status, errors, interrupts, etc.) without\n * prop drilling.\n *\n * @example\n * ```tsx\n * import { StreamProvider, useStreamContext } from \"@langchain/react\";\n *\n * function App() {\n * return (\n * <StreamProvider assistantId=\"agent\" apiUrl=\"http://localhost:2024\">\n * <ChatHeader />\n * <MessageList />\n * <MessageInput />\n * </StreamProvider>\n * );\n * }\n *\n * function ChatHeader() {\n * const { isLoading, error } = useStreamContext();\n * return (\n * <header>\n * {isLoading && <span>Thinking...</span>}\n * {error && <span>Error</span>}\n * </header>\n * );\n * }\n *\n * function MessageList() {\n * const { messages } = useStreamContext();\n * return messages.map((msg, i) => <div key={msg.id ?? i}>{msg.content}</div>);\n * }\n *\n * function MessageInput() {\n * const { submit } = useStreamContext();\n * return (\n * <button onClick={() => submit({ messages: [{ type: \"human\", content: \"Hi\" }] })}>\n * Send\n * </button>\n * );\n * }\n * ```\n *\n * Multiple providers can be nested for multi-agent scenarios:\n *\n * @example\n * ```tsx\n * <StreamProvider assistantId=\"researcher\" apiUrl=\"http://localhost:2024\">\n * <ResearchPanel />\n * </StreamProvider>\n * <StreamProvider assistantId=\"writer\" apiUrl=\"http://localhost:2024\">\n * <WriterPanel />\n * </StreamProvider>\n * ```\n */\nexport function StreamProvider<\n T = Record<string, unknown>,\n Bag extends BagTemplate = BagTemplate,\n>(\n props: StreamProviderProps<T, Bag> | StreamProviderCustomProps<T, Bag>\n): ReactNode {\n const { children, ...options } = props;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const stream = useStream<T, Bag>(options as any);\n\n return (\n <StreamContext.Provider value={stream}>{children}</StreamContext.Provider>\n );\n}\n\n/**\n * Accesses the shared stream instance from the nearest `StreamProvider`.\n *\n * Throws if called outside of a `StreamProvider`.\n *\n * @example\n * ```tsx\n * function MessageList() {\n * const { messages, getMessagesMetadata } = useStreamContext();\n * return messages.map((msg, i) => {\n * const metadata = getMessagesMetadata(msg, i);\n * return <div key={msg.id ?? i}>{msg.content}</div>;\n * });\n * }\n * ```\n *\n * @example With type parameters for full type safety:\n * ```tsx\n * import type { agent } from \"./agent\";\n *\n * function Chat() {\n * const { toolCalls } = useStreamContext<typeof agent>();\n * // toolCalls are fully typed from the agent's tools\n * }\n * ```\n */\nexport function useStreamContext<\n T = Record<string, unknown>,\n Bag extends BagTemplate = BagTemplate,\n>(): ReturnType<typeof useStream<T, Bag>> {\n const context = useContext(StreamContext);\n if (context === null) {\n throw new Error(\n \"useStreamContext must be used within a <StreamProvider>. \" +\n \"Wrap your component tree with <StreamProvider> or use useStream() directly.\"\n );\n }\n return context;\n}\n"],"mappings":";;;;;AAeA,MAAM,iBAAA,GAAA,MAAA,eAA0C,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFrD,SAAgB,eAId,OACW;CACX,MAAM,EAAE,UAAU,GAAG,YAAY;CAEjC,MAAM,SAASA,eAAAA,UAAkB,QAAe;AAEhD,QACE,iBAAA,GAAA,kBAAA,KAAC,cAAc,UAAf;EAAwB,OAAO;EAAS;EAAkC,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8B9E,SAAgB,mBAG0B;CACxC,MAAM,WAAA,GAAA,MAAA,YAAqB,cAAc;AACzC,KAAI,YAAY,KACd,OAAM,IAAI,MACR,uIAED;AAEH,QAAO"}
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 {\n useStream,\n type UseStreamOptions,\n type UseStreamReturn,\n type AgentServerOptions,\n type CustomAdapterOptions,\n} from \"./use-stream.js\";\nimport type { InferStateType } from \"@langchain/langgraph-sdk/stream\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst StreamContext = createContext<any | null>(null);\n\n/**\n * Props for {@link StreamProvider} when talking to the default\n * LangGraph Platform agent server. Mirrors {@link AgentServerOptions}\n * plus `children`.\n */\nexport type StreamProviderProps<T = Record<string, unknown>> =\n AgentServerOptions<InferStateType<T>> & {\n children: ReactNode;\n };\n\n/**\n * Props for {@link StreamProvider} when wiring a custom\n * {@link AgentServerAdapter}. Mirrors {@link CustomAdapterOptions}\n * plus `children`.\n */\nexport type StreamProviderCustomProps<T = Record<string, unknown>> =\n CustomAdapterOptions<InferStateType<T>> & {\n children: ReactNode;\n };\n\n/**\n * Provides a shared {@link useStream} instance to all descendants via\n * React Context.\n *\n * Use `StreamProvider` when multiple components in a subtree need\n * access to the same stream state (messages, loading status, errors,\n * interrupts, ) without 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 *\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<T = Record<string, unknown>>(\n props: StreamProviderProps<T> | StreamProviderCustomProps<T>\n): ReactNode {\n const { children, ...options } = props;\n const stream = useStream<T>(options as UseStreamOptions<InferStateType<T>>);\n\n return (\n <StreamContext.Provider value={stream}>{children}</StreamContext.Provider>\n );\n}\n\n/**\n * Accesses the shared stream instance from the nearest\n * {@link StreamProvider}. Throws if called outside of one.\n *\n * @example\n * ```tsx\n * function MessageList() {\n * const { messages } = useStreamContext();\n * return messages.map((m, i) => <div key={m.id ?? i}>{String(m.content)}</div>);\n * }\n * ```\n *\n * @example With a type parameter for full type safety:\n * ```tsx\n * import type { agent } from \"./agent\";\n *\n * function Chat() {\n * const { toolCalls } = useStreamContext<typeof agent>();\n * }\n * ```\n */\nexport function useStreamContext<\n T = Record<string, unknown>,\n>(): UseStreamReturn<T> {\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 as UseStreamReturn<T>;\n}\n"],"mappings":";;;;;AAeA,MAAM,iBAAA,GAAA,MAAA,eAA0C,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmErD,SAAgB,eACd,OACW;CACX,MAAM,EAAE,UAAU,GAAG,YAAY;CACjC,MAAM,SAASA,mBAAAA,UAAa,QAA+C;AAE3E,QACE,iBAAA,GAAA,kBAAA,KAAC,cAAc,UAAf;EAAwB,OAAO;EAAS;EAAkC,CAAA;;;;;;;;;;;;;;;;;;;;;;;AAyB9E,SAAgB,mBAEQ;CACtB,MAAM,WAAA,GAAA,MAAA,YAAqB,cAAc;AACzC,KAAI,YAAY,KACd,OAAM,IAAI,MACR,uIAED;AAEH,QAAO"}
@@ -1,29 +1,31 @@
1
- import { useStream } from "./stream.cjs";
2
- import { BagTemplate } from "@langchain/langgraph-sdk";
3
- import { InferBag, InferStateType, ResolveStreamOptions, UseStreamCustomOptions } from "@langchain/langgraph-sdk/ui";
1
+ import { AgentServerOptions as AgentServerOptions$1, CustomAdapterOptions as CustomAdapterOptions$1, UseStreamReturn } from "./use-stream.cjs";
2
+ import { InferStateType } from "@langchain/langgraph-sdk/stream";
4
3
  import { ReactNode } from "react";
5
4
 
6
5
  //#region src/context.d.ts
7
6
  /**
8
- * Props for the StreamProvider component.
9
- * Accepts all `useStream` options plus `children`.
7
+ * Props for {@link StreamProvider} when talking to the default
8
+ * LangGraph Platform agent server. Mirrors {@link AgentServerOptions}
9
+ * plus `children`.
10
10
  */
11
- type StreamProviderProps<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate> = ResolveStreamOptions<T, InferBag<T, Bag>> & {
11
+ type StreamProviderProps<T = Record<string, unknown>> = AgentServerOptions$1<InferStateType<T>> & {
12
12
  children: ReactNode;
13
13
  };
14
14
  /**
15
- * Props for the StreamProvider component when using a custom transport.
16
- * Accepts all `useStream` custom options plus `children`.
15
+ * Props for {@link StreamProvider} when wiring a custom
16
+ * {@link AgentServerAdapter}. Mirrors {@link CustomAdapterOptions}
17
+ * plus `children`.
17
18
  */
18
- type StreamProviderCustomProps<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate> = UseStreamCustomOptions<InferStateType<T>, InferBag<T, Bag>> & {
19
+ type StreamProviderCustomProps<T = Record<string, unknown>> = CustomAdapterOptions$1<InferStateType<T>> & {
19
20
  children: ReactNode;
20
21
  };
21
22
  /**
22
- * Provides a shared `useStream` instance to all descendants via React Context.
23
+ * Provides a shared {@link useStream} instance to all descendants via
24
+ * React Context.
23
25
  *
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.
26
+ * Use `StreamProvider` when multiple components in a subtree need
27
+ * access to the same stream state (messages, loading status, errors,
28
+ * interrupts, …) without prop drilling.
27
29
  *
28
30
  * @example
29
31
  * ```tsx
@@ -48,20 +50,6 @@ type StreamProviderCustomProps<T = Record<string, unknown>, Bag extends BagTempl
48
50
  * </header>
49
51
  * );
50
52
  * }
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
53
  * ```
66
54
  *
67
55
  * Multiple providers can be nested for multi-agent scenarios:
@@ -76,34 +64,29 @@ type StreamProviderCustomProps<T = Record<string, unknown>, Bag extends BagTempl
76
64
  * </StreamProvider>
77
65
  * ```
78
66
  */
79
- declare function StreamProvider<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate>(props: StreamProviderProps<T, Bag> | StreamProviderCustomProps<T, Bag>): ReactNode;
67
+ declare function StreamProvider<T = Record<string, unknown>>(props: StreamProviderProps<T> | StreamProviderCustomProps<T>): ReactNode;
80
68
  /**
81
- * Accesses the shared stream instance from the nearest `StreamProvider`.
82
- *
83
- * Throws if called outside of a `StreamProvider`.
69
+ * Accesses the shared stream instance from the nearest
70
+ * {@link StreamProvider}. Throws if called outside of one.
84
71
  *
85
72
  * @example
86
73
  * ```tsx
87
74
  * 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
- * });
75
+ * const { messages } = useStreamContext();
76
+ * return messages.map((m, i) => <div key={m.id ?? i}>{String(m.content)}</div>);
93
77
  * }
94
78
  * ```
95
79
  *
96
- * @example With type parameters for full type safety:
80
+ * @example With a type parameter for full type safety:
97
81
  * ```tsx
98
82
  * import type { agent } from "./agent";
99
83
  *
100
84
  * function Chat() {
101
85
  * const { toolCalls } = useStreamContext<typeof agent>();
102
- * // toolCalls are fully typed from the agent's tools
103
86
  * }
104
87
  * ```
105
88
  */
106
- declare function useStreamContext<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate>(): ReturnType<typeof useStream<T, Bag>>;
89
+ declare function useStreamContext<T = Record<string, unknown>>(): UseStreamReturn<T>;
107
90
  //#endregion
108
91
  export { StreamProvider, StreamProviderCustomProps, StreamProviderProps, useStreamContext };
109
92
  //# sourceMappingURL=context.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.cts","names":[],"sources":["../src/context.tsx"],"mappings":";;;;;;;;AAqBA;;KAAY,mBAAA,KACN,MAAA,+BACQ,WAAA,GAAc,WAAA,IACxB,oBAAA,CAAqB,CAAA,EAAG,QAAA,CAAS,CAAA,EAAG,GAAA;EAAU,QAAA,EAAU,SAAA;AAAA;;;;;KAMhD,yBAAA,KACN,MAAA,+BACQ,WAAA,GAAc,WAAA,IACxB,sBAAA,CAAuB,cAAA,CAAe,CAAA,GAAI,QAAA,CAAS,CAAA,EAAG,GAAA;EACxD,QAAA,EAAU,SAAA;AAAA;;;;;;;;;;;;;;;;;AAJZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA;;;;;;;;;;;;iBAAgB,cAAA,KACV,MAAA,+BACQ,WAAA,GAAc,WAAA,CAAA,CAE1B,KAAA,EAAO,mBAAA,CAAoB,CAAA,EAAG,GAAA,IAAO,yBAAA,CAA0B,CAAA,EAAG,GAAA,IACjE,SAAA;;;;;;;;;;;;;;;;;;AAoCH;;;;;;;;;iBAAgB,gBAAA,KACV,MAAA,+BACQ,WAAA,GAAc,WAAA,CAAA,CAAA,GACvB,UAAA,QAAkB,SAAA,CAAU,CAAA,EAAG,GAAA"}
1
+ {"version":3,"file":"context.d.cts","names":[],"sources":["../src/context.tsx"],"mappings":";;;;;;;AAsBA;;;KAAY,mBAAA,KAAwB,MAAA,qBAClC,oBAAA,CAAmB,cAAA,CAAe,CAAA;EAChC,QAAA,EAAU,SAAA;AAAA;;;;;;KAQF,yBAAA,KAA8B,MAAA,qBACxC,sBAAA,CAAqB,cAAA,CAAe,CAAA;EAClC,QAAA,EAAU,SAAA;AAAA;;;;;;AAFd;;;;;;;;;;;;;;;;;;;AAkDA;;;;;;;;;;;;;;;;;;;;;iBAAgB,cAAA,KAAmB,MAAA,kBAAA,CACjC,KAAA,EAAO,mBAAA,CAAoB,CAAA,IAAK,yBAAA,CAA0B,CAAA,IACzD,SAAA;;;;;;;;;;;;;;;;;;;;;;iBA8Ba,gBAAA,KACV,MAAA,kBAAA,CAAA,GACD,eAAA,CAAgB,CAAA"}
package/dist/context.d.ts CHANGED
@@ -1,29 +1,31 @@
1
- import { useStream } from "./stream.js";
1
+ import { AgentServerOptions as AgentServerOptions$1, CustomAdapterOptions as CustomAdapterOptions$1, UseStreamReturn } from "./use-stream.js";
2
2
  import { ReactNode } from "react";
3
- import { InferBag, InferStateType, ResolveStreamOptions, UseStreamCustomOptions } from "@langchain/langgraph-sdk/ui";
4
- import { BagTemplate } from "@langchain/langgraph-sdk";
3
+ import { InferStateType } from "@langchain/langgraph-sdk/stream";
5
4
 
6
5
  //#region src/context.d.ts
7
6
  /**
8
- * Props for the StreamProvider component.
9
- * Accepts all `useStream` options plus `children`.
7
+ * Props for {@link StreamProvider} when talking to the default
8
+ * LangGraph Platform agent server. Mirrors {@link AgentServerOptions}
9
+ * plus `children`.
10
10
  */
11
- type StreamProviderProps<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate> = ResolveStreamOptions<T, InferBag<T, Bag>> & {
11
+ type StreamProviderProps<T = Record<string, unknown>> = AgentServerOptions$1<InferStateType<T>> & {
12
12
  children: ReactNode;
13
13
  };
14
14
  /**
15
- * Props for the StreamProvider component when using a custom transport.
16
- * Accepts all `useStream` custom options plus `children`.
15
+ * Props for {@link StreamProvider} when wiring a custom
16
+ * {@link AgentServerAdapter}. Mirrors {@link CustomAdapterOptions}
17
+ * plus `children`.
17
18
  */
18
- type StreamProviderCustomProps<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate> = UseStreamCustomOptions<InferStateType<T>, InferBag<T, Bag>> & {
19
+ type StreamProviderCustomProps<T = Record<string, unknown>> = CustomAdapterOptions$1<InferStateType<T>> & {
19
20
  children: ReactNode;
20
21
  };
21
22
  /**
22
- * Provides a shared `useStream` instance to all descendants via React Context.
23
+ * Provides a shared {@link useStream} instance to all descendants via
24
+ * React Context.
23
25
  *
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.
26
+ * Use `StreamProvider` when multiple components in a subtree need
27
+ * access to the same stream state (messages, loading status, errors,
28
+ * interrupts, …) without prop drilling.
27
29
  *
28
30
  * @example
29
31
  * ```tsx
@@ -48,20 +50,6 @@ type StreamProviderCustomProps<T = Record<string, unknown>, Bag extends BagTempl
48
50
  * </header>
49
51
  * );
50
52
  * }
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
53
  * ```
66
54
  *
67
55
  * Multiple providers can be nested for multi-agent scenarios:
@@ -76,34 +64,29 @@ type StreamProviderCustomProps<T = Record<string, unknown>, Bag extends BagTempl
76
64
  * </StreamProvider>
77
65
  * ```
78
66
  */
79
- declare function StreamProvider<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate>(props: StreamProviderProps<T, Bag> | StreamProviderCustomProps<T, Bag>): ReactNode;
67
+ declare function StreamProvider<T = Record<string, unknown>>(props: StreamProviderProps<T> | StreamProviderCustomProps<T>): ReactNode;
80
68
  /**
81
- * Accesses the shared stream instance from the nearest `StreamProvider`.
82
- *
83
- * Throws if called outside of a `StreamProvider`.
69
+ * Accesses the shared stream instance from the nearest
70
+ * {@link StreamProvider}. Throws if called outside of one.
84
71
  *
85
72
  * @example
86
73
  * ```tsx
87
74
  * 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
- * });
75
+ * const { messages } = useStreamContext();
76
+ * return messages.map((m, i) => <div key={m.id ?? i}>{String(m.content)}</div>);
93
77
  * }
94
78
  * ```
95
79
  *
96
- * @example With type parameters for full type safety:
80
+ * @example With a type parameter for full type safety:
97
81
  * ```tsx
98
82
  * import type { agent } from "./agent";
99
83
  *
100
84
  * function Chat() {
101
85
  * const { toolCalls } = useStreamContext<typeof agent>();
102
- * // toolCalls are fully typed from the agent's tools
103
86
  * }
104
87
  * ```
105
88
  */
106
- declare function useStreamContext<T = Record<string, unknown>, Bag extends BagTemplate = BagTemplate>(): ReturnType<typeof useStream<T, Bag>>;
89
+ declare function useStreamContext<T = Record<string, unknown>>(): UseStreamReturn<T>;
107
90
  //#endregion
108
91
  export { StreamProvider, StreamProviderCustomProps, StreamProviderProps, useStreamContext };
109
92
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","names":[],"sources":["../src/context.tsx"],"mappings":";;;;;;;;AAqBA;;KAAY,mBAAA,KACN,MAAA,+BACQ,WAAA,GAAc,WAAA,IACxB,oBAAA,CAAqB,CAAA,EAAG,QAAA,CAAS,CAAA,EAAG,GAAA;EAAU,QAAA,EAAU,SAAA;AAAA;;;;;KAMhD,yBAAA,KACN,MAAA,+BACQ,WAAA,GAAc,WAAA,IACxB,sBAAA,CAAuB,cAAA,CAAe,CAAA,GAAI,QAAA,CAAS,CAAA,EAAG,GAAA;EACxD,QAAA,EAAU,SAAA;AAAA;;;;;;;;;;;;;;;;;AAJZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA;;;;;;;;;;;;iBAAgB,cAAA,KACV,MAAA,+BACQ,WAAA,GAAc,WAAA,CAAA,CAE1B,KAAA,EAAO,mBAAA,CAAoB,CAAA,EAAG,GAAA,IAAO,yBAAA,CAA0B,CAAA,EAAG,GAAA,IACjE,SAAA;;;;;;;;;;;;;;;;;;AAoCH;;;;;;;;;iBAAgB,gBAAA,KACV,MAAA,+BACQ,WAAA,GAAc,WAAA,CAAA,CAAA,GACvB,UAAA,QAAkB,SAAA,CAAU,CAAA,EAAG,GAAA"}
1
+ {"version":3,"file":"context.d.ts","names":[],"sources":["../src/context.tsx"],"mappings":";;;;;;;AAsBA;;;KAAY,mBAAA,KAAwB,MAAA,qBAClC,oBAAA,CAAmB,cAAA,CAAe,CAAA;EAChC,QAAA,EAAU,SAAA;AAAA;;;;;;KAQF,yBAAA,KAA8B,MAAA,qBACxC,sBAAA,CAAqB,cAAA,CAAe,CAAA;EAClC,QAAA,EAAU,SAAA;AAAA;;;;;;AAFd;;;;;;;;;;;;;;;;;;;AAkDA;;;;;;;;;;;;;;;;;;;;;iBAAgB,cAAA,KAAmB,MAAA,kBAAA,CACjC,KAAA,EAAO,mBAAA,CAAoB,CAAA,IAAK,yBAAA,CAA0B,CAAA,IACzD,SAAA;;;;;;;;;;;;;;;;;;;;;;iBA8Ba,gBAAA,KACV,MAAA,kBAAA,CAAA,GACD,eAAA,CAAgB,CAAA"}
package/dist/context.js CHANGED
@@ -1,15 +1,16 @@
1
1
  "use client";
2
- import { useStream } from "./stream.js";
2
+ import { useStream } from "./use-stream.js";
3
3
  import { createContext, useContext } from "react";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  //#region src/context.tsx
6
6
  const StreamContext = createContext(null);
7
7
  /**
8
- * Provides a shared `useStream` instance to all descendants via React Context.
8
+ * Provides a shared {@link useStream} instance to all descendants via
9
+ * React Context.
9
10
  *
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.
11
+ * Use `StreamProvider` when multiple components in a subtree need
12
+ * access to the same stream state (messages, loading status, errors,
13
+ * interrupts, …) without prop drilling.
13
14
  *
14
15
  * @example
15
16
  * ```tsx
@@ -34,20 +35,6 @@ const StreamContext = createContext(null);
34
35
  * </header>
35
36
  * );
36
37
  * }
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
38
  * ```
52
39
  *
53
40
  * Multiple providers can be nested for multi-agent scenarios:
@@ -71,28 +58,23 @@ function StreamProvider(props) {
71
58
  });
72
59
  }
73
60
  /**
74
- * Accesses the shared stream instance from the nearest `StreamProvider`.
75
- *
76
- * Throws if called outside of a `StreamProvider`.
61
+ * Accesses the shared stream instance from the nearest
62
+ * {@link StreamProvider}. Throws if called outside of one.
77
63
  *
78
64
  * @example
79
65
  * ```tsx
80
66
  * 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
- * });
67
+ * const { messages } = useStreamContext();
68
+ * return messages.map((m, i) => <div key={m.id ?? i}>{String(m.content)}</div>);
86
69
  * }
87
70
  * ```
88
71
  *
89
- * @example With type parameters for full type safety:
72
+ * @example With a type parameter for full type safety:
90
73
  * ```tsx
91
74
  * import type { agent } from "./agent";
92
75
  *
93
76
  * function Chat() {
94
77
  * const { toolCalls } = useStreamContext<typeof agent>();
95
- * // toolCalls are fully typed from the agent's tools
96
78
  * }
97
79
  * ```
98
80
  */
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":[],"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,gBAAgB,cAA0B,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFrD,SAAgB,eAId,OACW;CACX,MAAM,EAAE,UAAU,GAAG,YAAY;CAEjC,MAAM,SAAS,UAAkB,QAAe;AAEhD,QACE,oBAAC,cAAc,UAAf;EAAwB,OAAO;EAAS;EAAkC,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8B9E,SAAgB,mBAG0B;CACxC,MAAM,UAAU,WAAW,cAAc;AACzC,KAAI,YAAY,KACd,OAAM,IAAI,MACR,uIAED;AAEH,QAAO"}
1
+ {"version":3,"file":"context.js","names":[],"sources":["../src/context.tsx"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\n\n\"use client\";\n\nimport { createContext, useContext, type ReactNode } from \"react\";\nimport {\n useStream,\n type UseStreamOptions,\n type UseStreamReturn,\n type AgentServerOptions,\n type CustomAdapterOptions,\n} from \"./use-stream.js\";\nimport type { InferStateType } from \"@langchain/langgraph-sdk/stream\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst StreamContext = createContext<any | null>(null);\n\n/**\n * Props for {@link StreamProvider} when talking to the default\n * LangGraph Platform agent server. Mirrors {@link AgentServerOptions}\n * plus `children`.\n */\nexport type StreamProviderProps<T = Record<string, unknown>> =\n AgentServerOptions<InferStateType<T>> & {\n children: ReactNode;\n };\n\n/**\n * Props for {@link StreamProvider} when wiring a custom\n * {@link AgentServerAdapter}. Mirrors {@link CustomAdapterOptions}\n * plus `children`.\n */\nexport type StreamProviderCustomProps<T = Record<string, unknown>> =\n CustomAdapterOptions<InferStateType<T>> & {\n children: ReactNode;\n };\n\n/**\n * Provides a shared {@link useStream} instance to all descendants via\n * React Context.\n *\n * Use `StreamProvider` when multiple components in a subtree need\n * access to the same stream state (messages, loading status, errors,\n * interrupts, ) without 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 *\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<T = Record<string, unknown>>(\n props: StreamProviderProps<T> | StreamProviderCustomProps<T>\n): ReactNode {\n const { children, ...options } = props;\n const stream = useStream<T>(options as UseStreamOptions<InferStateType<T>>);\n\n return (\n <StreamContext.Provider value={stream}>{children}</StreamContext.Provider>\n );\n}\n\n/**\n * Accesses the shared stream instance from the nearest\n * {@link StreamProvider}. Throws if called outside of one.\n *\n * @example\n * ```tsx\n * function MessageList() {\n * const { messages } = useStreamContext();\n * return messages.map((m, i) => <div key={m.id ?? i}>{String(m.content)}</div>);\n * }\n * ```\n *\n * @example With a type parameter for full type safety:\n * ```tsx\n * import type { agent } from \"./agent\";\n *\n * function Chat() {\n * const { toolCalls } = useStreamContext<typeof agent>();\n * }\n * ```\n */\nexport function useStreamContext<\n T = Record<string, unknown>,\n>(): UseStreamReturn<T> {\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 as UseStreamReturn<T>;\n}\n"],"mappings":";;;;;AAeA,MAAM,gBAAgB,cAA0B,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmErD,SAAgB,eACd,OACW;CACX,MAAM,EAAE,UAAU,GAAG,YAAY;CACjC,MAAM,SAAS,UAAa,QAA+C;AAE3E,QACE,oBAAC,cAAc,UAAf;EAAwB,OAAO;EAAS;EAAkC,CAAA;;;;;;;;;;;;;;;;;;;;;;;AAyB9E,SAAgB,mBAEQ;CACtB,MAAM,UAAU,WAAW,cAAc;AACzC,KAAI,YAAY,KACd,OAAM,IAAI,MACR,uIAED;AAEH,QAAO"}
package/dist/index.cjs CHANGED
@@ -1,43 +1,34 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("./stream.custom.cjs");
3
- const require_stream = require("./stream.cjs");
2
+ const require_use_stream = require("./use-stream.cjs");
3
+ const require_use_projection = require("./use-projection.cjs");
4
+ const require_selectors = require("./selectors.cjs");
5
+ const require_use_media_url = require("./use-media-url.cjs");
6
+ const require_use_audio_player = require("./use-audio-player.cjs");
7
+ const require_use_video_player = require("./use-video-player.cjs");
4
8
  const require_suspense_stream = require("./suspense-stream.cjs");
5
9
  const require_context = require("./context.cjs");
6
- let _langchain_langgraph_sdk_ui = require("@langchain/langgraph-sdk/ui");
7
10
  let _langchain_langgraph_sdk = require("@langchain/langgraph-sdk");
8
- exports.FetchStreamTransport = _langchain_langgraph_sdk_ui.FetchStreamTransport;
9
- exports.StreamProvider = require_context.StreamProvider;
10
- Object.defineProperty(exports, "SubagentManager", {
11
+ let _langchain_langgraph_sdk_stream = require("@langchain/langgraph-sdk/stream");
12
+ Object.defineProperty(exports, "HttpAgentServerAdapter", {
11
13
  enumerable: true,
12
14
  get: function() {
13
- return _langchain_langgraph_sdk_ui.SubagentManager;
15
+ return _langchain_langgraph_sdk.HttpAgentServerAdapter;
14
16
  }
15
17
  });
16
- Object.defineProperty(exports, "calculateDepthFromNamespace", {
18
+ Object.defineProperty(exports, "MediaAssemblyError", {
17
19
  enumerable: true,
18
20
  get: function() {
19
- return _langchain_langgraph_sdk_ui.calculateDepthFromNamespace;
21
+ return _langchain_langgraph_sdk_stream.MediaAssemblyError;
20
22
  }
21
23
  });
22
- exports.createSuspenseCache = require_suspense_stream.createSuspenseCache;
24
+ exports.STREAM_CONTROLLER = require_use_stream.STREAM_CONTROLLER;
25
+ exports.StreamProvider = require_context.StreamProvider;
23
26
  Object.defineProperty(exports, "executeHeadlessTool", {
24
27
  enumerable: true,
25
28
  get: function() {
26
29
  return _langchain_langgraph_sdk.executeHeadlessTool;
27
30
  }
28
31
  });
29
- Object.defineProperty(exports, "extractParentIdFromNamespace", {
30
- enumerable: true,
31
- get: function() {
32
- return _langchain_langgraph_sdk_ui.extractParentIdFromNamespace;
33
- }
34
- });
35
- Object.defineProperty(exports, "extractToolCallIdFromNamespace", {
36
- enumerable: true,
37
- get: function() {
38
- return _langchain_langgraph_sdk_ui.extractToolCallIdFromNamespace;
39
- }
40
- });
41
32
  Object.defineProperty(exports, "filterOutHeadlessToolInterrupts", {
42
33
  enumerable: true,
43
34
  get: function() {
@@ -68,25 +59,33 @@ Object.defineProperty(exports, "headlessToolResumeCommand", {
68
59
  return _langchain_langgraph_sdk.headlessToolResumeCommand;
69
60
  }
70
61
  });
71
- exports.invalidateSuspenseCache = require_suspense_stream.invalidateSuspenseCache;
72
62
  Object.defineProperty(exports, "isHeadlessToolInterrupt", {
73
63
  enumerable: true,
74
64
  get: function() {
75
65
  return _langchain_langgraph_sdk.isHeadlessToolInterrupt;
76
66
  }
77
67
  });
78
- Object.defineProperty(exports, "isSubagentNamespace", {
79
- enumerable: true,
80
- get: function() {
81
- return _langchain_langgraph_sdk_ui.isSubagentNamespace;
82
- }
83
- });
84
68
  Object.defineProperty(exports, "parseHeadlessToolInterruptPayload", {
85
69
  enumerable: true,
86
70
  get: function() {
87
71
  return _langchain_langgraph_sdk.parseHeadlessToolInterruptPayload;
88
72
  }
89
73
  });
90
- exports.useStream = require_stream.useStream;
74
+ exports.useAudio = require_selectors.useAudio;
75
+ exports.useAudioPlayer = require_use_audio_player.useAudioPlayer;
76
+ exports.useChannel = require_selectors.useChannel;
77
+ exports.useExtension = require_selectors.useExtension;
78
+ exports.useFiles = require_selectors.useFiles;
79
+ exports.useImages = require_selectors.useImages;
80
+ exports.useMediaURL = require_use_media_url.useMediaURL;
81
+ exports.useMessageMetadata = require_selectors.useMessageMetadata;
82
+ exports.useMessages = require_selectors.useMessages;
83
+ exports.useProjection = require_use_projection.useProjection;
84
+ exports.useStream = require_use_stream.useStream;
91
85
  exports.useStreamContext = require_context.useStreamContext;
86
+ exports.useSubmissionQueue = require_selectors.useSubmissionQueue;
92
87
  exports.useSuspenseStream = require_suspense_stream.useSuspenseStream;
88
+ exports.useToolCalls = require_selectors.useToolCalls;
89
+ exports.useValues = require_selectors.useValues;
90
+ exports.useVideo = require_selectors.useVideo;
91
+ exports.useVideoPlayer = require_use_video_player.useVideoPlayer;
package/dist/index.d.cts CHANGED
@@ -1,14 +1,17 @@
1
- import { SubagentStream, SubagentStreamInterface, UseStream, UseStreamCustom, UseSuspenseStream } from "./types.cjs";
2
- import { ClassSubagentStreamInterface, useStream } from "./stream.cjs";
3
- import { SuspenseCache, createSuspenseCache, invalidateSuspenseCache, useSuspenseStream } from "./suspense-stream.cjs";
4
- import { FetchStreamTransport } from "./stream.custom.cjs";
1
+ import { AgentServerOptions, AnyStream, CustomAdapterOptions, STREAM_CONTROLLER, UseStreamOptions, UseStreamResult, UseStreamReturn, useStream } from "./use-stream.cjs";
2
+ import { useProjection } from "./use-projection.cjs";
3
+ import { SelectorTarget, SubmissionQueueEntry, SubmissionQueueSnapshot, UseSubmissionQueueReturn, useAudio, useChannel, useExtension, useFiles, useImages, useMessageMetadata, useMessages, useSubmissionQueue, useToolCalls, useValues, useVideo } from "./selectors.cjs";
4
+ import { useMediaURL } from "./use-media-url.cjs";
5
+ import { AudioPlayerHandle, PlayerStatus, UseAudioPlayerOptions, useAudioPlayer } from "./use-audio-player.cjs";
6
+ import { UseVideoPlayerOptions, VideoPlayerHandle, useVideoPlayer } from "./use-video-player.cjs";
7
+ import { UseSuspenseStreamReturn, useSuspenseStream } from "./suspense-stream.cjs";
5
8
  import { StreamProvider, StreamProviderCustomProps, StreamProviderProps, useStreamContext } from "./context.cjs";
6
9
  import { AIMessage, ToolMessage } from "@langchain/core/messages";
7
- import { AnyHeadlessToolImplementation, DefaultToolCall, DefaultToolCall as DefaultToolCall$1, FlushPendingHeadlessToolInterruptsOptions, HeadlessToolImplementation, HeadlessToolInterrupt, OnToolCallback, ToolCallFromTool, ToolCallState, ToolCallWithResult as ToolCallWithResult$1, ToolCallsFromTools, ToolEvent, executeHeadlessTool, filterOutHeadlessToolInterrupts, findHeadlessTool, flushPendingHeadlessToolInterrupts, handleHeadlessToolInterrupt, headlessToolResumeCommand, isHeadlessToolInterrupt, parseHeadlessToolInterruptPayload } from "@langchain/langgraph-sdk";
8
- import { AgentTypeConfigLike, BaseStream, BaseSubagentState, CompiledSubAgentLike, DeepAgentTypeConfigLike, DefaultSubagentStates, ExtractAgentConfig, ExtractDeepAgentConfig, ExtractSubAgentMiddleware, GetToolCallsType, InferAgentToolCalls, InferBag, InferDeepAgentSubagents, InferNodeNames, InferStateType, InferSubagentByName, InferSubagentNames, InferSubagentState, InferSubagentStates, InferToolCalls, IsAgentLike, IsDeepAgentLike, MessageMetadata, QueueEntry, QueueInterface, ResolveStreamInterface, ResolveStreamOptions, SubAgentLike, SubagentManager, SubagentStateMap, SubagentStatus, SubagentToolCall, UseAgentStream, UseAgentStreamOptions, UseDeepAgentStream, UseDeepAgentStreamOptions, UseStreamCustomOptions, UseStreamOptions, UseStreamThread, UseStreamTransport, calculateDepthFromNamespace, extractParentIdFromNamespace, extractToolCallIdFromNamespace, isSubagentNamespace } from "@langchain/langgraph-sdk/ui";
10
+ import { AnyHeadlessToolImplementation, DefaultToolCall, DefaultToolCall as DefaultToolCall$1, FlushPendingHeadlessToolInterruptsOptions, HeadlessToolImplementation, HeadlessToolInterrupt, HttpAgentServerAdapter, HttpAgentServerAdapterOptions, OnToolCallback, ToolCallFromTool, ToolCallState, ToolCallWithResult as ToolCallWithResult$1, ToolCallsFromTools, ToolEvent, executeHeadlessTool, filterOutHeadlessToolInterrupts, findHeadlessTool, flushPendingHeadlessToolInterrupts, handleHeadlessToolInterrupt, headlessToolResumeCommand, isHeadlessToolInterrupt, parseHeadlessToolInterruptPayload } from "@langchain/langgraph-sdk";
11
+ import { AgentServerAdapter, AnyMediaHandle, AssembledToolCall, AudioMedia, Channel, Event, FileMedia, ImageMedia, InferStateType, InferSubagentStates, InferToolCalls, MediaAssemblyError, MediaAssemblyErrorKind, MediaBase, MediaBlockType, MessageMetadata, MessageMetadataMap, StreamSubmitOptions, SubagentDiscoverySnapshot, SubgraphDiscoverySnapshot, ToolCallStatus, VideoMedia, WidenUpdateMessages } from "@langchain/langgraph-sdk/stream";
9
12
 
10
13
  //#region src/index.d.ts
11
14
  type ToolCallWithResult<ToolCall = DefaultToolCall$1> = ToolCallWithResult$1<ToolCall, ToolMessage, AIMessage>;
12
15
  //#endregion
13
- export { type AgentTypeConfigLike, type AnyHeadlessToolImplementation, type BaseStream, type BaseSubagentState, type ClassSubagentStreamInterface, type CompiledSubAgentLike, type DeepAgentTypeConfigLike, type DefaultSubagentStates, type DefaultToolCall, type ExtractAgentConfig, type ExtractDeepAgentConfig, type ExtractSubAgentMiddleware, FetchStreamTransport, type FlushPendingHeadlessToolInterruptsOptions, type GetToolCallsType, type HeadlessToolImplementation, type HeadlessToolInterrupt, type InferAgentToolCalls, type InferBag, type InferDeepAgentSubagents, type InferNodeNames, type InferStateType, type InferSubagentByName, type InferSubagentNames, type InferSubagentState, type InferSubagentStates, type InferToolCalls, type IsAgentLike, type IsDeepAgentLike, type MessageMetadata, type OnToolCallback, type QueueEntry, type QueueInterface, type ResolveStreamInterface, type ResolveStreamOptions, StreamProvider, type StreamProviderCustomProps, type StreamProviderProps, type SubAgentLike, SubagentManager, type SubagentStateMap, type SubagentStatus, type SubagentStream, type SubagentStreamInterface, type SubagentToolCall, type SuspenseCache, type ToolCallFromTool, type ToolCallState, ToolCallWithResult, type ToolCallsFromTools, type ToolEvent, type UseAgentStream, type UseAgentStreamOptions, type UseDeepAgentStream, type UseDeepAgentStreamOptions, type UseStream, type UseStreamCustom, type UseStreamCustomOptions, type UseStreamOptions, type UseStreamThread, type UseStreamTransport, type UseSuspenseStream, calculateDepthFromNamespace, createSuspenseCache, executeHeadlessTool, extractParentIdFromNamespace, extractToolCallIdFromNamespace, filterOutHeadlessToolInterrupts, findHeadlessTool, flushPendingHeadlessToolInterrupts, handleHeadlessToolInterrupt, headlessToolResumeCommand, invalidateSuspenseCache, isHeadlessToolInterrupt, isSubagentNamespace, parseHeadlessToolInterruptPayload, useStream, useStreamContext, useSuspenseStream };
16
+ export { type AgentServerAdapter, type AgentServerOptions, type AnyHeadlessToolImplementation, type AnyMediaHandle, type AnyStream, type AssembledToolCall, type AudioMedia, type AudioPlayerHandle, type Channel, type CustomAdapterOptions, type DefaultToolCall, type Event, type FileMedia, type FlushPendingHeadlessToolInterruptsOptions, type HeadlessToolImplementation, type HeadlessToolInterrupt, HttpAgentServerAdapter, type HttpAgentServerAdapterOptions, type ImageMedia, type InferStateType, type InferSubagentStates, type InferToolCalls, MediaAssemblyError, type MediaAssemblyErrorKind, type MediaBase, type MediaBlockType, type MessageMetadata, type MessageMetadataMap, type OnToolCallback, type PlayerStatus, STREAM_CONTROLLER, type SelectorTarget, StreamProvider, type StreamProviderCustomProps, type StreamProviderProps, type StreamSubmitOptions, type SubagentDiscoverySnapshot, type SubgraphDiscoverySnapshot, type SubmissionQueueEntry, type SubmissionQueueSnapshot, type ToolCallFromTool, type ToolCallState, type ToolCallStatus, ToolCallWithResult, type ToolCallsFromTools, type ToolEvent, type UseAudioPlayerOptions, type UseStreamOptions, type UseStreamResult, type UseStreamReturn, type UseSubmissionQueueReturn, type UseSuspenseStreamReturn, type UseVideoPlayerOptions, type VideoMedia, type VideoPlayerHandle, type WidenUpdateMessages, executeHeadlessTool, filterOutHeadlessToolInterrupts, findHeadlessTool, flushPendingHeadlessToolInterrupts, handleHeadlessToolInterrupt, headlessToolResumeCommand, isHeadlessToolInterrupt, parseHeadlessToolInterruptPayload, useAudio, useAudioPlayer, useChannel, useExtension, useFiles, useImages, useMediaURL, useMessageMetadata, useMessages, useProjection, useStream, useStreamContext, useSubmissionQueue, useSuspenseStream, useToolCalls, useValues, useVideo, useVideoPlayer };
14
17
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;KAkFY,kBAAA,YAA8B,iBAAA,IACxC,oBAAA,CAAoB,QAAA,EAAU,WAAA,EAAiB,SAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;KAkGY,kBAAA,YAA8B,iBAAA,IACxC,oBAAA,CAAoB,QAAA,EAAU,WAAA,EAAiB,SAAA"}