@docsearch/react 4.6.1 → 4.6.3
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/dist/esm/DocSearchButton.js +1 -1
- package/dist/esm/DocSearchModal.d.ts +1 -5
- package/dist/esm/DocSearchModal.js +2 -2
- package/dist/esm/Sidepanel.d.ts +23 -1
- package/dist/esm/Sidepanel.js +2 -2
- package/dist/esm/index.d.ts +110 -11
- package/dist/esm/index.js +2 -2
- package/dist/esm/useDocSearchKeyboardEvents.js +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/DocSearchModal.js +2 -2
- package/dist/umd/DocSearchModal.js.map +1 -1
- package/dist/umd/DocsearchButton.js +2 -2
- package/dist/umd/DocsearchButton.js.map +1 -1
- package/dist/umd/Sidepanel.js +3 -3
- package/dist/umd/Sidepanel.js.map +1 -1
- package/dist/umd/index.js +3 -3
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/useDocSearchKeyboardEvents.js +2 -2
- package/dist/umd/useDocSearchKeyboardEvents.js.map +1 -1
- package/dist/umd/useTheme.js +1 -1
- package/dist/umd/useTheme.js.map +1 -1
- package/dist/umd/version.js +2 -2
- package/dist/umd/version.js.map +1 -1
- package/package.json +4 -4
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { UIMessage } from '@ai-sdk/react';
|
|
2
|
+
import { UIDataTypes } from 'ai';
|
|
1
3
|
import { BaseItem, AutocompleteState, AutocompleteContext, AutocompleteInsightsApi, AutocompleteOptions } from '@algolia/autocomplete-core';
|
|
2
4
|
import { InitialAskAiMessage, DocSearchModalShortcuts, DocSearchRef, OnAskAiToggle } from '@docsearch/core';
|
|
3
5
|
export { DocSearchRef } from '@docsearch/core';
|
|
4
|
-
import { Hit,
|
|
6
|
+
import { Hit, SearchParamsObject, LiteClient } from 'algoliasearch/lite';
|
|
5
7
|
import React, { JSX } from 'react';
|
|
6
|
-
import { UIMessage } from '@ai-sdk/react';
|
|
7
|
-
import { UIDataTypes } from 'ai';
|
|
8
8
|
|
|
9
9
|
type ContentType = 'askAI' | 'content' | 'lvl0' | 'lvl1' | 'lvl2' | 'lvl3' | 'lvl4' | 'lvl5' | 'lvl6';
|
|
10
10
|
interface DocSearchHitAttributeHighlightResult {
|
|
@@ -134,7 +134,18 @@ interface AgentStudioSearchTool {
|
|
|
134
134
|
queryID?: string;
|
|
135
135
|
};
|
|
136
136
|
}
|
|
137
|
+
interface AlgoliaMCPSearchTool {
|
|
138
|
+
input: {
|
|
139
|
+
query: string;
|
|
140
|
+
};
|
|
141
|
+
output: {
|
|
142
|
+
hits?: any[];
|
|
143
|
+
nbHits?: number;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
137
146
|
type Tools = {
|
|
147
|
+
[K in `algolia_search_index_${string}`]: AlgoliaMCPSearchTool;
|
|
148
|
+
} & {
|
|
138
149
|
searchIndex: SearchIndexTool;
|
|
139
150
|
algolia_search_index: AgentStudioSearchTool;
|
|
140
151
|
};
|
|
@@ -163,6 +174,98 @@ type SuggestedQuestion = {
|
|
|
163
174
|
};
|
|
164
175
|
type SuggestedQuestionHit = Hit<SuggestedQuestion>;
|
|
165
176
|
|
|
177
|
+
type ExchangeWithOptionalAssistant = {
|
|
178
|
+
assistantMessage: AIMessage | null;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Pass-through: keep all exchanges when thread depth fails so the last user message stays visible
|
|
182
|
+
* (there is often no assistant reply for that turn).
|
|
183
|
+
*/
|
|
184
|
+
declare function filterExchangesForThreadDepthError<T extends ExchangeWithOptionalAssistant>(exchanges: T[], _hasThreadDepthError: boolean): T[];
|
|
185
|
+
/**
|
|
186
|
+
* Whether the error is thread depth exceeded (AI-217), including JSON-shaped Agent Studio payloads.
|
|
187
|
+
*/
|
|
188
|
+
declare function isThreadDepthError(error?: Error): boolean;
|
|
189
|
+
/**
|
|
190
|
+
* Whether further prompts should be blocked: thread depth (all backends) or Agent Studio cost controls.
|
|
191
|
+
*/
|
|
192
|
+
declare function isAskAiPromptBlockingError(error: Error | undefined, agentStudio: boolean): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Agent Studio stream hit the completion token ceiling (`TokenOutputLimitError`).
|
|
195
|
+
* This case uses a message-only banner (no “Start a new conversation” row).
|
|
196
|
+
*/
|
|
197
|
+
declare function isAgentStudioTokenOutputLimitError(error?: Error): boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Whether the blocking banner should include “Start a new conversation … to continue”.
|
|
200
|
+
* Thread depth and most Agent Studio limits keep it; token output limit and “request blocked for this domain” omit it.
|
|
201
|
+
*/
|
|
202
|
+
declare function showAskAiBlockingBannerNewConversationLink(error: Error | undefined, agentStudio: boolean): boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Pulls `message` or `error` from Agent Studio JSON payloads, including double-encoded JSON
|
|
205
|
+
* and objects serialized with escaped quotes (`{\"error\": \"...\"}`).
|
|
206
|
+
*/
|
|
207
|
+
declare function extractAgentStudioErrorFieldMessage(raw: string): string | undefined;
|
|
208
|
+
/**
|
|
209
|
+
* Prefer the API `message` when the body was JSON; otherwise the thrown message (without a trailing `(AI-xxx)` suffix).
|
|
210
|
+
* Only meaningful when {@link isAskAiPromptBlockingError} would return true for this error.
|
|
211
|
+
*/
|
|
212
|
+
declare function getAskAiPromptBlockingUserFacingMessage(error?: Error): string | undefined;
|
|
213
|
+
/**
|
|
214
|
+
* Message shown in the top blocking banner (parsed API text, never raw JSON when avoidable).
|
|
215
|
+
*/
|
|
216
|
+
declare function getAskAiBlockingBannerMessage(error?: Error): string | undefined;
|
|
217
|
+
/**
|
|
218
|
+
* Prefer the API `message` field when the error body is JSON; otherwise the thrown message string.
|
|
219
|
+
* Only meaningful when {@link isThreadDepthError} is true.
|
|
220
|
+
*/
|
|
221
|
+
declare function getThreadDepthErrorUserFacingMessage(error?: Error): string | undefined;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Registry of Agent Studio prompt-blocking matchers (cost controls, access, limits).
|
|
225
|
+
* Add cases here instead of scattering regex across call sites.
|
|
226
|
+
* Set `showNewConversationLink` to false to omit the “Start a new conversation … to continue” row when starting over does not fix the issue (for example, domain allowlisting).
|
|
227
|
+
*/
|
|
228
|
+
type AgentStudioBlockingMatchContext = {
|
|
229
|
+
message: string;
|
|
230
|
+
messageLower: string;
|
|
231
|
+
parsedJson: Record<string, unknown> | null;
|
|
232
|
+
extractedCodeUpper: string | undefined;
|
|
233
|
+
};
|
|
234
|
+
type AgentStudioPromptBlockingMatcher = {
|
|
235
|
+
matches: (ctx: AgentStudioBlockingMatchContext) => boolean;
|
|
236
|
+
showNewConversationLink?: boolean;
|
|
237
|
+
};
|
|
238
|
+
/** Agent Studio cost / access control codes that block further input. */
|
|
239
|
+
declare const AGENT_STUDIO_PROMPT_BLOCKING_CODES: Set<string>;
|
|
240
|
+
declare function readAgentStudioJsonStringField(o: Record<string, unknown>, key: string): string | undefined;
|
|
241
|
+
declare function extractAiErrorCodeFromMessage(message: string): string | undefined;
|
|
242
|
+
/** Plain-text / stringified JSON heuristic; JSON-shaped payloads still use `isThreadDepthError` in `ai.ts`. */
|
|
243
|
+
declare function matchesThreadDepthLimitError(normalizedMessage: string): boolean;
|
|
244
|
+
/** API copy for domain allowlisting — starting a new conversation does not resolve it. */
|
|
245
|
+
declare function matchesRequestBlockedForThisDomainMessage(normalizedMessage: string): boolean;
|
|
246
|
+
declare function matchesAgentStudioMaxStepsMessage(normalizedMessage: string): boolean;
|
|
247
|
+
declare function matchesAgentStudioRateLimitMessage(normalizedMessage: string): boolean;
|
|
248
|
+
declare function matchesAgentStudioTokenOutputLimitPlainMessage(message: string): boolean;
|
|
249
|
+
declare function matchesAgentStudioWhitelistOrNotAllowedDomainPlainMessage(normalizedMessage: string): boolean;
|
|
250
|
+
declare function matchesAgentStudioContextOrTokenLimitsPlainMessage(normalizedMessage: string): boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Ordered registry: first match does not win alone — `resolveAgentStudioPromptBlocking`
|
|
253
|
+
* OR-combines blocking and AND-combines “show new conversation” (any `false` hides the row).
|
|
254
|
+
*/
|
|
255
|
+
declare const agentStudioPromptBlockingMatchers: AgentStudioPromptBlockingMatcher[];
|
|
256
|
+
declare function resolveAgentStudioPromptBlocking(error: Error): {
|
|
257
|
+
blocking: boolean;
|
|
258
|
+
showNewConversationLink: boolean;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Plain-text matchers over `Error.message.toLowerCase()` (callers pass `error.message.toLowerCase()`).
|
|
262
|
+
* Thread depth: first entry mirrors common plain cases; JSON-shaped payloads still need `isThreadDepthError` in `ai.ts`.
|
|
263
|
+
*
|
|
264
|
+
* Blocking UX and “Start new conversation” visibility are driven by `agentStudioPromptBlockingMatchers`.
|
|
265
|
+
*/
|
|
266
|
+
type NewConversationErrorMatcher = (normalizedMessage: string) => boolean;
|
|
267
|
+
declare const newConversationErrorMatchers: NewConversationErrorMatcher[];
|
|
268
|
+
|
|
166
269
|
type DocSearchTranslations = Partial<{
|
|
167
270
|
button: ButtonTranslations;
|
|
168
271
|
modal: ModalTranslations;
|
|
@@ -446,11 +549,7 @@ type AskAiScreenTranslations = Partial<{
|
|
|
446
549
|
*/
|
|
447
550
|
errorTitleText: string;
|
|
448
551
|
/**
|
|
449
|
-
*
|
|
450
|
-
*/
|
|
451
|
-
threadDepthExceededMessage: string;
|
|
452
|
-
/**
|
|
453
|
-
* Button text for starting a new conversation after thread depth error.
|
|
552
|
+
* Button text for starting a new conversation after a blocking Ask AI error.
|
|
454
553
|
*/
|
|
455
554
|
startNewConversationButtonText: string;
|
|
456
555
|
}>;
|
|
@@ -550,7 +649,7 @@ interface UseDocSearchKeyboardEventsProps {
|
|
|
550
649
|
}
|
|
551
650
|
declare function useDocSearchKeyboardEvents({ isOpen, onOpen, onClose, isAskAiActive, onAskAiToggle, keyboardShortcuts, }: UseDocSearchKeyboardEventsProps): void;
|
|
552
651
|
|
|
553
|
-
declare const version = "4.6.
|
|
652
|
+
declare const version = "4.6.3";
|
|
554
653
|
|
|
555
|
-
export { DocSearch, DocSearchButton, DocSearchInner, DocSearchModal, useDocSearchKeyboardEvents, version };
|
|
556
|
-
export type { AgentStudioSearchParameters, AskAiSearchParameters, ButtonTranslations, DocSearchAskAi, DocSearchButtonProps, DocSearchHit, DocSearchIndex, DocSearchModalProps, DocSearchProps, DocSearchState, DocSearchTheme, DocSearchTransformClient, DocSearchTranslations, InternalDocSearchHit, KeyboardShortcuts, ModalTranslations, StoredAskAiMessage, StoredAskAiState, StoredDocSearchHit, SuggestedQuestion, SuggestedQuestionHit, UseDocSearchKeyboardEventsProps };
|
|
654
|
+
export { AGENT_STUDIO_PROMPT_BLOCKING_CODES, DocSearch, DocSearchButton, DocSearchInner, DocSearchModal, agentStudioPromptBlockingMatchers, extractAgentStudioErrorFieldMessage, extractAiErrorCodeFromMessage, filterExchangesForThreadDepthError, getAskAiBlockingBannerMessage, getAskAiPromptBlockingUserFacingMessage, getThreadDepthErrorUserFacingMessage, isAgentStudioTokenOutputLimitError, isAskAiPromptBlockingError, isThreadDepthError, matchesAgentStudioContextOrTokenLimitsPlainMessage, matchesAgentStudioMaxStepsMessage, matchesAgentStudioRateLimitMessage, matchesAgentStudioTokenOutputLimitPlainMessage, matchesAgentStudioWhitelistOrNotAllowedDomainPlainMessage, matchesRequestBlockedForThisDomainMessage, matchesThreadDepthLimitError, newConversationErrorMatchers, readAgentStudioJsonStringField, resolveAgentStudioPromptBlocking, showAskAiBlockingBannerNewConversationLink, useDocSearchKeyboardEvents, version };
|
|
655
|
+
export type { AgentStudioBlockingMatchContext, AgentStudioPromptBlockingMatcher, AgentStudioSearchParameters, AskAiSearchParameters, ButtonTranslations, DocSearchAskAi, DocSearchButtonProps, DocSearchHit, DocSearchIndex, DocSearchModalProps, DocSearchProps, DocSearchState, DocSearchTheme, DocSearchTransformClient, DocSearchTranslations, InternalDocSearchHit, KeyboardShortcuts, ModalTranslations, NewConversationErrorMatcher, StoredAskAiMessage, StoredAskAiState, StoredDocSearchHit, SuggestedQuestion, SuggestedQuestionHit, UseDocSearchKeyboardEventsProps };
|