@aikaara/chat-sdk 0.3.0 → 0.4.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.
- package/dist/MountTenant-5CL6i2El.mjs +13712 -0
- package/dist/MountTenant-dM6HzlAl.cjs +792 -0
- package/dist/headless.cjs +1 -1
- package/dist/headless.d.ts +766 -1
- package/dist/headless.mjs +24 -51
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +377 -1
- package/dist/index.mjs +40 -35
- package/dist/ui.cjs +1 -621
- package/dist/ui.d.ts +334 -7
- package/dist/ui.mjs +17 -1232
- package/package.json +1 -1
- package/dist/AikaaraChatClient-Cqbcd1jb.mjs +0 -11538
- package/dist/AikaaraChatClient-kAu65hX-.cjs +0 -8
- package/dist/cdn/aikaara-chat.iife.js +0 -628
package/dist/headless.d.ts
CHANGED
|
@@ -41,15 +41,21 @@ export declare class AikaaraChatClient extends EventEmitter<ChatEvents> {
|
|
|
41
41
|
private config;
|
|
42
42
|
private mode;
|
|
43
43
|
private uploadAdapter;
|
|
44
|
+
private historyAdapter;
|
|
44
45
|
private tiledeskUnsubs;
|
|
45
46
|
constructor(config: ChatClientConfig, opts?: {
|
|
46
47
|
uploadAdapter?: UploadAdapter;
|
|
48
|
+
historyAdapter?: ConversationHistoryAdapter;
|
|
47
49
|
});
|
|
48
50
|
private usesAikaara;
|
|
49
51
|
private usesTiledesk;
|
|
50
52
|
private initTiledeskTransport;
|
|
51
53
|
connect(): Promise<void>;
|
|
52
|
-
|
|
54
|
+
private hydrateTiledeskHistory;
|
|
55
|
+
sendMessage(content: string, opts?: {
|
|
56
|
+
attributes?: Record<string, unknown>;
|
|
57
|
+
metadata?: Record<string, unknown>;
|
|
58
|
+
}): Promise<void>;
|
|
53
59
|
/**
|
|
54
60
|
* Upload a file via the configured UploadAdapter (client-side: file goes
|
|
55
61
|
* to the tenant's own backend, never through Aikaara). Then publish the
|
|
@@ -102,6 +108,103 @@ export declare class AikaaraChatClient extends EventEmitter<ChatEvents> {
|
|
|
102
108
|
private handleBroadcast;
|
|
103
109
|
}
|
|
104
110
|
|
|
111
|
+
declare class AikaaraChatClient_2 extends EventEmitter_2<ChatEvents_2> {
|
|
112
|
+
private connection;
|
|
113
|
+
private tiledesk;
|
|
114
|
+
private api;
|
|
115
|
+
private messageStore;
|
|
116
|
+
private conversationManager;
|
|
117
|
+
private subscription;
|
|
118
|
+
private config;
|
|
119
|
+
private mode;
|
|
120
|
+
private uploadAdapter;
|
|
121
|
+
private historyAdapter;
|
|
122
|
+
private tiledeskUnsubs;
|
|
123
|
+
constructor(config: ChatClientConfig_2, opts?: {
|
|
124
|
+
uploadAdapter?: UploadAdapter_2;
|
|
125
|
+
historyAdapter?: ConversationHistoryAdapter_2;
|
|
126
|
+
});
|
|
127
|
+
private usesAikaara;
|
|
128
|
+
private usesTiledesk;
|
|
129
|
+
private initTiledeskTransport;
|
|
130
|
+
connect(): Promise<void>;
|
|
131
|
+
private hydrateTiledeskHistory;
|
|
132
|
+
sendMessage(content: string, opts?: {
|
|
133
|
+
attributes?: Record<string, unknown>;
|
|
134
|
+
metadata?: Record<string, unknown>;
|
|
135
|
+
}): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Upload a file via the configured UploadAdapter (client-side: file goes
|
|
138
|
+
* to the tenant's own backend, never through Aikaara). Then publish the
|
|
139
|
+
* Tiledesk file-message envelope so hooks_controller picks it up.
|
|
140
|
+
*/
|
|
141
|
+
sendFile(file: File | Blob, opts?: {
|
|
142
|
+
caption?: string;
|
|
143
|
+
}): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Trigger Tiledesk's CHAT_INITIATED event — required to kick off a bot flow
|
|
146
|
+
* for newly-created Tiledesk request groups.
|
|
147
|
+
*/
|
|
148
|
+
initiateTiledeskChat(extraAttributes?: Record<string, unknown>): void;
|
|
149
|
+
/** Mark a Tiledesk message as read (publishes status=300 update). */
|
|
150
|
+
markTiledeskRead(messageId: string): void;
|
|
151
|
+
setUploadAdapter(adapter: UploadAdapter_2): void;
|
|
152
|
+
sendUserEvent(eventKey: string, value?: object, source?: string): Promise<void>;
|
|
153
|
+
loadHistory(): Promise<Message_2[]>;
|
|
154
|
+
get messages(): Message_2[];
|
|
155
|
+
get conversationId(): string | null;
|
|
156
|
+
get isConnected(): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Update the agent's context with information about the host app's current state.
|
|
159
|
+
* Call this on route changes so the agent knows what page/entity the user is viewing.
|
|
160
|
+
*
|
|
161
|
+
* The context is stored in conversation metadata and interpolated into the system prompt.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* // On route change
|
|
166
|
+
* client.setContext({
|
|
167
|
+
* currentPage: '/products/42',
|
|
168
|
+
* entityType: 'product',
|
|
169
|
+
* entityId: '42',
|
|
170
|
+
* availableRoutes: { products: '/products', orders: '/orders' },
|
|
171
|
+
* });
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
setContext(context: AppContext_2): Promise<void>;
|
|
175
|
+
disconnect(): Promise<void>;
|
|
176
|
+
private handleTiledeskMessage;
|
|
177
|
+
private handleTiledeskStatusUpdate;
|
|
178
|
+
/**
|
|
179
|
+
* Parse structured action results from tool execution output.
|
|
180
|
+
* When the agent calls tools like `edit_current_entity`, `save_current_entity`,
|
|
181
|
+
* `navigate_to`, or `test_tool_by_id`, the result contains an action payload
|
|
182
|
+
* that the SDK emits as a typed event for the host app to handle.
|
|
183
|
+
*/
|
|
184
|
+
private parseActionResult;
|
|
185
|
+
private handleBroadcast;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
declare class AikaaraChatWidget extends HTMLElement {
|
|
189
|
+
private shadow;
|
|
190
|
+
private controller;
|
|
191
|
+
private _config;
|
|
192
|
+
static get observedAttributes(): string[];
|
|
193
|
+
constructor();
|
|
194
|
+
connectedCallback(): void;
|
|
195
|
+
disconnectedCallback(): void;
|
|
196
|
+
attributeChangedCallback(_name: string, oldVal: string, newVal: string): void;
|
|
197
|
+
configure(config: Partial<WidgetConfig>): void;
|
|
198
|
+
private getConfig;
|
|
199
|
+
setUploadAdapter(adapter: UploadAdapter): void;
|
|
200
|
+
setHistoryAdapter(adapter: ConversationHistoryAdapter): void;
|
|
201
|
+
private render;
|
|
202
|
+
private initController;
|
|
203
|
+
sendUserEvent(eventKey: string, value?: Record<string, unknown>, source?: string): void;
|
|
204
|
+
getClient(): AikaaraChatClient_2 | null;
|
|
205
|
+
private darkenColor;
|
|
206
|
+
}
|
|
207
|
+
|
|
105
208
|
export declare class ApiClient {
|
|
106
209
|
private baseUrl;
|
|
107
210
|
private apiKey?;
|
|
@@ -135,6 +238,21 @@ export declare interface AppContext {
|
|
|
135
238
|
custom?: Record<string, unknown>;
|
|
136
239
|
}
|
|
137
240
|
|
|
241
|
+
declare interface AppContext_2 {
|
|
242
|
+
/** Current page/route path in the host app (e.g., '/products/42') */
|
|
243
|
+
currentPage: string;
|
|
244
|
+
/** Entity type on the current page (e.g., 'product', 'agent') */
|
|
245
|
+
entityType?: string;
|
|
246
|
+
/** Entity ID on the current page */
|
|
247
|
+
entityId?: string | number;
|
|
248
|
+
/** Project/workspace ID if applicable */
|
|
249
|
+
projectId?: string | number;
|
|
250
|
+
/** Routes the agent can navigate to — map of label → path */
|
|
251
|
+
availableRoutes?: Record<string, string>;
|
|
252
|
+
/** Additional context for the agent (e.g., form field names, entity schema) */
|
|
253
|
+
custom?: Record<string, unknown>;
|
|
254
|
+
}
|
|
255
|
+
|
|
138
256
|
export declare class ChannelSubscription {
|
|
139
257
|
readonly identifier: string;
|
|
140
258
|
private callbacks;
|
|
@@ -176,6 +294,13 @@ export declare interface ChatClientConfig extends ConnectionConfig {
|
|
|
176
294
|
departmentId?: string;
|
|
177
295
|
senderFullname?: string;
|
|
178
296
|
};
|
|
297
|
+
/**
|
|
298
|
+
* Tenant-level defaults merged into the `action` object of every template
|
|
299
|
+
* postback (e.g. submit-action click). Useful for app-specific keys like
|
|
300
|
+
* `serviceType: 'ITR'` that the bot expects on every form submission.
|
|
301
|
+
* Per-submit values from the form take precedence over these defaults.
|
|
302
|
+
*/
|
|
303
|
+
templateActionAttributes?: Record<string, unknown>;
|
|
179
304
|
onMessage?: (message: Message) => void;
|
|
180
305
|
onStatusChange?: (status: string) => void;
|
|
181
306
|
onError?: (error: Error) => void;
|
|
@@ -184,6 +309,46 @@ export declare interface ChatClientConfig extends ConnectionConfig {
|
|
|
184
309
|
onTemplateMessage?: (template: TemplateMessageEvent) => void;
|
|
185
310
|
}
|
|
186
311
|
|
|
312
|
+
declare interface ChatClientConfig_2 extends ConnectionConfig_2 {
|
|
313
|
+
apiKey?: string;
|
|
314
|
+
authToken?: string;
|
|
315
|
+
extUid?: string;
|
|
316
|
+
conversationId?: string;
|
|
317
|
+
systemPromptId?: number;
|
|
318
|
+
channel?: 'widget' | 'api' | 'sidekick';
|
|
319
|
+
/**
|
|
320
|
+
* Transport selection.
|
|
321
|
+
* - `aikaara` (default): ActionCable to Aikaara Rails (AI streaming).
|
|
322
|
+
* - `tiledesk`: MQTT direct to a self-hosted Tiledesk + chat21 stack.
|
|
323
|
+
* - `dual`: both — Aikaara cable for AI, Tiledesk MQTT for live-agent + file events.
|
|
324
|
+
*/
|
|
325
|
+
transport?: TransportMode_2;
|
|
326
|
+
/**
|
|
327
|
+
* Tiledesk-side identity. Required when `transport` is `tiledesk` or `dual`.
|
|
328
|
+
* `userId` here is the Tiledesk user `_id` and is also used as the SDK conversation
|
|
329
|
+
* subject — Aikaara conversations bound to this user via ext_uid mapping.
|
|
330
|
+
*/
|
|
331
|
+
tiledeskIdentity?: {
|
|
332
|
+
userId: string;
|
|
333
|
+
userName?: string;
|
|
334
|
+
departmentId?: string;
|
|
335
|
+
senderFullname?: string;
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* Tenant-level defaults merged into the `action` object of every template
|
|
339
|
+
* postback (e.g. submit-action click). Useful for app-specific keys like
|
|
340
|
+
* `serviceType: 'ITR'` that the bot expects on every form submission.
|
|
341
|
+
* Per-submit values from the form take precedence over these defaults.
|
|
342
|
+
*/
|
|
343
|
+
templateActionAttributes?: Record<string, unknown>;
|
|
344
|
+
onMessage?: (message: Message_2) => void;
|
|
345
|
+
onStatusChange?: (status: string) => void;
|
|
346
|
+
onError?: (error: Error) => void;
|
|
347
|
+
onStreamUpdate?: (delta: string, fullContent: string) => void;
|
|
348
|
+
onConnectionStateChange?: (state: ConnectionState_2) => void;
|
|
349
|
+
onTemplateMessage?: (template: TemplateMessageEvent_2) => void;
|
|
350
|
+
}
|
|
351
|
+
|
|
187
352
|
export declare interface ChatEvents {
|
|
188
353
|
'connection:state': ConnectionState;
|
|
189
354
|
'message:received': Message;
|
|
@@ -222,6 +387,46 @@ export declare interface ChatEvents {
|
|
|
222
387
|
};
|
|
223
388
|
}
|
|
224
389
|
|
|
390
|
+
declare interface ChatEvents_2 {
|
|
391
|
+
'connection:state': ConnectionState_2;
|
|
392
|
+
'message:received': Message_2;
|
|
393
|
+
'message:updated': Message_2;
|
|
394
|
+
'message:sent': Message_2;
|
|
395
|
+
'stream:start': {
|
|
396
|
+
messageId: string;
|
|
397
|
+
};
|
|
398
|
+
'stream:update': {
|
|
399
|
+
delta: string;
|
|
400
|
+
content: string;
|
|
401
|
+
};
|
|
402
|
+
'stream:end': {
|
|
403
|
+
messageId: string;
|
|
404
|
+
usage?: {
|
|
405
|
+
tokensInput: number;
|
|
406
|
+
tokensOutput: number;
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
'typing:start': void;
|
|
410
|
+
'typing:stop': void;
|
|
411
|
+
'error': Error;
|
|
412
|
+
'status': string;
|
|
413
|
+
'action:edit_entity': EditEntityAction_2;
|
|
414
|
+
'action:save_entity': SaveEntityAction_2;
|
|
415
|
+
'action:test_tool': TestToolAction_2;
|
|
416
|
+
'action:navigate': NavigateAction_2;
|
|
417
|
+
'tool:start': {
|
|
418
|
+
toolName: string;
|
|
419
|
+
args: Record<string, unknown>;
|
|
420
|
+
};
|
|
421
|
+
'tool:end': {
|
|
422
|
+
toolName: string;
|
|
423
|
+
result: unknown;
|
|
424
|
+
isError: boolean;
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
export declare function clearPersistedConversationId(userId: string, projectId: string): void;
|
|
429
|
+
|
|
225
430
|
export declare interface ConnectionConfig {
|
|
226
431
|
baseUrl: string;
|
|
227
432
|
wsUrl?: string;
|
|
@@ -232,6 +437,16 @@ export declare interface ConnectionConfig {
|
|
|
232
437
|
reconnectInterval?: number;
|
|
233
438
|
}
|
|
234
439
|
|
|
440
|
+
declare interface ConnectionConfig_2 {
|
|
441
|
+
baseUrl: string;
|
|
442
|
+
wsUrl?: string;
|
|
443
|
+
userToken: string;
|
|
444
|
+
tiledesk?: TiledeskTransportConfig_2;
|
|
445
|
+
reconnect?: boolean;
|
|
446
|
+
maxReconnectAttempts?: number;
|
|
447
|
+
reconnectInterval?: number;
|
|
448
|
+
}
|
|
449
|
+
|
|
235
450
|
export declare class ConnectionManager extends EventEmitter<ChatEvents> {
|
|
236
451
|
private client;
|
|
237
452
|
private config;
|
|
@@ -253,6 +468,34 @@ export declare class ConnectionManager extends EventEmitter<ChatEvents> {
|
|
|
253
468
|
|
|
254
469
|
export declare type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
|
|
255
470
|
|
|
471
|
+
declare type ConnectionState_2 = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Pluggable adapter that hydrates prior conversation messages on connect.
|
|
475
|
+
* The SDK calls this once after MQTT subscribes so the user sees existing
|
|
476
|
+
* history before any new live messages arrive.
|
|
477
|
+
*/
|
|
478
|
+
export declare interface ConversationHistoryAdapter {
|
|
479
|
+
fetchMessages(conversationId: string, ctx: {
|
|
480
|
+
userId: string;
|
|
481
|
+
appId?: string;
|
|
482
|
+
projectId?: string;
|
|
483
|
+
}): Promise<TiledeskMessage[]>;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Pluggable adapter that hydrates prior conversation messages on connect.
|
|
488
|
+
* The SDK calls this once after MQTT subscribes so the user sees existing
|
|
489
|
+
* history before any new live messages arrive.
|
|
490
|
+
*/
|
|
491
|
+
declare interface ConversationHistoryAdapter_2 {
|
|
492
|
+
fetchMessages(conversationId: string, ctx: {
|
|
493
|
+
userId: string;
|
|
494
|
+
appId?: string;
|
|
495
|
+
projectId?: string;
|
|
496
|
+
}): Promise<TiledeskMessage_2[]>;
|
|
497
|
+
}
|
|
498
|
+
|
|
256
499
|
export declare class ConversationManager {
|
|
257
500
|
private _conversationId;
|
|
258
501
|
private persist;
|
|
@@ -271,6 +514,10 @@ declare interface CreateConversationResponse {
|
|
|
271
514
|
|
|
272
515
|
export declare function createFetchUploadAdapter(config: FetchUploadAdapterConfig): UploadAdapter;
|
|
273
516
|
|
|
517
|
+
export declare function createPresigned3StepUploadAdapter(config: Presigned3StepAdapterConfig): UploadAdapter;
|
|
518
|
+
|
|
519
|
+
export declare function createTiledeskHistoryAdapter(config: TiledeskHistoryAdapterConfig): ConversationHistoryAdapter;
|
|
520
|
+
|
|
274
521
|
export declare interface EditEntityAction {
|
|
275
522
|
action: 'edit_entity';
|
|
276
523
|
entity_type: string;
|
|
@@ -278,6 +525,13 @@ export declare interface EditEntityAction {
|
|
|
278
525
|
fields: FieldUpdate[];
|
|
279
526
|
}
|
|
280
527
|
|
|
528
|
+
declare interface EditEntityAction_2 {
|
|
529
|
+
action: 'edit_entity';
|
|
530
|
+
entity_type: string;
|
|
531
|
+
entity_id: string | number;
|
|
532
|
+
fields: FieldUpdate_2[];
|
|
533
|
+
}
|
|
534
|
+
|
|
281
535
|
export declare class EventEmitter<Events extends Record<string, any>> {
|
|
282
536
|
private handlers;
|
|
283
537
|
on<K extends keyof Events & string>(event: K, handler: (data: Events[K]) => void): () => void;
|
|
@@ -286,6 +540,14 @@ export declare class EventEmitter<Events extends Record<string, any>> {
|
|
|
286
540
|
removeAllListeners(): void;
|
|
287
541
|
}
|
|
288
542
|
|
|
543
|
+
declare class EventEmitter_2<Events extends Record<string, any>> {
|
|
544
|
+
private handlers;
|
|
545
|
+
on<K extends keyof Events & string>(event: K, handler: (data: Events[K]) => void): () => void;
|
|
546
|
+
off<K extends keyof Events & string>(event: K, handler: (data: Events[K]) => void): void;
|
|
547
|
+
emit<K extends keyof Events & string>(event: K, data: Events[K]): void;
|
|
548
|
+
removeAllListeners(): void;
|
|
549
|
+
}
|
|
550
|
+
|
|
289
551
|
export declare function extractTiledeskFileEnvelope(message: TiledeskMessage): TiledeskFileEnvelope | null;
|
|
290
552
|
|
|
291
553
|
export declare interface FetchUploadAdapterConfig {
|
|
@@ -304,6 +566,12 @@ export declare interface FieldUpdate {
|
|
|
304
566
|
previousValue?: unknown;
|
|
305
567
|
}
|
|
306
568
|
|
|
569
|
+
declare interface FieldUpdate_2 {
|
|
570
|
+
field: string;
|
|
571
|
+
value: unknown;
|
|
572
|
+
previousValue?: unknown;
|
|
573
|
+
}
|
|
574
|
+
|
|
307
575
|
export declare class FormBridge extends EventEmitter<FormBridgeEvents> {
|
|
308
576
|
private registration;
|
|
309
577
|
private pendingEdits;
|
|
@@ -455,6 +723,32 @@ export declare interface Message {
|
|
|
455
723
|
}>;
|
|
456
724
|
}
|
|
457
725
|
|
|
726
|
+
declare interface Message_2 {
|
|
727
|
+
id: string;
|
|
728
|
+
conversationId: string;
|
|
729
|
+
role: 'user' | 'assistant' | 'system' | 'tool' | 'agent';
|
|
730
|
+
content: string;
|
|
731
|
+
toolCalls?: ToolCall_2[];
|
|
732
|
+
toolCallResults?: ToolCallResult_2;
|
|
733
|
+
tokensInput?: number;
|
|
734
|
+
tokensOutput?: number;
|
|
735
|
+
metadata?: Record<string, unknown>;
|
|
736
|
+
createdAt: string;
|
|
737
|
+
status?: 'sending' | 'sent' | 'delivered' | 'read' | 'streaming' | 'complete' | 'error';
|
|
738
|
+
externalId?: string;
|
|
739
|
+
template?: {
|
|
740
|
+
contentType?: string;
|
|
741
|
+
templateId?: string;
|
|
742
|
+
payload?: unknown;
|
|
743
|
+
};
|
|
744
|
+
attachments?: Array<{
|
|
745
|
+
fileName: string;
|
|
746
|
+
fileUrl: string;
|
|
747
|
+
cloudFileId?: string;
|
|
748
|
+
contentType?: string;
|
|
749
|
+
}>;
|
|
750
|
+
}
|
|
751
|
+
|
|
458
752
|
export declare class MessageStore {
|
|
459
753
|
private _messages;
|
|
460
754
|
private optimisticCounter;
|
|
@@ -490,16 +784,182 @@ export declare class MessageStore {
|
|
|
490
784
|
clear(): void;
|
|
491
785
|
}
|
|
492
786
|
|
|
787
|
+
export declare interface MountedTenantWidget {
|
|
788
|
+
widget: AikaaraChatWidget;
|
|
789
|
+
requestId: string;
|
|
790
|
+
config: WidgetConfig;
|
|
791
|
+
destroy: () => void;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Single-call mount. Pulls the descriptor from `widget_configs/:slug`, runs
|
|
796
|
+
* descriptor.auth to mint chat JWT + requestId, builds upload + history
|
|
797
|
+
* adapters from descriptor.upload, and mounts the web component. Host app
|
|
798
|
+
* supplies only the user id + their session JWT.
|
|
799
|
+
*
|
|
800
|
+
* import { mountFromSlug } from '@aikaara/chat-sdk';
|
|
801
|
+
*
|
|
802
|
+
* await mountFromSlug({
|
|
803
|
+
* container: '#chat',
|
|
804
|
+
* slug: 'bandhan-itr',
|
|
805
|
+
* user: { id: '33568', token: () => getCognitoJwt() },
|
|
806
|
+
* });
|
|
807
|
+
*/
|
|
808
|
+
export declare function mountFromSlug(opts: SlugMountOptions): Promise<SlugMountedWidget>;
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Standard tenant mount. Fetches the descriptor (when `configUrl` is set),
|
|
812
|
+
* merges per-mount overrides, builds default adapters from the descriptor's
|
|
813
|
+
* endpoint URLs (when no override is supplied), and mounts the widget.
|
|
814
|
+
*/
|
|
815
|
+
export declare function mountTenantWidget(opts: TenantMountOptions): Promise<MountedTenantWidget>;
|
|
816
|
+
|
|
493
817
|
export declare interface NavigateAction {
|
|
494
818
|
navigate_to: string;
|
|
495
819
|
}
|
|
496
820
|
|
|
821
|
+
declare interface NavigateAction_2 {
|
|
822
|
+
navigate_to: string;
|
|
823
|
+
}
|
|
824
|
+
|
|
497
825
|
export declare function parseTiledeskTemplate(message: TiledeskMessage): TiledeskParsedTemplate;
|
|
498
826
|
|
|
827
|
+
/**
|
|
828
|
+
* Three-step presigned-S3 upload (sign → PUT → register). Driven entirely
|
|
829
|
+
* by descriptor — no tenant-specific code in host apps.
|
|
830
|
+
*/
|
|
831
|
+
export declare interface Presigned3StepAdapterConfig {
|
|
832
|
+
/** GET endpoint that returns a presigned URL. `{fileName}` placeholder. */
|
|
833
|
+
signEndpoint: string;
|
|
834
|
+
signMethod?: 'GET' | 'POST';
|
|
835
|
+
/** Dot path into the response JSON for the presigned URL. Default `data.s3SignedUrl`. */
|
|
836
|
+
signedUrlPath?: string;
|
|
837
|
+
/** Optional POST registering the upload (e.g. `/chatbuddy/file-upload`). */
|
|
838
|
+
registerEndpoint?: string;
|
|
839
|
+
/**
|
|
840
|
+
* Body JSON for the register POST. Tokens: `{fileName}`, `{userId}`,
|
|
841
|
+
* `{requestId}` (alias `{conversationId}`).
|
|
842
|
+
*/
|
|
843
|
+
registerBody?: Record<string, unknown>;
|
|
844
|
+
/**
|
|
845
|
+
* Final URL the chat message will carry. Tokens: `{fileName}`, `{userId}`,
|
|
846
|
+
* `{requestId}`. When omitted the presigned URL itself is used.
|
|
847
|
+
*/
|
|
848
|
+
viewerTemplate?: string;
|
|
849
|
+
/**
|
|
850
|
+
* Rewrite the host portion of the presigned URL before PUTting (used for
|
|
851
|
+
* dev proxies). E.g. `/s3-upload`. Leave empty for direct.
|
|
852
|
+
*/
|
|
853
|
+
s3HostRewrite?: string;
|
|
854
|
+
/** Bearer token getter for sign + register calls. */
|
|
855
|
+
authHeader?: () => string | Promise<string>;
|
|
856
|
+
/** Static extra headers for sign + register. */
|
|
857
|
+
extraHeaders?: Record<string, string>;
|
|
858
|
+
}
|
|
859
|
+
|
|
499
860
|
export declare interface SaveEntityAction {
|
|
500
861
|
action: 'save_entity';
|
|
501
862
|
}
|
|
502
863
|
|
|
864
|
+
declare interface SaveEntityAction_2 {
|
|
865
|
+
action: 'save_entity';
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
export declare class SessionAuthAdapter {
|
|
869
|
+
private readonly descriptor;
|
|
870
|
+
private readonly sessionToken;
|
|
871
|
+
private cache;
|
|
872
|
+
private inflight;
|
|
873
|
+
constructor(descriptor: SessionAuthDescriptor, sessionToken: SessionTokenProvider);
|
|
874
|
+
/** Force-refresh by clearing cache. Next `get()` call refetches. */
|
|
875
|
+
reset(): void;
|
|
876
|
+
get(): Promise<SessionAuthData>;
|
|
877
|
+
private fetchOnce;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
export declare interface SessionAuthData {
|
|
881
|
+
token: string;
|
|
882
|
+
requestId: string;
|
|
883
|
+
fullName: string;
|
|
884
|
+
expiresAt: number;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* Descriptor-driven session auth.
|
|
889
|
+
*
|
|
890
|
+
* The host app supplies a "session token" — typically a JWT issued by their
|
|
891
|
+
* own auth (Cognito/Auth0/firebase/etc) — and the descriptor declares how to
|
|
892
|
+
* exchange it for a chat-platform JWT + conversation requestId. The SDK runs
|
|
893
|
+
* the exchange itself, caches the result, and refreshes when the chat JWT
|
|
894
|
+
* approaches expiry. The original requestId is preserved across refreshes so
|
|
895
|
+
* the conversation thread is stable.
|
|
896
|
+
*/
|
|
897
|
+
export declare interface SessionAuthDescriptor {
|
|
898
|
+
/** Absolute or same-origin URL — POSTed with the session token as bearer. */
|
|
899
|
+
endpoint: string;
|
|
900
|
+
method?: 'POST' | 'GET';
|
|
901
|
+
/** JSON body for the request. POST only. */
|
|
902
|
+
body?: Record<string, unknown>;
|
|
903
|
+
/** Extra static headers (e.g. partnerid). */
|
|
904
|
+
headers?: Record<string, string>;
|
|
905
|
+
/** Header carrying the session token. Default `Authorization`. */
|
|
906
|
+
authHeader?: string;
|
|
907
|
+
/**
|
|
908
|
+
* Template for the session-token header value. `{token}` is replaced.
|
|
909
|
+
* Default: `Bearer {token}`. Use `JWT {token}` etc. when required.
|
|
910
|
+
*/
|
|
911
|
+
authHeaderTemplate?: string;
|
|
912
|
+
/** Dot path into the response JSON for the chat JWT. Default `data.token`. */
|
|
913
|
+
tokenPath?: string;
|
|
914
|
+
/** Stripped from the extracted token before use (e.g. `JWT `). */
|
|
915
|
+
tokenStripPrefix?: string;
|
|
916
|
+
/** Dot path for the conversation requestId. Default `data.requestId`. */
|
|
917
|
+
requestIdPath?: string;
|
|
918
|
+
/** Dot path for the user display name. Default `data.fullName`. */
|
|
919
|
+
fullNamePath?: string;
|
|
920
|
+
/** Refetch when the JWT is within this many ms of expiry. Default 60_000. */
|
|
921
|
+
expiryBufferMs?: number;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
export declare type SessionTokenProvider = string | (() => string | Promise<string>);
|
|
925
|
+
|
|
926
|
+
export declare interface SlugMountedWidget extends MountedTenantWidget {
|
|
927
|
+
fullName: string;
|
|
928
|
+
/** Force a fresh /chatbuddy/auth-style refetch (clears cached requestId). */
|
|
929
|
+
refreshAuth(): Promise<void>;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
export declare interface SlugMountOptions {
|
|
933
|
+
/** Container element or CSS selector (e.g. `#chat`). */
|
|
934
|
+
container: HTMLElement | string;
|
|
935
|
+
/** Tenant identifier — the SDK fetches `${configBase}/widget_configs/${slug}`. */
|
|
936
|
+
slug: string;
|
|
937
|
+
/** Defaults to `https://api.aikaara.com`. Override for self-hosted aikaara. */
|
|
938
|
+
configBase?: string;
|
|
939
|
+
/** Additional headers for the descriptor fetch. */
|
|
940
|
+
configHeaders?: Record<string, string>;
|
|
941
|
+
user: {
|
|
942
|
+
id: string;
|
|
943
|
+
/** Display name fallback when descriptor.auth doesn't return one. */
|
|
944
|
+
name?: string;
|
|
945
|
+
departmentId?: string;
|
|
946
|
+
/**
|
|
947
|
+
* Session JWT (Cognito/Auth0/firebase/etc) — passed as bearer to
|
|
948
|
+
* `descriptor.auth.endpoint`. Can be a string (static for the session)
|
|
949
|
+
* or a getter that re-resolves on each refresh.
|
|
950
|
+
*/
|
|
951
|
+
token: SessionTokenProvider;
|
|
952
|
+
};
|
|
953
|
+
/** Optional escape hatches; merge over descriptor-driven defaults. */
|
|
954
|
+
hooks?: {
|
|
955
|
+
upload?: UploadAdapter;
|
|
956
|
+
history?: ConversationHistoryAdapter;
|
|
957
|
+
onError?: (err: Error) => void;
|
|
958
|
+
};
|
|
959
|
+
/** Per-mount visual overrides. */
|
|
960
|
+
overrides?: Partial<WidgetConfigDescriptor>;
|
|
961
|
+
}
|
|
962
|
+
|
|
503
963
|
declare type SubscriptionCallback = (data: unknown) => void;
|
|
504
964
|
|
|
505
965
|
declare interface TemplateMessageEvent {
|
|
@@ -513,12 +973,66 @@ declare interface TemplateMessageEvent {
|
|
|
513
973
|
raw: unknown;
|
|
514
974
|
}
|
|
515
975
|
|
|
976
|
+
declare interface TemplateMessageEvent_2 {
|
|
977
|
+
messageId: string;
|
|
978
|
+
conversationId: string;
|
|
979
|
+
role: 'user' | 'assistant' | 'system' | 'agent';
|
|
980
|
+
contentType?: string;
|
|
981
|
+
templateId?: string;
|
|
982
|
+
payload?: unknown;
|
|
983
|
+
innerMessage?: string;
|
|
984
|
+
raw: unknown;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
export declare interface TenantMountOptions {
|
|
988
|
+
container: HTMLElement;
|
|
989
|
+
/** Fetched from this URL when `config` is omitted. */
|
|
990
|
+
configUrl?: string;
|
|
991
|
+
/** Pre-resolved descriptor — skip the fetch. */
|
|
992
|
+
config?: WidgetConfigDescriptor;
|
|
993
|
+
/** Headers attached when fetching `configUrl` (e.g. tenant-API auth). */
|
|
994
|
+
configHeaders?: Record<string, string>;
|
|
995
|
+
identity: {
|
|
996
|
+
userId: string;
|
|
997
|
+
userName?: string;
|
|
998
|
+
departmentId?: string;
|
|
999
|
+
senderFullname?: string;
|
|
1000
|
+
};
|
|
1001
|
+
/** Returns a raw Tiledesk JWT (no Bearer/JWT prefix) for MQTT password. */
|
|
1002
|
+
tokenProvider: () => Promise<string>;
|
|
1003
|
+
/** Authorization value for the history fetch. Defaults to `tokenProvider()`. */
|
|
1004
|
+
historyTokenProvider?: () => Promise<string>;
|
|
1005
|
+
/**
|
|
1006
|
+
* Optional override adapters. If omitted and the descriptor specifies the
|
|
1007
|
+
* matching endpoint, the SDK builds default fetch-based adapters.
|
|
1008
|
+
*/
|
|
1009
|
+
uploadAdapter?: UploadAdapter;
|
|
1010
|
+
historyAdapter?: ConversationHistoryAdapter;
|
|
1011
|
+
/**
|
|
1012
|
+
* Pin a conversationId. When omitted we look up
|
|
1013
|
+
* `aikaara_chat:requestId:{userId}:{projectId}` in localStorage and reuse
|
|
1014
|
+
* any persisted value; only mint a fresh `requestId` when nothing is stored.
|
|
1015
|
+
*/
|
|
1016
|
+
conversationId?: string;
|
|
1017
|
+
forceNewConversation?: boolean;
|
|
1018
|
+
/** Per-mount overrides that take precedence over the descriptor. */
|
|
1019
|
+
overrides?: Partial<WidgetConfigDescriptor>;
|
|
1020
|
+
/** Surfaced from the SDK. */
|
|
1021
|
+
onError?: (err: Error) => void;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
516
1024
|
export declare interface TestToolAction {
|
|
517
1025
|
action: 'test_tool';
|
|
518
1026
|
tool_id: number;
|
|
519
1027
|
parameters: Record<string, unknown>;
|
|
520
1028
|
}
|
|
521
1029
|
|
|
1030
|
+
declare interface TestToolAction_2 {
|
|
1031
|
+
action: 'test_tool';
|
|
1032
|
+
tool_id: number;
|
|
1033
|
+
parameters: Record<string, unknown>;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
522
1036
|
export declare interface TiledeskFileEnvelope {
|
|
523
1037
|
fileName?: string;
|
|
524
1038
|
fileUrl?: string;
|
|
@@ -546,6 +1060,39 @@ export declare interface TiledeskFileTemplateConfig {
|
|
|
546
1060
|
isDeepLink?: boolean;
|
|
547
1061
|
}
|
|
548
1062
|
|
|
1063
|
+
declare interface TiledeskFileTemplateConfig_2 {
|
|
1064
|
+
templateId: string;
|
|
1065
|
+
headerImgSrc?: string;
|
|
1066
|
+
type?: 'link' | 'image';
|
|
1067
|
+
isDeepLink?: boolean;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
export declare interface TiledeskHistoryAdapterConfig {
|
|
1071
|
+
/**
|
|
1072
|
+
* Base URL of the Tiledesk chat API, e.g. `https://uat-tiledesk.taxbuddy.com/chatapi/api`
|
|
1073
|
+
* (no trailing slash). Final URL is composed as
|
|
1074
|
+
* `{apiBase}/tilechat/{userId}/conversations/{conversationId}/messages?pageSize={pageSize}`
|
|
1075
|
+
*/
|
|
1076
|
+
apiBase: string;
|
|
1077
|
+
pageSize?: number;
|
|
1078
|
+
/**
|
|
1079
|
+
* Async getter for the bearer token. Most Tiledesk-fronted gateways accept
|
|
1080
|
+
* the same JWT used for the MQTT connection. Return `null` to omit the
|
|
1081
|
+
* `Authorization` header.
|
|
1082
|
+
*/
|
|
1083
|
+
getToken?: () => string | null | Promise<string | null>;
|
|
1084
|
+
/** Override the path template. Default mirrors bandhan's chatapi route. */
|
|
1085
|
+
pathTemplate?: string;
|
|
1086
|
+
/** Extra static headers to attach (e.g. `partnerid`, `environment`). */
|
|
1087
|
+
extraHeaders?: Record<string, string>;
|
|
1088
|
+
/**
|
|
1089
|
+
* Optional response shape mapper. Default expects
|
|
1090
|
+
* `{ success: true, result: TiledeskMessage[] }`
|
|
1091
|
+
* which matches the bandhan `/chatapi/api/tilechat/.../messages` response.
|
|
1092
|
+
*/
|
|
1093
|
+
parseResponse?: (raw: unknown) => TiledeskMessage[];
|
|
1094
|
+
}
|
|
1095
|
+
|
|
549
1096
|
export declare interface TiledeskMessage {
|
|
550
1097
|
text?: string;
|
|
551
1098
|
type?: string;
|
|
@@ -564,6 +1111,24 @@ export declare interface TiledeskMessage {
|
|
|
564
1111
|
[key: string]: unknown;
|
|
565
1112
|
}
|
|
566
1113
|
|
|
1114
|
+
declare interface TiledeskMessage_2 {
|
|
1115
|
+
text?: string;
|
|
1116
|
+
type?: string;
|
|
1117
|
+
sender?: string;
|
|
1118
|
+
senderFullname?: string;
|
|
1119
|
+
sender_fullname?: string;
|
|
1120
|
+
recipient?: string;
|
|
1121
|
+
recipient_fullname?: string;
|
|
1122
|
+
channel_type?: string;
|
|
1123
|
+
timestamp?: number;
|
|
1124
|
+
app_id?: string;
|
|
1125
|
+
message_id?: string;
|
|
1126
|
+
status?: number;
|
|
1127
|
+
attributes?: Record<string, unknown>;
|
|
1128
|
+
metadata?: Record<string, unknown>;
|
|
1129
|
+
[key: string]: unknown;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
567
1132
|
export declare interface TiledeskMessageContext {
|
|
568
1133
|
topic: string;
|
|
569
1134
|
conversationId?: string;
|
|
@@ -581,6 +1146,16 @@ export declare interface TiledeskMessageDefaults {
|
|
|
581
1146
|
attributes?: Record<string, unknown>;
|
|
582
1147
|
}
|
|
583
1148
|
|
|
1149
|
+
declare interface TiledeskMessageDefaults_2 {
|
|
1150
|
+
channelType?: string;
|
|
1151
|
+
channel?: string;
|
|
1152
|
+
requestChannel?: string;
|
|
1153
|
+
platform?: string;
|
|
1154
|
+
medium?: string;
|
|
1155
|
+
departmentId?: string;
|
|
1156
|
+
attributes?: Record<string, unknown>;
|
|
1157
|
+
}
|
|
1158
|
+
|
|
584
1159
|
export declare interface TiledeskParsedTemplate {
|
|
585
1160
|
contentType?: string;
|
|
586
1161
|
templateId?: string;
|
|
@@ -612,6 +1187,14 @@ export declare interface TiledeskTopicTemplates {
|
|
|
612
1187
|
wildcardSubscribe?: string;
|
|
613
1188
|
}
|
|
614
1189
|
|
|
1190
|
+
declare interface TiledeskTopicTemplates_2 {
|
|
1191
|
+
inbound?: string;
|
|
1192
|
+
inboundUpdate?: string;
|
|
1193
|
+
outbound?: string;
|
|
1194
|
+
presence?: string;
|
|
1195
|
+
wildcardSubscribe?: string;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
615
1198
|
export declare class TiledeskTransport {
|
|
616
1199
|
private client;
|
|
617
1200
|
private config;
|
|
@@ -632,6 +1215,7 @@ export declare class TiledeskTransport {
|
|
|
632
1215
|
private inboundUpdateRegex;
|
|
633
1216
|
constructor(config: TiledeskTransportConfig);
|
|
634
1217
|
connect(): Promise<void>;
|
|
1218
|
+
private debugLog;
|
|
635
1219
|
subscribeWildcard(): void;
|
|
636
1220
|
subscribeToConversation(conversationId: string): void;
|
|
637
1221
|
unsubscribeFromConversation(conversationId: string): void;
|
|
@@ -693,6 +1277,64 @@ export declare interface TiledeskTransportConfig {
|
|
|
693
1277
|
fileTemplate?: TiledeskFileTemplateConfig;
|
|
694
1278
|
recipientFullnameResolver?: (conversationId: string) => string | undefined;
|
|
695
1279
|
senderFullname?: string;
|
|
1280
|
+
/**
|
|
1281
|
+
* If true (default), AikaaraChatClient publishes a `CHAT_INITIATED` event
|
|
1282
|
+
* to the conversation's outbound topic on first connect — but only when
|
|
1283
|
+
* the conversation history is empty (so reload of an in-flight chat
|
|
1284
|
+
* doesn't replay the kickoff).
|
|
1285
|
+
*/
|
|
1286
|
+
autoInitiateOnEmpty?: boolean;
|
|
1287
|
+
/** Extra attributes merged into the auto-fired CHAT_INITIATED envelope. */
|
|
1288
|
+
chatInitiatedAttributes?: Record<string, unknown>;
|
|
1289
|
+
/**
|
|
1290
|
+
* Log decoded MQTT frames to console as they're sent/received.
|
|
1291
|
+
* Off by default — set true for debugging Tiledesk wire traffic.
|
|
1292
|
+
*/
|
|
1293
|
+
debug?: boolean;
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
declare interface TiledeskTransportConfig_2 {
|
|
1297
|
+
mqttEndpoint: string;
|
|
1298
|
+
jwtToken: string;
|
|
1299
|
+
userId: string;
|
|
1300
|
+
userName?: string;
|
|
1301
|
+
projectId: string;
|
|
1302
|
+
appId?: string;
|
|
1303
|
+
clientId?: string;
|
|
1304
|
+
protocolVersion?: 3 | 4 | 5;
|
|
1305
|
+
protocolId?: 'MQIsdp' | 'MQTT';
|
|
1306
|
+
mqttUsername?: string;
|
|
1307
|
+
connectTimeoutMs?: number;
|
|
1308
|
+
keepAliveSec?: number;
|
|
1309
|
+
maxReconnectAttempts?: number;
|
|
1310
|
+
reconnectMaxDelayMs?: number;
|
|
1311
|
+
tokenProvider?: () => Promise<string>;
|
|
1312
|
+
wildcardSubscribe?: boolean;
|
|
1313
|
+
subscribeQos?: 0 | 1 | 2;
|
|
1314
|
+
publishQos?: 0 | 1 | 2;
|
|
1315
|
+
publishRetain?: boolean;
|
|
1316
|
+
enablePresence?: boolean;
|
|
1317
|
+
presencePayloadConnected?: Record<string, unknown>;
|
|
1318
|
+
presencePayloadDisconnected?: Record<string, unknown>;
|
|
1319
|
+
topicTemplates?: TiledeskTopicTemplates_2;
|
|
1320
|
+
messageDefaults?: TiledeskMessageDefaults_2;
|
|
1321
|
+
fileTemplate?: TiledeskFileTemplateConfig_2;
|
|
1322
|
+
recipientFullnameResolver?: (conversationId: string) => string | undefined;
|
|
1323
|
+
senderFullname?: string;
|
|
1324
|
+
/**
|
|
1325
|
+
* If true (default), AikaaraChatClient publishes a `CHAT_INITIATED` event
|
|
1326
|
+
* to the conversation's outbound topic on first connect — but only when
|
|
1327
|
+
* the conversation history is empty (so reload of an in-flight chat
|
|
1328
|
+
* doesn't replay the kickoff).
|
|
1329
|
+
*/
|
|
1330
|
+
autoInitiateOnEmpty?: boolean;
|
|
1331
|
+
/** Extra attributes merged into the auto-fired CHAT_INITIATED envelope. */
|
|
1332
|
+
chatInitiatedAttributes?: Record<string, unknown>;
|
|
1333
|
+
/**
|
|
1334
|
+
* Log decoded MQTT frames to console as they're sent/received.
|
|
1335
|
+
* Off by default — set true for debugging Tiledesk wire traffic.
|
|
1336
|
+
*/
|
|
1337
|
+
debug?: boolean;
|
|
696
1338
|
}
|
|
697
1339
|
|
|
698
1340
|
export declare interface ToolCall {
|
|
@@ -704,15 +1346,31 @@ export declare interface ToolCall {
|
|
|
704
1346
|
};
|
|
705
1347
|
}
|
|
706
1348
|
|
|
1349
|
+
declare interface ToolCall_2 {
|
|
1350
|
+
id: string;
|
|
1351
|
+
type: 'function';
|
|
1352
|
+
function: {
|
|
1353
|
+
name: string;
|
|
1354
|
+
arguments: string;
|
|
1355
|
+
};
|
|
1356
|
+
}
|
|
1357
|
+
|
|
707
1358
|
export declare interface ToolCallResult {
|
|
708
1359
|
tool_call_id: string;
|
|
709
1360
|
content: string;
|
|
710
1361
|
}
|
|
711
1362
|
|
|
1363
|
+
declare interface ToolCallResult_2 {
|
|
1364
|
+
tool_call_id: string;
|
|
1365
|
+
content: string;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
712
1368
|
export declare type TransportMessageHandler = (message: TiledeskMessage, ctx: TiledeskMessageContext) => void;
|
|
713
1369
|
|
|
714
1370
|
declare type TransportMode = 'aikaara' | 'tiledesk' | 'dual';
|
|
715
1371
|
|
|
1372
|
+
declare type TransportMode_2 = 'aikaara' | 'tiledesk' | 'dual';
|
|
1373
|
+
|
|
716
1374
|
export declare type TransportStateHandler = (connected: boolean) => void;
|
|
717
1375
|
|
|
718
1376
|
export declare type TransportStatusUpdateHandler = (update: TiledeskStatusUpdate) => void;
|
|
@@ -721,6 +1379,10 @@ export declare interface UploadAdapter {
|
|
|
721
1379
|
upload(file: File | Blob, ctx: UploadAdapterContext): Promise<UploadAdapterResult>;
|
|
722
1380
|
}
|
|
723
1381
|
|
|
1382
|
+
declare interface UploadAdapter_2 {
|
|
1383
|
+
upload(file: File | Blob, ctx: UploadAdapterContext_2): Promise<UploadAdapterResult_2>;
|
|
1384
|
+
}
|
|
1385
|
+
|
|
724
1386
|
export declare interface UploadAdapterContext {
|
|
725
1387
|
conversationId: string;
|
|
726
1388
|
userId: string;
|
|
@@ -728,6 +1390,13 @@ export declare interface UploadAdapterContext {
|
|
|
728
1390
|
appId?: string;
|
|
729
1391
|
}
|
|
730
1392
|
|
|
1393
|
+
declare interface UploadAdapterContext_2 {
|
|
1394
|
+
conversationId: string;
|
|
1395
|
+
userId: string;
|
|
1396
|
+
projectId?: string;
|
|
1397
|
+
appId?: string;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
731
1400
|
export declare interface UploadAdapterResult {
|
|
732
1401
|
url: string;
|
|
733
1402
|
fileName: string;
|
|
@@ -738,6 +1407,16 @@ export declare interface UploadAdapterResult {
|
|
|
738
1407
|
meta?: Record<string, unknown>;
|
|
739
1408
|
}
|
|
740
1409
|
|
|
1410
|
+
declare interface UploadAdapterResult_2 {
|
|
1411
|
+
url: string;
|
|
1412
|
+
fileName: string;
|
|
1413
|
+
cloudFileId?: string;
|
|
1414
|
+
relativePath?: string;
|
|
1415
|
+
contentType?: string;
|
|
1416
|
+
byteSize?: number;
|
|
1417
|
+
meta?: Record<string, unknown>;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
741
1420
|
export declare interface WidgetConfig extends ChatClientConfig {
|
|
742
1421
|
position?: 'bottom-right' | 'bottom-left';
|
|
743
1422
|
offset?: {
|
|
@@ -761,6 +1440,92 @@ export declare interface WidgetConfig extends ChatClientConfig {
|
|
|
761
1440
|
bubbleText?: string;
|
|
762
1441
|
bubbleIcon?: string;
|
|
763
1442
|
uploadAdapter?: UploadAdapter;
|
|
1443
|
+
historyAdapter?: ConversationHistoryAdapter;
|
|
1444
|
+
/**
|
|
1445
|
+
* Display mode:
|
|
1446
|
+
* - `popup` (default): floating bubble in the corner, click to open panel.
|
|
1447
|
+
* - `embed`: render the chat panel inline at the host element's location,
|
|
1448
|
+
* filling its container. Bubble + open/close animation are skipped.
|
|
1449
|
+
*/
|
|
1450
|
+
display?: 'popup' | 'embed';
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
export declare interface WidgetConfigDescriptor {
|
|
1454
|
+
/** Visuals */
|
|
1455
|
+
display?: 'popup' | 'embed';
|
|
1456
|
+
position?: 'bottom-right' | 'bottom-left';
|
|
1457
|
+
primaryColor?: string;
|
|
1458
|
+
title?: string;
|
|
1459
|
+
subtitle?: string;
|
|
1460
|
+
avatarUrl?: string;
|
|
1461
|
+
width?: number;
|
|
1462
|
+
height?: number;
|
|
1463
|
+
borderRadius?: number;
|
|
1464
|
+
fontFamily?: string;
|
|
1465
|
+
welcomeMessage?: string;
|
|
1466
|
+
placeholder?: string;
|
|
1467
|
+
showTimestamps?: boolean;
|
|
1468
|
+
persistConversation?: boolean;
|
|
1469
|
+
/** Transport selection */
|
|
1470
|
+
transport?: TransportMode;
|
|
1471
|
+
/** Tiledesk wire config (JSON-serializable subset of TiledeskTransportConfig) */
|
|
1472
|
+
tiledesk?: {
|
|
1473
|
+
mqttEndpoint: string;
|
|
1474
|
+
appId?: string;
|
|
1475
|
+
projectId: string;
|
|
1476
|
+
mqttUsername?: string;
|
|
1477
|
+
protocolId?: 'MQIsdp' | 'MQTT';
|
|
1478
|
+
protocolVersion?: 3 | 4 | 5;
|
|
1479
|
+
keepAliveSec?: number;
|
|
1480
|
+
connectTimeoutMs?: number;
|
|
1481
|
+
maxReconnectAttempts?: number;
|
|
1482
|
+
reconnectMaxDelayMs?: number;
|
|
1483
|
+
wildcardSubscribe?: boolean;
|
|
1484
|
+
enablePresence?: boolean;
|
|
1485
|
+
autoInitiateOnEmpty?: boolean;
|
|
1486
|
+
chatInitiatedAttributes?: Record<string, unknown>;
|
|
1487
|
+
messageDefaults?: TiledeskMessageDefaults;
|
|
1488
|
+
fileTemplate?: TiledeskFileTemplateConfig;
|
|
1489
|
+
topicTemplates?: TiledeskTopicTemplates;
|
|
1490
|
+
debug?: boolean;
|
|
1491
|
+
/**
|
|
1492
|
+
* Pattern for `support-group-…` requestId minted on first chat. Use
|
|
1493
|
+
* `{projectId}` and `{uuid}` placeholders. Defaults to bandhan's
|
|
1494
|
+
* `support-group-{projectId}-{uuid}`.
|
|
1495
|
+
*/
|
|
1496
|
+
requestIdTemplate?: string;
|
|
1497
|
+
};
|
|
1498
|
+
/** Defaults merged into every form-action postback */
|
|
1499
|
+
templateActionAttributes?: Record<string, unknown>;
|
|
1500
|
+
/** Adapter endpoints — SDK builds the actual fetch calls */
|
|
1501
|
+
uploadEndpoint?: string;
|
|
1502
|
+
uploadFieldName?: string;
|
|
1503
|
+
uploadExtraFields?: Record<string, string>;
|
|
1504
|
+
historyApiBase?: string;
|
|
1505
|
+
historyPageSize?: number;
|
|
1506
|
+
historyPathTemplate?: string;
|
|
1507
|
+
/**
|
|
1508
|
+
* Server-side session-token exchange. When set, the SDK exchanges the
|
|
1509
|
+
* caller-supplied `sessionToken` for a chat JWT + conversation requestId
|
|
1510
|
+
* itself — the host app no longer needs a `tokenProvider` callback.
|
|
1511
|
+
*/
|
|
1512
|
+
auth?: SessionAuthDescriptor;
|
|
1513
|
+
/**
|
|
1514
|
+
* Built-in upload strategy. `mode: "presigned-3step"` runs sign → PUT →
|
|
1515
|
+
* register entirely from descriptor config; `mode: "direct"` POSTs as
|
|
1516
|
+
* multipart to a single endpoint; `mode: "none"` disables uploads. Host
|
|
1517
|
+
* apps can still override with `opts.uploadAdapter`.
|
|
1518
|
+
*/
|
|
1519
|
+
upload?: {
|
|
1520
|
+
mode: 'none';
|
|
1521
|
+
} | {
|
|
1522
|
+
mode: 'direct';
|
|
1523
|
+
endpoint: string;
|
|
1524
|
+
fieldName?: string;
|
|
1525
|
+
extraFields?: Record<string, string>;
|
|
1526
|
+
} | ({
|
|
1527
|
+
mode: 'presigned-3step';
|
|
1528
|
+
} & Presigned3StepAdapterConfig);
|
|
764
1529
|
}
|
|
765
1530
|
|
|
766
1531
|
export { }
|