@inkeep/agents-ui 0.0.0-dev-20260721222136 → 0.0.0-dev-20260804222744

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.
@@ -1,27 +1,27 @@
1
1
  "use client";
2
- import { useChat as it } from "@ai-sdk/react";
3
- import { normalizeFileType as ct } from "./file-upload-input.js";
4
- import { DefaultChatTransport as lt } from "ai";
5
- import { useRef as i, useEffect as _, useState as k, useMemo as Oe, useCallback as $, useImperativeHandle as ut } from "react";
6
- import { useInkeepConfig as dt } from "../../providers/config-provider.js";
7
- import { useChatAuth as pt } from "../../providers/chat-auth-provider.js";
8
- import { useMediaQuery as ft } from "../../hooks/use-media-query.js";
9
- import { useConversationLoader as mt } from "../../hooks/use-conversation-loader.js";
10
- import { useInitialConversation as gt } from "../../hooks/use-initial-conversation.js";
2
+ import { useChat as lt } from "@ai-sdk/react";
3
+ import { normalizeFileType as ut } from "./file-upload-input.js";
4
+ import { DefaultChatTransport as dt } from "ai";
5
+ import { useRef as i, useEffect as b, useState as k, useMemo as Oe, useCallback as $, useImperativeHandle as pt } from "react";
6
+ import { useInkeepConfig as ft } from "../../providers/config-provider.js";
7
+ import { useChatAuth as mt } from "../../providers/chat-auth-provider.js";
8
+ import { useMediaQuery as gt } from "../../hooks/use-media-query.js";
9
+ import { useConversationLoader as ht } from "../../hooks/use-conversation-loader.js";
10
+ import { useInitialConversation as vt } from "../../hooks/use-initial-conversation.js";
11
11
  import { generateUid as F } from "../../utils/generate-uid.js";
12
- import { useBaseEvents as ht } from "../../providers/base-events-provider.js";
13
- import { useChatForm as vt } from "../../providers/chat-form-provider.js";
14
- import { useWidget as yt } from "../../providers/widget-provider.js";
15
- import { useControllableState as Rt } from "@radix-ui/react-use-controllable-state";
12
+ import { useBaseEvents as yt } from "../../providers/base-events-provider.js";
13
+ import { useChatForm as Rt } from "../../providers/chat-form-provider.js";
14
+ import { useWidget as Et } from "../../providers/widget-provider.js";
15
+ import { useControllableState as St } from "@radix-ui/react-use-controllable-state";
16
16
  import { useStreamingEvents as It } from "../../hooks/use-streaming-events.js";
17
17
  import { useInputNotification as Ct } from "../../hooks/use-input-notification.js";
