@inkeep/agents-ui 0.14.16 → 0.14.17

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,3 +1,3 @@
1
1
  "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const X=require("@ai-sdk/react"),Y=require("ai"),t=require("react"),Z=require("../../providers/config-provider.cjs"),ee=require("../../hooks/use-media-query.cjs"),te=require("../../utils/generate-uid.cjs"),se=require("../../providers/base-events-provider.cjs"),ne=require("../../providers/chat-form-provider.cjs"),re=require("../../providers/widget-provider.cjs"),ae=require("@radix-ui/react-use-controllable-state"),oe=require("../../hooks/use-streaming-events.cjs"),F=`Hmm..
2
2
 
3
- It seems I might be having some issues right now. Please clear the chat and try again.`,ie=()=>{const{baseSettings:f,aiChatSettings:o}=Z.useInkeepConfig(),[n="",v]=ae.useControllableState({prop:o.conversationId,defaultProp:o.conversationId??""}),{logEvent:i}=se.useBaseEvents(),{setConversationId:R,emitToParent:E}=oe.useStreamingEvents(),[a,u]=t.useState(""),P=e=>u(e.target.value),{filters:S}=f,{onInputMessageChange:k,filters:C,agentUrl:A,context:D,headers:x,apiKey:I}=o,N=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${f.organizationDisplayName??"Administrator"}`;default:return F}},[T,U]=t.useState({}),[B,l]=t.useState([]),[O,b]=t.useState(null),{messages:g,sendMessage:K,status:y,setMessages:w,stop:L,error:d}=X.useChat({transport:new Y.DefaultChatTransport({api:A,headers:{...I?{Authorization:`Bearer ${I}`}:{},...x},body:{requestContext:D}}),onData(e){E(e.type,e.data)},async onFinish(){E("completion",{conversationId:n}),await i({eventName:"assistant_message_received",properties:{conversationId:n}}),i({eventName:"assistant_answer_displayed",properties:{conversationId:n}})},onError(e){console.log("onError",e.message),w(c=>{const r=[...c],s=r[r.length-1];return s&&(s.parts=[{type:"text",text:N(e)}]),r})}}),M=y==="submitted",W=y==="streaming",$=g.length===0,m=!a.trim()||M,z=ee.useMediaQuery("(max-width: 768px)"),[G,p]=t.useState(null);t.useEffect(()=>{d&&p(d)},[d]);const H=()=>p(null),_=t.useRef(null);t.useEffect(()=>{k?.(a)},[a]);const Q=e=>{e.key==="Enter"&&!e.shiftKey&&!m&&!e.nativeEvent.isComposing&&(e.preventDefault(),h())},h=async(e=a)=>{if(m&&(!e||e.trim().length===0))return;l([]),u(""),await i({eventName:"user_message_submitted",properties:{conversationId:n}});const c=S||C?JSON.stringify({...S,...C}):void 0,r={};c&&(r["inkeep-filters"]=c);let s=n;s||(s=`conv_${te.generateUid(16)}`,v(s)),R(s),K({text:e},{headers:r,body:{conversationId:s}})},j=()=>{L()},q=()=>{H(),w([]),v(""),U({}),l([]),b(null),i({eventName:"chat_clear_button_clicked",properties:{conversationId:n}})},{openForm:J}=ne.useChatForm(),V=re.useWidget();return t.useImperativeHandle(o.chatFunctionsRef,()=>({submitMessage:h,updateInputMessage(e){u(e)},clearChat:q,openForm:e=>{V?.setView("chat"),J(e,void 0)},focusInput:()=>{_.current?.focus()}})),{messages:g,isLoading:M,isStreaming:W,error:G,setError:p,isSubmitDisabled:m,input:a,handleInputChange:P,handleInputKeyDown:Q,handleSubmit:h,stop:j,clear:q,messageButtons:T,isEmpty:g.length===0,inputRef:_,isMobile:z,messageAttachments:B,setMessageAttachments:l,selectedWorkflow:O,setSelectedWorkflow:b,isNewChat:$,conversationId:n}};exports.DEFAULT_ERROR_MESSAGE=F;exports.useInkeepChat=ie;
3
+ It seems I might be having some issues right now. Please clear the chat and try again.`,ie=()=>{const{baseSettings:v,aiChatSettings:o}=Z.useInkeepConfig(),[s="",E]=ae.useControllableState({prop:o.conversationId,defaultProp:o.conversationId??""}),{logEvent:i}=se.useBaseEvents(),{setConversationId:R,emitToParent:u}=oe.useStreamingEvents(),[a,l]=t.useState(""),P=e=>l(e.target.value),{filters:S}=v,{onInputMessageChange:k,filters:b,agentUrl:A,context:D,headers:x,apiKey:C}=o,N=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${v.organizationDisplayName??"Administrator"}`;default:return F}},[T,U]=t.useState({}),[B,d]=t.useState([]),[O,I]=t.useState(null),{messages:g,sendMessage:K,status:y,setMessages:w,stop:L,error:m}=X.useChat({transport:new Y.DefaultChatTransport({api:A,headers:{...C?{Authorization:`Bearer ${C}`}:{},...x},body:{requestContext:D}}),onData(e){u(e.type,e.data)},async onFinish(){u("completion",{conversationId:s}),await i({eventName:"assistant_message_received",properties:{conversationId:s}}),i({eventName:"assistant_answer_displayed",properties:{conversationId:s}})},onError(e){console.log("onError",e.message),w(c=>{const r=[...c],n=r[r.length-1];return n&&(n.parts=[{type:"text",text:N(e)}]),r})}}),M=y==="submitted",W=y==="streaming",$=g.length===0,p=!a.trim()||M,z=ee.useMediaQuery("(max-width: 768px)"),[G,h]=t.useState(null);t.useEffect(()=>{m&&h(m)},[m]);const H=()=>h(null),_=t.useRef(null);t.useEffect(()=>{k?.(a)},[a]);const Q=e=>{e.key==="Enter"&&!e.shiftKey&&!p&&!e.nativeEvent.isComposing&&(e.preventDefault(),f())},f=async(e=a)=>{if(p&&(!e||e.trim().length===0))return;d([]),l(""),await i({eventName:"user_message_submitted",properties:{conversationId:s}});const c=S||b?JSON.stringify({...S,...b}):void 0,r={};c&&(r["inkeep-filters"]=c);let n=s;n||(n=`conv_${te.generateUid(16)}`,E(n)),R(n),K({text:e},{headers:r,body:{conversationId:n}})},j=()=>{L().then(()=>{u("aborted",{conversationId:s})})},q=()=>{H(),w([]),E(""),U({}),d([]),I(null),i({eventName:"chat_clear_button_clicked",properties:{conversationId:s}})},{openForm:J}=ne.useChatForm(),V=re.useWidget();return t.useImperativeHandle(o.chatFunctionsRef,()=>({submitMessage:f,updateInputMessage(e){l(e)},clearChat:q,openForm:e=>{V?.setView("chat"),J(e,void 0)},focusInput:()=>{_.current?.focus()}})),{messages:g,isLoading:M,isStreaming:W,error:G,setError:h,isSubmitDisabled:p,input:a,handleInputChange:P,handleInputKeyDown:Q,handleSubmit:f,stop:j,clear:q,messageButtons:T,isEmpty:g.length===0,inputRef:_,isMobile:z,messageAttachments:B,setMessageAttachments:d,selectedWorkflow:O,setSelectedWorkflow:I,isNewChat:$,conversationId:s}};exports.DEFAULT_ERROR_MESSAGE=F;exports.useInkeepChat=ie;
@@ -12,41 +12,41 @@ import { useControllableState as ie } from "@radix-ui/react-use-controllable-sta
12
12
  import { useStreamingEvents as ce } from "../../hooks/use-streaming-events.js";
