@elqnt/chat 2.0.7 → 3.0.0

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 (52) hide show
  1. package/README.md +386 -0
  2. package/dist/api/index.d.mts +308 -0
  3. package/dist/api/index.d.ts +308 -0
  4. package/dist/api/index.js +220 -0
  5. package/dist/api/index.js.map +1 -0
  6. package/dist/api/index.mjs +183 -0
  7. package/dist/api/index.mjs.map +1 -0
  8. package/dist/hooks/index.d.mts +78 -0
  9. package/dist/hooks/index.d.ts +78 -0
  10. package/dist/hooks/index.js +709 -0
  11. package/dist/hooks/index.js.map +1 -0
  12. package/dist/hooks/index.mjs +683 -0
  13. package/dist/hooks/index.mjs.map +1 -0
  14. package/dist/index.d.mts +4 -109
  15. package/dist/index.d.ts +4 -109
  16. package/dist/index.js +699 -3607
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +690 -3584
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/models/index.d.mts +76 -6
  21. package/dist/models/index.d.ts +76 -6
  22. package/dist/models/index.js +21 -0
  23. package/dist/models/index.js.map +1 -1
  24. package/dist/models/index.mjs +14 -0
  25. package/dist/models/index.mjs.map +1 -1
  26. package/dist/transport/index.d.mts +243 -0
  27. package/dist/transport/index.d.ts +243 -0
  28. package/dist/transport/index.js +875 -0
  29. package/dist/transport/index.js.map +1 -0
  30. package/dist/transport/index.mjs +843 -0
  31. package/dist/transport/index.mjs.map +1 -0
  32. package/dist/types-BB5nRdZs.d.mts +222 -0
  33. package/dist/types-CNvuxtcv.d.ts +222 -0
  34. package/package.json +32 -40
  35. package/dist/hooks/use-websocket-chat-admin.d.mts +0 -17
  36. package/dist/hooks/use-websocket-chat-admin.d.ts +0 -17
  37. package/dist/hooks/use-websocket-chat-admin.js +0 -1196
  38. package/dist/hooks/use-websocket-chat-admin.js.map +0 -1
  39. package/dist/hooks/use-websocket-chat-admin.mjs +0 -1172
  40. package/dist/hooks/use-websocket-chat-admin.mjs.map +0 -1
  41. package/dist/hooks/use-websocket-chat-base.d.mts +0 -81
  42. package/dist/hooks/use-websocket-chat-base.d.ts +0 -81
  43. package/dist/hooks/use-websocket-chat-base.js +0 -1025
  44. package/dist/hooks/use-websocket-chat-base.js.map +0 -1
  45. package/dist/hooks/use-websocket-chat-base.mjs +0 -1001
  46. package/dist/hooks/use-websocket-chat-base.mjs.map +0 -1
  47. package/dist/hooks/use-websocket-chat-customer.d.mts +0 -24
  48. package/dist/hooks/use-websocket-chat-customer.d.ts +0 -24
  49. package/dist/hooks/use-websocket-chat-customer.js +0 -1092
  50. package/dist/hooks/use-websocket-chat-customer.js.map +0 -1
  51. package/dist/hooks/use-websocket-chat-customer.mjs +0 -1068
  52. package/dist/hooks/use-websocket-chat-customer.mjs.map +0 -1
