@vegintech/langchain-react-agent 0.0.19 → 0.0.21

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/index.d.mts CHANGED
@@ -2,6 +2,7 @@ import * as react from "react";
2
2
  import React$1, { ReactNode } from "react";
3
3
  import { ThoughtChainItemProps } from "@ant-design/x";
4
4
  import { Components } from "streamdown";
5
+ import * as _langchain_langgraph_sdk_react0 from "@langchain/langgraph-sdk/react";
5
6
  import { BaseNode, InsertPosition, NodeRender, SenderProps, SkillType, SlotConfigType } from "@ant-design/x/es/sender/interface.ts";
6
7
  import { Message } from "@langchain/langgraph-sdk";
7
8
 
@@ -246,6 +247,19 @@ interface AgentChatRef {
246
247
  clearInput: () => void;
247
248
  /** 聚焦输入框 */
248
249
  focusInput: () => void;
250
+ /**
251
+ * LangGraph Stream 实例
252
+ * 提供对底层流式连接的完整访问,包括:
253
+ * - messages: 当前消息列表
254
+ * - values: Agent 状态值
255
+ * - isLoading: 是否正在加载
256
+ * - submit: 提交消息
257
+ * - stop: 停止流
258
+ * - interrupt: 中断事件
259
+ * - client: LangGraph 客户端(可通过 client.threads.create() 创建新线程)
260
+ * 等完整功能
261
+ */
262
+ stream: ReturnType<typeof _langchain_langgraph_sdk_react0.useStream> | null;
249
263
  }
250
264
  /** Streamdown 安全过滤配置 */
251
265
  interface StreamdownSecurityConfig {
package/dist/index.mjs CHANGED
@@ -1357,25 +1357,14 @@ function injectStyles() {
1357
1357
  //#endregion
1358
1358
  //#region src/components/AgentChat.tsx
1359
1359
  injectStyles();
1360
- const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId: externalThreadId, onThreadIdChange, className = "", tools, contexts, messageConfig, inputConfig, onError, interruptConfig, agentState, onAgentStateChange, showDebug }, ref) => {
1361
- const [internalThreadId, setInternalThreadId] = useState(externalThreadId);
1362
- useEffect(() => {
1363
- setInternalThreadId(externalThreadId);
1364
- }, [externalThreadId]);
1360
+ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId, onThreadIdChange, className = "", tools, contexts, messageConfig, inputConfig, onError, interruptConfig, agentState, onAgentStateChange, showDebug }, ref) => {
1365
1361
  const { onPreSend, ...chatInputConfig } = inputConfig || {};
1366
1362
  const chatInputRef = useRef(null);
1367
- useImperativeHandle(ref, () => ({
1368
- input: chatInputRef.current,
1369
- setSkill: (skill) => chatInputRef.current?.setSkill?.(skill),
1370
- clearInput: () => chatInputRef.current?.clear?.(),
1371
- focusInput: () => chatInputRef.current?.focus?.()
1372
- }));
1373
1363
  const stream = useStream({
1374
1364
  apiUrl,
1375
1365
  assistantId,
1376
- threadId: internalThreadId,
1366
+ threadId,
1377
1367
  onThreadId: (newThreadId) => {
1378
- setInternalThreadId(newThreadId);
1379
1368
  onThreadIdChange?.(newThreadId);
1380
1369
  },
1381
1370
  defaultHeaders: headers,
@@ -1385,6 +1374,13 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId: external
1385
1374
  onError?.(err);
1386
1375
  }
1387
1376
  });
1377
+ useImperativeHandle(ref, () => ({
1378
+ input: chatInputRef.current,
1379
+ setSkill: (skill) => chatInputRef.current?.setSkill?.(skill),
1380
+ clearInput: () => chatInputRef.current?.clear?.(),
1381
+ focusInput: () => chatInputRef.current?.focus?.(),
1382
+ stream
1383
+ }));
1388
1384
  useEffect(() => {
1389
1385
  if (stream.values && onAgentStateChange) onAgentStateChange(stream.values);
1390
1386
  }, [stream.values, onAgentStateChange]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vegintech/langchain-react-agent",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "LangChain Agent UI component library for React",
5
5
  "license": "MIT",
6
6
  "files": [