@inkeep/cxkit-primitives 0.5.68 → 0.5.70

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"),D=require("../../utils/get-message-metadata.cjs"),Be=require("../../utils/misc.cjs"),ae=require("../../utils/reset-query-params.cjs"),De=require("../../providers/chat-form-provider.cjs"),Oe=require("../../providers/widget-provider.cjs"),Fe=require("../../hooks/use-media-query.cjs"),Te=require("./use-captcha.cjs"),Ke=require("../modal/modal-provider.cjs"),l=require("../../utils/generate-uid.cjs"),Qe=require("../../utils/tools/links-tool.cjs"),We=require("../../atoms/api/analytics/conversation.cjs"),Je=()=>{const{chatId:f,setConversation:re,conversation:N,resetConversation:ie}=Le.useInkeepConversation(),{baseSettings:b,aiChatSettings:O}=Re.useInkeepConfig(),{aiApiBaseUrl:F,shouldBypassCaptcha:T,filters:K}=b,Q=Ke.useModal(),{getSolution:ce,prefetchSolution:q,invalidateSolution:W}=Te.useCaptcha({fetchUrl:`${F}/v1/challenge`,shouldBypassCaptcha:T,shouldMakeInitialRequest:Q?Q.isOpen:!0}),ue=new Ae({baseURL:`${F}/v1`,apiKey:b.apiKey??"",dangerouslyAllowBrowser:!0}),{onInputMessageChange:le,getTools:ge,prompts:de,model:me,filters:J,onToolCall:fe}=O,[p,_]=t.useState(""),z=t.useRef(null);t.useEffect(()=>{le?.(p)},[p]);const[g,u]=t.useState([]),[H,h]=t.useState(!1),[pe,v]=t.useState(!1),[he,j]=t.useState(null),[A,G]=t.useState(null),[y,S]=t.useState([]),ve=e=>{S(s=>[...s,e])},[ye,V]=t.useState({}),r=t.useRef([]),C=t.useRef(null),{logEvent:P}=xe.useChatEvents(),X=de?.map((e,s)=>({id:`system-${Date.now().toString()}-${l.generateUid(4)}-${s}`,role:"system",content:e})),[Se,Ce]=t.useState(!!f);t.useEffect(()=>{if(f){const{apiKey:e,analyticsApiBaseUrl:s}=b;We.getConversation(f,e,s).then(o=>{if(o){P({eventName:"shared_chat_loaded",properties:{conversation:o}}),Ce(!1),re({...o,id:""});const a=o.messages.map(c=>({id:Date.now().toString()+l.generateUid(4)+c.id,content:Be.parseIfJson(c.content),role:c.role,links:c.links}));u(a),r.current=a}})}},[f]);const Me=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${b.organizationDisplayName??"Administrator"}`;default:return`Hmm..
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"),D=require("../../utils/get-message-metadata.cjs"),Be=require("../../utils/misc.cjs"),ae=require("../../utils/reset-query-params.cjs"),De=require("../../providers/chat-form-provider.cjs"),Oe=require("../../providers/widget-provider.cjs"),Fe=require("../../hooks/use-media-query.cjs"),Te=require("./use-captcha.cjs"),Ke=require("../modal/modal-provider.cjs"),l=require("../../utils/generate-uid.cjs"),Qe=require("../../utils/tools/links-tool.cjs"),We=require("../../atoms/api/analytics/conversation.cjs"),Je=()=>{const{chatId:f,setConversation:re,conversation:$,resetConversation:ie}=Le.useInkeepConversation(),{baseSettings:b,aiChatSettings:O}=Re.useInkeepConfig(),{aiApiBaseUrl:F,shouldBypassCaptcha:T,filters:K}=b,Q=Ke.useModal(),{getSolution:ce,prefetchSolution:q,invalidateSolution:W}=Te.useCaptcha({fetchUrl:`${F}/v1/challenge`,shouldBypassCaptcha:T,shouldMakeInitialRequest:Q?Q.isOpen:!0}),ue=new Ae({baseURL:`${F}/v1`,apiKey:b.apiKey??"",dangerouslyAllowBrowser:!0}),{onInputMessageChange:le,getTools:ge,prompts:de,model:me,filters:J,onToolCall:fe}=O,[p,N]=t.useState(""),z=t.useRef(null);t.useEffect(()=>{le?.(p)},[p]);const[g,u]=t.useState([]),[H,h]=t.useState(!1),[pe,v]=t.useState(!1),[he,j]=t.useState(null),[A,G]=t.useState(null),[y,S]=t.useState([]),ve=e=>{S(s=>[...s,e])},[ye,V]=t.useState({}),r=t.useRef([]),M=t.useRef(null),{logEvent:P}=xe.useChatEvents(),X=de?.map((e,s)=>({id:`system-${Date.now().toString()}-${l.generateUid(4)}-${s}`,role:"system",content:e})),[Se,Me]=t.useState(!!f);t.useEffect(()=>{if(f){const{apiKey:e,analyticsApiBaseUrl:s}=b;We.getConversation(f,e,s).then(o=>{if(o){P({eventName:"shared_chat_loaded",properties:{conversation:o}}),Me(!1),re({...o,id:""});const a=o.messages.map(c=>({id:Date.now().toString()+l.generateUid(4)+c.id,content:Be.parseIfJson(c.content),role:c.role,links:c.links}));u(a),r.current=a}})}},[f]);const we=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${b.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.`}},Y=e=>{j(e),u(s=>{const o=[...s],a=o[o.length-1];return a&&(a.content=Me(e)),o}),h(!1),v(!1),W(),q()},R=!p.trim()&&!y.length||H,we=e=>{e.key==="Enter"&&!e.shiftKey&&!R&&!e.nativeEvent.isComposing&&(e.preventDefault(),L())},Ie=e=>{const s=e.target.value;_(s)},L=async(e=p)=>{if(R&&(!e||e.trim().length===0))return;h(!0);const s=A?g.length===2:g.length===0,o=D.getMessageMetadata(A,y,s);let a;const c=D.serializeAttachments(y);y.length&&c?a=[{type:"text",text:c}]:a=e;const ee={id:`${Date.now().toString()}-${l.generateUid(4)}-1`,role:"user",content:a,metadata:o},E=[...g.length?[]:X,ee];f&&ae.resetQueryParams(),u(M=>[...M,...E]),r.current=[...r.current,...E],S([]),_(""),P({eventName:"user_message_submitted",properties:{}},r.current);const te=[Qe.provideLinksTool,...ge?.({conversation:N})||[]];try{const M={model:me,messages:r.current,stream:!0,tools:te,tool_choice:"auto"},se=await ce(),ne=se?btoa(JSON.stringify(se)):null,oe=K||J?JSON.stringify({...K,...J}):void 0,U={};!T&&ne&&(U["X-INKEEP-CHALLENGE-SOLUTION"]=ne),oe&&(U["inkeep-filters"]=oe);const d=ue.beta.chat.completions.stream(M,Object.keys(U).length>0?{headers:U}:void 0),n={id:`${Date.now().toString()}-${l.generateUid(4)}-2`,role:"assistant",content:"",links:[],toolCalls:[]};u(w=>[...w,n]),d.on("content",(w,I)=>{v(!0),n.content=I,u($=>{const i=[...$],x=i.findIndex(k=>k.id===n.id);return x===-1?[...i,n]:(i[x]={...n},i)})}),d.on("tool_calls.function.arguments.done",async w=>{const{name:I,arguments:$}=w,i=te?.find(m=>m.function.name===I);if(!i)return;const k=("parse"in i.function?i.function.parse:JSON.parse)($),Ue=i.function.function?.(k,d),$e=i.renderMessageButtons?.({args:k,execution:Ue})??[];I==="provideLinks"?n.links=k.links??[]:V(m=>({...m,[n.id]:[...m[n.id]??[],...$e]})),n.toolCalls?.push({id:"call_"+l.generateUid(24),type:"function",function:{name:I,arguments:$}}),u(m=>{const B=[...m],Ne=B.findIndex(_e=>_e.id===n.id);return B[Ne]={...n},B}),fe?.(w,{conversation:{...N,messages:[...r.current,n]}})}),d.on("error",Y),d.finalChatCompletion().then(()=>{r.current=[...r.current,n],C.current=null,h(!1),v(!1),q(),P({eventName:"assistant_message_received",properties:{}},r.current)}),C.current=d.controller}catch(M){Y(M),h(!1),v(!1)}},ke=()=>{C.current&&(C.current.abort(),C.current=null),h(!1),v(!1),q()},Z=()=>{j(null),u([]),r.current=[],ie(),V({}),S([]),ae.resetQueryParams(),G(null),W(),q(),P({eventName:"chat_clear_button_clicked",properties:{conversation:N}})},be=e=>{G(e);const{initialReplyMessage:s,displayName:o}=e,a={id:g.length.toString()+l.generateUid(4),role:"user",content:o},c={id:(g.length+1).toString()+l.generateUid(4),role:"assistant",content:s,links:[]},E=[{id:`system-${Date.now().toString()}-${l.generateUid(4)}-${e.id}`,role:"system",content:`Company has asked user to follow this guided workflow:
4
- ${D.serializeWorkflow(e)}`},...X,a,c];u(E),S([])},{openForm:qe}=De.useChatForm(),Pe=Oe.useWidget();t.useImperativeHandle(O.chatFunctionsRef,()=>({submitMessage:L,updateInputMessage(e){_(e)},clearChat:Z,openForm:e=>{Pe?.setView("chat"),qe(e)},focusInput:()=>{z.current?.focus()}}));const Ee=Fe.useMediaQuery("(max-width: 768px)");return{messages:g,input:p,isLoading:H,isStreaming:pe,isLoadingConversation:Se,error:he,isSubmitDisabled:R,handleInputChange:Ie,handleInputKeyDown:we,handleSubmit:L,stop:ke,clear:Z,handleWorkflow:be,selectedWorkflow:A,messageAttachments:y,setMessageAttachments:S,addAttachment:ve,messageButtons:ye,isEmpty:g.length===0,inputRef:z,isMobile:Ee}};exports.useInkeepChat=Je;
3
+ It seems I might be having some issues right now. Please clear the chat and try again.`}},Y=e=>{j(e),u(s=>{const o=[...s],a=o[o.length-1];return a&&(a.content=we(e)),o}),h(!1),v(!1),W(),q()},R=!p.trim()&&!y.length||H,Ce=e=>{e.key==="Enter"&&!e.shiftKey&&!R&&!e.nativeEvent.isComposing&&(e.preventDefault(),L())},Ie=e=>{const s=e.target.value;N(s)},L=async(e=p)=>{if(R&&(!e||e.trim().length===0))return;h(!0);const s=A?g.length===2:g.length===0,o=D.getMessageMetadata(A,y,s);let a;const c=D.serializeAttachments(y);y.length&&c?a=[{type:"text",text:c}]:a=e;const ee={id:`${Date.now().toString()}-${l.generateUid(4)}-1`,role:"user",content:a,metadata:o},E=[...g.length?[]:X,ee];f&&ae.resetQueryParams(),u(w=>[...w,...E]),r.current=[...r.current,...E],S([]),N(""),P({eventName:"user_message_submitted",properties:{}},r.current);const te=[Qe.provideLinksTool,...ge?.({conversation:$})||[]];try{const w={model:me,messages:r.current,stream:!0,tools:te,tool_choice:"auto"},se=await ce(),ne=se?btoa(JSON.stringify(se)):null,oe=K||J?JSON.stringify({...K,...J}):void 0,U={};!T&&ne&&(U["X-INKEEP-CHALLENGE-SOLUTION"]=ne),oe&&(U["inkeep-filters"]=oe);const d=ue.beta.chat.completions.stream(w,Object.keys(U).length>0?{headers:U}:void 0),n={id:`${Date.now().toString()}-${l.generateUid(4)}-2`,role:"assistant",content:"",links:[],tool_calls:[]};u(C=>[...C,n]),d.on("content",(C,I)=>{v(!0),n.content=I,u(_=>{const i=[..._],x=i.findIndex(k=>k.id===n.id);return x===-1?[...i,n]:(i[x]={...n},i)})}),d.on("tool_calls.function.arguments.done",async C=>{const{name:I,arguments:_}=C,i=te?.find(m=>m.function.name===I);if(!i)return;const k=("parse"in i.function?i.function.parse:JSON.parse)(_),Ue=i.function.function?.(k,d),_e=i.renderMessageButtons?.({args:k,execution:Ue})??[];I==="provideLinks"?n.links=k.links??[]:V(m=>({...m,[n.id]:[...m[n.id]??[],..._e]})),n.tool_calls?.push({id:"call_"+l.generateUid(24),type:"function",function:{name:I,arguments:_}}),u(m=>{const B=[...m],$e=B.findIndex(Ne=>Ne.id===n.id);return B[$e]={...n},B}),fe?.(C,{conversation:{...$,messages:[...r.current,n]}})}),d.on("error",Y),d.finalChatCompletion().then(()=>{r.current=[...r.current,n],M.current=null,h(!1),v(!1),q(),P({eventName:"assistant_message_received",properties:{}},r.current)}),M.current=d.controller}catch(w){Y(w),h(!1),v(!1)}},ke=()=>{M.current&&(M.current.abort(),M.current=null),h(!1),v(!1),q()},Z=()=>{j(null),u([]),r.current=[],ie(),V({}),S([]),ae.resetQueryParams(),G(null),W(),q(),P({eventName:"chat_clear_button_clicked",properties:{conversation:$}})},be=e=>{G(e);const{initialReplyMessage:s,displayName:o}=e,a={id:g.length.toString()+l.generateUid(4),role:"user",content:o},c={id:(g.length+1).toString()+l.generateUid(4),role:"assistant",content:s,links:[]},E=[{id:`system-${Date.now().toString()}-${l.generateUid(4)}-${e.id}`,role:"system",content:`Company has asked user to follow this guided workflow:
4
+ ${D.serializeWorkflow(e)}`},...X,a,c];u(E),S([])},{openForm:qe}=De.useChatForm(),Pe=Oe.useWidget();t.useImperativeHandle(O.chatFunctionsRef,()=>({submitMessage:L,updateInputMessage(e){N(e)},clearChat:Z,openForm:e=>{Pe?.setView("chat"),qe(e)},focusInput:()=>{z.current?.focus()}}));const Ee=Fe.useMediaQuery("(max-width: 768px)");return{messages:g,input:p,isLoading:H,isStreaming:pe,isLoadingConversation:Se,error:he,isSubmitDisabled:R,handleInputChange:Ie,handleInputKeyDown:Ce,handleSubmit:L,stop:ke,clear:Z,handleWorkflow:be,selectedWorkflow:A,messageAttachments:y,setMessageAttachments:S,addAttachment:ve,messageButtons:ye,isEmpty:g.length===0,inputRef:z,isMobile:Ee}};exports.useInkeepChat=Je;
@@ -16,7 +16,7 @@ import { generateUid as u } from "../../utils/generate-uid.js";
16
16
  import { provideLinksTool as qe } from "../../utils/tools/links-tool.js";
