@inkeep/agents-ui 0.0.0-dev-20260402200940 → 0.0.0-dev-20260402205727
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/index.cjs +1 -1
- package/dist/index.js +165 -174
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.cjs +3 -3
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.d.ts +1 -5
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +198 -203
- package/dist/primitives/components/embedded-chat.cjs +5 -5
- package/dist/primitives/components/embedded-chat.d.ts +2 -112
- package/dist/primitives/components/embedded-chat.js +1082 -1511
- package/dist/primitives/index.cjs +1 -1
- package/dist/primitives/index.js +146 -155
- package/dist/primitives/providers/feedback-provider.cjs +1 -1
- package/dist/primitives/providers/feedback-provider.js +37 -38
- package/dist/primitives/providers/index.cjs +1 -1
- package/dist/primitives/providers/index.d.ts +0 -3
- package/dist/primitives/providers/index.js +54 -63
- package/dist/primitives/utils/component-ids.cjs +1 -1
- package/dist/primitives/utils/component-ids.d.ts +0 -98
- package/dist/primitives/utils/component-ids.js +7 -56
- package/dist/primitives/utils/default-settings.cjs +1 -1
- package/dist/primitives/utils/default-settings.d.ts +0 -2
- package/dist/primitives/utils/default-settings.js +6 -8
- package/dist/react/embedded-chat.cjs +1 -1
- package/dist/react/embedded-chat.js +261 -310
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.js +165 -174
- package/dist/styled/components/embedded-chat.cjs +1 -1
- package/dist/styled/components/embedded-chat.d.ts +2 -50
- package/dist/styled/components/embedded-chat.js +568 -1041
- package/dist/styled/components/ui/recipes/citation.d.ts +1 -1
- package/dist/styled/components/ui/recipes/index.cjs +1 -1
- package/dist/styled/components/ui/recipes/index.d.ts +0 -1
- package/dist/styled/components/ui/recipes/index.js +31 -33
- package/dist/styled/index.cjs +1 -1
- package/dist/styled/index.js +150 -159
- package/dist/styled/inkeep.css.cjs +0 -66
- package/dist/styled/inkeep.css.js +0 -66
- package/dist/types/config/ai.d.ts +1 -10
- package/dist/types/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/primitives/providers/attachment-item-provider.cjs +0 -1
- package/dist/primitives/providers/attachment-item-provider.d.ts +0 -9
- package/dist/primitives/providers/attachment-item-provider.js +0 -13
- package/dist/primitives/providers/attachments-bar-provider.cjs +0 -1
- package/dist/primitives/providers/attachments-bar-provider.d.ts +0 -30
- package/dist/primitives/providers/attachments-bar-provider.js +0 -57
- package/dist/primitives/providers/message-attachments-provider.cjs +0 -1
- package/dist/primitives/providers/message-attachments-provider.d.ts +0 -13
- package/dist/primitives/providers/message-attachments-provider.js +0 -27
- package/dist/primitives/utils/get-message-metadata.d.ts +0 -8
- package/dist/styled/components/ui/recipes/attachment.cjs +0 -1
- package/dist/styled/components/ui/recipes/attachment.d.ts +0 -4
- package/dist/styled/components/ui/recipes/attachment.js +0 -28
- package/dist/types/config/settings/workflow.d.ts +0 -86
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useChat as
|
|
3
|
-
import { normalizeFileType as
|
|
4
|
-
import { DefaultChatTransport as
|
|
5
|
-
import { useRef as l, useEffect as
|
|
6
|
-
import { useModal as
|
|
7
|
-
import { useOptionalChatBubble as
|
|
8
|
-
import { useOptionalSidebarChat as
|
|
9
|
-
import { useInkeepConfig as
|
|
10
|
-
import { useCaptcha as
|
|
11
|
-
import { useMediaQuery as
|
|
12
|
-
import { useAnonymousSession as
|
|
13
|
-
import { useAuthToken as
|
|
14
|
-
import { useConversationLoader as
|
|
15
|
-
import { generateUid as
|
|
16
|
-
import { useBaseEvents as
|
|
17
|
-
import { useChatForm as
|
|
18
|
-
import { useWidget as
|
|
19
|
-
import { useControllableState as
|
|
20
|
-
import { useStreamingEvents as
|
|
21
|
-
import { parseAuthError as
|
|
22
|
-
import { useInputNotification as
|
|
23
|
-
function
|
|
2
|
+
import { useChat as et } from "@ai-sdk/react";
|
|
3
|
+
import { normalizeFileType as Re } from "./file-upload-input.js";
|
|
4
|
+
import { DefaultChatTransport as tt } from "ai";
|
|
5
|
+
import { useRef as l, useEffect as k, useState as D, useMemo as Te, useCallback as $, useImperativeHandle as st } from "react";
|
|
6
|
+
import { useModal as rt } from "../modal/modal-provider.js";
|
|
7
|
+
import { useOptionalChatBubble as nt } from "../../providers/chat-bubble-provider.js";
|
|
8
|
+
import { useOptionalSidebarChat as ot } from "../../providers/sidebar-chat-provider.js";
|
|
9
|
+
import { useInkeepConfig as at } from "../../providers/config-provider.js";
|
|
10
|
+
import { useCaptcha as it } from "./use-captcha.js";
|
|
11
|
+
import { useMediaQuery as lt } from "../../hooks/use-media-query.js";
|
|
12
|
+
import { useAnonymousSession as ct } from "../../hooks/use-anonymous-session.js";
|
|
13
|
+
import { useAuthToken as ut } from "../../hooks/use-auth-token.js";
|
|
14
|
+
import { useConversationLoader as pt } from "../../hooks/use-conversation-loader.js";
|
|
15
|
+
import { generateUid as L } from "../../utils/generate-uid.js";
|
|
16
|
+
import { useBaseEvents as dt } from "../../providers/base-events-provider.js";
|
|
17
|
+
import { useChatForm as ft } from "../../providers/chat-form-provider.js";
|
|
18
|
+
import { useWidget as mt } from "../../providers/widget-provider.js";
|
|
19
|
+
import { useControllableState as ht } from "@radix-ui/react-use-controllable-state";
|
|
20
|
+
import { useStreamingEvents as gt } from "../../hooks/use-streaming-events.js";
|
|
21
|
+
import { parseAuthError as yt } from "../../hooks/use-inkeep-api-client.js";
|
|
22
|
+
import { useInputNotification as vt } from "../../hooks/use-input-notification.js";
|
|
23
|
+
function bt(h) {
|
|
24
24
|
const g = h.message ?? "";
|
|
25
25
|
let s = Number(h.code) || Number(h.statusCode);
|
|
26
26
|
if (Number.isNaN(s))
|
|
@@ -28,19 +28,19 @@ function At(h) {
|
|
|
28
28
|
s = Number(JSON.parse(g).status);
|
|
29
29
|
} catch {
|
|
30
30
|
}
|
|
31
|
-
const p =
|
|
31
|
+
const p = yt(s, { detail: g });
|
|
32
32
|
return p !== null ? p : s === 401 ? "session" : null;
|
|
33
33
|
}
|
|
34
|
-
const
|
|
34
|
+
const te = `Hmm..
|
|
35
35
|
|
|
36
|
-
It seems I might be having some issues right now. Please clear the chat and try again.`,
|
|
37
|
-
const { baseSettings: h, aiChatSettings: g } =
|
|
36
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`, zt = () => {
|
|
37
|
+
const { baseSettings: h, aiChatSettings: g } = at(), [s = "", p] = ht({
|
|
38
38
|
prop: g.conversationId,
|
|
39
39
|
defaultProp: g.conversationId ?? ""
|
|
40
|
-
}),
|
|
41
|
-
|
|
42
|
-
const e =
|
|
43
|
-
|
|
40
|
+
}), ke = rt(), xe = nt(), Me = ot(), { logEvent: y } = dt(), { setConversationId: Ee, emitToParent: x } = gt(), se = l(s);
|
|
41
|
+
k(() => {
|
|
42
|
+
const e = se.current;
|
|
43
|
+
se.current = s, e !== s && y({
|
|
44
44
|
eventName: "chat_conversation_changed",
|
|
45
45
|
properties: {
|
|
46
46
|
conversationId: s,
|
|
@@ -48,79 +48,79 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
}, [s, y]);
|
|
51
|
-
const [
|
|
52
|
-
onInputMessageChange:
|
|
53
|
-
filters:
|
|
54
|
-
baseUrl:
|
|
55
|
-
agentUrl:
|
|
56
|
-
context:
|
|
57
|
-
headers:
|
|
58
|
-
appId:
|
|
51
|
+
const [C, M] = D(""), Fe = (e) => M(e.target.value), { shouldBypassCaptcha: re, filters: ne, privacyPreferences: Ne, userProperties: B } = h, { authToken: E, isLoading: Pe, refreshToken: oe } = ut(), ae = !!h.getAuthToken, d = !!E, {
|
|
52
|
+
onInputMessageChange: Oe,
|
|
53
|
+
filters: ie,
|
|
54
|
+
baseUrl: F,
|
|
55
|
+
agentUrl: _e,
|
|
56
|
+
context: le,
|
|
57
|
+
headers: ce,
|
|
58
|
+
appId: w,
|
|
59
59
|
apiKey: v,
|
|
60
|
-
files:
|
|
61
|
-
} = g,
|
|
62
|
-
baseUrl:
|
|
63
|
-
shouldBypassCaptcha:
|
|
64
|
-
shouldMakeInitialRequest:
|
|
65
|
-
}),
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
baseUrl:
|
|
69
|
-
appId:
|
|
60
|
+
files: S
|
|
61
|
+
} = g, De = ke?.isOpen ?? xe?.isOpen ?? Me?.isOpen ?? !0, { getCaptchaHeader: I, invalidate: c } = it({
|
|
62
|
+
baseUrl: F,
|
|
63
|
+
shouldBypassCaptcha: re || !!v,
|
|
64
|
+
shouldMakeInitialRequest: De
|
|
65
|
+
}), ue = l(I);
|
|
66
|
+
ue.current = I;
|
|
67
|
+
const pe = _e || `${F}/run/api/chat`, { sessionToken: U, refreshSession: z } = ct({
|
|
68
|
+
baseUrl: F,
|
|
69
|
+
appId: w,
|
|
70
70
|
getCaptchaHeader: I,
|
|
71
71
|
invalidateCaptcha: c,
|
|
72
|
-
optOutAllAnalytics:
|
|
73
|
-
enabled: !d && !
|
|
74
|
-
}), { loadConversation:
|
|
75
|
-
baseUrl:
|
|
76
|
-
appId:
|
|
77
|
-
authToken: v ?? (d ?
|
|
72
|
+
optOutAllAnalytics: Ne?.optOutAllAnalytics,
|
|
73
|
+
enabled: !d && !Pe
|
|
74
|
+
}), { loadConversation: de } = pt({
|
|
75
|
+
baseUrl: F,
|
|
76
|
+
appId: w,
|
|
77
|
+
authToken: v ?? (d ? E : U),
|
|
78
78
|
getCaptchaHeader: I,
|
|
79
79
|
invalidateCaptcha: c,
|
|
80
|
-
refreshSession: v || d ? void 0 :
|
|
81
|
-
}), [
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
const b = l(0),
|
|
80
|
+
refreshSession: v || d ? void 0 : z
|
|
81
|
+
}), [$e, fe] = D(!1), H = l(null);
|
|
82
|
+
H.current = U;
|
|
83
|
+
const q = l(null);
|
|
84
|
+
q.current = E;
|
|
85
|
+
const K = l(void 0);
|
|
86
|
+
K.current = B && Object.keys(B).length > 0 ? JSON.stringify(B) : void 0;
|
|
87
|
+
const b = l(0), me = l(null), J = l(null), A = l(void 0), Le = S?.map((e) => `${e.filename ?? ""}:${e.mediaType}:${e.url.length}:${e.url.slice(0, 64)}:${e.url.slice(-32)}`).join(`
|
|
88
88
|
`) ?? "";
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}, [
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
const
|
|
89
|
+
k(() => {
|
|
90
|
+
A.current = S?.length ? S : void 0;
|
|
91
|
+
}, [Le]);
|
|
92
|
+
const he = l(ce);
|
|
93
|
+
he.current = ce;
|
|
94
|
+
const j = l(void 0);
|
|
95
|
+
j.current = ne || ie ? JSON.stringify({ ...ne, ...ie }) : void 0;
|
|
96
|
+
const Be = (e) => {
|
|
97
97
|
switch (e.code) {
|
|
98
98
|
case 400:
|
|
99
99
|
return e.message;
|
|
100
100
|
case 401:
|
|
101
|
-
return
|
|
101
|
+
return ae ? "Authentication failed. Please try again." : te;
|
|
102
102
|
case 403:
|
|
103
103
|
return `There seems to be a configuration error. Please contact ${h.organizationDisplayName ?? "Administrator"}`;
|
|
104
104
|
default:
|
|
105
|
-
return
|
|
105
|
+
return te;
|
|
106
106
|
}
|
|
107
|
-
}, [
|
|
108
|
-
() => new
|
|
109
|
-
api:
|
|
107
|
+
}, [N, W] = D([]), Ue = Te(
|
|
108
|
+
() => new tt({
|
|
109
|
+
api: pe,
|
|
110
110
|
headers: () => {
|
|
111
|
-
const e = v ??
|
|
111
|
+
const e = v ?? q.current ?? H.current;
|
|
112
112
|
return {
|
|
113
113
|
"x-inkeep-client-timezone": Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
114
114
|
"x-inkeep-client-timestamp": (/* @__PURE__ */ new Date()).toISOString(),
|
|
115
|
-
...
|
|
115
|
+
...w ? { "x-inkeep-app-id": w } : {},
|
|
116
116
|
...e ? { Authorization: `Bearer ${e}` } : {},
|
|
117
|
-
...
|
|
118
|
-
...
|
|
119
|
-
...
|
|
117
|
+
...j.current ? { "inkeep-filters": j.current } : {},
|
|
118
|
+
...K.current ? { "x-inkeep-user-properties": K.current } : {},
|
|
119
|
+
...he.current
|
|
120
120
|
};
|
|
121
121
|
},
|
|
122
122
|
prepareSendMessagesRequest: async (e) => {
|
|
123
|
-
const i = await
|
|
123
|
+
const i = await ue.current(), t = e.messages[e.messages.length - 1];
|
|
124
124
|
return t || console.warn("[useInkeepChat] prepareSendMessagesRequest called with empty messages array"), {
|
|
125
125
|
body: {
|
|
126
126
|
...e.body,
|
|
@@ -136,25 +136,25 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
136
136
|
};
|
|
137
137
|
},
|
|
138
138
|
body: {
|
|
139
|
-
requestContext:
|
|
139
|
+
requestContext: le
|
|
140
140
|
}
|
|
141
141
|
}),
|
|
142
|
-
[
|
|
142
|
+
[pe, le, w, v]
|
|
143
143
|
), {
|
|
144
|
-
messages:
|
|
145
|
-
sendMessage:
|
|
146
|
-
addToolApprovalResponse:
|
|
147
|
-
status:
|
|
144
|
+
messages: P,
|
|
145
|
+
sendMessage: G,
|
|
146
|
+
addToolApprovalResponse: Q,
|
|
147
|
+
status: ge,
|
|
148
148
|
setMessages: m,
|
|
149
|
-
stop:
|
|
150
|
-
error:
|
|
151
|
-
} =
|
|
152
|
-
transport:
|
|
149
|
+
stop: O,
|
|
150
|
+
error: V
|
|
151
|
+
} = et({
|
|
152
|
+
transport: Ue,
|
|
153
153
|
onData(e) {
|
|
154
|
-
|
|
154
|
+
x(e.type, e.data);
|
|
155
155
|
},
|
|
156
156
|
async onFinish() {
|
|
157
|
-
|
|
157
|
+
x("completion", { conversationId: s }), await y({
|
|
158
158
|
eventName: "assistant_message_received",
|
|
159
159
|
properties: {
|
|
160
160
|
conversationId: s
|
|
@@ -168,28 +168,28 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
168
168
|
},
|
|
169
169
|
onError(e) {
|
|
170
170
|
console.error("onError", { code: e.code, message: e.message });
|
|
171
|
-
const i =
|
|
171
|
+
const i = re || v ? null : bt(e);
|
|
172
172
|
if (i !== null && b.current < 1) {
|
|
173
173
|
b.current++;
|
|
174
|
-
const t =
|
|
174
|
+
const t = J.current, r = me.current;
|
|
175
175
|
(async () => {
|
|
176
|
-
if (i === "session" &&
|
|
177
|
-
const n = await
|
|
176
|
+
if (i === "session" && ae) {
|
|
177
|
+
const n = await oe();
|
|
178
178
|
if (!n) throw new Error("Auth token refresh failed");
|
|
179
|
-
|
|
179
|
+
q.current = n;
|
|
180
180
|
} else if (i === "session") {
|
|
181
|
-
const n = await
|
|
182
|
-
n && (
|
|
181
|
+
const n = await z();
|
|
182
|
+
n && (H.current = n);
|
|
183
183
|
} else
|
|
184
184
|
c();
|
|
185
185
|
if (t) {
|
|
186
|
-
|
|
186
|
+
Q(t);
|
|
187
187
|
return;
|
|
188
188
|
}
|
|
189
189
|
r && (m((n) => {
|
|
190
190
|
let o = [...n];
|
|
191
191
|
return o.at(-1)?.role === "assistant" && (o = o.slice(0, -1)), o.at(-1)?.role === "user" && (o = o.slice(0, -1)), o;
|
|
192
|
-
}),
|
|
192
|
+
}), G(
|
|
193
193
|
r.files?.length ? { parts: [{ type: "text", text: r.content }, ...r.files] } : { text: r.content },
|
|
194
194
|
{ body: r.body }
|
|
195
195
|
));
|
|
@@ -197,9 +197,9 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
197
197
|
b.current = 0, c(), m((n) => {
|
|
198
198
|
const o = [...n], f = o[o.length - 1];
|
|
199
199
|
if (!f) return o;
|
|
200
|
-
const u =
|
|
200
|
+
const u = te;
|
|
201
201
|
return f.role === "user" ? o.push({
|
|
202
|
-
id:
|
|
202
|
+
id: L(16),
|
|
203
203
|
role: "assistant",
|
|
204
204
|
parts: [{ type: "text", text: u }]
|
|
205
205
|
}) : f.parts = [{ type: "text", text: u }], o;
|
|
@@ -216,9 +216,9 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
216
216
|
}), m((t) => {
|
|
217
217
|
const r = [...t], a = r[r.length - 1];
|
|
218
218
|
if (a) {
|
|
219
|
-
const n =
|
|
219
|
+
const n = Be(e);
|
|
220
220
|
a.role === "user" ? r.push({
|
|
221
|
-
id:
|
|
221
|
+
id: L(16),
|
|
222
222
|
role: "assistant",
|
|
223
223
|
parts: [{ type: "text", text: n }]
|
|
224
224
|
}) : a.parts = [{ type: "text", text: n }];
|
|
@@ -226,69 +226,69 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
226
226
|
return r;
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
|
-
}),
|
|
230
|
-
|
|
231
|
-
const e =
|
|
232
|
-
|
|
233
|
-
}, [d,
|
|
234
|
-
const
|
|
229
|
+
}), ye = l(d);
|
|
230
|
+
k(() => {
|
|
231
|
+
const e = ye.current;
|
|
232
|
+
ye.current = d, e !== d && (O(), R(null), m([]), p(""), M(""), W([]), c());
|
|
233
|
+
}, [d, O, m, p, c]);
|
|
234
|
+
const ve = ge === "submitted", Z = ge === "streaming", ze = Te(() => {
|
|
235
235
|
const e = (a) => {
|
|
236
236
|
if (!a || typeof a != "object") return !1;
|
|
237
237
|
const n = a;
|
|
238
238
|
return typeof n.type == "string" && n.type.startsWith("tool-");
|
|
239
|
-
}, t = [...
|
|
239
|
+
}, t = [...P ?? []].reverse().find((a) => a.role === "assistant");
|
|
240
240
|
if (!t) return !1;
|
|
241
241
|
const r = t.parts?.at(-1);
|
|
242
|
-
return !(!e(r) || r.state !== "output-available" || !r.approval?.id ||
|
|
243
|
-
}, [
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}, [
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}, [
|
|
251
|
-
const
|
|
252
|
-
e.key === "Enter" && !e.shiftKey && !
|
|
253
|
-
},
|
|
254
|
-
if (
|
|
255
|
-
const i =
|
|
256
|
-
|
|
242
|
+
return !(!e(r) || r.state !== "output-available" || !r.approval?.id || Z);
|
|
243
|
+
}, [P, Z]), be = Z || ze, Ce = ve || be, He = P.length === 0, X = !C.trim() && N.length === 0 || Ce, qe = lt("(max-width: 768px)"), [Ke, R] = D(null);
|
|
244
|
+
k(() => {
|
|
245
|
+
V && R(V);
|
|
246
|
+
}, [V]);
|
|
247
|
+
const Je = () => R(null), { inputNotification: je, showInputNotification: we, clearInputNotification: We } = vt(), Se = l(null);
|
|
248
|
+
k(() => {
|
|
249
|
+
Oe?.(C);
|
|
250
|
+
}, [C]);
|
|
251
|
+
const Ge = (e) => {
|
|
252
|
+
e.key === "Enter" && !e.shiftKey && !X && !e.nativeEvent.isComposing && (e.preventDefault(), Y());
|
|
253
|
+
}, Y = async (e = C) => {
|
|
254
|
+
if (X && (!e || e.trim().length === 0) && N.length === 0) return;
|
|
255
|
+
const i = N;
|
|
256
|
+
W([]), M(""), b.current = 0, J.current = null, await y({
|
|
257
257
|
eventName: "user_message_submitted",
|
|
258
258
|
properties: {
|
|
259
259
|
conversationId: s
|
|
260
260
|
}
|
|
261
261
|
});
|
|
262
262
|
let t = s;
|
|
263
|
-
t || (t = `conv_${
|
|
264
|
-
const r =
|
|
265
|
-
|
|
263
|
+
t || (t = `conv_${L(16)}`, p(t)), Ee(t);
|
|
264
|
+
const r = A.current;
|
|
265
|
+
A.current = void 0;
|
|
266
266
|
let a, n;
|
|
267
267
|
if (r?.length) {
|
|
268
268
|
let o;
|
|
269
269
|
try {
|
|
270
270
|
o = await Promise.all(
|
|
271
271
|
i.map((f) => {
|
|
272
|
-
const u =
|
|
273
|
-
return new Promise((
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
if (typeof
|
|
277
|
-
|
|
272
|
+
const u = Re(f);
|
|
273
|
+
return new Promise((Ye, Ae) => {
|
|
274
|
+
const T = new FileReader();
|
|
275
|
+
T.onload = () => {
|
|
276
|
+
if (typeof T.result != "string") {
|
|
277
|
+
Ae(new Error(`Failed to read file "${u.name}"`));
|
|
278
278
|
return;
|
|
279
279
|
}
|
|
280
|
-
|
|
280
|
+
Ye({
|
|
281
281
|
type: "file",
|
|
282
|
-
url:
|
|
282
|
+
url: T.result,
|
|
283
283
|
mediaType: u.type,
|
|
284
284
|
filename: u.name
|
|
285
285
|
});
|
|
286
|
-
},
|
|
286
|
+
}, T.onerror = () => Ae(new Error(`Failed to read file "${u.name}"`)), T.readAsDataURL(u);
|
|
287
287
|
});
|
|
288
288
|
})
|
|
289
289
|
);
|
|
290
290
|
} catch {
|
|
291
|
-
|
|
291
|
+
we({
|
|
292
292
|
title: "Failed to attach files",
|
|
293
293
|
message: "Could not read one or more files. Please try again."
|
|
294
294
|
});
|
|
@@ -297,107 +297,102 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
297
297
|
n = [...o, ...r], a = e.trim() ? { parts: [{ type: "text", text: e }, ...n] } : { parts: n };
|
|
298
298
|
} else if (i.length > 0) {
|
|
299
299
|
const o = new DataTransfer();
|
|
300
|
-
for (const u of i) o.items.add(
|
|
300
|
+
for (const u of i) o.items.add(Re(u));
|
|
301
301
|
const f = o.files;
|
|
302
302
|
a = e.trim() ? { text: e, files: f } : { files: f };
|
|
303
303
|
} else
|
|
304
304
|
a = { text: e };
|
|
305
|
-
|
|
305
|
+
me.current = {
|
|
306
306
|
content: e,
|
|
307
307
|
body: { conversationId: t },
|
|
308
308
|
files: n
|
|
309
|
-
},
|
|
309
|
+
}, G(a, {
|
|
310
310
|
body: { conversationId: t }
|
|
311
311
|
});
|
|
312
|
-
},
|
|
312
|
+
}, Qe = $(
|
|
313
313
|
(e) => {
|
|
314
|
-
b.current = 0,
|
|
314
|
+
b.current = 0, J.current = e, Q(e);
|
|
315
315
|
},
|
|
316
|
-
[
|
|
317
|
-
),
|
|
318
|
-
|
|
319
|
-
|
|
316
|
+
[Q]
|
|
317
|
+
), ee = $(() => {
|
|
318
|
+
O().then(() => {
|
|
319
|
+
x("aborted", { conversationId: s });
|
|
320
320
|
});
|
|
321
|
-
}, [
|
|
322
|
-
|
|
321
|
+
}, [O, s, x]), Ie = () => {
|
|
322
|
+
Je(), m([]), p(""), c(), A.current = S?.length ? S : void 0, y({
|
|
323
323
|
eventName: "chat_clear_button_clicked",
|
|
324
324
|
properties: {
|
|
325
325
|
conversationId: s
|
|
326
326
|
}
|
|
327
327
|
});
|
|
328
|
-
},
|
|
328
|
+
}, _ = $(
|
|
329
329
|
(e, i) => {
|
|
330
|
-
|
|
330
|
+
R(null), m(i), p(e), c(), A.current = void 0;
|
|
331
331
|
},
|
|
332
332
|
[m, p, c]
|
|
333
|
-
),
|
|
333
|
+
), Ve = $(
|
|
334
334
|
async (e, i) => {
|
|
335
|
-
|
|
335
|
+
ee(), _(e, []), fe(!0);
|
|
336
336
|
try {
|
|
337
|
-
const t = await
|
|
338
|
-
id:
|
|
337
|
+
const t = await de(e, i), r = t?.[t.length - 1], a = t !== null && r?.role === "user" ? [...t, {
|
|
338
|
+
id: L(16),
|
|
339
339
|
role: "assistant",
|
|
340
340
|
parts: [{ type: "text", text: "This session was interrupted. Please check back in a few minutes or start a new conversation." }]
|
|
341
341
|
}] : t;
|
|
342
|
-
a !== null &&
|
|
342
|
+
a !== null && _(e, a);
|
|
343
343
|
} finally {
|
|
344
|
-
i?.aborted ||
|
|
344
|
+
i?.aborted || fe(!1);
|
|
345
345
|
}
|
|
346
346
|
},
|
|
347
|
-
[
|
|
348
|
-
), { openForm:
|
|
349
|
-
return
|
|
350
|
-
submitMessage:
|
|
347
|
+
[_, de, ee]
|
|
348
|
+
), { openForm: Ze } = ft(), Xe = mt();
|
|
349
|
+
return st(g.chatFunctionsRef, () => ({
|
|
350
|
+
submitMessage: Y,
|
|
351
351
|
updateInputMessage(e) {
|
|
352
|
-
|
|
352
|
+
M(e);
|
|
353
353
|
},
|
|
354
|
-
clearChat:
|
|
354
|
+
clearChat: Ie,
|
|
355
355
|
openForm: (e) => {
|
|
356
|
-
|
|
356
|
+
Xe?.setView("chat"), Ze(e, void 0);
|
|
357
357
|
},
|
|
358
358
|
focusInput: () => {
|
|
359
|
-
|
|
359
|
+
Se.current?.focus();
|
|
360
360
|
}
|
|
361
361
|
})), {
|
|
362
|
-
messages:
|
|
363
|
-
sendMessage:
|
|
364
|
-
addToolApprovalResponse:
|
|
365
|
-
isLoading:
|
|
366
|
-
isStreaming:
|
|
367
|
-
isBusy:
|
|
368
|
-
error:
|
|
369
|
-
setError:
|
|
370
|
-
isSubmitDisabled:
|
|
371
|
-
input:
|
|
372
|
-
handleInputChange:
|
|
373
|
-
handleInputKeyDown:
|
|
374
|
-
handleSubmit:
|
|
375
|
-
stop:
|
|
376
|
-
clear:
|
|
377
|
-
inputRef:
|
|
378
|
-
isMobile:
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
selectedWorkflow: qe,
|
|
383
|
-
setSelectedWorkflow: O,
|
|
384
|
-
files: _,
|
|
385
|
-
setFiles: Q,
|
|
386
|
-
isNewChat: Je,
|
|
362
|
+
messages: P,
|
|
363
|
+
sendMessage: G,
|
|
364
|
+
addToolApprovalResponse: Qe,
|
|
365
|
+
isLoading: ve,
|
|
366
|
+
isStreaming: be,
|
|
367
|
+
isBusy: Ce,
|
|
368
|
+
error: Ke,
|
|
369
|
+
setError: R,
|
|
370
|
+
isSubmitDisabled: X,
|
|
371
|
+
input: C,
|
|
372
|
+
handleInputChange: Fe,
|
|
373
|
+
handleInputKeyDown: Ge,
|
|
374
|
+
handleSubmit: Y,
|
|
375
|
+
stop: ee,
|
|
376
|
+
clear: Ie,
|
|
377
|
+
inputRef: Se,
|
|
378
|
+
isMobile: qe,
|
|
379
|
+
files: N,
|
|
380
|
+
setFiles: W,
|
|
381
|
+
isNewChat: He,
|
|
387
382
|
conversationId: s,
|
|
388
|
-
restoreSession:
|
|
389
|
-
loadAndRestoreSession:
|
|
390
|
-
isSessionLoading:
|
|
391
|
-
authToken: d ?
|
|
392
|
-
refreshSession: d ?
|
|
383
|
+
restoreSession: _,
|
|
384
|
+
loadAndRestoreSession: Ve,
|
|
385
|
+
isSessionLoading: $e,
|
|
386
|
+
authToken: d ? E : U,
|
|
387
|
+
refreshSession: d ? oe : z,
|
|
393
388
|
getCaptchaHeader: I,
|
|
394
389
|
invalidateCaptcha: c,
|
|
395
|
-
inputNotification:
|
|
396
|
-
showInputNotification:
|
|
397
|
-
clearInputNotification:
|
|
390
|
+
inputNotification: je,
|
|
391
|
+
showInputNotification: we,
|
|
392
|
+
clearInputNotification: We
|
|
398
393
|
};
|
|
399
394
|
};
|
|
400
395
|
export {
|
|
401
|
-
|
|
402
|
-
|
|
396
|
+
te as DEFAULT_ERROR_MESSAGE,
|
|
397
|
+
zt as useInkeepChat
|
|
403
398
|
};
|