@agents24/chat-react 0.5.5 → 0.5.7

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 (35) hide show
  1. package/dist/index.cjs +11 -6
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +11 -6
  4. package/dist/index.js.map +1 -1
  5. package/dist/latest-thread-scroller.d.ts +2 -1
  6. package/dist/runtime/index.cjs +17 -11
  7. package/dist/runtime/index.cjs.map +1 -1
  8. package/dist/runtime/index.js +17 -11
  9. package/dist/runtime/index.js.map +1 -1
  10. package/dist/runtime/use-agent-chat-runtime.d.ts +7 -2
  11. package/dist/scaffold/components/chat/chat-composer.d.ts +2 -1
  12. package/dist/scaffold/components/chat/chat-message.d.ts +3 -1
  13. package/dist/scaffold/components/chat/turn-outline.d.ts +1 -1
  14. package/dist/scaffold/index.cjs +195 -154
  15. package/dist/scaffold/index.cjs.map +1 -1
  16. package/dist/scaffold/index.js +215 -168
  17. package/dist/scaffold/index.js.map +1 -1
  18. package/dist/styles.css +25 -6
  19. package/dist/ui/adapters.d.ts +14 -2
  20. package/dist/ui/agent-chat-composer.d.ts +2 -9
  21. package/dist/ui/agent-chat-message.d.ts +7 -1
  22. package/dist/ui/composer-attachments.d.ts +11 -0
  23. package/dist/ui/index.cjs +781 -389
  24. package/dist/ui/index.cjs.map +1 -1
  25. package/dist/ui/index.d.ts +1 -0
  26. package/dist/ui/index.js +766 -375
  27. package/dist/ui/index.js.map +1 -1
  28. package/package.json +4 -3
  29. package/scaffold/src/components/chat/chat-composer.tsx +43 -19
  30. package/scaffold/src/components/chat/chat-message.tsx +19 -10
  31. package/scaffold/src/components/chat/chat-shell.tsx +65 -34
  32. package/scaffold/src/components/chat/turn-outline.tsx +17 -59
  33. package/scaffold/src/components/ui/message-scroller.tsx +1 -1
  34. package/scaffold/src/components/ui/message.tsx +1 -1
  35. package/scaffold/src/components/ui/sidebar.tsx +1 -1
package/dist/styles.css CHANGED
@@ -57,7 +57,7 @@
57
57
  }
58
58
  .a24-scroller__viewport { flex: 1; height: 100%; min-height: 0; min-width: 0; overscroll-behavior: contain; overflow-y: auto; scrollbar-width: none; width: 100%; }
59
59
  .a24-scroller__viewport::-webkit-scrollbar { display: none; }
60
- .a24-scroller__content { display: flex; flex-direction: column; gap: 2rem; min-height: 100%; }
60
+ .a24-scroller__content { display: flex; flex-direction: column; gap: .75rem; min-height: 100%; }
61
61
  .a24-scroller__item { animation: var(--a24-message-enter-animation); flex: 0 0 auto; min-width: 0; overflow: visible; }
