veryfront 0.0.70 → 0.0.71

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.
@@ -337,7 +337,7 @@ function formatStatus(status) {
337
337
  // src/ai/react/primitives/tool-primitives.tsx
338
338
  import * as React5 from "react";
339
339
  import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
340
- var ToolInvocation = React5.forwardRef(({ className, name, args, status, children, ...props }, ref) => {
340
+ var ToolInvocation = React5.forwardRef(({ className, name, input, output: _output, state, errorText, dynamic, children, ...props }, ref) => {
341
341
  return /* @__PURE__ */ jsxs2(
342
342
  "div",
343
343
  {
@@ -345,18 +345,21 @@ var ToolInvocation = React5.forwardRef(({ className, name, args, status, childre
345
345
  className,
346
346
  "data-tool-invocation": "",
347
347
  "data-tool-name": name,
348
- "data-status": status,
348
+ "data-state": state,
349
+ "data-dynamic": dynamic || void 0,
349
350
  ...props,
350
351
  children: [
351
352
  /* @__PURE__ */ jsxs2("div", { "data-tool-header": "", children: [
352
353
  /* @__PURE__ */ jsx5("span", { "data-tool-name": "", children: name }),
353
- status && /* @__PURE__ */ jsxs2("span", { "data-tool-status": "", children: [
354
+ state && /* @__PURE__ */ jsxs2("span", { "data-tool-state": "", children: [
354
355
  "(",
355
- status,
356
+ state,
356
357
  ")"
357
- ] })
358
+ ] }),
359
+ dynamic && /* @__PURE__ */ jsx5("span", { "data-tool-dynamic": "", children: "[dynamic]" })
358
360
  ] }),
359
- args && /* @__PURE__ */ jsx5("div", { "data-tool-args": "", children: /* @__PURE__ */ jsx5("pre", { children: JSON.stringify(args, null, 2) }) }),
361
+ input && /* @__PURE__ */ jsx5("div", { "data-tool-input": "", children: /* @__PURE__ */ jsx5("pre", { children: JSON.stringify(input, null, 2) }) }),
362
+ errorText && /* @__PURE__ */ jsx5("div", { "data-tool-error": "", children: errorText }),
360
363
  children
361
364
  ]
362
365
  }
@@ -364,8 +367,8 @@ var ToolInvocation = React5.forwardRef(({ className, name, args, status, childre
364
367
  });
365
368
  ToolInvocation.displayName = "ToolInvocation";
366
369
  var ToolResult = React5.forwardRef(
367
- ({ className, result, renderResult, ...props }, ref) => {
368
- const content = renderResult ? renderResult(result) : JSON.stringify(result, null, 2);
370
+ ({ className, output, renderOutput, ...props }, ref) => {
371
+ const content = renderOutput ? renderOutput(output) : JSON.stringify(output, null, 2);
369
372
  return /* @__PURE__ */ jsx5(
370
373
  "div",
371
374
  {
@@ -380,7 +383,7 @@ var ToolResult = React5.forwardRef(
380
383
  );
381
384
  ToolResult.displayName = "ToolResult";
382
385
  var ToolList = React5.forwardRef(
383
- ({ className, toolCalls, renderTool, ...props }, ref) => {
386
+ ({ className, tools, renderTool, ...props }, ref) => {
384
387
  return /* @__PURE__ */ jsx5(
385
388
  "div",
386
389
  {
@@ -388,16 +391,18 @@ var ToolList = React5.forwardRef(
388
391
  className,
389
392
  "data-tool-list": "",
390
393
  ...props,
391
- children: toolCalls.map(
392
- (tool) => renderTool ? /* @__PURE__ */ jsx5(React5.Fragment, { children: renderTool(tool) }, tool.id) : /* @__PURE__ */ jsx5(
394
+ children: tools.map(
395
+ (tool) => renderTool ? /* @__PURE__ */ jsx5(React5.Fragment, { children: renderTool(tool) }, tool.toolCallId) : /* @__PURE__ */ jsx5(
393
396
  ToolInvocation,
394
397
  {
395
- name: tool.name,
396
- args: tool.args,
397
- status: tool.status,
398
- children: tool.result !== void 0 && /* @__PURE__ */ jsx5(ToolResult, { result: tool.result })
398
+ name: tool.toolName,
399
+ input: tool.input,
400
+ state: tool.state,
401
+ errorText: tool.errorText,
402
+ dynamic: tool.type === "dynamic-tool",
403
+ children: tool.output !== void 0 && /* @__PURE__ */ jsx5(ToolResult, { output: tool.output })
399
404
  },
400
- tool.id
405
+ tool.toolCallId
401
406
  )
402
407
  )
403
408
  }
@@ -731,6 +736,11 @@ import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
731
736
  function getTextContent(message) {
732
737
  return message.parts.filter((p) => p.type === "text").map((p) => p.text).join("");
733
738
  }
739
+ function getToolParts(message) {
740
+ return message.parts.filter(
741
+ (p) => p.type === "tool-call" || p.type === "dynamic-tool"
742
+ );
743
+ }
734
744
  var Chat = React8.forwardRef(
735
745
  ({
736
746
  messages,
@@ -750,7 +760,7 @@ var Chat = React8.forwardRef(
750
760
  className,
751
761
  theme: userTheme,
752
762
  renderMessage,
753
- renderTool: _renderTool,
763
+ renderTool,
754
764
  multiline = false
755
765
  }, ref) => {
756
766
  const theme = mergeThemes(defaultChatTheme, userTheme);
@@ -786,6 +796,7 @@ var Chat = React8.forwardRef(
786
796
  /* @__PURE__ */ jsx7(MessageList, { className: "flex-1 min-h-0 overflow-y-auto", children: /* @__PURE__ */ jsxs4("div", { className: "max-w-2xl mx-auto px-4 py-4 space-y-2", children: [
787
797
  messages.map((msg) => {
788
798
  const content = getTextContent(msg);
799
+ const toolParts = getToolParts(msg);
789
800
  return renderMessage ? /* @__PURE__ */ jsx7(React8.Fragment, { children: renderMessage(msg) }, msg.id) : /* @__PURE__ */ jsx7(
790
801
  MessageItem,
791
802
  {
@@ -794,7 +805,30 @@ var Chat = React8.forwardRef(
794
805
  "flex",
795
806
  msg.role === "user" ? "justify-end" : "justify-start"
796
807
  ),
797
- children: /* @__PURE__ */ jsx7("div", { className: theme.message?.[msg.role] || theme.message?.assistant, children: msg.role === "user" ? /* @__PURE__ */ jsx7("p", { className: "whitespace-pre-wrap text-[15px] leading-relaxed", children: content }) : /* @__PURE__ */ jsx7(Markdown, { className: "text-[15px] leading-relaxed", children: content }) })
808
+ children: /* @__PURE__ */ jsxs4("div", { className: theme.message?.[msg.role] || theme.message?.assistant, children: [
809
+ msg.role === "user" ? /* @__PURE__ */ jsx7("p", { className: "whitespace-pre-wrap text-[15px] leading-relaxed", children: content }) : /* @__PURE__ */ jsx7(Markdown, { className: "text-[15px] leading-relaxed", children: content }),
810
+ toolParts.length > 0 && /* @__PURE__ */ jsx7("div", { className: "mt-2 space-y-1", children: toolParts.map(
811
+ (tool) => renderTool ? /* @__PURE__ */ jsx7(React8.Fragment, { children: renderTool(tool) }, tool.toolCallId) : /* @__PURE__ */ jsxs4(
812
+ "div",
813
+ {
814
+ className: cn(
815
+ "text-xs rounded px-2 py-1",
816
+ tool.type === "dynamic-tool" ? "bg-blue-50 dark:bg-blue-900/20" : "bg-neutral-100 dark:bg-neutral-800"
817
+ ),
818
+ children: [
819
+ /* @__PURE__ */ jsx7("span", { className: "font-mono", children: tool.toolName }),
820
+ /* @__PURE__ */ jsxs4("span", { className: "ml-2 opacity-70", children: [
821
+ "[",
822
+ tool.state,
823
+ "]"
824
+ ] }),
825
+ tool.errorText && /* @__PURE__ */ jsx7("div", { className: "text-red-600 dark:text-red-400 mt-1", children: tool.errorText })
826
+ ]
827
+ },
828
+ tool.toolCallId
829
+ )
830
+ ) })
831
+ ] })
798
832
  },
799
833
  msg.id
800
834
  );
@@ -992,8 +1026,20 @@ function getStatusColor(status) {
992
1026
  // src/ai/react/components/message.tsx
993
1027
  import * as React10 from "react";
994
1028
  import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
1029
+ function getTextFromParts(parts) {
1030
+ return parts.filter((p) => p.type === "text").map((p) => p.text).join("");
1031
+ }
995
1032
  var Message = React10.forwardRef(
996
- ({ message, className, theme: userTheme, showRole = false, showTimestamp = false }, ref) => {
1033
+ ({
1034
+ message,
1035
+ className,
1036
+ theme: userTheme,
1037
+ showRole = false,
1038
+ showTimestamp = false,
1039
+ renderToolCall,
1040
+ renderDynamicTool,
1041
+ renderReasoning
1042
+ }, ref) => {
997
1043
  const theme = mergeThemes(defaultChatTheme, userTheme);
998
1044
  return /* @__PURE__ */ jsx9(
999
1045
  MessageItem,
@@ -1007,16 +1053,56 @@ var Message = React10.forwardRef(
1007
1053
  ),
1008
1054
  children: /* @__PURE__ */ jsxs6("div", { className: theme.message?.[message.role] || theme.message?.assistant, children: [
1009
1055
  showRole && /* @__PURE__ */ jsx9(MessageRole, { className: "block text-xs font-semibold mb-1 opacity-75 uppercase", children: message.role }),
1010
- /* @__PURE__ */ jsx9(MessageContent, { children: message.content }),
1011
- showTimestamp && message.timestamp && /* @__PURE__ */ jsx9("div", { className: "text-xs opacity-60 mt-1", children: new Date(message.timestamp).toLocaleTimeString() })
1056
+ message.parts.map((part, index) => {
1057
+ const key = `${message.id}-part-${index}`;
1058
+ switch (part.type) {
1059
+ case "text":
1060
+ return /* @__PURE__ */ jsx9(MessageContent, { children: part.text }, key);
1061
+ case "reasoning":
1062
+ if (renderReasoning) {
1063
+ return /* @__PURE__ */ jsx9(React10.Fragment, { children: renderReasoning(part) }, key);
1064
+ }
1065
+ return /* @__PURE__ */ jsx9("div", { className: "text-sm italic opacity-70 my-2 pl-2 border-l-2", children: part.text }, key);
1066
+ case "tool-call":
1067
+ if (renderToolCall) {
1068
+ return /* @__PURE__ */ jsx9(React10.Fragment, { children: renderToolCall(part) }, key);
1069
+ }
1070
+ return /* @__PURE__ */ jsxs6("div", { className: "text-xs bg-gray-100 rounded p-2 my-2", children: [
1071
+ /* @__PURE__ */ jsx9("span", { className: "font-mono", children: part.toolName }),
1072
+ /* @__PURE__ */ jsxs6("span", { className: "ml-2 text-gray-500", children: [
1073
+ "[",
1074
+ part.state,
1075
+ "]"
1076
+ ] }),
1077
+ part.errorText && /* @__PURE__ */ jsx9("div", { className: "text-red-600 mt-1", children: part.errorText })
1078
+ ] }, key);
1079
+ case "dynamic-tool":
1080
+ if (renderDynamicTool) {
1081
+ return /* @__PURE__ */ jsx9(React10.Fragment, { children: renderDynamicTool(part) }, key);
1082
+ }
1083
+ return /* @__PURE__ */ jsxs6("div", { className: "text-xs bg-blue-50 rounded p-2 my-2", children: [
1084
+ /* @__PURE__ */ jsx9("span", { className: "font-mono", children: part.toolName }),
1085
+ /* @__PURE__ */ jsxs6("span", { className: "ml-2 text-blue-500", children: [
1086
+ "[dynamic: ",
1087
+ part.state,
1088
+ "]"
1089
+ ] }),
1090
+ part.errorText && /* @__PURE__ */ jsx9("div", { className: "text-red-600 mt-1", children: part.errorText })
1091
+ ] }, key);
1092
+ default:
1093
+ return null;
1094
+ }
1095
+ }),
1096
+ showTimestamp && message.createdAt && /* @__PURE__ */ jsx9("div", { className: "text-xs opacity-60 mt-1", children: new Date(message.createdAt).toLocaleTimeString() })
1012
1097
  ] })
1013
1098
  }
1014
1099
  );
1015
1100
  }
1016
1101
  );
1017
1102
  Message.displayName = "Message";
1018
- var StreamingMessage = React10.forwardRef(({ content, showCursor = true, className, theme: userTheme }, ref) => {
1103
+ var StreamingMessage = React10.forwardRef(({ parts, showCursor = true, className, theme: userTheme }, ref) => {
1019
1104
  const theme = mergeThemes(defaultChatTheme, userTheme);
1105
+ const textContent = getTextFromParts(parts);
1020
1106
  return /* @__PURE__ */ jsx9(
1021
1107
  MessageItem,
1022
1108
  {
@@ -1024,7 +1110,7 @@ var StreamingMessage = React10.forwardRef(({ content, showCursor = true, classNa
1024
1110
  role: "assistant",
1025
1111
  className: cn("flex justify-start", className),
1026
1112
  children: /* @__PURE__ */ jsx9("div", { className: theme.message?.assistant, children: /* @__PURE__ */ jsxs6(MessageContent, { children: [
1027
- content,
1113
+ textContent,
1028
1114
  showCursor && /* @__PURE__ */ jsx9("span", { className: "inline-block w-1 h-4 bg-current ml-1 animate-pulse" })
1029
1115
  ] }) })
1030
1116
  }