@bikdotai/bik-component-library 0.0.870 → 0.0.872

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.
Files changed (114) hide show
  1. package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js +5 -5
  2. package/dist/cjs/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
  3. package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js +5 -5
  4. package/dist/cjs/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  5. package/dist/cjs/components/agent-builder/components/MentionPicker.js +27 -27
  6. package/dist/cjs/components/agent-builder/components/MentionPicker.js.map +1 -1
  7. package/dist/cjs/components/agent-builder/components/SelectableListSection.js +6 -6
  8. package/dist/cjs/components/agent-builder/components/SelectableListSection.js.map +1 -1
  9. package/dist/cjs/components/agent-builder/constants/tools.js +1 -1
  10. package/dist/cjs/components/agent-builder/constants/tools.js.map +1 -1
  11. package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js +1 -1
  12. package/dist/cjs/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
  13. package/dist/cjs/components/agent-builder/utils/sourceGrouping.js +2 -0
  14. package/dist/cjs/components/agent-builder/utils/sourceGrouping.js.map +1 -0
  15. package/dist/cjs/components/agent-builder/utils/sourceIcons.js +1 -1
  16. package/dist/cjs/components/agent-builder/utils/sourceIcons.js.map +1 -1
  17. package/dist/cjs/components/agent-builder/utils/toolActions.js +1 -1
  18. package/dist/cjs/components/agent-builder/utils/toolActions.js.map +1 -1
  19. package/dist/cjs/components/bik-copilot/CopilotPanel.js +1 -1
  20. package/dist/cjs/components/bik-copilot/CopilotPanel.js.map +1 -1
  21. package/dist/cjs/components/bik-copilot/useCopilotStreamChat.js +1 -1
  22. package/dist/cjs/components/bik-copilot/useCopilotStreamChat.js.map +1 -1
  23. package/dist/cjs/icons/Social/Channels/Aftership.js +2 -0
  24. package/dist/cjs/icons/Social/Channels/Aftership.js.map +1 -0
  25. package/dist/cjs/icons/Social/Channels/Attentive.js +2 -0
  26. package/dist/cjs/icons/Social/Channels/Attentive.js.map +1 -0
  27. package/dist/cjs/icons/Social/Channels/Freshdesk.js +2 -0
  28. package/dist/cjs/icons/Social/Channels/Freshdesk.js.map +1 -0
  29. package/dist/cjs/icons/Social/Channels/GoogleSheets.js +2 -0
  30. package/dist/cjs/icons/Social/Channels/GoogleSheets.js.map +1 -0
  31. package/dist/cjs/icons/Social/Channels/Klavyio.js +2 -0
  32. package/dist/cjs/icons/Social/Channels/Klavyio.js.map +1 -0
  33. package/dist/cjs/icons/Social/Channels/Kustomer.js +2 -0
  34. package/dist/cjs/icons/Social/Channels/Kustomer.js.map +1 -0
  35. package/dist/cjs/icons/Social/Channels/Mailchimp.js +2 -0
  36. package/dist/cjs/icons/Social/Channels/Mailchimp.js.map +1 -0
  37. package/dist/cjs/icons/Social/Channels/OmniSend.js +2 -0
  38. package/dist/cjs/icons/Social/Channels/OmniSend.js.map +1 -0
  39. package/dist/cjs/icons/Social/Channels/Segment.js +2 -0
  40. package/dist/cjs/icons/Social/Channels/Segment.js.map +1 -0
  41. package/dist/cjs/icons/Social/Channels/ShipBob.js +2 -0
  42. package/dist/cjs/icons/Social/Channels/ShipBob.js.map +1 -0
  43. package/dist/cjs/icons/Social/Channels/Skio.js +1 -1
  44. package/dist/cjs/icons/Social/Channels/Skio.js.map +1 -1
  45. package/dist/cjs/icons/index.js +1 -1
  46. package/dist/esm/components/agent-builder/__fixtures__/integrationCatalog.d.ts +17 -0
  47. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js +104 -96
  48. package/dist/esm/components/agent-builder/components/ConfigToolPanel.js.map +1 -1
  49. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js +256 -242
  50. package/dist/esm/components/agent-builder/components/CreateSubAgentPanel.js.map +1 -1
  51. package/dist/esm/components/agent-builder/components/MentionPicker.d.ts +0 -10
  52. package/dist/esm/components/agent-builder/components/MentionPicker.js +201 -199
  53. package/dist/esm/components/agent-builder/components/MentionPicker.js.map +1 -1
  54. package/dist/esm/components/agent-builder/components/SelectableListSection.d.ts +9 -0
  55. package/dist/esm/components/agent-builder/components/SelectableListSection.js +213 -188
  56. package/dist/esm/components/agent-builder/components/SelectableListSection.js.map +1 -1
  57. package/dist/esm/components/agent-builder/constants/tools.d.ts +46 -22
  58. package/dist/esm/components/agent-builder/constants/tools.js +86 -35
  59. package/dist/esm/components/agent-builder/constants/tools.js.map +1 -1
  60. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js +289 -279
  61. package/dist/esm/components/agent-builder/steps/Step3HowItResponds.js.map +1 -1
  62. package/dist/esm/components/agent-builder/utils/sourceGrouping.d.ts +39 -0
  63. package/dist/esm/components/agent-builder/utils/sourceGrouping.js +14 -0
  64. package/dist/esm/components/agent-builder/utils/sourceGrouping.js.map +1 -0
  65. package/dist/esm/components/agent-builder/utils/sourceIcons.d.ts +6 -4
  66. package/dist/esm/components/agent-builder/utils/sourceIcons.js +64 -33
  67. package/dist/esm/components/agent-builder/utils/sourceIcons.js.map +1 -1
  68. package/dist/esm/components/agent-builder/utils/toolActions.d.ts +11 -6
  69. package/dist/esm/components/agent-builder/utils/toolActions.js +23 -16
  70. package/dist/esm/components/agent-builder/utils/toolActions.js.map +1 -1
  71. package/dist/esm/components/bik-copilot/CopilotPanel.js +235 -244
  72. package/dist/esm/components/bik-copilot/CopilotPanel.js.map +1 -1
  73. package/dist/esm/components/bik-copilot/model.d.ts +4 -2
  74. package/dist/esm/components/bik-copilot/useCopilotStreamChat.d.ts +0 -18
  75. package/dist/esm/components/bik-copilot/useCopilotStreamChat.js +168 -163
  76. package/dist/esm/components/bik-copilot/useCopilotStreamChat.js.map +1 -1
  77. package/dist/esm/icons/Social/Channels/Aftership.d.ts +6 -0
  78. package/dist/esm/icons/Social/Channels/Aftership.js +47 -0
  79. package/dist/esm/icons/Social/Channels/Aftership.js.map +1 -0
  80. package/dist/esm/icons/Social/Channels/Attentive.d.ts +6 -0
  81. package/dist/esm/icons/Social/Channels/Attentive.js +54 -0
  82. package/dist/esm/icons/Social/Channels/Attentive.js.map +1 -0
  83. package/dist/esm/icons/Social/Channels/Freshdesk.d.ts +6 -0
  84. package/dist/esm/icons/Social/Channels/Freshdesk.js +47 -0
  85. package/dist/esm/icons/Social/Channels/Freshdesk.js.map +1 -0
  86. package/dist/esm/icons/Social/Channels/GoogleSheets.d.ts +6 -0
  87. package/dist/esm/icons/Social/Channels/GoogleSheets.js +53 -0
  88. package/dist/esm/icons/Social/Channels/GoogleSheets.js.map +1 -0
  89. package/dist/esm/icons/Social/Channels/Klavyio.d.ts +6 -0
  90. package/dist/esm/icons/Social/Channels/Klavyio.js +47 -0
  91. package/dist/esm/icons/Social/Channels/Klavyio.js.map +1 -0
  92. package/dist/esm/icons/Social/Channels/Kustomer.d.ts +6 -0
  93. package/dist/esm/icons/Social/Channels/Kustomer.js +68 -0
  94. package/dist/esm/icons/Social/Channels/Kustomer.js.map +1 -0
  95. package/dist/esm/icons/Social/Channels/Mailchimp.d.ts +6 -0
  96. package/dist/esm/icons/Social/Channels/Mailchimp.js +31 -0
  97. package/dist/esm/icons/Social/Channels/Mailchimp.js.map +1 -0
  98. package/dist/esm/icons/Social/Channels/OmniSend.d.ts +6 -0
  99. package/dist/esm/icons/Social/Channels/OmniSend.js +47 -0
  100. package/dist/esm/icons/Social/Channels/OmniSend.js.map +1 -0
  101. package/dist/esm/icons/Social/Channels/Segment.d.ts +6 -0
  102. package/dist/esm/icons/Social/Channels/Segment.js +53 -0
  103. package/dist/esm/icons/Social/Channels/Segment.js.map +1 -0
  104. package/dist/esm/icons/Social/Channels/ShipBob.d.ts +6 -0
  105. package/dist/esm/icons/Social/Channels/ShipBob.js +28 -0
  106. package/dist/esm/icons/Social/Channels/ShipBob.js.map +1 -0
  107. package/dist/esm/icons/Social/Channels/Skio.js +41 -19
  108. package/dist/esm/icons/Social/Channels/Skio.js.map +1 -1
  109. package/dist/esm/icons/Social/Channels/Zendesk.d.ts +6 -0
  110. package/dist/esm/icons/Social/Channels/index.d.ts +10 -0
  111. package/dist/esm/icons/index.d.ts +26 -25
  112. package/dist/esm/icons/index.js +658 -638
  113. package/dist/esm/icons/index.js.map +1 -1
  114. package/package.json +1 -1