62
62
  .a24-scroller__button {
63
63
  align-items: center;
@@ -155,7 +155,6 @@
155
155
  .a24-context-status__sr-only { border: 0; clip: rect(0, 0, 0, 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; white-space: nowrap; width: 1px; }
156
156
  .a24-tool-disclosure { min-width: 0; width: 100%; }
157
157
  .a24-tool-trigger-row { align-items: center; display: flex; gap: .35rem; min-width: 0; }
158
- .a24-tool-trigger-row--text { padding-inline: 6px; }
159
158
  .a24-tool-trigger { align-items: center; appearance: none; background: transparent; border: 0; color: var(--a24-muted); display: flex; font: inherit; font-size: .875rem; gap: .35rem; line-height: 1.35; min-width: 0; padding: .125rem 0; text-align: start; }
160
159
  button.a24-tool-trigger { border-radius: .5rem; cursor: pointer; transition: background-color 140ms ease, color 140ms ease; }
161
160
  button.a24-tool-trigger:hover { color: var(--a24-text); }
@@ -208,11 +207,31 @@ button.a24-tool-trigger:focus-visible { outline: 2px solid var(--a24-focus); out
208
207
  .a24-message-response { box-sizing: border-box; max-width: 100%; min-width: 0; padding-inline: 6px; width: 100%; }
209
208
  .a24-timeline-error { padding-inline: 6px; }
210
209
  .a24-ask-user--resolved { padding-inline: 6px; }
211
- .a24-chat-message { display: flex; flex-direction: column; gap: .5rem; min-width: 0; width: 100%; }
212
- .a24-chat-message--user { margin-inline-start: auto; max-width: 80%; }
213
- .a24-chat-message--assistant { max-width: 100%; }
210
+ .a24-chat-message { display: flex; flex-direction: column; min-width: 0; width: 100%; }
211
+ .a24-chat-message--user { gap: 0; max-width: 100%; }
212
+ .a24-chat-message--assistant { gap: .5rem; max-width: 100%; }
213
+ .a24-chat-message-action-row--user { align-items: center; align-self: flex-start; display: flex; gap: .5rem; height: 2rem; margin-left: auto; margin-top: .25rem; padding-inline: .25rem; transition: opacity 150ms ease; width: auto; }
214
+ .a24-user-message-actions { color: var(--a24-muted); font-family: inherit; font-size: .75rem; font-weight: 400; gap: .5rem; }
215
+ .a24-user-message-actions time { white-space: nowrap; }
216
+ .a24-user-message-copy { color: var(--a24-muted); height: 1.75rem; padding: 0; position: relative; width: 1.75rem; }
217
+ .a24-user-message-copy:hover { color: var(--a24-text); }
218
+ .a24-user-message-copy__check, .a24-user-message-copy__icon { height: .875rem; inset: 0; margin: auto; position: absolute; width: .875rem; }
219
+ .a24-user-message-copy__icon { opacity: 0; transform: scale(.75); transition: opacity 150ms ease, transform 150ms ease; }
220
+ .a24-chat-message-action-row--user.is-visible .a24-user-message-copy__icon { opacity: 1; transform: scale(1); }
221
+ .a24-chat-attachment-rows { align-self: flex-end; display: flex; flex-direction: column; gap: .375rem; max-width: 100%; min-width: 0; width: 100%; }
222
+ .a24-chat-attachments { align-self: stretch; justify-content: safe flex-end; max-width: 100%; scrollbar-width: none; width: 100%; }
223
+ .a24-chat-attachments[dir="rtl"] { justify-content: safe flex-start; }
224
+ .a24-chat-attachment { align-items: center; border-radius: var(--radius, .75rem); flex-wrap: nowrap; max-width: min(22rem, 100%); min-height: 2.5rem; padding: .375rem .625rem !important; }
225
+ .a24-chat-attachment-icon { border-radius: 0 !important; height: 1.75rem; width: 1.75rem; }
226
+ .a24-chat-attachment-icon svg { display: block; height: 100%; width: 100%; }
227
+ .a24-chat-attachment-content { overflow: hidden; }
228
+ .a24-chat-image-attachment { border: 0; border-radius: var(--radius, .75rem); height: 6rem; min-width: 6rem; overflow: hidden; padding: 0 !important; width: 6rem; }
229
+ .a24-chat-image-media { border-radius: inherit; height: 6rem; opacity: 1 !important; width: 6rem !important; }
230
+ .a24-chat-image-media img { height: 100%; object-fit: cover; width: 100%; }
231
+ .a24-chat-image-spinner { color: var(--a24-muted); }
232
+ .a24-chat-image-remove { align-items: center; background: color-mix(in srgb, var(--a24-background) 88%, transparent); border: 0; border-radius: .375rem; color: var(--a24-text); display: inline-flex; height: 1.5rem; justify-content: center; position: absolute; right: .375rem; top: .375rem; width: 1.5rem; z-index: 2; }
214
233
  .a24-chat-message-content { display: flex; flex-direction: column; max-width: 100%; min-width: 0; }
215
- .a24-chat-message-content--user { align-self: flex-end; overflow: visible; width: fit-content; }
234
+ .a24-chat-message-content--user { align-self: flex-end; max-width: 80%; overflow: visible; width: fit-content; }
216
235
  .a24-chat-message-content--assistant { overflow: visible; width: 100%; }
217
236
  .a24-message-response > :first-child { margin-top: 0; }
218
237
  .a24-message-response > :last-child { margin-bottom: 0; }
@@ -28,8 +28,20 @@ export type ChatAttachmentData = Agents24ChatAttachment & {
28
28
  export type ChatAttachmentProps = React.ComponentProps<typeof Attachment> & {
29
29
  data: ChatAttachmentData;
30
30
  onRemove?: () => void;
31
+ resolveContent?: ChatAttachmentContentResolver;
31
32
  };
32
- export declare function ChatAttachment({ data, onRemove, orientation, ...props }: ChatAttachmentProps): React.ReactElement;
33
+ export type ChatAttachmentContentResult = {
34
+ url: string;
35
+ validUntil?: string | null;
36
+ };
37
+ export type ChatAttachmentContentResolver = (attachment: ChatAttachmentData, signal: AbortSignal) => Promise<ChatAttachmentContentResult>;
38
+ export declare function ChatAttachment({ className, data, onRemove, orientation, resolveContent, ...props }: ChatAttachmentProps): React.ReactElement;
33
39
  export type ChatAttachmentsProps = React.ComponentProps<typeof AttachmentGroup>;
34
40
  export declare function ChatAttachments({ children, className, ...props }: ChatAttachmentsProps): React.ReactElement | null;
35
- export { ChatAttachment as MessageAttachment, ChatAttachments as MessageAttachments, ChatMessage as Message, ChatMessageAction as MessageAction, ChatMessageActions as MessageActions, ChatMessageContent as MessageContent, };
41
+ export type ChatAttachmentRowsProps = Omit<React.ComponentProps<"div">, "children"> & {
42
+ attachments: readonly ChatAttachmentData[];
43
+ onRemove?: (attachment: ChatAttachmentData) => void;
44
+ resolveContent?: ChatAttachmentContentResolver;
45
+ };
46
+ export declare function ChatAttachmentRows({ attachments, className, dir, onRemove, resolveContent, ...props }: ChatAttachmentRowsProps): React.ReactElement | null;
47
+ export { ChatAttachment as MessageAttachment, ChatAttachmentRows as MessageAttachmentRows, ChatAttachments as MessageAttachments, ChatMessage as Message, ChatMessageAction as MessageAction, ChatMessageActions as MessageActions, ChatMessageContent as MessageContent, };
@@ -1,13 +1,6 @@
1
1
  import * as React from "react";
2
- import type { ChatAttachment } from "../types";
3
- export type AgentChatComposerFile = ChatAttachment & {
4
- id: string;
5
- type: "file";
6
- url: string;
7
- filename: string;
8
- mediaType: string;
9
- source: File;
10
- };
2
+ import { type AgentChatComposerFile } from "./composer-attachments";
3
+ export type { AgentChatComposerFile } from "./composer-attachments";
11
4
  export type AgentChatComposerSubmit = {
12
5
  text: string;
13
6
  files: AgentChatComposerFile[];
@@ -1,5 +1,6 @@
1
1
  import * as React from "react";
2
2
  import type { ChatHitlPart, ChatHitlResponse, ChatMessage } from "../types";
3
+ import { type ChatAttachmentContentResolver } from "./adapters";
3
4
  import { type AgentChatMessageActionHandlers } from "./agent-chat-actions";
4
5
  import { type AgentChatPartActionState, type AgentChatTimelineComponent } from "./agent-response-timeline";
5
6
  export type AgentChatUserMessageContentProps = {
@@ -14,6 +15,7 @@ export type AgentChatMessageProps = {
14
15
  additionalActions?: React.ReactNode;
15
16
  actions?: React.ReactNode;
16
17
  actionsClassName?: string;
18
+ attachmentContentResolver?: ChatAttachmentContentResolver;
17
19
  className?: string;
18
20
  contentClassName?: string;
19
21
  dir?: "ltr" | "rtl";
@@ -39,4 +41,8 @@ export type AgentChatMessageProps = {
39
41
  };
40
42
  export declare function shouldCollapseUserMessage(content: string, threshold?: number | null | undefined): boolean;
41
43
  export declare function AgentChatUserMessageContent({ collapsedLines, collapseThreshold, content, showLessLabel, showMoreLabel, }: AgentChatUserMessageContentProps): import("react/jsx-runtime").JSX.Element;
42
- export declare function AgentChatMessage({ actionHandlers, additionalActions, actions, actionsClassName, className, contentClassName, dir, getHitlActionState, message, nodeActivityMode, onHitlAction, Timeline, renderAssistantContent, renderUserContent, showAssistantAttachments, streamingMessageId, userMessageCollapsedLines, userMessageContent, userMessageCollapseThreshold, userMessageShowLessLabel, userMessageShowMoreLabel, }: AgentChatMessageProps): import("react/jsx-runtime").JSX.Element;
44
+ export declare function AgentChatUserMessageActionRow({ children, className, }: {
45
+ children: React.ReactNode;
46
+ className?: string;
47
+ }): import("react/jsx-runtime").JSX.Element;
48
+ export declare function AgentChatMessage({ actionHandlers, additionalActions, actions, actionsClassName, attachmentContentResolver, className, contentClassName, dir, getHitlActionState, message, nodeActivityMode, onHitlAction, Timeline, renderAssistantContent, renderUserContent, showAssistantAttachments, streamingMessageId, userMessageCollapsedLines, userMessageContent, userMessageCollapseThreshold, userMessageShowLessLabel, userMessageShowMoreLabel, }: AgentChatMessageProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import type { ChatAttachment } from "../types";
2
+ export type AgentChatComposerFile = ChatAttachment & {
3
+ id: string;
4
+ type: "file";
5
+ url: string;
6
+ filename: string;
7
+ mediaType: string;
8
+ source: File;
9
+ };
10
+ export declare function createAgentChatComposerFile(file: File): AgentChatComposerFile;
11
+ export declare function revokeAgentChatComposerFiles(files: readonly AgentChatComposerFile[]): void;