@inkeep/cxkit-primitives 0.5.29 → 0.5.30
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,4 +1,4 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ee=require("openai"),t=require("react"),$e=require("../../atoms/api/analytics/conversation.cjs"),Ue=require("../../providers/config-provider.cjs"),Ne=require("../../providers/conversation-provider.cjs"),_e=require("../../providers/chat-events-provider.cjs"),D=require("../../utils/get-message-metadata.cjs"),Ae=require("../../utils/misc.cjs"),te=require("../../utils/reset-query-params.cjs"),Re=require("../../providers/chat-form-provider.cjs"),De=require("../../providers/widget-provider.cjs"),Le=require("../../hooks/use-media-query.cjs"),Oe=require("./use-captcha.cjs"),xe=require("../modal/modal-provider.cjs"),m=require("../../utils/generate-uid.cjs"),Fe=()=>{const{chatId:h,setConversation:se,conversation:ne,resetConversation:oe}=Ne.useInkeepConversation(),{baseSettings:k,aiChatSettings:L}=Ue.useInkeepConfig(),{aiApiBaseUrl:O,shouldBypassCaptcha:x,filters:F}=k,K=xe.useModal(),{getSolution:ae,prefetchSolution:b,invalidateSolution:T}=Oe.useCaptcha({fetchUrl:`${O}/v1/challenge`,shouldBypassCaptcha:x,shouldMakeInitialRequest:K?K.isOpen:!0}),re=new Ee({baseURL:`${O}/v1`,apiKey:k.apiKey,dangerouslyAllowBrowser:!0}),{onInputMessageChange:ie,tools:ce,prompts:le,model:ue,onToolCall:ge,filters:B}=L,[p,$]=t.useState(""),Q=t.useRef(null);t.useEffect(()=>{ie?.(p)},[p]);const[u,l]=t.useState([]),[W,f]=t.useState(!1),[de,v]=t.useState(!1),[me,J]=t.useState(null),[U,z]=t.useState(null),[y,S]=t.useState([]),he=e=>{S(s=>[...s,e])},[pe,H]=t.useState({}),i=t.useRef([]),C=t.useRef(null),{logEvent:q}=_e.useChatEvents(),j=le?.map((e,s)=>({id:`system-${Date.now().toString()}-${m.generateUid(4)}-${s}`,role:"system",content:e})),[fe,ve]=t.useState(!!h);t.useEffect(()=>{if(h){const{apiKey:e,analyticsApiBaseUrl:s}=k;$e.getConversation(h,e,s).then(n=>{if(n){q({eventName:"shared_chat_loaded",properties:{conversation:n}}),ve(!1),se({...n,id:""});const o=n.messages.map(c=>({id:Date.now().toString()+m.generateUid(4)+c.id,content:Ae.parseIfJson(c.content),role:c.role,links:c.links}));l(o),i.current=o}})}},[h]);const ye=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${k.organizationDisplayName??"Administrator"}`;default:return`Hmm..
|
|
2
2
|
|
|
3
|
-
It seems I might be having some issues right now. Please clear the chat and try again.`}},
|
|
4
|
-
${D.serializeWorkflow(e)}`},...
|
|
3
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`}},G=e=>{J(e),l(s=>{const n=[...s],o=n[n.length-1];return o&&(o.content=ye(e)),n}),f(!1),v(!1),T(),b()},N=!p.trim()&&!y.length||W,Se=e=>{e.key==="Enter"&&!e.shiftKey&&!N&&!e.nativeEvent.isComposing&&(e.preventDefault(),_())},Ce=e=>{const s=e.target.value;$(s)},_=async(e=p)=>{if(N&&(!e||e.trim().length===0))return;f(!0);const s=U?u.length===2:u.length===0,n=D.getMessageMetadata(U,y,s);let o;const c=D.serializeAttachments(y);y.length&&c?o=[{type:"text",text:c}]:o=e;const X={id:`${Date.now().toString()}-${m.generateUid(4)}-1`,role:"user",content:o,metadata:n},P=[...u.length?[]:j,X];h&&te.resetQueryParams(),l(M=>[...M,...P]),i.current=[...i.current,...P],S([]),$(""),q({eventName:"user_message_submitted",properties:{}},i.current);try{const M={model:ue,messages:i.current,stream:!0,tools:ce,tool_choice:"auto"},Y=await ae(),Z=Y?btoa(JSON.stringify(Y)):null,ee=F||B?JSON.stringify({...F,...B}):void 0,E={};!x&&Z&&(E["X-INKEEP-CHALLENGE-SOLUTION"]=Z),ee&&(E["inkeep-filters"]=ee);const w=re.beta.chat.completions.stream(M,Object.keys(E).length>0?{headers:E}:void 0),a={id:`${Date.now().toString()}-${m.generateUid(4)}-2`,role:"assistant",content:"",links:[]};l(g=>[...g,a]),w.on("content",(g,A)=>{v(!0),a.content=A,l(R=>{const r=[...R],d=r.findIndex(I=>I.id===a.id);return d===-1?[...r,a]:(r[d]={...a},r)})}),w.on("tool_calls.function.arguments.done",g=>{const{name:A,arguments:R}=g;if(A==="provideLinks"){const r=JSON.parse(R);r.links?.length>0&&(a.links=r.links,l(d=>{const I=[...d],qe=I.findIndex(Pe=>Pe.id===a.id);return I[qe]={...a},I}))}else{const r=ge?.(g);r&&H(d=>({...d,[a.id]:[...d[a.id]||[],r]}))}}),w.on("error",g=>{G(g)}),w.finalChatCompletion().then(()=>{i.current=[...i.current,a],C.current=null,f(!1),v(!1),b(),q({eventName:"assistant_message_received",properties:{}},i.current)}),C.current=w.controller}catch(M){G(M),f(!1),v(!1)}},Me=()=>{C.current&&(C.current.abort(),C.current=null),f(!1),v(!1),b()},V=()=>{J(null),l([]),i.current=[],oe(),H({}),S([]),te.resetQueryParams(),z(null),T(),b(),q({eventName:"chat_clear_button_clicked",properties:{conversation:ne}})},we=e=>{z(e);const{initialReplyMessage:s,displayName:n}=e,o={id:u.length.toString()+m.generateUid(4),role:"user",content:n},c={id:(u.length+1).toString()+m.generateUid(4),role:"assistant",content:s,links:[]},P=[{id:`system-${Date.now().toString()}-${m.generateUid(4)}-${e.id}`,role:"system",content:`Company has asked user to follow this guided workflow:
|
|
4
|
+
${D.serializeWorkflow(e)}`},...j,o,c];l(P),S([])},{openForm:Ie}=Re.useChatForm(),ke=De.useWidget();t.useImperativeHandle(L.chatFunctionsRef,()=>({submitMessage:_,updateInputMessage(e){$(e)},clearChat:V,openForm:e=>{ke?.setView("chat"),Ie(e)},focusInput:()=>{Q.current?.focus()}}));const be=Le.useMediaQuery("(max-width: 768px)");return{messages:u,input:p,isLoading:W,isStreaming:de,isLoadingConversation:fe,error:me,isSubmitDisabled:N,handleInputChange:Ce,handleInputKeyDown:Se,handleSubmit:_,stop:Me,clear:V,handleWorkflow:we,selectedWorkflow:U,messageAttachments:y,setMessageAttachments:S,addAttachment:he,messageToolCalls:pe,isEmpty:u.length===0,inputRef:Q,isMobile:be}};exports.useInkeepChat=Fe;
|
|
@@ -1,58 +1,59 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import _e from "openai";
|
|
3
|
-
import { useState as c, useRef as
|
|
4
|
-
import { getConversation as
|
|
5
|
-
import { useInkeepConfig as
|
|
6
|
-
import { useInkeepConversation as
|
|
7
|
-
import { useChatEvents as
|
|
8
|
-
import { getMessageMetadata as
|
|
3
|
+
import { useState as c, useRef as R, useEffect as te, useImperativeHandle as Ae } from "react";
|
|
4
|
+
import { getConversation as xe } from "../../atoms/api/analytics/conversation.js";
|
|
5
|
+
import { useInkeepConfig as De } from "../../providers/config-provider.js";
|
|
6
|
+
import { useInkeepConversation as Le } from "../../providers/conversation-provider.js";
|
|
7
|
+
import { useChatEvents as Oe } from "../../providers/chat-events-provider.js";
|
|
8
|
+
import { getMessageMetadata as Re, serializeAttachments as Pe, serializeWorkflow as Ue } from "../../utils/get-message-metadata.js";
|
|
9
9
|
import { parseIfJson as Fe } from "../../utils/misc.js";
|
|
10
|
-
import { resetQueryParams as
|
|
10
|
+
import { resetQueryParams as se } from "../../utils/reset-query-params.js";
|
|
11
11
|
import { useChatForm as Ke } from "../../providers/chat-form-provider.js";
|
|
12
|
-
import { useWidget as
|
|
13
|
-
import { useMediaQuery as
|
|
14
|
-
import { useCaptcha as
|
|
15
|
-
import { useModal as
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
import { useWidget as Be } from "../../providers/widget-provider.js";
|
|
13
|
+
import { useMediaQuery as Te } from "../../hooks/use-media-query.js";
|
|
14
|
+
import { useCaptcha as We } from "./use-captcha.js";
|
|
15
|
+
import { useModal as Je } from "../modal/modal-provider.js";
|
|
16
|
+
import { generateUid as d } from "../../utils/generate-uid.js";
|
|
17
|
+
const at = () => {
|
|
18
|
+
const { chatId: p, setConversation: ne, conversation: oe, resetConversation: ae } = Le(), { baseSettings: k, aiChatSettings: P } = De(), { aiApiBaseUrl: U, shouldBypassCaptcha: F, filters: K } = k, B = Je(), { getSolution: re, prefetchSolution: b, invalidateSolution: T } = We({
|
|
19
|
+
fetchUrl: `${U}/v1/challenge`,
|
|
19
20
|
shouldBypassCaptcha: F,
|
|
20
|
-
shouldMakeInitialRequest:
|
|
21
|
-
}),
|
|
22
|
-
baseURL: `${
|
|
23
|
-
apiKey:
|
|
21
|
+
shouldMakeInitialRequest: B ? B.isOpen : !0
|
|
22
|
+
}), ie = new _e({
|
|
23
|
+
baseURL: `${U}/v1`,
|
|
24
|
+
apiKey: k.apiKey,
|
|
24
25
|
dangerouslyAllowBrowser: !0
|
|
25
26
|
}), {
|
|
26
|
-
onInputMessageChange:
|
|
27
|
-
tools:
|
|
28
|
-
prompts:
|
|
29
|
-
model:
|
|
30
|
-
onToolCall:
|
|
31
|
-
filters:
|
|
32
|
-
} =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}, [
|
|
36
|
-
const [u, l] = c([]), [
|
|
37
|
-
|
|
38
|
-
}, [
|
|
39
|
-
id: `system-${Date.now().toString()}-${t}`,
|
|
27
|
+
onInputMessageChange: ce,
|
|
28
|
+
tools: le,
|
|
29
|
+
prompts: ue,
|
|
30
|
+
model: me,
|
|
31
|
+
onToolCall: ge,
|
|
32
|
+
filters: W
|
|
33
|
+
} = P, [f, _] = c(""), J = R(null);
|
|
34
|
+
te(() => {
|
|
35
|
+
ce?.(f);
|
|
36
|
+
}, [f]);
|
|
37
|
+
const [u, l] = c([]), [z, h] = c(!1), [de, y] = c(!1), [pe, H] = c(null), [A, Q] = c(null), [C, w] = c([]), fe = (e) => {
|
|
38
|
+
w((t) => [...t, e]);
|
|
39
|
+
}, [he, j] = c({}), r = R([]), I = R(null), { logEvent: $ } = Oe(), q = ue?.map((e, t) => ({
|
|
40
|
+
id: `system-${Date.now().toString()}-${d(4)}-${t}`,
|
|
40
41
|
role: "system",
|
|
41
42
|
content: e
|
|
42
|
-
})), [
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
const { apiKey: e, analyticsApiBaseUrl: t } =
|
|
46
|
-
|
|
43
|
+
})), [ye, Ce] = c(!!p);
|
|
44
|
+
te(() => {
|
|
45
|
+
if (p) {
|
|
46
|
+
const { apiKey: e, analyticsApiBaseUrl: t } = k;
|
|
47
|
+
xe(p, e, t).then((s) => {
|
|
47
48
|
if (s) {
|
|
48
|
-
|
|
49
|
+
$({
|
|
49
50
|
eventName: "shared_chat_loaded",
|
|
50
51
|
properties: {
|
|
51
52
|
conversation: s
|
|
52
53
|
}
|
|
53
|
-
}),
|
|
54
|
+
}), Ce(!1), ne({ ...s, id: "" });
|
|
54
55
|
const n = s.messages.map((i) => ({
|
|
55
|
-
id: Date.now().toString() + i.id,
|
|
56
|
+
id: Date.now().toString() + d(4) + i.id,
|
|
56
57
|
content: Fe(i.content),
|
|
57
58
|
role: i.role,
|
|
58
59
|
links: i.links
|
|
@@ -61,42 +62,42 @@ const nt = () => {
|
|
|
61
62
|
}
|
|
62
63
|
});
|
|
63
64
|
}
|
|
64
|
-
}, [
|
|
65
|
-
const
|
|
65
|
+
}, [p]);
|
|
66
|
+
const we = (e) => {
|
|
66
67
|
switch (e.code) {
|
|
67
68
|
case 400:
|
|
68
69
|
return e.message;
|
|
69
70
|
case 403:
|
|
70
|
-
return `There seems to be a configuration error. Please contact ${
|
|
71
|
+
return `There seems to be a configuration error. Please contact ${k.organizationDisplayName ?? "Administrator"}`;
|
|
71
72
|
default:
|
|
72
73
|
return `Hmm..
|
|
73
74
|
|
|
74
75
|
It seems I might be having some issues right now. Please clear the chat and try again.`;
|
|
75
76
|
}
|
|
76
|
-
},
|
|
77
|
-
|
|
77
|
+
}, G = (e) => {
|
|
78
|
+
H(e), l((t) => {
|
|
78
79
|
const s = [...t], n = s[s.length - 1];
|
|
79
|
-
return n && (n.content =
|
|
80
|
-
}),
|
|
81
|
-
},
|
|
82
|
-
e.key === "Enter" && !e.shiftKey &&
|
|
83
|
-
},
|
|
80
|
+
return n && (n.content = we(e)), s;
|
|
81
|
+
}), h(!1), y(!1), T(), b();
|
|
82
|
+
}, x = !f.trim() && !C.length || z, Ie = (e) => {
|
|
83
|
+
e.key === "Enter" && !e.shiftKey && !x && !e.nativeEvent.isComposing && (e.preventDefault(), D());
|
|
84
|
+
}, ve = (e) => {
|
|
84
85
|
const t = e.target.value;
|
|
85
86
|
_(t);
|
|
86
|
-
},
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
const t = A ? u.length === 2 : u.length === 0, s =
|
|
87
|
+
}, D = async (e = f) => {
|
|
88
|
+
if (x && (!e || e.trim().length === 0)) return;
|
|
89
|
+
h(!0);
|
|
90
|
+
const t = A ? u.length === 2 : u.length === 0, s = Re(A, C, t);
|
|
90
91
|
let n;
|
|
91
|
-
const i =
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
id: `${Date.now().toString()}1`,
|
|
92
|
+
const i = Pe(C);
|
|
93
|
+
C.length && i ? n = [{ type: "text", text: i }] : n = e;
|
|
94
|
+
const X = {
|
|
95
|
+
id: `${Date.now().toString()}-${d(4)}-1`,
|
|
95
96
|
role: "user",
|
|
96
97
|
content: n,
|
|
97
98
|
metadata: s
|
|
98
|
-
}, E = [...u.length ? [] :
|
|
99
|
-
|
|
99
|
+
}, E = [...u.length ? [] : q, X];
|
|
100
|
+
p && se(), l((v) => [...v, ...E]), r.current = [...r.current, ...E], w([]), _(""), $(
|
|
100
101
|
{
|
|
101
102
|
eventName: "user_message_submitted",
|
|
102
103
|
properties: {}
|
|
@@ -104,128 +105,128 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
104
105
|
r.current
|
|
105
106
|
);
|
|
106
107
|
try {
|
|
107
|
-
const
|
|
108
|
-
model:
|
|
108
|
+
const v = {
|
|
109
|
+
model: me,
|
|
109
110
|
messages: r.current,
|
|
110
111
|
stream: !0,
|
|
111
|
-
tools:
|
|
112
|
+
tools: le,
|
|
112
113
|
tool_choice: "auto"
|
|
113
|
-
},
|
|
114
|
+
}, Y = await re(), Z = Y ? btoa(JSON.stringify(Y)) : null, ee = K || W ? JSON.stringify({
|
|
114
115
|
...K,
|
|
115
|
-
...
|
|
116
|
+
...W
|
|
116
117
|
}) : void 0, N = {};
|
|
117
|
-
!F &&
|
|
118
|
-
const
|
|
119
|
-
|
|
118
|
+
!F && Z && (N["X-INKEEP-CHALLENGE-SOLUTION"] = Z), ee && (N["inkeep-filters"] = ee);
|
|
119
|
+
const M = ie.beta.chat.completions.stream(
|
|
120
|
+
v,
|
|
120
121
|
Object.keys(N).length > 0 ? { headers: N } : void 0
|
|
121
122
|
), o = {
|
|
122
|
-
id: `${Date.now().toString()}2`,
|
|
123
|
+
id: `${Date.now().toString()}-${d(4)}-2`,
|
|
123
124
|
role: "assistant",
|
|
124
125
|
content: "",
|
|
125
126
|
links: []
|
|
126
127
|
};
|
|
127
|
-
l((m) => [...m, o]),
|
|
128
|
-
|
|
129
|
-
const a = [...
|
|
128
|
+
l((m) => [...m, o]), M.on("content", (m, L) => {
|
|
129
|
+
y(!0), o.content = L, l((O) => {
|
|
130
|
+
const a = [...O], g = a.findIndex((S) => S.id === o.id);
|
|
130
131
|
return g === -1 ? [...a, o] : (a[g] = { ...o }, a);
|
|
131
132
|
});
|
|
132
|
-
}),
|
|
133
|
-
const { name:
|
|
134
|
-
if (
|
|
135
|
-
const a = JSON.parse(
|
|
133
|
+
}), M.on("tool_calls.function.arguments.done", (m) => {
|
|
134
|
+
const { name: L, arguments: O } = m;
|
|
135
|
+
if (L === "provideLinks") {
|
|
136
|
+
const a = JSON.parse(O);
|
|
136
137
|
a.links?.length > 0 && (o.links = a.links, l((g) => {
|
|
137
|
-
const
|
|
138
|
-
return
|
|
138
|
+
const S = [...g], Ee = S.findIndex((Ne) => Ne.id === o.id);
|
|
139
|
+
return S[Ee] = { ...o }, S;
|
|
139
140
|
}));
|
|
140
141
|
} else {
|
|
141
|
-
const a =
|
|
142
|
-
a &&
|
|
142
|
+
const a = ge?.(m);
|
|
143
|
+
a && j((g) => ({
|
|
143
144
|
...g,
|
|
144
145
|
[o.id]: [...g[o.id] || [], a]
|
|
145
146
|
}));
|
|
146
147
|
}
|
|
147
|
-
}),
|
|
148
|
-
|
|
149
|
-
}),
|
|
150
|
-
r.current = [...r.current, o],
|
|
148
|
+
}), M.on("error", (m) => {
|
|
149
|
+
G(m);
|
|
150
|
+
}), M.finalChatCompletion().then(() => {
|
|
151
|
+
r.current = [...r.current, o], I.current = null, h(!1), y(!1), b(), $(
|
|
151
152
|
{
|
|
152
153
|
eventName: "assistant_message_received",
|
|
153
154
|
properties: {}
|
|
154
155
|
},
|
|
155
156
|
r.current
|
|
156
157
|
);
|
|
157
|
-
}),
|
|
158
|
-
} catch (
|
|
159
|
-
|
|
158
|
+
}), I.current = M.controller;
|
|
159
|
+
} catch (v) {
|
|
160
|
+
G(v), h(!1), y(!1);
|
|
160
161
|
}
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
},
|
|
164
|
-
|
|
162
|
+
}, Me = () => {
|
|
163
|
+
I.current && (I.current.abort(), I.current = null), h(!1), y(!1), b();
|
|
164
|
+
}, V = () => {
|
|
165
|
+
H(null), l([]), r.current = [], ae(), j({}), w([]), se(), Q(null), T(), b(), $({
|
|
165
166
|
eventName: "chat_clear_button_clicked",
|
|
166
167
|
properties: {
|
|
167
|
-
conversation:
|
|
168
|
+
conversation: oe
|
|
168
169
|
}
|
|
169
170
|
});
|
|
170
|
-
},
|
|
171
|
-
|
|
171
|
+
}, Se = (e) => {
|
|
172
|
+
Q(e);
|
|
172
173
|
const { initialReplyMessage: t, displayName: s } = e, n = {
|
|
173
|
-
id: u.length.toString(),
|
|
174
|
+
id: u.length.toString() + d(4),
|
|
174
175
|
role: "user",
|
|
175
176
|
content: s
|
|
176
177
|
}, i = {
|
|
177
|
-
id: (u.length + 1).toString(),
|
|
178
|
+
id: (u.length + 1).toString() + d(4),
|
|
178
179
|
role: "assistant",
|
|
179
180
|
content: t,
|
|
180
181
|
links: []
|
|
181
182
|
}, E = [{
|
|
182
|
-
id: `system-${Date.now().toString()}-${e.id}`,
|
|
183
|
+
id: `system-${Date.now().toString()}-${d(4)}-${e.id}`,
|
|
183
184
|
role: "system",
|
|
184
185
|
content: `Company has asked user to follow this guided workflow:
|
|
185
|
-
${
|
|
186
|
+
${Ue(
|
|
186
187
|
e
|
|
187
188
|
)}`
|
|
188
|
-
}, ...
|
|
189
|
-
l(E),
|
|
190
|
-
}, { openForm:
|
|
191
|
-
Ae(
|
|
192
|
-
submitMessage:
|
|
189
|
+
}, ...q, n, i];
|
|
190
|
+
l(E), w([]);
|
|
191
|
+
}, { openForm: ke } = Ke(), be = Be();
|
|
192
|
+
Ae(P.chatFunctionsRef, () => ({
|
|
193
|
+
submitMessage: D,
|
|
193
194
|
updateInputMessage(e) {
|
|
194
195
|
_(e);
|
|
195
196
|
},
|
|
196
|
-
clearChat:
|
|
197
|
+
clearChat: V,
|
|
197
198
|
openForm: (e) => {
|
|
198
|
-
|
|
199
|
+
be?.setView("chat"), ke(e);
|
|
199
200
|
},
|
|
200
201
|
focusInput: () => {
|
|
201
|
-
|
|
202
|
+
J.current?.focus();
|
|
202
203
|
}
|
|
203
204
|
}));
|
|
204
|
-
const
|
|
205
|
+
const $e = Te("(max-width: 768px)");
|
|
205
206
|
return {
|
|
206
207
|
messages: u,
|
|
207
|
-
input:
|
|
208
|
-
isLoading:
|
|
209
|
-
isStreaming:
|
|
210
|
-
isLoadingConversation:
|
|
211
|
-
error:
|
|
212
|
-
isSubmitDisabled:
|
|
213
|
-
handleInputChange:
|
|
214
|
-
handleInputKeyDown:
|
|
215
|
-
handleSubmit:
|
|
216
|
-
stop:
|
|
217
|
-
clear:
|
|
218
|
-
handleWorkflow:
|
|
208
|
+
input: f,
|
|
209
|
+
isLoading: z,
|
|
210
|
+
isStreaming: de,
|
|
211
|
+
isLoadingConversation: ye,
|
|
212
|
+
error: pe,
|
|
213
|
+
isSubmitDisabled: x,
|
|
214
|
+
handleInputChange: ve,
|
|
215
|
+
handleInputKeyDown: Ie,
|
|
216
|
+
handleSubmit: D,
|
|
217
|
+
stop: Me,
|
|
218
|
+
clear: V,
|
|
219
|
+
handleWorkflow: Se,
|
|
219
220
|
selectedWorkflow: A,
|
|
220
|
-
messageAttachments:
|
|
221
|
-
setMessageAttachments:
|
|
222
|
-
addAttachment:
|
|
223
|
-
messageToolCalls:
|
|
221
|
+
messageAttachments: C,
|
|
222
|
+
setMessageAttachments: w,
|
|
223
|
+
addAttachment: fe,
|
|
224
|
+
messageToolCalls: he,
|
|
224
225
|
isEmpty: u.length === 0,
|
|
225
|
-
inputRef:
|
|
226
|
-
isMobile:
|
|
226
|
+
inputRef: J,
|
|
227
|
+
isMobile: $e
|
|
227
228
|
};
|
|
228
229
|
};
|
|
229
230
|
export {
|
|
230
|
-
|
|
231
|
+
at as useInkeepChat
|
|
231
232
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react/jsx-runtime"),t=require("react"),y=require("../atoms/api/analytics/events.cjs"),B=require("./config-provider.cjs"),b=require("./user-provider.cjs"),p=t.createContext(void 0),f=({children:e})=>{const{baseSettings:s,componentType:n}=B.useInkeepConfig(),{apiKey:o,analyticsApiBaseUrl:r,tags:i,privacyPreferences:d,env:E}=s,{userProperties:c}=b.useUser(),a=t.useMemo(()=>({widgetLibraryVersion:"0.5.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react/jsx-runtime"),t=require("react"),y=require("../atoms/api/analytics/events.cjs"),B=require("./config-provider.cjs"),b=require("./user-provider.cjs"),p=t.createContext(void 0),f=({children:e})=>{const{baseSettings:s,componentType:n}=B.useInkeepConfig(),{apiKey:o,analyticsApiBaseUrl:r,tags:i,privacyPreferences:d,env:E}=s,{userProperties:c}=b.useUser(),a=t.useMemo(()=>({widgetLibraryVersion:"0.5.30",componentType:n,tags:i}),[n,i]),u=!d.optOutAllAnalytics&&E!=="development",g={logEvent:t.useCallback(async v=>{const m={...a,...v.properties},l={eventName:v.eventName,properties:m,userProperties:c};u&&y.logEvent(l,o,r),s.onEvent?.(l)},[u,s,o,r,c,a])};return P.jsx(p.Provider,{value:g,children:e})},x=()=>{const e=t.useContext(p);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=f;exports.useBaseEvents=x;
|
|
@@ -7,7 +7,7 @@ import { useUser as b } from "./user-provider.js";
|
|
|
7
7
|
const m = x(void 0), U = ({ children: e }) => {
|
|
8
8
|
const { baseSettings: t, componentType: o } = C(), { apiKey: n, analyticsApiBaseUrl: s, tags: r, privacyPreferences: u, env: l } = t, { userProperties: i } = b(), a = d(
|
|
9
9
|
() => ({
|
|
10
|
-
widgetLibraryVersion: "0.5.
|
|
10
|
+
widgetLibraryVersion: "0.5.30",
|
|
11
11
|
componentType: o,
|
|
12
12
|
tags: r
|
|
13
13
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/cxkit-primitives",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.30",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Inkeep, Inc. Customer License (IICL) v1.1",
|
|
6
6
|
"homepage": "",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"rehype-raw": "7.0.0",
|
|
59
59
|
"unist-util-visit": "^5.0.0",
|
|
60
60
|
"use-sync-external-store": "^1.4.0",
|
|
61
|
-
"@inkeep/cxkit-color-mode": "0.5.
|
|
62
|
-
"@inkeep/cxkit-theme": "0.5.
|
|
63
|
-
"@inkeep/cxkit-types": "0.5.
|
|
61
|
+
"@inkeep/cxkit-color-mode": "0.5.30",
|
|
62
|
+
"@inkeep/cxkit-theme": "0.5.30",
|
|
63
|
+
"@inkeep/cxkit-types": "0.5.30"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@biomejs/biome": "1.9.4",
|