@slipstream-ui/ai 0.5.0 → 0.6.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 (47) hide show
  1. package/dist/index.d.mts +19 -4
  2. package/dist/index.d.ts +19 -4
  3. package/dist/index.js +12 -7
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +12 -7
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/manifests/attachment.manifest.json +35 -8
  8. package/dist/manifests/branch.manifest.json +1 -1
  9. package/dist/manifests/chain-thought.manifest.json +1 -1
  10. package/dist/manifests/code-block.manifest.json +1 -1
  11. package/dist/manifests/command-palette.manifest.json +22 -1
  12. package/dist/manifests/confirmation.manifest.json +1 -1
  13. package/dist/manifests/conversation.manifest.json +1 -1
  14. package/dist/manifests/inline-citation.manifest.json +1 -1
  15. package/dist/manifests/message-actions.manifest.json +59 -11
  16. package/dist/manifests/message.manifest.json +13 -1
  17. package/dist/manifests/prompt-input.manifest.json +2 -2
  18. package/dist/manifests/reasoning.manifest.json +13 -1
  19. package/dist/manifests/response.manifest.json +1 -1
  20. package/dist/manifests/source.manifest.json +2 -2
  21. package/dist/manifests/streaming-indicator.manifest.json +1 -1
  22. package/dist/manifests/suggestions.manifest.json +2 -2
  23. package/dist/manifests/tool-call.manifest.json +1 -1
  24. package/package.json +10 -10
  25. package/src/components/command-palette/CommandPalette.test.tsx +21 -0
  26. package/src/components/command-palette/CommandPalette.tsx +12 -3
  27. package/src/components/message/Message.test.tsx +15 -0
  28. package/src/components/message/Message.tsx +9 -1
  29. package/src/components/reasoning/Reasoning.test.tsx +15 -0
  30. package/src/components/reasoning/Reasoning.tsx +8 -2
  31. package/src/manifests/attachment.manifest.json +35 -8
  32. package/src/manifests/branch.manifest.json +1 -1
  33. package/src/manifests/chain-thought.manifest.json +1 -1
  34. package/src/manifests/code-block.manifest.json +1 -1
  35. package/src/manifests/command-palette.manifest.json +22 -1
  36. package/src/manifests/confirmation.manifest.json +1 -1
  37. package/src/manifests/conversation.manifest.json +1 -1
  38. package/src/manifests/inline-citation.manifest.json +1 -1
  39. package/src/manifests/message-actions.manifest.json +59 -11
  40. package/src/manifests/message.manifest.json +13 -1
  41. package/src/manifests/prompt-input.manifest.json +2 -2
  42. package/src/manifests/reasoning.manifest.json +13 -1
  43. package/src/manifests/response.manifest.json +1 -1
  44. package/src/manifests/source.manifest.json +2 -2
  45. package/src/manifests/streaming-indicator.manifest.json +1 -1
  46. package/src/manifests/suggestions.manifest.json +2 -2
  47. package/src/manifests/tool-call.manifest.json +1 -1
