@docsearch/react 5.0.3 → 5.0.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.
@@ -0,0 +1,270 @@
1
+ import { o as ToolCalls } from "./index-BijiN4hK.js";
2
+ import { _ as StoredSearchesSectionsTranslations, a as DocSearchProps, c as DocSearchTranslations, g as ErrorScreenTranslations, h as NoResultsScreenTranslations, m as ResultsScreenTranslations, v as FooterTranslations, y as FacetBarTranslations } from "./DocSearch-2gNxdJcC.js";
3
+ import { DocSearchRef, InitialAskAiMessage, OnAskAiToggle } from "@docsearch/core";
4
+ import React, { JSX } from "react";
5
+ import { AutocompleteState, BaseItem } from "@algolia/autocomplete-core";
6
+ import "@ai-sdk/react";
7
+ //#region src/components/ToolCall.d.ts
8
+ type ToolCallTranslations = {
9
+ /** Text shown while assistant is preparing tool call. */
10
+ preToolCallText: string;
11
+ /** Text shown while assistant is performing search tool call. */
12
+ searchingText: string;
13
+ /** Text shown while assistant is finished performing tool call. */
14
+ toolCallResultText: string;
15
+ /** Text shown when the agent saved related information to memory. */
16
+ savedMemoryToolResultText: string;
17
+ /** Text shown when the agent used the memory tool to enhance results. */
18
+ memoryToolResultText: string;
19
+ };
20
+ //#endregion
21
+ //#region src/AskAiScreen.d.ts
22
+ type AskAiScreenTranslations = Partial<Omit<ToolCallTranslations, 'searchingText' | 'toolCallResultText'> & {
23
+ disclaimerText: string;
24
+ /** Text shown describing a singular related source. */
25
+ relatedSourcesText: string;
26
+ /** Text shown describing multiple related sources. */
27
+ relatedSourcesTextPlural: string;
28
+ thinkingText: string;
29
+ copyButtonText: string;
30
+ copyButtonCopiedText: string;
31
+ copyButtonTitle: string;
32
+ likeButtonTitle: string;
33
+ dislikeButtonTitle: string;
34
+ thanksForFeedbackText: string;
35
+ feedbackPanelTitle: string;
36
+ feedbackDetailsPlaceholder: string;
37
+ feedbackDisclaimerText: string;
38
+ feedbackSubmitButtonText: string;
39
+ feedbackCloseButtonTitle: string;
40
+ feedbackTagIncorrect: string;
41
+ feedbackTagNotWhatIAsked: string;
42
+ feedbackTagSlowOrBuggy: string;
43
+ feedbackTagStyleOrTone: string;
44
+ feedbackTagSafetyOrLegal: string;
45
+ feedbackTagOther: string;
46
+ /**
47
+ * Text shown while assistant is performing search tool call. Maps to
48
+ * `ToolCallTranslations.searchingText`.
49
+ */
50
+ duringToolCallText: string;
51
+ /**
52
+ * Text shown while assistant is finished performing tool call. Maps to
53
+ * `ToolCallTranslations.toolCallResultText`.
54
+ */
55
+ afterToolCallText: string;
56
+ /**
57
+ * Build the full jsx element for the aggregated search block. If provided,
58
+ * completely overrides the default english renderer.
59
+ */
60
+ aggregatedToolCallNode?: (queries: string[], onSearchQueryClick: (query: string) => void) => React.ReactNode;
61
+ /**
62
+ * Generate the list connective parts only (backwards compatibility).
63
+ * Receives full list of queries and should return translation parts for
64
+ * before/after/separators. Example: (qs) => ({ before: 'searched for ',
65
+ * separator: ', ', lastSeparator: ' and ', after: '' }).
66
+ */
67
+ aggregatedToolCallText?: (queries: string[]) => {
68
+ before?: string;
69
+ separator?: string;
70
+ lastSeparator?: string;
71
+ after?: string;
72
+ };
73
+ /** Message that's shown when user has stopped the streaming of a message. */
74
+ stoppedStreamingText: string;
75
+ /** Error title shown if there is an error while chatting. */
76
+ errorTitleText: string;
77
+ /** Message shown when thread depth limit is exceeded (AI-217 error). */
78
+ threadDepthExceededMessage: string;
79
+ /** Button text for starting a new conversation after thread depth error. */
80
+ startNewConversationButtonText: string;
81
+ suggestedPromptsTitleText: string;
82
+ }>;
83
+ //#endregion
84
+ //#region src/components/ui/RecentConversationsResults.d.ts
85
+ type RecentConversationsResultsTranslations = Partial<{
86
+ recentConversationsTitle: string;
87
+ removeRecentConversationButtonTitle: string;
88
+ }>;
89
+ //#endregion
90
+ //#region src/components/AskAiStartScreen.d.ts
91
+ type AskAiStartScreenTranslations = RecentConversationsResultsTranslations & StoredSearchesSectionsTranslations;
92
+ //#endregion
93
+ //#region src/NewConversationScreen.d.ts
94
+ type NewConversationTranslations = Partial<{
95
+ newConversationTitle: string;
96
+ newConversationDescription: string;
97
+ }>;
98
+ //#endregion
99
+ //#region src/AskAiScreenState.d.ts
100
+ type AskAiScreenStateTranslations = Partial<{
101
+ errorScreen: ErrorScreenTranslations;
102
+ startScreen: AskAiStartScreenTranslations;
103
+ noResultsScreen: NoResultsScreenTranslations;
104
+ resultsScreen: ResultsScreenTranslations;
105
+ askAiScreen: AskAiScreenTranslations;
106
+ newConversation: NewConversationTranslations;
107
+ }>;
108
+ //#endregion
109
+ //#region src/components/AskAiSearchBox.d.ts
110
+ type AskAiSearchBoxTranslations = Partial<{
111
+ clearButtonTitle: string;
112
+ clearButtonAriaLabel: string;
113
+ closeButtonText: string;
114
+ closeButtonAriaLabel: string;
115
+ placeholderText: string;
116
+ placeholderTextAskAi: string;
117
+ placeholderTextAskAiStreaming: string;
118
+ enterKeyHint: string;
119
+ enterKeyHintAskAi: string;
120
+ searchInputLabel: string;
121
+ backToKeywordSearchButtonText: string;
122
+ backToKeywordSearchButtonAriaLabel: string;
123
+ newConversationPlaceholder: string;
124
+ conversationHistoryTitle: string;
125
+ startNewConversationText: string;
126
+ viewConversationHistoryText: string;
127
+ threadDepthErrorPlaceholder: string;
128
+ }>;
129
+ //#endregion
130
+ //#region src/DocSearchAskAiModal.d.ts
131
+ type DocSearchAskAiModalTranslations = AskAiScreenStateTranslations & Partial<{
132
+ searchBox: AskAiSearchBoxTranslations;
133
+ newConversation: NewConversationTranslations;
134
+ footer: FooterTranslations;
135
+ facets: FacetBarTranslations;
136
+ }>;
137
+ type DocSearchAskAiModalProps = DocSearchAIProps & {
138
+ initialScrollY: number;
139
+ onAskAiToggle: OnAskAiToggle;
140
+ onClose?: () => void;
141
+ isAskAiActive?: boolean;
142
+ translations?: DocSearchAskAiModalTranslations;
143
+ isHybridModeSupported?: boolean;
144
+ };
145
+ declare function DocSearchAskAiModal({ appId, apiKey, askAi, maxResultsPerGroup, theme, onClose, transformItems, hitComponent, resultsFooterComponent, navigator, initialScrollY, transformSearchClient, disableUserPersonalization, initialQuery: initialQueryFromProp, translations, getMissingResultsUrl, insights, onAskAiToggle, interceptAskAiEvent, isAskAiActive, recentSearchesLimit, recentSearchesWithFavoritesLimit, indices, facets, isHybridModeSupported, footerAction, ...props }: DocSearchAskAiModalProps): JSX.Element;
146
+ //#endregion
147
+ //#region src/DocSearchAI.d.ts
148
+ interface AskAiSearchParameters {
149
+ facetFilters?: string[];
150
+ filters?: string;
151
+ attributesToRetrieve?: string[];
152
+ restrictSearchableAttributes?: string[];
153
+ distinct?: boolean | number | string;
154
+ }
155
+ type AgentStudioSearchParameters = Record<string, Omit<AskAiSearchParameters, 'facetFilters'>>;
156
+ interface Memory {
157
+ /**
158
+ * Determines whether or not to display the memory based tool calls.
159
+ *
160
+ * @default false
161
+ */
162
+ enabled?: boolean;
163
+ /**
164
+ * The JWT used by the agent to know which user's memory to read.
165
+ *
166
+ * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/user-authentication
167
+ */
168
+ userToken?: string;
169
+ }
170
+ interface PromptSuggestions {
171
+ /** The name of the index where the prompt suggestions are stored. */
172
+ indexName: string;
173
+ /**
174
+ * The number of prompt suggestions that are retrieved and displayed.
175
+ *
176
+ * @default 3
177
+ */
178
+ hitsPerPage?: number;
179
+ }
180
+ interface DocSearchAskAi {
181
+ /**
182
+ * The API key to use for the ask AI feature. Your assistant will use this API
183
+ * key to search the index. If not provided, the API key will be used.
184
+ */
185
+ apiKey?: string;
186
+ /**
187
+ * The app ID to use for the ask AI feature. Your assistant will use this app
188
+ * ID to search the index. If not provided, the app ID will be used.
189
+ */
190
+ appId?: string;
191
+ /** The Agent Studio Agent ID to use for the Ask AI feature. */
192
+ agentId: string;
193
+ /**
194
+ * Enables displaying suggested questions on Ask AI's new conversation screen.
195
+ *
196
+ * @default false
197
+ */
198
+ suggestedQuestions?: boolean;
199
+ /**
200
+ * The search parameters to use for the ask AI feature. Keyed by the index
201
+ * name.
202
+ *
203
+ * @example
204
+ * {
205
+ * "INDEX_NAME": { distinct: false }
206
+ * }
207
+ */
208
+ searchParameters?: AgentStudioSearchParameters;
209
+ /**
210
+ * Index names for the Agent Studio search tool on this request.
211
+ *
212
+ * Agent Studio expects names only. Put descriptions and tool defaults on the
213
+ * agent configuration. Put per-index runtime overrides in
214
+ * `searchParameters`.
215
+ */
216
+ indices?: string[];
217
+ /**
218
+ * Use custom tools driven by Agent Studio.
219
+ *
220
+ * For best performance, memoize this object with `useMemo` or define it
221
+ * outside the component. Inline object literals will be recreated every
222
+ * render but will not affect correctness.
223
+ */
224
+ tools?: ToolCalls;
225
+ /**
226
+ * Configuration for the Agent Studio memory feature.
227
+ *
228
+ * @example
229
+ * { enabled: true, userToken: '{{SERVER_GENERATED_JWT_TOKEN}}' }
230
+ *
231
+ * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/memory/overview
232
+ */
233
+ memory?: Memory;
234
+ /**
235
+ * Enables and configures prompt suggestions that are displayed during keyword
236
+ * search.
237
+ *
238
+ * @example
239
+ * { indexName: 'docsearch-markdown_prompt_suggestions', hitsPerPage: 1 }
240
+ *
241
+ * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/integration#prompt-suggestions
242
+ */
243
+ promptSuggestions?: PromptSuggestions;
244
+ }
245
+ type DocSearchAITranslations = Partial<{
246
+ button: DocSearchTranslations['button'];
247
+ modal: DocSearchAskAiModalTranslations;
248
+ }>;
249
+ interface DocSearchAIProps extends Omit<DocSearchProps, 'translations'> {
250
+ /**
251
+ * Configuration or assistant id to enable ask ai mode. Pass a string
252
+ * assistant id or a full config object.
253
+ */
254
+ askAi: DocSearchAskAi | string;
255
+ /**
256
+ * Intercept Ask AI requests (e.g. Submitting a prompt or selecting a
257
+ * suggested question).
258
+ *
259
+ * Return `true` to prevent the default modal Ask AI flow (no toggle, no
260
+ * sendMessage). Useful to route Ask AI into a different UI (e.g.
261
+ * `@docsearch/sidepanel-js`) without flicker.
262
+ */
263
+ interceptAskAiEvent?: (initialMessage: InitialAskAiMessage) => boolean | void;
264
+ translations?: DocSearchAITranslations;
265
+ }
266
+ declare const DocSearchAI: React.ForwardRefExoticComponent<DocSearchAIProps & React.RefAttributes<DocSearchRef>>;
267
+ declare function DocSearchAIInner(props: Omit<DocSearchAIProps, 'appId' | 'apiKey'>): JSX.Element;
268
+ //#endregion
269
+ export { DocSearchAIProps as a, Memory as c, DocSearchAskAiModalProps as d, DocSearchAskAiModalTranslations as f, DocSearchAIInner as i, PromptSuggestions as l, AskAiSearchParameters as n, DocSearchAITranslations as o, ToolCallTranslations as p, DocSearchAI as r, DocSearchAskAi as s, AgentStudioSearchParameters as t, DocSearchAskAiModal as u };
270
+ //# sourceMappingURL=DocSearchAI-DKtAqje2.d.ts.map
@@ -1,2 +1,2 @@
1
- import { n as DocSearchAskAiModalProps, r as DocSearchAskAiModalTranslations, t as DocSearchAskAiModal } from "./DocSearchAskAiModal-BY3KtJ54.js";
1
+ import { d as DocSearchAskAiModalProps, f as DocSearchAskAiModalTranslations, u as DocSearchAskAiModal } from "./DocSearchAI-DKtAqje2.js";
2
2
  export { DocSearchAskAiModal, DocSearchAskAiModalProps, DocSearchAskAiModalTranslations };
