@inkeep/agents-ui 0.15.29 → 0.15.30

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.
Files changed (42) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +156 -158
  3. package/dist/primitives/components/embedded-chat.cjs +4 -4
  4. package/dist/primitives/components/embedded-chat.d.ts +5 -14
  5. package/dist/primitives/components/embedded-chat.js +821 -866
  6. package/dist/primitives/hooks/use-feedback-api.cjs +1 -0
  7. package/dist/primitives/hooks/use-feedback-api.d.ts +19 -0
  8. package/dist/primitives/hooks/use-feedback-api.js +37 -0
  9. package/dist/primitives/index.cjs +1 -1
  10. package/dist/primitives/index.js +134 -137
  11. package/dist/primitives/providers/base-events-provider.cjs +1 -1
  12. package/dist/primitives/providers/base-events-provider.js +1 -1
  13. package/dist/primitives/providers/feedback-provider.cjs +1 -1
  14. package/dist/primitives/providers/feedback-provider.d.ts +1 -1
  15. package/dist/primitives/providers/feedback-provider.js +57 -64
  16. package/dist/primitives/providers/index.cjs +1 -1
  17. package/dist/primitives/providers/index.d.ts +0 -1
  18. package/dist/primitives/providers/index.js +42 -45
  19. package/dist/primitives/utils/component-ids.cjs +1 -1
  20. package/dist/primitives/utils/component-ids.d.ts +2 -6
  21. package/dist/primitives/utils/component-ids.js +1 -3
  22. package/dist/react/embedded-chat.cjs +1 -1
  23. package/dist/react/embedded-chat.js +248 -263
  24. package/dist/react/index.cjs +1 -1
  25. package/dist/react/index.js +156 -158
  26. package/dist/styled/components/embedded-chat.cjs +1 -1
  27. package/dist/styled/components/embedded-chat.d.ts +2 -4
  28. package/dist/styled/components/embedded-chat.js +381 -411
  29. package/dist/styled/components/index.cjs +1 -1
  30. package/dist/styled/components/index.js +12 -11
  31. package/dist/styled/components/message.cjs +1 -1
  32. package/dist/styled/components/message.d.ts +20 -0
  33. package/dist/styled/components/message.js +304 -228
  34. package/dist/styled/index.cjs +1 -1
  35. package/dist/styled/index.js +152 -154
  36. package/dist/styled/inkeep.css.cjs +79 -12
  37. package/dist/styled/inkeep.css.js +79 -12
  38. package/dist/types/events.d.ts +3 -17
  39. package/package.json +1 -1
  40. package/dist/primitives/providers/feedback-item-provider.cjs +0 -1
  41. package/dist/primitives/providers/feedback-item-provider.d.ts +0 -10
  42. package/dist/primitives/providers/feedback-item-provider.js +0 -16
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./embedded-chat.cjs"),r=require("./chat-history.cjs"),t=require("./sidebar-chat.cjs"),a=require("./chat-bubble.cjs"),o=require("./embedded-search.cjs"),d=require("./modal.cjs"),i=require("./chat-button.cjs"),s=require("./searchbar.cjs"),u=require("./shadow.cjs"),c=require("./loading-indicator.cjs"),n=require("./ui/recipes/widget-toggle.cjs"),h=require("./message.cjs"),g=require("./data-summary-group.cjs");exports.EmbeddedChat=e;exports.ChatHistory=r;exports.SidebarChat=t;exports.ChatBubble=a;exports.EmbeddedSearch=o;exports.Modal=d;exports.ChatButton=i;exports.SearchBar=s;exports.Shadow=u.Shadow;exports.LoadingIndicator=c.LoadingIndicator;exports.widgetToggle=n.widgetToggle;exports.EmbeddedChatMessagePart=h.EmbeddedChatMessagePart;exports.DataSummaryGroup=g.DataSummaryGroup;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./embedded-chat.cjs"),r=require("./chat-history.cjs"),a=require("./sidebar-chat.cjs"),o=require("./chat-bubble.cjs"),d=require("./embedded-search.cjs"),i=require("./modal.cjs"),u=require("./chat-button.cjs"),n=require("./searchbar.cjs"),s=require("./shadow.cjs"),c=require("./loading-indicator.cjs"),h=require("./ui/recipes/widget-toggle.cjs"),e=require("./message.cjs"),g=require("./data-summary-group.cjs");exports.EmbeddedChat=t;exports.ChatHistory=r;exports.SidebarChat=a;exports.ChatBubble=o;exports.EmbeddedSearch=d;exports.Modal=i;exports.ChatButton=u;exports.SearchBar=n;exports.Shadow=s.Shadow;exports.LoadingIndicator=c.LoadingIndicator;exports.widgetToggle=h.widgetToggle;exports.DefaultToolComponent=e.DefaultToolComponent;exports.EmbeddedChatMessagePart=e.EmbeddedChatMessagePart;exports.DataSummaryGroup=g.DataSummaryGroup;
@@ -1,6 +1,6 @@
1
- import * as r from "./embedded-chat.js";
2
- import * as a from "./chat-history.js";
3
- import * as o from "./sidebar-chat.js";
1
+ import * as o from "./embedded-chat.js";
2
+ import * as r from "./chat-history.js";
3
+ import * as a from "./sidebar-chat.js";
4
4
  import * as t from "./chat-bubble.js";