package/README.md ADDED
@@ -0,0 +1,386 @@
1
+ # @elqnt/chat
2
+
3
+ Platform-agnostic chat SDK for React and React Native. Uses POST + SSE (no WebSocket) for reliable real-time communication.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @elqnt/chat
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```tsx
14
+ import { useChat } from "@elqnt/chat/hooks";
15
+
16
+ function ChatComponent() {
17
+ const {
18
+ connect,
19
+ disconnect,
20
+ sendMessage,
21
+ messages,
22
+ isConnected,
23
+ startChat,
24
+ } = useChat({
25
+ baseUrl: "https://api.example.com/chat",
26
+ orgId: "org-123",
27
+ userId: "user-456",
28
+ });
29
+
30
+ useEffect(() => {
31
+ connect();
32
+ return () => disconnect();
33
+ }, []);
34
+
35
+ const handleSend = async (text: string) => {
36
+ await sendMessage(text);
37
+ };
38
+
39
+ return (
40
+ <div>
41
+ <ConnectionStatus connected={isConnected} />
42
+ <MessageList messages={messages} />
43
+ <MessageInput onSend={handleSend} />
44
+ </div>
45
+ );
46
+ }
47
+ ```
48
+
49
+ ## Architecture
50
+
51
+ ```
52
+ ┌─────────────────────────────────────────────────────────────┐
53
+ │ Your App │
54
+ ├─────────────────────────────────────────────────────────────┤
55
+ │ useChat Hook │
56
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
57
+ │ │ State │ │ Events │ │ Chat Operations │ │
58
+ │ │ messages │ │ onMessage │ │ sendMessage │ │
59
+ │ │ chatKey │ │ on(type) │ │ startChat │ │
60
+ │ │ isConnected│ │ │ │ loadChat │ │
61
+ │ └─────────────┘ └─────────────┘ └─────────────────────┘ │
62
+ ├─────────────────────────────────────────────────────────────┤
63
+ │ Transport Layer │
64
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────────┐ │
65
+ │ │ SSE │ │ SSE-Fetch │ │ WhatsApp │ │
66
+ │ │ (Browser) │ │ (React │ │ (Backend │ │
67
+ │ │ │ │ Native) │ │ Webhook) │ │
68
+ │ └──────────────┘ └──────────────┘ └──────────────────┘ │
69
+ ├─────────────────────────────────────────────────────────────┤
70
+ │ Chat Server │
71
+ │ ┌──────────────────────────────────────────────────────┐ │
72
+ │ │ POST /create, /send, /load, /end, /typing, /event │ │
73
+ │ │ GET /stream (SSE) │ │
74
+ │ └──────────────────────────────────────────────────────┘ │
75
+ └─────────────────────────────────────────────────────────────┘
76
+ ```
77
+
78
+ ## Exports
79
+
80
+ ### `/hooks` - React Hooks
81
+
82
+ ```typescript
83
+ import { useChat } from "@elqnt/chat/hooks";
84
+ ```
85
+
86
+ **useChat Options:**
87
+
88
+ | Option | Type | Required | Description |
89
+ |--------|------|----------|-------------|
90
+ | `baseUrl` | `string` | Yes | Chat server URL |
91
+ | `orgId` | `string` | Yes | Organization ID |
92
+ | `userId` | `string` | Yes | User ID |
93
+ | `clientType` | `"customer" \| "humanAgent" \| "observer"` | No | Client type (default: "customer") |
94
+ | `transport` | `ChatTransport \| "sse" \| "sse-fetch"` | No | Transport to use |
95
+ | `onMessage` | `(event: ChatEvent) => void` | No | Event callback |
96
+ | `onError` | `(error: TransportError) => void` | No | Error callback |
97
+ | `autoConnect` | `boolean` | No | Connect on mount |
98
+ | `debug` | `boolean` | No | Enable logging |
99
+
100
+ **useChat Return:**
101
+
102
+ ```typescript
103
+ interface UseChatReturn {
104
+ // Connection
105
+ connect: () => Promise<void>;
106
+ disconnect: () => void;
107
+ connectionState: TransportState;
108
+ isConnected: boolean;
109
+
110
+ // Chat Operations
111
+ startChat: (metadata?: Record<string, unknown>) => Promise<string>;
112
+ loadChat: (chatKey: string) => Promise<void>;
113
+ sendMessage: (content: string, attachments?: unknown[]) => Promise<void>;
114
+ endChat: (reason?: string) => Promise<void>;
115
+
116
+ // Typing Indicators
117
+ startTyping: () => void;
118
+ stopTyping: () => void;
119
+
120
+ // State
121
+ currentChat: Chat | null;
122
+ chatKey: string | null;
123
+ messages: ChatMessage[];
124
+ error: TransportError | null;
125
+ metrics: ConnectionMetrics;
126
+
127
+ // Events
128
+ on: (eventType: string, handler: (event: ChatEvent) => void) => () => void;
129
+ clearError: () => void;
130
+ }
131
+ ```
132
+
133
+ ### `/api` - Low-Level API Functions
134
+
135
+ ```typescript
136
+ import {
137
+ // Browser API (uses @elqnt/api-client)
138
+ getChatHistoryApi,
139
+ getChatApi,
140
+ updateChatApi,
141
+ deleteChatApi,
142
+ getActiveChatsApi,
143
+ getActiveChatsCountApi,
144
+
145
+ // Stream API (direct HTTP)
146
+ createChat,
147
+ sendChatMessage,
148
+ loadChat,
149
+ endChat,
150
+ sendTypingIndicator,
151
+ sendEvent,
152
+ } from "@elqnt/chat/api";
153
+ ```
154
+
155
+ ### `/models` - TypeScript Types
156
+
157
+ ```typescript
158
+ import type {
159
+ Chat,
160
+ ChatMessage,
161
+ ChatEvent,
162
+ ChatEventTypeTS,
163
+ ChatUser,
164
+ ChatStatusTS,
165
+ MessageStatusTS,
166
+ Attachment,
167
+ } from "@elqnt/chat/models";
168
+ ```
169
+
170
+ ### `/transport` - Transport Adapters
171
+
172
+ ```typescript
173
+ import {
174
+ createSSETransport, // Browser EventSource
175
+ createFetchSSETransport, // React Native / Fetch-based
176
+ createWhatsAppTransport, // WhatsApp Business API (stub)
177
+ } from "@elqnt/chat/transport";
178
+
179
+ import type {
180
+ ChatTransport,
181
+ TransportConfig,
182
+ TransportState,
183
+ TransportError,
184
+ ConnectionMetrics,
185
+ } from "@elqnt/chat/transport";
186
+ ```
187
+
188
+ ## Transport Options
189
+
190
+ ### Browser (Default)
191
+
192
+ Uses native `EventSource` for SSE. This is the default and recommended transport for browser environments.
193
+
194
+ ```typescript
195
+ const chat = useChat({
196
+ baseUrl: "...",
197
+ orgId: "...",
198
+ userId: "...",
199
+ // transport defaults to "sse"
200
+ });
201
+ ```
202
+
203
+ ### React Native
204
+
205
+ Uses `fetch` with `ReadableStream` for SSE. Required for React Native since it doesn't have native `EventSource`.
206
+
207
+ ```typescript
208
+ import { createFetchSSETransport } from "@elqnt/chat/transport";
209
+
210
+ const transport = createFetchSSETransport();
211
+
212
+ const chat = useChat({
213
+ baseUrl: "...",
214
+ orgId: "...",
215
+ userId: "...",
216
+ transport,
217
+ });
218
+ ```
219
+
220
+ ### Custom Transport
221
+
222
+ Implement the `ChatTransport` interface for custom integrations:
223
+
224
+ ```typescript
225
+ import type { ChatTransport } from "@elqnt/chat/transport";
226
+
227
+ const customTransport: ChatTransport = {
228
+ async connect(config) { /* ... */ },
229
+ disconnect() { /* ... */ },
230
+ async send(event) { /* ... */ },
231
+ async sendMessage(message) { /* ... */ },
232
+ onMessage(handler) { /* ... */ },
233
+ on(eventType, handler) { /* ... */ },
234
+ getState() { /* ... */ },
235
+ getMetrics() { /* ... */ },
236
+ getError() { /* ... */ },
237
+ clearError() { /* ... */ },
238
+ };
239
+ ```
240
+
241
+ ## Event Types
242
+
243
+ Subscribe to specific events:
244
+
245
+ ```typescript
246
+ const { on } = useChat({ ... });
247
+
248
+ // Subscribe to typing events
249
+ const unsubscribe = on("typing", (event) => {
250
+ console.log("User typing:", event.userId);
251
+ });
252
+
253
+ // Clean up
254
+ unsubscribe();
255
+ ```
256
+
257
+ Common event types:
258
+
259
+ | Event | Description |
260
+ |-------|-------------|
261
+ | `message` | New message received |
262
+ | `typing` | User started typing |
263
+ | `stopped_typing` | User stopped typing |
264
+ | `new_chat_created` | New chat session created |
265
+ | `load_chat_response` | Chat loaded |
266
+ | `chat_ended` | Chat session ended |
267
+ | `human_agent_joined` | Human agent joined chat |
268
+ | `human_agent_left` | Human agent left chat |
269
+ | `agent_execution_started` | AI agent started processing |
270
+ | `agent_execution_ended` | AI agent finished processing |
271
+
272
+ ## WhatsApp Integration
273
+
274
+ WhatsApp Business API integration happens via backend webhooks. The `createWhatsAppTransport` is a stub that documents the integration pattern.
275
+
276
+ ### Backend Setup
277
+
278
+ 1. Create a Meta Business App with WhatsApp integration
279
+ 2. Configure webhook URL pointing to your chat service
280
+ 3. Implement webhook handlers:
281
+
282
+ ```go
283
+ // Webhook verification
284
+ func HandleWhatsAppWebhook(w http.ResponseWriter, r *http.Request) {
285
+ if r.Method == "GET" {
286
+ verifyToken := r.URL.Query().Get("hub.verify_token")
287
+ if verifyToken == os.Getenv("WHATSAPP_VERIFY_TOKEN") {
288
+ w.Write([]byte(r.URL.Query().Get("hub.challenge")))
289
+ return
290
+ }
291
+ http.Error(w, "Invalid verify token", 403)
292
+ return
293
+ }
294
+
295
+ // Handle incoming message
296
+ var payload WhatsAppPayload
297
+ json.NewDecoder(r.Body).Decode(&payload)
298
+
299
+ // Map to chat event and publish
300
+ chatEvent := mapWhatsAppToChatEvent(payload)
301
+ publishToChatService(chatEvent)
302
+ }
303
+ ```
304
+
305
+ ### Helper Functions
306
+
307
+ ```typescript
308
+ import { mapWhatsAppToChatEvent } from "@elqnt/chat/transport";
309
+
310
+ // In your webhook handler
311
+ const events = mapWhatsAppToChatEvent(webhookPayload, orgId);
312
+ events.forEach(event => publishToChatService(event));
313
+ ```
314
+
315
+ ## Migration from v2
316
+
317
+ ### Breaking Changes
318
+
319
+ 1. **UI Components Removed** - Build your own UI
320
+ 2. **Contexts Removed** - Use `useChat` hook directly
321
+ 3. **WebSocket Removed** - SSE only (more reliable)
322
+ 4. **Redux Integration Removed** - Use hook state
323
+
324
+ ### Migration Steps
325
+
326
+ ```tsx
327
+ // Before (v2)
328
+ import { WebSocketChatCustomerProvider, useWebSocketChatCustomer } from "@elqnt/chat";
329
+
330
+ function App() {
331
+ return (
332
+ <WebSocketChatCustomerProvider config={...}>
333
+ <ChatComponent />
334
+ </WebSocketChatCustomerProvider>
335
+ );
336
+ }
337
+
338
+ function ChatComponent() {
339
+ const { messages, sendMessage } = useWebSocketChatCustomer();
340
+ return <ChatUI messages={messages} onSend={sendMessage} />;
341
+ }
342
+
343
+ // After (v3)
344
+ import { useChat } from "@elqnt/chat/hooks";
345
+
346
+ function ChatComponent() {
347
+ const { messages, sendMessage, connect, disconnect } = useChat({
348
+ baseUrl: "...",
349
+ orgId: "...",
350
+ userId: "...",
351
+ });
352
+
353
+ useEffect(() => {
354
+ connect();
355
+ return () => disconnect();
356
+ }, []);
357
+
358
+ return <ChatUI messages={messages} onSend={sendMessage} />;
359
+ }
360
+ ```
361
+
362
+ ### Removed Exports
363
+
364
+ - `WebSocketChatCustomerProvider`
365
+ - `WebSocketChatAdminProvider`
366
+ - `useWebSocketChatCustomer`
367
+ - `useWebSocketChatAdmin`
368
+ - `useWebSocketChatBase`
369
+ - All UI components (`ChatMessages`, `ChatInput`, etc.)
370
+
371
+ ## Development
372
+
373
+ ```bash
374
+ # Build
375
+ pnpm build
376
+
377
+ # Type check
378
+ pnpm typecheck
379
+
380
+ # Watch mode
381
+ pnpm dev
382
+ ```
383
+
384
+ ## License
385
+
386
+ MIT
@@ -0,0 +1,308 @@
1
+ import { ApiClientOptions, ApiResponse } from '@elqnt/api-client';
2
+ import { ResponseMetadata } from '@elqnt/types';
3
+ import { Chat, ChatSummary } from '../models/index.mjs';
4
+
5
+ /**
6
+ * Stream API
7
+ *
8
+ * Low-level functions for chat streaming operations.
9
+ * These are used internally by the transport layer but can also
10
+ * be used directly for custom implementations.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { createChat, sendChatMessage, loadChat } from "@elqnt/chat/api";
15
+ *
16
+ * // Create a new chat
17
+ * const chatKey = await createChat({
18
+ * baseUrl: "https://api.example.com/chat",
19
+ * orgId: "org-123",
20
+ * userId: "user-456",
21
+ * });
22
+ *
23
+ * // Send a message
24
+ * await sendChatMessage({
25
+ * baseUrl: "https://api.example.com/chat",
26
+ * orgId: "org-123",
27
+ * chatKey,
28
+ * userId: "user-456",
29
+ * content: "Hello!",
30
+ * });
31
+ * ```
32
+ */
33
+
34
+ /**
35
+ * Base options for all stream API calls
36
+ */
37
+ interface StreamApiOptions {
38
+ /** Base URL for the chat server */
39
+ baseUrl: string;
40
+ /** Organization ID */
41
+ orgId: string;
42
+ /** User ID */
43
+ userId: string;
44
+ }
45
+ /**
46
+ * Response from stream API calls
47
+ */
48
+ interface StreamApiResponse<T = unknown> {
49
+ success: boolean;
50
+ data?: T;
51
+ error?: string;
52
+ }
53
+ /**
54
+ * Create chat options
55
+ */
56
+ interface CreateChatApiOptions extends StreamApiOptions {
57
+ /** Optional metadata for the new chat */
58
+ metadata?: Record<string, unknown>;
59
+ }
60
+ /**
61
+ * Create chat response data
62
+ */
63
+ interface CreateChatResponseData {
64
+ chatKey: string;
65
+ }
66
+ /**
67
+ * Send message options
68
+ */
69
+ interface SendMessageApiOptions extends StreamApiOptions {
70
+ /** Chat key */
71
+ chatKey: string;
72
+ /** Message content */
73
+ content: string;
74
+ /** Optional attachments */
75
+ attachments?: unknown[];
76
+ /** Optional message metadata */
77
+ metadata?: Record<string, unknown>;
78
+ }
79
+ /**
80
+ * Load chat options
81
+ */
82
+ interface LoadChatApiOptions extends StreamApiOptions {
83
+ /** Chat key to load */
84
+ chatKey: string;
85
+ }
86
+ /**
87
+ * Load chat response data
88
+ */
89
+ interface LoadChatResponseData {
90
+ chat: Chat;
91
+ }
92
+ /**
93
+ * End chat options
94
+ */
95
+ interface EndChatApiOptions extends StreamApiOptions {
96
+ /** Chat key to end */
97
+ chatKey: string;
98
+ /** Optional end reason */
99
+ reason?: string;
100
+ }
101
+ /**
102
+ * Typing indicator options
103
+ */
104
+ interface TypingApiOptions extends StreamApiOptions {
105
+ /** Chat key */
106
+ chatKey: string;
107
+ /** Whether user is typing */
108
+ typing: boolean;
109
+ }
110
+ /**
111
+ * Generic event options
112
+ */
113
+ interface SendEventApiOptions extends StreamApiOptions {
114
+ /** Chat key */
115
+ chatKey: string;
116
+ /** Event type */
117
+ type: string;
118
+ /** Event data */
119
+ data?: Record<string, unknown>;
120
+ }
121
+ /**
122
+ * Create a new chat session
123
+ *
124
+ * @param options - Create chat options
125
+ * @returns Chat key of the created chat
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * const chatKey = await createChat({
130
+ * baseUrl: "https://api.example.com/chat",
131
+ * orgId: "org-123",
132
+ * userId: "user-456",
133
+ * metadata: { source: "website" },
134
+ * });
135
+ * ```
136
+ */
137
+ declare function createChat(options: CreateChatApiOptions): Promise<string>;
138
+ /**
139
+ * Send a message in a chat
140
+ *
141
+ * @param options - Send message options
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * await sendChatMessage({
146
+ * baseUrl: "https://api.example.com/chat",
147
+ * orgId: "org-123",
148
+ * chatKey: "chat-789",
149
+ * userId: "user-456",
150
+ * content: "Hello!",
151
+ * });
152
+ * ```
153
+ */
154
+ declare function sendChatMessage(options: SendMessageApiOptions): Promise<void>;
155
+ /**
156
+ * Load an existing chat
157
+ *
158
+ * @param options - Load chat options
159
+ * @returns The loaded chat object
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * const chat = await loadChat({
164
+ * baseUrl: "https://api.example.com/chat",
165
+ * orgId: "org-123",
166
+ * chatKey: "chat-789",
167
+ * userId: "user-456",
168
+ * });
169
+ * ```
170
+ */
171
+ declare function loadChat(options: LoadChatApiOptions): Promise<Chat>;
172
+ /**
173
+ * End a chat session
174
+ *
175
+ * @param options - End chat options
176
+ *
177
+ * @example
178
+ * ```typescript
179
+ * await endChat({
180
+ * baseUrl: "https://api.example.com/chat",
181
+ * orgId: "org-123",
182
+ * chatKey: "chat-789",
183
+ * userId: "user-456",
184
+ * reason: "User closed chat",
185
+ * });
186
+ * ```
187
+ */
188
+ declare function endChat(options: EndChatApiOptions): Promise<void>;
189
+ /**
190
+ * Send typing indicator
191
+ *
192
+ * @param options - Typing indicator options
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * // User started typing
197
+ * await sendTypingIndicator({
198
+ * baseUrl: "https://api.example.com/chat",
199
+ * orgId: "org-123",
200
+ * chatKey: "chat-789",
201
+ * userId: "user-456",
202
+ * typing: true,
203
+ * });
204
+ *
205
+ * // User stopped typing
206
+ * await sendTypingIndicator({
207
+ * baseUrl: "https://api.example.com/chat",
208
+ * orgId: "org-123",
209
+ * chatKey: "chat-789",
210
+ * userId: "user-456",
211
+ * typing: false,
212
+ * });
213
+ * ```
214
+ */
215
+ declare function sendTypingIndicator(options: TypingApiOptions): Promise<void>;
216
+ /**
217
+ * Send a generic event
218
+ *
219
+ * @param options - Event options
220
+ *
221
+ * @example
222
+ * ```typescript
223
+ * await sendEvent({
224
+ * baseUrl: "https://api.example.com/chat",
225
+ * orgId: "org-123",
226
+ * chatKey: "chat-789",
227
+ * userId: "user-456",
228
+ * type: "skill_activate",
229
+ * data: { skillId: "research" },
230
+ * });
231
+ * ```
232
+ */
233
+ declare function sendEvent(options: SendEventApiOptions): Promise<void>;
234
+
235
+ /**
236
+ * Chat API
237
+ *
238
+ * API functions for chat operations.
239
+ *
240
+ * ## Browser API (uses @elqnt/api-client)
241
+ * ```typescript
242
+ * import { getChatHistoryApi, getChatApi } from "@elqnt/chat/api";
243
+ *
244
+ * const history = await getChatHistoryApi({ baseUrl, orgId, limit: 10 });
245
+ * const chat = await getChatApi(chatKey, { baseUrl, orgId });
246
+ * ```
247
+ *
248
+ * ## Stream API (direct HTTP calls)
249
+ * ```typescript
250
+ * import { createChat, sendChatMessage, loadChat } from "@elqnt/chat/api";
251
+ *
252
+ * const chatKey = await createChat({ baseUrl, orgId, userId });
253
+ * await sendChatMessage({ baseUrl, orgId, chatKey, userId, content: "Hello!" });
254
+ * ```
255
+ */
256
+
257
+ interface ChatHistoryResponse {
258
+ chats: ChatSummary[];
259
+ total: number;
260
+ hasMore: boolean;
261
+ metadata: ResponseMetadata;
262
+ }
263
+ interface ChatResponse {
264
+ chat: ChatSummary;
265
+ metadata: ResponseMetadata;
266
+ }
267
+ interface UpdateChatResponse {
268
+ chatKey: string;
269
+ title: string;
270
+ pinned: boolean;
271
+ metadata: ResponseMetadata;
272
+ }
273
+ interface ActiveChatsResponse {
274
+ chats: ChatSummary[];
275
+ metadata: ResponseMetadata;
276
+ }
277
+ interface ActiveChatsCountResponse {
278
+ count: number;
279
+ metadata: ResponseMetadata;
280
+ }
281
+ declare function getChatHistoryApi(options: ApiClientOptions & {
282
+ limit?: number;
283
+ offset?: number;
284
+ skipCache?: boolean;
285
+ }): Promise<ApiResponse<ChatHistoryResponse>>;
286
+ declare function getChatApi(chatKey: string, options: ApiClientOptions): Promise<ApiResponse<ChatResponse>>;
287
+ declare function updateChatApi(chatKey: string, updates: {
288
+ title?: string;
289
+ pinned?: boolean;
290
+ }, options: ApiClientOptions): Promise<ApiResponse<UpdateChatResponse>>;
291
+ declare function deleteChatApi(chatKey: string, options: ApiClientOptions): Promise<ApiResponse<{
292
+ success: boolean;
293
+ metadata: ResponseMetadata;
294
+ }>>;
295
+ declare function getActiveChatsCountApi(options: ApiClientOptions): Promise<ApiResponse<ActiveChatsCountResponse>>;
296
+ declare function getActiveChatsApi(options: ApiClientOptions & {
297
+ pastHours?: number;
298
+ }): Promise<ApiResponse<ActiveChatsResponse>>;
299
+ declare function updateProjectChatTitleApi(projectId: string, chatKey: string, title: string, options: ApiClientOptions): Promise<ApiResponse<{
300
+ success: boolean;
301
+ metadata: ResponseMetadata;
302
+ }>>;
303
+ declare function addChatToProjectApi(projectId: string, chatKey: string, options: ApiClientOptions): Promise<ApiResponse<{
304
+ success: boolean;
305
+ metadata: ResponseMetadata;
306
+ }>>;
307
+
308
+ export { type ActiveChatsCountResponse, type ActiveChatsResponse, Chat, type ChatHistoryResponse, type ChatResponse, ChatSummary, type CreateChatApiOptions, type CreateChatResponseData, type EndChatApiOptions, type LoadChatApiOptions, type LoadChatResponseData, type SendEventApiOptions, type SendMessageApiOptions, type StreamApiOptions, type StreamApiResponse, type TypingApiOptions, type UpdateChatResponse, addChatToProjectApi, createChat, deleteChatApi, endChat, getActiveChatsApi, getActiveChatsCountApi, getChatApi, getChatHistoryApi, loadChat, sendChatMessage, sendEvent, sendTypingIndicator, updateChatApi, updateProjectChatTitleApi };