@inkeep/cxkit-primitives 0.5.92 → 0.5.93

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 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..
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ae=require("openai"),t=require("react"),Le=require("../../providers/config-provider.cjs"),xe=require("../../providers/conversation-provider.cjs"),Be=require("../../providers/chat-events-provider.cjs"),F=require("../../utils/get-message-metadata.cjs"),re=require("../../utils/reset-query-params.cjs"),Oe=require("../../providers/chat-form-provider.cjs"),De=require("../../providers/widget-provider.cjs"),Fe=require("../../hooks/use-media-query.cjs"),Te=require("./use-captcha.cjs"),Ke=require("../modal/modal-provider.cjs"),g=require("../../utils/generate-uid.cjs"),Qe=require("../../utils/tools/links-tool.cjs"),We=require("../../atoms/api/analytics/conversation.cjs"),Je=require("../../utils/misc.cjs"),ze=()=>{const{chatId:y,isSharedChat:ie,setConversation:ce,conversation:N,resetConversation:le}=xe.useInkeepConversation(),{baseSettings:q,aiChatSettings:T}=Le.useInkeepConfig(),{aiApiBaseUrl:K,shouldBypassCaptcha:Q,filters:W}=q,J=Ke.useModal(),{getSolution:ue,prefetchSolution:P,invalidateSolution:z}=Te.useCaptcha({fetchUrl:`${K}/v1/challenge`,shouldBypassCaptcha:Q,shouldMakeInitialRequest:J?J.isOpen:!0}),de=new ae({baseURL:`${K}/v1`,apiKey:q.apiKey??"",dangerouslyAllowBrowser:!0}),{onInputMessageChange:ge,getTools:me,prompts:fe,model:pe,filters:H,onToolCall:he}=T,[S,R]=t.useState(""),j=t.useRef(null);t.useEffect(()=>{ge?.(S)},[S]);const[m,l]=t.useState([]),[G,M]=t.useState(!1),[ve,C]=t.useState(!1),[ye,V]=t.useState(null),[L,X]=t.useState(null),[w,I]=t.useState([]),Se=e=>{I(s=>[...s,e])},[Me,Y]=t.useState({}),o=t.useRef([]),k=t.useRef(null),{logEvent:_}=Be.useChatEvents(),Z=fe?.map((e,s)=>({id:`system-${Date.now().toString()}-${g.generateUid(4)}-${s}`,role:"system",content:e})),[Ce,we]=t.useState(!!y);t.useEffect(()=>{if(y){const{apiKey:e,analyticsApiBaseUrl:s}=q;We.getConversation(y,e,s).then(a=>{if(a){_({eventName:"shared_chat_loaded",properties:{conversation:a}}),we(!1),ce({...a});const r=a.messages.map(f=>({...f,content:Je.parseIfJson(f.content)}));l(r),o.current=r}})}},[y]);const Ie=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}),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;
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=Ie(e)),a}),M(!1),C(!1),z(),P()},x=!S.trim()&&!w.length||G,ke=e=>{e.key==="Enter"&&!e.shiftKey&&!x&&!e.nativeEvent.isComposing&&(e.preventDefault(),B())},be=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,w,s);let r;const f=F.serializeAttachments(w);w.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(ie&&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=[Qe.provideLinksTool,...me?.({conversation:N})||[]];try{const u={model:pe,messages:o.current,stream:!0,tools:ne,tool_choice:"auto"},i=await ue(),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=de.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)=>{C(!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),Ue=c.function.function?.($,h),Ae=c.renderMessageButtons?.({args:$,execution:Ue})??[];b==="provideLinks"?n.links=$.links??[]:Y(v=>({...v,[n.id]:[...v[n.id]??[],...Ae]})),n.tool_calls?.push({id:"call_"+g.generateUid(24),type:"function",function:{name:b,arguments:A}}),l(v=>{const D=[...v],Ne=D.findIndex(Re=>Re.id===n.id);return D[Ne]={...n},D}),he?.(d,{conversation:{...N,messages:[...o.current,n]}})}),h.on("error",ee),h.finalChatCompletion().then(()=>{o.current=[...o.current,n],k.current=null,M(!1),C(!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),C(!1)}},$e=()=>{k.current&&(k.current.abort(),k.current=null),M(!1),C(!1),P()},te=()=>{V(null),l([]),o.current=[],le(),Y({}),I([]),re.resetQueryParams(),X(null),z(),P(),_({eventName:"chat_clear_button_clicked",properties:{conversation:N}})},qe=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:Pe}=Oe.useChatForm(),_e=De.useWidget();t.useImperativeHandle(T.chatFunctionsRef,()=>({submitMessage:B,updateInputMessage(e){R(e)},clearChat:te,openForm:e=>{_e?.setView("chat"),Pe(e)},focusInput:()=>{j.current?.focus()}}));const Ee=Fe.useMediaQuery("(max-width: 768px)");return{messages:m,input:S,isLoading:G,isStreaming:ve,isLoadingConversation:Ce,error:ye,isSubmitDisabled:x,handleInputChange:be,handleInputKeyDown:ke,handleSubmit:B,stop:$e,clear:te,handleWorkflow:qe,selectedWorkflow:L,messageAttachments:w,setMessageAttachments:I,addAttachment:Se,messageButtons:Me,isEmpty:m.length===0,inputRef:j,isMobile:Ee}};exports.useInkeepChat=ze;
@@ -1,43 +1,43 @@
1
1
  "use client";
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
- import { useInkeepConfig as Re } from "../../providers/config-provider.js";
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";
2
+ import Oe, { APIUserAbortError as Pe } from "openai";
3
+ import { useState as l, useRef as K, useEffect as ae, useImperativeHandle as Re } from "react";
4
+ import { useInkeepConfig as Ue } from "../../providers/config-provider.js";
5
+ import { useInkeepConversation as Fe } from "../../providers/conversation-provider.js";
6
+ import { useChatEvents as Ke } from "../../providers/chat-events-provider.js";
7
+ import { getMessageMetadata as Te, serializeAttachments as We, serializeWorkflow as Je } from "../../utils/get-message-metadata.js";
8
8
  import { resetQueryParams as re } from "../../utils/reset-query-params.js";
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";
9
+ import { useChatForm as ze } from "../../providers/chat-form-provider.js";
10
+ import { useWidget as He } from "../../providers/widget-provider.js";
11
+ import { useMediaQuery as Qe } from "../../hooks/use-media-query.js";
12
+ import { useCaptcha as je } from "./use-captcha.js";
13
+ import { useModal as qe } from "../modal/modal-provider.js";
14
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({
15
+ import { provideLinksTool as Ge } from "../../utils/tools/links-tool.js";
16
+ import { getConversation as Ve } from "../../atoms/api/analytics/conversation.js";
17
+ import { parseIfJson as Xe } from "../../utils/misc.js";
18
+ const dt = () => {
19
+ const { chatId: v, isSharedChat: ie, setConversation: ce, conversation: B, resetConversation: le } = Fe(), { baseSettings: $, aiChatSettings: T } = Ue(), { aiApiBaseUrl: W, shouldBypassCaptcha: J, filters: z } = $, H = qe(), { getSolution: ue, prefetchSolution: E, invalidateSolution: Q } = je({
20
20
  fetchUrl: `${W}/v1/challenge`,
21
21
  shouldBypassCaptcha: J,
22
22
  shouldMakeInitialRequest: H ? H.isOpen : !0
23
- }), ue = new De({
23
+ }), me = new Oe({
24
24
  baseURL: `${W}/v1`,
25
25
  apiKey: $.apiKey ?? "",
26
26
  dangerouslyAllowBrowser: !0
27
27
  }), {
28
- onInputMessageChange: me,
29
- getTools: ge,
30
- prompts: pe,
31
- model: de,
28
+ onInputMessageChange: ge,
29
+ getTools: pe,
30
+ prompts: de,
31
+ model: fe,
32
32
  filters: j,
33
- onToolCall: fe
33
+ onToolCall: he
34
34
  } = T, [w, D] = l(""), q = K(null);
35
35
  ae(() => {
36
- me?.(w);
36
+ ge?.(w);
37
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) => {
38
+ const [p, c] = l([]), [G, C] = l(!1), [ye, I] = l(!1), [ve, V] = l(null), [O, X] = l(null), [M, S] = l([]), we = (e) => {
39
39
  S((t) => [...t, e]);
40
- }, [we, Y] = l({}), n = K([]), k = K(null), { logEvent: A } = Fe(), Z = pe?.map((e, t) => ({
40
+ }, [Ce, Y] = l({}), n = K([]), k = K(null), { logEvent: A } = Ke(), Z = de?.map((e, t) => ({
41
41
  id: `system-${Date.now().toString()}-${g(4)}-${t}`,
42
42
  role: "system",
43
43
  content: e
@@ -45,24 +45,24 @@ const pt = () => {
45
45
  ae(() => {
46
46
  if (v) {
47
47
  const { apiKey: e, analyticsApiBaseUrl: t } = $;
48
- Ge(v, e, t).then((o) => {
48
+ Ve(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
- }), Me(!1), ie({ ...o });
55
+ }), Me(!1), ce({ ...o });
56
56
  const a = o.messages.map((d) => ({
57
57
  ...d,
58
- content: Ve(d.content)
58
+ content: Xe(d.content)
59
59
  }));
60
60
  c(a), n.current = a;
61
61
  }
62
62
  });
63
63
  }
64
64
  }, [v]);
65
- const Ce = (e) => {
65
+ const Se = (e) => {
66
66
  switch (e.code) {
67
67
  case 400:
68
68
  return e.message;
@@ -76,27 +76,27 @@ 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 = Ce(e)), o;
80
- }), I(!1), M(!1), Q(), E();
81
- }, P = !w.trim() && !C.length || G, Se = (e) => {
79
+ return a && (a.content = Se(e)), o;
80
+ }), C(!1), I(!1), Q(), E();
81
+ }, P = !w.trim() && !M.length || G, ke = (e) => {
82
82
  e.key === "Enter" && !e.shiftKey && !P && !e.nativeEvent.isComposing && (e.preventDefault(), R());
83
- }, ke = (e) => {
83
+ }, be = (e) => {
84
84
  const t = e.target.value;
85
85
  D(t);
86
86
  }, R = async (e = w) => {
87
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);
88
+ C(!0);
89
+ const t = O ? p.length === 2 : p.length === 0, o = Te(O, M, t);
90
90
  let a;
91
- const d = Te(C);
92
- C.length && d ? a = [{ type: "text", text: d }] : a = e;
91
+ const d = We(M);
92
+ M.length && d ? a = [{ type: "text", text: d }] : a = e;
93
93
  const se = {
94
94
  id: `${Date.now().toString()}-${g(4)}-1`,
95
95
  role: "user",
96
96
  content: a,
97
97
  metadata: o
98
98
  }, f = [...p.length ? [] : Z, se];
99
- if (v) {
99
+ if (ie && v) {
100
100
  re();
101
101
  const u = n.current.map((r, N) => ({
102
102
  id: `${r.id}-${g(6)}-${N}`,
@@ -116,20 +116,20 @@ It seems I might be having some issues right now. Please clear the chat and try
116
116
  },
117
117
  n.current
118
118
  );
119
- const ne = [qe, ...ge?.({ conversation: B }) || []];
119
+ const ne = [Ge, ...pe?.({ conversation: B }) || []];
120
120
  try {
121
121
  const u = {
122
- model: de,
122
+ model: fe,
123
123
  messages: n.current,
124
124
  stream: !0,
125
125
  tools: ne,
126
126
  tool_choice: "auto"
127
- }, r = await le(), N = r ? btoa(JSON.stringify(r)) : null, oe = z || j ? JSON.stringify({
127
+ }, r = await ue(), N = r ? btoa(JSON.stringify(r)) : null, oe = z || j ? JSON.stringify({
128
128
  ...z,
129
129
  ...j
130
130
  }) : void 0, x = {};
131
131
  !J && N && (x["X-INKEEP-CHALLENGE-SOLUTION"] = N), oe && (x["inkeep-filters"] = oe);
132
- const h = ue.beta.chat.completions.stream(
132
+ const h = me.beta.chat.completions.stream(
133
133
  u,
134
134
  Object.keys(x).length > 0 ? { headers: x } : void 0
135
135
  ), s = {
@@ -140,17 +140,17 @@ It seems I might be having some issues right now. Please clear the chat and try
140
140
  tool_calls: []
141
141
  };
142
142
  c((m) => [...m, s]), h.on("content", (m, b) => {
143
- M(!0), s.content = b, c((L) => {
143
+ I(!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
147
  }), h.on("tool_calls.function.arguments.done", async (m) => {
148
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), Ne = i.function.function?.(_, h), xe = i.renderMessageButtons?.({ args: _, execution: Ne }) ?? [];
150
+ const _ = ("parse" in i.function ? i.function.parse : JSON.parse)(L), xe = i.function.function?.(_, h), Le = i.renderMessageButtons?.({ args: _, execution: xe }) ?? [];
151
151
  b === "provideLinks" ? s.links = _.links ?? [] : Y((y) => ({
152
152
  ...y,
153
- [s.id]: [...y[s.id] ?? [], ...xe]
153
+ [s.id]: [...y[s.id] ?? [], ...Le]
154
154
  })), s.tool_calls?.push({
155
155
  id: "call_" + g(24),
156
156
  type: "function",
@@ -159,16 +159,16 @@ It seems I might be having some issues right now. Please clear the chat and try
159
159
  arguments: L
160
160
  }
161
161
  }), c((y) => {
162
- const F = [...y], Le = F.findIndex((Be) => Be.id === s.id);
163
- return F[Le] = { ...s }, F;
164
- }), fe?.(m, {
162
+ const F = [...y], Be = F.findIndex((De) => De.id === s.id);
163
+ return F[Be] = { ...s }, F;
164
+ }), he?.(m, {
165
165
  conversation: {
166
166
  ...B,
167
167
  messages: [...n.current, s]
168
168
  }
169
169
  });
170
170
  }), h.on("error", ee), h.finalChatCompletion().then(() => {
171
- n.current = [...n.current, s], k.current = null, I(!1), M(!1), E(), A(
171
+ n.current = [...n.current, s], k.current = null, C(!1), I(!1), E(), A(
172
172
  {
173
173
  eventName: "assistant_message_received",
174
174
  properties: {}
@@ -176,21 +176,21 @@ It seems I might be having some issues right now. Please clear the chat and try
176
176
  n.current
177
177
  );
178
178
  }).catch((m) => {
179
- m instanceof Oe || console.warn(m);
179
+ m instanceof Pe || console.warn(m);
180
180
  }), k.current = h.controller;
181
181
  } catch (u) {
182
- ee(u), I(!1), M(!1);
182
+ ee(u), C(!1), I(!1);
183
183
  }
184
- }, be = () => {
185
- k.current && (k.current.abort(), k.current = null), I(!1), M(!1), E();
184
+ }, _e = () => {
185
+ k.current && (k.current.abort(), k.current = null), C(!1), I(!1), E();
186
186
  }, te = () => {
187
- V(null), c([]), n.current = [], ce(), Y({}), S([]), re(), X(null), Q(), E(), A({
187
+ V(null), c([]), n.current = [], le(), Y({}), S([]), re(), X(null), Q(), E(), A({
188
188
  eventName: "chat_clear_button_clicked",
189
189
  properties: {
190
190
  conversation: B
191
191
  }
192
192
  });
193
- }, _e = (e) => {
193
+ }, $e = (e) => {
194
194
  X(e);
195
195
  const { initialReplyMessage: t, displayName: o } = e, a = {
196
196
  id: p.length.toString() + g(4),
@@ -205,48 +205,48 @@ It seems I might be having some issues right now. Please clear the chat and try
205
205
  id: `system-${Date.now().toString()}-${g(4)}-${e.id}`,
206
206
  role: "system",
207
207
  content: `Company has asked user to follow this guided workflow:
208
- ${We(e)}`
208
+ ${Je(e)}`
209
209
  }, ...Z, a, d];
210
210
  c(f), S([]);
211
- }, { openForm: $e } = Je(), Ee = ze();
212
- Pe(T.chatFunctionsRef, () => ({
211
+ }, { openForm: Ee } = ze(), Ae = He();
212
+ Re(T.chatFunctionsRef, () => ({
213
213
  submitMessage: R,
214
214
  updateInputMessage(e) {
215
215
  D(e);
216
216
  },
217
217
  clearChat: te,
218
218
  openForm: (e) => {
219
- Ee?.setView("chat"), $e(e);
219
+ Ae?.setView("chat"), Ee(e);
220
220
  },
221
221
  focusInput: () => {
222
222
  q.current?.focus();
223
223
  }
224
224
  }));
225
- const Ae = He("(max-width: 768px)");
225
+ const Ne = Qe("(max-width: 768px)");
226
226
  return {
227
227
  messages: p,
228
228
  input: w,
229
229
  isLoading: G,
230
- isStreaming: he,
230
+ isStreaming: ye,
231
231
  isLoadingConversation: Ie,
232
- error: ye,
232
+ error: ve,
233
233
  isSubmitDisabled: P,
234
- handleInputChange: ke,
235
- handleInputKeyDown: Se,
234
+ handleInputChange: be,
235
+ handleInputKeyDown: ke,
236
236
  handleSubmit: R,
237
- stop: be,
237
+ stop: _e,
238
238
  clear: te,
239
- handleWorkflow: _e,
239
+ handleWorkflow: $e,
240
240
  selectedWorkflow: O,
241
- messageAttachments: C,
241
+ messageAttachments: M,
242
242
  setMessageAttachments: S,
243
- addAttachment: ve,
244
- messageButtons: we,
243
+ addAttachment: we,
244
+ messageButtons: Ce,
245
245
  isEmpty: p.length === 0,
246
246
  inputRef: q,
247
- isMobile: Ae
247
+ isMobile: Ne
248
248
  };
249
249
  };
250
250
  export {
251
- pt as useInkeepChat
251
+ dt as useInkeepChat
252
252
  };
package/dist/index.d.cts CHANGED
@@ -2807,6 +2807,7 @@ export declare interface InkeepConversationContextValue {
2807
2807
  conversation: ConversationResponse;
2808
2808
  setConversation: React.Dispatch<React.SetStateAction<ConversationResponse>>;
2809
2809
  chatId: string | undefined;
2810
+ isSharedChat: boolean;
2810
2811
  resetConversation: () => void;
2811
2812
  setExternalChatId: React.Dispatch<React.SetStateAction<string | undefined>>;
2812
2813
  }
package/dist/index.d.ts CHANGED
@@ -2807,6 +2807,7 @@ export declare interface InkeepConversationContextValue {
2807
2807
  conversation: ConversationResponse;
2808
2808
  setConversation: React.Dispatch<React.SetStateAction<ConversationResponse>>;
2809
2809
  chatId: string | undefined;
2810
+ isSharedChat: boolean;
2810
2811
  resetConversation: () => void;
2811
2812
  setExternalChatId: React.Dispatch<React.SetStateAction<string | undefined>>;
2812
2813
  }
@@ -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.92",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;
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.93",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.92",
10
+ widgetLibraryVersion: "0.5.93",
11
11
  componentType: s,
12
12
  tags: a
13
13
  }),
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("react/jsx-runtime"),e=require("react"),j=require("../atoms/api/analytics/conversation.cjs"),k=require("./config-provider.cjs"),R=require("./conversation-provider.cjs"),U=require("./user-provider.cjs"),A=require("./base-events-provider.cjs"),O=require("../utils/generate-uid.cjs"),b=e.createContext(void 0),S=({children:o})=>{const{baseSettings:q}=k.useInkeepConfig(),{apiKey:p,analyticsApiBaseUrl:E,tags:h,privacyPreferences:{optOutAllAnalytics:c},env:a,analyticsProperties:u}=q,{userProperties:f}=U.useUser(),{logEvent:g}=A.useBaseEvents(),{conversation:v,setConversation:x,chatId:l,setExternalChatId:P}=R.useInkeepConversation(),i=e.useRef(v),d=e.useRef(l);e.useEffect(()=>{i.current=v},[v]),e.useEffect(()=>{d.current=l},[l]);const C=e.useCallback(async r=>{const t=i.current;d.current&&(t.id="",P(void 0),d.current=void 0);const n=!c&&a!=="development";let s=Object.assign({},t,{messages:r});if(n){const y=await j.logConversation(t.id,{messages:r,tags:h,userProperties:f,properties:u},p,E);y&&(s=y)}else s.id="conv_"+O.generateUid(16);return s},[E,p,h,f,c,a,u,P]),w={logEvent:e.useCallback(async(r,t)=>{let n=i.current;t&&(n=await C(t),x(n),i.current=n);const s={...r,properties:{conversation:n,...r.properties}};g(s)},[g,C,c,a,u]),logConversation:C};return I.jsx(b.Provider,{value:w,children:o})},m=()=>{const o=e.useContext(b);if(!o)throw new Error("useChatEvents must be used within a ChatEventsProvider");return o};exports.ChatEventsProvider=S;exports.useChatEvents=m;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),e=require("react"),R=require("../atoms/api/analytics/conversation.cjs"),U=require("./config-provider.cjs"),A=require("./conversation-provider.cjs"),O=require("./user-provider.cjs"),m=require("./base-events-provider.cjs"),B=require("../utils/generate-uid.cjs"),x=e.createContext(void 0),K=({children:o})=>{const{baseSettings:w,aiChatSettings:I}=U.useInkeepConfig(),{apiKey:p,analyticsApiBaseUrl:E,tags:f,privacyPreferences:{optOutAllAnalytics:a},env:c,analyticsProperties:v}=w,{conversationVisibility:g}=I,{userProperties:P}=O.useUser(),{logEvent:y}=m.useBaseEvents(),{conversation:u,setConversation:S,chatId:d,isSharedChat:l,setExternalChatId:b}=A.useInkeepConversation(),i=e.useRef(u),C=e.useRef(l?d:void 0);e.useEffect(()=>{i.current=u},[u]),e.useEffect(()=>{C.current=l?d:void 0},[d,l]);const h=e.useCallback(async r=>{const t=i.current;C.current&&(t.id="",b(void 0),C.current=void 0);const n=!a&&c!=="development";let s=Object.assign({},t,{messages:r});if(n){const q=await R.logConversation(t.id,{messages:r,tags:f,userProperties:P,properties:v,visibility:g},p,E);q&&(s=q)}else s.id="conv_"+B.generateUid(16);return s},[E,p,f,P,a,c,v,b,g]),j={logEvent:e.useCallback(async(r,t)=>{let n=i.current;t&&(n=await h(t),S(n),i.current=n);const s={...r,properties:{conversation:n,...r.properties}};y(s)},[y,h,a,c,v]),logConversation:h};return k.jsx(x.Provider,{value:j,children:o})},L=()=>{const o=e.useContext(x);if(!o)throw new Error("useChatEvents must be used within a ChatEventsProvider");return o};exports.ChatEventsProvider=K;exports.useChatEvents=L;
@@ -1,64 +1,66 @@
1
1
  "use client";
2
- import { jsx as A } from "react/jsx-runtime";
3
- import { useRef as x, useEffect as y, useCallback as P, createContext as U, useContext as j } from "react";
4
- import { logConversation as B } from "../atoms/api/analytics/conversation.js";
5
- import { useInkeepConfig as O } from "./config-provider.js";
6
- import { useInkeepConversation as K } from "./conversation-provider.js";
7
- import { useUser as L } from "./user-provider.js";
8
- import { useBaseEvents as R } from "./base-events-provider.js";
9
- import { generateUid as S } from "../utils/generate-uid.js";
10
- const w = U(void 0), M = ({ children: r }) => {
11
- const { baseSettings: I } = O(), {
12
- apiKey: C,
13
- analyticsApiBaseUrl: d,
14
- tags: f,
2
+ import { jsx as j } from "react/jsx-runtime";
3
+ import { useRef as b, useEffect as P, useCallback as w, createContext as B, useContext as O } from "react";
4
+ import { logConversation as K } from "../atoms/api/analytics/conversation.js";
5
+ import { useInkeepConfig as L } from "./config-provider.js";
6
+ import { useInkeepConversation as R } from "./conversation-provider.js";
7
+ import { useUser as V } from "./user-provider.js";
8
+ import { useBaseEvents as _ } from "./base-events-provider.js";
9
+ import { generateUid as $ } from "../utils/generate-uid.js";
10
+ const I = B(void 0), Q = ({ children: r }) => {
11
+ const { baseSettings: k, aiChatSettings: A } = L(), {
12
+ apiKey: d,
13
+ analyticsApiBaseUrl: f,
14
+ tags: h,
15
15
  privacyPreferences: { optOutAllAnalytics: i },
16
16
  env: a,
17
17
  analyticsProperties: c
18
- } = I, { userProperties: m } = L(), { logEvent: h } = R(), { conversation: v, setConversation: b, chatId: u, setExternalChatId: E } = K(), s = x(v), p = x(u);
19
- y(() => {
18
+ } = k, { conversationVisibility: m } = A, { userProperties: E } = V(), { logEvent: g } = _(), { conversation: v, setConversation: S, chatId: u, isSharedChat: l, setExternalChatId: y } = R(), s = b(v), p = b(l ? u : void 0);
19
+ P(() => {
20
20
  s.current = v;
21
- }, [v]), y(() => {
22
- p.current = u;
23
- }, [u]);
24
- const l = P(
21
+ }, [v]), P(() => {
22
+ p.current = l ? u : void 0;
23
+ }, [u, l]);
24
+ const C = w(
25
25
  async (n) => {
26
26
  const t = s.current;
27
- p.current && (t.id = "", E(void 0), p.current = void 0);
27
+ p.current && (t.id = "", y(void 0), p.current = void 0);
28
28
  const e = !i && a !== "development";
29
29
  let o = Object.assign({}, t, { messages: n });
30
30
  if (e) {
31
- const g = await B(
31
+ const x = await K(
32
32
  t.id,
33
33
  {
34
34
  messages: n,
35
- tags: f,
36
- userProperties: m,
37
- properties: c
35
+ tags: h,
36
+ userProperties: E,
37
+ properties: c,
38
+ visibility: m
38
39
  },
39
- C,
40
- d
40
+ d,
41
+ f
41
42
  );
42
- g && (o = g);
43
+ x && (o = x);
43
44
  } else
44
- o.id = "conv_" + S(16);
45
+ o.id = "conv_" + $(16);
45
46
  return o;
46
47
  },
47
48
  [
48
- d,
49
- C,
50
49
  f,
51
- m,
50
+ d,
51
+ h,
52
+ E,
52
53
  i,
53
54
  a,
54
55
  c,
55
- E
56
+ y,
57
+ m
56
58
  ]
57
- ), k = {
58
- logEvent: P(
59
+ ), U = {
60
+ logEvent: w(
59
61
  async (n, t) => {
60
62
  let e = s.current;
61
- t && (e = await l(t), b(e), s.current = e);
63
+ t && (e = await C(t), S(e), s.current = e);
62
64
  const o = {
63
65
  ...n,
64
66
  properties: {
@@ -66,20 +68,20 @@ const w = U(void 0), M = ({ children: r }) => {
66
68
  ...n.properties
67
69
  }
68
70
  };
69
- h(o);
71
+ g(o);
70
72
  },
71
- [h, l, i, a, c]
73
+ [g, C, i, a, c]
72
74
  ),
73
- logConversation: l
75
+ logConversation: C
74
76
  };
75
- return /* @__PURE__ */ A(w.Provider, { value: k, children: r });
76
- }, N = () => {
77
- const r = j(w);
77
+ return /* @__PURE__ */ j(I.Provider, { value: U, children: r });
78
+ }, T = () => {
79
+ const r = O(I);
78
80
  if (!r)
79
81
  throw new Error("useChatEvents must be used within a ChatEventsProvider");
80
82
  return r;
81
83
  };
82
84
  export {
83
- M as ChatEventsProvider,
84
- N as useChatEvents
85
+ Q as ChatEventsProvider,
86
+ T as useChatEvents
85
87
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),t=require("react"),C=require("./config-provider.cjs"),l="conversationId",I=t.createContext(null),f=({children:o})=>{const d=w(),{aiChatSettings:u}=C.useInkeepConfig(),n=u.chatId||d,[r,s]=t.useState(n);t.useEffect(()=>{s(n)},[n]);const a={id:"",messages:[]},[e,i]=t.useState(a),h=()=>{i(a),s(void 0)},c=t.useMemo(()=>({conversation:e,setConversation:i,chatId:r,resetConversation:h,setExternalChatId:s}),[e,r]);return p.jsx(I.Provider,{value:c,children:o})},S=()=>{const o=t.useContext(I);if(!o)throw new Error("useInkeepConversation must be used within an InkeepConversationProvider");return o};function w(){const[o,d]=t.useState(void 0),{aiChatSettings:u}=C.useInkeepConfig(),{shareChatUrlBasePath:n}=u;return t.useEffect(()=>{if(!n||typeof window>"u")return;const r=e=>e.endsWith("/")?e.slice(0,-1):e,s=()=>{const{origin:e,pathname:i,search:h}=window.location,c=new URL(n),m=r(i),P=r(c.pathname);if(e===c.origin&&m===P){const v=new URLSearchParams(h).get(l);v&&d(v)}};s();const a=()=>s();return window.addEventListener("popstate",a),()=>{window.removeEventListener("popstate",a)}},[n]),o}exports.InkeepConversationProvider=f;exports.SHARE_QUERY_PARAM=l;exports.useInkeepConversation=S;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),t=require("react"),C=require("./config-provider.cjs"),l="conversationId",I=t.createContext(null),S=({children:o})=>{const r=w(),{aiChatSettings:u}=C.useInkeepConfig(),n=u.chatId||r,[a,s]=t.useState(n);t.useEffect(()=>{s(n)},[n]);const i={id:"",messages:[]},[e,c]=t.useState(i),h=()=>{c(i),s(void 0)},d=t.useMemo(()=>({conversation:e,setConversation:c,chatId:a,isSharedChat:!!r,resetConversation:h,setExternalChatId:s}),[e,a,r]);return p.jsx(I.Provider,{value:d,children:o})},f=()=>{const o=t.useContext(I);if(!o)throw new Error("useInkeepConversation must be used within an InkeepConversationProvider");return o};function w(){const[o,r]=t.useState(void 0),{aiChatSettings:u}=C.useInkeepConfig(),{shareChatUrlBasePath:n}=u;return t.useEffect(()=>{if(!n||typeof window>"u")return;const a=e=>e.endsWith("/")?e.slice(0,-1):e,s=()=>{const{origin:e,pathname:c,search:h}=window.location,d=new URL(n),m=a(c),P=a(d.pathname);if(e===d.origin&&m===P){const v=new URLSearchParams(h).get(l);v&&r(v)}};s();const i=()=>s();return window.addEventListener("popstate",i),()=>{window.removeEventListener("popstate",i)}},[n]),o}exports.InkeepConversationProvider=S;exports.SHARE_QUERY_PARAM=l;exports.useInkeepConversation=f;
@@ -3,26 +3,27 @@ import { jsx as f } from "react/jsx-runtime";
3
3
  import { useState as u, useEffect as m, useMemo as w, createContext as P, useContext as S } from "react";
4
4
  import { useInkeepConfig as v } from "./config-provider.js";
5
5
  const x = "conversationId", l = P(null), z = ({ children: n }) => {
6
- const c = g(), { aiChatSettings: d } = v(), t = d.chatId || c, [s, o] = u(t);
6
+ const s = g(), { aiChatSettings: d } = v(), t = d.chatId || s, [r, o] = u(t);
7
7
  m(() => {
8
8
  o(t);
9
9
  }, [t]);
10
- const r = {
10
+ const a = {
11
11
  id: "",
12
12
  messages: []
13
- }, [e, a] = u(r), h = () => {
14
- a(r), o(void 0);
15
- }, i = w(
13
+ }, [e, i] = u(a), h = () => {
14
+ i(a), o(void 0);
15
+ }, c = w(
16
16
  () => ({
17
17
  conversation: e,
18
- setConversation: a,
19
- chatId: s,
18
+ setConversation: i,
19
+ chatId: r,
20
+ isSharedChat: !!s,
20
21
  resetConversation: h,
21
22
  setExternalChatId: o
22
23
  }),
23
- [e, s]
24
+ [e, r, s]
24
25
  );
25
- return /* @__PURE__ */ f(l.Provider, { value: i, children: n });
26
+ return /* @__PURE__ */ f(l.Provider, { value: c, children: n });
26
27
  }, L = () => {
27
28
  const n = S(l);
28
29
  if (!n)
@@ -30,20 +31,20 @@ const x = "conversationId", l = P(null), z = ({ children: n }) => {
30
31
  return n;
31
32
  };
32
33
  function g() {
33
- const [n, c] = u(void 0), { aiChatSettings: d } = v(), { shareChatUrlBasePath: t } = d;
34
+ const [n, s] = u(void 0), { aiChatSettings: d } = v(), { shareChatUrlBasePath: t } = d;
34
35
  return m(() => {
35
36
  if (!t || typeof window > "u") return;
36
- const s = (e) => e.endsWith("/") ? e.slice(0, -1) : e, o = () => {
37
- const { origin: e, pathname: a, search: h } = window.location, i = new URL(t), I = s(a), p = s(i.pathname);
38
- if (e === i.origin && I === p) {
37
+ const r = (e) => e.endsWith("/") ? e.slice(0, -1) : e, o = () => {
38
+ const { origin: e, pathname: i, search: h } = window.location, c = new URL(t), I = r(i), p = r(c.pathname);
39
+ if (e === c.origin && I === p) {
39
40
  const C = new URLSearchParams(h).get(x);
40
- C && c(C);
41
+ C && s(C);
41
42
  }
42
43
  };
43
44
  o();
44
- const r = () => o();
45
- return window.addEventListener("popstate", r), () => {
46
- window.removeEventListener("popstate", r);
45
+ const a = () => o();
46
+ return window.addEventListener("popstate", a), () => {
47
+ window.removeEventListener("popstate", a);
47
48
  };
48
49
  }, [t]), n;
49
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/cxkit-primitives",
3
- "version": "0.5.92",
3
+ "version": "0.5.93",
4
4
  "description": "",
5
5
  "license": "Inkeep, Inc. Customer License (IICL) v1.1",
6
6
  "homepage": "",
@@ -67,9 +67,9 @@
67
67
  "remark-gfm": "^4.0.1",
68
68
  "unist-util-visit": "^5.0.0",
69
69
  "use-sync-external-store": "^1.4.0",
70
- "@inkeep/cxkit-color-mode": "^0.5.92",
71
- "@inkeep/cxkit-theme": "0.5.92",
72
- "@inkeep/cxkit-types": "0.5.92"
70
+ "@inkeep/cxkit-color-mode": "^0.5.93",
71
+ "@inkeep/cxkit-theme": "0.5.93",
72
+ "@inkeep/cxkit-types": "0.5.93"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@biomejs/biome": "1.9.4",