package/dist/index.d.mts CHANGED
@@ -45,6 +45,10 @@ type MessageProps = {
45
45
  userLabel?: string;
46
46
  /** Display name for the assistant role; override for localization. */
47
47
  assistantLabel?: string;
48
+ /** Formats the message timestamp; defaults to the runtime's toLocaleTimeString(). */
49
+ formatTime?: (date: Date) => string;
50
+ /** BCP-47 locale used by the default timestamp formatter. */
51
+ locale?: string;
48
52
  /**
49
53
  * Custom content renderer, e.g. for markdown/code blocks.
50
54
  * When provided, it fully replaces the default plain-text rendering.
@@ -77,7 +81,7 @@ type MessageProps = {
77
81
  * (and timestamp re-formatting) for every other message in the transcript.
78
82
  * Callback props must be referentially stable for memo to help.
79
83
  */
80
- declare const MemoizedMessage: React.MemoExoticComponent<React.ForwardRefExoticComponent<MessageProps & React.RefAttributes<HTMLDivElement>>>;
84
+ declare const MemoizedMessage: React.NamedExoticComponent<MessageProps & React.RefAttributes<HTMLDivElement>>;
81
85
 
82
86
  /** User sentiment for an AI response. */
83
87
  type FeedbackRating = 'up' | 'down';
@@ -357,7 +361,7 @@ type PromptInputProps = {
357
361
  };
358
362
  declare const PromptInputRoot: React.ForwardRefExoticComponent<PromptInputProps & React.RefAttributes<HTMLTextAreaElement>>;
359
363
  /** Auto-resizing textarea bound to the prompt state. Accepts standard textarea props. */
360
- declare const PromptInputTextarea: React.ForwardRefExoticComponent<Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, "onChange" | "value"> & React.RefAttributes<HTMLTextAreaElement>>;
364
+ declare const PromptInputTextarea: React.ForwardRefExoticComponent<Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, "value" | "onChange"> & React.RefAttributes<HTMLTextAreaElement>>;
361
365
  /** Status-aware submit control: send / stop / error icons chosen automatically. */
362
366
  declare const PromptInputSubmit: React.ForwardRefExoticComponent<{
363
367
  className?: string;
@@ -409,6 +413,10 @@ type ReasoningProps = {
409
413
  duration?: number | string;
410
414
  /** Marks reasoning as still arriving: animated header state. */
411
415
  isStreaming?: boolean;
416
+ /** Formats step timestamps; defaults to the runtime's toLocaleTimeString(). */
417
+ formatTime?: (date: Date) => string;
418
+ /** BCP-47 locale used by the default timestamp formatter. */
419
+ locale?: string;
412
420
  /** Localized header, count and step labels. */
413
421
  labels?: {
414
422
  title?: string;
@@ -527,13 +535,19 @@ type CommandPaletteProps = {
527
535
  /** Shown while async commands load. */
528
536
  loadingText?: string;
529
537
  placeholder?: string;
538
+ /** Accessible label for the combobox. Default 'Command palette'. */
539
+ dialogLabel?: string;
540
+ /** Accessible label for the listbox. Default 'Commands'. */
541
+ listLabel?: string;
542
+ /** Shown when no command matches. Default 'No matching commands.'. */
543
+ emptyText?: string;
530
544
  };
531
545
  /**
532
546
  * Cmd+K command palette: combobox + listbox with aria-activedescendant
533
547
  * keyboard navigation, lexical filtering over label/keywords, and
534
548
  * Escape-to-close. No focus leaves the input while navigating.
535
549
  */
536
- declare function CommandPalette({ open, onOpenChange, commands, onSelect, loadCommands, debounceMs, renderCommand, loadingText, placeholder, }: CommandPaletteProps): React.JSX.Element | null;
550
+ declare function CommandPalette({ open, onOpenChange, commands, onSelect, loadCommands, debounceMs, renderCommand, loadingText, placeholder, dialogLabel, listLabel, emptyText, }: CommandPaletteProps): React.JSX.Element | null;
537
551
 
538
552
  /**
539
553
  * Structural types mirroring the parts of the Vercel AI SDK's chat state the
@@ -608,4 +622,5 @@ type UseSlipstreamStreamResult = {
608
622
  */
609
623
  declare function useSlipstreamStream({ status, error, onRetry, messages, }: UseSlipstreamStreamOptions): UseSlipstreamStreamResult;
610
624
 
611
- export { type AiSdkMessage, type AiSdkStatus, type AiSdkToolInvocation, Attachment, type AttachmentItem, AttachmentList, type AttachmentListProps, type AttachmentProps, Branch, type BranchProps, ChainThought, type ChainThoughtProps, type ChainThoughtStep, CodeBlock, type CodeBlockProps, type Command, CommandPalette, type CommandPaletteProps, Confirmation, type ConfirmationProps, type ConfirmationStatus, Conversation, type ConversationProps, type FeedbackRating, InlineCitation, type InlineCitationProps, MemoizedMessage as Message, MessageActions, type MessageActionsProps, type Message as MessageData, type MessageProps, type MessageRole, PromptInputRoot as PromptInput, PromptInputActionAddAttachments, PromptInputActionDictate, PromptInputBody, PromptInputButton, type PromptInputButtonProps, PromptInputFooter, PromptInputHeader, type PromptInputProps, PromptInputSubmit, PromptInputTextarea, PromptInputTools, Reasoning, type ReasoningProps, type ReasoningStep, Response, type ResponseProps, Source, type SourceItem, type SourceProps, Sources, type SourcesProps, StreamingIndicator, type StreamingIndicatorProps, type Suggestion, Suggestions, type SuggestionsProps, ToolCall, type ToolCall$1 as ToolCallData, type ToolCallProps, type UseAttachmentsOptions, type UseAttachmentsResult, type UseSlipstreamMessagesOptions, type UseSlipstreamMessagesResult, type UseSlipstreamStreamOptions, type UseSlipstreamStreamResult, closeIncompleteMarkdown, toSlipstreamMessage, toSlipstreamMessages, toSlipstreamToolCall, toSlipstreamToolCalls, usePromptInputAttachments, useSlipstreamMessages, useSlipstreamStream, useSpeechRecognition };
625
+ export { Attachment, AttachmentList, Branch, ChainThought, CodeBlock, CommandPalette, Confirmation, Conversation, InlineCitation, MemoizedMessage as Message, MessageActions, PromptInputRoot as PromptInput, PromptInputActionAddAttachments, PromptInputActionDictate, PromptInputBody, PromptInputButton, PromptInputFooter, PromptInputHeader, PromptInputSubmit, PromptInputTextarea, PromptInputTools, Reasoning, Response, Source, Sources, StreamingIndicator, Suggestions, ToolCall, closeIncompleteMarkdown, toSlipstreamMessage, toSlipstreamMessages, toSlipstreamToolCall, toSlipstreamToolCalls, usePromptInputAttachments, useSlipstreamMessages, useSlipstreamStream, useSpeechRecognition };
626
+ export type { AiSdkMessage, AiSdkStatus, AiSdkToolInvocation, AttachmentItem, AttachmentListProps, AttachmentProps, BranchProps, ChainThoughtProps, ChainThoughtStep, CodeBlockProps, Command, CommandPaletteProps, ConfirmationProps, ConfirmationStatus, ConversationProps, FeedbackRating, InlineCitationProps, MessageActionsProps, Message as MessageData, MessageProps, MessageRole, PromptInputButtonProps, PromptInputProps, ReasoningProps, ReasoningStep, ResponseProps, SourceItem, SourceProps, SourcesProps, StreamingIndicatorProps, Suggestion, SuggestionsProps, ToolCall$1 as ToolCallData, ToolCallProps, UseAttachmentsOptions, UseAttachmentsResult, UseSlipstreamMessagesOptions, UseSlipstreamMessagesResult, UseSlipstreamStreamOptions, UseSlipstreamStreamResult };
package/dist/index.d.ts CHANGED
@@ -45,6 +45,10 @@ type MessageProps = {
45
45
  userLabel?: string;
46
46
  /** Display name for the assistant role; override for localization. */
47
47
  assistantLabel?: string;
48
+ /** Formats the message timestamp; defaults to the runtime's toLocaleTimeString(). */
49
+ formatTime?: (date: Date) => string;
50
+ /** BCP-47 locale used by the default timestamp formatter. */
51
+ locale?: string;
48
52
  /**
49
53
  * Custom content renderer, e.g. for markdown/code blocks.
50
54
  * When provided, it fully replaces the default plain-text rendering.
@@ -77,7 +81,7 @@ type MessageProps = {
77
81
  * (and timestamp re-formatting) for every other message in the transcript.
78
82
  * Callback props must be referentially stable for memo to help.
79
83
  */
80
- declare const MemoizedMessage: React.MemoExoticComponent<React.ForwardRefExoticComponent<MessageProps & React.RefAttributes<HTMLDivElement>>>;
84
+ declare const MemoizedMessage: React.NamedExoticComponent<MessageProps & React.RefAttributes<HTMLDivElement>>;
81
85
 
82
86
  /** User sentiment for an AI response. */
83
87
  type FeedbackRating = 'up' | 'down';
@@ -357,7 +361,7 @@ type PromptInputProps = {
357
361
  };
358
362
  declare const PromptInputRoot: React.ForwardRefExoticComponent<PromptInputProps & React.RefAttributes<HTMLTextAreaElement>>;
359
363
  /** Auto-resizing textarea bound to the prompt state. Accepts standard textarea props. */
360
- declare const PromptInputTextarea: React.ForwardRefExoticComponent<Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, "onChange" | "value"> & React.RefAttributes<HTMLTextAreaElement>>;
364
+ declare const PromptInputTextarea: React.ForwardRefExoticComponent<Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, "value" | "onChange"> & React.RefAttributes<HTMLTextAreaElement>>;
361
365
  /** Status-aware submit control: send / stop / error icons chosen automatically. */
362
366
  declare const PromptInputSubmit: React.ForwardRefExoticComponent<{
363
367
  className?: string;
@@ -409,6 +413,10 @@ type ReasoningProps = {
409
413
  duration?: number | string;
410
414
  /** Marks reasoning as still arriving: animated header state. */
411
415
  isStreaming?: boolean;
416
+ /** Formats step timestamps; defaults to the runtime's toLocaleTimeString(). */
417
+ formatTime?: (date: Date) => string;
418
+ /** BCP-47 locale used by the default timestamp formatter. */
419
+ locale?: string;
412
420
  /** Localized header, count and step labels. */
413
421
  labels?: {
414
422
  title?: string;
@@ -527,13 +535,19 @@ type CommandPaletteProps = {
527
535
  /** Shown while async commands load. */
528
536
  loadingText?: string;
529
537
  placeholder?: string;
538
+ /** Accessible label for the combobox. Default 'Command palette'. */
539
+ dialogLabel?: string;
540
+ /** Accessible label for the listbox. Default 'Commands'. */
541
+ listLabel?: string;
542
+ /** Shown when no command matches. Default 'No matching commands.'. */
543
+ emptyText?: string;
530
544
  };
531
545
  /**
532
546
  * Cmd+K command palette: combobox + listbox with aria-activedescendant
533
547
  * keyboard navigation, lexical filtering over label/keywords, and
534
548
  * Escape-to-close. No focus leaves the input while navigating.
535
549
  */
536
- declare function CommandPalette({ open, onOpenChange, commands, onSelect, loadCommands, debounceMs, renderCommand, loadingText, placeholder, }: CommandPaletteProps): React.JSX.Element | null;
550
+ declare function CommandPalette({ open, onOpenChange, commands, onSelect, loadCommands, debounceMs, renderCommand, loadingText, placeholder, dialogLabel, listLabel, emptyText, }: CommandPaletteProps): React.JSX.Element | null;
537
551
 
538
552
  /**
539
553
  * Structural types mirroring the parts of the Vercel AI SDK's chat state the
@@ -608,4 +622,5 @@ type UseSlipstreamStreamResult = {
608
622
  */
609
623
  declare function useSlipstreamStream({ status, error, onRetry, messages, }: UseSlipstreamStreamOptions): UseSlipstreamStreamResult;
610
624
 
611
- export { type AiSdkMessage, type AiSdkStatus, type AiSdkToolInvocation, Attachment, type AttachmentItem, AttachmentList, type AttachmentListProps, type AttachmentProps, Branch, type BranchProps, ChainThought, type ChainThoughtProps, type ChainThoughtStep, CodeBlock, type CodeBlockProps, type Command, CommandPalette, type CommandPaletteProps, Confirmation, type ConfirmationProps, type ConfirmationStatus, Conversation, type ConversationProps, type FeedbackRating, InlineCitation, type InlineCitationProps, MemoizedMessage as Message, MessageActions, type MessageActionsProps, type Message as MessageData, type MessageProps, type MessageRole, PromptInputRoot as PromptInput, PromptInputActionAddAttachments, PromptInputActionDictate, PromptInputBody, PromptInputButton, type PromptInputButtonProps, PromptInputFooter, PromptInputHeader, type PromptInputProps, PromptInputSubmit, PromptInputTextarea, PromptInputTools, Reasoning, type ReasoningProps, type ReasoningStep, Response, type ResponseProps, Source, type SourceItem, type SourceProps, Sources, type SourcesProps, StreamingIndicator, type StreamingIndicatorProps, type Suggestion, Suggestions, type SuggestionsProps, ToolCall, type ToolCall$1 as ToolCallData, type ToolCallProps, type UseAttachmentsOptions, type UseAttachmentsResult, type UseSlipstreamMessagesOptions, type UseSlipstreamMessagesResult, type UseSlipstreamStreamOptions, type UseSlipstreamStreamResult, closeIncompleteMarkdown, toSlipstreamMessage, toSlipstreamMessages, toSlipstreamToolCall, toSlipstreamToolCalls, usePromptInputAttachments, useSlipstreamMessages, useSlipstreamStream, useSpeechRecognition };
625
+ export { Attachment, AttachmentList, Branch, ChainThought, CodeBlock, CommandPalette, Confirmation, Conversation, InlineCitation, MemoizedMessage as Message, MessageActions, PromptInputRoot as PromptInput, PromptInputActionAddAttachments, PromptInputActionDictate, PromptInputBody, PromptInputButton, PromptInputFooter, PromptInputHeader, PromptInputSubmit, PromptInputTextarea, PromptInputTools, Reasoning, Response, Source, Sources, StreamingIndicator, Suggestions, ToolCall, closeIncompleteMarkdown, toSlipstreamMessage, toSlipstreamMessages, toSlipstreamToolCall, toSlipstreamToolCalls, usePromptInputAttachments, useSlipstreamMessages, useSlipstreamStream, useSpeechRecognition };
626
+ export type { AiSdkMessage, AiSdkStatus, AiSdkToolInvocation, AttachmentItem, AttachmentListProps, AttachmentProps, BranchProps, ChainThoughtProps, ChainThoughtStep, CodeBlockProps, Command, CommandPaletteProps, ConfirmationProps, ConfirmationStatus, ConversationProps, FeedbackRating, InlineCitationProps, MessageActionsProps, Message as MessageData, MessageProps, MessageRole, PromptInputButtonProps, PromptInputProps, ReasoningProps, ReasoningStep, ResponseProps, SourceItem, SourceProps, SourcesProps, StreamingIndicatorProps, Suggestion, SuggestionsProps, ToolCall$1 as ToolCallData, ToolCallProps, UseAttachmentsOptions, UseAttachmentsResult, UseSlipstreamMessagesOptions, UseSlipstreamMessagesResult, UseSlipstreamStreamOptions, UseSlipstreamStreamResult };
package/dist/index.js CHANGED
@@ -85,6 +85,8 @@ var Message = React.forwardRef(
85
85
  avatarFallback,
86
86
  userLabel = "You",
87
87
  assistantLabel = "Assistant",
88
+ formatTime,
89
+ locale,
88
90
  renderContent,
89
91
  isStreaming = false,
90
92
  error,
@@ -138,7 +140,7 @@ var Message = React.forwardRef(
138
140
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex-1 min-w-0", children: [
139
141
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2 mb-1", children: [
140
142
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-sm font-medium", children: displayLabel }),
141
- message.timestamp && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs text-muted-foreground", children: new Date(message.timestamp).toLocaleTimeString() })
143
+ message.timestamp && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs text-muted-foreground", children: formatTime ? formatTime(new Date(message.timestamp)) : new Date(message.timestamp).toLocaleTimeString(locale) })
142
144
  ] }),
143
145
  error ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { role: "alert", className: "text-sm", children: [
144
146
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-destructive mb-2", children: error }),
@@ -1362,7 +1364,7 @@ var React12 = __toESM(require("react"));
1362
1364
  var import_core16 = require("@slipstream-ui/core");
1363
1365
  var import_jsx_runtime12 = require("react/jsx-runtime");
1364
1366
  var Reasoning = React12.forwardRef(
1365
- ({ steps, className, collapsible = true, defaultExpanded = false, duration, isStreaming = false, labels, ...props }, ref) => {
1367
+ ({ steps, className, collapsible = true, defaultExpanded = false, duration, isStreaming = false, labels, formatTime, locale, ...props }, ref) => {
1366
1368
  const [isExpanded, setIsExpanded] = React12.useState(defaultExpanded);
1367
1369
  const contentId = React12.useId();
1368
1370
  if (steps.length === 0) {
@@ -1401,7 +1403,7 @@ var Reasoning = React12.forwardRef(
1401
1403
  /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "text-sm flex-1", children: [
1402
1404
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "font-medium text-foreground mb-1", children: labels?.step?.(index + 1) ?? `Step ${index + 1}` }),
1403
1405
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "text-muted-foreground", children: step.content }),
1404
- step.timestamp && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "text-xs text-muted-foreground mt-1", children: new Date(step.timestamp).toLocaleTimeString() })
1406
+ step.timestamp && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "text-xs text-muted-foreground mt-1", children: formatTime ? formatTime(new Date(step.timestamp)) : new Date(step.timestamp).toLocaleTimeString(locale) })
1405
1407
  ] })
1406
1408
  ] }, step.id)) })
