react-instantsearch 7.40.0 → 7.41.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.
- package/dist/cjs/widgets/Autocomplete.js +22 -13
- package/dist/cjs/widgets/Chat.js +1 -1
- package/dist/cjs/widgets/chat/tools/SearchIndexTool.js +14 -86
- package/dist/es/index.js +1 -1
- package/dist/es/widgets/Autocomplete.d.ts +3 -1
- package/dist/es/widgets/Autocomplete.js +12 -11
- package/dist/es/widgets/Chat.js +2 -2
- package/dist/es/widgets/chat/tools/SearchIndexTool.js +16 -88
- package/dist/es/widgets/index.js +1 -1
- package/dist/umd/ReactInstantSearch.js +854 -509
- package/dist/umd/ReactInstantSearch.min.js +3 -3
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! React InstantSearch 7.
|
|
1
|
+
/*! React InstantSearch 7.41.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
26
26
|
|
|
27
|
-
var version$2 = '7.
|
|
27
|
+
var version$2 = '7.41.0';
|
|
28
28
|
|
|
29
29
|
function _define_property(obj, key, value) {
|
|
30
30
|
if (key in obj) {
|
|
@@ -7037,7 +7037,7 @@
|
|
|
7037
7037
|
return attribute;
|
|
7038
7038
|
}
|
|
7039
7039
|
|
|
7040
|
-
function addAbsolutePosition(hits, page, hitsPerPage) {
|
|
7040
|
+
function addAbsolutePosition$1(hits, page, hitsPerPage) {
|
|
7041
7041
|
return hits.map(function(hit, idx) {
|
|
7042
7042
|
return _object_spread_props(_object_spread({}, hit), {
|
|
7043
7043
|
__position: hitsPerPage * page + idx + 1
|
|
@@ -7045,7 +7045,7 @@
|
|
|
7045
7045
|
});
|
|
7046
7046
|
}
|
|
7047
7047
|
|
|
7048
|
-
function addQueryID(hits, queryID) {
|
|
7048
|
+
function addQueryID$1(hits, queryID) {
|
|
7049
7049
|
if (!queryID) {
|
|
7050
7050
|
return hits;
|
|
7051
7051
|
}
|
|
@@ -7254,6 +7254,12 @@
|
|
|
7254
7254
|
return widget.$$type === 'ais.dynamicWidgets' || widget.$$type === 'ais.feeds';
|
|
7255
7255
|
}
|
|
7256
7256
|
|
|
7257
|
+
/**
|
|
7258
|
+
* Logs a warning when this function is called, in development environment only.
|
|
7259
|
+
*/ var deprecate = function deprecate(fn, // eslint-disable-next-line no-unused-vars
|
|
7260
|
+
message) {
|
|
7261
|
+
return fn;
|
|
7262
|
+
};
|
|
7257
7263
|
/**
|
|
7258
7264
|
* Logs a warning
|
|
7259
7265
|
* This is used to log issues in development environment only.
|
|
@@ -8507,12 +8513,13 @@
|
|
|
8507
8513
|
instantSearchInstance._hasRecommendWidget = hasRecommendWidget;
|
|
8508
8514
|
}
|
|
8509
8515
|
var index = function index(widgetParams) {
|
|
8510
|
-
|
|
8516
|
+
var _widgetParams_EXPERIMENTAL_isolated;
|
|
8517
|
+
if (widgetParams === undefined || widgetParams.indexName === undefined && !widgetParams.isolated && !widgetParams.EXPERIMENTAL_isolated) {
|
|
8511
8518
|
throw new Error(withUsage$s('The `indexName` option is required.'));
|
|
8512
8519
|
}
|
|
8513
8520
|
// When isolated=true, we use an empty string as the default indexName.
|
|
8514
8521
|
// This is intentional: isolated indices do not require a real index name.
|
|
8515
|
-
var _widgetParams_indexName = widgetParams.indexName, indexName = _widgetParams_indexName === void 0 ? '' : _widgetParams_indexName, _widgetParams_indexId = widgetParams.indexId, indexId = _widgetParams_indexId === void 0 ? indexName : _widgetParams_indexId,
|
|
8522
|
+
var _widgetParams_indexName = widgetParams.indexName, indexName = _widgetParams_indexName === void 0 ? '' : _widgetParams_indexName, _widgetParams_indexId = widgetParams.indexId, indexId = _widgetParams_indexId === void 0 ? indexName : _widgetParams_indexId, _widgetParams_isolated = widgetParams.isolated, isolated = _widgetParams_isolated === void 0 ? (_widgetParams_EXPERIMENTAL_isolated = widgetParams.EXPERIMENTAL_isolated) !== null && _widgetParams_EXPERIMENTAL_isolated !== void 0 ? _widgetParams_EXPERIMENTAL_isolated : false : _widgetParams_isolated;
|
|
8516
8523
|
var localWidgets = [];
|
|
8517
8524
|
var localUiState = {};
|
|
8518
8525
|
var localInstantSearchInstance = null;
|
|
@@ -9177,7 +9184,7 @@
|
|
|
9177
9184
|
});
|
|
9178
9185
|
}
|
|
9179
9186
|
|
|
9180
|
-
var version = '4.
|
|
9187
|
+
var version = '4.108.0';
|
|
9181
9188
|
|
|
9182
9189
|
var ANONYMOUS_TOKEN_COOKIE_KEY = '_ALGOLIA';
|
|
9183
9190
|
function getCookie(name) {
|
|
@@ -12126,7 +12133,7 @@
|
|
|
12126
12133
|
helper: scopedResult.helper,
|
|
12127
12134
|
widgetType: _this.$$type
|
|
12128
12135
|
});
|
|
12129
|
-
var hits = scopedResult.results ? addQueryID(addAbsolutePosition(scopedResult.results.hits, scopedResult.results.page, scopedResult.results.hitsPerPage), scopedResult.results.queryID) : [];
|
|
12136
|
+
var hits = scopedResult.results ? addQueryID$1(addAbsolutePosition$1(scopedResult.results.hits, scopedResult.results.page, scopedResult.results.hitsPerPage), scopedResult.results.queryID) : [];
|
|
12130
12137
|
return {
|
|
12131
12138
|
indexId: scopedResult.indexId,
|
|
12132
12139
|
indexName: ((_scopedResult_results = scopedResult.results) === null || _scopedResult_results === void 0 ? void 0 : _scopedResult_results.index) || '',
|
|
@@ -12623,6 +12630,7 @@
|
|
|
12623
12630
|
return undefined;
|
|
12624
12631
|
}
|
|
12625
12632
|
|
|
12633
|
+
var _computedKey$1;
|
|
12626
12634
|
var tryParseJson = function tryParseJson(value) {
|
|
12627
12635
|
try {
|
|
12628
12636
|
return JSON.parse(value);
|
|
@@ -12693,6 +12701,8 @@
|
|
|
12693
12701
|
return fallbackInput;
|
|
12694
12702
|
};
|
|
12695
12703
|
var defaultGuardrailFallbackResponse = 'Sorry, we are not able to generate a response at the moment.';
|
|
12704
|
+
_computedKey$1 = /** @internal */ '~addToolResultForMessage';
|
|
12705
|
+
var _computedKey1$1 = _computedKey$1;
|
|
12696
12706
|
/**
|
|
12697
12707
|
* Abstract base class for chat implementations.
|
|
12698
12708
|
*/ var AbstractChat = /*#__PURE__*/ function() {
|
|
@@ -12712,6 +12722,12 @@
|
|
|
12712
12722
|
_define_property(this, "sendAutomaticallyWhen", void 0);
|
|
12713
12723
|
_define_property(this, "shouldRepairToolInput", void 0);
|
|
12714
12724
|
_define_property(this, "activeResponse", null);
|
|
12725
|
+
_define_property(this, "latestResponse", null);
|
|
12726
|
+
_define_property(this, "responsesByToolCallId", new Map());
|
|
12727
|
+
_define_property(this, "responseByMessage", new WeakMap());
|
|
12728
|
+
// Once tool ownership is discarded, an identifier-only result cannot prove
|
|
12729
|
+
// which response generation submitted it. Scoped submissions remain safe.
|
|
12730
|
+
_define_property(this, "acceptsIdentifierOnlyToolResults", true);
|
|
12715
12731
|
_define_property(this, "jobExecutor", new SerialJobExecutor());
|
|
12716
12732
|
/**
|
|
12717
12733
|
* Appends or replaces a user message to the chat list. This triggers the API call to fetch
|
|
@@ -12797,13 +12813,13 @@
|
|
|
12797
12813
|
// Find the message to regenerate from
|
|
12798
12814
|
var targetIndex = -1;
|
|
12799
12815
|
if (messageId) {
|
|
12800
|
-
targetIndex = _this1.
|
|
12816
|
+
targetIndex = _this1.messages.findIndex(function(m) {
|
|
12801
12817
|
return m.id === messageId;
|
|
12802
12818
|
});
|
|
12803
12819
|
} else {
|
|
12804
12820
|
// Find the last assistant message
|
|
12805
|
-
for(var i = _this1.
|
|
12806
|
-
if (_this1.
|
|
12821
|
+
for(var i = _this1.messages.length - 1; i >= 0; i--){
|
|
12822
|
+
if (_this1.messages[i].role === 'assistant') {
|
|
12807
12823
|
targetIndex = i;
|
|
12808
12824
|
break;
|
|
12809
12825
|
}
|
|
@@ -12811,7 +12827,7 @@
|
|
|
12811
12827
|
}
|
|
12812
12828
|
if (targetIndex >= 0) {
|
|
12813
12829
|
// Remove the assistant message and all messages after it
|
|
12814
|
-
_this1.
|
|
12830
|
+
_this1.messages = _this1.messages.slice(0, targetIndex);
|
|
12815
12831
|
}
|
|
12816
12832
|
return _this1.makeRequest(_object_spread({
|
|
12817
12833
|
trigger: 'regenerate-message',
|
|
@@ -12826,23 +12842,10 @@
|
|
|
12826
12842
|
if (!_this.transport) {
|
|
12827
12843
|
return Promise.reject(new Error('Transport is required for resuming stream. Please provide a transport when initializing the chat.'));
|
|
12828
12844
|
}
|
|
12829
|
-
_this.
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
chatId: _this.id
|
|
12834
|
-
}, options)).then(function(stream) {
|
|
12835
|
-
if (stream) {
|
|
12836
|
-
return _this.processStreamWithCallbacks(stream);
|
|
12837
|
-
} else {
|
|
12838
|
-
_this.setStatus({
|
|
12839
|
-
status: 'ready'
|
|
12840
|
-
});
|
|
12841
|
-
return Promise.resolve();
|
|
12842
|
-
}
|
|
12843
|
-
}, function(error) {
|
|
12844
|
-
_this.handleError(error);
|
|
12845
|
-
return Promise.resolve();
|
|
12845
|
+
return _this.consume(function() {
|
|
12846
|
+
return _this.transport.reconnectToStream(_object_spread({
|
|
12847
|
+
chatId: _this.id
|
|
12848
|
+
}, options));
|
|
12846
12849
|
});
|
|
12847
12850
|
});
|
|
12848
12851
|
});
|
|
@@ -12858,53 +12861,57 @@
|
|
|
12858
12861
|
});
|
|
12859
12862
|
/**
|
|
12860
12863
|
* Add a tool result for a tool call.
|
|
12861
|
-
*/ _define_property(this, "addToolResult", function(
|
|
12862
|
-
|
|
12863
|
-
|
|
12864
|
-
|
|
12865
|
-
|
|
12866
|
-
|
|
12867
|
-
|
|
12868
|
-
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
var message = _this.state.messages[messageIndex];
|
|
12874
|
-
var updatedParts = message.parts.map(function(part) {
|
|
12875
|
-
if ('toolCallId' in part && part.toolCallId === toolCallId && 'state' in part) {
|
|
12876
|
-
return _object_spread_props(_object_spread({}, part), {
|
|
12877
|
-
state: 'output-available',
|
|
12878
|
-
output: output
|
|
12879
|
-
});
|
|
12880
|
-
}
|
|
12881
|
-
return part;
|
|
12882
|
-
});
|
|
12883
|
-
_this.state.replaceMessage(messageIndex, _object_spread_props(_object_spread({}, message), {
|
|
12884
|
-
parts: updatedParts
|
|
12885
|
-
}));
|
|
12886
|
-
// Check if we should auto-send based on sendAutomaticallyWhen
|
|
12887
|
-
if (_this.sendAutomaticallyWhen) {
|
|
12888
|
-
return Promise.resolve(_this.sendAutomaticallyWhen({
|
|
12889
|
-
messages: _this.state.messages
|
|
12890
|
-
})).then(function(shouldSend) {
|
|
12891
|
-
if (shouldSend) {
|
|
12892
|
-
return _this.makeRequest({
|
|
12893
|
-
trigger: 'submit-message'
|
|
12894
|
-
});
|
|
12895
|
-
}
|
|
12896
|
-
return Promise.resolve();
|
|
12864
|
+
*/ _define_property(this, "addToolResult", function(options) {
|
|
12865
|
+
if (!_this.acceptsIdentifierOnlyToolResults) {
|
|
12866
|
+
return Promise.resolve();
|
|
12867
|
+
}
|
|
12868
|
+
var owners = _this.responsesByToolCallId.get(options.toolCallId);
|
|
12869
|
+
var response = (owners === null || owners === void 0 ? void 0 : owners.size) === 1 ? owners.values().next().value : undefined;
|
|
12870
|
+
if (response) return _this.submitToolResult(response, options);
|
|
12871
|
+
var findMatchingMessage = function findMatchingMessage() {
|
|
12872
|
+
var matchingMessages = _this.messages.filter(function(message) {
|
|
12873
|
+
var _message_parts;
|
|
12874
|
+
return (_message_parts = message.parts) === null || _message_parts === void 0 ? void 0 : _message_parts.some(function(part) {
|
|
12875
|
+
return 'toolCallId' in part && part.toolCallId === options.toolCallId;
|
|
12897
12876
|
});
|
|
12877
|
+
});
|
|
12878
|
+
return matchingMessages.length === 1 ? matchingMessages[0] : undefined;
|
|
12879
|
+
};
|
|
12880
|
+
if (!findMatchingMessage()) return Promise.resolve();
|
|
12881
|
+
return _this.jobExecutor.run(function() {
|
|
12882
|
+
if (!_this.acceptsIdentifierOnlyToolResults) return Promise.resolve();
|
|
12883
|
+
var message = findMatchingMessage();
|
|
12884
|
+
if (!message || !_this.commit(options.toolCallId, options.output, message.id, undefined, message)) {
|
|
12885
|
+
return Promise.resolve();
|
|
12898
12886
|
}
|
|
12899
|
-
return
|
|
12887
|
+
return _this.continueResponse();
|
|
12900
12888
|
});
|
|
12901
12889
|
});
|
|
12890
|
+
_define_property(this, _computedKey1$1, function(message, options) {
|
|
12891
|
+
var hasToolCall = function hasToolCall(candidate) {
|
|
12892
|
+
var _candidate_parts;
|
|
12893
|
+
return ((_candidate_parts = candidate.parts) === null || _candidate_parts === void 0 ? void 0 : _candidate_parts.some(function(part) {
|
|
12894
|
+
return 'toolCallId' in part && part.toolCallId === options.toolCallId;
|
|
12895
|
+
})) === true;
|
|
12896
|
+
};
|
|
12897
|
+
if (!hasToolCall(message)) {
|
|
12898
|
+
return Promise.resolve();
|
|
12899
|
+
}
|
|
12900
|
+
var response = _this.responseByMessage.get(message);
|
|
12901
|
+
var currentMessage = _this.messages.includes(message) ? message : response && !response.isRetired ? _this.messages.find(function(candidate) {
|
|
12902
|
+
return candidate.id === message.id && _this.responseByMessage.get(candidate) === response && hasToolCall(candidate);
|
|
12903
|
+
}) : undefined;
|
|
12904
|
+
if (!currentMessage) return Promise.resolve();
|
|
12905
|
+
return _this.submitToolResult(response, options, currentMessage.id, currentMessage);
|
|
12906
|
+
});
|
|
12902
12907
|
/**
|
|
12903
12908
|
* Abort the current request immediately, keep the generated tokens if any.
|
|
12904
12909
|
*/ _define_property(this, "stop", function() {
|
|
12905
12910
|
if (_this.activeResponse) {
|
|
12906
|
-
_this.activeResponse
|
|
12911
|
+
var response = _this.activeResponse;
|
|
12912
|
+
response.outcome = 'aborted';
|
|
12907
12913
|
_this.activeResponse = null;
|
|
12914
|
+
response.abortController.abort();
|
|
12908
12915
|
}
|
|
12909
12916
|
_this.setStatus({
|
|
12910
12917
|
status: 'ready'
|
|
@@ -12966,6 +12973,14 @@
|
|
|
12966
12973
|
* context.
|
|
12967
12974
|
*/ key: "resetConversationId",
|
|
12968
12975
|
value: function resetConversationId() {
|
|
12976
|
+
if (this.responsesByToolCallId.size > 0 || this.messages.some(function(message) {
|
|
12977
|
+
var _message_parts;
|
|
12978
|
+
return (_message_parts = message.parts) === null || _message_parts === void 0 ? void 0 : _message_parts.some(function(part) {
|
|
12979
|
+
return 'toolCallId' in part;
|
|
12980
|
+
});
|
|
12981
|
+
})) {
|
|
12982
|
+
this.acceptsIdentifierOnlyToolResults = false;
|
|
12983
|
+
}
|
|
12969
12984
|
this.conversationId = this.generateId();
|
|
12970
12985
|
}
|
|
12971
12986
|
},
|
|
@@ -12975,7 +12990,93 @@
|
|
|
12975
12990
|
return this.state.messages;
|
|
12976
12991
|
},
|
|
12977
12992
|
set: function set(messages) {
|
|
12993
|
+
var _this = this;
|
|
12994
|
+
var getToolOccurrences = function getToolOccurrences(message) {
|
|
12995
|
+
return message.parts.filter(function(part) {
|
|
12996
|
+
return 'toolCallId' in part;
|
|
12997
|
+
}).map(function(part) {
|
|
12998
|
+
return {
|
|
12999
|
+
type: part.type,
|
|
13000
|
+
toolCallId: part.toolCallId,
|
|
13001
|
+
state: 'state' in part ? part.state : undefined,
|
|
13002
|
+
input: 'input' in part ? part.input : undefined,
|
|
13003
|
+
output: 'output' in part ? part.output : undefined,
|
|
13004
|
+
errorText: 'errorText' in part ? part.errorText : undefined,
|
|
13005
|
+
providerExecuted: 'providerExecuted' in part ? part.providerExecuted : undefined
|
|
13006
|
+
};
|
|
13007
|
+
});
|
|
13008
|
+
};
|
|
13009
|
+
var isEquivalentRehydration = function isEquivalentRehydration(message) {
|
|
13010
|
+
var replacements = messages.filter(function(candidate) {
|
|
13011
|
+
return candidate.id === message.id;
|
|
13012
|
+
});
|
|
13013
|
+
if (replacements.length !== 1) return false;
|
|
13014
|
+
var toolOccurrences = getToolOccurrences(message);
|
|
13015
|
+
var replacementToolOccurrences = getToolOccurrences(replacements[0]);
|
|
13016
|
+
return toolOccurrences.length > 0 || replacementToolOccurrences.length > 0 ? isEqual(toolOccurrences, replacementToolOccurrences) : isEqual(message.parts, replacements[0].parts);
|
|
13017
|
+
};
|
|
13018
|
+
var detachedResponses = new Set();
|
|
13019
|
+
this.state.messages.forEach(function(message) {
|
|
13020
|
+
if (!messages.includes(message)) {
|
|
13021
|
+
var response = _this.responseByMessage.get(message);
|
|
13022
|
+
if (response && !isEquivalentRehydration(message)) {
|
|
13023
|
+
detachedResponses.add(response);
|
|
13024
|
+
}
|
|
13025
|
+
}
|
|
13026
|
+
});
|
|
13027
|
+
var removedToolOwner = this.state.messages.some(function(message) {
|
|
13028
|
+
var _message_parts;
|
|
13029
|
+
return ((_message_parts = message.parts) === null || _message_parts === void 0 ? void 0 : _message_parts.some(function(part) {
|
|
13030
|
+
return 'toolCallId' in part;
|
|
13031
|
+
})) && !messages.includes(message) && !isEquivalentRehydration(message);
|
|
13032
|
+
});
|
|
13033
|
+
var toolCallIds = new Set();
|
|
13034
|
+
var hasDuplicateToolCallId = messages.some(function(message) {
|
|
13035
|
+
var _message_parts;
|
|
13036
|
+
return ((_message_parts = message.parts) === null || _message_parts === void 0 ? void 0 : _message_parts.some(function(part) {
|
|
13037
|
+
if (!('toolCallId' in part)) {
|
|
13038
|
+
return false;
|
|
13039
|
+
}
|
|
13040
|
+
if (toolCallIds.has(part.toolCallId)) {
|
|
13041
|
+
return true;
|
|
13042
|
+
}
|
|
13043
|
+
toolCallIds.add(part.toolCallId);
|
|
13044
|
+
return false;
|
|
13045
|
+
})) === true;
|
|
13046
|
+
});
|
|
13047
|
+
if (removedToolOwner || hasDuplicateToolCallId) {
|
|
13048
|
+
this.acceptsIdentifierOnlyToolResults = false;
|
|
13049
|
+
}
|
|
12978
13050
|
this.state.messages = messages;
|
|
13051
|
+
var retainedMessageIds = new Set(messages.map(function(message) {
|
|
13052
|
+
return message.id;
|
|
13053
|
+
}));
|
|
13054
|
+
var responses = new Set();
|
|
13055
|
+
this.responsesByToolCallId.forEach(function(owners) {
|
|
13056
|
+
owners.forEach(function(response) {
|
|
13057
|
+
return responses.add(response);
|
|
13058
|
+
});
|
|
13059
|
+
});
|
|
13060
|
+
if (this.activeResponse) {
|
|
13061
|
+
responses.add(this.activeResponse);
|
|
13062
|
+
}
|
|
13063
|
+
detachedResponses.forEach(function(response) {
|
|
13064
|
+
responses.add(response);
|
|
13065
|
+
_this.retireResponse(response);
|
|
13066
|
+
});
|
|
13067
|
+
responses.forEach(function(response) {
|
|
13068
|
+
var message = response.messageId ? messages.find(function(candidate) {
|
|
13069
|
+
return candidate.id === response.messageId;
|
|
13070
|
+
}) : undefined;
|
|
13071
|
+
if (message && !response.isRetired && !detachedResponses.has(response)) {
|
|
13072
|
+
_this.responseByMessage.set(message, response);
|
|
13073
|
+
}
|
|
13074
|
+
});
|
|
13075
|
+
responses.forEach(function(response) {
|
|
13076
|
+
if (detachedResponses.has(response) || response.messageId && !retainedMessageIds.has(response.messageId)) {
|
|
13077
|
+
_this.pruneDetachedResponse(response);
|
|
13078
|
+
}
|
|
13079
|
+
});
|
|
12979
13080
|
}
|
|
12980
13081
|
},
|
|
12981
13082
|
{
|
|
@@ -12984,6 +13085,154 @@
|
|
|
12984
13085
|
return this.state.messages[this.state.messages.length - 1];
|
|
12985
13086
|
}
|
|
12986
13087
|
},
|
|
13088
|
+
{
|
|
13089
|
+
key: "replaceMessage",
|
|
13090
|
+
value: function replaceMessage(index, message, response) {
|
|
13091
|
+
var _this_messages_index;
|
|
13092
|
+
this.state.replaceMessage(index, message);
|
|
13093
|
+
var canonicalMessage = (_this_messages_index = this.messages[index]) !== null && _this_messages_index !== void 0 ? _this_messages_index : message;
|
|
13094
|
+
if (response && this.messages.includes(canonicalMessage)) {
|
|
13095
|
+
this.responseByMessage.set(canonicalMessage, response);
|
|
13096
|
+
}
|
|
13097
|
+
return canonicalMessage;
|
|
13098
|
+
}
|
|
13099
|
+
},
|
|
13100
|
+
{
|
|
13101
|
+
key: "commit",
|
|
13102
|
+
value: function commit(toolCallId, output, messageId, response, expectedMessage) {
|
|
13103
|
+
var isTargetPart = function isTargetPart(part) {
|
|
13104
|
+
return 'toolCallId' in part && part.toolCallId === toolCallId;
|
|
13105
|
+
};
|
|
13106
|
+
var messageIndex = this.messages.findIndex(function(message) {
|
|
13107
|
+
return (!messageId || message.id === messageId) && (!expectedMessage || message === expectedMessage) && message.parts.some(isTargetPart);
|
|
13108
|
+
});
|
|
13109
|
+
if (messageIndex === -1) return false;
|
|
13110
|
+
var message = this.messages[messageIndex];
|
|
13111
|
+
var partIndex = message.parts.findIndex(isTargetPart);
|
|
13112
|
+
var part = message.parts[partIndex];
|
|
13113
|
+
if (!('state' in part) || part.state === 'output-available' && !part.preliminary || part.state === 'output-error') {
|
|
13114
|
+
return false;
|
|
13115
|
+
}
|
|
13116
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
13117
|
+
part.preliminary; // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
13118
|
+
part.rawOutput;
|
|
13119
|
+
var committedPart = _object_without_properties(part, [
|
|
13120
|
+
"preliminary",
|
|
13121
|
+
"rawOutput"
|
|
13122
|
+
]);
|
|
13123
|
+
var updatedParts = _to_consumable_array(message.parts);
|
|
13124
|
+
updatedParts[partIndex] = _object_spread_props(_object_spread({}, committedPart), {
|
|
13125
|
+
state: 'output-available',
|
|
13126
|
+
output: output
|
|
13127
|
+
});
|
|
13128
|
+
var updatedMessage = _object_spread_props(_object_spread({}, message), {
|
|
13129
|
+
parts: updatedParts
|
|
13130
|
+
});
|
|
13131
|
+
this.replaceMessage(messageIndex, updatedMessage, response);
|
|
13132
|
+
return true;
|
|
13133
|
+
}
|
|
13134
|
+
},
|
|
13135
|
+
{
|
|
13136
|
+
key: "continueResponse",
|
|
13137
|
+
value: function continueResponse(response) {
|
|
13138
|
+
var _this = this;
|
|
13139
|
+
if (response) {
|
|
13140
|
+
this.pruneDetachedResponse(response);
|
|
13141
|
+
if (response.isRetired || response.outcome !== 'succeeded' || response.requiredToolCallIds.size === 0 || Array.from(response.requiredToolCallIds).some(function(toolCallId) {
|
|
13142
|
+
return !response.resolvedToolCallIds.has(toolCallId);
|
|
13143
|
+
}) || !response.didNotifyFinish || response.didEvaluateContinuation) {
|
|
13144
|
+
return Promise.resolve();
|
|
13145
|
+
}
|
|
13146
|
+
response.didEvaluateContinuation = true;
|
|
13147
|
+
}
|
|
13148
|
+
if (!this.sendAutomaticallyWhen) return Promise.resolve();
|
|
13149
|
+
return Promise.resolve().then(function() {
|
|
13150
|
+
return _this.sendAutomaticallyWhen({
|
|
13151
|
+
messages: _this.messages
|
|
13152
|
+
});
|
|
13153
|
+
}).then(function(shouldSend) {
|
|
13154
|
+
if (response) {
|
|
13155
|
+
_this.pruneDetachedResponse(response);
|
|
13156
|
+
if (response.isRetired) return undefined;
|
|
13157
|
+
}
|
|
13158
|
+
return shouldSend ? _this.makeRequest({
|
|
13159
|
+
trigger: 'submit-message'
|
|
13160
|
+
}) : undefined;
|
|
13161
|
+
}).catch(function(error) {
|
|
13162
|
+
if (response) {
|
|
13163
|
+
_this.pruneDetachedResponse(response);
|
|
13164
|
+
if (response.isRetired) return;
|
|
13165
|
+
_this.handleError(error, {
|
|
13166
|
+
updateState: _this.latestResponse === response
|
|
13167
|
+
});
|
|
13168
|
+
return;
|
|
13169
|
+
}
|
|
13170
|
+
_this.handleError(error);
|
|
13171
|
+
});
|
|
13172
|
+
}
|
|
13173
|
+
},
|
|
13174
|
+
{
|
|
13175
|
+
key: "retireResponse",
|
|
13176
|
+
value: function retireResponse(response) {
|
|
13177
|
+
if (response.isRetired) return;
|
|
13178
|
+
response.isRetired = true;
|
|
13179
|
+
response.didEvaluateContinuation = true;
|
|
13180
|
+
if (this.activeResponse === response) {
|
|
13181
|
+
response.outcome = 'aborted';
|
|
13182
|
+
this.activeResponse = null;
|
|
13183
|
+
response.abortController.abort();
|
|
13184
|
+
this.setStatus({
|
|
13185
|
+
status: 'ready'
|
|
13186
|
+
});
|
|
13187
|
+
}
|
|
13188
|
+
}
|
|
13189
|
+
},
|
|
13190
|
+
{
|
|
13191
|
+
key: "pruneDetachedResponse",
|
|
13192
|
+
value: function pruneDetachedResponse(response) {
|
|
13193
|
+
var _this = this;
|
|
13194
|
+
if (!response.isRetired) {
|
|
13195
|
+
if (!response.messageId || this.messages.some(function(message) {
|
|
13196
|
+
return message.id === response.messageId;
|
|
13197
|
+
})) {
|
|
13198
|
+
return;
|
|
13199
|
+
}
|
|
13200
|
+
this.retireResponse(response);
|
|
13201
|
+
}
|
|
13202
|
+
// Keep a routing tombstone while a callback is running so public
|
|
13203
|
+
// addToolResult calls settle directly instead of entering the executor.
|
|
13204
|
+
if (response.pendingToolCallbacks > 0) return;
|
|
13205
|
+
this.responsesByToolCallId.forEach(function(owners, toolCallId) {
|
|
13206
|
+
owners.delete(response);
|
|
13207
|
+
if (owners.size === 0) {
|
|
13208
|
+
_this.responsesByToolCallId.delete(toolCallId);
|
|
13209
|
+
}
|
|
13210
|
+
});
|
|
13211
|
+
}
|
|
13212
|
+
},
|
|
13213
|
+
{
|
|
13214
|
+
key: "submitToolResult",
|
|
13215
|
+
value: function submitToolResult(response, param) {
|
|
13216
|
+
var _this = this;
|
|
13217
|
+
var toolCallId = param.toolCallId, output = param.output, messageId = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : response === null || response === void 0 ? void 0 : response.messageId, expectedMessage = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : messageId ? this.messages.find(function(message) {
|
|
13218
|
+
return message.id === messageId;
|
|
13219
|
+
}) : undefined;
|
|
13220
|
+
if (response === null || response === void 0 ? void 0 : response.isRetired) return Promise.resolve();
|
|
13221
|
+
var commitResult = function commitResult() {
|
|
13222
|
+
if (!_this.commit(toolCallId, output, messageId, response, expectedMessage)) {
|
|
13223
|
+
return Promise.resolve();
|
|
13224
|
+
}
|
|
13225
|
+
if (response === null || response === void 0 ? void 0 : response.requiredToolCallIds.has(toolCallId)) {
|
|
13226
|
+
response.resolvedToolCallIds.add(toolCallId);
|
|
13227
|
+
}
|
|
13228
|
+
return _this.continueResponse(response);
|
|
13229
|
+
};
|
|
13230
|
+
if (response && (this.activeResponse === response || response.outcome !== 'succeeded' || response.didEvaluateContinuation)) {
|
|
13231
|
+
return commitResult();
|
|
13232
|
+
}
|
|
13233
|
+
return this.jobExecutor.run(commitResult);
|
|
13234
|
+
}
|
|
13235
|
+
},
|
|
12987
13236
|
{
|
|
12988
13237
|
key: "makeRequest",
|
|
12989
13238
|
value: function makeRequest(options) {
|
|
@@ -12991,42 +13240,72 @@
|
|
|
12991
13240
|
if (!this.transport) {
|
|
12992
13241
|
return Promise.reject(new Error('Transport is required for sending messages. Please provide a transport when initializing the chat.'));
|
|
12993
13242
|
}
|
|
12994
|
-
|
|
13243
|
+
return this.consume(function(abortSignal) {
|
|
13244
|
+
return _this.transport.sendMessages({
|
|
13245
|
+
chatId: _this.id,
|
|
13246
|
+
messages: _this.messages,
|
|
13247
|
+
abortSignal: abortSignal,
|
|
13248
|
+
trigger: options.trigger,
|
|
13249
|
+
messageId: options.messageId,
|
|
13250
|
+
headers: options.headers,
|
|
13251
|
+
body: options.body,
|
|
13252
|
+
requestMetadata: options.metadata
|
|
13253
|
+
});
|
|
13254
|
+
});
|
|
13255
|
+
}
|
|
13256
|
+
},
|
|
13257
|
+
{
|
|
13258
|
+
key: "consume",
|
|
13259
|
+
value: function consume(createStream) {
|
|
13260
|
+
var _this = this;
|
|
12995
13261
|
if (this.activeResponse) {
|
|
13262
|
+
this.activeResponse.outcome = 'aborted';
|
|
12996
13263
|
this.activeResponse.abortController.abort();
|
|
12997
13264
|
}
|
|
12998
|
-
var
|
|
12999
|
-
|
|
13000
|
-
|
|
13265
|
+
var response = {
|
|
13266
|
+
abortController: new AbortController(),
|
|
13267
|
+
outcome: 'active',
|
|
13268
|
+
isRetired: false,
|
|
13269
|
+
requiredToolCallIds: new Set(),
|
|
13270
|
+
resolvedToolCallIds: new Set(),
|
|
13271
|
+
returnedToolCallbacks: [],
|
|
13272
|
+
pendingToolCallbacks: 0,
|
|
13273
|
+
didNotifyFinish: false,
|
|
13274
|
+
didEvaluateContinuation: false
|
|
13001
13275
|
};
|
|
13276
|
+
this.activeResponse = response;
|
|
13277
|
+
this.latestResponse = response;
|
|
13002
13278
|
this.setStatus({
|
|
13003
13279
|
status: 'submitted'
|
|
13004
13280
|
});
|
|
13005
|
-
return
|
|
13006
|
-
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
|
|
13010
|
-
|
|
13011
|
-
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
|
|
13015
|
-
_this.activeResponse.stream = stream;
|
|
13016
|
-
return _this.processStreamWithCallbacks(stream);
|
|
13281
|
+
return createStream(response.abortController.signal).then(function(stream) {
|
|
13282
|
+
if (_this.activeResponse === response) {
|
|
13283
|
+
if (stream) return _this.processStream(stream, response);
|
|
13284
|
+
response.outcome = 'succeeded';
|
|
13285
|
+
_this.activeResponse = null;
|
|
13286
|
+
_this.setStatus({
|
|
13287
|
+
status: 'ready'
|
|
13288
|
+
});
|
|
13289
|
+
}
|
|
13290
|
+
return undefined;
|
|
13017
13291
|
}, function(error) {
|
|
13292
|
+
if (_this.activeResponse !== response) return;
|
|
13293
|
+
_this.activeResponse = null;
|
|
13018
13294
|
if (error.name === 'AbortError') {
|
|
13019
|
-
|
|
13020
|
-
|
|
13295
|
+
response.outcome = 'aborted';
|
|
13296
|
+
_this.setStatus({
|
|
13297
|
+
status: 'ready'
|
|
13298
|
+
});
|
|
13299
|
+
} else {
|
|
13300
|
+
response.outcome = 'failed';
|
|
13301
|
+
_this.handleError(error);
|
|
13021
13302
|
}
|
|
13022
|
-
_this.handleError(error);
|
|
13023
|
-
return Promise.resolve();
|
|
13024
13303
|
});
|
|
13025
13304
|
}
|
|
13026
13305
|
},
|
|
13027
13306
|
{
|
|
13028
|
-
key: "
|
|
13029
|
-
value: function
|
|
13307
|
+
key: "processStream",
|
|
13308
|
+
value: function processStream1(stream, response) {
|
|
13030
13309
|
var _this = this;
|
|
13031
13310
|
this.setStatus({
|
|
13032
13311
|
status: 'streaming'
|
|
@@ -13035,26 +13314,135 @@
|
|
|
13035
13314
|
var currentMessage;
|
|
13036
13315
|
var currentMessageIndex = -1;
|
|
13037
13316
|
var isAbort = false;
|
|
13038
|
-
var isDisconnect = false;
|
|
13039
13317
|
var isError = false;
|
|
13040
|
-
// Track current text/reasoning part state
|
|
13041
|
-
var currentTextPartId;
|
|
13042
|
-
var currentReasoningPartId;
|
|
13043
13318
|
var toolRawInputByCallId = {};
|
|
13044
13319
|
var toolRawOutputByCallId = {};
|
|
13045
|
-
|
|
13046
|
-
|
|
13320
|
+
var findToolPart = function findToolPart(toolCallId) {
|
|
13321
|
+
return currentMessage.parts.findIndex(function(part) {
|
|
13322
|
+
return 'toolCallId' in part && part.toolCallId === toolCallId;
|
|
13323
|
+
});
|
|
13324
|
+
};
|
|
13325
|
+
var setPart = function setPart(index, part) {
|
|
13326
|
+
var parts = _to_consumable_array(currentMessage.parts);
|
|
13327
|
+
parts[index < 0 ? parts.length : index] = part;
|
|
13328
|
+
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13329
|
+
parts: parts
|
|
13330
|
+
});
|
|
13331
|
+
currentMessage = _this.replaceMessage(currentMessageIndex, currentMessage, response);
|
|
13332
|
+
};
|
|
13333
|
+
var mergeCallProviderMetadata = function mergeCallProviderMetadata(toolCallId, metadata) {
|
|
13334
|
+
var toolIndex = findToolPart(toolCallId);
|
|
13335
|
+
if (toolIndex < 0) return;
|
|
13336
|
+
var existingPart = currentMessage.parts[toolIndex];
|
|
13337
|
+
setPart(toolIndex, _object_spread_props(_object_spread({}, existingPart), {
|
|
13338
|
+
callProviderMetadata: metadata !== null && metadata !== void 0 ? metadata : existingPart.callProviderMetadata
|
|
13339
|
+
}));
|
|
13340
|
+
};
|
|
13341
|
+
var getCanonicalMessage = function getCanonicalMessage() {
|
|
13342
|
+
var _this_messages_find;
|
|
13343
|
+
return response.messageId ? (_this_messages_find = _this.messages.find(function(message) {
|
|
13344
|
+
return message.id === response.messageId;
|
|
13345
|
+
})) !== null && _this_messages_find !== void 0 ? _this_messages_find : currentMessage : currentMessage;
|
|
13346
|
+
};
|
|
13347
|
+
var notifyFinish = function notifyFinish(param) {
|
|
13348
|
+
var isAbort = param.isAbort, isDisconnect = param.isDisconnect, isError = param.isError, message = param.message, _param_allowRetired = param.allowRetired, allowRetired = _param_allowRetired === void 0 ? false : _param_allowRetired;
|
|
13349
|
+
_this.pruneDetachedResponse(response);
|
|
13350
|
+
if (response.isRetired && !allowRetired || response.didNotifyFinish) {
|
|
13351
|
+
return;
|
|
13352
|
+
}
|
|
13353
|
+
response.didNotifyFinish = true;
|
|
13354
|
+
var canonicalMessage = message !== null && message !== void 0 ? message : getCanonicalMessage();
|
|
13355
|
+
if (_this.onFinish && canonicalMessage) {
|
|
13356
|
+
_this.onFinish({
|
|
13357
|
+
message: canonicalMessage,
|
|
13358
|
+
messages: _this.messages,
|
|
13359
|
+
isAbort: isAbort,
|
|
13360
|
+
isDisconnect: isDisconnect,
|
|
13361
|
+
isError: isError
|
|
13362
|
+
});
|
|
13363
|
+
}
|
|
13364
|
+
};
|
|
13365
|
+
var failToolCall = function failToolCall(reason) {
|
|
13366
|
+
if (response.outcome !== 'active') return;
|
|
13367
|
+
var message = getCanonicalMessage();
|
|
13368
|
+
var wasRetired = response.isRetired;
|
|
13369
|
+
var error = _instanceof(reason, Error) ? reason : new Error(String(reason));
|
|
13370
|
+
response.outcome = 'failed';
|
|
13371
|
+
response.abortController.abort();
|
|
13372
|
+
if (_this.activeResponse === response) {
|
|
13373
|
+
_this.activeResponse = null;
|
|
13374
|
+
_this.handleError(error);
|
|
13375
|
+
}
|
|
13376
|
+
notifyFinish({
|
|
13377
|
+
isAbort: false,
|
|
13378
|
+
isDisconnect: false,
|
|
13379
|
+
isError: true,
|
|
13380
|
+
message: message,
|
|
13381
|
+
allowRetired: !wasRetired
|
|
13382
|
+
});
|
|
13383
|
+
};
|
|
13384
|
+
var acceptServerToolResult = function acceptServerToolResult(toolCallId) {
|
|
13385
|
+
if (response.requiredToolCallIds.has(toolCallId)) {
|
|
13386
|
+
response.resolvedToolCallIds.add(toolCallId);
|
|
13387
|
+
}
|
|
13388
|
+
};
|
|
13047
13389
|
return new Promise(function(resolve) {
|
|
13390
|
+
var finish = function finish(error) {
|
|
13391
|
+
if (response.outcome === 'failed') {
|
|
13392
|
+
resolve();
|
|
13393
|
+
return;
|
|
13394
|
+
}
|
|
13395
|
+
isAbort || (isAbort = response.outcome === 'aborted' || !!error && error.name === 'AbortError');
|
|
13396
|
+
response.outcome = isAbort ? 'aborted' : error ? 'failed' : 'succeeded';
|
|
13397
|
+
if (_this.activeResponse === response) {
|
|
13398
|
+
_this.activeResponse = null;
|
|
13399
|
+
if (error && !isAbort) {
|
|
13400
|
+
_this.handleError(error);
|
|
13401
|
+
} else {
|
|
13402
|
+
_this.setStatus({
|
|
13403
|
+
status: 'ready'
|
|
13404
|
+
});
|
|
13405
|
+
}
|
|
13406
|
+
}
|
|
13407
|
+
notifyFinish({
|
|
13408
|
+
isAbort: isAbort,
|
|
13409
|
+
isDisconnect: !!error && !isAbort,
|
|
13410
|
+
isError: isError
|
|
13411
|
+
});
|
|
13412
|
+
resolve(isAbort || error ? undefined : _this.continueResponse(response));
|
|
13413
|
+
};
|
|
13048
13414
|
processStream(stream, function(chunk) {
|
|
13415
|
+
if (_this.activeResponse !== response || response.isRetired) return;
|
|
13416
|
+
if (currentMessageId) {
|
|
13417
|
+
var canonicalMessageIndex = _this.messages.findIndex(function(message) {
|
|
13418
|
+
return message.id === currentMessageId;
|
|
13419
|
+
});
|
|
13420
|
+
if (canonicalMessageIndex === -1) {
|
|
13421
|
+
_this.pruneDetachedResponse(response);
|
|
13422
|
+
return;
|
|
13423
|
+
}
|
|
13424
|
+
currentMessageIndex = canonicalMessageIndex;
|
|
13425
|
+
currentMessage = _this.messages[canonicalMessageIndex];
|
|
13426
|
+
_this.responseByMessage.set(currentMessage, response);
|
|
13427
|
+
}
|
|
13049
13428
|
switch(chunk.type){
|
|
13050
13429
|
case 'start':
|
|
13051
13430
|
{
|
|
13052
13431
|
currentMessageId = chunk.messageId || _this.generateId();
|
|
13432
|
+
response.messageId = currentMessageId;
|
|
13053
13433
|
// Check if we're continuing an existing message or creating a new one
|
|
13054
13434
|
var lastMessage = _this.lastMessage;
|
|
13055
13435
|
if (lastMessage && lastMessage.role === 'assistant' && lastMessage.id === currentMessageId) {
|
|
13056
|
-
|
|
13057
|
-
|
|
13436
|
+
if (lastMessage.parts.some(function(part) {
|
|
13437
|
+
return 'toolCallId' in part;
|
|
13438
|
+
})) {
|
|
13439
|
+
_this.acceptsIdentifierOnlyToolResults = false;
|
|
13440
|
+
}
|
|
13441
|
+
currentMessage = _object_spread_props(_object_spread({}, lastMessage), {
|
|
13442
|
+
parts: _to_consumable_array(lastMessage.parts)
|
|
13443
|
+
});
|
|
13444
|
+
currentMessageIndex = _this.messages.length - 1;
|
|
13445
|
+
currentMessage = _this.replaceMessage(currentMessageIndex, currentMessage, response);
|
|
13058
13446
|
} else {
|
|
13059
13447
|
currentMessage = {
|
|
13060
13448
|
id: currentMessageId,
|
|
@@ -13063,123 +13451,60 @@
|
|
|
13063
13451
|
metadata: chunk.messageMetadata
|
|
13064
13452
|
};
|
|
13065
13453
|
_this.state.pushMessage(currentMessage);
|
|
13066
|
-
currentMessageIndex = _this.
|
|
13454
|
+
currentMessageIndex = _this.messages.length - 1;
|
|
13455
|
+
_this.responseByMessage.set(currentMessage, response);
|
|
13067
13456
|
}
|
|
13068
13457
|
break;
|
|
13069
13458
|
}
|
|
13070
13459
|
case 'text-start':
|
|
13460
|
+
case 'reasoning-start':
|
|
13071
13461
|
{
|
|
13072
13462
|
if (!currentMessage) break;
|
|
13073
|
-
|
|
13074
|
-
|
|
13075
|
-
type:
|
|
13463
|
+
var type = chunk.type === 'text-start' ? 'text' : 'reasoning';
|
|
13464
|
+
setPart(-1, {
|
|
13465
|
+
type: type,
|
|
13076
13466
|
text: '',
|
|
13077
13467
|
state: 'streaming',
|
|
13078
13468
|
providerMetadata: chunk.providerMetadata
|
|
13079
|
-
};
|
|
13080
|
-
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13081
|
-
parts: _to_consumable_array(currentMessage.parts).concat([
|
|
13082
|
-
textPart
|
|
13083
|
-
])
|
|
13084
13469
|
});
|
|
13085
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13086
13470
|
break;
|
|
13087
13471
|
}
|
|
13088
13472
|
case 'text-delta':
|
|
13473
|
+
case 'reasoning-delta':
|
|
13089
13474
|
{
|
|
13090
|
-
|
|
13091
|
-
|
|
13092
|
-
|
|
13475
|
+
var type1 = chunk.type === 'text-delta' ? 'text' : 'reasoning';
|
|
13476
|
+
if (!currentMessage) break;
|
|
13477
|
+
var partIndex = currentMessage.parts.findIndex(function(part) {
|
|
13478
|
+
return part.type === type1 && part.state === 'streaming';
|
|
13093
13479
|
});
|
|
13094
13480
|
if (partIndex === -1) break;
|
|
13095
|
-
var
|
|
13096
|
-
|
|
13097
|
-
|
|
13098
|
-
|
|
13099
|
-
});
|
|
13100
|
-
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13101
|
-
parts: updatedParts
|
|
13102
|
-
});
|
|
13103
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13481
|
+
var part = currentMessage.parts[partIndex];
|
|
13482
|
+
setPart(partIndex, _object_spread_props(_object_spread({}, part), {
|
|
13483
|
+
text: part.text + chunk.delta
|
|
13484
|
+
}));
|
|
13104
13485
|
break;
|
|
13105
13486
|
}
|
|
13106
13487
|
case 'text-end':
|
|
13107
|
-
{
|
|
13108
|
-
if (!currentMessage) break;
|
|
13109
|
-
var partIndex1 = currentMessage.parts.findIndex(function(p) {
|
|
13110
|
-
return p.type === 'text' && p.state === 'streaming';
|
|
13111
|
-
});
|
|
13112
|
-
if (partIndex1 === -1) break;
|
|
13113
|
-
var updatedParts1 = _to_consumable_array(currentMessage.parts);
|
|
13114
|
-
var textPart2 = updatedParts1[partIndex1];
|
|
13115
|
-
updatedParts1[partIndex1] = _object_spread_props(_object_spread({}, textPart2), {
|
|
13116
|
-
state: 'done'
|
|
13117
|
-
});
|
|
13118
|
-
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13119
|
-
parts: updatedParts1
|
|
13120
|
-
});
|
|
13121
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13122
|
-
currentTextPartId = undefined;
|
|
13123
|
-
break;
|
|
13124
|
-
}
|
|
13125
|
-
case 'reasoning-start':
|
|
13126
|
-
{
|
|
13127
|
-
if (!currentMessage) break;
|
|
13128
|
-
currentReasoningPartId = chunk.id;
|
|
13129
|
-
var reasoningPart = {
|
|
13130
|
-
type: 'reasoning',
|
|
13131
|
-
text: '',
|
|
13132
|
-
state: 'streaming',
|
|
13133
|
-
providerMetadata: chunk.providerMetadata
|
|
13134
|
-
};
|
|
13135
|
-
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13136
|
-
parts: _to_consumable_array(currentMessage.parts).concat([
|
|
13137
|
-
reasoningPart
|
|
13138
|
-
])
|
|
13139
|
-
});
|
|
13140
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13141
|
-
break;
|
|
13142
|
-
}
|
|
13143
|
-
case 'reasoning-delta':
|
|
13144
|
-
{
|
|
13145
|
-
if (!currentMessage || !currentReasoningPartId) break;
|
|
13146
|
-
var partIndex2 = currentMessage.parts.findIndex(function(p) {
|
|
13147
|
-
return p.type === 'reasoning' && p.state === 'streaming';
|
|
13148
|
-
});
|
|
13149
|
-
if (partIndex2 === -1) break;
|
|
13150
|
-
var updatedParts2 = _to_consumable_array(currentMessage.parts);
|
|
13151
|
-
var reasoningPart1 = updatedParts2[partIndex2];
|
|
13152
|
-
updatedParts2[partIndex2] = _object_spread_props(_object_spread({}, reasoningPart1), {
|
|
13153
|
-
text: reasoningPart1.text + chunk.delta
|
|
13154
|
-
});
|
|
13155
|
-
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13156
|
-
parts: updatedParts2
|
|
13157
|
-
});
|
|
13158
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13159
|
-
break;
|
|
13160
|
-
}
|
|
13161
13488
|
case 'reasoning-end':
|
|
13162
13489
|
{
|
|
13163
13490
|
if (!currentMessage) break;
|
|
13164
|
-
var
|
|
13165
|
-
|
|
13491
|
+
var type2 = chunk.type === 'text-end' ? 'text' : 'reasoning';
|
|
13492
|
+
var partIndex1 = currentMessage.parts.findIndex(function(part) {
|
|
13493
|
+
return part.type === type2 && part.state === 'streaming';
|
|
13166
13494
|
});
|
|
13167
|
-
if (
|
|
13168
|
-
|
|
13169
|
-
var reasoningPart2 = updatedParts3[partIndex3];
|
|
13170
|
-
updatedParts3[partIndex3] = _object_spread_props(_object_spread({}, reasoningPart2), {
|
|
13495
|
+
if (partIndex1 === -1) break;
|
|
13496
|
+
setPart(partIndex1, _object_spread_props(_object_spread({}, currentMessage.parts[partIndex1]), {
|
|
13171
13497
|
state: 'done'
|
|
13172
|
-
});
|
|
13173
|
-
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13174
|
-
parts: updatedParts3
|
|
13175
|
-
});
|
|
13176
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13177
|
-
currentReasoningPartId = undefined;
|
|
13498
|
+
}));
|
|
13178
13499
|
break;
|
|
13179
13500
|
}
|
|
13180
13501
|
case 'tool-input-start':
|
|
13181
13502
|
{
|
|
13182
13503
|
if (!currentMessage) break;
|
|
13504
|
+
var completedPart = currentMessage.parts.find(function(part) {
|
|
13505
|
+
return 'toolCallId' in part && part.toolCallId === chunk.toolCallId && 'state' in part && (part.state === 'output-available' || part.state === 'output-error');
|
|
13506
|
+
});
|
|
13507
|
+
if (completedPart) break;
|
|
13183
13508
|
var initialRawInput = typeof chunk.input === 'string' ? chunk.input : chunk.input !== undefined ? JSON.stringify(chunk.input) : '';
|
|
13184
13509
|
toolRawInputByCallId[chunk.toolCallId] = initialRawInput;
|
|
13185
13510
|
var toolPart = {
|
|
@@ -13190,12 +13515,7 @@
|
|
|
13190
13515
|
rawInput: initialRawInput || undefined,
|
|
13191
13516
|
providerExecuted: chunk.providerExecuted
|
|
13192
13517
|
};
|
|
13193
|
-
|
|
13194
|
-
parts: _to_consumable_array(currentMessage.parts).concat([
|
|
13195
|
-
toolPart
|
|
13196
|
-
])
|
|
13197
|
-
});
|
|
13198
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13518
|
+
setPart(-1, toolPart);
|
|
13199
13519
|
break;
|
|
13200
13520
|
}
|
|
13201
13521
|
case 'tool-input-delta':
|
|
@@ -13203,10 +13523,11 @@
|
|
|
13203
13523
|
var _ref, _ref1, _chunk_toolName, _ref2;
|
|
13204
13524
|
var _existingPart_type, _this_shouldRepairToolInput, _this1;
|
|
13205
13525
|
if (!currentMessage) break;
|
|
13206
|
-
var toolIndex =
|
|
13207
|
-
return 'toolCallId' in p && p.toolCallId === chunk.toolCallId;
|
|
13208
|
-
});
|
|
13526
|
+
var toolIndex = findToolPart(chunk.toolCallId);
|
|
13209
13527
|
var existingPart = toolIndex >= 0 ? currentMessage.parts[toolIndex] : null;
|
|
13528
|
+
if ((existingPart === null || existingPart === void 0 ? void 0 : existingPart.state) === 'output-available' || (existingPart === null || existingPart === void 0 ? void 0 : existingPart.state) === 'output-error') {
|
|
13529
|
+
break;
|
|
13530
|
+
}
|
|
13210
13531
|
var previousRawInput = (_ref = (_ref1 = existingPart === null || existingPart === void 0 ? void 0 : existingPart.rawInput) !== null && _ref1 !== void 0 ? _ref1 : toolRawInputByCallId[chunk.toolCallId]) !== null && _ref !== void 0 ? _ref : '';
|
|
13211
13532
|
var nextRawInput = "".concat(previousRawInput).concat(chunk.inputTextDelta);
|
|
13212
13533
|
toolRawInputByCallId[chunk.toolCallId] = nextRawInput;
|
|
@@ -13221,30 +13542,20 @@
|
|
|
13221
13542
|
input: parsedInput,
|
|
13222
13543
|
rawInput: nextRawInput
|
|
13223
13544
|
});
|
|
13224
|
-
|
|
13225
|
-
var updatedParts4 = _to_consumable_array(currentMessage.parts);
|
|
13226
|
-
updatedParts4[toolIndex] = nextToolPart;
|
|
13227
|
-
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13228
|
-
parts: updatedParts4
|
|
13229
|
-
});
|
|
13230
|
-
} else {
|
|
13231
|
-
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13232
|
-
parts: _to_consumable_array(currentMessage.parts).concat([
|
|
13233
|
-
nextToolPart
|
|
13234
|
-
])
|
|
13235
|
-
});
|
|
13236
|
-
}
|
|
13237
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13545
|
+
setPart(toolIndex, nextToolPart);
|
|
13238
13546
|
break;
|
|
13239
13547
|
}
|
|
13240
13548
|
case 'tool-input-available':
|
|
13241
13549
|
{
|
|
13242
13550
|
if (!currentMessage) break;
|
|
13551
|
+
if (response.requiredToolCallIds.has(chunk.toolCallId)) break;
|
|
13243
13552
|
delete toolRawInputByCallId[chunk.toolCallId];
|
|
13244
13553
|
// Find existing tool part or create new one
|
|
13245
|
-
var existingIndex =
|
|
13246
|
-
|
|
13247
|
-
|
|
13554
|
+
var existingIndex = findToolPart(chunk.toolCallId);
|
|
13555
|
+
var existingPart1 = existingIndex >= 0 ? currentMessage.parts[existingIndex] : null;
|
|
13556
|
+
if ((existingPart1 === null || existingPart1 === void 0 ? void 0 : existingPart1.state) === 'output-available' || (existingPart1 === null || existingPart1 === void 0 ? void 0 : existingPart1.state) === 'output-error') {
|
|
13557
|
+
break;
|
|
13558
|
+
}
|
|
13248
13559
|
var toolPart1 = {
|
|
13249
13560
|
type: "tool-".concat(chunk.toolName),
|
|
13250
13561
|
toolCallId: chunk.toolCallId,
|
|
@@ -13253,35 +13564,63 @@
|
|
|
13253
13564
|
callProviderMetadata: chunk.callProviderMetadata,
|
|
13254
13565
|
providerExecuted: chunk.providerExecuted
|
|
13255
13566
|
};
|
|
13256
|
-
|
|
13257
|
-
|
|
13258
|
-
|
|
13259
|
-
currentMessage
|
|
13260
|
-
|
|
13261
|
-
});
|
|
13262
|
-
}
|
|
13263
|
-
|
|
13264
|
-
parts: _to_consumable_array(currentMessage.parts).concat([
|
|
13265
|
-
toolPart1
|
|
13266
|
-
])
|
|
13267
|
-
});
|
|
13567
|
+
setPart(existingIndex, toolPart1);
|
|
13568
|
+
if (_this.messages.some(function(message) {
|
|
13569
|
+
var _message_parts;
|
|
13570
|
+
return message !== currentMessage && ((_message_parts = message.parts) === null || _message_parts === void 0 ? void 0 : _message_parts.some(function(part) {
|
|
13571
|
+
return 'toolCallId' in part && part.toolCallId === chunk.toolCallId;
|
|
13572
|
+
}));
|
|
13573
|
+
})) {
|
|
13574
|
+
_this.acceptsIdentifierOnlyToolResults = false;
|
|
13268
13575
|
}
|
|
13269
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13270
13576
|
// Trigger onToolCall callback only for client-executed tools
|
|
13271
13577
|
// (server-executed tools have providerExecuted: true and don't need client handling)
|
|
13272
13578
|
if (_this.onToolCall && !chunk.providerExecuted) {
|
|
13273
|
-
var
|
|
13274
|
-
|
|
13275
|
-
|
|
13276
|
-
|
|
13277
|
-
input: chunk.input,
|
|
13278
|
-
dynamic: 'dynamic' in chunk ? chunk.dynamic : undefined
|
|
13279
|
-
}
|
|
13579
|
+
var _this_responsesByToolCallId_get;
|
|
13580
|
+
var owners = (_this_responsesByToolCallId_get = _this.responsesByToolCallId.get(chunk.toolCallId)) !== null && _this_responsesByToolCallId_get !== void 0 ? _this_responsesByToolCallId_get : new Set();
|
|
13581
|
+
var existingOwners = Array.from(owners).filter(function(owner) {
|
|
13582
|
+
return owner !== response;
|
|
13280
13583
|
});
|
|
13281
|
-
if (
|
|
13282
|
-
|
|
13283
|
-
|
|
13584
|
+
if (existingOwners.length > 0) {
|
|
13585
|
+
_this.acceptsIdentifierOnlyToolResults = false;
|
|
13586
|
+
var conflictingOwner = existingOwners.find(function(owner) {
|
|
13587
|
+
return !owner.isRetired && (owner.outcome === 'active' || owner.outcome === 'succeeded' && (!owner.resolvedToolCallIds.has(chunk.toolCallId) || owner.pendingToolCallbacks > 0));
|
|
13284
13588
|
});
|
|
13589
|
+
if (conflictingOwner) {
|
|
13590
|
+
// Neither response may continue once ownership is ambiguous.
|
|
13591
|
+
conflictingOwner.didEvaluateContinuation = true;
|
|
13592
|
+
failToolCall(new Error('Tool call "'.concat(chunk.toolCallId, '" is already owned by another response.')));
|
|
13593
|
+
break;
|
|
13594
|
+
}
|
|
13595
|
+
}
|
|
13596
|
+
response.requiredToolCallIds.add(chunk.toolCallId);
|
|
13597
|
+
owners.add(response);
|
|
13598
|
+
_this.responsesByToolCallId.set(chunk.toolCallId, owners);
|
|
13599
|
+
response.pendingToolCallbacks++;
|
|
13600
|
+
try {
|
|
13601
|
+
var result = _this.onToolCall({
|
|
13602
|
+
toolCall: {
|
|
13603
|
+
toolName: chunk.toolName,
|
|
13604
|
+
toolCallId: chunk.toolCallId,
|
|
13605
|
+
input: chunk.input,
|
|
13606
|
+
dynamic: 'dynamic' in chunk ? chunk.dynamic : undefined
|
|
13607
|
+
}
|
|
13608
|
+
}, function(options) {
|
|
13609
|
+
return response.isRetired ? Promise.resolve() : _this.submitToolResult(response, options);
|
|
13610
|
+
});
|
|
13611
|
+
if (result) {
|
|
13612
|
+
response.returnedToolCallbacks.push(Promise.resolve(result).catch(failToolCall).then(function() {
|
|
13613
|
+
response.pendingToolCallbacks--;
|
|
13614
|
+
_this.pruneDetachedResponse(response);
|
|
13615
|
+
}));
|
|
13616
|
+
} else {
|
|
13617
|
+
response.pendingToolCallbacks--;
|
|
13618
|
+
_this.pruneDetachedResponse(response);
|
|
13619
|
+
}
|
|
13620
|
+
} catch (error) {
|
|
13621
|
+
response.pendingToolCallbacks--;
|
|
13622
|
+
failToolCall(error);
|
|
13623
|
+
_this.pruneDetachedResponse(response);
|
|
13285
13624
|
}
|
|
13286
13625
|
}
|
|
13287
13626
|
break;
|
|
@@ -13291,15 +13630,14 @@
|
|
|
13291
13630
|
var _ref3, _ref4;
|
|
13292
13631
|
if (!currentMessage) break;
|
|
13293
13632
|
var _chunk_data = chunk.data, toolCallId = _chunk_data.toolCallId, toolName1 = _chunk_data.toolName, delta = _chunk_data.delta;
|
|
13294
|
-
|
|
13295
|
-
|
|
13296
|
-
|
|
13297
|
-
var
|
|
13298
|
-
var previousRawOutput = (_ref3 = (_ref4 = existingPart1 === null || existingPart1 === void 0 ? void 0 : existingPart1.rawOutput) !== null && _ref4 !== void 0 ? _ref4 : toolRawOutputByCallId[toolCallId]) !== null && _ref3 !== void 0 ? _ref3 : '';
|
|
13633
|
+
if (response.resolvedToolCallIds.has(toolCallId)) break;
|
|
13634
|
+
var toolIndex1 = findToolPart(toolCallId);
|
|
13635
|
+
var existingPart2 = toolIndex1 >= 0 ? currentMessage.parts[toolIndex1] : null;
|
|
13636
|
+
var previousRawOutput = (_ref3 = (_ref4 = existingPart2 === null || existingPart2 === void 0 ? void 0 : existingPart2.rawOutput) !== null && _ref4 !== void 0 ? _ref4 : toolRawOutputByCallId[toolCallId]) !== null && _ref3 !== void 0 ? _ref3 : '';
|
|
13299
13637
|
var nextRawOutput = "".concat(previousRawOutput).concat(delta);
|
|
13300
13638
|
toolRawOutputByCallId[toolCallId] = nextRawOutput;
|
|
13301
|
-
var parsedOutput = parseToolInputDelta(nextRawOutput,
|
|
13302
|
-
var nextToolPart1 = _object_spread_props(_object_spread({},
|
|
13639
|
+
var parsedOutput = parseToolInputDelta(nextRawOutput, existingPart2 === null || existingPart2 === void 0 ? void 0 : existingPart2.output);
|
|
13640
|
+
var nextToolPart1 = _object_spread_props(_object_spread({}, existingPart2 !== null && existingPart2 !== void 0 ? existingPart2 : {
|
|
13303
13641
|
type: "tool-".concat(toolName1),
|
|
13304
13642
|
toolCallId: toolCallId,
|
|
13305
13643
|
input: undefined
|
|
@@ -13309,47 +13647,34 @@
|
|
|
13309
13647
|
rawOutput: nextRawOutput,
|
|
13310
13648
|
preliminary: true
|
|
13311
13649
|
});
|
|
13312
|
-
|
|
13313
|
-
var updatedParts6 = _to_consumable_array(currentMessage.parts);
|
|
13314
|
-
updatedParts6[toolIndex1] = nextToolPart1;
|
|
13315
|
-
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13316
|
-
parts: updatedParts6
|
|
13317
|
-
});
|
|
13318
|
-
} else {
|
|
13319
|
-
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13320
|
-
parts: _to_consumable_array(currentMessage.parts).concat([
|
|
13321
|
-
nextToolPart1
|
|
13322
|
-
])
|
|
13323
|
-
});
|
|
13324
|
-
}
|
|
13325
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13650
|
+
setPart(toolIndex1, nextToolPart1);
|
|
13326
13651
|
break;
|
|
13327
13652
|
}
|
|
13328
13653
|
case 'tool-output-available':
|
|
13329
13654
|
{
|
|
13330
13655
|
if (!currentMessage) break;
|
|
13331
|
-
var toolIndex2 =
|
|
13332
|
-
return 'toolCallId' in p && p.toolCallId === chunk.toolCallId;
|
|
13333
|
-
});
|
|
13656
|
+
var toolIndex2 = findToolPart(chunk.toolCallId);
|
|
13334
13657
|
if (toolIndex2 >= 0) {
|
|
13335
13658
|
delete toolRawInputByCallId[chunk.toolCallId];
|
|
13336
13659
|
delete toolRawOutputByCallId[chunk.toolCallId];
|
|
13337
|
-
var
|
|
13338
|
-
|
|
13660
|
+
var existingPart3 = currentMessage.parts[toolIndex2];
|
|
13661
|
+
if (response.resolvedToolCallIds.has(chunk.toolCallId)) {
|
|
13662
|
+
mergeCallProviderMetadata(chunk.toolCallId, chunk.callProviderMetadata);
|
|
13663
|
+
break;
|
|
13664
|
+
}
|
|
13339
13665
|
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
13340
|
-
var _ignored =
|
|
13666
|
+
var _ignored = existingPart3.rawOutput, rest = _object_without_properties(existingPart3, [
|
|
13341
13667
|
"rawOutput"
|
|
13342
13668
|
]);
|
|
13343
|
-
|
|
13669
|
+
setPart(toolIndex2, _object_spread_props(_object_spread({}, rest), {
|
|
13344
13670
|
state: 'output-available',
|
|
13345
13671
|
output: chunk.output,
|
|
13346
13672
|
callProviderMetadata: chunk.callProviderMetadata,
|
|
13347
13673
|
preliminary: chunk.preliminary
|
|
13348
|
-
});
|
|
13349
|
-
|
|
13350
|
-
|
|
13351
|
-
}
|
|
13352
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13674
|
+
}));
|
|
13675
|
+
if (!chunk.preliminary) {
|
|
13676
|
+
acceptServerToolResult(chunk.toolCallId);
|
|
13677
|
+
}
|
|
13353
13678
|
}
|
|
13354
13679
|
break;
|
|
13355
13680
|
}
|
|
@@ -13357,13 +13682,15 @@
|
|
|
13357
13682
|
{
|
|
13358
13683
|
var _chunk_input, _chunk_providerExecuted, _chunk_providerMetadata;
|
|
13359
13684
|
if (!currentMessage) break;
|
|
13685
|
+
if (response.resolvedToolCallIds.has(chunk.toolCallId)) {
|
|
13686
|
+
mergeCallProviderMetadata(chunk.toolCallId, chunk.providerMetadata);
|
|
13687
|
+
break;
|
|
13688
|
+
}
|
|
13360
13689
|
delete toolRawInputByCallId[chunk.toolCallId];
|
|
13361
13690
|
delete toolRawOutputByCallId[chunk.toolCallId];
|
|
13362
|
-
var toolIndex3 =
|
|
13363
|
-
|
|
13364
|
-
}
|
|
13365
|
-
var existingPart3 = toolIndex3 >= 0 ? currentMessage.parts[toolIndex3] : null;
|
|
13366
|
-
var _ref5 = existingPart3 !== null && existingPart3 !== void 0 ? existingPart3 : {}, _ignoredOutput = _ref5.output, _ignoredRawOutput = _ref5.rawOutput, _ignoredPreliminary = _ref5.preliminary, carryOver = _object_without_properties(_ref5, [
|
|
13691
|
+
var toolIndex3 = findToolPart(chunk.toolCallId);
|
|
13692
|
+
var existingPart4 = toolIndex3 >= 0 ? currentMessage.parts[toolIndex3] : null;
|
|
13693
|
+
var _ref5 = existingPart4 !== null && existingPart4 !== void 0 ? existingPart4 : {}, _ignoredOutput = _ref5.output, _ignoredRawOutput = _ref5.rawOutput, _ignoredPreliminary = _ref5.preliminary, carryOver = _object_without_properties(_ref5, [
|
|
13367
13694
|
"output",
|
|
13368
13695
|
"rawOutput",
|
|
13369
13696
|
"preliminary"
|
|
@@ -13378,49 +13705,35 @@
|
|
|
13378
13705
|
providerExecuted: (_chunk_providerExecuted = chunk.providerExecuted) !== null && _chunk_providerExecuted !== void 0 ? _chunk_providerExecuted : carryOver.providerExecuted,
|
|
13379
13706
|
callProviderMetadata: (_chunk_providerMetadata = chunk.providerMetadata) !== null && _chunk_providerMetadata !== void 0 ? _chunk_providerMetadata : carryOver.callProviderMetadata
|
|
13380
13707
|
});
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
updatedParts8[toolIndex3] = nextToolPart2;
|
|
13384
|
-
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13385
|
-
parts: updatedParts8
|
|
13386
|
-
});
|
|
13387
|
-
} else {
|
|
13388
|
-
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13389
|
-
parts: _to_consumable_array(currentMessage.parts).concat([
|
|
13390
|
-
nextToolPart2
|
|
13391
|
-
])
|
|
13392
|
-
});
|
|
13393
|
-
}
|
|
13394
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13708
|
+
setPart(toolIndex3, nextToolPart2);
|
|
13709
|
+
acceptServerToolResult(chunk.toolCallId);
|
|
13395
13710
|
break;
|
|
13396
13711
|
}
|
|
13397
13712
|
case 'tool-output-error':
|
|
13398
13713
|
{
|
|
13399
13714
|
var _chunk_providerExecuted1, _chunk_providerMetadata1;
|
|
13400
13715
|
if (!currentMessage) break;
|
|
13401
|
-
|
|
13402
|
-
|
|
13403
|
-
|
|
13716
|
+
if (response.resolvedToolCallIds.has(chunk.toolCallId)) {
|
|
13717
|
+
mergeCallProviderMetadata(chunk.toolCallId, chunk.providerMetadata);
|
|
13718
|
+
break;
|
|
13719
|
+
}
|
|
13720
|
+
var toolIndex4 = findToolPart(chunk.toolCallId);
|
|
13404
13721
|
if (toolIndex4 < 0) break;
|
|
13405
13722
|
delete toolRawInputByCallId[chunk.toolCallId];
|
|
13406
13723
|
delete toolRawOutputByCallId[chunk.toolCallId];
|
|
13407
|
-
var
|
|
13408
|
-
var
|
|
13409
|
-
var _ignoredRawOutput1 = existingPart4.rawOutput, _ignoredPreliminary1 = existingPart4.preliminary, _ignoredOutput1 = existingPart4.output, rest1 = _object_without_properties(existingPart4, [
|
|
13724
|
+
var existingPart5 = currentMessage.parts[toolIndex4];
|
|
13725
|
+
var _ignoredRawOutput1 = existingPart5.rawOutput, _ignoredPreliminary1 = existingPart5.preliminary, _ignoredOutput1 = existingPart5.output, rest1 = _object_without_properties(existingPart5, [
|
|
13410
13726
|
"rawOutput",
|
|
13411
13727
|
"preliminary",
|
|
13412
13728
|
"output"
|
|
13413
13729
|
]);
|
|
13414
|
-
|
|
13730
|
+
setPart(toolIndex4, _object_spread_props(_object_spread({}, rest1), {
|
|
13415
13731
|
state: 'output-error',
|
|
13416
13732
|
errorText: chunk.errorText,
|
|
13417
13733
|
providerExecuted: (_chunk_providerExecuted1 = chunk.providerExecuted) !== null && _chunk_providerExecuted1 !== void 0 ? _chunk_providerExecuted1 : rest1.providerExecuted,
|
|
13418
13734
|
callProviderMetadata: (_chunk_providerMetadata1 = chunk.providerMetadata) !== null && _chunk_providerMetadata1 !== void 0 ? _chunk_providerMetadata1 : rest1.callProviderMetadata
|
|
13419
|
-
});
|
|
13420
|
-
|
|
13421
|
-
parts: updatedParts9
|
|
13422
|
-
});
|
|
13423
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13735
|
+
}));
|
|
13736
|
+
acceptServerToolResult(chunk.toolCallId);
|
|
13424
13737
|
break;
|
|
13425
13738
|
}
|
|
13426
13739
|
case 'source-url':
|
|
@@ -13432,12 +13745,7 @@
|
|
|
13432
13745
|
url: chunk.url,
|
|
13433
13746
|
title: chunk.title
|
|
13434
13747
|
};
|
|
13435
|
-
|
|
13436
|
-
parts: _to_consumable_array(currentMessage.parts).concat([
|
|
13437
|
-
sourcePart
|
|
13438
|
-
])
|
|
13439
|
-
});
|
|
13440
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13748
|
+
setPart(-1, sourcePart);
|
|
13441
13749
|
break;
|
|
13442
13750
|
}
|
|
13443
13751
|
case 'source-document':
|
|
@@ -13451,12 +13759,7 @@
|
|
|
13451
13759
|
filename: chunk.filename,
|
|
13452
13760
|
providerMetadata: chunk.providerMetadata
|
|
13453
13761
|
};
|
|
13454
|
-
|
|
13455
|
-
parts: _to_consumable_array(currentMessage.parts).concat([
|
|
13456
|
-
docPart
|
|
13457
|
-
])
|
|
13458
|
-
});
|
|
13459
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13762
|
+
setPart(-1, docPart);
|
|
13460
13763
|
break;
|
|
13461
13764
|
}
|
|
13462
13765
|
case 'file':
|
|
@@ -13467,26 +13770,15 @@
|
|
|
13467
13770
|
url: chunk.url,
|
|
13468
13771
|
mediaType: chunk.mediaType
|
|
13469
13772
|
};
|
|
13470
|
-
|
|
13471
|
-
parts: _to_consumable_array(currentMessage.parts).concat([
|
|
13472
|
-
filePart
|
|
13473
|
-
])
|
|
13474
|
-
});
|
|
13475
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13773
|
+
setPart(-1, filePart);
|
|
13476
13774
|
break;
|
|
13477
13775
|
}
|
|
13478
13776
|
case 'start-step':
|
|
13479
13777
|
{
|
|
13480
13778
|
if (!currentMessage) break;
|
|
13481
|
-
|
|
13779
|
+
setPart(-1, {
|
|
13482
13780
|
type: 'step-start'
|
|
13483
|
-
};
|
|
13484
|
-
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13485
|
-
parts: _to_consumable_array(currentMessage.parts).concat([
|
|
13486
|
-
stepPart
|
|
13487
|
-
])
|
|
13488
13781
|
});
|
|
13489
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13490
13782
|
break;
|
|
13491
13783
|
}
|
|
13492
13784
|
case 'message-metadata':
|
|
@@ -13495,7 +13787,7 @@
|
|
|
13495
13787
|
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13496
13788
|
metadata: chunk.messageMetadata
|
|
13497
13789
|
});
|
|
13498
|
-
_this.
|
|
13790
|
+
currentMessage = _this.replaceMessage(currentMessageIndex, currentMessage, response);
|
|
13499
13791
|
break;
|
|
13500
13792
|
}
|
|
13501
13793
|
case 'error':
|
|
@@ -13515,7 +13807,7 @@
|
|
|
13515
13807
|
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13516
13808
|
metadata: chunk.messageMetadata
|
|
13517
13809
|
});
|
|
13518
|
-
_this.
|
|
13810
|
+
currentMessage = _this.replaceMessage(currentMessageIndex, currentMessage, response);
|
|
13519
13811
|
}
|
|
13520
13812
|
break;
|
|
13521
13813
|
}
|
|
@@ -13541,14 +13833,13 @@
|
|
|
13541
13833
|
]
|
|
13542
13834
|
};
|
|
13543
13835
|
if (currentMessageIndex >= 0) {
|
|
13544
|
-
_this.
|
|
13836
|
+
currentMessage = _this.replaceMessage(currentMessageIndex, currentMessage, response);
|
|
13545
13837
|
} else {
|
|
13546
13838
|
_this.state.pushMessage(currentMessage);
|
|
13547
|
-
currentMessageIndex = _this.
|
|
13839
|
+
currentMessageIndex = _this.messages.length - 1;
|
|
13840
|
+
_this.responseByMessage.set(currentMessage, response);
|
|
13548
13841
|
}
|
|
13549
13842
|
currentMessageId = currentMessage.id;
|
|
13550
|
-
currentTextPartId = undefined;
|
|
13551
|
-
currentReasoningPartId = undefined;
|
|
13552
13843
|
break;
|
|
13553
13844
|
}
|
|
13554
13845
|
default:
|
|
@@ -13561,12 +13852,7 @@
|
|
|
13561
13852
|
id: chunk.id,
|
|
13562
13853
|
data: chunk.data
|
|
13563
13854
|
};
|
|
13564
|
-
|
|
13565
|
-
parts: _to_consumable_array(currentMessage.parts).concat([
|
|
13566
|
-
dataPart
|
|
13567
|
-
])
|
|
13568
|
-
});
|
|
13569
|
-
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13855
|
+
setPart(-1, dataPart);
|
|
13570
13856
|
// Trigger onData callback
|
|
13571
13857
|
if (_this.onData) {
|
|
13572
13858
|
_this.onData(dataPart);
|
|
@@ -13575,49 +13861,11 @@
|
|
|
13575
13861
|
}
|
|
13576
13862
|
}
|
|
13577
13863
|
}, function() {
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
// Stream finished successfully
|
|
13581
|
-
_this.setStatus({
|
|
13582
|
-
status: 'ready'
|
|
13583
|
-
});
|
|
13584
|
-
_this.activeResponse = null;
|
|
13585
|
-
// Trigger onFinish callback
|
|
13586
|
-
if (_this.onFinish && currentMessage) {
|
|
13587
|
-
_this.onFinish({
|
|
13588
|
-
message: currentMessage,
|
|
13589
|
-
messages: _this.state.messages,
|
|
13590
|
-
isAbort: isAbort,
|
|
13591
|
-
isDisconnect: isDisconnect,
|
|
13592
|
-
isError: isError
|
|
13593
|
-
});
|
|
13594
|
-
}
|
|
13595
|
-
// Note: sendAutomaticallyWhen is only checked in addToolResult,
|
|
13596
|
-
// not here. For server-executed tools, the server continues the
|
|
13597
|
-
// conversation. For client-executed tools, addToolResult handles it.
|
|
13598
|
-
resolve();
|
|
13864
|
+
return Promise.all(response.returnedToolCallbacks).then(function() {
|
|
13865
|
+
return finish();
|
|
13599
13866
|
});
|
|
13600
13867
|
}, function(error) {
|
|
13601
|
-
|
|
13602
|
-
isAbort = true;
|
|
13603
|
-
_this.setStatus({
|
|
13604
|
-
status: 'ready'
|
|
13605
|
-
});
|
|
13606
|
-
} else {
|
|
13607
|
-
isDisconnect = true;
|
|
13608
|
-
_this.handleError(error);
|
|
13609
|
-
}
|
|
13610
|
-
// Still call onFinish even on error/abort
|
|
13611
|
-
if (_this.onFinish && currentMessage) {
|
|
13612
|
-
_this.onFinish({
|
|
13613
|
-
message: currentMessage,
|
|
13614
|
-
messages: _this.state.messages,
|
|
13615
|
-
isAbort: isAbort,
|
|
13616
|
-
isDisconnect: isDisconnect,
|
|
13617
|
-
isError: isError
|
|
13618
|
-
});
|
|
13619
|
-
}
|
|
13620
|
-
resolve();
|
|
13868
|
+
return finish(error);
|
|
13621
13869
|
});
|
|
13622
13870
|
});
|
|
13623
13871
|
}
|
|
@@ -13625,10 +13873,13 @@
|
|
|
13625
13873
|
{
|
|
13626
13874
|
key: "handleError",
|
|
13627
13875
|
value: function handleError(error) {
|
|
13628
|
-
|
|
13629
|
-
|
|
13630
|
-
|
|
13631
|
-
|
|
13876
|
+
var _ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, _ref_updateState = _ref.updateState, updateState = _ref_updateState === void 0 ? true : _ref_updateState;
|
|
13877
|
+
if (updateState) {
|
|
13878
|
+
this.setStatus({
|
|
13879
|
+
status: 'error',
|
|
13880
|
+
error: error
|
|
13881
|
+
});
|
|
13882
|
+
}
|
|
13632
13883
|
if (this.onError) {
|
|
13633
13884
|
this.onError(error);
|
|
13634
13885
|
}
|
|
@@ -14301,7 +14552,7 @@
|
|
|
14301
14552
|
if (!tool) return true;
|
|
14302
14553
|
return Boolean(tool.streamInput);
|
|
14303
14554
|
},
|
|
14304
|
-
onToolCall: function onToolCall(param) {
|
|
14555
|
+
onToolCall: function onToolCall(param, submitToolResult) {
|
|
14305
14556
|
var toolCall = param.toolCall;
|
|
14306
14557
|
var tool = tools[toolCall.toolName];
|
|
14307
14558
|
// Compatibility shim with Algolia MCP Server search tool
|
|
@@ -14309,7 +14560,7 @@
|
|
|
14309
14560
|
tool = tools[SearchIndexToolType$2];
|
|
14310
14561
|
}
|
|
14311
14562
|
if (!tool) {
|
|
14312
|
-
return
|
|
14563
|
+
return submitToolResult({
|
|
14313
14564
|
output: 'No tool implemented for "'.concat(toolCall.toolName, '".'),
|
|
14314
14565
|
tool: toolCall.toolName,
|
|
14315
14566
|
toolCallId: toolCall.toolCallId
|
|
@@ -14318,7 +14569,7 @@
|
|
|
14318
14569
|
if (tool.onToolCall) {
|
|
14319
14570
|
var addToolResult = function addToolResult(param) {
|
|
14320
14571
|
var output = param.output;
|
|
14321
|
-
return
|
|
14572
|
+
return submitToolResult({
|
|
14322
14573
|
output: output,
|
|
14323
14574
|
tool: toolCall.toolName,
|
|
14324
14575
|
toolCallId: toolCall.toolCallId
|
|
@@ -14440,6 +14691,7 @@
|
|
|
14440
14691
|
var _param = _sliced_to_array(param, 2), key = _param[0], tool = _param[1];
|
|
14441
14692
|
var toolWithAddToolResult = _object_spread_props(_object_spread({}, tool), {
|
|
14442
14693
|
addToolResult: _chatInstance.addToolResult,
|
|
14694
|
+
'~addToolResultForMessage': _chatInstance['~addToolResultForMessage'],
|
|
14443
14695
|
applyFilters: applyFilters,
|
|
14444
14696
|
sendEvent: sendEvent
|
|
14445
14697
|
});
|
|
@@ -14936,8 +15188,8 @@
|
|
|
14936
15188
|
if (escapeHTML && results.hits.length > 0) {
|
|
14937
15189
|
results.hits = escapeHits(results.hits);
|
|
14938
15190
|
}
|
|
14939
|
-
var itemsWithAbsolutePosition = addAbsolutePosition(results.hits, 0, 1);
|
|
14940
|
-
var itemsWithAbsolutePositionAndQueryID = addQueryID(itemsWithAbsolutePosition, results.queryID);
|
|
15191
|
+
var itemsWithAbsolutePosition = addAbsolutePosition$1(results.hits, 0, 1);
|
|
15192
|
+
var itemsWithAbsolutePositionAndQueryID = addQueryID$1(itemsWithAbsolutePosition, results.queryID);
|
|
14941
15193
|
var transformedItems = transformItems(itemsWithAbsolutePositionAndQueryID, {
|
|
14942
15194
|
results: results
|
|
14943
15195
|
});
|
|
@@ -15456,8 +15708,8 @@
|
|
|
15456
15708
|
if (escapeHTML && results.hits.length > 0) {
|
|
15457
15709
|
results.hits = escapeHits(results.hits);
|
|
15458
15710
|
}
|
|
15459
|
-
var hitsWithAbsolutePosition = addAbsolutePosition(results.hits, results.page, results.hitsPerPage);
|
|
15460
|
-
var hitsWithAbsolutePositionAndQueryID = addQueryID(hitsWithAbsolutePosition, results.queryID);
|
|
15711
|
+
var hitsWithAbsolutePosition = addAbsolutePosition$1(results.hits, results.page, results.hitsPerPage);
|
|
15712
|
+
var hitsWithAbsolutePositionAndQueryID = addQueryID$1(hitsWithAbsolutePosition, results.queryID);
|
|
15461
15713
|
var items = transformItems(hitsWithAbsolutePositionAndQueryID, {
|
|
15462
15714
|
results: results
|
|
15463
15715
|
});
|
|
@@ -15788,8 +16040,8 @@
|
|
|
15788
16040
|
if (escapeHTML && results.hits.length > 0) {
|
|
15789
16041
|
results.hits = escapeHits(results.hits);
|
|
15790
16042
|
}
|
|
15791
|
-
var hitsWithAbsolutePosition = addAbsolutePosition(results.hits, results.page, results.hitsPerPage);
|
|
15792
|
-
var hitsWithAbsolutePositionAndQueryID = addQueryID(hitsWithAbsolutePosition, results.queryID);
|
|
16043
|
+
var hitsWithAbsolutePosition = addAbsolutePosition$1(results.hits, results.page, results.hitsPerPage);
|
|
16044
|
+
var hitsWithAbsolutePositionAndQueryID = addQueryID$1(hitsWithAbsolutePosition, results.queryID);
|
|
15793
16045
|
var transformedHits = transformItems(hitsWithAbsolutePositionAndQueryID, {
|
|
15794
16046
|
results: results
|
|
15795
16047
|
});
|
|
@@ -17221,8 +17473,8 @@
|
|
|
17221
17473
|
if (escapeHTML && results.hits.length > 0) {
|
|
17222
17474
|
results.hits = escapeHits(results.hits);
|
|
17223
17475
|
}
|
|
17224
|
-
var itemsWithAbsolutePosition = addAbsolutePosition(results.hits, 0, 1);
|
|
17225
|
-
var itemsWithAbsolutePositionAndQueryID = addQueryID(itemsWithAbsolutePosition, results.queryID);
|
|
17476
|
+
var itemsWithAbsolutePosition = addAbsolutePosition$1(results.hits, 0, 1);
|
|
17477
|
+
var itemsWithAbsolutePositionAndQueryID = addQueryID$1(itemsWithAbsolutePosition, results.queryID);
|
|
17226
17478
|
var transformedItems = transformItems(itemsWithAbsolutePositionAndQueryID, {
|
|
17227
17479
|
results: results
|
|
17228
17480
|
});
|
|
@@ -17902,8 +18154,8 @@
|
|
|
17902
18154
|
if (escapeHTML && results.hits.length > 0) {
|
|
17903
18155
|
results.hits = escapeHits(results.hits);
|
|
17904
18156
|
}
|
|
17905
|
-
var itemsWithAbsolutePosition = addAbsolutePosition(results.hits, 0, 1);
|
|
17906
|
-
var itemsWithAbsolutePositionAndQueryID = addQueryID(itemsWithAbsolutePosition, results.queryID);
|
|
18157
|
+
var itemsWithAbsolutePosition = addAbsolutePosition$1(results.hits, 0, 1);
|
|
18158
|
+
var itemsWithAbsolutePositionAndQueryID = addQueryID$1(itemsWithAbsolutePosition, results.queryID);
|
|
17907
18159
|
var transformedItems = transformItems(itemsWithAbsolutePositionAndQueryID, {
|
|
17908
18160
|
results: results
|
|
17909
18161
|
});
|
|
@@ -18075,8 +18327,8 @@
|
|
|
18075
18327
|
if (escapeHTML && results.hits.length > 0) {
|
|
18076
18328
|
results.hits = escapeHits(results.hits);
|
|
18077
18329
|
}
|
|
18078
|
-
var itemsWithAbsolutePosition = addAbsolutePosition(results.hits, 0, 1);
|
|
18079
|
-
var itemsWithAbsolutePositionAndQueryID = addQueryID(itemsWithAbsolutePosition, results.queryID);
|
|
18330
|
+
var itemsWithAbsolutePosition = addAbsolutePosition$1(results.hits, 0, 1);
|
|
18331
|
+
var itemsWithAbsolutePositionAndQueryID = addQueryID$1(itemsWithAbsolutePosition, results.queryID);
|
|
18080
18332
|
var transformedItems = transformItems(itemsWithAbsolutePositionAndQueryID, {
|
|
18081
18333
|
results: results
|
|
18082
18334
|
});
|
|
@@ -20423,8 +20675,11 @@
|
|
|
20423
20675
|
var ToolLayoutComponent = tool.layoutComponent;
|
|
20424
20676
|
var toolMessage = part;
|
|
20425
20677
|
var boundAddToolResult = function boundAddToolResult(params) {
|
|
20426
|
-
|
|
20427
|
-
|
|
20678
|
+
return tool['~addToolResultForMessage'] ? tool['~addToolResultForMessage'](message, {
|
|
20679
|
+
output: params.output,
|
|
20680
|
+
tool: part.type,
|
|
20681
|
+
toolCallId: toolMessage.toolCallId
|
|
20682
|
+
}) : tool.addToolResult({
|
|
20428
20683
|
output: params.output,
|
|
20429
20684
|
tool: part.type,
|
|
20430
20685
|
toolCallId: toolMessage.toolCallId
|
|
@@ -20598,20 +20853,6 @@
|
|
|
20598
20853
|
var copyToClipboard = function copyToClipboard(message) {
|
|
20599
20854
|
navigator.clipboard.writeText(getTextContent(message));
|
|
20600
20855
|
};
|
|
20601
|
-
/**
|
|
20602
|
-
* Memoization comparator for a message row. `replaceMessage` only clones the
|
|
20603
|
-
* message being updated, so completed messages keep a stable reference across
|
|
20604
|
-
* streaming deltas. We compare just what affects a row's render — `message`,
|
|
20605
|
-
* `status`, `suggestionsElement`, and this message's feedback — and ignore the
|
|
20606
|
-
* props that get a fresh reference every render but don't change the output
|
|
20607
|
-
* (`tools`, `messages`, callbacks, `indexUiState`). `indexUiState` in
|
|
20608
|
-
* particular can't be compared: `getUiState()` returns a new object each render
|
|
20609
|
-
* and would defeat the memo. Trade-off: a completed row keeps the callbacks/
|
|
20610
|
-
* `indexUiState` it last rendered with until its next genuine render.
|
|
20611
|
-
*/ function areMessagePropsEqual(prev, next) {
|
|
20612
|
-
var _prev_feedbackState, _next_feedbackState;
|
|
20613
|
-
return prev.message === next.message && prev.status === next.status && prev.suggestionsElement === next.suggestionsElement && ((_prev_feedbackState = prev.feedbackState) === null || _prev_feedbackState === void 0 ? void 0 : _prev_feedbackState[prev.message.id]) === ((_next_feedbackState = next.feedbackState) === null || _next_feedbackState === void 0 ? void 0 : _next_feedbackState[next.message.id]);
|
|
20614
|
-
}
|
|
20615
20856
|
function createDefaultMessageComponent(param) {
|
|
20616
20857
|
var createElement = param.createElement, Fragment = param.Fragment;
|
|
20617
20858
|
var ChatMessage = createChatMessageComponent({
|
|
@@ -20719,7 +20960,7 @@
|
|
|
20719
20960
|
};
|
|
20720
20961
|
}
|
|
20721
20962
|
function createChatMessagesComponent(param) {
|
|
20722
|
-
var createElement = param.createElement, Fragment = param.Fragment,
|
|
20963
|
+
var createElement = param.createElement, Fragment = param.Fragment, useMemo = param.useMemo;
|
|
20723
20964
|
var Button = createButtonComponent({
|
|
20724
20965
|
createElement: createElement
|
|
20725
20966
|
});
|
|
@@ -20728,8 +20969,23 @@
|
|
|
20728
20969
|
Fragment: Fragment
|
|
20729
20970
|
});
|
|
20730
20971
|
// Skip re-rendering (and re-compiling the markdown of) completed messages on
|
|
20731
|
-
// every streaming delta.
|
|
20732
|
-
|
|
20972
|
+
// every streaming delta. The deps tuple matches the row's render inputs;
|
|
20973
|
+
// callbacks/`indexUiState` are intentionally excluded because `getUiState()`
|
|
20974
|
+
// returns a fresh object every render and would defeat the memo — completed
|
|
20975
|
+
// rows keep the callbacks/`indexUiState` they last rendered with until their
|
|
20976
|
+
// next genuine update.
|
|
20977
|
+
function MemoizedDefaultMessage(props) {
|
|
20978
|
+
var _props_feedbackState;
|
|
20979
|
+
var messageFeedback = (_props_feedbackState = props.feedbackState) === null || _props_feedbackState === void 0 ? void 0 : _props_feedbackState[props.message.id];
|
|
20980
|
+
return useMemo(function() {
|
|
20981
|
+
return /*#__PURE__*/ createElement(DefaultMessageComponent, props);
|
|
20982
|
+
}, [
|
|
20983
|
+
props.message,
|
|
20984
|
+
props.status,
|
|
20985
|
+
props.suggestionsElement,
|
|
20986
|
+
messageFeedback
|
|
20987
|
+
]);
|
|
20988
|
+
}
|
|
20733
20989
|
var DefaultLoaderComponent = createChatMessageLoaderComponent({
|
|
20734
20990
|
createElement: createElement
|
|
20735
20991
|
});
|
|
@@ -21110,7 +21366,7 @@
|
|
|
21110
21366
|
return typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
21111
21367
|
}
|
|
21112
21368
|
function createChatComponent(param) {
|
|
21113
|
-
var createElement = param.createElement, Fragment = param.Fragment,
|
|
21369
|
+
var createElement = param.createElement, Fragment = param.Fragment, useMemo = param.useMemo, useState = param.useState;
|
|
21114
21370
|
var ChatHeader = createChatHeaderComponent({
|
|
21115
21371
|
createElement: createElement,
|
|
21116
21372
|
Fragment: Fragment
|
|
@@ -21118,7 +21374,7 @@
|
|
|
21118
21374
|
var ChatMessages = createChatMessagesComponent({
|
|
21119
21375
|
createElement: createElement,
|
|
21120
21376
|
Fragment: Fragment,
|
|
21121
|
-
|
|
21377
|
+
useMemo: useMemo
|
|
21122
21378
|
});
|
|
21123
21379
|
var ChatPrompt = createChatPromptComponent({
|
|
21124
21380
|
createElement: createElement,
|
|
@@ -21392,6 +21648,162 @@
|
|
|
21392
21648
|
};
|
|
21393
21649
|
}
|
|
21394
21650
|
|
|
21651
|
+
function addAbsolutePosition(hits, page, hitsPerPage) {
|
|
21652
|
+
return hits.map(function(hit, idx) {
|
|
21653
|
+
return _object_spread_props(_object_spread({}, hit), {
|
|
21654
|
+
__position: hitsPerPage * page + idx + 1
|
|
21655
|
+
});
|
|
21656
|
+
});
|
|
21657
|
+
}
|
|
21658
|
+
function addQueryID(hits, queryID) {
|
|
21659
|
+
if (!queryID) {
|
|
21660
|
+
return hits;
|
|
21661
|
+
}
|
|
21662
|
+
return hits.map(function(hit) {
|
|
21663
|
+
return _object_spread_props(_object_spread({}, hit), {
|
|
21664
|
+
__queryID: queryID
|
|
21665
|
+
});
|
|
21666
|
+
});
|
|
21667
|
+
}
|
|
21668
|
+
|
|
21669
|
+
function createHeaderComponent(param) {
|
|
21670
|
+
var createElement = param.createElement;
|
|
21671
|
+
var Button = createButtonComponent({
|
|
21672
|
+
createElement: createElement
|
|
21673
|
+
});
|
|
21674
|
+
return function HeaderComponent(param) {
|
|
21675
|
+
var showViewAll = param.showViewAll, canScrollLeft = param.canScrollLeft, canScrollRight = param.canScrollRight, scrollLeft = param.scrollLeft, scrollRight = param.scrollRight, nbHits = param.nbHits, input = param.input, nbItems = param.nbItems, applyFilters = param.applyFilters, getSearchPageURL = param.getSearchPageURL, onClose = param.onClose;
|
|
21676
|
+
if (nbItems < 1) {
|
|
21677
|
+
return null;
|
|
21678
|
+
}
|
|
21679
|
+
return /*#__PURE__*/ createElement("div", {
|
|
21680
|
+
className: "ais-ChatToolSearchIndexCarouselHeader"
|
|
21681
|
+
}, /*#__PURE__*/ createElement("div", {
|
|
21682
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderResults"
|
|
21683
|
+
}, nbHits && /*#__PURE__*/ createElement("div", {
|
|
21684
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderCount"
|
|
21685
|
+
}, nbItems, " of ", nbHits.toLocaleString(), " result", nbHits > 1 ? 's' : ''), showViewAll && /*#__PURE__*/ createElement(Button, {
|
|
21686
|
+
variant: "ghost",
|
|
21687
|
+
size: "sm",
|
|
21688
|
+
onClick: function onClick() {
|
|
21689
|
+
if (!input || !applyFilters) return;
|
|
21690
|
+
var params = applyFilters({
|
|
21691
|
+
query: input.query,
|
|
21692
|
+
facetFilters: getFacetFiltersFromToolInput(input)
|
|
21693
|
+
});
|
|
21694
|
+
if (getSearchPageURL) {
|
|
21695
|
+
var searchPageURL = getSearchPageURL(params);
|
|
21696
|
+
var resolvedURL = new URL(searchPageURL, window.location.href);
|
|
21697
|
+
if (resolvedURL.pathname !== window.location.pathname) {
|
|
21698
|
+
window.location.href = searchPageURL;
|
|
21699
|
+
}
|
|
21700
|
+
}
|
|
21701
|
+
onClose();
|
|
21702
|
+
},
|
|
21703
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderViewAll"
|
|
21704
|
+
}, "View all", /*#__PURE__*/ createElement(ArrowRightIcon, {
|
|
21705
|
+
createElement: createElement
|
|
21706
|
+
}))), nbItems > 2 && /*#__PURE__*/ createElement("div", {
|
|
21707
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButtons"
|
|
21708
|
+
}, /*#__PURE__*/ createElement(Button, {
|
|
21709
|
+
variant: "outline",
|
|
21710
|
+
size: "sm",
|
|
21711
|
+
iconOnly: true,
|
|
21712
|
+
onClick: scrollLeft,
|
|
21713
|
+
disabled: !canScrollLeft,
|
|
21714
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
|
|
21715
|
+
}, /*#__PURE__*/ createElement(ChevronLeftIcon, {
|
|
21716
|
+
createElement: createElement
|
|
21717
|
+
})), /*#__PURE__*/ createElement(Button, {
|
|
21718
|
+
variant: "outline",
|
|
21719
|
+
size: "sm",
|
|
21720
|
+
iconOnly: true,
|
|
21721
|
+
onClick: scrollRight,
|
|
21722
|
+
disabled: !canScrollRight,
|
|
21723
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
|
|
21724
|
+
}, /*#__PURE__*/ createElement(ChevronRightIcon, {
|
|
21725
|
+
createElement: createElement
|
|
21726
|
+
}))));
|
|
21727
|
+
};
|
|
21728
|
+
}
|
|
21729
|
+
function createCarouselToolComponent(param) {
|
|
21730
|
+
var createElement = param.createElement, Fragment = param.Fragment, useMemo = param.useMemo, useRef = param.useRef, useState = param.useState;
|
|
21731
|
+
var DefaultHeader = createHeaderComponent({
|
|
21732
|
+
createElement: createElement,
|
|
21733
|
+
Fragment: Fragment
|
|
21734
|
+
});
|
|
21735
|
+
var Carousel = createCarouselComponent({
|
|
21736
|
+
createElement: createElement,
|
|
21737
|
+
Fragment: Fragment
|
|
21738
|
+
});
|
|
21739
|
+
return function CarouselTool(userProps) {
|
|
21740
|
+
var ItemComponent = userProps.itemComponent, HeaderComponent = userProps.headerComponent, getSearchPageURL = userProps.getSearchPageURL, _userProps_toolProps = userProps.toolProps, message = _userProps_toolProps.message, applyFilters = _userProps_toolProps.applyFilters, onClose = _userProps_toolProps.onClose, sendEvent = _userProps_toolProps.sendEvent, showViewAll = userProps.headerProps.showViewAll;
|
|
21741
|
+
var input = message === null || message === void 0 ? void 0 : message.input;
|
|
21742
|
+
var output = message === null || message === void 0 ? void 0 : message.output;
|
|
21743
|
+
var hits = (output === null || output === void 0 ? void 0 : output.hits) || [];
|
|
21744
|
+
var items = addQueryID(addAbsolutePosition(hits, 0, hits.length), output === null || output === void 0 ? void 0 : output.queryID);
|
|
21745
|
+
var nbItems = items.length;
|
|
21746
|
+
var _useState = _sliced_to_array(useState(false), 2), canScrollLeft = _useState[0], setCanScrollLeft = _useState[1];
|
|
21747
|
+
var _useState1 = _sliced_to_array(useState(true), 2), canScrollRight = _useState1[0], setCanScrollRight = _useState1[1];
|
|
21748
|
+
var carouselIdRef = useRef('');
|
|
21749
|
+
if (!carouselIdRef.current) {
|
|
21750
|
+
carouselIdRef.current = generateCarouselId();
|
|
21751
|
+
}
|
|
21752
|
+
var carouselRefs = {
|
|
21753
|
+
listRef: useRef(null),
|
|
21754
|
+
nextButtonRef: useRef(null),
|
|
21755
|
+
previousButtonRef: useRef(null),
|
|
21756
|
+
carouselIdRef: carouselIdRef,
|
|
21757
|
+
canScrollLeft: canScrollLeft,
|
|
21758
|
+
canScrollRight: canScrollRight,
|
|
21759
|
+
setCanScrollLeft: setCanScrollLeft,
|
|
21760
|
+
setCanScrollRight: setCanScrollRight
|
|
21761
|
+
};
|
|
21762
|
+
var MemoedHeaderComponent = useMemo(function() {
|
|
21763
|
+
if (HeaderComponent) {
|
|
21764
|
+
return function(props) {
|
|
21765
|
+
return /*#__PURE__*/ createElement(HeaderComponent, _object_spread({
|
|
21766
|
+
showViewAll: showViewAll,
|
|
21767
|
+
nbHits: output === null || output === void 0 ? void 0 : output.nbHits,
|
|
21768
|
+
input: input,
|
|
21769
|
+
nbItems: nbItems,
|
|
21770
|
+
applyFilters: applyFilters,
|
|
21771
|
+
getSearchPageURL: getSearchPageURL,
|
|
21772
|
+
onClose: onClose
|
|
21773
|
+
}, props));
|
|
21774
|
+
};
|
|
21775
|
+
}
|
|
21776
|
+
return function(props) {
|
|
21777
|
+
return /*#__PURE__*/ createElement(DefaultHeader, _object_spread({
|
|
21778
|
+
showViewAll: showViewAll,
|
|
21779
|
+
nbHits: output === null || output === void 0 ? void 0 : output.nbHits,
|
|
21780
|
+
input: input,
|
|
21781
|
+
nbItems: nbItems,
|
|
21782
|
+
applyFilters: applyFilters,
|
|
21783
|
+
getSearchPageURL: getSearchPageURL,
|
|
21784
|
+
onClose: onClose
|
|
21785
|
+
}, props));
|
|
21786
|
+
};
|
|
21787
|
+
}, [
|
|
21788
|
+
showViewAll,
|
|
21789
|
+
HeaderComponent,
|
|
21790
|
+
output === null || output === void 0 ? void 0 : output.nbHits,
|
|
21791
|
+
input,
|
|
21792
|
+
nbItems,
|
|
21793
|
+
applyFilters,
|
|
21794
|
+
getSearchPageURL,
|
|
21795
|
+
onClose
|
|
21796
|
+
]);
|
|
21797
|
+
return /*#__PURE__*/ createElement(Carousel, _object_spread_props(_object_spread({}, carouselRefs), {
|
|
21798
|
+
items: items,
|
|
21799
|
+
itemComponent: ItemComponent,
|
|
21800
|
+
headerComponent: MemoedHeaderComponent,
|
|
21801
|
+
showNavigation: false,
|
|
21802
|
+
sendEvent: sendEvent
|
|
21803
|
+
}));
|
|
21804
|
+
};
|
|
21805
|
+
}
|
|
21806
|
+
|
|
21395
21807
|
var DEFAULT_TRANSLATIONS$1 = {
|
|
21396
21808
|
streamingLabel: 'Curating results…'
|
|
21397
21809
|
};
|
|
@@ -22580,7 +22992,7 @@
|
|
|
22580
22992
|
}));
|
|
22581
22993
|
}
|
|
22582
22994
|
|
|
22583
|
-
var
|
|
22995
|
+
var AutocompleteUiComponent = createAutocompleteComponent({
|
|
22584
22996
|
createElement: React.createElement,
|
|
22585
22997
|
Fragment: React.Fragment
|
|
22586
22998
|
});
|
|
@@ -22766,7 +23178,7 @@
|
|
|
22766
23178
|
setIsModalOpen: setIsModalOpen
|
|
22767
23179
|
};
|
|
22768
23180
|
}
|
|
22769
|
-
function
|
|
23181
|
+
function Autocomplete(props) {
|
|
22770
23182
|
var _showRecent_classNames, _showRecent_classNames1, _showRecent_classNames2, _showRecent_classNames3;
|
|
22771
23183
|
var indices = 'indices' in props ? props.indices : undefined;
|
|
22772
23184
|
var feeds = 'feeds' in props ? props.feeds : undefined;
|
|
@@ -22799,10 +23211,10 @@
|
|
|
22799
23211
|
var domId = useAutocompleteId();
|
|
22800
23212
|
var instanceKey = domId.replace(/:/g, '');
|
|
22801
23213
|
if (isFeedsMode && indices !== undefined) {
|
|
22802
|
-
throw new Error('
|
|
23214
|
+
throw new Error('Autocomplete: `feeds` and `indices` are mutually exclusive.');
|
|
22803
23215
|
}
|
|
22804
23216
|
if (isFeedsMode && !compositionID) {
|
|
22805
|
-
throw new Error('
|
|
23217
|
+
throw new Error('Autocomplete in feeds-mode requires a composition-based <InstantSearch> (compositionID must be set).');
|
|
22806
23218
|
}
|
|
22807
23219
|
var isSearchStalled = status === 'stalled';
|
|
22808
23220
|
var searchParameters = _object_spread({
|
|
@@ -23017,7 +23429,7 @@
|
|
|
23017
23429
|
}
|
|
23018
23430
|
setActivated(true);
|
|
23019
23431
|
};
|
|
23020
|
-
return /*#__PURE__*/ React.createElement(
|
|
23432
|
+
return /*#__PURE__*/ React.createElement(AutocompleteUiComponent, _object_spread_props(_object_spread({}, shellRootProps), {
|
|
23021
23433
|
classNames: classNames
|
|
23022
23434
|
}), isDetached ? /*#__PURE__*/ React.createElement(AutocompleteDetachedSearchButton, {
|
|
23023
23435
|
query: (_indexUiState_query = indexUiState.query) !== null && _indexUiState_query !== void 0 ? _indexUiState_query : '',
|
|
@@ -23060,7 +23472,7 @@
|
|
|
23060
23472
|
}));
|
|
23061
23473
|
if (isFeedsMode) {
|
|
23062
23474
|
return /*#__PURE__*/ React.createElement(Index, {
|
|
23063
|
-
|
|
23475
|
+
isolated: true,
|
|
23064
23476
|
indexName: compositionID,
|
|
23065
23477
|
indexId: "ais-autocomplete-".concat(instanceKey)
|
|
23066
23478
|
}, /*#__PURE__*/ React.createElement(Configure, searchParameters), /*#__PURE__*/ React.createElement(Feeds, {
|
|
@@ -23071,7 +23483,7 @@
|
|
|
23071
23483
|
}), innerAutocomplete);
|
|
23072
23484
|
}
|
|
23073
23485
|
return /*#__PURE__*/ React.createElement(Index, {
|
|
23074
|
-
|
|
23486
|
+
isolated: true,
|
|
23075
23487
|
indexId: "ais-autocomplete-".concat(instanceKey)
|
|
23076
23488
|
}, /*#__PURE__*/ React.createElement(Configure, searchParameters), indicesConfig.map(function(index) {
|
|
23077
23489
|
return /*#__PURE__*/ React.createElement(Index, {
|
|
@@ -23081,6 +23493,7 @@
|
|
|
23081
23493
|
}, /*#__PURE__*/ React.createElement(Configure, index.searchParameters));
|
|
23082
23494
|
}), innerAutocomplete);
|
|
23083
23495
|
}
|
|
23496
|
+
/** @deprecated use Autocomplete instead */ var EXPERIMENTAL_Autocomplete = deprecate(Autocomplete);
|
|
23084
23497
|
function InnerAutocomplete(_0) {
|
|
23085
23498
|
var indicesConfig = _0.indicesConfig, refineSearchBox = _0.refineSearchBox, isSearchStalled = _0.isSearchStalled, getSearchPageURL = _0.getSearchPageURL, userOnSelect = _0.onSelect, indexUiState = _0.indexUiState, isSearchPage = _0.isSearchPage, PanelComponent = _0.panelComponent, showRecent = _0.showRecent, recentSearchConfig = _0.recentSearchConfig, showQuerySuggestions = _0.showQuerySuggestions, showPromptSuggestions = _0.showPromptSuggestions, chatRenderState = _0.chatRenderState, transformItems = _0.transformItems, placeholder = _0.placeholder, autoFocus = _0.autoFocus, translations = _0.translations, classNames = _0.classNames, aiMode = _0.aiMode, domId = _0.domId, detached = _0.detached, props = _object_without_properties(_0, [
|
|
23086
23499
|
"indicesConfig",
|
|
@@ -23370,7 +23783,7 @@
|
|
|
23370
23783
|
"ref"
|
|
23371
23784
|
]);
|
|
23372
23785
|
if (isDetached) {
|
|
23373
|
-
return /*#__PURE__*/ React.createElement(
|
|
23786
|
+
return /*#__PURE__*/ React.createElement(AutocompleteUiComponent, _object_spread_props(_object_spread({}, props, rootProps), {
|
|
23374
23787
|
rootRef: rootRef,
|
|
23375
23788
|
classNames: classNames
|
|
23376
23789
|
}), /*#__PURE__*/ React.createElement(AutocompleteDetachedSearchButton, {
|
|
@@ -23396,7 +23809,7 @@
|
|
|
23396
23809
|
}, searchBoxContent), panelContent)));
|
|
23397
23810
|
}
|
|
23398
23811
|
// Normal (non-detached) rendering
|
|
23399
|
-
return /*#__PURE__*/ React.createElement(
|
|
23812
|
+
return /*#__PURE__*/ React.createElement(AutocompleteUiComponent, _object_spread_props(_object_spread({}, props, rootProps), {
|
|
23400
23813
|
rootRef: rootRef,
|
|
23401
23814
|
classNames: classNames
|
|
23402
23815
|
}), searchBoxContent, panelContent);
|
|
@@ -23613,92 +24026,23 @@
|
|
|
23613
24026
|
}
|
|
23614
24027
|
|
|
23615
24028
|
function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
|
|
23616
|
-
var
|
|
23617
|
-
createElement: React.createElement
|
|
24029
|
+
var SearchLayoutUIComponent = createCarouselToolComponent({
|
|
24030
|
+
createElement: React.createElement,
|
|
24031
|
+
Fragment: React.Fragment,
|
|
24032
|
+
useMemo: React.useMemo,
|
|
24033
|
+
useRef: React.useRef,
|
|
24034
|
+
useState: React.useState
|
|
23618
24035
|
});
|
|
23619
|
-
function SearchLayoutComponent(
|
|
23620
|
-
|
|
23621
|
-
|
|
23622
|
-
|
|
23623
|
-
|
|
23624
|
-
|
|
23625
|
-
var hitsWithAbsolutePosition = addAbsolutePosition((output === null || output === void 0 ? void 0 : output.hits) || [], 0, ((_ref = input === null || input === void 0 ? void 0 : input.number_of_results) !== null && _ref !== void 0 ? _ref : output === null || output === void 0 ? void 0 : (_output_hits = output.hits) === null || _output_hits === void 0 ? void 0 : _output_hits.length) || 5);
|
|
23626
|
-
var items = addQueryID(hitsWithAbsolutePosition, output === null || output === void 0 ? void 0 : output.queryID);
|
|
23627
|
-
var MemoedHeaderComponent = React.useMemo(function() {
|
|
23628
|
-
return function(props) {
|
|
23629
|
-
return /*#__PURE__*/ React.createElement(HeaderComponent, _object_spread({
|
|
23630
|
-
nbHits: output === null || output === void 0 ? void 0 : output.nbHits,
|
|
23631
|
-
input: input,
|
|
23632
|
-
hitsPerPage: items.length,
|
|
23633
|
-
onClose: onClose,
|
|
23634
|
-
applyFilters: applyFilters
|
|
23635
|
-
}, props));
|
|
23636
|
-
};
|
|
23637
|
-
}, [
|
|
23638
|
-
items.length,
|
|
23639
|
-
input,
|
|
23640
|
-
output === null || output === void 0 ? void 0 : output.nbHits,
|
|
23641
|
-
applyFilters,
|
|
23642
|
-
onClose
|
|
23643
|
-
]);
|
|
23644
|
-
return /*#__PURE__*/ React.createElement(Carousel, {
|
|
23645
|
-
items: items,
|
|
24036
|
+
var SearchLayoutComponent = function SearchLayoutComponent(toolProps) {
|
|
24037
|
+
return /*#__PURE__*/ React.createElement(SearchLayoutUIComponent, {
|
|
24038
|
+
getSearchPageURL: getSearchPageURL,
|
|
24039
|
+
headerProps: {
|
|
24040
|
+
showViewAll: showViewAll
|
|
24041
|
+
},
|
|
23646
24042
|
itemComponent: itemComponent,
|
|
23647
|
-
|
|
23648
|
-
showNavigation: false,
|
|
23649
|
-
headerComponent: MemoedHeaderComponent
|
|
24043
|
+
toolProps: toolProps
|
|
23650
24044
|
});
|
|
23651
|
-
}
|
|
23652
|
-
function HeaderComponent(param) {
|
|
23653
|
-
var canScrollLeft = param.canScrollLeft, canScrollRight = param.canScrollRight, scrollLeft = param.scrollLeft, scrollRight = param.scrollRight, nbHits = param.nbHits, input = param.input, hitsPerPage = param.hitsPerPage, applyFilters = param.applyFilters, onClose = param.onClose;
|
|
23654
|
-
if ((hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0) < 1) {
|
|
23655
|
-
return null;
|
|
23656
|
-
}
|
|
23657
|
-
return /*#__PURE__*/ React.createElement("div", {
|
|
23658
|
-
className: "ais-ChatToolSearchIndexCarouselHeader"
|
|
23659
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
23660
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderResults"
|
|
23661
|
-
}, nbHits && /*#__PURE__*/ React.createElement("div", {
|
|
23662
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderCount"
|
|
23663
|
-
}, hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0, " of ", nbHits.toLocaleString(), " result", nbHits > 1 ? 's' : ''), showViewAll && /*#__PURE__*/ React.createElement(Button, {
|
|
23664
|
-
variant: "ghost",
|
|
23665
|
-
size: "sm",
|
|
23666
|
-
onClick: function onClick() {
|
|
23667
|
-
if (!input || !applyFilters) return;
|
|
23668
|
-
var params = applyFilters({
|
|
23669
|
-
query: input.query,
|
|
23670
|
-
facetFilters: getFacetFiltersFromToolInput(input)
|
|
23671
|
-
});
|
|
23672
|
-
if (getSearchPageURL && new URL(getSearchPageURL(params)).pathname !== window.location.pathname) {
|
|
23673
|
-
window.location.href = getSearchPageURL(params);
|
|
23674
|
-
}
|
|
23675
|
-
onClose();
|
|
23676
|
-
},
|
|
23677
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderViewAll"
|
|
23678
|
-
}, "View all", /*#__PURE__*/ React.createElement(ArrowRightIcon, {
|
|
23679
|
-
createElement: React.createElement
|
|
23680
|
-
}))), (hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0) > 2 && /*#__PURE__*/ React.createElement("div", {
|
|
23681
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButtons"
|
|
23682
|
-
}, /*#__PURE__*/ React.createElement(Button, {
|
|
23683
|
-
variant: "outline",
|
|
23684
|
-
size: "sm",
|
|
23685
|
-
iconOnly: true,
|
|
23686
|
-
onClick: scrollLeft,
|
|
23687
|
-
disabled: !canScrollLeft,
|
|
23688
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
|
|
23689
|
-
}, /*#__PURE__*/ React.createElement(ChevronLeftIcon, {
|
|
23690
|
-
createElement: React.createElement
|
|
23691
|
-
})), /*#__PURE__*/ React.createElement(Button, {
|
|
23692
|
-
variant: "outline",
|
|
23693
|
-
size: "sm",
|
|
23694
|
-
iconOnly: true,
|
|
23695
|
-
onClick: scrollRight,
|
|
23696
|
-
disabled: !canScrollRight,
|
|
23697
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
|
|
23698
|
-
}, /*#__PURE__*/ React.createElement(ChevronRightIcon, {
|
|
23699
|
-
createElement: React.createElement
|
|
23700
|
-
}))));
|
|
23701
|
-
}
|
|
24045
|
+
};
|
|
23702
24046
|
return {
|
|
23703
24047
|
layoutComponent: SearchLayoutComponent
|
|
23704
24048
|
};
|
|
@@ -23707,7 +24051,7 @@
|
|
|
23707
24051
|
var ChatUiComponent = createChatComponent({
|
|
23708
24052
|
createElement: React.createElement,
|
|
23709
24053
|
Fragment: React.Fragment,
|
|
23710
|
-
|
|
24054
|
+
useMemo: React.useMemo,
|
|
23711
24055
|
useState: React.useState
|
|
23712
24056
|
});
|
|
23713
24057
|
function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
@@ -25770,6 +26114,7 @@
|
|
|
25770
26114
|
return /*#__PURE__*/ React.createElement(FilterSuggestionsUiComponent, _object_spread({}, props, uiProps));
|
|
25771
26115
|
}
|
|
25772
26116
|
|
|
26117
|
+
exports.Autocomplete = Autocomplete;
|
|
25773
26118
|
exports.Breadcrumb = Breadcrumb;
|
|
25774
26119
|
exports.Carousel = Carousel;
|
|
25775
26120
|
exports.Chat = Chat;
|