@inkeep/agents-ui 0.0.0-dev-20260508201702 → 0.0.0-dev-20260508211520

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 (21) hide show
  1. package/dist/node_modules/.pnpm/@hookform_resolvers@5.2.2_react-hook-form@7.70.0_react@19.3.0-canary-87ae75b3-20260128_/node_modules/@hookform/resolvers/zod/dist/zod.cjs +1 -0
  2. package/dist/node_modules/.pnpm/@hookform_resolvers@5.2.2_react-hook-form@7.70.0_react@19.3.0-canary-87ae75b3-20260128_/node_modules/@hookform/resolvers/zod/dist/zod.js +93 -0
  3. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.cjs +1 -0
  4. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.js +49 -0
  5. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.cjs +1 -0
  6. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.js +19 -0
  7. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/parse.cjs +1 -0
  8. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/parse.js +28 -0
  9. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.cjs +1 -0
  10. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js +23 -0
  11. package/dist/primitives/components/embedded-chat/use-inkeep-chat.cjs +2 -2
  12. package/dist/primitives/components/embedded-chat/use-inkeep-chat.d.ts +13 -0
  13. package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +181 -183
  14. package/dist/styled/components/ask-user-form.cjs +1 -0
  15. package/dist/styled/components/ask-user-form.d.ts +96 -0
  16. package/dist/styled/components/ask-user-form.js +672 -0
  17. package/dist/styled/components/message.cjs +1 -1
  18. package/dist/styled/components/message.js +272 -210
  19. package/dist/styled/inkeep.css.cjs +78 -0
  20. package/dist/styled/inkeep.css.js +78 -0
  21. package/package.json +2 -1
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),ae=require("../../primitives/providers/base-events-provider.cjs"),re=require("../../primitives/providers/config-provider.cjs"),se=require("../../primitives/providers/message-provider.cjs"),C=require("../../primitives/components/embedded-chat.cjs"),ne=require("../../primitives/components/embedded-chat/chat-provider.cjs"),oe=require("../../primitives/utils/misc.cjs"),ie=require("merge-anything"),b=require("../utils.cjs"),le=require("./ui/markdown-styles.cjs"),de=require("../../primitives/components/embedded-chat/use-stream-processor.cjs"),ce=require("./data-summary-group.cjs"),o=require("react"),T=require("./embedded-chat.cjs"),d=require("lucide-react"),V=require("./ui/recipes/button.cjs"),pe={"input-streaming":"Pending","input-available":"Running","approval-requested":"Awaiting Approval","approval-responded":"Responded","output-available":"Completed","output-error":"Error","output-denied":"Denied"};function ue(t){if(!t||typeof t!="object")return!1;const a=t;return typeof a.type=="string"&&a.type.startsWith("tool-")}const me=t=>{if(!t||typeof t!="object"||!("status"in t))return;const a=t.status;return typeof a=="string"?a:void 0},xe=()=>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))}),B=({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("div",{className:"px-4 py-2",children:e.jsx(K,{value:i})})]}),he=({name:t,props:a})=>e.jsx(B,{name:t,Icon:d.ComponentIcon,props:a,componentType:"component"}),fe=({name:t,props:a})=>e.jsx(B,{name:t,Icon:d.Library,props:a,componentType:"artifact"}),ge=({tool:t,componentDef:a,renderText:i,approvalId:n,messagePartsLength:x,setApprovalDelayPending:s,addToolApprovalResponse:u,sendMessage:c,conversationId:g})=>{const l=o.useRef(c);l.current=c;const m=o.useRef(u);m.current=u;const p=o.useRef(s);p.current=s;const h=o.useCallback(async(E=!0)=>{n&&(p.current({partCount:x}),m.current({id:n,approved:E}),await l.current(void 0,{body:{conversationId:g}}))},[n,x,g]),k=o.useMemo(()=>({tool:t,approve:h,renderMarkdown:i}),[t]),A=a?T.DynamicComponent:W;return e.jsx(A,{name:t.type,props:k,componentDef:a})};function F(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:String(t)}):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 G=({name:t,value:a,isArrayIndex:i,depth:n=0})=>{const[x,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",{className:"min-w-0",children:F(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(!x)},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",!x&&"-rotate-90")}),e.jsx("span",{className:"font-medium text-gray-500 dark:text-white-alpha-500",children:t}),!x&&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":""}`})]}),x&&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(G,{name:p,value:h,isArrayIndex:c,depth:n+1},p))})]})},K=({value:t})=>{if(t==null||typeof t!="object")return e.jsx("span",{className:"text-xs",children:F(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(G,{name:i,value:n,isArrayIndex:Array.isArray(t)},i))})},W=({props:t})=>{const{tool:a,approve:i}=t,n=a.type,x=n.startsWith("tool-")?n.slice(5):n,s=a.state,u=a.approval?.id,c=!!u,g=s==="approval-requested",l=me(a.output),[m,p]=o.useState(c),h=s?pe[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(!m),"aria-expanded":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(d.Hammer,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:x})]})}),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":m,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":m,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":m,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(K,{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(V.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(V.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]})]})]})},ye=({className:t,componentStyles:a,children:i,isLast:n,...x})=>{const{message:s}=se.useMessage(),{logEvent:u}=ae.useBaseEvents(),{conversationId:c,isStreaming:g,isLoading:l,setError:m,addToolApprovalResponse:p,sendMessage:h}=ne.useChat(),{aiChatSettings:{components:k,artifacts:A,headers:E}}=re.useInkeepConfig(),X=E?.["x-emit-operations"]==="true",L=s.role==="user",q=(g||l)&&n&&s.role==="assistant",{processedParts:H,summaryTimings:J,shouldShowInitialLoading:Q,shouldShowStreamDelayLoading:Y}=de.useStreamProcessor(s.parts,q,m),[S,_]=o.useState(null),[Z,M]=o.useState(!1),y=o.useRef(null);o.useEffect(()=>{if(!S){M(!1),y.current&&(clearTimeout(y.current),y.current=null);return}return M(!1),y.current&&clearTimeout(y.current),y.current=window.setTimeout(()=>{M(!0)},1e3),()=>{y.current&&(clearTimeout(y.current),y.current=null)}},[S]),o.useEffect(()=>{S&&(!n||s.parts.length>S.partCount||!q)&&_(null)},[S,n,s.parts.length,q]);const I=o.useMemo(()=>s.parts.filter(oe.isCitationArtifact),[s.parts]),O=o.useMemo(()=>ie.merge(le.markdownStyles,a??{}),[a]),z=o.useCallback((r,f)=>{u({eventName:"assistant_message_inline_link_opened",properties:{title:f?.toString(),url:r}})},[u]),U=o.useCallback((r,f)=>{u({eventName:"assistant_code_block_copied",properties:{conversationId:c,language:r,code:f}})},[u,c]),R=o.useCallback(r=>e.jsx(C.EmbeddedChatPrimitiveMarkdown,{text:r,componentStyles:O,onLinkClick:z,onCodeCopy:U,artifacts:I}),[O,z,U,I]),ee=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]),te=!L||s.parts.some(r=>r.type==="text"&&r.text?.trim());return e.jsxs(e.Fragment,{children:[!te&&e.jsx("span",{className:"text-gray-500 dark:text-white-alpha-500",children:"No message content"}),H.map((r,f)=>{const v={"data-role":s.role,"data-type":r?.type==="data-component"?r.data.type:r?.type,...x,className:ee};switch(r?.type){case"text":return e.jsx(C.PrimitiveMessagePart,{...v,children:L?r.text:R(r.text||"")},f);case"data-component":{const{type:w}=r.data;switch(w){case"text":return e.jsx("div",{...v,children:R(r.data.text||"")},f);default:{const N=r.data,{name:j,props:D}=N,P=k?.[j],$=P?T.DynamicComponent:he;return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx($,{name:j,props:D,componentDef:P})},`${j}-${f}`)}}}case"data-artifact":{const w=r.data,{name:N,type:j,artifactSummary:D}=w;if(j==="citation"&&!D?.url)return null;const P=A?.[j],$=P?T.DynamicComponent:fe;return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx($,{name:j,props:D,componentDef:P})},`${N}-${f}`)}case"summary-group":{const w=J.get(r.groupKey)||{isCompleted:!1};return e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(ce.DataSummaryGroup,{summaries:r.summaries||[],isCompleted:w.isCompleted})},`${r.groupKey}-${f}`)}default:{if(!ue(r))return null;const w=r,N=r.approval?.id;return X||N?e.jsx(C.PrimitiveMessagePart,{...v,children:e.jsx(ge,{tool:w,componentDef:k?.IkpTool,renderText:R,approvalId:N,messagePartsLength:s.parts.length,setApprovalDelayPending:_,addToolApprovalResponse:p,sendMessage:h,conversationId:c})},r.toolCallId??`${r.type}-${f}`):null}}}),Q&&e.jsx(T.MessageLoading,{}),(Y||Z)&&e.jsx(xe,{})]})};exports.DefaultToolComponent=W;exports.EmbeddedChatMessagePart=ye;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),ne=require("../../primitives/providers/base-events-provider.cjs"),oe=require("../../primitives/providers/config-provider.cjs"),ie=require("../../primitives/providers/message-provider.cjs"),T=require("../../primitives/components/embedded-chat.cjs"),le=require("../../primitives/components/embedded-chat/chat-provider.cjs"),ce=require("../../primitives/utils/misc.cjs"),de=require("merge-anything"),k=require("../utils.cjs"),pe=require("./ui/markdown-styles.cjs"),ue=require("../../primitives/components/embedded-chat/use-stream-processor.cjs"),me=require("./data-summary-group.cjs"),n=require("react"),_=require("./embedded-chat.cjs"),xe=require("./ask-user-form.cjs"),d=require("lucide-react"),H=require("./ui/recipes/button.cjs"),K="askUser",J=`tool-${K}`,he={"input-streaming":"Pending","input-available":"Running","approval-requested":"Awaiting Approval","approval-responded":"Responded","output-available":"Completed","output-error":"Error","output-denied":"Denied"};function fe(t){if(!t||typeof t!="object")return!1;const a=t;return typeof a.type=="string"&&a.type.startsWith("tool-")}const ye=t=>{if(!t||typeof t!="object"||!("status"in t))return;const a=t.status;return typeof a=="string"?a:void 0},ge=()=>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))}),Y=({name:t,Icon:a,props:l,componentType:o})=>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:o})]}),e.jsx("div",{className:"px-4 py-2",children:e.jsx(ee,{value:l})})]}),be=({name:t,props:a})=>e.jsx(Y,{name:t,Icon:d.ComponentIcon,props:a,componentType:"component"}),je=({name:t,props:a})=>e.jsx(Y,{name:t,Icon:d.Library,props:a,componentType:"artifact"}),we=({tool:t,componentDef:a,renderText:l,approvalId:o,messagePartsLength:c,setApprovalDelayPending:s,addToolApprovalResponse:x,addToolOutput:p,sendMessage:b,conversationId:i})=>{const u=n.useRef(b);u.current=b;const m=n.useRef(x);m.current=x;const h=n.useRef(p);h.current=p;const y=n.useRef(s);y.current=s;const M=n.useCallback(async(f=!0)=>{o&&(y.current({partCount:c}),m.current({id:o,approved:f}),await u.current(void 0,{body:{conversationId:i}}))},[o,c,i]),I=n.useCallback(async f=>{if(!t.toolCallId)return;y.current({partCount:c});const v=t.input;try{await h.current({tool:K,toolCallId:t.toolCallId,output:{form:v.form,answers:f,...v.message!==void 0?{message:v.message}:{}}}),await u.current(void 0,{body:{conversationId:i}})}catch(D){console.error("[askUser] submit failed",D),y.current(null)}},[t.toolCallId,t.input,c,i]),U=n.useCallback(async()=>{if(t.toolCallId){y.current({partCount:c});try{await h.current({state:"output-error",tool:K,toolCallId:t.toolCallId,errorText:"User declined to provide input."}),await u.current(void 0,{body:{conversationId:i}})}catch(f){console.error("[askUser] decline failed",f),y.current(null)}}},[t.toolCallId,c,i]),O=n.useMemo(()=>({tool:t,approve:M,renderMarkdown:l}),[t]);if(t.type===J){const f=t.input&&typeof t.input=="object"?t.input:void 0,v=!!f&&Array.isArray(f.form),D=v?t.input:void 0,$=t.state==="output-available"&&t.output?t.output:void 0;let N;return t.state==="output-available"?N="submitted":t.state==="output-error"?N="declined":v&&t.state==="input-available"?N="active":N="pending",e.jsx(xe.AskUserForm,{input:D,output:$,status:N,errorText:t.state==="output-error"&&"errorText"in t?t.errorText:void 0,onSubmit:I,onDecline:U})}const R=a?_.DynamicComponent:te;return e.jsx(R,{name:t.type,props:O,componentDef:a})};function Q(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:k.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:String(t)}):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 Z=({name:t,value:a,isArrayIndex:l,depth:o=0})=>{const[c,s]=n.useState(o<1),x=a!==null&&typeof a=="object"&&!Array.isArray(a),p=Array.isArray(a);if(!(x||p))return e.jsxs("div",{className:"flex items-baseline gap-2 py-1 text-xs",children:[e.jsx("span",{className:k.cn("font-medium shrink-0",l?"text-gray-300 dark:text-white-alpha-300":"text-gray-500 dark:text-white-alpha-500"),children:l?"—":t}),e.jsx("span",{className:"min-w-0",children:Q(a)})]});const i=p?a.map((m,h)=>[String(h),m]):Object.entries(a);return i.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:p?"empty list":"empty"})]}):e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:m=>{m.stopPropagation(),s(!c)},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:k.cn("h-3.5 w-3.5 text-gray-400 dark:text-white-alpha-400 shrink-0 transition-transform",!c&&"-rotate-90")}),e.jsx("span",{className:"font-medium text-gray-500 dark:text-white-alpha-500",children:t}),!c&&e.jsx("span",{className:"text-gray-400 dark:text-white-alpha-400 text-1xs ml-1",children:p?`${i.length} item${i.length!==1?"s":""}`:`${i.length} field${i.length!==1?"s":""}`})]}),c&&e.jsx("div",{className:"border-l-2 border-gray-200 dark:border-white-alpha-200 ml-1.5 pl-3",children:i.map(([m,h])=>e.jsx(Z,{name:m,value:h,isArrayIndex:p,depth:o+1},m))})]})},ee=({value:t})=>{if(t==null||typeof t!="object")return e.jsx("span",{className:"text-xs",children:Q(t)});const a=Array.isArray(t)?t.map((l,o)=>[String(o),l]):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(([l,o])=>e.jsx(Z,{name:l,value:o,isArrayIndex:Array.isArray(t)},l))})},te=({props:t})=>{const{tool:a,approve:l}=t,o=a.type,c=o.startsWith("tool-")?o.slice(5):o,s=a.state,x=a.approval?.id,p=!!x,b=s==="approval-requested",i=ye(a.output),[u,m]=n.useState(p),h=s?he[s]??s:"tool";n.useEffect(()=>{b&&m(!0)},[b]);const y=()=>{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:()=>m(!u),"aria-expanded":u,"data-expanded":u,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:c})]})}),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:[y(),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":u,className:k.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":u,className:k.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":u,className:k.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(ee,{value:a.input})})})}),b&&x&&e.jsxs("div",{className:"flex justify-end gap-2 pt-1 pb-3 px-4",children:[e.jsx("button",{type:"button",className:k.cn(H.button({size:"xs",variant:"outline"}),"px-2 py-1 rounded-md text-xs text-gray-700 dark:text-white-alpha-700"),onClick:()=>l(!1),children:"Deny"}),e.jsxs("button",{type:"button",className:k.cn(H.button({size:"xs",variant:"primaryFilled"}),"px-2 py-1 rounded-md text-xs gap-1"),onClick:()=>l(!0),children:[e.jsx(d.Check,{className:"w-3 h-3"}),"Approve"]})]}),s==="output-available"&&i&&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:[i==="approved"&&e.jsx(d.Check,{className:"w-3 h-3"}),i]}),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]})]})]})},ke=({className:t,componentStyles:a,children:l,isLast:o,...c})=>{const{message:s}=ie.useMessage(),{logEvent:x}=ne.useBaseEvents(),{conversationId:p,isStreaming:b,isLoading:i,setError:u,addToolApprovalResponse:m,addToolOutput:h,sendMessage:y}=le.useChat(),{aiChatSettings:{components:M,artifacts:I,headers:U}}=oe.useInkeepConfig(),O=U?.["x-emit-operations"]==="true",R=s.role==="user",f=(b||i)&&o&&s.role==="assistant",{processedParts:v,summaryTimings:D,shouldShowInitialLoading:$,shouldShowStreamDelayLoading:N}=ue.useStreamProcessor(s.parts,f,u),[P,V]=n.useState(null),[ae,L]=n.useState(!1),j=n.useRef(null);n.useEffect(()=>{if(!P){L(!1),j.current&&(clearTimeout(j.current),j.current=null);return}return L(!1),j.current&&clearTimeout(j.current),j.current=window.setTimeout(()=>{L(!0)},1e3),()=>{j.current&&(clearTimeout(j.current),j.current=null)}},[P]),n.useEffect(()=>{P&&(!o||s.parts.length>P.partCount||!f)&&V(null)},[P,o,s.parts.length,f]);const B=n.useMemo(()=>s.parts.filter(ce.isCitationArtifact),[s.parts]),G=n.useMemo(()=>de.merge(pe.markdownStyles,a??{}),[a]),W=n.useCallback((r,g)=>{x({eventName:"assistant_message_inline_link_opened",properties:{title:g?.toString(),url:r}})},[x]),X=n.useCallback((r,g)=>{x({eventName:"assistant_code_block_copied",properties:{conversationId:p,language:r,code:g}})},[x,p]),z=n.useCallback(r=>e.jsx(T.EmbeddedChatPrimitiveMarkdown,{text:r,componentStyles:G,onLinkClick:W,onCodeCopy:X,artifacts:B}),[G,W,X,B]),re=n.useMemo(()=>k.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]),se=!R||s.parts.some(r=>r.type==="text"&&r.text?.trim());return e.jsxs(e.Fragment,{children:[!se&&e.jsx("span",{className:"text-gray-500 dark:text-white-alpha-500",children:"No message content"}),v.map((r,g)=>{const S={"data-role":s.role,"data-type":r?.type==="data-component"?r.data.type:r?.type,...c,className:re};switch(r?.type){case"text":return e.jsx(T.PrimitiveMessagePart,{...S,children:R?r.text:z(r.text||"")},g);case"data-component":{const{type:C}=r.data;switch(C){case"text":return e.jsx("div",{...S,children:z(r.data.text||"")},g);default:{const A=r.data,{name:w,props:E}=A,q=M?.[w],F=q?_.DynamicComponent:be;return e.jsx(T.PrimitiveMessagePart,{...S,children:e.jsx(F,{name:w,props:E,componentDef:q})},`${w}-${g}`)}}}case"data-artifact":{const C=r.data,{name:A,type:w,artifactSummary:E}=C;if(w==="citation"&&!E?.url)return null;const q=I?.[w],F=q?_.DynamicComponent:je;return e.jsx(T.PrimitiveMessagePart,{...S,children:e.jsx(F,{name:w,props:E,componentDef:q})},`${A}-${g}`)}case"summary-group":{const C=D.get(r.groupKey)||{isCompleted:!1};return e.jsx(T.PrimitiveMessagePart,{...S,children:e.jsx(me.DataSummaryGroup,{summaries:r.summaries||[],isCompleted:C.isCompleted})},`${r.groupKey}-${g}`)}default:{if(!fe(r))return null;const C=r,A=r.approval?.id,w=C.type===J;return O||A||w?e.jsx(T.PrimitiveMessagePart,{...S,children:e.jsx(we,{tool:C,componentDef:M?.IkpTool,renderText:z,approvalId:A,messagePartsLength:s.parts.length,setApprovalDelayPending:V,addToolApprovalResponse:m,addToolOutput:h,sendMessage:y,conversationId:p})},r.toolCallId??`${r.type}-${g}`):null}}}),$&&e.jsx(_.MessageLoading,{}),(N||ae)&&e.jsx(ge,{})]})};exports.DefaultToolComponent=te;exports.EmbeddedChatMessagePart=ke;