@inkeep/agents-ui 0.14.12 → 0.14.13

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"),q=`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:F,emitStreamError:R}=oe.useStreamingEvents(),[a,u]=t.useState(""),k=e=>u(e.target.value),{filters:S}=f,{onInputMessageChange:A,filters:E,agentUrl:P,context:x,headers:D,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 ${f.organizationDisplayName??"Administrator"}`;default:return q}},[U,T]=t.useState({}),[B,l]=t.useState([]),[O,I]=t.useState(null),{messages:g,sendMessage:K,status:b,setMessages:y,stop:L,error:d}=X.useChat({transport:new Y.DefaultChatTransport({api:P,headers:{...C?{Authorization:`Bearer ${C}`}:{},...D},body:{requestContext:x}}),async onFinish(){await i({eventName:"assistant_message_received",properties:{conversationId:n}}),i({eventName:"assistant_answer_displayed",properties:{conversationId:n}})},onError(e){console.log("onError",e.message),R(e.message,void 0,e.code?.toString()),y(c=>{const r=[...c],s=r[r.length-1];return s&&(s.parts=[{type:"text",text:N(e)}]),r})}}),w=b==="submitted",W=b==="streaming",$=g.length===0,m=!a.trim()||w,z=ee.useMediaQuery("(max-width: 768px)"),[G,p]=t.useState(null);t.useEffect(()=>{d&&p(d)},[d]);const H=()=>p(null),M=t.useRef(null);t.useEffect(()=>{A?.(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||E?JSON.stringify({...S,...E}):void 0,r={};c&&(r["inkeep-filters"]=c);let s=n;s||(s=`conv_${te.generateUid(16)}`,v(s)),F(s),K({text:e},{headers:r,body:{conversationId:s}})},j=()=>{L()},_=()=>{H(),y([]),v(""),T({}),l([]),I(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:_,openForm:e=>{V?.setView("chat"),J(e,void 0)},focusInput:()=>{M.current?.focus()}})),{messages:g,isLoading:w,isStreaming:W,error:G,setError:p,isSubmitDisabled:m,input:a,handleInputChange:k,handleInputKeyDown:Q,handleSubmit:h,stop:j,clear:_,messageButtons:U,isEmpty:g.length===0,inputRef:M,isMobile:z,messageAttachments:B,setMessageAttachments:l,selectedWorkflow:O,setSelectedWorkflow:I,isNewChat:$,conversationId:n}};exports.DEFAULT_ERROR_MESSAGE=q;exports.useInkeepChat=ie;
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:F,emitToParent:R}=oe.useStreamingEvents(),[a,u]=t.useState(""),P=e=>u(e.target.value),{filters:E}=f,{onInputMessageChange:k,filters:S,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 ${f.organizationDisplayName??"Administrator"}`;default:return q}},[T,U]=t.useState({}),[B,l]=t.useState([]),[O,I]=t.useState(null),{messages:g,sendMessage:K,status:b,setMessages:y,stop:L,error:d}=X.useChat({transport:new Y.DefaultChatTransport({api:A,headers:{...C?{Authorization:`Bearer ${C}`}:{},...x},body:{requestContext:D}}),onData(e){R(e.type,e.data)},async onFinish(){await i({eventName:"assistant_message_received",properties:{conversationId:n}}),i({eventName:"assistant_answer_displayed",properties:{conversationId:n}})},onError(e){console.log("onError",e.message),y(c=>{const r=[...c],s=r[r.length-1];return s&&(s.parts=[{type:"text",text:N(e)}]),r})}}),w=b==="submitted",W=b==="streaming",$=g.length===0,m=!a.trim()||w,z=ee.useMediaQuery("(max-width: 768px)"),[G,p]=t.useState(null);t.useEffect(()=>{d&&p(d)},[d]);const H=()=>p(null),M=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=E||S?JSON.stringify({...E,...S}):void 0,r={};c&&(r["inkeep-filters"]=c);let s=n;s||(s=`conv_${te.generateUid(16)}`,v(s)),F(s),K({text:e},{headers:r,body:{conversationId:s}})},j=()=>{L()},_=()=>{H(),y([]),v(""),U({}),l([]),I(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:_,openForm:e=>{V?.setView("chat"),J(e,void 0)},focusInput:()=>{M.current?.focus()}})),{messages:g,isLoading:w,isStreaming:W,error:G,setError:p,isSubmitDisabled:m,input:a,handleInputChange:P,handleInputKeyDown:Q,handleSubmit:h,stop:j,clear:_,messageButtons:T,isEmpty:g.length===0,inputRef:M,isMobile:z,messageAttachments:B,setMessageAttachments:l,selectedWorkflow:O,setSelectedWorkflow:I,isNewChat:$,conversationId:n}};exports.DEFAULT_ERROR_MESSAGE=q;exports.useInkeepChat=ie;
@@ -12,21 +12,21 @@ 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.`, Se = () => {
15
+ It seems I might be having some issues right now. Please clear the chat and try again.`, ye = () => {
16
16
  const { baseSettings: f, aiChatSettings: a } = te(), [s = "", v] = ie({
17
17
  prop: a.conversationId,
18
18
  defaultProp: a.conversationId ?? ""
19
- }), { logEvent: i } = oe(), { setConversationId: F, emitStreamError: k } = ce(), [o, m] = r(""), N = (e) => m(e.target.value), {
19
+ }), { logEvent: i } = oe(), { setConversationId: F, emitToParent: k } = ce(), [o, m] = r(""), D = (e) => m(e.target.value), {
20
20
  /* shouldBypassCaptcha, */
21
21
  filters: I
22
22
  } = f, {
23
- onInputMessageChange: A,
23
+ onInputMessageChange: N,
24
24
  filters: C,
25
- agentUrl: D,
25
+ agentUrl: A,
26
26
  context: R,
27
27
  headers: B,
28
28
  apiKey: E
29
- } = a, K = (e) => {
29
+ } = a, P = (e) => {
30
30
  switch (e.code) {
31
31
  case 400:
32
32
  return e.message;
@@ -35,16 +35,16 @@ It seems I might be having some issues right now. Please clear the chat and try
35
35
  default:
36
36
  return me;
37
37
  }
38
- }, [P, T] = r({}), [U, u] = r([]), [W, S] = r(null), {
38
+ }, [T, K] = r({}), [U, u] = r([]), [W, y] = r(null), {
39
39
  messages: l,
40
40
  sendMessage: $,
41
41
  status: b,
42
- setMessages: y,
42
+ setMessages: w,
43
43
  stop: z,
44
44
  error: p
45
45
  } = X({
46
46
  transport: new Y({
47
- api: D,
47
+ api: A,
48
48
  headers: {
49
49
  ...E ? { Authorization: `Bearer ${E}` } : {},
50
50
  ...B
@@ -53,6 +53,9 @@ It seems I might be having some issues right now. Please clear the chat and try
53
53
  requestContext: R
54
54
  }
55
55
  }),
56
+ onData(e) {
57
+ k(e.type, e.data);
58
+ },
56
59
  async onFinish() {
57
60
  await i({
58
61
  eventName: "assistant_message_received",
@@ -67,18 +70,18 @@ It seems I might be having some issues right now. Please clear the chat and try
67
70
  });
68
71
  },
69
72
  onError(e) {
70
- console.log("onError", e.message), k(e.message, void 0, e.code?.toString()), y((c) => {
73
+ console.log("onError", e.message), w((c) => {
71
74
  const n = [...c], t = n[n.length - 1];
72
- return t && (t.parts = [{ type: "text", text: K(e) }]), n;
75
+ return t && (t.parts = [{ type: "text", text: P(e) }]), n;
73
76
  });
74
77
  }
75
- }), w = b === "submitted", H = b === "streaming", L = l.length === 0, g = !o.trim() || w, O = se("(max-width: 768px)"), [q, d] = r(null);
78
+ }), S = b === "submitted", H = b === "streaming", L = l.length === 0, g = !o.trim() || S, O = se("(max-width: 768px)"), [q, d] = r(null);
76
79
  x(() => {
77
80
  p && d(p);
78
81
  }, [p]);
79
82
  const G = () => d(null), M = Z(null);
80
83
  x(() => {
81
- A?.(o);
84
+ N?.(o);
82
85
  }, [o]);
83
86
  const J = (e) => {
84
87
  e.key === "Enter" && !e.shiftKey && !g && !e.nativeEvent.isComposing && (e.preventDefault(), h());
@@ -112,7 +115,7 @@ It seems I might be having some issues right now. Please clear the chat and try
112
115
  }, Q = () => {
113
116
  z();
114
117
  }, _ = () => {
115
- G(), y([]), v(""), T({}), u([]), S(null), i({
118
+ G(), w([]), v(""), K({}), u([]), y(null), i({
116
119
  eventName: "chat_clear_button_clicked",
117
120
  properties: {
118
121
  conversationId: s
@@ -133,18 +136,18 @@ It seems I might be having some issues right now. Please clear the chat and try
133
136
  }
134
137
  })), {
135
138
  messages: l,
136
- isLoading: w,
139
+ isLoading: S,
137
140
  isStreaming: H,
138
141
  error: q,
139
142
  setError: d,
140
143
  isSubmitDisabled: g,
141
144
  input: o,
142
- handleInputChange: N,
145
+ handleInputChange: D,
143
146
  handleInputKeyDown: J,
144
147
  handleSubmit: h,
145
148
  stop: Q,
146
149
  clear: _,
147
- messageButtons: P,
150
+ messageButtons: T,
148
151
  isEmpty: l.length === 0,
149
152
  inputRef: M,
150
153
  isMobile: O,
@@ -152,12 +155,12 @@ It seems I might be having some issues right now. Please clear the chat and try
152
155
  messageAttachments: U,
153
156
  setMessageAttachments: u,
154
157
  selectedWorkflow: W,
155
- setSelectedWorkflow: S,
158
+ setSelectedWorkflow: y,
156
159
  isNewChat: L,
157
160
  conversationId: s
158
161
  };
159
162
  };
160
163
  export {
161
164
  me as DEFAULT_ERROR_MESSAGE,
162
- Se as useInkeepChat
165
+ ye as useInkeepChat
163
166
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),M=require("./use-inkeep-chat.cjs"),_=require("../../hooks/use-streaming-events.cjs"),q=require("../../../types/message.cjs");function z(u,l,g){const[m,D]=r.useState([]),[d,E]=r.useState(new Map),[y,I]=r.useState(Date.now()),[P,h]=r.useState(!1),w=r.useRef(0),S=r.useRef(0),x=r.useRef([]),f=r.useRef(d);f.current=d;const{emitArtifactSaved:k,emitCompletion:C,emitAgentInitializing:T,emitTextDelta:A}=_.useStreamingEvents(),R=r.useCallback(()=>{const n=[];let e="",o=[],c=!1;u.length>w.current&&(I(Date.now()),w.current=u.length),S.current=0;const p=new Map,i=(t=!1)=>{if(o.length>0){const s=`group-${S.current++}`,a=f.current.get(s);a?p.set(s,{...a,isCompleted:t}):p.set(s,{isCompleted:t}),n.push({type:"summary-group",summaries:[...o],groupKey:s}),o=[]}};for(const t of u)if(t.type==="text")i(!0),t.text&&l&&A(t.text),e+=t.text||"";else if(t.type==="data-summary")e.trim()&&(n.push({type:"text",text:e}),e=""),o.push(t.data);else if(t.type==="data-operation"){e.trim()&&(n.push({type:"text",text:e}),e="");const s=t.data;if(s?.type)switch(s.type){case"completion":C("unknown",1),i(!0);break;case"agent_initializing":T("unknown","unknown");break;case"error":{i(!0);const a=s.message||"Unknown error";console.warn("Data operation error:",a),g(new Error(a)),c||(n.push({type:"text",text:M.DEFAULT_ERROR_MESSAGE}),c=!0);break}default:{const{type:a,label:L}=s;o.push({type:a,label:L});break}}}else if(t.type==="data-artifact")if(t.data?.type?.toLowerCase()===q.CITATION_ARTIFACT_TYPE){const s=t.data,a=s.artifactSummary||{title:s.name};e+=` ^${a?.title||s.name}^`}else e.trim()&&(n.push({type:"text",text:e}),e=""),n.push(t),t.data&&k(t.data.artifactId||"unknown",t.data.taskId||"unknown","unknown",t.data.artifactType||"unknown",t.data.artifactSummary||{},{},{name:t.data.name,description:t.data.description});else t.type==="data-component"&&(e.trim()&&(n.push({type:"text",text:e}),e=""),i(!0),n.push(t));return i(!l),e.trim()&&n.push({type:"text",text:e}),{processed:n,newTimings:p}},[u,l,k,C,T,A,g]);r.useEffect(()=>{if(x.current===u)return;x.current=u;const{processed:n,newTimings:e}=R();D(n),(e.size!==f.current.size||Array.from(e.entries()).some(([c,p])=>{const i=f.current.get(c);return!i||i.isCompleted!==p.isCompleted}))&&E(e)},[R,u]);const v=r.useCallback(()=>{const n=Date.now()-y,e=Array.from(f.current.values()).some(c=>!c.isCompleted),o=n>1e3&&!e;h(o)},[y]);r.useEffect(()=>{if(!l){h(!1);return}if(!(m.length>0)){h(!1);return}const e=setInterval(v,200);return()=>clearInterval(e)},[l,v,m.length]);const b=r.useMemo(()=>!(m.length>0),[m.length]);return{processedParts:m,summaryTimings:d,shouldShowInitialLoading:b,shouldShowStreamDelayLoading:P}}exports.useStreamProcessor=z;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),b=require("./use-inkeep-chat.cjs"),E=require("../../../types/message.cjs");function L(i,p,g){const[l,R]=n.useState([]),[h,A]=n.useState(new Map),[d,D]=n.useState(Date.now()),[P,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;i.length>S.current&&(D(Date.now()),S.current=i.length),x.current=0;const m=new Map,u=(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 i)if(s.type==="text")u(!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"completion":u(!0);break;case"error":{u(!0);const a=r.message||"Unknown error";console.warn("Data operation error:",a),g(new Error(a)),c||(t.push({type:"text",text:b.DEFAULT_ERROR_MESSAGE}),c=!0);break}default:{const{type:a,label:v}=r;o.push({type:a,label:v});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=""),u(!0),t.push(s));return u(!p),e.trim()&&t.push({type:"text",text:e}),{processed:t,newTimings:m}},[i,p,g]);n.useEffect(()=>{if(w.current===i)return;w.current=i;const{processed:t,newTimings:e}=C();R(t),(e.size!==f.current.size||Array.from(e.entries()).some(([c,m])=>{const u=f.current.get(c);return!u||u.isCompleted!==m.isCompleted}))&&A(e)},[C,i]);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 k=n.useMemo(()=>!(l.length>0),[l.length]);return{processedParts:l,summaryTimings:h,shouldShowInitialLoading:k,shouldShowStreamDelayLoading:P}}exports.useStreamProcessor=L;
@@ -1,135 +1,101 @@
1
1
  "use client";
2
- import { useState as p, useRef as d, useCallback as R, useEffect as E, useMemo as F } from "react";
3
- import { DEFAULT_ERROR_MESSAGE as G } from "./use-inkeep-chat.js";
4
- import { useStreamingEvents as O } from "../../hooks/use-streaming-events.js";
5
- import { CITATION_ARTIFACT_TYPE as U } from "../../../types/message.js";
6
- function j(i, u, g) {
7
- const [m, L] = p([]), [h, P] = p(/* @__PURE__ */ new Map()), [w, b] = p(Date.now()), [M, y] = p(!1), x = d(0), k = d(0), S = d([]), f = d(h);
8
- f.current = h;
9
- const { emitArtifactSaved: T, emitCompletion: C, emitAgentInitializing: A, emitTextDelta: D } = O(), v = R(() => {
10
- const n = [];
11
- let t = "", s = [], c = !1;
12
- i.length > x.current && (b(Date.now()), x.current = i.length), k.current = 0;
13
- const l = /* @__PURE__ */ new Map(), o = (e = !1) => {
14
- if (s.length > 0) {
15
- const r = `group-${k.current++}`, a = f.current.get(r);
16
- a ? l.set(r, {
17
- ...a,
18
- isCompleted: e
19
- }) : l.set(r, {
20
- isCompleted: e
21
- }), n.push({
2
+ import { useState as p, useRef as h, useCallback as D, useEffect as R, useMemo as M } from "react";
3
+ import { DEFAULT_ERROR_MESSAGE as b } from "./use-inkeep-chat.js";
4
+ import { CITATION_ARTIFACT_TYPE as _ } from "../../../types/message.js";
5
+ function z(i, f, d) {
6
+ const [u, v] = p([]), [y, L] = p(/* @__PURE__ */ new Map()), [x, P] = p(Date.now()), [k, g] = p(!1), w = h(0), C = h(0), S = h([]), m = h(y);
7
+ m.current = y;
8
+ const T = D(() => {
9
+ const e = [];
10
+ let t = "", o = [], c = !1;
11
+ i.length > w.current && (P(Date.now()), w.current = i.length), C.current = 0;
12
+ const l = /* @__PURE__ */ new Map(), a = (r = !1) => {
13
+ if (o.length > 0) {
14
+ const s = `group-${C.current++}`, n = m.current.get(s);
15
+ n ? l.set(s, {
16
+ ...n,
17
+ isCompleted: r
18
+ }) : l.set(s, {
19
+ isCompleted: r
20
+ }), e.push({
22
21
  type: "summary-group",
23
- summaries: [...s],
24
- groupKey: r
25
- }), s = [];
22
+ summaries: [...o],
23
+ groupKey: s
24
+ }), o = [];
26
25
  }
27
26
  };
28
- for (const e of i)
29
- if (e.type === "text")
30
- o(!0), e.text && u && D(e.text), t += e.text || "";
31
- else if (e.type === "data-summary")
32
- t.trim() && (n.push({ type: "text", text: t }), t = ""), s.push(e.data);
33
- else if (e.type === "data-operation") {
34
- t.trim() && (n.push({ type: "text", text: t }), t = "");
35
- const r = e.data;
36
- if (r?.type)
37
- switch (r.type) {
27
+ for (const r of i)
28
+ if (r.type === "text")
29
+ a(!0), t += r.text || "";
30
+ else if (r.type === "data-summary")
31
+ t.trim() && (e.push({ type: "text", text: t }), t = ""), o.push(r.data);
32
+ else if (r.type === "data-operation") {
33
+ t.trim() && (e.push({ type: "text", text: t }), t = "");
34
+ const s = r.data;
35
+ if (s?.type)
36
+ switch (s.type) {
38
37
  case "completion":
39
- C(
40
- "unknown",
41
- // No agent ID available in current structure
42
- 1
43
- // No iteration available in current structure
44
- ), o(!0);
45
- break;
46
- case "agent_initializing":
47
- A(
48
- "unknown",
49
- // No session ID available in current structure
50
- "unknown"
51
- // No graph ID available in current structure
52
- );
38
+ a(!0);
53
39
  break;
54
40
  case "error": {
55
- o(!0);
56
- const a = r.message || "Unknown error";
57
- console.warn("Data operation error:", a), g(new Error(a)), c || (n.push({ type: "text", text: G }), c = !0);
41
+ a(!0);
42
+ const n = s.message || "Unknown error";
43
+ console.warn("Data operation error:", n), d(new Error(n)), c || (e.push({ type: "text", text: b }), c = !0);
58
44
  break;
59
45
  }
60
46
  default: {
61
- const { type: a, label: z } = r;
62
- s.push({ type: a, label: z });
47
+ const { type: n, label: I } = s;
48
+ o.push({ type: n, label: I });
63
49
  break;
64
50
  }
65
51
  }
66
- } else if (e.type === "data-artifact")
67
- if (e.data?.type?.toLowerCase() === U) {
68
- const r = e.data, a = r.artifactSummary || {
69
- title: r.name
52
+ } else if (r.type === "data-artifact")
53
+ if (r.data?.type?.toLowerCase() === _) {
54
+ const s = r.data, n = s.artifactSummary || {
55
+ title: s.name
70
56
  };
71
- t += ` ^${a?.title || r.name}^`;
57
+ t += ` ^${n?.title || s.name}^`;
72
58
  } else
73
- t.trim() && (n.push({ type: "text", text: t }), t = ""), n.push(e), e.data && T(
74
- e.data.artifactId || "unknown",
75
- e.data.taskId || "unknown",
76
- "unknown",
77
- // toolCallId not available in current structure
78
- e.data.artifactType || "unknown",
79
- e.data.artifactSummary || {},
80
- // Use artifactSummary as summaryData
81
- {},
82
- // fullData not available in current structure
83
- { name: e.data.name, description: e.data.description }
84
- // Use available fields as metadata
85
- );
86
- else e.type === "data-component" && (t.trim() && (n.push({ type: "text", text: t }), t = ""), o(!0), n.push(e));
87
- return o(!u), t.trim() && n.push({ type: "text", text: t }), { processed: n, newTimings: l };
88
- }, [
89
- i,
90
- u,
91
- T,
92
- C,
93
- A,
94
- D,
95
- g
96
- ]);
97
- E(() => {
59
+ t.trim() && (e.push({ type: "text", text: t }), t = ""), e.push(r);
60
+ else r.type === "data-component" && (t.trim() && (e.push({ type: "text", text: t }), t = ""), a(!0), e.push(r));
61
+ return a(!f), t.trim() && e.push({ type: "text", text: t }), { processed: e, newTimings: l };
62
+ }, [i, f, d]);
63
+ R(() => {
98
64
  if (S.current === i)
99
65
  return;
100
66
  S.current = i;
101
- const { processed: n, newTimings: t } = v();
102
- L(n), (t.size !== f.current.size || Array.from(t.entries()).some(([c, l]) => {
103
- const o = f.current.get(c);
104
- return !o || o.isCompleted !== l.isCompleted;
105
- })) && P(t);
106
- }, [v, i]);
107
- const I = R(() => {
108
- const n = Date.now() - w, t = Array.from(f.current.values()).some(
67
+ const { processed: e, newTimings: t } = T();
68
+ v(e), (t.size !== m.current.size || Array.from(t.entries()).some(([c, l]) => {
69
+ const a = m.current.get(c);
70
+ return !a || a.isCompleted !== l.isCompleted;
71
+ })) && L(t);
72
+ }, [T, i]);
73
+ const A = D(() => {
74
+ const e = Date.now() - x, t = Array.from(m.current.values()).some(
109
75
  (c) => !c.isCompleted
110
- ), s = n > 1e3 && !t;
111
- y(s);
112
- }, [w]);
113
- E(() => {
114
- if (!u) {
115
- y(!1);
76
+ ), o = e > 1e3 && !t;
77
+ g(o);
78
+ }, [x]);
79
+ R(() => {
80
+ if (!f) {
81
+ g(!1);
116
82
  return;
117
83
  }
118
- if (!(m.length > 0)) {
119
- y(!1);
84
+ if (!(u.length > 0)) {
85
+ g(!1);
120
86
  return;
121
87
  }
122
- const t = setInterval(I, 200);
88
+ const t = setInterval(A, 200);
123
89
  return () => clearInterval(t);
124
- }, [u, I, m.length]);
125
- const _ = F(() => !(m.length > 0), [m.length]);
90
+ }, [f, A, u.length]);
91
+ const E = M(() => !(u.length > 0), [u.length]);
126
92
  return {
127
- processedParts: m,
128
- summaryTimings: h,
129
- shouldShowInitialLoading: _,
130
- shouldShowStreamDelayLoading: M
93
+ processedParts: u,
94
+ summaryTimings: y,
95
+ shouldShowInitialLoading: E,
96
+ shouldShowStreamDelayLoading: k
131
97
  };
132
98
  }
133
99
  export {
134
- j as useStreamProcessor
100
+ z as useStreamProcessor
135
101
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),p=require("../atoms/shadow/context.cjs");function x(){const c=p.useShadow()?.shadowHost,r=s.useRef(""),t=s.useCallback(e=>{if(!c){console.warn("useStreamingEvents: No host element available for event emission");return}const n={...e,conversationId:r.current,timestamp:Date.now()},a=new CustomEvent("streaming-event",{detail:n,bubbles:!0,composed:!0});c.dispatchEvent(a)},[c]),d=s.useCallback(e=>{r.current=e},[]),u=s.useCallback(e=>{t({kind:"text:delta",data:{text:e}})},[t]),m=s.useCallback((e,n,a)=>{t({kind:"stream:error",data:{message:e,agent:n,severity:"error",code:a}})},[t]),k=s.useCallback((e,n)=>{t({kind:"agent:reasoning",data:{agentId:e,parts:n}})},[t]),g=s.useCallback((e,n,a)=>{t({kind:"agent:generate",data:{agentId:e,parts:n,generationType:a}})},[t]),b=s.useCallback((e,n,a,o,i,l)=>{t({kind:"tool:execution",data:{agentId:e,toolName:n,args:a,result:o,toolId:i,duration:l}})},[t]),v=s.useCallback((e,n,a,o)=>{t({kind:"agent:transfer",data:{fromAgent:e,targetAgent:n,reason:a,context:o}})},[t]),C=s.useCallback((e,n,a,o,i)=>{t({kind:"delegation:sent",data:{delegationId:e,fromAgent:n,targetAgent:a,taskDescription:o,context:i}})},[t]),f=s.useCallback((e,n,a,o)=>{t({kind:"delegation:returned",data:{delegationId:e,fromAgent:n,targetAgent:a,result:o}})},[t]),E=s.useCallback((e,n,a,o,i,l,w)=>{t({kind:"artifact:saved",data:{artifactId:e,taskId:n,toolCallId:a,artifactType:o,summaryData:i,fullData:l,metadata:w}})},[t]),S=s.useCallback((e,n)=>{t({kind:"completion",data:{agent:e,iteration:n}})},[t]),h=s.useCallback((e,n)=>{t({kind:"agent:initializing",data:{sessionId:e,graphId:n}})},[t]);return{emitEvent:t,setConversationId:d,emitTextDelta:u,emitStreamError:m,emitAgentReasoning:k,emitAgentGenerate:g,emitToolExecution:b,emitAgentTransfer:v,emitDelegationSent:C,emitDelegationReturned:f,emitArtifactSaved:E,emitCompletion:S,emitAgentInitializing:h}}exports.useStreamingEvents=x;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),u=require("../atoms/shadow/context.cjs");function i(){const e=u.useShadow()?.shadowHost,s=n.useRef(""),o=n.useCallback(t=>{s.current=t},[]),r=n.useCallback((t,a)=>{if(!e){console.warn("useStreamingEvents: No host element available for parent event emission");return}const c=new CustomEvent(`ikp-${t}`,{detail:{...a,conversationId:s.current,timestamp:Date.now()},bubbles:!0,composed:!0});e.dispatchEvent(c)},[e]);return{setConversationId:o,emitToParent:r}}exports.useStreamingEvents=i;
@@ -1,140 +1,33 @@
1
1
  "use client";
2
- import { useRef as x, useCallback as o } from "react";
3
- import { useShadow as A } from "../atoms/shadow/context.js";
4
- function R() {
5
- const r = A()?.shadowHost, c = x(""), e = o(
6
- (t) => {
7
- if (!r) {
8
- console.warn("useStreamingEvents: No host element available for event emission");
2
+ import { useRef as c, useCallback as o } from "react";
3
+ import { useShadow as u } from "../atoms/shadow/context.js";
4
+ function v() {
5
+ const e = u()?.shadowHost, n = c(""), s = o((t) => {
6
+ n.current = t;
7
+ }, []), r = o(
8
+ (t, a) => {
9
+ if (!e) {
10
+ console.warn("useStreamingEvents: No host element available for parent event emission");
9
11
  return;
10
12
  }
11
- const n = {
12
- ...t,
13
- conversationId: c.current,
14
- timestamp: Date.now()
15
- }, a = new CustomEvent("streaming-event", {
16
- detail: n,
13
+ const i = new CustomEvent(`ikp-${t}`, {
14
+ detail: {
15
+ ...a,
16
+ conversationId: n.current,
17
+ timestamp: Date.now()
18
+ },
17
19
  bubbles: !0,
18
- // Allow event to bubble up
19
20
  composed: !0
20
- // Allow event to escape Shadow DOM boundary
21
- });
22
- r.dispatchEvent(a);
23
- },
24
- [r]
25
- ), m = o((t) => {
26
- c.current = t;
27
- }, []), l = o(
28
- (t) => {
29
- e({
30
- kind: "text:delta",
31
- data: { text: t }
32
- });
33
- },
34
- [e]
35
- ), u = o(
36
- (t, n, a) => {
37
- e({
38
- kind: "stream:error",
39
- data: {
40
- message: t,
41
- agent: n,
42
- severity: "error",
43
- code: a
44
- }
45
- });
46
- },
47
- [e]
48
- ), g = o(
49
- (t, n) => {
50
- e({
51
- kind: "agent:reasoning",
52
- data: { agentId: t, parts: n }
53
- });
54
- },
55
- [e]
56
- ), v = o(
57
- (t, n, a) => {
58
- e({
59
- kind: "agent:generate",
60
- data: { agentId: t, parts: n, generationType: a }
61
- });
62
- },
63
- [e]
64
- ), f = o(
65
- (t, n, a, i, s, d) => {
66
- e({
67
- kind: "tool:execution",
68
- data: { agentId: t, toolName: n, args: a, result: i, toolId: s, duration: d }
69
- });
70
- },
71
- [e]
72
- ), k = o(
73
- (t, n, a, i) => {
74
- e({
75
- kind: "agent:transfer",
76
- data: { fromAgent: t, targetAgent: n, reason: a, context: i }
77
- });
78
- },
79
- [e]
80
- ), E = o(
81
- (t, n, a, i, s) => {
82
- e({
83
- kind: "delegation:sent",
84
- data: { delegationId: t, fromAgent: n, targetAgent: a, taskDescription: i, context: s }
85
- });
86
- },
87
- [e]
88
- ), p = o(
89
- (t, n, a, i) => {
90
- e({
91
- kind: "delegation:returned",
92
- data: { delegationId: t, fromAgent: n, targetAgent: a, result: i }
93
- });
94
- },
95
- [e]
96
- ), h = o(
97
- (t, n, a, i, s, d, b) => {
98
- e({
99
- kind: "artifact:saved",
100
- data: { artifactId: t, taskId: n, toolCallId: a, artifactType: i, summaryData: s, fullData: d, metadata: b }
101
- });
102
- },
103
- [e]
104
- ), w = o(
105
- (t, n) => {
106
- e({
107
- kind: "completion",
108
- data: { agent: t, iteration: n }
109
- });
110
- },
111
- [e]
112
- ), S = o(
113
- (t, n) => {
114
- e({
115
- kind: "agent:initializing",
116
- data: { sessionId: t, graphId: n }
117
21
  });
22
+ e.dispatchEvent(i);
118
23
  },
119
24
  [e]
120
25
  );
121
26
  return {
122
- emitEvent: e,
123
- setConversationId: m,
124
- // Convenience methods
125
- emitTextDelta: l,
126
- emitStreamError: u,
127
- emitAgentReasoning: g,
128
- emitAgentGenerate: v,
129
- emitToolExecution: f,
130
- emitAgentTransfer: k,
131
- emitDelegationSent: E,
132
- emitDelegationReturned: p,
133
- emitArtifactSaved: h,
134
- emitCompletion: w,
135
- emitAgentInitializing: S
27
+ setConversationId: s,
28
+ emitToParent: r
136
29
  };
137
30
  }
138
31
  export {
139
- R as useStreamingEvents
32
+ v as useStreamingEvents
140
33
  };
@@ -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.12",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.11",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.12",
8
+ widgetLibraryVersion: "0.14.11",
9
9
  componentType: o,
10
10
  tags: s
11
11
  }),
@@ -444,7 +444,7 @@ export declare interface InkeepAIChatSettings {
444
444
  /**
445
445
  * Headers for requests
446
446
  */
447
- headers: Record<string, string>;
447
+ headers?: Record<string, string>;
448
448
  /**
449
449
  * API key for requests
450
450
  */
@@ -444,7 +444,7 @@ export declare interface InkeepAIChatSettings {
444
444
  /**
445
445
  * Headers for requests
446
446
  */
447
- headers: Record<string, string>;
447
+ headers?: Record<string, string>;
448
448
  /**
449
449
  * API key for requests
450
450
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-ui",
3
- "version": "0.14.12",
3
+ "version": "0.14.13",
4
4
  "description": "",
5
5
  "homepage": "",
6
6
  "repository": {