1407
1409
  ] });
@@ -1647,7 +1649,10 @@ function CommandPalette({
1647
1649
  debounceMs = 200,
1648
1650
  renderCommand,
1649
1651
  loadingText = "Searching\u2026",
1650
- placeholder = "Type a command."
1652
+ placeholder = "Type a command.",
1653
+ dialogLabel = "Command palette",
1654
+ listLabel = "Commands",
1655
+ emptyText = "No matching commands."
1651
1656
  }) {
1652
1657
  const [query, setQuery] = React19.useState("");
1653
1658
  const [activeIndex, setActiveIndex] = React19.useState(0);
@@ -1734,7 +1739,7 @@ function CommandPalette({
1734
1739
  "aria-controls": listboxId,
1735
1740
  "aria-activedescendant": filtered.length > 0 ? optionId(activeIndex) : void 0,
1736
1741
  "aria-autocomplete": "list",
1737
- "aria-label": "Command palette",
1742
+ "aria-label": dialogLabel,
1738
1743
  placeholder,
1739
1744
  value: query,
1740
1745
  onChange: (event) => {
@@ -1750,12 +1755,12 @@ function CommandPalette({
1750
1755
  {
1751
1756
  id: listboxId,
1752
1757
  role: "listbox",
1753
- "aria-label": "Commands",
1758
+ "aria-label": listLabel,
1754
1759
  "aria-busy": loading || void 0,
1755
1760
  className: "max-h-72 overflow-y-auto py-1",
1756
1761
  children: [
1757
1762
  loading && filtered.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("li", { role: "presentation", className: "px-4 py-3 text-sm text-muted-foreground", children: loadingText }),
1758
- !loading && filtered.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("li", { role: "presentation", className: "px-4 py-3 text-sm text-muted-foreground", children: "No matching commands." }),
1763
+ !loading && filtered.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("li", { role: "presentation", className: "px-4 py-3 text-sm text-muted-foreground", children: emptyText }),
1759
1764
  filtered.map((command, index) => {
1760
1765
  const showSection = command.section && command.section !== lastSection;
1761
1766
  lastSection = command.section ?? lastSection;