@agents24/chat-react 0.5.4 → 0.5.6

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 (34) hide show
  1. package/README.md +8 -2
  2. package/compatibility.json +4 -4
  3. package/dist/runtime/index.cjs +127 -18
  4. package/dist/runtime/index.cjs.map +1 -1
  5. package/dist/runtime/index.js +125 -18
  6. package/dist/runtime/index.js.map +1 -1
  7. package/dist/runtime/use-agent-chat-runtime.d.ts +17 -2
  8. package/dist/scaffold/app.d.ts +1 -0
  9. package/dist/scaffold/components/chat/chat-composer.d.ts +10 -2
  10. package/dist/scaffold/components/chat/chat-message.d.ts +3 -1
  11. package/dist/scaffold/components/chat/chat-shell.d.ts +3 -1
  12. package/dist/scaffold/index.cjs +415 -253
  13. package/dist/scaffold/index.cjs.map +1 -1
  14. package/dist/scaffold/index.js +408 -240
  15. package/dist/scaffold/index.js.map +1 -1
  16. package/dist/styles.css +18 -4
  17. package/dist/ui/adapters.d.ts +14 -2
  18. package/dist/ui/agent-chat-composer.d.ts +2 -9
  19. package/dist/ui/agent-chat-message.d.ts +3 -1
  20. package/dist/ui/composer-attachments.d.ts +11 -0
  21. package/dist/ui/index.cjs +653 -343
  22. package/dist/ui/index.cjs.map +1 -1
  23. package/dist/ui/index.d.ts +1 -0
  24. package/dist/ui/index.js +638 -328
  25. package/dist/ui/index.js.map +1 -1
  26. package/package.json +4 -3
  27. package/scaffold/src/app.tsx +2 -1
  28. package/scaffold/src/chat.css +13 -1
  29. package/scaffold/src/components/chat/chat-composer.tsx +107 -27
  30. package/scaffold/src/components/chat/chat-message.tsx +8 -9
  31. package/scaffold/src/components/chat/chat-shell.tsx +24 -11
  32. package/scaffold/src/components/ui/button.tsx +1 -1
  33. package/scaffold/src/components/ui/dropdown-menu.tsx +1 -1
  34. package/scaffold/src/components/ui/sidebar.tsx +4 -4
package/dist/styles.css CHANGED
@@ -155,6 +155,7 @@
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; }
158
159
  .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; }
159
160
  button.a24-tool-trigger { border-radius: .5rem; cursor: pointer; transition: background-color 140ms ease, color 140ms ease; }
160
161
  button.a24-tool-trigger:hover { color: var(--a24-text); }
@@ -204,13 +205,26 @@ button.a24-tool-trigger:focus-visible { outline: 2px solid var(--a24-focus); out
204
205
  to { opacity: 0; transform: translateY(-75%); }
205
206
  }
206
207
 
207
- .a24-message-response { box-sizing: border-box; max-width: 100%; min-width: 0; padding-inline: 3px; width: 100%; }
208
- .a24-timeline-error { padding-inline: 3px; }
208
+ .a24-message-response { box-sizing: border-box; max-width: 100%; min-width: 0; padding-inline: 6px; width: 100%; }
209
+ .a24-timeline-error { padding-inline: 6px; }
210
+ .a24-ask-user--resolved { padding-inline: 6px; }
209
211
  .a24-chat-message { display: flex; flex-direction: column; gap: .5rem; min-width: 0; width: 100%; }
210
- .a24-chat-message--user { margin-inline-start: auto; max-width: 80%; }
212
+ .a24-chat-message--user { max-width: 100%; }
211
213
  .a24-chat-message--assistant { max-width: 100%; }
214
+ .a24-chat-attachment-rows { align-self: flex-end; display: flex; flex-direction: column; gap: .375rem; max-width: 100%; min-width: 0; width: 100%; }
215
+ .a24-chat-attachments { align-self: stretch; justify-content: safe flex-end; max-width: 100%; scrollbar-width: none; width: 100%; }
216
+ .a24-chat-attachments[dir="rtl"] { justify-content: safe flex-start; }
217
+ .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; }
218
+ .a24-chat-attachment-icon { border-radius: 0 !important; height: 1.75rem; width: 1.75rem; }
219
+ .a24-chat-attachment-icon svg { display: block; height: 100%; width: 100%; }
220
+ .a24-chat-attachment-content { overflow: hidden; }
221
+ .a24-chat-image-attachment { border: 0; border-radius: var(--radius, .75rem); height: 6rem; min-width: 6rem; overflow: hidden; padding: 0 !important; width: 6rem; }
222
+ .a24-chat-image-media { border-radius: inherit; height: 6rem; opacity: 1 !important; width: 6rem !important; }
223
+ .a24-chat-image-media img { height: 100%; object-fit: cover; width: 100%; }
224
+ .a24-chat-image-spinner { color: var(--a24-muted); }
225
+ .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; }
212
226
  .a24-chat-message-content { display: flex; flex-direction: column; max-width: 100%; min-width: 0; }
213
- .a24-chat-message-content--user { align-self: flex-end; overflow: visible; width: fit-content; }
227
+ .a24-chat-message-content--user { align-self: flex-end; max-width: 80%; overflow: visible; width: fit-content; }
214
228
  .a24-chat-message-content--assistant { overflow: visible; width: 100%; }
215
229
  .a24-message-response > :first-child { margin-top: 0; }
216
230
  .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,4 @@ 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 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;