18
- import { resolveStreamingAuthError as Et, DEFAULT_ERROR_MESSAGE as oe, isRecoverableError as St, isNetworkError as Ne, RECOVERABLE_NOTIFICATION_DURATION_MS as Pe, PAYLOAD_TOO_LARGE_MESSAGE as U, RATE_LIMIT_MESSAGE as Be, NETWORK_ERROR_MESSAGE as At, resolveHttpStatusCode as wt, RECOVERABLE_FALLBACK_MESSAGE as De, estimateRequestBodyBytes as Tt, MAX_REQUEST_BODY_BYTES as bt } from "./chat-error-helpers.js";
19
- const Ht = () => {
20
- const { baseSettings: ae, aiChatSettings: v } = dt(), [c = "", y] = Rt({
18
+ import { resolveStreamingAuthError as At, DEFAULT_ERROR_MESSAGE as ne, isRecoverableError as Tt, isNetworkError as Ne, RECOVERABLE_NOTIFICATION_DURATION_MS as Pe, PAYLOAD_TOO_LARGE_MESSAGE as oe, RATE_LIMIT_MESSAGE as Be, NETWORK_ERROR_MESSAGE as De, NETWORK_ERROR_WITH_FILES_MESSAGE as Le, resolveHttpStatusCode as _t, RECOVERABLE_FALLBACK_MESSAGE as $e, estimateRequestBodyBytes as wt, MAX_REQUEST_BODY_BYTES as Mt } from "./chat-error-helpers.js";
19
+ const bt = 50, jt = () => {
20
+ const { baseSettings: ae, aiChatSettings: v } = ft(), [c = "", y] = St({
21
21
  prop: v.conversationIdOverride,
22
22
  defaultProp: v.conversationIdOverride ?? ""
23
- }), { logEvent: g } = ht(), { setConversationId: Le, emitToParent: x } = It(), ie = i(c);
24
- _(() => {
23
+ }), { logEvent: g } = yt(), { setConversationId: Ue, emitToParent: x } = It(), ie = i(c);
24
+ b(() => {
25
25
  const e = ie.current;
26
26
  ie.current = c, e !== c && g({
27
27
  eventName: "chat_conversation_changed",
@@ -31,10 +31,10 @@ const Ht = () => {
31
31
  }
32
32
  });
33
33
  }, [c, g]);
34
- const [S, A] = k(""), $e = (e) => A(e.target.value), {
35
- shouldBypassCaptcha: Ue,
34
+ const [C, A] = k(""), Ge = (e) => A(e.target.value), {
35
+ shouldBypassCaptcha: He,
36
36
  filters: ce,
37
- userProperties: z,
37
+ userProperties: U,
38
38
  analyticsProperties: G
39
39
  } = ae, {
40
40
  authToken: le,
@@ -46,80 +46,80 @@ const Ht = () => {
46
46
  getCaptchaHeader: O,
47
47
  invalidateCaptcha: d,
48
48
  effectiveAuthToken: me,
49
- applicableRefreshSession: ze
50
- } = pt(), {
51
- onInputMessageChange: Ge,
49
+ applicableRefreshSession: Ke
50
+ } = mt(), {
51
+ onInputMessageChange: ze,
52
52
  filters: ge,
53
53
  baseUrl: he,
54
- agentUrl: Ke,
54
+ agentUrl: qe,
55
55
  context: ve,
56
56
  headers: ye,
57
57
  appId: N,
58
- apiKey: K,
59
- files: w
58
+ apiKey: H,
59
+ files: T
60
60
  } = v, Re = i(O);
61
61
  Re.current = O;
62
- const Ie = Ke || `${he}/run/api/chat`, { loadConversation: Ce } = mt({
62
+ const Ee = qe || `${he}/run/api/chat`, { loadConversation: Se } = ht({
63
63
  baseUrl: he,
64
64
  appId: N,
65
65
  authToken: me,
66
66
  getCaptchaHeader: O,
67
67
  invalidateCaptcha: d,
68
- refreshSession: ze
69
- }), [qe, Ee] = k(!1), q = i(null);
70
- q.current = pe;
71
- const H = i(null);
72
- H.current = le;
73
- const j = i(void 0);
74
- j.current = z && Object.keys(z).length > 0 ? z : void 0;
75
- const V = i(void 0);
76
- V.current = G && Object.keys(G).length > 0 ? G : void 0;
77
- const I = i(0), P = i(null), W = i(null), h = i(void 0), He = w?.map(
68
+ refreshSession: Ke
69
+ }), [We, Ie] = k(!1), K = i(null);
70
+ K.current = pe;
71
+ const z = i(null);
72
+ z.current = le;
73
+ const q = i(void 0);
74
+ q.current = U && Object.keys(U).length > 0 ? U : void 0;
75
+ const W = i(void 0);
76
+ W.current = G && Object.keys(G).length > 0 ? G : void 0;
77
+ const E = i(0), P = i(null), j = i(null), h = i(void 0), je = T?.map(
78
78
  (e) => `${e.filename ?? ""}:${e.mediaType}:${e.url.length}:${e.url.slice(0, 64)}:${e.url.slice(-32)}`
79
79
  ).join(`
80
80
  `) ?? "";
81
- _(() => {
82
- h.current = w?.length ? w : void 0;
83
- }, [He]);
84
- const Se = i(ye);
85
- Se.current = ye;
86
- const Y = i(void 0);
87
- Y.current = ce || ge ? JSON.stringify({ ...ce, ...ge }) : void 0;
88
- const je = (e) => {
81
+ b(() => {
82
+ h.current = T?.length ? T : void 0;
83
+ }, [je]);
84
+ const Ce = i(ye);
85
+ Ce.current = ye;
86
+ const V = i(void 0);
87
+ V.current = ce || ge ? JSON.stringify({ ...ce, ...ge }) : void 0;
88
+ const Ve = (e) => {
89
89
  if (Ne(e))
90
- return P.current?.files?.length ? U : At;
91
- switch (wt(e)) {
90
+ return P.current?.files?.length ? Le : De;
91
+ switch (_t(e)) {
92
92
  case 400:
93
93
  try {
94
94
  const t = JSON.parse(e.message ?? "");
95
- return t.detail ?? t.error?.message ?? De;
95
+ return t.detail ?? t.error?.message ?? $e;
96
96
  } catch {
97
- return e.message?.trim() || De;
97
+ return e.message?.trim() || $e;
98
98
  }
99
99
  case 401:
100
- return ue ? "Authentication failed. Please try again." : oe;
100
+ return ue ? "Authentication failed. Please try again." : ne;
101
101
  case 403:
102
102
  return `There seems to be a configuration error. Please contact ${ae.organizationDisplayName ?? "Administrator"}`;
103
103
  case 413:
104
- return U;
104
+ return oe;
105
105
  case 429:
106
106
  return Be;
107
107
  default:
108
- return oe;
108
+ return ne;
109
109
  }
110
- }, [C, J] = k([]), Ve = Oe(
111
- () => new lt({
112
- api: Ie,
110
+ }, [S, Y] = k([]), Ye = Oe(
111
+ () => new dt({
112
+ api: Ee,
113
113
  headers: () => {
114
- const e = K ?? H.current ?? q.current;
114
+ const e = H ?? z.current ?? K.current;
115
115
  return {
116
116
  "x-inkeep-client-timezone": Intl.DateTimeFormat().resolvedOptions().timeZone,
117
117
  "x-inkeep-client-timestamp": (/* @__PURE__ */ new Date()).toISOString(),
118
118
  "x-inkeep-invocation-type": "chat_widget",
119
119
  ...N ? { "x-inkeep-app-id": N } : {},
120
120
  ...e ? { Authorization: `Bearer ${e}` } : {},
121
- ...Y.current ? { "inkeep-filters": Y.current } : {},
122
- ...Se.current
121
+ ...V.current ? { "inkeep-filters": V.current } : {},
122
+ ...Ce.current
123
123
  };
124
124
  },
125
125
  prepareSendMessagesRequest: async (e) => {
@@ -133,8 +133,8 @@ const Ht = () => {
133
133
  messages: t ? [t] : [],
134
134
  trigger: e.trigger,
135
135
  messageId: e.messageId,
136
- ...j.current ? { userProperties: j.current } : {},
137
- ...V.current ? { properties: V.current } : {}
136
+ ...q.current ? { userProperties: q.current } : {},
137
+ ...W.current ? { properties: W.current } : {}
138
138
  },
139
139
  headers: {
140
140
  ...e.headers,
@@ -146,17 +146,23 @@ const Ht = () => {
146
146
  requestContext: ve
147
147
  }
148
148
  }),
149
- [Ie, ve, N, K]
149
+ [Ee, ve, N, H]
150
150
  ), {
151
- messages: T,
152
- sendMessage: Q,
153
- addToolApprovalResponse: X,
151
+ messages: _,
152
+ sendMessage: J,
153
+ addToolApprovalResponse: Q,
154
154
  status: Ae,
155
155
  setMessages: m,
156
156
  stop: B,
157
157
  error: D
158
- } = it({
159
- transport: Ve,
158
+ } = lt({
159
+ transport: Ye,
160
+ // The SDK notifies React once per streamed chunk, which at typical token
161
+ // rates is 20-60 renders/sec of the whole chat tree. Coalescing to ~20fps
162
+ // is imperceptible while streaming text but caps the render work that grows
163
+ // with conversation length. Does not affect what is streamed, only how
164
+ // often React is told about it.
165
+ experimental_throttle: bt,
160
166
  onData(e) {
161
167
  x(e.type, e.data);
162
168
  },
@@ -177,42 +183,42 @@ const Ht = () => {
177
183
  },
178
184
  onError(e) {
179
185
  console.error("onError", { code: e.code, message: e.message });
180
- const l = Ue || K ? null : Et(e);
181
- if (l !== null && I.current < 1) {
182
- I.current++;
183
- const o = W.current, s = P.current;
186
+ const l = He || H ? null : At(e);
187
+ if (l !== null && E.current < 1) {
188
+ E.current++;
189
+ const o = j.current, r = P.current;
184
190
  (async () => {
185
191
  if (l === "session" && ue) {
186
- const r = await de();
187
- if (!r) throw new Error("Auth token refresh failed");
188
- H.current = r;
192
+ const n = await de();
193
+ if (!n) throw new Error("Auth token refresh failed");
194
+ z.current = n;
189
195
  } else if (l === "session") {
190
- const r = await fe();
191
- r && (q.current = r);
196
+ const n = await fe();
197
+ n && (K.current = n);
192
198
  } else
193
199
  d();
194
200
  if (o) {
195
- X(o);
201
+ Q(o);
196
202
  return;
197
203
  }
198
- s && (m((r) => {
199
- let a = [...r];
204
+ r && (m((n) => {
205
+ let a = [...n];
200
206
  return a.at(-1)?.role === "assistant" && (a = a.slice(0, -1)), a.at(-1)?.role === "user" && (a = a.slice(0, -1)), a;
201
- }), Q(
207
+ }), J(
202
208
  {
203
- id: s.messageId,
209
+ id: r.messageId,
204
210
  parts: [
205
- ...s.content.trim() ? [{ type: "text", text: s.content }] : [],
206
- ...s.files ?? []
211
+ ...r.content.trim() ? [{ type: "text", text: r.content }] : [],
212
+ ...r.files ?? []
207
213
  ]
208
214
  },
209
- { body: s.body }
215
+ { body: r.body }
210
216
  ));
211
217
  })().catch(() => {
212
- I.current = 0, d(), m((r) => {
213
- const a = [...r], f = a[a.length - 1];
218
+ E.current = 0, d(), m((n) => {
219
+ const a = [...n], f = a[a.length - 1];
214
220
  if (!f) return a;
215
- const u = oe;
221
+ const u = ne;
216
222
  return f.role === "user" ? a.push({
217
223
  id: F(16),
218
224
  role: "assistant",
@@ -222,111 +228,111 @@ const Ht = () => {
222
228
  });
223
229
  return;
224
230
  }
225
- I.current = 0, l !== null && d();
226
- const t = St(e) || Ne(e), n = je(e);
231
+ E.current = 0, l !== null && d();
232
+ const t = Tt(e) || Ne(e), s = Ve(e);
227
233
  if (g({
228
234
  eventName: "chat_error",
229
235
  properties: {
230
236
  conversationId: c,
231
- messageId: T.at(-1)?.id,
237
+ messageId: _.at(-1)?.id,
232
238
  error: e.message
233
239
  }
234
240
  }), t) {
235
241
  L(
236
- { title: n === U ? "Message too large" : n === Be ? "Rate limit reached" : "Request failed", message: n },
242
+ { title: s === oe ? "Message too large" : s === Be ? "Rate limit reached" : s === De || s === Le ? "Connection error" : "Request failed", message: s },
237
243
  Pe
238
244
  ), m((p) => {
239
- let r = [...p];
240
- return r.at(-1)?.role === "assistant" && (r = r.slice(0, -1)), r.at(-1)?.role === "user" && (r = r.slice(0, -1)), r;
245
+ let n = [...p];
246
+ return n.at(-1)?.role === "assistant" && (n = n.slice(0, -1)), n.at(-1)?.role === "user" && (n = n.slice(0, -1)), n;
241
247
  });
242
- const s = P.current?.content;
243
- s && A(s), se.current = e;
248
+ const r = P.current?.content;
249
+ r && A(r), te.current = e;
244
250
  return;
245
251
  }
246
252
  m((o) => {
247
- const s = [...o], p = s[s.length - 1];
248
- return p && (p.role === "user" ? s.push({
253
+ const r = [...o], p = r[r.length - 1];
254
+ return p && (p.role === "user" ? r.push({
249
255
  id: F(16),
250
256
  role: "assistant",
251
- parts: [{ type: "text", text: n }]
252
- }) : p.parts = [{ type: "text", text: n }]), s;
257
+ parts: [{ type: "text", text: s }]
258
+ }) : p.parts = [{ type: "text", text: s }]), r;
253
259
  });
254
260
  }
255
- }), we = i(R);
256
- _(() => {
257
- const e = we.current;
258
- we.current = R, e !== R && (B(), b(null), m([]), y(""), A(""), J([]), d());
261
+ }), Te = i(R);
262
+ b(() => {
263
+ const e = Te.current;
264
+ Te.current = R, e !== R && (B(), w(null), m([]), y(""), A(""), Y([]), d());
259
265
  }, [R, B, m, y, d]);
260
- const Te = Ae === "submitted", Z = Ae === "streaming", We = Oe(() => {
266
+ const _e = Ae === "submitted", X = Ae === "streaming", Je = Oe(() => {
261
267
  const e = (o) => {
262
268
  if (!o || typeof o != "object") return !1;
263
- const s = o;
264
- return typeof s.type == "string" && s.type.startsWith("tool-");
265
- }, t = [...T ?? []].reverse().find((o) => o.role === "assistant");
269
+ const r = o;
270
+ return typeof r.type == "string" && r.type.startsWith("tool-");
271
+ }, t = [..._ ?? []].reverse().find((o) => o.role === "assistant");
266
272
  if (!t) return !1;
267
- const n = t.parts?.at(-1);
268
- return !(!e(n) || n.state !== "output-available" || !n.approval?.id || Z);
269
- }, [T, Z]), [Ye, ee] = k(!1), be = Z || We && !Ye, Me = Te || be, Je = T.length === 0, te = !S.trim() && C.length === 0 || Me, Qe = ft("(max-width: 768px)"), [Xe, b] = k(null), se = i(null);
270
- _(() => {
273
+ const s = t.parts?.at(-1);
274
+ return !(!e(s) || s.state !== "output-available" || !s.approval?.id || X);
275
+ }, [_, X]), [Qe, Z] = k(!1), we = X || Je && !Qe, Me = _e || we, Xe = _.length === 0, ee = !C.trim() && S.length === 0 || Me, Ze = gt("(max-width: 768px)"), [et, w] = k(null), te = i(null);
276
+ b(() => {
271
277
  if (D) {
272
- if (se.current === D) {
273
- se.current = null;
278
+ if (te.current === D) {
279
+ te.current = null;
274
280
  return;
275
281
  }
276
- b(D);
282
+ w(D);
277
283
  }
278
284
  }, [D]);
279
- const Ze = () => b(null), { inputNotification: et, showInputNotification: L, clearInputNotification: tt } = Ct(), _e = i(null);
280
- _(() => {
281
- Ge?.(S);
282
- }, [S]);
283
- const st = (e) => {
284
- e.key === "Enter" && !e.shiftKey && !te && !e.nativeEvent.isComposing && (e.preventDefault(), re());
285
- }, re = async (e = S) => {
286
- if (te && (!e || e.trim().length === 0) && C.length === 0 || !e.trim() && !C.length && !h.current?.length)
285
+ const tt = () => w(null), { inputNotification: st, showInputNotification: L, clearInputNotification: rt } = Ct(), be = i(null);
286
+ b(() => {
287
+ ze?.(C);
288
+ }, [C]);
289
+ const nt = (e) => {
290
+ e.key === "Enter" && !e.shiftKey && !ee && !e.nativeEvent.isComposing && (e.preventDefault(), se());
291
+ }, se = async (e = C) => {
292
+ if (ee && (!e || e.trim().length === 0) && S.length === 0 || !e.trim() && !S.length && !h.current?.length)
287
293
  return;
288
- if (Tt({
294
+ if (wt({
289
295
  text: e,
290
- rawFileBytes: C.reduce((f, u) => f + u.size, 0),
296
+ rawFileBytes: S.reduce((f, u) => f + u.size, 0),
291
297
  encodedPartsBytes: (h.current ?? []).reduce(
292
298
  (f, u) => f + u.url.length,
293
299
  0
294
300
  )
295
- }) > bt) {
301
+ }) > Mt) {
296
302
  L(
297
- { title: "Message too large", message: U },
303
+ { title: "Message too large", message: oe },
298
304
  Pe
299
305
  );
300
306
  return;
301
307
  }
302
- const t = C;
303
- J([]), A(""), I.current = 0, W.current = null, ee(!1);
304
- let n = c;
305
- n || (n = `conv_${F(16)}`, y(n));
308
+ const t = S;
309
+ Y([]), A(""), E.current = 0, j.current = null, Z(!1);
310
+ let s = c;
311
+ s || (s = `conv_${F(16)}`, y(s));
306
312
  const o = F(21);
307
- Le(n), await g({
313
+ Ue(s), await g({
308
314
  eventName: "user_message_submitted",
309
315
  properties: {
310
- conversationId: n,
316
+ conversationId: s,
311
317
  messageId: o
312
318
  }
313
319
  });
314
- const s = h.current;
320
+ const r = h.current;
315
321
  h.current = void 0;
316
322
  let p = [];
317
323
  if (t.length > 0)
318
324
  try {
319
325
  p = await Promise.all(
320
326
  t.map((f) => {
321
- const u = ct(f);
322
- return new Promise((at, xe) => {
327
+ const u = ut(f);
328
+ return new Promise((ct, xe) => {
323
329
  const M = new FileReader();
324
330
  M.onload = () => {
325
331
  if (typeof M.result != "string") {
326
332
  xe(new Error(`Failed to read file "${u.name}"`));
327
333
  return;
328
334
  }
329
- at({
335
+ ct({
330
336
  type: "file",
331
337
  url: M.result,
332
338
  mediaType: u.type,
@@ -343,42 +349,42 @@ const Ht = () => {
343
349
  });
344
350
  return;
345
351
  }
346
- const r = p.length || s?.length ? [...p, ...s ?? []] : void 0, a = [
352
+ const n = p.length || r?.length ? [...p, ...r ?? []] : void 0, a = [
347
353
  ...e.trim() ? [{ type: "text", text: e }] : [],
348
- ...r ?? []
354
+ ...n ?? []
349
355
  ];
350
356
  P.current = {
351
357
  content: e,
352
358
  messageId: o,
353
- body: { conversationId: n },
354
- files: r
355
- }, Q({ id: o, parts: a }, { body: { conversationId: n } });
356
- }, rt = $(
359
+ body: { conversationId: s },
360
+ files: n
361
+ }, J({ id: o, parts: a }, { body: { conversationId: s } });
362
+ }, ot = $(
357
363
  (e) => {
358
- I.current = 0, W.current = e, ee(!1), X(e);
364
+ E.current = 0, j.current = e, Z(!1), Q(e);
359
365
  },
360
- [X]
361
- ), ne = $(() => {
362
- ee(!0), B().then(() => {
366
+ [Q]
367
+ ), re = $(() => {
368
+ Z(!0), B().then(() => {
363
369
  x("aborted", { conversationId: c });
364
370
  });
365
371
  }, [B, c, x]), ke = () => {
366
- Ze(), m([]), y(""), d(), h.current = w?.length ? w : void 0, g({
372
+ tt(), m([]), y(""), d(), h.current = T?.length ? T : void 0, g({
367
373
  eventName: "chat_clear_button_clicked",
368
374
  properties: {
369
375
  conversationId: c
370
376
  }
371
377
  });
372
- }, E = $(
378
+ }, I = $(
373
379
  (e, l) => {
374
- b(null), m(l), y(e), d(), h.current = void 0;
380
+ w(null), m(l), y(e), d(), h.current = void 0;
375
381
  },
376
382
  [m, y, d]
377
383
  ), Fe = $(
378
384
  async (e, l) => {
379
- ne(), E(e, []), Ee(!0);
385
+ re(), I(e, []), Ie(!0);
380
386
  try {
381
- const t = await Ce(e, l);
387
+ const t = await Se(e, l);
382
388
  if (t === null) return !1;
383
389
  const o = t[t.length - 1]?.role === "user" ? [
384
390
  ...t,
@@ -393,68 +399,68 @@ const Ht = () => {
393
399
  ]
394
400
  }
395
401
  ] : t;
396
- return E(e, o), !0;
402
+ return I(e, o), !0;
397
403
  } finally {
398
- l?.aborted || Ee(!1);
404
+ l?.aborted || Ie(!1);
399
405
  }
400
406
  },
401
- [E, Ce, ne]
407
+ [I, Se, re]
402
408
  );
403
- gt({
409
+ vt({
404
410
  conversationId: v.conversationId,
405
411
  fetchedConversation: v.fetchedConversation,
406
412
  effectiveAuthToken: me,
407
- restoreSession: E,
413
+ restoreSession: I,
408
414
  loadAndRestoreSession: Fe,
409
- onLoadFailed: () => E("", [])
415
+ onLoadFailed: () => I("", [])
410
416
  });
411
- const { openForm: nt } = vt(), ot = yt();
412
- return ut(v.chatFunctionsRef, () => ({
413
- submitMessage: re,
417
+ const { openForm: at } = Rt(), it = Et();
418
+ return pt(v.chatFunctionsRef, () => ({
419
+ submitMessage: se,
414
420
  updateInputMessage(e) {
415
421
  A(e);
416
422
  },
417
423
  clearChat: ke,
418
424
  openForm: (e) => {
419
- ot?.setView("chat"), nt(e, void 0);
425
+ it?.setView("chat"), at(e, void 0);
420
426
  },
421
427
  focusInput: () => {
422
- _e.current?.focus();
428
+ be.current?.focus();
423
429
  }
424
430
  })), {
425
- messages: T,
426
- sendMessage: Q,
427
- addToolApprovalResponse: rt,
428
- isLoading: Te,
429
- isStreaming: be,
431
+ messages: _,
432
+ sendMessage: J,
433
+ addToolApprovalResponse: ot,
434
+ isLoading: _e,
435
+ isStreaming: we,
430
436
  isBusy: Me,
431
- error: Xe,
432
- setError: b,
433
- isSubmitDisabled: te,
434
- input: S,
435
- handleInputChange: $e,
436
- handleInputKeyDown: st,
437
- handleSubmit: re,
438
- stop: ne,
437
+ error: et,
438
+ setError: w,
439
+ isSubmitDisabled: ee,
440
+ input: C,
441
+ handleInputChange: Ge,
442
+ handleInputKeyDown: nt,
443
+ handleSubmit: se,
444
+ stop: re,
439
445
  clear: ke,
440
- inputRef: _e,
441
- isMobile: Qe,
442
- files: C,
443
- setFiles: J,
444
- isNewChat: Je,
446
+ inputRef: be,
447
+ isMobile: Ze,
448
+ files: S,
449
+ setFiles: Y,
450
+ isNewChat: Xe,
445
451
  conversationId: c,
446
- restoreSession: E,
452
+ restoreSession: I,
447
453
  loadAndRestoreSession: Fe,
448
- isSessionLoading: qe,
454
+ isSessionLoading: We,
449
455
  authToken: R ? le : pe,
450
456
  refreshSession: R ? de : fe,
451
457
  getCaptchaHeader: O,
452
458
  invalidateCaptcha: d,
453
- inputNotification: et,
459
+ inputNotification: st,
454
460
  showInputNotification: L,
455
- clearInputNotification: tt
461
+ clearInputNotification: rt
456
462
  };
457
463
  };
458
464
  export {
459
- Ht as useInkeepChat
465
+ jt as useInkeepChat
460
466
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),t=require("react"),p=require("./config-provider.cjs"),n=t.createContext(void 0),g=({children:e})=>{const{baseSettings:s,componentType:o}=p.useInkeepConfig(),{tags:r,analyticsProperties:i}=s,c="0.17.6",a=t.useMemo(()=>({widgetLibraryVersion:c,componentType:o,tags:r}),[o,r,c]),v={logEvent:t.useCallback(async u=>{const E={...a,...u.properties,...i},d={eventName:u.eventName,properties:E};return s.onEvent?.(d)},[s,a,i])};return l.jsx(n.Provider,{value:v,children:e})},m=()=>{const e=t.useContext(n);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsContext=n;exports.BaseEventsProvider=g;exports.useBaseEvents=m;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),t=require("react"),p=require("./config-provider.cjs"),n=t.createContext(void 0),g=({children:e})=>{const{baseSettings:s,componentType:o}=p.useInkeepConfig(),{tags:r,analyticsProperties:i}=s,c="0.17.7",a=t.useMemo(()=>({widgetLibraryVersion:c,componentType:o,tags:r}),[o,r,c]),v={logEvent:t.useCallback(async u=>{const E={...a,...u.properties,...i},d={eventName:u.eventName,properties:E};return s.onEvent?.(d)},[s,a,i])};return l.jsx(n.Provider,{value:v,children:e})},m=()=>{const e=t.useContext(n);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsContext=n;exports.BaseEventsProvider=g;exports.useBaseEvents=m;
@@ -3,7 +3,7 @@ import { jsx as u } from "react/jsx-runtime";
3
3
  import { createContext as E, useMemo as d, useCallback as l, useContext as g } from "react";
4
4
  import { useInkeepConfig as x } from "./config-provider.js";
5
5
  const c = E(void 0), b = ({ children: e }) => {
6
- const { baseSettings: t, componentType: o } = x(), { tags: s, analyticsProperties: n } = t, r = "0.17.6", i = d(
6
+ const { baseSettings: t, componentType: o } = x(), { tags: s, analyticsProperties: n } = t, r = "0.17.7", i = d(
7
7
  () => ({
8
8
  widgetLibraryVersion: r,
9
9
  componentType: o,
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("react/jsx-runtime"),u=require("react"),B=require("./config-provider.cjs"),O=require("./chat-auth-provider.cjs"),U=require("../hooks/use-events-api.cjs"),x=require("./base-events-provider.cjs"),M=({children:g})=>{const{baseSettings:n,aiChatSettings:h,componentType:i}=B.useInkeepConfig(),{tags:t,analyticsProperties:r,privacyPreferences:y,userProperties:o}=n,c="0.17.6",a=u.useMemo(()=>({widgetLibraryVersion:c,componentType:i}),[i,c]),{effectiveAuthToken:b,applicableRefreshSession:f,getCaptchaHeader:E,invalidateCaptcha:P}=O.useChatAuth(),{baseUrl:m,appId:A,analyticsApiBaseUrl:C,headers:I}=h,p=y?.optOutAllAnalytics??!1,{logEvent:l}=U.useEventsApi({baseUrl:C??m,appId:A,authToken:b,getCaptchaHeader:E,invalidateCaptcha:P,refreshSession:f,headers:I}),k={logEvent:u.useCallback(async s=>{const q={eventName:s.eventName,properties:{...a,...t?{tags:t}:{},...s.properties,...r}};if(!p){const e=s.properties??{},v=typeof e.conversationId=="string"?e.conversationId:void 0,d=typeof e.messageId=="string"?e.messageId:void 0,S=!!o&&Object.keys(o).length>0,w={...t?{tags:t}:{},...r??{}},T={...a,...s.properties};l({body:{type:s.eventName,...v?{conversationId:v}:{},...d?{messageId:d}:{},...S?{userProperties:o}:{},properties:w,metadata:T}})}try{return await n.onEvent?.(q)}catch(e){console.warn("[events] onEvent callback threw",e)}},[n,a,t,r,l,p,o])};return j.jsx(x.BaseEventsContext.Provider,{value:k,children:g})};exports.ChatBaseEventsProvider=M;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("react/jsx-runtime"),u=require("react"),B=require("./config-provider.cjs"),O=require("./chat-auth-provider.cjs"),U=require("../hooks/use-events-api.cjs"),x=require("./base-events-provider.cjs"),M=({children:g})=>{const{baseSettings:n,aiChatSettings:h,componentType:i}=B.useInkeepConfig(),{tags:t,analyticsProperties:r,privacyPreferences:y,userProperties:o}=n,c="0.17.7",a=u.useMemo(()=>({widgetLibraryVersion:c,componentType:i}),[i,c]),{effectiveAuthToken:b,applicableRefreshSession:f,getCaptchaHeader:E,invalidateCaptcha:P}=O.useChatAuth(),{baseUrl:m,appId:A,analyticsApiBaseUrl:C,headers:I}=h,p=y?.optOutAllAnalytics??!1,{logEvent:l}=U.useEventsApi({baseUrl:C??m,appId:A,authToken:b,getCaptchaHeader:E,invalidateCaptcha:P,refreshSession:f,headers:I}),k={logEvent:u.useCallback(async s=>{const q={eventName:s.eventName,properties:{...a,...t?{tags:t}:{},...s.properties,...r}};if(!p){const e=s.properties??{},v=typeof e.conversationId=="string"?e.conversationId:void 0,d=typeof e.messageId=="string"?e.messageId:void 0,S=!!o&&Object.keys(o).length>0,w={...t?{tags:t}:{},...r??{}},T={...a,...s.properties};l({body:{type:s.eventName,...v?{conversationId:v}:{},...d?{messageId:d}:{},...S?{userProperties:o}:{},properties:w,metadata:T}})}try{return await n.onEvent?.(q)}catch(e){console.warn("[events] onEvent callback threw",e)}},[n,a,t,r,l,p,o])};return j.jsx(x.BaseEventsContext.Provider,{value:k,children:g})};exports.ChatBaseEventsProvider=M;
@@ -6,7 +6,7 @@ import { useChatAuth as O } from "./chat-auth-provider.js";
6
6
  import { useEventsApi as j } from "../hooks/use-events-api.js";
7
7
  import { BaseEventsContext as M } from "./base-events-provider.js";
8
8
  const F = ({ children: m }) => {
9
- const { baseSettings: r, aiChatSettings: g, componentType: i } = N(), { tags: t, analyticsProperties: n, privacyPreferences: f, userProperties: o } = r, c = "0.17.6", a = x(
9
+ const { baseSettings: r, aiChatSettings: g, componentType: i } = N(), { tags: t, analyticsProperties: n, privacyPreferences: f, userProperties: o } = r, c = "0.17.7", a = x(
10
10
  () => ({
11
11
  widgetLibraryVersion: c,
12
12
  componentType: i