@inkeep/agents-ui 0.14.16 → 0.14.18

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 n=require("react"),v=require("./use-inkeep-chat.cjs"),E=require("../../../types/message.cjs");function L(u,p,g){const[l,R]=n.useState([]),[h,A]=n.useState(new Map),[d,k]=n.useState(Date.now()),[D,y]=n.useState(!1),S=n.useRef(0),x=n.useRef(0),w=n.useRef([]),f=n.useRef(h);f.current=h;const C=n.useCallback(()=>{const t=[];let e="",o=[],c=!1;u.length>S.current&&(k(Date.now()),S.current=u.length),x.current=0;const m=new Map,i=(s=!1)=>{if(o.length>0){const r=`group-${x.current++}`,a=f.current.get(r);a?m.set(r,{...a,isCompleted:s}):m.set(r,{isCompleted:s}),t.push({type:"summary-group",summaries:[...o],groupKey:r}),o=[]}};for(const s of u)if(s.type==="text")i(!0),e+=s.text||"";else if(s.type==="data-summary")e.trim()&&(t.push({type:"text",text:e}),e=""),o.push(s.data);else if(s.type==="data-operation"){e.trim()&&(t.push({type:"text",text:e}),e="");const r=s.data;if(r?.type)switch(r.type){case"agent_initializing":break;case"completion":i(!0);break;case"error":{i(!0);const a=r.message||"Unknown error";console.warn("Data operation error:",a),g(new Error(a)),c||(t.push({type:"text",text:v.DEFAULT_ERROR_MESSAGE}),c=!0);break}default:{const{type:a,label:b}=r;o.push({type:a,label:b});break}}}else if(s.type==="data-artifact")if(s.data?.type?.toLowerCase()===E.CITATION_ARTIFACT_TYPE){const r=s.data,a=r.artifactSummary||{title:r.name};e+=` ^${a?.title||r.name}^`}else e.trim()&&(t.push({type:"text",text:e}),e=""),t.push(s);else s.type==="data-component"&&(e.trim()&&(t.push({type:"text",text:e}),e=""),i(!0),t.push(s));return i(!p),e.trim()&&t.push({type:"text",text:e}),{processed:t,newTimings:m}},[u,p,g]);n.useEffect(()=>{if(w.current===u)return;w.current=u;const{processed:t,newTimings:e}=C();R(t),(e.size!==f.current.size||Array.from(e.entries()).some(([c,m])=>{const i=f.current.get(c);return!i||i.isCompleted!==m.isCompleted}))&&A(e)},[C,u]);const T=n.useCallback(()=>{const t=Date.now()-d,e=Array.from(f.current.values()).some(c=>!c.isCompleted),o=t>1e3&&!e;y(o)},[d]);n.useEffect(()=>{if(!p){y(!1);return}if(!(l.length>0)){y(!1);return}const e=setInterval(T,200);return()=>clearInterval(e)},[p,T,l.length]);const P=n.useMemo(()=>!(l.length>0),[l.length]);return{processedParts:l,summaryTimings:h,shouldShowInitialLoading:P,shouldShowStreamDelayLoading:D}}exports.useStreamProcessor=L;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),E=require("./use-inkeep-chat.cjs"),v=require("../../../types/message.cjs");function L(f,u,g){const[m,A]=r.useState([]),[h,d]=r.useState(new Map),[C,k]=r.useState(Date.now()),[D,y]=r.useState(!1),w=r.useRef(0),x=r.useRef(0),S=r.useRef([]),p=r.useRef(h);p.current=h;const T=r.useCallback(()=>{const t=[];let e="",a=[],i=!1;f.length>w.current&&(k(Date.now()),w.current=f.length),x.current=0;const c=new Map,l=(s=!1)=>{if(a.length>0){const n=`group-${x.current++}`,o=p.current.get(n);o?c.set(n,{...o,isCompleted:s}):c.set(n,{isCompleted:s}),t.push({type:"summary-group",summaries:[...a],groupKey:n}),a=[]}};for(const s of f)if(s.type==="text")l(!0),e+=s.text||"";else if(s.type==="data-summary")e.trim()&&(t.push({type:"text",text:e}),e=""),a.push(s.data);else if(s.type==="data-operation"){e.trim()&&(t.push({type:"text",text:e}),e="");const n=s.data;if(n?.type)switch(n.type){case"agent_initializing":break;case"completion":l(!0);break;case"error":{l(!0);const o=n.message||"Unknown error";console.warn("Data operation error:",o),g(new Error(o)),i||(t.push({type:"text",text:E.DEFAULT_ERROR_MESSAGE}),i=!0);break}default:{const{type:o,label:b}=n;a.push({type:o,label:b});break}}}else if(s.type==="data-artifact")if(s.data?.type?.toLowerCase()===v.CITATION_ARTIFACT_TYPE){const n=s.data,o=n.artifactSummary||{title:n.name};e+=` ^${o?.title||n.name}^`}else e.trim()&&(t.push({type:"text",text:e}),e=""),t.push(s);else s.type==="data-component"&&(e.trim()&&(t.push({type:"text",text:e}),e=""),l(!0),t.push(s));return l(!u),e.trim()&&t.push({type:"text",text:e}),{processed:t,newTimings:c}},[f,u,g]);r.useEffect(()=>{if(S.current===f)return;S.current=f;const{processed:t,newTimings:e}=T();A(t),(e.size!==p.current.size||Array.from(e.entries()).some(([i,c])=>{const l=p.current.get(i);return!l||l.isCompleted!==c.isCompleted}))&&d(e)},[T,f]),r.useEffect(()=>{u||d(t=>{const e=new Map(t);let a=!1;for(const[i,c]of e.entries())c.isCompleted||(e.set(i,{...c,isCompleted:!0}),a=!0);return a?e:t})},[u]);const R=r.useCallback(()=>{const t=Date.now()-C,e=Array.from(p.current.values()).some(i=>!i.isCompleted),a=t>1e3&&!e;y(a)},[C]);r.useEffect(()=>{if(!u){y(!1);return}if(!(m.length>0)){y(!1);return}const e=setInterval(R,200);return()=>clearInterval(e)},[u,R,m.length]);const P=r.useMemo(()=>!!(!(m.length>0)&&u),[m.length,u]);return{processedParts:m,summaryTimings:h,shouldShowInitialLoading:P,shouldShowStreamDelayLoading:D}}exports.useStreamProcessor=L;
@@ -1,101 +1,112 @@
1
1
  "use client";