@@ -1,123 +1,3 @@
1
1
  import { o as ToolCalls } from "./index-BijiN4hK.js";
2
- import { a as DocSearchProps } from "./DocSearch-2gNxdJcC.js";
3
- import { DocSearchRef, InitialAskAiMessage } from "@docsearch/core";
4
- import React, { JSX } from "react";
5
- //#region src/DocSearchAI.d.ts
6
- interface AskAiSearchParameters {
7
- facetFilters?: string[];
8
- filters?: string;
9
- attributesToRetrieve?: string[];
10
- restrictSearchableAttributes?: string[];
11
- distinct?: boolean | number | string;
12
- }
13
- type AgentStudioSearchParameters = Record<string, Omit<AskAiSearchParameters, 'facetFilters'>>;
14
- interface Memory {
15
- /**
16
- * Determines whether or not to display the memory based tool calls.
17
- *
18
- * @default false
19
- */
20
- enabled?: boolean;
21
- /**
22
- * The JWT used by the agent to know which user's memory to read.
23
- *
24
- * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/user-authentication
25
- */
26
- userToken?: string;
27
- }
28
- interface PromptSuggestions {
29
- /** The name of the index where the prompt suggestions are stored. */
30
- indexName: string;
31
- /**
32
- * The number of prompt suggestions that are retrieved and displayed.
33
- *
34
- * @default 3
35
- */
36
- hitsPerPage?: number;
37
- }
38
- interface DocSearchAskAi {
39
- /**
40
- * The API key to use for the ask AI feature. Your assistant will use this API
41
- * key to search the index. If not provided, the API key will be used.
42
- */
43
- apiKey?: string;
44
- /**
45
- * The app ID to use for the ask AI feature. Your assistant will use this app
46
- * ID to search the index. If not provided, the app ID will be used.
47
- */
48
- appId?: string;
49
- /** The Agent Studio Agent ID to use for the Ask AI feature. */
50
- agentId: string;
51
- /**
52
- * Enables displaying suggested questions on Ask AI's new conversation screen.
53
- *
54
- * @default false
55
- */
56
- suggestedQuestions?: boolean;
57
- /**
58
- * The search parameters to use for the ask AI feature. Keyed by the index
59
- * name.
60
- *
61
- * @example
62
- * {
63
- * "INDEX_NAME": { distinct: false }
64
- * }
65
- */
66
- searchParameters?: AgentStudioSearchParameters;
67
- /**
68
- * Index names for the Agent Studio search tool on this request.
69
- *
70
- * Agent Studio expects names only. Put descriptions and tool defaults on the
71
- * agent configuration. Put per-index runtime overrides in
72
- * `searchParameters`.
73
- */
74
- indices?: string[];
75
- /**
76
- * Use custom tools driven by Agent Studio.
77
- *
78
- * For best performance, memoize this object with `useMemo` or define it
79
- * outside the component. Inline object literals will be recreated every
80
- * render but will not affect correctness.
81
- */
82
- tools?: ToolCalls;
83
- /**
84
- * Configuration for the Agent Studio memory feature.
85
- *
86
- * @example
87
- * { enabled: true, userToken: '{{SERVER_GENERATED_JWT_TOKEN}}' }
88
- *
89
- * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/memory/overview
90
- */
91
- memory?: Memory;
92
- /**
93
- * Enables and configures prompt suggestions that are displayed during keyword
94
- * search.
95
- *
96
- * @example
97
- * { indexName: 'docsearch-markdown_prompt_suggestions', hitsPerPage: 1 }
98
- *
99
- * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/integration#prompt-suggestions
100
- */
101
- promptSuggestions?: PromptSuggestions;
102
- }
103
- interface DocSearchAIProps extends DocSearchProps {
104
- /**
105
- * Configuration or assistant id to enable ask ai mode. Pass a string
106
- * assistant id or a full config object.
107
- */
108
- askAi: DocSearchAskAi | string;
109
- /**
110
- * Intercept Ask AI requests (e.g. Submitting a prompt or selecting a
111
- * suggested question).
112
- *
113
- * Return `true` to prevent the default modal Ask AI flow (no toggle, no
114
- * sendMessage). Useful to route Ask AI into a different UI (e.g.
115
- * `@docsearch/sidepanel-js`) without flicker.
116
- */
117
- interceptAskAiEvent?: (initialMessage: InitialAskAiMessage) => boolean | void;
118
- }
119
- declare const DocSearchAI: React.ForwardRefExoticComponent<DocSearchAIProps & React.RefAttributes<DocSearchRef>>;
120
- declare function DocSearchAIInner(props: Omit<DocSearchAIProps, 'appId' | 'apiKey'>): JSX.Element;
121
- //#endregion
122
- export { AgentStudioSearchParameters, AskAiSearchParameters, DocSearchAI, DocSearchAIInner, DocSearchAIProps, DocSearchAskAi, Memory, PromptSuggestions, type ToolCalls };
123
- //# sourceMappingURL=docsearchAi.d.ts.map
2
+ import { a as DocSearchAIProps, c as Memory, i as DocSearchAIInner, l as PromptSuggestions, n as AskAiSearchParameters, o as DocSearchAITranslations, r as DocSearchAI, s as DocSearchAskAi, t as AgentStudioSearchParameters } from "./DocSearchAI-DKtAqje2.js";
3
+ export { AgentStudioSearchParameters, AskAiSearchParameters, DocSearchAI, DocSearchAIInner, DocSearchAIProps, DocSearchAITranslations, DocSearchAskAi, Memory, PromptSuggestions, type ToolCalls };
@@ -1 +1 @@
1
- {"version":3,"file":"docsearchAi.js","names":["DocSearchProvider"],"sources":["../../src/DocSearchAI.tsx"],"sourcesContent":["import { DocSearch as DocSearchProvider, useDocSearch } from '@docsearch/core';\nimport type { DocSearchRef, InitialAskAiMessage } from '@docsearch/core';\nimport React, { type JSX } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport type { DocSearchProps } from './DocSearch';\nimport { DocSearchAskAiModal } from './DocSearchAskAiModal';\nimport { DocSearchButton } from './DocSearchButton';\nimport type { ToolCalls } from './types/AskiAi';\n\nexport interface AskAiSearchParameters {\n facetFilters?: string[];\n filters?: string;\n attributesToRetrieve?: string[];\n restrictSearchableAttributes?: string[];\n distinct?: boolean | number | string;\n}\n\nexport type AgentStudioSearchParameters = Record<\n string,\n Omit<AskAiSearchParameters, 'facetFilters'>\n>;\n\nexport interface Memory {\n /**\n * Determines whether or not to display the memory based tool calls.\n *\n * @default false\n */\n enabled?: boolean;\n /**\n * The JWT used by the agent to know which user's memory to read.\n *\n * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/user-authentication\n */\n userToken?: string;\n}\n\nexport interface PromptSuggestions {\n /** The name of the index where the prompt suggestions are stored. */\n indexName: string;\n /**\n * The number of prompt suggestions that are retrieved and displayed.\n *\n * @default 3\n */\n hitsPerPage?: number;\n}\n\nexport interface DocSearchAskAi {\n /**\n * The API key to use for the ask AI feature. Your assistant will use this API\n * key to search the index. If not provided, the API key will be used.\n */\n apiKey?: string;\n /**\n * The app ID to use for the ask AI feature. Your assistant will use this app\n * ID to search the index. If not provided, the app ID will be used.\n */\n appId?: string;\n /** The Agent Studio Agent ID to use for the Ask AI feature. */\n agentId: string;\n /**\n * Enables displaying suggested questions on Ask AI's new conversation screen.\n *\n * @default false\n */\n suggestedQuestions?: boolean;\n /**\n * The search parameters to use for the ask AI feature. Keyed by the index\n * name.\n *\n * @example\n * {\n * \"INDEX_NAME\": { distinct: false }\n * }\n */\n searchParameters?: AgentStudioSearchParameters;\n /**\n * Index names for the Agent Studio search tool on this request.\n *\n * Agent Studio expects names only. Put descriptions and tool defaults on the\n * agent configuration. Put per-index runtime overrides in\n * `searchParameters`.\n */\n indices?: string[];\n /**\n * Use custom tools driven by Agent Studio.\n *\n * For best performance, memoize this object with `useMemo` or define it\n * outside the component. Inline object literals will be recreated every\n * render but will not affect correctness.\n */\n tools?: ToolCalls;\n /**\n * Configuration for the Agent Studio memory feature.\n *\n * @example\n * { enabled: true, userToken: '{{SERVER_GENERATED_JWT_TOKEN}}' }\n *\n * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/memory/overview\n */\n memory?: Memory;\n /**\n * Enables and configures prompt suggestions that are displayed during keyword\n * search.\n *\n * @example\n * { indexName: 'docsearch-markdown_prompt_suggestions', hitsPerPage: 1 }\n *\n * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/integration#prompt-suggestions\n */\n promptSuggestions?: PromptSuggestions;\n}\n\nexport interface DocSearchAIProps extends DocSearchProps {\n /**\n * Configuration or assistant id to enable ask ai mode. Pass a string\n * assistant id or a full config object.\n */\n askAi: DocSearchAskAi | string;\n /**\n * Intercept Ask AI requests (e.g. Submitting a prompt or selecting a\n * suggested question).\n *\n * Return `true` to prevent the default modal Ask AI flow (no toggle, no\n * sendMessage). Useful to route Ask AI into a different UI (e.g.\n * `@docsearch/sidepanel-js`) without flicker.\n */\n interceptAskAiEvent?: (initialMessage: InitialAskAiMessage) => boolean | void;\n}\n\nfunction DocSearchAIComponent(\n { appId, apiKey, ...props }: DocSearchAIProps,\n ref: React.ForwardedRef<DocSearchRef>\n): JSX.Element {\n return (\n <DocSearchProvider {...props} appId={appId} apiKey={apiKey} ref={ref}>\n <DocSearchAIInner {...props} />\n </DocSearchProvider>\n );\n}\n\nexport const DocSearchAI = React.forwardRef(DocSearchAIComponent);\n\nexport function DocSearchAIInner(\n props: Omit<DocSearchAIProps, 'appId' | 'apiKey'>\n): JSX.Element {\n const {\n searchButtonRef,\n keyboardShortcuts,\n isModalActive,\n isAskAiActive,\n initialQuery,\n onAskAiToggle,\n openModal,\n closeModal,\n isHybridModeSupported,\n appId,\n apiKey,\n } = useDocSearch();\n\n if (!appId || !apiKey) {\n throw new Error('`DocSearchAI` requires `appId` and `apiKey` props.');\n }\n\n return (\n <>\n <DocSearchButton\n keyboardShortcuts={keyboardShortcuts}\n ref={searchButtonRef}\n translations={props.translations?.button}\n onClick={openModal}\n />\n {isModalActive &&\n createPortal(\n <DocSearchAskAiModal\n {...props}\n appId={appId}\n apiKey={apiKey}\n initialScrollY={window.scrollY}\n initialQuery={initialQuery}\n translations={props?.translations?.modal}\n isAskAiActive={isAskAiActive}\n isHybridModeSupported={isHybridModeSupported}\n onAskAiToggle={onAskAiToggle}\n onClose={closeModal}\n />,\n props.portalContainer ?? document.body\n )}\n </>\n );\n}\n\nexport type { ToolCalls } from './types/AskiAi';\n"],"mappings":";;;;;;;;;mBAqII,SAAO;AADX,SAAS,qBACP,MACA,KACa;KAFb,EAAE,OAAO,iBAAW;CAGpB,OACE,oCAACA,6CAAsB;EAAc;EAAe;EAAa;EAE9C,GADjB,oCAAC,kBAAqB,KAAQ,CACb;AAEvB;AAEA,MAAa,cAAc,MAAM,WAAW,oBAAoB;AAEhE,SAAgB,iBACd,OACa;;CACb,MAAM,EACJ,iBACA,mBACA,eACA,eACA,cACA,eACA,WACA,YACA,uBACA,OACA,WACE,aAAa;CAEjB,IAAI,CAAC,SAAS,CAAC,QACb,MAAM,IAAI,MAAM,oDAAoD;CAGtE,OACE,0DACE,oCAAC,iBAAD;EACqB;EACnB,KAAK;EACL,qCAAc,MAAM,wFAAc;EAClC,SAAS;CACV,IACA,iBACC,aACE,oCAAC,uDACK;EACG;EACC;EACR,gBAAgB,OAAO;EACT;EACd,4EAAc,MAAO,0FAAc;EACpB;EACQ;EACR;EACf,SAAS;EACV,6BACD,MAAM,wFAAmB,SAAS,IACpC,CACF;AAEN"}
1
+ {"version":3,"file":"docsearchAi.js","names":["DocSearchProvider"],"sources":["../../src/DocSearchAI.tsx"],"sourcesContent":["import { DocSearch as DocSearchProvider, useDocSearch } from '@docsearch/core';\nimport type { DocSearchRef, InitialAskAiMessage } from '@docsearch/core';\nimport React, { type JSX } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport type { DocSearchProps, DocSearchTranslations } from './DocSearch';\nimport {\n DocSearchAskAiModal,\n type DocSearchAskAiModalTranslations,\n} from './DocSearchAskAiModal';\nimport { DocSearchButton } from './DocSearchButton';\nimport type { ToolCalls } from './types/AskiAi';\n\nexport interface AskAiSearchParameters {\n facetFilters?: string[];\n filters?: string;\n attributesToRetrieve?: string[];\n restrictSearchableAttributes?: string[];\n distinct?: boolean | number | string;\n}\n\nexport type AgentStudioSearchParameters = Record<\n string,\n Omit<AskAiSearchParameters, 'facetFilters'>\n>;\n\nexport interface Memory {\n /**\n * Determines whether or not to display the memory based tool calls.\n *\n * @default false\n */\n enabled?: boolean;\n /**\n * The JWT used by the agent to know which user's memory to read.\n *\n * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/user-authentication\n */\n userToken?: string;\n}\n\nexport interface PromptSuggestions {\n /** The name of the index where the prompt suggestions are stored. */\n indexName: string;\n /**\n * The number of prompt suggestions that are retrieved and displayed.\n *\n * @default 3\n */\n hitsPerPage?: number;\n}\n\nexport interface DocSearchAskAi {\n /**\n * The API key to use for the ask AI feature. Your assistant will use this API\n * key to search the index. If not provided, the API key will be used.\n */\n apiKey?: string;\n /**\n * The app ID to use for the ask AI feature. Your assistant will use this app\n * ID to search the index. If not provided, the app ID will be used.\n */\n appId?: string;\n /** The Agent Studio Agent ID to use for the Ask AI feature. */\n agentId: string;\n /**\n * Enables displaying suggested questions on Ask AI's new conversation screen.\n *\n * @default false\n */\n suggestedQuestions?: boolean;\n /**\n * The search parameters to use for the ask AI feature. Keyed by the index\n * name.\n *\n * @example\n * {\n * \"INDEX_NAME\": { distinct: false }\n * }\n */\n searchParameters?: AgentStudioSearchParameters;\n /**\n * Index names for the Agent Studio search tool on this request.\n *\n * Agent Studio expects names only. Put descriptions and tool defaults on the\n * agent configuration. Put per-index runtime overrides in\n * `searchParameters`.\n */\n indices?: string[];\n /**\n * Use custom tools driven by Agent Studio.\n *\n * For best performance, memoize this object with `useMemo` or define it\n * outside the component. Inline object literals will be recreated every\n * render but will not affect correctness.\n */\n tools?: ToolCalls;\n /**\n * Configuration for the Agent Studio memory feature.\n *\n * @example\n * { enabled: true, userToken: '{{SERVER_GENERATED_JWT_TOKEN}}' }\n *\n * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/memory/overview\n */\n memory?: Memory;\n /**\n * Enables and configures prompt suggestions that are displayed during keyword\n * search.\n *\n * @example\n * { indexName: 'docsearch-markdown_prompt_suggestions', hitsPerPage: 1 }\n *\n * @see https://www.algolia.com/doc/guides/algolia-ai/agent-studio/how-to/integration#prompt-suggestions\n */\n promptSuggestions?: PromptSuggestions;\n}\n\nexport type DocSearchAITranslations = Partial<{\n button: DocSearchTranslations['button'];\n modal: DocSearchAskAiModalTranslations;\n}>;\n\nexport interface DocSearchAIProps extends Omit<DocSearchProps, 'translations'> {\n /**\n * Configuration or assistant id to enable ask ai mode. Pass a string\n * assistant id or a full config object.\n */\n askAi: DocSearchAskAi | string;\n /**\n * Intercept Ask AI requests (e.g. Submitting a prompt or selecting a\n * suggested question).\n *\n * Return `true` to prevent the default modal Ask AI flow (no toggle, no\n * sendMessage). Useful to route Ask AI into a different UI (e.g.\n * `@docsearch/sidepanel-js`) without flicker.\n */\n interceptAskAiEvent?: (initialMessage: InitialAskAiMessage) => boolean | void;\n translations?: DocSearchAITranslations;\n}\n\nfunction DocSearchAIComponent(\n { appId, apiKey, ...props }: DocSearchAIProps,\n ref: React.ForwardedRef<DocSearchRef>\n): JSX.Element {\n return (\n <DocSearchProvider {...props} appId={appId} apiKey={apiKey} ref={ref}>\n <DocSearchAIInner {...props} />\n </DocSearchProvider>\n );\n}\n\nexport const DocSearchAI = React.forwardRef(DocSearchAIComponent);\n\nexport function DocSearchAIInner(\n props: Omit<DocSearchAIProps, 'appId' | 'apiKey'>\n): JSX.Element {\n const {\n searchButtonRef,\n keyboardShortcuts,\n isModalActive,\n isAskAiActive,\n initialQuery,\n onAskAiToggle,\n openModal,\n closeModal,\n isHybridModeSupported,\n appId,\n apiKey,\n } = useDocSearch();\n\n if (!appId || !apiKey) {\n throw new Error('`DocSearchAI` requires `appId` and `apiKey` props.');\n }\n\n return (\n <>\n <DocSearchButton\n keyboardShortcuts={keyboardShortcuts}\n ref={searchButtonRef}\n translations={props.translations?.button}\n onClick={openModal}\n />\n {isModalActive &&\n createPortal(\n <DocSearchAskAiModal\n {...props}\n appId={appId}\n apiKey={apiKey}\n initialScrollY={window.scrollY}\n initialQuery={initialQuery}\n translations={props?.translations?.modal}\n isAskAiActive={isAskAiActive}\n isHybridModeSupported={isHybridModeSupported}\n onAskAiToggle={onAskAiToggle}\n onClose={closeModal}\n />,\n props.portalContainer ?? document.body\n )}\n </>\n );\n}\n\nexport type { ToolCalls } from './types/AskiAi';\n"],"mappings":";;;;;;;;;mBA8II,SAAO;AADX,SAAS,qBACP,MACA,KACa;KAFb,EAAE,OAAO,iBAAW;CAGpB,OACE,oCAACA,6CAAsB;EAAc;EAAe;EAAa;EAE9C,GADjB,oCAAC,kBAAqB,KAAQ,CACb;AAEvB;AAEA,MAAa,cAAc,MAAM,WAAW,oBAAoB;AAEhE,SAAgB,iBACd,OACa;;CACb,MAAM,EACJ,iBACA,mBACA,eACA,eACA,cACA,eACA,WACA,YACA,uBACA,OACA,WACE,aAAa;CAEjB,IAAI,CAAC,SAAS,CAAC,QACb,MAAM,IAAI,MAAM,oDAAoD;CAGtE,OACE,0DACE,oCAAC,iBAAD;EACqB;EACnB,KAAK;EACL,qCAAc,MAAM,wFAAc;EAClC,SAAS;CACV,IACA,iBACC,aACE,oCAAC,uDACK;EACG;EACC;EACR,gBAAgB,OAAO;EACT;EACd,4EAAc,MAAO,0FAAc;EACpB;EACQ;EACR;EACf,SAAS;EACV,6BACD,MAAM,wFAAmB,SAAS,IACpC,CACF;AAEN"}
@@ -3,7 +3,6 @@ import { t as DocSearchTheme } from "./DocSearchTheme-DvL4mf0D.js";
3
3
  import { a as DocSearchProps, b as InternalDocSearchHit, c as DocSearchTranslations, d as DocSearchModal, f as DocSearchModalProps, i as DocSearchInner, l as HitComponentProps, n as DocSearchFacet, o as DocSearchRef, p as ModalTranslations, r as DocSearchIndex, s as DocSearchTransformClient, t as DocSearch, u as ResultsFooterComponentProps } from "./DocSearch-2gNxdJcC.js";
