@docsearch/sidepanel-js 4.4.0 → 4.5.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,26 @@ interface SidepanelShortcuts {
8
8
  }
9
9
 
10
10
  type DocSearchTheme = 'dark' | 'light';
11
+ type InitialAskAiMessage = {
12
+ query: string;
13
+ messageId?: string;
14
+ suggestedQuestionId?: string;
15
+ };
16
+ /**
17
+ * Lifecycle callbacks for DocSearch.
18
+ */
19
+ interface DocSearchCallbacks {
20
+ /** Called once DocSearch is mounted and ready for interaction. */
21
+ onReady?: () => void;
22
+ /** Called when the modal opens. */
23
+ onOpen?: () => void;
24
+ /** Called when the modal closes. */
25
+ onClose?: () => void;
26
+ /** Called when the sidepanel opens. */
27
+ onSidepanelOpen?: () => void;
28
+ /** Called when the sidepanel closes. */
29
+ onSidepanelClose?: () => void;
30
+ }
11
31
 
12
32
  type AskAiSearchParameters = {
13
33
  facetFilters?: string[];
@@ -21,19 +41,7 @@ type AlgoliaLogoTranslations = Partial<{
21
41
  poweredByText: string;
22
42
  }>;
23
43
 
24
- type ConversationScreenTranslations = Partial<{
25
- /**
26
- * Text shown as an LLM disclaimer.
27
- */
28
- conversationDisclaimer: string;
29
- /**
30
- * Text shown while assistant is reasoning.
31
- */
32
- reasoningText: string;
33
- /**
34
- * Text show while assistant is thinking.
35
- */
36
- thinkingText: string;
44
+ type ToolCallTranslations = {
37
45
  /**
38
46
  * Text shown while assistant is preparing tool call.
39
47
  */
@@ -46,6 +54,21 @@ type ConversationScreenTranslations = Partial<{
46
54
  * Text shown while assistant is finished performing tool call.
47
55
  */
48
56
  toolCallResultText: string;
57
+ };
58
+
59
+ type ConversationScreenTranslations = Partial<ToolCallTranslations & {
60
+ /**
61
+ * Text shown as an LLM disclaimer.
62
+ */
63
+ conversationDisclaimer: string;
64
+ /**
65
+ * Text shown while assistant is reasoning.
66
+ */
67
+ reasoningText: string;
68
+ /**
69
+ * Text show while assistant is thinking.
70
+ */
71
+ thinkingText: string;
49
72
  /**
50
73
  * Text shown describing related sources.
51
74
  */
@@ -129,7 +152,6 @@ type HeaderTranslations = Partial<{
129
152
  **/
130
153
  viewConversationHistoryText: string;
131
154
  }>;
132
-
133
155
  type SidepanelTranslations = Partial<{
134
156
  /**
135
157
  * Translation texts for the Sidepanel header.
@@ -208,6 +230,7 @@ type SidepanelProps$1 = {
208
230
  * @default `{ 'Ctrl/Cmd+I': true }`
209
231
  */
210
232
  keyboardShortcuts?: SidepanelShortcuts;
233
+ useStagingEnv?: boolean;
211
234
  };
212
235
 
213
236
  type SidepanelButtonTranslations = Partial<{
@@ -247,7 +270,7 @@ type SidepanelButtonProps = {
247
270
  keyboardShortcuts?: SidepanelShortcuts;
248
271
  };
249
272
 
250
- type DocSearchSidepanelProps = {
273
+ type DocSearchSidepanelProps = DocSearchCallbacks & {
251
274
  /**
252
275
  * The assistant ID to use for the ask AI feature.
253
276
  */
@@ -288,13 +311,48 @@ type DocSearchSidepanelProps = {
288
311
  * Props specific to the Sidepanel panel.
289
312
  */
290
313
  panel?: Omit<SidepanelProps$1, 'keyboardShortcuts'>;
314
+ /**
315
+ * **Experimental:** Whether to use Agent Studio as the chat backend.
316
+ *
317
+ * This is an experimental feature and its API may change without notice in future releases.
318
+ * Use with caution in production environments.
319
+ *
320
+ * @default false
321
+ */
322
+ agentStudio?: boolean;
291
323
  };
292
324
 
293
- type SidepanelProps = DocSearchSidepanelProps & {
325
+ /**
326
+ * Instance returned by sidepanel() for programmatic control.
327
+ */
328
+ interface SidepanelInstance {
329
+ /** Returns true once the component is mounted and ready. */
330
+ readonly isReady: boolean;
331
+ /** Returns true if the sidepanel is currently open. */
332
+ readonly isOpen: boolean;
333
+ /** Opens the sidepanel, optionally with an initial message. */
334
+ open(initialMessage?: InitialAskAiMessage): void;
335
+ /** Closes the sidepanel. */
336
+ close(): void;
337
+ /** Unmounts the Sidepanel component and cleans up. */
338
+ destroy(): void;
339
+ }
340
+ /**
341
+ * Lifecycle callbacks for the Sidepanel instance.
342
+ */
343
+ interface SidepanelCallbacks {
344
+ /** Called once Sidepanel is mounted and ready for interaction. */
345
+ onReady?: () => void;
346
+ /** Called when the sidepanel opens. */
347
+ onOpen?: () => void;
348
+ /** Called when the sidepanel closes. */
349
+ onClose?: () => void;
350
+ }
351
+ type SidepanelProps = DocSearchSidepanelProps & SidepanelCallbacks & {
294
352
  container: HTMLElement | string;
295
353
  environment?: typeof window;
296
354
  };
297
- declare function sidepanel(props: SidepanelProps): () => void;
355
+ declare function sidepanel(props: SidepanelProps): SidepanelInstance;
298
356
 
299
357
  export { sidepanel as default };
300
- export type { SidepanelProps };
358
+ export type { SidepanelCallbacks, SidepanelInstance, SidepanelProps };