@bikdotai/bik-component-library 0.0.870-beta.1 → 0.0.871
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/components/bik-copilot/CopilotPanel.js +1 -1
- package/dist/cjs/components/bik-copilot/CopilotPanel.js.map +1 -1
- package/dist/cjs/components/bik-copilot/useCopilotStreamChat.js +1 -1
- package/dist/cjs/components/bik-copilot/useCopilotStreamChat.js.map +1 -1
- package/dist/cjs/components/button/Button.js +1 -1
- package/dist/cjs/components/button/Button.js.map +1 -1
- package/dist/cjs/components/button/Button.styled.js +2 -2
- package/dist/cjs/components/button/Button.styled.js.map +1 -1
- package/dist/cjs/components/dropdown-button/DropdownButton.js +1 -1
- package/dist/cjs/components/dropdown-button/DropdownButton.js.map +1 -1
- package/dist/cjs/components/tag/Tag.js +1 -1
- package/dist/cjs/components/tag/Tag.js.map +1 -1
- package/dist/cjs/components/tag/Tag.styled.js +4 -4
- package/dist/cjs/components/tag/Tag.styled.js.map +1 -1
- package/dist/cjs/components/tag/model.js.map +1 -1
- package/dist/cjs/icons/BIK AI specific/WandSparkles.js +1 -1
- package/dist/cjs/icons/BIK AI specific/WandSparkles.js.map +1 -1
- package/dist/esm/components/ProgressChecklist/ProgressChecklist.style.d.ts +59 -24
- package/dist/esm/components/QueryBuilder/components/Connectors/Connector.styled.d.ts +4 -1
- package/dist/esm/components/QueryBuilder/components/QueryBuilderNode/Property/PropertyNode.styled.d.ts +4 -1
- package/dist/esm/components/QueryBuilder/components/QueryBuilderNode/Property/PropertyNodeUIWrapper.styled.d.ts +10 -3
- package/dist/esm/components/QueryBuilder/components/QueryBuilderNodes.styled.d.ts +7 -2
- package/dist/esm/components/TablePagination/TablePagination.styled.d.ts +8 -3
- package/dist/esm/components/TablePagination/TablePaginationCard.d.ts +4 -2
- package/dist/esm/components/TypographyStyle.d.ts +141 -62
- package/dist/esm/components/WhatsAppTextEditor/AIRephrase.styled.d.ts +5 -2
- package/dist/esm/components/WhatsAppTextEditor/CustomEditor.styled.d.ts +20 -7
- package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditorHeader.d.ts +3 -1
- package/dist/esm/components/access-token-troubleshoot-dialog/AccessTokenTroubleshootDialog.styles.d.ts +26 -9
- package/dist/esm/components/accordion/Accordion.style.d.ts +10 -4
- package/dist/esm/components/action-button/ActionButton.styled.d.ts +5 -2
- package/dist/esm/components/adbanner/Banner.styled.d.ts +88 -20
- package/dist/esm/components/add-variableV2/AddVariableBox.styled.d.ts +4 -1
- package/dist/esm/components/add-variableV2/AddVariableV2.styled.d.ts +9 -4
- package/dist/esm/components/agent-builder/AgentBuilder.styled.d.ts +328 -186
- package/dist/esm/components/agent-listing/AgentListing.styled.d.ts +88 -49
- package/dist/esm/components/alerts/Alert.styled.d.ts +11 -5
- package/dist/esm/components/analytics-card/AnalyticsCard.styled.d.ts +8 -4
- package/dist/esm/components/analytics-chips-and-dropdowns/CommonStyles.d.ts +27 -18
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/ComparisonBarChart/ComparisonBarChart.styled.d.ts +26 -11
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/FunnelChart/FunnelChart.styled.d.ts +26 -11
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/HorizontalBarGraph/HorizontalGraph.styles.d.ts +5 -2
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/LineChart/LineChart.styled.d.ts +12 -5
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/StackedBarChart/StackedBarChart.styles.d.ts +8 -3
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/VerticalBarAndLinearGraph/VerticalBarAndLinearGraph.styles.d.ts +17 -6
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/VerticalBarGraph/VerticalGraph.styles.d.ts +5 -2
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/heatmap/HeatMapStyled.d.ts +28 -11
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/heatmap/HeatMapVertical.d.ts +3 -1
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/linearChipGroupedChart/LinearChipGroupedChart.styled.d.ts +18 -7
- package/dist/esm/components/analytics-chips-and-dropdowns/chart/scoreBlock/ScoreBlock.styled.d.ts +18 -7
- package/dist/esm/components/avatar/Avatar.styled.d.ts +4 -2
- package/dist/esm/components/bik-chatbot/components/ChatWindow.d.ts +4 -2
- package/dist/esm/components/bik-copilot/ControlledCopilot.styled.d.ts +5 -2
- package/dist/esm/components/bik-copilot/CopilotBall.styled.d.ts +5 -2
- package/dist/esm/components/bik-copilot/CopilotFeedbackModal.styled.d.ts +32 -11
- package/dist/esm/components/bik-copilot/CopilotPanel.js +235 -244
- package/dist/esm/components/bik-copilot/CopilotPanel.js.map +1 -1
- package/dist/esm/components/bik-copilot/CopilotPanel.styled.d.ts +120 -43
- package/dist/esm/components/bik-copilot/model.d.ts +4 -2
- package/dist/esm/components/bik-copilot/useCopilotStreamChat.d.ts +0 -18
- package/dist/esm/components/bik-copilot/useCopilotStreamChat.js +168 -163
- package/dist/esm/components/bik-copilot/useCopilotStreamChat.js.map +1 -1
- package/dist/esm/components/bik-layout/BikSidebarV2/SidebarV2Styles.d.ts +49 -18
- package/dist/esm/components/bik-layout/CommonStyles.d.ts +88 -28
- package/dist/esm/components/bik-layout/SidebarStyles.d.ts +17 -7
- package/dist/esm/components/button/Button.js +19 -21
- package/dist/esm/components/button/Button.js.map +1 -1
- package/dist/esm/components/button/Button.styled.d.ts +4 -3
- package/dist/esm/components/button/Button.styled.js +5 -5
- package/dist/esm/components/button/Button.styled.js.map +1 -1
- package/dist/esm/components/button/model.d.ts +0 -5
- package/dist/esm/components/button/themes.d.ts +16 -2
- package/dist/esm/components/buttonGroup/ButtonGroupStyle.d.ts +9 -4
- package/dist/esm/components/card-selection-modal/CardSelectionModal.styled.d.ts +7 -2
- package/dist/esm/components/card-selector/CardSelector.styled.d.ts +8 -3
- package/dist/esm/components/carousel-preview/CarouselPreview.style.d.ts +9 -4
- package/dist/esm/components/carousel-secondary/CarouselSecondary.style.d.ts +23 -11
- package/dist/esm/components/channel-playground/shell/TestingPlayground.style.d.ts +74 -18
- package/dist/esm/components/checkBox/CheckBox.styled.d.ts +9 -4
- package/dist/esm/components/checkList/CheckList.styled.d.ts +4 -1
- package/dist/esm/components/code-block/CodeBlock.styled.d.ts +43 -20
- package/dist/esm/components/colourInput/ColourInput.styled.d.ts +7 -2
- package/dist/esm/components/connected-app-dialog/ConnectedAppDialog.styled.d.ts +49 -16
- package/dist/esm/components/country-code-picker/CountryCodePicker.styled.d.ts +8 -3
- package/dist/esm/components/country-code-picker/CountryPicker.styled.d.ts +8 -3
- package/dist/esm/components/curtain/Curtain.styled.d.ts +11 -5
- package/dist/esm/components/custom-date-time/CustomDateTime.styled.d.ts +4 -1
- package/dist/esm/components/dashboard-review-popup/DashboardReviewPopUp.styled.d.ts +7 -2
- package/dist/esm/components/dashboard-review-popup/components/FiveStar.styled.d.ts +7 -2
- package/dist/esm/components/dashboard-review-popup/components/Form.styled.d.ts +20 -7
- package/dist/esm/components/data-source-panel/DataSourcePanel.style.d.ts +13 -4
- package/dist/esm/components/datePicker/DatePicker.styled.d.ts +22 -15
- package/dist/esm/components/datePicker/DatePickerWrapper.styled.d.ts +8 -4
- package/dist/esm/components/discount-modal/DiscountModal.styled.d.ts +17 -6
- package/dist/esm/components/discount-modal/DynamicCoupon/DynamicCoupon.styled.d.ts +23 -8
- package/dist/esm/components/dropdown/ChipDropdown.d.ts +4 -2
- package/dist/esm/components/dropdown/Common.styled.d.ts +15 -6
- package/dist/esm/components/dropdown/OpenedDropdown/components/OpennedDropdown.styled.d.ts +12 -5
- package/dist/esm/components/dropdown/OpenedDropdown/components/description/Description.styled.d.ts +5 -2
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/FreeFormMenu.styled.d.ts +4 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuList.styled.d.ts +18 -4
- package/dist/esm/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.styled.d.ts +4 -1
- package/dist/esm/components/dropdown-button/DropdownButton.d.ts +0 -5
- package/dist/esm/components/dropdown-button/DropdownButton.js +3 -4
- package/dist/esm/components/dropdown-button/DropdownButton.js.map +1 -1
- package/dist/esm/components/dropdown-button/DropdownButton.style.d.ts +9 -5
- package/dist/esm/components/dual-icon-button/DualIconButton.styled.d.ts +12 -5
- package/dist/esm/components/file-uploader/FileUploaderStyle.d.ts +9 -4
- package/dist/esm/components/floating-action-button/FloatingActionButton.styles.d.ts +24 -13
- package/dist/esm/components/half-doughnut-chart/HalfDoughnutChart.styled.d.ts +29 -10
- package/dist/esm/components/icon-button/IconButton.styled.d.ts +4 -2
- package/dist/esm/components/input/Input.styled.d.ts +114 -29
- package/dist/esm/components/keywords-input/KeywordsInput.styled.d.ts +4 -1
- package/dist/esm/components/list-item/ListItem.styled.d.ts +4 -2
- package/dist/esm/components/list-item/themes.d.ts +1 -1
- package/dist/esm/components/modals/modal.styled.d.ts +16 -7
- package/dist/esm/components/multi-level-dropdown/MultiLevelDropdown.styled.d.ts +60 -22
- package/dist/esm/components/navigation-hyperlink/NavigationHyperlink.d.ts +3 -1
- package/dist/esm/components/pagination/Pagination.styled.d.ts +4 -1
- package/dist/esm/components/plans/DurationSelectorStyles.d.ts +4 -1
- package/dist/esm/components/plans/SubscriptionPlanSelector.d.ts +6 -2
- package/dist/esm/components/plans/SubscriptionPlanStyled.d.ts +9 -4
- package/dist/esm/components/postPicker/PostPicker.styled.d.ts +43 -13
- package/dist/esm/components/product-picker/ProductPicker.styled.d.ts +7 -2
- package/dist/esm/components/product-picker-v2/style.d.ts +82 -25
- package/dist/esm/components/progress-bar/ProgressBarComponent.d.ts +5 -2
- package/dist/esm/components/radioButton/RadioButton.styled.d.ts +8 -3
- package/dist/esm/components/radioList/RadioList.styled.d.ts +4 -1
- package/dist/esm/components/shimmer/ShimmerComponent/ShimmerStyled.d.ts +9 -4
- package/dist/esm/components/side-modal/SideModal.style.d.ts +25 -12
- package/dist/esm/components/spinner/Spinner.d.ts +4 -2
- package/dist/esm/components/states/StateComponent.styled.d.ts +20 -9
- package/dist/esm/components/stepper/Stepper.styled.d.ts +10 -4
- package/dist/esm/components/switch/Switch.d.ts +12 -6
- package/dist/esm/components/tabs/Tabs.styles.d.ts +30 -9
- package/dist/esm/components/tag/Tag.d.ts +1 -1
- package/dist/esm/components/tag/Tag.js +41 -48
- package/dist/esm/components/tag/Tag.js.map +1 -1
- package/dist/esm/components/tag/Tag.styled.d.ts +4 -5
- package/dist/esm/components/tag/Tag.styled.js +9 -6
- package/dist/esm/components/tag/Tag.styled.js.map +1 -1
- package/dist/esm/components/tag/model.d.ts +0 -11
- package/dist/esm/components/tag/model.js.map +1 -1
- package/dist/esm/components/template-context-mapper/Badge/index.d.ts +5 -2
- package/dist/esm/components/template-context-mapper/modalElements/EditMediaV2.style.d.ts +14 -5
- package/dist/esm/components/template-context-mapper/modalElements/VariableConnector.d.ts +4 -2
- package/dist/esm/components/template-context-mapper/modalElements/VariableConnectorsPanel.d.ts +7 -2
- package/dist/esm/components/template-context-mapper/styles/TemplateAnalyticsStyles.d.ts +24 -6
- package/dist/esm/components/template-context-mapper/utils/TemplateConstants.d.ts +16 -8
- package/dist/esm/components/template-preview/EmailTemplatePreview.styled.d.ts +23 -10
- package/dist/esm/components/template-preview/RCS/RCSPreview.styled.d.ts +70 -20
- package/dist/esm/components/template-preview/SMS/SMSBubble.d.ts +7 -2
- package/dist/esm/components/template-preview/SmsTemplatePreview.styled.d.ts +27 -10
- package/dist/esm/components/template-preview/TemplatePreview.styled.d.ts +4 -1
- package/dist/esm/components/template-preview/WhatsApp/ChatHeader.style.d.ts +16 -5
- package/dist/esm/components/template-preview/WhatsApp/ChatUI.style.d.ts +53 -11
- package/dist/esm/components/template-preview/WhatsApp/ChatUiV2.d.ts +3 -1
- package/dist/esm/components/template-preview/WhatsApp/LimitedTimeOffer/LimitedTimeOffer.index.d.ts +9 -3
- package/dist/esm/components/template-preview/webpush/WebpushPreview.styled.d.ts +4 -1
- package/dist/esm/components/testimonial-card/TestimonialCard.style.d.ts +30 -11
- package/dist/esm/components/text-selection-ask/SelectionAskPill.styled.d.ts +5 -2
- package/dist/esm/components/thumbnail/Thumbnail.styled.d.ts +4 -2
- package/dist/esm/components/toaster/Toaster.styled.d.ts +4 -2
- package/dist/esm/components/unsatisfactory-response-list/UnsatisfactoryCountIntentWiseModal.style.d.ts +4 -1
- package/dist/esm/components/unsatisfactory-response-list/UnsatisfactoryResponseList.style.d.ts +4 -1
- package/dist/esm/components/variable-picker-v3/styles.d.ts +15 -6
- package/dist/esm/components/vertical-full-screen-modal/styles.d.ts +15 -6
- package/dist/esm/components/whats-new/WhatsNew.styles.d.ts +18 -7
- package/dist/esm/editor/BikEditor.styles.d.ts +18 -7
- package/dist/esm/editor/extensions/editorDropdown.styles.d.ts +47 -12
- package/dist/esm/icons/BIK AI specific/WandSparkles.js +1 -1
- package/dist/esm/icons/BIK AI specific/WandSparkles.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { COPILOT_REGENERATE_PROMPT as
|
|
3
|
-
import { persistCopilotTurn as
|
|
4
|
-
import { sendCopilotFeedback as
|
|
5
|
-
import { fetchCopilotMessages as
|
|
6
|
-
import { resetCopilotSessionForRoute as
|
|
7
|
-
import { readCopilotEventContent as Z, streamCopilotChat as
|
|
8
|
-
import { DEFAULT_COPILOT_ROUTE as
|
|
9
|
-
const nt = "Something went wrong. Please try again.",
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { useState as h, useRef as p, useCallback as a, useEffect as Y, useMemo as It } from "react";
|
|
2
|
+
import { COPILOT_REGENERATE_PROMPT as ht } from "./copilotRegenerate.js";
|
|
3
|
+
import { persistCopilotTurn as yt, pruneCopilotSessions as Ct, deleteCopilotSession as Tt, loadCopilotSession as Et } from "./services/copilotDb.js";
|
|
4
|
+
import { sendCopilotFeedback as wt } from "./services/copilotFeedbackClient.js";
|
|
5
|
+
import { fetchCopilotMessages as St, COPILOT_HISTORY_PAGE_SIZE as vt } from "./services/copilotMessagesClient.js";
|
|
6
|
+
import { resetCopilotSessionForRoute as Ot, resolveCopilotSessionIdForRoute as Pt, getCopilotSessionIdForRoute as Mt } from "./services/copilotPageSession.js";
|
|
7
|
+
import { readCopilotEventContent as Z, streamCopilotChat as Ht } from "./services/copilotStreamClient.js";
|
|
8
|
+
import { DEFAULT_COPILOT_ROUTE as _t, DEFAULT_COPILOT_AGENT as bt } from "./useCopilotIcebreakers.js";
|
|
9
|
+
const nt = "Something went wrong. Please try again.", st = (c) => c.map(
|
|
10
|
+
(m) => m.role === "assistant" ? { ...m, isRestored: !0 } : m
|
|
11
|
+
), Dt = ({
|
|
12
|
+
storeId: c,
|
|
13
|
+
agent: m = bt,
|
|
14
|
+
route: R = _t,
|
|
13
15
|
messagesPath: j,
|
|
14
16
|
feedbackPath: q,
|
|
15
17
|
user: J,
|
|
16
18
|
loadHistory: K = !0,
|
|
17
19
|
systemPrompt: Q,
|
|
18
|
-
sessionId:
|
|
20
|
+
sessionId: y,
|
|
19
21
|
persist: l = !0,
|
|
20
|
-
onError:
|
|
22
|
+
onError: S,
|
|
21
23
|
onResponseComplete: V,
|
|
22
24
|
onSessionIdChange: N,
|
|
23
25
|
baseUrl: _,
|
|
@@ -27,29 +29,29 @@ const nt = "Something went wrong. Please try again.", Nt = ({
|
|
|
27
29
|
getAuthToken: L,
|
|
28
30
|
fetchImpl: A
|
|
29
31
|
}) => {
|
|
30
|
-
const [D, B] =
|
|
31
|
-
|
|
32
|
-
), [
|
|
33
|
-
k.current =
|
|
34
|
-
const
|
|
32
|
+
const [D, B] = h([]), [ot, tt] = h(
|
|
33
|
+
y ?? null
|
|
34
|
+
), [P, v] = h(!1), [ct, et] = h(!0), [ut, M] = h(), [it, at] = h(), [lt, F] = h(!1), [$, g] = h(!1), f = p([]), z = p(void 0), C = p(null), u = p(null), T = p(y ?? null), k = p(R);
|
|
35
|
+
k.current = R;
|
|
36
|
+
const E = p(1), H = p(!1), i = a(
|
|
35
37
|
(t) => {
|
|
36
38
|
const e = t(f.current);
|
|
37
39
|
f.current = e, B(e);
|
|
38
40
|
},
|
|
39
41
|
[]
|
|
40
|
-
),
|
|
41
|
-
z.current = t,
|
|
42
|
-
}, []),
|
|
43
|
-
const t =
|
|
44
|
-
!l || !t ||
|
|
42
|
+
), O = a((t) => {
|
|
43
|
+
z.current = t, at(t);
|
|
44
|
+
}, []), I = a(() => {
|
|
45
|
+
const t = T.current;
|
|
46
|
+
!l || !t || yt({
|
|
45
47
|
route: k.current,
|
|
46
48
|
sessionId: t,
|
|
47
49
|
messages: f.current,
|
|
48
50
|
previousResponseId: z.current,
|
|
49
|
-
storeId:
|
|
50
|
-
agent:
|
|
51
|
+
storeId: c,
|
|
52
|
+
agent: m
|
|
51
53
|
});
|
|
52
|
-
}, [
|
|
54
|
+
}, [m, l, c]), U = p({
|
|
53
55
|
baseUrl: _,
|
|
54
56
|
messagesPath: j,
|
|
55
57
|
feedbackPath: q,
|
|
@@ -57,7 +59,7 @@ const nt = "Something went wrong. Please try again.", Nt = ({
|
|
|
57
59
|
authToken: x,
|
|
58
60
|
getAuthToken: L,
|
|
59
61
|
fetchImpl: A,
|
|
60
|
-
storeId:
|
|
62
|
+
storeId: c,
|
|
61
63
|
loadHistory: K,
|
|
62
64
|
user: J
|
|
63
65
|
});
|
|
@@ -69,13 +71,15 @@ const nt = "Something went wrong. Please try again.", Nt = ({
|
|
|
69
71
|
authToken: x,
|
|
70
72
|
getAuthToken: L,
|
|
71
73
|
fetchImpl: A,
|
|
72
|
-
storeId:
|
|
74
|
+
storeId: c,
|
|
73
75
|
loadHistory: K,
|
|
74
76
|
user: J
|
|
75
77
|
};
|
|
76
|
-
const G =
|
|
77
|
-
const e = U.current,
|
|
78
|
-
|
|
78
|
+
const G = a(async (t) => {
|
|
79
|
+
const e = U.current, n = T.current;
|
|
80
|
+
if (!e.loadHistory || !n)
|
|
81
|
+
return null;
|
|
82
|
+
const r = await St({
|
|
79
83
|
baseUrl: e.baseUrl,
|
|
80
84
|
endpointPath: e.messagesPath,
|
|
81
85
|
headers: e.headers,
|
|
@@ -83,111 +87,112 @@ const nt = "Something went wrong. Please try again.", Nt = ({
|
|
|
83
87
|
getAuthToken: e.getAuthToken,
|
|
84
88
|
fetchImpl: e.fetchImpl,
|
|
85
89
|
storeId: e.storeId,
|
|
86
|
-
sessionId:
|
|
90
|
+
sessionId: n,
|
|
87
91
|
page: t,
|
|
88
|
-
pageSize:
|
|
92
|
+
pageSize: vt
|
|
89
93
|
});
|
|
94
|
+
return { ...r, messages: st(r.messages) };
|
|
90
95
|
}, []);
|
|
91
96
|
Y(() => {
|
|
92
97
|
let t = !1;
|
|
93
98
|
return (async () => {
|
|
94
|
-
|
|
95
|
-
const
|
|
99
|
+
u.current?.(), u.current = null, C.current = null, v(!1), M(void 0), et(!0), g(!1), H.current = !1, F(!1);
|
|
100
|
+
const n = y ?? (l ? await Pt({ route: R, storeId: c }) : Mt({ route: R, storeId: c })), r = l ? await Et(R, n) : null;
|
|
96
101
|
if (!t) {
|
|
97
|
-
if (
|
|
98
|
-
|
|
102
|
+
if (T.current = n, tt(n), f.current = st(r?.messages ?? []), B(f.current), O(r?.previousResponseId), et(!1), N?.(n), f.current.length > 0) {
|
|
103
|
+
E.current = 2, g(U.current.loadHistory);
|
|
99
104
|
return;
|
|
100
105
|
}
|
|
101
|
-
if (!
|
|
102
|
-
|
|
106
|
+
if (!y) {
|
|
107
|
+
E.current = 1, g(!1);
|
|
103
108
|
return;
|
|
104
109
|
}
|
|
105
|
-
|
|
110
|
+
E.current = 1;
|
|
106
111
|
try {
|
|
107
112
|
const s = await G(1);
|
|
108
113
|
if (t || !s)
|
|
109
114
|
return;
|
|
110
|
-
|
|
115
|
+
E.current = 2, i(() => s.messages), g(s.hasMore);
|
|
111
116
|
} catch {
|
|
112
|
-
|
|
117
|
+
g(!1);
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
120
|
})(), () => {
|
|
116
121
|
t = !0;
|
|
117
122
|
};
|
|
118
123
|
}, [
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
R,
|
|
125
|
+
c,
|
|
126
|
+
y,
|
|
122
127
|
l,
|
|
123
|
-
|
|
124
|
-
|
|
128
|
+
O,
|
|
129
|
+
i,
|
|
125
130
|
G
|
|
126
131
|
]);
|
|
127
|
-
const
|
|
128
|
-
if (
|
|
132
|
+
const ft = a(() => {
|
|
133
|
+
if (H.current || !$)
|
|
129
134
|
return;
|
|
130
|
-
|
|
131
|
-
const t =
|
|
135
|
+
H.current = !0, F(!0);
|
|
136
|
+
const t = E.current;
|
|
132
137
|
(async () => {
|
|
133
138
|
try {
|
|
134
139
|
const e = await G(t);
|
|
135
140
|
if (!e) {
|
|
136
|
-
|
|
141
|
+
g(!1);
|
|
137
142
|
return;
|
|
138
143
|
}
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
144
|
+
E.current = t + 1, g(e.hasMore), i((n) => {
|
|
145
|
+
const r = new Set(
|
|
146
|
+
n.flatMap(
|
|
142
147
|
(o) => o.messageId ? [o.id, o.messageId] : [o.id]
|
|
143
148
|
)
|
|
144
149
|
), s = e.messages.filter(
|
|
145
|
-
(o) => !
|
|
150
|
+
(o) => !r.has(o.id)
|
|
146
151
|
);
|
|
147
|
-
return s.length > 0 ? [...s, ...
|
|
152
|
+
return s.length > 0 ? [...s, ...n] : n;
|
|
148
153
|
});
|
|
149
154
|
} catch (e) {
|
|
150
|
-
|
|
155
|
+
S?.(
|
|
151
156
|
e instanceof Error ? e : new Error(String(e))
|
|
152
157
|
);
|
|
153
158
|
} finally {
|
|
154
|
-
|
|
159
|
+
H.current = !1, F(!1);
|
|
155
160
|
}
|
|
156
161
|
})();
|
|
157
|
-
}, [
|
|
162
|
+
}, [i, $, S, G]);
|
|
158
163
|
Y(() => {
|
|
159
|
-
l &&
|
|
160
|
-
}, [l]), Y(() => () =>
|
|
161
|
-
const
|
|
164
|
+
l && Ct();
|
|
165
|
+
}, [l]), Y(() => () => u.current?.(), []);
|
|
166
|
+
const w = a(
|
|
162
167
|
(t) => {
|
|
163
|
-
const e =
|
|
164
|
-
|
|
165
|
-
(
|
|
166
|
-
if (
|
|
167
|
-
return
|
|
168
|
+
const e = C.current;
|
|
169
|
+
C.current = null, e && i(
|
|
170
|
+
(n) => n.map((r) => {
|
|
171
|
+
if (r.id !== e)
|
|
172
|
+
return r;
|
|
168
173
|
const s = {
|
|
169
|
-
...
|
|
174
|
+
...r,
|
|
170
175
|
isStreaming: !1
|
|
171
176
|
};
|
|
172
177
|
return t ? t(s) : s;
|
|
173
178
|
}).filter(
|
|
174
|
-
(
|
|
179
|
+
(r) => r.id !== e || r.content.length > 0 || r.wasInterrupted === !0
|
|
175
180
|
)
|
|
176
181
|
);
|
|
177
182
|
},
|
|
178
|
-
[
|
|
179
|
-
), rt =
|
|
183
|
+
[i]
|
|
184
|
+
), rt = a(
|
|
180
185
|
(t) => {
|
|
181
|
-
const e =
|
|
186
|
+
const e = C.current;
|
|
182
187
|
if (t.type === "STREAM") {
|
|
183
|
-
const
|
|
184
|
-
if (!e || !
|
|
188
|
+
const n = Z(t).text;
|
|
189
|
+
if (!e || !n)
|
|
185
190
|
return;
|
|
186
|
-
|
|
187
|
-
(
|
|
191
|
+
i(
|
|
192
|
+
(r) => r.map(
|
|
188
193
|
(s) => s.id === e ? {
|
|
189
194
|
...s,
|
|
190
|
-
content: s.content +
|
|
195
|
+
content: s.content + n,
|
|
191
196
|
messageId: t.messageId ?? s.messageId
|
|
192
197
|
} : s
|
|
193
198
|
)
|
|
@@ -196,58 +201,58 @@ const nt = "Something went wrong. Please try again.", Nt = ({
|
|
|
196
201
|
}
|
|
197
202
|
if (t.type === "TEXT") {
|
|
198
203
|
const {
|
|
199
|
-
text:
|
|
200
|
-
followUps:
|
|
204
|
+
text: n,
|
|
205
|
+
followUps: r,
|
|
201
206
|
toolResults: s,
|
|
202
207
|
responseId: o
|
|
203
208
|
} = Z(t);
|
|
204
|
-
|
|
209
|
+
w((d) => ({
|
|
205
210
|
...d,
|
|
206
|
-
content:
|
|
211
|
+
content: n,
|
|
207
212
|
messageId: t.messageId ?? d.messageId,
|
|
208
|
-
...
|
|
213
|
+
...r ? { followUps: r } : {},
|
|
209
214
|
// Kept on the message, not just handled in passing, so the
|
|
210
215
|
// action button is still there after a reload.
|
|
211
216
|
...s ? { toolResults: s } : {}
|
|
212
|
-
})),
|
|
213
|
-
text:
|
|
217
|
+
})), O(o), I(), V?.({
|
|
218
|
+
text: n,
|
|
214
219
|
responseId: o,
|
|
215
|
-
followUps:
|
|
220
|
+
followUps: r
|
|
216
221
|
});
|
|
217
222
|
return;
|
|
218
223
|
}
|
|
219
|
-
t.type === "ERROR" && (M(Z(t).text || nt),
|
|
224
|
+
t.type === "ERROR" && (M(Z(t).text || nt), w(), I());
|
|
220
225
|
},
|
|
221
226
|
[
|
|
222
|
-
|
|
223
|
-
|
|
227
|
+
i,
|
|
228
|
+
w,
|
|
224
229
|
V,
|
|
225
|
-
|
|
226
|
-
|
|
230
|
+
I,
|
|
231
|
+
O
|
|
227
232
|
]
|
|
228
|
-
), X =
|
|
233
|
+
), X = a(
|
|
229
234
|
(t) => {
|
|
230
|
-
const e = t.trim(),
|
|
231
|
-
if (!e || !
|
|
235
|
+
const e = t.trim(), n = T.current;
|
|
236
|
+
if (!e || !n || P)
|
|
232
237
|
return;
|
|
233
238
|
M(void 0);
|
|
234
|
-
const
|
|
235
|
-
|
|
239
|
+
const r = Date.now(), s = `copilot-a-${r}`;
|
|
240
|
+
C.current = s, i((o) => [
|
|
236
241
|
...o,
|
|
237
242
|
{
|
|
238
|
-
id: `copilot-u-${
|
|
243
|
+
id: `copilot-u-${r}`,
|
|
239
244
|
role: "user",
|
|
240
245
|
content: e,
|
|
241
|
-
timestamp:
|
|
246
|
+
timestamp: r
|
|
242
247
|
},
|
|
243
248
|
{
|
|
244
249
|
id: s,
|
|
245
250
|
role: "assistant",
|
|
246
251
|
content: "",
|
|
247
|
-
timestamp:
|
|
252
|
+
timestamp: r + 1,
|
|
248
253
|
isStreaming: !0
|
|
249
254
|
}
|
|
250
|
-
]),
|
|
255
|
+
]), v(!0), I(), u.current = Ht(
|
|
251
256
|
{
|
|
252
257
|
baseUrl: _,
|
|
253
258
|
endpointPath: W,
|
|
@@ -255,123 +260,123 @@ const nt = "Something went wrong. Please try again.", Nt = ({
|
|
|
255
260
|
authToken: x,
|
|
256
261
|
getAuthToken: L,
|
|
257
262
|
fetchImpl: A,
|
|
258
|
-
storeId:
|
|
259
|
-
agent:
|
|
260
|
-
route:
|
|
263
|
+
storeId: c,
|
|
264
|
+
agent: m,
|
|
265
|
+
route: R,
|
|
261
266
|
userPrompt: e,
|
|
262
|
-
sessionId:
|
|
267
|
+
sessionId: n,
|
|
263
268
|
previousResponseId: z.current,
|
|
264
269
|
systemPrompt: Q
|
|
265
270
|
},
|
|
266
271
|
{
|
|
267
272
|
onEvent: rt,
|
|
268
273
|
onComplete: () => {
|
|
269
|
-
|
|
274
|
+
w(), v(!1), u.current = null, I();
|
|
270
275
|
},
|
|
271
276
|
onError: (o) => {
|
|
272
|
-
M(o.message || nt),
|
|
277
|
+
M(o.message || nt), w(), v(!1), u.current = null, I(), S?.(o);
|
|
273
278
|
},
|
|
274
279
|
onAbort: () => {
|
|
275
|
-
|
|
280
|
+
w(), v(!1), u.current = null, I();
|
|
276
281
|
}
|
|
277
282
|
}
|
|
278
283
|
);
|
|
279
284
|
},
|
|
280
285
|
[
|
|
281
|
-
|
|
286
|
+
i,
|
|
282
287
|
x,
|
|
283
288
|
_,
|
|
284
289
|
W,
|
|
285
290
|
A,
|
|
286
|
-
|
|
287
|
-
|
|
291
|
+
m,
|
|
292
|
+
w,
|
|
288
293
|
L,
|
|
289
294
|
rt,
|
|
290
295
|
b,
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
+
P,
|
|
297
|
+
S,
|
|
298
|
+
R,
|
|
299
|
+
I,
|
|
300
|
+
c,
|
|
296
301
|
Q
|
|
297
302
|
]
|
|
298
|
-
),
|
|
303
|
+
), dt = a(() => {
|
|
299
304
|
f.current.some(
|
|
300
305
|
(e) => e.role === "assistant" && e.content.length > 0
|
|
301
|
-
) && X(
|
|
302
|
-
}, [X]),
|
|
303
|
-
(t, e,
|
|
304
|
-
const
|
|
306
|
+
) && X(ht);
|
|
307
|
+
}, [X]), pt = a(
|
|
308
|
+
(t, e, n) => {
|
|
309
|
+
const r = U.current, s = T.current;
|
|
305
310
|
if (!s)
|
|
306
311
|
return;
|
|
307
312
|
const o = f.current.find(
|
|
308
313
|
(d) => (d.messageId ?? d.id) === t
|
|
309
314
|
);
|
|
310
|
-
|
|
311
|
-
baseUrl:
|
|
312
|
-
endpointPath:
|
|
313
|
-
headers:
|
|
314
|
-
authToken:
|
|
315
|
-
getAuthToken:
|
|
316
|
-
fetchImpl:
|
|
317
|
-
storeId:
|
|
315
|
+
wt({
|
|
316
|
+
baseUrl: r.baseUrl,
|
|
317
|
+
endpointPath: r.feedbackPath,
|
|
318
|
+
headers: r.headers,
|
|
319
|
+
authToken: r.authToken,
|
|
320
|
+
getAuthToken: r.getAuthToken,
|
|
321
|
+
fetchImpl: r.fetchImpl,
|
|
322
|
+
storeId: r.storeId,
|
|
318
323
|
sessionId: s,
|
|
319
324
|
messageId: t,
|
|
320
325
|
feedback: e,
|
|
321
326
|
route: k.current,
|
|
322
327
|
reply: o?.content,
|
|
323
|
-
user:
|
|
324
|
-
reasons:
|
|
325
|
-
comment:
|
|
328
|
+
user: r.user,
|
|
329
|
+
reasons: n?.reasons,
|
|
330
|
+
comment: n?.comment
|
|
326
331
|
}).catch((d) => {
|
|
327
|
-
|
|
332
|
+
S?.(
|
|
328
333
|
d instanceof Error ? d : new Error(String(d))
|
|
329
334
|
);
|
|
330
335
|
});
|
|
331
336
|
},
|
|
332
|
-
[
|
|
333
|
-
),
|
|
334
|
-
if (!
|
|
337
|
+
[S]
|
|
338
|
+
), mt = a(() => {
|
|
339
|
+
if (!u.current)
|
|
335
340
|
return;
|
|
336
|
-
const t =
|
|
337
|
-
t &&
|
|
341
|
+
const t = C.current;
|
|
342
|
+
t && i(
|
|
338
343
|
(e) => e.map(
|
|
339
|
-
(
|
|
344
|
+
(n) => n.id === t ? { ...n, wasInterrupted: !0 } : n
|
|
340
345
|
)
|
|
341
|
-
),
|
|
342
|
-
}, [
|
|
343
|
-
|
|
344
|
-
const t = k.current, e =
|
|
345
|
-
|
|
346
|
+
), u.current(), u.current = null;
|
|
347
|
+
}, [i]), Rt = a(() => {
|
|
348
|
+
u.current?.(), u.current = null, C.current = null, v(!1), M(void 0), E.current = 1, H.current = !1, F(!1), g(!1);
|
|
349
|
+
const t = k.current, e = T.current, n = y ?? Ot({ route: t, storeId: c });
|
|
350
|
+
T.current = n, tt(n), f.current = [], B([]), O(void 0), l && e && Tt(t, e), N?.(n);
|
|
346
351
|
}, [
|
|
347
352
|
N,
|
|
348
353
|
l,
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
]),
|
|
353
|
-
() =>
|
|
354
|
-
[
|
|
354
|
+
y,
|
|
355
|
+
O,
|
|
356
|
+
c
|
|
357
|
+
]), gt = It(
|
|
358
|
+
() => P && !D.some((t) => t.isStreaming && t.content),
|
|
359
|
+
[P, D]
|
|
355
360
|
);
|
|
356
361
|
return {
|
|
357
362
|
messages: D,
|
|
358
|
-
sessionId:
|
|
359
|
-
previousResponseId:
|
|
360
|
-
isStreaming:
|
|
361
|
-
isThinking:
|
|
362
|
-
isRestoring:
|
|
363
|
-
isLoadingHistory:
|
|
363
|
+
sessionId: ot,
|
|
364
|
+
previousResponseId: it,
|
|
365
|
+
isStreaming: P,
|
|
366
|
+
isThinking: gt,
|
|
367
|
+
isRestoring: ct,
|
|
368
|
+
isLoadingHistory: lt,
|
|
364
369
|
hasMoreHistory: $,
|
|
365
|
-
error:
|
|
370
|
+
error: ut,
|
|
366
371
|
sendMessage: X,
|
|
367
|
-
regenerate:
|
|
368
|
-
submitFeedback:
|
|
369
|
-
loadOlderMessages:
|
|
370
|
-
stopStreaming:
|
|
371
|
-
startNewConversation:
|
|
372
|
+
regenerate: dt,
|
|
373
|
+
submitFeedback: pt,
|
|
374
|
+
loadOlderMessages: ft,
|
|
375
|
+
stopStreaming: mt,
|
|
376
|
+
startNewConversation: Rt
|
|
372
377
|
};
|
|
373
378
|
};
|
|
374
379
|
export {
|
|
375
|
-
|
|
380
|
+
Dt as useCopilotStreamChat
|
|
376
381
|
};
|
|
377
382
|
//# sourceMappingURL=useCopilotStreamChat.js.map
|