@uraiagent/react 0.0.5 → 0.0.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.
@@ -0,0 +1,5 @@
1
+ import { AttachmentRef } from '../../interfaces/messages';
2
+ /** Renders a message's attachments, choosing a presentation per file type. */
3
+ export declare function MessageAttachments({ attachments }: {
4
+ attachments?: AttachmentRef[];
5
+ }): import("react/jsx-runtime").JSX.Element | null;
@@ -5,5 +5,5 @@ type Props = ComponentProps<{
5
5
  /**
6
6
  * The Basic Text component
7
7
  */
8
- export declare function Text({ _id, data, createdAt }: Props): import("react/jsx-runtime").JSX.Element;
8
+ export declare function Text({ _id, data, createdAt, attachments }: Props): import("react/jsx-runtime").JSX.Element;
9
9
  export {};
@@ -1,2 +1,2 @@
1
1
  import { UserMessageProps } from '../../interfaces/messages';
2
- export declare function UserMessage({ message, _id, createdAt }: UserMessageProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function UserMessage({ message, _id, createdAt, attachments }: UserMessageProps): import("react/jsx-runtime").JSX.Element;
@@ -3,6 +3,9 @@ type SessionContextType = {
3
3
  sessionId: string | null;
4
4
  conversationId: string | null;
5
5
  ensureSession: () => Promise<string>;
6
+ /** Adopt a session id the backend resolved us onto (e.g. it resumed an archived conversation onto
7
+ * a fresh one) so we persist + subscribe to the right session. */
8
+ adoptSession: (sessionId: string, conversationId?: string) => void;
6
9
  isCreating: boolean;
7
10
  };
8
11
  export declare function SessionProvider({ children }: {
@@ -1,3 +1,11 @@
1
+ export interface AttachmentRef {
2
+ id: string;
3
+ /** Permanent public URL (object stored public-read under an unguessable randomized key). */
4
+ url: string;
5
+ filename: string;
6
+ mimeType: string;
7
+ size: number;
8
+ }
1
9
  export interface ChatMessage {
2
10
  id: string;
3
11
  role: "user" | "agent";
@@ -5,6 +13,7 @@ export interface ChatMessage {
5
13
  createdAt: string;
6
14
  senderName?: string;
7
15
  senderAvatarUrl?: string;
16
+ attachments?: AttachmentRef[];
8
17
  /** MessageContentTypeEnum value — 'text' | 'ui_component' | 'mixed'. */
9
18
  type?: string;
10
19
  /** Present for ui_component messages so widget history re-renders. */
@@ -22,7 +31,10 @@ export interface SessionResponse {
22
31
  sessionId: string;
23
32
  conversationId: string;
24
33
  }
34
+ export type ConversationLifecycleState = "active" | "resolved" | "archived";
25
35
  export interface SessionHistoryResponse extends SessionResponse {
36
+ /** Lifecycle state of the resolved conversation (informational). */
37
+ state?: ConversationLifecycleState;
26
38
  messages: ChatMessage[];
27
39
  }
28
40
  export interface CreateSessionOptions {
@@ -79,10 +91,16 @@ export declare function loadSession(api: string, sessionId: string, widgetToken:
79
91
  export interface SendMessageOptions {
80
92
  headers?: Record<string, string>;
81
93
  queryParams?: Record<string, string>;
94
+ attachments?: AttachmentRef[];
82
95
  }
83
96
  export declare function sendMessage(api: string, sessionId: string, message: string, organizationId: string, options?: SendMessageOptions): Promise<{
84
97
  ok: boolean;
85
98
  }>;
99
+ /**
100
+ * Upload one file to the chat attachment endpoint. Returns the attachment ref to include on the next
101
+ * message. Note: no Content-Type header — the browser sets the multipart boundary itself.
102
+ */
103
+ export declare function uploadFile(api: string, organizationId: string, file: File): Promise<AttachmentRef>;
86
104
  export interface WidgetActionRequest {
87
105
  action: {
88
106
  type: string;
@@ -1,4 +1,4 @@
1
- import { ProgressEventType, AgentResponseUI, ConfirmationEvent, FollowUpProps, HandoffPayloadType, Message, Meta, UserMessageProps } from '../interfaces';
1
+ import { ProgressEventType, AgentResponseUI, AttachmentRef, ConfirmationEvent, FollowUpProps, HandoffPayloadType, Message, Meta, UserMessageProps } from '../interfaces';
2
2
  export type State = {
3
3
  current_message: null | UserMessageProps;
4
4
  progress_msg: null | string;
@@ -37,6 +37,7 @@ export declare class ChatController {
37
37
  createdAt: string;
38
38
  senderName?: string;
39
39
  senderAvatarUrl?: string;
40
+ attachments?: AttachmentRef[];
40
41
  type?: string;
41
42
  uiComponent?: {
42
43
  componentType: string;
@@ -49,10 +50,10 @@ export declare class ChatController {
49
50
  };
50
51
  };
51
52
  }>) => void;
52
- /** Optimistically add the user's message and mark as loading. */
53
- appendUserMessage: (message: string) => string;
53
+ /** Optimistically add the user's message (with any attachments) and mark as loading. */
54
+ appendUserMessage: (message: string, attachments?: AttachmentRef[]) => string;
54
55
  /** Add a complete agent message (non-streaming). */
55
- appendAgentMessageFull: (id: string, text: string, senderName?: string, senderAvatarUrl?: string) => void;
56
+ appendAgentMessageFull: (id: string, text: string, senderName?: string, senderAvatarUrl?: string, attachments?: AttachmentRef[]) => void;
56
57
  /** Append a streaming chunk to the current in-progress agent message. */
57
58
  appendAgentMessage: (text: string) => void;
58
59
  /**
@@ -1,3 +1,3 @@
1
1
  export declare function useSendMessage(): {
2
- send: (message: string) => Promise<void>;
2
+ send: (message: string, files?: File[]) => Promise<void>;
3
3
  };