2
- import { useState as p, useRef as h, useCallback as D, useEffect as R, useMemo as I } from "react";
3
- import { DEFAULT_ERROR_MESSAGE as M } from "./use-inkeep-chat.js";
2
+ import { useState as p, useRef as h, useCallback as k, useEffect as d, useMemo as b } from "react";
3
+ import { DEFAULT_ERROR_MESSAGE as I } from "./use-inkeep-chat.js";
4
4
  import { CITATION_ARTIFACT_TYPE as _ } from "../../../types/message.js";
5
- function O(i, f, d) {
6
- const [u, k] = p([]), [y, v] = p(/* @__PURE__ */ new Map()), [x, L] = p(Date.now()), [P, g] = p(!1), w = h(0), C = h(0), S = h([]), l = h(y);
7
- l.current = y;
8
- const T = D(() => {
5
+ function O(l, a, w) {
6
+ const [f, L] = p([]), [y, x] = p(/* @__PURE__ */ new Map()), [C, P] = p(Date.now()), [v, g] = p(!1), T = h(0), A = h(0), D = h([]), m = h(y);
7
+ m.current = y;
8
+ const S = k(() => {
9
9
  const e = [];
10
- let t = "", a = [], c = !1;
11
- i.length > w.current && (L(Date.now()), w.current = i.length), C.current = 0;
12
- const m = /* @__PURE__ */ new Map(), o = (r = !1) => {
13
- if (a.length > 0) {
14
- const s = `group-${C.current++}`, n = l.current.get(s);
15
- n ? m.set(s, {
16
- ...n,
17
- isCompleted: r
18
- }) : m.set(s, {
19
- isCompleted: r
10
+ let t = "", n = [], i = !1;
11
+ l.length > T.current && (P(Date.now()), T.current = l.length), A.current = 0;
12
+ const c = /* @__PURE__ */ new Map(), u = (s = !1) => {
13
+ if (n.length > 0) {
14
+ const r = `group-${A.current++}`, o = m.current.get(r);
15
+ o ? c.set(r, {
16
+ ...o,
17
+ isCompleted: s
18
+ }) : c.set(r, {
19
+ isCompleted: s
20
20
  }), e.push({
21
21
  type: "summary-group",
22
- summaries: [...a],
23
- groupKey: s
24
- }), a = [];
22
+ summaries: [...n],
23
+ groupKey: r
24
+ }), n = [];
25
25
  }
26
26
  };
27
- for (const r of i)
28
- if (r.type === "text")
29
- o(!0), t += r.text || "";
30
- else if (r.type === "data-summary")
31
- t.trim() && (e.push({ type: "text", text: t }), t = ""), a.push(r.data);
32
- else if (r.type === "data-operation") {
27
+ for (const s of l)
28
+ if (s.type === "text")
29
+ u(!0), t += s.text || "";
30
+ else if (s.type === "data-summary")
31
+ t.trim() && (e.push({ type: "text", text: t }), t = ""), n.push(s.data);
32
+ else if (s.type === "data-operation") {
33
33
  t.trim() && (e.push({ type: "text", text: t }), t = "");
34
- const s = r.data;
35
- if (s?.type)
36
- switch (s.type) {
34
+ const r = s.data;
35
+ if (r?.type)
36
+ switch (r.type) {
37
37
  case "agent_initializing":
38
38
  break;
39
39
  case "completion":
40
- o(!0);
40
+ u(!0);
41
41
  break;
42
42
  case "error": {
43
- o(!0);
44
- const n = s.message || "Unknown error";
45
- console.warn("Data operation error:", n), d(new Error(n)), c || (e.push({ type: "text", text: M }), c = !0);
43
+ u(!0);
44
+ const o = r.message || "Unknown error";
45
+ console.warn("Data operation error:", o), w(new Error(o)), i || (e.push({ type: "text", text: I }), i = !0);
46
46
  break;
47
47
  }
48
48
  default: {
49
- const { type: n, label: b } = s;
50
- a.push({ type: n, label: b });
49
+ const { type: o, label: M } = r;
50
+ n.push({ type: o, label: M });
51
51
  break;
52
52
  }
53
53
  }
54
- } else if (r.type === "data-artifact")
55
- if (r.data?.type?.toLowerCase() === _) {
56
- const s = r.data, n = s.artifactSummary || {
57
- title: s.name
54
+ } else if (s.type === "data-artifact")
55
+ if (s.data?.type?.toLowerCase() === _) {
56
+ const r = s.data, o = r.artifactSummary || {
57
+ title: r.name
58
58
  };
59
- t += ` ^${n?.title || s.name}^`;
59
+ t += ` ^${o?.title || r.name}^`;
60
60
  } else
61
- t.trim() && (e.push({ type: "text", text: t }), t = ""), e.push(r);
62
- else r.type === "data-component" && (t.trim() && (e.push({ type: "text", text: t }), t = ""), o(!0), e.push(r));
63
- return o(!f), t.trim() && e.push({ type: "text", text: t }), { processed: e, newTimings: m };
64
- }, [i, f, d]);
65
- R(() => {
66
- if (S.current === i)
61
+ t.trim() && (e.push({ type: "text", text: t }), t = ""), e.push(s);
62
+ else s.type === "data-component" && (t.trim() && (e.push({ type: "text", text: t }), t = ""), u(!0), e.push(s));
63
+ return u(!a), t.trim() && e.push({ type: "text", text: t }), { processed: e, newTimings: c };
64
+ }, [l, a, w]);
65
+ d(() => {
66
+ if (D.current === l)
67
67
  return;
68
- S.current = i;
69
- const { processed: e, newTimings: t } = T();
70
- k(e), (t.size !== l.current.size || Array.from(t.entries()).some(([c, m]) => {
71
- const o = l.current.get(c);
72
- return !o || o.isCompleted !== m.isCompleted;
73
- })) && v(t);
74
- }, [T, i]);
75
- const A = D(() => {
76
- const e = Date.now() - x, t = Array.from(l.current.values()).some(
77
- (c) => !c.isCompleted
78
- ), a = e > 1e3 && !t;
79
- g(a);
80
- }, [x]);
81
- R(() => {
82
- if (!f) {
68
+ D.current = l;
69
+ const { processed: e, newTimings: t } = S();
70
+ L(e), (t.size !== m.current.size || Array.from(t.entries()).some(([i, c]) => {
71
+ const u = m.current.get(i);
72
+ return !u || u.isCompleted !== c.isCompleted;
73
+ })) && x(t);
74
+ }, [S, l]), d(() => {
75
+ a || x((e) => {
76
+ const t = new Map(e);
77
+ let n = !1;
78
+ for (const [i, c] of t.entries())
79
+ c.isCompleted || (t.set(i, {
80
+ ...c,
81
+ isCompleted: !0
82
+ }), n = !0);
83
+ return n ? t : e;
84
+ });
85
+ }, [a]);
86
+ const R = k(() => {
87
+ const e = Date.now() - C, t = Array.from(m.current.values()).some(
88
+ (i) => !i.isCompleted
89
+ ), n = e > 1e3 && !t;
90
+ g(n);
91
+ }, [C]);
92
+ d(() => {
93
+ if (!a) {
83
94
  g(!1);
84
95
  return;
85
96
  }
86
- if (!(u.length > 0)) {
97
+ if (!(f.length > 0)) {
87
98
  g(!1);
88
99
  return;
89
100
  }
90
- const t = setInterval(A, 200);
101
+ const t = setInterval(R, 200);
91
102
  return () => clearInterval(t);
92
- }, [f, A, u.length]);
93
- const E = I(() => !(u.length > 0), [u.length]);
103
+ }, [a, R, f.length]);
104
+ const E = b(() => !!(!(f.length > 0) && a), [f.length, a]);
94
105
  return {
95
- processedParts: u,
106
+ processedParts: f,
96
107
  summaryTimings: y,
97
108
  shouldShowInitialLoading: E,
98
- shouldShowStreamDelayLoading: P
109
+ shouldShowStreamDelayLoading: v
99
110
  };
100
111
  }
101
112
  export {
@@ -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.17",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.17",
9
9
  componentType: o,
10
10
  tags: s
11
11
  }),
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),t=require("lucide-react"),x=a=>{const{type:s,label:r}=a;return r||s.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase())},d={agent_generate:e.jsx(t.RefreshCw,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),agent_reasoning:e.jsx(t.Brain,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),tool_call:e.jsx(t.Hammer,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),tool_result:e.jsx(t.Hammer,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),transfer:e.jsx(t.ArrowRight,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),delegation_sent:e.jsx(t.Forward,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),delegation_returned:e.jsx(t.CheckCheck,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),artifact_saved:e.jsx(t.Download,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),error:e.jsx(t.TriangleAlert,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),agent_initializing:e.jsx(t.CircleDot,{className:"w-3 h-3 animate-spin"}),completion:e.jsx(t.CheckCheck,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),default:e.jsx(t.Dot,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"})},h={retrieve:e.jsx(t.Search,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),action:e.jsx(t.CheckCheck,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),default:e.jsx(t.Dot,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),...d},p=n.memo(({summary:a,index:s,showConnector:r})=>{const l=n.useMemo(()=>a.details?JSON.stringify(a.details,null,2):null,[a.details]),o=n.useMemo(()=>x(a),[a]),i=n.useMemo(()=>h[a.type]||h.default,[a.type]);return e.jsxs("div",{className:"flex items-start gap-2 text-xs relative",children:[r&&e.jsx("div",{className:"absolute left-1.5 top-4 bottom-0 w-px bg-gray-200 dark:bg-white-alpha-200 -mb-3"}),e.jsx("div",{className:"flex items-center justify-center w-3 h-3 relative z-10 mt-0.5",children:i}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:" text-gray-700 dark:text-white-alpha-600",children:o}),l&&e.jsx("pre",{className:"mt-2 text-xs whitespace-pre-wrap font-mono bg-gray-50 dark:bg-gray-dark-900 p-2 rounded-md px-3 py-2",children:l})]})]},`op-${a.type}-${s}`)}),m=n.memo(({summaries:a,isCompleted:s})=>{const[r,l]=n.useState(!s);n.useEffect(()=>{let i;return s?i=setTimeout(()=>{l(!1)},1e3):l(!0),()=>{i&&clearTimeout(i)}},[s]);const o=n.useCallback(()=>{l(!r)},[r]);return e.jsxs("div",{className:"flex flex-col items-start mb-2.5 mt-2.5 first:mt-1 relative",children:[e.jsx("button",{type:"button",onClick:o,"data-expanded":r,className:"inline-flex items-center group gap-2 text-xs text-gray-500 dark:text-white-alpha-600 hover:text-gray-700 dark:hover:text-white-alpha-700 transition-colors cursor-pointer",children:s?e.jsxs(e.Fragment,{children:[e.jsx(t.Check,{className:"check-icon w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 absolute opacity-100 group-hover:opacity-0 group-data-[expanded=true]:opacity-0"}),e.jsx(t.ChevronRight,{className:"chevron-icon w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform opacity-0 rotate-0 group-hover:opacity-100 group-data-[expanded=true]:opacity-100 group-data-[expanded=true]:rotate-90"}),e.jsx("span",{className:"font-medium",children:"Completed"})]}):e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{className:"font-medium",children:"Thinking..."})]})}),e.jsx("div",{"data-expanded":r,className:"overflow-hidden transition-all duration-300 ease-in-out data-[expanded=true]:opacity-100 data-[expanded=false]:max-h-0 data-[expanded=false]:opacity-0 max-w-full",children:e.jsx("div",{className:"pb-2 mt-1.5 space-y-3 relative",children:a.map((i,c)=>e.jsx(p,{summary:i,index:c,showConnector:a.length>1&&c<a.length-1},`op-${i.type}-${c}`))})})]})});exports.DataSummaryGroup=m;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),t=require("lucide-react"),h=a=>{const{type:s,label:r}=a;return r||s.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase())},x={agent_generate:e.jsx(t.RefreshCw,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),agent_reasoning:e.jsx(t.Brain,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),tool_call:e.jsx(t.Hammer,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),tool_result:e.jsx(t.Hammer,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),transfer:e.jsx(t.ArrowRight,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),delegation_sent:e.jsx(t.Forward,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),delegation_returned:e.jsx(t.CheckCheck,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),artifact_saved:e.jsx(t.Download,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),error:e.jsx(t.TriangleAlert,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),agent_initializing:e.jsx(t.CircleDot,{className:"w-3 h-3 animate-spin"}),completion:e.jsx(t.CheckCheck,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),default:e.jsx(t.Dot,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"})},d={retrieve:e.jsx(t.Search,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),action:e.jsx(t.CheckCheck,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),...x},p=n.memo(({summary:a,index:s,showConnector:r})=>{const l=n.useMemo(()=>a.details?JSON.stringify(a.details,null,2):null,[a.details]),o=n.useMemo(()=>h(a),[a]),i=n.useMemo(()=>d[a.type]||d.default,[a.type]);return e.jsxs("div",{className:"flex items-start gap-2 text-xs relative",children:[r&&e.jsx("div",{className:"absolute left-1.5 top-4 bottom-0 w-px bg-gray-200 dark:bg-white-alpha-200 -mb-3"}),e.jsx("div",{className:"flex items-center justify-center w-3 h-3 relative z-10 mt-0.5",children:i}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:" text-gray-700 dark:text-white-alpha-600",children:o}),l&&e.jsx("pre",{className:"mt-2 text-xs whitespace-pre-wrap font-mono bg-gray-50 dark:bg-gray-dark-900 p-2 rounded-md px-3 py-2",children:l})]})]},`op-${a.type}-${s}`)}),m=n.memo(({summaries:a,isCompleted:s})=>{const[r,l]=n.useState(!s);n.useEffect(()=>{let i;return s?i=setTimeout(()=>{l(!1)},1e3):l(!0),()=>{i&&clearTimeout(i)}},[s]);const o=n.useCallback(()=>{l(!r)},[r]);return e.jsxs("div",{className:"flex flex-col items-start mb-2.5 mt-2.5 first:mt-1 relative",children:[e.jsx("button",{type:"button",onClick:o,"data-expanded":r,className:"inline-flex items-center group gap-2 text-xs text-gray-500 dark:text-white-alpha-600 hover:text-gray-700 dark:hover:text-white-alpha-700 transition-colors cursor-pointer",children:s?e.jsxs(e.Fragment,{children:[e.jsx(t.Check,{className:"check-icon w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 absolute opacity-100 group-hover:opacity-0 group-data-[expanded=true]:opacity-0"}),e.jsx(t.ChevronRight,{className:"chevron-icon w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform opacity-0 rotate-0 group-hover:opacity-100 group-data-[expanded=true]:opacity-100 group-data-[expanded=true]:rotate-90"}),e.jsx("span",{className:"font-medium",children:"Completed"})]}):e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{className:"font-medium",children:"Thinking..."})]})}),e.jsx("div",{"data-expanded":r,className:"overflow-hidden transition-all duration-300 ease-in-out data-[expanded=true]:opacity-100 data-[expanded=false]:max-h-0 data-[expanded=false]:opacity-0 max-w-full",children:e.jsx("div",{className:"pb-2 mt-1.5 space-y-3 relative",children:a.map((i,c)=>e.jsx(p,{summary:i,index:c,showConnector:a.length>1&&c<a.length-1},`op-${i.type}-${c}`))})})]})});exports.DataSummaryGroup=m;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsxs as s, jsx as e, Fragment as h } from "react/jsx-runtime";
3
- import { memo as m, useState as w, useEffect as u, useCallback as y, useMemo as c } from "react";
4
- import { Check as f, ChevronRight as N, LoaderCircle as k, Dot as g, CheckCheck as d, Search as v, CircleDot as b, TriangleAlert as _, Download as C, Forward as S, ArrowRight as A, Hammer as p, Brain as D, RefreshCw as E } from "lucide-react";
3
+ import { memo as m, useState as g, useEffect as w, useCallback as u, useMemo as c } from "react";
4
+ import { Check as y, ChevronRight as f, LoaderCircle as N, CheckCheck as d, Search as k, Dot as v, CircleDot as b, TriangleAlert as _, Download as C, Forward as S, ArrowRight as A, Hammer as p, Brain as D, RefreshCw as E } from "lucide-react";
5
5
  const I = (t) => {
6
6
  const { type: r, label: a } = t;
7
7
  return a || r.replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
@@ -17,11 +17,10 @@ const I = (t) => {
17
17
  error: /* @__PURE__ */ e(_, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
18
18
  agent_initializing: /* @__PURE__ */ e(b, { className: "w-3 h-3 animate-spin" }),
19
19
  completion: /* @__PURE__ */ e(d, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
20
- default: /* @__PURE__ */ e(g, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" })
20
+ default: /* @__PURE__ */ e(v, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" })
21
21
  }, x = {
22
- retrieve: /* @__PURE__ */ e(v, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
22
+ retrieve: /* @__PURE__ */ e(k, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
23
23
  action: /* @__PURE__ */ e(d, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
24
- default: /* @__PURE__ */ e(g, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
25
24
  ...M
26
25
  }, O = m(({ summary: t, index: r, showConnector: a }) => {
27
26
  const l = c(() => t.details ? JSON.stringify(t.details, null, 2) : null, [t.details]), n = c(() => I(t), [t]), i = c(
@@ -37,8 +36,8 @@ const I = (t) => {
37
36
  ] })
38
37
  ] }, `op-${t.type}-${r}`);
39
38
  }), j = m(({ summaries: t, isCompleted: r }) => {
40
- const [a, l] = w(!r);
41
- u(() => {
39
+ const [a, l] = g(!r);
40
+ w(() => {
42
41
  let i;
43
42
  return r ? i = setTimeout(() => {
44
43
  l(!1);
@@ -46,7 +45,7 @@ const I = (t) => {
46
45
  i && clearTimeout(i);
47
46
  };
48
47
  }, [r]);
49
- const n = y(() => {
48
+ const n = u(() => {
50
49
  l(!a);
51
50
  }, [a]);
52
51
  return /* @__PURE__ */ s("div", { className: "flex flex-col items-start mb-2.5 mt-2.5 first:mt-1 relative", children: [
@@ -58,11 +57,11 @@ const I = (t) => {
58
57
  "data-expanded": a,
59
58
  className: "inline-flex items-center group gap-2 text-xs text-gray-500 dark:text-white-alpha-600 hover:text-gray-700 dark:hover:text-white-alpha-700 transition-colors cursor-pointer",
60
59
  children: r ? /* @__PURE__ */ s(h, { children: [
61
- /* @__PURE__ */ e(f, { className: "check-icon w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 absolute opacity-100 group-hover:opacity-0 group-data-[expanded=true]:opacity-0" }),
62
- /* @__PURE__ */ e(N, { className: "chevron-icon w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform opacity-0 rotate-0 group-hover:opacity-100 group-data-[expanded=true]:opacity-100 group-data-[expanded=true]:rotate-90" }),
60
+ /* @__PURE__ */ e(y, { className: "check-icon w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 absolute opacity-100 group-hover:opacity-0 group-data-[expanded=true]:opacity-0" }),
61
+ /* @__PURE__ */ e(f, { className: "chevron-icon w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform opacity-0 rotate-0 group-hover:opacity-100 group-data-[expanded=true]:opacity-100 group-data-[expanded=true]:rotate-90" }),
63
62
  /* @__PURE__ */ e("span", { className: "font-medium", children: "Completed" })
64
63
  ] }) : /* @__PURE__ */ s(h, { children: [
65
- /* @__PURE__ */ e(k, { className: "w-3 h-3 animate-spin" }),
64
+ /* @__PURE__ */ e(N, { className: "w-3 h-3 animate-spin" }),
66
65
  /* @__PURE__ */ e("span", { className: "font-medium", children: "Thinking..." })
67
66
  ] })
68
67
  }
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.18",
4
4
  "description": "",
5
5
  "homepage": "",
6
6
  "repository": {