@uraiagent/react 0.0.5 → 0.0.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.
- package/dist/Widget.d.ts +7 -3
- package/dist/components/Attachment/MessageAttachments.d.ts +6 -0
- package/dist/components/Chat/ChatFooter.d.ts +6 -0
- package/dist/components/Chat/ChatScreen.d.ts +5 -0
- package/dist/components/Event/Text.d.ts +1 -1
- package/dist/components/Launcher/WidgetLauncher.d.ts +9 -0
- package/dist/components/Panel/PanelHeader.d.ts +6 -0
- package/dist/components/Panel/WidgetPanel.d.ts +7 -0
- package/dist/components/Screens/HomeScreen.d.ts +6 -0
- package/dist/components/User/UserMessage.d.ts +1 -1
- package/dist/contexts/WidgetContext.d.ts +10 -0
- package/dist/contexts/session/SessionContext.d.ts +3 -0
- package/dist/contexts/session/session.api.d.ts +18 -0
- package/dist/helpers/MessageHandler.d.ts +5 -4
- package/dist/hooks/useSendMessage.d.ts +1 -1
- package/dist/index.cjs.js +21 -21
- package/dist/index.es.js +7724 -7263
- package/dist/interfaces/messages.d.ts +11 -8
- package/dist/utils/index.d.ts +2 -0
- package/dist-embed/agent.js +22 -22
- package/package.json +1 -1
package/dist/Widget.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The widget's UI shell
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The widget's UI shell. A fixed bottom-right dock holding two decoupled pieces:
|
|
3
|
+
* the standalone launcher, and the panel that mounts above it on open. The morphing
|
|
4
|
+
* single-surface launcher of the old design is gone — opening/closing is now a clean
|
|
5
|
+
* swap between the two, animated by framer-motion.
|
|
6
|
+
*
|
|
7
|
+
* Internal: must render inside the providers set up by `Root`. Consumers use the
|
|
8
|
+
* unified `AgentWidget` (which composes `Root` + this).
|
|
5
9
|
*/
|
|
6
10
|
export declare function WidgetShell(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AttachmentRef } from '../../interfaces/messages';
|
|
2
|
+
/** Renders a message's attachments: images as a wrapping row of small thumbnails
|
|
3
|
+
* (Gleap-style), other file types as cards stacked below. */
|
|
4
|
+
export declare function MessageAttachments({ attachments, }: {
|
|
5
|
+
attachments?: AttachmentRef[];
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The message composer. A single rounded card: the text area sits on top, and a
|
|
3
|
+
* toolbar row underneath holds the attach + voice actions on the left and a circular
|
|
4
|
+
* send button on the right. Always active (it only mounts inside the open panel's
|
|
5
|
+
* chat view), so there's no hover/open state to juggle.
|
|
6
|
+
*/
|
|
1
7
|
export declare function ChatFooter(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The conversation view. Header and launcher live at the panel/dock level now, so
|
|
3
|
+
* this is purely the scrollable message log + the composer. Always "open" — it only
|
|
4
|
+
* mounts when the panel's `chat` view is active.
|
|
5
|
+
*/
|
|
1
6
|
export declare function ChatScreen(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -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 {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The standalone floating launcher — the only thing on screen when the widget is closed.
|
|
3
|
+
*
|
|
4
|
+
* It's fully decoupled from the panel now: clicking it opens the panel (which slides down
|
|
5
|
+
* into the launcher's corner) and the launcher itself scales/fades away. Closing reverses
|
|
6
|
+
* it. Keeps the original pulsing brand mark as the resting icon; while open it briefly shows
|
|
7
|
+
* a chevron so the affordance reads as "collapse back down".
|
|
8
|
+
*/
|
|
9
|
+
export declare function WidgetLauncher(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The panel's top bar. Keeps the original "Powered by uraiagent.com" strip (with the
|
|
3
|
+
* live connection dot) and owns the close affordance for the whole widget. On the chat
|
|
4
|
+
* screen it also offers a back arrow to the home screen.
|
|
5
|
+
*/
|
|
6
|
+
export declare function PanelHeader(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The open widget surface. Mounts above the launcher and settles down into its
|
|
3
|
+
* corner (transform-origin bottom-right), so opening reads as the panel dropping
|
|
4
|
+
* into the launcher's place. Owns the header; the body cross-fades between the
|
|
5
|
+
* home screen and the conversation.
|
|
6
|
+
*/
|
|
7
|
+
export declare function WidgetPanel(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The panel's landing screen. Gradient hero up top (with a bottom-aligned brand +
|
|
3
|
+
* welcome block, like the earlier layout), then a clean body with the single primary
|
|
4
|
+
* action. Owns its own close control since the panel drops its top bar on this view.
|
|
5
|
+
*/
|
|
6
|
+
export declare function HomeScreen(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -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;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
/** Which screen the open panel is showing. `home` = greeting + CTA, `chat` = the conversation. */
|
|
3
|
+
export type WidgetView = "home" | "chat";
|
|
2
4
|
type WidgetContextType = {
|
|
3
5
|
open: boolean;
|
|
6
|
+
/** Active panel screen. Only meaningful while `open`. */
|
|
7
|
+
view: WidgetView;
|
|
4
8
|
maximize: {
|
|
5
9
|
value: boolean;
|
|
6
10
|
component: ReactNode | null;
|
|
7
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Legacy hover flag from the old morphing-launcher design. The split
|
|
14
|
+
* launcher/panel UI no longer drives it, but it's kept so any lingering
|
|
15
|
+
* consumer keeps compiling. Always `false`.
|
|
16
|
+
*/
|
|
8
17
|
hover: boolean;
|
|
9
18
|
setMaximize: (data: {
|
|
10
19
|
value: boolean;
|
|
@@ -12,6 +21,7 @@ type WidgetContextType = {
|
|
|
12
21
|
}) => void;
|
|
13
22
|
setOpen: (data: boolean) => void;
|
|
14
23
|
setHover: (data: boolean) => void;
|
|
24
|
+
setView: (view: WidgetView) => void;
|
|
15
25
|
toggleWidget: () => void;
|
|
16
26
|
toggleMaximize: (component: ReactNode | null) => void;
|
|
17
27
|
onClose: () => void;
|
|
@@ -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
|
/**
|