17
17
  import { getConversation as Ge } from "../../atoms/api/analytics/conversation.js";
18
18
  const gt = () => {
19
- const { chatId: d, setConversation: ie, conversation: x, resetConversation: ce } = Pe(), { baseSettings: b, aiChatSettings: F } = Re(), { aiApiBaseUrl: K, shouldBypassCaptcha: T, filters: W } = b, J = je(), { getSolution: le, prefetchSolution: $, invalidateSolution: z } = Qe({
19
+ const { chatId: d, setConversation: ie, conversation: x, resetConversation: ce } = Pe(), { baseSettings: b, aiChatSettings: F } = Re(), { aiApiBaseUrl: K, shouldBypassCaptcha: T, filters: W } = b, J = je(), { getSolution: le, prefetchSolution: _, invalidateSolution: z } = Qe({
20
20
  fetchUrl: `${K}/v1/challenge`,
21
21
  shouldBypassCaptcha: T,
22
22
  shouldMakeInitialRequest: J ? J.isOpen : !0
@@ -35,19 +35,19 @@ const gt = () => {
35
35
  ae(() => {
36
36
  me?.(f);
37
37
  }, [f]);
38
- const [m, l] = c([]), [j, h] = c(!1), [he, y] = c(!1), [ye, q] = c(null), [B, G] = c(null), [C, v] = c([]), Ce = (e) => {
39
- v((t) => [...t, e]);
40
- }, [ve, V] = c({}), a = U([]), w = U(null), { logEvent: E } = Ue(), X = pe?.map((e, t) => ({
38
+ const [m, l] = c([]), [j, h] = c(!1), [he, y] = c(!1), [ye, q] = c(null), [B, G] = c(null), [v, w] = c([]), ve = (e) => {
39
+ w((t) => [...t, e]);
40
+ }, [we, V] = c({}), a = U([]), C = U(null), { logEvent: $ } = Ue(), X = pe?.map((e, t) => ({
41
41
  id: `system-${Date.now().toString()}-${u(4)}-${t}`,
42
42
  role: "system",
43
43
  content: e
44
- })), [we, Ie] = c(!!d);
44
+ })), [Ce, Ie] = c(!!d);
45
45
  ae(() => {
46
46
  if (d) {
47
47
  const { apiKey: e, analyticsApiBaseUrl: t } = b;
48
48
  Ge(d, e, t).then((n) => {
49
49
  if (n) {
50
- E({
50
+ $({
51
51
  eventName: "shared_chat_loaded",
52
52
  properties: {
53
53
  conversation: n
@@ -79,8 +79,8 @@ It seems I might be having some issues right now. Please clear the chat and try
79
79
  q(e), l((t) => {
80
80
  const n = [...t], o = n[n.length - 1];
81
81
  return o && (o.content = Me(e)), n;
82
- }), h(!1), y(!1), z(), $();
83
- }, D = !f.trim() && !C.length || j, Se = (e) => {
82
+ }), h(!1), y(!1), z(), _();
83
+ }, D = !f.trim() && !v.length || j, Se = (e) => {
84
84
  e.key === "Enter" && !e.shiftKey && !D && !e.nativeEvent.isComposing && (e.preventDefault(), O());
85
85
  }, ke = (e) => {
86
86
  const t = e.target.value;
@@ -88,17 +88,17 @@ It seems I might be having some issues right now. Please clear the chat and try
88
88
  }, O = async (e = f) => {
89
89
  if (D && (!e || e.trim().length === 0)) return;
90
90
  h(!0);
91
- const t = B ? m.length === 2 : m.length === 0, n = Fe(B, C, t);
91
+ const t = B ? m.length === 2 : m.length === 0, n = Fe(B, v, t);
92
92
  let o;
93
- const i = Ke(C);
94
- C.length && i ? o = [{ type: "text", text: i }] : o = e;
93
+ const i = Ke(v);
94
+ v.length && i ? o = [{ type: "text", text: i }] : o = e;
95
95
  const ee = {
96
96
  id: `${Date.now().toString()}-${u(4)}-1`,
97
97
  role: "user",
98
98
  content: o,
99
99
  metadata: n
100
- }, N = [...m.length ? [] : X, ee];
101
- d && re(), l((I) => [...I, ...N]), a.current = [...a.current, ...N], v([]), L(""), E(
100
+ }, E = [...m.length ? [] : X, ee];
101
+ d && re(), l((I) => [...I, ...E]), a.current = [...a.current, ...E], w([]), L(""), $(
102
102
  {
103
103
  eventName: "user_message_submitted",
104
104
  properties: {}
@@ -116,17 +116,17 @@ It seems I might be having some issues right now. Please clear the chat and try
116
116
  }, se = await le(), ne = se ? btoa(JSON.stringify(se)) : null, oe = W || H ? JSON.stringify({
117
117
  ...W,
118
118
  ...H
119
- }) : void 0, _ = {};
120
- !T && ne && (_["X-INKEEP-CHALLENGE-SOLUTION"] = ne), oe && (_["inkeep-filters"] = oe);
119
+ }) : void 0, N = {};
120
+ !T && ne && (N["X-INKEEP-CHALLENGE-SOLUTION"] = ne), oe && (N["inkeep-filters"] = oe);
121
121
  const g = ue.beta.chat.completions.stream(
122
122
  I,
123
- Object.keys(_).length > 0 ? { headers: _ } : void 0
123
+ Object.keys(N).length > 0 ? { headers: N } : void 0
124
124
  ), s = {
125
125
  id: `${Date.now().toString()}-${u(4)}-2`,
126
126
  role: "assistant",
127
127
  content: "",
128
128
  links: [],
129
- toolCalls: []
129
+ tool_calls: []
130
130
  };
131
131
  l((M) => [...M, s]), g.on("content", (M, S) => {
132
132
  y(!0), s.content = S, l((A) => {
@@ -140,7 +140,7 @@ It seems I might be having some issues right now. Please clear the chat and try
140
140
  S === "provideLinks" ? s.links = k.links ?? [] : V((p) => ({
141
141
  ...p,
142
142
  [s.id]: [...p[s.id] ?? [], ...xe]
143
- })), s.toolCalls?.push({
143
+ })), s.tool_calls?.push({
144
144
  id: "call_" + u(24),
145
145
  type: "function",
146
146
  function: {
@@ -157,27 +157,27 @@ It seems I might be having some issues right now. Please clear the chat and try
157
157
  }
158
158
  });
159
159
  }), g.on("error", Y), g.finalChatCompletion().then(() => {
160
- a.current = [...a.current, s], w.current = null, h(!1), y(!1), $(), E(
160
+ a.current = [...a.current, s], C.current = null, h(!1), y(!1), _(), $(
161
161
  {
162
162
  eventName: "assistant_message_received",
163
163
  properties: {}
164
164
  },
165
165
  a.current
166
166
  );
167
- }), w.current = g.controller;
167
+ }), C.current = g.controller;
168
168
  } catch (I) {
169
169
  Y(I), h(!1), y(!1);
170
170
  }
171
171
  }, be = () => {
172
- w.current && (w.current.abort(), w.current = null), h(!1), y(!1), $();
172
+ C.current && (C.current.abort(), C.current = null), h(!1), y(!1), _();
173
173
  }, Z = () => {
174
- q(null), l([]), a.current = [], ce(), V({}), v([]), re(), G(null), z(), $(), E({
174
+ q(null), l([]), a.current = [], ce(), V({}), w([]), re(), G(null), z(), _(), $({
175
175
  eventName: "chat_clear_button_clicked",
176
176
  properties: {
177
177
  conversation: x
178
178
  }
179
179
  });
180
- }, $e = (e) => {
180
+ }, _e = (e) => {
181
181
  G(e);
182
182
  const { initialReplyMessage: t, displayName: n } = e, o = {
183
183
  id: m.length.toString() + u(4),
@@ -188,14 +188,14 @@ It seems I might be having some issues right now. Please clear the chat and try
188
188
  role: "assistant",
189
189
  content: t,
190
190
  links: []
191
- }, N = [{
191
+ }, E = [{
192
192
  id: `system-${Date.now().toString()}-${u(4)}-${e.id}`,
193
193
  role: "system",
194
194
  content: `Company has asked user to follow this guided workflow:
195
195
  ${Te(e)}`
196
196
  }, ...X, o, i];
197
- l(N), v([]);
198
- }, { openForm: Ee } = Je(), Ne = ze();
197
+ l(E), w([]);
198
+ }, { openForm: $e } = Je(), Ee = ze();
199
199
  Oe(F.chatFunctionsRef, () => ({
200
200
  submitMessage: O,
201
201
  updateInputMessage(e) {
@@ -203,19 +203,19 @@ ${Te(e)}`
203
203
  },
204
204
  clearChat: Z,
205
205
  openForm: (e) => {
206
- Ne?.setView("chat"), Ee(e);
206
+ Ee?.setView("chat"), $e(e);
207
207
  },
208
208
  focusInput: () => {
209
209
  Q.current?.focus();
210
210
  }
211
211
  }));
212
- const _e = He("(max-width: 768px)");
212
+ const Ne = He("(max-width: 768px)");
213
213
  return {
214
214
  messages: m,
215
215
  input: f,
216
216
  isLoading: j,
217
217
  isStreaming: he,
218
- isLoadingConversation: we,
218
+ isLoadingConversation: Ce,
219
219
  error: ye,
220
220
  isSubmitDisabled: D,
221
221
  handleInputChange: ke,
@@ -223,15 +223,15 @@ ${Te(e)}`
223
223
  handleSubmit: O,
224
224
  stop: be,
225
225
  clear: Z,
226
- handleWorkflow: $e,
226
+ handleWorkflow: _e,
227
227
  selectedWorkflow: B,
228
- messageAttachments: C,
229
- setMessageAttachments: v,
230
- addAttachment: Ce,
231
- messageButtons: ve,
228
+ messageAttachments: v,
229
+ setMessageAttachments: w,
230
+ addAttachment: ve,
231
+ messageButtons: we,
232
232
  isEmpty: m.length === 0,
233
233
  inputRef: Q,
234
- isMobile: _e
234
+ isMobile: Ne
235
235
  };
236
236
  };
237
237
  export {
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./escalation-schema.cjs"),p=async(o,i,n)=>{const t=await i.chat.completions.create({model:"inkeep-qa-expert",messages:o,tools:[{type:"function",function:{name:"provideAIAnnotations",description:"Provides AI confidence levels for the response",parameters:l.escalationSchema}},{type:"function",function:{name:"provideRecordsConsidered",description:"Provides records considered in generating the response",parameters:{type:"object"}}}],tool_choice:"auto"},n?{headers:n}:void 0),c=t.choices[0]?.message?.content;let s,r;const a=t.choices[0]?.message?.tool_calls||[];for(const e of a)e.function.name==="provideAIAnnotations"&&(s=JSON.parse(e.function.arguments).aiAnnotations),e.function.name==="provideRecordsConsidered"&&(r=JSON.parse(e.function.arguments).recordsConsidered??[]);return{answer:c||null,aiAnnotations:s,recordsConsidered:r,messages:o}};exports.generateQAModelResponse=p;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./escalation-schema.cjs"),p=async(o,c,n)=>{const t=await c.chat.completions.create({model:"inkeep-qa-expert",messages:o,tools:[{type:"function",function:{name:"provideAIAnnotations",description:"Provides AI confidence levels for the response",parameters:l.escalationSchema}},{type:"function",function:{name:"provideRecordsConsidered",description:"Provides records considered in generating the response",parameters:{type:"object"}}}],tool_choice:"auto"},n?{headers:n}:void 0),i=t.choices[0]?.message?.content;let s,r;const a=t.choices[0]?.message?.tool_calls||[];for(const e of a)e.function.name==="provideAIAnnotations"&&(s=JSON.parse(e.function.arguments).aiAnnotations),e.function.name==="provideRecordsConsidered"&&(r=JSON.parse(e.function.arguments).recordsConsidered??[]);return{answer:i||null,aiAnnotations:s,recordsConsidered:r,messages:o}};exports.generateQAModelResponse=p;
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react");function i(){const[o,e]=t.useState(!1),r=t.useCallback(async a=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(a),e(!0),setTimeout(()=>{e(!1)},1e3),!0}catch(s){return console.warn("Copy failed",s),e(!1),!1}},[]);return[o,r]}exports.useCopyToClipboard=i;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),i=require("marked");function s(){const[a,e]=r.useState(!1),l=r.useCallback(async o=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{const t=await i.marked.parse(o),n={"text/plain":new Blob([o],{type:"text/plain"}),"text/html":new Blob([t],{type:"text/html"})};return await navigator.clipboard.write([new ClipboardItem(n)]),e(!0),setTimeout(()=>{e(!1)},1e3),!0}catch(t){return console.warn("Copy failed",t),e(!1),!1}},[]);return[a,l]}exports.useCopyToClipboard=s;
@@ -1,19 +1,24 @@
1
1
  "use client";
2
- import { useState as n, useCallback as s } from "react";
3
- function l() {
4
- const [r, e] = n(!1), o = s(async (t) => {
2
+ import { useState as n, useCallback as i } from "react";
3
+ import { marked as p } from "marked";
4
+ function u() {
5
+ const [r, e] = n(!1), a = i(async (o) => {
5
6
  if (!navigator?.clipboard)
6
7
  return console.warn("Clipboard not supported"), !1;
7
8
  try {
8
- return await navigator.clipboard.writeText(t), e(!0), setTimeout(() => {
9
+ const t = await p.parse(o), l = {
10
+ "text/plain": new Blob([o], { type: "text/plain" }),
11
+ "text/html": new Blob([t], { type: "text/html" })
12
+ };
13
+ return await navigator.clipboard.write([new ClipboardItem(l)]), e(!0), setTimeout(() => {
9
14
  e(!1);
10
15
  }, 1e3), !0;
11
- } catch (a) {
12
- return console.warn("Copy failed", a), e(!1), !1;
16
+ } catch (t) {
17
+ return console.warn("Copy failed", t), e(!1), !1;
13
18
  }
14
19
  }, []);
15
- return [r, o];
20
+ return [r, a];
16
21
  }
17
22
  export {
18
- l as useCopyToClipboard
23
+ u as useCopyToClipboard
19
24
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),t=require("react"),B=require("../atoms/api/analytics/events.cjs"),f=require("./config-provider.cjs"),b=require("./user-provider.cjs"),p=t.createContext(void 0),x=({children:e})=>{const{baseSettings:n,componentType:r}=f.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:E,env:m}=n,{userProperties:v}=b.useUser(),u=t.useMemo(()=>({widgetLibraryVersion:"0.5.68",componentType:r,tags:a}),[r,a]),d=!E.optOutAllAnalytics&&m!=="development",g={logEvent:t.useCallback(async s=>{const o={...u,...s.properties},l={eventName:s.eventName,properties:o,userProperties:v},P=["modal_opened","modal_closed"].includes(s.eventName);if(d&&!P){if("conversation"in o&&!o.conversation?.id)return;B.logEvent(l,i,c)}n.onEvent?.(l)},[d,n,i,c,v,u])};return y.jsx(p.Provider,{value:g,children:e})},q=()=>{const e=t.useContext(p);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=x;exports.useBaseEvents=q;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),t=require("react"),B=require("../atoms/api/analytics/events.cjs"),f=require("./config-provider.cjs"),b=require("./user-provider.cjs"),p=t.createContext(void 0),x=({children:e})=>{const{baseSettings:n,componentType:r}=f.useInkeepConfig(),{apiKey:i,analyticsApiBaseUrl:c,tags:a,privacyPreferences:E,env:m}=n,{userProperties:v}=b.useUser(),u=t.useMemo(()=>({widgetLibraryVersion:"0.5.70",componentType:r,tags:a}),[r,a]),d=!E.optOutAllAnalytics&&m!=="development",g={logEvent:t.useCallback(async s=>{const o={...u,...s.properties},l={eventName:s.eventName,properties:o,userProperties:v},P=["modal_opened","modal_closed"].includes(s.eventName);if(d&&!P){if("conversation"in o&&!o.conversation?.id)return;B.logEvent(l,i,c)}n.onEvent?.(l)},[d,n,i,c,v,u])};return y.jsx(p.Provider,{value:g,children:e})},q=()=>{const e=t.useContext(p);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=x;exports.useBaseEvents=q;
@@ -7,7 +7,7 @@ import { useUser as w } from "./user-provider.js";
7
7
  const l = B(void 0), _ = ({ children: e }) => {
8
8
  const { baseSettings: t, componentType: s } = b(), { apiKey: r, analyticsApiBaseUrl: i, tags: a, privacyPreferences: u, env: d } = t, { userProperties: c } = w(), v = y(
9
9
  () => ({
10
- widgetLibraryVersion: "0.5.68",
10
+ widgetLibraryVersion: "0.5.70",
11
11
  componentType: s,
12
12
  tags: a
13
13
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/cxkit-primitives",
3
- "version": "0.5.68",
3
+ "version": "0.5.70",
4
4
  "description": "",
5
5
  "license": "Inkeep, Inc. Customer License (IICL) v1.1",
6
6
  "homepage": "",
@@ -46,6 +46,7 @@
46
46
  "aria-hidden": "^1.2.4",
47
47
  "dequal": "^2.0.3",
48
48
  "humps": "2.0.1",
49
+ "marked": "^15.0.9",
49
50
  "merge-anything": "5.1.7",
50
51
  "openai": "4.78.1",
51
52
  "prism-react-renderer": "2.4.1",
@@ -59,9 +60,9 @@
59
60
  "remark-gfm": "^4.0.1",
60
61
  "unist-util-visit": "^5.0.0",
61
62
  "use-sync-external-store": "^1.4.0",
62
- "@inkeep/cxkit-color-mode": "0.5.68",
63
- "@inkeep/cxkit-theme": "0.5.68",
64
- "@inkeep/cxkit-types": "0.5.68"
63
+ "@inkeep/cxkit-color-mode": "0.5.70",
64
+ "@inkeep/cxkit-theme": "0.5.70",
65
+ "@inkeep/cxkit-types": "0.5.70"
65
66
  },
66
67
  "devDependencies": {
67
68
  "@biomejs/biome": "1.9.4",