@bymos/agentkit-sdk 0.7.2 → 0.7.4
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/agentkit-widget.iife.js +15 -16
- package/agentkit-widget.js +15 -8309
- package/index.cjs +15 -16
- package/index.d.ts +656 -115
- package/index.js +7435 -9505
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,81 +1,232 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
1
|
+
import { JSX } from 'preact';
|
|
2
|
+
|
|
3
|
+
export declare type AgentKitWidgetConfig = {
|
|
4
|
+
agentId: string;
|
|
5
|
+
apiBaseUrl: string;
|
|
6
|
+
/** Tenant or organisation identifier. Required for conversation tracking and widget validation. */
|
|
7
|
+
tenantId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Identity of the end-user in the host application.
|
|
10
|
+
* All fields are optional — omit entirely for anonymous sessions.
|
|
11
|
+
*/
|
|
12
|
+
user?: {
|
|
13
|
+
/** Tenant's own identifier for this user — can be anything (DB user ID, UUID, email, etc.). */
|
|
14
|
+
externalId?: string;
|
|
15
|
+
/** User ID from the host app's auth system (e.g. JWT sub, Clerk userId). Highest-priority lookup key. */
|
|
16
|
+
authId?: string;
|
|
17
|
+
/** Display name — stored on the contact record. */
|
|
18
|
+
name?: string;
|
|
19
|
+
/** Email address — stored on the contact record. */
|
|
20
|
+
email?: string;
|
|
21
|
+
};
|
|
22
|
+
sessionId?: string;
|
|
23
|
+
mode?: 'floating' | 'inline';
|
|
24
|
+
title?: string;
|
|
25
|
+
/** Short subtitle shown below the agent name in the widget header. */
|
|
26
|
+
subtitle?: string;
|
|
27
|
+
/** Agent description — used in the widget empty state. Populated from the server; can be overridden by the host. */
|
|
28
|
+
description?: string;
|
|
29
|
+
/** URL of the agent's avatar image — shown in the header and launcher. */
|
|
30
|
+
avatarUrl?: string;
|
|
31
|
+
theme?: {
|
|
32
|
+
mode?: 'light' | 'dark' | 'system';
|
|
33
|
+
accentColor?: string;
|
|
34
|
+
fontFamily?: string;
|
|
35
|
+
borderRadius?: string;
|
|
36
|
+
};
|
|
37
|
+
metadata?: Record<string, unknown>;
|
|
38
|
+
streaming?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Preview mode. When true, the widget sends its session cookie with API requests so an
|
|
41
|
+
* authenticated tenant member can still chat with an agent whose status is inactive/draft.
|
|
42
|
+
* Intended for the dashboard sandbox only — third-party embeds should leave this false.
|
|
43
|
+
*/
|
|
44
|
+
preview?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Skip the SDK's own widget-config fetch during hydrate. Use when the host has already
|
|
47
|
+
* fetched the server config and provided all display fields (title, avatarUrl, suggestedQuestions)
|
|
48
|
+
* inline — avoids a duplicate network call. Dashboard sandbox sets this.
|
|
49
|
+
*/
|
|
50
|
+
skipServerConfigFetch?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Which agent config the server should serve: the published snapshot (default) or the
|
|
53
|
+
* live editable draft. `'draft'` is honoured ONLY for a caller with a session cookie for
|
|
54
|
+
* the owning tenant, so it is inert for third-party embeds — the dashboard sandbox uses
|
|
55
|
+
* it to preview unpublished edits. Intended for the dashboard only.
|
|
56
|
+
*/
|
|
57
|
+
configChannel?: 'draft' | 'published';
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export declare type ApiChatRequest = {
|
|
61
|
+
agentId: string;
|
|
62
|
+
/** Only the new user message — server owns the full conversation history. */
|
|
63
|
+
message: string;
|
|
64
|
+
/** Omit on the first turn; the server returns one to store for subsequent turns. */
|
|
65
|
+
sessionId?: string;
|
|
66
|
+
tenantId?: string;
|
|
67
|
+
/** Tenant's own identifier for this user — anything they want (DB ID, UUID, email, etc.). */
|
|
68
|
+
externalId?: string;
|
|
69
|
+
/** Display name of the authenticated user — stored on the contact record. */
|
|
70
|
+
name?: string;
|
|
71
|
+
/** Email of the authenticated user — stored on the contact record. */
|
|
72
|
+
email?: string;
|
|
73
|
+
/** User ID from the host app's auth system (e.g. JWT sub, Clerk userId). Stored as auth_user_id on the contact. */
|
|
74
|
+
authId?: string;
|
|
75
|
+
/** Optional browser fingerprint computed client-side (e.g. via FingerprintJS). */
|
|
76
|
+
fingerprint?: string;
|
|
77
|
+
metadata?: Record<string, unknown>;
|
|
78
|
+
/** ISO timestamp when the end-user accepted the privacy/consent notice. Recorded for PDPA consent obligation. */
|
|
79
|
+
consentAcceptedAt?: string;
|
|
80
|
+
/** Version of the privacy notice the user accepted (e.g. "2026-06-21"). */
|
|
81
|
+
consentVersion?: string;
|
|
82
|
+
/** @deprecated Use `attachments` with `kind: 'image'`. Retained for back-compat. */
|
|
83
|
+
imageUrl?: string;
|
|
84
|
+
/** Photos and files attached to this turn. Pre-uploaded via /v1/upload before sending. */
|
|
85
|
+
attachments?: Array<{
|
|
86
|
+
url: string;
|
|
87
|
+
mimeType: string;
|
|
88
|
+
fileName?: string;
|
|
89
|
+
kind: 'image' | 'file';
|
|
90
|
+
}>;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export declare type ApiChatResponse = {
|
|
94
|
+
content: string;
|
|
95
|
+
/** Always returned; store this and send it back on every subsequent request. */
|
|
96
|
+
sessionId: string;
|
|
97
|
+
images?: Array<{
|
|
98
|
+
base64?: string;
|
|
99
|
+
url?: string;
|
|
100
|
+
mimeType: string;
|
|
101
|
+
width?: number;
|
|
102
|
+
height?: number;
|
|
103
|
+
}>;
|
|
104
|
+
documents?: Array<{
|
|
105
|
+
url?: string;
|
|
106
|
+
mimeType: string;
|
|
107
|
+
fileName?: string;
|
|
108
|
+
sizeBytes?: number;
|
|
109
|
+
}>;
|
|
110
|
+
/**
|
|
111
|
+
* `true` when an operator has taken over and the AI is suppressed. The
|
|
112
|
+
* message was persisted but no assistant reply will follow from this turn.
|
|
113
|
+
*/
|
|
114
|
+
queued?: boolean;
|
|
115
|
+
/** Server-reported control mode when the turn was queued. */
|
|
116
|
+
controlMode?: 'ai' | 'human';
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export declare class ApiClient {
|
|
120
|
+
private baseUrl;
|
|
121
|
+
private options;
|
|
122
|
+
constructor(baseUrl: string, options?: WidgetRequestOptions);
|
|
123
|
+
private get credentials();
|
|
124
|
+
/** Decorate a channel-selecting route's URL with the serving channel. */
|
|
125
|
+
private channel;
|
|
126
|
+
/**
|
|
127
|
+
* Called during widget init phase. Validates that the tenantId resolves to a real
|
|
128
|
+
* tenant and that the agentId is accessible under that tenant.
|
|
129
|
+
* Returns a structured result — never throws.
|
|
130
|
+
*/
|
|
131
|
+
validateWidget(agentId: string, tenantId: string | undefined): Promise<ValidateWidgetResponse>;
|
|
132
|
+
chat(request: ApiChatRequest): Promise<ApiChatResponse>;
|
|
133
|
+
fetchSessionMessages(sessionId: string, tenantId?: string): Promise<Array<{
|
|
134
|
+
role: string;
|
|
135
|
+
content: string;
|
|
136
|
+
createdAt?: string;
|
|
137
|
+
imageUrl?: string;
|
|
138
|
+
images?: Array<{
|
|
139
|
+
url?: string;
|
|
140
|
+
base64?: string;
|
|
141
|
+
mimeType: string;
|
|
142
|
+
width?: number;
|
|
143
|
+
height?: number;
|
|
144
|
+
}>;
|
|
145
|
+
/** All user-uploaded attachments on this message (images + files). */
|
|
146
|
+
media?: Array<{
|
|
147
|
+
url: string;
|
|
148
|
+
mimeType: string;
|
|
149
|
+
fileName?: string;
|
|
150
|
+
source?: 'user_upload' | 'tool_generated';
|
|
151
|
+
}>;
|
|
152
|
+
/** `human` → operator reply; drives operator avatar + tint on hydrate. */
|
|
153
|
+
direction?: 'user_inbound' | 'ai' | 'human' | 'system' | null;
|
|
154
|
+
/** Operator display name when direction is 'human'. */
|
|
155
|
+
senderDisplay?: string | null;
|
|
156
|
+
}> | null>;
|
|
157
|
+
/**
|
|
158
|
+
* Upload a file to R2 via the API and return the presigned URL.
|
|
159
|
+
* @param fileBase64 - base64-encoded file contents (no data URL prefix)
|
|
160
|
+
* @param mimeType - e.g. 'image/jpeg'
|
|
161
|
+
* @param fileName - original file name (optional, used for the R2 key)
|
|
162
|
+
*/
|
|
163
|
+
uploadImage(fileBase64: string, mimeType: string, fileName?: string, agentId?: string, tenantId?: string): Promise<{
|
|
164
|
+
url: string;
|
|
165
|
+
}>;
|
|
166
|
+
/**
|
|
167
|
+
* Upload a non-image file (.pdf/.md/.txt/.csv) and return the presigned URL.
|
|
168
|
+
* Same shape as `uploadImage` but with `kind: 'file'` so the API validates
|
|
169
|
+
* against the file allowlist + per-agent size/count caps.
|
|
170
|
+
*/
|
|
171
|
+
uploadFile(fileBase64: string, mimeType: string, fileName?: string, agentId?: string, tenantId?: string): Promise<{
|
|
172
|
+
url: string;
|
|
173
|
+
}>;
|
|
174
|
+
fetchWidgetConfig(agentId: string, tenantId?: string): Promise<Record<string, unknown> | null>;
|
|
175
|
+
endSession(sessionId: string, tenantId?: string, agentId?: string, fingerprint?: string, externalId?: string, skipMemory?: boolean): Promise<void>;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Generates CSS custom property overrides from the widget theme config.
|
|
180
|
+
* These are injected into the shadow root's :host element.
|
|
181
|
+
*/
|
|
182
|
+
export declare function buildThemeVars(config: NormalizedWidgetConfig): string;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Full CSS string: base widget styles + theme variable overrides derived from config.
|
|
186
|
+
* Pass this to `init()` or `mount()`.
|
|
187
|
+
*/
|
|
188
|
+
export declare function buildWidgetCSS(config: NormalizedWidgetConfig): string;
|
|
189
|
+
|
|
190
|
+
export declare function clearSession(agentId: string): void;
|
|
191
|
+
|
|
192
|
+
export declare function Composer({ onSend, disabled, placeholder, photoSendingEnabled, fileUploadEnabled, attachmentMaxCount, attachmentMaxFileSizeMb, }: Props_7): JSX.Element;
|
|
193
|
+
|
|
194
|
+
declare type ComposerAttachment = {
|
|
195
|
+
file: File;
|
|
196
|
+
kind: 'image' | 'file';
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export declare function createFloatingContainer(): HTMLElement;
|
|
200
|
+
|
|
201
|
+
export declare function createShadowHost(container: HTMLElement): ShadowHost;
|
|
202
|
+
|
|
203
|
+
export declare function createWidget(config: NormalizedWidgetConfig, hostConfig: AgentKitWidgetConfig, render: RenderFn, css: string,
|
|
204
|
+
/** Provide a target element for inline mode; omit for floating mode. */
|
|
205
|
+
targetElement?: HTMLElement): WidgetInstance;
|
|
66
206
|
|
|
67
207
|
/** Destroy a widget by registry ID, or all widgets if no ID is given. */
|
|
68
208
|
export declare function destroy(id?: string): void;
|
|
69
209
|
|
|
70
|
-
|
|
210
|
+
/** Destroy a specific widget by its registry ID, or all widgets if no ID given. */
|
|
211
|
+
export declare function destroyWidget(id?: string): void;
|
|
212
|
+
|
|
213
|
+
declare type EmitArgs<K extends keyof WidgetEventMap> = WidgetEventMap[K] extends undefined ? [event: K, data?: undefined] : [event: K, data: WidgetEventMap[K]];
|
|
71
214
|
|
|
72
|
-
export
|
|
215
|
+
export declare function ErrorState({ message }: Props_8): JSX.Element;
|
|
73
216
|
|
|
74
|
-
export
|
|
217
|
+
export declare class EventEmitter {
|
|
218
|
+
private listeners;
|
|
219
|
+
on<K extends keyof WidgetEventMap>(event: K, handler: Handler<WidgetEventMap[K]>): void;
|
|
220
|
+
off<K extends keyof WidgetEventMap>(event: K, handler: Handler<WidgetEventMap[K]>): void;
|
|
221
|
+
emit<K extends keyof WidgetEventMap>(...args: EmitArgs<K>): void;
|
|
222
|
+
removeAllListeners(): void;
|
|
223
|
+
}
|
|
75
224
|
|
|
76
|
-
export
|
|
225
|
+
export declare function getSessionId(agentId: string): string | undefined;
|
|
77
226
|
|
|
78
|
-
|
|
227
|
+
declare type Handler<T> = (data: T) => void;
|
|
228
|
+
|
|
229
|
+
export declare function Header({ title, subtitle, avatarUrl, onClose, onReset, hideClose }: Props_4): JSX.Element;
|
|
79
230
|
|
|
80
231
|
/**
|
|
81
232
|
* Create a floating widget anchored to document.body.
|
|
@@ -83,15 +234,16 @@ export { Header }
|
|
|
83
234
|
*/
|
|
84
235
|
export declare function init(config: AgentKitWidgetConfig, render?: RenderFn, css?: string): WidgetInstance;
|
|
85
236
|
|
|
86
|
-
export
|
|
237
|
+
export declare function injectStyles(styleSlot: HTMLStyleElement, css: string): void;
|
|
87
238
|
|
|
88
|
-
export
|
|
239
|
+
export declare function Launcher({ isOpen, onClick, avatarUrl, ariaLabel }: Props_3): JSX.Element;
|
|
89
240
|
|
|
90
|
-
|
|
241
|
+
/** List all active widget IDs. */
|
|
242
|
+
export declare function listWidgets(): string[];
|
|
91
243
|
|
|
92
|
-
export
|
|
244
|
+
export declare function MessageBubble({ message }: Props_6): JSX.Element;
|
|
93
245
|
|
|
94
|
-
export
|
|
246
|
+
export declare function MessageList({ messages, isLoading, operatorFallbackLabel }: Props_5): JSX.Element;
|
|
95
247
|
|
|
96
248
|
/**
|
|
97
249
|
* Mount a widget inline inside the given DOM element.
|
|
@@ -105,48 +257,437 @@ export declare function mount(element: HTMLElement, config: AgentKitWidgetConfig
|
|
|
105
257
|
*/
|
|
106
258
|
export declare function mountFloating(element: HTMLElement, config: AgentKitWidgetConfig, render?: RenderFn, css?: string): WidgetInstance;
|
|
107
259
|
|
|
108
|
-
export
|
|
109
|
-
|
|
110
|
-
export
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
260
|
+
export declare function normalizeConfig(config: AgentKitWidgetConfig, serverConfig?: Record<string, unknown>): NormalizedWidgetConfig;
|
|
261
|
+
|
|
262
|
+
export declare type NormalizedWidgetConfig = {
|
|
263
|
+
agentId: string;
|
|
264
|
+
apiBaseUrl: string;
|
|
265
|
+
tenantId: string | undefined;
|
|
266
|
+
user: {
|
|
267
|
+
externalId: string | undefined;
|
|
268
|
+
authId: string | undefined;
|
|
269
|
+
name: string | undefined;
|
|
270
|
+
email: string | undefined;
|
|
271
|
+
};
|
|
272
|
+
sessionId: string | undefined;
|
|
273
|
+
mode: 'floating' | 'inline';
|
|
274
|
+
title: string;
|
|
275
|
+
subtitle: string | undefined;
|
|
276
|
+
/** Agent description — surfaced from agent.description for use in the empty state. */
|
|
277
|
+
description: string | undefined;
|
|
278
|
+
/** Suggested questions shown as chips in the widget empty state. Populated from the server. */
|
|
279
|
+
suggestedQuestions: Array<{
|
|
280
|
+
title: string;
|
|
281
|
+
description?: string;
|
|
282
|
+
prompt?: string;
|
|
283
|
+
}>;
|
|
284
|
+
avatarUrl: string | undefined;
|
|
285
|
+
streaming: boolean;
|
|
286
|
+
preview: boolean;
|
|
287
|
+
skipServerConfigFetch: boolean;
|
|
288
|
+
/** Serving channel asked of the API. `undefined` = published (the default). */
|
|
289
|
+
configChannel: 'draft' | 'published' | undefined;
|
|
290
|
+
metadata: Record<string, unknown>;
|
|
291
|
+
theme: {
|
|
292
|
+
mode: 'light' | 'dark' | 'system';
|
|
293
|
+
accentColor: string;
|
|
294
|
+
fontFamily: string;
|
|
295
|
+
borderRadius: string;
|
|
296
|
+
};
|
|
297
|
+
/** Whether end-users can attach and send photos in the widget. Premium feature. */
|
|
298
|
+
photoSendingEnabled: boolean;
|
|
299
|
+
/** Whether end-users can attach and send .pdf/.md/.txt/.csv files in the widget. */
|
|
300
|
+
fileUploadEnabled: boolean;
|
|
301
|
+
/** Maximum number of attachments (photos + files combined) per turn. Server-clamped. */
|
|
302
|
+
attachmentMaxCount: number;
|
|
303
|
+
/** Maximum per-attachment size (MB) — shared between photos and files. Server-clamped. */
|
|
304
|
+
attachmentMaxFileSizeMb: number;
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
export declare function prepareInlineContainer(element: HTMLElement): HTMLElement;
|
|
308
|
+
|
|
309
|
+
declare type Props = {
|
|
310
|
+
config: NormalizedWidgetConfig;
|
|
311
|
+
state: WidgetState;
|
|
312
|
+
callbacks: WidgetCallbacks;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
declare type Props_2 = {
|
|
316
|
+
config: NormalizedWidgetConfig;
|
|
317
|
+
messages: WidgetMessage[];
|
|
318
|
+
isLoading: boolean;
|
|
319
|
+
error: string | null;
|
|
320
|
+
isInline: boolean;
|
|
321
|
+
initStatus: 'validating' | 'ready' | 'error' | 'disabled';
|
|
322
|
+
initError: string | null;
|
|
323
|
+
callbacks: WidgetCallbacks;
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
declare type Props_3 = {
|
|
327
|
+
isOpen: boolean;
|
|
328
|
+
onClick: () => void;
|
|
329
|
+
avatarUrl?: string;
|
|
330
|
+
ariaLabel?: string;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
declare type Props_4 = {
|
|
334
|
+
title: string;
|
|
335
|
+
subtitle?: string;
|
|
336
|
+
avatarUrl?: string;
|
|
337
|
+
onClose?: () => void;
|
|
338
|
+
onReset?: () => void;
|
|
339
|
+
/** Hide the close button (e.g. inline mode) */
|
|
340
|
+
hideClose?: boolean;
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
declare type Props_5 = {
|
|
344
|
+
messages: WidgetMessage[];
|
|
345
|
+
isLoading: boolean;
|
|
346
|
+
operatorFallbackLabel?: string;
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
declare type Props_6 = {
|
|
350
|
+
message: WidgetMessage;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
declare type Props_7 = {
|
|
354
|
+
/**
|
|
355
|
+
* Called on submit. `attachments` carries both photos and files in selection
|
|
356
|
+
* order; the SDK pre-uploads each before sending the chat request.
|
|
357
|
+
*/
|
|
358
|
+
onSend: (text: string, attachments: ComposerAttachment[]) => void;
|
|
359
|
+
disabled?: boolean;
|
|
360
|
+
placeholder?: string;
|
|
361
|
+
/** When true, the "+" menu shows a Photo option. */
|
|
362
|
+
photoSendingEnabled?: boolean;
|
|
363
|
+
/** When true, the "+" menu shows a File option. */
|
|
364
|
+
fileUploadEnabled?: boolean;
|
|
365
|
+
/** Max total attachments per turn — counts photos + files combined. */
|
|
366
|
+
attachmentMaxCount?: number;
|
|
367
|
+
/** Max size per attachment in MB — applies to photos and files alike. */
|
|
368
|
+
attachmentMaxFileSizeMb?: number;
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
declare type Props_8 = {
|
|
372
|
+
message: string;
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
export declare function removeShadowHost(host: HTMLElement): void;
|
|
376
|
+
|
|
377
|
+
export declare type RenderFn = (mountPoint: HTMLElement, config: NormalizedWidgetConfig, initialState: WidgetState, callbacks: WidgetCallbacks) => {
|
|
378
|
+
update: (state: WidgetState, config: NormalizedWidgetConfig) => void;
|
|
379
|
+
destroy: () => void;
|
|
380
|
+
};
|
|
119
381
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
export
|
|
125
|
-
|
|
126
|
-
export { StreamCallbacks }
|
|
127
|
-
|
|
128
|
-
export { streamChat }
|
|
129
|
-
|
|
130
|
-
export { TypingIndicator }
|
|
131
|
-
|
|
132
|
-
export { WidgetApp }
|
|
133
|
-
|
|
134
|
-
export { WidgetCallbacks }
|
|
135
|
-
|
|
136
|
-
export { WidgetClient }
|
|
137
|
-
|
|
138
|
-
export { widgetCSS }
|
|
139
|
-
|
|
140
|
-
export { WidgetEventMap }
|
|
141
|
-
|
|
142
|
-
export { WidgetInstance }
|
|
143
|
-
|
|
144
|
-
export { WidgetMessage }
|
|
145
|
-
|
|
146
|
-
export { WidgetProgressEvent }
|
|
382
|
+
/**
|
|
383
|
+
* React-based render function — satisfies the RenderFn contract from widget-sdk.
|
|
384
|
+
* Pass this to `init()` or `mount()` along with `fullWidgetCSS`.
|
|
385
|
+
*/
|
|
386
|
+
export declare const renderWidget: RenderFn;
|
|
147
387
|
|
|
148
|
-
|
|
388
|
+
/**
|
|
389
|
+
* Returns 'dark' | 'light' by resolving 'system' against the OS preference.
|
|
390
|
+
*/
|
|
391
|
+
export declare function resolveThemeMode(mode: 'light' | 'dark' | 'system'): 'light' | 'dark';
|
|
392
|
+
|
|
393
|
+
export declare function setSessionId(agentId: string, sessionId: string): void;
|
|
394
|
+
|
|
395
|
+
export declare type ShadowHost = {
|
|
396
|
+
host: HTMLElement;
|
|
397
|
+
shadowRoot: ShadowRoot;
|
|
398
|
+
styleSlot: HTMLStyleElement;
|
|
399
|
+
mountPoint: HTMLElement;
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
declare type StateChangeCallback = (state: WidgetState, config: NormalizedWidgetConfig) => void;
|
|
403
|
+
|
|
404
|
+
export declare type StreamCallbacks = {
|
|
405
|
+
onDelta: (delta: string, accumulated: string) => void;
|
|
406
|
+
onEnd: (content: string) => void;
|
|
407
|
+
onError: (error: Error) => void;
|
|
408
|
+
/** Called as soon as the response headers arrive with the server-assigned session ID. */
|
|
409
|
+
onSession?: (sessionId: string) => void;
|
|
410
|
+
/** Called as soon as the response headers arrive with the server-assigned run ID. */
|
|
411
|
+
onRunId?: (runId: string) => void;
|
|
412
|
+
/** Called when image generation tool results are available mid-stream. */
|
|
413
|
+
onImages?: (images: WidgetImageData[]) => void;
|
|
414
|
+
/** Called when document delivery tool results (e.g. assets.send_asset) are available mid-stream. */
|
|
415
|
+
onDocuments?: (documents: WidgetDocumentData[]) => void;
|
|
416
|
+
/** Called when the engine begins executing tool calls between LLM turns.
|
|
417
|
+
* toolNames are restored tool IDs; activityMode is the agent's display mode
|
|
418
|
+
* ('off' means the client should not surface a tool-status indicator). */
|
|
419
|
+
onToolCallsStarted?: (toolNames: string[], activityMode?: string) => void;
|
|
420
|
+
/**
|
|
421
|
+
* Called when the server reports the turn was suppressed because an
|
|
422
|
+
* operator has taken over. The stream ends immediately after.
|
|
423
|
+
*/
|
|
424
|
+
onControlMode?: (mode: 'ai' | 'human', queued: boolean) => void;
|
|
425
|
+
/** Called when assistant_ack event is received — pre-execution acknowledgement. */
|
|
426
|
+
onAck?: (text: string) => void;
|
|
427
|
+
/** Called for each user-visible progress stage event. mode is the agent's effective
|
|
428
|
+
* display mode; timestamp is the server emit time (ISO) for truthful step durations. */
|
|
429
|
+
onProgress?: (stage: string, text: string, mode?: string, timestamp?: string) => void;
|
|
430
|
+
/** Called when a tool execution starts. toolId is the per-call id; toolName the restored tool id. */
|
|
431
|
+
onToolStart?: (toolId: string, text: string, toolName?: string, mode?: string, timestamp?: string) => void;
|
|
432
|
+
/** Called when a tool execution completes. ok is false when the tool failed. */
|
|
433
|
+
onToolComplete?: (toolId: string, text: string, durationMs: number, ok?: boolean) => void;
|
|
434
|
+
/** Called when the final_meta event arrives after done. `turn` carries the
|
|
435
|
+
* effective activity display mode and collapse-after-response setting. */
|
|
436
|
+
onFinalMeta?: (metrics: {
|
|
437
|
+
ttftMs?: number;
|
|
438
|
+
totalMs?: number;
|
|
439
|
+
provider?: string;
|
|
440
|
+
model?: string;
|
|
441
|
+
}, turn?: {
|
|
442
|
+
mode?: string;
|
|
443
|
+
collapseAfterFinal?: boolean;
|
|
444
|
+
}) => void;
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
export declare function streamChat(baseUrl: string, request: ApiChatRequest, callbacks: StreamCallbacks, options?: WidgetRequestOptions): Promise<void>;
|
|
448
|
+
|
|
449
|
+
export declare function TypingIndicator(): JSX.Element;
|
|
450
|
+
|
|
451
|
+
declare type ValidateWidgetErrorCode = 'AGENT_DISABLED' | 'AGENT_NOT_FOUND';
|
|
452
|
+
|
|
453
|
+
declare type ValidateWidgetResponse = {
|
|
454
|
+
valid: true;
|
|
455
|
+
agentId: string;
|
|
456
|
+
tenantId: string;
|
|
457
|
+
} | {
|
|
458
|
+
valid: false;
|
|
459
|
+
error: string;
|
|
460
|
+
code?: ValidateWidgetErrorCode;
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
export declare function WidgetApp({ config, state, callbacks }: Props): JSX.Element;
|
|
464
|
+
|
|
465
|
+
export declare type WidgetCallbacks = {
|
|
466
|
+
onOpen: () => void;
|
|
467
|
+
onClose: () => void;
|
|
468
|
+
onSendMessage: (text: string, attachments: Array<{
|
|
469
|
+
file: File;
|
|
470
|
+
kind: 'image' | 'file';
|
|
471
|
+
}>) => void;
|
|
472
|
+
onReset: () => void;
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
export declare class WidgetClient {
|
|
476
|
+
private readonly hostConfig;
|
|
477
|
+
private onStateChange;
|
|
478
|
+
private config;
|
|
479
|
+
private apiClient;
|
|
480
|
+
private state;
|
|
481
|
+
private fingerprint;
|
|
482
|
+
private eventSource;
|
|
483
|
+
readonly emitter: EventEmitter;
|
|
484
|
+
constructor(config: NormalizedWidgetConfig, hostConfig: AgentKitWidgetConfig, onStateChange: StateChangeCallback);
|
|
485
|
+
private reportError;
|
|
486
|
+
private initializeFingerprint;
|
|
487
|
+
getState(): WidgetState;
|
|
488
|
+
setOpen(isOpen: boolean): void;
|
|
489
|
+
private openWithGreeting;
|
|
490
|
+
/**
|
|
491
|
+
* Validate tenant + agent, fetch widget config from the server, and hydrate message history.
|
|
492
|
+
* Called once on init — fires and forgets from create-widget.ts.
|
|
493
|
+
* The renderer updates automatically via setState/onStateChange.
|
|
494
|
+
*/
|
|
495
|
+
hydrate(): Promise<void>;
|
|
496
|
+
private openEventStream;
|
|
497
|
+
/**
|
|
498
|
+
* Close the operator-reply SSE stream. Public because widget teardown must
|
|
499
|
+
* call it — EventSource auto-reconnects forever otherwise, so an SPA that
|
|
500
|
+
* mounts and unmounts the widget per route accumulates live connections (and
|
|
501
|
+
* server-side bus subscriptions) with no ceiling.
|
|
502
|
+
*/
|
|
503
|
+
closeEventStream(): void;
|
|
504
|
+
private setState;
|
|
505
|
+
private updateMessage;
|
|
506
|
+
/**
|
|
507
|
+
* End the current session on the server and clear conversation history.
|
|
508
|
+
* Emits a 'reset' event. The next message sent will create a fresh server session.
|
|
509
|
+
*/
|
|
510
|
+
resetConversation(): Promise<void>;
|
|
511
|
+
/**
|
|
512
|
+
* The session stored in sessionStorage has expired on the server (410).
|
|
513
|
+
* Clear it so the next attempt starts a fresh session.
|
|
514
|
+
*/
|
|
515
|
+
private handleSessionExpired;
|
|
516
|
+
sendMessage(text: string, attachments?: Array<{
|
|
517
|
+
file: File;
|
|
518
|
+
kind: 'image' | 'file';
|
|
519
|
+
}>): Promise<void>;
|
|
520
|
+
private sendNonStreaming;
|
|
521
|
+
private sendStreaming;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
declare type WidgetControlMode = 'ai_active' | 'human_takeover' | 'closed';
|
|
525
|
+
|
|
526
|
+
export declare const widgetCSS = "\n*, *::before, *::after {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n}\n\n:host {\n --ak-accent: #6366f1;\n --ak-accent-hover: #4f46e5;\n --ak-bg: #ffffff;\n --ak-surface: #f9fafb;\n --ak-text: #111827;\n --ak-text-muted: #6b7280;\n --ak-border: #e5e7eb;\n --ak-user-bg: var(--ak-accent);\n --ak-user-text: #ffffff;\n --ak-bot-bg: #f3f4f6;\n --ak-bot-text: #111827;\n --ak-maintenance-fg: #92400e;\n --ak-maintenance-bg: #fffbeb;\n --ak-maintenance-halo: #fcd34d;\n --ak-font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;\n --ak-radius: 12px;\n /* Chat surface texture \u2014 scattered line doodles, tiled. Neutral stroke (not accent-tinted)\n so it stays a texture rather than competing with brand colour. Alpha is baked into the\n SVG stroke, so the light/dark variants differ only in stroke rgba. */\n --ak-pattern: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' fill='none' stroke='rgba(0,0,0,0.045)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 30c5-8 14-8 19 0s14 8 19 0'/%3E%3Ccircle cx='96' cy='22' r='8'/%3E%3Cpath d='M150 34l6-11 6 11z'/%3E%3Cpath d='M196 18v14M189 25h14'/%3E%3Cpath d='M28 74h22M28 81h14'/%3E%3Cpath d='M84 68l8-8 8 8-8 8z'/%3E%3Cpath d='M186 76c0 7-6 12-13 12h-10l-6 6v-6c-5-1-8-6-8-12 0-7 6-12 13-12h11c7 0 13 5 13 12z'/%3E%3Ccircle cx='124' cy='104' r='5'/%3E%3Cpath d='M18 122c7-5 14-5 21 0'/%3E%3Cpath d='M62 132l7-13 7 13z'/%3E%3Cpath d='M106 156h20M106 163h12'/%3E%3Ccircle cx='176' cy='140' r='8'/%3E%3Cpath d='M32 170l6-6 6 6-6 6z'/%3E%3Cpath d='M148 196c5-7 13-7 18 0'/%3E%3Cpath d='M74 196v12M68 202h12'/%3E%3Ccircle cx='206' cy='178' r='4.5'/%3E%3Ccircle cx='58' cy='48' r='4'/%3E%3Cpath d='M128 56h16M128 62h10'/%3E%3Cpath d='M40 100l5-5 5 5-5 5z'/%3E%3Cpath d='M150 116c5-6 12-6 17 0'/%3E%3Ccircle cx='92' cy='128' r='4'/%3E%3Cpath d='M198 108v11M193 113h11'/%3E%3Cpath d='M8 148c5-7 12-7 17 0'/%3E%3Ccircle cx='142' cy='176' r='4'/%3E%3Cpath d='M76 166h16M76 172h9'/%3E%3Cpath d='M186 208l5-9 5 9z'/%3E%3Cpath d='M110 190l6-6 6 6-6 6z'/%3E%3Ccircle cx='46' cy='206' r='5'/%3E%3C/svg%3E\");\n --ak-pattern-size: 210px;\n --ak-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 8px 24px rgba(0, 0, 0, 0.08);\n --ak-launcher-size: 56px;\n /* Panel-to-launcher offset. Negative pulls the launcher up toward the panel.\n Applied as a margin on .ak-shell-wrap because CSS gap rejects negatives. */\n --ak-launcher-gap: -12px;\n font-family: var(--ak-font);\n -webkit-font-smoothing: antialiased;\n}\n\n/* Dark mode \u2014 set data-theme=\"dark\" on the shadow host element.\n Slate palette, aligned with the KlicForge dashboard dark tokens. */\n:host([data-theme=\"dark\"]) {\n --ak-bg: #0f172a; /* slate-900 \u2014 panel surface */\n --ak-surface: #1e293b; /* slate-800 \u2014 inputs, insets (lift off panel) */\n --ak-text: #f1f5f9; /* slate-100 */\n --ak-text-muted: #94a3b8;/* slate-400 */\n --ak-border: #334155; /* slate-700 */\n --ak-bot-bg: #1e293b; /* slate-800 \u2014 assistant bubble */\n --ak-bot-text: #f1f5f9; /* slate-100 */\n /* Same doodle tile, white stroke \u2014 dark surfaces need ~1.5x the alpha to read the same */\n --ak-pattern: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' fill='none' stroke='rgba(255,255,255,0.07)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 30c5-8 14-8 19 0s14 8 19 0'/%3E%3Ccircle cx='96' cy='22' r='8'/%3E%3Cpath d='M150 34l6-11 6 11z'/%3E%3Cpath d='M196 18v14M189 25h14'/%3E%3Cpath d='M28 74h22M28 81h14'/%3E%3Cpath d='M84 68l8-8 8 8-8 8z'/%3E%3Cpath d='M186 76c0 7-6 12-13 12h-10l-6 6v-6c-5-1-8-6-8-12 0-7 6-12 13-12h11c7 0 13 5 13 12z'/%3E%3Ccircle cx='124' cy='104' r='5'/%3E%3Cpath d='M18 122c7-5 14-5 21 0'/%3E%3Cpath d='M62 132l7-13 7 13z'/%3E%3Cpath d='M106 156h20M106 163h12'/%3E%3Ccircle cx='176' cy='140' r='8'/%3E%3Cpath d='M32 170l6-6 6 6-6 6z'/%3E%3Cpath d='M148 196c5-7 13-7 18 0'/%3E%3Cpath d='M74 196v12M68 202h12'/%3E%3Ccircle cx='206' cy='178' r='4.5'/%3E%3Ccircle cx='58' cy='48' r='4'/%3E%3Cpath d='M128 56h16M128 62h10'/%3E%3Cpath d='M40 100l5-5 5 5-5 5z'/%3E%3Cpath d='M150 116c5-6 12-6 17 0'/%3E%3Ccircle cx='92' cy='128' r='4'/%3E%3Cpath d='M198 108v11M193 113h11'/%3E%3Cpath d='M8 148c5-7 12-7 17 0'/%3E%3Ccircle cx='142' cy='176' r='4'/%3E%3Cpath d='M76 166h16M76 172h9'/%3E%3Cpath d='M186 208l5-9 5 9z'/%3E%3Cpath d='M110 190l6-6 6 6-6 6z'/%3E%3Ccircle cx='46' cy='206' r='5'/%3E%3C/svg%3E\");\n --ak-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.4);\n --ak-maintenance-fg: #fde68a;\n --ak-maintenance-bg: rgba(253, 230, 138, 0.06);\n --ak-maintenance-halo: #f59e0b;\n}\n\n/* \u2500\u2500 Floating layout \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-floating {\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 0;\n pointer-events: none;\n}\n.ak-floating > * {\n pointer-events: all;\n}\n\n/* \u2500\u2500 Inline layout \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-inline {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n min-height: 400px;\n max-height: 100%;\n}\n\n/* \u2500\u2500 Launcher button \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-launcher {\n width: var(--ak-launcher-size);\n height: var(--ak-launcher-size);\n border-radius: 50%;\n background: var(--ak-accent);\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n box-shadow: 0 4px 16px rgba(99, 102, 241, 0.45);\n transition: background 0.2s, transform 0.15s, box-shadow 0.2s;\n flex-shrink: 0;\n}\n.ak-launcher:hover {\n background: var(--ak-accent-hover);\n transform: scale(1.08);\n box-shadow: 0 6px 24px rgba(99, 102, 241, 0.55);\n}\n.ak-launcher:active {\n transform: scale(0.95);\n}\n.ak-launcher svg {\n pointer-events: none;\n}\n/* Launcher showing avatar image instead of chat icon */\n.ak-launcher--avatar {\n padding: 0;\n overflow: hidden;\n}\n.ak-launcher__avatar-img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 50%;\n pointer-events: none;\n}\n\n/* \u2500\u2500 Shell wrapper (positions the hanging branding tab) \u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-shell-wrap {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n margin-bottom: var(--ak-launcher-gap);\n}\n\n/* \u2500\u2500 Widget shell / panel \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-shell {\n background: var(--ak-bg);\n border-radius: var(--ak-radius);\n box-shadow: var(--ak-shadow);\n display: flex;\n flex-direction: column;\n overflow: hidden;\n border: 1px solid var(--ak-border);\n}\n.ak-shell--floating {\n width: 380px;\n height: 580px;\n}\n.ak-shell--inline {\n width: 100%;\n height: 100%;\n min-height: 400px;\n max-height: 100%;\n border-radius: 0;\n box-shadow: none;\n border: none;\n display: flex;\n flex-direction: column;\n}\n/* Inline shell-wrap fills its container and suppresses the duplicate widget header\n (the sidebar already renders its own header and close button). */\n.ak-inline .ak-shell-wrap {\n width: 100%;\n height: 100%;\n /* No launcher in inline mode \u2014 the negative offset would overflow the host. */\n margin-bottom: 0;\n}\n.ak-inline .ak-header {\n display: none;\n}\n.ak-shell-enter {\n animation: ak-panel-in 0.2s ease-out;\n}\n@keyframes ak-panel-in {\n from { opacity: 0; transform: translateY(10px) scale(0.97); }\n to { opacity: 1; transform: translateY(0) scale(1); }\n}\n\n/* \u2500\u2500 Header \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-header {\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n padding: 10px 14px;\n background: var(--ak-accent);\n color: #fff;\n flex-shrink: 0;\n gap: 8px;\n}\n.ak-header--confirming {\n flex-direction: column;\n align-items: stretch;\n justify-content: flex-start;\n gap: 0;\n}\n.ak-header__row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n gap: 8px;\n}\n.ak-header__status {\n width: 8px;\n height: 8px;\n border-radius: 50%;\n background: #4ade80;\n flex-shrink: 0;\n}\n.ak-header__title-group {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 1px;\n min-width: 0;\n}\n.ak-header__title {\n font-size: 15px;\n font-weight: 600;\n letter-spacing: -0.01em;\n}\n.ak-header__subtitle {\n font-size: 11px;\n font-weight: 400;\n opacity: 0.8;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.ak-header__close {\n width: 28px;\n height: 28px;\n border-radius: 50%;\n background: rgba(255, 255, 255, 0.2);\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #fff;\n transition: background 0.15s;\n flex-shrink: 0;\n}\n.ak-header__close:hover {\n background: rgba(255, 255, 255, 0.35);\n}\n.ak-header__avatar {\n width: 30px;\n height: 30px;\n border-radius: 50%;\n object-fit: cover;\n flex-shrink: 0;\n border: 2px solid rgba(255, 255, 255, 0.3);\n background: rgba(255, 255, 255, 0.15);\n}\n.ak-header__bot-icon {\n width: 28px;\n height: 28px;\n border-radius: 50%;\n background: rgba(255, 255, 255, 0.2);\n display: flex;\n align-items: center;\n justify-content: center;\n color: #fff;\n flex-shrink: 0;\n}\n.ak-header__button {\n width: 28px;\n height: 28px;\n border-radius: 50%;\n background: transparent;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #fff;\n transition: background 0.15s;\n flex-shrink: 0;\n}\n.ak-header__button:hover {\n background: rgba(255, 255, 255, 0.15);\n}\n.ak-header__button--active {\n background: rgba(255, 255, 255, 0.3);\n}\n.ak-header__confirm {\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n padding: 8px 0 0;\n margin: 8px 0 0;\n border-top: 1px solid rgba(255, 255, 255, 0.2);\n animation: ak-confirm-in 0.18s ease-out;\n}\n@keyframes ak-confirm-in {\n from { opacity: 0; transform: translateY(-4px); }\n to { opacity: 1; transform: translateY(0); }\n}\n.ak-header__confirm-text {\n display: flex;\n flex-direction: column;\n gap: 1px;\n flex: 1;\n min-width: 0;\n}\n.ak-header__confirm-title {\n font-size: 13px;\n font-weight: 600;\n color: #fff;\n line-height: 1.3;\n}\n.ak-header__confirm-sub {\n font-size: 11px;\n color: rgba(255, 255, 255, 0.75);\n line-height: 1.3;\n}\n.ak-header__confirm-actions {\n display: flex;\n align-items: center;\n gap: 6px;\n flex-shrink: 0;\n}\n.ak-header__confirm-cancel {\n padding: 5px 10px;\n border-radius: 6px;\n border: 1px solid rgba(255, 255, 255, 0.4);\n background: transparent;\n color: #fff;\n font-family: var(--ak-font);\n font-size: 12px;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.15s;\n white-space: nowrap;\n}\n.ak-header__confirm-cancel:hover {\n background: rgba(255, 255, 255, 0.15);\n}\n.ak-header__confirm-cancel:active {\n background: rgba(255, 255, 255, 0.25);\n}\n.ak-header__confirm-ok {\n padding: 5px 10px;\n border-radius: 6px;\n border: none;\n background: rgba(255, 255, 255, 0.2);\n color: #fff;\n font-family: var(--ak-font);\n font-size: 12px;\n font-weight: 600;\n cursor: pointer;\n transition: background 0.15s;\n white-space: nowrap;\n}\n.ak-header__confirm-ok:hover {\n background: rgba(239, 68, 68, 0.7);\n}\n.ak-header__confirm-ok:active {\n background: rgba(239, 68, 68, 0.85);\n}\n\n/* \u2500\u2500 Message list \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-messages {\n flex: 1;\n overflow-y: auto;\n padding: 12px;\n display: flex;\n flex-direction: column;\n gap: 8px;\n scroll-behavior: smooth;\n min-height: 0; /* Allow flex child to shrink below its content height */\n /* Faint doodle texture so bubbles read as objects on a surface, not floating on flat colour.\n background-attachment defaults to scroll = anchored to the padding box, so the\n pattern stays put while messages scroll. */\n background-image: var(--ak-pattern);\n background-size: var(--ak-pattern-size) var(--ak-pattern-size);\n}\n.ak-messages::-webkit-scrollbar { width: 4px; }\n.ak-messages::-webkit-scrollbar-track { background: transparent; }\n.ak-messages::-webkit-scrollbar-thumb {\n background: var(--ak-border);\n border-radius: 4px;\n}\n\n/* \u2500\u2500 Empty state \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-empty-state {\n flex: 1;\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: safe center;\n padding: 16px;\n text-align: center;\n gap: 16px;\n overflow-y: auto;\n overflow-x: hidden;\n min-height: 0;\n /* Glow layer is translucent so the same doodle texture as .ak-messages shows through \u2014\n keeps empty state and message list on one continuous surface. */\n background-color: var(--ak-bg);\n background-image:\n radial-gradient(ellipse 110% 55% at 50% 0%,\n color-mix(in srgb, var(--ak-accent) 10%, transparent),\n transparent 72%\n ),\n var(--ak-pattern);\n background-size: auto, var(--ak-pattern-size) var(--ak-pattern-size);\n}\n/* Decorative blurred orb behind the avatar */\n.ak-empty-state__glow {\n position: absolute;\n top: -24px;\n left: 50%;\n transform: translateX(-50%);\n width: 180px;\n height: 180px;\n border-radius: 50%;\n background: color-mix(in srgb, var(--ak-accent) 18%, transparent);\n filter: blur(48px);\n pointer-events: none;\n}\n.ak-empty-state__body {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n position: relative;\n width: 100%;\n}\n.ak-empty-state__avatar {\n width: 64px;\n height: 64px;\n border-radius: 50%;\n background: var(--ak-bg);\n border: 2px solid color-mix(in srgb, var(--ak-accent) 25%, var(--ak-border));\n box-shadow:\n 0 0 0 4px color-mix(in srgb, var(--ak-accent) 10%, transparent),\n 0 4px 16px color-mix(in srgb, var(--ak-accent) 20%, transparent);\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--ak-accent);\n margin-bottom: 4px;\n flex-shrink: 0;\n}\n.ak-empty-state__avatar-img {\n width: 64px;\n height: 64px;\n border-radius: 50%;\n object-fit: cover;\n}\n.ak-empty-state__bot-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.ak-empty-state__title {\n margin: 0;\n font-size: 16px;\n font-weight: 700;\n color: var(--ak-text);\n line-height: 1.3;\n letter-spacing: -0.01em;\n}\n.ak-empty-state__description {\n margin: 0;\n font-size: 13px;\n color: var(--ak-text-muted);\n line-height: 1.55;\n width: 100%;\n}\n/* Suggested question chips \u2014 2-column grid */\n.ak-empty-state__suggestions {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 8px;\n width: 100%;\n}\n.ak-empty-state__suggestion {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n background: color-mix(in srgb, var(--ak-accent) 5%, var(--ak-bg));\n border: 1px solid color-mix(in srgb, var(--ak-accent) 16%, var(--ak-border));\n border-radius: 10px;\n padding: 10px 12px;\n cursor: pointer;\n text-align: left;\n transition: background 0.15s ease, border-color 0.15s ease;\n}\n/* Odd last item spans both columns so the grid doesn't look lopsided */\n.ak-empty-state__suggestion:last-child:nth-child(odd) {\n grid-column: 1 / -1;\n}\n.ak-empty-state__suggestion:hover {\n background: color-mix(in srgb, var(--ak-accent) 10%, var(--ak-bg));\n border-color: color-mix(in srgb, var(--ak-accent) 30%, var(--ak-border));\n}\n.ak-empty-state__suggestion-title {\n font-size: 13px;\n font-weight: 700;\n color: var(--ak-text);\n line-height: 1.4;\n}\n.ak-empty-state__suggestion-desc {\n font-size: 12px;\n color: var(--ak-text-muted);\n line-height: 1.4;\n margin-top: 2px;\n}\n\n/* \u2500\u2500 Message bubbles \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-message {\n display: flex;\n flex-direction: column;\n max-width: 86%;\n animation: ak-msg-in 0.15s ease-out;\n}\n@keyframes ak-msg-in {\n from { opacity: 0; transform: translateY(4px); }\n to { opacity: 1; transform: translateY(0); }\n}\n.ak-message--user {\n align-self: flex-end;\n align-items: flex-end;\n}\n.ak-message--assistant {\n align-self: flex-start;\n align-items: flex-start;\n}\n.ak-message__bubble {\n padding: 8px 12px;\n border-radius: 16px;\n font-size: 14px;\n line-height: 1.55;\n word-break: break-word;\n white-space: pre-wrap;\n max-width: 100%;\n min-width: 0;\n}\n.ak-message__bubble--md {\n white-space: normal;\n}\n.ak-message--user .ak-message__bubble {\n background: var(--ak-user-bg);\n color: var(--ak-user-text);\n border-bottom-right-radius: 4px;\n}\n.ak-message--assistant .ak-message__bubble {\n background: var(--ak-bot-bg);\n color: var(--ak-bot-text);\n border-bottom-left-radius: 4px;\n border: 1px solid var(--ak-border);\n}\n.ak-message--error .ak-message__bubble {\n background: #fee2e2;\n color: #991b1b;\n border-color: #fca5a5;\n}\n.ak-message--operator .ak-message__bubble--operator {\n background: color-mix(in srgb, var(--ak-accent) 8%, var(--ak-bot-bg));\n border: 1px solid color-mix(in srgb, var(--ak-accent) 22%, var(--ak-border));\n}\n.ak-message__time {\n display: block;\n text-align: right;\n font-size: 11px;\n color: var(--ak-text-muted);\n margin-top: 2px;\n padding: 0 4px;\n}\n.ak-message--user .ak-message__time {\n color: rgba(255, 255, 255, 0.7);\n}\n.ak-message__sender-label {\n font-size: 11px;\n font-weight: 500;\n color: var(--ak-text-muted);\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 0 2px;\n margin-bottom: 4px;\n}\n.ak-message--operator .ak-message__sender-label {\n color: var(--ak-accent);\n font-weight: 600;\n}\n.ak-message__operator-avatar {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 18px;\n height: 18px;\n border-radius: 50%;\n background: var(--ak-accent);\n color: #fff;\n font-size: 10px;\n font-weight: 700;\n line-height: 1;\n flex-shrink: 0;\n}\n.ak-message__operator-name {\n line-height: 1;\n}\n.ak-handoff-divider {\n display: flex;\n align-items: center;\n gap: 10px;\n margin: 8px 4px;\n color: var(--ak-text-muted);\n font-size: 11px;\n font-weight: 500;\n}\n.ak-handoff-divider::before,\n.ak-handoff-divider::after {\n content: '';\n flex: 1;\n height: 1px;\n background: var(--ak-border);\n}\n.ak-handoff-divider__label {\n white-space: nowrap;\n padding: 2px 8px;\n border-radius: 999px;\n background: color-mix(in srgb, var(--ak-accent) 6%, var(--ak-bg));\n border: 1px solid color-mix(in srgb, var(--ak-accent) 14%, var(--ak-border));\n color: color-mix(in srgb, var(--ak-accent) 70%, var(--ak-text));\n}\n/* \u2500\u2500 Message avatar (assistant only, when avatarUrl is set) \u2500\u2500\u2500 */\n.ak-message--with-avatar {\n flex-direction: row;\n align-items: flex-end;\n gap: 8px;\n}\n.ak-message__avatar {\n width: 28px;\n height: 28px;\n border-radius: 50%;\n object-fit: cover;\n flex-shrink: 0;\n background: var(--ak-surface);\n}\n.ak-message__body {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n min-width: 0;\n}\n\n/* \u2500\u2500 Generated images \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n/* Bubble that contains an image \u2014 remove padding so image is flush at top */\n.ak-message__bubble--has-image {\n padding: 0;\n overflow: hidden;\n}\n\n.ak-message__images {\n display: flex;\n flex-direction: column;\n gap: 0;\n}\n\n.ak-message__image-wrap {\n position: relative;\n line-height: 0;\n}\n\n/* Clicking the image opens it in a new tab */\n.ak-message__image-link {\n display: block;\n line-height: 0;\n}\n\n.ak-message__image {\n width: 100%;\n display: block;\n transition: filter 0.2s;\n}\n\n.ak-message__image-link:hover .ak-message__image {\n filter: brightness(0.93);\n}\n\n/* \u2500\u2500 Image gallery (count-aware layouts) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-gallery {\n position: relative;\n width: 100%;\n background: #ffffff;\n overflow: hidden;\n}\n\n/* Single hero: natural aspect, contained inside a white frame so transparent\n * product PNGs read clearly. Caps at 320px tall to keep bubble compact. */\n.ak-gallery--single {\n line-height: 0;\n}\n.ak-gallery--single .ak-gallery__cell--hero {\n display: block;\n background: #ffffff;\n}\n.ak-gallery__img--contain {\n width: 100%;\n max-height: 320px;\n object-fit: contain;\n background: #ffffff;\n display: block;\n}\n\n/* 2-up: side-by-side squares, gap-1 */\n.ak-gallery--two {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 2px;\n background: #e2e8f0;\n}\n\n/* 3-up: big left + 2 stacked right; container holds aspect */\n.ak-gallery--three {\n display: grid;\n grid-template-columns: 2fr 1fr;\n gap: 2px;\n background: #e2e8f0;\n aspect-ratio: 4 / 3;\n}\n.ak-gallery--three > .ak-gallery__cell {\n aspect-ratio: auto;\n height: 100%;\n}\n.ak-gallery--three .ak-gallery__col {\n display: grid;\n grid-template-rows: 1fr 1fr;\n gap: 2px;\n}\n\n/* 4-up (and 5+): 2x2 grid */\n.ak-gallery--grid {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 2px;\n background: #e2e8f0;\n}\n\n.ak-gallery__cell {\n position: relative;\n display: block;\n overflow: hidden;\n background: #f8fafc;\n aspect-ratio: 1 / 1;\n line-height: 0;\n text-decoration: none;\n}\n\n/* Override aspect-ratio for the 3-up layout's column cells (they take parent height) */\n.ak-gallery--three .ak-gallery__col .ak-gallery__cell {\n aspect-ratio: auto;\n height: 100%;\n width: 100%;\n}\n\n.ak-gallery__img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n display: block;\n transition: transform 0.2s ease-out, filter 0.2s;\n}\n\n.ak-gallery__cell:hover .ak-gallery__img {\n transform: scale(1.04);\n filter: brightness(0.97);\n}\n\n.ak-gallery__cell:focus-visible {\n outline: 2px solid var(--ak-primary, #6366f1);\n outline-offset: -2px;\n}\n\n.ak-gallery__overlay {\n position: absolute;\n inset: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background: rgba(15, 23, 42, 0.6);\n color: #ffffff;\n font-size: 22px;\n font-weight: 600;\n letter-spacing: -0.01em;\n pointer-events: none;\n}\n\n/* \u2500\u2500 File chips (user-uploaded .pdf/.md/.txt/.csv) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-message__files {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 8px 10px 4px;\n}\n.ak-message__bubble--has-image .ak-message__files {\n padding: 8px 8px 4px;\n}\n\n.ak-file-chip {\n display: inline-flex;\n align-items: center;\n gap: 10px;\n padding: 8px 10px;\n background: var(--ak-surface);\n border: 1px solid var(--ak-border, #e2e8f0);\n border-radius: 12px;\n text-decoration: none;\n color: var(--ak-text, #0f172a);\n transition: border-color 0.15s, box-shadow 0.15s;\n max-width: 100%;\n}\n\n.ak-file-chip:hover {\n border-color: #cbd5e1;\n box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);\n}\n\n.ak-file-chip:focus-visible {\n outline: 2px solid var(--ak-primary, #6366f1);\n outline-offset: 2px;\n}\n\n.ak-file-chip__icon {\n flex-shrink: 0;\n width: 34px;\n height: 34px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 8px;\n}\n\n.ak-file-chip__icon--pdf { background: #fff1f2; color: #e11d48; }\n.ak-file-chip__icon--csv { background: #ecfdf5; color: #059669; }\n.ak-file-chip__icon--md { background: #f5f3ff; color: #7c3aed; }\n.ak-file-chip__icon--txt { background: #f1f5f9; color: #475569; }\n.ak-file-chip__icon--default { background: #eef2ff; color: #4f46e5; }\n\n.ak-file-chip__body {\n display: flex;\n flex-direction: column;\n min-width: 0;\n line-height: 1.2;\n}\n\n.ak-file-chip__name {\n font-size: 13px;\n font-weight: 500;\n color: var(--ak-text, #0f172a);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n max-width: 220px;\n}\n\n.ak-file-chip__label {\n font-size: 10px;\n font-weight: 600;\n letter-spacing: 0.05em;\n color: #64748b;\n margin-top: 2px;\n}\n\n/* In user-side bubble (dark primary background), invert chip surface for legibility */\n.ak-message--user .ak-file-chip {\n background: rgba(255, 255, 255, 0.96);\n border-color: transparent;\n}\n\n/* \u2500\u2500 Lightbox (image preview modal) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-lightbox {\n position: fixed;\n inset: 0;\n z-index: 2147483600; /* near max int \u2014 sits above any host-page content */\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 24px;\n background: rgba(15, 23, 42, 0.85);\n backdrop-filter: blur(6px);\n -webkit-backdrop-filter: blur(6px);\n animation: ak-lightbox-in 0.12s ease-out;\n}\n\n@keyframes ak-lightbox-in {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n.ak-lightbox__img {\n max-width: 92vw;\n max-height: 88vh;\n border-radius: 8px;\n box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);\n user-select: none;\n display: block;\n}\n\n.ak-lightbox__toolbar {\n position: absolute;\n top: 16px;\n right: 16px;\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.ak-lightbox__counter {\n display: inline-flex;\n align-items: center;\n height: 28px;\n padding: 0 12px;\n border-radius: 999px;\n background: rgba(255, 255, 255, 0.12);\n color: #ffffff;\n font-size: 12px;\n font-weight: 500;\n font-variant-numeric: tabular-nums;\n}\n\n.ak-lightbox__btn {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 36px;\n height: 36px;\n border: none;\n border-radius: 999px;\n background: rgba(255, 255, 255, 0.12);\n color: #ffffff;\n cursor: pointer;\n transition: background 0.15s;\n text-decoration: none;\n padding: 0;\n}\n\n.ak-lightbox__btn:hover {\n background: rgba(255, 255, 255, 0.22);\n}\n\n.ak-lightbox__btn:focus-visible {\n outline: 2px solid rgba(255, 255, 255, 0.8);\n outline-offset: 2px;\n}\n\n.ak-lightbox__nav {\n position: absolute;\n top: 50%;\n transform: translateY(-50%);\n display: flex;\n align-items: center;\n justify-content: center;\n width: 44px;\n height: 44px;\n border: none;\n border-radius: 999px;\n background: rgba(255, 255, 255, 0.12);\n color: #ffffff;\n cursor: pointer;\n transition: background 0.15s;\n padding: 0;\n}\n\n.ak-lightbox__nav:hover {\n background: rgba(255, 255, 255, 0.22);\n}\n\n.ak-lightbox__nav--prev { left: 16px; }\n.ak-lightbox__nav--next { right: 16px; }\n\n.ak-lightbox__nav:focus-visible {\n outline: 2px solid rgba(255, 255, 255, 0.8);\n outline-offset: 2px;\n}\n\n/* Gallery cells must be styled as plain buttons (we converted from <a>) */\n.ak-gallery__cell {\n border: none;\n padding: 0;\n margin: 0;\n cursor: zoom-in;\n font: inherit;\n color: inherit;\n background: #f8fafc;\n}\n\n.ak-gallery__cell:focus-visible {\n outline: 2px solid var(--ak-primary, #6366f1);\n outline-offset: -2px;\n}\n\n/* Faint download icon \u2014 always present, top-right corner of the image */\n.ak-message__image-dl-icon {\n position: absolute;\n top: 8px;\n right: 8px;\n width: 26px;\n height: 26px;\n background: rgba(0, 0, 0, 0.28);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n color: rgba(255, 255, 255, 0.75);\n text-decoration: none;\n transition: background 0.15s, color 0.15s;\n}\n\n.ak-message__image-dl-icon:hover {\n background: rgba(0, 0, 0, 0.55);\n color: #ffffff;\n}\n\n/* Caption / text below the image, inside the same bubble */\n.ak-message__image-caption {\n padding: 8px 10px 8px;\n font-size: 14px;\n font-style: normal;\n color: var(--ak-text);\n line-height: 1.45;\n}\n\n/* User-uploaded image caption uses user bubble colors */\n.ak-message--user .ak-message__image-caption {\n color: rgba(255, 255, 255, 0.8);\n font-style: normal;\n}\n\n/* \u2500\u2500 Typing indicator \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-typing {\n display: flex;\n align-items: center;\n gap: 5px;\n padding: 9px 12px;\n background: var(--ak-bot-bg);\n border-radius: 16px;\n border-bottom-left-radius: 4px;\n border: 1px solid var(--ak-border);\n align-self: flex-start;\n width: fit-content;\n animation: ak-msg-in 0.15s ease-out;\n}\n.ak-typing__dot {\n width: 7px;\n height: 7px;\n background: var(--ak-text-muted);\n border-radius: 50%;\n animation: ak-bounce 1.3s infinite ease-in-out;\n}\n.ak-typing__dot:nth-child(2) { animation-delay: 0.2s; }\n.ak-typing__dot:nth-child(3) { animation-delay: 0.4s; }\n@keyframes ak-bounce {\n 0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }\n 30% { transform: translateY(-5px); opacity: 1; }\n}\n\n/* \u2500\u2500 Init status (validating / error) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-init-status {\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 24px;\n}\n.ak-init-spinner {\n width: 28px;\n height: 28px;\n border: 3px solid var(--ak-border);\n border-top-color: var(--ak-accent);\n border-radius: 50%;\n animation: ak-spin 0.7s linear infinite;\n}\n@keyframes ak-spin {\n to { transform: rotate(360deg); }\n}\n.ak-init-status--error {\n justify-content: flex-start;\n}\n.ak-init-status--maintenance {\n padding: 28px 24px;\n}\n\n/* \u2500\u2500 Composer \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-composer {\n position: relative; /* establishes positioning context for the attachment submenu */\n padding: 8px 12px 10px;\n border-top: 1px solid var(--ak-border);\n display: flex;\n flex-direction: column;\n gap: 8px;\n background: var(--ak-bg);\n flex-shrink: 0;\n}\n\n/* Hidden native file input */\n.ak-composer__file-input {\n display: none;\n}\n\n/* Unified input container \u2014 wraps +, textarea, send as one row */\n.ak-composer__input-wrap {\n display: flex;\n align-items: center;\n gap: 6px;\n background: var(--ak-surface);\n border: 1px solid var(--ak-border);\n border-radius: 14px;\n padding: 5px 5px 5px 6px;\n transition: border-color 0.15s;\n}\n.ak-composer__input-wrap:focus-within {\n border-color: var(--ak-accent);\n}\n\n/* Attach button wrapper */\n.ak-composer__attach-wrap {\n flex-shrink: 0;\n}\n\n/* \"+\" attachment button \u2014 square with rounded corners */\n.ak-composer__attach {\n width: 28px;\n height: 28px;\n border-radius: 8px;\n background: var(--ak-bg);\n border: 1px solid var(--ak-border);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--ak-text-muted);\n transition: color 0.15s, border-color 0.15s, background 0.15s;\n flex-shrink: 0;\n}\n.ak-composer__attach:hover:not(:disabled) {\n color: var(--ak-accent);\n border-color: var(--ak-accent);\n}\n.ak-composer__attach--open {\n color: var(--ak-accent);\n border-color: var(--ak-accent);\n background: color-mix(in srgb, var(--ak-accent) 8%, transparent);\n}\n.ak-composer__attach:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n/* Attachment submenu \u2014 floats above the composer, positioned relative to .ak-composer */\n.ak-composer__attach-menu {\n position: absolute;\n bottom: calc(100% + 6px);\n left: 12px;\n background: var(--ak-surface);\n border: 1px solid var(--ak-border);\n border-radius: 10px;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);\n padding: 4px;\n min-width: 130px;\n z-index: 10;\n}\n\n/* Individual item inside the attachment submenu */\n.ak-composer__attach-menu-item {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 7px 10px;\n border: none;\n border-radius: 7px;\n background: transparent;\n color: var(--ak-text);\n font-family: var(--ak-font);\n font-size: 13px;\n cursor: pointer;\n transition: background 0.12s;\n text-align: left;\n}\n.ak-composer__attach-menu-item:hover:not(:disabled) {\n background: var(--ak-bg);\n}\n.ak-composer__attach-menu-item:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n/* Textarea \u2014 borderless, transparent, sits inside the container */\n.ak-composer__input {\n flex: 1;\n padding: 4px 6px;\n border: none;\n border-radius: 0;\n background: transparent;\n color: var(--ak-text);\n font-family: var(--ak-font);\n font-size: 14px;\n line-height: 1.45;\n resize: none;\n outline: none;\n min-height: 28px;\n max-height: 110px;\n overflow-y: auto;\n}\n.ak-composer__input::placeholder {\n color: var(--ak-text-muted);\n}\n\n/* Send button \u2014 square with rounded corners */\n.ak-composer__send {\n width: 28px;\n height: 28px;\n border-radius: 8px;\n background: var(--ak-accent);\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n transition: background 0.15s, opacity 0.15s;\n flex-shrink: 0;\n}\n.ak-composer__send:hover:not(:disabled) {\n background: var(--ak-accent-hover);\n}\n.ak-composer__send:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n}\n\n/* Old photo button \u2014 hidden but keep so file-input trigger still works */\n.ak-composer__photo {\n display: none;\n}\n\n/* Image preview strip above the input row */\n.ak-composer__preview {\n display: flex;\n gap: 6px;\n padding: 0 2px;\n}\n.ak-composer__preview-wrap {\n position: relative;\n width: 60px;\n height: 60px;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid var(--ak-border);\n flex-shrink: 0;\n}\n.ak-composer__preview-img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n display: block;\n}\n.ak-composer__preview-remove {\n position: absolute;\n top: 3px;\n right: 3px;\n width: 18px;\n height: 18px;\n border-radius: 50%;\n background: rgba(0, 0, 0, 0.55);\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #ffffff;\n padding: 0;\n transition: background 0.15s;\n}\n.ak-composer__preview-remove:hover {\n background: rgba(0, 0, 0, 0.8);\n}\n\n/* \u2500\u2500 Streaming cursor \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-cursor {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n margin-left: 4px;\n vertical-align: middle;\n}\n.ak-cursor__dot {\n display: inline-block;\n width: 7px;\n height: 7px;\n border-radius: 50%;\n background: currentColor;\n opacity: 0.6;\n animation: ak-bounce 1.3s infinite ease-in-out;\n}\n.ak-cursor__dot:nth-child(2) { animation-delay: 0.2s; }\n.ak-cursor__dot:nth-child(3) { animation-delay: 0.4s; }\n\n/* Pre-first-chunk wait \u2014 deliberately shares the metrics of .ak-progress__item\n and .ak-progress__summary so dots \u2192 activity line \u2192 summary never reflow. */\n.ak-typing-row {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n padding: 2px 0;\n margin: 0 0 4px;\n /* One text line at the shared row metrics, so the dots occupy exactly the\n box the activity line and summary will occupy (border-box). */\n min-height: calc(0.76rem * 1.4 + 4px);\n animation: ak-msg-in 0.15s ease-out;\n}\n.ak-typing-row__dot {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--ak-bot-text);\n opacity: 0.5;\n animation: ak-bounce 1.3s infinite ease-in-out;\n}\n.ak-typing-row__dot:nth-child(2) { animation-delay: 0.2s; }\n.ak-typing-row__dot:nth-child(3) { animation-delay: 0.4s; }\n@media (prefers-reduced-motion: reduce) {\n .ak-typing-row__dot,\n .ak-cursor__dot,\n .ak-typing__dot,\n .ak-progress__item--active,\n .ak-agent-status__icon {\n animation: none;\n }\n}\n\n/* \u2500\u2500 Markdown rendering \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-message__bubble--md {\n white-space: normal;\n min-width: 0;\n}\n.ak-message__bubble--md .ak-md-p {\n margin: 0 0 0.4em 0;\n}\n.ak-message__bubble--md .ak-md-p:last-child {\n margin-bottom: 0;\n}\n/* Collapse margins between paragraph and following list */\n.ak-message__bubble--md .ak-md-p + .ak-md-ul,\n.ak-message__bubble--md .ak-md-p + .ak-md-ol {\n margin-top: 0;\n}\n.ak-message__bubble--md .ak-md-h1,\n.ak-message__bubble--md .ak-md-h2,\n.ak-message__bubble--md .ak-md-h3 {\n font-weight: 700;\n line-height: 1.3;\n margin: 0.6em 0 0.3em;\n}\n.ak-message__bubble--md .ak-md-h1:first-child,\n.ak-message__bubble--md .ak-md-h2:first-child,\n.ak-message__bubble--md .ak-md-h3:first-child {\n margin-top: 0;\n}\n.ak-message__bubble--md .ak-md-h1 { font-size: 1.12em; }\n.ak-message__bubble--md .ak-md-h2 { font-size: 1.04em; }\n.ak-message__bubble--md .ak-md-h3 { font-size: 0.97em; }\n.ak-message__bubble--md .ak-md-ul,\n.ak-message__bubble--md .ak-md-ol {\n padding-left: 1.4em;\n margin: 0.4em 0;\n}\n.ak-message__bubble--md .ak-md-ul li,\n.ak-message__bubble--md .ak-md-ol li {\n margin-bottom: 0.15em;\n}\n.ak-message__bubble--md .ak-md-pre-wrap {\n position: relative;\n margin: 0.4em 0;\n border-radius: 6px;\n overflow-x: auto;\n overflow-y: hidden;\n background: rgba(0, 0, 0, 0.08);\n max-width: 100%;\n}\n.ak-message--user .ak-message__bubble--md .ak-md-pre-wrap {\n background: rgba(255, 255, 255, 0.15);\n}\n.ak-message__bubble--md .ak-md-pre-lang {\n display: block;\n padding: 3px 10px;\n font-size: 10px;\n font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n opacity: 0.55;\n border-bottom: 1px solid rgba(0, 0, 0, 0.08);\n}\n.ak-message--user .ak-message__bubble--md .ak-md-pre-lang {\n border-bottom-color: rgba(255, 255, 255, 0.15);\n}\n.ak-message__bubble--md .ak-md-pre {\n margin: 0;\n padding: 8px 10px;\n font-size: 12px;\n font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;\n white-space: pre;\n box-sizing: border-box;\n}\n.ak-message__bubble--md .ak-md-code {\n display: block;\n font-family: inherit;\n font-size: inherit;\n}\n.ak-message__bubble--md .ak-md-ic {\n background: rgba(0, 0, 0, 0.08);\n border-radius: 3px;\n padding: 1px 5px;\n font-size: 0.87em;\n font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;\n}\n.ak-message--user .ak-message__bubble--md .ak-md-ic {\n background: rgba(255, 255, 255, 0.2);\n}\n.ak-message__bubble--md .ak-md-hr {\n border: none;\n border-top: 1px solid currentColor;\n opacity: 0.2;\n margin: 0.5em 0;\n}\n.ak-message__bubble--md a {\n color: var(--ak-accent);\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n.ak-message--user .ak-message__bubble--md a {\n color: rgba(255, 255, 255, 0.9);\n}\n.ak-message__bubble--md .ak-md-table {\n width: 100%;\n border-collapse: collapse;\n margin: 0.4em 0;\n font-size: 0.95em;\n line-height: 1.5;\n}\n.ak-message__bubble--md .ak-md-th {\n padding: 8px 10px;\n text-align: left;\n border-bottom: 2px solid var(--ak-accent) !important;\n background: color-mix(in srgb, var(--ak-accent) 8%, transparent) !important;\n font-weight: 600;\n color: var(--ak-text) !important;\n}\n.ak-message--user .ak-message__bubble--md .ak-md-th {\n border-bottom-color: rgba(255, 255, 255, 0.5) !important;\n background: rgba(0, 0, 0, 0.25) !important;\n color: #ffffff !important;\n font-weight: 700;\n}\n.ak-message__bubble--md .ak-md-td {\n padding: 6px 10px;\n border-bottom: 1px solid var(--ak-border) !important;\n color: var(--ak-text) !important;\n}\n.ak-message__bubble--md tr:nth-child(even) .ak-md-td {\n background: color-mix(in srgb, var(--ak-surface), transparent 40%) !important;\n}\n.ak-message--user .ak-message__bubble--md .ak-md-td {\n color: #ffffff !important;\n border-bottom-color: rgba(255, 255, 255, 0.25) !important;\n}\n.ak-message--user .ak-message__bubble--md tr:nth-child(even) .ak-md-td {\n background: rgba(0, 0, 0, 0.15) !important;\n}\n\n/* \u2500\u2500 Composer disclaimer \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-composer__disclaimer {\n font-size: 11px;\n color: var(--ak-text-muted);\n text-align: center;\n line-height: 1.4;\n}\n.ak-composer__disclaimer a {\n color: var(--ak-text-muted);\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n.ak-composer__disclaimer a:hover {\n color: var(--ak-accent);\n}\n\n/* \u2500\u2500 Maintenance state \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-maintenance {\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: center;\n text-align: center;\n max-width: 320px;\n padding: 8px 4px;\n animation: ak-maintenance-enter 320ms cubic-bezier(0.2, 0.7, 0.2, 1) both;\n}\n.ak-maintenance__halo {\n position: absolute;\n top: -6px;\n left: 50%;\n width: 120px;\n height: 120px;\n transform: translateX(-50%);\n border-radius: 50%;\n background: radial-gradient(\n closest-side,\n var(--ak-maintenance-halo) 0%,\n transparent 72%\n );\n opacity: 0.22;\n filter: blur(4px);\n pointer-events: none;\n animation: ak-maintenance-pulse 2.8s ease-in-out infinite;\n}\n.ak-maintenance__icon {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 56px;\n height: 56px;\n border-radius: 50%;\n background: var(--ak-maintenance-bg);\n color: var(--ak-maintenance-fg);\n border: 1px solid color-mix(in srgb, var(--ak-maintenance-halo) 40%, transparent);\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);\n}\n.ak-maintenance__title {\n margin-top: 16px;\n font-size: 15px;\n font-weight: 600;\n color: var(--ak-text);\n line-height: 1.3;\n letter-spacing: -0.01em;\n}\n.ak-maintenance__description {\n margin-top: 6px;\n font-size: 13px;\n color: var(--ak-text-muted);\n line-height: 1.5;\n max-width: 28ch;\n}\n\n@keyframes ak-maintenance-enter {\n from {\n opacity: 0;\n transform: translateY(6px) scale(0.98);\n }\n to {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n}\n@keyframes ak-maintenance-pulse {\n 0%, 100% { opacity: 0.18; transform: translateX(-50%) scale(1); }\n 50% { opacity: 0.32; transform: translateX(-50%) scale(1.06); }\n}\n@media (prefers-reduced-motion: reduce) {\n .ak-maintenance,\n .ak-maintenance__halo,\n .ak-maintenance__icon {\n animation: none;\n }\n}\n\n/* \u2500\u2500 Error banner \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-error {\n padding: 12px 16px;\n background: #fee2e2;\n color: #991b1b;\n font-size: 13px;\n border-top: 1px solid #fca5a5;\n text-align: left;\n flex-shrink: 0;\n display: flex;\n align-items: flex-start;\n gap: 10px;\n}\n\n.ak-error__icon {\n font-size: 16px;\n line-height: 1;\n flex-shrink: 0;\n margin-top: 1px;\n}\n\n.ak-error__content {\n flex: 1;\n}\n\n.ak-error__title {\n font-size: 14px;\n font-weight: 600;\n margin: 0 0 4px 0;\n line-height: 1.3;\n}\n\n.ak-error__description {\n font-size: 13px;\n margin: 0 0 4px 0;\n line-height: 1.4;\n opacity: 0.9;\n}\n\n.ak-error__message {\n font-size: 13px;\n margin: 0;\n line-height: 1.4;\n opacity: 0.85;\n}\n\n/* Specific styling for origin restriction errors */\n.ak-error--origin {\n background: #fef3c7; /* Amber background instead of red for less scary appearance */\n color: #92400e; /* Amber text color */\n border-top: 1px solid #fbbf24;\n}\n\n/* \u2500\u2500 Agent status indicator \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n/* Same bare row as .ak-progress__item / .ak-typing-row \u2014 activity-off tenants\n see the tool status swap in without the surrounding box changing size. */\n.ak-agent-status {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n margin-bottom: 4px;\n padding: 2px 0;\n color: var(--ak-bot-text);\n font-size: 0.76rem;\n line-height: 1.4;\n opacity: 0.6;\n animation: ak-msg-in 0.15s ease-out;\n}\n.ak-agent-status__icon {\n flex-shrink: 0;\n color: var(--ak-primary, #6366f1);\n animation: ak-sparkle-pulse 2.5s ease-in-out infinite;\n}\n.ak-agent-status__text {\n line-height: 1.4;\n}\n@keyframes ak-sparkle-pulse {\n 0%, 100% { opacity: 1; transform: scale(1) rotate(0deg); }\n 50% { opacity: 0.45; transform: scale(0.85) rotate(15deg); }\n}\n\n/* \u2500\u2500 Progress block (tool execution / streaming chain) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-progress {\n margin-bottom: 4px;\n max-width: 80%;\n}\n.ak-progress__block {\n display: inline-flex;\n flex-direction: column;\n gap: 3px;\n padding: 6px 12px;\n border-radius: 14px;\n background: var(--ak-bot-bg);\n border: 1px solid var(--ak-border);\n font-size: 0.8rem;\n color: var(--ak-bot-text);\n opacity: 0.85;\n animation: ak-msg-in 0.15s ease-out;\n}\n.ak-progress__header {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.ak-progress__label {\n font-weight: 600;\n font-size: 0.78rem;\n color: var(--ak-primary, #6366f1);\n}\n.ak-progress__toggle {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n padding: 1px 7px;\n border: 1px solid var(--ak-border);\n border-radius: 8px;\n background: transparent;\n color: var(--ak-bot-text);\n font-size: 0.72rem;\n cursor: pointer;\n opacity: 0.65;\n transition: opacity 0.15s;\n}\n.ak-progress__toggle:hover { opacity: 0.9; }\n.ak-progress__toggle--collapsed {\n display: inline-flex;\n align-items: center;\n gap: 5px;\n padding: 5px 10px;\n border: 1px solid var(--ak-border);\n border-radius: 12px;\n background: transparent;\n color: var(--ak-bot-text);\n font-size: 0.78rem;\n cursor: pointer;\n opacity: 0.55;\n transition: opacity 0.15s;\n margin-bottom: 4px;\n}\n.ak-progress__toggle--collapsed:hover { opacity: 0.85; }\n.ak-progress__text {\n font-size: 0.76rem;\n color: var(--ak-bot-text);\n line-height: 1.4;\n margin: 0;\n}\n/* Active streaming state */\n.ak-progress__list {\n list-style: none;\n margin: 0 0 4px;\n padding: 0;\n}\n/* Bare row, not a pill \u2014 identical metrics to .ak-progress__summary so the\n live line and the post-turn \"Worked for Ns\" swap without a size change. */\n.ak-progress__item {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0;\n font-size: 0.76rem;\n line-height: 1.4;\n color: var(--ak-bot-text);\n opacity: 0.6;\n animation: ak-msg-in 0.15s ease-out;\n}\n.ak-progress__item--active {\n /* inherits base .ak-progress__item; subtle pulse to signal in-flight */\n animation: ak-msg-in 0.15s ease-out, ak-active-pulse 2s ease-in-out infinite;\n}\n@keyframes ak-active-pulse {\n 0%, 100% { opacity: 0.6; }\n 50% { opacity: 0.9; }\n}\n/* Claude-style step list (detailed mode) */\n.ak-progress__steps {\n list-style: none;\n margin: 0 0 4px;\n padding: 2px 0;\n}\n.ak-progress__step {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0;\n font-size: 0.76rem;\n color: var(--ak-bot-text);\n opacity: 0.6;\n line-height: 1.4;\n}\n.ak-progress__step--active {\n opacity: 0.9;\n}\n.ak-progress__step-text {\n min-width: 0;\n}\n.ak-progress__step-dur {\n opacity: 0.65;\n flex-shrink: 0;\n}\n.ak-progress__step-icon {\n flex-shrink: 0;\n opacity: 0.55;\n}\n.ak-progress__step-icon--fail {\n color: #ef4444;\n opacity: 0.9;\n}\n/* Post-turn summary row (\"Worked for Ns \u00B7 N steps\") */\n.ak-progress__summary {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 2px 0;\n margin: 0 0 4px;\n /* Shrink-to-fit as a column flex item would otherwise break \"Worked for 8.4s\"\n onto two lines, doubling the row height as the turn ends. */\n white-space: nowrap;\n border: none;\n background: transparent;\n font-size: 0.76rem;\n color: var(--ak-bot-text);\n opacity: 0.6;\n cursor: pointer;\n transition: opacity 0.15s;\n}\n.ak-progress__summary:hover { opacity: 0.85; }\n.ak-progress__summary--static {\n cursor: default;\n}\n.ak-progress__summary--static:hover { opacity: 0.6; }\n.ak-progress__spinner {\n display: inline-block;\n width: 11px;\n height: 11px;\n border: 1.5px solid var(--ak-border);\n border-top-color: var(--ak-primary, #6366f1);\n border-radius: 50%;\n flex-shrink: 0;\n animation: ak-spin 0.7s linear infinite;\n}\n\n/* \u2500\u2500 Powered by hanging tab \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.ak-branding {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n padding: 3px 8px 4px;\n background: var(--ak-bg);\n border: 1px solid var(--ak-border);\n border-top: none;\n border-radius: 0 0 8px 8px;\n margin-left: 16px;\n box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);\n}\n.ak-branding__logo {\n width: 11px;\n height: 11px;\n flex-shrink: 0;\n color: var(--ak-accent);\n opacity: 0.75;\n}\n.ak-branding__label {\n font-size: 9px;\n color: var(--ak-text-muted);\n opacity: 0.75;\n}\n.ak-branding__name {\n font-size: 9px;\n font-weight: 600;\n color: var(--ak-accent);\n opacity: 0.75;\n letter-spacing: -0.01em;\n}\n\n/* \u2500\u2500 Mobile: full-viewport panel \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n@media (max-width: 639px) {\n @keyframes ak-panel-in-mobile {\n from { opacity: 0; transform: translateY(32px); }\n to { opacity: 1; transform: translateY(0); }\n }\n\n /* The shadow host (data-agentkit-widget) sits inside the outer fixed container.\n Give it its own fixed position so it fills the viewport independently,\n bypassing the outer container's bottom/right offsets. */\n :host([data-open]) {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 2147483647;\n pointer-events: none;\n }\n\n :host([data-open]) .ak-floating {\n width: 100%;\n height: 100%;\n align-items: stretch;\n gap: 0;\n }\n\n :host([data-open]) .ak-shell-wrap {\n flex: 1;\n min-height: 0;\n width: 100%;\n align-items: stretch;\n /* Launcher is hidden here \u2014 the negative offset would leave a dead strip. */\n margin-bottom: 0;\n }\n\n :host([data-open]) .ak-shell--floating {\n width: 100%;\n flex: 1;\n height: auto;\n border-radius: 0;\n box-shadow: none;\n border-left: none;\n border-right: none;\n border-top: none;\n }\n\n :host([data-open]) .ak-launcher {\n display: none;\n }\n\n :host([data-open]) .ak-shell-enter {\n animation: ak-panel-in-mobile 0.22s ease-out;\n }\n\n :host([data-open]) .ak-branding {\n display: none;\n }\n}\n";
|
|
527
|
+
|
|
528
|
+
/** Non-image asset delivered by a tool call (e.g. Assets Storage sending a PDF). */
|
|
529
|
+
declare type WidgetDocumentData = {
|
|
530
|
+
url?: string;
|
|
531
|
+
mimeType: string;
|
|
532
|
+
fileName?: string;
|
|
533
|
+
sizeBytes?: number;
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
export declare type WidgetEventMap = {
|
|
537
|
+
ready: WidgetState;
|
|
538
|
+
open: undefined;
|
|
539
|
+
close: undefined;
|
|
540
|
+
'message:sent': WidgetMessage;
|
|
541
|
+
'message:received': WidgetMessage;
|
|
542
|
+
'message:error': {
|
|
543
|
+
error: string;
|
|
544
|
+
message: WidgetMessage | null;
|
|
545
|
+
};
|
|
546
|
+
'conversation:started': {
|
|
547
|
+
sessionId: string;
|
|
548
|
+
};
|
|
549
|
+
'stream:start': undefined;
|
|
550
|
+
'stream:delta': {
|
|
551
|
+
delta: string;
|
|
552
|
+
accumulated: string;
|
|
553
|
+
};
|
|
554
|
+
'stream:end': {
|
|
555
|
+
content: string;
|
|
556
|
+
};
|
|
557
|
+
control_mode_changed: {
|
|
558
|
+
mode: WidgetControlMode;
|
|
559
|
+
};
|
|
560
|
+
reset: undefined;
|
|
561
|
+
destroy: undefined;
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
declare type WidgetImageData = {
|
|
565
|
+
base64?: string;
|
|
566
|
+
url?: string;
|
|
567
|
+
mimeType: string;
|
|
568
|
+
width?: number;
|
|
569
|
+
height?: number;
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
export declare interface WidgetInstance {
|
|
573
|
+
open(): void;
|
|
574
|
+
close(): void;
|
|
575
|
+
toggle(): void;
|
|
576
|
+
sendMessage(text: string, attachments?: Array<{
|
|
577
|
+
file: File;
|
|
578
|
+
kind: 'image' | 'file';
|
|
579
|
+
}>): Promise<void>;
|
|
580
|
+
/** Clear the current session and conversation history, then show the greeting again. */
|
|
581
|
+
reset(): void;
|
|
582
|
+
destroy(): void;
|
|
583
|
+
on<K extends keyof WidgetEventMap>(event: K, handler: (data: WidgetEventMap[K]) => void): void;
|
|
584
|
+
off<K extends keyof WidgetEventMap>(event: K, handler: (data: WidgetEventMap[K]) => void): void;
|
|
585
|
+
getState(): WidgetState;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
export declare type WidgetMessage = {
|
|
589
|
+
id: string;
|
|
590
|
+
role: 'user' | 'assistant' | 'system';
|
|
591
|
+
content: string;
|
|
592
|
+
images?: WidgetImageData[];
|
|
593
|
+
documents?: WidgetDocumentData[];
|
|
594
|
+
/** @deprecated Use `uploadedAttachments`. First uploaded image URL for back-compat. */
|
|
595
|
+
uploadedImageUrl?: string;
|
|
596
|
+
/** All user-uploaded attachments (photos + files) on this message. */
|
|
597
|
+
uploadedAttachments?: Array<{
|
|
598
|
+
url: string;
|
|
599
|
+
mimeType: string;
|
|
600
|
+
fileName?: string;
|
|
601
|
+
kind: 'image' | 'file';
|
|
602
|
+
}>;
|
|
603
|
+
createdAt: string;
|
|
604
|
+
status?: 'pending' | 'sent' | 'streaming' | 'error';
|
|
605
|
+
/** Status text shown while the agent is executing tools or thinking between LLM turns. Cleared when real content arrives. */
|
|
606
|
+
toolStatus?: string;
|
|
607
|
+
/** Pre-execution acknowledgement text from the server. */
|
|
608
|
+
ackText?: string;
|
|
609
|
+
/** Live progress events accumulated during streaming. Kept after stream end
|
|
610
|
+
* in detailed mode so the trail persists as an expandable step list. */
|
|
611
|
+
progressEvents?: WidgetProgressEvent[];
|
|
612
|
+
/** Whether the progress block is collapsed (auto-collapsed after stream ends). */
|
|
613
|
+
progressCollapsed?: boolean;
|
|
614
|
+
/** Turn metadata — the "Worked for Ns" duration, the effective activity
|
|
615
|
+
* display mode, and the server-authoritative collapse-after-response setting
|
|
616
|
+
* (the latter two from the server's final_meta event). */
|
|
617
|
+
turnMeta?: {
|
|
618
|
+
/** Time from turn start to the first chunk of the final answer — NOT the
|
|
619
|
+
* full stream duration. Typing out a long reply is time the user spends
|
|
620
|
+
* reading, not waiting, so it doesn't belong in the number. */
|
|
621
|
+
totalMs: number | null;
|
|
622
|
+
collapseAfterFinal: boolean | null;
|
|
623
|
+
mode: string | null;
|
|
624
|
+
};
|
|
625
|
+
/** Absolute timestamp of the first content chunk of the final answer, reset on
|
|
626
|
+
* each tool round. Freezes the live progress clock at the same moment
|
|
627
|
+
* `turnMeta.totalMs` measures, so the summary never jumps backwards. */
|
|
628
|
+
answerStartedAtMs?: number | null;
|
|
629
|
+
/** True when this assistant message was sent by a human operator rather than the AI. */
|
|
630
|
+
isHuman?: boolean;
|
|
631
|
+
/** Display name of the operator who sent this message, if known. */
|
|
632
|
+
senderDisplay?: string | null;
|
|
633
|
+
/** Server-assigned run ID for this turn's execution, used for reconnect/resume. */
|
|
634
|
+
runId?: string;
|
|
635
|
+
};
|
|
149
636
|
|
|
150
|
-
|
|
637
|
+
/**
|
|
638
|
+
* Progress-trail helpers shared by the widget client (event folding) and
|
|
639
|
+
* widget-ui (rendering). Mirrors the dashboard's Claude-style semantics: one
|
|
640
|
+
* live non-tool step at a time (a new step closes the previous one), while
|
|
641
|
+
* parallel tool entries stay active independently until each tool_complete.
|
|
642
|
+
*/
|
|
643
|
+
export declare type WidgetProgressEvent = {
|
|
644
|
+
stage: string;
|
|
645
|
+
text: string;
|
|
646
|
+
timestamp: string;
|
|
647
|
+
status: 'active' | 'done';
|
|
648
|
+
/** Set for tool entries — pairs tool_start with its tool_complete (per-call id). */
|
|
649
|
+
toolId?: string;
|
|
650
|
+
/** Restored tool id (e.g. `tenant_data.search_records`) for tool entries. */
|
|
651
|
+
toolName?: string;
|
|
652
|
+
/** Server-measured duration for tool entries; client-derived for other steps. */
|
|
653
|
+
durationMs?: number;
|
|
654
|
+
/** False when the tool call failed. */
|
|
655
|
+
ok?: boolean;
|
|
656
|
+
/** Client receipt time (Date.now()) — baseline for the live running clock. */
|
|
657
|
+
startedAtMs?: number;
|
|
658
|
+
/** Server emit time (ms since epoch). Preferred over client receipt for
|
|
659
|
+
* closed-step durations: prepare-stage events buffer server-side and arrive
|
|
660
|
+
* in one tick, so client deltas misattribute their timing. */
|
|
661
|
+
serverTsMs?: number;
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
/** Per-request options shared by the client, stream and reconnect modules. */
|
|
665
|
+
declare interface WidgetRequestOptions {
|
|
666
|
+
/** Send the session cookie so an authenticated tenant member can preview. */
|
|
667
|
+
preview?: boolean;
|
|
668
|
+
/** Which agent config the server should serve. See AgentKitWidgetConfig.configChannel. */
|
|
669
|
+
configChannel?: 'draft' | 'published';
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
export declare function WidgetShell({ config, messages, isLoading, error, isInline, initStatus, initError, callbacks, }: Props_2): JSX.Element;
|
|
673
|
+
|
|
674
|
+
export declare type WidgetState = {
|
|
675
|
+
isOpen: boolean;
|
|
676
|
+
messages: WidgetMessage[];
|
|
677
|
+
isLoading: boolean;
|
|
678
|
+
error: string | null;
|
|
679
|
+
sessionId: string | undefined;
|
|
680
|
+
/** Lifecycle status of the widget init/validation phase. */
|
|
681
|
+
initStatus: 'validating' | 'ready' | 'error' | 'disabled';
|
|
682
|
+
/** Human-readable reason when initStatus === 'error'. */
|
|
683
|
+
initError: string | null;
|
|
684
|
+
/**
|
|
685
|
+
* Current conversation control mode. Populated from the server's
|
|
686
|
+
* `/v1/sessions/:id/events` SSE stream. UIs should suppress AI-typing
|
|
687
|
+
* indicators and surface a "connected to support" banner when the mode
|
|
688
|
+
* is `human_takeover`.
|
|
689
|
+
*/
|
|
690
|
+
controlMode?: WidgetControlMode;
|
|
691
|
+
};
|
|
151
692
|
|
|
152
693
|
export { }
|