@@ -1,23 +1,25 @@
1
- import { useState as I, useRef as p, useCallback as i, useEffect as Y, useMemo as gt } from "react";
2
- import { COPILOT_REGENERATE_PROMPT as It } from "./copilotRegenerate.js";
3
- import { persistCopilotTurn as ht, pruneCopilotSessions as yt, deleteCopilotSession as Ct, loadCopilotSession as Tt } from "./services/copilotDb.js";
4
- import { sendCopilotFeedback as Et } from "./services/copilotFeedbackClient.js";
5
- import { fetchCopilotMessages as wt, COPILOT_HISTORY_PAGE_SIZE as St } from "./services/copilotMessagesClient.js";
6
- import { resetCopilotSessionForRoute as vt, resolveCopilotSessionIdForRoute as Ot, getCopilotSessionIdForRoute as Mt } from "./services/copilotPageSession.js";
7
- import { readCopilotEventContent as Z, streamCopilotChat as Pt } from "./services/copilotStreamClient.js";
8
- import { DEFAULT_COPILOT_ROUTE as Ht, DEFAULT_COPILOT_AGENT as _t } from "./useCopilotIcebreakers.js";
9
- const nt = "Something went wrong. Please try again.", Nt = ({
10
- storeId: a,
11
- agent: H = _t,
12
- route: m = Ht,
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: h,
20
+ sessionId: y,
19
21
  persist: l = !0,
20
- onError: w,
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] = I([]), [st, tt] = I(
31
- h ?? null
32
- ), [O, S] = I(!1), [ot, et] = I(!0), [ct, M] = I(), [ut, it] = I(), [at, F] = I(!1), [$, R] = I(!1), f = p([]), z = p(void 0), y = p(null), c = p(null), C = p(h ?? null), k = p(m);
33
- k.current = m;
34
- const T = p(1), P = p(!1), u = i(
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
- ), v = i((t) => {
41
- z.current = t, it(t);
42
- }, []), g = i(() => {
43
- const t = C.current;
44
- !l || !t || ht({
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: a,
50
- agent: H
51
+ storeId: c,
52
+ agent: m
51
53
  });
52
- }, [H, l, a]), U = p({
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: a,
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: a,
74
+ storeId: c,
73
75
  loadHistory: K,
74
76
  user: J
75
77
  };
76
- const G = i(async (t) => {
77
- const e = U.current, r = C.current;
78
- return !e.loadHistory || !r ? null : wt({
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: r,
90
+ sessionId: n,
87
91
  page: t,
88
- pageSize: St
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
- c.current?.(), c.current = null, y.current = null, S(!1), M(void 0), et(!0), R(!1), P.current = !1, F(!1);
95
- const r = h ?? (l ? await Ot({ route: m, storeId: a }) : Mt({ route: m, storeId: a })), n = l ? await Tt(m, r) : null;
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 (C.current = r, tt(r), f.current = n?.messages ?? [], B(f.current), v(n?.previousResponseId), et(!1), N?.(r), f.current.length > 0) {
98
- T.current = 2, R(U.current.loadHistory);
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 (!h) {
102
- T.current = 1, R(!1);
106
+ if (!y) {
107
+ E.current = 1, g(!1);
103
108
  return;
104
109
  }
105
- T.current = 1;
110
+ E.current = 1;
106
111
  try {
107
112
  const s = await G(1);
108
113
  if (t || !s)
109
114
  return;
110
- T.current = 2, u(() => s.messages), R(s.hasMore);
115
+ E.current = 2, i(() => s.messages), g(s.hasMore);
111
116
  } catch {
112
- R(!1);
117
+ g(!1);
113
118
  }
114
119
  }
115
120
  })(), () => {
116
121
  t = !0;
117
122
  };
118
123
  }, [
119
- m,
120
- a,
121
- h,
124
+ R,
125
+ c,
126
+ y,
122
127
  l,
123
- v,
124
- u,
128
+ O,
129
+ i,
125
130
  G
126
131
  ]);
127
- const lt = i(() => {
128
- if (P.current || !$)
132
+ const ft = a(() => {
133
+ if (H.current || !$)
129
134
  return;
130
- P.current = !0, F(!0);
131
- const t = T.current;
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
- R(!1);
141
+ g(!1);
137
142
  return;
138
143
  }
139
- T.current = t + 1, R(e.hasMore), u((r) => {
140
- const n = new Set(
141
- r.flatMap(
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) => !n.has(o.id)
150
+ (o) => !r.has(o.id)
146
151
  );
147
- return s.length > 0 ? [...s, ...r] : r;
152
+ return s.length > 0 ? [...s, ...n] : n;
148
153
  });
149
154
  } catch (e) {
150
- w?.(
155
+ S?.(
151
156
  e instanceof Error ? e : new Error(String(e))
152
157
  );
153
158
  } finally {
154
- P.current = !1, F(!1);
159
+ H.current = !1, F(!1);
155
160
  }
156
161
  })();
157
- }, [u, $, w, G]);
162
+ }, [i, $, S, G]);
158
163
  Y(() => {
159
- l && yt();
160
- }, [l]), Y(() => () => c.current?.(), []);
161
- const E = i(
164
+ l && Ct();
165
+ }, [l]), Y(() => () => u.current?.(), []);
166
+ const w = a(
162
167
  (t) => {
163
- const e = y.current;
164
- y.current = null, e && u(
165
- (r) => r.map((n) => {
166
- if (n.id !== e)
167
- return n;
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
- ...n,
174
+ ...r,
170
175
  isStreaming: !1
171
176
  };
172
177
  return t ? t(s) : s;
173
178
  }).filter(
174
- (n) => n.id !== e || n.content.length > 0 || n.wasInterrupted === !0
179
+ (r) => r.id !== e || r.content.length > 0 || r.wasInterrupted === !0
175
180
  )
176
181
  );
177
182
  },
