PageSourceSearch

https://apps.mrassistant.ai/static/js/315.5f5bfb7b.chunk.js

js mrassistant.ai collected 2026-10-05 12:17:10 UTC 86,322 bytes, 2 lines download raw bytes

1/*! For license information please see 315.5f5bfb7b.chunk.js.LICENSE.txt */
2"use strict";(self.webpackChunkmrassistant_frontend=self.webpackChunkmrassistant_frontend||[]).push([[315],{315:(e,t,a)=>{a.r(t),a.d(t,{default:()=>X});var r=a(9950),s=a(8429),n=a(2074),o=a(3084),l=a(5885),i=a(1262),d=a(7091),c=a(2759);async function u(){const e=await i.Ay.getAgents(),t=Array.isArray(e)?e:[],a={};return await Promise.all(t.map(async e=>{const t=String(e.id);try{a[t]=await i.Ay.listAgentTools(t)}catch{a[t]=[]}})),{agents:t,instancesByAgent:a}}var g=a(3053),x=a(998),m=a(3365),h=a(2393),p=a(4414);const y=x._C.tools,f=x.RV.search,b=x.RV.add,v=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter(Boolean).join(" ")},k=e=>{let{agents:t,instancesByAgent:a,selectedAgentId:s,onSelectAgent:n,onCreate:o,onSearch:l,searchValue:i,embedded:d=!1}=e;const c=i.trim().toLowerCase(),u=(0,r.useMemo)(()=>t.filter(e=>(a[e.id]||[]).length>0),[t,a]),g=(0,r.useMemo)(()=>c?u.filter(e=>{const t=(e.name||"").toLowerCase().includes(c),r=(a[e.id]||[]).some(e=>String(e.instance_name||"").toLowerCase().includes(c)||String(e.tool_key||e.tool_id||"").toLowerCase().includes(c)||String(e.display_name||"").toLowerCase().includes(c));return t||r}):u,[u,a,c]),x=(0,r.useMemo)(()=>g.reduce((e,t)=>e+(a[t.id]||[]).length,0),[g,a]);return(0,p.jsxs)("nav",{className:v(m.aP,d?"h-full w-full":m.y3),"aria-label":"Tools by assistant",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between border-b border-gray-200 px-3 pt-4 pb-2 dark:border-edge",children:[(0,p.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,p.jsx)(y,{className:"h-5 w-5 text-gray-700 dark:text-gray-300"}),(0,p.jsx)("h2",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Tools"})]}),(0,p.jsx)("button",{type:"button",onClick:()=>(0,m.Os)(h.A.docsBaseUrl),className:m.a8,children:"Docs"})]}),(0,p.jsxs)("div",{className:"border-b border-gray-200 px-3 py-2 space-y-2 dark:border-edge",children:[(0,p.jsxs)("button",{type:"button",onClick:o,className:"inline-flex w-full items-center justify-center gap-2 rounded-lg bg-accent px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-accent-hover",children:[(0,p.jsx)(b,{className:"h-4 w-4"}),"Create Tool"]}),(0,p.jsxs)("div",{className:"relative",children:[(0,p.jsx)(f,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),(0,p.jsx)("input",{value:i,onChange:e=>l(e.target.value),placeholder:"Search assistants...",className:"w-full rounded-lg border border-gray-200 bg-gray-50 py-2 pl-9 pr-3 text-sm text-gray-900 placeholder-gray-500 transition-colors focus:border-accent focus:bg-white focus:outline-none focus:ring-2 focus:ring-accent/20 dark:border-neutral-700 dark:bg-surface dark:text-gray-100 dark:placeholder-gray-400 dark:focus:border-accent"})]})]}),(0,p.jsxs)("div",{className:"flex-1 overflow-y-auto min-h-0 px-3 py-2",children:[(0,p.jsx)("p",{className:"px-3 pb-2 text-[11px] text-gray-500 dark:text-gray-400",children:"Only assistants with at least one tool are listed."}),0===g.length?(0,p.jsx)("p",{className:"px-3 py-4 text-center text-sm text-gray-500 dark:text-gray-400",children:0===u.length?"No assistants have tools yet. Create a tool and assign it to an assistant.":"No matching assistants with tools."}):(0,p.jsx)("div",{className:"space-y-0.5",children:g.map(e=>{const t=s===e.id,r=(a[e.id]||[]).length;return(0,p.jsxs)("button",{type:"button",onClick:()=>n(e.id),className:v("flex w-full items-center gap-2",(0,m.TI)(t)),children:[(0,p.jsx)("div",{className:"min-w-0 flex-1 text-left",children:(0,p.jsx)("span",{className:(0,m.gQ)(t),children:e.name||"Assistant"})}),(0,p.jsx)("span",{className:(0,m.pr)(t),children:r})]},e.id)})})]}),(0,p.jsx)("div",{className:"border-t border-gray-200 px-3 py-2 dark:border-edge",children:(0,p.jsxs)("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[g.length," ",1===g.length?"assistant":"assistants"," \xb7 ",x," ",1===x?"instance":"instances"]})})]})};var j=a(9318);const w=(0,a(6230).A)("unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]);var N=a(5867),_=a(691);const C=x.RV.delete,S=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter(Boolean).join(" ")},A={connected:{label:"Connected",dot:"bg-emerald-500"},disconnected:{label:"Disconnected",dot:"bg-gray-400"},error:{label:"Error",dot:"bg-red-500"}
2,pending:{label:"Pending",dot:"bg-amber-500"}},T=(0,r.memo)(e=>{let{title:t,onClick:a,children:r,pressed:s,className:n,...o}=e;return(0,p.jsx)("button",{type:"button",title:t,onClick:a,"aria-pressed":s,className:S("inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-gray-200 bg-white text-gray-500 transition-colors","hover:bg-gray-50 hover:text-gray-800 dark:border-edge dark:bg-surface dark:text-gray-400 dark:hover:bg-white/5 dark:hover:text-gray-200","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-300/40 dark:focus-visible:ring-neutral-600/40","disabled:cursor-not-allowed disabled:opacity-50",n),...o,children:r})});T.displayName="IconButton";const I=(0,r.memo)(e=>{let{status:t}=e;const a=A[t];return(0,p.jsx)("span",{className:"inline-flex shrink-0 items-center justify-center p-1",role:"status",title:a.label,"aria-label":`Status: ${a.label}`,children:(0,p.jsx)("span",{className:S("h-2 w-2 rounded-full",a.dot),"aria-hidden":"true"})})});I.displayName="StatusDot";const L=(0,r.memo)(e=>{let{filled:t}=e;return(0,p.jsx)("svg",{className:"h-3.5 w-3.5",viewBox:"0 0 24 24",fill:t?"currentColor":"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:(0,p.jsx)("path",{d:"M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.385a.563.563 0 00-.182-.557L3.041 10.385a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345l2.125-5.111z"})})});L.displayName="StarIcon";const E=(0,r.memo)(function(e){var t,a;let{tool:s,onEdit:n,onDelete:o,onToggle:l,onToggleFavorite:i,selectable:d=!1,selected:c=!1,onSelectToggle:u,getToolIcon:g,getToolDescription:x,getToolCategory:m,isFavorite:y=!1,className:f}=e;const b=(0,r.useMemo)(()=>s.description||x(s.type),[s.description,s.type,x]),v=(0,r.useMemo)(()=>m(s),[s,m]),k=(0,r.useMemo)(()=>{const e=s.updatedAt;if(!e)return null;const t="string"===typeof e?new Date(e):e;return Number.isNaN(t.getTime())?null:new Intl.DateTimeFormat(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t)},[s.updatedAt]),A=(0,r.useMemo)(()=>{var e;if(!s.updatedAt)return;const t="string"===typeof s.updatedAt?new Date(s.updatedAt):s.updatedAt;return null===(e=t.toISOString)||void 0===e?void 0:e.call(t)},[s.updatedAt]),E=(0,r.useCallback)(()=>n(s),[n,s]),$=(0,r.useCallback)(()=>o(s),[o,s]),O=(0,r.useCallback)(()=>l(s),[l,s]),D=(0,r.useCallback)(()=>{null===i||void 0===i||i(s.id)},[i,s.id]),M=(0,r.useCallback)(e=>{null===u||void 0===u||u(s.id,e.target.checked)},[u,s.id]),F=s.status||"disconnected",B="connected"===F,R=(null===(t=s.function)||void 0===t?void 0:t.name)||s.id,U=R?`${h.A.docsBaseUrl}/tools/${encodeURIComponent(R)}`:null,z=s.name||(null===(a=s.function)||void 0===a?void 0:a.name)||"Untitled Tool";return(0,p.jsxs)("article",{role:"group","aria-labelledby":`tool-${s.id}-title`,className:S("flex h-full min-w-0 flex-col rounded-lg border border-gray-200 bg-white p-3 shadow-sm transition-colors","dark:border-edge dark:bg-dark-700","hover:border-gray-300 dark:hover:border-neutral-600",f),children:[(0,p.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[d?(0,p.jsx)("input",{id:`select-tool-${s.id}`,type:"checkbox",checked:c,onChange:M,className:"mt-0.5 h-3.5 w-3.5 shrink-0 rounded border-gray-300 text-gray-900 focus:ring-1 focus:ring-gray-300/50 dark:border-neutral-600 dar
2k:bg-surface","aria-label":`Select ${z}`}):null,(0,p.jsx)("div",{className:S(_.ib,"shrink-0"),"aria-hidden":"true",children:(0,p.jsx)("span",{className:_.$4,children:g(s.type,"0.875rem","currentColor")})}),(0,p.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,p.jsxs)("div",{className:"flex min-w-0 items-start justify-between gap-2",children:[(0,p.jsx)("h3",{id:`tool-${s.id}-title`,className:"truncate text-sm font-semibold leading-tight text-gray-900 dark:text-gray-100",title:z,children:z}),(0,p.jsx)(I,{status:F})]}),(0,p.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-gray-500 dark:text-gray-400",children:[(0,p.jsx)("span",{children:v}),k?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,p.jsx)("time",{title:`Last updated: ${k}`,dateTime:A,children:k})]}):null]})]})]}),(0,p.jsx)("p",{className:"mt-2 line-clamp-2 flex-1 text-xs leading-snug text-gray-600 dark:text-gray-400",title:b,children:b}),U?(0,p.jsx)("a",{href:U,target:"_blank",rel:"noopener noreferrer",title:"Docs",className:"mt-2 inline-flex text-[11px] font-medium text-gray-500 transition-colors hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-200",onClick:e=>e.stopPropagation(),children:"Docs"}):null,(0,p.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-1 border-t border-gray-100 pt-2.5 dark:border-edge",children:[(0,p.jsx)(T,{title:"Configure","aria-label":`Configure ${z}`,onClick:E,children:(0,p.jsx)(j.A,{className:"h-3.5 w-3.5","aria-hidden":!0})}),(0,p.jsx)(T,{title:B?"Disconnect":"Connect","aria-label":B?`Disconnect ${z}`:`Connect ${z}`,onClick:O,children:B?(0,p.jsx)(w,{className:"h-3.5 w-3.5","aria-hidden":!0}):(0,p.jsx)(N.A,{className:"h-3.5 w-3.5","aria-hidden":!0})}),(0,p.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[i?(0,p.jsx)(T,{title:y?"Remove from favorites":"Add to favorites","aria-label":y?"Remove from favorites":"Add to favorites",onClick:D,pressed:y,className:S(y&&"border-amber-200 text-amber-600 dark:border-amber-500/30 dark:text-amber-400"),children:(0,p.jsx)(L,{filled:y})}):null,(0,p.jsx)(T,{title:`Delete ${z}`,"aria-label":`Delete ${z}`,onClick:$,className:"text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/30",children:(0,p.jsx)(C,{className:"h-3.5 w-3.5","aria-hidden":!0})})]})]})]})});E.displayName="ToolsCard";const $=E;var O=a(7130);const D=e=>{let{isOpen:t,onClose:a,tools:s,onOpenTool:n}=e;const o=(0,r.useRef)(null);(0,r.useEffect)(()=>{t&&setTimeout(()=>{var e;return null===(e=o.current)||void 0===e?void 0:e.focus()},50)},[t]);const[l,i]=r.useState(""),d=(0,r.useMemo)(()=>{const e=l.trim().toLowerCase();return e?s.map(t=>({t:t,score:(t.name+" "+(t.description||"")+" "+t.type).toLowerCase().includes(e)?1:0})).filter(e=>e.score>0).slice(0,20).map(e=>e.t):s.slice(0,20)},[s,l]);return(0,p.jsx)(O.A,{isOpen:t,onClose:a,size:"lg",title:"Quick search",children:(0,p.jsxs)("div",{className:"space-y-3",children:[(0,p.jsx)("input",{ref:o,value:l,onChange:e=>i(e.target.value),placeholder:"Search tools (name, description, type)",className:"w-full rounded-lg bg-white dark:bg-dark-700 border border-gray-300 dark:border-dark-600 px-3 py-2 text-sm text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-[#ff0000]/40 focus:border-accent"}),(0,p.jsx)("ul",{className:"max-h-96 overflow-auto divide-y divide-gray-200 dark:divide-dark-600",children:d.map(e=>(0,p.jsx)("li",{children:(0,p.jsxs)("button",{onClick:()=>{n(e),a()},className:"w-full text-left px-3 py-2 hover:bg-gray-50 dark:hover:bg-dark-700 rounded-md flex items-center justify-between",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:e.name}),(0,p.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-300",children:e.description})]}),(0,p.jsx)("span",{className:"text-xs text-gray-400",children:"Enter"})]})},e.id))})]})})},M=e=>{let{id:t,value:a,onChange:s,rows:n=16,placeholder:o="{}",className:l="","aria-label":i="JSON configuration editor"}=e;const d=(0,r.useCallback)(()=>{try{const e=JSON.parse(a||"{}");s(JSON.stringify(e,null,2))}catch{}},[s,a]);return(0,p.jsxs)("div",{className:`overflow-hidden rounded-xl border border-gray-300 dark:border-dark-600 ${l}`,children:[(0,p.jsxs)("div",{className:"flex items-center justify-between border-b border-gray-200 bg-gray-100 px-3 py-1.5 dark:border-dark-600 dark:bg-dark-900",children:[(0,p.jsx)("span",{className:"text-[11px] font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"JSON"}),(0,p.jsx)("button",{type:"button",onClick:d,className:"text-[11px] font-semibold text-accent hover:underline",children:"Format"})]}),(0,p.jsx)("textarea",{id:t,value:a,onChange:e=>s(e.target.value),rows:n,spellCheck:!1,"aria-label":i,placeholder:o,className:"block w-full resize-y bg-gray-50 px-4 py-3 font-mono text-xs leading-relaxed text-gray-900 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-accent/30 dark:bg-dark-900 dark:text-gray-100"})]})};var F=a(3621),B=a(6479);const R=e=>{var t,a,s;let{isOpen:n,onClose:o,tool:l,toolName:i,toolDescription:d,configData:c,onNameChange:u,onDescriptionChange:g,onConfigChange:x,onSave:m,getToolIconBgColor:h,getToolIcon:y,showJsonEditor:f,onToggleJsonEditor:b,instanceEdit:v=null,toolEnabled:k=!0,toolIsActive:j=!0,onToolEnabledChange:w,onToolIsActiveChange:N,docsUrl:_=null}=e;const C=(0,r.useRef)(null);if((0,r.useEffect)(()=>{const e=e=>{"Escape"===e.key&&n&&o()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[n,o]),(0,r.useEffect)(()=>(document.body.style.overflow=n?"hidden":"",()=>{document.body.style.overflow=""}),[n]),!n||!l)return null;const S=(e=>{switch(e){case"send_text":return"sms";case"transfer_call":return"call";case"end_call":return"endCall";case"dtmf":return"dtmf";case"google_calendar":return"calendar";case"google_sheets":return"sheets";case"slack":return"chat";default:return null}})(l.type);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("div",{className:"fixed inset-0 z-40 bg-black/50 transition-opacity duration-300 "+(n?"opacity-100":"opacity-0 pointer-events-none"),onClick:o,"aria-hidden":"true"}),(0,p.jsxs)("div",{ref:C,className:"fixed right-0 top-0 z-50 flex h-full w-[600px] max-w-full flex-col border-l border-gray-200/80 bg-white shadow-2xl transition-transform duration-300 ease-out dark:border-edge dark:bg-surface-raised "+(n?"translate-x-0":"translate-x-full"),role:"dialog","aria-modal":"true","aria-labelledby":"drawer-title",children:[(0,p.jsx)("div",{className:"shrink-0 border-b border-gray-200/80 bg-gray-50 dark:border-edge dark:bg-surface-page",children:(0,p.jsxs)("div",{className:"px-6 py-4",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between",children:[(0,p.jsxs)("div",{className:"flex items-center gap-3",children:[(0,p.jsx)("div",{className:`flex h-12 w-12 items-center justify-center rounded-lg ${h(l.type)}
2`,children:y(l.type,"1.5rem","white")}),(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[(0,p.jsx)("h2",{id:"drawer-title",className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:i||(null===(t=l.function)||void 0===t?void 0:t.name)||"Untitled Tool"}),S&&(0,p.jsx)("span",{className:"px-2 py-1 text-xs font-medium rounded-md bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300 transition-all duration-300 hover:scale-105",children:S})]})]}),(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[(0,p.jsxs)("button",{onClick:m,className:"inline-flex items-center gap-2 rounded-lg bg-primary px-4 py-2 text-sm font-semibold text-primary-contrast shadow-sm transition duration-150 hover:bg-primary-hover",children:[(0,p.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Save"]}),!v&&(0,p.jsxs)("button",{type:"button",onClick:b,className:"inline-flex items-center gap-2 rounded-lg border border-gray-300 bg-white px-4 py-2 text-sm font-semibold text-gray-700 transition duration-150 hover:bg-gray-50 dark:border-edge dark:bg-surface dark:text-gray-200 dark:hover:bg-surface-raised",title:f?"Show Form":"Show Code",children:[(0,p.jsx)("svg",{className:"w-4 h-4 transition-transform duration-300 group-hover:scale-110 group-hover:rotate-12",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),"Code"]}),(0,p.jsx)("button",{onClick:o,className:"rounded-lg p-2 text-gray-500 transition duration-150 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-surface-raised dark:hover:text-gray-200","aria-label":"Close drawer",children:(0,p.jsx)(B.A,{className:"h-5 w-5"})})]})]}),(0,p.jsxs)("p",{className:"mt-2 text-sm text-gray-500 dark:text-gray-400",children:[l.id,_?(0,p.jsxs)(p.Fragment,{children:[" \xb7 ",(0,p.jsx)("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-accent hover:underline",children:"Documentation"})]}):null]})]})}),(0,p.jsx)("div",{className:"flex-1 overflow-y-auto overscroll-contain",children:(0,p.jsxs)("div",{className:"px-6 py-6 space-y-6",children:[(0,p.jsxs)("div",{className:"group",children:[(0,p.jsx)("label",{htmlFor:"drawer-tool-name",className:"block text-sm font-semibold text-gray-900 dark:text-white mb-2 transition-colors duration-300 group-focus-within:text-accent",children:v?"Display name":"Tool Name"}),(0,p.jsx)("input",{id:"drawer-tool-name",type:"text",value:i||(null===(a=l.function)||void 0===a?void 0:a.name)||"",onChange:e=>u(e.target.value),className:"w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-900 placeholder-gray-400 focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/20 dark:border-edge dark:bg-surface dark:text-white",placeholder:(null===(s=l.function)||void 0===s?void 0:s.name)||"Enter tool name"})]}),(0,p.jsxs)("div",{className:"group",children:[(0,p.jsxs)("label",{htmlFor:"drawer-description",className:"block text-sm font-semibold text-gray-900 dark:text-white mb-2 transition-colors duration-300 group-focus-within:text-accent",children:["Description",(0,p.jsxs)("span",{className:"ml-2 text-xs font-normal text-gray-500 dark:text-gray-400",children:[d.length,"/1000"]})]}),(0,p.jsx)("textarea",{id:"drawer-description",value:d,onChange:e=>g(e.target.value),rows:3,maxLength:1e3,className:"w-full resize-none rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-900 placeholder-gray-400 focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/20 dark:border-edge dark:bg-surface dark:text-white",placeholder:"Describe the tool in a few sentences"})]}),v&&(0,p.jsxs)("div",{className:"rounded-xl border border-gray-200/80 dark:border-dark-600 bg-gray-50/80 dark:bg-dark-900/50 p-4 space-y-3",children:[(0,p.jsx)("p",{className:"text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Instance"}),(0,p.jsxs)("div",{className:"grid gap-2 text-sm",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:"Instance name"}),(0,p.jsx)("p",{className:"font-mono text-gray-900 dark:text-white break-all",children:v.instanceName})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:"Tool key"}),(0,p.jsx)("p",{className:"font-mono text-gray-900 dark:text-white break-all",children:v.toolKey})]}),null!=v.toolType&&""!==v.toolType&&(0,p.jsxs)("div",{children:[(0,p.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:"Tool type"}),(0,p.jsx)("p",{className:"font-mono text-gray-900 dark:text-white",children:v.toolType})]})]}),(0,p.jsxs)("div",{className:"flex flex-wrap gap-4 pt-1",children:[(0,p.jsxs)("label",{className:"inline-flex items-center gap-2 text-sm text-gray-800 dark:text-gray-200 cursor-pointer",children:[(0,p.jsx)("input",{type:"checkbox",className:"rounded border-gray-300 text-accent focus:ring-accent/20",checked:k,onChange:e=>null===w||void 0===w?void 0:w(e.target.checked)}),"Enabled"]}),(0,p.jsxs)("label",{className:"inline-flex items-center gap-2 text-sm text-gray-800 dark:text-gray-200 cursor-pointer",children:[(0,p.jsx)("input",{type:"checkbox",className:"rounded border-gray-300 text-accent focus:ring-accent/20",checked:j,onChange:e=>null===N||void 0===N?void 0:N(e.target.checked)}),"Active"]})]})]}),v?(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{htmlFor:"drawer-json-config-agent",className:"block text-sm font-semibold text-gray-900 dark:text-white mb-2",children:"Configuration (JSON)"}),(0,p.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:"Full tool config sent to the server. edit keys to match this tool type."}
2),(0,p.jsx)(M,{id:"drawer-json-config-agent",value:c,onChange:x,rows:22,"aria-label":"Tool configuration JSON"})]}):f?(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{htmlFor:"drawer-json-config",className:"block text-sm font-semibold text-gray-900 dark:text-white mb-2",children:"Configuration (JSON)"}),(0,p.jsx)(M,{id:"drawer-json-config",value:c,onChange:x,rows:20,"aria-label":"Tool configuration JSON"})]}):(0,p.jsxs)("div",{children:[(0,p.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-4",children:"Settings"}),(0,p.jsxs)("div",{className:"space-y-6",children:["send_text"===l.type&&(0,p.jsx)("div",{className:"rounded-xl border border-amber-200 bg-amber-50 dark:border-amber-900/50 dark:bg-amber-900/20 p-4",children:(0,p.jsxs)("div",{className:"flex items-start gap-3",children:[(0,p.jsx)("svg",{className:"w-5 h-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,p.jsxs)("div",{children:[(0,p.jsx)("h4",{className:"text-sm font-semibold text-amber-900 dark:text-amber-200 mb-1",children:"From Phone Number"}),(0,p.jsx)("p",{className:"text-sm text-amber-800 dark:text-amber-300",children:"No configured Twilio numbers found. Add one in Phone Numbers."}),(0,p.jsx)("p",{className:"text-xs text-amber-700 dark:text-amber-400 mt-1",children:"Select one of your configured Twilio phone numbers (required)"})]})]})}),"slack"===l.type&&(0,p.jsxs)("div",{className:"space-y-4",children:[(0,p.jsx)("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Slack Configuration"}),(0,p.jsxs)("div",{children:[(0,p.jsxs)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Bot User OAuth Token ",(0,p.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,p.jsx)("input",{type:"password",placeholder:"xoxb-your-bot-token",className:"w-full px-3 py-2 border border-gray-300 dark:border-dark-600 rounded-lg bg-white dark:bg-dark-700 text-gray-900 dark:text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-transparent"}),(0,p.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Required for API authentication. Get it from OAuth & Permissions in your Slack App settings."})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Workspace Name"}),(0,p.jsx)("input",{type:"text",placeholder:"your-workspace",className:"w-full px-3 py-2 border border-gray-300 dark:border-dark-600 rounded-lg bg-white dark:bg-dark-700 text-gray-900 dark:text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-transparent"}),(0,p.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Your Slack workspace name (e.g., company-name.slack.com)"})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Default Channel"}),(0,p.jsx)("input",{type:"text",placeholder:"#general",className:"w-full px-3 py-2 border border-gray-300 dark:border-dark-600 rounded-lg bg-white dark:bg-dark-700 text-gray-900 dark:text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-transparent"}),(0,p.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Default channel for posting messages (e.g., #general, #notifications)"})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Webhook URL (Optional)"}),(0,p.jsx)("input",{type:"url",placeholder:"https://hooks.slack.com/services/...",className:"w-full px-3 py-2 border border-gray-300 dark:border-dark-600 rounded-lg bg-white dark:bg-dark-700 text-gray-900 dark:text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-accent/20 focu
2s:border-transparent"}),(0,p.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Incoming webhook URL for posting messages (alternative to OAuth token)"})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"OAuth Scopes"}),(0,p.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,p.jsx)("span",{className:"px-2 py-1 text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded-md",children:"chat:write"}),(0,p.jsx)("span",{className:"px-2 py-1 text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded-md",children:"channels:read"}),(0,p.jsx)("span",{className:"px-2 py-1 text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded-md",children:"users:read"})]}),(0,p.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:"Required OAuth scopes configured in your Slack App"})]})]}),"google_sheets"===l.type&&(0,p.jsxs)("div",{className:"space-y-4",children:[(0,p.jsx)("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Google Sheets Configuration"}),(0,p.jsxs)("div",{children:[(0,p.jsxs)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["OAuth 2.0 Client Credentials ",(0,p.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,p.jsx)("textarea",{rows:6,placeholder:'{"type": "service_account", "project_id": "...", "private_key": "..."}',className:"w-full px-3 py-2 border border-gray-300 dark:border-dark-600 rounded-lg bg-white dark:bg-dark-700 text-gray-900 dark:text-white placeholder-gray-400 font-mono text-xs focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-transparent"}),(0,p.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Paste your Google Cloud service account JSON credentials here"})]}),(0,p.jsxs)("div",{children:[(0,p.jsxs)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["Spreadsheet ID ",(0,p.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,p.jsx)("input",{type:"text",placeholder:"1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",className:"w-full px-3 py-2 border border-gray-300 dark:border-dark-600 rounded-lg bg-white dark:bg-dark-700 text-gray-900 dark:text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-transparent"}),(0,p.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"The ID from your Google Sheets URL (between /d/ and /edit)"})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Sheet Name/Range"}),(0,p.jsx)("input",{type:"text",placeholder:"Sheet1!A1:Z1000",className:"w-full px-3 py-2 border border-gray-300 dark:border-dark-600 rounded-lg bg-white dark:bg-dark-700 text-gray-900 dark:text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-transparent"}),(0,p.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Specify the sheet and range to read/write (e.g., Sheet1!A1:Z1000)"})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Access Mode"}),(0,p.jsxs)("select",{className:F.KK,children:[(0,p.jsx)("option",{value:"read",children:"Read Only"}),(0,p.jsx)("option",{value:"write",children:"Write Only"}),(0,p.jsx)("option",{value:"readwrite",children:"Read & Write"})]}),(0,p.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Define the access permissions for this integration"})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"API Scopes"}),(0,p.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,p.jsx)("span",{className:"px-2 py-1 text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300 rounded-md",children:"spreadsheets"}),(0,p.jsx)("span",{className:"px-2 py-1 text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300 rounded-md",children:"drive.readonly"})]}),(0,p.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:"Required Google API scopes for Sheets access"})]})]}),"google_calendar"===l.type&&(0,p.jsxs)("div",{className:"space-y-4",children:[(0,p.jsx)("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Google Calendar Configuration"}),(0,p.jsxs)("div",{children:[(0,p.jsxs)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["OAuth 2.0 Client Credentials ",(0,p.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,p.jsx)("textarea",{rows:6,placeholder:'{"type": "service_account", "project_id": "...", "private_key": "..."}',className:"w-full px-3 py-2 border border-gray-300 dark:border-dark-600 rounded-lg bg-white dark:bg-dark-700 text-gray-900 dark:text-white placeholder-gray-400 font-mono text-xs focus:outline-none focus:ring-2 focus:ring-accent/20 focu
2s:border-transparent"}),(0,p.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Paste your Google Cloud service account JSON credentials here"})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Calendar ID"}),(0,p.jsx)("input",{type:"text",placeholder:"primary or [email protected]",className:"w-full px-3 py-2 border border-gray-300 dark:border-dark-600 rounded-lg bg-white dark:bg-dark-700 text-gray-900 dark:text-white placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-transparent"}),(0,p.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:'The ID of the Google Calendar. Use "primary" for the main calendar or provide a specific calendar ID'})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Timezone"}),(0,p.jsxs)("select",{className:F.KK,children:[(0,p.jsx)("option",{value:"UTC",children:"UTC (Coordinated Universal Time)"}),(0,p.jsx)("option",{value:"America/New_York",children:"America/Ne
2w_York (EST/EDT)"}),(0,p.jsx)("option",{value:"America/Chicago",children:"America/Chicago (CST/CDT)"}),(0,p.jsx)("option",{value:"America/Denver",children:"America/Denver (MST/MDT)"}),(0,p.jsx)("option",{value:"America/Los_Angeles",children:"America/Los_Angeles (PST/PDT)"}),(0,p.jsx)("option",{value:"Europe/London",children:"Europe/London (GMT/BST)"}),(0,p.jsx)("option",{value:"Europe/Paris",children:"Europe/Paris (CET/CEST)"}),(0,p.jsx)("option",{value:"Asia/Tokyo",children:"Asia/Tokyo (JST)"}),(0,p.jsx)("option",{value:"Asia/Shanghai",children:"Asia/Shanghai (CST)"}),(0,p.jsx)("option",{value:"Australia/Sydney",children:"Australia/Sydney (AEST/AEDT)"})]}),(0,p.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"The time zone for calendar events. Defaults to UTC if not specified"})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Event Settings"}),(0,p.jsxs)("div",{className:"space-y-2",children:[(0,p.jsxs)("label",{className:"flex items-center gap-2",children:[(0,p.jsx)("input",{type:"checkbox",className:"w-4 h-4 text-accent rounded focus:ring-accent/20"}),(0,p.jsx)("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Send email notifications to attendees"})]}),(0,p.jsxs)("label",{className:"flex items-center gap-2",children:[(0,p.jsx)("input",{type:"checkbox",className:"w-4 h-4 text-accent rounded focus:ring-accent/20"}),(0,p.jsx)("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Enable meeting reminders"})]}),(0,p.jsxs)("label",{className:"flex items-center gap-2",children:[(0,p.jsx)("input",{type:"checkbox",className:"w-4 h-4 text-accent rounded focus:ring-accent/20",defaultChecked:!0}),(0,p.jsx)("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Use default visibility (public)"})]})]})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"API Scopes"}),(0,p.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,p.jsx)("span",{className:"px-2 py-1 text-xs bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 rounded-md",children:"calendar"}),(0,p.jsx)("span",{className:"px-2 py-1 text-xs bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 rounded-md",children:"calendar.events"}),(0,p.jsx)("span",{className:"px-2 py-1 text-xs bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 rounded-md",children:"calendar.readonly"})]}),(0,p.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:"Required Google API scopes for Calendar access"})]})]}),(0,p.jsxs)("div",{children:[(0,p.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,p.jsx)("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Messages"}),(0,p.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-lg bg-gray-100 px-3 py-1.5 text-sm font-medium text-gray-700 transition duration-150 hover:bg-gray-200 dark:bg-surface-raised dark:text-gray-200 dark:hover:bg-surface-page",children:[(0,p.jsx)("svg",{className:"w-4 h-4 transition-transform duration-300 group-hover:scale-110 group-hover:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"Add Message"]})]}),(0,p.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-4",children:"Configure messages to be spoken during different stages of tool execution"}),(0,p.jsxs)("div",{className:"rounded-xl border border-gray-200 dark:border-dark-600 p-4 bg-gray-50 dark:bg-dark-900",children:[(0,p.jsxs)("div",{className:"flex items-start gap-3 mb-3",children:[(0,p.jsxs)("div",{className:"flex-1",children:[(0,p.jsx)("label",{className:"block text-xs font-semibold text-gray-700 dark:text-gray-300 mb-2",children:"Request Start"}),(0,p.jsxs)("div",{className:"space-y-2",children:[(0,p.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,p.jsx)("input",{type:"radio",name:"request-start",className:"w-4 h-4 text-accent focus:ring-accent/20",defaultChecked:!0}),(0,p.jsx)("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Default (server will use default message)"})]}),(0,p.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,p.jsx)("input",{type:"radio",name:"request-start",className:"w-4 h-4 text-accent focus:ring-accent/20"}),(0,p.jsx)("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"None (no message will be spoken)"})]}),(0,p.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,p.jsx)("input",{type:"radio",name:"request-start",className:"w-4 h-4 text-accent focus:ring-accent/20"}),(0,p.jsx)("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Custom"})]})]})]}),(0,p.jsx)("button",{type:"button",className:"p-1.5 text-gray-400 hover:text-red-600 dark:hover:text-red-400 transition-colors","aria-label":"Delete message",children:(0,p.jsx)("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]}),(0,p.jsxs)("label",{className:"flex items-center gap-2 mt-3",children:[(0,p.jsx)("input",{type:"checkbox",className:"w-4 h-4 text-accent rounded focus:ring-accent/20"}),(0,p.jsx)("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Wait for message to be spoken before triggering tool call"})]})]}),(0,p.jsxs)("div",{className:"mt-6",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,p.jsx)("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"Conditions"}),(0,p.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-lg bg-gray-100 px-3 py-1.5 text-sm font-medium text-gray-700 transition duration-150 hover:bg-gray-200 dark:bg-surface-raised dark:text-gray-200 dark:hover:bg-surface-page",children:[(0,p.jsx)("svg",{className:"w-4 h-4 transition-transform duration-300 group-hover:scale-110 group-hover:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),"Add Condition"]})]}),(0,p.jsx)("p",{className:"text-sm italic text-gray-500 dark:text-gray-400",children:"No conditions defined"})]})]})]})]})]})})]})]})};var U=a(7334),z=a(5205),P=a(7624);const J=x._C.tools,W=e=>{let{isOpen:t,onClose:a,busy:s=!1,agents:n,agentId:o,onAgentIdChange:l,registryKeys:i,toolKey:d,onToolKeyChange:c,instanceName:u,onInstanceNameChange:g,displayName:x,onDisplayNameChange:m,description:h,onDescriptionChange:y,toolType:f,onToolTypeChange:b,configJson:v,onConfigJsonChange:k,enabled:j,onEnabledChange:w,onSubmit:N}=e;const _=(0,r.useMemo)(()=>{const e=u.trim();return e?/^[A-Za-z][A-Za-z0-9_-]{0,118}[A-Za-z0-9]?$/.test(e)?null:"Must start with a letter and use only letters, digits, _ or -.":null},[u]),C=(0,r.useMemo)(()=>
2{if(!_)return"";const e=u.trim().replace(/[^A-Za-z0-9_-]+/g,"_").replace(/^[^A-Za-z]+/,"").replace(/_+/g,"_").replace(/^_|_$/g,"").slice(0,120);return e&&/^[A-Za-z]/.test(e)?e:""},[u,_]),S=Boolean(o.trim()&&d.trim()&&u.trim()&&!_),A=(0,r.useMemo)(()=>n.map(e=>({value:String(e.id),label:e.name||String(e.id)})),[n]),T=(0,r.useMemo)(()=>i.map(e=>({value:e,label:e})),[i]);return(0,p.jsxs)(U.A,{isOpen:t,onClose:a,busy:s,width:"2xl",title:"Create tool instance",subtitle:"Attach a catalog tool to an assistant with custom configuration",icon:(0,p.jsx)(J,{className:"h-4 w-4","aria-hidden":!0}),titleId:"create-tool-instance-drawer-title",asForm:!0,onSubmit:N,footer:(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)("button",{type:"button",onClick:a,disabled:s,className:z.If,children:"Cancel"}),(0,p.jsx)("button",{type:"submit",disabled:!S||s,className:z.QH,children:s?"Creating\u2026":"Create instance"})]}),children:[(0,p.jsx)("p",{className:`mb-4 ${F.Z6}`,children:"Pick an assistant and catalog tool key, then set a unique instance name and JSON config. A starter template loads when you choose a tool type."}),(0,p.jsxs)("div",{className:`${F.f4} space-y-3`,children:[(0,p.jsx)("p",{className:F.th,children:"Target"}),(0,p.jsxs)("div",{children:[(0,p.jsxs)("label",{className:F.Q2,htmlFor:"create-tool-agent",children:["Assistant ",(0,p.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,p.jsx)("div",{className:"mt-1",children:(0,p.jsx)(P.A,{value:o,onChange:l,placeholder:"Select assistant\u2026",options:A})})]}),(0,p.jsxs)("div",{children:[(0,p.jsxs)("label",{className:F.Q2,htmlFor:"create-tool-key",children:["Tool type (catalog ",(0,p.jsx)("span",{className:"font-mono",children:"tool_key"}),") ",(0,p.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,p.jsx)("div",{className:"mt-1",children:(0,p.jsx)(P.A,{value:d,onChange:c,placeholder:o?"Select tool key\u2026":"Select an assistant first",options:T,disabled:!o})}),o?0===i.length?(0,p.jsx)("p",{className:`mt-1 ${F.Z6}`,children:"No catalog keys found for this assistant."}):null:(0,p.jsx)("p",{className:`mt-1 ${F.Z6}`,children:"Choose an assistant to load available catalog keys."})]})]}),(0,p.jsxs)("div",{className:`${F.f4} mt-3 space-y-3`,children:[(0,p.jsx)("p",{className:F.th,children:"Identity"}),(0,p.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,p.jsxs)("div",{children:[(0,p.jsxs)("label",{className:F.Q2,htmlFor:"create-tool-instance",children:["Instance name ",(0,p.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,p.jsx)("input",{id:"create-tool-instance",type:"text",value:u,onChange:e=>g(e.target.value),className:`mt-1 font-mono ${F.s1}`,placeholder:"e.g. end_call_polite",required:!0,autoComplete:"off","aria-invalid":Boolean(_),"aria-describedby":"create-tool-instance-hint"}),(0,p.jsx)("p",{id:"create-tool-instance-hint",className:`mt-1 ${_?"text-[10px] leading-snug text-red-600 dark:text-red-400":F.Z6}`,children:_||"Letters, digits, _ or -. used in API paths."}),C?(0,p.jsxs)("button",{type:"button",onClick:()=>g(C),className:"mt-1 text-[10px] font-medium text-accent hover:underline dark:text-accent-text",children:["Use \u201c",C,"\u201d"]}):null]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:F.Q2,htmlFor:"create-tool-display",children:"Display name"}),(0,p.jsx)("input",{id:"create-tool-display",type:"text",value:x,onChange:e=>m(e.target.value),className:`mt-1 ${F.s1}`,placeholder:"Label for operators (optional)"})]})]}),(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:F.Q2,htmlFor:"create-tool-desc",children:"Description"}),(0,p.jsx)("textarea",{id:"create-tool-desc",value:h,onChange:e=>y(e.target.value),rows:3,className:`mt-1 ${F.yV}`,placeholder:"Shown to the model / operators"})]}),(0,p.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("label",{className:F.Q2,htmlFor:"create-tool-type",children:"Tool type (API)"}),(0,p.jsx)("input",{id:"create-tool-type",type:"text",value:f,onChange:e=>b(e.target.value),className:`mt-1 font-mono ${F.s1}`,placeholder:"function"})]}),(0,p.jsxs)("div",{className:`${F.OO} mt-5 sm:mt-6`,children:[(0,p.jsxs)("div",{children:[(0,p.jsx)("p",{className:"text-xs font-medium text-gray-900 dark:text-gray-100",children:"Enabled"}),(0,p.jsx)("p",{className:`${F.Z6} mt-0.5`,children:"Instance is active for this assistant"})]}
2),(0,p.jsx)("input",{type:"checkbox",className:"h-4 w-4 rounded border-gray-300 text-accent focus:ring-accent/30",checked:j,onChange:e=>w(e.target.checked),"aria-label":"Enabled"})]})]})]}),(0,p.jsxs)("div",{className:`${F.f4} mt-3`,children:[(0,p.jsx)("p",{className:F.th,children:"Configuration"}),(0,p.jsx)("p",{className:`mt-1 ${F.Z6}`,children:"Replace placeholders (numbers, URLs, trunk IDs) before creating. Must be valid JSON object."}),(0,p.jsx)("div",{className:"mt-2",children:(0,p.jsx)(M,{id:"create-tool-cfg",value:v,onChange:k,rows:14,"aria-label":"New tool configuration JSON"})})]})]})};var q=a(9981);const K="::";function Z(e,t){return`${String(e)}${K}${encodeURIComponent(t)}`}function V(e){const t=e.indexOf(K);return t<=0?null:{agentId:e.slice(0,t),instanceName:decodeURIComponent(e.slice(t+2))}}function H(e,t){var a,r,s,n,o;const i=String(null!==(a=null!==(r=e.tool_key)&&void 0!==r?r:e.tool_id)&&void 0!==a?a:"function").trim()||"function",d=(0,l.rE)(i),c=(new Date).toISOString();return{id:Z(t,e.instance_name),name:(null===(s=e.display_name)||void 0===s?void 0:s.trim())||e.instance_name,description:(null===(n=e.description)||void 0===n?void 0:n.trim())||("string"===typeof(null===(o=e.config)||void 0===o?void 0:o.description)?e.config.description:"")||"",type:d,function:{name:i},orgId:"",createdAt:e.created_at||c,updatedAt:e.created_at||c,status:!1!==e.enabled&&!1!==e.is_active?"connected":"disconnected",configuration:e.config&&"object"===typeof e.config?e.config:{}}}const Q={end_call:{goodbye_instructions:"Thank you for calling Acme. Have a wonderful day!",goodbye_max_duration_ms:6e3,delete_room:!0,wait_for_playout:!0,record_end_reason:!0,description:"Use to end the call once the caller is done.",tool_type:"function",is_end_call:!0},"end-call":{description:"End Call",tool_type:"function",is_end_call:!0},send_dtmf_events:{default_inter_digit_ms:100,default_duration_ms:200,default_volume:50,ivr_detection:!1,allowed_digits:"0123456789*#",max_sequence_length:16,description:"Press digits during a phone call (for IVR navigation).",tool_type:"function"},cold_transfer:{sip_trunk_id:"ST_replace",target_directory:["human_operator","general_support","representative"],target_number:"+10000000000",play_dialtone:!1,cold_transfer_announcement_prompt:"Connecting you to a representative now. One moment please.",description:"Cold-transfer the caller to a real human.",tool_type:"function",is_transfer:!0,targets:[{number:"+10000000000",name:"human_operator"},{number:"+10000000000",name:"representative"}]},warm_transfer:{sip_trunk_id:"ST_replace",transfer_briefing_prompt:"Brief the supervisor: {summary}",transfer_announcement_prompt:"Connecting you to a supervisor.",transfer_timeout_s:30,transfer_max_attempts:1,take_message_on_failure:!0,target_directory:["supervisor"],target_number:"+18005550100",description:"Warm-transfer the caller to a supervisor with full context.",tool_type:"function",is_transfer:!0},transfer_to_specialist:{prefer_warm:!0,handoff_announcement_prompt:"Connecting you to {display_name}.",preserve_chat_ctx:!0,chat_ctx_token_cap:6e3,description:"Hand off the conversation to a specialist (e.g. billing).",tool_type:"function",is_transfer:!0},custom_test_tool:{simulate_latency_ms:100,simulate_error_rate:0,canned_response:"ECHO: {input}",description:"A test tool that echoes back whatever input it receives.",tool_type:"function"},http_webhook:{auth_mode:"none",url:"https://httpbin.org/anything",url_allowlist:["https://httpbin.org/*"],default_method:"POST",allowed_methods:["GET","POST"],default_headers:{"X-Source":"mrassistant"},timeout_s:10,max_retries:1,max_body_bytes:32768,redact_response_pii:!0,response_format:"json",description:"Fetch information from an external HTTP endpoint.",tool_type:"function"},query_tool:{data_source_type:"vector_search",data_source_url:"internal://kb",query_template:"{query}",top_k_default:5,similarity_threshold:.3,description:"Search the agent knowledge base for relevant info.",tool_type:"function"},mcp_server:{timeout_s:10,timeout_seconds:10,mcp_url:"https://mrasst.mrassistant.ai/mcp",mcp_allowlist:["platform.current_time","platform.echo"],bearer_token:"",description:"MCP server tools (set bearer_token and allowlist as needed).",tool_type:"function"}
2,dtmf_tool:{description:"dtmf_tool",tool_type:"function"}},G={send_dtmf:"send_dtmf_events",dtmf:"send_dtmf_events","warm-transfer":"warm_transfer","cold-transfer":"cold_transfer"};function Y(e){return null!=e&&"object"===typeof e?JSON.parse(JSON.stringify(e)):e}const X=()=>{var e;const t=(0,s.zy)(),a=(0,s.Zp)(),[y]=(0,n.ok)(),f=y.get("agentId"),{data:b,isLoading:v,isError:j,refetch:w}=function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return(0,d.I)({queryKey:c.l.agentsWithTools,queryFn:u,enabled:e,staleTime:12e4,gcTime:9e5})}(),N=null!==(e=null===b||void 0===b?void 0:b.agents)&&void 0!==e?e:[],[_,C]=(0,r.useState)({}),[S,A]=(0,r.useState)(null),[T,I]=(0,r.useState)(null),[L,E]=(0,r.useState)(null),[O,M]=(0,r.useState)(!1),[F,B]=(0,r.useState)(null),[U,P]=(0,r.useState)(!1),[J,K]=(0,r.useState)(!1),[Z,X]=(0,r.useState)("{}"),[ee,te]=(0,r.useState)(""),[ae,re]=(0,r.useState)(null),[se,ne]=(0,r.useState)(""),[oe,le]=(0,r.useState)(""),[ie,de]=(0,r.useState)(!1),[ce,ue]=(0,r.useState)(null),[ge,xe]=(0,r.useState)(!0),[me,he]=(0,r.useState)(!0),[pe,ye]=(0,r.useState)(""),[fe,be]=(0,r.useState)([]),[ve,ke]=(0,r.useState)(""),[je,we]=(0,r.useState)(""),[Ne,_e]=(0,r.useState)(""),[Ce,Se]=(0,r.useState)(""),[Ae,Te]=(0,r.useState)("function"),[Ie,Le]=(0,r.useState)("{}"),[Ee,$e]=(0,r.useState)(!0),[Oe,De]=(0,r.useState)(""),[Me,Fe]=(0,r.useState)(()=>{try{const e=localStorage.getItem("tool_favorites");return e?JSON.parse(e):[]}catch{return[]}}),[Be,Re]=(0,r.useState)("All"),[Ue,ze]=(0,r.useState)(!1),[Pe,Je]=(0,r.useState)([]),[We,qe]=(0,r.useState)(!1);(0,r.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"k"===e.key.toLowerCase()&&(e.preventDefault(),ze(e=>!e))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[]),(0,r.useEffect)(()=>{"1"===new URLSearchParams(t.search).get("create")&&P(!0)},[t.search]);const{toast:Ke}=(0,o.d)();(0,r.useEffect)(()=>{if(!b)return;C(b.instancesByAgent),B(null);const e=b.agents,t=b.instancesByAgent,a=new URLSearchParams(window.location.search).get("agentId"),r=e.find(e=>(t[String(e.id)]||[]).length>0),s=a&&e.some(e=>String(e.id)===a)?a:r?String(r.id):null;A(e=>null!==e&&void 0!==e?e:s)},[b]),(0,r.useEffect)(()=>{j&&(B("Failed to load assistants or tools."),Ke("Failed to load assistants or tools","error"))},[j,Ke]),(0,r.useEffect)(()=>{f&&0!==N.length&&N.some(e=>String(e.id)===f)&&A(f)},[f,N]),(0,r.useEffect)(()=>{if(!S)return;if((_[S]||[]).length>0)return;const e=N.find(e=>(_[String(e.id)]||[]).length>0);A(e?String(e.id):null)},[S,_,N]),(0,r.useEffect)(()=>{if(!S)return;const e=new URLSearchParams(y);e.get("agentId")!==S&&(e.set("agentId",S),a({pathname:t.pathname,search:e.toString()},{replace:!0}))},[S,a,t.pathname,y]),(0,r.useEffect)(()=>{U&&S&&ye(S)},[U,S]),(0,r.useEffect)(()=>{if(!U||!pe)return;let e=!1;return async function(e){try{const t=await i.p.getToolsRegistryForAgent(e),a=(0,i.hr)(t);if(a.length>0)return a}catch{}const t=await l.Ay.getTools(),a=(Array.isArray(t)?t:[]).map(e=>{var t;return String((null===e||void 0===e||null===(t=e.function)||void 0===t?void 0:t.name)||(null===e||void 0===e?void 0:e.id)||"")}).filter(Boolean);return Array.from(new Set(a)).sort((e,t)=>e.localeCompare(t))}(pe).then(t=>{e||be(t)}).catch(()=>{e||be([])}),()=>{e=!0}},[U,pe]),(0,r.useEffect)(()=>{if(!U)return;const e=ve.trim();if(!e)return void Le("{}");const t=function(e){const t=e.trim();if(!t)return null;const a=Q[t];if(a)return{...Y(a)};const r=G[t];return r&&Q[r]?{...Y(Q[r])}:null}(e);Le(t?JSON.stringify(t,null,2):"{}")},[U,ve]);const Ze=(0,r.useCallback)(async e=>{try{const t=await i.p.listAgentTools(e);C(a=>({...a,[e]:t})),c.q.invalidateQueries({queryKey:c.l.agentsWithTools})}catch(t){console.error(t)}},[]),Ve=(0,r.useMemo)(()=>N.filter(e=>(_[String(e.id)]||[]).length>0).map(e=>({id:String(e.id),name:e.name||"Assistant"})),[N,_]),He=(0,r.useMemo)(()=>{var e;if(!S)return"";const t=N.find(e=>String(e.id)===S);return(null===t||void 0===t||null===(e=t.name)||void 0===e?void 0:e.trim())||"Assistant"},[N,S]),Qe=(0,r.useMemo)(()=>S?He||"Assistant":"Tools",[S,He]),Ge=(0,r.useMemo)(()=>
2{if(!S)return[];let e=(_[S]||[]).map(e=>H(e,S));const t=Oe.trim().toLowerCase();return t&&(e=e.filter(e=>{var a,r;return(e.name||"").toLowerCase().includes(t)||(e.description||"").toLowerCase().includes(t)||((null===(a=e.function)||void 0===a?void 0:a.name)||"").toLowerCase().includes(t)||(null===(r=V(e.id))||void 0===r?void 0:r.instanceName.toLowerCase().includes(t))})),"All"!==Be&&(e=e.filter(e=>(e.status||"disconnected")===Be)),e},[S,_,Oe,Be]),Ye=(0,r.useMemo)(()=>{const e=[];for(const t of N){const a=String(t.id);for(const t of _[a]||[])e.push(H(t,a))}return e},[N,_]),Xe=(0,r.useMemo)(()=>{var e;const t=(null===ce||void 0===ce?void 0:ce.toolKey)||(null===ae||void 0===ae||null===(e=ae.function)||void 0===e?void 0:e.name)||"";return t?`${h.A.docsBaseUrl}/tools/${encodeURIComponent(t)}`:null},[ce,ae]),et=e=>{switch(e){case"sms":case"send_text":case"dtmf":case"end_call":case"endCall":return{messages:[],conditions:[]};case"slack":return{botToken:"",workspace:"",defaultChannel:"",webhookUrl:"",scopes:["chat:write","channels:read","users:read"]};case"calendar":case"google_calendar":return{credentials:{},calendarId:"primary",timezone:"UTC",sendNotifications:!1,enableReminders:!1,defaultVisibility:"public"};case"sheets":case"google_sheets":return{credentials:{},spreadsheetId:"",sheetRange:"Sheet1!A1:Z1000",accessMode:"readwrite"};case"transfer":case"transfer_call":return{properties:{},messages:[],conditions:[]};default:return{}}},tt=/^[A-Za-z][A-Za-z0-9_-]{0,118}[A-Za-z0-9]?$/,at=async e=>{re(e),te(""),de(!0);const t=V(e.id);E(t);try{if(t){var a,r;const s=await i.p.getAgentTool(t.agentId,t.instanceName);ne((null===(a=s.display_name)||void 0===a?void 0:a.trim())||s.instance_name||""),le(s.description&&String(s.description)||"");const n=s.config&&"object"===typeof s.config?s.config:{};X(JSON.stringify(Object.keys(n).length?n:et(e.type),null,2)),I(e.id),S!==t.agentId&&A(t.agentId),ue({instanceName:s.instance_name,toolKey:String(null!==(r=s.tool_key)&&void 0!==r?r:""),toolType:null!=s.tool_type?String(s.tool_type):void 0}),xe(!1!==s.enabled),he(!1!==s.is_active)}else{E(null),ue(null),de(!1);const t=await l.Ay.getTool(e.id);if(t){var s;ne(t.name||(null===(s=t.function)||void 0===s?void 0:s.name)||""),le(t.description||"");const e=t.configuration||et(t.type);X(JSON.stringify(e,null,2))}else{var n;ne(e.name||(null===(n=e.function)||void 0===n?void 0:n.name)||""),le(e.description||"");const t=e.configuration||et(e.type);X(JSON.stringify(t,null,2))}}K(!0)}catch(F){var o;console.error("Failed to get tool configuration:",F),Ke("Failed to load configuration","error"),ne(e.name||(null===(o=e.function)||void 0===o?void 0:o.name)||""),le(e.description||"");const a=e.configuration||et(e.type);X(JSON.stringify(a,null,2)),ue(null),K(!0)}},rt=()=>{X("{}"),ne(""),le(""),ye(""),be([]),ke(""),we(""),_e(""),Se(""),Te("function"),Le("{}"),$e(!0)},st=e=>(0,l.ps)(e),nt=e=>{switch(e){case"function":return"Execute custom API function";case"dtmf":return"Process touch-tone input";case"query":return"Database or knowledge query";case"end_call":return"End active call";case"transfer_call":return"Transfer to another number";case"send_text":return"Send SMS message";case"google_calendar":return"Create calendar events";case"google_sheets":return"Query or update spreadsheets";case"slack":return"Send Slack messages";default:return"Custom tool"}},ot=e=>"bg-white border border-gray-200 dark:bg-dark-700 dark:border-dark-600",lt=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"1rem",a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"currentColor";const r="white"===a?"#ff0000":a;switch(e){case"function":return(0,p.jsxs)("svg",{width:t,height:t,fill:r,viewBox:"0 0 24 24",children:[(0,p.jsx)("path",{d:"M13 17.5a1 1 0 11-2 0 1 1 0 012 0zm-.25-8.25a.75.75 0 00-1.5 0v4.5a.75.75 0 001.5 0v-4.5z"}),(0,p.jsx)("path",{fillRule:"evenodd",d:"M9.836 3.244c.963-1.665 3.365-1.665 4.328 0l8.967 15.504c.963 1.667-.24 3.752-2.165 3.752H3.034c-1.926 0-3.128-2.085-2.165-3.752L9.836 3.244zm3.03.751a1 1 0 00-1.732 0L2.168 19.499A1 1 0 003.034 21h17.932a1 1 0 00.866-1.5L12.866 3.994z"})]});case"dtmf":return(0,p.jsx)("svg",{width:t,height:t,fill:"none",stroke:r,viewBox:"0 0 24 24",children:(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 4v16m8-8H4"})});case"query":return(0,p.jsx)("svg",{width:t,height:t,fill:"none",stroke:r,viewBox:"0 0 24 24",children:(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 16l2.879-2.879m0 0a3 3 0 104.243-4.242 3 3 0 00-4.243 4.242zM21 12a9 9 0 11-18 0 9 9 0 0118 0z"})});case"end_call":return(0,p.jsx)("svg",{width:t,height:t,fill:"none",stroke:r,viewBox:"0 0 24 24",children:(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M16 8l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2M5 3a2 2 0 00-2 2v1c0 8.284 6.716 15 15 15h1a2 2 0 002-2v-3.28a1 1 0 00-.684-.948l-4.493-1.498a1 1 0 00-1.21.502l-1.13 2.257a11.042 11.042 0 01-5.516-5.517l2.257-1.128a1 1 0 00.502-1.21L9.228 3.683A1 1 0 008.279 3H5z"})});case"transfer_call":return(0,p.jsx)("svg",{width:t,height:t,fill:"none",stroke:r,viewBox:"0 0 24 24",children:(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"})});case"send_text":return(0,p.jsx)("svg",{width:t,height:t,fill:"none",stroke:r,viewBox:"0 0 24 24",children:(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})});case"google_calendar":return(0,p.jsx)("svg",{width:t,height:t,fill:"none",stroke:r,viewBox:"0 0 24 24",children:(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})});case"google_sheets":return(0,p.jsx)("svg",{width:t,height:t,fill:"none",stroke:r,viewBox:"0 0 24 24",children:(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M3 10h18M3 14h18m-9-4v8m-7 0h14a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"})});case"slack":return(0,p.jsx)("svg",{width:t,height:t,fill:"none",stroke:r,viewBox:"0 0 24 24",children:(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 10V3L4 14h7v7l9-11h-7z"})});default:return(0,p.jsxs)("svg",{width:t,height:t,fill:"none",stroke:r,viewBox:"0 0 24 24",children:[(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),(0,p.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}},it=e=>{A(e),I(null)},dt=async e=>{const t=V(e);try{if(M(!0),t)await i.p.deleteAgentTool(t.agentId,t.instanceName),Ke("Tool instance deleted","success"),T===e&&I(null),await Ze(t.agentId);else{if(!await l.Ay.deleteTool(e))throw new Error("Delete failed");Ke("Tool removed","success")}}catch(F){console.error("Failed to delete tool:",F),Ke("Failed to delete tool. Please try again.","error")}finally{M(!1)}};if(v)return(0,p.jsx)(g.A,{});const ct=x.PC.menu,ut=x.RV.search,gt=x.RV.delete;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:m.FR,children:[(0,p.jsx)(q.A,{isOpen:We,onClose:()=>qe(!1),title:"Tools",children:(0,p.jsx)(k,{embedded:!0,agents:Ve,instancesByAgent:_,selectedAgentId:S,onSelectAgent:e=>{it(e)},onCreate:()=>{P(!0),qe(!1)},onSearch:De,searchValue:Oe})}),(0,p.jsx)("div",{className:"hidden lg:block",children:(0,p.jsx)(k,{agents:Ve,instancesByAgent:_,selectedAgentId:S,onSelectAgent:it,onCreate:()=>{P(!0)},onSearch:De,searchValue:Oe})}),(0,p.jsx)("div",{className:"lg:hidden fixed top-0 left-0 right-0 z-20 px-4 py-3 border-b border-gray-200/80 dark:border-gray-700/80 bg-white/98 dark:bg-gray-950/98 backdrop-blur-xl shadow-sm dark:shadow-gray-900/50",children:(0,p.jsxs)("div",{className:"flex items-center justify-between",children:[(0,p.jsx)("div",{className:"w-10 h-10"}),(0,p.jsxs)("button",{onClick:()=>qe(!0),className:"inline-flex items-center gap-2 rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-gray-900 shadow-sm transition duration-150 hover:border-accent/40 dark:border-edge dark:bg-surface dark:text-gray-100","aria-label":"Open tools menu",children:[(0,p.jsx)("span",{className:"max-w-[10rem] truncate sm:max-w-xs",children:Qe}),(0,p.jsx)(ct,{className:"h-4 w-4 text-gray-600 dark:text-gray-300"})]})]})}),(0,p.jsxs)("div",{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain ${m.os}`,children:[(0,p.jsx)("div",{className:"lg:hidden h-[60px]"}),(0,p.jsxs)("div",{className:"mx-auto max-w-7xl px-4 pb-4 sm:px-6 sm:pb-6",children:[(0,p.jsxs)("div",{className:"sticky top-[60
2px] z-20 -mx-4 mb-4 space-y-2.5 border-b border-gray-200/80 bg-gray-50/95 px-4 py-3 backdrop-blur-xl supports-[backdrop-filter]:bg-gray-50/90 dark:border-edge dark:bg-surface-page/95 sm:-mx-6 sm:px-6 lg:top-0",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,p.jsxs)("div",{className:"min-w-0",children:[(0,p.jsx)("h1",{className:"truncate text-lg font-semibold text-gray-900 dark:text-gray-100 sm:text-xl",title:Qe,children:Qe}),(0,p.jsx)("p",{className:"mt-0.5 line-clamp-1 text-xs text-gray-500 dark:text-gray-400",children:"Connect and manage tools your assistants can use."})]}),(0,p.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-1.5",children:[(0,p.jsxs)("select",{value:Be,onChange:e=>Re(e.target.value),className:z.K_,"aria-label":"Filter by status",children:[(0,p.jsx)("option",{value:"All",children:"All statuses"}),(0,p.jsx)("option",{value:"connected",children:"Connected"}),(0,p.jsx)("option",{value:"disconnected",children:"Disconnected"})]}),(0,p.jsxs)("button",{onClick:()=>ze(!0),className:"inline-flex items-center gap-1.5 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-xs text-gray-700 shadow-sm hover:border-accent/40 dark:border-dark-600 dark:bg-dark-800 dark:text-gray-200",title:"Open command palette (Ctrl/Cmd+K)","aria-label":"Search tools",children:[(0,p.jsx)(ut,{className:"h-3.5 w-3.5","aria-hidden":!0}),(0,p.jsx)("span",{className:"hidden sm:inline",children:"Search"}),(0,p.jsx)("span",{className:"hidden rounded border border-gray-200 px-1 text-[10px] text-gray-400 dark:border-dark-600 sm:inline",children:"\u2318K"})]}),Pe.length>0&&(0,p.jsxs)("button",{type:"button",onClick:()=>{window.confirm(`Delete ${Pe.length} tool(s)?`)&&(Pe.forEach(e=>dt(e)),Je([]))},className:"inline-flex items-center gap-1 rounded-lg border border-red-300 bg-white px-2.5 py-1.5 text-xs text-red-600 hover:bg-red-50 dark:border-red-500/40 dark:bg-dark-800 dark:text-red-400 dark:hover:bg-red-900/20","aria-label":`Delete ${Pe.length} selected tools`,title:`Delete ${Pe.length} selected`,children:[(0,p.jsx)(gt,{className:"h-3.5 w-3.5","aria-hidden":!0}),(0,p.jsx)("span",{className:"tabular-nums",children:Pe.length})]})]})]}),S&&Ge.length>0&&(0,p.jsxs)("div",{className:"relative",children:[(0,p.jsx)(ut,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-gray-400","aria-hidden":!0}),(0,p.jsx)("input",{type:"search",value:Oe,onChange:e=>De(e.target.value),placeholder:"Filter tool instances\u2026",className:"w-full rounded-lg border border-gray-200 bg-white py-1.5 pl-8 pr-3 text-xs text-gray-900 shadow-sm placeholder:text-gray-400 focus:border-accent/40 focus:outline-none focus:ring-2 focus:ring-accent/20 dark:border-dark-600 dark:bg-dark-800 dark:text-gray-100"})]})]}),F&&(0,p.jsx)("div",{className:"mb-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-500/40 dark:bg-amber-900/20 dark:text-amber-100",children:F}),S?0===Ge.length?(0,p.jsxs)("div",{className:"rounded-lg border border-gray-200 bg-white p-8 shadow-sm dark:border-edge dark:bg-dark-700",children:[(0,p.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:He}),(0,p.jsx)("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"No tool instances for this assistant yet. Add instances via the Assistants page or API, then configure them here."})]}):(0,p.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:Ge.map(e=>(0,p.jsx)($,{tool:e,onEdit:e=>{at(e)},onDelete:e=>{dt(e.id)},onToggle:e=>{(async e=>{const t=V(e);if(t)try{M(!0);const e=(_[t.agentId]||[]).find(e=>e.instance_name===t.instanceName),a=!(!1!==(null===e||void 0===e?void 0:e.enabled)&&!1!==(null===e||void 0===e?void 0:e.is_active));await i.p.patchAgentTool(t.agentId,t.instanceName,{enabled:a,is_active:a}),Ke(a?"Tool enabled":"Tool disabled","success"),await Ze(t.agentId)}catch(F){console.error("Failed to toggle tool status:",F),Ke("Failed to update tool status","error")}finally{M(!1)}else Ke("Cannot update this tool from here","error")})(e.id)},onToggleFavorite:e=>{Fe(t=>{const a=t.includes(e)?t.filter(t=>t!==e):[...t,e];return localStorage.setItem("tool_favorites",JSON.stringify(a)),a})}
2,selectable:!0,selected:Pe.includes(e.id),onSelectToggle:(e,t)=>Je(a=>t?[...a,e]:a.filter(t=>t!==e)),getToolIconBgColor:ot,getToolIcon:lt,getToolDescription:nt,getToolCategory:st,isFavorite:Me.includes(e.id)},e.id))}):(0,p.jsx)("div",{className:"rounded-lg border border-gray-200 bg-white p-8 shadow-sm dark:border-edge dark:bg-dark-700",children:(0,p.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Select an assistant in the sidebar to view tool instances."})})]})]})]}),(0,p.jsx)(R,{isOpen:J,onClose:()=>{K(!1),ue(null)},tool:ae,toolName:se,toolDescription:oe,configData:Z,onNameChange:ne,onDescriptionChange:le,onConfigChange:X,onSave:async()=>{if(ae)try{M(!0);const e=JSON.parse(Z);if(L)await i.p.patchAgentTool(L.agentId,L.instanceName,{display_name:se,description:oe,config:e,enabled:ge,is_active:me}),Ke("Tool updated successfully","success"),K(!1),ue(null),await Ze(L.agentId);else{const t=(e=>{switch(e){case"Utilities":return"Function";case"Communication":return"Communication";case"Integrations":return"Integration";case"Data":return"Data Source";case"API":return"API";default:return"Other"}})((0,l.ps)(ae));await l.Ay.updateTool(ae.id,{name:se,description:oe,category:t,configuration:e}),Ke("Tool updated successfully","success"),K(!1)}}catch(F){F instanceof SyntaxError?te("Invalid JSON format. Please check your configuration."):(te("Failed to update configuration. Please try again."),console.error("Failed to update tool configuration:",F),Ke("Failed to update tool","error"))}finally{M(!1)}},getToolIconBgColor:ot,getToolIcon:lt,showJsonEditor:ie,onToggleJsonEditor:()=>de(!ie),instanceEdit:ce,toolEnabled:ge,toolIsActive:me,onToolEnabledChange:xe,onToolIsActiveChange:he,docsUrl:Xe}),(0,p.jsx)(W,{isOpen:U,onClose:()=>{if(P(!1),rt(),t.search.includes("create=1")){const e=new URLSearchParams(t.search);e.delete("create");const r=e.toString();a({pathname:t.pathname,search:r?`?${r}`:""},{replace:!0})}},busy:O,agents:N,agentId:pe,onAgentIdChange:e=>{ye(e),ke("")},registryKeys:fe,toolKey:ve,onToolKeyChange:ke,instanceName:je,onInstanceNameChange:we,displayName:Ne,onDisplayNameChange:_e,description:Ce,onDescriptionChange:Se,toolType:Ae,onToolTypeChange:Te,configJson:Ie,onConfigJsonChange:Le,enabled:Ee,onEnabledChange:$e,onSubmit:async e=>{e.preventDefault();const t=pe.trim(),a=ve.trim(),r=je.trim();if(!t)return void Ke("Select an assistant.","error");if(!a)return void Ke("Select a tool type (catalog tool key).","error");if(!r)return void Ke("Instance name is required.","error");if(!tt.test(r))return void Ke("Instance name must start with a letter and use only letters, digits, _ or -.","error");let s;try{const e=JSON.parse(Ie);if("object"!==typeof e||null===e||Array.isArray(e))throw new SyntaxError("not object");s=e}catch{return void Ke("Configuration must be valid JSON object.","error")}try{M(!0);const e=await i.p.createAgentTool(t,{tool_key:a,instance_name:r,display_name:Ne.trim()||r,description:Ce.trim()||void 0,tool_type:Ae.trim()||"function",config:s,enabled:Ee,is_active:Ee});Ke("Tool instance created","success"),P(!1),ke(""),we(""),_e(""),Se(""),Te("function"),Le("{}"),$e(!0),await Ze(t),A(t);const n=H(e,t);I(n.id),await at(n)}catch(n){console.error(n),Ke("Could not create tool instance. Check fields and API errors.","error")}finally{M(!1)}}}),(0,p.jsx)(D,{isOpen:Ue,onClose:()=>ze(!1),tools:Ye,onOpenTool:e=>at(e)})]})}},3084:(e,t,a)=>{a.d(t,{d:()=>n});var r=a(9950),s=a(7871);const n=()=>{const e=(0,r.useContext)(s.$o);return e?{toast:e.toast}:{toast:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info";console.warn(`[toast:${t}] ${e} (no ToastProvider mounted)`)}}}}
2,3621:(e,t,a)=>{a.d(t,{HS:()=>x,KK:()=>l,MB:()=>p,MS:()=>f,O0:()=>v,OO:()=>h,Q2:()=>s,Z6:()=>n,aQ:()=>m,f4:()=>d,fF:()=>g,i9:()=>u,k6:()=>y,s1:()=>o,th:()=>c,vM:()=>b,wU:()=>k,yV:()=>i});var r=a(691);const s="text-[11px] font-medium text-gray-600 dark:text-gray-400",n="text-[10px] leading-snug text-gray-500 dark:text-gray-500",o=r.oT,l=r.gl,i="w-full min-w-0 rounded-lg border border-gray-200 bg-white px-2 py-1.5 text-xs text-gray-900 shadow-sm transition-colors placeholder:text-gray-400 focus:border-accent/40 focus:outline-none focus:ring-1 focus:ring-accent/20 dark:border-edge dark:bg-surface dark:text-gray-100 resize-y",d="rounded-lg border border-gray-200/80 bg-gray-50/50 p-3 dark:border-edge dark:bg-surface/60",c="text-[10px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",u="fixed inset-0 z-40 bg-black/40 backdrop-blur-[1px]",g="flex shrink-0 items-center justify-between gap-2 border-b border-gray-200/80 px-3 py-2.5 dark:border-edge",x="flex shrink-0 items-center justify-end gap-2 border-t border-gray-200/80 bg-gray-50/95 px-3 py-2.5 backdrop-blur-xl dark:border-edge dark:bg-surface-raised/95",m="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-gray-200 bg-white text-gray-500 transition-colors hover:bg-gray-50 hover:text-gray-800 dark:border-edge dark:bg-surface dark:hover:bg-white/5 dark:hover:text-gray-200",h="flex items-center justify-between gap-3 rounded-lg border border-gray-200/70 bg-white/80 px-3 py-2 dark:border-edge dark:bg-surface/80",p="flex w-full items-center justify-between gap-2 rounded-lg border px-2.5 py-2 text-left text-xs transition-colors",y="border-accent/50 bg-red-50/80 text-gray-900 dark:border-accent-text/40 dark:bg-red-950/20 dark:text-gray-100",f="border-gray-200/80 bg-white/80 text-gray-900 hover:bg-gray-50 dark:border-edge dark:bg-surface/80 dark:text-gray-100 dark:hover:bg-white/5",b="rounded-lg border border-accent/25 bg-accent/5 px-3 py-2 text-xs text-gray-900 dark:border-accent/35 dark:bg-accent/10 dark:text-gray-100",v="rounded-lg border border-gray-200/80 bg-white px-3 py-2 text-xs text-gray-900 dark:border-edge dark:bg-surface/80 dark:text-gray-100";function k(){const e="fixed inset-y-0 right-0 z-50 flex w-full flex-col border-l border-gray-200/80 bg-white shadow-2xl dark:border-edge dark:bg-surface-raised";return{sm:`${e} max-w-md sm:max-w-sm`,md:`${e} max-w-lg sm:max-w-md`,lg:`${e} max-w-xl sm:max-w-lg`,xl:`${e} max-w-2xl sm:max-w-xl`,"2xl":`${e} max-w-3xl sm:max-w-2xl`}[arguments.length>0&&void 0!==arguments[0]?arguments[0]:"md"]}k("sm")},5205:(e,t,a)=>{a.d(t,{$O:()=>d,If:()=>l,K_:()=>r,QH:()=>n,VL:()=>i,iW:()=>o});const r=`${a(691).gl} disabled:cursor-not-allowed disabled:opacity-60`,s="inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs transition duration-150 active:scale-[0.98] disabled:cursor-not-allowed disabled:opacity-50 disabled:active:scale-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 focus-visible:ring-offset-2 focus-visible:ring-offset-white dark:focus-visible:ring-offset-dark-700",n=`${s} bg-primary font-semibold text-primary-contrast shadow-sm hover:bg-primary-hover`,o=`${s} bg-accent font-semibold text-white shadow-sm hover:bg-accent-hover`,l=`${s} border border-gray-200 bg-white font-medium text-gray-700 shadow-sm hover:border-accent/40 hover:text-gray-900 dark:border-edge dark:bg-surface dark:text-gray-200 dark:hover:border-accent-text/50`,i=`${s} font-medium text-gray-600 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-white/5 dark:hover:text-gray-100`,d=`${s} border border-red-500/50 bg-transparent font-medium text-red-600 hover:bg-red-600 hover:text-white dark:border-red-400/40 dark:text-red-400 dark:hover:bg-red-600 dark:hover:text-white`},5885:(e,t,a)=>{a.d(t,{Ay:()=>u,ps:()=>i,rE:()=>l});var r=a(1029),s=a(6850);const n="/tools";function o(e){var t,a,r,s,n;if(!e)return[];if(Array.isArray(e))return e.filter(Boolean).flatMap(e=>{const t=function(e){var t,a,r,s,n,o,l,i,d,c,u;if(!e||"object"!==typeof e)return null;const g=e,x=String(null!==(t=null!==(a=null!==(r=null!==(s=null!==(n=g.tool_key)&&void 0!==n?n:g.slug)&&void 0!==s?s:g.function_name)&&void 0!==r?r:g.i
2d)&&void 0!==a?a:g.name)&&void 0!==t?t:"").trim();if(!x)return null;const m=Boolean(null!==(o=null!==(l=g.connected)&&void 0!==l?l:g.is_connected)&&void 0!==o?o:g.configured),h=null==g.ui_manifest||"object"!==typeof g.ui_manifest||Array.isArray(g.ui_manifest)?null:g.ui_manifest,p="string"===typeof(null===h||void 0===h?void 0:h.description)?h.description.trim():"",y=("string"===typeof g.description?String(g.description).trim():"")||p||"",f=g.scopes,b=h&&"string"===typeof h.docs_url?h.docs_url:h&&"string"===typeof h.documentation_url?h.documentation_url:null;return{tool_key:x,connected:m,enabled_for_agent:Boolean(null===(i=null!==(d=g.enabled_for_agent)&&void 0!==d?d:g.enabled)||void 0===i||i),display_name:String(null!==(c=null!==(u=g.display_name)&&void 0!==u?u:g.title)&&void 0!==c?c:x),ui_manifest:h,scopes:Array.isArray(f)?f:[],connect_url:null!=g.connect_url?String(g.connect_url):null,registry_description:y||void 0,config_schema:g.config_schema,docs_url:b||(null!=g.docs_url?String(g.docs_url):null)}}(e);return t?[t]:[]});if("object"!==typeof e)return[];const l=e,i=null!==(t=null!==(a=null!==(r=null!==(s=null!==(n=l.tools)&&void 0!==n?n:l.registry)&&void 0!==s?s:l.items)&&void 0!==r?r:l.results)&&void 0!==a?a:l.available_tools)&&void 0!==t?t:l.data;return Array.isArray(i)?o(i):[]}function l(e){const t=(e||"").toLowerCase();return t.includes("transfer")||t.includes("warm-transfer")||/^transfer-/.test(t)?"transfer_call":t.endsWith("_call")&&t.includes("end")||t.includes("end-call")||t.includes("end_call")||t.includes("system.end")||/\.end\b/.test(t)?"end_call":t.includes("send-dtmf")||t.includes("dtmf")?"dtmf":t.includes("query_tool")||/^query$/.test(t)&&!t.includes("transfer")?"query":t.includes("google_sheets")||"google_sheets_tool"===t?"google_sheets":t.includes("send_text")?"send_text":t.includes("calendar")?"google_calendar":t.includes("slack")?"slack":"function"}function i(e){var t;const a=String((null===(t=e.function)||void 0===t?void 0:t.name)||e.id||"").toLowerCase();return/\.end|system\.end|(^|[-_.])end($|[-._])|\btransfer\b|\bwarm-|cold-|send-dtmf|\bdtmf\b|sip|ivr|telephony|hangup/.test(a)||/(^|[-_.])end-call|end_call|transfer-call|warm-transfer/.test(a)?"Communication":/^http\.|\.fetch|google_|sheets|slack|calendar|webhook|mcp|integration|crm|\bfetch\b/.test(a)?"Integrations":"Utilities"}const d=e=>{const t=(new Date).toISOString(),a=l(e.tool_key),r=(e.registry_description||e.display_name||e.tool_key).trim();return{id:String(e.tool_key),createdAt:t,updatedAt:t,type:a,function:{name:e.tool_key},orgId:"",name:e.display_name||e.tool_key,description:r,status:e.connected?"connected":"disconnected"}},c={getTools:async()=>o((await r.Ay.get(`${n}/registry`)).data).map(d),getTool:async e=>{const t=(new Date).toISOString(),a=(await r.Ay.get(`${n}/${encodeURIComponent(e)}/config`)).data||{};return{id:String(a.tool_key||e),createdAt:a.last_updated||t,updatedAt:a.last_updated||t,type:"function",function:{name:a.tool_key||e},orgId:"",name:a.tool_key||e,description:"",status:a.configured?"connected":"disconnected",configuration:a.configuration||{}}},createTool:async e=>{var t;const a=(null===e||void 0===e||null===(t=e.function)||void 0===t?void 0:t.name)||(null===e||void 0===e?void 0:e.tool_key)||`custom_${Date.now()}`,s=(await r.Ay.post(`${n}/custom`,{tool_key:a,display_name:(null===e||void 0===e?void 0:e.name)||a,type:(null===e||void 0===e?void 0:e.type)||"function",description:(null===e||void 0===e?void 0:e.description)||"",function_schema:(null===e||void 0===e?void 0:e.function_schema)||{},config_schema:(null===e||void 0===e?void 0:e.config_schema)||{},scopes:(null===e||void 0===e?void 0:e.scopes)||[],ui_manifest:(null===e||void 0===e?void 0:e.ui_manifest)||{}})).data||{},o=(new Date).toISOString();return{id:String(s.tool_key||a),createdAt:o,updatedAt:o,type:(null===e||void 0===e?void 0:e.type)||"function",function:{name:s.tool_key||a},orgId:(null===e||void 0===e?void 0:e.orgId)||"",name:s.tool_key||a,description:(null===e||void 0===e?void 0:e.description)||"",status:"disconnected"}},updateTool:async(e,t)=>{const a=(null===t||void 0===t?void 0:t.configuration)||t||{};return await r.Ay.post(`${n}/${encodeURIComponent(e)}/configure`,a),await c.getTool(e)},deleteTool:async e=>!0,toggleStatus:async e=>!0,execute:async e=>(await r.Ay.post(`${n}/execute`,e)).data,getExecutionStatus:async e=>(await r.Ay.get(`${n}/executions/${encodeURIComponent(e)}`)).data,retryExecution:async e=>(await r.Ay.post(`${n}/executions/${encodeURIComponent(e)}/retry`)).data,confirmExecution:async(e,t)=>(await r.Ay.post(`${n}/executions/${encodeURIComponent(e)}/confirm`,{approved:t})).data,addToolToAgent:async(e,t)=>{try{return await s.A.create(e,t)}catch{return(await r.Ay.post(`${n}/agents/${encodeURIComponent(e)}/add-tool`,t)).data}},getSchema:async e=>(await r.Ay.get(`${n}/${encodeURIComponent(e)}/schema`)).data,getRequirements:async e=>(await r.Ay.get(`${n}/${encodeURIComponent(e)}/requirements`)).data},u=c},7334:(e,t,a)=>{a.d(t,{A:()=>d});var r=a(9950),s=a(6479),n=a(3621),o=a(691),l=a(4414);const i=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter(Boolean).join(" ")};const d=e=>{let{isOpen:t,onClose:a,title:d,subtitle:c,icon:u,children:g,footer
2:x,headerActions:m,busy:h=!1,titleId:p="app-drawer-title",asForm:y=!1,onSubmit:f,panelClassName:b,headerIconClassName:v=o.ib,width:k="md"}=e;const j=(0,r.useRef)(null);if(function(e,t){let a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];(0,r.useEffect)(()=>{if(!e)return;const r=e=>{"Escape"!==e.key||a||t()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t,a])}(t,a,h),(0,r.useEffect)(()=>{var e;if(!t)return;const a=document.body.style.overflow;document.body.style.overflow="hidden";const r=j.current,s=r?Array.from(r.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')):[],n=document.activeElement;null===(e=s[0])||void 0===e||e.focus();const o=e=>{if("Tab"!==e.key||0===s.length)return;const t=s[0],a=s[s.length-1];e.shiftKey&&document.activeElement===t?(e.preventDefault(),a.focus()):e.shiftKey||document.activeElement!==a||(e.preventDefault(),t.focus())};return document.addEventListener("keydown",o),()=>{var e;document.body.style.overflow=a,document.removeEventListener("keydown",o),null===n||void 0===n||null===(e=n.focus)||void 0===e||e.call(n)}},[t]),!t)return null;const w=(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:g}),x?(0,l.jsx)("div",{className:n.HS,children:x}):null]});return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("button",{type:"button",className:n.i9,"aria-label":"Close drawer",onClick:()=>{h||a()}}),(0,l.jsxs)("aside",{ref:j,className:i((0,n.wU)(k),b),role:"dialog","aria-modal":"true","aria-labelledby":p,children:[(0,l.jsxs)("div",{className:n.fF,children:[(0,l.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,l.jsx)("div",{className:i("shrink-0 rounded-lg p-1.5 shadow-sm",v),children:u}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("h2",{id:p,className:"truncate text-sm font-semibold text-gray-900 dark:text-white",children:d}),c?(0,l.jsx)("p",{className:"truncate text-[11px] text-gray-500 dark:text-gray-400",children:c}):null]})]}),(0,l.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[m,(0,l.jsx)("button",{type:"button",onClick:a,disabled:h,className:n.aQ,"aria-label":"Close",children:(0,l.jsx)(s.A,{className:"h-4 w-4","aria-hidden":!0})})]})]}),y?(0,l.jsx)("form",{onSubmit:f,className:"flex min-h-0 flex-1 flex-col",children:w}):(0,l.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:w})]})]})}},7624:(e,t,a)=>{a.d(t,{A:()=>c});var r=a(9950),s=a(2463),n=a(7133),o=a(6311),l=a(7453),i=a(4414);const d=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter(Boolean).join(" ")},c=e=>{let{value:t,onChange:a,options:c,placeholder:u="Select\u2026",disabled:g=!1,className:x,compact:m=!0,renderOption:h}=e;const p=c.find(e=>e.value===t);return(0,i.jsx)(s.W,{value:t,onChange:a,disabled:g,children:e=>{let{open:t}=e;return(0,i.jsxs)("div",{className:d("relative",x),children:[(0,i.jsxs)(s.W.Button,{className:d("flex w-full min-w-0 items-center justify-between border text-left transition-colors",m?"h-7 gap-1 rounded-md px-2 py-0 text-xs leading-tight":"gap-2 rounded-lg px-3 py-2 text-sm shadow-sm","bg-white text-gray-900 hover:border-gray-300 dark:bg-surface dark:text-gray-100 dark:hover:border-neutral-600",t?"border-gray-400 ring-1 ring-gray-300/40 dark:border-neutral-500 dark:ring-neutral-600/40":"border-gray-200 dark:border-neutral-700","focus:outline-none",g&&"cursor-not-allowed opacity-60"),children:[(0,i.jsxs)("span",{className:d("flex min-w-0 flex-1 items-center truncate",m?"gap-1":"gap-2",!p&&"text-gray-400 dark:text-gray-500"),children:[null!==p&&void 0!==p&&p.icon?(0,i.jsx)("span",{className:"flex shrink-0 items-center [&_svg]:h-3.5 [&_svg]:w-3.5",children:p.icon}):null,(0,i.jsx)("span",{className:"truncate",children:p?p.label:u})]}),(0,i.jsx)(l.A,{className:d("shrink-0 text-gray-400 transition-transform",m?"h-3.5 w-3.5":"h-4 w-4",t&&"rotate-180"),"aria-hidden":!0})]}),(0,i.jsx)(n.e,{as:r.Fragment,enter:"transition ease-out duration-100",enterFrom:"opacity-0 -translate-y-1",enterTo:"opacity-100 translate-y-0",leave:"transition ease-in duration-75",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 -translate-y-1",children:(0,i.jsx)(s.W.Options,{className:d("absolute z-50 w-full min-w-[10rem] overflow-auto border shadow-xl focus:outline-none",m?"mt-1 max-h-56 rounded-lg p-0.5":"mt-1.5 max-h-64 roun
2ded-xl p-1","border-gray-200 bg-white","dark:border-neutral-700 dark:bg-[#141414]"),children:0===c.length?(0,i.jsx)("div",{className:d("text-gray-400 dark:text-gray-500",m?"px-2 py-1 text-xs":"px-3 py-2 text-sm"),children:"No options"}):c.map(e=>(0,i.jsx)(s.W.Option,{value:e.value,disabled:e.disabled,className:e=>{let{active:t,disabled:a}=e;return d("relative cursor-pointer select-none",m?"rounded-md px-2 py-1 text-xs":"rounded-lg px-2.5 py-2 text-sm",t?"bg-accent/[0.08] text-accent dark:bg-accent/15 dark:text-accent-text":"text-gray-800 dark:text-gray-200",a&&"cursor-not-allowed opacity-40")},children:t=>{let{active:a,selected:r}=t;return(0,i.jsx)(i.Fragment,{children:h?h(e,{active:a,selected:r}):(0,i.jsxs)("div",{className:d("flex items-center",m?"gap-1.5":"gap-2"),children:[e.icon?(0,i.jsx)("span",{className:d("flex shrink-0 items-center",m&&"[&_svg]:h-3.5 [&_svg]:w-3.5"),children:e.icon}):null,(0,i.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,i.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,i.jsx)("span",{className:d("truncate leading-tight",r&&"font-semibold"),children:e.label}),e.meta?(0,i.jsx)("span",{className:d("shrink-0 tabular-nums",m?"text-[10px]":"text-[11px]"),children:e.meta}):null]}),e.description?(0,i.jsx)("p",{className:d("truncate text-gray-400 dark:text-gray-500",m?"text-[10px] leading-tight":"text-[11px]"),children:e.description}):null]}),r?(0,i.jsx)(o.A,{className:d("shrink-0 text-accent dark:text-accent-text",m?"h-3.5 w-3.5":"h-4 w-4")}):null]})})}},e.value))})})]})}})}},9981:(e,t,a)=>{a.d(t,{A:()=>o});var r=a(9950),s=a(6479),n=a(4414);const o=e=>{let{isOpen:t,onClose:a,children:o,title:l}=e;return(0,r.useEffect)(()=>(document.body.style.overflow=t?"hidden":"",()=>{document.body.style.overflow=""}),[t]),(0,r.useEffect)(()=>{const e=e=>{"Escape"===e.key&&t&&a()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,a]),t?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-[100] transition-opacity duration-300 lg:hidden",onClick:a,"aria-hidden":"true"}),(0,n.jsxs)("div",{className:"fixed top-0 left-0 bottom-0 w-[80%] max-w-sm bg-white dark:bg-dark-800 shadow-2xl z-[101] transform transition-transform duration-300 ease-out lg:hidden "+(t?"translate-x-0":"-translate-x-full"),role:"dialog","aria-modal":"true","aria-label":l||"Sidebar menu",children:[(0,n.jsxs)("div",{className:"sticky top-0 z-10 bg-white dark:bg-dark-800 border-b border-gray-200 dark:border-dark-700 px-4 py-3 flex items-center justify-between",children:[l&&(0,n.jsx)("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:l}),(0,n.jsx)("button",{onClick:a,className:"ml-auto inline-flex items-center justify-center rounded-lg p-2 text-gray-400 hover:bg-gray-100 dark:hover:bg-dark-700 hover:text-gray-600 dark:hover:text-gray-200 transition-all duration-200","aria-label":"Close menu",children:(0,n.jsx)(s.A,{className:"h-5 w-5"})})]}),(0,n.jsx)("div",{className:"h-[calc(100%-60px)] overflow-y-auto",children:o})]})]}):null}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.