@inkeep/agents-ui 0.0.0-dev-20260509021601 → 0.0.0-dev-20260509025038

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,2 +1,2 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const We=require("@ai-sdk/react"),ke=require("./file-upload-input.cjs"),Ze=require("ai"),t=require("react"),Xe=require("../../providers/config-provider.cjs"),Ye=require("../../providers/chat-auth-provider.cjs"),et=require("../../hooks/use-media-query.cjs"),tt=require("../../hooks/use-conversation-loader.cjs"),st=require("../../hooks/use-initial-conversation.cjs"),O=require("../../utils/generate-uid.cjs"),rt=require("../../providers/base-events-provider.cjs"),nt=require("../../providers/chat-form-provider.cjs"),at=require("../../providers/widget-provider.cjs"),ot=require("@radix-ui/react-use-controllable-state"),it=require("../../hooks/use-streaming-events.cjs"),ct=require("../../hooks/use-input-notification.cjs"),f=require("./chat-error-helpers.cjs"),ut=()=>{const{baseSettings:ae,aiChatSettings:y}=Xe.useInkeepConfig(),[u="",m]=ot.useControllableState({prop:y.conversationIdOverride,defaultProp:y.conversationIdOverride??""}),{logEvent:h}=rt.useBaseEvents(),{setConversationId:Me,emitToParent:F}=it.useStreamingEvents(),oe=t.useRef(u);t.useEffect(()=>{const e=oe.current;oe.current=u,e!==u&&h({eventName:"chat_conversation_changed",properties:{conversationId:u,previousConversationId:e}})},[u,h]);const[R,E]=t.useState(""),Fe=e=>E(e.target.value),{shouldBypassCaptcha:_e,filters:ie,userProperties:L,analyticsProperties:D}=ae,{authToken:U,isAuthenticated:g,isAuthConfigured:ce,refreshAuthToken:ue,sessionToken:$,refreshSession:B,getCaptchaHeader:_,invalidateCaptcha:d}=Ye.useChatAuth(),{onInputMessageChange:xe,filters:le,baseUrl:de,agentUrl:Pe,context:fe,headers:pe,appId:x,apiKey:S,files:C}=y,ge=t.useRef(_);ge.current=_;const he=Pe||`${de}/run/api/chat`,me=S??(g?U:$),{loadConversation:ve}=tt.useConversationLoader({baseUrl:de,appId:x,authToken:me,getCaptchaHeader:_,invalidateCaptcha:d,refreshSession:S||g?void 0:B}),[qe,ye]=t.useState(!1),z=t.useRef(null);z.current=$;const G=t.useRef(null);G.current=U;const H=t.useRef(void 0);H.current=L&&Object.keys(L).length>0?JSON.stringify(L):void 0;const K=t.useRef(void 0);K.current=D&&Object.keys(D).length>0?JSON.stringify(D):void 0;const v=t.useRef(0),j=t.useRef(null),J=t.useRef(null),I=t.useRef(void 0),Ne=C?.map(e=>`${e.filename??""}:${e.mediaType}:${e.url.length}:${e.url.slice(0,64)}:${e.url.slice(-32)}`).join(`
2
- `)??"";t.useEffect(()=>{I.current=C?.length?C:void 0},[Ne]);const Re=t.useRef(pe);Re.current=pe;const V=t.useRef(void 0);V.current=ie||le?JSON.stringify({...ie,...le}):void 0;const Oe=e=>{switch(f.resolveHttpStatusCode(e)){case 400:try{const s=JSON.parse(e.message??"");return s.detail??s.error?.message??f.RECOVERABLE_FALLBACK_MESSAGE}catch{return e.message?.trim()||f.RECOVERABLE_FALLBACK_MESSAGE}case 401:return ce?"Authentication failed. Please try again.":f.DEFAULT_ERROR_MESSAGE;case 403:return`There seems to be a configuration error. Please contact ${ae.organizationDisplayName??"Administrator"}`;case 429:return f.RATE_LIMIT_MESSAGE;default:return f.DEFAULT_ERROR_MESSAGE}},[P,Q]=t.useState([]),Le=t.useMemo(()=>new Ze.DefaultChatTransport({api:he,headers:()=>{const e=S??G.current??z.current;return{"x-inkeep-client-timezone":Intl.DateTimeFormat().resolvedOptions().timeZone,"x-inkeep-client-timestamp":new Date().toISOString(),"x-inkeep-invocation-type":"chat_widget",...x?{"x-inkeep-app-id":x}:{},...e?{Authorization:`Bearer ${e}`}:{},...V.current?{"inkeep-filters":V.current}:{},...H.current?{"x-inkeep-user-properties":H.current}:{},...K.current?{"x-inkeep-properties":K.current}:{},...Re.current}},prepareSendMessagesRequest:async e=>{const i=await ge.current(),s=e.messages[e.messages.length-1];return s||console.warn("[useInkeepChat] prepareSendMessagesRequest called with empty messages array"),{body:{...e.body,id:e.id,messages:s?[s]:[],trigger:e.trigger,messageId:e.messageId},headers:{...e.headers,...i}}},body:{requestContext:fe}}),[he,fe,x,S]),{messages:A,sendMessage:W,addToolApprovalResponse:Z,status:Ee,setMessages:p,stop:q,error:N}=We.useChat({transport:Le,onData(e){F(e.type,e.data)},async onFinish({message:e}){F("completion",{conversationId:u}),await h({eventName:"assistant_message_received",properties:{conversationId:u,messageId:e.id}}),h({eventName:"assistant_answer_displayed",properties:{conversationId:u,messageId:e.id}})},onError(e){console.error("onError",{code:e.code,message:e.message});const i=_e||S?null:f.resolveStreamingAuthError(e);if(i!==null&&v.current<1){v.current++;const a=J.current,r=j.current;(async()=>{if(i==="session"&&ce){const c=await ue();if(!c)throw new Error("Auth token refresh failed");G.current=c}else if(i==="session"){const c=await B();c&&(z.current=c)}else d();if(a){Z(a);return}r&&(p(c=>{let n=[...c];return n.at(-1)?.role==="assistant"&&(n=n.slice(0,-1)),n.at(-1)?.role==="user"&&(n=n.slice(0,-1)),n}),W(r.files?.length?{parts:[{type:"text",text:r.content},...r.files]}:{text:r.content},{body:r.body}))})().catch(()=>{v.current=0,d(),p(c=>{const n=[...c],w=n[n.length-1];if(!w)return n;const k=f.DEFAULT_ERROR_MESSAGE;return w.role==="user"?n.push({id:O.generateUid(16),role:"assistant",parts:[{type:"text",text:k}]}):w.parts=[{type:"text",text:k}],n})});return}v.current=0,i!==null&&d();const s=f.isRecoverableError(e),l=Oe(e);if(h({eventName:"chat_error",properties:{conversationId:u,messageId:A.at(-1)?.id,error:e.message}}),s){se({title:"Request failed",message:l},f.RECOVERABLE_NOTIFICATION_DURATION_MS),p(r=>{let o=[...r];return o.at(-1)?.role==="assistant"&&(o=o.slice(0,-1)),o.at(-1)?.role==="user"&&(o=o.slice(0,-1)),o});const a=j.current?.content;a&&E(a),te.current=e;return}p(a=>{const r=[...a],o=r[r.length-1];return o&&(o.role==="user"?r.push({id:O.generateUid(16),role:"assistant",parts:[{type:"text",text:l}]}):o.parts=[{type:"text",text:l}]),r})}}),Se=t.useRef(g);t.useEffect(()=>{const e=Se.current;Se.current=g,e!==g&&(q(),b(null),p([]),m(""),E(""),Q([]),d())},[g,q,p,m,d]);const Ce=Ee==="submitted",X=Ee==="streaming",De=t.useMemo(()=>{const e=a=>{if(!a||typeof a!="object")return!1;const r=a;return typeof r.type=="string"&&r.type.startsWith("tool-")},s=[...A??[]].reverse().find(a=>a.role==="assistant");if(!s)return!1;const l=s.parts?.at(-1);return!(!e(l)||l.state!=="output-available"||!l.approval?.id||X)},[A,X]),[Ue,Y]=t.useState(!1),Ie=X||De&&!Ue,Ae=Ce||Ie,$e=A.length===0,ee=!R.trim()&&P.length===0||Ae,Be=et.useMediaQuery("(max-width: 768px)"),[ze,b]=t.useState(null),te=t.useRef(null);t.useEffect(()=>{if(N){if(te.current===N){te.current=null;return}b(N)}},[N]);const Ge=()=>b(null),{inputNotification:He,showInputNotification:se,clearInputNotification:Ke}=ct.useInputNotification(),be=t.useRef(null);t.useEffect(()=>{xe?.(R)},[R]);const je=e=>{e.key==="Enter"&&!e.shiftKey&&!ee&&!e.nativeEvent.isComposing&&(e.preventDefault(),re())},re=async(e=R)=>{if(ee&&(!e||e.trim().length===0)&&P.length===0)return;const i=P;Q([]),E(""),v.current=0,J.current=null,Y(!1);let s=u;s||(s=`conv_${O.generateUid(16)}`,m(s)),Me(s),await h({eventName:"user_message_submitted",properties:{conversationId:s}});const l=I.current;I.current=void 0;let a,r;if(l?.length){let o;try{o=await Promise.all(i.map(c=>{const n=ke.normalizeFileType(c);return new Promise((w,k)=>{const M=new FileReader;M.onload=()=>{if(typeof M.result!="string"){k(new Error(`Failed to read file "${n.name}"`));return}w({type:"file",url:M.result,mediaType:n.type,filename:n.name})},M.onerror=()=>k(new Error(`Failed to read file "${n.name}"`)),M.readAsDataURL(n)})}))}catch{se({title:"Failed to attach files",message:"Could not read one or more files. Please try again."});return}r=[...o,...l],a=e.trim()?{parts:[{type:"text",text:e},...r]}:{parts:r}}else if(i.length>0){const o=new DataTransfer;for(const n of i)o.items.add(ke.normalizeFileType(n));const c=o.files;a=e.trim()?{text:e,files:c}:{files:c}}else a={text:e};j.current={content:e,body:{conversationId:s},files:r},W(a,{body:{conversationId:s}})},Je=t.useCallback(e=>{v.current=0,J.current=e,Y(!1),Z(e)},[Z]),ne=t.useCallback(()=>{Y(!0),q().then(()=>{F("aborted",{conversationId:u})})},[q,u,F]),Te=()=>{Ge(),p([]),m(""),d(),I.current=C?.length?C:void 0,h({eventName:"chat_clear_button_clicked",properties:{conversationId:u}})},T=t.useCallback((e,i)=>{b(null),p(i),m(e),d(),I.current=void 0},[p,m,d]),we=t.useCallback(async(e,i)=>{ne(),T(e,[]),ye(!0);try{const s=await ve(e,i);if(s===null)return!1;const a=s[s.length-1]?.role==="user"?[...s,{id:O.generateUid(16),role:"assistant",parts:[{type:"text",text:"This session was interrupted. Please check back in a few minutes or start a new conversation."}]}]:s;return T(e,a),!0}finally{i?.aborted||ye(!1)}},[T,ve,ne]);st.useInitialConversation({conversationId:y.conversationId,effectiveAuthToken:me,loadAndRestoreSession:we,onLoadFailed:()=>T("",[])});const{openForm:Ve}=nt.useChatForm(),Qe=at.useWidget();return t.useImperativeHandle(y.chatFunctionsRef,()=>({submitMessage:re,updateInputMessage(e){E(e)},clearChat:Te,openForm:e=>{Qe?.setView("chat"),Ve(e,void 0)},focusInput:()=>{be.current?.focus()}})),{messages:A,sendMessage:W,addToolApprovalResponse:Je,isLoading:Ce,isStreaming:Ie,isBusy:Ae,error:ze,setError:b,isSubmitDisabled:ee,input:R,handleInputChange:Fe,handleInputKeyDown:je,handleSubmit:re,stop:ne,clear:Te,inputRef:be,isMobile:Be,files:P,setFiles:Q,isNewChat:$e,conversationId:u,restoreSession:T,loadAndRestoreSession:we,isSessionLoading:qe,authToken:g?U:$,refreshSession:g?ue:B,getCaptchaHeader:_,invalidateCaptcha:d,inputNotification:He,showInputNotification:se,clearInputNotification:Ke}};exports.useInkeepChat=ut;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ze=require("@ai-sdk/react"),ke=require("./file-upload-input.cjs"),Xe=require("ai"),t=require("react"),Ye=require("../../providers/config-provider.cjs"),et=require("../../providers/chat-auth-provider.cjs"),tt=require("../../hooks/use-media-query.cjs"),st=require("../../hooks/use-conversation-loader.cjs"),rt=require("../../hooks/use-initial-conversation.cjs"),N=require("../../utils/generate-uid.cjs"),nt=require("../../providers/base-events-provider.cjs"),at=require("../../providers/chat-form-provider.cjs"),ot=require("../../providers/widget-provider.cjs"),it=require("@radix-ui/react-use-controllable-state"),ct=require("../../hooks/use-streaming-events.cjs"),ut=require("../../hooks/use-input-notification.cjs"),f=require("./chat-error-helpers.cjs"),lt=()=>{const{baseSettings:se,aiChatSettings:y}=Ye.useInkeepConfig(),[u="",h]=it.useControllableState({prop:y.conversationIdOverride,defaultProp:y.conversationIdOverride??""}),{logEvent:g}=nt.useBaseEvents(),{setConversationId:Me,emitToParent:M}=ct.useStreamingEvents(),re=t.useRef(u);t.useEffect(()=>{const e=re.current;re.current=u,e!==u&&g({eventName:"chat_conversation_changed",properties:{conversationId:u,previousConversationId:e}})},[u,g]);const[R,S]=t.useState(""),Fe=e=>S(e.target.value),{shouldBypassCaptcha:_e,filters:ne,userProperties:O,analyticsProperties:L}=se,{authToken:ae,isAuthenticated:m,isAuthConfigured:oe,refreshAuthToken:ie,sessionToken:ce,refreshSession:ue,getCaptchaHeader:F,invalidateCaptcha:d,effectiveAuthToken:le,applicableRefreshSession:xe}=et.useChatAuth(),{onInputMessageChange:Pe,filters:de,baseUrl:fe,agentUrl:qe,context:pe,headers:ge,appId:_,apiKey:D,files:E}=y,he=t.useRef(F);he.current=F;const me=qe||`${fe}/run/api/chat`,{loadConversation:ve}=st.useConversationLoader({baseUrl:fe,appId:_,authToken:le,getCaptchaHeader:F,invalidateCaptcha:d,refreshSession:xe}),[Ne,ye]=t.useState(!1),U=t.useRef(null);U.current=ce;const $=t.useRef(null);$.current=ae;const B=t.useRef(void 0);B.current=O&&Object.keys(O).length>0?JSON.stringify(O):void 0;const z=t.useRef(void 0);z.current=L&&Object.keys(L).length>0?JSON.stringify(L):void 0;const v=t.useRef(0),G=t.useRef(null),H=t.useRef(null),C=t.useRef(void 0),Oe=E?.map(e=>`${e.filename??""}:${e.mediaType}:${e.url.length}:${e.url.slice(0,64)}:${e.url.slice(-32)}`).join(`
2
+ `)??"";t.useEffect(()=>{C.current=E?.length?E:void 0},[Oe]);const Re=t.useRef(ge);Re.current=ge;const K=t.useRef(void 0);K.current=ne||de?JSON.stringify({...ne,...de}):void 0;const Le=e=>{switch(f.resolveHttpStatusCode(e)){case 400:try{const s=JSON.parse(e.message??"");return s.detail??s.error?.message??f.RECOVERABLE_FALLBACK_MESSAGE}catch{return e.message?.trim()||f.RECOVERABLE_FALLBACK_MESSAGE}case 401:return oe?"Authentication failed. Please try again.":f.DEFAULT_ERROR_MESSAGE;case 403:return`There seems to be a configuration error. Please contact ${se.organizationDisplayName??"Administrator"}`;case 429:return f.RATE_LIMIT_MESSAGE;default:return f.DEFAULT_ERROR_MESSAGE}},[x,j]=t.useState([]),De=t.useMemo(()=>new Xe.DefaultChatTransport({api:me,headers:()=>{const e=D??$.current??U.current;return{"x-inkeep-client-timezone":Intl.DateTimeFormat().resolvedOptions().timeZone,"x-inkeep-client-timestamp":new Date().toISOString(),"x-inkeep-invocation-type":"chat_widget",..._?{"x-inkeep-app-id":_}:{},...e?{Authorization:`Bearer ${e}`}:{},...K.current?{"inkeep-filters":K.current}:{},...B.current?{"x-inkeep-user-properties":B.current}:{},...z.current?{"x-inkeep-properties":z.current}:{},...Re.current}},prepareSendMessagesRequest:async e=>{const i=await he.current(),s=e.messages[e.messages.length-1];return s||console.warn("[useInkeepChat] prepareSendMessagesRequest called with empty messages array"),{body:{...e.body,id:e.id,messages:s?[s]:[],trigger:e.trigger,messageId:e.messageId},headers:{...e.headers,...i}}},body:{requestContext:pe}}),[me,pe,_,D]),{messages:I,sendMessage:J,addToolApprovalResponse:V,status:Se,setMessages:p,stop:P,error:q}=Ze.useChat({transport:De,onData(e){M(e.type,e.data)},async onFinish({message:e}){M("completion",{conversationId:u}),await g({eventName:"assistant_message_received",properties:{conversationId:u,messageId:e.id}}),g({eventName:"assistant_answer_displayed",properties:{conversationId:u,messageId:e.id}})},onError(e){console.error("onError",{code:e.code,message:e.message});const i=_e||D?null:f.resolveStreamingAuthError(e);if(i!==null&&v.current<1){v.current++;const a=H.current,r=G.current;(async()=>{if(i==="session"&&oe){const c=await ie();if(!c)throw new Error("Auth token refresh failed");$.current=c}else if(i==="session"){const c=await ue();c&&(U.current=c)}else d();if(a){V(a);return}r&&(p(c=>{let n=[...c];return n.at(-1)?.role==="assistant"&&(n=n.slice(0,-1)),n.at(-1)?.role==="user"&&(n=n.slice(0,-1)),n}),J(r.files?.length?{parts:[{type:"text",text:r.content},...r.files]}:{text:r.content},{body:r.body}))})().catch(()=>{v.current=0,d(),p(c=>{const n=[...c],T=n[n.length-1];if(!T)return n;const w=f.DEFAULT_ERROR_MESSAGE;return T.role==="user"?n.push({id:N.generateUid(16),role:"assistant",parts:[{type:"text",text:w}]}):T.parts=[{type:"text",text:w}],n})});return}v.current=0,i!==null&&d();const s=f.isRecoverableError(e),l=Le(e);if(g({eventName:"chat_error",properties:{conversationId:u,messageId:I.at(-1)?.id,error:e.message}}),s){Y({title:"Request failed",message:l},f.RECOVERABLE_NOTIFICATION_DURATION_MS),p(r=>{let o=[...r];return o.at(-1)?.role==="assistant"&&(o=o.slice(0,-1)),o.at(-1)?.role==="user"&&(o=o.slice(0,-1)),o});const a=G.current?.content;a&&S(a),X.current=e;return}p(a=>{const r=[...a],o=r[r.length-1];return o&&(o.role==="user"?r.push({id:N.generateUid(16),role:"assistant",parts:[{type:"text",text:l}]}):o.parts=[{type:"text",text:l}]),r})}}),Ee=t.useRef(m);t.useEffect(()=>{const e=Ee.current;Ee.current=m,e!==m&&(P(),A(null),p([]),h(""),S(""),j([]),d())},[m,P,p,h,d]);const Ce=Se==="submitted",Q=Se==="streaming",Ue=t.useMemo(()=>{const e=a=>{if(!a||typeof a!="object")return!1;const r=a;return typeof r.type=="string"&&r.type.startsWith("tool-")},s=[...I??[]].reverse().find(a=>a.role==="assistant");if(!s)return!1;const l=s.parts?.at(-1);return!(!e(l)||l.state!=="output-available"||!l.approval?.id||Q)},[I,Q]),[$e,W]=t.useState(!1),Ie=Q||Ue&&!$e,Ae=Ce||Ie,Be=I.length===0,Z=!R.trim()&&x.length===0||Ae,ze=tt.useMediaQuery("(max-width: 768px)"),[Ge,A]=t.useState(null),X=t.useRef(null);t.useEffect(()=>{if(q){if(X.current===q){X.current=null;return}A(q)}},[q]);const He=()=>A(null),{inputNotification:Ke,showInputNotification:Y,clearInputNotification:je}=ut.useInputNotification(),be=t.useRef(null);t.useEffect(()=>{Pe?.(R)},[R]);const Je=e=>{e.key==="Enter"&&!e.shiftKey&&!Z&&!e.nativeEvent.isComposing&&(e.preventDefault(),ee())},ee=async(e=R)=>{if(Z&&(!e||e.trim().length===0)&&x.length===0)return;const i=x;j([]),S(""),v.current=0,H.current=null,W(!1);let s=u;s||(s=`conv_${N.generateUid(16)}`,h(s)),Me(s),await g({eventName:"user_message_submitted",properties:{conversationId:s}});const l=C.current;C.current=void 0;let a,r;if(l?.length){let o;try{o=await Promise.all(i.map(c=>{const n=ke.normalizeFileType(c);return new Promise((T,w)=>{const k=new FileReader;k.onload=()=>{if(typeof k.result!="string"){w(new Error(`Failed to read file "${n.name}"`));return}T({type:"file",url:k.result,mediaType:n.type,filename:n.name})},k.onerror=()=>w(new Error(`Failed to read file "${n.name}"`)),k.readAsDataURL(n)})}))}catch{Y({title:"Failed to attach files",message:"Could not read one or more files. Please try again."});return}r=[...o,...l],a=e.trim()?{parts:[{type:"text",text:e},...r]}:{parts:r}}else if(i.length>0){const o=new DataTransfer;for(const n of i)o.items.add(ke.normalizeFileType(n));const c=o.files;a=e.trim()?{text:e,files:c}:{files:c}}else a={text:e};G.current={content:e,body:{conversationId:s},files:r},J(a,{body:{conversationId:s}})},Ve=t.useCallback(e=>{v.current=0,H.current=e,W(!1),V(e)},[V]),te=t.useCallback(()=>{W(!0),P().then(()=>{M("aborted",{conversationId:u})})},[P,u,M]),Te=()=>{He(),p([]),h(""),d(),C.current=E?.length?E:void 0,g({eventName:"chat_clear_button_clicked",properties:{conversationId:u}})},b=t.useCallback((e,i)=>{A(null),p(i),h(e),d(),C.current=void 0},[p,h,d]),we=t.useCallback(async(e,i)=>{te(),b(e,[]),ye(!0);try{const s=await ve(e,i);if(s===null)return!1;const a=s[s.length-1]?.role==="user"?[...s,{id:N.generateUid(16),role:"assistant",parts:[{type:"text",text:"This session was interrupted. Please check back in a few minutes or start a new conversation."}]}]:s;return b(e,a),!0}finally{i?.aborted||ye(!1)}},[b,ve,te]);rt.useInitialConversation({conversationId:y.conversationId,effectiveAuthToken:le,loadAndRestoreSession:we,onLoadFailed:()=>b("",[])});const{openForm:Qe}=at.useChatForm(),We=ot.useWidget();return t.useImperativeHandle(y.chatFunctionsRef,()=>({submitMessage:ee,updateInputMessage(e){S(e)},clearChat:Te,openForm:e=>{We?.setView("chat"),Qe(e,void 0)},focusInput:()=>{be.current?.focus()}})),{messages:I,sendMessage:J,addToolApprovalResponse:Ve,isLoading:Ce,isStreaming:Ie,isBusy:Ae,error:Ge,setError:A,isSubmitDisabled:Z,input:R,handleInputChange:Fe,handleInputKeyDown:Je,handleSubmit:ee,stop:te,clear:Te,inputRef:be,isMobile:ze,files:x,setFiles:j,isNewChat:Be,conversationId:u,restoreSession:b,loadAndRestoreSession:we,isSessionLoading:Ne,authToken:m?ae:ce,refreshSession:m?ie:ue,getCaptchaHeader:F,invalidateCaptcha:d,inputNotification:Ke,showInputNotification:Y,clearInputNotification:je}};exports.useInkeepChat=lt;
@@ -1,90 +1,92 @@
1
1
  "use client";