5
5
  import * as e from "./embedded-search.js";
6
6
  import * as m from "./modal.js";
@@ -8,21 +8,22 @@ import * as d from "./chat-button.js";
8
8
  import * as p from "./searchbar.js";
9
9
  import { Shadow as i } from "./shadow.js";
10
10
  import { LoadingIndicator as x } from "./loading-indicator.js";
11
- import { widgetToggle as c } from "./ui/recipes/widget-toggle.js";
12
- import { EmbeddedChatMessagePart as u } from "./message.js";
13
- import { DataSummaryGroup as g } from "./data-summary-group.js";
11
+ import { widgetToggle as C } from "./ui/recipes/widget-toggle.js";
12
+ import { DefaultToolComponent as l, EmbeddedChatMessagePart as u } from "./message.js";
13
+ import { DataSummaryGroup as S } from "./data-summary-group.js";
14
14
  export {
15
15
  t as ChatBubble,
16
16
  d as ChatButton,
17
- a as ChatHistory,
18
- g as DataSummaryGroup,
19
- r as EmbeddedChat,
17
+ r as ChatHistory,
18
+ S as DataSummaryGroup,
19
+ l as DefaultToolComponent,
20
+ o as EmbeddedChat,
20
21
  u as EmbeddedChatMessagePart,
21
22
  e as EmbeddedSearch,
22
23
  x as LoadingIndicator,
23
24
  m as Modal,
24
25
  p as SearchBar,
25
26
  i as Shadow,
26
- o as SidebarChat,
27
- c as widgetToggle
27
+ a as SidebarChat,
28
+ C as widgetToggle
28
29
  };
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),Y=require("../../primitives/providers/base-events-provider.cjs"),Z=require("../../primitives/providers/config-provider.cjs"),ee=require("../../primitives/providers/message-provider.cjs"),k=require("../../primitives/components/embedded-chat.cjs"),te=require("../../primitives/components/embedded-chat/chat-provider.cjs"),ae=require("merge-anything"),T=require("../utils.cjs"),se=require("./ui/markdown-styles.cjs"),re=require("../../primitives/components/embedded-chat/use-stream-processor.cjs"),ne=require("./data-summary-group.cjs"),r=require("react"),D=require("./embedded-chat.cjs"),l=require("lucide-react"),J=require("./ui/recipes/button.cjs"),oe={"input-streaming":"Pending","input-available":"Running","approval-requested":"Awaiting Approval","approval-responded":"Responded","output-available":"Completed","output-error":"Error","output-denied":"Denied"};function ie(a){if(!a||typeof a!="object")return!1;const s=a;return typeof s.type=="string"&&s.type.startsWith("tool-")}const le=a=>{if(!a||typeof a!="object"||!("status"in a))return;const s=a.status;return typeof s=="string"?s:void 0},ce=()=>e.jsx("div",{className:"flex space-x-1",children:[0,1,2].map(a=>e.jsx("span",{className:"animate-bounce-dot opacity-30",style:{animationDelay:`${a*.2}s`},children:"."},a))}),U=({name:a,Icon:s,props:n,componentType:c})=>e.jsxs("div",{className:"border rounded-lg bg-gray-50 dark:bg-gray-dark-800 mb-3",children:[e.jsxs("div",{className:"flex justify-between px-4 py-2 text-xs",children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(s,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:a})]}),e.jsx("div",{className:"flex items-center px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-200 dark:bg-white-alpha-200 font-medium text-gray-700 dark:text-white-alpha-700 font-mono",children:c})]}),e.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono px-4 py-2",children:JSON.stringify(n,null,2)})]}),de=({name:a,props:s})=>e.jsx(U,{name:a,Icon:l.ComponentIcon,props:s,componentType:"component"}),pe=({name:a,props:s})=>e.jsx(U,{name:a,Icon:l.Library,props:s,componentType:"artifact"}),ue=({tool:a,componentDef:s,renderText:n,approvalId:c,messagePartsLength:h,setApprovalDelayPending:o,addToolApprovalResponse:i,sendMessage:p,conversationId:u})=>{const f=r.useRef(p);f.current=p;const g=r.useRef(i);g.current=i;const m=r.useRef(o);m.current=o;const j=r.useCallback(async(M=!0)=>{c&&(m.current({partCount:h}),g.current({id:c,approved:M}),await f.current(void 0,{body:{conversationId:u}}))},[c,h,u]),y=r.useMemo(()=>({tool:a,approve:j,renderMarkdown:n}),[a]),N=s?D.DynamicComponent:me;return e.jsx(N,{name:a.type,props:y,componentDef:s})},me=({props:a,isDebug:s=!1})=>{const{tool:n,approve:c}=a,h=n.type,o=h.startsWith("tool-")?h.slice(5):h,i=n.state,p=n.approval?.id,u=!!p,f=i==="approval-requested",g=le(n.output),[m,j]=r.useState(u||s),y=i?oe[i]??i:"tool";r.useEffect(()=>{f&&j(!0)},[f]);const N=()=>{switch(i){case"input-streaming":return e.jsx(l.Circle,{className:"w-3 h-3"});case"input-available":return e.jsx(l.Loader2,{className:"w-3 h-3 animate-spin"});case"approval-requested":return e.jsx(l.Clock,{className:"w-3 h-3"});case"approval-responded":return e.jsx(l.CheckCircle,{className:"w-3 h-3"});case"output-available":return e.jsx(l.CheckCircle,{className:"w-3 h-3"});case"output-error":return e.jsx(l.XCircle,{className:"w-3 h-3"});case"output-denied":return e.jsx(l.XCircle,{className:"w-3 h-3"});default:return null}};return e.jsxs("div",{className:"border rounded-lg mb-3 overflow-hidden",children:[(!u||s)&&e.jsxs("button",{type:"button",className:"inline-flex items-center group gap-2 text-xs text-gray-700 dark:text-white-alpha-700 hover:text-gray-800 dark:hover:text-white-alpha-800 transition-colors cursor-pointer w-full justify-between px-4 py-2",onClick:()=>j(!m),"data-expanded":m,children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(l.Hammer,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:o})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-100 dark:bg-white-alpha-100 font-medium text-gray-700 dark:text-white-alpha-700 font-mono",children:[N(),y]}),e.jsx(l.ChevronDown,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform rotate-0 group-data-[expanded=true]:rotate-180"})]})]}),e.jsx("div",{"data-expanded":m,className:T.cn("relative",'before:content-[""] before:absolute before:inset-x-0 before:-top-px before:h-3 before:pointer-events-none before:z-10','after:content-[""] after:absolute after:inset-x-0 after:bottom-0 after:h-3 after:pointer-events-none after:z-10',"before:bg-[linear-gradient(white,_transparent)] after:bg-[linear-gradient(transparent,_white)]","dark:before:bg-[linear-gradient(var(--ikp-color-gray-dark-950),_transparent)] dark:after:bg-[linear-gradient(transparent,_var(--ikp-color-gray-dark-950))]","data-[expanded=false]:before:opacity-0 data-[expanded=false]:after:opacity-0"),children:e.jsxs("div",{"data-expanded":m,className:T.cn("px-4 data-[expanded=true]:pb-3 [scrollbar-width:thin] 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",u?"":"data-[expanded=true]:max-h-48 data-[expanded=true]:overflow-y-auto"),children:[n.input!=null&&e.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono py-2",children:JSON.stringify(n.input,null,2)}),!s&&u&&e.jsxs("div",{className:"whitespace-pre-wrap text-sm text-gray-700 dark:text-white-alpha-700 py-2",children:["Approval is needed to run ",e.jsx("strong",{children:o}),"."]}),f&&p&&e.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[e.jsx("button",{type:"button",className:T.cn(J.button({size:"xs",variant:"outline"}),"px-2 py-1 rounded-md text-xs text-gray-700 dark:text-white-alpha-700"),onClick:()=>c(!1),children:"Deny"}),e.jsxs("button",{type:"button",className:T.cn(J.button({size:"xs",variant:"primaryFilled"}),"px-2 py-1 rounded-md text-xs gap-1"),onClick:()=>c(!0),children:[e.jsx(l.Check,{className:"w-3 h-3"}),"Approve"]})]}),i==="output-available"&&n.output!=null&&!s&&e.jsxs("div",{className:"flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize",children:[g==="approved"&&e.jsx(l.Check,{className:"w-3 h-3"}),g]}),i==="output-denied"&&!s&&e.jsxs("div",{className:"flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize",children:[e.jsx(l.X,{className:"w-3 h-3"}),y]}),i==="output-available"&&n.output!=null&&s&&e.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono py-2",children:typeof n.output=="string"?n.output:JSON.stringify(n.output,null,2)})]})})]})},xe=({className:a,componentStyles:s,children:n,isLast:c,...h})=>{const{message:o}=ee.useMessage(),{logEvent:i}=Y.useBaseEvents(),{conversationId:p,isStreaming:u,isLoading:f,setError:g,addToolApprovalResponse:m,sendMessage:j}=te.useChat(),{aiChatSettings:{components:y,artifacts:N,headers:M}}=Z.useInkeepConfig(),X=M?.["x-emit-operations"]==="true",R=o.role==="user",B=(u||f)&&c&&o.role==="assistant",{processedParts:F,summaryTimings:G,shouldShowInitialLoading:K,shouldShowStreamDelayLoading:W}=re.useStreamProcessor(o.parts,B,g),[S,_]=r.useState(null),[H,q]=r.useState(!1),x=r.useRef(null);r.useEffect(()=>{if(!S){q(!1),x.current&&(clearTimeout(x.current),x.current=null);return}return q(!1),x.current&&clearTimeout(x.current),x.current=window.setTimeout(()=>{q(!0)},1e3),()=>{x.current&&(clearTimeout(x.current),x.current=null)}},[S]),r.useEffect(()=>{S&&(!c||o.parts.length>S.partCount)&&_(null)},[S,c,o.parts.length]);const I=r.useMemo(()=>o.parts.filter(t=>t.type==="data-artifact"&&t.data?.type?.toLowerCase()==="citation"),[o.parts]),$=r.useMemo(()=>ae.merge(se.markdownStyles,s??{}),[s]),O=r.useCallback((t,d)=>{i({eventName:"assistant_message_inline_link_opened",properties:{title:d?.toString(),url:t}})},[i]),z=r.useCallback((t,d)=>{i({eventName:"assistant_code_block_copied",properties:{conversationId:p,language:t,code:d}})},[i,p]),E=r.useCallback(t=>e.jsx(k.EmbeddedChatPrimitiveMarkdown,{text:t,componentStyles:$,onLinkClick:O,onCodeCopy:z,artifacts:I}),[$,O,z,I]),V=r.useMemo(()=>T.cn("data-[role=user]:whitespace-pre-wrap mb-3 data-[role=user]:mb-0 [&[data-role=user]>p]:mb-0 max-w-full",a),[a]),Q=!R||o.parts.some(t=>t.type==="text"&&t.text?.trim());return e.jsxs(e.Fragment,{children:[!Q&&e.jsx("span",{className:"text-gray-500 dark:text-white-alpha-500",children:"No message content"}),F.map((t,d)=>{const b={"data-role":o.role,"data-type":t?.type==="data-component"?t.data.type:t?.type,...h,className:V};switch(t?.type){case"text":return e.jsx(k.PrimitiveMessagePart,{...b,children:R?t.text:E(t.text||"")},d);case"data-component":{const{type:v}=t.data;switch(v){case"text":return e.jsx("div",{...b,children:E(t.data.text||"")},d);default:{const C=t.data,{name:w,props:A}=C,P=y?.[w],L=P?D.DynamicComponent:de;return e.jsx(k.PrimitiveMessagePart,{...b,children:e.jsx(L,{name:w,props:A,componentDef:P})},`${w}-${d}`)}}}case"data-artifact":{const v=t.data,{name:C,type:w,artifactSummary:A}=v,P=N?.[w],L=P?D.DynamicComponent:pe;return e.jsx(k.PrimitiveMessagePart,{...b,children:e.jsx(L,{name:w,props:A,componentDef:P})},`${C}-${d}`)}case"summary-group":{const v=G.get(t.groupKey)||{isCompleted:!1};return e.jsx(k.PrimitiveMessagePart,{...b,children:e.jsx(ne.DataSummaryGroup,{summaries:t.summaries||[],isCompleted:v.isCompleted})},`${t.groupKey}-${d}`)}default:{if(!ie(t))return null;const v=t,C=t.approval?.id;return X||C?e.jsx(k.PrimitiveMessagePart,{...b,children:e.jsx(ue,{tool:v,componentDef:y?.IkpTool,renderText:E,approvalId:C,messagePartsLength:o.parts.length,setApprovalDelayPending:_,addToolApprovalResponse:m,sendMessage:j,conversationId:p})},t.toolCallId??`${t.type}-${d}`):null}}}),K&&e.jsx(D.MessageLoading,{}),(W||H)&&e.jsx(ce,{})]})};exports.EmbeddedChatMessagePart=xe;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),te=require("../../primitives/providers/base-events-provider.cjs"),ae=require("../../primitives/providers/config-provider.cjs"),re=require("../../primitives/providers/message-provider.cjs"),C=require("../../primitives/components/embedded-chat.cjs"),se=require("../../primitives/components/embedded-chat/chat-provider.cjs"),ne=require("merge-anything"),b=require("../utils.cjs"),oe=require("./ui/markdown-styles.cjs"),ie=require("../../primitives/components/embedded-chat/use-stream-processor.cjs"),le=require("./data-summary-group.cjs"),o=require("react"),D=require("./embedded-chat.cjs"),d=require("lucide-react"),U=require("./ui/recipes/button.cjs"),de={"input-streaming":"Pending","input-available":"Running","approval-requested":"Awaiting Approval","approval-responded":"Responded","output-available":"Completed","output-error":"Error","output-denied":"Denied"};function ce(t){if(!t||typeof t!="object")return!1;const a=t;return typeof a.type=="string"&&a.type.startsWith("tool-")}const pe=t=>{if(!t||typeof t!="object"||!("status"in t))return;const a=t.status;return typeof a=="string"?a:void 0},ue=()=>e.jsx("div",{className:"flex space-x-1",children:[0,1,2].map(t=>e.jsx("span",{className:"animate-bounce-dot opacity-30",style:{animationDelay:`${t*.2}s`},children:"."},t))}),V=({name:t,Icon:a,props:i,componentType:n})=>e.jsxs("div",{className:"border rounded-lg bg-gray-50 dark:bg-gray-dark-800 mb-3",children:[e.jsxs("div",{className:"flex justify-between px-4 py-2 text-xs",children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(a,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:t})]}),e.jsx("div",{className:"flex items-center px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-200 dark:bg-white-alpha-200 font-medium text-gray-700 dark:text-white-alpha-700 font-mono",children:n})]}),e.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono px-4 py-2",children:JSON.stringify(i,null,2)})]}),xe=({name:t,props:a})=>e.jsx(V,{name:t,Icon:d.ComponentIcon,props:a,componentType:"component"}),me=({name:t,props:a})=>e.jsx(V,{name:t,Icon:d.Library,props:a,componentType:"artifact"}),he=({tool:t,componentDef:a,renderText:i,approvalId:n,messagePartsLength:m,setApprovalDelayPending:s,addToolApprovalResponse:u,sendMessage:c,conversationId:g})=>{const l=o.useRef(c);l.current=c;const x=o.useRef(u);x.current=u;const p=o.useRef(s);p.current=s;const h=o.useCallback(async(A=!0)=>{n&&(p.current({partCount:m}),x.current({id:n,approved:A}),await l.current(void 0,{body:{conversationId:g}}))},[n,m,g]),k=o.useMemo(()=>({tool:t,approve:h,renderMarkdown:i}),[t]),T=a?D.DynamicComponent:G;return e.jsx(T,{name:t.type,props:k,componentDef:a})};function B(t){return t===null?e.jsx("span",{className:"text-gray-500 dark:text-white-alpha-500 font-mono font-medium text-1xs",children:"null"}):t===void 0?e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 italic text-xs font-medium",children:"undefined"}):typeof t=="boolean"?e.jsx("span",{className:b.cn("inline-flex font-mono font-semibold items-center px-1 py-0.5 text-1xs rounded-md border",t?"bg-inkeep-expanded-primary-50 border-inkeep-expanded-primary-200 text-inkeep-expanded-primary-600 dark:bg-inkeep-expanded-primary-950 dark:border-inkeep-expanded-primary-600 dark:text-inkeep-expanded-primary-200":"bg-gray-100 dark:bg-white-alpha-50 text-gray-700 dark:text-white-alpha-700"),children:t?"true":"false"}):typeof t=="number"?e.jsx("span",{className:"tabular-nums font-medium text-inkeep-expanded-primary-600 dark:text-inkeep-expanded-primary-200",children:t.toLocaleString()}):typeof t=="string"?e.jsx("span",{className:"text-gray-800 dark:text-white-alpha-800 break-words",children:t}):e.jsx("span",{children:String(t)})}const F=({name:t,value:a,isArrayIndex:i,depth:n=0})=>{const[m,s]=o.useState(n<1),u=a!==null&&typeof a=="object"&&!Array.isArray(a),c=Array.isArray(a);if(!(u||c))return e.jsxs("div",{className:"flex items-baseline gap-2 py-1 text-xs",children:[e.jsx("span",{className:b.cn("font-medium shrink-0",i?"text-gray-300 dark:text-white-alpha-300":"text-gray-500 dark:text-white-alpha-500"),children:i?"—":t}),e.jsx("span",{children:B(a)})]});const l=c?a.map((p,h)=>[String(h),p]):Object.entries(a);return l.length===0?e.jsxs("div",{className:"flex items-baseline gap-2 py-1 text-xs",children:[e.jsx("span",{className:"font-medium text-gray-500 dark:text-white-alpha-500 shrink-0",children:t}),e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 italic",children:c?"empty list":"empty"})]}):e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:p=>{p.stopPropagation(),s(!m)},className:"flex items-center gap-1.5 py-1 text-xs hover:bg-gray-50 dark:hover:bg-white-alpha-50 -mx-1.5 px-1.5 rounded transition-colors w-full text-left",children:[e.jsx(d.ChevronDown,{className:b.cn("h-3.5 w-3.5 text-gray-400 dark:text-white-alpha-400 shrink-0 transition-transform",!m&&"-rotate-90")}),e.jsx("span",{className:"font-medium text-gray-500 dark:text-white-alpha-500",children:t}),!m&&e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 text-1xs ml-1",children:c?`${l.length} item${l.length!==1?"s":""}`:`${l.length} field${l.length!==1?"s":""}`})]}),m&&e.jsx("div",{className:"border-l-2 border-gray-200 dark:border-white-alpha-200 ml-1.5 pl-3",children:l.map(([p,h])=>e.jsx(F,{name:p,value:h,isArrayIndex:c,depth:n+1},p))})]})},fe=({value:t})=>{if(t==null||typeof t!="object")return e.jsx("span",{className:"text-xs",children:B(t)});const a=Array.isArray(t)?t.map((i,n)=>[String(n),i]):Object.entries(t);return a.length===0?e.jsx("div",{className:"text-xs text-gray-400 dark:text-white-alpha-400 italic",children:"No arguments"}):e.jsx("div",{className:"space-y-1",children:a.map(([i,n])=>e.jsx(F,{name:i,value:n,isArrayIndex:Array.isArray(t)},i))})},G=({props:t})=>{const{tool:a,approve:i}=t,n=a.type,m=n.startsWith("tool-")?n.slice(5):n,s=a.state,u=a.approval?.id,c=!!u,g=s==="approval-requested",l=pe(a.output),[x,p]=o.useState(c),h=s?de[s]??s:"tool";o.useEffect(()=>{g&&p(!0)},[g]);const k=()=>{switch(s){case"input-streaming":return e.jsx(d.Circle,{className:"w-3 h-3"});case"input-available":return e.jsx(d.Loader2,{className:"w-3 h-3 animate-spin"});case"approval-requested":return e.jsx(d.Clock,{className:"w-3 h-3"});case"approval-responded":return e.jsx(d.CheckCircle,{className:"w-3 h-3"});case"output-available":return e.jsx(d.CheckCircle,{className:"w-3 h-3"});case"output-error":return e.jsx(d.TriangleAlert,{className:"w-3 h-3"});case"output-denied":return e.jsx(d.XCircle,{className:"w-3 h-3"});default:return null}};return e.jsxs("div",{className:"border rounded-lg mb-3 overflow-hidden",children:[e.jsxs("button",{type:"button",className:"inline-flex items-center group gap-2 text-xs text-gray-700 dark:text-white-alpha-700 hover:text-gray-800 dark:hover:text-white-alpha-800 transition-colors cursor-pointer w-full justify-between px-4 py-2 data-[expanded=true]:border-b",onClick:()=>p(!x),"aria-expanded":x,"data-expanded":x,children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(d.Hammer,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:m})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-100 dark:bg-white-alpha-100 font-medium text-gray-700 dark:text-white-alpha-700 font-mono",children:[k(),h]}),e.jsx(d.ChevronDown,{className:"w-3.5 h-3.5 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform rotate-0 group-data-[expanded=true]:rotate-180"})]})]}),e.jsxs("div",{"data-expanded":x,className:b.cn("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",{"data-expanded":x,className:b.cn("relative",'before:content-[""] before:absolute before:inset-x-0 before:top-0 before:h-3 before:pointer-events-none before:z-10','after:content-[""] after:absolute after:inset-x-0 after:bottom-0 after:h-3 after:pointer-events-none after:z-10',"before:bg-[linear-gradient(white,_transparent)] after:bg-[linear-gradient(transparent,_white)]","dark:before:bg-[linear-gradient(var(--ikp-color-gray-dark-950),_transparent)] dark:after:bg-[linear-gradient(transparent,_var(--ikp-color-gray-dark-950))]","data-[expanded=false]:before:opacity-0 data-[expanded=false]:after:opacity-0"),children:e.jsx("div",{"data-expanded":x,className:b.cn("[scrollbar-width:thin] px-4","data-[expanded=true]:max-h-48 data-[expanded=true]:overflow-y-auto"),children:a.input!=null&&e.jsx("div",{className:"text-xs py-2",children:e.jsx(fe,{value:a.input})})})}),g&&u&&e.jsxs("div",{className:"flex justify-end gap-2 pt-1 pb-3 px-4",children:[e.jsx("button",{type:"button",className:b.cn(U.button({size:"xs",variant:"outline"}),"px-2 py-1 rounded-md text-xs text-gray-700 dark:text-white-alpha-700"),onClick:()=>i(!1),children:"Deny"}),e.jsxs("button",{type:"button",className:b.cn(U.button({size:"xs",variant:"primaryFilled"}),"px-2 py-1 rounded-md text-xs gap-1"),onClick:()=>i(!0),children:[e.jsx(d.Check,{className:"w-3 h-3"}),"Approve"]})]}),s==="output-available"&&l&&a.output!=null&&e.jsxs("div",{className:"flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize pb-3 px-4",children:[l==="approved"&&e.jsx(d.Check,{className:"w-3 h-3"}),l]}),s==="output-denied"&&e.jsxs("div",{className:"flex justify-end items-center gap-1 whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 capitalize pb-3 px-4",children:[e.jsx(d.X,{className:"w-3 h-3"}),h]})]})]})},ge=({className:t,componentStyles:a,children:i,isLast:n,...m})=>{const{message:s}=re.useMessage(),{logEvent:u}=te.useBaseEvents(),{conversationId:c,isStreaming:g,isLoading:l,setError:x,addToolApprovalResponse:p,sendMessage:h}=se.useChat(),{aiChatSettings:{components:k,artifacts:T,headers:A}}=ae.useInkeepConfig(),K=A?.["x-emit-operations"]==="true",R=s.role==="user",W=(g||l)&&n&&s.role==="assistant",{processedParts:X,summaryTimings:H,shouldShowInitialLoading:J,shouldShowStreamDelayLoading:Q}=ie.useStreamProcessor(s.parts,W,x),[S,$]=o.useState(null),[Y,E]=o.useState(!1),y=o.useRef(null);o.useEffect(()=>{if(!S){E(!1),y.current&&(clearTimeout(y.current),y.current=null);return}return E(!1),y.current&&clearTimeout(y.current),y.current=window.setTimeout(()=>{E(!0)},1e3),()=>{y.current&&(clearTimeout(y.current),y.current=null)}},[S]),o.useEffect(()=>{S&&(!n||s.parts.length>S.partCount)&&$(null)},[S,n,s.parts.length]);const _=o.useMemo(()=>s.parts.filter(r=>r.type==="data-artifact"&&r.data?.type?.toLowerCase()==="citation"),[s.parts]),I=o.useMemo(()=>ne.merge(oe.markdownStyles,a??{}),[a]),O=o.useCallback((r,f)=>{u({eventName:"assistant_message_inline_link_opened",properties:{title:f?.toString(),url:r}})},[u]),z=o.useCallback((r,f)=>{u({eventName:"assistant_code_block_copied",properties:{conversationId:c,language:r,code:f}})},[u,c]),M=o.useCallback(r=>e.jsx(C.EmbeddedChatPrimitiveMarkdown,{text:r,componentStyles:I,onLinkClick:O,onCodeCopy:z,artifacts:_}),[I,O,z,_]),Z=o.useMemo(()=>b.cn("data-[role=user]:whitespace-pre-wrap mb-3 data-[role=user]:mb-0 [&[data-role=user]>p]:mb-0 max-w-full",t),[t]),ee=!R||s.parts.some(r=>r.type==="text"&&r.text?.trim());return e.jsxs(e.Fragment,{children:[!ee&&e.jsx("span",{className:"text-gray-500 dark:text-white-alpha-500",children:"No message content"}),X.map((r,f)=>{const v={"data-role":s.role,"data-type":r?.type==="data-component"?r.data.type:r?.type,...m,className:Z};switch(r?.type){case"text":return e.jsx(C.PrimitiveMessagePart,{...v,children:R?r.text:M(r.text||"")},f);case"data-component":{const{type:j}=r.data;switch(j){case"text":return e.jsx("div",{...v,children:M(r.data.text||"")},f);default:{const N=r.data,{name:w,props:q}=N,P=k?.[w],L=P?D.DynamicComponent:xe;return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(L,{name:w,props:q,componentDef:P})},`${w}-${f}`)}}}case"data-artifact":{const j=r.data,{name:N,type:w,artifactSummary:q}=j,P=T?.[w],L=P?D.DynamicComponent:me;return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(L,{name:w,props:q,componentDef:P})},`${N}-${f}`)}case"summary-group":{const j=H.get(r.groupKey)||{isCompleted:!1};return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(le.DataSummaryGroup,{summaries:r.summaries||[],isCompleted:j.isCompleted})},`${r.groupKey}-${f}`)}default:{if(!ce(r))return null;const j=r,N=r.approval?.id;return K||N?e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(he,{tool:j,componentDef:k?.IkpTool,renderText:M,approvalId:N,messagePartsLength:s.parts.length,setApprovalDelayPending:$,addToolApprovalResponse:p,sendMessage:h,conversationId:c})},r.toolCallId??`${r.type}-${f}`):null}}}),J&&e.jsx(D.MessageLoading,{}),(Q||Y)&&e.jsx(ue,{})]})};exports.DefaultToolComponent=G;exports.EmbeddedChatMessagePart=ge;
@@ -1,4 +1,24 @@
1
+ import { FC } from 'react';
1
2
  import { EmbeddedChatPrimitiveMessagePartProps } from '../../primitives/components/embedded-chat';
3
+ type ToolApproval = {
4
+ id: string;
5
+ };
6
+ type ToolUIPart = {
7
+ type: string;
8
+ state?: string;
9
+ toolCallId?: string;
10
+ input?: unknown;
11
+ output?: unknown;
12
+ approval?: ToolApproval;
13
+ };
14
+ export declare const DefaultToolComponent: FC<{
15
+ name: string;
16
+ props: Record<string, unknown> & {
17
+ tool: ToolUIPart;
18
+ approve: (approved?: boolean) => Promise<void>;
19
+ };
20
+ }>;
2
21
  export declare const EmbeddedChatMessagePart: ({ className, componentStyles, children, isLast, ...rest }: EmbeddedChatPrimitiveMessagePartProps & {
3
22
  isLast: boolean;
4
23
  }) => import("react/jsx-runtime").JSX.Element;
24
+ export {};