@vegintech/langchain-react-agent 0.0.25 → 0.0.27
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 +63 -27
- package/dist/index.mjs +816 -819
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,29 +1,12 @@
|
|
|
1
1
|
import * as react from "react";
|
|
2
2
|
import React$1, { ReactNode } from "react";
|
|
3
3
|
import { ThoughtChainItemProps } from "@ant-design/x";
|
|
4
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
5
|
import { Components } from "streamdown";
|
|
5
6
|
import { UseStreamOptions, useStream } from "@langchain/langgraph-sdk/react";
|
|
6
7
|
import { BaseNode, InsertPosition, NodeRender, SenderProps, SkillType, SlotConfigType } from "@ant-design/x/es/sender/interface.ts";
|
|
7
8
|
import { Message } from "@langchain/langgraph-sdk";
|
|
8
9
|
|
|
9
|
-
//#region src/hooks/useAgentStream.d.ts
|
|
10
|
-
type AgentStreamOptions = UseStreamOptions;
|
|
11
|
-
type AgentStream = ReturnType<typeof useStream>;
|
|
12
|
-
/**
|
|
13
|
-
* 包装 useStream hook,为 AgentChat 提供统一的 stream 实例创建方式
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```tsx
|
|
17
|
-
* const stream = useAgentStream({
|
|
18
|
-
* apiUrl: "http://localhost:2026",
|
|
19
|
-
* assistantId: "demo",
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* <AgentChat stream={stream} />
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
declare function useAgentStream(options: AgentStreamOptions): AgentStream;
|
|
26
|
-
//#endregion
|
|
27
10
|
//#region src/types.d.ts
|
|
28
11
|
/** ToolCard 组件 Props */
|
|
29
12
|
interface ToolCardProps extends Omit<ThoughtChainItemProps, "children"> {
|
|
@@ -53,8 +36,11 @@ interface InterruptConfig {
|
|
|
53
36
|
}
|
|
54
37
|
/** InterruptManager Hook 的 Props */
|
|
55
38
|
interface InterruptManagerProps {
|
|
56
|
-
/** 当前 interrupt 事件 */
|
|
57
|
-
interrupt:
|
|
39
|
+
/** 当前 interrupt 事件 - 与 useStream 返回的 Interrupt 类型兼容 */
|
|
40
|
+
interrupt: {
|
|
41
|
+
value: unknown;
|
|
42
|
+
id?: string;
|
|
43
|
+
} | null | undefined;
|
|
58
44
|
/** Interrupt 处理配置 */
|
|
59
45
|
config?: InterruptConfig;
|
|
60
46
|
/** 提交回调 */
|
|
@@ -64,7 +50,7 @@ interface InterruptManagerProps {
|
|
|
64
50
|
command?: {
|
|
65
51
|
resume: unknown;
|
|
66
52
|
};
|
|
67
|
-
}) => Promise<void> | void;
|
|
53
|
+
} | Record<string, unknown>) => Promise<void> | void;
|
|
68
54
|
}
|
|
69
55
|
/** Context Item,用于传递上下文信息 */
|
|
70
56
|
interface ContextItem {
|
|
@@ -237,12 +223,34 @@ interface InputConfig extends SenderCustomizationProps {
|
|
|
237
223
|
/** 输入框占位符文本 */
|
|
238
224
|
placeholder?: string;
|
|
239
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* AgentChat 需要的 Stream 属性
|
|
228
|
+
* 由外部通过 useStream/useAgentStream hook 创建并传入
|
|
229
|
+
*/
|
|
230
|
+
interface AgentChatStreamProps {
|
|
231
|
+
/** 消息列表 */
|
|
232
|
+
messages: Message[];
|
|
233
|
+
/** 是否正在加载 */
|
|
234
|
+
isLoading: boolean;
|
|
235
|
+
/** 提交消息 */
|
|
236
|
+
submit: (values: {
|
|
237
|
+
[x: string]: unknown;
|
|
238
|
+
} | null | undefined, options?: {
|
|
239
|
+
command?: {
|
|
240
|
+
resume: unknown;
|
|
241
|
+
};
|
|
242
|
+
} | Record<string, unknown>) => Promise<void> | void;
|
|
243
|
+
/** 中断事件 - 与 useStream 返回的 Interrupt 类型兼容 */
|
|
244
|
+
interrupt: unknown;
|
|
245
|
+
/** 停止流 */
|
|
246
|
+
stop: () => Promise<void> | void;
|
|
247
|
+
}
|
|
240
248
|
interface AgentChatProps {
|
|
241
249
|
/**
|
|
242
|
-
* Stream
|
|
243
|
-
* 由外部通过 useAgentStream hook
|
|
250
|
+
* Stream 相关属性
|
|
251
|
+
* 由外部通过 useAgentStream/useStream hook 创建并解构传入
|
|
244
252
|
*/
|
|
245
|
-
stream:
|
|
253
|
+
stream: AgentChatStreamProps;
|
|
246
254
|
className?: string;
|
|
247
255
|
tools?: ToolDefinition<any>[];
|
|
248
256
|
contexts?: ContextItem[];
|
|
@@ -251,8 +259,6 @@ interface AgentChatProps {
|
|
|
251
259
|
interruptConfig?: InterruptConfig;
|
|
252
260
|
/** Agent 状态值 */
|
|
253
261
|
agentState?: Record<string, unknown>;
|
|
254
|
-
/** 是否显示调试面板,默认 false。仅在开发环境生效 */
|
|
255
|
-
showDebug?: boolean;
|
|
256
262
|
/** 欢迎组件,当消息列表为空且非加载状态时显示 */
|
|
257
263
|
welcome?: ReactNode;
|
|
258
264
|
}
|
|
@@ -311,4 +317,34 @@ interface MessageContentRendererProps {
|
|
|
311
317
|
/** 消息内容渲染组件 - 支持字符串和多模态内容块 */
|
|
312
318
|
declare const MessageContentRenderer: React$1.FC<MessageContentRendererProps>;
|
|
313
319
|
//#endregion
|
|
314
|
-
|
|
320
|
+
//#region src/components/DebugPanel.d.ts
|
|
321
|
+
interface DebugPanelProps {
|
|
322
|
+
/** Stream 状态数据(包含 messages) */
|
|
323
|
+
streamState: Record<string, unknown>;
|
|
324
|
+
/** 是否显示调试面板 */
|
|
325
|
+
visible?: boolean;
|
|
326
|
+
}
|
|
327
|
+
declare function DebugPanel({
|
|
328
|
+
streamState,
|
|
329
|
+
visible
|
|
330
|
+
}: DebugPanelProps): react_jsx_runtime0.JSX.Element | null;
|
|
331
|
+
//#endregion
|
|
332
|
+
//#region src/hooks/useAgentStream.d.ts
|
|
333
|
+
type AgentStreamOptions = UseStreamOptions;
|
|
334
|
+
type AgentStream = ReturnType<typeof useStream>;
|
|
335
|
+
/**
|
|
336
|
+
* 包装 useStream hook,为 AgentChat 提供统一的 stream 实例创建方式
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* ```tsx
|
|
340
|
+
* const stream = useAgentStream({
|
|
341
|
+
* apiUrl: "http://localhost:2026",
|
|
342
|
+
* assistantId: "demo",
|
|
343
|
+
* });
|
|
344
|
+
*
|
|
345
|
+
* <AgentChat stream={stream} />
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
declare function useAgentStream(options: AgentStreamOptions): AgentStream;
|
|
349
|
+
//#endregion
|
|
350
|
+
export { AgentChat, type AgentChatInputRef, type AgentChatProps, type AgentChatRef, type AgentChatStreamProps, type AgentStream, type AgentStreamOptions, type BackendTool, type ChatMessage, type ContextItem, DebugPanel, type DebugPanelProps, type EmptyStateConfig, type FrontendTool, type InputConfig, type InterruptConfig, type InterruptEvent, type InterruptManagerProps, type InterruptRenderProps, type MessageConfig, type MessageContent, type MessageContentBlock, MessageContentRenderer, type MessageContentRendererProps, type MessageType, type SenderCustomizationProps, type SenderSlotConfig, type SenderSubmitParams, type ToolCallInput, ToolCard, type ToolCardProps, type ToolDefinition, type ToolExecutionRecord, type ToolExecutionStatus, type ToolParameterSchema, type ToolRenderProps, useAgentStream };
|