@aikaara/chat-sdk 0.1.3 → 0.2.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/README.md +435 -0
- package/dist/AikaaraChatClient-C4lWcRsS.mjs +611 -0
- package/dist/AikaaraChatClient-ChZ2bL9f.cjs +1 -0
- package/dist/cdn/aikaara-chat.iife.js +52 -19
- package/dist/headless.cjs +8 -1
- package/dist/headless.d.ts +253 -2
- package/dist/headless.mjs +10588 -9
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +255 -2
- package/dist/index.mjs +21 -18
- package/dist/ui.cjs +45 -19
- package/dist/ui.d.ts +208 -1
- package/dist/ui.mjs +221 -206
- package/package.json +5 -2
- package/dist/headless-CXRux2Q-.mjs +0 -565
- package/dist/headless-DDmLD-ag.cjs +0 -1
package/dist/ui.d.ts
CHANGED
|
@@ -6,6 +6,50 @@ export declare class AikaaraChatBubble extends HTMLElement {
|
|
|
6
6
|
setIcon(svgOrText: string): void;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
declare class AikaaraChatClient extends EventEmitter<ChatEvents> {
|
|
10
|
+
private connection;
|
|
11
|
+
private api;
|
|
12
|
+
private messageStore;
|
|
13
|
+
private conversationManager;
|
|
14
|
+
private subscription;
|
|
15
|
+
private config;
|
|
16
|
+
constructor(config: ChatClientConfig_2);
|
|
17
|
+
connect(): Promise<void>;
|
|
18
|
+
sendMessage(content: string): Promise<void>;
|
|
19
|
+
sendUserEvent(eventKey: string, value?: object, source?: string): Promise<void>;
|
|
20
|
+
loadHistory(): Promise<Message_2[]>;
|
|
21
|
+
get messages(): Message_2[];
|
|
22
|
+
get conversationId(): string | null;
|
|
23
|
+
get isConnected(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Update the agent's context with information about the host app's current state.
|
|
26
|
+
* Call this on route changes so the agent knows what page/entity the user is viewing.
|
|
27
|
+
*
|
|
28
|
+
* The context is stored in conversation metadata and interpolated into the system prompt.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* // On route change
|
|
33
|
+
* client.setContext({
|
|
34
|
+
* currentPage: '/products/42',
|
|
35
|
+
* entityType: 'product',
|
|
36
|
+
* entityId: '42',
|
|
37
|
+
* availableRoutes: { products: '/products', orders: '/orders' },
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
setContext(context: AppContext): Promise<void>;
|
|
42
|
+
disconnect(): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Parse structured action results from tool execution output.
|
|
45
|
+
* When the agent calls tools like `edit_current_entity`, `save_current_entity`,
|
|
46
|
+
* `navigate_to`, or `test_tool_by_id`, the result contains an action payload
|
|
47
|
+
* that the SDK emits as a typed event for the host app to handle.
|
|
48
|
+
*/
|
|
49
|
+
private parseActionResult;
|
|
50
|
+
private handleBroadcast;
|
|
51
|
+
}
|
|
52
|
+
|
|
9
53
|
export declare class AikaaraChatHeader extends HTMLElement {
|
|
10
54
|
private shadow;
|
|
11
55
|
static get observedAttributes(): string[];
|
|
@@ -45,6 +89,8 @@ export declare class AikaaraChatWidget extends HTMLElement {
|
|
|
45
89
|
private getConfig;
|
|
46
90
|
private render;
|
|
47
91
|
private initController;
|
|
92
|
+
sendUserEvent(eventKey: string, value?: Record<string, unknown>, source?: string): void;
|
|
93
|
+
getClient(): AikaaraChatClient | null;
|
|
48
94
|
private darkenColor;
|
|
49
95
|
}
|
|
50
96
|
|
|
@@ -104,12 +150,28 @@ export declare class AikaaraTypingIndicator extends HTMLElement {
|
|
|
104
150
|
hide(): void;
|
|
105
151
|
}
|
|
106
152
|
|
|
153
|
+
declare interface AppContext {
|
|
154
|
+
/** Current page/route path in the host app (e.g., '/products/42') */
|
|
155
|
+
currentPage: string;
|
|
156
|
+
/** Entity type on the current page (e.g., 'product', 'agent') */
|
|
157
|
+
entityType?: string;
|
|
158
|
+
/** Entity ID on the current page */
|
|
159
|
+
entityId?: string | number;
|
|
160
|
+
/** Project/workspace ID if applicable */
|
|
161
|
+
projectId?: string | number;
|
|
162
|
+
/** Routes the agent can navigate to — map of label → path */
|
|
163
|
+
availableRoutes?: Record<string, string>;
|
|
164
|
+
/** Additional context for the agent (e.g., form field names, entity schema) */
|
|
165
|
+
custom?: Record<string, unknown>;
|
|
166
|
+
}
|
|
167
|
+
|
|
107
168
|
declare interface ChatClientConfig extends ConnectionConfig {
|
|
108
169
|
apiKey?: string;
|
|
170
|
+
authToken?: string;
|
|
109
171
|
extUid?: string;
|
|
110
172
|
conversationId?: string;
|
|
111
173
|
systemPromptId?: number;
|
|
112
|
-
channel?: 'widget' | 'api';
|
|
174
|
+
channel?: 'widget' | 'api' | 'sidekick';
|
|
113
175
|
onMessage?: (message: Message) => void;
|
|
114
176
|
onStatusChange?: (status: string) => void;
|
|
115
177
|
onError?: (error: Error) => void;
|
|
@@ -117,9 +179,73 @@ declare interface ChatClientConfig extends ConnectionConfig {
|
|
|
117
179
|
onConnectionStateChange?: (state: ConnectionState) => void;
|
|
118
180
|
}
|
|
119
181
|
|
|
182
|
+
declare interface ChatClientConfig_2 extends ConnectionConfig_2 {
|
|
183
|
+
apiKey?: string;
|
|
184
|
+
authToken?: string;
|
|
185
|
+
extUid?: string;
|
|
186
|
+
conversationId?: string;
|
|
187
|
+
systemPromptId?: number;
|
|
188
|
+
channel?: 'widget' | 'api' | 'sidekick';
|
|
189
|
+
onMessage?: (message: Message_2) => void;
|
|
190
|
+
onStatusChange?: (status: string) => void;
|
|
191
|
+
onError?: (error: Error) => void;
|
|
192
|
+
onStreamUpdate?: (delta: string, fullContent: string) => void;
|
|
193
|
+
onConnectionStateChange?: (state: ConnectionState_2) => void;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
declare interface ChatEvents {
|
|
197
|
+
'connection:state': ConnectionState_2;
|
|
198
|
+
'message:received': Message_2;
|
|
199
|
+
'message:updated': Message_2;
|
|
200
|
+
'message:sent': Message_2;
|
|
201
|
+
'stream:start': {
|
|
202
|
+
messageId: string;
|
|
203
|
+
};
|
|
204
|
+
'stream:update': {
|
|
205
|
+
delta: string;
|
|
206
|
+
content: string;
|
|
207
|
+
};
|
|
208
|
+
'stream:end': {
|
|
209
|
+
messageId: string;
|
|
210
|
+
usage?: {
|
|
211
|
+
tokensInput: number;
|
|
212
|
+
tokensOutput: number;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
'typing:start': void;
|
|
216
|
+
'typing:stop': void;
|
|
217
|
+
'error': Error;
|
|
218
|
+
'status': string;
|
|
219
|
+
'action:edit_entity': EditEntityAction;
|
|
220
|
+
'action:save_entity': SaveEntityAction;
|
|
221
|
+
'action:test_tool': TestToolAction;
|
|
222
|
+
'action:navigate': NavigateAction;
|
|
223
|
+
'tool:start': {
|
|
224
|
+
toolName: string;
|
|
225
|
+
args: Record<string, unknown>;
|
|
226
|
+
};
|
|
227
|
+
'tool:end': {
|
|
228
|
+
toolName: string;
|
|
229
|
+
result: unknown;
|
|
230
|
+
isError: boolean;
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
120
234
|
declare interface ConnectionConfig {
|
|
121
235
|
baseUrl: string;
|
|
236
|
+
wsUrl?: string;
|
|
122
237
|
userToken: string;
|
|
238
|
+
tiledesk?: TiledeskTransportConfig;
|
|
239
|
+
reconnect?: boolean;
|
|
240
|
+
maxReconnectAttempts?: number;
|
|
241
|
+
reconnectInterval?: number;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
declare interface ConnectionConfig_2 {
|
|
245
|
+
baseUrl: string;
|
|
246
|
+
wsUrl?: string;
|
|
247
|
+
userToken: string;
|
|
248
|
+
tiledesk?: TiledeskTransportConfig_2;
|
|
123
249
|
reconnect?: boolean;
|
|
124
250
|
maxReconnectAttempts?: number;
|
|
125
251
|
reconnectInterval?: number;
|
|
@@ -127,6 +253,29 @@ declare interface ConnectionConfig {
|
|
|
127
253
|
|
|
128
254
|
declare type ConnectionState = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
|
|
129
255
|
|
|
256
|
+
declare type ConnectionState_2 = 'disconnected' | 'connecting' | 'connected' | 'reconnecting';
|
|
257
|
+
|
|
258
|
+
declare interface EditEntityAction {
|
|
259
|
+
action: 'edit_entity';
|
|
260
|
+
entity_type: string;
|
|
261
|
+
entity_id: string | number;
|
|
262
|
+
fields: FieldUpdate[];
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
declare class EventEmitter<Events extends Record<string, any>> {
|
|
266
|
+
private handlers;
|
|
267
|
+
on<K extends keyof Events & string>(event: K, handler: (data: Events[K]) => void): () => void;
|
|
268
|
+
off<K extends keyof Events & string>(event: K, handler: (data: Events[K]) => void): void;
|
|
269
|
+
emit<K extends keyof Events & string>(event: K, data: Events[K]): void;
|
|
270
|
+
removeAllListeners(): void;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
declare interface FieldUpdate {
|
|
274
|
+
field: string;
|
|
275
|
+
value: unknown;
|
|
276
|
+
previousValue?: unknown;
|
|
277
|
+
}
|
|
278
|
+
|
|
130
279
|
declare interface Message {
|
|
131
280
|
id: string;
|
|
132
281
|
conversationId: string;
|
|
@@ -141,8 +290,52 @@ declare interface Message {
|
|
|
141
290
|
status?: 'sending' | 'sent' | 'streaming' | 'complete' | 'error';
|
|
142
291
|
}
|
|
143
292
|
|
|
293
|
+
declare interface Message_2 {
|
|
294
|
+
id: string;
|
|
295
|
+
conversationId: string;
|
|
296
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
297
|
+
content: string;
|
|
298
|
+
toolCalls?: ToolCall_2[];
|
|
299
|
+
toolCallResults?: ToolCallResult_2;
|
|
300
|
+
tokensInput?: number;
|
|
301
|
+
tokensOutput?: number;
|
|
302
|
+
metadata?: Record<string, unknown>;
|
|
303
|
+
createdAt: string;
|
|
304
|
+
status?: 'sending' | 'sent' | 'streaming' | 'complete' | 'error';
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
declare interface NavigateAction {
|
|
308
|
+
navigate_to: string;
|
|
309
|
+
}
|
|
310
|
+
|
|
144
311
|
export declare function registerComponents(): void;
|
|
145
312
|
|
|
313
|
+
declare interface SaveEntityAction {
|
|
314
|
+
action: 'save_entity';
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
declare interface TestToolAction {
|
|
318
|
+
action: 'test_tool';
|
|
319
|
+
tool_id: number;
|
|
320
|
+
parameters: Record<string, unknown>;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
declare interface TiledeskTransportConfig {
|
|
324
|
+
mqttEndpoint: string;
|
|
325
|
+
jwtToken: string;
|
|
326
|
+
userId: string;
|
|
327
|
+
userName?: string;
|
|
328
|
+
projectId: string;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
declare interface TiledeskTransportConfig_2 {
|
|
332
|
+
mqttEndpoint: string;
|
|
333
|
+
jwtToken: string;
|
|
334
|
+
userId: string;
|
|
335
|
+
userName?: string;
|
|
336
|
+
projectId: string;
|
|
337
|
+
}
|
|
338
|
+
|
|
146
339
|
declare interface ToolCall {
|
|
147
340
|
id: string;
|
|
148
341
|
type: 'function';
|
|
@@ -152,11 +345,25 @@ declare interface ToolCall {
|
|
|
152
345
|
};
|
|
153
346
|
}
|
|
154
347
|
|
|
348
|
+
declare interface ToolCall_2 {
|
|
349
|
+
id: string;
|
|
350
|
+
type: 'function';
|
|
351
|
+
function: {
|
|
352
|
+
name: string;
|
|
353
|
+
arguments: string;
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
|
|
155
357
|
declare interface ToolCallResult {
|
|
156
358
|
tool_call_id: string;
|
|
157
359
|
content: string;
|
|
158
360
|
}
|
|
159
361
|
|
|
362
|
+
declare interface ToolCallResult_2 {
|
|
363
|
+
tool_call_id: string;
|
|
364
|
+
content: string;
|
|
365
|
+
}
|
|
366
|
+
|
|
160
367
|
declare interface WidgetConfig extends ChatClientConfig {
|
|
161
368
|
position?: 'bottom-right' | 'bottom-left';
|
|
162
369
|
offset?: {
|