@uraiagent/react 0.0.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.
Files changed (83) hide show
  1. package/README.md +133 -0
  2. package/dist/Root.d.ts +8 -0
  3. package/dist/Widget.d.ts +1 -0
  4. package/dist/components/Agent/AgentAvatar.d.ts +1 -0
  5. package/dist/components/Agent/AgentInitialMessage.d.ts +3 -0
  6. package/dist/components/Agent/AgentMaximize.d.ts +1 -0
  7. package/dist/components/Agent/AgentMessage.d.ts +2 -0
  8. package/dist/components/Agent/AgentMessageWrapper.d.ts +9 -0
  9. package/dist/components/Agent/index.d.ts +5 -0
  10. package/dist/components/Chat/ChatFooter.d.ts +1 -0
  11. package/dist/components/Chat/ChatHeader.d.ts +1 -0
  12. package/dist/components/Chat/ChatLoader.d.ts +6 -0
  13. package/dist/components/Chat/ChatScreen.d.ts +1 -0
  14. package/dist/components/Chat/ChatWarning.d.ts +4 -0
  15. package/dist/components/Chat/WidgetTrigger.d.ts +10 -0
  16. package/dist/components/Chat/index.d.ts +6 -0
  17. package/dist/components/Dialog/Dialog.d.ts +12 -0
  18. package/dist/components/Dialog/index.d.ts +1 -0
  19. package/dist/components/Event/Confirmation.d.ts +4 -0
  20. package/dist/components/Event/EventMessage.d.ts +2 -0
  21. package/dist/components/Event/Fallback.d.ts +7 -0
  22. package/dist/components/Event/FollowUp.d.ts +4 -0
  23. package/dist/components/Event/Handoff.d.ts +4 -0
  24. package/dist/components/Event/Progress.d.ts +1 -0
  25. package/dist/components/Event/Text.d.ts +9 -0
  26. package/dist/components/Event/index.d.ts +7 -0
  27. package/dist/components/Loader.d.ts +5 -0
  28. package/dist/components/User/UserAvatar.d.ts +1 -0
  29. package/dist/components/User/UserMessage.d.ts +2 -0
  30. package/dist/components/User/index.d.ts +2 -0
  31. package/dist/components/Voice/VoiceRecorder.d.ts +4 -0
  32. package/dist/components/Voice/index.d.ts +1 -0
  33. package/dist/components/Vote/Vote.d.ts +3 -0
  34. package/dist/components/Vote/index.d.ts +1 -0
  35. package/dist/components/index.d.ts +6 -0
  36. package/dist/contexts/ConfigContext.d.ts +10 -0
  37. package/dist/contexts/DialogContext.d.ts +10 -0
  38. package/dist/contexts/LanguageProvider.d.ts +10 -0
  39. package/dist/contexts/MessageProvider.d.ts +12 -0
  40. package/dist/contexts/WidgetContext.d.ts +23 -0
  41. package/dist/contexts/index.d.ts +5 -0
  42. package/dist/contexts/session/SessionContext.d.ts +12 -0
  43. package/dist/contexts/session/index.d.ts +2 -0
  44. package/dist/contexts/session/session.api.d.ts +61 -0
  45. package/dist/contexts/session/session.cookie.d.ts +3 -0
  46. package/dist/contexts/socket/SocketContext.d.ts +15 -0
  47. package/dist/contexts/socket/channels.d.ts +2 -0
  48. package/dist/contexts/socket/index.d.ts +1 -0
  49. package/dist/contexts/socket/pusher.client.d.ts +9 -0
  50. package/dist/contexts/socket/ws.config.d.ts +15 -0
  51. package/dist/helpers/ComponentRegistry.d.ts +13 -0
  52. package/dist/helpers/MessageHandler.d.ts +78 -0
  53. package/dist/hooks/index.d.ts +11 -0
  54. package/dist/hooks/useAsyncFn.d.ts +23 -0
  55. package/dist/hooks/useAudioRecord.d.ts +27 -0
  56. package/dist/hooks/useCanSend.d.ts +6 -0
  57. package/dist/hooks/useChatLoading.d.ts +1 -0
  58. package/dist/hooks/useChatState.d.ts +1 -0
  59. package/dist/hooks/useDocumentDirection.d.ts +7 -0
  60. package/dist/hooks/useMountedState.d.ts +1 -0
  61. package/dist/hooks/useOutsideClick.d.ts +1 -0
  62. package/dist/hooks/useScrollTo.d.ts +2 -0
  63. package/dist/hooks/useSendMessage.d.ts +3 -0
  64. package/dist/hooks/useToast.d.ts +44 -0
  65. package/dist/hooks/useToggle.d.ts +2 -0
  66. package/dist/hooks/useTrigger.d.ts +1 -0
  67. package/dist/hooks/useVote.d.ts +2 -0
  68. package/dist/index.cjs.js +202 -0
  69. package/dist/index.d.ts +6 -0
  70. package/dist/index.es.js +88453 -0
  71. package/dist/interfaces/components.d.ts +9 -0
  72. package/dist/interfaces/config.d.ts +101 -0
  73. package/dist/interfaces/form.d.ts +15 -0
  74. package/dist/interfaces/helpers.d.ts +2 -0
  75. package/dist/interfaces/index.d.ts +5 -0
  76. package/dist/interfaces/messages.d.ts +127 -0
  77. package/dist/interfaces/translations.d.ts +3 -0
  78. package/dist/utils/cn.d.ts +2 -0
  79. package/dist/utils/icons.d.ts +1 -0
  80. package/dist/utils/index.d.ts +126 -0
  81. package/dist/utils/map.d.ts +9 -0
  82. package/dist-embed/agent.js +204 -0
  83. package/package.json +110 -0
