@inkeep/cxkit-primitives 0.5.78 → 0.5.80
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/atoms/api/analytics/conversation.cjs +1 -1
- package/dist/atoms/api/analytics/conversation.js +36 -28
- package/dist/atoms/api/analytics/events.cjs +1 -1
- package/dist/atoms/api/analytics/events.js +28 -24
- package/dist/atoms/api/analytics/feedback.cjs +1 -1
- package/dist/atoms/api/analytics/feedback.js +25 -21
- package/dist/atoms/error-boundary.cjs +1 -0
- package/dist/atoms/error-boundary.js +9 -0
- package/dist/components/embedded-chat/use-captcha.cjs +1 -1
- package/dist/components/embedded-chat/use-captcha.js +20 -20
- package/dist/components/embedded-chat/use-inkeep-chat.cjs +3 -3
- package/dist/components/embedded-chat/use-inkeep-chat.js +98 -96
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +18 -16
- package/dist/providers/base-events-provider.cjs +1 -1
- package/dist/providers/base-events-provider.js +1 -1
- package/dist/utils/graphql-client.cjs +1 -1
- package/dist/utils/graphql-client.js +23 -19
- package/package.json +9 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function c(
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function c(e,n,r,t){try{const o=`${t}/conversations`,a={id:e||void 0,type:"openai",...n},i=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify(a)});if(!i.ok){const s=await i.text();throw new Error(`Failed to log conversation: ${s}`)}return i.json()}catch(o){console.warn("Error in logConversation:",o)}}async function l(e,n,r){try{const t=`${r}/conversations/${e}`,o=await fetch(t,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});if(!o.ok){const a=await o.text();throw new Error(`Failed to get conversation: ${a}`)}return o.json()}catch(t){console.warn("Error in getConversation:",t)}}exports.getConversation=l;exports.logConversation=c;
|
|
@@ -1,37 +1,45 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
async function c(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
async function c(r, n, e, t) {
|
|
3
|
+
try {
|
|
4
|
+
const o = `${t}/conversations`, a = {
|
|
5
|
+
id: r || void 0,
|
|
6
|
+
type: "openai",
|
|
7
|
+
...n
|
|
8
|
+
}, i = await fetch(o, {
|
|
9
|
+
method: "POST",
|
|
10
|
+
headers: {
|
|
11
|
+
"Content-Type": "application/json",
|
|
12
|
+
Authorization: `Bearer ${e}`
|
|
13
|
+
},
|
|
14
|
+
body: JSON.stringify(a)
|
|
15
|
+
});
|
|
16
|
+
if (!i.ok) {
|
|
17
|
+
const s = await i.text();
|
|
18
|
+
throw new Error(`Failed to log conversation: ${s}`);
|
|
19
|
+
}
|
|
20
|
+
return i.json();
|
|
21
|
+
} catch (o) {
|
|
22
|
+
console.warn("Error in logConversation:", o);
|
|
18
23
|
}
|
|
19
|
-
return s.json();
|
|
20
24
|
}
|
|
21
|
-
async function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
async function l(r, n, e) {
|
|
26
|
+
try {
|
|
27
|
+
const t = `${e}/conversations/${r}`, o = await fetch(t, {
|
|
28
|
+
headers: {
|
|
29
|
+
"Content-Type": "application/json",
|
|
30
|
+
Authorization: `Bearer ${n}`
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
if (!o.ok) {
|
|
34
|
+
const a = await o.text();
|
|
35
|
+
throw new Error(`Failed to get conversation: ${a}`);
|
|
26
36
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
throw new Error(`Failed to get conversation: ${i}`);
|
|
37
|
+
return o.json();
|
|
38
|
+
} catch (t) {
|
|
39
|
+
console.warn("Error in getConversation:", t);
|
|
31
40
|
}
|
|
32
|
-
return o.json();
|
|
33
41
|
}
|
|
34
42
|
export {
|
|
35
|
-
|
|
43
|
+
l as getConversation,
|
|
36
44
|
c as logConversation
|
|
37
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function a(e,
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function a(e,s,i){try{const t=`${i}/events`,r={...e,type:e.eventName};if("searchQuery"in e.properties)r.entityType="search",r.searchQuery=e.properties.searchQuery;else if("messageId"in e.properties)r.entityType="message",r.messageId=e.properties.messageId;else{if(r.entityType="conversation",!e.properties.conversation)return;r.conversationId=e.properties.conversation.id}const o=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify(r)});if(!o.ok){const n=await o.text();throw new Error(`Failed to log event: ${n}`)}}catch(t){console.warn("Error in logEvent:",t)}}exports.logEvent=a;
|
|
@@ -1,28 +1,32 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
async function a(e,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
async function a(e, s, i) {
|
|
3
|
+
try {
|
|
4
|
+
const o = `${i}/events`, r = {
|
|
5
|
+
...e,
|
|
6
|
+
type: e.eventName
|
|
7
|
+
};
|
|
8
|
+
if ("searchQuery" in e.properties)
|
|
9
|
+
r.entityType = "search", r.searchQuery = e.properties.searchQuery;
|
|
10
|
+
else if ("messageId" in e.properties)
|
|
11
|
+
r.entityType = "message", r.messageId = e.properties.messageId;
|
|
12
|
+
else {
|
|
13
|
+
if (r.entityType = "conversation", !e.properties.conversation) return;
|
|
14
|
+
r.conversationId = e.properties.conversation.id;
|
|
15
|
+
}
|
|
16
|
+
const t = await fetch(o, {
|
|
17
|
+
method: "POST",
|
|
18
|
+
headers: {
|
|
19
|
+
"Content-Type": "application/json",
|
|
20
|
+
Authorization: `Bearer ${s}`
|
|
21
|
+
},
|
|
22
|
+
body: JSON.stringify(r)
|
|
23
|
+
});
|
|
24
|
+
if (!t.ok) {
|
|
25
|
+
const n = await t.text();
|
|
26
|
+
throw new Error(`Failed to log event: ${n}`);
|
|
27
|
+
}
|
|
28
|
+
} catch (o) {
|
|
29
|
+
console.warn("Error in logEvent:", o);
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
32
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function p(o){try{const{type:e,messageId:n,reasons:s=[],apiKey:a,apiUrl:i,userProperties:c,properties:d}=o,b=`${i}/feedback`,r={type:e,messageId:n,createdAt:new Date().toISOString(),userProperties:c,properties:d};e==="negative"&&(r.reasons=s);const t=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(r)});if(!t.ok){const u=await t.text();throw new Error(`Failed to send feedback: ${u}`)}return t.json()}catch(e){console.warn("Error in submitFeedback:",e)}}exports.submitFeedback=p;
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
async function u(
|
|
3
|
-
|
|
4
|
-
type:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
async function u(o) {
|
|
3
|
+
try {
|
|
4
|
+
const { type: e, messageId: n, reasons: s = [], apiKey: a, apiUrl: i, userProperties: c, properties: d } = o, p = `${i}/feedback`, r = {
|
|
5
|
+
type: e,
|
|
6
|
+
messageId: n,
|
|
7
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8
|
+
userProperties: c,
|
|
9
|
+
properties: d
|
|
10
|
+
};
|
|
11
|
+
e === "negative" && (r.reasons = s);
|
|
12
|
+
const t = await fetch(p, {
|
|
13
|
+
method: "POST",
|
|
14
|
+
headers: {
|
|
15
|
+
"Content-Type": "application/json",
|
|
16
|
+
Authorization: `Bearer ${a}`
|
|
17
|
+
},
|
|
18
|
+
body: JSON.stringify(r)
|
|
19
|
+
});
|
|
20
|
+
if (!t.ok) {
|
|
21
|
+
const b = await t.text();
|
|
22
|
+
throw new Error(`Failed to send feedback: ${b}`);
|
|
23
|
+
}
|
|
24
|
+
return t.json();
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.warn("Error in submitFeedback:", e);
|
|
22
27
|
}
|
|
23
|
-
return e.json();
|
|
24
28
|
}
|
|
25
29
|
export {
|
|
26
30
|
u as submitFeedback
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),u=require("react-error-boundary"),a=()=>null,c=({children:r})=>{const o=(n,e)=>{console.warn(n),console.warn(e)};return t.jsx(u.ErrorBoundary,{FallbackComponent:a,onError:o,children:r})};exports.ErrorBoundary=c;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
3
|
+
import { ErrorBoundary as e } from "react-error-boundary";
|
|
4
|
+
const l = () => null, u = ({ children: r }) => /* @__PURE__ */ a(e, { FallbackComponent: l, onError: (o, n) => {
|
|
5
|
+
console.warn(o), console.warn(n);
|
|
6
|
+
}, children: r });
|
|
7
|
+
export {
|
|
8
|
+
u as ErrorBoundary
|
|
9
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("altcha-lib"),l=require("react"),f={getSolution:async()=>{},prefetchSolution:()=>{},invalidateSolution:()=>{}},u=async n=>{try{const t=await fetch(n,{method:"GET"});if(!t.ok)throw new Error(`Failed to fetch challenge: ${t.statusText}`);const o=await t.json(),{challenge:e,algorithm:r,salt:c,maxnumber:s}=o,{promise:a}=await h.solveChallenge(e,c,r,s),i=await a||void 0;if(!i)throw new Error("Challenge not solved");return{number:i.number,...o}}catch(t){console.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("altcha-lib"),l=require("react"),f={getSolution:async()=>{},prefetchSolution:()=>{},invalidateSolution:()=>{}},u=async n=>{try{const t=await fetch(n,{method:"GET"});if(!t.ok)throw new Error(`Failed to fetch challenge: ${t.statusText}`);const o=await t.json(),{challenge:e,algorithm:r,salt:c,maxnumber:s}=o,{promise:a}=await h.solveChallenge(e,c,r,s),i=await a||void 0;if(!i)throw new Error("Challenge not solved");return{number:i.number,...o}}catch(t){console.warn("Error solving captcha:",t)}},g=({fetchUrl:n,shouldBypassCaptcha:t=!1,shouldMakeInitialRequest:o=!0})=>{if(t)return f;const e=l.useRef(null),r=l.useCallback(()=>{e.current||(e.current=u(n))},[n]),c=l.useCallback(async()=>{let a=await e.current;return a||(e.current=u(n),a=await e.current),e.current=null,a},[n]),s=l.useCallback(()=>{e.current=null},[]);return l.useEffect(()=>{o&&r()},[r,o]),{getSolution:c,prefetchSolution:r,invalidateSolution:s}};exports.fetchAndSolveChallenge=u;exports.useCaptcha=g;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { solveChallenge as f } from "altcha-lib";
|
|
3
3
|
import { useRef as h, useCallback as s, useEffect as m } from "react";
|
|
4
|
-
const
|
|
4
|
+
const w = {
|
|
5
5
|
getSolution: async () => {
|
|
6
6
|
},
|
|
7
7
|
prefetchSolution: () => {
|
|
@@ -10,42 +10,42 @@ const g = {
|
|
|
10
10
|
}
|
|
11
11
|
}, u = async (n) => {
|
|
12
12
|
try {
|
|
13
|
-
const
|
|
13
|
+
const o = await fetch(n, {
|
|
14
14
|
method: "GET"
|
|
15
15
|
});
|
|
16
|
-
if (!
|
|
17
|
-
throw new Error(`Failed to fetch challenge: ${
|
|
18
|
-
const e = await
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
if (!o.ok)
|
|
17
|
+
throw new Error(`Failed to fetch challenge: ${o.statusText}`);
|
|
18
|
+
const e = await o.json(), { challenge: t, algorithm: r, salt: l, maxnumber: c } = e, { promise: a } = await f(
|
|
19
|
+
t,
|
|
20
|
+
l,
|
|
21
21
|
r,
|
|
22
22
|
c
|
|
23
|
-
), i = await
|
|
23
|
+
), i = await a || void 0;
|
|
24
24
|
if (!i)
|
|
25
25
|
throw new Error("Challenge not solved");
|
|
26
26
|
return { number: i.number, ...e };
|
|
27
|
-
} catch (
|
|
28
|
-
console.
|
|
27
|
+
} catch (o) {
|
|
28
|
+
console.warn("Error solving captcha:", o);
|
|
29
29
|
}
|
|
30
30
|
}, v = ({
|
|
31
31
|
fetchUrl: n,
|
|
32
|
-
shouldBypassCaptcha:
|
|
32
|
+
shouldBypassCaptcha: o = !1,
|
|
33
33
|
shouldMakeInitialRequest: e = !0
|
|
34
34
|
}) => {
|
|
35
|
-
if (
|
|
36
|
-
return
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
}, [n]),
|
|
40
|
-
let
|
|
41
|
-
return
|
|
35
|
+
if (o)
|
|
36
|
+
return w;
|
|
37
|
+
const t = h(null), r = s(() => {
|
|
38
|
+
t.current || (t.current = u(n));
|
|
39
|
+
}, [n]), l = s(async () => {
|
|
40
|
+
let a = await t.current;
|
|
41
|
+
return a || (t.current = u(n), a = await t.current), t.current = null, a;
|
|
42
42
|
}, [n]), c = s(() => {
|
|
43
|
-
|
|
43
|
+
t.current = null;
|
|
44
44
|
}, []);
|
|
45
45
|
return m(() => {
|
|
46
46
|
e && r();
|
|
47
47
|
}, [r, e]), {
|
|
48
|
-
getSolution:
|
|
48
|
+
getSolution: l,
|
|
49
49
|
prefetchSolution: r,
|
|
50
50
|
invalidateSolution: c
|
|
51
51
|
};
|
|
@@ -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 ae=require("openai"),t=require("react"),Re=require("../../providers/config-provider.cjs"),Le=require("../../providers/conversation-provider.cjs"),xe=require("../../providers/chat-events-provider.cjs"),F=require("../../utils/get-message-metadata.cjs"),re=require("../../utils/reset-query-params.cjs"),Be=require("../../providers/chat-form-provider.cjs"),Oe=require("../../providers/widget-provider.cjs"),De=require("../../hooks/use-media-query.cjs"),Fe=require("./use-captcha.cjs"),Te=require("../modal/modal-provider.cjs"),g=require("../../utils/generate-uid.cjs"),Ke=require("../../utils/tools/links-tool.cjs"),Qe=require("../../atoms/api/analytics/conversation.cjs"),We=require("../../utils/misc.cjs"),Je=()=>{const{chatId:y,setConversation:ie,conversation:N,resetConversation:ce}=Le.useInkeepConversation(),{baseSettings:q,aiChatSettings:T}=Re.useInkeepConfig(),{aiApiBaseUrl:K,shouldBypassCaptcha:Q,filters:W}=q,J=Te.useModal(),{getSolution:le,prefetchSolution:P,invalidateSolution:z}=Fe.useCaptcha({fetchUrl:`${K}/v1/challenge`,shouldBypassCaptcha:Q,shouldMakeInitialRequest:J?J.isOpen:!0}),ue=new ae({baseURL:`${K}/v1`,apiKey:q.apiKey??"",dangerouslyAllowBrowser:!0}),{onInputMessageChange:de,getTools:ge,prompts:me,model:fe,filters:H,onToolCall:pe}=T,[S,R]=t.useState(""),j=t.useRef(null);t.useEffect(()=>{de?.(S)},[S]);const[m,l]=t.useState([]),[G,M]=t.useState(!1),[he,w]=t.useState(!1),[ve,V]=t.useState(null),[L,X]=t.useState(null),[C,I]=t.useState([]),ye=e=>{I(s=>[...s,e])},[Se,Y]=t.useState({}),o=t.useRef([]),k=t.useRef(null),{logEvent:_}=xe.useChatEvents(),Z=me?.map((e,s)=>({id:`system-${Date.now().toString()}-${g.generateUid(4)}-${s}`,role:"system",content:e})),[Me,we]=t.useState(!!y);t.useEffect(()=>{if(y){const{apiKey:e,analyticsApiBaseUrl:s}=q;Qe.getConversation(y,e,s).then(a=>{if(a){_({eventName:"shared_chat_loaded",properties:{conversation:a}}),we(!1),ie({...a});const r=a.messages.map(f=>({...f,content:We.parseIfJson(f.content)}));l(r),o.current=r}})}},[y]);const Ce=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${q.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.`}},ee=e=>{V(e),l(s=>{const a=[...s],r=a[a.length-1];return r&&(r.content=Ce(e)),a}),
|
|
4
|
-
${F.serializeWorkflow(e)}`},...Z,r,
|
|
3
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`}},ee=e=>{V(e),l(s=>{const a=[...s],r=a[a.length-1];return r&&(r.content=Ce(e)),a}),M(!1),w(!1),z(),P()},x=!S.trim()&&!C.length||G,Ie=e=>{e.key==="Enter"&&!e.shiftKey&&!x&&!e.nativeEvent.isComposing&&(e.preventDefault(),B())},ke=e=>{const s=e.target.value;R(s)},B=async(e=S)=>{if(x&&(!e||e.trim().length===0))return;M(!0);const s=L?m.length===2:m.length===0,a=F.getMessageMetadata(L,C,s);let r;const f=F.serializeAttachments(C);C.length&&f?r=[{type:"text",text:f}]:r=e;const se={id:`${Date.now().toString()}-${g.generateUid(4)}-1`,role:"user",content:r,metadata:a},p=[...m.length?[]:Z,se];if(y){re.resetQueryParams();const u=o.current.map((i,E)=>({id:`${i.id}-${g.generateUid(6)}-${E}`,role:i.role,...i.role==="assistant"?{links:i.links??[]}:{},content:i.content,metadata:i.metadata,tool_calls:i.tool_calls}));l([...u,...p]),o.current=[...u,...p]}else l(u=>[...u,...p]),o.current=[...o.current,...p];I([]),R(""),_({eventName:"user_message_submitted",properties:{}},o.current);const ne=[Ke.provideLinksTool,...ge?.({conversation:N})||[]];try{const u={model:fe,messages:o.current,stream:!0,tools:ne,tool_choice:"auto"},i=await le(),E=i?btoa(JSON.stringify(i)):null,oe=W||H?JSON.stringify({...W,...H}):void 0,U={};!Q&&E&&(U["X-INKEEP-CHALLENGE-SOLUTION"]=E),oe&&(U["inkeep-filters"]=oe);const h=ue.beta.chat.completions.stream(u,Object.keys(U).length>0?{headers:U}:void 0),n={id:`${Date.now().toString()}-${g.generateUid(4)}-2`,role:"assistant",content:"",links:[],tool_calls:[]};l(d=>[...d,n]),h.on("content",(d,b)=>{w(!0),n.content=b,l(A=>{const c=[...A],O=c.findIndex($=>$.id===n.id);return O===-1?[...c,n]:(c[O]={...n},c)})}),h.on("tool_calls.function.arguments.done",async d=>{const{name:b,arguments:A}=d,c=ne?.find(v=>v.function.name===b);if(!c)return;const $=("parse"in c.function?c.function.parse:JSON.parse)(A),Ee=c.function.function?.($,h),Ue=c.renderMessageButtons?.({args:$,execution:Ee})??[];b==="provideLinks"?n.links=$.links??[]:Y(v=>({...v,[n.id]:[...v[n.id]??[],...Ue]})),n.tool_calls?.push({id:"call_"+g.generateUid(24),type:"function",function:{name:b,arguments:A}}),l(v=>{const D=[...v],Ae=D.findIndex(Ne=>Ne.id===n.id);return D[Ae]={...n},D}),pe?.(d,{conversation:{...N,messages:[...o.current,n]}})}),h.on("error",ee),h.finalChatCompletion().then(()=>{o.current=[...o.current,n],k.current=null,M(!1),w(!1),P(),_({eventName:"assistant_message_received",properties:{}},o.current)}).catch(d=>{d instanceof ae.APIUserAbortError||console.warn(d)}),k.current=h.controller}catch(u){ee(u),M(!1),w(!1)}},be=()=>{k.current&&(k.current.abort(),k.current=null),M(!1),w(!1),P()},te=()=>{V(null),l([]),o.current=[],ce(),Y({}),I([]),re.resetQueryParams(),X(null),z(),P(),_({eventName:"chat_clear_button_clicked",properties:{conversation:N}})},$e=e=>{X(e);const{initialReplyMessage:s,displayName:a}=e,r={id:m.length.toString()+g.generateUid(4),role:"user",content:a},f={id:(m.length+1).toString()+g.generateUid(4),role:"assistant",content:s,links:[]},p=[{id:`system-${Date.now().toString()}-${g.generateUid(4)}-${e.id}`,role:"system",content:`Company has asked user to follow this guided workflow:
|
|
4
|
+
${F.serializeWorkflow(e)}`},...Z,r,f];l(p),I([])},{openForm:qe}=Be.useChatForm(),Pe=Oe.useWidget();t.useImperativeHandle(T.chatFunctionsRef,()=>({submitMessage:B,updateInputMessage(e){R(e)},clearChat:te,openForm:e=>{Pe?.setView("chat"),qe(e)},focusInput:()=>{j.current?.focus()}}));const _e=De.useMediaQuery("(max-width: 768px)");return{messages:m,input:S,isLoading:G,isStreaming:he,isLoadingConversation:Me,error:ve,isSubmitDisabled:x,handleInputChange:ke,handleInputKeyDown:Ie,handleSubmit:B,stop:be,clear:te,handleWorkflow:$e,selectedWorkflow:L,messageAttachments:C,setMessageAttachments:I,addAttachment:ye,messageButtons:Se,isEmpty:m.length===0,inputRef:j,isMobile:_e}};exports.useInkeepChat=Je;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import De from "openai";
|
|
3
|
-
import { useState as l, useRef as K, useEffect as ae, useImperativeHandle as
|
|
2
|
+
import De, { APIUserAbortError as Oe } from "openai";
|
|
3
|
+
import { useState as l, useRef as K, useEffect as ae, useImperativeHandle as Pe } from "react";
|
|
4
4
|
import { useInkeepConfig as Re } from "../../providers/config-provider.js";
|
|
5
|
-
import { useInkeepConversation as
|
|
6
|
-
import { useChatEvents as
|
|
7
|
-
import { getMessageMetadata as
|
|
5
|
+
import { useInkeepConversation as Ue } from "../../providers/conversation-provider.js";
|
|
6
|
+
import { useChatEvents as Fe } from "../../providers/chat-events-provider.js";
|
|
7
|
+
import { getMessageMetadata as Ke, serializeAttachments as Te, serializeWorkflow as We } from "../../utils/get-message-metadata.js";
|
|
8
8
|
import { resetQueryParams as re } from "../../utils/reset-query-params.js";
|
|
9
|
-
import { useChatForm as
|
|
10
|
-
import { useWidget as
|
|
11
|
-
import { useMediaQuery as
|
|
12
|
-
import { useCaptcha as
|
|
13
|
-
import { useModal as
|
|
14
|
-
import { generateUid as
|
|
15
|
-
import { provideLinksTool as
|
|
16
|
-
import { getConversation as
|
|
17
|
-
import { parseIfJson as
|
|
18
|
-
const
|
|
19
|
-
const { chatId:
|
|
9
|
+
import { useChatForm as Je } from "../../providers/chat-form-provider.js";
|
|
10
|
+
import { useWidget as ze } from "../../providers/widget-provider.js";
|
|
11
|
+
import { useMediaQuery as He } from "../../hooks/use-media-query.js";
|
|
12
|
+
import { useCaptcha as Qe } from "./use-captcha.js";
|
|
13
|
+
import { useModal as je } from "../modal/modal-provider.js";
|
|
14
|
+
import { generateUid as g } from "../../utils/generate-uid.js";
|
|
15
|
+
import { provideLinksTool as qe } from "../../utils/tools/links-tool.js";
|
|
16
|
+
import { getConversation as Ge } from "../../atoms/api/analytics/conversation.js";
|
|
17
|
+
import { parseIfJson as Ve } from "../../utils/misc.js";
|
|
18
|
+
const pt = () => {
|
|
19
|
+
const { chatId: v, setConversation: ie, conversation: B, resetConversation: ce } = Ue(), { baseSettings: $, aiChatSettings: T } = Re(), { aiApiBaseUrl: W, shouldBypassCaptcha: J, filters: z } = $, H = je(), { getSolution: le, prefetchSolution: E, invalidateSolution: Q } = Qe({
|
|
20
20
|
fetchUrl: `${W}/v1/challenge`,
|
|
21
21
|
shouldBypassCaptcha: J,
|
|
22
22
|
shouldMakeInitialRequest: H ? H.isOpen : !0
|
|
@@ -31,38 +31,38 @@ const gt = () => {
|
|
|
31
31
|
model: de,
|
|
32
32
|
filters: j,
|
|
33
33
|
onToolCall: fe
|
|
34
|
-
} = T, [
|
|
34
|
+
} = T, [w, D] = l(""), q = K(null);
|
|
35
35
|
ae(() => {
|
|
36
|
-
me?.(
|
|
37
|
-
}, [
|
|
38
|
-
const [
|
|
39
|
-
|
|
40
|
-
}, [
|
|
41
|
-
id: `system-${Date.now().toString()}-${
|
|
36
|
+
me?.(w);
|
|
37
|
+
}, [w]);
|
|
38
|
+
const [p, c] = l([]), [G, I] = l(!1), [he, M] = l(!1), [ye, V] = l(null), [O, X] = l(null), [C, S] = l([]), ve = (e) => {
|
|
39
|
+
S((t) => [...t, e]);
|
|
40
|
+
}, [we, Y] = l({}), n = K([]), k = K(null), { logEvent: A } = Fe(), Z = pe?.map((e, t) => ({
|
|
41
|
+
id: `system-${Date.now().toString()}-${g(4)}-${t}`,
|
|
42
42
|
role: "system",
|
|
43
43
|
content: e
|
|
44
|
-
})), [
|
|
44
|
+
})), [Ie, Me] = l(!!v);
|
|
45
45
|
ae(() => {
|
|
46
|
-
if (
|
|
46
|
+
if (v) {
|
|
47
47
|
const { apiKey: e, analyticsApiBaseUrl: t } = $;
|
|
48
|
-
|
|
48
|
+
Ge(v, e, t).then((o) => {
|
|
49
49
|
if (o) {
|
|
50
|
-
|
|
50
|
+
A({
|
|
51
51
|
eventName: "shared_chat_loaded",
|
|
52
52
|
properties: {
|
|
53
53
|
conversation: o
|
|
54
54
|
}
|
|
55
|
-
}),
|
|
56
|
-
const a = o.messages.map((
|
|
57
|
-
...
|
|
58
|
-
content:
|
|
55
|
+
}), Me(!1), ie({ ...o });
|
|
56
|
+
const a = o.messages.map((d) => ({
|
|
57
|
+
...d,
|
|
58
|
+
content: Ve(d.content)
|
|
59
59
|
}));
|
|
60
60
|
c(a), n.current = a;
|
|
61
61
|
}
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
}, [
|
|
65
|
-
const
|
|
64
|
+
}, [v]);
|
|
65
|
+
const Ce = (e) => {
|
|
66
66
|
switch (e.code) {
|
|
67
67
|
case 400:
|
|
68
68
|
return e.message;
|
|
@@ -76,47 +76,47 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
76
76
|
}, ee = (e) => {
|
|
77
77
|
V(e), c((t) => {
|
|
78
78
|
const o = [...t], a = o[o.length - 1];
|
|
79
|
-
return a && (a.content =
|
|
80
|
-
}),
|
|
81
|
-
},
|
|
82
|
-
e.key === "Enter" && !e.shiftKey && !
|
|
79
|
+
return a && (a.content = Ce(e)), o;
|
|
80
|
+
}), I(!1), M(!1), Q(), E();
|
|
81
|
+
}, P = !w.trim() && !C.length || G, Se = (e) => {
|
|
82
|
+
e.key === "Enter" && !e.shiftKey && !P && !e.nativeEvent.isComposing && (e.preventDefault(), R());
|
|
83
83
|
}, ke = (e) => {
|
|
84
84
|
const t = e.target.value;
|
|
85
85
|
D(t);
|
|
86
|
-
},
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
const t = O ?
|
|
86
|
+
}, R = async (e = w) => {
|
|
87
|
+
if (P && (!e || e.trim().length === 0)) return;
|
|
88
|
+
I(!0);
|
|
89
|
+
const t = O ? p.length === 2 : p.length === 0, o = Ke(O, C, t);
|
|
90
90
|
let a;
|
|
91
|
-
const
|
|
92
|
-
C.length &&
|
|
91
|
+
const d = Te(C);
|
|
92
|
+
C.length && d ? a = [{ type: "text", text: d }] : a = e;
|
|
93
93
|
const se = {
|
|
94
|
-
id: `${Date.now().toString()}-${
|
|
94
|
+
id: `${Date.now().toString()}-${g(4)}-1`,
|
|
95
95
|
role: "user",
|
|
96
96
|
content: a,
|
|
97
97
|
metadata: o
|
|
98
|
-
},
|
|
99
|
-
if (
|
|
98
|
+
}, f = [...p.length ? [] : Z, se];
|
|
99
|
+
if (v) {
|
|
100
100
|
re();
|
|
101
|
-
const u = n.current.map((r,
|
|
102
|
-
id: `${r.id}-${
|
|
101
|
+
const u = n.current.map((r, N) => ({
|
|
102
|
+
id: `${r.id}-${g(6)}-${N}`,
|
|
103
103
|
role: r.role,
|
|
104
104
|
...r.role === "assistant" ? { links: r.links ?? [] } : {},
|
|
105
105
|
content: r.content,
|
|
106
106
|
metadata: r.metadata,
|
|
107
107
|
tool_calls: r.tool_calls
|
|
108
108
|
}));
|
|
109
|
-
c([...u, ...
|
|
109
|
+
c([...u, ...f]), n.current = [...u, ...f];
|
|
110
110
|
} else
|
|
111
|
-
c((u) => [...u, ...
|
|
112
|
-
|
|
111
|
+
c((u) => [...u, ...f]), n.current = [...n.current, ...f];
|
|
112
|
+
S([]), D(""), A(
|
|
113
113
|
{
|
|
114
114
|
eventName: "user_message_submitted",
|
|
115
115
|
properties: {}
|
|
116
116
|
},
|
|
117
117
|
n.current
|
|
118
118
|
);
|
|
119
|
-
const ne = [
|
|
119
|
+
const ne = [qe, ...ge?.({ conversation: B }) || []];
|
|
120
120
|
try {
|
|
121
121
|
const u = {
|
|
122
122
|
model: de,
|
|
@@ -124,65 +124,67 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
124
124
|
stream: !0,
|
|
125
125
|
tools: ne,
|
|
126
126
|
tool_choice: "auto"
|
|
127
|
-
}, r = await le(),
|
|
127
|
+
}, r = await le(), N = r ? btoa(JSON.stringify(r)) : null, oe = z || j ? JSON.stringify({
|
|
128
128
|
...z,
|
|
129
129
|
...j
|
|
130
130
|
}) : void 0, x = {};
|
|
131
|
-
!J &&
|
|
132
|
-
const
|
|
131
|
+
!J && N && (x["X-INKEEP-CHALLENGE-SOLUTION"] = N), oe && (x["inkeep-filters"] = oe);
|
|
132
|
+
const h = ue.beta.chat.completions.stream(
|
|
133
133
|
u,
|
|
134
134
|
Object.keys(x).length > 0 ? { headers: x } : void 0
|
|
135
135
|
), s = {
|
|
136
|
-
id: `${Date.now().toString()}-${
|
|
136
|
+
id: `${Date.now().toString()}-${g(4)}-2`,
|
|
137
137
|
role: "assistant",
|
|
138
138
|
content: "",
|
|
139
139
|
links: [],
|
|
140
140
|
tool_calls: []
|
|
141
141
|
};
|
|
142
|
-
c((
|
|
143
|
-
|
|
142
|
+
c((m) => [...m, s]), h.on("content", (m, b) => {
|
|
143
|
+
M(!0), s.content = b, c((L) => {
|
|
144
144
|
const i = [...L], U = i.findIndex((_) => _.id === s.id);
|
|
145
145
|
return U === -1 ? [...i, s] : (i[U] = { ...s }, i);
|
|
146
146
|
});
|
|
147
|
-
}),
|
|
148
|
-
const { name: b, arguments: L } =
|
|
147
|
+
}), h.on("tool_calls.function.arguments.done", async (m) => {
|
|
148
|
+
const { name: b, arguments: L } = m, i = ne?.find((y) => y.function.name === b);
|
|
149
149
|
if (!i) return;
|
|
150
|
-
const _ = ("parse" in i.function ? i.function.parse : JSON.parse)(L),
|
|
151
|
-
b === "provideLinks" ? s.links = _.links ?? [] : Y((
|
|
152
|
-
...
|
|
153
|
-
[s.id]: [...
|
|
150
|
+
const _ = ("parse" in i.function ? i.function.parse : JSON.parse)(L), Ne = i.function.function?.(_, h), xe = i.renderMessageButtons?.({ args: _, execution: Ne }) ?? [];
|
|
151
|
+
b === "provideLinks" ? s.links = _.links ?? [] : Y((y) => ({
|
|
152
|
+
...y,
|
|
153
|
+
[s.id]: [...y[s.id] ?? [], ...xe]
|
|
154
154
|
})), s.tool_calls?.push({
|
|
155
|
-
id: "call_" +
|
|
155
|
+
id: "call_" + g(24),
|
|
156
156
|
type: "function",
|
|
157
157
|
function: {
|
|
158
158
|
name: b,
|
|
159
159
|
arguments: L
|
|
160
160
|
}
|
|
161
|
-
}), c((
|
|
162
|
-
const F = [...
|
|
161
|
+
}), c((y) => {
|
|
162
|
+
const F = [...y], Le = F.findIndex((Be) => Be.id === s.id);
|
|
163
163
|
return F[Le] = { ...s }, F;
|
|
164
|
-
}), fe?.(
|
|
164
|
+
}), fe?.(m, {
|
|
165
165
|
conversation: {
|
|
166
166
|
...B,
|
|
167
167
|
messages: [...n.current, s]
|
|
168
168
|
}
|
|
169
169
|
});
|
|
170
|
-
}),
|
|
171
|
-
n.current = [...n.current, s],
|
|
170
|
+
}), h.on("error", ee), h.finalChatCompletion().then(() => {
|
|
171
|
+
n.current = [...n.current, s], k.current = null, I(!1), M(!1), E(), A(
|
|
172
172
|
{
|
|
173
173
|
eventName: "assistant_message_received",
|
|
174
174
|
properties: {}
|
|
175
175
|
},
|
|
176
176
|
n.current
|
|
177
177
|
);
|
|
178
|
-
})
|
|
178
|
+
}).catch((m) => {
|
|
179
|
+
m instanceof Oe || console.warn(m);
|
|
180
|
+
}), k.current = h.controller;
|
|
179
181
|
} catch (u) {
|
|
180
|
-
ee(u),
|
|
182
|
+
ee(u), I(!1), M(!1);
|
|
181
183
|
}
|
|
182
184
|
}, be = () => {
|
|
183
|
-
|
|
185
|
+
k.current && (k.current.abort(), k.current = null), I(!1), M(!1), E();
|
|
184
186
|
}, te = () => {
|
|
185
|
-
V(null), c([]), n.current = [], ce(), Y({}),
|
|
187
|
+
V(null), c([]), n.current = [], ce(), Y({}), S([]), re(), X(null), Q(), E(), A({
|
|
186
188
|
eventName: "chat_clear_button_clicked",
|
|
187
189
|
properties: {
|
|
188
190
|
conversation: B
|
|
@@ -191,24 +193,24 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
191
193
|
}, _e = (e) => {
|
|
192
194
|
X(e);
|
|
193
195
|
const { initialReplyMessage: t, displayName: o } = e, a = {
|
|
194
|
-
id:
|
|
196
|
+
id: p.length.toString() + g(4),
|
|
195
197
|
role: "user",
|
|
196
198
|
content: o
|
|
197
|
-
},
|
|
198
|
-
id: (
|
|
199
|
+
}, d = {
|
|
200
|
+
id: (p.length + 1).toString() + g(4),
|
|
199
201
|
role: "assistant",
|
|
200
202
|
content: t,
|
|
201
203
|
links: []
|
|
202
|
-
},
|
|
203
|
-
id: `system-${Date.now().toString()}-${
|
|
204
|
+
}, f = [{
|
|
205
|
+
id: `system-${Date.now().toString()}-${g(4)}-${e.id}`,
|
|
204
206
|
role: "system",
|
|
205
207
|
content: `Company has asked user to follow this guided workflow:
|
|
206
|
-
${
|
|
207
|
-
}, ...Z, a,
|
|
208
|
-
c(
|
|
209
|
-
}, { openForm: $e } =
|
|
210
|
-
|
|
211
|
-
submitMessage:
|
|
208
|
+
${We(e)}`
|
|
209
|
+
}, ...Z, a, d];
|
|
210
|
+
c(f), S([]);
|
|
211
|
+
}, { openForm: $e } = Je(), Ee = ze();
|
|
212
|
+
Pe(T.chatFunctionsRef, () => ({
|
|
213
|
+
submitMessage: R,
|
|
212
214
|
updateInputMessage(e) {
|
|
213
215
|
D(e);
|
|
214
216
|
},
|
|
@@ -220,31 +222,31 @@ ${Te(e)}`
|
|
|
220
222
|
q.current?.focus();
|
|
221
223
|
}
|
|
222
224
|
}));
|
|
223
|
-
const
|
|
225
|
+
const Ae = He("(max-width: 768px)");
|
|
224
226
|
return {
|
|
225
|
-
messages:
|
|
226
|
-
input:
|
|
227
|
+
messages: p,
|
|
228
|
+
input: w,
|
|
227
229
|
isLoading: G,
|
|
228
230
|
isStreaming: he,
|
|
229
|
-
isLoadingConversation:
|
|
231
|
+
isLoadingConversation: Ie,
|
|
230
232
|
error: ye,
|
|
231
|
-
isSubmitDisabled:
|
|
233
|
+
isSubmitDisabled: P,
|
|
232
234
|
handleInputChange: ke,
|
|
233
235
|
handleInputKeyDown: Se,
|
|
234
|
-
handleSubmit:
|
|
236
|
+
handleSubmit: R,
|
|
235
237
|
stop: be,
|
|
236
238
|
clear: te,
|
|
237
239
|
handleWorkflow: _e,
|
|
238
240
|
selectedWorkflow: O,
|
|
239
241
|
messageAttachments: C,
|
|
240
|
-
setMessageAttachments:
|
|
242
|
+
setMessageAttachments: S,
|
|
241
243
|
addAttachment: ve,
|
|
242
|
-
messageButtons:
|
|
243
|
-
isEmpty:
|
|
244
|
+
messageButtons: we,
|
|
245
|
+
isEmpty: p.length === 0,
|
|
244
246
|
inputRef: q,
|
|
245
|
-
isMobile:
|
|
247
|
+
isMobile: Ae
|
|
246
248
|
};
|
|
247
249
|
};
|
|
248
250
|
export {
|
|
249
|
-
|
|
251
|
+
pt as useInkeepChat
|
|
250
252
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./providers/attachment-item-provider.cjs"),l=require("./providers/attachments-bar-provider.cjs"),v=require("./providers/base-events-provider.cjs"),C=require("./providers/chat-events-provider.cjs"),s=require("./providers/chat-form-provider.cjs"),n=require("./providers/config-provider.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./providers/attachment-item-provider.cjs"),l=require("./providers/attachments-bar-provider.cjs"),v=require("./providers/base-events-provider.cjs"),C=require("./providers/chat-events-provider.cjs"),s=require("./providers/chat-form-provider.cjs"),n=require("./providers/config-provider.cjs"),a=require("./providers/conversation-provider.cjs"),P=require("./providers/feedback-item-provider.cjs"),I=require("./providers/feedback-provider.cjs"),h=require("./providers/form-field-provider.cjs"),i=require("./providers/help-menu-provider.cjs"),p=require("./providers/markdown-provider.cjs"),g=require("./providers/message-attachments-provider.cjs"),d=require("./providers/message-provider.cjs"),R=require("./providers/root-provider.cjs"),S=require("./providers/source-item-provider.cjs"),w=require("./providers/theme-provider.cjs"),q=require("./providers/user-provider.cjs"),F=require("./providers/widget-provider.cjs"),M=require("./components/factory.cjs"),y=require("./components/embedded-chat.cjs"),b=require("./components/embedded-chat/chat-provider.cjs"),E=require("./components/embedded-search.cjs"),u=require("./components/embedded-search/search-provider.cjs"),f=require("./components/modal.cjs"),k=require("./components/modal/modal-provider.cjs"),T=require("./components/intelligent-form.cjs"),m=require("./components/intelligent-form/intelligent-form-provider.cjs"),W=require("./components/chat-button.cjs"),U=require("./components/searchbar.cjs"),H=require("./hooks/use-boolean.cjs"),B=require("./hooks/use-browser-storage.cjs"),x=require("./hooks/use-component-classnames.cjs"),z=require("./hooks/use-container-size.cjs"),D=require("./hooks/use-copy-to-clipboard.cjs"),O=require("./hooks/use-instant-update.cjs"),Q=require("./hooks/use-is-mounted.cjs"),L=require("./hooks/use-media-query.cjs"),_=require("./hooks/use-resize-observer.cjs"),j=require("./hooks/use-scrolling-fades.cjs"),J=require("./hooks/use-settle-action.cjs"),K=require("./hooks/use-scroll-to-bottom.cjs"),o=require("./utils/misc.cjs"),r=require("./utils/component-ids.cjs"),A=require("./utils/compose-refs.cjs"),N=require("./atoms/portal.cjs"),Y=require("./atoms/icons/custom-icon.cjs"),G=require("./atoms/icons/built-in-icon-renderer.cjs"),V=require("./atoms/portal-with-theme.cjs"),e=require("./atoms/cmdk/index.cjs"),X=require("./atoms/error-boundary.cjs"),t=require("./atoms/shadow/context.cjs");exports.AttachmentItemProvider=c.AttachmentItemProvider;exports.useAttachmentItem=c.useAttachmentItem;exports.AttachmentsBarProvider=l.AttachmentsBarProvider;exports.useAttachmentsBar=l.useAttachmentsBar;exports.BaseEventsProvider=v.BaseEventsProvider;exports.useBaseEvents=v.useBaseEvents;exports.ChatEventsProvider=C.ChatEventsProvider;exports.useChatEvents=C.useChatEvents;exports.ChatFormProvider=s.ChatFormProvider;exports.useChatForm=s.useChatForm;exports.useChatFormState=s.useChatFormState;exports.InkeepConfigProvider=n.InkeepConfigProvider;exports.WebWidgetInteractionType=n.WebWidgetInteractionType;exports.useInkeepConfig=n.useInkeepConfig;exports.InkeepConversationProvider=a.InkeepConversationProvider;exports.SHARE_QUERY_PARAM=a.SHARE_QUERY_PARAM;exports.useInkeepConversation=a.useInkeepConversation;exports.FeedbackItemProvider=P.FeedbackItemProvider;exports.useFeedbackItem=P.useFeedbackItem;exports.FeedbackProvider=I.FeedbackProvider;exports.useMessageFeedback=I.useMessageFeedback;exports.FormFieldProvider=h.FormFieldProvider;exports.useFormField=h.useFormField;exports.HelpMenuProvider=i.HelpMenuProvider;exports.useHelpMenu=i.useHelpMenu;exports.useHelpMenuState=i.useHelpMenuState;exports.ChatMarkdownProvider=p.ChatMarkdownProvider;exports.useChatMarkdown=p.useChatMarkdown;exports.MessageAttachmentsProvider=g.MessageAttachmentsProvider;exports.useMessageAttachments=g.useMessageAttachments;exports.MessageProvider=d.MessageProvider;exports.useMessage=d.useMessage;exports.useOptionalMessage=d.useOptionalMessage;exports.RootProvider=R.RootProvider;exports.SourceItemProvider=S.SourceItemProvider;exports.useSourceItem=S.useSourceItem;exports.ThemeProvider=w.ThemeProvider;exports.UserProvider=q.UserProvider;exports.useUser=q.useUser;exports.WidgetProvider=F.WidgetProvider;exports.useWidget=F.useWidget;exports.ikp=M.ikp;exports.jsxFactory=M.jsxFactory;exports.EmbeddedChatPrimitive=y;exports.ChatProvider=b.ChatProvider;exports.useChat=b.useChat;exports.EmbeddedSearchPrimitive=E;exports.SearchProvider=u.SearchProvider;exports.SearchProviderImpl=u.SearchProviderImpl;exports.useSearch=u.useSearch;exports.ModalPrimitive=f;exports.ModalProvider=k.ModalProvider;exports.useModal=k.useModal;exports.IntelligentFormPrimitive=T;exports.IntelligentFormProvider=m.IntelligentFormProvider;exports.IntelligentFormProviderImpl=m.IntelligentFormProviderImpl;exports.useIntelligentForm=m.useIntelligentForm;exports.ChatButtonPrimitive=W;exports.SearchBarPrimitive=U;exports.useBoolean=H.useBoolean;exports.passesBrowserStorageChecks=B.passesBrowserStorageChecks;exports.useBrowserStorage=B.useBrowserStorage;exports.useComponentClassNames=x.useComponentClassNames;exports.useContainerSize=z.useContainerSize;exports.useCopyToClipboard=D.useCopyToClipboard;exports.useInstantUpdate=O.useInstantUpdate;exports.useIsMounted=Q.useIsMounted;exports.useMediaQuery=L.useMediaQuery;exports.useResizeObserver=_.useResizeObserver;exports.useScrollingFades=j.useScrollingFades;exports.useSettleAction=J.useSettleAction;exports.useScrollToBottom=K.useScrollToBottom;exports.callAll=o.callAll;exports.dataAttr=o.dataAttr;exports.getInitials=o.getInitials;exports.getMessageContent=o.getMessageContent;exports.isString=o.isString;exports.maybeRender=o.maybeRender;exports.parseIfJson=o.parseIfJson;exports.toKebabCase=o.toKebabCase;exports.SearchBarComponentIds=r.SearchBarComponentIds;exports.aiChatComponentIds=r.aiChatComponentIds;exports.aiSearchComponentIds=r.aiSearchComponentIds;exports.chatButtonComponentIds=r.chatButtonComponentIds;exports.componentIDs=r.componentIDs;exports.intelligentFormComponentIds=r.intelligentFormComponentIds;exports.markDownComponentIds=r.markDownComponentIds;exports.miscellanousComponentIds=r.miscellanousComponentIds;exports.modalComponentIds=r.modalComponentIds;exports.composeRefs=A.composeRefs;exports.useComposedRefs=A.useComposedRefs;exports.Portal=N.Portal;exports.CustomIcon=Y.CustomIcon;exports.BuiltInIconRenderer=G.BuiltInIconRenderer;exports.PortalWithTheme=V.PortalWithTheme;exports.Command=e.Command;exports.CommandDialog=e.CommandDialog;exports.CommandEmpty=e.CommandEmpty;exports.CommandInput=e.CommandInput;exports.CommandItem=e.CommandItem;exports.CommandList=e.CommandList;exports.CommandLoading=e.CommandLoading;exports.CommandRoot=e.CommandRoot;exports.CommandSeparator=e.CommandSeparator;exports.defaultFilter=e.defaultFilter;exports.useCommandState=e.useCommandState;exports.useCommandStore=e.useCommandStore;exports.ErrorBoundary=X.ErrorBoundary;exports.InkeepShadow=t.InkeepShadow;exports.InkeepShadowProvider=t.InkeepShadowProvider;exports.ShadowContext=t.ShadowContext;exports.useShadow=t.useShadow;
|
package/dist/index.d.cts
CHANGED
|
@@ -18,6 +18,7 @@ import { default as default_2 } from 'react';
|
|
|
18
18
|
import { DetailedHTMLProps } from 'react';
|
|
19
19
|
import { DismissableLayer } from '@radix-ui/react-dismissable-layer';
|
|
20
20
|
import { Dispatch } from 'react';
|
|
21
|
+
import { FC } from 'react';
|
|
21
22
|
import { FeebackReason } from '@inkeep/cxkit-types';
|
|
22
23
|
import { FeedbackItemType } from '@inkeep/cxkit-types';
|
|
23
24
|
import { FeedbackType } from '@inkeep/cxkit-types';
|
|
@@ -2699,6 +2700,12 @@ export declare interface EmbeddedSearchProviderProps {
|
|
|
2699
2700
|
shouldAutoFocusInput?: boolean;
|
|
2700
2701
|
}
|
|
2701
2702
|
|
|
2703
|
+
export declare const ErrorBoundary: FC<ErrorBoundaryProps>;
|
|
2704
|
+
|
|
2705
|
+
declare interface ErrorBoundaryProps {
|
|
2706
|
+
children: ReactNode;
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2702
2709
|
export declare type FeedbackContextValue = ReturnType<typeof useFeedback>;
|
|
2703
2710
|
|
|
2704
2711
|
export declare type FeedbackItemContextValue = {
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { default as default_2 } from 'react';
|
|
|
18
18
|
import { DetailedHTMLProps } from 'react';
|
|
19
19
|
import { DismissableLayer } from '@radix-ui/react-dismissable-layer';
|
|
20
20
|
import { Dispatch } from 'react';
|
|
21
|
+
import { FC } from 'react';
|
|
21
22
|
import { FeebackReason } from '@inkeep/cxkit-types';
|
|
22
23
|
import { FeedbackItemType } from '@inkeep/cxkit-types';
|
|
23
24
|
import { FeedbackType } from '@inkeep/cxkit-types';
|
|
@@ -2699,6 +2700,12 @@ export declare interface EmbeddedSearchProviderProps {
|
|
|
2699
2700
|
shouldAutoFocusInput?: boolean;
|
|
2700
2701
|
}
|
|
2701
2702
|
|
|
2703
|
+
export declare const ErrorBoundary: FC<ErrorBoundaryProps>;
|
|
2704
|
+
|
|
2705
|
+
declare interface ErrorBoundaryProps {
|
|
2706
|
+
children: ReactNode;
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2702
2709
|
export declare type FeedbackContextValue = ReturnType<typeof useFeedback>;
|
|
2703
2710
|
|
|
2704
2711
|
export declare type FeedbackItemContextValue = {
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { BaseEventsProvider as C, useBaseEvents as l } from "./providers/base-ev
|
|
|
4
4
|
import { ChatEventsProvider as h, useChatEvents as I } from "./providers/chat-events-provider.js";
|
|
5
5
|
import { ChatFormProvider as P, useChatForm as S, useChatFormState as g } from "./providers/chat-form-provider.js";
|
|
6
6
|
import { InkeepConfigProvider as M, WebWidgetInteractionType as b, useInkeepConfig as k } from "./providers/config-provider.js";
|
|
7
|
-
import { InkeepConversationProvider as A, SHARE_QUERY_PARAM as
|
|
7
|
+
import { InkeepConversationProvider as A, SHARE_QUERY_PARAM as E, useInkeepConversation as R } from "./providers/conversation-provider.js";
|
|
8
8
|
import { FeedbackItemProvider as y, useFeedbackItem as T } from "./providers/feedback-item-provider.js";
|
|
9
9
|
import { FeedbackProvider as H, useMessageFeedback as U } from "./providers/feedback-provider.js";
|
|
10
10
|
import { FormFieldProvider as z, useFormField as L } from "./providers/form-field-provider.js";
|
|
@@ -25,10 +25,10 @@ import { SearchProvider as Pe, SearchProviderImpl as Se, useSearch as ge } from
|
|
|
25
25
|
import * as r from "./components/modal.js";
|
|
26
26
|
import { ModalProvider as Me, useModal as be } from "./components/modal/modal-provider.js";
|
|
27
27
|
import * as t from "./components/intelligent-form.js";
|
|
28
|
-
import { IntelligentFormProvider as Be, IntelligentFormProviderImpl as Ae, useIntelligentForm as
|
|
28
|
+
import { IntelligentFormProvider as Be, IntelligentFormProviderImpl as Ae, useIntelligentForm as Ee } from "./components/intelligent-form/intelligent-form-provider.js";
|
|
29
29
|
import * as m from "./components/chat-button.js";
|
|
30
30
|
import * as a from "./components/searchbar.js";
|
|
31
|
-
import { useBoolean as
|
|
31
|
+
import { useBoolean as we } from "./hooks/use-boolean.js";
|
|
32
32
|
import { passesBrowserStorageChecks as Te, useBrowserStorage as We } from "./hooks/use-browser-storage.js";
|
|
33
33
|
import { useComponentClassNames as Ue } from "./hooks/use-component-classnames.js";
|
|
34
34
|
import { useContainerSize as ze } from "./hooks/use-container-size.js";
|
|
@@ -45,15 +45,16 @@ import { SearchBarComponentIds as uo, aiChatComponentIds as xo, aiSearchComponen
|
|
|
45
45
|
import { composeRefs as go, useComposedRefs as Fo } from "./utils/compose-refs.js";
|
|
46
46
|
import { Portal as bo } from "./atoms/portal.js";
|
|
47
47
|
import { CustomIcon as Bo } from "./atoms/icons/custom-icon.js";
|
|
48
|
-
import { BuiltInIconRenderer as
|
|
49
|
-
import { PortalWithTheme as
|
|
48
|
+
import { BuiltInIconRenderer as Eo } from "./atoms/icons/built-in-icon-renderer.js";
|
|
49
|
+
import { PortalWithTheme as wo } from "./atoms/portal-with-theme.js";
|
|
50
50
|
import { Command as To, CommandDialog as Wo, CommandEmpty as Ho, CommandInput as Uo, CommandItem as Do, CommandList as zo, CommandLoading as Lo, CommandRoot as Oo, CommandSeparator as Qo, defaultFilter as _o, useCommandState as jo, useCommandStore as Jo } from "./atoms/cmdk/index.js";
|
|
51
|
-
import {
|
|
51
|
+
import { ErrorBoundary as No } from "./atoms/error-boundary.js";
|
|
52
|
+
import { InkeepShadow as qo, InkeepShadowProvider as Go, ShadowContext as Vo, useShadow as Xo } from "./atoms/shadow/context.js";
|
|
52
53
|
export {
|
|
53
54
|
p as AttachmentItemProvider,
|
|
54
55
|
f as AttachmentsBarProvider,
|
|
55
56
|
C as BaseEventsProvider,
|
|
56
|
-
|
|
57
|
+
Eo as BuiltInIconRenderer,
|
|
57
58
|
m as ChatButtonPrimitive,
|
|
58
59
|
h as ChatEventsProvider,
|
|
59
60
|
P as ChatFormProvider,
|
|
@@ -71,14 +72,15 @@ export {
|
|
|
71
72
|
Bo as CustomIcon,
|
|
72
73
|
e as EmbeddedChatPrimitive,
|
|
73
74
|
o as EmbeddedSearchPrimitive,
|
|
75
|
+
No as ErrorBoundary,
|
|
74
76
|
y as FeedbackItemProvider,
|
|
75
77
|
H as FeedbackProvider,
|
|
76
78
|
z as FormFieldProvider,
|
|
77
79
|
Q as HelpMenuProvider,
|
|
78
80
|
M as InkeepConfigProvider,
|
|
79
81
|
A as InkeepConversationProvider,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
qo as InkeepShadow,
|
|
83
|
+
Go as InkeepShadowProvider,
|
|
82
84
|
t as IntelligentFormPrimitive,
|
|
83
85
|
Be as IntelligentFormProvider,
|
|
84
86
|
Ae as IntelligentFormProviderImpl,
|
|
@@ -87,14 +89,14 @@ export {
|
|
|
87
89
|
r as ModalPrimitive,
|
|
88
90
|
Me as ModalProvider,
|
|
89
91
|
bo as Portal,
|
|
90
|
-
|
|
92
|
+
wo as PortalWithTheme,
|
|
91
93
|
oe as RootProvider,
|
|
92
|
-
|
|
94
|
+
E as SHARE_QUERY_PARAM,
|
|
93
95
|
uo as SearchBarComponentIds,
|
|
94
96
|
a as SearchBarPrimitive,
|
|
95
97
|
Pe as SearchProvider,
|
|
96
98
|
Se as SearchProviderImpl,
|
|
97
|
-
|
|
99
|
+
Vo as ShadowContext,
|
|
98
100
|
te as SourceItemProvider,
|
|
99
101
|
se as ThemeProvider,
|
|
100
102
|
pe as UserProvider,
|
|
@@ -124,7 +126,7 @@ export {
|
|
|
124
126
|
i as useAttachmentItem,
|
|
125
127
|
u as useAttachmentsBar,
|
|
126
128
|
l as useBaseEvents,
|
|
127
|
-
|
|
129
|
+
we as useBoolean,
|
|
128
130
|
We as useBrowserStorage,
|
|
129
131
|
Ie as useChat,
|
|
130
132
|
I as useChatEvents,
|
|
@@ -142,9 +144,9 @@ export {
|
|
|
142
144
|
_ as useHelpMenu,
|
|
143
145
|
j as useHelpMenuState,
|
|
144
146
|
k as useInkeepConfig,
|
|
145
|
-
|
|
147
|
+
R as useInkeepConversation,
|
|
146
148
|
_e as useInstantUpdate,
|
|
147
|
-
|
|
149
|
+
Ee as useIntelligentForm,
|
|
148
150
|
Je as useIsMounted,
|
|
149
151
|
Ne as useMediaQuery,
|
|
150
152
|
Z as useMessage,
|
|
@@ -157,7 +159,7 @@ export {
|
|
|
157
159
|
Ve as useScrollingFades,
|
|
158
160
|
ge as useSearch,
|
|
159
161
|
Ze as useSettleAction,
|
|
160
|
-
|
|
162
|
+
Xo as useShadow,
|
|
161
163
|
me as useSourceItem,
|
|
162
164
|
ie as useUser,
|
|
163
165
|
ue as useWidget
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react/jsx-runtime"),t=require("react"),f=require("../atoms/api/analytics/events.cjs"),b=require("./config-provider.cjs"),x=require("./user-provider.cjs"),E=t.createContext(void 0),q=({children:e})=>{const{baseSettings:s,componentType:r}=b.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:m,env:g,analyticsProperties:v}=s,{userProperties:u}=x.useUser(),l=t.useMemo(()=>({widgetLibraryVersion:"0.5.80",componentType:r,tags:a}),[r,a]),d=!m.optOutAllAnalytics&&g!=="development",P={logEvent:t.useCallback(async n=>{const o={...l,...n.properties,...v},p={eventName:n.eventName,properties:o,userProperties:u},y=["modal_opened","modal_closed"].includes(n.eventName);if(d&&!y){if("conversation"in o&&!o.conversation?.id)return;f.logEvent(p,i,c)}s.onEvent?.(p)},[d,s,i,c,u,l,v])};return B.jsx(E.Provider,{value:P,children:e})},C=()=>{const e=t.useContext(E);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=q;exports.useBaseEvents=C;
|
|
@@ -7,7 +7,7 @@ import { useUser as A } from "./user-provider.js";
|
|
|
7
7
|
const u = B(void 0), $ = ({ children: e }) => {
|
|
8
8
|
const { baseSettings: t, componentType: s } = w(), { apiKey: r, analyticsApiBaseUrl: i, tags: a, privacyPreferences: d, env: E, analyticsProperties: c } = t, { userProperties: v } = A(), p = P(
|
|
9
9
|
() => ({
|
|
10
|
-
widgetLibraryVersion: "0.5.
|
|
10
|
+
widgetLibraryVersion: "0.5.80",
|
|
11
11
|
componentType: s,
|
|
12
12
|
tags: a
|
|
13
13
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function i(
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});async function i(t,o,s,n,a){try{const r=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",...n},signal:a,body:JSON.stringify({query:o,variables:s})});if(!r.ok)throw new Error(`Network response was not OK (status: ${r.status})`);const e=await r.json();if(e.errors?.length)throw new Error(e.errors[0].message);return e.data}catch(r){throw r instanceof Error&&r.name==="AbortError"||console.warn("Error in graphqlRequest:",r),r}}exports.graphqlRequest=i;
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
async function i(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
async function i(e, o, s, n, a) {
|
|
3
|
+
try {
|
|
4
|
+
const r = await fetch(e, {
|
|
5
|
+
method: "POST",
|
|
6
|
+
headers: {
|
|
7
|
+
"Content-Type": "application/json",
|
|
8
|
+
...n
|
|
9
|
+
},
|
|
10
|
+
signal: a,
|
|
11
|
+
body: JSON.stringify({
|
|
12
|
+
query: o,
|
|
13
|
+
variables: s
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
if (!r.ok)
|
|
17
|
+
throw new Error(`Network response was not OK (status: ${r.status})`);
|
|
18
|
+
const t = await r.json();
|
|
19
|
+
if (t.errors?.length)
|
|
20
|
+
throw new Error(t.errors[0].message);
|
|
21
|
+
return t.data;
|
|
22
|
+
} catch (r) {
|
|
23
|
+
throw r instanceof Error && r.name === "AbortError" || console.warn("Error in graphqlRequest:", r), r;
|
|
24
|
+
}
|
|
21
25
|
}
|
|
22
26
|
export {
|
|
23
27
|
i as graphqlRequest
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/cxkit-primitives",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.80",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Inkeep, Inc. Customer License (IICL) v1.1",
|
|
6
6
|
"homepage": "",
|
|
@@ -51,18 +51,19 @@
|
|
|
51
51
|
"merge-anything": "5.1.7",
|
|
52
52
|
"openai": "4.78.1",
|
|
53
53
|
"prism-react-renderer": "2.4.1",
|
|
54
|
+
"react-error-boundary": "^6.0.0",
|
|
54
55
|
"react-hook-form": "7.54.2",
|
|
55
56
|
"react-markdown": "9.0.3",
|
|
56
|
-
"react-remove-scroll": "
|
|
57
|
+
"react-remove-scroll": "2.6.3",
|
|
57
58
|
"react-svg": "16.3.0",
|
|
58
59
|
"react-textarea-autosize": "8.5.7",
|
|
59
60
|
"rehype-raw": "7.0.0",
|
|
60
61
|
"remark-gfm": "^4.0.1",
|
|
61
62
|
"unist-util-visit": "^5.0.0",
|
|
62
63
|
"use-sync-external-store": "^1.4.0",
|
|
63
|
-
"@inkeep/cxkit-color-mode": "0.5.
|
|
64
|
-
"@inkeep/cxkit-theme": "0.5.
|
|
65
|
-
"@inkeep/cxkit-types": "0.5.
|
|
64
|
+
"@inkeep/cxkit-color-mode": "0.5.80",
|
|
65
|
+
"@inkeep/cxkit-theme": "0.5.80",
|
|
66
|
+
"@inkeep/cxkit-types": "0.5.80"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
69
|
"@biomejs/biome": "1.9.4",
|
|
@@ -92,6 +93,9 @@
|
|
|
92
93
|
"react": ">=17.0.0",
|
|
93
94
|
"react-dom": ">=17.0.0"
|
|
94
95
|
},
|
|
96
|
+
"overrides": {
|
|
97
|
+
"react-remove-scroll": "2.6.3"
|
|
98
|
+
},
|
|
95
99
|
"module": "dist/index.js",
|
|
96
100
|
"types": "dist/index.d.ts",
|
|
97
101
|
"exports": {
|