@mcp-use/inspector 20.0.0-beta.5 → 20.0.0-beta.7
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.
- package/dist/cdn/{AnimatePresence-Dcw-FOy8.js → AnimatePresence-D1bZ5_-l.js} +79 -78
- package/dist/cdn/{ChatTab-B255lH5i.js → ChatTab-DtUGK07C.js} +1628 -1561
- package/dist/cdn/CheckboxIndicator-BjF73mGX.js +252 -0
- package/dist/cdn/{ConnectionSettingsForm-DF-NS58d.js → ConnectionSettingsForm-CNuMa6jp.js} +202 -202
- package/dist/cdn/{ConnectionSettingsTab-dI-Cqe79.js → ConnectionSettingsTab-qSVQ1aIF.js} +36 -35
- package/dist/cdn/{ElicitationTab-CL1KJ0bz.js → ElicitationTab-PEmEDvC5.js} +47 -46
- package/dist/cdn/{FormContext-tmgN_Vdr.js → FormContext-NtUiZclE.js} +26 -26
- package/dist/cdn/{InspectorContext-UjtEbNod.js → InspectorContext-BBKCdfmK.js} +1 -1
- package/dist/cdn/{JSONDisplay-BFxf5oEu.js → JSONDisplay-BJqMz7Ny.js} +22 -22
- package/dist/cdn/{ListTabHeader-Cv-GmtGF.js → ListTabHeader-DzmTtN1e.js} +20 -19
- package/dist/cdn/{WidgetWrapper-B4H3Fek7.js → MCPAppsDebugControls-BpP-Ifap.js} +514 -550
- package/dist/cdn/{ManufactOAuthCallback-B98kSYCj.js → ManufactOAuthCallback-ChbbjFIT.js} +2 -2
- package/dist/cdn/{MarkdownRenderer-Ba7nA4Ie.js → MarkdownRenderer-bX1BrKgI.js} +23 -23
- package/dist/cdn/McpAppsViewPanel-jlsYQ7uS.js +56 -0
- package/dist/cdn/{NotificationsTab-CeImSrhx.js → NotificationsTab-B7uebqMV.js} +21 -21
- package/dist/cdn/{OAuthCallback-Blc2Asxc.js → OAuthCallback--NZdLoWx.js} +3 -3
- package/dist/cdn/PromptsTab-BlXDcau3.js +902 -0
- package/dist/cdn/{ResourcesTab-BGualKW-.js → ResourcesTab-D45_JojP.js} +116 -114
- package/dist/cdn/{SamplingTab-BeZBUeni.js → SamplingTab-r7tImM6L.js} +34 -33
- package/dist/cdn/{ServerMetadataTab-CvrKX8fz.js → ServerMetadataTab-BM3VhSLf.js} +9 -9
- package/dist/cdn/{StatusIcon-D0-ARyOh.js → StatusIcon-Q3n3YRtE.js} +10 -11
- package/dist/cdn/{ToolsTab-j6n4O_3s.js → ToolsTab-DOAO8HnS.js} +664 -652
- package/dist/cdn/{ViewPreview-DihyG6Qd.js → ViewPreview-CBhrVdwx.js} +3 -3
- package/dist/cdn/{WidgetDebugContext-D4usL_MA.js → WidgetDebugContext-B6yoOVVV.js} +1 -11
- package/dist/cdn/WidgetWrapper-BlbQAh_X.js +12 -0
- package/dist/cdn/{bell-CGjAO_0s.js → bell-GrTZcnD2.js} +1 -1
- package/dist/cdn/{browser-CbQIH4w2.js → browser-DG2Z8392.js} +1 -1
- package/dist/cdn/{brush-B_mKhyxG.js → brush-CelVvMGp.js} +1 -1
- package/dist/cdn/button-CB4uOoUV.js +2509 -0
- package/dist/cdn/card-BA-DQk-G.js +41 -0
- package/dist/cdn/{checkbox-By0FklhG.js → checkbox-kwVa4gRX.js} +7 -7
- package/dist/cdn/{clock-CmUbSx_B.js → clock-YMF8Gtw5.js} +1 -1
- package/dist/cdn/{code-V_0nf5rg.js → code-C8sN2OGR.js} +1 -1
- package/dist/cdn/{jsx-runtime-CIxvMpEo.js → createLucideIcon-BONxC1L5.js} +57 -24
- package/dist/cdn/{dialog-BsDpuJd3.js → dialog-CJGnC5Ag.js} +171 -171
- package/dist/cdn/{dist-DaMB0Su9.js → dist-CTJnCYmk.js} +1 -1
- package/dist/cdn/{dist-DbX5yidW.js → dist-SxRsB1iS.js} +5 -4
- package/dist/cdn/{external-link-CjmfT6rW.js → external-link-Bo4lQxr1.js} +1 -1
- package/dist/cdn/{eye-B7H96av8.js → eye-pSGG7nvf.js} +1 -1
- package/dist/cdn/{folder-open-B3lu2rG_.js → folder-open-aM8CPtBO.js} +1 -1
- package/dist/cdn/{hash-BVQnWi7q.js → hash-DDs2vE1k.js} +1 -1
- package/dist/cdn/{history-Csw4rb44.js → history-BfUFpL1d.js} +1 -1
- package/dist/cdn/{index-browser-DkQOzkvX.js → index-browser-Dm3R1Mfe.js} +1 -1
- package/dist/cdn/{info-CNiOwqkf.js → info-BMkB68mB.js} +1 -1
- package/dist/cdn/{input-C2OBd4PJ.js → input-BCpgLXU1.js} +2993 -5499
- package/dist/cdn/inspector.css +1 -1
- package/dist/cdn/inspector.js +7106 -7140
- package/dist/cdn/{label-B9Jmm9be.js → label-A0UGV8FE.js} +9 -9
- package/dist/cdn/{loader-circle-BLy9A_pp.js → loader-circle-BKRHJEB7.js} +1 -1
- package/dist/cdn/{maximize-2-CH5Lq90B.js → maximize-2-DdrB_spi.js} +1 -1
- package/dist/cdn/{maximize-BALCV_ep.js → maximize-hSOCz133.js} +1 -1
- package/dist/cdn/{message-square-BnxdpJxZ.js → message-square-D3tKB3uJ.js} +1 -1
- package/dist/cdn/{not-found-DEtSM_Wd.js → not-found-BajFyZpp.js} +9 -11
- package/dist/cdn/{play-vuZ5PLnI.js → play-B1leulYf.js} +1 -1
- package/dist/cdn/providerMeta-CjGU4rID.js +436 -0
- package/dist/cdn/{react-BajV-X4P.js → react-Bl-hSkvn.js} +628 -571
- package/dist/cdn/{refresh-cw-BXY-Pa0U.js → refresh-cw-CyvXrS91.js} +1 -1
- package/dist/cdn/{save-Tgil_AJZ.js → save-CmdEPUAm.js} +1 -1
- package/dist/cdn/{select-DDdiIPR2.js → select-CCFHjOGk.js} +808 -807
- package/dist/cdn/{servers-Dm72iTpY.js → servers-Dd0Vcp81.js} +5 -1
- package/dist/cdn/{shared-DaILIQPP.js → shared-CJVHJhag.js} +36 -36
- package/dist/cdn/{sheet-Br_l2kry.js → sheet-oyq1mIyg.js} +620 -619
- package/dist/cdn/{sparkles-BntO2rDR.js → sparkles-CxeZpVtX.js} +1 -1
- package/dist/cdn/spinner-Be1GlSGX.js +15 -0
- package/dist/cdn/{square-check-big-BvwQ17Bl.js → square-check-big-C_4wbfwF.js} +1 -1
- package/dist/cdn/{switch-C3IyQuid.js → switch-DHXEA_N5.js} +190 -189
- package/dist/cdn/{tabs-subtle-CkdI6Mac.js → tabs-subtle-Dubd6Kj8.js} +269 -268
- package/dist/cdn/{telemetry-DabTAQ8x.js → telemetry-TwPKZlFf.js} +2 -2
- package/dist/cdn/{textarea-DSbwcFVt.js → textarea-CwmI8_uI.js} +6 -6
- package/dist/cdn/{trash-2-RwpJY5SL.js → trash-2-BhumJAFE.js} +1 -1
- package/dist/cdn/{useAriaLabelledBy-DqAdnppm.js → useAriaLabelledBy-Cra6w3YY.js} +2 -1
- package/dist/cdn/{useCompositeItem-BRqEzYh-.js → useCompositeItem-Dhnm-7el.js} +3 -3
- package/dist/cdn/{useConfig-Btmh8wjJ.js → useConfig-leHVjdjl.js} +2 -2
- package/dist/cdn/{useSavedRequests-Ci2I919u.js → useSavedRequests-mSIsDd4c.js} +1 -1
- package/dist/cdn/{useViewHostProps-B6SKeeH9.js → useViewHostProps-CDOm2w6u.js} +124 -109
- package/dist/cdn/{wrench-DzGmCfnb.js → wrench-DvK20LUT.js} +1 -1
- package/dist/cdn/{x-C3vRQIYu.js → x-EilKPiCX.js} +1 -1
- package/dist/cdn/{zap-Mb-pbw2X.js → zap-0Wr9QO7N.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/client/components/ChatTab.d.ts.map +1 -1
- package/dist/client/components/MCPAppsDebugControls.d.ts.map +1 -1
- package/dist/client/components/ToolsTab.d.ts.map +1 -1
- package/dist/client/components/chat/ConfigurationDialog.d.ts.map +1 -1
- package/dist/client/components/chat/MessageList.d.ts +1 -0
- package/dist/client/components/chat/MessageList.d.ts.map +1 -1
- package/dist/client/components/chat/ToolResultRenderer.d.ts.map +1 -1
- package/dist/client/components/chat/partialToolArgs.d.ts +10 -0
- package/dist/client/components/chat/partialToolArgs.d.ts.map +1 -0
- package/dist/client/components/chat/types.d.ts +1 -0
- package/dist/client/components/chat/types.d.ts.map +1 -1
- package/dist/client/components/chat/useChatMessages.d.ts.map +1 -1
- package/dist/client/components/chat/useChatMessagesClientSide.d.ts.map +1 -1
- package/dist/client/components/mcp-apps/McpAppsViewPanel.d.ts +29 -0
- package/dist/client/components/mcp-apps/McpAppsViewPanel.d.ts.map +1 -0
- package/dist/client/components/tools/ToolExecutionPanel.d.ts.map +1 -1
- package/dist/client/components/tools/ToolResultDisplay.d.ts +2 -1
- package/dist/client/components/tools/ToolResultDisplay.d.ts.map +1 -1
- package/dist/client/components/tools/useToolsTabNavigation.d.ts.map +1 -1
- package/dist/client/components/ui/MeshGradientCanvas.d.ts.map +1 -1
- package/dist/client/components/ui/mesh-animation-pause.d.ts +14 -0
- package/dist/client/components/ui/mesh-animation-pause.d.ts.map +1 -0
- package/dist/client/components/ui/mesh-gradient-colors.d.ts +6 -0
- package/dist/client/components/ui/mesh-gradient-colors.d.ts.map +1 -0
- package/dist/client/components/ui/mesh-tab-background.d.ts +1 -1
- package/dist/client/components/ui/mesh-tab-background.d.ts.map +1 -1
- package/dist/client/components/ui/not-found.d.ts.map +1 -1
- package/dist/client/context/WidgetDebugContext.d.ts +1 -11
- package/dist/client/context/WidgetDebugContext.d.ts.map +1 -1
- package/dist/client/hooks/useDeviceViewport.d.ts +1 -5
- package/dist/client/hooks/useDeviceViewport.d.ts.map +1 -1
- package/dist/client/hooks/useViewHostProps.d.ts +1 -1
- package/dist/client/hooks/useViewHostProps.d.ts.map +1 -1
- package/dist/client/index.js +2238 -1935
- package/dist/client/utils/servers.d.ts +5 -0
- package/dist/client/utils/servers.d.ts.map +1 -1
- package/dist/server/cdn-shell.js +2 -2
- package/dist/server/{chunk-ZCGLU5T7.js → chunk-5GVQGIAX.js} +1 -1
- package/dist/server/{chunk-DSTNUYWX.js → chunk-UZZDBVKF.js} +1 -1
- package/dist/server/{chunk-SQ4XNMLT.js → chunk-VFVFLXKP.js} +1 -1
- package/dist/server/cli.js +2 -2
- package/dist/server/index.js +3 -3
- package/dist/server/middleware.js +3 -3
- package/dist/server/version.js +1 -1
- package/dist/web/assets/AnimatePresence-FfDQQNFJ.js +9 -0
- package/dist/web/assets/ChatTab-B6ubLbeA.js +18 -0
- package/dist/web/assets/ConnectionSettingsTab-Cb2eDgEu.js +1 -0
- package/dist/web/assets/ElicitationTab-CbnCrmu9.js +1 -0
- package/dist/web/assets/FormContext-sV-yByKz.js +1 -0
- package/dist/web/assets/ListTabHeader-CrGae306.js +1 -0
- package/dist/web/assets/MCPAppsDebugControls-sRglMhat.js +34 -0
- package/dist/web/assets/{ManufactOAuthCallback-CS3ydSZg.js → ManufactOAuthCallback-D4uYGigW.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-BeeBfQhv.js → MarkdownRenderer-Cwxp9fLj.js} +2 -2
- package/dist/web/assets/McpAppsViewPanel-jQYFoZNX.js +1 -0
- package/dist/web/assets/{NotificationsTab-Uj0_DrmK.js → NotificationsTab-DuSm762_.js} +1 -1
- package/dist/web/assets/{OAuthCallback-C0ljgCiw.js → OAuthCallback-VLHlUe2c.js} +1 -1
- package/dist/web/assets/PromptsTab-DK6XZxR8.js +15 -0
- package/dist/web/assets/ResourcesTab-CUE4MAtJ.js +2 -0
- package/dist/web/assets/SamplingTab-BYNkVCTu.js +1 -0
- package/dist/web/assets/ServerMetadataTab-DWjNFMbq.js +1 -0
- package/dist/web/assets/ToolsTab-BisWWY2p.js +8 -0
- package/dist/web/assets/{ViewPreview-Ba1Ec5uA.js → ViewPreview-COrmPpRr.js} +1 -1
- package/dist/web/assets/WidgetWrapper-cv_BM1bY.js +1 -0
- package/dist/web/assets/{brush--0LobUi4.js → brush-DX0UZ_pI.js} +1 -1
- package/dist/web/assets/button-C8Xa2k4x.js +1 -0
- package/dist/web/assets/checkbox-B6dtF73d.js +1 -0
- package/dist/web/assets/code-B14rVdNt.js +1 -0
- package/dist/web/assets/createLucideIcon-BEHeJH0M.js +1 -0
- package/dist/web/assets/{dist-C5JjLJN9.js → dist-9Oy7e0v8.js} +5 -5
- package/dist/web/assets/index-BMaSsizY.js +499 -0
- package/dist/web/assets/index-D7TVTIt9.css +1 -0
- package/dist/web/assets/input-C0OQCUZy.js +1 -0
- package/dist/web/assets/{label-Cdim77Jw.js → label-CI7JWQOo.js} +1 -1
- package/dist/web/assets/{maximize-2-BTT9QQU9.js → maximize-2-Br1WQzT2.js} +1 -1
- package/dist/web/assets/{maximize-_O55kFcr.js → maximize-CJNgRe6S.js} +1 -1
- package/dist/web/assets/{refresh-cw-C9wQl8_d.js → refresh-cw-B5iaAZKn.js} +1 -1
- package/dist/web/assets/{save-B-MsgxX9.js → save-TM6fvNrt.js} +1 -1
- package/dist/web/assets/select-D6jzbLJn.js +1 -0
- package/dist/web/assets/shared-CFs9CZfB.js +1 -0
- package/dist/web/assets/{sparkles-2OAsc1aP.js → sparkles-BGYTDThM.js} +1 -1
- package/dist/web/assets/tabs-subtle-D2XkWhLL.js +1 -0
- package/dist/web/assets/textarea-CRTXuRmE.js +1 -0
- package/dist/web/assets/{useConfig-BAgALiZg.js → useConfig-B6tXvJOb.js} +1 -1
- package/dist/web/assets/useViewHostProps-DZqOwiAm.js +1 -0
- package/dist/web/assets/{zap-Du2Uc5pa.js → zap-BDWHCVHU.js} +1 -1
- package/dist/web/index.html +10 -10
- package/package.json +4 -4
- package/dist/cdn/CheckboxIndicator-Bt4IICtv.js +0 -251
- package/dist/cdn/PromptsTab-BYKnY7Rp.js +0 -901
- package/dist/cdn/card-DgiYnSg-.js +0 -41
- package/dist/cdn/createLucideIcon-C5fZZ6oB.js +0 -38
- package/dist/cdn/providerMeta-BQIfHuNL.js +0 -379
- package/dist/cdn/spinner-jQtC7EBj.js +0 -15
- package/dist/web/assets/AnimatePresence-C5p0yiY1.js +0 -9
- package/dist/web/assets/ChatTab-BCobuZDc.js +0 -18
- package/dist/web/assets/ConnectionSettingsTab-BjGkLwVu.js +0 -1
- package/dist/web/assets/ElicitationTab-D3ZUKHND.js +0 -1
- package/dist/web/assets/FormContext-DH2caWKO.js +0 -1
- package/dist/web/assets/ListTabHeader-R17w_JsB.js +0 -1
- package/dist/web/assets/PromptsTab-Bns2u0G-.js +0 -15
- package/dist/web/assets/ResourcesTab-CO24312V.js +0 -2
- package/dist/web/assets/SamplingTab-7gtN7FwU.js +0 -1
- package/dist/web/assets/ServerMetadataTab-CQwqYSjL.js +0 -1
- package/dist/web/assets/ToolsTab-bDdRxI1b.js +0 -8
- package/dist/web/assets/WidgetWrapper-CYHfzrtb.js +0 -34
- package/dist/web/assets/checkbox-CzBkaNKa.js +0 -1
- package/dist/web/assets/code-tME-5H6D.js +0 -1
- package/dist/web/assets/createLucideIcon-B3b8EU0b.js +0 -1
- package/dist/web/assets/index-TQ5V7cM9.js +0 -492
- package/dist/web/assets/index-fBX3akc8.css +0 -1
- package/dist/web/assets/input-CLYhA7PK.js +0 -1
- package/dist/web/assets/jsx-runtime-Cjj9sGSy.js +0 -1
- package/dist/web/assets/select-CJ57-Bor.js +0 -1
- package/dist/web/assets/shared-BF0rJNdE.js +0 -1
- package/dist/web/assets/tabs-subtle-6D79T1xd.js +0 -1
- package/dist/web/assets/textarea-DLAmNVf_.js +0 -1
- package/dist/web/assets/useViewHostProps-BYitt_6K.js +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{s as e,t}from"./react-CU_d2d5K.js";import{a as n,f as r,n as i,r as a,sr as o,t as s}from"./input-C0OQCUZy.js";import{n as c,t as l}from"./createLucideIcon-BEHeJH0M.js";import{H as u,i as d,n as f,t as p}from"./button-C8Xa2k4x.js";import{t as m}from"./label-CI7JWQOo.js";import{t as h}from"./AnimatePresence-FfDQQNFJ.js";import{a as g,i as _,n as v,r as y,t as b}from"./select-D6jzbLJn.js";import{n as x,t as S}from"./MCPAppsDebugControls-sRglMhat.js";import{n as C,t as w}from"./zap-BDWHCVHU.js";import{t as T}from"./code-B14rVdNt.js";import{a as E,i as D,n as O,o as k,r as A,s as ee}from"./shared-CFs9CZfB.js";import{t as j}from"./maximize-CJNgRe6S.js";import{n as M,t as N}from"./save-TM6fvNrt.js";import{$ as P,B as te,Ct as ne,F,G as I,J as L,M as R,Ot as z,P as B,Q as V,Qt as H,R as U,Rt as W,Sn as G,Tt as K,U as re,W as ie,Wt as ae,X as oe,Xt as se,Y as ce,Z as q,Zt as le,b as J,bt as ue,fn as Y,in as de,ot as fe,q as pe,rn as me,w as X,xn as he,yn as ge,z as _e,zt as ve}from"./index-BMaSsizY.js";import{t as ye}from"./textarea-CRTXuRmE.js";import{t as be}from"./WidgetWrapper-cv_BM1bY.js";import{t as xe}from"./McpAppsViewPanel-jQYFoZNX.js";import{t as Se}from"./ListTabHeader-CrGae306.js";var Ce=l(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Z=e(t(),1),Q=c();function we({savedRequests:e,selectedRequest:t,onLoadRequest:r,onDeleteRequest:o,focusedIndex:s}){if(e.length===0)return(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-4 text-center`,children:[(0,Q.jsx)(x,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,Q.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`No saved requests yet`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Execute a tool and click Save to store requests`})]});let c=(e,t)=>{e.stopPropagation(),t()};return(0,Q.jsx)(`div`,{children:e.map((e,l)=>(0,Q.jsxs)(`div`,{className:`relative group`,children:[(0,Q.jsx)(A,{id:`saved-${e.id}`,isSelected:t?.id===e.id,isFocused:s===l,title:e.name,description:e.toolName,metadata:(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:(0,Q.jsx)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:new Date(e.savedAt).toLocaleString()})}),onClick:()=>r(e)}),(0,Q.jsx)(`div`,{className:`absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10`,children:(0,Q.jsxs)(i,{children:[(0,Q.jsx)(n,{render:(0,Q.jsx)(p,{variant:`secondary`,size:`sm`,onClick:t=>c(t,()=>o(e.id)),className:`h-8 w-8 p-0`,children:(0,Q.jsx)(H,{className:`h-4 w-4`})}),nativeButton:!0}),(0,Q.jsx)(a,{children:(0,Q.jsx)(`p`,{children:`Delete saved request`})})]})})]},e.id))})}function Te({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:r,onSave:i,onCancel:a}){return e?(0,Q.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:a,children:(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-zinc-800 rounded-lg p-6 w-[400px] shadow-xl border border-gray-200 dark:border-zinc-700`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100`,children:`Save Request`}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(m,{htmlFor:`request-name`,children:`Request Name (optional)`}),(0,Q.jsx)(s,{id:`request-name`,value:t,onChange:e=>r(e.target.value),placeholder:n,className:`mt-2`,onKeyDown:e=>{e.key===`Enter`&&i()},autoFocus:!0})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(p,{variant:`outline`,onClick:a,children:`Cancel`}),(0,Q.jsxs)(p,{onClick:i,children:[(0,Q.jsx)(N,{className:`h-4 w-4 mr-2`}),`Save`]})]})]})]})}):null}function Ee(e,t){if(!e?.$ref)return e;let n=e.$ref;if(!n.startsWith(`#/`))return e;let r=n.substring(2).split(`/`),i=t;for(let t of r)if(i&&typeof i==`object`&&t in i)i=i[t];else return e;return i}function De(e,t){if(e?.anyOf&&Array.isArray(e.anyOf)){let n=e.anyOf.find(e=>Ee(e,t)?.type!==`null`);if(n)return{...Ee(n,t),nullable:!0}}return e}function Oe(e,t){let n=De(e||{},t);return n=Ee(n,t),n}function ke(e,t){let n=Oe(e,t);if(typeof n.type==`string`)return n.type;if(Array.isArray(n.type)){let e=n.type.find(e=>e!==`null`);return typeof e==`string`?e:void 0}}function Ae(e){let t=e?.enum;return Array.isArray(t)&&t.every(e=>typeof e==`string`)?t:null}function je(e){let t=e.trim().toLowerCase();return[`true`,`1`,`yes`,`on`].includes(t)?!0:[`false`,`0`,`no`,`off`].includes(t)?!1:e}function Me(e,t){if(t===`number`||t===`integer`){let t=e.trim();if(!t)return e;let n=Number(t);return Number.isFinite(n)?n:e}return t===`boolean`?je(e):e}function Ne(e,t){if(e===void 0)return e;if(t===`object`||t===`array`){if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}if(t===`number`||t===`integer`){if(typeof e==`number`)return e;if(typeof e==`string`){let t=e.trim();if(!t)return e;let n=Number(t);return Number.isFinite(n)?n:e}return e}return t===`boolean`?typeof e==`boolean`?e:typeof e==`string`?je(e):e:e}function Pe(e){let t=``,n=0,r=!1,i=!1;for(;n<e.length;){let a=e[n];if(i){t+=a,i=!1,n++;continue}if(a===`\\`){i=!0,t+=a,n++;continue}if(a==="`"){r?(t+=`"`,r=!1):(t+=`"`,r=!0),n++;continue}if(r&&a===`"`){t+=`\\"`,n++;continue}t+=a,n++}return t}function Fe(e){if(!e||typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return e}catch{try{let e=Pe(t),n=JSON.parse(e);if(n&&typeof n==`object`&&!Array.isArray(n))return n}catch{return null}}return null}function Ie({selectedTool:e,toolArgs:t,onArgChange:n,onBulkPaste:r,autoFilledFields:i,setFields:a,sendEmptyFields:o,onToggleEmpty:c}){let l=e?.inputSchema?.properties||{},u=e?.inputSchema?.required||[],d=Object.keys(l).length>0,f=async(e,t)=>{r&&await r(e.clipboardData.getData(`text`),t)&&e.preventDefault()};return d?(0,Q.jsx)(`div`,{className:`space-y-4`,children:Object.entries(l).map(([r,l])=>{let d=Oe(l,e?.inputSchema||{}),p=Ae(d),h=d.type===`string`&&p!==null,x=d,S=u.includes(r),C=t[r],w=``;C!=null&&(w=typeof C==`string`?C:typeof C==`object`&&C?JSON.stringify(C,null,2):String(C));let T=x.type===`object`||x.type===`array`,E=T?x.type===`array`?`array`:`object`:`string`,D=a?.has(r)??!0,O=c&&(x.type===`string`||T);return T?(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(m,{htmlFor:r,className:`text-sm font-medium`,children:[r,S&&(0,Q.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),x?.description&&(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:x.description})]}),O&&c&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:E===`array`?`Send empty array explicitly`:`Send empty object explicitly`}),(0,Q.jsx)(X,{checked:o?.has(r)??!1,onCheckedChange:e=>c(r,E,e),"aria-label":E===`array`?`Send empty array`:`Send empty object`,title:E===`array`?`Send empty array []`:`Send empty object {}`})]})]}),(0,Q.jsx)(ye,{id:r,"data-testid":`tool-param-${r}`,value:w,onChange:e=>n(r,e.target.value),onPaste:e=>f(e,r),placeholder:`Enter ${r}`,disabled:o?.has(r)??!1,className:`min-h-[100px] ${D?``:`opacity-70`} ${i?.has(r)?`animate-pulse ring-2 ring-green-500 dark:ring-green-400`:``}`})]},r):h&&p?(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(m,{htmlFor:r,className:`text-sm font-medium`,children:[r,S&&(0,Q.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),x.description&&(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:x.description})]}),(0,Q.jsxs)(b,{value:String(t[r]||``),onValueChange:e=>n(r,e),children:[(0,Q.jsx)(_,{id:r,className:`w-full ${D?``:`opacity-70`}`,"data-testid":`tool-param-${r}`,children:(0,Q.jsx)(g,{placeholder:`Select an option`})}),(0,Q.jsx)(v,{children:p.map((e,t)=>(0,Q.jsx)(y,{value:e,children:x.enumNames?.[t]||e},e))})]})]},r):(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(m,{htmlFor:r,className:`text-sm font-medium`,children:[r,S&&(0,Q.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),x?.description&&(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:x.description})]}),O&&c&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`Send empty string`}),(0,Q.jsx)(X,{checked:o?.has(r)??!1,onCheckedChange:e=>c(r,`string`,e),"aria-label":`Send empty string`,title:`Send empty string`})]})]}),(0,Q.jsx)(s,{id:r,"data-testid":`tool-param-${r}`,value:w,onChange:e=>n(r,e.target.value),onPaste:e=>f(e,r),placeholder:`Enter ${r}`,disabled:o?.has(r)??!1,className:`${D?``:`opacity-70`} ${i?.has(r)?`animate-pulse ring-2 ring-green-500 dark:ring-green-400`:``}`})]},r)})}):(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm`,children:`No parameters required`})}function Le({selectedTool:e,toolArgs:t,payloadToSend:r,isExecuting:o,isConnected:s,onArgChange:c,onExecute:l,onSave:m,onCancel:h,onBulkPaste:g,autoFilledFields:_,setFields:v,sendEmptyFields:y,onToggleEmpty:b}){let x=`hidden @[700px]/tool-exec:inline`,S=`hidden @[700px]/tool-exec:inline shrink-0 text-[10px] leading-none border border-current/30 p-1 rounded-full`,C=`@max-[699px]/tool-exec:size-8 @max-[699px]/tool-exec:min-w-8 @max-[699px]/tool-exec:shrink-0 @max-[699px]/tool-exec:gap-0 @max-[699px]/tool-exec:rounded-full @max-[699px]/tool-exec:!px-0 @max-[699px]/tool-exec:!py-0`,w=`@max-[699px]/tool-exec:!pr-0`,[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(!1),[A,ee]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(!1),[P,ne]=(0,Z.useState)(!1),L=(0,Z.useRef)(null);return(0,Z.useEffect)(()=>{if(L.current&&e?.description){let e=L.current,t=parseFloat(getComputedStyle(e).lineHeight),n=e.scrollHeight;ne(Math.round(n/t)>3),M(!1)}},[e?.description]),(0,Z.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&e&&!o&&s&&(t.preventDefault(),l()),t.key===`Escape`&&o&&h&&(t.preventDefault(),h())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,o,s,l,h]),e?(0,Q.jsxs)(`div`,{className:`flex flex-col h-full @container/tool-exec`,children:[(0,Q.jsx)(`div`,{className:`shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-2 sm:pb-2 sm:pr-4`,children:(0,Q.jsx)(`div`,{children:(0,Q.jsxs)(`div`,{className:`flex flex-row items-center justify-between mb-0 gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-base sm:text-lg font-semibold`,"data-testid":`tool-execution-title`,children:e.name}),(0,Q.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,Q.jsxs)(i,{children:[(0,Q.jsx)(n,{render:(0,Q.jsxs)(p,{"data-testid":`tool-execution-metadata-button`,variant:O?`default`:`outline`,onClick:()=>k(!O),disabled:o,size:`sm`,className:u(d,C),title:`View tool metadata`,children:[(0,Q.jsx)(T,{}),(0,Q.jsx)(`span`,{className:x,children:`Metadata`})]}),nativeButton:!0}),(0,Q.jsx)(a,{children:(0,Q.jsx)(`p`,{children:`View tool definition metadata`})})]}),(0,Q.jsxs)(i,{children:[(0,Q.jsx)(n,{render:(0,Q.jsxs)(p,{"data-testid":`tool-execution-copy-payload-button`,variant:`outline`,onClick:async()=>{if(e)try{await ue(JSON.stringify(r??t,null,2)),ee(!0),setTimeout(()=>ee(!1),2e3)}catch{}},disabled:o,size:`sm`,className:u(d,C),title:`Copy payload as JSON`,children:[A?(0,Q.jsx)(G,{className:`text-green-600`}):(0,Q.jsx)(ge,{}),(0,Q.jsx)(`span`,{className:x,children:A?`Copied!`:`Payload`})]}),nativeButton:!0}),(0,Q.jsx)(a,{children:(0,Q.jsx)(`p`,{children:`Copy payload as JSON`})})]}),(0,Q.jsxs)(i,{children:[(0,Q.jsx)(n,{render:(0,Q.jsxs)(p,{"data-testid":`tool-execution-save-button`,variant:`outline`,onClick:m,disabled:o,size:`sm`,className:u(d,C),title:`Save request`,children:[(0,Q.jsx)(N,{}),(0,Q.jsx)(`span`,{className:x,children:`Save`})]}),nativeButton:!0}),(0,Q.jsx)(a,{children:(0,Q.jsx)(`p`,{children:`Save request`})})]}),o&&h?(0,Q.jsxs)(i,{open:E?void 0:!1,children:[(0,Q.jsx)(n,{render:(0,Q.jsx)(`div`,{onMouseEnter:()=>D(!0),onMouseLeave:()=>D(!1),className:`relative`,children:(0,Q.jsx)(p,{"data-testid":`tool-execution-cancel-button`,onClick:h,variant:E?`destructive`:`default`,size:`sm`,className:u(f,C,w,`transition-all`),children:E?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(se,{}),(0,Q.jsx)(`span`,{className:x,children:`Cancel`}),(0,Q.jsx)(`span`,{className:S,children:`Esc`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{}),(0,Q.jsx)(`span`,{className:x,children:`Executing...`})]})})}),nativeButton:!1}),(0,Q.jsx)(a,{children:(0,Q.jsx)(`p`,{children:`Hover to cancel (or press Esc)`})})]}):(0,Q.jsx)(p,{"data-testid":`tool-execution-execute-button`,onClick:l,disabled:o||!s,size:`sm`,className:u(f,C,w),children:o?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(F,{}),(0,Q.jsx)(`span`,{className:x,children:`Executing...`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(me,{}),(0,Q.jsx)(`span`,{className:x,children:`Execute`}),(0,Q.jsx)(`span`,{className:S,children:`⌘↵`})]})})]})]})})}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-3 sm:px-5 pb-4 pr-3`,children:[e.description&&(0,Q.jsxs)(`div`,{className:`relative mb-6`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`p`,{ref:L,"data-testid":`tool-execution-description`,className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed transition-all duration-300 ${!j&&P?`line-clamp-3`:``}`,children:e.description}),P&&!j&&(0,Q.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-[1.4em] bg-linear-to-t from-white/95 dark:from-black/95 via-white/55 dark:via-black/55 to-transparent pointer-events-none`})]}),P&&(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(`button`,{onClick:()=>M(!j),className:`relative z-10 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 mt-1 transition-colors`,children:j?(0,Q.jsxs)(Q.Fragment,{children:[`Show less`,(0,Q.jsx)(Ce,{className:`h-3 w-3`})]}):(0,Q.jsxs)(Q.Fragment,{children:[`Show more`,(0,Q.jsx)(he,{className:`h-3 w-3`})]})})})]}),(0,Q.jsx)(Ie,{selectedTool:e,toolArgs:t,onArgChange:c,onBulkPaste:g,autoFilledFields:_,setFields:v,sendEmptyFields:y,onToggleEmpty:b})]}),(0,Q.jsx)(U,{open:O,onOpenChange:k,children:(0,Q.jsxs)(te,{scrollable:!0,className:`max-w-3xl max-h-[80vh]`,children:[(0,Q.jsx)(re,{sticky:!0,children:(0,Q.jsx)(I,{children:`Tool Definition`})}),(0,Q.jsx)(_e,{children:(0,Q.jsx)(ie,{onCopy:async()=>{e&&await ue(JSON.stringify(e,null,2))},children:(0,Q.jsx)(J,{data:e,filename:`tool-definition-${e.name}-${Date.now()}.json`})})})]})})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a tool to get started`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a tool from the list to view its details and execute it`})]})}function Re({timestamp:e}){let[t,n]=(0,Z.useState)(()=>ze(e));return(0,Z.useEffect)(()=>{let t=()=>n(ze(e));t();let r=setInterval(t,1e3);return()=>clearInterval(r)},[e]),(0,Q.jsx)(`span`,{children:t})}function ze(e){let t=Date.now()-e,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<10?`now`:n<60?`${n}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${a}d ago`}function Be(e){if(!e?.isError)return null;let t=e.content;if(Array.isArray(t)){let e=t.filter(e=>e.type===`text`).map(e=>e.text).filter(Boolean);if(e.length>0)return e.join(`
|
|
2
|
+
`)}return`An error occurred`}function $(e){try{return JSON.parse(e),!0}catch{return!1}}function Ve({content:e}){let[t,n]=(0,Z.useState)(new Set),r=(0,Z.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return!Array.isArray(e)||e.length===0?(0,Q.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:`No content`}):(0,Q.jsx)(`div`,{className:`space-y-4`,children:e.map((e,n)=>{if(e.type===`text`){let i=e.text||``,a=t.has(n),o=$(i),s=o?(()=>{try{return JSON.parse(i)}catch{return null}})():null;return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:[`Text Content`,a?` (formatted)`:``]}),o&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r(n),className:`text-xs text-blue-600 dark:text-blue-400 hover:underline`,"data-testid":`tool-result-format-toggle-${n}`,children:a?`Show as text`:`Try to format`})]}),a&&s!==null?(0,Q.jsx)(J,{data:s,filename:`content-${n}.json`}):(0,Q.jsx)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 font-mono text-sm whitespace-pre-wrap break-words`,"data-testid":`tool-execution-results-text-content`,children:i})]},n)}if(e.type===`image`)return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Image Content`}),(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3`,children:[(0,Q.jsx)(`img`,{src:`data:${e.mimeType||`image/png`};base64,${e.data}`,alt:`Result`,className:`max-w-full rounded`,"data-testid":`tool-execution-results-image-content`}),e.annotations&&(0,Q.jsx)(`div`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400`,children:(0,Q.jsx)(J,{data:e.annotations,filename:`image-annotations-${n}.json`,"data-testid":`tool-execution-results-image-annotations`})})]})]},n);if(e.type===`audio`)return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Audio Content`}),(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3`,children:[(0,Q.jsx)(`audio`,{controls:!0,src:`data:${e.mimeType||`audio/wav`};base64,${e.data}`,className:`w-full`,"data-testid":`tool-execution-results-audio-content`}),e.annotations&&(0,Q.jsx)(`div`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400`,children:(0,Q.jsx)(J,{data:e.annotations,filename:`audio-annotations-${n}.json`,"data-testid":`tool-execution-results-audio-annotations`})})]})]},n);if(e.type===`resource_link`)return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Resource Link`}),(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`font-mono text-sm break-all`,children:[(0,Q.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`URI:`}),` `,e.uri]}),e.name&&(0,Q.jsxs)(`div`,{className:`text-sm`,children:[(0,Q.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`Name:`}),` `,e.name]}),e.description&&(0,Q.jsxs)(`div`,{className:`text-sm`,children:[(0,Q.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`Description:`}),` `,e.description]}),e.mimeType&&(0,Q.jsxs)(`div`,{className:`text-sm`,children:[(0,Q.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`MIME Type:`}),` `,e.mimeType]}),e.annotations&&(0,Q.jsxs)(`div`,{className:`mt-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:`Annotations:`}),(0,Q.jsx)(J,{data:e.annotations,filename:`resource-link-annotations-${n}.json`,"data-testid":`tool-execution-results-resource-link-annotations`})]})]})]},n);if(e.type===`resource`){let t=e.resource||{};return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Embedded Resource`}),(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`font-mono text-sm break-all`,"data-testid":`tool-execution-results-resource-uri`,children:[(0,Q.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`URI:`}),` `,t.uri]}),t.mimeType&&(0,Q.jsxs)(`div`,{className:`text-sm`,children:[(0,Q.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,"data-testid":`tool-execution-results-mime-type`,children:`MIME Type:`}),` `,t.mimeType]}),t.text&&(0,Q.jsxs)(`div`,{"data-testid":`tool-execution-results-resource-text-content`,children:[(0,Q.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:`Content:`}),(0,Q.jsx)(`div`,{className:`bg-white dark:bg-black rounded p-2 font-mono text-sm whitespace-pre-wrap break-words max-h-60 overflow-y-auto`,children:t.text})]}),t.blob&&(0,Q.jsxs)(`div`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[`[Binary content: `,t.blob.length||0,` bytes]`]}),t.annotations&&(0,Q.jsxs)(`div`,{className:`mt-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:`Annotations:`}),(0,Q.jsx)(J,{data:t.annotations,filename:`resource-annotations-${n}.json`,"data-testid":`tool-execution-results-resource-annotations`})]})]})]},n)}return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:[`Unknown Content Type: `,e.type||`N/A`]}),(0,Q.jsx)(J,{data:e,filename:`content-${n}.json`,"data-testid":`tool-execution-results-unknown-content`})]},n)})})}function He({results:e,copiedResult:t,serverId:n,readResource:r,onCopy:i,onMaximize:a,isMaximized:o=!1,onRerunTool:s,onWidgetHeightChange:c}){let[l,u]=(0,Z.useState)(0),[d,f]=(0,Z.useState)(!0),[m,h]=(0,Z.useState)(null),[g,x]=(0,Z.useState)(`inline`),[C,T]=(0,Z.useState)(null),E=(0,Z.useRef)(!1),D=e[0],O=D?e.filter(e=>e.toolName===D.toolName):[],k=O[l]||O[0],A=e.findIndex(e=>e===k),ee=(k?k.error||Be(k.result):null)??(k==null?``:JSON.stringify(k.result,null,2));(0,Z.useEffect)(()=>{O.length>0&&l>=O.length&&u(0)},[O.length,l]),(0,Z.useEffect)(()=>{E.current=!1,h(null)},[D?.toolName]);let N=(0,Z.useMemo)(()=>k?.args,[k?.timestamp,l]),P=(0,Z.useMemo)(()=>k?.result,[k?.timestamp,k?.duration,l]),te=(0,Z.useCallback)(e=>r(e),[r]),I=(0,Z.useCallback)(e=>{let t=e.filter(e=>e.type===`text`&&`text`in e).map(e=>e.text).join(`
|
|
3
|
+
`),n=e.filter(e=>e.type===`image`).length,r=e.filter(e=>e.type===`resource`).length,i=[n>0&&`${n} image${n>1?`s`:``}`,r>0&&`${r} resource${r>1?`s`:``}`].filter(Boolean).join(`, `);fe.info(`Widget follow-up`,{description:[t,i].filter(Boolean).join(` — `),duration:5e3})},[]),L=(0,Z.useMemo)(()=>k&&K(k.toolMeta)?`mcp-apps`:null,[k]),R=(0,Z.useMemo)(()=>k?.toolMeta?ne(k.toolMeta):null,[k?.toolMeta]),z=(0,Z.useMemo)(()=>L===`mcp-apps`&&!!R,[L,R]),B=(0,Z.useMemo)(()=>k?.result?.content||[],[k]),V=(0,Z.useMemo)(()=>R||null,[R]),H=(0,Z.useMemo)(()=>!!(B&&B.length>0||k?.result?.structuredContent),[B,k]),U=(0,Z.useMemo)(()=>!z&&H,[z,H]),W=(0,Z.useMemo)(()=>{let e=[];return z&&R&&e.push({mode:`mcp-apps`,label:`Component (MCP Apps)`}),e.push({mode:`json`,label:`Raw JSON`}),e},[z,R]);return(0,Z.useEffect)(()=>{if(W.length===0)return;let e=m&&W.some(e=>e.mode===m),t=W.find(e=>e.mode!==`json`);if(t){let n=E.current;if(E.current=!0,!m||!e||m===`json`&&!n){h(t.mode);return}}else (!m||!e)&&h(`json`)},[W,m]),(0,Z.useEffect)(()=>{c&&(e.length===0||m!==`mcp-apps`||g!==`inline`||!z)&&c(null)},[c,e.length,m,g,z]),e.length===0?(0,Q.jsx)(`div`,{className:`flex flex-col h-full bg-white dark:bg-black`,children:(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Q.jsx)(`div`,{className:`text-center`,children:(0,Q.jsx)(ae,{vertical:!0,noBorder:!0,message:`No Results yet`})})})})}):(0,Q.jsxs)(`div`,{className:`relative flex flex-col h-full bg-white dark:bg-black`,children:[(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,Q.jsxs)(`div`,{className:`space-y-0 flex flex-col flex-1 h-full`,children:[(0,Q.jsxs)(`div`,{className:`sticky top-0 z-40 flex items-center gap-2 px-4 pt-2 backdrop-blur-xs bg-white/50 dark:bg-black/50 ${z||U?`border-b border-gray-200 dark:border-zinc-600 pb-2`:``}`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium hidden sm:block`,children:`Response`}),k.duration!==void 0&&(0,Q.jsxs)(`div`,{className:`hidden sm:flex items-center gap-1`,children:[(0,Q.jsx)(w,{className:`h-3 w-3 text-gray-400`}),(0,Q.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[k.duration,`ms`]})]}),z&&(0,Q.jsx)(`div`,{className:`flex items-center gap-4 sm:ml-4`,children:(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:W.map((e,t)=>(0,Q.jsxs)(Z.Fragment,{children:[t>0&&(0,Q.jsx)(`span`,{className:`text-xs text-zinc-400`,children:`|`}),(0,Q.jsx)(`button`,{"data-testid":`tool-result-view-${e.mode}`,onClick:()=>h(e.mode),className:`text-xs font-medium ${m===e.mode?`text-black dark:text-white`:`text-zinc-500 dark:text-zinc-400`}`,children:e.label})]},e.mode))})}),U&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 sm:ml-4`,children:[(0,Q.jsx)(`button`,{onClick:()=>f(!0),className:`text-xs font-medium ${d?`text-black dark:text-white`:`text-zinc-500 dark:text-zinc-400`}`,children:`Formatted`}),(0,Q.jsx)(`span`,{className:`text-xs text-zinc-400`,children:`|`}),(0,Q.jsx)(`button`,{onClick:()=>f(!1),className:`text-xs font-medium ${d?`text-zinc-500 dark:text-zinc-400`:`text-black dark:text-white`}`,children:`Raw`})]}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[o&&s&&(0,Q.jsxs)(p,{"data-testid":`tool-result-rerun`,variant:`ghost`,size:`sm`,onClick:s,title:`Re-run with same arguments`,children:[(0,Q.jsx)(me,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline ml-1`,children:`Re-run`})]}),z&&a&&(0,Q.jsx)(p,{"data-testid":`tool-result-maximize`,variant:`ghost`,size:`sm`,onClick:a,title:o?`Restore`:`Maximize`,children:o?(0,Q.jsx)(M,{className:`h-4 w-4`}):(0,Q.jsx)(j,{className:`h-4 w-4`})}),O.length>1&&(0,Q.jsxs)(b,{value:l.toString(),onValueChange:e=>u(parseInt(e)),children:[(0,Q.jsx)(_,{className:`w-[140px] h-8 text-xs`,leading:(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(Y,{className:`h-3 w-3`}),(0,Q.jsx)(Re,{timestamp:k.timestamp})]})}),(0,Q.jsx)(v,{children:O.map((e,t)=>(0,Q.jsx)(y,{value:t.toString(),children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Y,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:ze(e.timestamp)}),(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,new Date(e.timestamp).toLocaleTimeString(),`)`]})]})},t))})]}),(0,Q.jsx)(p,{"data-testid":`tool-result-copy-${A}`,variant:`ghost`,size:`sm`,onClick:()=>i(A,ee),children:t===A?(0,Q.jsx)(G,{className:`h-4 w-4`}):(0,Q.jsx)(ge,{className:`h-4 w-4`})})]})]}),(()=>{let e=k.error||Be(k.result);return e?(0,Q.jsxs)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4`,children:[(0,Q.jsx)(`p`,{className:`text-red-800 dark:text-red-300 font-medium`,children:`Error:`}),(0,Q.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-sm`,children:e})]}):(()=>{if(!m)return(0,Q.jsx)(`div`,{className:`flex items-center justify-center w-full h-[200px]`,children:(0,Q.jsx)(F,{className:`size-5`})});switch(m){case`mcp-apps`:return!z||!R?(0,Q.jsx)(`div`,{className:`px-4 pt-4`,children:(0,Q.jsx)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:`MCP Apps resource not available`})})}):(0,Q.jsxs)(be,{className:`relative flex flex-1 w-full min-h-[240px] items-stretch`,children:[(0,Q.jsx)(`div`,{className:`absolute top-2 right-2 z-30 flex items-center gap-2`,children:(0,Q.jsx)(S,{toolCallId:`tool-${k.timestamp}`,displayMode:g,onDisplayModeChange:x,propsContext:`tool`,resourceUri:R,toolInput:k.args,resourceAnnotations:k.toolMeta,llmConfig:null,resource:null,onPropsChange:T})}),(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col pt-11`,children:(0,Q.jsx)(xe,{serverId:n,viewId:`tool-${k.timestamp}`,toolName:k.toolName,toolInput:N,toolOutput:P,toolMetadata:k.toolMeta,resourceUri:R,readResource:te,customProps:C||void 0,displayMode:g,onDisplayModeChange:x,onSendFollowUp:I,onWidgetHeightChange:c?e=>c(e):void 0,noWrapper:!0},`mcp-apps-${k.timestamp}`)})]});case`json`:if(U&&d){let e=k.result?.structuredContent;return(0,Q.jsxs)(`div`,{className:`px-4 pt-4 space-y-4`,"data-testid":`tool-execution-results-content`,children:[e&&(0,Q.jsxs)(`div`,{className:`space-y-2`,"data-testid":`tool-execution-results-structured-content`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Structured Content`}),(0,Q.jsx)(J,{data:e,filename:`structured-content-${k.toolName}-${Date.now()}.json`})]}),B&&B.length>0&&(0,Q.jsx)(Ve,{content:B}),!e&&(!B||B.length===0)&&(0,Q.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,"data-testid":`tool-execution-results-no-content`,children:`No content to display`})]})}return(0,Q.jsx)(`div`,{className:`px-4 pt-4`,children:(0,Q.jsx)(J,{data:k.result,filename:`tool-result-${k.toolName}-${Date.now()}.json`})});default:return null}})()})()]})}),V&&m===`mcp-apps`&&(0,Q.jsx)(`div`,{className:`absolute bottom-0 left-1/2 -translate-x-1/2 z-40 pointer-events-none`,children:(0,Q.jsx)(`span`,{className:`text-[11px] bg-gray-200 dark:bg-zinc-800 text-gray-500 dark:text-gray-400 px-3 py-0.5 rounded-t-xl font-mono max-w-[320px] truncate block`,children:V})})]})}function Ue({tools:e,selectedTool:t,onToolSelect:r,focusedIndex:s}){if(e.length===0)return(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-4 text-center`,children:[(0,Q.jsx)(le,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,Q.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No tools available`})]});let c=e.some(e=>e.inputSchema?.properties&&Object.keys(e.inputSchema.properties).length>0);return(0,Q.jsx)(`div`,{children:e.map((e,l)=>{let u=e._meta,d=K(u)?`mcp-apps`:null,f=e.inputSchema?.properties,p=f?Object.keys(f).length:0,m=c&&p>0&&(0,Q.jsxs)(o,{variant:`outline`,className:`text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400`,children:[p,` params`]}),h=d===`mcp-apps`||m?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[d===`mcp-apps`&&(0,Q.jsxs)(i,{children:[(0,Q.jsx)(n,{render:(0,Q.jsx)(`span`,{className:`inline-flex`,children:(0,Q.jsx)(de,{className:`h-3.5 w-3.5`})}),nativeButton:!1}),(0,Q.jsx)(a,{children:(0,Q.jsx)(`p`,{children:`UI widget`})})]}),m]}):void 0;return(0,Q.jsx)(A,{id:`tool-${e.name}`,"data-testid":`tool-item-${e.name}`,isSelected:t?.name===e.name,isFocused:s===l,title:e.name,description:e.description,metadata:h,onClick:()=>r(e)},e.name)})})}function We(e){return L(e,`alert-dialog`)}function Ge({...e}){return(0,Q.jsx)(We,{"data-slot":`alert-dialog`,...e})}function Ke({...e}){return(0,Q.jsx)(ce,{"data-slot":`alert-dialog-portal`,...e})}function qe({className:e,...t}){return(0,Q.jsx)(P,{"data-slot":`alert-dialog-overlay`,className:u(`fixed inset-0 isolate z-50 bg-black/50 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function Je({className:e,size:t=`default`,...n}){return(0,Q.jsxs)(Ke,{children:[(0,Q.jsx)(qe,{}),(0,Q.jsx)(oe,{"data-slot":`alert-dialog-content`,"data-size":t,className:u(`group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-popover p-6 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...n})]})}function Ye({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:u(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function Xe({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:u(`flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function Ze({className:e,...t}){return(0,Q.jsx)(pe,{"data-slot":`alert-dialog-title`,className:u(`text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function Qe({className:e,...t}){return(0,Q.jsx)(q,{"data-slot":`alert-dialog-description`,className:u(`text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}function $e({className:e,...t}){return(0,Q.jsx)(p,{"data-slot":`alert-dialog-action`,className:u(e),...t})}function et({className:e,variant:t=`outline`,size:n=`default`,...r}){return(0,Q.jsx)(V,{"data-slot":`alert-dialog-cancel`,className:u(e),render:(0,Q.jsx)(p,{variant:t,size:n}),...r})}function tt({selectedTool:e,payloadToSend:t,toolArgs:n,callTool:r,readResource:i,serverId:a}){let[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),m=(0,Z.useCallback)(async()=>{if(!e||c)return;let o=new AbortController;p(o),l(!0);let u=Date.now();try{let c=t,l=e?._meta||e?.metadata,d=l?.ui?.resourceUri;if(d&&typeof d==`string`){try{await i(d)}catch{}s([{toolName:e.name,args:c,result:null,timestamp:u,duration:0,toolMeta:l}])}let f=await r(e.name,c,{timeout:6e5,resetTimeoutOnProgress:!0,signal:o.signal}),p=Date.now()-u,m=f?._meta??l;z(new W({toolName:e.name,serverId:a,success:!0,duration:p})).catch(()=>{}),window.dispatchEvent(new Event(`mcp-tool-executed`)),s(d&&typeof d==`string`?e=>e.map((e,t)=>t===0?{...e,result:f,duration:p,toolMeta:m}:e):t=>[{toolName:e.name,args:n,result:f,timestamp:u,duration:p,toolMeta:m},...t])}catch(t){let r=Date.now()-u;z(new W({toolName:e.name,serverId:a,success:!1,duration:r,error:t instanceof Error?t.message:String(t)})).catch(()=>{}),window.dispatchEvent(new Event(`mcp-tool-executed`));let i=e?._meta||e?.metadata,o={toolName:e.name,args:n,result:null,error:t instanceof Error?t.message:String(t),timestamp:u,duration:r,toolMeta:i};i?.ui?.resourceUri?s([o]):s(e=>[o,...e])}finally{l(!1)}},[e,t,n,c,r,i,a]),h=(0,Z.useCallback)(async(e,t)=>{try{await ue(t),d(e),setTimeout(()=>d(null),2e3)}catch(e){console.error(`[ToolsTab] Failed to copy result:`,e)}},[]),g=(0,Z.useCallback)(e=>{s(t=>t.filter((t,n)=>n!==e))},[]),_=(0,Z.useMemo)(()=>e?o.filter(t=>t.toolName===e.name):[],[o,e]);return{results:o,setResults:s,isExecuting:c,copiedResult:u,executeTool:m,handleCopyResult:h,handleDeleteResult:g,handleFullscreen:(0,Z.useCallback)(e=>{let t=_[e];if(!t)return;let n=window.open(``,`_blank`,`width=800,height=600`);n&&(n.document.write(`
|
|
4
|
+
<html>
|
|
5
|
+
<head><title>${t.toolName} Result</title></head>
|
|
6
|
+
<body><pre>${JSON.stringify(t.result,null,2)}</pre></body>
|
|
7
|
+
</html>
|
|
8
|
+
`),n.document.close())},[_]),filteredResults:_,cancelExecution:(0,Z.useCallback)(()=>{f?.abort(),p(null),l(!1)},[f])}}function nt({ref:e,activeTab:t,filteredTools:n,savedRequests:r,searchQuery:i,setSearchQuery:a,selectedTool:o,results:s,isExecuting:c,handleToolSelect:l,loadSavedRequest:u,refreshTools:d,selectedToolName:f,tools:p,setSelectedToolName:m}){let[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(-1),y=(0,Z.useRef)(null),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(`list`),[w,T]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let e=()=>x(window.innerWidth<1024);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,Z.useEffect)(()=>{C(o?`detail`:`list`)},[o]),(0,Z.useEffect)(()=>{if(!b||s.length===0)return;let e=s[0];(!c||e?.result===null)&&C(`response`)},[s,c,b]),(0,Z.useImperativeHandle)(e,()=>({focusSearch:()=>{g(!0),setTimeout(()=>y.current?.focus(),0)},blurSearch:()=>{a(``),g(!1),y.current?.blur()}})),(0,Z.useEffect)(()=>{h&&y.current?.focus()},[h]);let E=(0,Z.useCallback)(()=>{i.trim()||g(!1)},[i]),D=(0,Z.useCallback)(async()=>{if(d){T(!0);try{await d()}finally{T(!1)}}},[d]);return(0,Z.useEffect)(()=>{t!==`tools`&&g(!1)},[t]),(0,Z.useEffect)(()=>{v(-1)},[i,t]),(0,Z.useEffect)(()=>{let e=e=>{let i=e.target;if(i.tagName===`INPUT`||i.tagName===`TEXTAREA`||i.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let a=t===`tools`?n:r;if(e.key===`ArrowDown`)e.preventDefault(),v(e=>e+1>=a.length?0:e+1);else if(e.key===`ArrowUp`)e.preventDefault(),v(e=>e-1<0?a.length-1:e-1);else if(e.key===`Enter`&&_>=0)if(e.preventDefault(),t===`tools`){let e=n[_];e&&l(e)}else{let e=r[_];e&&u(e)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[_,n,r,t,l,u]),(0,Z.useEffect)(()=>{if(_>=0){let e=t===`tools`?`tool-${n[_]?.name}`:`saved-${r[_]?.id}`;document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[_,n,r,t]),(0,Z.useEffect)(()=>{if(!f||p.length===0)return;let e=p.find(e=>e.name===f);if(e){m(null);let t=setTimeout(()=>{l(e),document.getElementById(`tool-${e.name}`)?.scrollIntoView({behavior:`smooth`,block:`nearest`})},100);return()=>clearTimeout(t)}},[f,p,l,m]),{isSearchExpanded:h,setIsSearchExpanded:g,focusedIndex:_,searchInputRef:y,isMobile:b,mobileView:S,setMobileView:C,isRefreshing:w,handleSearchBlur:E,handleRefresh:D}}var rt=200,it=140;function at({ref:e,tools:t,callTool:n,readResource:i,serverId:a,isConnected:o,refreshTools:s}){let[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),{selectedToolName:f,setSelectedToolName:m}=B(),[g,_]=(0,Z.useState)({}),[v,y]=(0,Z.useState)(new Set),[b,S]=(0,Z.useState)(new Set),[w,T]=(0,Z.useState)(``),[A,j]=(0,Z.useState)(`tools`),{savedRequests:M,saveSavedRequests:N}=R(),[P,te]=(0,Z.useState)(!1),[ne,F]=(0,Z.useState)(``),[I,L]=(0,Z.useState)(!1),[V,H]=(0,Z.useState)({open:!1,parsedObject:{},fieldsToUpdate:[],newFields:[],resolve:null}),[U,W]=(0,Z.useState)(new Set),G=ee(),K=ee(),re=ee(),ie=(0,Z.useRef)(null),ae=(0,Z.useRef)(!1),oe=(0,Z.useRef)(!1),se=(0,Z.useRef)(!0),ce=(0,Z.useCallback)(()=>{I?(G.current&&G.current.expand(),K.current&&K.current.expand(),L(!1)):(G.current&&G.current.collapse(),K.current&&K.current.collapse(),L(!0))},[I,G,K]),q=(0,Z.useMemo)(()=>{if(!w.trim())return t;let e=w.toLowerCase();return t.filter(t=>t.name.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))},[t,w]),J=(0,Z.useCallback)(e=>{l(e);let t={},n=new Set;e.inputSchema?.properties&&Object.entries(e.inputSchema.properties).forEach(([e,r])=>{let i=r;i.default!==void 0&&(t[e]=i.default,n.add(e))}),_(t),y(n),S(new Set)},[]),ue=(0,Z.useCallback)(e=>{let n=t.find(t=>t.name===e.toolName);n&&(l(n),_(e.args),y(new Set(Object.keys(e.args))),S(new Set),d(e))},[t]);(0,Z.useEffect)(()=>{if(c){let e=t.find(e=>e.name===c.name);e?e!==c&&(JSON.stringify(e.inputSchema)!==JSON.stringify(c.inputSchema)||e.description!==c.description||JSON.stringify(e?._meta)!==JSON.stringify(c?._meta))&&l(e):(l(null),m(null))}},[t,c,m]);let Y=(0,Z.useCallback)((e,t)=>{let n=c?.inputSchema||{},r=c?.inputSchema?.properties?.[e],i=r?ke(r,n):`string`,a;a=i===`object`||i===`array`||i===`string`?t:Me(t,i),_(t=>({...t,[e]:a}));let o=String(t).trim()===``;y(t=>{let n=new Set(t);return o?n.delete(e):n.add(e),n}),S(t=>{let n=new Set(t);return n.delete(e),n})},[c]),de=(0,Z.useCallback)((e,t,n)=>{if(n){let n=t===`array`?`[]`:t===`object`?`{}`:``;_(t=>({...t,[e]:n})),y(t=>new Set(t).add(e)),S(t=>new Set(t).add(e))}else S(t=>{let n=new Set(t);return n.delete(e),n}),y(t=>{let n=new Set(t);return n.delete(e),n})},[]),fe=(0,Z.useCallback)(async(e,t)=>{if(!c)return!1;let n=Fe(e);if(!n)return!1;let r=c.inputSchema?.properties||{},i=Object.keys(r),a=c.inputSchema||{},o=[],s=[];return Object.entries(n).forEach(([e,t])=>{if(i.includes(e)){let n=r[e],i=ke(n,a),c=t;i===`object`||i===`array`?typeof t==`object`&&t?c=JSON.stringify(t,null,2):typeof t==`string`&&(c=t):c=typeof t==`object`&&t?JSON.stringify(t):String(t);let l=g[e];l!=null&&l!==``?o.push({key:e,oldValue:l,newValue:c}):(s.push(e),Y(e,String(c)))}}),o.length===0&&s.length===0?!1:o.length===0?(W(new Set(s)),setTimeout(()=>W(new Set),2e3),!0):new Promise(e=>{H({open:!0,parsedObject:n,fieldsToUpdate:o,newFields:s,resolve:e})})},[c,g,Y]),pe=(0,Z.useCallback)(()=>{if(!V.resolve)return;V.fieldsToUpdate.forEach(({key:e,newValue:t})=>{Y(e,String(t))});let e=[...V.fieldsToUpdate.map(e=>e.key),...V.newFields];W(new Set(e)),setTimeout(()=>W(new Set),2e3),V.resolve(!0),H({open:!1,parsedObject:{},fieldsToUpdate:[],newFields:[],resolve:null})},[V,Y]),me=(0,Z.useCallback)(()=>{V.resolve&&(V.resolve(!1),H({open:!1,parsedObject:{},fieldsToUpdate:[],newFields:[],resolve:null}))},[V]),X=(0,Z.useMemo)(()=>{if(!c?.inputSchema?.properties)return{};let e=c.inputSchema||{},t={};for(let n of v){let r=c.inputSchema.properties[n];if(!r)continue;let i=ke(r,e);t[n]=Ne(b.has(n)?i===`array`?`[]`:i===`object`?`{}`:``:g[n],i)}return t},[c,g,v,b]),{isExecuting:he,copiedResult:ge,executeTool:_e,handleCopyResult:ye,handleDeleteResult:be,handleFullscreen:xe,filteredResults:Ce,cancelExecution:Ee,results:De}=tt({selectedTool:c,payloadToSend:X,toolArgs:g,callTool:n,readResource:i,serverId:a}),Oe=Ce[0]?.timestamp;(0,Z.useEffect)(()=>{ae.current=!1,se.current=!0;let e=requestAnimationFrame(()=>{se.current=!1});return()=>cancelAnimationFrame(e)},[Oe]);let Ae=(0,Z.useCallback)(()=>{oe.current||se.current||(ae.current=!0)},[]),je=(0,Z.useCallback)(e=>{if(e===null||I||ae.current)return;let t=re.current,n=ie.current;if(!t||!n)return;let r=n.offsetHeight;if(r<=0)return;let i=t.getSize().inPixels,a=e+it,o=r-rt;if(a<=i||o<=i)return;let s=Math.min(a,o);s<=i||(oe.current=!0,t.resize(s),requestAnimationFrame(()=>{oe.current=!1}))},[I,re]),{isSearchExpanded:Pe,setIsSearchExpanded:Ie,focusedIndex:Re,searchInputRef:ze,isMobile:Be,mobileView:$,setMobileView:Ve,isRefreshing:We,handleSearchBlur:Ke,handleRefresh:qe}=nt({ref:e,activeTab:A,filteredTools:q,savedRequests:M,searchQuery:w,setSearchQuery:T,selectedTool:c,results:De,isExecuting:he,handleToolSelect:J,loadSavedRequest:ue,refreshTools:s,selectedToolName:f,tools:t,setSelectedToolName:m}),at=(0,Z.useCallback)(()=>{c&&(F(``),te(!0))},[c]),ot=(0,Z.useCallback)(()=>{if(!c)return;let e={id:`${Date.now()}-${Math.random()}`,name:ne.trim()||`${c.name} - ${new Date().toLocaleString()}`,toolName:c.name,args:X,savedAt:Date.now(),serverId:c._serverId,serverName:c._serverName};N([...M,e]),z(new ve({toolName:c.name,serverId:a})).catch(()=>{}),te(!1),F(``)},[c,ne,X,M,N,a]),st=(0,Z.useCallback)(e=>{N(M.filter(t=>t.id!==e)),u?.id===e&&d(null)},[M,N,u]);return Be?(0,Q.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden relative bg-background`,children:[$!==`list`&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10`,children:[(0,Q.jsx)(p,{variant:`ghost`,size:`sm`,onClick:()=>{$===`response`?Ve(`detail`):(l(null),Ve(`list`))},className:`p-0 h-8 w-8`,children:(0,Q.jsx)(C,{className:`h-4 w-4`})}),(0,Q.jsxs)(`div`,{className:`flex items-center text-sm font-medium`,children:[(0,Q.jsx)(`button`,{onClick:()=>{l(null),Ve(`list`)},className:`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`,children:`Tools`}),$===`detail`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,Q.jsx)(`button`,{onClick:()=>{Ve(`response`)},className:$===`detail`?`text-foreground hover:underline`:$===`response`?`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`:`text-muted-foreground`,children:`Execute`})]}),$===`response`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,Q.jsx)(`span`,{className:`text-foreground`,children:`Response`})]})]})]}),(0,Q.jsx)(`div`,{className:`flex-1 relative overflow-hidden`,children:(0,Q.jsxs)(h,{initial:!1,mode:`popLayout`,children:[$===`list`&&(0,Q.jsx)(r.div,{initial:{x:`-100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 flex flex-col bg-background z-0`,children:(0,Q.jsx)(O,{children:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Se,{isScrolled:e,activeTab:A,isSearchExpanded:Pe,searchQuery:w,primaryTabName:`tools`,secondaryTabName:`saved`,primaryTabTitle:`Tools`,secondaryTabTitle:`Saved`,primaryCount:q.length,secondaryCount:M.length,primaryIcon:le,secondaryIcon:x,searchPlaceholder:`Search tools...`,onSearchExpand:()=>Ie(!0),onSearchChange:T,onSearchBlur:Ke,onTabSwitch:()=>j(A===`tools`?`saved`:`tools`),searchInputRef:ze,onRefresh:s?qe:void 0,isRefreshing:We}),A===`tools`?(0,Q.jsx)(Ue,{tools:q,selectedTool:c,onToolSelect:J,focusedIndex:Re}):(0,Q.jsx)(we,{savedRequests:M,selectedRequest:u,onLoadRequest:ue,onDeleteRequest:st,focusedIndex:Re})]})})},`list`),$===`detail`&&(0,Q.jsx)(r.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-background z-10`,children:(0,Q.jsx)(Le,{selectedTool:c,toolArgs:g,payloadToSend:X,isExecuting:he,isConnected:o,onArgChange:Y,onExecute:_e,onSave:at,onBulkPaste:fe,autoFilledFields:U,setFields:v,sendEmptyFields:b,onToggleEmpty:de})},`detail`),$===`response`&&(0,Q.jsx)(r.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-background z-20`,children:(0,Q.jsx)(He,{results:Ce,copiedResult:ge,serverId:a,readResource:i,onCopy:ye,onDelete:be,onFullscreen:xe,onRerunTool:_e})},`response`)]})}),(0,Q.jsx)(Te,{isOpen:P,requestName:ne,defaultPlaceholder:`${c?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:F,onSave:ot,onCancel:()=>te(!1)}),(0,Q.jsx)(Ge,{open:V.open,onOpenChange:e=>{e||me()},children:(0,Q.jsxs)(Je,{children:[(0,Q.jsxs)(Ye,{children:[(0,Q.jsx)(Ze,{children:`Auto-fill fields from pasted object?`}),(0,Q.jsxs)(Qe,{children:[V.fieldsToUpdate.length>0&&(0,Q.jsxs)(`div`,{className:`mb-3`,children:[(0,Q.jsx)(`p`,{className:`font-medium mb-2`,children:`The following fields will be updated:`}),(0,Q.jsx)(`ul`,{className:`text-sm space-y-1 max-h-[200px] overflow-y-auto`,children:V.fieldsToUpdate.map(({key:e,oldValue:t,newValue:n})=>(0,Q.jsxs)(`li`,{className:`font-mono`,children:[(0,Q.jsxs)(`span`,{className:`font-semibold`,children:[e,`:`]}),` `,(0,Q.jsx)(`span`,{className:`text-red-600 dark:text-red-400 line-through`,children:typeof t==`object`?JSON.stringify(t).substring(0,30)+`...`:String(t).substring(0,30)}),` `,`→`,` `,(0,Q.jsx)(`span`,{className:`text-green-600 dark:text-green-400`,children:typeof n==`string`&&n.length>30?n.substring(0,30)+`...`:String(n).substring(0,30)})]},e))})]}),V.newFields.length>0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium mb-1`,children:`New fields to be filled:`}),(0,Q.jsx)(`p`,{className:`text-sm font-mono`,children:V.newFields.join(`, `)})]})]})]}),(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(et,{onClick:me,children:`Cancel`}),(0,Q.jsx)($e,{onClick:pe,children:`Auto-fill`})]})]})})]}):(0,Q.jsxs)(k,{orientation:`horizontal`,className:`h-full`,children:[(0,Q.jsx)(E,{id:`left-panel`,defaultSize:`33%`,minSize:250,collapsedSize:0,collapsible:!0,className:`flex flex-col h-full relative`,panelRef:G,children:(0,Q.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden`,children:(0,Q.jsx)(O,{children:e=>(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Se,{isScrolled:e,activeTab:A,isSearchExpanded:Pe,searchQuery:w,primaryTabName:`tools`,secondaryTabName:`saved`,primaryTabTitle:`Tools`,secondaryTabTitle:`Saved`,primaryCount:q.length,secondaryCount:M.length,primaryIcon:le,secondaryIcon:x,searchPlaceholder:`Search tools...`,onSearchExpand:()=>Ie(!0),onSearchChange:T,onSearchBlur:Ke,onTabSwitch:()=>j(A===`tools`?`saved`:`tools`),searchInputRef:ze,onRefresh:s?qe:void 0,isRefreshing:We}),A===`tools`?(0,Q.jsx)(Ue,{tools:q,selectedTool:c,onToolSelect:J,focusedIndex:Re}):(0,Q.jsx)(we,{savedRequests:M,selectedRequest:u,onLoadRequest:ue,onDeleteRequest:st,focusedIndex:Re})]})})})}),(0,Q.jsx)(D,{withHandle:!0}),(0,Q.jsx)(E,{defaultSize:`67%`,children:(0,Q.jsxs)(k,{orientation:`vertical`,elementRef:ie,onLayoutChanged:Ae,children:[(0,Q.jsx)(E,{id:`tool-params`,defaultSize:`40%`,minSize:`${rt}px`,collapsible:!0,panelRef:K,children:(0,Q.jsx)(Le,{selectedTool:c,toolArgs:g,payloadToSend:X,isExecuting:he,isConnected:o,onArgChange:Y,onExecute:_e,onSave:at,onCancel:Ee,onBulkPaste:fe,autoFilledFields:U,setFields:v,sendEmptyFields:b,onToggleEmpty:de})}),(0,Q.jsx)(D,{withHandle:!0}),(0,Q.jsx)(E,{id:`tool-result`,defaultSize:`60%`,panelRef:re,children:(0,Q.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,Q.jsx)(He,{results:Ce,copiedResult:ge,serverId:a,readResource:i,onCopy:ye,onDelete:be,onFullscreen:xe,onMaximize:ce,isMaximized:I,onRerunTool:_e,onWidgetHeightChange:je})})})]})}),(0,Q.jsx)(Te,{isOpen:P,requestName:ne,defaultPlaceholder:`${c?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:F,onSave:ot,onCancel:()=>te(!1)}),(0,Q.jsx)(Ge,{open:V.open,onOpenChange:e=>{e||me()},children:(0,Q.jsxs)(Je,{children:[(0,Q.jsxs)(Ye,{children:[(0,Q.jsx)(Ze,{children:`Auto-fill fields from pasted object?`}),(0,Q.jsxs)(Qe,{children:[V.fieldsToUpdate.length>0&&(0,Q.jsxs)(`div`,{className:`mb-3`,children:[(0,Q.jsx)(`p`,{className:`font-medium mb-2`,children:`The following fields will be updated:`}),(0,Q.jsx)(`ul`,{className:`text-sm space-y-1 max-h-[200px] overflow-y-auto`,children:V.fieldsToUpdate.map(({key:e,oldValue:t,newValue:n})=>(0,Q.jsxs)(`li`,{className:`font-mono`,children:[(0,Q.jsxs)(`span`,{className:`font-semibold`,children:[e,`:`]}),` `,(0,Q.jsx)(`span`,{className:`text-red-600 dark:text-red-400 line-through`,children:typeof t==`object`?JSON.stringify(t).substring(0,30)+`...`:String(t).substring(0,30)}),` `,`→`,` `,(0,Q.jsx)(`span`,{className:`text-green-600 dark:text-green-400`,children:typeof n==`string`&&n.length>30?n.substring(0,30)+`...`:String(n).substring(0,30)})]},e))})]}),V.newFields.length>0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium mb-1`,children:`New fields to be filled:`}),(0,Q.jsx)(`p`,{className:`text-sm font-mono`,children:V.newFields.join(`, `)})]})]})]}),(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(et,{onClick:me,children:`Cancel`}),(0,Q.jsx)($e,{onClick:pe,children:`Auto-fill`})]})]})})]})}at.displayName=`ToolsTab`;export{at as ToolsTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as e,t}from"./react-CU_d2d5K.js";import{
|
|
1
|
+
import{s as e,t}from"./react-CU_d2d5K.js";import{n}from"./createLucideIcon-BEHeJH0M.js";import{Dt as r,St as i,ct as a,st as o,vt as s}from"./index-BMaSsizY.js";import{t as c}from"./useViewHostProps-DZqOwiAm.js";var l=e(t(),1),u=n(),d=`preview-default`;function f(e){if(!e)return{};try{let t=atob(e),n=JSON.parse(t);if(n&&typeof n==`object`)return n}catch{}return{}}function p(e,t){let n=`ui://widget/${t}`,r=e.find(e=>e.uri.startsWith(`${n}.`)&&e.uri.endsWith(`.html`));return r?r.uri:e.find(e=>e.name===t)?.uri}function m(){let e=globalThis.__mcpUsePreviewBundle;if(!e||typeof e!=`object`)return;let t=e;if(typeof t.resourceUri==`string`)return t}function h(){(0,l.useEffect)(()=>{let e=document.documentElement,t=document.body,n=e.style.margin,r=t.style.margin,i=t.style.overflow;return e.style.margin=`0`,t.style.margin=`0`,t.style.overflow=`hidden`,()=>{e.style.margin=n,t.style.margin=r,t.style.overflow=i}},[])}function g(e,t){(0,l.useEffect)(()=>{let n=()=>{document.body.dataset.viewError=`runtime_error`};return e&&!t&&(document.body.dataset.viewError=`invalid_payload`),window.addEventListener(`error`,n),window.addEventListener(`unhandledrejection`,n),()=>{window.removeEventListener(`error`,n),window.removeEventListener(`unhandledrejection`,n),delete document.body.dataset.viewError}},[e,t])}function _(e){(0,l.useEffect)(()=>{if(!e)return;let t=!1;return(async()=>{try{await document.fonts.ready}catch{}t||(await new Promise(e=>requestAnimationFrame(()=>e(void 0))),await new Promise(e=>requestAnimationFrame(()=>e(void 0))),!t&&document.body.setAttribute(`data-view-ready`,`true`))})(),()=>{t=!0,document.body.removeAttribute(`data-view-ready`)}},[e])}function v(e,t){(0,l.useEffect)(()=>{if(!e)return;let n=!1,r,i,a=e=>{n||(e&&(document.body.dataset.viewX=String(Math.round(e.left)),document.body.dataset.viewY=String(Math.round(e.top)),document.body.dataset.viewWidth=String(Math.round(e.width)),document.body.dataset.viewHeight=String(Math.round(e.height))),document.body.setAttribute(`data-view-ready`,`true`))};return(async()=>{try{await document.fonts.ready}catch{}if(n||(await new Promise(e=>requestAnimationFrame(()=>e(void 0))),await new Promise(e=>requestAnimationFrame(()=>e(void 0))),n))return;let e=t.current?.querySelector(`iframe`);if(!e){a(null);return}let o=()=>{r&&clearTimeout(r),r=setTimeout(()=>{n||(i?.disconnect(),a(e.getBoundingClientRect()))},250)};i=new ResizeObserver(o),i.observe(e),o()})(),()=>{n=!0,r&&clearTimeout(r),i?.disconnect(),document.body.removeAttribute(`data-view-ready`),delete document.body.dataset.viewX,delete document.body.dataset.viewY,delete document.body.dataset.viewWidth,delete document.body.dataset.viewHeight}},[e,t])}function y({view:e,bundle:t,widthOverride:n}){let[r,a]=(0,l.useState)(!1),o=(0,l.useRef)(null);h(),v(r,o);let s=(0,l.useMemo)(()=>async e=>{if(e===t.resourceUri)return t.resourceContents;throw Error(`Resource ${e} not in screenshot bundle`)},[t]);return(0,u.jsx)(`div`,{ref:o,style:{width:`100vw`,height:`100vh`},children:(0,u.jsx)(i,{viewId:(0,l.useMemo)(()=>`preview-bundle-${e}-${Date.now().toString(36)}`,[e]),toolName:e,toolInput:t.toolInput,toolOutput:t.toolOutput,displayMode:`inline`,inlineMaxWidth:n,chromeless:!0,onReady:()=>a(!0),source:{kind:`live`,connection:{callTool:async()=>{throw Error(`Preview bundle mode has no server connection`)},readResource:s},resourceUri:t.resourceUri},cspMode:`permissive`,hostInfo:{name:`mcp-use-inspector`,version:`11.0.0`},mockOpenAiFileApis:!0})})}function b({view:e}){let[t]=a(),n=(0,l.useMemo)(()=>f(t.get(`props`)),[t]),o=(0,l.useMemo)(()=>t.get(`server`)||`${window.location.origin}${s()||`/`}`,[t]),m=(0,l.useMemo)(()=>{let e=t.get(`headers`);if(e)try{let t=JSON.parse(atob(e));if(t&&typeof t==`object`)return t}catch{}},[t]),{servers:g,addServer:v,storageLoaded:y}=r(),b=g.find(e=>e.id===d);(0,l.useEffect)(()=>{y&&v(d,{url:o,displayName:`Preview`,protocolNegotiation:`auto`,...m?{headers:m}:{}})},[y,o,m,v]);let x=b?.state===`ready`,S=b?.state===`failed`,C=(0,l.useMemo)(()=>{if(x)return p(b.resources,e)},[x,b?.resources,e]),w=(0,l.useMemo)(()=>`preview-${e}-${Date.now().toString(36)}`,[e]),T=(0,l.useMemo)(()=>async e=>{if(!b?.readResource)throw Error(`Server not ready`);return b.readResource(e)},[b]),[E,D]=(0,l.useState)(!1);_(E),h();let O=c({serverId:d,viewId:w,resourceUri:C??``,toolName:e,toolInput:n.toolInput,toolOutput:n.toolOutput,readResource:T,displayMode:`fullscreen`,chromeless:!0,onReady:()=>D(!0)});return S?(0,u.jsxs)(`div`,{style:{padding:16,fontFamily:`monospace`,color:`#b00`},children:[`Failed to connect to MCP server at `,o,`.`]}):!x||!C?x&&!C?(0,u.jsxs)(`div`,{style:{padding:16,fontFamily:`monospace`,color:`#b00`},children:[`View "`,e,`" not found on `,o,`.`]}):(0,u.jsx)(`div`,{style:{width:`100vw`,height:`100vh`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontFamily:`monospace`,color:`var(--muted-foreground, #888)`},children:`Loading…`}):(0,u.jsx)(`div`,{style:{width:`100vw`,height:`100vh`},children:O&&C?(0,u.jsx)(i,{viewId:w,toolName:e,toolInput:n.toolInput,toolOutput:n.toolOutput,displayMode:`fullscreen`,chromeless:!0,...O}):null})}function x(){let e=o(),[t]=a(),n=e.view??``,r=(0,l.useMemo)(()=>m(),[]),i=t.get(`protocol`)===`1`;g(i,r!==void 0);let s=(0,l.useMemo)(()=>{let e=t.get(`width`);if(!e)return;let n=parseInt(e,10);return Number.isFinite(n)&&n>0?n:void 0},[t]);return r?(0,u.jsx)(y,{view:n,bundle:r,widthOverride:s}):i?null:(0,u.jsx)(b,{view:n})}export{x as ViewPreview};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./createLucideIcon-BEHeJH0M.js";import{H as t}from"./button-C8Xa2k4x.js";var n=e();function r({children:e,className:r,noWrapper:i}){return i?e:(0,n.jsx)(`div`,{className:t(`flex flex-1 items-center justify-center bg-zinc-50 dark:bg-zinc-800`,`[background-image:radial-gradient(circle,rgba(0,0,0,0.12)_1px,transparent_1px)]`,`dark:[background-image:radial-gradient(circle,rgba(255,255,255,0.1)_1px,transparent_1px)]`,`bg-[length:32px_32px]`,r),children:e})}export{r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./createLucideIcon-
|
|
1
|
+
import{t as e}from"./createLucideIcon-BEHeJH0M.js";var t=e(`brush`,[[`path`,{d:`m11 10 3 3`,key:`fzmg1i`}],[`path`,{d:`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`,key:`p4q2r7`}],[`path`,{d:`M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031`,key:`wy6l02`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e,t}from"./react-CU_d2d5K.js";import{n}from"./createLucideIcon-BEHeJH0M.js";var r=e(t(),1);function i(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=i(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function a(){for(var e,t,n=0,r=``,a=arguments.length;n<a;n++)(e=arguments[n])&&(t=i(e))&&(r&&(r+=` `),r+=t);return r}var o=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,s=a,c=(e,t)=>n=>{if(t?.variants==null)return s(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let s=o(t)||o(a);return r[e][s]}),c=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return s(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...c}[t]):{...i,...c}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},l=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},u=(e,t)=>({classGroupId:e,validator:t}),d=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),f=`-`,p=[],m=`arbitrary..`,h=e=>{let t=v(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return _(e);let n=e.split(f);return g(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?l(i,t):t:i||p}return n[e]||p}}},g=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=g(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(f):e.slice(t).join(f),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},_=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?m+r:void 0})(),v=e=>{let{theme:t,classGroups:n}=e;return y(n,t)},y=(e,t)=>{let n=d();for(let r in e){let i=e[r];b(i,n,r,t)}return n},b=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];x(i,t,n,r)}},x=(e,t,n,r)=>{if(typeof e==`string`){S(e,t,n);return}if(typeof e==`function`){C(e,t,n,r);return}w(e,t,n,r)},S=(e,t,n)=>{let r=e===``?t:T(t,e);r.classGroupId=n},C=(e,t,n,r)=>{if(ee(e)){b(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(u(n,e))},w=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];b(o,T(t,a),n,r)}},T=(e,t)=>{let n=e,r=t.split(f),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=d(),n.nextPart.set(t,i)),n=i}return n},ee=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,te=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},E=`!`,ne=`:`,re=[],D=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),O=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===ne){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(E)?(c=s.slice(0,-1),l=!0):s.startsWith(E)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return D(t,l,c,u)};if(t){let e=t+ne,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):D(re,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},k=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},ie=e=>({cache:te(e.cacheSize),parseClassName:O(e),sortModifiers:k(e),...h(e)}),ae=/\s+/,A=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(ae),c=``;for(let e=s.length-1;e>=0;--e){let t=s[e],{isExternal:l,modifiers:u,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:p}=n(t);if(l){c=t+(c.length>0?` `+c:c);continue}let m=!!p,h=r(m?f.substring(0,p):f);if(!h){if(!m){c=t+(c.length>0?` `+c:c);continue}if(h=r(f),!h){c=t+(c.length>0?` `+c:c);continue}m=!1}let g=u.length===0?``:u.length===1?u[0]:a(u).join(`:`),_=d?g+E:g,v=_+h;if(o.indexOf(v)>-1)continue;o.push(v);let y=i(h,m);for(let e=0;e<y.length;++e){let t=y[e];o.push(_+t)}c=t+(c.length>0?` `+c:c)}return c},oe=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=se(n))&&(i&&(i+=` `),i+=r);return i},se=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=se(e[r]))&&(n&&(n+=` `),n+=t);return n},ce=(e,...t)=>{let n,r,i,a,o=o=>(n=ie(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=A(e,n);return i(e,a),a};return a=o,(...e)=>a(oe(...e))},le=[],j=e=>{let t=t=>t[e]||le;return t.isThemeGetter=!0,t},M=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,N=/^\((?:(\w[\w-]*):)?(.+)\)$/i,P=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ue=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,F=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,de=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,fe=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,I=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,L=e=>P.test(e),R=e=>!!e&&!Number.isNaN(Number(e)),z=e=>!!e&&Number.isInteger(Number(e)),pe=e=>e.endsWith(`%`)&&R(e.slice(0,-1)),B=e=>ue.test(e),me=()=>!0,he=e=>F.test(e)&&!de.test(e),V=()=>!1,ge=e=>fe.test(e),_e=e=>I.test(e),ve=e=>!H(e)&&!W(e),ye=e=>K(e,Pe,V),H=e=>M.test(e),U=e=>K(e,Fe,he),be=e=>K(e,Ie,R),xe=e=>K(e,Re,me),Se=e=>K(e,Le,V),Ce=e=>K(e,Me,V),we=e=>K(e,Ne,_e),Te=e=>K(e,ze,ge),W=e=>N.test(e),G=e=>q(e,Fe),Ee=e=>q(e,Le),De=e=>q(e,Me),Oe=e=>q(e,Pe),ke=e=>q(e,Ne),Ae=e=>q(e,ze,!0),je=e=>q(e,Re,!0),K=(e,t,n)=>{let r=M.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},q=(e,t,n=!1)=>{let r=N.exec(e);return r?r[1]?t(r[1]):n:!1},Me=e=>e===`position`||e===`percentage`,Ne=e=>e===`image`||e===`url`,Pe=e=>e===`length`||e===`size`||e===`bg-size`,Fe=e=>e===`length`,Ie=e=>e===`number`,Le=e=>e===`family-name`,Re=e=>e===`number`||e===`weight`,ze=e=>e===`shadow`,Be=ce(()=>{let e=j(`color`),t=j(`font`),n=j(`text`),r=j(`font-weight`),i=j(`tracking`),a=j(`leading`),o=j(`breakpoint`),s=j(`container`),c=j(`spacing`),l=j(`radius`),u=j(`shadow`),d=j(`inset-shadow`),f=j(`text-shadow`),p=j(`drop-shadow`),m=j(`blur`),h=j(`perspective`),g=j(`aspect`),_=j(`ease`),v=j(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),W,H],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[W,H,c],T=()=>[L,`full`,`auto`,...w()],ee=()=>[z,`none`,`subgrid`,W,H],te=()=>[`auto`,{span:[`full`,z,W,H]},z,W,H],E=()=>[z,`auto`,W,H],ne=()=>[`auto`,`min`,`max`,`fr`,W,H],re=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],D=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],O=()=>[`auto`,...w()],k=()=>[L,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ie=()=>[L,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],ae=()=>[L,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],A=()=>[e,W,H],oe=()=>[...b(),De,Ce,{position:[W,H]}],se=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],ce=()=>[`auto`,`cover`,`contain`,Oe,ye,{size:[W,H]}],le=()=>[pe,G,U],M=()=>[``,`none`,`full`,l,W,H],N=()=>[``,R,G,U],P=()=>[`solid`,`dashed`,`dotted`,`double`],ue=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],F=()=>[R,pe,De,Ce],de=()=>[``,`none`,m,W,H],fe=()=>[`none`,R,W,H],I=()=>[`none`,R,W,H],he=()=>[R,W,H],V=()=>[L,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[B],breakpoint:[B],color:[me],container:[B],"drop-shadow":[B],ease:[`in`,`out`,`in-out`],font:[ve],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[B],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[B],shadow:[B],spacing:[`px`,R],text:[B],"text-shadow":[B],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,L,H,W,g]}],container:[`container`],columns:[{columns:[R,H,W,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[z,`auto`,W,H]}],basis:[{basis:[L,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[R,L,`auto`,`initial`,`none`,H]}],grow:[{grow:[``,R,W,H]}],shrink:[{shrink:[``,R,W,H]}],order:[{order:[z,`first`,`last`,`none`,W,H]}],"grid-cols":[{"grid-cols":ee()}],"col-start-end":[{col:te()}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":ee()}],"row-start-end":[{row:te()}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":ne()}],"auto-rows":[{"auto-rows":ne()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...re(),`normal`]}],"justify-items":[{"justify-items":[...D(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...D()]}],"align-content":[{content:[`normal`,...re()]}],"align-items":[{items:[...D(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...D(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":re()}],"place-items":[{"place-items":[...D(),`baseline`]}],"place-self":[{"place-self":[`auto`,...D()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:O()}],mx:[{mx:O()}],my:[{my:O()}],ms:[{ms:O()}],me:[{me:O()}],mbs:[{mbs:O()}],mbe:[{mbe:O()}],mt:[{mt:O()}],mr:[{mr:O()}],mb:[{mb:O()}],ml:[{ml:O()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:k()}],"inline-size":[{inline:[`auto`,...ie()]}],"min-inline-size":[{"min-inline":[`auto`,...ie()]}],"max-inline-size":[{"max-inline":[`none`,...ie()]}],"block-size":[{block:[`auto`,...ae()]}],"min-block-size":[{"min-block":[`auto`,...ae()]}],"max-block-size":[{"max-block":[`none`,...ae()]}],w:[{w:[s,`screen`,...k()]}],"min-w":[{"min-w":[s,`screen`,`none`,...k()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...k()]}],h:[{h:[`screen`,`lh`,...k()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...k()]}],"max-h":[{"max-h":[`screen`,`lh`,...k()]}],"font-size":[{text:[`base`,n,G,U]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,je,xe]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,pe,H]}],"font-family":[{font:[Ee,Se,t]}],"font-features":[{"font-features":[H]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,W,H]}],"line-clamp":[{"line-clamp":[R,`none`,W,be]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,W,H]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,W,H]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...P(),`wavy`]}],"text-decoration-thickness":[{decoration:[R,`from-font`,`auto`,W,U]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[R,`auto`,W,H]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,W,H]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,W,H]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:oe()}],"bg-repeat":[{bg:se()}],"bg-size":[{bg:ce()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},z,W,H],radial:[``,W,H],conic:[z,W,H]},ke,we]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:le()}],"gradient-via-pos":[{via:le()}],"gradient-to-pos":[{to:le()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],rounded:[{rounded:M()}],"rounded-s":[{"rounded-s":M()}],"rounded-e":[{"rounded-e":M()}],"rounded-t":[{"rounded-t":M()}],"rounded-r":[{"rounded-r":M()}],"rounded-b":[{"rounded-b":M()}],"rounded-l":[{"rounded-l":M()}],"rounded-ss":[{"rounded-ss":M()}],"rounded-se":[{"rounded-se":M()}],"rounded-ee":[{"rounded-ee":M()}],"rounded-es":[{"rounded-es":M()}],"rounded-tl":[{"rounded-tl":M()}],"rounded-tr":[{"rounded-tr":M()}],"rounded-br":[{"rounded-br":M()}],"rounded-bl":[{"rounded-bl":M()}],"border-w":[{border:N()}],"border-w-x":[{"border-x":N()}],"border-w-y":[{"border-y":N()}],"border-w-s":[{"border-s":N()}],"border-w-e":[{"border-e":N()}],"border-w-bs":[{"border-bs":N()}],"border-w-be":[{"border-be":N()}],"border-w-t":[{"border-t":N()}],"border-w-r":[{"border-r":N()}],"border-w-b":[{"border-b":N()}],"border-w-l":[{"border-l":N()}],"divide-x":[{"divide-x":N()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":N()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...P(),`hidden`,`none`]}],"divide-style":[{divide:[...P(),`hidden`,`none`]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-bs":[{"border-bs":A()}],"border-color-be":[{"border-be":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...P(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[R,W,H]}],"outline-w":[{outline:[``,R,G,U]}],"outline-color":[{outline:A()}],shadow:[{shadow:[``,`none`,u,Ae,Te]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":[`none`,d,Ae,Te]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:N()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[R,U]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":N()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":[`none`,f,Ae,Te]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[R,W,H]}],"mix-blend":[{"mix-blend":[...ue(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":ue()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[R]}],"mask-image-linear-from-pos":[{"mask-linear-from":F()}],"mask-image-linear-to-pos":[{"mask-linear-to":F()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":F()}],"mask-image-t-to-pos":[{"mask-t-to":F()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":F()}],"mask-image-r-to-pos":[{"mask-r-to":F()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":F()}],"mask-image-b-to-pos":[{"mask-b-to":F()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":F()}],"mask-image-l-to-pos":[{"mask-l-to":F()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":F()}],"mask-image-x-to-pos":[{"mask-x-to":F()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":F()}],"mask-image-y-to-pos":[{"mask-y-to":F()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[W,H]}],"mask-image-radial-from-pos":[{"mask-radial-from":F()}],"mask-image-radial-to-pos":[{"mask-radial-to":F()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[R]}],"mask-image-conic-from-pos":[{"mask-conic-from":F()}],"mask-image-conic-to-pos":[{"mask-conic-to":F()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:oe()}],"mask-repeat":[{mask:se()}],"mask-size":[{mask:ce()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,W,H]}],filter:[{filter:[``,`none`,W,H]}],blur:[{blur:de()}],brightness:[{brightness:[R,W,H]}],contrast:[{contrast:[R,W,H]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Ae,Te]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:[``,R,W,H]}],"hue-rotate":[{"hue-rotate":[R,W,H]}],invert:[{invert:[``,R,W,H]}],saturate:[{saturate:[R,W,H]}],sepia:[{sepia:[``,R,W,H]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,W,H]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[R,W,H]}],"backdrop-contrast":[{"backdrop-contrast":[R,W,H]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,R,W,H]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[R,W,H]}],"backdrop-invert":[{"backdrop-invert":[``,R,W,H]}],"backdrop-opacity":[{"backdrop-opacity":[R,W,H]}],"backdrop-saturate":[{"backdrop-saturate":[R,W,H]}],"backdrop-sepia":[{"backdrop-sepia":[``,R,W,H]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,W,H]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[R,`initial`,W,H]}],ease:[{ease:[`linear`,`initial`,_,W,H]}],delay:[{delay:[R,W,H]}],animate:[{animate:[`none`,v,W,H]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,W,H]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:fe()}],"rotate-x":[{"rotate-x":fe()}],"rotate-y":[{"rotate-y":fe()}],"rotate-z":[{"rotate-z":fe()}],scale:[{scale:I()}],"scale-x":[{"scale-x":I()}],"scale-y":[{"scale-y":I()}],"scale-z":[{"scale-z":I()}],"scale-3d":[`scale-3d`],skew:[{skew:he()}],"skew-x":[{"skew-x":he()}],"skew-y":[{"skew-y":he()}],transform:[{transform:[W,H,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:V()}],"translate-x":[{"translate-x":V()}],"translate-y":[{"translate-y":V()}],"translate-z":[{"translate-z":V()}],"translate-none":[`translate-none`],accent:[{accent:A()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:A()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,W,H]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,W,H]}],fill:[{fill:[`none`,...A()]}],"stroke-w":[{stroke:[R,G,U,be]}],stroke:[{stroke:[`none`,...A()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function J(...e){return Be(a(e))}var Y=n(),Ve={pill:{item:`rounded-[20px]`,bg:`rounded-[20px]`,focusRing:`rounded-[22px]`,mergedBg:`rounded-2xl`,container:`rounded-3xl`,button:`rounded-[20px]`,input:`rounded-[20px]`,bgRadius:20,mergedRadius:16},rounded:{item:`rounded-lg`,bg:`rounded-lg`,focusRing:`rounded-[10px]`,mergedBg:`rounded-lg`,container:`rounded-xl`,button:`rounded-lg`,input:`rounded-lg`,bgRadius:8,mergedRadius:8}},He=(0,r.createContext)(null);function Ue(){let e=(0,r.useContext)(He);return e?e.classes:Ve.pill}function We({children:e,defaultShape:t=`pill`}){let[n,i]=(0,r.useState)(t),a=(0,r.useRef)(null),o=(0,r.useCallback)(e=>{let t=document.documentElement;t.classList.add(`transitioning`),t.offsetHeight,e(),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>t.classList.remove(`transitioning`),200)},[]),s=(0,r.useCallback)(e=>{o(()=>i(e))},[o]);(0,r.useEffect)(()=>{document.documentElement.style.setProperty(`--shape-input-radius`,`${Ve[n].bgRadius}px`)},[n]);let c=(0,r.useMemo)(()=>({shape:n,setShape:s,classes:Ve[n]}),[n,s]);return(0,Y.jsx)(He.Provider,{value:c,children:e})}function Ge(){return typeof window<`u`}function Ke(e){return Je(e)?(e.nodeName||``).toLowerCase():`#document`}function X(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function qe(e){return((Je(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Je(e){return Ge()?e instanceof Node||e instanceof X(e).Node:!1}function Ye(e){return Ge()?e instanceof Element||e instanceof X(e).Element:!1}function Xe(e){return Ge()?e instanceof HTMLElement||e instanceof X(e).HTMLElement:!1}function Ze(e){return!Ge()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof X(e).ShadowRoot}function Qe(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=ct(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function $e(e){return/^(table|td|th)$/.test(Ke(e))}function et(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var tt=/transform|translate|scale|rotate|perspective|filter/,nt=/paint|layout|strict|content/,Z=e=>!!e&&e!==`none`,rt;function it(e){let t=Ye(e)?ct(e):e;return Z(t.transform)||Z(t.translate)||Z(t.scale)||Z(t.rotate)||Z(t.perspective)||!ot()&&(Z(t.backdropFilter)||Z(t.filter))||tt.test(t.willChange||``)||nt.test(t.contain||``)}function at(e){let t=ut(e);for(;Xe(t)&&!st(t);){if(it(t))return t;if(et(t))return null;t=ut(t)}return null}function ot(){return rt??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),rt}function st(e){return/^(html|body|#document)$/.test(Ke(e))}function ct(e){return X(e).getComputedStyle(e)}function lt(e){return Ye(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ut(e){if(Ke(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Ze(e)&&e.host||qe(e);return Ze(t)?t.host:t}function dt(e){let t=ut(e);return st(t)?(e.ownerDocument||e).body:Xe(t)&&Qe(t)?t:dt(t)}function ft(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=dt(e),i=r===e.ownerDocument?.body,a=X(r);if(i){let e=pt(a);return t.concat(a,a.visualViewport||[],Qe(r)?r:[],e&&n?ft(e):[])}else return t.concat(r,ft(r,[],n))}function pt(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}var mt={...r},ht={};function gt(e,t){let n=r.useRef(ht);return n.current===ht&&(n.current=e(t)),n}var _t=mt.useInsertionEffect,vt=_t&&_t!==mt.useLayoutEffect?_t:e=>e();function yt(e){let t=gt(bt).current;return t.next=e,vt(t.effect),t.trampoline}function bt(){let e={next:void 0,callback:xt,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function xt(){}var St=typeof document<`u`?r.useLayoutEffect:()=>{};function Ct(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}var wt={};function Tt(e,t,n,r,i){if(!n&&!r&&!i&&!e)return Dt(t);let a=Dt(e);return t&&(a=Q(a,t)),n&&(a=Q(a,n)),r&&(a=Q(a,r)),i&&(a=Q(a,i)),a}function Et(e){if(e.length===0)return wt;if(e.length===1)return Dt(e[0]);let t=Dt(e[0]);for(let n=1;n<e.length;n+=1)t=Q(t,e[n]);return t}function Dt(e){return jt(e)?{...Mt(e,wt)}:Ot(e)}function Q(e,t){return jt(t)?Mt(t,e):kt(e,t)}function Ot(e){let t={...e};for(let e in t){let n=t[e];At(e,n)&&(t[e]=Pt(n))}return t}function kt(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Ct(e.style,r);break;case`className`:e[n]=It(e.className,r);break;default:At(n,r)?e[n]=Nt(e[n],r):e[n]=r}}return e}function At(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function jt(e){return typeof e==`function`}function Mt(e,t){return jt(e)?e(t):e??wt}function Nt(e,t){return t?e?(...n)=>{let r=n[0];if(Lt(r)){let i=r;Ft(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:Pt(t):e}function Pt(e){return e&&((...t)=>{let n=t[0];return Lt(n)&&Ft(n),e(...t)})}function Ft(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function It(e,t){return t?e?t+` `+e:t:e}function Lt(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function Rt(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var zt=Rt(`https://base-ui.com/production-error`,`Base UI`),Bt=r.createContext(void 0);function Vt(e=!1){let t=r.useContext(Bt);if(t===void 0&&!e)throw Error(zt(16));return t}function Ht(e){let{focusableWhenDisabled:t,disabled:n,composite:i=!1,tabIndex:a=0,isNativeButton:o}=e,s=i&&t!==!1,c=i&&t===!1;return{props:r.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return i||(e.tabIndex=a,!o&&n&&(e.tabIndex=t?a:-1)),(o&&(t||s)||!o&&n)&&(e[`aria-disabled`]=n),o&&(!t||c)&&(e.disabled=n),e},[i,n,t,s,c,o,a])}}function Ut(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:i=0,native:a=!0,composite:o}=e,s=r.useRef(null),c=Vt(!0),l=o??c!==void 0,{props:u}=Ht({focusableWhenDisabled:n,disabled:t,composite:l,tabIndex:i,isNativeButton:a}),d=r.useCallback(()=>{let e=s.current;Wt(e)&&l&&t&&u.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,u.disabled,l]);return St(d,[d]),{getButtonProps:r.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:i,onKeyDown:o,onPointerDown:s,...c}=e;return Tt({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(Ft(e),o?.(e),e.baseUIHandlerPrevented))return;let r=e.target===e.currentTarget,i=e.currentTarget,s=Wt(i),c=!a&&Gt(i),u=r&&(a?s:!c),d=e.key===`Enter`,f=e.key===` `,p=i.getAttribute(`role`),m=p?.startsWith(`menuitem`)||p===`option`||p===`gridcell`;if(r&&l&&f){if(e.defaultPrevented&&m)return;e.preventDefault(),c||a&&s?(i.click(),e.preventBaseUIHandler()):u&&(n?.(e),e.preventBaseUIHandler());return}u&&(!a&&(f||d)&&e.preventDefault(),!a&&d&&n?.(e))},onKeyUp(e){if(!t){if(Ft(e),i?.(e),e.target===e.currentTarget&&a&&l&&Wt(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!a&&!l&&e.key===` `&&n?.(e)}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},a?{type:`button`}:{role:`button`},u,c)},[t,u,l,a]),buttonRef:yt(e=>{s.current=e,d()})}}function Wt(e){return Xe(e)&&e.tagName===`BUTTON`}function Gt(e){return!!(e?.tagName===`A`&&e?.href)}function Kt(e,t,n,r){let i=gt(Jt).current;return Yt(i,e,t,n,r)&&Zt(i,[e,t,n,r]),i.callback}function qt(e){let t=gt(Jt).current;return Xt(t,e)&&Zt(t,e),t.callback}function Jt(){return{callback:null,cleanup:null,refs:[]}}function Yt(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Xt(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Zt(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n;break;default:}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null;break;default:}}}}}}var Qt=19;function $t(e){return Qt>=e}function en(e){if(!r.isValidElement(e))return null;let t=e,n=t.props;return($t(19)?n?.ref:t.ref)??null}function tn(){}var nn=Object.freeze([]),$=Object.freeze({});function rn(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function an(e,t){return typeof e==`function`?e(t):e}function on(e,t){return typeof e==`function`?e(t):e}function sn(e,t,n={}){let r=t.render,i=cn(t,n);return n.enabled===!1?null:dn(e,r,i,n.state??$)}function cn(e,t={}){let{className:n,style:r,render:i}=e,{state:a=$,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?an(n,a):void 0,d=l?on(r,a):void 0,f=l?rn(a,c):$,p=l&&s?ln(s):void 0,m=l?Ct(f,p)??{}:$;return typeof document<`u`&&(l?Array.isArray(o)?m.ref=qt([m.ref,en(i),...o]):m.ref=Kt(m.ref,en(i),o):Kt(null,null)),l?(u!==void 0&&(m.className=It(m.className,u)),d!==void 0&&(m.style=Ct(m.style,d)),m):$}function ln(e){return Array.isArray(e)?Et(e):Tt(void 0,e)}var un=Symbol.for(`react.lazy`);function dn(e,t,n,i){if(t){if(typeof t==`function`)return t(n,i);let e=Tt(n,t.props);e.ref=n.ref;let a=t;return a?.$$typeof===un&&(a=r.Children.toArray(t)[0]),r.cloneElement(a,e)}if(e&&typeof e==`string`)return fn(e,n);throw Error(zt(8))}function fn(e,t){return e===`button`?(0,r.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,r.createElement)(`img`,{alt:``,...t,key:t.key}):r.createElement(e,t)}var pn=r.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=Ut({disabled:i,focusableWhenDisabled:a,native:o});return sn(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})}),mn=c([`group relative isolate inline-flex items-center justify-center outline-none cursor-pointer`,`[&_svg]:pointer-events-none [&_svg]:shrink-0`,`transition-colors duration-80`,`disabled:opacity-50 disabled:pointer-events-none`,`focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)]`],{variants:{variant:{primary:`text-background`,secondary:`text-foreground`,tertiary:`border border-border text-foreground`,ghost:`text-muted-foreground hover:text-foreground`,destructive:`text-white`},size:{sm:`h-7 px-3 text-[12px] gap-1 [&_svg:not([class*='size-'])]:size-3.5`,md:`h-8 px-4 text-[13px] gap-1.5 [&_svg:not([class*='size-'])]:size-4`,lg:`h-9 px-5 text-[14px] gap-1.5 [&_svg:not([class*='size-'])]:size-4`,"icon-sm":`h-8 w-8 p-0 [&_svg]:h-3.5 [&_svg]:w-3.5`,icon:`h-9 w-9 p-0 [&_svg]:h-4 [&_svg]:w-4`,"icon-lg":`h-10 w-10 p-0 [&_svg]:h-5 [&_svg]:w-5`},iconLeft:{true:``},iconRight:{true:``}},compoundVariants:[{size:`sm`,iconLeft:!0,className:`pl-[6px]`},{size:`md`,iconLeft:!0,className:`pl-[10px]`},{size:`lg`,iconLeft:!0,className:`pl-[14px]`},{size:`sm`,iconRight:!0,className:`pr-[6px]`},{size:`md`,iconRight:!0,className:`pr-[10px]`},{size:`lg`,iconRight:!0,className:`pr-[14px]`}],defaultVariants:{variant:`primary`,size:`md`}}),hn={primary:`bg-foreground group-hover:bg-foreground/90 group-active:bg-foreground/80`,secondary:`bg-accent group-hover:bg-accent/80 group-active:bg-accent`,tertiary:`bg-transparent group-hover:bg-hover group-active:bg-active`,ghost:`bg-transparent group-hover:bg-hover group-active:bg-active`,destructive:`bg-destructive group-hover:bg-destructive/90 group-active:bg-destructive/80`},gn={primary:`bg-foreground/80`,secondary:`bg-accent`,tertiary:`bg-active`,ghost:`bg-active`,destructive:`bg-destructive/80`},_n={default:`primary`,destructive:`destructive`,outline:`tertiary`,secondary:`secondary`,ghost:`ghost`,link:`ghost`},vn={default:`md`,xs:`sm`,sm:`sm`,lg:`lg`,icon:`icon`,"icon-xs":`icon-sm`,"icon-sm":`icon-sm`,"icon-lg":`icon-lg`};function yn(e){return typeof e==`string`||typeof e==`number`}function bn({children:e}){return yn(e)?(0,Y.jsx)(`span`,{className:`[text-box:trim-both_cap_alphabetic]`,children:e}):(0,Y.jsx)(`span`,{className:`inline-flex items-center gap-1`,children:e})}var xn=`sm:h-8 sm:min-h-8 sm:px-4 sm:text-[13px] sm:[&_svg:not([class*='size-'])]:size-4`,Sn=`hidden sm:inline shrink-0 text-[10px] leading-none border border-current/30 p-1 rounded-full`,Cn=J(xn,`pr-1! sm:pr-2!`);function wn({variant:e,size:t,className:n}){let r=e&&e in _n?_n[e]:e;return{variant:r,size:t&&t in vn?vn[t]:t,className:J(r===`ghost`&&(e===`link`?`underline-offset-4 hover:underline`:void 0),n)}}var Tn=(0,r.forwardRef)(({className:e,variant:t,size:n,render:i,nativeButton:a=!0,loading:o=!1,leadingIcon:s,trailingIcon:c,active:l=!1,disabled:u,children:d,style:f,...p},m)=>{let h=wn({variant:t,size:n,className:e});t=h.variant,n=h.size,e=h.className;let g=i&&(0,r.isValidElement)(i)?i:null,_=g&&g.props.children!=null?g.props.children:d,v=n===`icon`||n===`icon-sm`||n===`icon-lg`,y=n===`sm`?14:n===`lg`?20:16,b=n===`sm`?`h-7 w-7`:n===`lg`||n===`icon`?`h-9 w-9`:n===`icon-lg`?`h-10 w-10`:`h-8 w-8`,x=Ue(),S=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:J(`absolute inset-0 rounded-[inherit] transition-[background-color,transform] duration-80 group-active:scale-[0.98]`,l?gn[t??`primary`]:hn[t??`primary`])}),(0,Y.jsx)(`span`,{className:`relative inline-flex items-center justify-center gap-[inherit]`,children:o?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center justify-center gap-[inherit] opacity-0`,children:[s&&!v&&(0,Y.jsx)(s,{size:y,strokeWidth:2}),(0,Y.jsx)(bn,{children:_}),c&&!v&&(0,Y.jsx)(c,{size:y,strokeWidth:2})]}),(0,Y.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,Y.jsx)(`svg`,{className:b,viewBox:`0 0 24 24`,fill:`none`,children:(0,Y.jsx)(`path`,{d:`M 12 12 C 14 8.5 19 8.5 19 12 C 19 15.5 14 15.5 12 12 C 10 8.5 5 8.5 5 12 C 5 15.5 10 15.5 12 12 Z`,stroke:`currentColor`,strokeWidth:`1.125`,strokeLinecap:`round`,pathLength:`100`,style:{strokeDasharray:`15 85`,animation:`spinner-move 2s linear infinite, spinner-dash 4s ease-in-out infinite`}})})})]}):v?(0,Y.jsx)(`span`,{className:`inline-flex items-center justify-center [&_svg]:stroke-[1.5] [&_svg]:transition-[stroke-width] [&_svg]:duration-80 group-hover:[&_svg]:stroke-[2]`,children:_}):s||c?(0,Y.jsxs)(Y.Fragment,{children:[s&&(0,Y.jsx)(s,{size:y,strokeWidth:1.5,className:`transition-[stroke-width] duration-80 group-hover:stroke-[2]`}),(0,Y.jsx)(bn,{children:_}),c&&(0,Y.jsx)(c,{size:y,strokeWidth:1.5,className:`transition-[stroke-width] duration-80 group-hover:stroke-[2]`})]}):(0,Y.jsx)(bn,{children:_})})]}),C=J(mn({variant:t,size:n,iconLeft:!v&&!!s,iconRight:!v&&!!c}),x.button,e);if(g){let e=g.props;return(0,Y.jsx)(pn,{ref:m,render:(0,r.cloneElement)(g,{className:J(C,e.className),style:{...f,...e.style}}),nativeButton:a,disabled:u||o,...p,children:S})}return(0,Y.jsx)(pn,{ref:m,className:C,disabled:u||o,style:f,...p,children:S})});Tn.displayName=`Button`;export{Ye as A,Ve as B,pt as C,ut as D,ft as E,Ze as F,J as H,$e as I,et as L,st as M,Je as N,X as O,Qe as P,ot as R,qe as S,lt as T,c as U,Ue as V,yt as _,sn as a,ct as b,tn as c,Ut as d,Bt as f,St as g,Tt as h,xn as i,Xe as j,it as k,$t as l,zt as m,Cn as n,nn as o,Vt as p,Sn as r,$ as s,Tn as t,Kt as u,gt as v,Ke as w,at as x,mt as y,We as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./createLucideIcon-BEHeJH0M.js";import{H as t}from"./button-C8Xa2k4x.js";import{Sn as n,g as r,h as i}from"./index-BMaSsizY.js";var a=e();function o({className:e,...o}){return(0,a.jsx)(r,{"data-slot":`checkbox`,className:t(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input shadow-xs transition-shadow outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,e),...o,children:(0,a.jsx)(i,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,a.jsx)(n,{})})})}export{o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./createLucideIcon-BEHeJH0M.js";var t=e(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,s as t,t as n}from"./react-CU_d2d5K.js";var r=e((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),i=e(((e,t)=>{t.exports=r()})),a=t(n()),o=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),s=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),c=e=>{let t=s(e);return t.charAt(0).toUpperCase()+t.slice(1)},l=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),u=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0},d={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},f=(0,a.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:o,iconNode:s,...c},f)=>(0,a.createElement)(`svg`,{ref:f,...d,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:l(`lucide`,i),...!o&&!u(c)&&{"aria-hidden":`true`},...c},[...s.map(([e,t])=>(0,a.createElement)(e,t)),...Array.isArray(o)?o:[o]])),p=(e,t)=>{let n=(0,a.forwardRef)(({className:n,...r},i)=>(0,a.createElement)(f,{ref:i,iconNode:t,className:l(`lucide-${o(c(e))}`,`lucide-${e}`,n),...r}));return n.displayName=c(e),n};export{i as n,p as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{At as e,
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BMaSsizY.js","assets/react-CU_d2d5K.js","assets/button-C8Xa2k4x.js","assets/createLucideIcon-BEHeJH0M.js","assets/FormContext-sV-yByKz.js","assets/input-C0OQCUZy.js","assets/select-D6jzbLJn.js","assets/AnimatePresence-FfDQQNFJ.js","assets/label-CI7JWQOo.js","assets/index-D7TVTIt9.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{At as e,Nt as t,jt as n}from"./index-BMaSsizY.js";var r=class{disallowedTools;connectorToolMap=new Map;constructor(e){this.disallowedTools=e??[]}static async createTools(t,n){let r=new this(n);(!t.activeSessions||Object.keys(t.activeSessions).length===0)&&(e.debug(`No active sessions found, creating new ones...`),await t.createAllSessions());let i=t.getAllActiveSessions(),a=Object.values(i).map(e=>e.connector);return r.createToolsFromConnectors(a)}async loadToolsForConnector(t){if(this.connectorToolMap.has(t)){let n=this.connectorToolMap.get(t);return e.debug(`Returning ${n.length} existing tools for connector`),n}let n=[];if(!await this.ensureConnectorInitialized(t))return[];for(let e of t.tools){let r=this.convertTool(e,t);r&&n.push(r)}return this.connectorToolMap.set(t,n),e.debug(`Loaded ${n.length} new tools for connector: ${n.map(e=>e?.name??String(e)).join(`, `)}`),n}async createToolsFromConnectors(t){let n=[];for(let e of t){let t=await this.loadToolsForConnector(e);n.push(...t)}return e.debug(`Available tools: ${n.length}`),n}async loadResourcesForConnector(t){let n=[];if(!await this.ensureConnectorInitialized(t))return[];try{let r=(await t.listAllResources())?.resources||[];if(this.convertResource)for(let e of r){let r=this.convertResource(e,t);r&&n.push(r)}e.debug(`Loaded ${n.length} new resources for connector: ${n.map(e=>e?.name??String(e)).join(`, `)}`)}catch(t){e.warn(`Error loading resources for connector: ${t}`)}return n}async loadPromptsForConnector(t){let n=[];if(!await this.ensureConnectorInitialized(t))return[];try{let r=(await t.listPrompts())?.prompts||[];if(this.convertPrompt)for(let e of r){let r=this.convertPrompt(e,t);r&&n.push(r)}e.debug(`Loaded ${n.length} new prompts for connector: ${n.map(e=>e?.name??String(e)).join(`, `)}`)}catch(t){e.warn(`Error loading prompts for connector: ${t}`)}return n}async createResourcesFromConnectors(t){let n=[];for(let e of t){let t=await this.loadResourcesForConnector(e);n.push(...t)}return e.debug(`Available resources: ${n.length}`),n}async createPromptsFromConnectors(t){let n=[];for(let e of t){let t=await this.loadPromptsForConnector(e);n.push(...t)}return e.debug(`Available prompts: ${n.length}`),n}checkConnectorInitialized(e){return!!(e.tools&&e.tools.length)}async ensureConnectorInitialized(t){if(!this.checkConnectorInitialized(t)){e.debug(`Connector doesn't have tools, initializing it`);try{return await t.initialize(),!0}catch(t){return e.error(`Error initializing connector: ${t}`),!1}}return!0}};function i(e){return e.replace(/[^A-Za-z0-9_]+/g,`_`).toLowerCase().replace(/^_+|_+$/g,``)}var a=class extends r{usedToolNames=new Set;handlers=new Map;constructor(e=[]){super(e)}async createToolsFromConnectors(e){return this.usedToolNames.clear(),this.handlers.clear(),super.createToolsFromConnectors(e)}createCallTool(){let t=this.handlers;return async(n,r)=>{let i=t.get(n);if(!i)throw Error(`Unknown tool: ${n}`);try{if(i.kind===`tool`)return await i.connector.callTool(i.mcpName,r);if(i.kind===`resource`){let e=i.resourceUri??i.mcpName;return await i.connector.readResource(e)}return await i.connector.getPrompt(i.mcpName,r)}catch(t){throw e.error(`Error executing native MCP tool ${n}: ${t}`),t}}}toProviderTools(e){return e.map(({name:e,description:t,inputSchema:n})=>({name:e,description:t,inputSchema:n}))}reserveName(e,t){if(!this.usedToolNames.has(e))return this.usedToolNames.add(e),e;if(t){let n=`${t}_${e}`;if(!this.usedToolNames.has(n))return this.usedToolNames.add(n),n;let r=2;for(;this.usedToolNames.has(`${n}_${r}`);)r++;let i=`${n}_${r}`;return this.usedToolNames.add(i),i}let n=2;for(;this.usedToolNames.has(`${e}_${n}`);)n++;let r=`${e}_${n}`;return this.usedToolNames.add(r),r}register(e,t){return this.handlers.set(e.name,t),e}convertTool(e,t){if(this.disallowedTools.includes(e.name))return null;let n=this.reserveName(e.name??`tool`),r={name:n,dispatchKey:n,description:e.description??``,inputSchema:e.inputSchema??{type:`object`,properties:{}}};return this.register(r,{connector:t,kind:`tool`,mcpName:e.name})}convertResource(e,t){let n=i(e.name||e.uri)||`resource`,r=this.reserveName(n,`resource`),a={name:r,dispatchKey:r,description:e.description||`Return the content of the resource located at URI ${e.uri}.`,inputSchema:{type:`object`,properties:{}}};return this.register(a,{connector:t,kind:`resource`,mcpName:e.uri,resourceUri:e.uri})}convertPrompt(e,t){let n={},r=[];if(e.arguments?.length)for(let t of e.arguments)n[t.name]={type:`string`,description:t.description},t.required!==!1&&r.push(t.name);let a=i(e.name||`prompt`)||`prompt`,o=this.reserveName(a,`prompt`),s={name:o,dispatchKey:o,description:e.description||``,inputSchema:{type:`object`,properties:n,...r.length>0?{required:r}:{}}};return this.register(s,{connector:t,kind:`prompt`,mcpName:e.name})}};function o(e){return{type:`text`,text:e}}function s(e,t){return{type:`image`,url:`data:${t};base64,${e}`,mimeType:t,data:e}}function c(e){if(!e||typeof e!=`object`)return!1;let t=e;return Array.isArray(t.content)?!0:`structuredContent`in t}function l(e){return typeof e==`object`&&!!e&&e.isError===!0}function u(e){if(!e||typeof e!=`object`)return null;switch(e.type){case`text`:{let t=e.text;return typeof t==`string`&&t.length>0?o(t):null}case`image`:{let t=e;if(typeof t.data!=`string`||!t.data)return null;let n=typeof t.mimeType==`string`&&t.mimeType?t.mimeType:`image/png`;return s(t.data,n)}case`audio`:{let t=e;return o(`[audio: ${typeof t.mimeType==`string`&&t.mimeType?t.mimeType:`audio/*`}, base64 omitted (${typeof t.data==`string`?t.data.length:0} chars)]`)}case`resource`:{let t=e.resource??{};return typeof t.text==`string`&&t.text.length>0?o(t.text):typeof t.blob==`string`&&typeof t.mimeType==`string`&&t.mimeType.startsWith(`image/`)?s(t.blob,t.mimeType):o(`[resource: ${typeof t.uri==`string`?t.uri:`<unknown>`} (${typeof t.mimeType==`string`?t.mimeType:`unknown`})]`)}case`resource_link`:{let t=e,n=typeof t.uri==`string`?t.uri:`<unknown>`;return o(`[resource_link${typeof t.name==`string`?` "${t.name}"`:``}: ${n}]`)}default:return o(`[unsupported tool content block: ${String(e.type)}]`)}}function ee(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let{_meta:t,...n}=e;return n}return e}function te(e){let t=ee(e);if(typeof t==`string`)return t.length>0?[o(t)]:[];if(c(t)){let e=t,n=[];if(Array.isArray(e.content))for(let t of e.content){let e=u(t);e&&n.push(e)}if(e.structuredContent!==void 0)try{n.push(o(`structuredContent: ${JSON.stringify(e.structuredContent)}`))}catch{}return e.isError&&n.unshift(o(`[tool reported isError=true]`)),n}try{return[o(JSON.stringify(t))]}catch{return[o(String(t))]}}function ne(e){return e.length===0?``:e.every(e=>e.type===`text`)?e.map(e=>e.text).join(`
|
|
3
3
|
`):null}function d(e){let t=te(e),n=ne(t);return n===null?t:n}function f(e){if(typeof e==`string`)return{text:e,imageParts:[],isString:!0};let t=[],n=[];for(let r of e)r.type===`text`?r.text&&t.push(r.text):r.type===`image`&&n.push(r);return{text:t.join(`
|
|
4
4
|
`),imageParts:n,isString:!1}}function p(e,t){return`(Tool "${e??`<tool>`}" returned the following image${t===1?``:`s`}:)`}function m(e){let t=typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(e=>e?.text??``).join(`
|
|
5
5
|
`):JSON.stringify(e.content??``);return t.trim()?t.trim():e.parts?.length?e.parts.filter(e=>e.type===`text`&&e.text).map(e=>e.text).join(``).trim():``}function re(e){let t=[];return e.forEach((e,n)=>{if(e.role===`user`){let n=m(e)||`[no content]`;if(e.attachments?.length){let r=[{type:`text`,text:n}];for(let t of e.attachments)t.type===`image`&&r.push({type:`image`,url:`data:${t.mimeType};base64,${t.data}`,mimeType:t.mimeType,data:t.data});t.push({role:`user`,content:r})}else t.push({role:`user`,content:n});return}let r=(e.parts??[]).filter(e=>e.type===`tool-invocation`&&e.toolInvocation&&e.toolInvocation.result!==void 0);if(r.length===0){let n=m(e)||`[no content]`;t.push({role:`assistant`,content:n});return}let i=m(e),a=r.map((e,t)=>({id:`call_${n}_${t}_${e.toolInvocation.toolName}`,name:e.toolInvocation.toolName,args:e.toolInvocation.args}));t.push({role:`assistant`,content:i,toolCalls:a}),r.forEach((e,r)=>{let i=e.toolInvocation.result;t.push({role:`tool`,content:d(i),toolCallId:`call_${n}_${r}_${e.toolInvocation.toolName}`,toolName:e.toolInvocation.toolName,toolResult:i,toolIsError:l(i)})})}),t}function ie(e){let t=[],n=[];for(let r of e)if(r.role===`system`){if(typeof r.content==`string`)t.push(r.content);else if(Array.isArray(r.content))for(let e of r.content)e.type===`text`&&t.push(e.text)}else n.push(r);return{system:t.length>0?t.join(`
|
|
@@ -9,13 +9,13 @@ import{At as e,Mt as t,kt as n}from"./index-TQ5V7cM9.js";var r=class{disallowedT
|
|
|
9
9
|
`),n=e.indexOf(`\r
|
|
10
10
|
\r
|
|
11
11
|
`);return t===-1?n:n===-1?t:Math.min(t,n)}function _(e){let t,n=[];for(let r of e.split(/\r?\n/)){if(!r||r.startsWith(`:`))continue;let e=r.indexOf(`:`),i=e===-1?r:r.slice(0,e),a=e===-1?``:r.slice(e+1);a.startsWith(` `)&&(a=a.slice(1)),i===`event`?t=a:i===`data`&&n.push(a)}return n.length===0?null:{event:t,data:n.join(`
|
|
12
|
-
`)}}function v(e,...t){for(let n of t){let t=e[n];if(typeof t==`number`&&Number.isFinite(t))return t}}function y(e){if(!e||typeof e!=`object`)return;let t=e,n=v(t,`inputTokens`,`input_tokens`,`prompt_tokens`,`promptTokenCount`,`prompt_eval_count`),r=v(t,`outputTokens`,`output_tokens`,`completion_tokens`,`candidatesTokenCount`,`eval_count`),i=v(t,`totalTokens`,`total_tokens`,`totalTokenCount`)??(n!==void 0&&r!==void 0?n+r:void 0),a=t.input_tokens_details&&typeof t.input_tokens_details==`object`?t.input_tokens_details:void 0,o=t.output_tokens_details&&typeof t.output_tokens_details==`object`?t.output_tokens_details:void 0,s=v(t,`cachedInputTokens`,`cache_read_input_tokens`)??(a?v(a,`cached_tokens`):void 0),c=v(t,`reasoningTokens`,`thoughtsTokenCount`)??(o?v(o,`reasoning_tokens`):void 0);if(!(n===void 0&&r===void 0&&i===void 0&&s===void 0&&c===void 0))return{inputTokens:n,outputTokens:r,totalTokens:i,cachedInputTokens:s,reasoningTokens:c}}var b=`https://api.anthropic.com/v1/messages`,x=`2023-06-01`,oe=4096;function S(e){if(e.type!==`image`)return null;if(e.data&&e.mimeType)return{type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.data}};let t=h(e.url);return t?{type:`image`,source:{type:`base64`,media_type:t.mimeType,data:t.data}}:{type:`image`,source:{type:`url`,url:e.url}}}function se(e){if(typeof e==`string`)return[{type:`text`,text:e||`[no content]`}];let t=[];for(let n of e)if(n.type===`text`)n.text&&t.push({type:`text`,text:n.text});else{let e=S(n);e&&t.push(e)}return t.length===0&&t.push({type:`text`,text:`[no content]`}),t}function ce(e){if(typeof e==`string`)return e;let t=[];for(let n of e)if(n.type===`text`)n.text&&t.push({type:`text`,text:n.text});else if(n.type===`image`){let e=S(n);e&&t.push(e)}return t.length===0?`[no content]`:t}function le(e){let t=[];for(let n of e){if(n.role===`tool`){let e=t[t.length-1],r={type:`tool_result`,tool_use_id:n.toolCallId,content:ce(n.content),...n.toolIsError?{is_error:!0}:{}};e&&e.role===`user`&&Array.isArray(e.content)?e.content.push(r):t.push({role:`user`,content:[r]});continue}if(n.role===`assistant`){let e=[],r=typeof n.content==`string`?n.content:Array.isArray(n.content)?n.content.map(e=>e.type===`text`?e.text:``).join(``):``;if(r&&e.push({type:`text`,text:r}),n.toolCalls?.length)for(let t of n.toolCalls)e.push({type:`tool_use`,id:t.id,name:t.name,input:t.args??{}});e.length===0&&e.push({type:`text`,text:`[no content]`}),t.push({role:`assistant`,content:e});continue}t.push({role:`user`,content:se(n.content)})}return t}function C(e,t){let{config:n,messages:r,tools:i}=e,{system:a,rest:o}=ie(r),s={model:n.model,max_tokens:n.maxTokens??oe,messages:le(o),...t?{stream:!0}:{}};return n.temperature!==void 0&&(s.temperature=n.temperature),a&&(s.system=a),i&&i.length>0&&(s.tools=i.map(e=>({name:e.name,description:e.description,input_schema:e.inputSchema}))),s}async function*ue(e){let{config:t,signal:n}=e,r=await fetch(b,{method:`POST`,headers:{"Content-Type":`application/json`,"x-api-key":t.apiKey,"anthropic-version":x,"anthropic-dangerous-direct-browser-access":`true`},body:JSON.stringify(C(e,!0)),signal:n});if(!r.ok||!r.body){let e=await r.text().catch(()=>``);throw Error(`Anthropic request failed (${r.status} ${r.statusText}): ${e}`)}let i=new Map,a;for await(let e of g(r.body,n)){let t;try{t=JSON.parse(e.data)}catch{continue}let n=t?.type;if(n===`message_start`)a=y(t?.message?.usage);else if(n===`message_delta`){let e=y(t?.usage);e&&(a={...a,...e})}else if(n===`content_block_start`){let e=t.index,n=t.content_block??{};if(n.type===`tool_use`){i.set(e,{kind:`tool_use`,id:n.id,name:n.name,argsJson:``,emittedStart:!1}),yield{type:`tool-call-start`,index:e,toolCallId:n.id,toolName:n.name};let t=i.get(e);t&&(t.emittedStart=!0)}else i.set(e,{kind:`text`,argsJson:``,emittedStart:!1})}else if(n===`content_block_delta`){let e=t.index,n=t.delta??{},r=i.get(e);if(!r)continue;n.type===`text_delta`&&typeof n.text==`string`?yield{type:`text-delta`,delta:n.text}:n.type===`input_json_delta`&&typeof n.partial_json==`string`&&r.kind===`tool_use`&&(r.argsJson+=n.partial_json,yield{type:`tool-call-args-delta`,index:e,toolCallId:r.id,toolName:r.name,argsDelta:n.partial_json})}else if(n===`content_block_stop`){let e=t.index,n=i.get(e);if(n&&n.kind===`tool_use`&&n.id&&n.name){let t={};if(n.argsJson)try{t=JSON.parse(n.argsJson)}catch{t={}}yield{type:`tool-call-ready`,index:e,toolCallId:n.id,toolName:n.name,args:t}}}else if(n===`message_stop`){if(a){let e=a.totalTokens??(a.inputTokens!==void 0&&a.outputTokens!==void 0?a.inputTokens+a.outputTokens:void 0);yield{type:`usage`,usage:{...a,totalTokens:e}}}}else n===`error`&&(yield{type:`error`,message:t?.error?.message??`Anthropic stream error`})}yield{type:`done`}}async function de(e){let{config:t,signal:n}=e,r=await fetch(b,{method:`POST`,headers:{"Content-Type":`application/json`,"x-api-key":t.apiKey,"anthropic-version":x,"anthropic-dangerous-direct-browser-access":`true`},body:JSON.stringify(C(e,!1)),signal:n});if(!r.ok){let e=await r.text().catch(()=>``);throw Error(`Anthropic request failed (${r.status} ${r.statusText}): ${e}`)}let i=await r.json(),a=``,o=[];for(let e of i?.content??[])e.type===`text`&&typeof e.text==`string`?a+=e.text:e.type===`tool_use`&&o.push({id:e.id,name:e.name,args:e.input&&typeof e.input==`object`?e.input:{}});return{text:a,toolCalls:o}}var fe=new Set([`type`,`description`,`enum`,`properties`,`required`,`items`,`format`,`nullable`,`minimum`,`maximum`,`minItems`,`maxItems`,`minLength`,`maxLength`,`pattern`]);function pe(e){if(!e||typeof e!=`object`)return{type:`object`};let t=w(e);if(typeof t!=`object`||!t)return{type:`object`};let n=t;return n.type||=`object`,n}function w(e){if(Array.isArray(e))return e.map(w);if(!e||typeof e!=`object`)return e;let t=e;for(let e of[`oneOf`,`anyOf`,`allOf`]){let n=t[e];if(Array.isArray(n)&&n.length===1)return w(n[0])}let n={};for(let[e,r]of Object.entries(t))if(fe.has(e))if(e===`properties`&&r&&typeof r==`object`){let t={};for(let[e,n]of Object.entries(r))t[e]=w(n);n[e]=t}else e===`items`?n[e]=w(r):n[e]=r;return n}function me(e){let t=e.trim();return t.startsWith(`models/`)?t.slice(7):t}function he(e,t){let n=t===`stream`?`streamGenerateContent?alt=sse`:`generateContent`;return`https://generativelanguage.googleapis.com/v1beta/models/${encodeURIComponent(me(e))}:${n}`}function ge(e){if(e.type!==`image`)return null;if(e.data&&e.mimeType)return{inlineData:{mimeType:e.mimeType,data:e.data}};let t=h(e.url);return t?{inlineData:{mimeType:t.mimeType,data:t.data}}:null}function _e(e){if(typeof e==`string`)return[{text:e||`[no content]`}];let t=[];for(let n of e)if(n.type===`text`)n.text&&t.push({text:n.text});else{let e=ge(n);e&&t.push(e)}return t.length===0&&t.push({text:`[no content]`}),t}function ve(e){if(typeof e==`string`){let t;try{t=JSON.parse(e)}catch{t={result:e}}return(!t||typeof t!=`object`)&&(t={result:t}),{response:t,imageParts:[]}}let{text:t,imageParts:n}=f(e),r={};return t&&(r.text=t),n.length>0&&(r.images=n.map(e=>({mimeType:e.mimeType??`image/*`,omitted:!0})),r.note=`Image bytes were sent in the next user turn as inlineData.`),Object.keys(r).length===0&&(r.result=null),{response:r,imageParts:n}}function ye(e){let t=[];for(let n of e){if(n.role===`tool`){let{response:e,imageParts:r}=ve(n.content),i=t[t.length-1],a={functionResponse:{name:n.toolName,response:e}};if(i&&i.role===`function`?i.parts.push(a):t.push({role:`function`,parts:[a]}),r.length>0){let e=[{text:p(n.toolName,r.length)}];for(let t of r){let n=ge(t);n&&e.push(n)}t.push({role:`user`,parts:e})}continue}if(n.role===`assistant`){let e=[],r=typeof n.content==`string`?n.content:Array.isArray(n.content)?n.content.map(e=>e.type===`text`?e.text:``).join(``):``;if(r&&e.push({text:r}),n.toolCalls?.length)for(let t of n.toolCalls)e.push({functionCall:{name:t.name,args:t.args??{}}});e.length===0&&e.push({text:`[no content]`}),t.push({role:`model`,parts:e});continue}t.push({role:`user`,parts:_e(n.content)})}return t}function T(e){let{config:t,messages:n,tools:r}=e,{system:i,rest:a}=ie(n),o={contents:ye(a)};i&&(o.systemInstruction={parts:[{text:i}]});let s={};return t.temperature!==void 0&&(s.temperature=t.temperature),t.maxTokens!==void 0&&(s.maxOutputTokens=t.maxTokens),Object.keys(s).length>0&&(o.generationConfig=s),r&&r.length>0&&(o.tools=[{functionDeclarations:r.map(e=>({name:e.name,description:e.description,parameters:pe(e.inputSchema)}))}]),o}async function*be(e){let{config:t,signal:n}=e,r=`${he(t.model,`stream`)}&key=${encodeURIComponent(t.apiKey)}`,i=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(T(e)),signal:n});if(!i.ok||!i.body){let e=await i.text().catch(()=>``);throw Error(`Google request failed (${i.status} ${i.statusText}): ${e}`)}let a=0,o;for await(let e of g(i.body,n)){let t;try{t=JSON.parse(e.data)}catch{continue}o=y(t?.usageMetadata)??o;let n=t?.candidates?.[0]?.content?.parts??[];for(let e of n)if(typeof e.text==`string`&&e.text.length>0)yield{type:`text-delta`,delta:e.text};else if(e.functionCall&&typeof e.functionCall==`object`){let t=a++,n=`call_${t}_${e.functionCall.name??`tool`}`,r=e.functionCall.name??``,i=e.functionCall.args&&typeof e.functionCall.args==`object`?e.functionCall.args:{};yield{type:`tool-call-start`,index:t,toolCallId:n,toolName:r};let o=JSON.stringify(i);o&&o!==`{}`&&(yield{type:`tool-call-args-delta`,index:t,toolCallId:n,toolName:r,argsDelta:o}),yield{type:`tool-call-ready`,index:t,toolCallId:n,toolName:r,args:i}}}o&&(yield{type:`usage`,usage:o}),yield{type:`done`}}async function xe(e){let{config:t,signal:n}=e,r=`${he(t.model,`single`)}?key=${encodeURIComponent(t.apiKey)}`,i=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(T(e)),signal:n});if(!i.ok){let e=await i.text().catch(()=>``);throw Error(`Google request failed (${i.status} ${i.statusText}): ${e}`)}let a=await i.json(),o=``,s=[],c=a?.candidates?.[0]?.content?.parts??[];for(let e of c)typeof e.text==`string`?o+=e.text:e.functionCall&&s.push({id:`call_${s.length}_${e.functionCall.name??`tool`}`,name:e.functionCall.name??``,args:e.functionCall.args&&typeof e.functionCall.args==`object`?e.functionCall.args:{}});return{text:o,toolCalls:s}}async function*Se(e,t){let n=e.getReader(),r=new TextDecoder,i=``;try{for(;;){if(t?.aborted)return;let{done:e,value:a}=await n.read();if(e)break;i+=r.decode(a,{stream:!0});let o=i.split(`
|
|
12
|
+
`)}}function v(e,...t){for(let n of t){let t=e[n];if(typeof t==`number`&&Number.isFinite(t))return t}}function y(e){if(!e||typeof e!=`object`)return;let t=e,n=v(t,`inputTokens`,`input_tokens`,`prompt_tokens`,`promptTokenCount`,`prompt_eval_count`),r=v(t,`outputTokens`,`output_tokens`,`completion_tokens`,`candidatesTokenCount`,`eval_count`),i=v(t,`totalTokens`,`total_tokens`,`totalTokenCount`)??(n!==void 0&&r!==void 0?n+r:void 0),a=t.input_tokens_details&&typeof t.input_tokens_details==`object`?t.input_tokens_details:void 0,o=t.output_tokens_details&&typeof t.output_tokens_details==`object`?t.output_tokens_details:void 0,s=v(t,`cachedInputTokens`,`cache_read_input_tokens`)??(a?v(a,`cached_tokens`):void 0),c=v(t,`reasoningTokens`,`thoughtsTokenCount`)??(o?v(o,`reasoning_tokens`):void 0);if(!(n===void 0&&r===void 0&&i===void 0&&s===void 0&&c===void 0))return{inputTokens:n,outputTokens:r,totalTokens:i,cachedInputTokens:s,reasoningTokens:c}}var b=`https://api.anthropic.com/v1/messages`,x=`2023-06-01`,oe=4096;function S(e){if(e.type!==`image`)return null;if(e.data&&e.mimeType)return{type:`image`,source:{type:`base64`,media_type:e.mimeType,data:e.data}};let t=h(e.url);return t?{type:`image`,source:{type:`base64`,media_type:t.mimeType,data:t.data}}:{type:`image`,source:{type:`url`,url:e.url}}}function se(e){if(typeof e==`string`)return[{type:`text`,text:e||`[no content]`}];let t=[];for(let n of e)if(n.type===`text`)n.text&&t.push({type:`text`,text:n.text});else{let e=S(n);e&&t.push(e)}return t.length===0&&t.push({type:`text`,text:`[no content]`}),t}function ce(e){if(typeof e==`string`)return e;let t=[];for(let n of e)if(n.type===`text`)n.text&&t.push({type:`text`,text:n.text});else if(n.type===`image`){let e=S(n);e&&t.push(e)}return t.length===0?`[no content]`:t}function le(e){let t=[];for(let n of e){if(n.role===`tool`){let e=t[t.length-1],r={type:`tool_result`,tool_use_id:n.toolCallId,content:ce(n.content),...n.toolIsError?{is_error:!0}:{}};e&&e.role===`user`&&Array.isArray(e.content)?e.content.push(r):t.push({role:`user`,content:[r]});continue}if(n.role===`assistant`){let e=[],r=typeof n.content==`string`?n.content:Array.isArray(n.content)?n.content.map(e=>e.type===`text`?e.text:``).join(``):``;if(r&&e.push({type:`text`,text:r}),n.toolCalls?.length)for(let t of n.toolCalls)e.push({type:`tool_use`,id:t.id,name:t.name,input:t.args??{}});e.length===0&&e.push({type:`text`,text:`[no content]`}),t.push({role:`assistant`,content:e});continue}t.push({role:`user`,content:se(n.content)})}return t}function C(e,t){let{config:n,messages:r,tools:i}=e,{system:a,rest:o}=ie(r),s={model:n.model,max_tokens:n.maxTokens??oe,messages:le(o),...t?{stream:!0}:{}};return n.temperature!==void 0&&(s.temperature=n.temperature),a&&(s.system=a),i&&i.length>0&&(s.tools=i.map(e=>({name:e.name,description:e.description,input_schema:e.inputSchema,...t?{eager_input_streaming:!0}:{}}))),s}async function*ue(e){let{config:t,signal:n}=e,r=await fetch(b,{method:`POST`,headers:{"Content-Type":`application/json`,"x-api-key":t.apiKey,"anthropic-version":x,"anthropic-dangerous-direct-browser-access":`true`},body:JSON.stringify(C(e,!0)),signal:n});if(!r.ok||!r.body){let e=await r.text().catch(()=>``);throw Error(`Anthropic request failed (${r.status} ${r.statusText}): ${e}`)}let i=new Map,a;for await(let e of g(r.body,n)){let t;try{t=JSON.parse(e.data)}catch{continue}let n=t?.type;if(n===`message_start`)a=y(t?.message?.usage);else if(n===`message_delta`){let e=y(t?.usage);e&&(a={...a,...e})}else if(n===`content_block_start`){let e=t.index,n=t.content_block??{};if(n.type===`tool_use`){i.set(e,{kind:`tool_use`,id:n.id,name:n.name,argsJson:``,emittedStart:!1}),yield{type:`tool-call-start`,index:e,toolCallId:n.id,toolName:n.name};let t=i.get(e);t&&(t.emittedStart=!0)}else i.set(e,{kind:`text`,argsJson:``,emittedStart:!1})}else if(n===`content_block_delta`){let e=t.index,n=t.delta??{},r=i.get(e);if(!r)continue;n.type===`text_delta`&&typeof n.text==`string`?yield{type:`text-delta`,delta:n.text}:n.type===`input_json_delta`&&typeof n.partial_json==`string`&&r.kind===`tool_use`&&(r.argsJson+=n.partial_json,yield{type:`tool-call-args-delta`,index:e,toolCallId:r.id,toolName:r.name,argsDelta:n.partial_json})}else if(n===`content_block_stop`){let e=t.index,n=i.get(e);if(n&&n.kind===`tool_use`&&n.id&&n.name){let t={};if(n.argsJson)try{t=JSON.parse(n.argsJson)}catch{t={}}yield{type:`tool-call-ready`,index:e,toolCallId:n.id,toolName:n.name,args:t}}}else if(n===`message_stop`){if(a){let e=a.totalTokens??(a.inputTokens!==void 0&&a.outputTokens!==void 0?a.inputTokens+a.outputTokens:void 0);yield{type:`usage`,usage:{...a,totalTokens:e}}}}else n===`error`&&(yield{type:`error`,message:t?.error?.message??`Anthropic stream error`})}yield{type:`done`}}async function de(e){let{config:t,signal:n}=e,r=await fetch(b,{method:`POST`,headers:{"Content-Type":`application/json`,"x-api-key":t.apiKey,"anthropic-version":x,"anthropic-dangerous-direct-browser-access":`true`},body:JSON.stringify(C(e,!1)),signal:n});if(!r.ok){let e=await r.text().catch(()=>``);throw Error(`Anthropic request failed (${r.status} ${r.statusText}): ${e}`)}let i=await r.json(),a=``,o=[];for(let e of i?.content??[])e.type===`text`&&typeof e.text==`string`?a+=e.text:e.type===`tool_use`&&o.push({id:e.id,name:e.name,args:e.input&&typeof e.input==`object`?e.input:{}});return{text:a,toolCalls:o}}var fe=new Set([`type`,`description`,`enum`,`properties`,`required`,`items`,`format`,`nullable`,`minimum`,`maximum`,`minItems`,`maxItems`,`minLength`,`maxLength`,`pattern`]);function pe(e){if(!e||typeof e!=`object`)return{type:`object`};let t=w(e);if(typeof t!=`object`||!t)return{type:`object`};let n=t;return n.type||=`object`,n}function w(e){if(Array.isArray(e))return e.map(w);if(!e||typeof e!=`object`)return e;let t=e;for(let e of[`oneOf`,`anyOf`,`allOf`]){let n=t[e];if(Array.isArray(n)&&n.length===1)return w(n[0])}let n={};for(let[e,r]of Object.entries(t))if(fe.has(e))if(e===`properties`&&r&&typeof r==`object`){let t={};for(let[e,n]of Object.entries(r))t[e]=w(n);n[e]=t}else e===`items`?n[e]=w(r):n[e]=r;return n}function me(e){let t=e.trim();return t.startsWith(`models/`)?t.slice(7):t}function he(e,t){let n=t===`stream`?`streamGenerateContent?alt=sse`:`generateContent`;return`https://generativelanguage.googleapis.com/v1beta/models/${encodeURIComponent(me(e))}:${n}`}function ge(e){if(e.type!==`image`)return null;if(e.data&&e.mimeType)return{inlineData:{mimeType:e.mimeType,data:e.data}};let t=h(e.url);return t?{inlineData:{mimeType:t.mimeType,data:t.data}}:null}function _e(e){if(typeof e==`string`)return[{text:e||`[no content]`}];let t=[];for(let n of e)if(n.type===`text`)n.text&&t.push({text:n.text});else{let e=ge(n);e&&t.push(e)}return t.length===0&&t.push({text:`[no content]`}),t}function ve(e){if(typeof e==`string`){let t;try{t=JSON.parse(e)}catch{t={result:e}}return(!t||typeof t!=`object`)&&(t={result:t}),{response:t,imageParts:[]}}let{text:t,imageParts:n}=f(e),r={};return t&&(r.text=t),n.length>0&&(r.images=n.map(e=>({mimeType:e.mimeType??`image/*`,omitted:!0})),r.note=`Image bytes were sent in the next user turn as inlineData.`),Object.keys(r).length===0&&(r.result=null),{response:r,imageParts:n}}function ye(e){let t=[];for(let n of e){if(n.role===`tool`){let{response:e,imageParts:r}=ve(n.content),i=t[t.length-1],a={functionResponse:{name:n.toolName,response:e}};if(i&&i.role===`function`?i.parts.push(a):t.push({role:`function`,parts:[a]}),r.length>0){let e=[{text:p(n.toolName,r.length)}];for(let t of r){let n=ge(t);n&&e.push(n)}t.push({role:`user`,parts:e})}continue}if(n.role===`assistant`){let e=[],r=typeof n.content==`string`?n.content:Array.isArray(n.content)?n.content.map(e=>e.type===`text`?e.text:``).join(``):``;if(r&&e.push({text:r}),n.toolCalls?.length)for(let t of n.toolCalls)e.push({functionCall:{name:t.name,args:t.args??{}}});e.length===0&&e.push({text:`[no content]`}),t.push({role:`model`,parts:e});continue}t.push({role:`user`,parts:_e(n.content)})}return t}function T(e){let{config:t,messages:n,tools:r}=e,{system:i,rest:a}=ie(n),o={contents:ye(a)};i&&(o.systemInstruction={parts:[{text:i}]});let s={};return t.temperature!==void 0&&(s.temperature=t.temperature),t.maxTokens!==void 0&&(s.maxOutputTokens=t.maxTokens),Object.keys(s).length>0&&(o.generationConfig=s),r&&r.length>0&&(o.tools=[{functionDeclarations:r.map(e=>({name:e.name,description:e.description,parameters:pe(e.inputSchema)}))}]),o}async function*be(e){let{config:t,signal:n}=e,r=`${he(t.model,`stream`)}&key=${encodeURIComponent(t.apiKey)}`,i=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(T(e)),signal:n});if(!i.ok||!i.body){let e=await i.text().catch(()=>``);throw Error(`Google request failed (${i.status} ${i.statusText}): ${e}`)}let a=0,o;for await(let e of g(i.body,n)){let t;try{t=JSON.parse(e.data)}catch{continue}o=y(t?.usageMetadata)??o;let n=t?.candidates?.[0]?.content?.parts??[];for(let e of n)if(typeof e.text==`string`&&e.text.length>0)yield{type:`text-delta`,delta:e.text};else if(e.functionCall&&typeof e.functionCall==`object`){let t=a++,n=`call_${t}_${e.functionCall.name??`tool`}`,r=e.functionCall.name??``,i=e.functionCall.args&&typeof e.functionCall.args==`object`?e.functionCall.args:{};yield{type:`tool-call-start`,index:t,toolCallId:n,toolName:r};let o=JSON.stringify(i);o&&o!==`{}`&&(yield{type:`tool-call-args-delta`,index:t,toolCallId:n,toolName:r,argsDelta:o}),yield{type:`tool-call-ready`,index:t,toolCallId:n,toolName:r,args:i}}}o&&(yield{type:`usage`,usage:o}),yield{type:`done`}}async function xe(e){let{config:t,signal:n}=e,r=`${he(t.model,`single`)}?key=${encodeURIComponent(t.apiKey)}`,i=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(T(e)),signal:n});if(!i.ok){let e=await i.text().catch(()=>``);throw Error(`Google request failed (${i.status} ${i.statusText}): ${e}`)}let a=await i.json(),o=``,s=[],c=a?.candidates?.[0]?.content?.parts??[];for(let e of c)typeof e.text==`string`?o+=e.text:e.functionCall&&s.push({id:`call_${s.length}_${e.functionCall.name??`tool`}`,name:e.functionCall.name??``,args:e.functionCall.args&&typeof e.functionCall.args==`object`?e.functionCall.args:{}});return{text:o,toolCalls:s}}async function*Se(e,t){let n=e.getReader(),r=new TextDecoder,i=``;try{for(;;){if(t?.aborted)return;let{done:e,value:a}=await n.read();if(e)break;i+=r.decode(a,{stream:!0});let o=i.split(`
|
|
13
13
|
`);i=o.pop()??``;for(let e of o){let t=e.trim();if(t)try{yield JSON.parse(t)}catch{}}}let e=i.trim();if(e)try{yield JSON.parse(e)}catch{}}finally{n.releaseLock()}}var Ce=`http://localhost:11434`;function E(e){let t=(e||`http://localhost:11434`).trim(),n=t.length;for(;n>0&&t.charCodeAt(n-1)===47;)n--;let r=t.slice(0,n);return r.endsWith(`/api`)?r.slice(0,-4):r}function D(e,t){return`${E(e)}${t}`}var we=class extends Error{constructor(e){super("Could not reach Ollama. If it's running, allow this origin by starting Ollama with `OLLAMA_ORIGINS=*` (or your inspector origin) and try again."),this.name=`OllamaCorsError`,this.cause=e}};function Te(e){let t=[];for(let n of e){if(n.type!==`image`)continue;if(n.data){t.push(n.data);continue}let e=h(n.url);e?.data&&t.push(e.data)}return t}function O(e){if(typeof e==`string`)return{content:e};let t=e.filter(e=>e.type===`text`).map(e=>e.text).join(``),n=Te(e);return{content:t,...n.length>0?{images:n}:{}}}function Ee(e){return e.map(e=>e.role===`tool`?{role:`tool`,tool_name:e.toolName,content:typeof e.content==`string`?e.content:JSON.stringify(e.toolResult??e.content)}:e.role===`assistant`?{role:`assistant`,...typeof e.content==`string`?{content:e.content}:O(e.content),...e.toolCalls?.length?{tool_calls:e.toolCalls.map((e,t)=>({type:`function`,function:{index:t,name:e.name,arguments:e.args}}))}:{}}:{role:e.role,...O(e.content)})}function k(e,t){let{config:n,messages:r,tools:i}=e,a={model:n.model,messages:Ee(r),stream:t},o={};return n.temperature!==void 0&&(o.temperature=n.temperature),n.maxTokens!==void 0&&(o.num_predict=n.maxTokens),Object.keys(o).length>0&&(a.options=o),i&&i.length>0&&(a.tools=i.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.inputSchema}}))),a}function A(e){return{"Content-Type":`application/json`,...e.apiKey.trim()?{Authorization:`Bearer ${e.apiKey.trim()}`}:{}}}function j(e){return Array.isArray(e)?e.map(e=>{let t=e&&typeof e==`object`?e.function:void 0,n=typeof t?.name==`string`?t.name:``,r=t?.arguments;return{name:n,args:r&&typeof r==`object`?r:{}}}).filter(e=>e.name):[]}async function*De(e){let{config:t,signal:n}=e,r=await fetch(D(t.baseUrl,`/api/chat`),{method:`POST`,headers:A(t),body:JSON.stringify(k(e,!0)),signal:n});if(!r.ok||!r.body){let e=await r.text().catch(()=>``);throw Error(`Ollama request failed (${r.status} ${r.statusText}): ${e}`)}let i=!1,a;for await(let e of Se(r.body,n)){let t=e&&typeof e==`object`?e.message:void 0;if(typeof t?.content==`string`&&t.content.length>0&&(yield{type:`text-delta`,delta:t.content}),!i){let e=j(t?.tool_calls);if(e.length>0){for(let[t,n]of e.entries()){let e=`call_${t}_${n.name||`tool`}`;yield{type:`tool-call-start`,index:t,toolCallId:e,toolName:n.name};let r=JSON.stringify(n.args);r&&r!==`{}`&&(yield{type:`tool-call-args-delta`,index:t,toolCallId:e,toolName:n.name,argsDelta:r}),yield{type:`tool-call-ready`,index:t,toolCallId:e,toolName:n.name,args:n.args}}i=!0}}e&&typeof e==`object`&&e.error&&(yield{type:`error`,message:String(e.error)}),a=y(e)??a}a&&(yield{type:`usage`,usage:a}),yield{type:`done`}}async function Oe(e){let{config:t,signal:n}=e,r=await fetch(D(t.baseUrl,`/api/chat`),{method:`POST`,headers:A(t),body:JSON.stringify(k(e,!1)),signal:n});if(!r.ok){let e=await r.text().catch(()=>``);throw Error(`Ollama request failed (${r.status} ${r.statusText}): ${e}`)}let i=(await r.json())?.message??{};return{text:typeof i.content==`string`?i.content:``,toolCalls:j(i.tool_calls).map((e,t)=>({id:`call_${t}_${e.name||`tool`}`,name:e.name,args:e.args}))}}var M=class extends Error{status;body;constructor(e,t,n){super(t),this.name=`LlmRequestError`,this.status=e,this.body=n}};async function N(e){let t=await e.text().catch(()=>``),n=t;if(t)try{n=JSON.parse(t)}catch{}throw new M(e.status,`OpenAI request failed (${e.status} ${e.statusText}): ${t}`,n)}var ke=`https://api.openai.com/v1`;function P(e,t){return`${e.baseUrl??ke}${t}`}function F(e){let t={"Content-Type":`application/json`,...e.extraHeaders};return e.apiKey&&(t.Authorization=`Bearer ${e.apiKey}`),t}function Ae(e){return typeof e==`string`?e:e.map(e=>e.type===`text`?{type:`text`,text:e.text}:{type:`image_url`,image_url:{url:e.url}})}function I(e){let t=[];for(let n of e){if(n.role===`tool`){let{text:e,imageParts:r}=f(n.content),i=r.length>0?`[image content; see next message]`:`[no content]`;if(t.push({role:`tool`,tool_call_id:n.toolCallId,content:e||i}),r.length>0){let e=[{type:`text`,text:p(n.toolName,r.length)},...r.map(e=>({type:`image_url`,image_url:{url:e.url}}))];t.push({role:`user`,content:e})}continue}if(n.role===`assistant`){let e={role:`assistant`,content:typeof n.content==`string`&&n.content.length>0?n.content:null};n.toolCalls?.length&&(e.tool_calls=n.toolCalls.map(e=>({id:e.id,type:`function`,function:{name:e.name,arguments:JSON.stringify(e.args)}}))),t.push(e);continue}t.push({role:n.role,content:Ae(n.content)})}return t}async function*L(e){let{config:t,messages:n,tools:r,signal:i}=e,a={model:t.model,messages:I(n),stream:!0};t.provider===`openrouter`&&(a.stream_options={include_usage:!0}),t.temperature!==void 0&&(a.temperature=t.temperature),t.maxTokens!==void 0&&(a.max_tokens=t.maxTokens),r&&r.length>0&&(a.tools=r.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.inputSchema}})));let o=P(t,`/chat/completions`),s=await fetch(o,{method:`POST`,headers:F(t),body:JSON.stringify(a),signal:i,...t.credentials?{credentials:t.credentials}:{}}),c=s.body;s.ok||await N(s),c||await N(s);let l=c,u=new Map;for await(let e of g(l,i)){if(!e.data||e.data===`[DONE]`)continue;let t;try{t=JSON.parse(e.data)}catch{continue}let n=y(t?.usage);n&&(yield{type:`usage`,usage:n});let r=t?.choices?.[0];if(!r)continue;let i=r.delta??{};if(typeof i.content==`string`&&i.content.length>0&&(yield{type:`text-delta`,delta:i.content}),Array.isArray(i.tool_calls))for(let e of i.tool_calls){let t=typeof e.index==`number`?e.index:0,n=u.get(t);n||(n={id:e.id??`call_${t}`,name:e.function?.name??``,argsJson:``,started:!1},u.set(t,n)),(e.id&&!n.id.startsWith(`call_`)||e.id)&&(n.id=e.id),e.function?.name&&(n.name=e.function.name),!n.started&&n.name&&(n.started=!0,yield{type:`tool-call-start`,index:t,toolCallId:n.id,toolName:n.name});let r=e.function?.arguments;typeof r==`string`&&r.length>0&&(n.argsJson+=r,n.started&&(yield{type:`tool-call-args-delta`,index:t,toolCallId:n.id,toolName:n.name,argsDelta:r}))}if(r.finish_reason){for(let[e,t]of u){let n={};if(t.argsJson)try{n=JSON.parse(t.argsJson)}catch{n={}}yield{type:`tool-call-ready`,index:e,toolCallId:t.id,toolName:t.name,args:n}}u.clear()}}yield{type:`done`}}async function R(e){let{config:t,messages:n,tools:r,signal:i}=e,a={model:t.model,messages:I(n)};t.temperature!==void 0&&(a.temperature=t.temperature),t.maxTokens!==void 0&&(a.max_tokens=t.maxTokens),r&&r.length>0&&(a.tools=r.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.inputSchema}})));let o=P(t,`/chat/completions`),s=await fetch(o,{method:`POST`,headers:F(t),body:JSON.stringify(a),signal:i,...t.credentials?{credentials:t.credentials}:{}});s.ok||await N(s);let c=(await s.json())?.choices?.[0]?.message;return{text:typeof c?.content==`string`?c.content:``,toolCalls:Array.isArray(c?.tool_calls)?c.tool_calls.map(e=>{let t={};try{t=JSON.parse(e?.function?.arguments??`{}`)}catch{t={}}return{id:e.id,name:e.function?.name??``,args:t}}):[]}}function z(e){return{...e,config:{...e.config,baseUrl:`https://openrouter.ai/api/v1`,extraHeaders:{"HTTP-Referer":`https://inspector.mcp-use.com`,"X-Title":`mcp-use Inspector`}}}}function je(e){switch(e.config.provider){case`openai`:throw Error(`provider 'openai' uses the Responses API via OpenAIResponsesDriver, not streamChat`);case`openai-compatible`:return L(e);case`anthropic`:return ue(e);case`google`:return be(e);case`openrouter`:return L(z(e));case`ollama`:return De(e);default:throw Error(`Unsupported LLM provider: ${e.config.provider}`)}}function Me(e){switch(e.config.provider){case`openai`:throw Error(`provider 'openai' uses the Responses API via OpenAIResponsesDriver, not chat`);case`openai-compatible`:return R(e);case`anthropic`:return de(e);case`google`:return xe(e);case`openrouter`:return R(z(e));case`ollama`:return Oe(e);default:throw Error(`Unsupported LLM provider: ${e.config.provider}`)}}var Ne=`https://api.openai.com/v1`;function B(e,t){return`${(e.baseUrl??Ne).replace(/\/$/,``)}${t}`}function V(e){let t={"Content-Type":`application/json`,...e.extraHeaders};return e.apiKey&&(t.Authorization=`Bearer ${e.apiKey}`),t}async function H(e){let t=await e.text().catch(()=>``);return`OpenAI request failed (${e.status} ${e.statusText}): ${t}`}function Pe(e){return typeof e==`string`?e:e.map(e=>e.type===`text`?{type:`input_text`,text:e.text}:{type:`input_image`,image_url:e.url})}function U(e){let t=[],n=[];for(let r of e){if(r.role===`system`){let e=typeof r.content==`string`?r.content:r.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
14
14
|
`);e&&t.push(e);continue}if(r.role===`user`){n.push({role:`user`,content:Pe(r.content)});continue}if(r.role===`assistant`){typeof r.content==`string`&&r.content.length>0&&n.push({type:`message`,role:`assistant`,content:[{type:`output_text`,text:r.content}]});for(let e of r.toolCalls??[])n.push({type:`function_call`,call_id:e.id,name:e.name,arguments:JSON.stringify(e.args)});continue}if(r.role===`tool`){let{text:e,imageParts:t}=f(r.content),i=t.length>0?`[image content; see next message]`:`[no content]`;n.push({type:`function_call_output`,call_id:r.toolCallId,output:e||i}),t.length>0&&n.push({role:`user`,content:[{type:`input_text`,text:p(r.toolName,t.length)},...t.map(e=>({type:`input_image`,image_url:e.url}))]})}}return{instructions:t.length>0?t.join(`
|
|
15
15
|
|
|
16
|
-
`):void 0,input:n}}function Fe(e){return e.map(e=>({type:`function`,name:e.name,description:e.description,parameters:e.inputSchema,strict:!1}))}function W(e,t,n,r){let i=d(r);if(typeof i==`string`){e.push({type:`function_call_output`,call_id:t,output:i});return}let{text:a,imageParts:o}=f(i);e.push({type:`function_call_output`,call_id:t,output:a||`[image content; see next message]`}),o.length>0&&e.push({role:`user`,content:[{type:`input_text`,text:p(n,o.length)},...o.map(e=>({type:`input_image`,image_url:e.url}))]})}function G(e,t){let n={model:e.config.model,input:e.input,store:!1,include:[`reasoning.encrypted_content`],reasoning:{effort:e.config.reasoningEffort??`low`},stream:t};return e.instructions&&(n.instructions=e.instructions),e.tools&&e.tools.length>0&&(n.tools=Fe(e.tools)),e.config.maxTokens!==void 0&&(n.max_output_tokens=e.config.maxTokens),n}function K(e){let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;e.type===`function_call`&&(typeof e.call_id!=`string`||typeof e.name!=`string`||t.push({call_id:e.call_id,name:e.name,arguments:typeof e.arguments==`string`?e.arguments:`{}`}))}return t}function Ie(e){let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(e.type!==`message`||e.role!==`assistant`)continue;let r=e.content;if(Array.isArray(r))for(let e of r){if(!e||typeof e!=`object`)continue;let n=e;n.type===`output_text`&&typeof n.text==`string`&&t.push(n.text)}}return t.join(``)}function q(e){if(!e)return{};try{return JSON.parse(e)}catch{return{}}}async function*J(e){let t=await fetch(B(e.config,`/responses`),{method:`POST`,headers:V(e.config),body:JSON.stringify(G(e,!0)),signal:e.signal});if(!t.ok||!t.body)throw Error(await H(t));let n=new Map,r=0,i=[];for await(let a of g(t.body,e.signal)){if(!a.data||a.data===`[DONE]`)continue;let e;try{e=JSON.parse(a.data)}catch{continue}let t=typeof e.type==`string`?e.type:a.event;if(t===`response.output_text.delta`){let t=e.delta;typeof t==`string`&&t.length>0&&(yield{type:`text-delta`,delta:t});continue}if(t===`response.output_item.added`){let t=e.item;if(t?.type===`function_call`){let e=typeof t.call_id==`string`?t.call_id:`call_${r}`,i=typeof t.name==`string`?t.name:``,a=r++;n.set(e,{index:a,name:i,argsJson:``,started:!0}),yield{type:`tool-call-start`,index:a,toolCallId:e,toolName:i}}continue}if(t===`response.function_call_arguments.delta`){let t=typeof e.call_id==`string`?e.call_id:``,r=typeof e.delta==`string`?e.delta:``,i=n.get(t);i&&r.length>0&&(i.argsJson+=r,yield{type:`tool-call-args-delta`,index:i.index,toolCallId:t,toolName:i.name,argsDelta:r});continue}if(t===`response.function_call_arguments.done`){let t=typeof e.call_id==`string`?e.call_id:``,r=typeof e.arguments==`string`?e.arguments:``,i=n.get(t);i&&(r&&(i.argsJson=r),yield{type:`tool-call-ready`,index:i.index,toolCallId:t,toolName:i.name,args:q(i.argsJson||r)});continue}if(t===`response.completed`){let t=e.response;t&&Array.isArray(t.output)&&(i=t.output);let n=y(t?.usage);n&&(yield{type:`usage`,usage:n});continue}if(t===`error`)return yield{type:`error`,message:typeof e.message==`string`?e.message:`OpenAI Responses stream error`},[]}return yield{type:`done`},i}async function Y(e){let t=await fetch(B(e.config,`/responses`),{method:`POST`,headers:V(e.config),body:JSON.stringify(G(e,!1)),signal:e.signal});if(!t.ok)throw Error(await H(t));let n=await t.json(),r=n.status;if(r!==`completed`&&r!==void 0)throw Error(`OpenAI response ended with status ${String(r)}`);let i=Array.isArray(n.output)?n.output:[],a=K(i);return{text:typeof n.output_text==`string`?n.output_text:Ie(i),output:i,toolCalls:a.map(e=>({id:e.call_id,name:e.name,args:q(e.arguments)}))}}var Le=class{constructor(e){this.config=e}managesToolLoop=!0;stream(e){return this.streamSingleTurn(e)}async complete(e){let{instructions:t,input:n}=U(e.messages),r=await Y({config:this.config,instructions:t,input:n,tools:e.tools,signal:e.signal});return{text:r.text,toolCalls:r.toolCalls}}async*streamToolLoop(e){let{instructions:t,input:n}=U(e.messages),r=[...n],i=e.maxSteps??10;for(let n=0;n<i;n++){if(e.signal?.aborted)return;let n=J({config:this.config,instructions:t,input:r,tools:e.tools,signal:e.signal}),i=[];for(;;){let e=await n.next();if(e.done){i=e.value??[];break}if(yield e.value,e.value.type===`error`)return}r.push(...i);let a=K(i);if(a.length===0)return;for(let t of a){if(e.signal?.aborted)return;let n={};try{n=JSON.parse(t.arguments)}catch{n={}}let i,a=!1;try{i=await e.callTool(t.name,n),a=l(i)}catch(e){a=!0,i={isError:!0,error:e instanceof Error?e.message:String(e)}}W(r,t.call_id,t.name,i),yield{type:`tool-result`,toolCallId:t.call_id,toolName:t.name,result:i,isError:a}}}}async runToolLoopNonStreaming(e){let{instructions:t,input:n}=U(e.messages),r=[...n],i=e.maxSteps??10,a=[],o=``;for(let n=0;n<i&&!e.signal?.aborted;n++){let n=await Y({config:this.config,instructions:t,input:r,tools:e.tools,signal:e.signal});if(r.push(...n.output),n.toolCalls.length===0){o=n.text;break}for(let t of n.toolCalls){let n;try{n=await e.callTool(t.name,t.args),l(n)}catch(e){n={isError:!0,error:e instanceof Error?e.message:String(e)}}a.push({toolName:t.name,args:t.args,result:n}),W(r,t.id,t.name,n)}}return{content:o,toolCalls:a}}async*streamSingleTurn(e){let{instructions:t,input:n}=U(e.messages),r=J({config:this.config,instructions:t,input:n,tools:e.tools,signal:e.signal});for(;;){let e=await r.next();if(e.done||(yield e.value,e.value.type===`error`))return}}};function X(e){return e.provider===`openai`?new Le(e):new Re(e)}var Re=class{constructor(e){this.config=e}stream(e){return je({config:this.config,messages:e.messages,tools:e.tools,signal:e.signal})}async complete(e){let t=await Me({config:this.config,messages:e.messages,tools:e.tools,signal:e.signal});return{text:t.text,toolCalls:t.toolCalls}}};async function*ze(e){if(e.driver.managesToolLoop&&e.driver.streamToolLoop){yield*e.driver.streamToolLoop(e);return}let{driver:t,tools:n,callTool:r,signal:i}=e,a=e.maxSteps??10,o=[...e.messages];for(let e=0;e<a;e++){if(i?.aborted)return;let e=[],a=``;try{for await(let r of t.stream({messages:o,tools:n,signal:i}))r.type===`text-delta`?a+=r.delta:r.type===`tool-call-ready`&&e.push({id:r.toolCallId,name:r.toolName,args:r.args}),yield r}catch(e){if(e instanceof M)throw e;yield{type:`error`,message:e instanceof Error?e.message:String(e)};return}if(e.length===0)return;o.push({role:`assistant`,content:a,toolCalls:e});for(let t of e){if(i?.aborted)return;let e,n=!1;try{e=await r(t.name,t.args),n=l(e)}catch(t){n=!0,e={isError:!0,error:t instanceof Error?t.message:String(t)}}o.push({role:`tool`,content:d(e),toolCallId:t.id,toolName:t.name,toolResult:e,toolIsError:n}),yield{type:`tool-result`,toolCallId:t.id,toolName:t.name,result:e,isError:n}}}}async function Be(e){if(e.driver.managesToolLoop&&e.driver.runToolLoopNonStreaming)return e.driver.runToolLoopNonStreaming(e);let{driver:t,tools:n,callTool:r,signal:i}=e,a=e.maxSteps??10,o=[...e.messages],s=[],c=``;for(let e=0;e<a&&!i?.aborted;e++){let{text:e,toolCalls:a}=await t.complete({messages:o,tools:n,signal:i});if(a.length===0){c=e;break}o.push({role:`assistant`,content:e,toolCalls:a});for(let e of a){let t,n=!1;try{t=await r(e.name,e.args),n=l(t)}catch(e){n=!0,t={isError:!0,error:e instanceof Error?e.message:String(e)}}s.push({toolName:e.name,args:e.args,result:t}),o.push({role:`tool`,content:d(t),toolCallId:e.id,toolName:e.name,toolResult:t,toolIsError:n})}}return{content:c,toolCalls:s}}async function*Z(e,t){yield*ze({driver:e,messages:t.messages,tools:t.tools,callTool:t.callTool,maxSteps:t.maxSteps,signal:t.signal})}async function*Ve(e,t){let n=``,r=null;for await(let i of Z(e,t))if(i.type===`text-delta`)n+=i.delta;else if(i.type===`tool-call-ready`)r={action:{tool:i.toolName,toolInput:i.args,log:`Calling tool ${i.toolName}`},observation:``},yield r;else if(i.type===`tool-result`&&r){let e=typeof i.result==`string`?i.result:JSON.stringify(i.result??``);yield{action:r.action,observation:e},r=null}else if(i.type===`error`)throw Error(i.message);return n}async function He(e,t){return(await Be({driver:e,messages:t.messages,tools:t.tools,callTool:t.callTool,maxSteps:t.maxSteps,signal:t.signal})).content}var Ue={openai:[`OPENAI_API_KEY`],anthropic:[`ANTHROPIC_API_KEY`],google:[`GOOGLE_API_KEY`,`GOOGLE_GENERATIVE_AI_API_KEY`],openrouter:[`OPENROUTER_API_KEY`],ollama:[],"openai-compatible":[`OPENAI_API_KEY`]};function We(e,t){if(t?.apiKey)return t.apiKey;let r=Ue[e]??[];if(typeof process<`u`)for(let t of r){let r={}[t];if(r)return n.debug(`Using API key from ${t} for ${e}`),r}if(e===`ollama`)return``;let i=r.length>0?r.join(` or `):`apiKey in llmConfig`;throw Error(`API key not found for provider '${e}'. Set ${i}.`)}function Q(e,t){let n=e.split(`/`);if(n.length<2)throw Error(`Invalid LLM string '${e}'. Expected 'provider/model'.`);let r=n[0].toLowerCase(),i=n.slice(1).join(`/`),a=[`openai`,`anthropic`,`google`,`openrouter`,`ollama`,`openai-compatible`];if(!a.includes(r))throw Error(`Unsupported provider '${r}'. Supported: ${a.join(`, `)}`);return{provider:r,model:i,apiKey:We(r,t),temperature:t?.temperature,maxTokens:t?.maxTokens,baseUrl:t?.baseUrl,extraHeaders:t?.extraHeaders,credentials:t?.credentials}}function Ge(e,t,n){return{provider:e,model:t,apiKey:We(e,n),temperature:n?.temperature,maxTokens:n?.maxTokens,baseUrl:n?.baseUrl,extraHeaders:n?.extraHeaders,credentials:n?.credentials}}var Ke=`2.0.0-beta.3`;function qe(){return Ke}function $(e,t,n,r,i,a){return typeof e==`object`&&e?{prompt:e.prompt,maxSteps:e.maxSteps,manageConnector:e.manageConnector,messages:e.messages,schema:e.schema,signal:e.signal}:{prompt:e,maxSteps:t,manageConnector:n,schema:i,signal:a}}var Je=`/api/v1/chats`,Ye=`/api/v1/chats/{chat_id}/execute`;function Xe(e,t,n,r,i){if(typeof e==`object`&&e){let t=e;return{query:t.prompt??``,maxSteps:t.maxSteps,manageConnector:t.manageConnector,externalHistory:t.externalHistory,outputSchema:t.schema}}return{query:e,maxSteps:t,manageConnector:n,externalHistory:r,outputSchema:i}}var Ze=class{agentId;apiKey;baseUrl;chatId=null;constructor(e){this.agentId=e.agentId,this.baseUrl=e.baseUrl??`https://cloud.manufact.com`;let t=e.apiKey??(typeof process<`u`&&{}.MCP_USE_API_KEY);if(!t)throw Error(`API key is required for remote execution. Please provide it as a parameter or set the MCP_USE_API_KEY environment variable. You can get an API key from https://cloud.manufact.com`);this.apiKey=t}pydanticToJsonSchema(e){return t(e)}parseStructuredResponse(e,t){let r;if(typeof e==`object`&&e)if(`result`in e){let t=e.result;r=typeof t==`object`&&t&&`result`in t?t.result:t}else r=e;else if(typeof e==`string`)try{r=JSON.parse(e)}catch{r={content:e}}else r=e;try{return t.parse(r)}catch(e){n.warn(`Failed to parse structured output: ${e}`);let i=t._def?.shape();if(i&&`content`in i)return t.parse({content:String(r)});throw e}}async createChatSession(){let e={title:`Remote Agent Session - ${this.agentId}`,agent_id:this.agentId,type:`agent_execution`},t={"Content-Type":`application/json`,"x-api-key":this.apiKey},r=`${this.baseUrl}${Je}`;n.debug(`\u{1F4DD} Creating chat session for agent ${this.agentId}`);try{let i=await fetch(r,{method:`POST`,headers:t,body:JSON.stringify(e)});if(!i.ok){let e=await i.text(),t=i.status;throw Error(t===404?`Agent not found: Agent '${this.agentId}' does not exist or you don't have access to it. Please verify the agent ID and ensure it exists in your account.`:`Failed to create chat session: ${t} - ${e}`)}let a=(await i.json()).id;return n.debug(`\u2705 Chat session created: ${a}`),a}catch(e){throw e instanceof Error?TypeError(`Failed to create chat session: ${e.message}`):Error(`Failed to create chat session: ${String(e)}`)}}async run(e,t,r,i,a){let{query:o,maxSteps:s,externalHistory:c,outputSchema:l}=Xe(e,t,r,i,a);c!==void 0&&n.warn(`External history is not yet supported for remote execution`);try{n.debug(`\u{1F310} Executing query on remote agent ${this.agentId}`),this.chatId===null&&(this.chatId=await this.createChatSession());let e=this.chatId,t={query:o,max_steps:s??10};l&&(t.output_schema=this.pydanticToJsonSchema(l),n.debug(`🔧 Using structured output with schema`));let r={"Content-Type":`application/json`,"x-api-key":this.apiKey},i=`${this.baseUrl}${Ye.replace(`{chat_id}`,e)}`;n.debug(`\u{1F680} Executing agent in chat ${e}`);let a=await fetch(i,{method:`POST`,headers:r,body:JSON.stringify(t),signal:AbortSignal.timeout(3e5)});if(!a.ok){let e=await a.text(),t=a.status;throw t===401?(n.error(`\u274C Authentication failed: ${e}`),Error(`Authentication failed: Invalid or missing API key. Please check your API key and ensure the MCP_USE_API_KEY environment variable is set correctly.`)):t===403?(n.error(`\u274C Access forbidden: ${e}`),Error(`Access denied: You don't have permission to execute agent '${this.agentId}'. Check if the agent exists and you have the necessary permissions.`)):t===404?(n.error(`\u274C Agent not found: ${e}`),Error(`Agent not found: Agent '${this.agentId}' does not exist or you don't have access to it. Please verify the agent ID and ensure it exists in your account.`)):t===422?(n.error(`\u274C Validation error: ${e}`),Error(`Request validation failed: ${e}. Please check your query parameters and output schema format.`)):t===500?(n.error(`\u274C Server error: ${e}`),Error(`Internal server error occurred during agent execution. Please try again later or contact support if the issue persists.`)):(n.error(`\u274C Remote execution failed with status ${t}: ${e}`),Error(`Remote agent execution failed: ${t} - ${e}`))}let c=await a.json();if(n.debug(`\u{1F527} Response: ${JSON.stringify(c)}`),n.debug(`✅ Remote execution completed successfully`),typeof c==`object`&&c){if(c.status===`error`||c.error!==null){let e=c.error??String(c);throw n.error(`\u274C Remote agent execution failed: ${e}`),Error(`Remote agent execution failed: ${e}`)}if(String(c).includes(`failed to initialize`))throw n.error(`\u274C Agent initialization failed: ${c}`),Error(`Agent initialization failed on remote server. This usually indicates:
|
|
16
|
+
`):void 0,input:n}}function Fe(e){return e.map(e=>({type:`function`,name:e.name,description:e.description,parameters:e.inputSchema,strict:!1}))}function W(e,t,n,r){let i=d(r);if(typeof i==`string`){e.push({type:`function_call_output`,call_id:t,output:i});return}let{text:a,imageParts:o}=f(i);e.push({type:`function_call_output`,call_id:t,output:a||`[image content; see next message]`}),o.length>0&&e.push({role:`user`,content:[{type:`input_text`,text:p(n,o.length)},...o.map(e=>({type:`input_image`,image_url:e.url}))]})}function G(e,t){let n={model:e.config.model,input:e.input,store:!1,include:[`reasoning.encrypted_content`],reasoning:{effort:e.config.reasoningEffort??`low`},stream:t};return e.instructions&&(n.instructions=e.instructions),e.tools&&e.tools.length>0&&(n.tools=Fe(e.tools)),e.config.maxTokens!==void 0&&(n.max_output_tokens=e.config.maxTokens),n}function K(e){let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;e.type===`function_call`&&(typeof e.call_id!=`string`||typeof e.name!=`string`||t.push({call_id:e.call_id,name:e.name,arguments:typeof e.arguments==`string`?e.arguments:`{}`}))}return t}function Ie(e){let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(e.type!==`message`||e.role!==`assistant`)continue;let r=e.content;if(Array.isArray(r))for(let e of r){if(!e||typeof e!=`object`)continue;let n=e;n.type===`output_text`&&typeof n.text==`string`&&t.push(n.text)}}return t.join(``)}function q(e){if(!e)return{};try{return JSON.parse(e)}catch{return{}}}async function*J(e){let t=await fetch(B(e.config,`/responses`),{method:`POST`,headers:V(e.config),body:JSON.stringify(G(e,!0)),signal:e.signal});if(!t.ok||!t.body)throw Error(await H(t));let n=new Map,r=0,i=[];for await(let a of g(t.body,e.signal)){if(!a.data||a.data===`[DONE]`)continue;let e;try{e=JSON.parse(a.data)}catch{continue}let t=typeof e.type==`string`?e.type:a.event;if(t===`response.output_text.delta`){let t=e.delta;typeof t==`string`&&t.length>0&&(yield{type:`text-delta`,delta:t});continue}if(t===`response.output_item.added`){let t=e.item;if(t?.type===`function_call`){let e=typeof t.call_id==`string`?t.call_id:`call_${r}`,i=typeof t.name==`string`?t.name:``,a=r++;n.set(e,{index:a,name:i,argsJson:``,started:!0}),yield{type:`tool-call-start`,index:a,toolCallId:e,toolName:i}}continue}if(t===`response.function_call_arguments.delta`){let t=typeof e.call_id==`string`?e.call_id:``,r=typeof e.delta==`string`?e.delta:``,i=n.get(t);i&&r.length>0&&(i.argsJson+=r,yield{type:`tool-call-args-delta`,index:i.index,toolCallId:t,toolName:i.name,argsDelta:r});continue}if(t===`response.function_call_arguments.done`){let t=typeof e.call_id==`string`?e.call_id:``,r=typeof e.arguments==`string`?e.arguments:``,i=n.get(t);i&&(r&&(i.argsJson=r),yield{type:`tool-call-ready`,index:i.index,toolCallId:t,toolName:i.name,args:q(i.argsJson||r)});continue}if(t===`response.completed`){let t=e.response;t&&Array.isArray(t.output)&&(i=t.output);let n=y(t?.usage);n&&(yield{type:`usage`,usage:n});continue}if(t===`error`)return yield{type:`error`,message:typeof e.message==`string`?e.message:`OpenAI Responses stream error`},[]}return yield{type:`done`},i}async function Y(e){let t=await fetch(B(e.config,`/responses`),{method:`POST`,headers:V(e.config),body:JSON.stringify(G(e,!1)),signal:e.signal});if(!t.ok)throw Error(await H(t));let n=await t.json(),r=n.status;if(r!==`completed`&&r!==void 0)throw Error(`OpenAI response ended with status ${String(r)}`);let i=Array.isArray(n.output)?n.output:[],a=K(i);return{text:typeof n.output_text==`string`?n.output_text:Ie(i),output:i,toolCalls:a.map(e=>({id:e.call_id,name:e.name,args:q(e.arguments)}))}}var Le=class{constructor(e){this.config=e}managesToolLoop=!0;stream(e){return this.streamSingleTurn(e)}async complete(e){let{instructions:t,input:n}=U(e.messages),r=await Y({config:this.config,instructions:t,input:n,tools:e.tools,signal:e.signal});return{text:r.text,toolCalls:r.toolCalls}}async*streamToolLoop(e){let{instructions:t,input:n}=U(e.messages),r=[...n],i=e.maxSteps??10;for(let n=0;n<i;n++){if(e.signal?.aborted)return;let n=J({config:this.config,instructions:t,input:r,tools:e.tools,signal:e.signal}),i=[];for(;;){let e=await n.next();if(e.done){i=e.value??[];break}if(yield e.value,e.value.type===`error`)return}r.push(...i);let a=K(i);if(a.length===0)return;for(let t of a){if(e.signal?.aborted)return;let n={};try{n=JSON.parse(t.arguments)}catch{n={}}let i,a=!1;try{i=await e.callTool(t.name,n),a=l(i)}catch(e){a=!0,i={isError:!0,error:e instanceof Error?e.message:String(e)}}W(r,t.call_id,t.name,i),yield{type:`tool-result`,toolCallId:t.call_id,toolName:t.name,result:i,isError:a}}}}async runToolLoopNonStreaming(e){let{instructions:t,input:n}=U(e.messages),r=[...n],i=e.maxSteps??10,a=[],o=``;for(let n=0;n<i&&!e.signal?.aborted;n++){let n=await Y({config:this.config,instructions:t,input:r,tools:e.tools,signal:e.signal});if(r.push(...n.output),n.toolCalls.length===0){o=n.text;break}for(let t of n.toolCalls){let n;try{n=await e.callTool(t.name,t.args),l(n)}catch(e){n={isError:!0,error:e instanceof Error?e.message:String(e)}}a.push({toolName:t.name,args:t.args,result:n}),W(r,t.id,t.name,n)}}return{content:o,toolCalls:a}}async*streamSingleTurn(e){let{instructions:t,input:n}=U(e.messages),r=J({config:this.config,instructions:t,input:n,tools:e.tools,signal:e.signal});for(;;){let e=await r.next();if(e.done||(yield e.value,e.value.type===`error`))return}}};function X(e){return e.provider===`openai`?new Le(e):new Re(e)}var Re=class{constructor(e){this.config=e}stream(e){return je({config:this.config,messages:e.messages,tools:e.tools,signal:e.signal})}async complete(e){let t=await Me({config:this.config,messages:e.messages,tools:e.tools,signal:e.signal});return{text:t.text,toolCalls:t.toolCalls}}};async function*ze(e){if(e.driver.managesToolLoop&&e.driver.streamToolLoop){yield*e.driver.streamToolLoop(e);return}let{driver:t,tools:n,callTool:r,signal:i}=e,a=e.maxSteps??10,o=[...e.messages];for(let e=0;e<a;e++){if(i?.aborted)return;let e=[],a=``;try{for await(let r of t.stream({messages:o,tools:n,signal:i}))r.type===`text-delta`?a+=r.delta:r.type===`tool-call-ready`&&e.push({id:r.toolCallId,name:r.toolName,args:r.args}),yield r}catch(e){if(e instanceof M)throw e;yield{type:`error`,message:e instanceof Error?e.message:String(e)};return}if(e.length===0)return;o.push({role:`assistant`,content:a,toolCalls:e});for(let t of e){if(i?.aborted)return;let e,n=!1;try{e=await r(t.name,t.args),n=l(e)}catch(t){n=!0,e={isError:!0,error:t instanceof Error?t.message:String(t)}}o.push({role:`tool`,content:d(e),toolCallId:t.id,toolName:t.name,toolResult:e,toolIsError:n}),yield{type:`tool-result`,toolCallId:t.id,toolName:t.name,result:e,isError:n}}}}async function Be(e){if(e.driver.managesToolLoop&&e.driver.runToolLoopNonStreaming)return e.driver.runToolLoopNonStreaming(e);let{driver:t,tools:n,callTool:r,signal:i}=e,a=e.maxSteps??10,o=[...e.messages],s=[],c=``;for(let e=0;e<a&&!i?.aborted;e++){let{text:e,toolCalls:a}=await t.complete({messages:o,tools:n,signal:i});if(a.length===0){c=e;break}o.push({role:`assistant`,content:e,toolCalls:a});for(let e of a){let t,n=!1;try{t=await r(e.name,e.args),n=l(t)}catch(e){n=!0,t={isError:!0,error:e instanceof Error?e.message:String(e)}}s.push({toolName:e.name,args:e.args,result:t}),o.push({role:`tool`,content:d(t),toolCallId:e.id,toolName:e.name,toolResult:t,toolIsError:n})}}return{content:c,toolCalls:s}}async function*Z(e,t){yield*ze({driver:e,messages:t.messages,tools:t.tools,callTool:t.callTool,maxSteps:t.maxSteps,signal:t.signal})}async function*Ve(e,t){let n=``,r=null;for await(let i of Z(e,t))if(i.type===`text-delta`)n+=i.delta;else if(i.type===`tool-call-ready`)r={action:{tool:i.toolName,toolInput:i.args,log:`Calling tool ${i.toolName}`},observation:``},yield r;else if(i.type===`tool-result`&&r){let e=typeof i.result==`string`?i.result:JSON.stringify(i.result??``);yield{action:r.action,observation:e},r=null}else if(i.type===`error`)throw Error(i.message);return n}async function He(e,t){return(await Be({driver:e,messages:t.messages,tools:t.tools,callTool:t.callTool,maxSteps:t.maxSteps,signal:t.signal})).content}var Ue={openai:[`OPENAI_API_KEY`],anthropic:[`ANTHROPIC_API_KEY`],google:[`GOOGLE_API_KEY`,`GOOGLE_GENERATIVE_AI_API_KEY`],openrouter:[`OPENROUTER_API_KEY`],ollama:[],"openai-compatible":[`OPENAI_API_KEY`]};function We(t,n){if(n?.apiKey)return n.apiKey;let r=Ue[t]??[];if(typeof process<`u`)for(let n of r){let r={}[n];if(r)return e.debug(`Using API key from ${n} for ${t}`),r}if(t===`ollama`)return``;let i=r.length>0?r.join(` or `):`apiKey in llmConfig`;throw Error(`API key not found for provider '${t}'. Set ${i}.`)}function Q(e,t){let n=e.split(`/`);if(n.length<2)throw Error(`Invalid LLM string '${e}'. Expected 'provider/model'.`);let r=n[0].toLowerCase(),i=n.slice(1).join(`/`),a=[`openai`,`anthropic`,`google`,`openrouter`,`ollama`,`openai-compatible`];if(!a.includes(r))throw Error(`Unsupported provider '${r}'. Supported: ${a.join(`, `)}`);return{provider:r,model:i,apiKey:We(r,t),temperature:t?.temperature,maxTokens:t?.maxTokens,baseUrl:t?.baseUrl,extraHeaders:t?.extraHeaders,credentials:t?.credentials}}function Ge(e,t,n){return{provider:e,model:t,apiKey:We(e,n),temperature:n?.temperature,maxTokens:n?.maxTokens,baseUrl:n?.baseUrl,extraHeaders:n?.extraHeaders,credentials:n?.credentials}}var Ke=`2.0.0-beta.5`;function qe(){return Ke}function $(e,t,n,r,i,a){return typeof e==`object`&&e?{prompt:e.prompt,maxSteps:e.maxSteps,manageConnector:e.manageConnector,messages:e.messages,schema:e.schema,signal:e.signal}:{prompt:e,maxSteps:t,manageConnector:n,schema:i,signal:a}}var Je=`/api/v1/chats`,Ye=`/api/v1/chats/{chat_id}/execute`;function Xe(e,t,n,r,i){if(typeof e==`object`&&e){let t=e;return{query:t.prompt??``,maxSteps:t.maxSteps,manageConnector:t.manageConnector,externalHistory:t.externalHistory,outputSchema:t.schema}}return{query:e,maxSteps:t,manageConnector:n,externalHistory:r,outputSchema:i}}var Ze=class{agentId;apiKey;baseUrl;chatId=null;constructor(e){this.agentId=e.agentId,this.baseUrl=e.baseUrl??`https://cloud.manufact.com`;let t=e.apiKey??(typeof process<`u`&&{}.MCP_USE_API_KEY);if(!t)throw Error(`API key is required for remote execution. Please provide it as a parameter or set the MCP_USE_API_KEY environment variable. You can get an API key from https://cloud.manufact.com`);this.apiKey=t}pydanticToJsonSchema(e){return t(e)}parseStructuredResponse(t,n){let r;if(typeof t==`object`&&t)if(`result`in t){let e=t.result;r=typeof e==`object`&&e&&`result`in e?e.result:e}else r=t;else if(typeof t==`string`)try{r=JSON.parse(t)}catch{r={content:t}}else r=t;try{return n.parse(r)}catch(t){e.warn(`Failed to parse structured output: ${t}`);let i=n._def?.shape();if(i&&`content`in i)return n.parse({content:String(r)});throw t}}async createChatSession(){let t={title:`Remote Agent Session - ${this.agentId}`,agent_id:this.agentId,type:`agent_execution`},n={"Content-Type":`application/json`,"x-api-key":this.apiKey},r=`${this.baseUrl}${Je}`;e.debug(`\u{1F4DD} Creating chat session for agent ${this.agentId}`);try{let i=await fetch(r,{method:`POST`,headers:n,body:JSON.stringify(t)});if(!i.ok){let e=await i.text(),t=i.status;throw Error(t===404?`Agent not found: Agent '${this.agentId}' does not exist or you don't have access to it. Please verify the agent ID and ensure it exists in your account.`:`Failed to create chat session: ${t} - ${e}`)}let a=(await i.json()).id;return e.debug(`\u2705 Chat session created: ${a}`),a}catch(e){throw e instanceof Error?TypeError(`Failed to create chat session: ${e.message}`):Error(`Failed to create chat session: ${String(e)}`)}}async run(t,n,r,i,a){let{query:o,maxSteps:s,externalHistory:c,outputSchema:l}=Xe(t,n,r,i,a);c!==void 0&&e.warn(`External history is not yet supported for remote execution`);try{e.debug(`\u{1F310} Executing query on remote agent ${this.agentId}`),this.chatId===null&&(this.chatId=await this.createChatSession());let t=this.chatId,n={query:o,max_steps:s??10};l&&(n.output_schema=this.pydanticToJsonSchema(l),e.debug(`🔧 Using structured output with schema`));let r={"Content-Type":`application/json`,"x-api-key":this.apiKey},i=`${this.baseUrl}${Ye.replace(`{chat_id}`,t)}`;e.debug(`\u{1F680} Executing agent in chat ${t}`);let a=await fetch(i,{method:`POST`,headers:r,body:JSON.stringify(n),signal:AbortSignal.timeout(3e5)});if(!a.ok){let t=await a.text(),n=a.status;throw n===401?(e.error(`\u274C Authentication failed: ${t}`),Error(`Authentication failed: Invalid or missing API key. Please check your API key and ensure the MCP_USE_API_KEY environment variable is set correctly.`)):n===403?(e.error(`\u274C Access forbidden: ${t}`),Error(`Access denied: You don't have permission to execute agent '${this.agentId}'. Check if the agent exists and you have the necessary permissions.`)):n===404?(e.error(`\u274C Agent not found: ${t}`),Error(`Agent not found: Agent '${this.agentId}' does not exist or you don't have access to it. Please verify the agent ID and ensure it exists in your account.`)):n===422?(e.error(`\u274C Validation error: ${t}`),Error(`Request validation failed: ${t}. Please check your query parameters and output schema format.`)):n===500?(e.error(`\u274C Server error: ${t}`),Error(`Internal server error occurred during agent execution. Please try again later or contact support if the issue persists.`)):(e.error(`\u274C Remote execution failed with status ${n}: ${t}`),Error(`Remote agent execution failed: ${n} - ${t}`))}let c=await a.json();if(e.debug(`\u{1F527} Response: ${JSON.stringify(c)}`),e.debug(`✅ Remote execution completed successfully`),typeof c==`object`&&c){if(c.status===`error`||c.error!==null){let t=c.error??String(c);throw e.error(`\u274C Remote agent execution failed: ${t}`),Error(`Remote agent execution failed: ${t}`)}if(String(c).includes(`failed to initialize`))throw e.error(`\u274C Agent initialization failed: ${c}`),Error(`Agent initialization failed on remote server. This usually indicates:
|
|
17
17
|
\u2022 Invalid agent configuration (LLM model, system prompt)
|
|
18
18
|
\u2022 Missing or invalid MCP server configurations
|
|
19
19
|
\u2022 Network connectivity issues with MCP servers
|
|
20
20
|
\u2022 Missing environment variables or credentials
|
|
21
|
-
Raw error: ${c}`)}return l?this.parseStructuredResponse(c,l):typeof c==`object`&&c&&`result`in c?c.result:typeof c==`string`?c:String(c)}catch(
|
|
21
|
+
Raw error: ${c}`)}return l?this.parseStructuredResponse(c,l):typeof c==`object`&&c&&`result`in c?c.result:typeof c==`string`?c:String(c)}catch(t){throw t instanceof Error?t.name===`AbortError`?(e.error(`\u274C Remote execution timed out: ${t}`),Error(`Remote agent execution timed out. The server may be overloaded or the query is taking too long to process. Try again or use a simpler query.`)):(e.error(`\u274C Remote execution error: ${t}`),Error(`Remote agent execution failed: ${t.message}`)):(e.error(`\u274C Remote execution error: ${t}`),Error(`Remote agent execution failed: ${String(t)}`))}}async*stream(e,t,n,r,i){return await this.run(e,t,n,r,i)}async close(){e.debug(`🔌 Remote agent client closed`)}},Qe=class{static getPackageVersion(){return qe()}driver;client;connectors=[];clientOwnedByAgent=!1;nativeAdapter;providerTools=[];callTool;maxSteps;autoInitialize;systemPrompt;disallowedTools;exposeResourcesAsTools;exposePromptsAsTools;initialized=!1;isRemote=!1;remoteAgent=null;isSimplifiedMode=!1;llmString;llmConfig;mcpServersConfig;explicitProviderConfig;conversationMessages=[];memoryEnabled;boundConnections;constructor(e){if(e.agentId){this.isRemote=!0,this.remoteAgent=new Ze({agentId:e.agentId,apiKey:e.apiKey,baseUrl:e.baseUrl}),this.maxSteps=e.maxSteps??10,this.autoInitialize=e.autoInitialize??!1,this.nativeAdapter=new a,this.systemPrompt=e.systemPrompt??`You are a helpful assistant with access to MCP tools.`,this.disallowedTools=[],this.exposeResourcesAsTools=!0,this.exposePromptsAsTools=!0,this.memoryEnabled=e.memoryEnabled??!0;return}if(this.maxSteps=e.maxSteps??10,this.autoInitialize=e.autoInitialize??!1,this.systemPrompt=e.systemPrompt??`You are a helpful assistant with access to MCP tools.`,this.disallowedTools=e.disallowedTools??[],this.exposeResourcesAsTools=e.exposeResourcesAsTools??!0,this.exposePromptsAsTools=e.exposePromptsAsTools??!0,this.memoryEnabled=e.memoryEnabled??!0,this.nativeAdapter=new a(this.disallowedTools),this.llmConfig=e.llmConfig,this.resolveMcpServers(e.mcpServers),typeof e.llm==`string`){if(this.isSimplifiedMode=!0,this.llmString=e.llm,!this.hasLiveConnections()&&(!this.mcpServersConfig||Object.keys(this.mcpServersConfig).length===0)&&!e.client&&!e.connectors?.length)throw Error(`Simplified mode requires mcpServers, or an existing client/connectors.`)}else if(this.explicitProviderConfig=e.llm,this.client=e.client,this.connectors=e.connectors??[],!this.hasLiveConnections()&&!this.client&&this.connectors.length===0&&(!this.mcpServersConfig||Object.keys(this.mcpServersConfig).length===0))throw Error(`Explicit mode requires mcpServers, client, or connectors.`);e.client&&(this.client=e.client),e.connectors?.length&&(this.connectors=e.connectors),this.hasLiveConnections()&&this.explicitProviderConfig?this.bindConnections(this.boundConnections,this.explicitProviderConfig):this.hasLiveConnections()&&this.llmString&&(this.driver=X(Q(this.llmString,this.llmConfig)),this.bindConnections(this.boundConnections,Q(this.llmString,this.llmConfig)))}resolveMcpServers(e){if(e){if(Array.isArray(e)){this.boundConnections=e;return}this.mcpServersConfig=e}}hasLiveConnections(){return(this.boundConnections?.length??0)>0}async initialize(){if(this.isRemote){this.initialized=!0;return}if(!this.initialized){if(this.isSimplifiedMode){if(!this.client&&this.mcpServersConfig){let{MCPClient:e}=await n(async()=>{let{MCPClient:e}=await import(`./index-BMaSsizY.js`).then(e=>e.kt);return{MCPClient:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));this.client=new e({mcpServers:this.mcpServersConfig}),this.clientOwnedByAgent=!0}this.llmString&&(this.driver=X(Q(this.llmString,this.llmConfig)))}else this.explicitProviderConfig&&(this.driver=X(this.explicitProviderConfig));if(!this.driver)throw Error(`LLM driver not configured.`);this.hasLiveConnections()||await this.loadTools(),this.initialized=!0,e.debug(`MCPAgent initialized`)}}async loadTools(){let e=[];if(this.client){(!this.client.activeSessions||Object.keys(this.client.activeSessions).length===0)&&await this.client.createAllSessions();let t=this.client.getAllActiveSessions(),n=Object.values(t).map(e=>e.connector);e.push(...await this.nativeAdapter.createToolsFromConnectors(n)),this.exposeResourcesAsTools&&e.push(...await this.nativeAdapter.createResourcesFromConnectors(n)),this.exposePromptsAsTools&&e.push(...await this.nativeAdapter.createPromptsFromConnectors(n))}else{for(let e of this.connectors)e.isClientConnected||await e.connect();e.push(...await this.nativeAdapter.createToolsFromConnectors(this.connectors)),this.exposeResourcesAsTools&&e.push(...await this.nativeAdapter.createResourcesFromConnectors(this.connectors)),this.exposePromptsAsTools&&e.push(...await this.nativeAdapter.createPromptsFromConnectors(this.connectors))}this.providerTools=this.nativeAdapter.toProviderTools(e),this.callTool=this.nativeAdapter.createCallTool()}bindConnections(e,t){let n=new Set(this.disallowedTools),r=new Set,i=new Map,a=e=>{if(!r.has(e))return r.add(e),e;let t=2;for(;r.has(`${e}_${t}`);)t++;let n=`${e}_${t}`;return r.add(n),n},o=[];for(let t of e)for(let e of t.tools??[]){if(n.has(e.name))continue;let r=a(e.name);i.set(r,{connection:t,mcpName:e.name}),o.push({name:r,description:e.description,inputSchema:e.inputSchema??{type:`object`,properties:{}}})}this.providerTools=o,this.callTool=async(e,t)=>{let n=i.get(e);if(!n)throw Error(`Unknown tool: ${e}`);return n.connection.callTool(n.mcpName,t)},this.driver=X(t),this.initialized=!0}buildMessages(e){let t=[{role:`system`,content:this.systemPrompt}];return this.memoryEnabled&&this.conversationMessages.length>0&&t.push(...this.conversationMessages),e.messages?.length&&t.push(...e.messages),e.prompt&&t.push({role:`user`,content:e.prompt}),t}getConversationHistory(){return[...this.conversationMessages]}clearConversationHistory(){this.conversationMessages=[]}setSystemMessage(e){this.systemPrompt=e}async ensureReady(e=!0){if(e&&!this.initialized)if(this.autoInitialize)await this.initialize();else throw Error(`MCPAgent not initialized. Call initialize() first.`);if(!this.driver||!this.callTool)throw Error(`MCPAgent driver or tools not ready.`)}nativeRunParams(e){return{messages:this.buildMessages(e),tools:this.providerTools,callTool:this.callTool,maxSteps:e.maxSteps??this.maxSteps,signal:e.signal}}async run(e,t,n,r,i,a){let o=$(e,t,n,r,i,a);if(o.schema)throw Error(`Structured output requires @mcp-use/agent/langchain or pass a JSON schema via prompt.`);if(this.isRemote&&this.remoteAgent)return this.remoteAgent.run(o.prompt??``,o.maxSteps,o.manageConnector);await this.ensureReady(o.manageConnector??!0);let s=await He(this.driver,this.nativeRunParams(o));return this.memoryEnabled&&o.prompt&&(this.conversationMessages.push({role:`user`,content:o.prompt}),this.conversationMessages.push({role:`assistant`,content:s})),s}async*stream(e,t,n,r,i,a){let o=$(e,t,n,r,i,a);if(this.isRemote&&this.remoteAgent)return await this.remoteAgent.run(o.prompt??``,o.maxSteps,o.manageConnector);await this.ensureReady(o.manageConnector??!0);let s=yield*Ve(this.driver,this.nativeRunParams(o));return this.memoryEnabled&&o.prompt&&(this.conversationMessages.push({role:`user`,content:o.prompt}),this.conversationMessages.push({role:`assistant`,content:s})),s}async*streamEvents(e,t,n,r,i,a){let o=$(e,t,n,r,i,a);if(this.isRemote&&this.remoteAgent)throw Error(`streamEvents is not supported for remote agents.`);await this.ensureReady(o.manageConnector??!0),yield*Z(this.driver,this.nativeRunParams(o))}async chat(e){return await this.ensureReady(),(await this.driver.complete({messages:e.messages,tools:[],signal:e.signal})).text}async close(){this.clientOwnedByAgent&&this.client&&await this.client.closeAllSessions?.(),this.initialized=!1}};async function $e(e){return(await X(e.config).complete({messages:e.messages,tools:[],signal:e.signal})).text}export{$e as a,Ge as c,D as i,Qe as n,re as o,we as r,E as s,Ce as t};
|