package/README.md ADDED
@@ -0,0 +1,133 @@
1
+ # uraiagent
2
+
3
+ The `Agent Widget` in uraiagent is a customizable and embeddable component for creating chat widgets with configurable options and styles. This documentation outlines the properties, types, and usage of the widget.
4
+
5
+ ---
6
+
7
+ ## Installation
8
+
9
+ Install the package via npm:
10
+
11
+ ```bash
12
+ npm install uraiagent
13
+ ```
14
+
15
+ ---
16
+
17
+ ## Usage
18
+
19
+ ```tsx
20
+ import React from "react";
21
+ import { Root } from "agent-widget";
22
+
23
+ const Agent = () => {
24
+ return (
25
+ <Root
26
+ options={{
27
+ token: "your_token",
28
+ api: "https://your.api.endpoint",
29
+ socket: "https://your.socket.endpoint",
30
+ initialMessage: "Hello! How can I assist you?",
31
+ description: { visible: true, text: "How can we help?" },
32
+ components: [{ key: "example", component: <div></div> }],
33
+ containerProps: {
34
+ style: { position: "fixed", zIndex: 99 },
35
+ },
36
+ }}
37
+ classNames={{
38
+ shadow: "xl",
39
+ }}
40
+ >
41
+ <Widget />
42
+ </Root>
43
+ );
44
+ };
45
+
46
+ export default Agent;
47
+ ```
48
+
49
+ ---
50
+
51
+ ## API
52
+
53
+ ### `OptionsProps`
54
+
55
+ | **Property** | **Type** | **Default** | **Description** |
56
+ | ------------------ | ---------------------------------------------------------------------------------------------------- | -------------------- | ------------------------------------------------------------------ |
57
+ | `token` | `string` | **Required** | Authentication token for API requests. |
58
+ | `api` | `string` | **Required** | Base URL for the API endpoint. |
59
+ | `socket` | `string` | **Required** | URL for the WebSocket connection. |
60
+ | `headers` | `Record<string, string>` | `undefined` | Custom headers for API requests. |
61
+ | `queryParams` | `Record<string, string>` | `undefined` | Query parameters to append to API requests. |
62
+ | `initialMessage` | `string` | **Required** | Initial message to display in the chat widget. |
63
+ | `defaultOpen` | `boolean` | `false` | Whether the chat widget should be open by default. |
64
+ | `debug` | `boolean` | `false` | Enables debug mode for logging. |
65
+ | `warn` | `boolean` | `false` | Enables warning logs. |
66
+ | `language` | `string` | `undefined` | Sets the language of the chat widget. |
67
+ | `containerProps` | `React.DetailedHTMLProps` | `undefined` | Props for the container `<div>` element. |
68
+ | `closeOutside` | `boolean` | `true` | Allows closing the widget by clicking outside it. |
69
+ | `description` | `{ visible?: boolean; text?: string }` | `{ visible: false }` | Configures the description text. |
70
+ | `inputPlaceholder` | `string` | `undefined` | Placeholder text for the input field. |
71
+ | `components` | `ComponentType[]` | `[]` | Array of custom components to include in the widget. |
72
+ | `user` | `{ name?: string; email?: string; phone: string; avatar?: string; custom?: Record<string, string> }` | `undefined` | Information about the user interacting with the widget. |
73
+ | `agent` | `{ name?: string; logo?: string }` | `undefined` | Information about the agent or bot responding to messages. |
74
+ | `onClose` | `() => void` | `undefined` | Callback when the widget is closed. |
75
+ | `onHandoff` | `(handout: HandoffPayloadType) => void` | `undefined` | Callback for when a conversation is handed off to another service. |
76
+
77
+ ---
78
+
79
+ ### `ConfigStyleProps`
80
+
81
+ | **Property** | **Type** | **Default** | **Description** |
82
+ | ------------------ | --------------------------------------------------------------------------------------------------- | ----------- | ----------------------------------------------------- |
83
+ | `background` | `string` | `undefined` | Background color of the widget. |
84
+ | `color` | `string` | `undefined` | Text color for the widget. |
85
+ | `borderColor` | `string` | `undefined` | Color of the widget border. |
86
+ | `borderWidth` | `1 \| 2 \| 3 \| 4` | `1` | Width of the widget border. |
87
+ | `borderRadius` | `"none" \| "sm" \| "md" \| "xl"` | `"none"` | Border radius for the widget container. |
88
+ | `shadow` | `"none" \| "sm" \| "md" \| "xl"` | `"none"` | Shadow style for the widget. |
89
+ | `trigger` | `{ style?: string; icon?: ReactNode }` | `undefined` | Custom styles and icon for the widget trigger button. |
90
+ | `input` | `{ style?: string; wrapper?: string }` | `undefined` | Custom styles for the input field and wrapper. |
91
+ | `descriptionStyle` | `string` | `undefined` | Custom style for the description text. |
92
+ | `messages` | `{ agent?: { wrapper?: string; content?: string }; user?: { wrapper?: string; content?: string } }` | `undefined` | Custom styles for messages sent by the agent or user. |
93
+
94
+ ---
95
+
96
+ ## Example Configurations
97
+
98
+ ### Basic Setup
99
+
100
+ ```tsx
101
+ <Root
102
+ options={{
103
+ token: "example_token",
104
+ api: "https://example.api",
105
+ socket: "https://example.socket",
106
+ initialMessage: "Welcome!",
107
+ }}
108
+ />
109
+ ```
110
+
111
+ ### With Custom Styles
112
+
113
+ ```tsx
114
+ <Root
115
+ options={{
116
+ token: "example_token",
117
+ api: "https://example.api",
118
+ socket: "https://example.socket",
119
+ initialMessage: "Welcome!",
120
+ }}
121
+ classNames={{
122
+ background: "#f4f4f4",
123
+ borderColor: "#ccc",
124
+ borderWidth: 2,
125
+ borderRadius: "md",
126
+ shadow: "sm",
127
+ }}
128
+ />
129
+ ```
130
+
131
+ ---
132
+
133
+ Let me know if additional refinements are needed!
package/dist/Root.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+ import { WidgetConfig } from '.';
3
+ type RootProps = {
4
+ children: React.ReactNode;
5
+ config: WidgetConfig;
6
+ };
7
+ declare function Root({ children, config }: RootProps): import("react/jsx-runtime").JSX.Element;
8
+ export default Root;
@@ -0,0 +1 @@
1
+ export declare function AgentWidget(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function AgentAvatar(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export declare function AgentInitialMessage({ message }: {
2
+ message?: string;
3
+ }): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1 @@
1
+ export declare function AgentMaximize(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { AgentMessageProps } from '../../interfaces';
2
+ export declare function AgentMessage(message: AgentMessageProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,9 @@
1
+ type AgentMessage = {
2
+ children: React.ReactNode;
3
+ _id?: string;
4
+ className?: string;
5
+ isComponent?: boolean;
6
+ createdAt?: string;
7
+ };
8
+ export declare function AgentMessageWrapper({ children, _id, className, isComponent, createdAt, }: AgentMessage): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,5 @@
1
+ export * from './AgentAvatar';
2
+ export * from './AgentInitialMessage';
3
+ export * from './AgentMaximize';
4
+ export * from './AgentMessage';
5
+ export * from './AgentMessageWrapper';
@@ -0,0 +1 @@
1
+ export declare function ChatFooter(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare function ChatHeader(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { HTMLAttributes } from 'react';
2
+ interface ChatLoaderProps extends HTMLAttributes<HTMLDivElement> {
3
+ reachedBottomInitially: boolean;
4
+ }
5
+ export declare const ChatLoader: import('react').ForwardRefExoticComponent<ChatLoaderProps & import('react').RefAttributes<HTMLDivElement>>;
6
+ export {};
@@ -0,0 +1 @@
1
+ export declare function ChatScreen(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ declare const ChatWarning: ({ onClose }: {
2
+ onClose: () => void;
3
+ }) => import("react/jsx-runtime").JSX.Element;
4
+ export default ChatWarning;
@@ -0,0 +1,10 @@
1
+ type Props = {
2
+ open: boolean;
3
+ hover: boolean;
4
+ canSend?: boolean;
5
+ customIcon?: React.ReactNode;
6
+ onClick: () => void;
7
+ onMouseOver: () => void;
8
+ };
9
+ export declare function WidgetTrigger({ open, hover, canSend, customIcon, onClick, onMouseOver, }: Props): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,6 @@
1
+ export * from './ChatFooter';
2
+ export * from './ChatHeader';
3
+ export * from './ChatLoader';
4
+ export * from './ChatScreen';
5
+ export * from './ChatWarning';
6
+ export * from './WidgetTrigger';
@@ -0,0 +1,12 @@
1
+ type DialogProps = {
2
+ open?: boolean;
3
+ children: React.ReactNode;
4
+ onOpenChange?: (open: boolean) => void;
5
+ };
6
+ declare function Dialog({ children, ...props }: DialogProps): import('react').ReactNode;
7
+ declare const DialogTrigger: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import('react').RefAttributes<HTMLButtonElement>>;
8
+ declare const DialogOverlay: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
9
+ declare const DialogContent: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
10
+ declare const DialogClose: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & import('react').RefAttributes<HTMLButtonElement>>;
11
+ declare const DialogHeader: import('react').ForwardRefExoticComponent<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import('react').RefAttributes<HTMLDivElement>>;
12
+ export { Dialog, DialogTrigger, DialogOverlay, DialogContent, DialogClose, DialogHeader, };
@@ -0,0 +1 @@
1
+ export * from './Dialog';
@@ -0,0 +1,4 @@
1
+ import { ComponentProps, ConfirmationEvent } from '../../interfaces';
2
+ type Props = ComponentProps<ConfirmationEvent>;
3
+ export declare const Confirmation: (props: Props) => import("react/jsx-runtime").JSX.Element;
4
+ export {};
@@ -0,0 +1,2 @@
1
+ import { EventMessageProps } from '../../interfaces';
2
+ export declare function EventMessage(message: EventMessageProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,7 @@
1
+ import { ComponentProps } from '../../interfaces';
2
+ type Props = ComponentProps<unknown>;
3
+ /**
4
+ * The Basic Fallback component (Rendered when Debug is True and the component key is not found)
5
+ */
6
+ export declare function Fallback(props: Props): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,4 @@
1
+ import { ComponentProps, FollowUpProps } from '../../interfaces';
2
+ type Props = ComponentProps<FollowUpProps>;
3
+ export declare const FollowUp: (props: Props) => import("react/jsx-runtime").JSX.Element | null;
4
+ export {};
@@ -0,0 +1,4 @@
1
+ import { ComponentProps, HandoffPayloadType } from '../../interfaces';
2
+ type Props = ComponentProps<HandoffPayloadType>;
3
+ export declare const Handoff: (props: Props) => import("react/jsx-runtime").JSX.Element;
4
+ export {};
@@ -0,0 +1 @@
1
+ export declare function Progress(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,9 @@
1
+ import { ComponentProps } from '../../interfaces';
2
+ type Props = ComponentProps<{
3
+ message: string;
4
+ }>;
5
+ /**
6
+ * The Basic Text component
7
+ */
8
+ export declare function Text({ _id, data, createdAt }: Props): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,7 @@
1
+ export * from './EventMessage';
2
+ export * from './Confirmation';
3
+ export * from './Fallback';
4
+ export * from './FollowUp';
5
+ export * from './Handoff';
6
+ export * from './Progress';
7
+ export * from './Text';
@@ -0,0 +1,5 @@
1
+ type LoaderProps = {
2
+ size?: "sm" | "md";
3
+ };
4
+ declare const Loader: ({ size }: LoaderProps) => import("react/jsx-runtime").JSX.Element;
5
+ export default Loader;
@@ -0,0 +1 @@
1
+ export declare function UserAvatar(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { UserMessageProps } from '../..';
2
+ export declare function UserMessage({ message, _id, createdAt }: UserMessageProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export * from './UserAvatar';
2
+ export * from './UserMessage';
@@ -0,0 +1,4 @@
1
+ export declare function VoiceRecorder({ onSuccess, disabled, }: {
2
+ onSuccess?: (text: string) => void;
3
+ disabled?: boolean;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './VoiceRecorder';
@@ -0,0 +1,3 @@
1
+ export declare function Vote({ messageId }: {
2
+ messageId: number;
3
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export * from './Vote';
@@ -0,0 +1,6 @@
1
+ export * from './Agent';
2
+ export * from './Chat';
3
+ export * from './User';
4
+ export * from './Voice';
5
+ export * from './Vote';
6
+ export * from './Event';
@@ -0,0 +1,10 @@
1
+ import { ConfigProps } from '../interfaces';
2
+ import { ReactNode } from 'react';
3
+ export type ConfigContextType = Omit<ConfigProps, "container">;
4
+ type ConfigProviderProps = {
5
+ data: ConfigContextType;
6
+ children: ReactNode;
7
+ };
8
+ export declare const ConfigProvider: ({ children, data }: ConfigProviderProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const useConfig: () => ConfigContextType;
10
+ export {};
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ type DialogInstanceProps = {
3
+ open: boolean;
4
+ set: (val: boolean) => void;
5
+ };
6
+ export declare const DialogProvider: ({ children }: {
7
+ children: ReactNode;
8
+ }) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const useDialog: () => DialogInstanceProps;
10
+ export {};
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ type LanguageProps = {
3
+ lang: string;
4
+ get: (key: string) => string;
5
+ };
6
+ export declare const LanguageProvider: ({ children }: {
7
+ children: ReactNode;
8
+ }) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const useLanguage: () => LanguageProps;
10
+ export {};
@@ -0,0 +1,12 @@
1
+ import { ComponentRegistry } from '../helpers/ComponentRegistry';
2
+ import { ChatController } from '../helpers/MessageHandler';
3
+ type Props = {
4
+ children: React.ReactNode;
5
+ };
6
+ type MessageContextType = {
7
+ _handler: ChatController;
8
+ _components: ComponentRegistry;
9
+ };
10
+ export declare const MessageProvider: ({ children }: Props) => import("react/jsx-runtime").JSX.Element;
11
+ export declare const useMessage: () => MessageContextType;
12
+ export {};
@@ -0,0 +1,23 @@
1
+ import { ReactNode } from 'react';
2
+ type WidgetContextType = {
3
+ open: boolean;
4
+ maximize: {
5
+ value: boolean;
6
+ component: ReactNode | null;
7
+ };
8
+ hover: boolean;
9
+ setMaximize: (data: {
10
+ value: boolean;
11
+ component: ReactNode | null;
12
+ }) => void;
13
+ setOpen: (data: boolean) => void;
14
+ setHover: (data: boolean) => void;
15
+ toggleWidget: () => void;
16
+ toggleMaximize: (component: ReactNode | null) => void;
17
+ onClose: () => void;
18
+ };
19
+ export declare const WidgetProvider: ({ children }: {
20
+ children: ReactNode;
21
+ }) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const useWidget: () => WidgetContextType;
23
+ export {};
@@ -0,0 +1,5 @@
1
+ export * from './ConfigContext';
2
+ export * from './MessageProvider';
3
+ export * from './WidgetContext';
4
+ export * from './socket';
5
+ export * from './session';
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ type SessionContextType = {
3
+ sessionId: string | null;
4
+ conversationId: string | null;
5
+ ensureSession: () => Promise<string>;
6
+ isCreating: boolean;
7
+ };
8
+ export declare function SessionProvider({ children }: {
9
+ children: ReactNode;
10
+ }): import("react/jsx-runtime").JSX.Element;
11
+ export declare function useSession(): SessionContextType;
12
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './SessionContext';
2
+ export * from './session.api';
@@ -0,0 +1,61 @@
1
+ export interface ChatMessage {
2
+ id: string;
3
+ role: "user" | "agent";
4
+ text: string;
5
+ createdAt: string;
6
+ senderName?: string;
7
+ senderAvatarUrl?: string;
8
+ /** MessageContentTypeEnum value — 'text' | 'ui_component' | 'mixed'. */
9
+ type?: string;
10
+ /** Present for ui_component messages so widget history re-renders. */
11
+ uiComponent?: {
12
+ componentType: string;
13
+ componentId?: string;
14
+ data?: {
15
+ structure?: Record<string, unknown>;
16
+ state?: Record<string, unknown>;
17
+ [k: string]: unknown;
18
+ };
19
+ };
20
+ }
21
+ export interface SessionResponse {
22
+ sessionId: string;
23
+ conversationId: string;
24
+ }
25
+ export interface SessionHistoryResponse extends SessionResponse {
26
+ messages: ChatMessage[];
27
+ }
28
+ export interface CreateSessionOptions {
29
+ organizationId: string;
30
+ agentId: string;
31
+ agentName?: string;
32
+ user?: {
33
+ name?: string;
34
+ email?: string;
35
+ phone?: string;
36
+ };
37
+ }
38
+ export declare function createSession(api: string, widgetToken: string, options: CreateSessionOptions): Promise<SessionResponse>;
39
+ export declare function loadSession(api: string, sessionId: string, widgetToken: string, organizationId: string): Promise<SessionHistoryResponse>;
40
+ export interface SendMessageOptions {
41
+ headers?: Record<string, string>;
42
+ queryParams?: Record<string, string>;
43
+ }
44
+ export declare function sendMessage(api: string, sessionId: string, message: string, organizationId: string, options?: SendMessageOptions): Promise<{
45
+ ok: boolean;
46
+ }>;
47
+ export interface WidgetActionRequest {
48
+ action: {
49
+ type: string;
50
+ payload?: unknown;
51
+ };
52
+ source: {
53
+ executionId: string;
54
+ nodeId?: string;
55
+ messageId: string;
56
+ };
57
+ }
58
+ /** Post a widget button action (e.g. approve/reject) back to the backend to resume a workflow. */
59
+ export declare function sendAction(api: string, sessionId: string, organizationId: string, body: WidgetActionRequest): Promise<{
60
+ ok: boolean;
61
+ }>;
@@ -0,0 +1,3 @@
1
+ export declare function getSessionId(): string | null;
2
+ export declare function setSessionId(id: string): void;
3
+ export declare function clearSessionId(): void;
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+ type EventHandler<T = any> = (data: T) => void;
3
+ /** Mirrors Pusher's native connection state machine. */
4
+ export type WsConnectionState = "initialized" | "connecting" | "connected" | "unavailable" | "failed" | "disconnected";
5
+ type SocketContextType = {
6
+ wsReady: boolean;
7
+ connectionState: WsConnectionState;
8
+ on: <T = unknown>(event: string, handler: EventHandler<T>) => void;
9
+ off: <T = unknown>(event: string, handler: EventHandler<T>) => void;
10
+ };
11
+ export declare function SocketProvider({ children }: {
12
+ children: ReactNode;
13
+ }): import("react/jsx-runtime").JSX.Element;
14
+ export declare function useSocketContext(): SocketContextType;
15
+ export {};
@@ -0,0 +1,2 @@
1
+ /** Public channel for a guest widget session. No auth required. */
2
+ export declare const widgetSupportChannel: (sessionId: string) => `public-support.${string}`;
@@ -0,0 +1 @@
1
+ export * from './SocketContext';
@@ -0,0 +1,9 @@
1
+ import { default as Pusher } from 'pusher-js';
2
+ interface PusherConfig {
3
+ wsKey: string;
4
+ wsHost: string;
5
+ wsPort: number;
6
+ forceTls: boolean;
7
+ }
8
+ export declare function createPusherClient({ wsKey, wsHost, wsPort, forceTls, }: PusherConfig): Pusher;
9
+ export {};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Centralized realtime-transport (Soketi / Pusher) configuration.
3
+ *
4
+ * These values are intentionally hardcoded here and hidden from the public
5
+ * widget props — consumers should not need to know our broker details to embed
6
+ * the widget. This is the single source of truth: if we later need per-deployment
7
+ * values again, either expose them on the public config or replace these
8
+ * constants with a `/widget-config` bootstrap fetch, and nothing else changes.
9
+ */
10
+ export declare const WS_CONFIG: {
11
+ readonly key: "uraiagent-key";
12
+ readonly host: "ws.uraiagent.com";
13
+ readonly port: 443;
14
+ readonly forceTls: true;
15
+ };
@@ -0,0 +1,13 @@
1
+ import { ComponentType, OptionsType } from '../interfaces';
2
+ /**
3
+ * this a singleton class helps me to easily control the components present/available in the widget.
4
+ * it also manages the various types of components to be added along the way.
5
+ */
6
+ export declare class ComponentRegistry {
7
+ components: ComponentType[];
8
+ constructor(opts: OptionsType);
9
+ private get;
10
+ private getOrFallback;
11
+ getComponent(key: string, getFallback?: boolean): import('react').ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
12
+ register(com: ComponentType): this;
13
+ }