178
- [u]
179
- ), rt = i(
183
+ [i]
184
+ ), rt = a(
180
185
  (t) => {
181
- const e = y.current;
186
+ const e = C.current;
182
187
  if (t.type === "STREAM") {
183
- const r = Z(t).text;
184
- if (!e || !r)
188
+ const n = Z(t).text;
189
+ if (!e || !n)
185
190
  return;
186
- u(
187
- (n) => n.map(
191
+ i(
192
+ (r) => r.map(
188
193
  (s) => s.id === e ? {
189
194
  ...s,
190
- content: s.content + r,
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: r,
200
- followUps: n,
204
+ text: n,
205
+ followUps: r,
201
206
  toolResults: s,
202
207
  responseId: o
203
208
  } = Z(t);
204
- E((d) => ({
209
+ w((d) => ({
205
210
  ...d,
206
- content: r,
211
+ content: n,
207
212
  messageId: t.messageId ?? d.messageId,
208
- ...n ? { followUps: n } : {},
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
- })), v(o), g(), V?.({
213
- text: r,
217
+ })), O(o), I(), V?.({
218
+ text: n,
214
219
  responseId: o,
215
- followUps: n
220
+ followUps: r
216
221
  });
217
222
  return;
218
223
  }
219
- t.type === "ERROR" && (M(Z(t).text || nt), E(), g());
224
+ t.type === "ERROR" && (M(Z(t).text || nt), w(), I());
220
225
  },
221
226
  [
222
- u,
223
- E,
227
+ i,
228
+ w,
224
229
  V,
225
- g,
226
- v
230
+ I,
231
+ O
227
232
  ]
228
- ), X = i(
233
+ ), X = a(
229
234
  (t) => {
230
- const e = t.trim(), r = C.current;
231
- if (!e || !r || O)
235
+ const e = t.trim(), n = T.current;
236
+ if (!e || !n || P)
232
237
  return;
233
238
  M(void 0);
234
- const n = Date.now(), s = `copilot-a-${n}`;
235
- y.current = s, u((o) => [
239
+ const r = Date.now(), s = `copilot-a-${r}`;
240
+ C.current = s, i((o) => [
236
241
  ...o,
237
242
  {
238
- id: `copilot-u-${n}`,
243
+ id: `copilot-u-${r}`,
239
244
  role: "user",
240
245
  content: e,
241
- timestamp: n
246
+ timestamp: r
242
247
  },
243
248
  {
244
249
  id: s,
245
250
  role: "assistant",
246
251
  content: "",
247
- timestamp: n + 1,
252
+ timestamp: r + 1,
248
253
  isStreaming: !0
249
254
  }
250
- ]), S(!0), g(), c.current = Pt(
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: a,
259
- agent: H,
260
- route: m,
263
+ storeId: c,
264
+ agent: m,
265
+ route: R,
261
266
  userPrompt: e,
262
- sessionId: r,
267
+ sessionId: n,
263
268
  previousResponseId: z.current,
264
269
  systemPrompt: Q
265
270
  },
266
271
  {
267
272
  onEvent: rt,
268
273
  onComplete: () => {
269
- E(), S(!1), c.current = null, g();
274
+ w(), v(!1), u.current = null, I();
270
275
  },
271
276
  onError: (o) => {
272
- M(o.message || nt), E(), S(!1), c.current = null, g(), w?.(o);
277
+ M(o.message || nt), w(), v(!1), u.current = null, I(), S?.(o);
273
278
  },
274
279
  onAbort: () => {
275
- E(), S(!1), c.current = null, g();
280
+ w(), v(!1), u.current = null, I();
276
281
  }
277
282
  }
278
283
  );
279
284
  },
280
285
  [
281
- u,
286
+ i,
282
287
  x,
283
288
  _,
284
289
  W,
285
290
  A,
286
- H,
287
- E,
291
+ m,
292
+ w,
288
293
  L,
289
294
  rt,
290
295
  b,
291
- O,
292
- w,
293
- m,
294
- g,
295
- a,
296
+ P,
297
+ S,
298
+ R,
299
+ I,
300
+ c,
296
301
  Q
297
302
  ]
298
- ), ft = i(() => {
303
+ ), dt = a(() => {
299
304
  f.current.some(
300
305
  (e) => e.role === "assistant" && e.content.length > 0
301
- ) && X(It);
302
- }, [X]), dt = i(
303
- (t, e, r) => {
304
- const n = U.current, s = C.current;
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
- Et({
311
- baseUrl: n.baseUrl,
312
- endpointPath: n.feedbackPath,
313
- headers: n.headers,
314
- authToken: n.authToken,
315
- getAuthToken: n.getAuthToken,
316
- fetchImpl: n.fetchImpl,
317
- storeId: n.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: n.user,
324
- reasons: r?.reasons,
325
- comment: r?.comment
328
+ user: r.user,
329
+ reasons: n?.reasons,
330
+ comment: n?.comment
326
331
  }).catch((d) => {
327
- w?.(
332
+ S?.(
328
333
  d instanceof Error ? d : new Error(String(d))
329
334
  );
330
335
  });
331
336
  },
332
- [w]
333
- ), pt = i(() => {
334
- if (!c.current)
337
+ [S]
338
+ ), mt = a(() => {
339
+ if (!u.current)
335
340
  return;
336
- const t = y.current;
337
- t && u(
341
+ const t = C.current;
342
+ t && i(
338
343
  (e) => e.map(
339
- (r) => r.id === t ? { ...r, wasInterrupted: !0 } : r
344
+ (n) => n.id === t ? { ...n, wasInterrupted: !0 } : n
340
345
  )
341
- ), c.current(), c.current = null;
342
- }, [u]), mt = i(() => {
343
- c.current?.(), c.current = null, y.current = null, S(!1), M(void 0), T.current = 1, P.current = !1, F(!1), R(!1);
344
- const t = k.current, e = C.current, r = h ?? vt({ route: t, storeId: a });
345
- C.current = r, tt(r), f.current = [], B([]), v(void 0), l && e && Ct(t, e), N?.(r);
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
- h,
350
- v,
351
- a
352
- ]), Rt = gt(
353
- () => O && !D.some((t) => t.isStreaming && t.content),
354
- [O, D]
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: st,
359
- previousResponseId: ut,
360
- isStreaming: O,
361
- isThinking: Rt,
362
- isRestoring: ot,
363
- isLoadingHistory: at,
363
+ sessionId: ot,
364
+ previousResponseId: it,
365
+ isStreaming: P,
366
+ isThinking: gt,
367
+ isRestoring: ct,
368
+ isLoadingHistory: lt,
364
369
  hasMoreHistory: $,
365
- error: ct,
370
+ error: ut,
366
371
  sendMessage: X,
367
- regenerate: ft,
368
- submitFeedback: dt,
369
- loadOlderMessages: lt,
370
- stopStreaming: pt,
371
- startNewConversation: mt
372
+ regenerate: dt,
373
+ submitFeedback: pt,
374
+ loadOlderMessages: ft,
375
+ stopStreaming: mt,
376
+ startNewConversation: Rt
372
377
  };
373
378
  };
374
379
  export {
375
- Nt as useCopilotStreamChat
380
+ Dt as useCopilotStreamChat
376
381
  };
377
382
  //# sourceMappingURL=useCopilotStreamChat.js.map