13
13
  const me = `Hmm..
14
14
 
15
- It seems I might be having some issues right now. Please clear the chat and try again.`, ye = () => {
16
- const { baseSettings: f, aiChatSettings: a } = te(), [s = "", v] = ie({
15
+ It seems I might be having some issues right now. Please clear the chat and try again.`, be = () => {
16
+ const { baseSettings: v, aiChatSettings: a } = te(), [t = "", I] = ie({
17
17
  prop: a.conversationId,
18
18
  defaultProp: a.conversationId ?? ""
19
- }), { logEvent: i } = oe(), { setConversationId: k, emitToParent: I } = ce(), [o, m] = r(""), D = (e) => m(e.target.value), {
19
+ }), { logEvent: i } = oe(), { setConversationId: k, emitToParent: m } = ce(), [o, u] = r(""), D = (e) => u(e.target.value), {
20
20
  /* shouldBypassCaptcha, */
21
21
  filters: C
22
- } = f, {
22
+ } = v, {
23
23
  onInputMessageChange: N,
24
24
  filters: E,
25
25
  agentUrl: A,
26
26
  context: R,
27
27
  headers: B,
28
- apiKey: y
28
+ apiKey: b
29
29
  } = a, P = (e) => {
30
30
  switch (e.code) {
31
31
  case 400:
32
32
  return e.message;
33
33
  case 403:
34
- return `There seems to be a configuration error. Please contact ${f.organizationDisplayName ?? "Administrator"}`;
34
+ return `There seems to be a configuration error. Please contact ${v.organizationDisplayName ?? "Administrator"}`;
35
35
  default:
36
36
  return me;
37
37
  }
38
- }, [T, K] = r({}), [U, u] = r([]), [W, b] = r(null), {
39
- messages: l,
38
+ }, [T, K] = r({}), [U, l] = r([]), [W, y] = r(null), {
39
+ messages: p,
40
40
  sendMessage: $,
41
41
  status: w,
42
42
  setMessages: S,
43
43
  stop: z,
44
- error: p
44
+ error: g
45
45
  } = X({
46
46
  transport: new Y({
47
47
  api: A,
48
48
  headers: {
49
- ...y ? { Authorization: `Bearer ${y}` } : {},
49
+ ...b ? { Authorization: `Bearer ${b}` } : {},
50
50
  ...B
51
51
  },
52
52
  body: {
@@ -54,43 +54,43 @@ It seems I might be having some issues right now. Please clear the chat and try
54
54
  }
55
55
  }),
56
56
  onData(e) {
57
- I(e.type, e.data);
57
+ m(e.type, e.data);
58
58
  },
59
59
  async onFinish() {
60
- I("completion", { conversationId: s }), await i({
60
+ m("completion", { conversationId: t }), await i({
61
61
  eventName: "assistant_message_received",
62
62
  properties: {
63
- conversationId: s
63
+ conversationId: t
64
64
  }
65
65
  }), i({
66
66
  eventName: "assistant_answer_displayed",
67
67
  properties: {
68
- conversationId: s
68
+ conversationId: t
69
69
  }
70
70
  });
71
71
  },
72
72
  onError(e) {
73
73
  console.log("onError", e.message), S((c) => {
74
- const n = [...c], t = n[n.length - 1];
75
- return t && (t.parts = [{ type: "text", text: P(e) }]), n;
74
+ const n = [...c], s = n[n.length - 1];
75
+ return s && (s.parts = [{ type: "text", text: P(e) }]), n;
76
76
  });
77
77
  }
78
- }), M = w === "submitted", H = w === "streaming", L = l.length === 0, g = !o.trim() || M, O = se("(max-width: 768px)"), [q, d] = r(null);
78
+ }), M = w === "submitted", H = w === "streaming", L = p.length === 0, d = !o.trim() || M, O = se("(max-width: 768px)"), [q, h] = r(null);
79
79
  F(() => {
80
- p && d(p);
81
- }, [p]);
82
- const G = () => d(null), _ = Z(null);
80
+ g && h(g);
81
+ }, [g]);
82
+ const G = () => h(null), _ = Z(null);
83
83
  F(() => {
84
84
  N?.(o);
85
85
  }, [o]);
86
86
  const J = (e) => {
87
- e.key === "Enter" && !e.shiftKey && !g && !e.nativeEvent.isComposing && (e.preventDefault(), h());
88
- }, h = async (e = o) => {
89
- if (g && (!e || e.trim().length === 0)) return;
90
- u([]), m(""), await i({
87
+ e.key === "Enter" && !e.shiftKey && !d && !e.nativeEvent.isComposing && (e.preventDefault(), f());
88
+ }, f = async (e = o) => {
89
+ if (d && (!e || e.trim().length === 0)) return;
90
+ l([]), u(""), await i({
91
91
  eventName: "user_message_submitted",
92
92
  properties: {
93
- conversationId: s
93
+ conversationId: t
94
94
  }
95
95
  });
96
96
  const c = C || E ? JSON.stringify({
@@ -98,8 +98,8 @@ It seems I might be having some issues right now. Please clear the chat and try
98
98
  ...E
99
99
  }) : void 0, n = {};
100
100
  c && (n["inkeep-filters"] = c);
101
- let t = s;
102
- t || (t = `conv_${ne(16)}`, v(t)), k(t), $(
101
+ let s = t;
102
+ s || (s = `conv_${ne(16)}`, I(s)), k(s), $(
103
103
  // { ...userMessage, files },
104
104
  // { ...userMessage, },
105
105
  {
@@ -108,24 +108,26 @@ It seems I might be having some issues right now. Please clear the chat and try
108
108
  {
109
109
  headers: n,
110
110
  body: {
111
- conversationId: t
111
+ conversationId: s
112
112
  }
113
113
  }
114
114
  );
115
115
  }, Q = () => {
116
- z();
116
+ z().then(() => {
117
+ m("aborted", { conversationId: t });
118
+ });
117
119
  }, x = () => {
118
- G(), S([]), v(""), K({}), u([]), b(null), i({
120
+ G(), S([]), I(""), K({}), l([]), y(null), i({
119
121
  eventName: "chat_clear_button_clicked",
120
122
  properties: {
121
- conversationId: s
123
+ conversationId: t
122
124
  }
123
125
  });
124
126
  }, { openForm: V } = re(), j = ae();
125
127
  return ee(a.chatFunctionsRef, () => ({
126
- submitMessage: h,
128
+ submitMessage: f,
127
129
  updateInputMessage(e) {
128
- m(e);
130
+ u(e);
129
131
  },
130
132
  clearChat: x,
131
133
  openForm: (e) => {
@@ -135,32 +137,32 @@ It seems I might be having some issues right now. Please clear the chat and try
135
137
  _.current?.focus();
136
138
  }
137
139
  })), {
138
- messages: l,
140
+ messages: p,
139
141
  isLoading: M,
140
142
  isStreaming: H,
141
143
  error: q,
142
- setError: d,
143
- isSubmitDisabled: g,
144
+ setError: h,
145
+ isSubmitDisabled: d,
144
146
  input: o,
145
147
  handleInputChange: D,
146
148
  handleInputKeyDown: J,
147
- handleSubmit: h,
149
+ handleSubmit: f,
148
150
  stop: Q,
149
151
  clear: x,
150
152
  messageButtons: T,
151
- isEmpty: l.length === 0,
153
+ isEmpty: p.length === 0,
152
154
  inputRef: _,
153
155
  isMobile: O,
154
156
  // Additional state for attachments and workflow
155
157
  messageAttachments: U,
156
- setMessageAttachments: u,
158
+ setMessageAttachments: l,
157
159
  selectedWorkflow: W,
158
- setSelectedWorkflow: b,
160
+ setSelectedWorkflow: y,
159
161
  isNewChat: L,
160
- conversationId: s
162
+ conversationId: t
161
163
  };
162
164
  };
163
165
  export {
164
166
  me as DEFAULT_ERROR_MESSAGE,
165
- ye as useInkeepChat
167
+ be as useInkeepChat
166
168
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react/jsx-runtime"),t=require("react"),l=require("./config-provider.cjs"),a=t.createContext(void 0),p=({children:e})=>{const{baseSettings:s,componentType:n}=l.useInkeepConfig(),{tags:o,analyticsProperties:r}=s,i=t.useMemo(()=>({widgetLibraryVersion:"0.14.15",componentType:n,tags:o}),[n,o]),u={logEvent:t.useCallback(async c=>{const v={...i,...c.properties,...r},d={eventName:c.eventName,properties:v};return s.onEvent?.(d)},[s,i,r])};return E.jsx(a.Provider,{value:u,children:e})},g=()=>{const e=t.useContext(a);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=p;exports.useBaseEvents=g;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react/jsx-runtime"),t=require("react"),l=require("./config-provider.cjs"),a=t.createContext(void 0),p=({children:e})=>{const{baseSettings:s,componentType:n}=l.useInkeepConfig(),{tags:o,analyticsProperties:r}=s,i=t.useMemo(()=>({widgetLibraryVersion:"0.14.16",componentType:n,tags:o}),[n,o]),u={logEvent:t.useCallback(async c=>{const v={...i,...c.properties,...r},d={eventName:c.eventName,properties:v};return s.onEvent?.(d)},[s,i,r])};return E.jsx(a.Provider,{value:u,children:e})},g=()=>{const e=t.useContext(a);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=p;exports.useBaseEvents=g;
@@ -5,7 +5,7 @@ import { useInkeepConfig as g } from "./config-provider.js";
5
5
  const a = d(void 0), P = ({ children: e }) => {
6
6
  const { baseSettings: t, componentType: o } = g(), { tags: s, analyticsProperties: n } = t, r = u(
7
7
  () => ({
8
- widgetLibraryVersion: "0.14.15",
8
+ widgetLibraryVersion: "0.14.16",
9
9
  componentType: o,
10
10
  tags: s
11
11
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-ui",
3
- "version": "0.14.16",
3
+ "version": "0.14.17",
4
4
  "description": "",
5
5
  "homepage": "",
6
6
  "repository": {