react-instantsearch 7.49.0 → 7.50.0

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.
@@ -13,9 +13,16 @@ _export(exports, {
13
13
  get Chat () {
14
14
  return Chat;
15
15
  },
16
- get DisplayResultsToolType () {
16
+ get CompareProductsToolType () {
17
+ return _chat.CompareProductsToolType;
18
+ },
19
+ get // eslint-disable-next-line typescript/no-deprecated
20
+ DisplayResultsToolType () {
17
21
  return _chat.DisplayResultsToolType;
18
22
  },
23
+ get GroupedResultsToolType () {
24
+ return _chat.GroupedResultsToolType;
25
+ },
19
26
  get MemorizeToolType () {
20
27
  return _chat.MemorizeToolType;
21
28
  },
@@ -53,7 +60,8 @@ var _focusAfterReveal = require("instantsearch.js/cjs/lib/chat/focusAfterReveal"
53
60
  var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
54
61
  var _reactinstantsearchcore = require("react-instantsearch-core");
55
62
  var _useStickToBottom = require("../lib/useStickToBottom");
56
- var _DisplayResultsTool = require("./chat/tools/DisplayResultsTool");
63
+ var _CompareProductsTool = require("./chat/tools/CompareProductsTool");
64
+ var _GroupedResultsTool = require("./chat/tools/GroupedResultsTool");
57
65
  var _SearchIndexTool = require("./chat/tools/SearchIndexTool");
58
66
  var ChatUiComponent = (0, _instantsearchuicomponents.createChatComponent)({
59
67
  createElement: _react.createElement,
@@ -63,20 +71,15 @@ var ChatUiComponent = (0, _instantsearchuicomponents.createChatComponent)({
63
71
  useEffect: _react.useEffect
64
72
  });
65
73
  function createDefaultTools(itemComponent, getSearchPageURL) {
74
+ var groupedResultsTool = (0, _GroupedResultsTool.createGroupedResultsTool)(itemComponent);
66
75
  var _obj;
67
76
  return _obj = {}, _define_property._(_obj, _chat.SearchIndexToolType, _object_spread_props._(_object_spread._({}, (0, _SearchIndexTool.createCarouselTool)(true, itemComponent, getSearchPageURL)), {
68
- // The agent decides per turn whether the richer display-results tool
77
+ // The agent decides per turn whether the richer Grouped Results tool
69
78
  // takes over the rendering of the search results.
70
- shouldRender: isDisplayResultsDisabled
71
- })), _define_property._(_obj, _chat.RecommendToolType, (0, _SearchIndexTool.createCarouselTool)(false, itemComponent, getSearchPageURL)), _define_property._(_obj, _chat.DisplayResultsToolType, (0, _DisplayResultsTool.createDisplayResultsTool)(itemComponent)), _define_property._(_obj, _chat.MemorizeToolType, {}), _define_property._(_obj, _chat.MemorySearchToolType, {}), _define_property._(_obj, _chat.PonderToolType, {}), _obj;
72
- }
73
- /**
74
- * Whether the search tool renders its own results, i.e. the agent did not hand
75
- * the turn to the display-results tool. Set on the message by the backend.
76
- */ function isDisplayResultsDisabled(param) {
77
- var parentMessage = param.parentMessage;
78
- var _parentMessage_metadata;
79
- return ((_parentMessage_metadata = parentMessage.metadata) === null || _parentMessage_metadata === void 0 ? void 0 : _parentMessage_metadata.displayResultsEnabled) !== true;
79
+ shouldRender: _instantsearchuicomponents.shouldSearchToolRenderResults
80
+ })), _define_property._(_obj, _chat.RecommendToolType, (0, _SearchIndexTool.createCarouselTool)(false, itemComponent, getSearchPageURL)), _define_property._(_obj, _chat.GroupedResultsToolType, groupedResultsTool), // Agents configured before the rename still emit the legacy tool name.
81
+ // eslint-disable-next-line typescript/no-deprecated
82
+ _define_property._(_obj, _chat.DisplayResultsToolType, groupedResultsTool), _define_property._(_obj, _chat.CompareProductsToolType, (0, _CompareProductsTool.createCompareProductsTool)()), _define_property._(_obj, _chat.MemorizeToolType, {}), _define_property._(_obj, _chat.MemorySearchToolType, {}), _define_property._(_obj, _chat.PonderToolType, {}), _obj;
80
83
  }
81
84
  function mergeToolOptions(defaultTools, userTools) {
82
85
  if (!userTools) {
@@ -203,7 +206,7 @@ function ChatInner(_0, _1) {
203
206
  tools: tools,
204
207
  disableTriggerValidation: effectiveDisableTriggerValidation
205
208
  }));
206
- var messages = chatState.messages, sendMessage = chatState.sendMessage, status = chatState.status, regenerate = chatState.regenerate, stop = chatState.stop, error = chatState.error, input = chatState.input, setInput = chatState.setInput, open = chatState.open, setOpen = chatState.setOpen, clearMessages = chatState.clearMessages, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions, suggestionsStatus = chatState.suggestionsStatus, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState, consumeInputFocus = chatState['~consumeInputFocus'], isOpenStatePersistenceEnabled = chatState['~isOpenStatePersistenceEnabled'];
209
+ var messages = chatState.messages, sendMessage = chatState.sendMessage, status = chatState.status, regenerate = chatState.regenerate, stop = chatState.stop, error = chatState.error, input = chatState.input, setInput = chatState.setInput, open = chatState.open, setOpen = chatState.setOpen, clearMessages = chatState.clearMessages, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState, consumeInputFocus = chatState['~consumeInputFocus'], isOpenStatePersistenceEnabled = chatState['~isOpenStatePersistenceEnabled'];
207
210
  var sendMessageAndScrollToBottom = (0, _react.useCallback)(function() {
208
211
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
209
212
  args[_key] = arguments[_key];
@@ -361,7 +364,6 @@ function ChatInner(_0, _1) {
361
364
  }),
362
365
  suggestionsProps: {
363
366
  suggestions: suggestions,
364
- isLoading: suggestionsStatus === 'loading',
365
367
  onSuggestionClick: function onSuggestionClick(suggestion) {
366
368
  sendMessageAndScrollToBottom({
367
369
  text: suggestion
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "CompareBar", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return CompareBar;
10
+ }
11
+ });
12
+ var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
13
+ var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
14
+ var _instantsearchuicomponents = require("instantsearch-ui-components");
15
+ var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
16
+ var _reactinstantsearchcore = require("react-instantsearch-core");
17
+ var CompareBarUiComponent = (0, _instantsearchuicomponents.createCompareBarComponent)({
18
+ createElement: _react.createElement,
19
+ Fragment: _react.Fragment
20
+ });
21
+ function CompareBar(_0) {
22
+ var classNames = _0.classNames, translations = _0.translations, itemComponent = _0.itemComponent, props = _object_without_properties._(_0, [
23
+ "classNames",
24
+ "translations",
25
+ "itemComponent"
26
+ ]);
27
+ var _useCompare = (0, _reactinstantsearchcore.useCompare)(props, {
28
+ $$widgetType: 'ais.compareBar'
29
+ }), items = _useCompare.items, minItems = _useCompare.minItems, maxItems = _useCompare.maxItems, canCompare = _useCompare.canCompare, removeItem = _useCompare.removeItem, clearItems = _useCompare.clearItems, compare = _useCompare.compare;
30
+ return /*#__PURE__*/ _react.default.createElement(CompareBarUiComponent, {
31
+ items: items,
32
+ minItems: minItems,
33
+ maxItems: maxItems,
34
+ canCompare: canCompare,
35
+ onCompare: function onCompare() {
36
+ return compare();
37
+ },
38
+ onRemove: function onRemove(item) {
39
+ return removeItem(item.objectID);
40
+ },
41
+ onClear: clearItems,
42
+ itemComponent: itemComponent,
43
+ classNames: classNames,
44
+ translations: translations
45
+ });
46
+ }
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "createCompareProductsTool", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return createCompareProductsTool;
10
+ }
11
+ });
12
+ var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
13
+ var _instantsearchuicomponents = require("instantsearch-ui-components");
14
+ var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
15
+ /**
16
+ * Builtin comparison tool (`algolia_compare_products`).
17
+ *
18
+ * Registered by default in the chat widget so the agent can trigger a grounded
19
+ * side-by-side comparison: its tool call names only the product objectIDs and
20
+ * the attribute keys, and every cell is hydrated client-side from the real
21
+ * `algolia_search_index` hits. The model never types a value, so it cannot
22
+ * hallucinate one. See `instantsearch-ui-components` `CompareProductsTool` for
23
+ * the contract, and `comparison-eval/README.md` for the study behind it.
24
+ */ function createCompareProductsTool(translations) {
25
+ var CompareProductsUIComponent = (0, _instantsearchuicomponents.createCompareProductsToolComponent)({
26
+ createElement: _react.createElement,
27
+ Fragment: _react.Fragment
28
+ });
29
+ var CompareProductsLayoutComponent = function CompareProductsLayoutComponent(toolProps) {
30
+ return /*#__PURE__*/ _react.default.createElement(CompareProductsUIComponent, {
31
+ toolProps: toolProps,
32
+ translations: translations
33
+ });
34
+ };
35
+ return {
36
+ layoutComponent: CompareProductsLayoutComponent,
37
+ // Client-side tool: acknowledge the call so the agent's turn can complete.
38
+ // The table itself is rendered from the call's input + real search hits.
39
+ onToolCall: function onToolCall(param) {
40
+ var input = param.input, addToolResult = param.addToolResult;
41
+ var objectIDs = input === null || input === void 0 ? void 0 : input.objectIDs;
42
+ addToolResult({
43
+ output: {
44
+ status: 'displayed',
45
+ objectIDs: Array.isArray(objectIDs) ? objectIDs : []
46
+ }
47
+ });
48
+ }
49
+ };
50
+ }
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "createComparisonTableTool", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return createComparisonTableTool;
10
+ }
11
+ });
12
+ var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
13
+ var _instantsearchuicomponents = require("instantsearch-ui-components");
14
+ var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
15
+ /**
16
+ * Grounded comparison-table tool (prototype).
17
+ *
18
+ * Renders a v2 `markdownTable` display block whose every cell is hydrated from
19
+ * the real `algolia_search_index` hits by objectID — the agent supplies only the
20
+ * objectIDs and the attribute keys, never the values. See
21
+ * `instantsearch-ui-components` `ComparisonTableTool` for the contract.
22
+ *
23
+ * Register under the display-results tool key (or a dedicated key) in
24
+ * `createDefaultTools` to have comparison answers rendered as a grounded table
25
+ * instead of the model-authored markdown table.
26
+ */ function createComparisonTableTool(translations) {
27
+ var ComparisonTableUIComponent = (0, _instantsearchuicomponents.createComparisonTableToolComponent)({
28
+ createElement: _react.createElement,
29
+ Fragment: _react.Fragment
30
+ });
31
+ var ComparisonTableLayoutComponent = function ComparisonTableLayoutComponent(toolProps) {
32
+ return /*#__PURE__*/ _react.default.createElement(ComparisonTableUIComponent, {
33
+ toolProps: toolProps,
34
+ translations: translations
35
+ });
36
+ };
37
+ return {
38
+ layoutComponent: ComparisonTableLayoutComponent
39
+ };
40
+ }
@@ -3,18 +3,18 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "createDisplayResultsTool", {
6
+ Object.defineProperty(exports, "createGroupedResultsTool", {
7
7
  enumerable: true,
8
8
  get: function() {
9
- return createDisplayResultsTool;
9
+ return createGroupedResultsTool;
10
10
  }
11
11
  });
12
12
  var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
13
13
  var _instantsearchuicomponents = require("instantsearch-ui-components");
14
14
  var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
15
15
  var _components = require("../../../components");
16
- function createDisplayResultsTool(itemComponent) {
17
- var DisplayResultsUIComponent = (0, _instantsearchuicomponents.createDisplayResultsToolComponent)({
16
+ function createGroupedResultsTool(itemComponent) {
17
+ var GroupedResultsUIComponent = (0, _instantsearchuicomponents.createGroupedResultsToolComponent)({
18
18
  createElement: _react.createElement,
19
19
  Fragment: _react.Fragment,
20
20
  useEffect: _react.useEffect,
@@ -23,14 +23,14 @@ function createDisplayResultsTool(itemComponent) {
23
23
  var Button = (0, _instantsearchuicomponents.createButtonComponent)({
24
24
  createElement: _react.createElement
25
25
  });
26
- var DisplayResultsCarouselHeader = function DisplayResultsCarouselHeader(param) {
26
+ var GroupedResultsCarouselHeader = function GroupedResultsCarouselHeader(param) {
27
27
  var nbItems = param.nbItems, canScrollLeft = param.canScrollLeft, canScrollRight = param.canScrollRight, scrollLeft = param.scrollLeft, scrollRight = param.scrollRight;
28
28
  return /*#__PURE__*/ _react.default.createElement("div", {
29
- className: "ais-ChatToolDisplayResultsCarouselHeader"
29
+ className: "ais-ChatToolGroupedResultsCarouselHeader"
30
30
  }, /*#__PURE__*/ _react.default.createElement("div", {
31
- className: "ais-ChatToolDisplayResultsCarouselHeaderCount"
31
+ className: "ais-ChatToolGroupedResultsCarouselHeaderCount"
32
32
  }, nbItems, " result", nbItems > 1 ? 's' : ''), /*#__PURE__*/ _react.default.createElement("div", {
33
- className: "ais-ChatToolDisplayResultsCarouselHeaderScrollButtons"
33
+ className: "ais-ChatToolGroupedResultsCarouselHeaderScrollButtons"
34
34
  }, /*#__PURE__*/ _react.default.createElement(Button, {
35
35
  variant: "outline",
36
36
  size: "sm",
@@ -38,7 +38,7 @@ function createDisplayResultsTool(itemComponent) {
38
38
  "aria-label": "Previous",
39
39
  onClick: scrollLeft,
40
40
  disabled: !canScrollLeft,
41
- className: "ais-ChatToolDisplayResultsCarouselHeaderScrollButton"
41
+ className: "ais-ChatToolGroupedResultsCarouselHeaderScrollButton"
42
42
  }, /*#__PURE__*/ _react.default.createElement(_instantsearchuicomponents.ChevronLeftIcon, {
43
43
  createElement: _react.createElement
44
44
  })), /*#__PURE__*/ _react.default.createElement(Button, {
@@ -48,13 +48,13 @@ function createDisplayResultsTool(itemComponent) {
48
48
  "aria-label": "Next",
49
49
  onClick: scrollRight,
50
50
  disabled: !canScrollRight,
51
- className: "ais-ChatToolDisplayResultsCarouselHeaderScrollButton"
51
+ className: "ais-ChatToolGroupedResultsCarouselHeaderScrollButton"
52
52
  }, /*#__PURE__*/ _react.default.createElement(_instantsearchuicomponents.ChevronRightIcon, {
53
53
  createElement: _react.createElement
54
54
  }))));
55
55
  };
56
- var DisplayResultsLayoutComponent = function DisplayResultsLayoutComponent(toolProps) {
57
- return /*#__PURE__*/ _react.default.createElement(DisplayResultsUIComponent, {
56
+ var GroupedResultsLayoutComponent = function GroupedResultsLayoutComponent(toolProps) {
57
+ return /*#__PURE__*/ _react.default.createElement(GroupedResultsUIComponent, {
58
58
  toolProps: toolProps,
59
59
  groupCarouselComponent: function groupCarouselComponent(param) {
60
60
  var items = param.items, sendEvent = param.sendEvent;
@@ -63,13 +63,13 @@ function createDisplayResultsTool(itemComponent) {
63
63
  itemComponent: itemComponent,
64
64
  sendEvent: sendEvent,
65
65
  showNavigation: false,
66
- headerComponent: DisplayResultsCarouselHeader
66
+ headerComponent: GroupedResultsCarouselHeader
67
67
  });
68
68
  }
69
69
  });
70
70
  };
71
71
  return {
72
- layoutComponent: DisplayResultsLayoutComponent,
72
+ layoutComponent: GroupedResultsLayoutComponent,
73
73
  streamInput: true
74
74
  };
75
75
  }
@@ -9,6 +9,7 @@ _export_star._(require("./Breadcrumb"), exports);
9
9
  _export_star._(require("./Chat"), exports);
10
10
  _export_star._(require("./PromptSuggestions"), exports);
11
11
  _export_star._(require("./ChatTrigger"), exports);
12
+ _export_star._(require("./CompareBar"), exports);
12
13
  _export_star._(require("./ClearRefinements"), exports);
13
14
  _export_star._(require("./CurrentRefinements"), exports);
14
15
  _export_star._(require("./FrequentlyBoughtTogether"), exports);
package/dist/es/index.js CHANGED
@@ -2,10 +2,11 @@ export * from 'react-instantsearch-core';
2
2
  export { useStickToBottom } from './lib/useStickToBottom.js';
3
3
  export { Autocomplete, EXPERIMENTAL_Autocomplete } from './widgets/Autocomplete.js';
4
4
  export { Breadcrumb } from './widgets/Breadcrumb.js';
5
- export { DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
5
+ export { CompareProductsToolType, DisplayResultsToolType, GroupedResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
6
6
  export { Chat, createDefaultTools } from './widgets/Chat.js';
7
7
  export { PromptSuggestions } from './widgets/PromptSuggestions.js';
8
8
  export { ChatTrigger } from './widgets/ChatTrigger.js';
9
+ export { CompareBar } from './widgets/CompareBar.js';
9
10
  export { ClearRefinements } from './widgets/ClearRefinements.js';
10
11
  export { CurrentRefinements } from './widgets/CurrentRefinements.js';
11
12
  export { FrequentlyBoughtTogether } from './widgets/FrequentlyBoughtTogether.js';
@@ -1,6 +1,6 @@
1
- import { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, DisplayResultsToolType } from 'instantsearch.js/es/lib/chat';
1
+ import { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, DisplayResultsToolType, CompareProductsToolType, GroupedResultsToolType } from 'instantsearch.js/es/lib/chat';
2
2
  import React from 'react';
3
- export { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, DisplayResultsToolType, };
3
+ export { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, DisplayResultsToolType, CompareProductsToolType, GroupedResultsToolType, };
4
4
  import type { ChatProps as ChatUiProps, ChatLayoutOwnProps, RecommendComponentProps, RecordWithObjectID, UserClientSideTool, UserClientSideTools, ChatMessageProps } from 'instantsearch-ui-components';
5
5
  import type { IndexUiState } from 'instantsearch.js';
6
6
  import type { UIMessage } from 'instantsearch.js/es/lib/chat';
@@ -9,14 +9,15 @@ import { _ as _$8 } from '@swc/helpers/esm/_object_without_properties.js';
9
9
  import { _ as _$9 } from '@swc/helpers/esm/_sliced_to_array.js';
10
10
  import { _ as _$7 } from '@swc/helpers/esm/_to_array.js';
11
11
  import { _ as _$a } from '@swc/helpers/esm/_to_consumable_array.js';
12
- import { createChatComponent } from 'instantsearch-ui-components';
13
- import { SearchIndexToolType, RecommendToolType, DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType } from 'instantsearch.js/es/lib/chat/index.js';
14
- export { DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
12
+ import { createChatComponent, shouldSearchToolRenderResults } from 'instantsearch-ui-components';
13
+ import { SearchIndexToolType, RecommendToolType, GroupedResultsToolType, DisplayResultsToolType, CompareProductsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType } from 'instantsearch.js/es/lib/chat/index.js';
14
+ export { CompareProductsToolType, DisplayResultsToolType, GroupedResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
15
15
  import { getActiveContainerAnimations, holdContainerInertUntilReveal, restoreContainerInertUntilReveal, focusAfterReveal } from 'instantsearch.js/es/lib/chat/focusAfterReveal.js';
16
16
  import React, { createElement, Fragment, useMemo, useState, useEffect, useRef, useCallback, useImperativeHandle } from 'react';
17
17
  import { useInstantSearch, useChat } from 'react-instantsearch-core';
18
18
  import { useStickToBottom } from '../lib/useStickToBottom.js';
19
- import { createDisplayResultsTool } from './chat/tools/DisplayResultsTool.js';
19
+ import { createCompareProductsTool } from './chat/tools/CompareProductsTool.js';
20
+ import { createGroupedResultsTool } from './chat/tools/GroupedResultsTool.js';
20
21
  import { createCarouselTool } from './chat/tools/SearchIndexTool.js';
21
22
 
22
23
  var ChatUiComponent = createChatComponent({
@@ -27,20 +28,15 @@ var ChatUiComponent = createChatComponent({
27
28
  useEffect: useEffect
28
29
  });
29
30
  function createDefaultTools(itemComponent, getSearchPageURL) {
31
+ var groupedResultsTool = createGroupedResultsTool(itemComponent);
30
32
  var _obj;
31
33
  return _obj = {}, _$4(_obj, SearchIndexToolType, _$5(_$6({}, createCarouselTool(true, itemComponent, getSearchPageURL)), {
32
- // The agent decides per turn whether the richer display-results tool
34
+ // The agent decides per turn whether the richer Grouped Results tool
33
35
  // takes over the rendering of the search results.
34
- shouldRender: isDisplayResultsDisabled
35
- })), _$4(_obj, RecommendToolType, createCarouselTool(false, itemComponent, getSearchPageURL)), _$4(_obj, DisplayResultsToolType, createDisplayResultsTool(itemComponent)), _$4(_obj, MemorizeToolType, {}), _$4(_obj, MemorySearchToolType, {}), _$4(_obj, PonderToolType, {}), _obj;
36
- }
37
- /**
38
- * Whether the search tool renders its own results, i.e. the agent did not hand
39
- * the turn to the display-results tool. Set on the message by the backend.
40
- */ function isDisplayResultsDisabled(param) {
41
- var parentMessage = param.parentMessage;
42
- var _parentMessage_metadata;
43
- return ((_parentMessage_metadata = parentMessage.metadata) === null || _parentMessage_metadata === void 0 ? void 0 : _parentMessage_metadata.displayResultsEnabled) !== true;
36
+ shouldRender: shouldSearchToolRenderResults
37
+ })), _$4(_obj, RecommendToolType, createCarouselTool(false, itemComponent, getSearchPageURL)), _$4(_obj, GroupedResultsToolType, groupedResultsTool), // Agents configured before the rename still emit the legacy tool name.
38
+ // eslint-disable-next-line typescript/no-deprecated
39
+ _$4(_obj, DisplayResultsToolType, groupedResultsTool), _$4(_obj, CompareProductsToolType, createCompareProductsTool()), _$4(_obj, MemorizeToolType, {}), _$4(_obj, MemorySearchToolType, {}), _$4(_obj, PonderToolType, {}), _obj;
44
40
  }
45
41
  function mergeToolOptions(defaultTools, userTools) {
46
42
  if (!userTools) {
@@ -167,7 +163,7 @@ function ChatInner(_0, _1) {
167
163
  tools: tools,
168
164
  disableTriggerValidation: effectiveDisableTriggerValidation
169
165
  }));
170
- var messages = chatState.messages, sendMessage = chatState.sendMessage, status = chatState.status, regenerate = chatState.regenerate, stop = chatState.stop, error = chatState.error, input = chatState.input, setInput = chatState.setInput, open = chatState.open, setOpen = chatState.setOpen, clearMessages = chatState.clearMessages, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions, suggestionsStatus = chatState.suggestionsStatus, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState, consumeInputFocus = chatState['~consumeInputFocus'], isOpenStatePersistenceEnabled = chatState['~isOpenStatePersistenceEnabled'];
166
+ var messages = chatState.messages, sendMessage = chatState.sendMessage, status = chatState.status, regenerate = chatState.regenerate, stop = chatState.stop, error = chatState.error, input = chatState.input, setInput = chatState.setInput, open = chatState.open, setOpen = chatState.setOpen, clearMessages = chatState.clearMessages, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState, consumeInputFocus = chatState['~consumeInputFocus'], isOpenStatePersistenceEnabled = chatState['~isOpenStatePersistenceEnabled'];
171
167
  var sendMessageAndScrollToBottom = useCallback(function() {
172
168
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
173
169
  args[_key] = arguments[_key];
@@ -325,7 +321,6 @@ function ChatInner(_0, _1) {
325
321
  }),
326
322
  suggestionsProps: {
327
323
  suggestions: suggestions,
328
- isLoading: suggestionsStatus === 'loading',
329
324
  onSuggestionClick: function onSuggestionClick(suggestion) {
330
325
  sendMessageAndScrollToBottom({
331
326
  text: suggestion
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import type { CompareBarClassNames, CompareBarItemComponentProps, CompareBarTranslations } from 'instantsearch-ui-components';
3
+ import type { UseCompareProps } from 'react-instantsearch-core';
4
+ export type CompareBarProps = UseCompareProps & {
5
+ /**
6
+ * CSS classes to add to the widget elements.
7
+ */
8
+ classNames?: Partial<CompareBarClassNames>;
9
+ /**
10
+ * Translations for the widget's texts.
11
+ */
12
+ translations?: Partial<CompareBarTranslations>;
13
+ /**
14
+ * Custom renderer for a selected item's label.
15
+ */
16
+ itemComponent?: (props: CompareBarItemComponentProps) => JSX.Element;
17
+ };
18
+ /**
19
+ * Renders the comparison selection bar: the records picked for comparison,
20
+ * a clear-selection action, and the "Compare" call-to-action that opens the
21
+ * `<Chat>` widget with the comparison message.
22
+ *
23
+ * Select records from your own UI (e.g. a "Compare" button in your hit
24
+ * component) with `useCompare().toggleItem(hit)` — the selection is shared
25
+ * with this widget.
26
+ */
27
+ export declare function CompareBar({ classNames, translations, itemComponent, ...props }: CompareBarProps): React.JSX.Element;
@@ -0,0 +1,45 @@
1
+ import { _ } from '@swc/helpers/esm/_object_without_properties.js';
2
+ import { createCompareBarComponent } from 'instantsearch-ui-components';
3
+ import React, { createElement, Fragment } from 'react';
4
+ import { useCompare } from 'react-instantsearch-core';
5
+
6
+ var CompareBarUiComponent = createCompareBarComponent({
7
+ createElement: createElement,
8
+ Fragment: Fragment
9
+ });
10
+ /**
11
+ * Renders the comparison selection bar: the records picked for comparison,
12
+ * a clear-selection action, and the "Compare" call-to-action that opens the
13
+ * `<Chat>` widget with the comparison message.
14
+ *
15
+ * Select records from your own UI (e.g. a "Compare" button in your hit
16
+ * component) with `useCompare().toggleItem(hit)` — the selection is shared
17
+ * with this widget.
18
+ */ function CompareBar(_0) {
19
+ var classNames = _0.classNames, translations = _0.translations, itemComponent = _0.itemComponent, props = _(_0, [
20
+ "classNames",
21
+ "translations",
22
+ "itemComponent"
23
+ ]);
24
+ var _useCompare = useCompare(props, {
25
+ $$widgetType: 'ais.compareBar'
26
+ }), items = _useCompare.items, minItems = _useCompare.minItems, maxItems = _useCompare.maxItems, canCompare = _useCompare.canCompare, removeItem = _useCompare.removeItem, clearItems = _useCompare.clearItems, compare = _useCompare.compare;
27
+ return /*#__PURE__*/ React.createElement(CompareBarUiComponent, {
28
+ items: items,
29
+ minItems: minItems,
30
+ maxItems: maxItems,
31
+ canCompare: canCompare,
32
+ onCompare: function onCompare() {
33
+ return compare();
34
+ },
35
+ onRemove: function onRemove(item) {
36
+ return removeItem(item.objectID);
37
+ },
38
+ onClear: clearItems,
39
+ itemComponent: itemComponent,
40
+ classNames: classNames,
41
+ translations: translations
42
+ });
43
+ }
44
+
45
+ export { CompareBar };
@@ -0,0 +1,13 @@
1
+ import type { ComparisonTableTranslations, UserClientSideTool } from 'instantsearch-ui-components';
2
+ /**
3
+ * Builtin comparison tool (`algolia_compare_products`).
4
+ *
5
+ * Registered by default in the chat widget so the agent can trigger a grounded
6
+ * side-by-side comparison: its tool call names only the product objectIDs and
7
+ * the attribute keys, and every cell is hydrated client-side from the real
8
+ * `algolia_search_index` hits. The model never types a value, so it cannot
9
+ * hallucinate one. See `instantsearch-ui-components` `CompareProductsTool` for
10
+ * the contract, and `comparison-eval/README.md` for the study behind it.
11
+ */
12
+ declare function createCompareProductsTool(translations?: Partial<ComparisonTableTranslations>): UserClientSideTool;
13
+ export { createCompareProductsTool };
@@ -0,0 +1,41 @@
1
+ import { createCompareProductsToolComponent } from 'instantsearch-ui-components';
2
+ import React, { createElement, Fragment } from 'react';
3
+
4
+ /**
5
+ * Builtin comparison tool (`algolia_compare_products`).
6
+ *
7
+ * Registered by default in the chat widget so the agent can trigger a grounded
8
+ * side-by-side comparison: its tool call names only the product objectIDs and
9
+ * the attribute keys, and every cell is hydrated client-side from the real
10
+ * `algolia_search_index` hits. The model never types a value, so it cannot
11
+ * hallucinate one. See `instantsearch-ui-components` `CompareProductsTool` for
12
+ * the contract, and `comparison-eval/README.md` for the study behind it.
13
+ */ function createCompareProductsTool(translations) {
14
+ var CompareProductsUIComponent = createCompareProductsToolComponent({
15
+ createElement: createElement,
16
+ Fragment: Fragment
17
+ });
18
+ var CompareProductsLayoutComponent = function CompareProductsLayoutComponent(toolProps) {
19
+ return /*#__PURE__*/ React.createElement(CompareProductsUIComponent, {
20
+ toolProps: toolProps,
21
+ translations: translations
22
+ });
23
+ };
24
+ return {
25
+ layoutComponent: CompareProductsLayoutComponent,
26
+ // Client-side tool: acknowledge the call so the agent's turn can complete.
27
+ // The table itself is rendered from the call's input + real search hits.
28
+ onToolCall: function onToolCall(param) {
29
+ var input = param.input, addToolResult = param.addToolResult;
30
+ var objectIDs = input === null || input === void 0 ? void 0 : input.objectIDs;
31
+ addToolResult({
32
+ output: {
33
+ status: 'displayed',
34
+ objectIDs: Array.isArray(objectIDs) ? objectIDs : []
35
+ }
36
+ });
37
+ }
38
+ };
39
+ }
40
+
41
+ export { createCompareProductsTool };
@@ -0,0 +1,15 @@
1
+ import type { ComparisonTableTranslations, UserClientSideTool } from 'instantsearch-ui-components';
2
+ /**
3
+ * Grounded comparison-table tool (prototype).
4
+ *
5
+ * Renders a v2 `markdownTable` display block whose every cell is hydrated from
6
+ * the real `algolia_search_index` hits by objectID — the agent supplies only the
7
+ * objectIDs and the attribute keys, never the values. See
8
+ * `instantsearch-ui-components` `ComparisonTableTool` for the contract.
9
+ *
10
+ * Register under the display-results tool key (or a dedicated key) in
11
+ * `createDefaultTools` to have comparison answers rendered as a grounded table
12
+ * instead of the model-authored markdown table.
13
+ */
14
+ declare function createComparisonTableTool(translations?: Partial<ComparisonTableTranslations>): UserClientSideTool;
15
+ export { createComparisonTableTool };
@@ -0,0 +1,31 @@
1
+ import { createComparisonTableToolComponent } from 'instantsearch-ui-components';
2
+ import React, { createElement, Fragment } from 'react';
3
+
4
+ /**
5
+ * Grounded comparison-table tool (prototype).
6
+ *
7
+ * Renders a v2 `markdownTable` display block whose every cell is hydrated from
8
+ * the real `algolia_search_index` hits by objectID — the agent supplies only the
9
+ * objectIDs and the attribute keys, never the values. See
10
+ * `instantsearch-ui-components` `ComparisonTableTool` for the contract.
11
+ *
12
+ * Register under the display-results tool key (or a dedicated key) in
13
+ * `createDefaultTools` to have comparison answers rendered as a grounded table
14
+ * instead of the model-authored markdown table.
15
+ */ function createComparisonTableTool(translations) {
16
+ var ComparisonTableUIComponent = createComparisonTableToolComponent({
17
+ createElement: createElement,
18
+ Fragment: Fragment
19
+ });
20
+ var ComparisonTableLayoutComponent = function ComparisonTableLayoutComponent(toolProps) {
21
+ return /*#__PURE__*/ React.createElement(ComparisonTableUIComponent, {
22
+ toolProps: toolProps,
23
+ translations: translations
24
+ });
25
+ };
26
+ return {
27
+ layoutComponent: ComparisonTableLayoutComponent
28
+ };
29
+ }
30
+
31
+ export { createComparisonTableTool };
@@ -1,4 +1,4 @@
1
1
  import type { RecommendComponentProps, RecordWithObjectID, UserClientSideTool } from 'instantsearch-ui-components';
2
2
  type ItemComponent<TObject> = RecommendComponentProps<TObject>['itemComponent'];
3
- declare function createDisplayResultsTool<TObject extends RecordWithObjectID>(itemComponent?: ItemComponent<TObject>): UserClientSideTool;
4
- export { createDisplayResultsTool };
3
+ declare function createGroupedResultsTool<TObject extends RecordWithObjectID>(itemComponent?: ItemComponent<TObject>): UserClientSideTool;
4
+ export { createGroupedResultsTool };