@vegintech/langchain-react-agent 0.0.22 → 0.0.24

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
@@ -211,8 +211,6 @@ interface MessageConfig {
211
211
  literalTagContent?: string[];
212
212
  /** Loading 动画颜色,支持 CSS 颜色值 */
213
213
  loadingColor?: string;
214
- /** 空状态配置 */
215
- emptyState?: EmptyStateConfig;
216
214
  }
217
215
  /** 输入框配置 */
218
216
  interface InputConfig extends SenderCustomizationProps {
@@ -240,6 +238,8 @@ interface AgentChatProps {
240
238
  onAgentStateChange?: (state: Record<string, unknown>) => void;
241
239
  /** 是否显示调试面板,默认 false。仅在开发环境生效 */
242
240
  showDebug?: boolean;
241
+ /** 欢迎组件,当消息列表为空且非加载状态时显示 */
242
+ welcome?: ReactNode;
243
243
  }
244
244
  /** AgentChat 组件对外暴露的方法 */
245
245
  interface AgentChatRef {
@@ -288,12 +288,6 @@ interface MessageListProps {
288
288
  loadingColor?: string;
289
289
  /** Interrupt 渲染函数,用于在消息列表中渲染中断 UI */
290
290
  interruptRender?: () => ReactNode;
291
- /** 空状态配置 */
292
- emptyState?: {
293
- /** 空状态标题 */title?: string; /** 空状态描述 */
294
- description?: string; /** 自定义渲染 */
295
- render?: () => ReactNode;
296
- };
297
291
  }
298
292
  //#endregion
299
293
  //#region src/components/AgentChat.d.ts
package/dist/index.mjs CHANGED
@@ -314,7 +314,7 @@ const renderMessageContent = (message, isLastMessage, isLoading, tools, toolExec
314
314
  children: /* @__PURE__ */ jsx(ReasoningContent, { content: message.reasoningContent })
315
315
  }),
316
316
  !isContentEmpty && /* @__PURE__ */ jsx("div", {
317
- style: { marginTop: message.reasoningContent ? "8px" : "3px" },
317
+ style: { marginTop: message.type == "human" ? "0px" : "8px" },
318
318
  children: /* @__PURE__ */ jsx(MessageContentRenderer, {
319
319
  content: message.content,
320
320
  components,
@@ -378,7 +378,7 @@ const roleConfig = {
378
378
  }
379
379
  }
380
380
  };
381
- const MessageList = ({ messages, isLoading = false, className = "", tools, toolExecutions, components, securityConfig, loadingColor, interruptRender, emptyState }) => {
381
+ const MessageList = ({ messages, isLoading = false, className = "", tools, toolExecutions, components, securityConfig, loadingColor, interruptRender }) => {
382
382
  const reasoningCacheRef = useRef(/* @__PURE__ */ new Map());
383
383
  const processedMessages = useMemo(() => {
384
384
  const cache = reasoningCacheRef.current;
@@ -444,19 +444,10 @@ const MessageList = ({ messages, isLoading = false, className = "", tools, toolE
444
444
  placement: "start",
445
445
  style: { paddingBlock: 0 }
446
446
  }] : items;
447
- if (allItems.length === 0) {
448
- if (emptyState?.render) return /* @__PURE__ */ jsx("div", {
449
- className: `agent-message-list empty ${className}`,
450
- children: emptyState.render()
451
- });
452
- return /* @__PURE__ */ jsx("div", {
453
- className: `agent-message-list empty ${className}`,
454
- children: /* @__PURE__ */ jsxs("div", {
455
- className: "agent-message-empty",
456
- children: [emptyState?.title && /* @__PURE__ */ jsx("h4", { children: emptyState.title }), emptyState?.description ? /* @__PURE__ */ jsx("p", { children: emptyState.description }) : /* @__PURE__ */ jsx("p", { children: "开始对话吧" })]
457
- })
458
- });
459
- }
447
+ if (allItems.length === 0) return /* @__PURE__ */ jsx("div", {
448
+ className: `agent-message-list empty ${className}`,
449
+ children: /* @__PURE__ */ jsx("div", { className: "agent-message-empty" })
450
+ });
460
451
  return /* @__PURE__ */ jsx(Bubble.List, {
461
452
  className: `agent-message-list ${className}`,
462
453
  items: allItems,
@@ -1358,7 +1349,7 @@ function injectStyles() {
1358
1349
  //#endregion
1359
1350
  //#region src/components/AgentChat.tsx
1360
1351
  injectStyles();
1361
- const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId, onThreadIdChange, className = "", tools, contexts, messageConfig, inputConfig, onError, interruptConfig, agentState, onAgentStateChange, showDebug }, ref) => {
1352
+ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId, onThreadIdChange, className = "", tools, contexts, messageConfig, inputConfig, onError, interruptConfig, agentState, onAgentStateChange, showDebug, welcome }, ref) => {
1362
1353
  const { onPreSend, ...chatInputConfig } = inputConfig || {};
1363
1354
  const chatInputRef = useRef(null);
1364
1355
  const stream = useStream({
@@ -1409,12 +1400,15 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId, onThread
1409
1400
  return next;
1410
1401
  });
1411
1402
  }, []);
1403
+ const frontendTools = useMemo(() => {
1404
+ return tools?.filter(isFrontendTool) || [];
1405
+ }, [tools]);
1412
1406
  const submitToStream = useCallback(async (submitMessages) => {
1413
1407
  await stream.submit({
1414
1408
  ...agentState,
1415
1409
  messages: submitMessages,
1416
1410
  agentkit: {
1417
- actions: tools,
1411
+ actions: frontendTools,
1418
1412
  context: contexts
1419
1413
  }
1420
1414
  }, {
@@ -1431,7 +1425,7 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId, onThread
1431
1425
  });
1432
1426
  }, [
1433
1427
  stream,
1434
- tools,
1428
+ frontendTools,
1435
1429
  contexts,
1436
1430
  agentState
1437
1431
  ]);
@@ -1472,13 +1466,16 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId, onThread
1472
1466
  onToolResultsBatch: handleToolResultsBatch,
1473
1467
  completedToolResults: toolResults
1474
1468
  });
1469
+ const shouldRenderWelcome = messages.length === 0 && !isLoading && welcome;
1475
1470
  return /* @__PURE__ */ jsxs("div", {
1476
1471
  className: `agent-chat-container ${className}`,
1477
1472
  children: [
1478
- /* @__PURE__ */ jsx(MessageList, {
1473
+ shouldRenderWelcome ? /* @__PURE__ */ jsx("div", {
1474
+ className: "agent-message-list agent-chat-welcome",
1475
+ children: welcome
1476
+ }) : /* @__PURE__ */ jsx(MessageList, {
1479
1477
  messages,
1480
1478
  isLoading: stream.isLoading,
1481
- className: "agent-chat-messages",
1482
1479
  tools,
1483
1480
  toolExecutions,
1484
1481
  components: messageConfig?.components,
@@ -1487,8 +1484,7 @@ const AgentChat = forwardRef(({ apiUrl, assistantId, headers, threadId, onThread
1487
1484
  literalTagContent: messageConfig?.literalTagContent
1488
1485
  },
1489
1486
  loadingColor: messageConfig?.loadingColor,
1490
- interruptRender,
1491
- emptyState: messageConfig?.emptyState
1487
+ interruptRender
1492
1488
  }),
1493
1489
  /* @__PURE__ */ jsx(ChatInput, {
1494
1490
  ref: chatInputRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vegintech/langchain-react-agent",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "LangChain Agent UI component library for React",
5
5
  "license": "MIT",
6
6
  "files": [