2
- import { useChat as tt } from "@ai-sdk/react";
2
+ import { useChat as st } from "@ai-sdk/react";
3
3
  import { normalizeFileType as Fe } from "./file-upload-input.js";
4
- import { DefaultChatTransport as st } from "ai";
5
- import { useRef as l, useEffect as x, useState as M, useMemo as _e, useCallback as L, useImperativeHandle as rt } from "react";
6
- import { useInkeepConfig as nt } from "../../providers/config-provider.js";
7
- import { useChatAuth as ot } from "../../providers/chat-auth-provider.js";
8
- import { useMediaQuery as at } from "../../hooks/use-media-query.js";
9
- import { useConversationLoader as it } from "../../hooks/use-conversation-loader.js";
10
- import { useInitialConversation as lt } from "../../hooks/use-initial-conversation.js";
11
- import { generateUid as $ } from "../../utils/generate-uid.js";
12
- import { useBaseEvents as ct } from "../../providers/base-events-provider.js";
13
- import { useChatForm as ut } from "../../providers/chat-form-provider.js";
14
- import { useWidget as pt } from "../../providers/widget-provider.js";
15
- import { useControllableState as dt } from "@radix-ui/react-use-controllable-state";
16
- import { useStreamingEvents as ft } from "../../hooks/use-streaming-events.js";
17
- import { useInputNotification as mt } from "../../hooks/use-input-notification.js";
18
- import { resolveStreamingAuthError as gt, DEFAULT_ERROR_MESSAGE as ie, isRecoverableError as ht, RECOVERABLE_NOTIFICATION_DURATION_MS as vt, resolveHttpStatusCode as yt, RATE_LIMIT_MESSAGE as Ct, RECOVERABLE_FALLBACK_MESSAGE as Ne } from "./chat-error-helpers.js";
19
- const Lt = () => {
20
- const { baseSettings: le, aiChatSettings: v } = nt(), [c = "", g] = dt({
4
+ import { DefaultChatTransport as rt } from "ai";
5
+ import { useRef as l, useEffect as k, useState as x, useMemo as _e, useCallback as D, useImperativeHandle as nt } from "react";
6
+ import { useInkeepConfig as ot } from "../../providers/config-provider.js";
7
+ import { useChatAuth as at } from "../../providers/chat-auth-provider.js";
8
+ import { useMediaQuery as it } from "../../hooks/use-media-query.js";
9
+ import { useConversationLoader as lt } from "../../hooks/use-conversation-loader.js";
10
+ import { useInitialConversation as ct } from "../../hooks/use-initial-conversation.js";
11
+ import { generateUid as L } from "../../utils/generate-uid.js";
12
+ import { useBaseEvents as ut } from "../../providers/base-events-provider.js";
13
+ import { useChatForm as pt } from "../../providers/chat-form-provider.js";
14
+ import { useWidget as dt } from "../../providers/widget-provider.js";
15
+ import { useControllableState as ft } from "@radix-ui/react-use-controllable-state";
16
+ import { useStreamingEvents as mt } from "../../hooks/use-streaming-events.js";
17
+ import { useInputNotification as gt } from "../../hooks/use-input-notification.js";
18
+ import { resolveStreamingAuthError as ht, DEFAULT_ERROR_MESSAGE as ne, isRecoverableError as vt, RECOVERABLE_NOTIFICATION_DURATION_MS as yt, resolveHttpStatusCode as Ct, RATE_LIMIT_MESSAGE as It, RECOVERABLE_FALLBACK_MESSAGE as Ne } from "./chat-error-helpers.js";
19
+ const $t = () => {
20
+ const { baseSettings: oe, aiChatSettings: v } = ot(), [c = "", m] = ft({
21
21
  prop: v.conversationIdOverride,
22
22
  defaultProp: v.conversationIdOverride ?? ""
23
- }), { logEvent: m } = ct(), { setConversationId: Pe, emitToParent: F } = ft(), ce = l(c);
24
- x(() => {
25
- const e = ce.current;
26
- ce.current = c, e !== c && m({
23
+ }), { logEvent: f } = ut(), { setConversationId: Pe, emitToParent: M } = mt(), ae = l(c);
24
+ k(() => {
25
+ const e = ae.current;
26
+ ae.current = c, e !== c && f({
27
27
  eventName: "chat_conversation_changed",
28
28
  properties: {
29
29
  conversationId: c,
30
30
  previousConversationId: e
31
31
  }
32
32
  });
33
- }, [c, m]);
34
- const [y, C] = M(""), Oe = (e) => C(e.target.value), {
33
+ }, [c, f]);
34
+ const [y, C] = x(""), Oe = (e) => C(e.target.value), {
35
35
  shouldBypassCaptcha: De,
36
- filters: ue,
37
- userProperties: B,
38
- analyticsProperties: U
39
- } = le, {
40
- authToken: z,
41
- isAuthenticated: f,
42
- isAuthConfigured: pe,
43
- refreshAuthToken: de,
44
- sessionToken: H,
45
- refreshSession: K,
46
- getCaptchaHeader: _,
47
- invalidateCaptcha: p
48
- } = ot(), {
49
- onInputMessageChange: Le,
50
- filters: fe,
51
- baseUrl: me,
52
- agentUrl: $e,
53
- context: ge,
54
- headers: he,
55
- appId: N,
56
- apiKey: I,
57
- files: R
58
- } = v, ve = l(_);
59
- ve.current = _;
60
- const ye = $e || `${me}/run/api/chat`, Ce = I ?? (f ? z : H), { loadConversation: Ie } = it({
61
- baseUrl: me,
62
- appId: N,
63
- authToken: Ce,
64
- getCaptchaHeader: _,
36
+ filters: ie,
37
+ userProperties: $,
38
+ analyticsProperties: B
39
+ } = oe, {
40
+ authToken: le,
41
+ isAuthenticated: g,
42
+ isAuthConfigured: ce,
43
+ refreshAuthToken: ue,
44
+ sessionToken: pe,
45
+ refreshSession: de,
46
+ getCaptchaHeader: F,
65
47
  invalidateCaptcha: p,
66
- refreshSession: I || f ? void 0 : K
67
- }), [Be, Re] = M(!1), q = l(null);
68
- q.current = H;
69
- const J = l(null);
70
- J.current = z;
71
- const j = l(void 0);
72
- j.current = B && Object.keys(B).length > 0 ? JSON.stringify(B) : void 0;
73
- const G = l(void 0);
74
- G.current = U && Object.keys(U).length > 0 ? JSON.stringify(U) : void 0;
75
- const h = l(0), V = l(null), W = l(null), S = l(void 0), Ue = R?.map(
48
+ effectiveAuthToken: fe,
49
+ applicableRefreshSession: Le
50
+ } = at(), {
51
+ onInputMessageChange: $e,
52
+ filters: me,
53
+ baseUrl: ge,
54
+ agentUrl: Be,
55
+ context: he,
56
+ headers: ve,
57
+ appId: _,
58
+ apiKey: U,
59
+ files: I
60
+ } = v, ye = l(F);
61
+ ye.current = F;
62
+ const Ce = Be || `${ge}/run/api/chat`, { loadConversation: Ie } = lt({
63
+ baseUrl: ge,
64
+ appId: _,
65
+ authToken: fe,
66
+ getCaptchaHeader: F,
67
+ invalidateCaptcha: p,
68
+ refreshSession: Le
69
+ }), [Ue, Re] = x(!1), z = l(null);
70
+ z.current = pe;
71
+ const H = l(null);
72
+ H.current = le;
73
+ const K = l(void 0);
74
+ K.current = $ && Object.keys($).length > 0 ? JSON.stringify($) : void 0;
75
+ const q = l(void 0);
76
+ q.current = B && Object.keys(B).length > 0 ? JSON.stringify(B) : void 0;
77
+ const h = l(0), J = l(null), j = l(null), R = l(void 0), ze = I?.map(
76
78
  (e) => `${e.filename ?? ""}:${e.mediaType}:${e.url.length}:${e.url.slice(0, 64)}:${e.url.slice(-32)}`
77
79
  ).join(`
78
80
  `) ?? "";
79
- x(() => {
80
- S.current = R?.length ? R : void 0;
81
- }, [Ue]);
82
- const Se = l(he);
83
- Se.current = he;
84
- const Q = l(void 0);
85
- Q.current = ue || fe ? JSON.stringify({ ...ue, ...fe }) : void 0;
86
- const ze = (e) => {
87
- switch (yt(e)) {
81
+ k(() => {
82
+ R.current = I?.length ? I : void 0;
83
+ }, [ze]);
84
+ const Se = l(ve);
85
+ Se.current = ve;
86
+ const G = l(void 0);
87
+ G.current = ie || me ? JSON.stringify({ ...ie, ...me }) : void 0;
88
+ const He = (e) => {
89
+ switch (Ct(e)) {
88
90
  case 400:
89
91
  try {
90
92
  const t = JSON.parse(e.message ?? "");
@@ -93,33 +95,33 @@ const Lt = () => {
93
95
  return e.message?.trim() || Ne;
94
96
  }
95
97
  case 401:
96
- return pe ? "Authentication failed. Please try again." : ie;
98
+ return ce ? "Authentication failed. Please try again." : ne;
97
99
  case 403:
98
- return `There seems to be a configuration error. Please contact ${le.organizationDisplayName ?? "Administrator"}`;
100
+ return `There seems to be a configuration error. Please contact ${oe.organizationDisplayName ?? "Administrator"}`;
99
101
  case 429:
100
- return Ct;
102
+ return It;
101
103
  default:
102
- return ie;
104
+ return ne;
103
105
  }
104
- }, [P, Z] = M([]), He = _e(
105
- () => new st({
106
- api: ye,
106
+ }, [N, V] = x([]), Ke = _e(
107
+ () => new rt({
108
+ api: Ce,
107
109
  headers: () => {
108
- const e = I ?? J.current ?? q.current;
110
+ const e = U ?? H.current ?? z.current;
109
111
  return {
110
112
  "x-inkeep-client-timezone": Intl.DateTimeFormat().resolvedOptions().timeZone,
111
113
  "x-inkeep-client-timestamp": (/* @__PURE__ */ new Date()).toISOString(),
112
114
  "x-inkeep-invocation-type": "chat_widget",
113
- ...N ? { "x-inkeep-app-id": N } : {},
115
+ ..._ ? { "x-inkeep-app-id": _ } : {},
114
116
  ...e ? { Authorization: `Bearer ${e}` } : {},
115
- ...Q.current ? { "inkeep-filters": Q.current } : {},
116
- ...j.current ? { "x-inkeep-user-properties": j.current } : {},
117
- ...G.current ? { "x-inkeep-properties": G.current } : {},
117
+ ...G.current ? { "inkeep-filters": G.current } : {},
118
+ ...K.current ? { "x-inkeep-user-properties": K.current } : {},
119
+ ...q.current ? { "x-inkeep-properties": q.current } : {},
118
120
  ...Se.current
119
121
  };
120
122
  },
121
123
  prepareSendMessagesRequest: async (e) => {
122
- const a = await ve.current(), t = e.messages[e.messages.length - 1];
124
+ const a = await ye.current(), t = e.messages[e.messages.length - 1];
123
125
  return t || console.warn(
124
126
  "[useInkeepChat] prepareSendMessagesRequest called with empty messages array"
125
127
  ), {
@@ -137,31 +139,31 @@ const Lt = () => {
137
139
  };
138
140
  },
139
141
  body: {
140
- requestContext: ge
142
+ requestContext: he
141
143
  }
142
144
  }),
143
- [ye, ge, N, I]
145
+ [Ce, he, _, U]
144
146
  ), {
145
- messages: w,
146
- sendMessage: X,
147
- addToolApprovalResponse: Y,
147
+ messages: S,
148
+ sendMessage: W,
149
+ addToolApprovalResponse: Q,
148
150
  status: we,
149
151
  setMessages: d,
150
- stop: O,
151
- error: D
152
- } = tt({
153
- transport: He,
152
+ stop: P,
153
+ error: O
154
+ } = st({
155
+ transport: Ke,
154
156
  onData(e) {
155
- F(e.type, e.data);
157
+ M(e.type, e.data);
156
158
  },
157
159
  async onFinish({ message: e }) {
158
- F("completion", { conversationId: c }), await m({
160
+ M("completion", { conversationId: c }), await f({
159
161
  eventName: "assistant_message_received",
160
162
  properties: {
161
163
  conversationId: c,
162
164
  messageId: e.id
163
165
  }
164
- }), m({
166
+ }), f({
165
167
  eventName: "assistant_answer_displayed",
166
168
  properties: {
167
169
  conversationId: c,
@@ -171,118 +173,118 @@ const Lt = () => {
171
173
  },
172
174
  onError(e) {
173
175
  console.error("onError", { code: e.code, message: e.message });
174
- const a = De || I ? null : gt(e);
176
+ const a = De || U ? null : ht(e);
175
177
  if (a !== null && h.current < 1) {
176
178
  h.current++;
177
- const n = W.current, s = V.current;
179
+ const n = j.current, s = J.current;
178
180
  (async () => {
179
- if (a === "session" && pe) {
180
- const i = await de();
181
+ if (a === "session" && ce) {
182
+ const i = await ue();
181
183
  if (!i) throw new Error("Auth token refresh failed");
182
- J.current = i;
184
+ H.current = i;
183
185
  } else if (a === "session") {
184
- const i = await K();
185
- i && (q.current = i);
186
+ const i = await de();
187
+ i && (z.current = i);
186
188
  } else
187
189
  p();
188
190
  if (n) {
189
- Y(n);
191
+ Q(n);
190
192
  return;
191
193
  }
192
194
  s && (d((i) => {
193
195
  let r = [...i];
194
196
  return r.at(-1)?.role === "assistant" && (r = r.slice(0, -1)), r.at(-1)?.role === "user" && (r = r.slice(0, -1)), r;
195
- }), X(
197
+ }), W(
196
198
  s.files?.length ? { parts: [{ type: "text", text: s.content }, ...s.files] } : { text: s.content },
197
199
  { body: s.body }
198
200
  ));
199
201
  })().catch(() => {
200
202
  h.current = 0, p(), d((i) => {
201
- const r = [...i], E = r[r.length - 1];
202
- if (!E) return r;
203
- const T = ie;
204
- return E.role === "user" ? r.push({
205
- id: $(16),
203
+ const r = [...i], b = r[r.length - 1];
204
+ if (!b) return r;
205
+ const E = ne;
206
+ return b.role === "user" ? r.push({
207
+ id: L(16),
206
208
  role: "assistant",
207
- parts: [{ type: "text", text: T }]
208
- }) : E.parts = [{ type: "text", text: T }], r;
209
+ parts: [{ type: "text", text: E }]
210
+ }) : b.parts = [{ type: "text", text: E }], r;
209
211
  });
210
212
  });
211
213
  return;
212
214
  }
213
215
  h.current = 0, a !== null && p();
214
- const t = ht(e), u = ze(e);
215
- if (m({
216
+ const t = vt(e), u = He(e);
217
+ if (f({
216
218
  eventName: "chat_error",
217
219
  properties: {
218
220
  conversationId: c,
219
- messageId: w.at(-1)?.id,
221
+ messageId: S.at(-1)?.id,
220
222
  error: e.message
221
223
  }
222
224
  }), t) {
223
- ne(
225
+ te(
224
226
  { title: "Request failed", message: u },
225
- vt
227
+ yt
226
228
  ), d((s) => {
227
229
  let o = [...s];
228
230
  return o.at(-1)?.role === "assistant" && (o = o.slice(0, -1)), o.at(-1)?.role === "user" && (o = o.slice(0, -1)), o;
229
231
  });
230
- const n = V.current?.content;
231
- n && C(n), re.current = e;
232
+ const n = J.current?.content;
233
+ n && C(n), ee.current = e;
232
234
  return;
233
235
  }
234
236
  d((n) => {
235
237
  const s = [...n], o = s[s.length - 1];
236
238
  return o && (o.role === "user" ? s.push({
237
- id: $(16),
239
+ id: L(16),
238
240
  role: "assistant",
239
241
  parts: [{ type: "text", text: u }]
240
242
  }) : o.parts = [{ type: "text", text: u }]), s;
241
243
  });
242
244
  }
243
- }), Ae = l(f);
244
- x(() => {
245
+ }), Ae = l(g);
246
+ k(() => {
245
247
  const e = Ae.current;
246
- Ae.current = f, e !== f && (O(), A(null), d([]), g(""), C(""), Z([]), p());
247
- }, [f, O, d, g, p]);
248
- const be = we === "submitted", ee = we === "streaming", Ke = _e(() => {
248
+ Ae.current = g, e !== g && (P(), w(null), d([]), m(""), C(""), V([]), p());
249
+ }, [g, P, d, m, p]);
250
+ const be = we === "submitted", Z = we === "streaming", qe = _e(() => {
249
251
  const e = (n) => {
250
252
  if (!n || typeof n != "object") return !1;
251
253
  const s = n;
252
254
  return typeof s.type == "string" && s.type.startsWith("tool-");
253
- }, t = [...w ?? []].reverse().find((n) => n.role === "assistant");
255
+ }, t = [...S ?? []].reverse().find((n) => n.role === "assistant");
254
256
  if (!t) return !1;
255
257
  const u = t.parts?.at(-1);
256
- return !(!e(u) || u.state !== "output-available" || !u.approval?.id || ee);
257
- }, [w, ee]), [qe, te] = M(!1), Ee = ee || Ke && !qe, Te = be || Ee, Je = w.length === 0, se = !y.trim() && P.length === 0 || Te, je = at("(max-width: 768px)"), [Ge, A] = M(null), re = l(null);
258
- x(() => {
259
- if (D) {
260
- if (re.current === D) {
261
- re.current = null;
258
+ return !(!e(u) || u.state !== "output-available" || !u.approval?.id || Z);
259
+ }, [S, Z]), [Je, X] = x(!1), Ee = Z || qe && !Je, Te = be || Ee, je = S.length === 0, Y = !y.trim() && N.length === 0 || Te, Ge = it("(max-width: 768px)"), [Ve, w] = x(null), ee = l(null);
260
+ k(() => {
261
+ if (O) {
262
+ if (ee.current === O) {
263
+ ee.current = null;
262
264
  return;
263
265
  }
264
- A(D);
266
+ w(O);
265
267
  }
266
- }, [D]);
267
- const Ve = () => A(null), { inputNotification: We, showInputNotification: ne, clearInputNotification: Qe } = mt(), ke = l(null);
268
- x(() => {
269
- Le?.(y);
268
+ }, [O]);
269
+ const We = () => w(null), { inputNotification: Qe, showInputNotification: te, clearInputNotification: Ze } = gt(), ke = l(null);
270
+ k(() => {
271
+ $e?.(y);
270
272
  }, [y]);
271
- const Ze = (e) => {
272
- e.key === "Enter" && !e.shiftKey && !se && !e.nativeEvent.isComposing && (e.preventDefault(), oe());
273
- }, oe = async (e = y) => {
274
- if (se && (!e || e.trim().length === 0) && P.length === 0) return;
275
- const a = P;
276
- Z([]), C(""), h.current = 0, W.current = null, te(!1);
273
+ const Xe = (e) => {
274
+ e.key === "Enter" && !e.shiftKey && !Y && !e.nativeEvent.isComposing && (e.preventDefault(), se());
275
+ }, se = async (e = y) => {
276
+ if (Y && (!e || e.trim().length === 0) && N.length === 0) return;
277
+ const a = N;
278
+ V([]), C(""), h.current = 0, j.current = null, X(!1);
277
279
  let t = c;
278
- t || (t = `conv_${$(16)}`, g(t)), Pe(t), await m({
280
+ t || (t = `conv_${L(16)}`, m(t)), Pe(t), await f({
279
281
  eventName: "user_message_submitted",
280
282
  properties: {
281
283
  conversationId: t
282
284
  }
283
285
  });
284
- const u = S.current;
285
- S.current = void 0;
286
+ const u = R.current;
287
+ R.current = void 0;
286
288
  let n, s;
287
289
  if (u?.length) {
288
290
  let o;
@@ -290,25 +292,25 @@ const Lt = () => {
290
292
  o = await Promise.all(
291
293
  a.map((i) => {
292
294
  const r = Fe(i);
293
- return new Promise((E, T) => {
294
- const k = new FileReader();
295
- k.onload = () => {
296
- if (typeof k.result != "string") {
297
- T(new Error(`Failed to read file "${r.name}"`));
295
+ return new Promise((b, E) => {
296
+ const T = new FileReader();
297
+ T.onload = () => {
298
+ if (typeof T.result != "string") {
299
+ E(new Error(`Failed to read file "${r.name}"`));
298
300
  return;
299
301
  }
300
- E({
302
+ b({
301
303
  type: "file",
302
- url: k.result,
304
+ url: T.result,
303
305
  mediaType: r.type,
304
306
  filename: r.name
305
307
  });
306
- }, k.onerror = () => T(new Error(`Failed to read file "${r.name}"`)), k.readAsDataURL(r);
308
+ }, T.onerror = () => E(new Error(`Failed to read file "${r.name}"`)), T.readAsDataURL(r);
307
309
  });
308
310
  })
309
311
  );
310
312
  } catch {
311
- ne({
313
+ te({
312
314
  title: "Failed to attach files",
313
315
  message: "Could not read one or more files. Please try again."
314
316
  });
@@ -322,44 +324,44 @@ const Lt = () => {
322
324
  n = e.trim() ? { text: e, files: i } : { files: i };
323
325
  } else
324
326
  n = { text: e };
325
- V.current = {
327
+ J.current = {
326
328
  content: e,
327
329
  body: { conversationId: t },
328
330
  files: s
329
- }, X(n, {
331
+ }, W(n, {
330
332
  body: { conversationId: t }
331
333
  });
332
- }, Xe = L(
334
+ }, Ye = D(
333
335
  (e) => {
334
- h.current = 0, W.current = e, te(!1), Y(e);
336
+ h.current = 0, j.current = e, X(!1), Q(e);
335
337
  },
336
- [Y]
337
- ), ae = L(() => {
338
- te(!0), O().then(() => {
339
- F("aborted", { conversationId: c });
338
+ [Q]
339
+ ), re = D(() => {
340
+ X(!0), P().then(() => {
341
+ M("aborted", { conversationId: c });
340
342
  });
341
- }, [O, c, F]), xe = () => {
342
- Ve(), d([]), g(""), p(), S.current = R?.length ? R : void 0, m({
343
+ }, [P, c, M]), xe = () => {
344
+ We(), d([]), m(""), p(), R.current = I?.length ? I : void 0, f({
343
345
  eventName: "chat_clear_button_clicked",
344
346
  properties: {
345
347
  conversationId: c
346
348
  }
347
349
  });
348
- }, b = L(
350
+ }, A = D(
349
351
  (e, a) => {
350
- A(null), d(a), g(e), p(), S.current = void 0;
352
+ w(null), d(a), m(e), p(), R.current = void 0;
351
353
  },
352
- [d, g, p]
353
- ), Me = L(
354
+ [d, m, p]
355
+ ), Me = D(
354
356
  async (e, a) => {
355
- ae(), b(e, []), Re(!0);
357
+ re(), A(e, []), Re(!0);
356
358
  try {
357
359
  const t = await Ie(e, a);
358
360
  if (t === null) return !1;
359
361
  const n = t[t.length - 1]?.role === "user" ? [
360
362
  ...t,
361
363
  {
362
- id: $(16),
364
+ id: L(16),
363
365
  role: "assistant",
364
366
  parts: [
365
367
  {
@@ -369,66 +371,66 @@ const Lt = () => {
369
371
  ]
370
372
  }
371
373
  ] : t;
372
- return b(e, n), !0;
374
+ return A(e, n), !0;
373
375
  } finally {
374
376
  a?.aborted || Re(!1);
375
377
  }
376
378
  },
377
- [b, Ie, ae]
379
+ [A, Ie, re]
378
380
  );
379
- lt({
381
+ ct({
380
382
  conversationId: v.conversationId,
381
- effectiveAuthToken: Ce,
383
+ effectiveAuthToken: fe,
382
384
  loadAndRestoreSession: Me,
383
- onLoadFailed: () => b("", [])
385
+ onLoadFailed: () => A("", [])
384
386
  });
385
- const { openForm: Ye } = ut(), et = pt();
386
- return rt(v.chatFunctionsRef, () => ({
387
- submitMessage: oe,
387
+ const { openForm: et } = pt(), tt = dt();
388
+ return nt(v.chatFunctionsRef, () => ({
389
+ submitMessage: se,
388
390
  updateInputMessage(e) {
389
391
  C(e);
390
392
  },
391
393
  clearChat: xe,
392
394
  openForm: (e) => {
393
- et?.setView("chat"), Ye(e, void 0);
395
+ tt?.setView("chat"), et(e, void 0);
394
396
  },
395
397
  focusInput: () => {
396
398
  ke.current?.focus();
397
399
  }
398
400
  })), {
399
- messages: w,
400
- sendMessage: X,
401
- addToolApprovalResponse: Xe,
401
+ messages: S,
402
+ sendMessage: W,
403
+ addToolApprovalResponse: Ye,
402
404
  isLoading: be,
403
405
  isStreaming: Ee,
404
406
  isBusy: Te,
405
- error: Ge,
406
- setError: A,
407
- isSubmitDisabled: se,
407
+ error: Ve,
408
+ setError: w,
409
+ isSubmitDisabled: Y,
408
410
  input: y,
409
411
  handleInputChange: Oe,
410
- handleInputKeyDown: Ze,
411
- handleSubmit: oe,
412
- stop: ae,
412
+ handleInputKeyDown: Xe,
413
+ handleSubmit: se,
414
+ stop: re,
413
415
  clear: xe,
414
416
  inputRef: ke,
415
- isMobile: je,
416
- files: P,
417
- setFiles: Z,
418
- isNewChat: Je,
417
+ isMobile: Ge,
418
+ files: N,
419
+ setFiles: V,
420
+ isNewChat: je,
419
421
  conversationId: c,
420
- restoreSession: b,
422
+ restoreSession: A,
421
423
  loadAndRestoreSession: Me,
422
- isSessionLoading: Be,
423
- authToken: f ? z : H,
424
- refreshSession: f ? de : K,
425
- getCaptchaHeader: _,
424
+ isSessionLoading: Ue,
425
+ authToken: g ? le : pe,
426
+ refreshSession: g ? ue : de,
427
+ getCaptchaHeader: F,
426
428
  invalidateCaptcha: p,
427
- inputNotification: We,
428
- showInputNotification: ne,
429
- clearInputNotification: Qe
429
+ inputNotification: Qe,
430
+ showInputNotification: te,
431
+ clearInputNotification: Ze
430
432
  };
431
433
  };
432
434
  export {
433
- Lt as useInkeepChat
435
+ $t as useInkeepChat
434
436
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),p=require("./use-inkeep-api-client.cjs"),v=()=>{};function d({baseUrl:e,appId:i,authToken:t,getCaptchaHeader:r,invalidateCaptcha:c,refreshSession:a}){const{fetchWithAuth:o}=p.useInkeepApiClient({appId:i,authToken:t,getCaptchaHeader:r,invalidateCaptcha:c??v,refreshSession:a});return{logEvent:l.useCallback(async({body:u})=>{if(!(!e||!t))try{const n=`${e}/run/v1/events`,s=await o(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});if(!s.ok){console.warn(`[events-api] log failed: ${s.status}`);return}return s.json()}catch(n){console.warn("[events-api] log threw",n)}},[e,t,o])}}exports.useEventsApi=d;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react"),v=require("./use-inkeep-api-client.cjs"),d=()=>{};function f({baseUrl:e,appId:o,authToken:t,getCaptchaHeader:a,invalidateCaptcha:c,refreshSession:r}){const{fetchWithAuth:s}=v.useInkeepApiClient({appId:o,authToken:t,getCaptchaHeader:a,invalidateCaptcha:c??d,refreshSession:r});return{logEvent:p.useCallback(async({body:l})=>{if(!(!e||!t))try{const n=`${e}/run/v1/events`,i=await s(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!i.ok){const u=await i.text().catch(()=>"<unreadable>");console.warn(`[events-api] log failed: ${i.status}`,u)}}catch(n){console.warn("[events-api] log threw",n)}},[e,t,s])}}exports.useEventsApi=f;
@@ -24,6 +24,6 @@ interface LogEventParams {
24
24
  body: LogEventBody;
25
25
  }
26
26
  export declare function useEventsApi({ baseUrl, appId, authToken, getCaptchaHeader, invalidateCaptcha, refreshSession, }: UseEventsApiOptions): {
27
- logEvent: ({ body }: LogEventParams) => Promise<any>;
27
+ logEvent: ({ body }: LogEventParams) => Promise<void>;
28
28
  };
29
29
  export {};
@@ -1,44 +1,43 @@
1
1
  "use client";
2
- import { useCallback as l } from "react";
3
- import { useInkeepApiClient as u } from "./use-inkeep-api-client.js";
4
- const f = () => {
2
+ import { useCallback as u } from "react";
3
+ import { useInkeepApiClient as f } from "./use-inkeep-api-client.js";
4
+ const v = () => {
5
5
  };
6
- function g({
6
+ function m({
7
7
  baseUrl: t,
8
- appId: s,
9
- authToken: n,
10
- getCaptchaHeader: i,
8
+ appId: a,
9
+ authToken: e,
10
+ getCaptchaHeader: s,
11
11
  invalidateCaptcha: c,
12
- refreshSession: a
12
+ refreshSession: r
13
13
  }) {
14
- const { fetchWithAuth: r } = u({
15
- appId: s,
16
- authToken: n,
17
- getCaptchaHeader: i,
18
- invalidateCaptcha: c ?? f,
19
- refreshSession: a
14
+ const { fetchWithAuth: i } = f({
15
+ appId: a,
16
+ authToken: e,
17
+ getCaptchaHeader: s,
18
+ invalidateCaptcha: c ?? v,
19
+ refreshSession: r
20
20
  });
21
- return { logEvent: l(
22
- async ({ body: p }) => {
23
- if (!(!t || !n))
21
+ return { logEvent: u(
22
+ async ({ body: l }) => {
23
+ if (!(!t || !e))
24
24
  try {
25
- const e = `${t}/run/v1/events`, o = await r(e, {
25
+ const n = `${t}/run/v1/events`, o = await i(n, {
26
26
  method: "POST",
27
27
  headers: { "Content-Type": "application/json" },
28
- body: JSON.stringify(p)
28
+ body: JSON.stringify(l)
29
29
  });
30
30
  if (!o.ok) {
31
- console.warn(`[events-api] log failed: ${o.status}`);
32
- return;
31
+ const p = await o.text().catch(() => "<unreadable>");
32
+ console.warn(`[events-api] log failed: ${o.status}`, p);
33
33
  }
34
- return o.json();
35
- } catch (e) {
36
- console.warn("[events-api] log threw", e);
34
+ } catch (n) {
35
+ console.warn("[events-api] log threw", n);
37
36
  }
38
37
  },
39
- [t, n, r]
38
+ [t, e, i]
40
39
  ) };
41
40
  }
42
41
  export {
43
- g as useEventsApi
42
+ m as useEventsApi
44
43
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("react/jsx-runtime"),u=require("react"),S=require("./config-provider.cjs"),T=require("../components/modal/modal-provider.cjs"),m=require("./chat-bubble-provider.cjs"),x=require("./sidebar-chat-provider.cjs"),B=require("../hooks/use-auth-token.cjs"),w=require("../components/embedded-chat/use-captcha.cjs"),I=require("../hooks/use-anonymous-session.cjs"),c=u.createContext(void 0),j=({children:e})=>{const{baseSettings:t,aiChatSettings:h}=S.useInkeepConfig(),{shouldBypassCaptcha:d,privacyPreferences:l}=t,{baseUrl:s,appId:C,apiKey:p}=h,A=T.useModal(),b=m.useOptionalChatBubble(),v=x.useOptionalSidebarChat(),g=A?.isOpen??b?.isOpen??v?.isOpen??!0,{authToken:n,isLoading:o,refreshToken:q}=B.useAuthToken(),y=!!t.getAuthToken,r=!!n,{getCaptchaHeader:a,invalidate:i}=w.useCaptcha({baseUrl:s,shouldBypassCaptcha:d||!!p,shouldMakeInitialRequest:g}),{sessionToken:P,refreshSession:f}=I.useAnonymousSession({baseUrl:s,appId:C,getCaptchaHeader:a,invalidateCaptcha:i,optOutAllAnalytics:l?.optOutAllAnalytics,enabled:!r&&!o}),k={authToken:n,isAuthenticated:r,isAuthLoading:o,isAuthConfigured:y,refreshAuthToken:q,sessionToken:P,refreshSession:f,getCaptchaHeader:a,invalidateCaptcha:i};return O.jsx(c.Provider,{value:k,children:e})},M=()=>{const e=u.useContext(c);if(!e)throw new Error("useChatAuth must be used within a ChatAuthProvider");return e};exports.ChatAuthProvider=j;exports.useChatAuth=M;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react/jsx-runtime"),d=require("react"),T=require("./config-provider.cjs"),O=require("../components/modal/modal-provider.cjs"),m=require("./chat-bubble-provider.cjs"),x=require("./sidebar-chat-provider.cjs"),B=require("../hooks/use-auth-token.cjs"),R=require("../components/embedded-chat/use-captcha.cjs"),w=require("../hooks/use-anonymous-session.cjs"),l=d.createContext(void 0),I=({children:e})=>{const{baseSettings:n,aiChatSettings:p}=T.useInkeepConfig(),{shouldBypassCaptcha:C,privacyPreferences:A}=n,{baseUrl:i,appId:b,apiKey:s}=p,v=O.useModal(),f=m.useOptionalChatBubble(),g=x.useOptionalSidebarChat(),k=v?.isOpen??f?.isOpen??g?.isOpen??!0,{authToken:o,isLoading:a,refreshToken:q}=B.useAuthToken(),y=!!n.getAuthToken,t=!!o,{getCaptchaHeader:r,invalidate:u}=R.useCaptcha({baseUrl:i,shouldBypassCaptcha:C||!!s,shouldMakeInitialRequest:k}),{sessionToken:c,refreshSession:h}=w.useAnonymousSession({baseUrl:i,appId:b,getCaptchaHeader:r,invalidateCaptcha:u,optOutAllAnalytics:A?.optOutAllAnalytics,enabled:!t&&!a}),P={authToken:o,isAuthenticated:t,isAuthLoading:a,isAuthConfigured:y,refreshAuthToken:q,sessionToken:c,refreshSession:h,getCaptchaHeader:r,invalidateCaptcha:u,effectiveAuthToken:s??(t?o:c),applicableRefreshSession:s||t?void 0:h};return S.jsx(l.Provider,{value:P,children:e})},j=()=>{const e=d.useContext(l);if(!e)throw new Error("useChatAuth must be used within a ChatAuthProvider");return e};exports.ChatAuthProvider=I;exports.useChatAuth=j;
@@ -8,6 +8,18 @@ export interface ChatAuthContextValue {
8
8
  refreshSession: () => Promise<string | null>;
9
9
  getCaptchaHeader: () => Promise<Record<string, string>>;
10
10
  invalidateCaptcha: () => void;
11
+ /**
12
+ * Resolved bearer token, in priority order:
13
+ * apiKey ?? (isAuthenticated ? authToken : sessionToken)
14
+ * This is what should be sent as `Authorization: Bearer <token>` for run API calls.
15
+ */
16
+ effectiveAuthToken: string | null;
17
+ /**
18
+ * The `refreshSession` callback to pass into `useInkeepApiClient` for 401 retries.
19
+ * Undefined when `apiKey` or JWT auth is in use, since neither has an anonymous
20
+ * session to refresh — in those modes a 401 is terminal and shouldn't retry.
21
+ */
22
+ applicableRefreshSession: (() => Promise<string | null>) | undefined;
11
23
  }
12
24
  export declare const ChatAuthProvider: React.FC<{
13
25
  children: React.ReactNode;
@@ -1,44 +1,46 @@
1
1
  "use client";
2
- import { jsx as y } from "react/jsx-runtime";
3
- import { useContext as x, createContext as T } from "react";
4
- import { useInkeepConfig as S } from "./config-provider.js";
2
+ import { jsx as T } from "react/jsx-runtime";
3
+ import { useContext as y, createContext as S } from "react";
4
+ import { useInkeepConfig as x } from "./config-provider.js";
5
5
  import { useModal as w } from "../components/modal/modal-provider.js";
6
6
  import { useOptionalChatBubble as B } from "./chat-bubble-provider.js";
7
7
  import { useOptionalSidebarChat as I } from "./sidebar-chat-provider.js";
8
8
  import { useAuthToken as P } from "../hooks/use-auth-token.js";
9
- import { useCaptcha as L } from "../components/embedded-chat/use-captcha.js";
10
- import { useAnonymousSession as M } from "../hooks/use-anonymous-session.js";
11
- const u = T(void 0), F = ({ children: t }) => {
12
- const { baseSettings: e, aiChatSettings: h } = S(), { shouldBypassCaptcha: c, privacyPreferences: p } = e, { baseUrl: o, appId: d, apiKey: l } = h, m = w(), C = B(), f = I(), A = m?.isOpen ?? C?.isOpen ?? f?.isOpen ?? !0, { authToken: s, isLoading: n, refreshToken: b } = P(), g = !!e.getAuthToken, a = !!s, { getCaptchaHeader: i, invalidate: r } = L({
13
- baseUrl: o,
14
- shouldBypassCaptcha: c || !!l,
15
- shouldMakeInitialRequest: A
16
- }), { sessionToken: k, refreshSession: v } = M({
17
- baseUrl: o,
18
- appId: d,
19
- getCaptchaHeader: i,
20
- invalidateCaptcha: r,
21
- optOutAllAnalytics: p?.optOutAllAnalytics,
22
- enabled: !a && !n
9
+ import { useCaptcha as R } from "../components/embedded-chat/use-captcha.js";
10
+ import { useAnonymousSession as L } from "../hooks/use-anonymous-session.js";
11
+ const p = S(void 0), J = ({ children: t }) => {
12
+ const { baseSettings: n, aiChatSettings: l } = x(), { shouldBypassCaptcha: d, privacyPreferences: f } = n, { baseUrl: i, appId: m, apiKey: o } = l, C = w(), A = B(), b = I(), v = C?.isOpen ?? A?.isOpen ?? b?.isOpen ?? !0, { authToken: s, isLoading: a, refreshToken: k } = P(), g = !!n.getAuthToken, e = !!s, { getCaptchaHeader: r, invalidate: u } = R({
13
+ baseUrl: i,
14
+ shouldBypassCaptcha: d || !!o,
15
+ shouldMakeInitialRequest: v
16
+ }), { sessionToken: h, refreshSession: c } = L({
17
+ baseUrl: i,
18
+ appId: m,
19
+ getCaptchaHeader: r,
20
+ invalidateCaptcha: u,
21
+ optOutAllAnalytics: f?.optOutAllAnalytics,
22
+ enabled: !e && !a
23
23
  }), O = {
24
24
  authToken: s,
25
- isAuthenticated: a,
26
- isAuthLoading: n,
25
+ isAuthenticated: e,
26
+ isAuthLoading: a,
27
27
  isAuthConfigured: g,
28
- refreshAuthToken: b,
29
- sessionToken: k,
30
- refreshSession: v,
31
- getCaptchaHeader: i,
32
- invalidateCaptcha: r
28
+ refreshAuthToken: k,
29
+ sessionToken: h,
30
+ refreshSession: c,
31
+ getCaptchaHeader: r,
32
+ invalidateCaptcha: u,
33
+ effectiveAuthToken: o ?? (e ? s : h),
34
+ applicableRefreshSession: o || e ? void 0 : c
33
35
  };
34
- return /* @__PURE__ */ y(u.Provider, { value: O, children: t });
35
- }, G = () => {
36
- const t = x(u);
36
+ return /* @__PURE__ */ T(p.Provider, { value: O, children: t });
37
+ }, N = () => {
38
+ const t = y(p);
37
39
  if (!t)
38
40
  throw new Error("useChatAuth must be used within a ChatAuthProvider");
39
41
  return t;
40
42
  };
41
43
  export {
42
- F as ChatAuthProvider,
43
- G as useChatAuth
44
+ J as ChatAuthProvider,
45
+ N as useChatAuth
44
46
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("react/jsx-runtime"),P=require("react"),x=require("./config-provider.cjs"),N=require("./chat-auth-provider.cjs"),M=require("../hooks/use-events-api.cjs"),R=require("./base-events-provider.cjs"),w=({children:f})=>{const{baseSettings:o,aiChatSettings:m,componentType:r}=x.useInkeepConfig(),{tags:i,analyticsProperties:a,privacyPreferences:A,userProperties:e}=o,c="0.16.1",p=P.useMemo(()=>({widgetLibraryVersion:c,componentType:r,tags:i}),[r,i,c]),{authToken:E,isAuthenticated:v,sessionToken:b,refreshSession:C,getCaptchaHeader:I,invalidateCaptcha:k}=N.useChatAuth(),{apiKey:u,baseUrl:T,appId:q,analyticsApiBaseUrl:S}=m,n=u??(v?E:b),d=A?.optOutAllAnalytics??!1,{logEvent:l}=M.useEventsApi({baseUrl:S??T,appId:q,authToken:n,getCaptchaHeader:I,invalidateCaptcha:k,refreshSession:u||v?void 0:C}),j={logEvent:P.useCallback(async t=>{const g={...p,...t.properties,...a},B={eventName:t.eventName,properties:g};if(!d&&n){const s=t.properties??{},h=typeof s.conversationId=="string"?s.conversationId:void 0,y=typeof s.messageId=="string"?s.messageId:void 0,O=!!e&&Object.keys(e).length>0;l({body:{type:t.eventName,...h?{conversationId:h}:{},...y?{messageId:y}:{},...O?{userProperties:e}:{},properties:g}})}return o.onEvent?.(B)},[o,p,a,l,d,n,e])};return U.jsx(R.BaseEventsContext.Provider,{value:j,children:f})};exports.ChatBaseEventsProvider=w;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("react/jsx-runtime"),h=require("react"),j=require("./config-provider.cjs"),w=require("./chat-auth-provider.cjs"),B=require("../hooks/use-events-api.cjs"),O=require("./base-events-provider.cjs"),U=({children:y})=>{const{baseSettings:n,aiChatSettings:P,componentType:r}=j.useInkeepConfig(),{tags:a,analyticsProperties:i,privacyPreferences:b,userProperties:t}=n,c="0.16.1",p=h.useMemo(()=>({widgetLibraryVersion:c,componentType:r,tags:a}),[r,a,c]),{effectiveAuthToken:o,applicableRefreshSession:f,getCaptchaHeader:m,invalidateCaptcha:E}=w.useChatAuth(),{baseUrl:A,appId:C,analyticsApiBaseUrl:I}=P,v=b?.optOutAllAnalytics??!1,{logEvent:l}=B.useEventsApi({baseUrl:I??A,appId:C,authToken:o,getCaptchaHeader:m,invalidateCaptcha:E,refreshSession:f}),k={logEvent:h.useCallback(async s=>{const u={...p,...s.properties,...i},q={eventName:s.eventName,properties:u};if(!v&&o){const e=s.properties??{},d=typeof e.conversationId=="string"?e.conversationId:void 0,g=typeof e.messageId=="string"?e.messageId:void 0,S=!!t&&Object.keys(t).length>0;l({body:{type:s.eventName,...d?{conversationId:d}:{},...g?{messageId:g}:{},...S?{userProperties:t}:{},properties:u}})}try{return await n.onEvent?.(q)}catch(e){console.warn("[events] onEvent callback threw",e)}},[n,p,i,l,v,o,t])};return T.jsx(O.BaseEventsContext.Provider,{value:k,children:y})};exports.ChatBaseEventsProvider=U;
@@ -1,68 +1,65 @@
1
1
  "use client";
2
- import { jsx as N } from "react/jsx-runtime";
3
- import { useMemo as O, useCallback as j } from "react";
4
- import { useInkeepConfig as w } from "./config-provider.js";
5
- import { useChatAuth as H } from "./chat-auth-provider.js";
6
- import { useEventsApi as K } from "../hooks/use-events-api.js";
7
- import { BaseEventsContext as L } from "./base-events-provider.js";
8
- const J = ({ children: h }) => {
9
- const { baseSettings: o, aiChatSettings: y, componentType: r } = w(), { tags: i, analyticsProperties: a, privacyPreferences: A, userProperties: e } = o, c = "0.16.1", p = O(
2
+ import { jsx as S } from "react/jsx-runtime";
3
+ import { useMemo as T, useCallback as U } from "react";
4
+ import { useInkeepConfig as x } from "./config-provider.js";
5
+ import { useChatAuth as B } from "./chat-auth-provider.js";
6
+ import { useEventsApi as N } from "../hooks/use-events-api.js";
7
+ import { BaseEventsContext as O } from "./base-events-provider.js";
8
+ const z = ({ children: g }) => {
9
+ const { baseSettings: s, aiChatSettings: u, componentType: r } = x(), { tags: a, analyticsProperties: i, privacyPreferences: h, userProperties: t } = s, c = "0.16.1", p = T(
10
10
  () => ({
11
11
  widgetLibraryVersion: c,
12
12
  componentType: r,
13
- tags: i
13
+ tags: a
14
14
  }),
15
- [r, i, c]
16
- ), {
17
- authToken: C,
18
- isAuthenticated: l,
19
- sessionToken: E,
20
- refreshSession: I,
21
- getCaptchaHeader: P,
22
- invalidateCaptcha: b
23
- } = H(), { apiKey: m, baseUrl: k, appId: T, analyticsApiBaseUrl: S } = y, n = m ?? (l ? C : E), v = A?.optOutAllAnalytics ?? !1, { logEvent: d } = K({
24
- baseUrl: S ?? k,
25
- appId: T,
15
+ [r, a, c]
16
+ ), { effectiveAuthToken: n, applicableRefreshSession: y, getCaptchaHeader: b, invalidateCaptcha: A } = B(), { baseUrl: E, appId: C, analyticsApiBaseUrl: I } = u, l = h?.optOutAllAnalytics ?? !1, { logEvent: v } = N({
17
+ baseUrl: I ?? E,
18
+ appId: C,
26
19
  authToken: n,
27
- getCaptchaHeader: P,
28
- invalidateCaptcha: b,
29
- refreshSession: m || l ? void 0 : I
30
- }), U = { logEvent: j(
31
- async (t) => {
32
- const u = {
20
+ getCaptchaHeader: b,
21
+ invalidateCaptcha: A,
22
+ refreshSession: y
23
+ }), P = { logEvent: U(
24
+ async (o) => {
25
+ const m = {
33
26
  ...p,
34
- ...t.properties,
35
- ...a
36
- }, x = {
37
- eventName: t.eventName,
38
- properties: u
27
+ ...o.properties,
28
+ ...i
29
+ }, k = {
30
+ eventName: o.eventName,
31
+ properties: m
39
32
  };
40
- if (!v && n) {
41
- const s = t.properties ?? {}, f = typeof s.conversationId == "string" ? s.conversationId : void 0, g = typeof s.messageId == "string" ? s.messageId : void 0, B = !!e && Object.keys(e).length > 0;
42
- d({
33
+ if (!l && n) {
34
+ const e = o.properties ?? {}, d = typeof e.conversationId == "string" ? e.conversationId : void 0, f = typeof e.messageId == "string" ? e.messageId : void 0, w = !!t && Object.keys(t).length > 0;
35
+ v({
43
36
  body: {
44
- type: t.eventName,
45
- ...f ? { conversationId: f } : {},
46
- ...g ? { messageId: g } : {},
47
- ...B ? { userProperties: e } : {},
48
- properties: u
37
+ type: o.eventName,
38
+ ...d ? { conversationId: d } : {},
39
+ ...f ? { messageId: f } : {},
40
+ ...w ? { userProperties: t } : {},
41
+ properties: m
49
42
  }
50
43
  });
51
44
  }
52
- return o.onEvent?.(x);
45
+ try {
46
+ return await s.onEvent?.(k);
47
+ } catch (e) {
48
+ console.warn("[events] onEvent callback threw", e);
49
+ }
53
50
  },
54
51
  [
55
- o,
52
+ s,
56
53
  p,
57
- a,
58
- d,
54
+ i,
59
55
  v,
56
+ l,
60
57
  n,
61
- e
58
+ t
62
59
  ]
63
60
  ) };
64
- return /* @__PURE__ */ N(L.Provider, { value: U, children: h });
61
+ return /* @__PURE__ */ S(O.Provider, { value: P, children: g });
65
62
  };
66
63
  export {
67
- J as ChatBaseEventsProvider
64
+ z as ChatBaseEventsProvider
68
65
  };
@@ -138,7 +138,7 @@ export interface AssistantSourceItemClickedEvent {
138
138
  export interface AssistantMessageLinkOpenedEvent {
139
139
  eventName: 'assistant_message_inline_link_opened';
140
140
  properties: {
141
- conversationId?: string;
141
+ conversationId: string;
142
142
  messageId?: string;
143
143
  title?: string;
144
144
  url?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-ui",
3
- "version": "0.0.0-dev-20260509021601",
3
+ "version": "0.0.0-dev-20260509025038",
4
4
  "description": "",
5
5
  "homepage": "",
6
6
  "repository": {