@invergent/agent-chat-react 1.6.9 → 1.7.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.
package/dist/index.d.cts CHANGED
@@ -12,6 +12,45 @@ interface AgentChatImageAttachment {
12
12
  /** MIME type, e.g. "image/png", "image/jpeg" */
13
13
  mimeType?: string;
14
14
  }
15
+ /**
16
+ * A workspace-resident attachment referenced from a user message.
17
+ *
18
+ * ``path`` is the workspace-relative location returned by
19
+ * ``adapter.uploadWorkspaceFile``. The harness validates this against the
20
+ * session's workspace bucket before persisting it on the user.message event.
21
+ */
22
+ interface AgentChatAttachment {
23
+ /** Workspace-relative path returned by uploadWorkspaceFile, e.g.
24
+ * ``"uploads/1715-0-report.pdf"``. */
25
+ path: string;
26
+ /** Original filename for display (the workspace path is the SDK's
27
+ * collision-avoidance rename). */
28
+ filename: string;
29
+ mimeType?: string;
30
+ size?: number;
31
+ }
32
+ /**
33
+ * Display variant used on user-message bubbles.
34
+ *
35
+ * ``path`` is optional: an optimistic local message rendered before the
36
+ * upload completes has the filename + MIME but no workspace path yet, so
37
+ * the chip renders disabled (not clickable) until the persisted event
38
+ * replaces it with a full :class:`AgentChatAttachment`.
39
+ */
40
+ interface AgentChatDisplayAttachment {
41
+ path?: string;
42
+ filename: string;
43
+ mimeType?: string;
44
+ size?: number;
45
+ }
46
+ /**
47
+ * Internal-to-runtime variant carrying the raw ``File`` so the runtime
48
+ * can upload it to the workspace. Never crosses the network — only
49
+ * passed from composer to runtime.
50
+ */
51
+ interface AgentChatPendingAttachment extends AgentChatDisplayAttachment {
52
+ file: File;
53
+ }
15
54
  interface AgentChatMessage {
16
55
  id: string;
17
56
  role: AgentChatRole;
@@ -24,6 +63,7 @@ interface AgentChatMessage {
24
63
  systemMeta?: Record<string, unknown>;
25
64
  errorInfo?: AgentChatErrorInfo;
26
65
  images?: AgentChatImageAttachment[];
66
+ attachments?: AgentChatDisplayAttachment[];
27
67
  }
28
68
  interface AgentChatToolCallInfo {
29
69
  id: string;
@@ -331,6 +371,8 @@ interface AgentChatAdapter {
331
371
  sessionId: string;
332
372
  content: string;
333
373
  images?: AgentChatImageAttachment[];
374
+ metadata?: Record<string, unknown>;
375
+ attachments?: AgentChatAttachment[];
334
376
  }): Promise<{
335
377
  eventId?: number;
336
378
  status?: string;
@@ -462,7 +504,7 @@ interface AgentChatRuntimeApi {
462
504
  tokenUsage: AgentChatTokenUsage;
463
505
  retryIndicator: AgentChatRetryIndicator | null;
464
506
  workspaceRefreshKey: number;
465
- send(content: string, images?: AgentChatImageAttachment[]): Promise<void>;
507
+ send(content: string, images?: AgentChatImageAttachment[], attachments?: AgentChatPendingAttachment[]): Promise<void>;
466
508
  stop(): Promise<void>;
467
509
  retry(): Promise<void>;
468
510
  markSending(content: string): void;
@@ -495,6 +537,17 @@ type WorkspaceTree = AgentChatWorkspaceTree;
495
537
  type WorkspaceFile = AgentChatWorkspaceFile;
496
538
  type WorkspaceUpload = AgentChatWorkspaceUpload;
497
539
 
540
+ interface ChatComposerError {
541
+ /**
542
+ * Stable error code so callers can route different rejections (e.g.
543
+ * show a different toast variant per code) without parsing the
544
+ * human-readable message.
545
+ */
546
+ code: "accept" | "max_files" | "max_file_size" | "max_images" | "max_image_size" | "max_attachments" | "max_attachment_size" | "max_attachments_total";
547
+ /** Display-ready, single-sentence reason. */
548
+ message: string;
549
+ }
550
+
498
551
  interface AgentChatProps {
499
552
  adapter: AgentChatAdapter;
500
553
  agentId?: string;
@@ -503,8 +556,14 @@ interface AgentChatProps {
503
556
  onFileSelect?: (path: string) => void;
504
557
  onMessagesChange?: (messages: AgentChatMessage[]) => void;
505
558
  disabled?: boolean;
559
+ /**
560
+ * Called when the composer rejects a file selection before sending —
561
+ * size/count caps, accept-pattern misses. Host apps wire this to
562
+ * their toast system; the SDK does not surface these on its own.
563
+ */
564
+ onComposerError?: (err: ChatComposerError) => void;
506
565
  }
507
- declare function AgentChat({ adapter, agentId, sessionId, onSessionChange, onFileSelect, onMessagesChange, disabled, }: AgentChatProps): react_jsx_runtime.JSX.Element;
566
+ declare function AgentChat({ adapter, agentId, sessionId, onSessionChange, onFileSelect, onMessagesChange, disabled, onComposerError, }: AgentChatProps): react_jsx_runtime.JSX.Element;
508
567
 
509
568
  interface AgentChatAdapterContextValue {
510
569
  adapter: AgentChatAdapter;
@@ -579,4 +638,4 @@ interface SessionTreePanelProps {
579
638
  }
580
639
  declare function SessionTreePanel({ adapter, sessionId, activeSessionId, agentId, title, sessionListLimit, hideRoot, hideHeader, loadList, onSessionSelect, onSessionDelete, }: SessionTreePanelProps): react_jsx_runtime.JSX.Element | null;
581
640
 
582
- export { AgentChat, type AgentChatAdapter, type AgentChatAdapterContextValue, AgentChatAdapterProvider, type AgentChatArtifactKind, type AgentChatArtifactMeta, type AgentChatArtifactPayload, type AgentChatChartArtifactSpec, type AgentChatClarifyAnswer, type AgentChatClarifyArgs, type AgentChatClarifyChoice, type AgentChatClarifyQuestion, type AgentChatErrorCategory, type AgentChatErrorInfo, type AgentChatEventStream, type AgentChatEventType, type AgentChatExpertFeedbackRating, type AgentChatHtmlArtifactSpec, type AgentChatImageAttachment, type AgentChatInboxEventStream, type AgentChatInboxItem, type AgentChatInboxKind, type AgentChatInboxList, type AgentChatInboxListInput, type AgentChatInboxStatus, type AgentChatInboxStreamEvent, type AgentChatMarkdownArtifactSpec, type AgentChatMessage, type AgentChatMessageStatus, type AgentChatProps, type AgentChatRole, type AgentChatRuntimeApi, type AgentChatRuntimeEvent, type AgentChatScheduledWorkItem, type AgentChatScheduledWorkKind, type AgentChatScheduledWorkList, type AgentChatSession, type AgentChatSessionList, type AgentChatSessionTree, type AgentChatSessionTreeNode, type AgentChatSlashCommand, type AgentChatSseMessageEvent, type AgentChatState, type AgentChatSvgArtifactSpec, type AgentChatSystemKind, type AgentChatTableArtifactSpec, type AgentChatTokenUsage, type AgentChatToolCallInfo, type AgentChatWorkspaceEntry, type AgentChatWorkspaceFile, type AgentChatWorkspaceTree, type AgentChatWorkspaceUpload, type ArtifactKind, type ArtifactPayload, type ChartArtifactSpec, type ChatMessage, type ClarifyAnswer, type ClarifyArgs, type ClarifyChoice, type ClarifyQuestion, type ErrorInfo, type HtmlArtifactSpec, type InboxItem, type InboxList, InboxPanel, type InboxPanelProps, type InboxUnreadCountState, type MarkdownArtifactSpec, MessageResponse, type MessageResponseProps, type RetryIndicator, type ScheduledWorkItem, type ScheduledWorkList, ScheduledWorkPanel, type ScheduledWorkPanelProps, type SessionTree, type SessionTreeNode, SessionTreePanel, type SessionTreePanelProps, type SvgArtifactSpec, type TableArtifactSpec, type TokenUsage, type ToolCallInfo, type WorkspaceEntry, type WorkspaceFile, type WorkspaceTree, type WorkspaceUpload, useAgentChatAdapterContext, useAgentChatRuntime, useInboxUnreadCount };
641
+ export { AgentChat, type AgentChatAdapter, type AgentChatAdapterContextValue, AgentChatAdapterProvider, type AgentChatArtifactKind, type AgentChatArtifactMeta, type AgentChatArtifactPayload, type AgentChatAttachment, type AgentChatChartArtifactSpec, type AgentChatClarifyAnswer, type AgentChatClarifyArgs, type AgentChatClarifyChoice, type AgentChatClarifyQuestion, type AgentChatDisplayAttachment, type AgentChatErrorCategory, type AgentChatErrorInfo, type AgentChatEventStream, type AgentChatEventType, type AgentChatExpertFeedbackRating, type AgentChatHtmlArtifactSpec, type AgentChatImageAttachment, type AgentChatInboxEventStream, type AgentChatInboxItem, type AgentChatInboxKind, type AgentChatInboxList, type AgentChatInboxListInput, type AgentChatInboxStatus, type AgentChatInboxStreamEvent, type AgentChatMarkdownArtifactSpec, type AgentChatMessage, type AgentChatMessageStatus, type AgentChatPendingAttachment, type AgentChatProps, type AgentChatRole, type AgentChatRuntimeApi, type AgentChatRuntimeEvent, type AgentChatScheduledWorkItem, type AgentChatScheduledWorkKind, type AgentChatScheduledWorkList, type AgentChatSession, type AgentChatSessionList, type AgentChatSessionTree, type AgentChatSessionTreeNode, type AgentChatSlashCommand, type AgentChatSseMessageEvent, type AgentChatState, type AgentChatSvgArtifactSpec, type AgentChatSystemKind, type AgentChatTableArtifactSpec, type AgentChatTokenUsage, type AgentChatToolCallInfo, type AgentChatWorkspaceEntry, type AgentChatWorkspaceFile, type AgentChatWorkspaceTree, type AgentChatWorkspaceUpload, type ArtifactKind, type ArtifactPayload, type ChartArtifactSpec, type ChatComposerError, type ChatMessage, type ClarifyAnswer, type ClarifyArgs, type ClarifyChoice, type ClarifyQuestion, type ErrorInfo, type HtmlArtifactSpec, type InboxItem, type InboxList, InboxPanel, type InboxPanelProps, type InboxUnreadCountState, type MarkdownArtifactSpec, MessageResponse, type MessageResponseProps, type RetryIndicator, type ScheduledWorkItem, type ScheduledWorkList, ScheduledWorkPanel, type ScheduledWorkPanelProps, type SessionTree, type SessionTreeNode, SessionTreePanel, type SessionTreePanelProps, type SvgArtifactSpec, type TableArtifactSpec, type TokenUsage, type ToolCallInfo, type WorkspaceEntry, type WorkspaceFile, type WorkspaceTree, type WorkspaceUpload, useAgentChatAdapterContext, useAgentChatRuntime, useInboxUnreadCount };
package/dist/index.d.ts CHANGED
@@ -12,6 +12,45 @@ interface AgentChatImageAttachment {
12
12
  /** MIME type, e.g. "image/png", "image/jpeg" */
13
13
  mimeType?: string;
14
14
  }
15
+ /**
16
+ * A workspace-resident attachment referenced from a user message.
17
+ *
18
+ * ``path`` is the workspace-relative location returned by
19
+ * ``adapter.uploadWorkspaceFile``. The harness validates this against the
20
+ * session's workspace bucket before persisting it on the user.message event.
21
+ */
22
+ interface AgentChatAttachment {
23
+ /** Workspace-relative path returned by uploadWorkspaceFile, e.g.
24
+ * ``"uploads/1715-0-report.pdf"``. */
25
+ path: string;
26
+ /** Original filename for display (the workspace path is the SDK's
27
+ * collision-avoidance rename). */
28
+ filename: string;
29
+ mimeType?: string;
30
+ size?: number;
31
+ }
32
+ /**
33
+ * Display variant used on user-message bubbles.
34
+ *
35
+ * ``path`` is optional: an optimistic local message rendered before the
36
+ * upload completes has the filename + MIME but no workspace path yet, so
37
+ * the chip renders disabled (not clickable) until the persisted event
38
+ * replaces it with a full :class:`AgentChatAttachment`.
39
+ */
40
+ interface AgentChatDisplayAttachment {
41
+ path?: string;
42
+ filename: string;
43
+ mimeType?: string;
44
+ size?: number;
45
+ }
46
+ /**
47
+ * Internal-to-runtime variant carrying the raw ``File`` so the runtime
48
+ * can upload it to the workspace. Never crosses the network — only
49
+ * passed from composer to runtime.
50
+ */
51
+ interface AgentChatPendingAttachment extends AgentChatDisplayAttachment {
52
+ file: File;
53
+ }
15
54
  interface AgentChatMessage {
16
55
  id: string;
17
56
  role: AgentChatRole;
@@ -24,6 +63,7 @@ interface AgentChatMessage {
24
63
  systemMeta?: Record<string, unknown>;
25
64
  errorInfo?: AgentChatErrorInfo;
26
65
  images?: AgentChatImageAttachment[];
66
+ attachments?: AgentChatDisplayAttachment[];
27
67
  }
28
68
  interface AgentChatToolCallInfo {
29
69
  id: string;
@@ -331,6 +371,8 @@ interface AgentChatAdapter {
331
371
  sessionId: string;
332
372
  content: string;
333
373
  images?: AgentChatImageAttachment[];
374
+ metadata?: Record<string, unknown>;
375
+ attachments?: AgentChatAttachment[];
334
376
  }): Promise<{
335
377
  eventId?: number;
336
378
  status?: string;
@@ -462,7 +504,7 @@ interface AgentChatRuntimeApi {
462
504
  tokenUsage: AgentChatTokenUsage;
463
505
  retryIndicator: AgentChatRetryIndicator | null;
464
506
  workspaceRefreshKey: number;
465
- send(content: string, images?: AgentChatImageAttachment[]): Promise<void>;
507
+ send(content: string, images?: AgentChatImageAttachment[], attachments?: AgentChatPendingAttachment[]): Promise<void>;
466
508
  stop(): Promise<void>;
467
509
  retry(): Promise<void>;
468
510
  markSending(content: string): void;
@@ -495,6 +537,17 @@ type WorkspaceTree = AgentChatWorkspaceTree;
495
537
  type WorkspaceFile = AgentChatWorkspaceFile;
496
538
  type WorkspaceUpload = AgentChatWorkspaceUpload;
497
539
 
540
+ interface ChatComposerError {
541
+ /**
542
+ * Stable error code so callers can route different rejections (e.g.
543
+ * show a different toast variant per code) without parsing the
544
+ * human-readable message.
545
+ */
546
+ code: "accept" | "max_files" | "max_file_size" | "max_images" | "max_image_size" | "max_attachments" | "max_attachment_size" | "max_attachments_total";
547
+ /** Display-ready, single-sentence reason. */
548
+ message: string;
549
+ }
550
+
498
551
  interface AgentChatProps {
499
552
  adapter: AgentChatAdapter;
500
553
  agentId?: string;
@@ -503,8 +556,14 @@ interface AgentChatProps {
503
556
  onFileSelect?: (path: string) => void;
504
557
  onMessagesChange?: (messages: AgentChatMessage[]) => void;
505
558
  disabled?: boolean;
559
+ /**
560
+ * Called when the composer rejects a file selection before sending —
561
+ * size/count caps, accept-pattern misses. Host apps wire this to
562
+ * their toast system; the SDK does not surface these on its own.
563
+ */
564
+ onComposerError?: (err: ChatComposerError) => void;
506
565
  }
507
- declare function AgentChat({ adapter, agentId, sessionId, onSessionChange, onFileSelect, onMessagesChange, disabled, }: AgentChatProps): react_jsx_runtime.JSX.Element;
566
+ declare function AgentChat({ adapter, agentId, sessionId, onSessionChange, onFileSelect, onMessagesChange, disabled, onComposerError, }: AgentChatProps): react_jsx_runtime.JSX.Element;
508
567
 
509
568
  interface AgentChatAdapterContextValue {
510
569
  adapter: AgentChatAdapter;
@@ -579,4 +638,4 @@ interface SessionTreePanelProps {
579
638
  }
580
639
  declare function SessionTreePanel({ adapter, sessionId, activeSessionId, agentId, title, sessionListLimit, hideRoot, hideHeader, loadList, onSessionSelect, onSessionDelete, }: SessionTreePanelProps): react_jsx_runtime.JSX.Element | null;
581
640
 
582
- export { AgentChat, type AgentChatAdapter, type AgentChatAdapterContextValue, AgentChatAdapterProvider, type AgentChatArtifactKind, type AgentChatArtifactMeta, type AgentChatArtifactPayload, type AgentChatChartArtifactSpec, type AgentChatClarifyAnswer, type AgentChatClarifyArgs, type AgentChatClarifyChoice, type AgentChatClarifyQuestion, type AgentChatErrorCategory, type AgentChatErrorInfo, type AgentChatEventStream, type AgentChatEventType, type AgentChatExpertFeedbackRating, type AgentChatHtmlArtifactSpec, type AgentChatImageAttachment, type AgentChatInboxEventStream, type AgentChatInboxItem, type AgentChatInboxKind, type AgentChatInboxList, type AgentChatInboxListInput, type AgentChatInboxStatus, type AgentChatInboxStreamEvent, type AgentChatMarkdownArtifactSpec, type AgentChatMessage, type AgentChatMessageStatus, type AgentChatProps, type AgentChatRole, type AgentChatRuntimeApi, type AgentChatRuntimeEvent, type AgentChatScheduledWorkItem, type AgentChatScheduledWorkKind, type AgentChatScheduledWorkList, type AgentChatSession, type AgentChatSessionList, type AgentChatSessionTree, type AgentChatSessionTreeNode, type AgentChatSlashCommand, type AgentChatSseMessageEvent, type AgentChatState, type AgentChatSvgArtifactSpec, type AgentChatSystemKind, type AgentChatTableArtifactSpec, type AgentChatTokenUsage, type AgentChatToolCallInfo, type AgentChatWorkspaceEntry, type AgentChatWorkspaceFile, type AgentChatWorkspaceTree, type AgentChatWorkspaceUpload, type ArtifactKind, type ArtifactPayload, type ChartArtifactSpec, type ChatMessage, type ClarifyAnswer, type ClarifyArgs, type ClarifyChoice, type ClarifyQuestion, type ErrorInfo, type HtmlArtifactSpec, type InboxItem, type InboxList, InboxPanel, type InboxPanelProps, type InboxUnreadCountState, type MarkdownArtifactSpec, MessageResponse, type MessageResponseProps, type RetryIndicator, type ScheduledWorkItem, type ScheduledWorkList, ScheduledWorkPanel, type ScheduledWorkPanelProps, type SessionTree, type SessionTreeNode, SessionTreePanel, type SessionTreePanelProps, type SvgArtifactSpec, type TableArtifactSpec, type TokenUsage, type ToolCallInfo, type WorkspaceEntry, type WorkspaceFile, type WorkspaceTree, type WorkspaceUpload, useAgentChatAdapterContext, useAgentChatRuntime, useInboxUnreadCount };
641
+ export { AgentChat, type AgentChatAdapter, type AgentChatAdapterContextValue, AgentChatAdapterProvider, type AgentChatArtifactKind, type AgentChatArtifactMeta, type AgentChatArtifactPayload, type AgentChatAttachment, type AgentChatChartArtifactSpec, type AgentChatClarifyAnswer, type AgentChatClarifyArgs, type AgentChatClarifyChoice, type AgentChatClarifyQuestion, type AgentChatDisplayAttachment, type AgentChatErrorCategory, type AgentChatErrorInfo, type AgentChatEventStream, type AgentChatEventType, type AgentChatExpertFeedbackRating, type AgentChatHtmlArtifactSpec, type AgentChatImageAttachment, type AgentChatInboxEventStream, type AgentChatInboxItem, type AgentChatInboxKind, type AgentChatInboxList, type AgentChatInboxListInput, type AgentChatInboxStatus, type AgentChatInboxStreamEvent, type AgentChatMarkdownArtifactSpec, type AgentChatMessage, type AgentChatMessageStatus, type AgentChatPendingAttachment, type AgentChatProps, type AgentChatRole, type AgentChatRuntimeApi, type AgentChatRuntimeEvent, type AgentChatScheduledWorkItem, type AgentChatScheduledWorkKind, type AgentChatScheduledWorkList, type AgentChatSession, type AgentChatSessionList, type AgentChatSessionTree, type AgentChatSessionTreeNode, type AgentChatSlashCommand, type AgentChatSseMessageEvent, type AgentChatState, type AgentChatSvgArtifactSpec, type AgentChatSystemKind, type AgentChatTableArtifactSpec, type AgentChatTokenUsage, type AgentChatToolCallInfo, type AgentChatWorkspaceEntry, type AgentChatWorkspaceFile, type AgentChatWorkspaceTree, type AgentChatWorkspaceUpload, type ArtifactKind, type ArtifactPayload, type ChartArtifactSpec, type ChatComposerError, type ChatMessage, type ClarifyAnswer, type ClarifyArgs, type ClarifyChoice, type ClarifyQuestion, type ErrorInfo, type HtmlArtifactSpec, type InboxItem, type InboxList, InboxPanel, type InboxPanelProps, type InboxUnreadCountState, type MarkdownArtifactSpec, MessageResponse, type MessageResponseProps, type RetryIndicator, type ScheduledWorkItem, type ScheduledWorkList, ScheduledWorkPanel, type ScheduledWorkPanelProps, type SessionTree, type SessionTreeNode, SessionTreePanel, type SessionTreePanelProps, type SvgArtifactSpec, type TableArtifactSpec, type TokenUsage, type ToolCallInfo, type WorkspaceEntry, type WorkspaceFile, type WorkspaceTree, type WorkspaceUpload, useAgentChatAdapterContext, useAgentChatRuntime, useInboxUnreadCount };