@docsearch/react 4.5.0-beta.0 → 4.5.0-beta.2

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.
@@ -121,11 +121,26 @@ interface SearchIndexTool {
121
121
  hits?: any[];
122
122
  };
123
123
  }
124
+ interface AgentStudioSearchTool {
125
+ input: {
126
+ index: string;
127
+ query: string;
128
+ number_of_results: number;
129
+ facet_filters: any | null;
130
+ };
131
+ output: {
132
+ hits?: any[];
133
+ nbHits?: number;
134
+ queryID?: string;
135
+ };
136
+ }
137
+ type Tools = {
138
+ searchIndex: SearchIndexTool;
139
+ algolia_search_index: AgentStudioSearchTool;
140
+ };
124
141
  type AIMessage = UIMessage<{
125
142
  stopped?: boolean;
126
- }, UIDataTypes, {
127
- searchIndex: SearchIndexTool;
128
- }>;
143
+ }, UIDataTypes, Tools>;
129
144
 
130
145
  type StoredDocSearchHit = Omit<DocSearchHit, '_highlightResult' | '_snippetResult'>;
131
146
  type StoredAskAiMessage = AIMessage & {
@@ -183,7 +198,7 @@ type DocSearchAskAi = {
183
198
  /**
184
199
  * The assistant ID to use for the ask AI feature.
185
200
  */
186
- assistantId: string | null;
201
+ assistantId: string;
187
202
  /**
188
203
  * The search parameters to use for the ask AI feature.
189
204
  */
@@ -231,13 +246,16 @@ interface DocSearchProps {
231
246
  * Return `true` to prevent the default modal Ask AI flow (no toggle, no sendMessage).
232
247
  * Useful to route Ask AI into a different UI (e.g. `@docsearch/sidepanel-js`) without flicker.
233
248
  */
249
+ interceptAskAiEvent?: (initialMessage: InitialAskAiMessage) => boolean | void;
234
250
  /**
235
- * Intercept Ask AI events (prompt submit, suggested question selection, etc).
251
+ * **Experimental:** Whether to use Agent Studio as the chat backend.
252
+ *
253
+ * This is an experimental feature and its API may change without notice in future releases.
254
+ * Use with caution in production environments.
236
255
  *
237
- * Return `true` to prevent *all* default Ask AI behavior that would normally follow
238
- * (no toggle, no sendMessage, no internal Ask AI state updates).
256
+ * @default false
239
257
  */
240
- interceptAskAiEvent?: (initialMessage: InitialAskAiMessage) => boolean | void;
258
+ agentStudio?: boolean;
241
259
  /**
242
260
  * Theme overrides applied to the modal and related components.
243
261
  */
@@ -488,21 +506,31 @@ type DocSearchModalProps = DocSearchProps & {
488
506
  translations?: ModalTranslations;
489
507
  isHybridModeSupported?: boolean;
490
508
  };
491
- declare function DocSearchModal({ appId, apiKey, askAi, maxResultsPerGroup, theme, onClose, transformItems, hitComponent, resultsFooterComponent, navigator, initialScrollY, transformSearchClient, disableUserPersonalization, initialQuery: initialQueryFromProp, translations, getMissingResultsUrl, insights, onAskAiToggle, interceptAskAiEvent, isAskAiActive, recentSearchesLimit, recentSearchesWithFavoritesLimit, indices, indexName, searchParameters, isHybridModeSupported, ...props }: DocSearchModalProps): JSX.Element;
509
+ declare function DocSearchModal({ appId, apiKey, askAi, maxResultsPerGroup, theme, onClose, transformItems, hitComponent, resultsFooterComponent, navigator, initialScrollY, transformSearchClient, disableUserPersonalization, initialQuery: initialQueryFromProp, translations, getMissingResultsUrl, insights, onAskAiToggle, interceptAskAiEvent, isAskAiActive, recentSearchesLimit, recentSearchesWithFavoritesLimit, indices, indexName, searchParameters, isHybridModeSupported, agentStudio, ...props }: DocSearchModalProps): JSX.Element;
492
510
 
493
511
  interface UseDocSearchKeyboardEventsProps {
494
512
  isOpen: boolean;
495
513
  onOpen: () => void;
496
514
  onClose: () => void;
515
+ /**
516
+ * Deprecated: Still here for backwards compat.
517
+ *
518
+ * @deprecated
519
+ */
497
520
  onInput?: (event: KeyboardEvent) => void;
498
- searchButtonRef: React.RefObject<HTMLButtonElement | null>;
521
+ /**
522
+ * Deprecated: Still here for backwards compat.
523
+ *
524
+ * @deprecated
525
+ */
526
+ searchButtonRef?: React.RefObject<HTMLButtonElement | null>;
499
527
  isAskAiActive: boolean;
500
528
  onAskAiToggle: (toggle: boolean) => void;
501
529
  keyboardShortcuts?: KeyboardShortcuts;
502
530
  }
503
- declare function useDocSearchKeyboardEvents({ isOpen, onOpen, onClose, onInput, isAskAiActive, onAskAiToggle, searchButtonRef, keyboardShortcuts, }: UseDocSearchKeyboardEventsProps): void;
531
+ declare function useDocSearchKeyboardEvents({ isOpen, onOpen, onClose, isAskAiActive, onAskAiToggle, keyboardShortcuts, }: UseDocSearchKeyboardEventsProps): void;
504
532
 
505
- declare const version = "4.5.0-beta.0";
533
+ declare const version = "4.5.0-beta.2";
506
534
 
507
535
  export { DocSearch, DocSearchButton, DocSearchInner, DocSearchModal, useDocSearchKeyboardEvents, version };
508
536
  export type { AskAiSearchParameters, ButtonTranslations, DocSearchAskAi, DocSearchButtonProps, DocSearchHit, DocSearchIndex, DocSearchModalProps, DocSearchProps, DocSearchState, DocSearchTheme, DocSearchTransformClient, DocSearchTranslations, InternalDocSearchHit, KeyboardShortcuts, ModalTranslations, StoredAskAiMessage, StoredAskAiState, StoredDocSearchHit, SuggestedQuestion, SuggestedQuestionHit, UseDocSearchKeyboardEventsProps };