4
4
  import { n as useDocSearchKeyboardEvents, r as KeyboardShortcuts, t as UseDocSearchKeyboardEventsProps } from "./useDocSearchKeyboardEvents-B7PKBkuX.js";
5
5
  import { n as DocSearchButton, r as DocSearchButtonProps, t as ButtonTranslations } from "./DocSearchButton-DyJd_QGM.js";
6
- import { AgentStudioSearchParameters, AskAiSearchParameters, DocSearchAI, DocSearchAIInner, DocSearchAIProps, DocSearchAskAi, Memory, PromptSuggestions } from "./docsearchAi.js";
7
- import { n as DocSearchAskAiModalProps, r as DocSearchAskAiModalTranslations, t as DocSearchAskAiModal } from "./DocSearchAskAiModal-BY3KtJ54.js";
6
+ import { a as DocSearchAIProps, c as Memory, d as DocSearchAskAiModalProps, f as DocSearchAskAiModalTranslations, i as DocSearchAIInner, l as PromptSuggestions, n as AskAiSearchParameters, o as DocSearchAITranslations, r as DocSearchAI, s as DocSearchAskAi, t as AgentStudioSearchParameters, u as DocSearchAskAiModal } from "./DocSearchAI-DKtAqje2.js";
8
7
  import { version } from "./version.js";
9
- export { AgentStudioSearchParameters, AskAiFeedbackPayload, AskAiFeedbackReason, AskAiSearchParameters, ButtonTranslations, DocSearch, DocSearchAI, DocSearchAIInner, DocSearchAIProps, DocSearchAskAi, DocSearchAskAiModal, DocSearchAskAiModalProps, DocSearchAskAiModalTranslations, DocSearchButton, DocSearchButtonProps, DocSearchFacet, DocSearchHit, DocSearchIndex, DocSearchInner, DocSearchModal, DocSearchModalProps, DocSearchProps, type DocSearchRef, DocSearchState, DocSearchTheme, DocSearchTransformClient, DocSearchTranslations, HitComponentProps, InternalDocSearchHit, KeyboardShortcuts, Memory, ModalTranslations, OnAskAiFeedback, PromptSuggestions, ResultsFooterComponentProps, StoredAskAiMessage, StoredAskAiState, StoredDocSearchHit, SuggestedQuestion, SuggestedQuestionHit, type ToolCalls, UseDocSearchKeyboardEventsProps, useDocSearchKeyboardEvents, version };
8
+ export { AgentStudioSearchParameters, AskAiFeedbackPayload, AskAiFeedbackReason, AskAiSearchParameters, ButtonTranslations, DocSearch, DocSearchAI, DocSearchAIInner, DocSearchAIProps, DocSearchAITranslations, DocSearchAskAi, DocSearchAskAiModal, DocSearchAskAiModalProps, DocSearchAskAiModalTranslations, DocSearchButton, DocSearchButtonProps, DocSearchFacet, DocSearchHit, DocSearchIndex, DocSearchInner, DocSearchModal, DocSearchModalProps, DocSearchProps, type DocSearchRef, DocSearchState, DocSearchTheme, DocSearchTransformClient, DocSearchTranslations, HitComponentProps, InternalDocSearchHit, KeyboardShortcuts, Memory, ModalTranslations, OnAskAiFeedback, PromptSuggestions, ResultsFooterComponentProps, StoredAskAiMessage, StoredAskAiState, StoredDocSearchHit, SuggestedQuestion, SuggestedQuestionHit, type ToolCalls, UseDocSearchKeyboardEventsProps, useDocSearchKeyboardEvents, version };
@@ -1,7 +1,6 @@
1
1
  import { o as ToolCalls } from "./index-BijiN4hK.js";
2
2
  import "./DocSearch-2gNxdJcC.js";
3
- import { AgentStudioSearchParameters, Memory } from "./docsearchAi.js";
4
- import { r as ToolCallTranslations } from "./AskAiScreenState-DuzmHxUz.js";
3
+ import { c as Memory, p as ToolCallTranslations, t as AgentStudioSearchParameters } from "./DocSearchAI-DKtAqje2.js";
5
4
  import { DocSearchCallbacks, DocSearchCallbacks as DocSearchCallbacks$1, DocSearchRef, DocSearchRef as DocSearchRef$1, DocSearchTheme, InitialAskAiMessage, SidepanelShortcuts } from "@docsearch/core";
6
5
  import React, { JSX } from "react";
7
6
  import "@ai-sdk/react";
@@ -1,5 +1,5 @@
1
1
  //#region src/version.d.ts
2
- declare const version = "5.0.3";
2
+ declare const version = "5.0.4";
3
3
  //#endregion
4
4
  export { version };
5
5
  //# sourceMappingURL=version.d.ts.map
@@ -1,5 +1,5 @@
1
1
  //#region src/version.ts
2
- const version = "5.0.3";
2
+ const version = "5.0.4";
3
3
 
4
4
  //#endregion
5
5
  export { version };
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const version = '5.0.3';\n"],"mappings":";AAAA,MAAa,UAAU"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const version = '5.0.4';\n"],"mappings":";AAAA,MAAa,UAAU"}