@mcpc-tech/unplugin-dev-inspector-mcp 0.0.40 → 0.0.41
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/client/dist/inspector.iife.js +1 -1
- package/dist/config-updater.cjs +73 -131
- package/dist/config-updater.js +73 -131
- package/dist/index.cjs +58 -13
- package/dist/index.d.cts +4 -4
- package/dist/index.js +58 -13
- package/package.json +1 -1
|
@@ -6882,7 +6882,7 @@ ${e.themeCSS}`),e.fontFamily!==void 0&&(n+=`
|
|
|
6882
6882
|
`)||(e.endsWith("```\n")||e.endsWith("```"))&&t%2==0)return e;let r=e.match(B7t);if(r&&!n){let t=r[2];if(!t||z7.test(t))return e;if(n9t(e)%2==1)return`${e}\``}return e},i9t=e=>{let t=e.match(V7t);if(t){let n=t[2];if(!n||z7.test(n))return e;if((e.match(/~~/g)||[]).length%2==1)return`${e}~~`}return e},a9t=e=>{if((e.match(/\$\$/g)||[]).length%2==0)return e;let t=e.indexOf(`$$`);return t!==-1&&e.indexOf(`
|
|
6883
6883
|
`,t)!==-1&&!e.endsWith(`
|
|
6884
6884
|
`)?`${e}
|
|
6885
|
-
$$`:`${e}$$`},o9t=e=>{let t=0,n=e.match(/\*+/g)||[];for(let e of n){let n=e.length;n>=3&&(t+=Math.floor(n/3))}return t},s9t=e=>{if(V7(e)||K7t.test(e))return e;let t=e.match(L7t);if(t){let n=t[2];if(!n||z7.test(n))return e;if(o9t(e)%2==1)return`${e}***`}return e},c9t=e=>{if(!e||typeof e!=`string`)return e;let t=e,n=q7t(t);return n.endsWith(`](streamdown:incomplete-link)`)?n:(t=n,t=s9t(t),t=J7t(t),t=Y7t(t),t=Z7t(t),t=e9t(t),t=r9t(t),t=i9t(t),t=a9t(t),t)},l9t={harden:[Qfe,{allowedImagePrefixes:[`*`],allowedLinkPrefixes:[`*`],defaultOrigin:void 0,allowDataImages:!0}],raw:Ebe,katex:[sy,{errorColor:`var(--color-muted-foreground)`}]},u9t={gfm:[GCe,{}],math:[rwe,{singleDollarTextMath:!1}],cjkFriendly:[axe,{}],cjkFriendlyGfmStrikethrough:[sxe,{}]},d9t=(0,_.createContext)([`github-light`,`github-dark`]),f9t=(0,_.createContext)(void 0),p9t=(0,_.createContext)(!0),H7=(0,_.createContext)({isAnimating:!1}),m9t=(0,_.memo)(({content:e,shouldParseIncompleteMarkdown:t,...n})=>{let r=(0,_.useMemo)(()=>typeof e==`string`&&t?c9t(e.trim()):e,[e,t]);return(0,S.jsx)(qfe,{...n,children:r})},(e,t)=>e.content===t.content);m9t.displayName=`Block`;var h9t=[`github-light`,`github-dark`],g9t=(0,_.memo)(({children:e,parseIncompleteMarkdown:t=!0,components:n,rehypePlugins:r=Object.values(l9t),remarkPlugins:i=Object.values(u9t),className:a,shikiTheme:o=h9t,mermaidConfig:s,controls:l=!0,isAnimating:u=!1,urlTransform:d=e=>e,BlockComponent:f=m9t,parseMarkdownIntoBlocksFn:m=N7t,...h})=>{let g=(0,_.useId)(),v=(0,_.useMemo)(()=>m(typeof e==`string`?e:``),[e,m]);(0,_.useEffect)(()=>{Array.isArray(r)&&r.some(e=>Array.isArray(e)?e[0]===sy:e===sy)&&Promise.resolve().then(()=>p(O5t(),1))},[r]);let y=(0,_.useMemo)(()=>({isAnimating:u}),[u]);return(0,S.jsx)(d9t.Provider,{value:o,children:(0,S.jsx)(f9t.Provider,{value:s,children:(0,S.jsx)(p9t.Provider,{value:l,children:(0,S.jsx)(H7.Provider,{value:y,children:(0,S.jsx)(`div`,{className:F7(`space-y-4`,a),children:v.map((e,a)=>(0,S.jsx)(f,{components:{...O7t,...n},content:e,index:a,rehypePlugins:r,remarkPlugins:i,shouldParseIncompleteMarkdown:t,urlTransform:d,...h},`${g}-block-${a}`))})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating);g9t.displayName=`Streamdown`;let _9t=(0,_.createContext)(null),v9t=()=>{let e=(0,_.useContext)(_9t);if(!e)throw Error(`Reasoning components must be used within Reasoning`);return e},y9t=(0,_.memo)(({className:e,isStreaming:t=!1,open:n,defaultOpen:r=!0,onOpenChange:i,duration:a,children:o,...s})=>{let[l,u]=Yt({prop:n,defaultProp:r,onChange:i}),[d,f]=Yt({prop:a,defaultProp:void 0}),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null);return(0,_.useEffect)(()=>{t?h===null&&g(Date.now()):h!==null&&(f(Math.ceil((Date.now()-h)/1e3)),g(null))},[t,h,f]),(0,_.useEffect)(()=>{if(r&&!t&&l&&!p){let e=setTimeout(()=>{u(!1),m(!0)},1e3);return()=>clearTimeout(e)}},[t,l,r,u,p]),(0,S.jsx)(_9t.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:d},children:(0,S.jsx)(xn,{className:nt(`not-prose mb-4`,e),onOpenChange:e=>{u(e)},open:l,...s,children:o})})}),b9t=(e,t)=>e||t===0?(0,S.jsx)(Foe,{duration:1,children:`Thinking...`}):t===void 0?(0,S.jsx)(`p`,{children:`Thought for a few seconds`}):(0,S.jsxs)(`p`,{children:[`Thought for `,t,` seconds`]}),x9t=(0,_.memo)(({className:e,children:t,...n})=>{let{isStreaming:r,isOpen:i,duration:a}=v9t();return(0,S.jsx)(Sn,{className:nt(`flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground`,e),...n,children:t??(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(gt,{className:`size-4`}),b9t(r,a),(0,S.jsx)(_t,{className:nt(`size-4 transition-transform`,i?`rotate-180`:`rotate-0`)})]})})}),S9t=(0,_.memo)(({className:e,children:t,...n})=>(0,S.jsx)(Cn,{className:nt(`mt-4 text-sm`,`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...n,children:(0,S.jsx)(g9t,{...n,children:t})}));y9t.displayName=`Reasoning`,x9t.displayName=`ReasoningTrigger`,S9t.displayName=`ReasoningContent`,(0,_.createContext)(null);let C9t=(0,_.memo)(({className:e,...t})=>(0,S.jsx)(g9t,{className:nt(`size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,e),...t}),(e,t)=>e.children===t.children);C9t.displayName=`MessageResponse`;let w9t=(0,_.createContext)({code:``}),T9t={name:`line-numbers`,line(e,t){e.children.unshift({type:`element`,tagName:`span`,properties:{className:[`inline-block`,`min-w-10`,`mr-4`,`text-right`,`select-none`,`text-muted-foreground`]},children:[{type:`text`,value:String(t)}]})}};async function E9t(e,t,n=!1){let r=n?[T9t]:[];return await Promise.all([Gqe(e,{lang:t,theme:`one-light`,transformers:r}),Gqe(e,{lang:t,theme:`one-dark-pro`,transformers:r})])}let U7=({code:e,language:t,showLineNumbers:n=!1,className:r,children:i,...a})=>{let[o,s]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),d=(0,_.useRef)(!1);return(0,_.useEffect)(()=>(E9t(e,t,n).then(([e,t])=>{d.current||=(s(e),u(t),!0)}),()=>{d.current=!1}),[e,t,n]),(0,S.jsx)(w9t.Provider,{value:{code:e},children:(0,S.jsx)(`div`,{className:nt(`group relative w-full overflow-hidden rounded-md border bg-background text-foreground`,r),...a,children:(0,S.jsxs)(`div`,{className:`relative`,children:[(0,S.jsx)(`div`,{className:`overflow-x-auto dark:hidden [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm`,dangerouslySetInnerHTML:{__html:o}}),(0,S.jsx)(`div`,{className:`hidden overflow-x-auto dark:block [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm`,dangerouslySetInnerHTML:{__html:l}}),i&&(0,S.jsx)(`div`,{className:`absolute top-2 right-2 flex items-center gap-2`,children:i})]})})})},D9t=({className:e,...t})=>(0,S.jsx)(xn,{className:nt(`not-prose mb-4 w-full rounded-md border`,e),...t}),O9t=e=>{let t={"input-streaming":`Pending`,"input-available":`Running`,"approval-requested":`Awaiting Approval`,"approval-responded":`Responded`,"output-available":`Completed`,"output-error":`Error`,"output-denied":`Denied`};return(0,S.jsxs)(it,{className:`gap-1.5 rounded-full text-xs`,variant:`secondary`,children:[{"input-streaming":(0,S.jsx)(wt,{className:`size-4`}),"input-available":(0,S.jsx)(Tt,{className:`size-4 animate-pulse`}),"approval-requested":(0,S.jsx)(Tt,{className:`size-4 text-yellow-600`}),"approval-responded":(0,S.jsx)(xt,{className:`size-4 text-blue-600`}),"output-available":(0,S.jsx)(xt,{className:`size-4 text-green-600`}),"output-error":(0,S.jsx)(Ct,{className:`size-4 text-red-600`}),"output-denied":(0,S.jsx)(Ct,{className:`size-4 text-orange-600`})}[e],t[e]]})},k9t=({className:e,title:t,type:n,state:r,...i})=>(0,S.jsxs)(Sn,{className:nt(`flex w-full items-center justify-between gap-4 p-3`,e),...i,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(Ft,{className:`size-4 text-muted-foreground`}),(0,S.jsx)(`span`,{className:`font-medium text-sm`,children:t??n.split(`-`).slice(1).join(`-`)}),O9t(r)]}),(0,S.jsx)(_t,{className:`size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]}),A9t=({className:e,...t})=>(0,S.jsx)(Cn,{className:nt(`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...t}),j9t=({className:e,input:t,...n})=>(0,S.jsxs)(`div`,{className:nt(`space-y-2 overflow-hidden p-4`,e),...n,children:[(0,S.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Parameters`}),(0,S.jsx)(`div`,{className:`rounded-md bg-muted/50`,children:(0,S.jsx)(U7,{code:JSON.stringify(t,null,2),language:`json`})})]}),M9t=({className:e,output:t,errorText:n,...r})=>{if(!(t||n))return null;let i=(0,S.jsx)(`div`,{children:t});return typeof t==`object`&&!(0,_.isValidElement)(t)?i=(0,S.jsx)(U7,{code:JSON.stringify(t,null,2),language:`json`}):typeof t==`string`&&(i=(0,S.jsx)(U7,{code:t,language:`json`})),(0,S.jsxs)(`div`,{className:nt(`space-y-2 p-4`,e),...r,children:[(0,S.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:n?`Error`:`Result`}),(0,S.jsxs)(`div`,{className:nt(`overflow-x-auto rounded-md text-xs [&_table]:w-full`,n?`bg-destructive/10 text-destructive`:`bg-muted/50 text-foreground`),children:[n&&(0,S.jsx)(`div`,{children:n}),i]})]})};function N9t({className:e,...t}){return(0,S.jsx)(`div`,{"data-slot":`card`,className:nt(`bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm`,e),...t})}function P9t({className:e,...t}){return(0,S.jsx)(`div`,{"data-slot":`card-header`,className:nt(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,e),...t})}function F9t({className:e,...t}){return(0,S.jsx)(`div`,{"data-slot":`card-content`,className:nt(`px-6`,e),...t})}let I9t=(0,_.createContext)(null),L9t=({className:e,isStreaming:t=!1,children:n,...r})=>(0,S.jsx)(I9t.Provider,{value:{isStreaming:t},children:(0,S.jsx)(xn,{asChild:!0,"data-slot":`plan`,...r,children:(0,S.jsx)(N9t,{className:nt(`shadow-none`,e),children:n})})}),R9t=({className:e,...t})=>(0,S.jsx)(P9t,{className:nt(`flex items-start justify-between`,e),"data-slot":`plan-header`,...t}),z9t=e=>(0,S.jsx)(Cn,{asChild:!0,children:(0,S.jsx)(F9t,{"data-slot":`plan-content`,...e})}),B9t=({className:e,...t})=>(0,S.jsx)(Sn,{asChild:!0,children:(0,S.jsxs)(Wt,{className:nt(`size-8`,e),"data-slot":`plan-trigger`,size:`icon`,variant:`ghost`,...t,children:[(0,S.jsx)(yt,{className:`size-4`}),(0,S.jsx)(`span`,{className:`sr-only`,children:`Toggle plan`})]})});function V9t(e){let t=e;return typeof t.type==`string`&&t.type.startsWith(`tool-`)&&`state`in t}function H9t(e,t,n,r,i){if(e.type===`text`&&e.text)return(0,S.jsx)(C9t,{className:`whitespace-pre-wrap`,children:e.text},`${t}-${n}`);if(e.type===`reasoning`)return(0,S.jsxs)(y9t,{className:`w-full`,isStreaming:r,children:[(0,S.jsx)(x9t,{}),(0,S.jsx)(S9t,{children:e.text})]},`${t}-${n}`);let a=i?.plan;if(a&&n===0)return(0,S.jsx)(`div`,{className:`w-full`,children:(0,S.jsxs)(L9t,{defaultOpen:!0,isStreaming:r,children:[(0,S.jsx)(R9t,{className:`flex flex-row items-center`,children:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`h1`,{className:`text-base`,children:`Agent Plan`}),(0,S.jsx)(B9t,{className:`mb-2`})]})}),(0,S.jsx)(z9t,{children:(0,S.jsx)(`ul`,{className:`space-y-2`,children:a.map((e,t)=>{let n=e.content||JSON.stringify(e),r=e.priority,i=e.status;return(0,S.jsxs)(`li`,{className:`flex items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`flex-1`,children:[(0,S.jsx)(`div`,{className:`text-sm ${i===`done`?`line-through text-muted-foreground`:`text-foreground`}`,children:n}),r&&(0,S.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Priority: `,r]})]}),(0,S.jsx)(`div`,{className:`shrink-0 text-xs`,children:(0,S.jsx)(`span`,{className:`px-2 py-1 rounded-full font-medium text-[10px] uppercase tracking-wide ${i===`pending`?`bg-muted text-muted-foreground`:`bg-primary/10 text-primary`}`,children:i??`pending`})})]},`plan-${t}`)})})})]})},`${t}-plan`);if(V9t(e)){let r=e=>(e=e.replace(`acp-ai-sdk-tools`,``),e),i=e.input;if(!i||!i.toolName)return null;let a=r(i.toolName),o=e.state,s=o===`output-available`||o===`output-error`;return(0,S.jsxs)(D9t,{defaultOpen:s,children:[(0,S.jsx)(k9t,{title:r(a.length>20?`${a.slice(0,20)}...`:a),type:a,state:o}),(0,S.jsxs)(A9t,{children:[e.input!==void 0&&(0,S.jsx)(j9t,{input:i.args}),s&&(0,S.jsx)(M9t,{output:e.output?(0,S.jsx)(U7,{code:JSON.stringify(e.output,null,2),language:`json`}):null,errorText:e.errorText})]})]},`${t}-${n}`)}return null}let U9t=({messages:e,status:t,selectedAgent:n})=>{let r=Ac.find(e=>e.name===(n||jc))||Ac[0],i=t===`submitted`||t===`streaming`,a=e[e.length-1],o=i&&(!a||a.role===`user`);return(0,S.jsxs)(qoe,{className:`w-full h-full`,children:[(0,S.jsx)(Joe,{className:`p-3 space-y-3`,children:e.length===0&&!i?(0,S.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`p`,{className:`text-sm`,children:`No messages yet`}),(0,S.jsx)(`p`,{className:`text-xs mt-1`,children:`Enter a question below to start`})]})}):(0,S.jsxs)(S.Fragment,{children:[e.map(e=>(0,S.jsxs)(kse,{className:`items-start`,from:e.role,children:[(0,S.jsx)(Ase,{children:e.parts.map((n,r)=>H9t(n,e.id,r,t===`streaming`,e.metadata))}),e.role===`assistant`&&(0,S.jsx)(jse,{name:r.name,src:r.meta?.icon??``})]},e.id)),o&&(0,S.jsxs)(kse,{className:`items-start`,from:`assistant`,children:[(0,S.jsx)(Ase,{children:(0,S.jsx)(Nse,{size:16})}),(0,S.jsx)(jse,{name:r.name,src:r.meta?.icon??``})]})]})}),(0,S.jsx)(Yoe,{})]})};function W9t(e,t,n=50){let[r,i]=(0,_.useState)(``),a=(0,_.useRef)(0),o=(0,_.useRef)(``);return(0,_.useEffect)(()=>{if(e.length<r.length||r&&!e.startsWith(r.slice(0,Math.min(r.length,20)))){i(e),o.current=e,a.current=Date.now();return}if(!t){r!==e&&(i(e),o.current=e);return}let s=e.slice(o.current.length);if(!s)return;let l=Date.now();if(l-a.current<n)return;let u=/[.?!。?!](\s|$)|[\n]/.test(s),d=s.length>50,f=s.trim().length<5;(u&&!f||d)&&(i(e),o.current=e,a.current=l)},[e,t,n,r]),r}function G9t({initialOffset:e={x:0,y:0}}={}){let t=(0,_.useRef)(null),[n,r]=(0,_.useState)(!1),i=(0,_.useRef)(e),a=(0,_.useRef)({x:0,y:0}),o=(0,_.useRef)({x:0,y:0}),s=(0,_.useCallback)(()=>{if(t.current){let{x:e,y:n}=i.current;t.current.style.transform=`translate3d(calc(-50% + ${e}px), ${n}px, 0)`}},[]),l=(0,_.useCallback)(e=>{e.target.closest(`button, input, a, [data-no-drag]`)||(e.preventDefault(),r(!0),a.current={x:e.clientX,y:e.clientY},o.current={...i.current})},[]);return(0,_.useEffect)(()=>{let e=e=>{if(!n)return;let t=e.clientX-a.current.x,r=e.clientY-a.current.y;i.current={x:o.current.x+t,y:o.current.y+r},s()},t=()=>{r(!1)};return n&&(window.addEventListener(`mousemove`,e,{passive:!0}),window.addEventListener(`mouseup`,t)),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}},[n,s]),(0,_.useEffect)(()=>{s()},[s]),{elementRef:t,isDragging:n,handleMouseDown:l}}let K9t=`AI_SELECTED_AGENT`,q9t=e=>{let[t,n]=(0,_.useState)(()=>{if(typeof window<`u`){let e=localStorage.getItem(K9t);if(e)return e}return e}),[r,i]=(0,_.useState)(!1);return(0,_.useEffect)(()=>{typeof window<`u`?Lc().then(e=>{e&&e!==jc&&n(e)}).finally(()=>{i(!0)}):i(!0)},[]),{agent:t,setAgent:e=>{n(e),!(typeof window>`u`)&&(e?.trim()?localStorage.setItem(K9t,e):localStorage.removeItem(K9t))},isReady:r}},J9t=({isActive:e,onToggleInspector:t,onSubmitAgent:n,onCancel:r,isAgentWorking:i,messages:a,status:o,inspectionCount:s=0,inspectionItems:l=[],onRemoveInspection:u=()=>{},toolsReady:d=!0})=>{let[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(`none`),[x,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(!0),{agent:O,setAgent:k,isReady:A}=q9t(jc),[j,M]=(0,_.useState)(!1),[N,P]=(0,_.useState)(null),[F,I]=(0,_.useState)(null),L=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(!A||!d)return;let e=!0,t=Ac.find(e=>e.name===O)||Ac[0];return(async()=>{if(L.current){try{await fetch(`${Pc()}/api/acp/cleanup-session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:L.current})})}catch(e){console.warn(`[InspectorBar] Failed to cleanup previous session:`,e)}L.current=null,e&&I(null)}console.log(`[InspectorBar] Initializing session for ${t.name}...`);try{let n=await fetch(`${Pc()}/api/acp/init-session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agent:t,envVars:{}})});if(!n.ok)throw Error(`Failed to init session`);let r=await n.json();e&&r.sessionId&&(console.log(`[InspectorBar] Session initialized: ${r.sessionId}`),I(r.sessionId),L.current=r.sessionId)}catch(e){console.error(`[InspectorBar] Failed to initialize session:`,e)}})(),()=>{e=!1}},[O,A,d]),(0,_.useEffect)(()=>()=>{L.current&&(console.log(`[InspectorBar] Cleaning up session on unmount: ${L.current}`),fetch(`${Pc()}/api/acp/cleanup-session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:L.current}),keepalive:!0}).catch(e=>console.warn(`[InspectorBar] Failed to cleanup session:`,e)))},[]);let R=Ac.find(e=>e.name===O)||Ac[0],{elementRef:ee,isDragging:te,handleMouseDown:z}=G9t(),[B,ne]=(0,_.useState)(null),[re,ie]=(0,_.useState)(``),ae=W9t(re,i,50),[oe,se]=(0,_.useState)(``),ce=(0,_.useRef)(``),le=(0,_.useRef)(``);(0,_.useEffect)(()=>{let e=ae,t=ce.current;if(e.length<t.length||!e.startsWith(t)){se(e),ce.current=e;return}if(e.length>t.length){let n=e.slice(t.length).trim();n&&se(n),ce.current=e}},[ae]);let ue=(0,_.useRef)(null),de=(0,_.useRef)(null),fe=(0,_.useRef)(null),pe=(0,_.useRef)(!1);(0,_.useEffect)(()=>{if(a.length===0){ie(``),v(null),fe.current=null,pe.current=!1,se(``),ce.current=``;return}let e=a[a.length-1];if(e.role!==`assistant`)return;let t=Roe(e),{displayText:n,toolCall:r}=Boe(e,t||fe.current);ie(n||``),t&&(fe.current=t),r?(de.current&&=(clearTimeout(de.current),null),v(r),pe.current=!0):pe.current=!1},[a]),(0,_.useEffect)(()=>{oe!==le.current&&(pe.current||v(null),le.current=oe)},[oe]),(0,_.useEffect)(()=>{f&&ue.current&&ue.current.focus()},[f]),(0,_.useEffect)(()=>{if(!i&&w){C(!1),T(!1),D(!1);let e=setTimeout(()=>{D(!0)},2e3);return()=>clearTimeout(e)}},[i,w]),(0,_.useEffect)(()=>{function e(e){let{plan:t,inspectionId:n}=e.detail;if(t?.steps){let e=t.steps.find(e=>e.status===`in-progress`),r=t.steps.filter(e=>e.status===`completed`).length;ne({id:n,status:`in-progress`,currentStep:e?{title:e.title,index:r+1,total:t.steps.length}:void 0})}}function t(e){let{status:t,result:n,inspectionId:r}=e.detail;ne({id:r,status:t,message:n?.message||n})}return window.addEventListener(`plan-progress-reported`,e),window.addEventListener(`inspection-result-received`,t),()=>{window.removeEventListener(`plan-progress-reported`,e),window.removeEventListener(`inspection-result-received`,t)}},[]);let me=e=>{e.preventDefault(),m.trim()&&(de.current&&=(clearTimeout(de.current),null),v(null),ie(``),se(``),ne(null),fe.current=null,ce.current=``,C(!0),T(!0),n(m,O,F||void 0),h(``),p(!0),b(`chat`))},he=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),me(e)),e.key===`Escape`&&(p(!1),ue.current?.blur())},ge=o===`error`,_e=a.length>0,ve=f&&!x,ye=(!f||x)&&(i||_e||B);return(0,S.jsxs)(S.Fragment,{children:[(f||y!==`none`)&&(0,S.jsx)(`div`,{className:`fixed inset-0 z-[999998] bg-transparent`,onClick:()=>{!w&&!i&&(p(!1),b(`none`))}}),(0,S.jsxs)(`div`,{ref:ee,className:nt(`fixed bottom-8 left-1/2 z-[999999]`,`transition-all duration-300 ease-[cubic-bezier(0.23,1,0.32,1)]`,f?`w-[480px]`:ye?`w-auto min-w-[200px] max-w-[480px]`:`w-[190px]`,te?`cursor-grabbing`:`cursor-grab`),onMouseDown:z,onMouseEnter:()=>{te||(i||w?(p(!0),b(`chat`)):E&&p(!0))},onMouseLeave:()=>{!m.trim()&&!w&&!te&&(p(!1),b(`none`)),D(!0)},children:[(0,S.jsxs)(`div`,{className:nt(`relative flex items-center backdrop-blur-xl shadow-2xl border border-border`,`transition-[width,height,padding,background-color,border-color] duration-200 ease-out`,f?`h-12 p-2 pl-4`:`h-9 px-2 py-1`,y===`none`?`bg-muted/90 rounded-full`:`bg-muted/95 rounded-b-lg rounded-t-none border-t-0`,ge&&!f&&`bg-destructive/10 border-destructive/20`),children:[(0,S.jsxs)(`div`,{className:nt(`flex items-center transition-opacity duration-300 w-full relative`,ve?`absolute left-3 opacity-0 pointer-events-none`:`relative opacity-100`),children:[!ye&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`flex items-center justify-center w-6 h-6 rounded-full bg-accent flex-shrink-0`,children:(0,S.jsx)(Mt,{className:`w-3.5 h-3.5 text-foreground`})}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground/70 ml-3 whitespace-nowrap`,children:`⌥I or hover to inspect`})]}),ye&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[(0,S.jsx)(`div`,{className:`relative flex items-center justify-center w-6 h-6 rounded-full bg-accent flex-shrink-0`,children:i?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`absolute inset-0 rounded-full border-2 border-current opacity-20 animate-ping text-foreground`}),(0,S.jsx)(Mt,{className:`w-3.5 h-3.5 animate-pulse text-foreground`})]}):B?B.status===`in-progress`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`absolute inset-0 rounded-full border-2 border-current opacity-20 animate-ping text-blue-500`}),(0,S.jsx)(Nt,{className:`w-3.5 h-3.5 animate-pulse text-blue-500`})]}):B.status===`completed`?(0,S.jsx)(St,{className:`w-5 h-5 text-green-500`}):(0,S.jsx)(Ct,{className:`w-5 h-5 text-red-500`}):ge?(0,S.jsx)(Ct,{className:`w-5 h-5 text-red-500`}):(0,S.jsx)(St,{className:`w-5 h-5 text-green-500`})}),(0,S.jsx)(`div`,{className:`w-px h-4 bg-border flex-shrink-0`})]}),(0,S.jsx)(`div`,{className:`flex-1 flex justify-center min-w-0 pl-2`,children:(0,S.jsx)(`div`,{className:`flex flex-col min-w-0 max-w-full pr-2 max-h-[24px] overflow-hidden`,children:B&&B.status===`in-progress`&&B.currentStep?(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground min-w-0`,children:[(0,S.jsx)(Nt,{className:`w-4 h-4 flex-shrink-0`}),(0,S.jsxs)(`span`,{className:`truncate min-w-0`,children:[`Step `,B.currentStep.index,`/`,B.currentStep.total,`: `,B.currentStep.title]})]}):B?.message?(0,S.jsx)(`div`,{className:`text-sm font-medium leading-[1.4] text-foreground truncate min-w-0`,children:B.message}):g?(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground min-w-0`,children:[(0,S.jsx)(Nt,{className:`w-4 h-4 flex-shrink-0`}),(0,S.jsx)(`span`,{className:`truncate min-w-0`,children:g})]}):(0,S.jsx)(`div`,{className:`text-sm font-medium leading-[1.4] text-foreground truncate min-w-0`,children:i&&!oe?(0,S.jsx)(Foe,{duration:2,spread:2,children:o===`submitted`&&R?.command===`npx`?`Starting ${R.name}... This may take a moment.`:`Thinking...`}):oe||`Processing...`})})})]})]}),(0,S.jsxs)(`div`,{className:nt(`flex items-center w-full gap-3 transition-all duration-500 delay-75`,ve?`opacity-100 translate-y-0 relative pointer-events-auto`:`opacity-0 translate-y-4 pointer-events-none absolute top-2 left-4 right-2`),onClick:e=>e.stopPropagation(),children:[(0,S.jsx)(`button`,{onClick:t,className:nt(`relative flex items-center justify-center w-7 h-7 rounded-full transition-colors flex-shrink-0`,e?`bg-blue-500 text-white shadow-[0_0_15px_rgba(59,130,246,0.5)]`:`bg-accent text-muted-foreground hover:bg-accent/80 hover:text-foreground`),title:`Toggle Inspector (⌥I)`,children:(0,S.jsx)(Et,{className:`w-3.5 h-3.5`})}),(0,S.jsx)(`div`,{className:`w-px h-4 bg-border flex-shrink-0`}),s>0&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{type:`button`,onClick:()=>b(e=>e===`inspections`?`none`:`inspections`),className:nt(`relative flex items-center justify-center w-7 h-7 rounded-full transition-colors flex-shrink-0`,`hover:bg-accent/50`,y===`inspections`&&`bg-accent/50 text-foreground`),title:`View Inspections`,children:[(0,S.jsx)(Dt,{className:`w-3.5 h-3.5`}),(0,S.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 flex items-center justify-center min-w-[12px] h-[12px] px-0.5 text-[8px] font-bold text-white bg-red-500 rounded-full border border-background shadow-sm leading-none`,children:s>99?`99+`:s})]}),(0,S.jsx)(`div`,{className:`w-px h-4 bg-border flex-shrink-0`})]}),(0,S.jsxs)(`form`,{onSubmit:me,className:`flex-1 flex items-center gap-2 min-w-0`,onClick:e=>e.stopPropagation(),children:[(0,S.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>M(!j),className:`flex items-center justify-center w-7 h-7 rounded-full hover:bg-accent/50 transition-colors`,title:`Select Agent`,children:(0,S.jsx)(`img`,{src:Ac.find(e=>e.name===O)?.meta?.icon,alt:O,className:`w-3.5 h-3.5`})}),j&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`fixed inset-0 z-[999998]`,onClick:()=>M(!1)}),(0,S.jsx)(`div`,{className:`absolute bottom-full left-0 mb-2 w-64 bg-popover border border-border rounded-lg shadow-lg overflow-hidden z-[999999] animate-in fade-in zoom-in-95 duration-200`,children:Ac.map(e=>(0,S.jsxs)(`div`,{className:nt(`w-full flex items-center gap-2 px-3 py-2 text-sm hover:bg-accent transition-colors group`,O===e.name&&`bg-accent/50 font-medium`),children:[(0,S.jsxs)(`button`,{onClick:()=>{k(e.name),M(!1)},className:`flex items-center gap-2 flex-1 text-left`,children:[e.meta?.icon&&(0,S.jsx)(`img`,{src:e.meta.icon,alt:``,className:`w-4 h-4 flex-shrink-0`}),(0,S.jsx)(`span`,{className:`flex-1`,children:e.name})]}),(e.configHint||e.configLink)&&(0,S.jsx)(`button`,{onClick:t=>{t.stopPropagation(),P(e.name)},className:`p-1 rounded hover:bg-accent-foreground/10 transition-colors`,title:`Configuration info`,children:(0,S.jsx)(Ot,{className:`w-3.5 h-3.5 text-muted-foreground`})})]},e.name))})]})]}),(0,S.jsx)(`input`,{ref:ue,type:`text`,value:m,onChange:e=>h(e.target.value),onKeyDown:he,placeholder:`Ask ${O}...`,className:`w-full bg-transparent border-none outline-none text-foreground placeholder-muted-foreground text-sm h-7 disabled:opacity-50`,tabIndex:0,disabled:i}),(a.length>0||i||w)&&(0,S.jsx)(`button`,{type:`button`,onClick:()=>b(e=>e===`chat`?`none`:`chat`),className:nt(`flex items-center justify-center w-7 h-7 rounded-full transition-all flex-shrink-0`,y===`chat`?`bg-foreground text-background`:`bg-accent text-muted-foreground hover:bg-accent/80 hover:text-foreground`),title:y===`chat`?`Collapse`:`Expand messages`,children:(0,S.jsx)(vt,{className:nt(`w-3.5 h-3.5 transition-transform duration-300`,y===`chat`&&`rotate-180`)})}),i?(0,S.jsx)(`button`,{type:`button`,onClick:r,className:`flex items-center justify-center w-7 h-7 rounded-full bg-destructive text-destructive-foreground transition-all flex-shrink-0 hover:bg-destructive/90`,title:`Cancel request`,children:(0,S.jsx)(tee,{className:`w-3 h-3`})}):(0,S.jsx)(`button`,{type:`submit`,disabled:!m.trim(),className:nt(`flex items-center justify-center w-7 h-7 rounded-full transition-all flex-shrink-0`,m.trim()?`bg-foreground text-background scale-100`:`bg-accent text-muted-foreground/50 scale-90`),children:(0,S.jsx)(ht,{className:`w-3.5 h-3.5`})})]})]})]}),y!==`none`&&(0,S.jsx)(`div`,{className:`absolute bottom-full left-0 right-0 pointer-events-auto max-w-[480px] mx-auto animate-panel-in`,children:(0,S.jsxs)(`div`,{className:`bg-muted/95 backdrop-blur-xl rounded-t-xl border border-border border-b-0 shadow-2xl overflow-hidden`,children:[y===`inspections`&&l.length>0&&(0,S.jsx)(`div`,{className:`border-b border-border`,children:(0,S.jsx)(pee,{items:l,onRemove:u})}),y===`chat`&&(0,S.jsx)(`div`,{className:`h-[500px]`,children:(0,S.jsx)(U9t,{messages:a,status:o,selectedAgent:O})})]})})]}),N&&(()=>{let e=Ac.find(e=>e.name===N);return e?(0,S.jsx)(Lt,{open:!!N,onOpenChange:()=>P(null),children:(0,S.jsxs)(Rt,{onClose:()=>P(null),className:`w-80`,children:[(0,S.jsxs)(zt,{children:[(0,S.jsxs)(nee,{className:`flex items-center gap-3`,children:[e.meta?.icon&&(0,S.jsx)(`img`,{src:e.meta.icon,alt:``,className:`w-6 h-6`}),e.name]}),e.configHint&&(0,S.jsx)(Vt,{children:e.configHint})]}),e.configLink&&(0,S.jsx)(`a`,{href:e.configLink,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-sm text-blue-500 hover:text-blue-600 underline`,children:`View ACP Documentation →`})]})}):null})()]})};var Y9t=`vercel.ai.error`,X9t=Symbol.for(Y9t),Z9t,Q9t=class e extends Error{constructor({name:e,message:t,cause:n}){super(t),this[Z9t]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,Y9t)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}};Z9t=X9t;var W7=Q9t;function $9t(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}var een=`AI_InvalidArgumentError`,ten=`vercel.ai.error.${een}`,nen=Symbol.for(ten),ren,ien=class extends W7{constructor({message:e,cause:t,argument:n}){super({name:een,message:e,cause:t}),this[ren]=!0,this.argument=n}static isInstance(e){return W7.hasMarker(e,ten)}};ren=nen;var aen=`AI_JSONParseError`,oen=`vercel.ai.error.${aen}`,sen=Symbol.for(oen),cen,len=class extends W7{constructor({text:e,cause:t}){super({name:aen,message:`JSON parsing failed: Text: ${e}.
|
|
6885
|
+
$$`:`${e}$$`},o9t=e=>{let t=0,n=e.match(/\*+/g)||[];for(let e of n){let n=e.length;n>=3&&(t+=Math.floor(n/3))}return t},s9t=e=>{if(V7(e)||K7t.test(e))return e;let t=e.match(L7t);if(t){let n=t[2];if(!n||z7.test(n))return e;if(o9t(e)%2==1)return`${e}***`}return e},c9t=e=>{if(!e||typeof e!=`string`)return e;let t=e,n=q7t(t);return n.endsWith(`](streamdown:incomplete-link)`)?n:(t=n,t=s9t(t),t=J7t(t),t=Y7t(t),t=Z7t(t),t=e9t(t),t=r9t(t),t=i9t(t),t=a9t(t),t)},l9t={harden:[Qfe,{allowedImagePrefixes:[`*`],allowedLinkPrefixes:[`*`],defaultOrigin:void 0,allowDataImages:!0}],raw:Ebe,katex:[sy,{errorColor:`var(--color-muted-foreground)`}]},u9t={gfm:[GCe,{}],math:[rwe,{singleDollarTextMath:!1}],cjkFriendly:[axe,{}],cjkFriendlyGfmStrikethrough:[sxe,{}]},d9t=(0,_.createContext)([`github-light`,`github-dark`]),f9t=(0,_.createContext)(void 0),p9t=(0,_.createContext)(!0),H7=(0,_.createContext)({isAnimating:!1}),m9t=(0,_.memo)(({content:e,shouldParseIncompleteMarkdown:t,...n})=>{let r=(0,_.useMemo)(()=>typeof e==`string`&&t?c9t(e.trim()):e,[e,t]);return(0,S.jsx)(qfe,{...n,children:r})},(e,t)=>e.content===t.content);m9t.displayName=`Block`;var h9t=[`github-light`,`github-dark`],g9t=(0,_.memo)(({children:e,parseIncompleteMarkdown:t=!0,components:n,rehypePlugins:r=Object.values(l9t),remarkPlugins:i=Object.values(u9t),className:a,shikiTheme:o=h9t,mermaidConfig:s,controls:l=!0,isAnimating:u=!1,urlTransform:d=e=>e,BlockComponent:f=m9t,parseMarkdownIntoBlocksFn:m=N7t,...h})=>{let g=(0,_.useId)(),v=(0,_.useMemo)(()=>m(typeof e==`string`?e:``),[e,m]);(0,_.useEffect)(()=>{Array.isArray(r)&&r.some(e=>Array.isArray(e)?e[0]===sy:e===sy)&&Promise.resolve().then(()=>p(O5t(),1))},[r]);let y=(0,_.useMemo)(()=>({isAnimating:u}),[u]);return(0,S.jsx)(d9t.Provider,{value:o,children:(0,S.jsx)(f9t.Provider,{value:s,children:(0,S.jsx)(p9t.Provider,{value:l,children:(0,S.jsx)(H7.Provider,{value:y,children:(0,S.jsx)(`div`,{className:F7(`space-y-4`,a),children:v.map((e,a)=>(0,S.jsx)(f,{components:{...O7t,...n},content:e,index:a,rehypePlugins:r,remarkPlugins:i,shouldParseIncompleteMarkdown:t,urlTransform:d,...h},`${g}-block-${a}`))})})})})})},(e,t)=>e.children===t.children&&e.shikiTheme===t.shikiTheme&&e.isAnimating===t.isAnimating);g9t.displayName=`Streamdown`;let _9t=(0,_.createContext)(null),v9t=()=>{let e=(0,_.useContext)(_9t);if(!e)throw Error(`Reasoning components must be used within Reasoning`);return e},y9t=(0,_.memo)(({className:e,isStreaming:t=!1,open:n,defaultOpen:r=!0,onOpenChange:i,duration:a,children:o,...s})=>{let[l,u]=Yt({prop:n,defaultProp:r,onChange:i}),[d,f]=Yt({prop:a,defaultProp:void 0}),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null);return(0,_.useEffect)(()=>{t?h===null&&g(Date.now()):h!==null&&(f(Math.ceil((Date.now()-h)/1e3)),g(null))},[t,h,f]),(0,_.useEffect)(()=>{if(r&&!t&&l&&!p){let e=setTimeout(()=>{u(!1),m(!0)},1e3);return()=>clearTimeout(e)}},[t,l,r,u,p]),(0,S.jsx)(_9t.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:d},children:(0,S.jsx)(xn,{className:nt(`not-prose mb-4`,e),onOpenChange:e=>{u(e)},open:l,...s,children:o})})}),b9t=(e,t)=>e||t===0?(0,S.jsx)(Foe,{duration:1,children:`Thinking...`}):t===void 0?(0,S.jsx)(`p`,{children:`Thought for a few seconds`}):(0,S.jsxs)(`p`,{children:[`Thought for `,t,` seconds`]}),x9t=(0,_.memo)(({className:e,children:t,...n})=>{let{isStreaming:r,isOpen:i,duration:a}=v9t();return(0,S.jsx)(Sn,{className:nt(`flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground`,e),...n,children:t??(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(gt,{className:`size-4`}),b9t(r,a),(0,S.jsx)(_t,{className:nt(`size-4 transition-transform`,i?`rotate-180`:`rotate-0`)})]})})}),S9t=(0,_.memo)(({className:e,children:t,...n})=>(0,S.jsx)(Cn,{className:nt(`mt-4 text-sm`,`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...n,children:(0,S.jsx)(g9t,{...n,children:t})}));y9t.displayName=`Reasoning`,x9t.displayName=`ReasoningTrigger`,S9t.displayName=`ReasoningContent`,(0,_.createContext)(null);let C9t=(0,_.memo)(({className:e,...t})=>(0,S.jsx)(g9t,{className:nt(`size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,e),...t}),(e,t)=>e.children===t.children);C9t.displayName=`MessageResponse`;let w9t=(0,_.createContext)({code:``}),T9t={name:`line-numbers`,line(e,t){e.children.unshift({type:`element`,tagName:`span`,properties:{className:[`inline-block`,`min-w-10`,`mr-4`,`text-right`,`select-none`,`text-muted-foreground`]},children:[{type:`text`,value:String(t)}]})}};async function E9t(e,t,n=!1){let r=n?[T9t]:[];return await Promise.all([Gqe(e,{lang:t,theme:`one-light`,transformers:r}),Gqe(e,{lang:t,theme:`one-dark-pro`,transformers:r})])}let U7=({code:e,language:t,showLineNumbers:n=!1,className:r,children:i,...a})=>{let[o,s]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),d=(0,_.useRef)(!1);return(0,_.useEffect)(()=>(E9t(e,t,n).then(([e,t])=>{d.current||=(s(e),u(t),!0)}),()=>{d.current=!1}),[e,t,n]),(0,S.jsx)(w9t.Provider,{value:{code:e},children:(0,S.jsx)(`div`,{className:nt(`group relative w-full overflow-hidden rounded-md border bg-background text-foreground`,r),...a,children:(0,S.jsxs)(`div`,{className:`relative`,children:[(0,S.jsx)(`div`,{className:`overflow-x-auto dark:hidden [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm`,dangerouslySetInnerHTML:{__html:o}}),(0,S.jsx)(`div`,{className:`hidden overflow-x-auto dark:block [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm`,dangerouslySetInnerHTML:{__html:l}}),i&&(0,S.jsx)(`div`,{className:`absolute top-2 right-2 flex items-center gap-2`,children:i})]})})})},D9t=({className:e,...t})=>(0,S.jsx)(xn,{className:nt(`not-prose mb-4 w-full rounded-md border`,e),...t}),O9t=e=>{let t={"input-streaming":`Pending`,"input-available":`Running`,"approval-requested":`Awaiting Approval`,"approval-responded":`Responded`,"output-available":`Completed`,"output-error":`Error`,"output-denied":`Denied`};return(0,S.jsxs)(it,{className:`gap-1.5 rounded-full text-xs`,variant:`secondary`,children:[{"input-streaming":(0,S.jsx)(wt,{className:`size-4`}),"input-available":(0,S.jsx)(Tt,{className:`size-4 animate-pulse`}),"approval-requested":(0,S.jsx)(Tt,{className:`size-4 text-yellow-600`}),"approval-responded":(0,S.jsx)(xt,{className:`size-4 text-blue-600`}),"output-available":(0,S.jsx)(xt,{className:`size-4 text-green-600`}),"output-error":(0,S.jsx)(Ct,{className:`size-4 text-red-600`}),"output-denied":(0,S.jsx)(Ct,{className:`size-4 text-orange-600`})}[e],t[e]]})},k9t=({className:e,title:t,type:n,state:r,...i})=>(0,S.jsxs)(Sn,{className:nt(`flex w-full items-center justify-between gap-4 p-3`,e),...i,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(Ft,{className:`size-4 text-muted-foreground`}),(0,S.jsx)(`span`,{className:`font-medium text-sm`,children:t??n.split(`-`).slice(1).join(`-`)}),O9t(r)]}),(0,S.jsx)(_t,{className:`size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]}),A9t=({className:e,...t})=>(0,S.jsx)(Cn,{className:nt(`data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in`,e),...t}),j9t=({className:e,input:t,...n})=>(0,S.jsxs)(`div`,{className:nt(`space-y-2 overflow-hidden p-4`,e),...n,children:[(0,S.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:`Parameters`}),(0,S.jsx)(`div`,{className:`rounded-md bg-muted/50`,children:(0,S.jsx)(U7,{code:JSON.stringify(t,null,2),language:`json`})})]}),M9t=({className:e,output:t,errorText:n,...r})=>{if(!(t||n))return null;let i=(0,S.jsx)(`div`,{children:t});return typeof t==`object`&&!(0,_.isValidElement)(t)?i=(0,S.jsx)(U7,{code:JSON.stringify(t,null,2),language:`json`}):typeof t==`string`&&(i=(0,S.jsx)(U7,{code:t,language:`json`})),(0,S.jsxs)(`div`,{className:nt(`space-y-2 p-4`,e),...r,children:[(0,S.jsx)(`h4`,{className:`font-medium text-muted-foreground text-xs uppercase tracking-wide`,children:n?`Error`:`Result`}),(0,S.jsxs)(`div`,{className:nt(`overflow-x-auto rounded-md text-xs [&_table]:w-full`,n?`bg-destructive/10 text-destructive`:`bg-muted/50 text-foreground`),children:[n&&(0,S.jsx)(`div`,{children:n}),i]})]})};function N9t({className:e,...t}){return(0,S.jsx)(`div`,{"data-slot":`card`,className:nt(`bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm`,e),...t})}function P9t({className:e,...t}){return(0,S.jsx)(`div`,{"data-slot":`card-header`,className:nt(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,e),...t})}function F9t({className:e,...t}){return(0,S.jsx)(`div`,{"data-slot":`card-content`,className:nt(`px-6`,e),...t})}let I9t=(0,_.createContext)(null),L9t=({className:e,isStreaming:t=!1,children:n,...r})=>(0,S.jsx)(I9t.Provider,{value:{isStreaming:t},children:(0,S.jsx)(xn,{asChild:!0,"data-slot":`plan`,...r,children:(0,S.jsx)(N9t,{className:nt(`shadow-none`,e),children:n})})}),R9t=({className:e,...t})=>(0,S.jsx)(P9t,{className:nt(`flex items-start justify-between`,e),"data-slot":`plan-header`,...t}),z9t=e=>(0,S.jsx)(Cn,{asChild:!0,children:(0,S.jsx)(F9t,{"data-slot":`plan-content`,...e})}),B9t=({className:e,...t})=>(0,S.jsx)(Sn,{asChild:!0,children:(0,S.jsxs)(Wt,{className:nt(`size-8`,e),"data-slot":`plan-trigger`,size:`icon`,variant:`ghost`,...t,children:[(0,S.jsx)(yt,{className:`size-4`}),(0,S.jsx)(`span`,{className:`sr-only`,children:`Toggle plan`})]})});function V9t(e){let t=e;return typeof t.type==`string`&&t.type.startsWith(`tool-`)&&`state`in t}function H9t(e,t,n,r,i){if(e.type===`text`&&e.text)return(0,S.jsx)(C9t,{className:`whitespace-pre-wrap`,children:e.text},`${t}-${n}`);if(e.type===`reasoning`)return(0,S.jsxs)(y9t,{className:`w-full`,isStreaming:r,children:[(0,S.jsx)(x9t,{}),(0,S.jsx)(S9t,{children:e.text})]},`${t}-${n}`);let a=i?.plan;if(a&&n===0)return(0,S.jsx)(`div`,{className:`w-full`,children:(0,S.jsxs)(L9t,{defaultOpen:!0,isStreaming:r,children:[(0,S.jsx)(R9t,{className:`flex flex-row items-center`,children:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`h1`,{className:`text-base`,children:`Agent Plan`}),(0,S.jsx)(B9t,{className:`mb-2`})]})}),(0,S.jsx)(z9t,{children:(0,S.jsx)(`ul`,{className:`space-y-2`,children:a.map((e,t)=>{let n=e.content||JSON.stringify(e),r=e.priority,i=e.status;return(0,S.jsxs)(`li`,{className:`flex items-start justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`flex-1`,children:[(0,S.jsx)(`div`,{className:`text-sm ${i===`done`?`line-through text-muted-foreground`:`text-foreground`}`,children:n}),r&&(0,S.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Priority: `,r]})]}),(0,S.jsx)(`div`,{className:`shrink-0 text-xs`,children:(0,S.jsx)(`span`,{className:`px-2 py-1 rounded-full font-medium text-[10px] uppercase tracking-wide ${i===`pending`?`bg-muted text-muted-foreground`:`bg-primary/10 text-primary`}`,children:i??`pending`})})]},`plan-${t}`)})})})]})},`${t}-plan`);if(V9t(e)){let r=e=>{let t=e;return t=t.replace(/^tool-/,``),t=t.replace(/^mcp__/,``),t=t.replace(/(^|__|\/)(acp[-_]?ai[-_]?sdk[-_]?tools)(?=__|\/|$)/g,`$1`),t=t.replace(/^__+/,``).replace(/__+$/,``),t=t.replace(/__{3,}/g,`__`),t||e},i=e.input;if(!i||!i.toolName)return null;let a=r(i.toolName),o=`tool-${a}`,s=e.state,l=s===`output-available`||s===`output-error`;return(0,S.jsxs)(D9t,{defaultOpen:l,children:[(0,S.jsx)(k9t,{title:a.length>20?`${a.slice(0,20)}...`:a,type:o,state:s}),(0,S.jsxs)(A9t,{children:[e.input!==void 0&&(0,S.jsx)(j9t,{input:i.args}),l&&(0,S.jsx)(M9t,{output:e.output?(0,S.jsx)(U7,{code:JSON.stringify(e.output,null,2),language:`json`}):null,errorText:e.errorText})]})]},`${t}-${n}`)}return null}let U9t=({messages:e,status:t,selectedAgent:n})=>{let r=Ac.find(e=>e.name===(n||jc))||Ac[0],i=t===`submitted`||t===`streaming`,a=e[e.length-1],o=i&&(!a||a.role===`user`);return(0,S.jsxs)(qoe,{className:`w-full h-full`,children:[(0,S.jsx)(Joe,{className:`p-3 space-y-3`,children:e.length===0&&!i?(0,S.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`p`,{className:`text-sm`,children:`No messages yet`}),(0,S.jsx)(`p`,{className:`text-xs mt-1`,children:`Enter a question below to start`})]})}):(0,S.jsxs)(S.Fragment,{children:[e.map(e=>(0,S.jsxs)(kse,{className:`items-start`,from:e.role,children:[(0,S.jsx)(Ase,{children:e.parts.map((n,r)=>H9t(n,e.id,r,t===`streaming`,e.metadata))}),e.role===`assistant`&&(0,S.jsx)(jse,{name:r.name,src:r.meta?.icon??``})]},e.id)),o&&(0,S.jsxs)(kse,{className:`items-start`,from:`assistant`,children:[(0,S.jsx)(Ase,{children:(0,S.jsx)(Nse,{size:16})}),(0,S.jsx)(jse,{name:r.name,src:r.meta?.icon??``})]})]})}),(0,S.jsx)(Yoe,{})]})};function W9t(e,t,n=50){let[r,i]=(0,_.useState)(``),a=(0,_.useRef)(0),o=(0,_.useRef)(``);return(0,_.useEffect)(()=>{if(e.length<r.length||r&&!e.startsWith(r.slice(0,Math.min(r.length,20)))){i(e),o.current=e,a.current=Date.now();return}if(!t){r!==e&&(i(e),o.current=e);return}let s=e.slice(o.current.length);if(!s)return;let l=Date.now();if(l-a.current<n)return;let u=/[.?!。?!](\s|$)|[\n]/.test(s),d=s.length>50,f=s.trim().length<5;(u&&!f||d)&&(i(e),o.current=e,a.current=l)},[e,t,n,r]),r}function G9t({initialOffset:e={x:0,y:0}}={}){let t=(0,_.useRef)(null),[n,r]=(0,_.useState)(!1),i=(0,_.useRef)(e),a=(0,_.useRef)({x:0,y:0}),o=(0,_.useRef)({x:0,y:0}),s=(0,_.useCallback)(()=>{if(t.current){let{x:e,y:n}=i.current;t.current.style.transform=`translate3d(calc(-50% + ${e}px), ${n}px, 0)`}},[]),l=(0,_.useCallback)(e=>{e.target.closest(`button, input, a, [data-no-drag]`)||(e.preventDefault(),r(!0),a.current={x:e.clientX,y:e.clientY},o.current={...i.current})},[]);return(0,_.useEffect)(()=>{let e=e=>{if(!n)return;let t=e.clientX-a.current.x,r=e.clientY-a.current.y;i.current={x:o.current.x+t,y:o.current.y+r},s()},t=()=>{r(!1)};return n&&(window.addEventListener(`mousemove`,e,{passive:!0}),window.addEventListener(`mouseup`,t)),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}},[n,s]),(0,_.useEffect)(()=>{s()},[s]),{elementRef:t,isDragging:n,handleMouseDown:l}}let K9t=`AI_SELECTED_AGENT`,q9t=e=>{let[t,n]=(0,_.useState)(()=>{if(typeof window<`u`){let e=localStorage.getItem(K9t);if(e)return e}return e}),[r,i]=(0,_.useState)(!1);return(0,_.useEffect)(()=>{typeof window<`u`?Lc().then(e=>{e&&e!==jc&&n(e)}).finally(()=>{i(!0)}):i(!0)},[]),{agent:t,setAgent:e=>{n(e),!(typeof window>`u`)&&(e?.trim()?localStorage.setItem(K9t,e):localStorage.removeItem(K9t))},isReady:r}},J9t=({isActive:e,onToggleInspector:t,onSubmitAgent:n,onCancel:r,isAgentWorking:i,messages:a,status:o,inspectionCount:s=0,inspectionItems:l=[],onRemoveInspection:u=()=>{},toolsReady:d=!0})=>{let[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(null),[y,b]=(0,_.useState)(`none`),[x,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(!0),{agent:O,setAgent:k,isReady:A}=q9t(jc),[j,M]=(0,_.useState)(!1),[N,P]=(0,_.useState)(null),[F,I]=(0,_.useState)(null),L=(0,_.useRef)(null),R=(0,_.useRef)(!1),ee=e=>{let t=`${Pc()}/api/acp/cleanup-session`,n=JSON.stringify({sessionId:e});try{if(navigator.sendBeacon){let e=new Blob([n],{type:`application/json`});navigator.sendBeacon(t,e);return}}catch{}fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`},body:n,keepalive:!0}).catch(()=>{})};(0,_.useEffect)(()=>{if(!A||!d)return;let e=!0,t=Ac.find(e=>e.name===O)||Ac[0];return(async()=>{if(L.current){try{await fetch(`${Pc()}/api/acp/cleanup-session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:L.current})})}catch(e){console.warn(`[InspectorBar] Failed to cleanup previous session:`,e)}L.current=null,e&&I(null)}console.log(`[InspectorBar] Initializing session for ${t.name}...`);try{let n=await fetch(`${Pc()}/api/acp/init-session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agent:t,envVars:{}})});if(!n.ok)throw Error(`Failed to init session`);let r=await n.json();e&&r.sessionId&&(console.log(`[InspectorBar] Session initialized: ${r.sessionId}`),I(r.sessionId),L.current=r.sessionId,R.current=!1)}catch(e){console.error(`[InspectorBar] Failed to initialize session:`,e)}})(),()=>{e=!1}},[O,A,d]),(0,_.useEffect)(()=>{let e=()=>{let e=L.current;!e||R.current||(R.current=!0,ee(e))};return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e)}},[]),(0,_.useEffect)(()=>()=>{let e=L.current;!e||R.current||(R.current=!0,console.log(`[InspectorBar] Cleaning up session on unmount: ${e}`),ee(e))},[]);let te=Ac.find(e=>e.name===O)||Ac[0],{elementRef:z,isDragging:B,handleMouseDown:ne}=G9t(),[re,ie]=(0,_.useState)(null),[ae,oe]=(0,_.useState)(``),se=W9t(ae,i,50),[ce,le]=(0,_.useState)(``),ue=(0,_.useRef)(``),de=(0,_.useRef)(``);(0,_.useEffect)(()=>{let e=se,t=ue.current;if(e.length<t.length||!e.startsWith(t)){le(e),ue.current=e;return}if(e.length>t.length){let n=e.slice(t.length).trim();n&&le(n),ue.current=e}},[se]);let fe=(0,_.useRef)(null),pe=(0,_.useRef)(null),me=(0,_.useRef)(null),he=(0,_.useRef)(!1);(0,_.useEffect)(()=>{if(a.length===0){oe(``),v(null),me.current=null,he.current=!1,le(``),ue.current=``;return}let e=a[a.length-1];if(e.role!==`assistant`)return;let t=Roe(e),{displayText:n,toolCall:r}=Boe(e,t||me.current);oe(n||``),t&&(me.current=t),r?(pe.current&&=(clearTimeout(pe.current),null),v(r),he.current=!0):he.current=!1},[a]),(0,_.useEffect)(()=>{ce!==de.current&&(he.current||v(null),de.current=ce)},[ce]),(0,_.useEffect)(()=>{f&&fe.current&&fe.current.focus()},[f]),(0,_.useEffect)(()=>{if(!i&&w){C(!1),T(!1),D(!1);let e=setTimeout(()=>{D(!0)},2e3);return()=>clearTimeout(e)}},[i,w]),(0,_.useEffect)(()=>{function e(e){let{plan:t,inspectionId:n}=e.detail;if(t?.steps){let e=t.steps.find(e=>e.status===`in-progress`),r=t.steps.filter(e=>e.status===`completed`).length;ie({id:n,status:`in-progress`,currentStep:e?{title:e.title,index:r+1,total:t.steps.length}:void 0})}}function t(e){let{status:t,result:n,inspectionId:r}=e.detail;ie({id:r,status:t,message:n?.message||n})}return window.addEventListener(`plan-progress-reported`,e),window.addEventListener(`inspection-result-received`,t),()=>{window.removeEventListener(`plan-progress-reported`,e),window.removeEventListener(`inspection-result-received`,t)}},[]);let ge=e=>{e.preventDefault(),m.trim()&&(pe.current&&=(clearTimeout(pe.current),null),v(null),oe(``),le(``),ie(null),me.current=null,ue.current=``,C(!0),T(!0),n(m,O,F||void 0),h(``),p(!0),b(`chat`))},_e=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ge(e)),e.key===`Escape`&&(p(!1),fe.current?.blur())},ve=o===`error`,ye=a.length>0,be=f&&!x,xe=(!f||x)&&(i||ye||re);return(0,S.jsxs)(S.Fragment,{children:[(f||y!==`none`)&&(0,S.jsx)(`div`,{className:`fixed inset-0 z-[999998] bg-transparent`,onClick:()=>{!w&&!i&&(p(!1),b(`none`))}}),(0,S.jsxs)(`div`,{ref:z,className:nt(`fixed bottom-8 left-1/2 z-[999999]`,`transition-all duration-300 ease-[cubic-bezier(0.23,1,0.32,1)]`,f?`w-[480px]`:xe?`w-auto min-w-[200px] max-w-[480px]`:`w-[190px]`,B?`cursor-grabbing`:`cursor-grab`),onMouseDown:ne,onMouseEnter:()=>{B||(i||w?(p(!0),b(`chat`)):E&&p(!0))},onMouseLeave:()=>{!m.trim()&&!w&&!B&&(p(!1),b(`none`)),D(!0)},children:[(0,S.jsxs)(`div`,{className:nt(`relative flex items-center backdrop-blur-xl shadow-2xl border border-border`,`transition-[width,height,padding,background-color,border-color] duration-200 ease-out`,f?`h-12 p-2 pl-4`:`h-9 px-2 py-1`,y===`none`?`bg-muted/90 rounded-full`:`bg-muted/95 rounded-b-lg rounded-t-none border-t-0`,ve&&!f&&`bg-destructive/10 border-destructive/20`),children:[(0,S.jsxs)(`div`,{className:nt(`flex items-center transition-opacity duration-300 w-full relative`,be?`absolute left-3 opacity-0 pointer-events-none`:`relative opacity-100`),children:[!xe&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`flex items-center justify-center w-6 h-6 rounded-full bg-accent flex-shrink-0`,children:(0,S.jsx)(Mt,{className:`w-3.5 h-3.5 text-foreground`})}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground/70 ml-3 whitespace-nowrap`,children:`⌥I or hover to inspect`})]}),xe&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[(0,S.jsx)(`div`,{className:`relative flex items-center justify-center w-6 h-6 rounded-full bg-accent flex-shrink-0`,children:i?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`absolute inset-0 rounded-full border-2 border-current opacity-20 animate-ping text-foreground`}),(0,S.jsx)(Mt,{className:`w-3.5 h-3.5 animate-pulse text-foreground`})]}):re?re.status===`in-progress`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`absolute inset-0 rounded-full border-2 border-current opacity-20 animate-ping text-blue-500`}),(0,S.jsx)(Nt,{className:`w-3.5 h-3.5 animate-pulse text-blue-500`})]}):re.status===`completed`?(0,S.jsx)(St,{className:`w-5 h-5 text-green-500`}):(0,S.jsx)(Ct,{className:`w-5 h-5 text-red-500`}):ve?(0,S.jsx)(Ct,{className:`w-5 h-5 text-red-500`}):(0,S.jsx)(St,{className:`w-5 h-5 text-green-500`})}),(0,S.jsx)(`div`,{className:`w-px h-4 bg-border flex-shrink-0`})]}),(0,S.jsx)(`div`,{className:`flex-1 flex justify-center min-w-0 pl-2`,children:(0,S.jsx)(`div`,{className:`flex flex-col min-w-0 max-w-full pr-2 max-h-[24px] overflow-hidden`,children:re&&re.status===`in-progress`&&re.currentStep?(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground min-w-0`,children:[(0,S.jsx)(Nt,{className:`w-4 h-4 flex-shrink-0`}),(0,S.jsxs)(`span`,{className:`truncate min-w-0`,children:[`Step `,re.currentStep.index,`/`,re.currentStep.total,`: `,re.currentStep.title]})]}):re?.message?(0,S.jsx)(`div`,{className:`text-sm font-medium leading-[1.4] text-foreground truncate min-w-0`,children:re.message}):g?(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground min-w-0`,children:[(0,S.jsx)(Nt,{className:`w-4 h-4 flex-shrink-0`}),(0,S.jsx)(`span`,{className:`truncate min-w-0`,children:g})]}):(0,S.jsx)(`div`,{className:`text-sm font-medium leading-[1.4] text-foreground truncate min-w-0`,children:i&&!ce?(0,S.jsx)(Foe,{duration:2,spread:2,children:o===`submitted`&&te?.command===`npx`?`Starting ${te.name}... This may take a moment.`:`Thinking...`}):ce||`Processing...`})})})]})]}),(0,S.jsxs)(`div`,{className:nt(`flex items-center w-full gap-3 transition-all duration-500 delay-75`,be?`opacity-100 translate-y-0 relative pointer-events-auto`:`opacity-0 translate-y-4 pointer-events-none absolute top-2 left-4 right-2`),onClick:e=>e.stopPropagation(),children:[(0,S.jsx)(`button`,{onClick:t,className:nt(`relative flex items-center justify-center w-7 h-7 rounded-full transition-colors flex-shrink-0`,e?`bg-blue-500 text-white shadow-[0_0_15px_rgba(59,130,246,0.5)]`:`bg-accent text-muted-foreground hover:bg-accent/80 hover:text-foreground`),title:`Toggle Inspector (⌥I)`,children:(0,S.jsx)(Et,{className:`w-3.5 h-3.5`})}),(0,S.jsx)(`div`,{className:`w-px h-4 bg-border flex-shrink-0`}),s>0&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{type:`button`,onClick:()=>b(e=>e===`inspections`?`none`:`inspections`),className:nt(`relative flex items-center justify-center w-7 h-7 rounded-full transition-colors flex-shrink-0`,`hover:bg-accent/50`,y===`inspections`&&`bg-accent/50 text-foreground`),title:`View Inspections`,children:[(0,S.jsx)(Dt,{className:`w-3.5 h-3.5`}),(0,S.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 flex items-center justify-center min-w-[12px] h-[12px] px-0.5 text-[8px] font-bold text-white bg-red-500 rounded-full border border-background shadow-sm leading-none`,children:s>99?`99+`:s})]}),(0,S.jsx)(`div`,{className:`w-px h-4 bg-border flex-shrink-0`})]}),(0,S.jsxs)(`form`,{onSubmit:ge,className:`flex-1 flex items-center gap-2 min-w-0`,onClick:e=>e.stopPropagation(),children:[(0,S.jsxs)(`div`,{className:`relative flex-shrink-0`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>M(!j),className:`flex items-center justify-center w-7 h-7 rounded-full hover:bg-accent/50 transition-colors`,title:`Select Agent`,children:(0,S.jsx)(`img`,{src:Ac.find(e=>e.name===O)?.meta?.icon,alt:O,className:`w-3.5 h-3.5`})}),j&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`fixed inset-0 z-[999998]`,onClick:()=>M(!1)}),(0,S.jsx)(`div`,{className:`absolute bottom-full left-0 mb-2 w-64 bg-popover border border-border rounded-lg shadow-lg overflow-hidden z-[999999] animate-in fade-in zoom-in-95 duration-200`,children:Ac.map(e=>(0,S.jsxs)(`div`,{className:nt(`w-full flex items-center gap-2 px-3 py-2 text-sm hover:bg-accent transition-colors group`,O===e.name&&`bg-accent/50 font-medium`),children:[(0,S.jsxs)(`button`,{onClick:()=>{k(e.name),M(!1)},className:`flex items-center gap-2 flex-1 text-left`,children:[e.meta?.icon&&(0,S.jsx)(`img`,{src:e.meta.icon,alt:``,className:`w-4 h-4 flex-shrink-0`}),(0,S.jsx)(`span`,{className:`flex-1`,children:e.name})]}),(e.configHint||e.configLink)&&(0,S.jsx)(`button`,{onClick:t=>{t.stopPropagation(),P(e.name)},className:`p-1 rounded hover:bg-accent-foreground/10 transition-colors`,title:`Configuration info`,children:(0,S.jsx)(Ot,{className:`w-3.5 h-3.5 text-muted-foreground`})})]},e.name))})]})]}),(0,S.jsx)(`input`,{ref:fe,type:`text`,value:m,onChange:e=>h(e.target.value),onKeyDown:_e,placeholder:`Ask ${O}...`,className:`w-full bg-transparent border-none outline-none text-foreground placeholder-muted-foreground text-sm h-7 disabled:opacity-50`,tabIndex:0,disabled:i}),(a.length>0||i||w)&&(0,S.jsx)(`button`,{type:`button`,onClick:()=>b(e=>e===`chat`?`none`:`chat`),className:nt(`flex items-center justify-center w-7 h-7 rounded-full transition-all flex-shrink-0`,y===`chat`?`bg-foreground text-background`:`bg-accent text-muted-foreground hover:bg-accent/80 hover:text-foreground`),title:y===`chat`?`Collapse`:`Expand messages`,children:(0,S.jsx)(vt,{className:nt(`w-3.5 h-3.5 transition-transform duration-300`,y===`chat`&&`rotate-180`)})}),i?(0,S.jsx)(`button`,{type:`button`,onClick:r,className:`flex items-center justify-center w-7 h-7 rounded-full bg-destructive text-destructive-foreground transition-all flex-shrink-0 hover:bg-destructive/90`,title:`Cancel request`,children:(0,S.jsx)(tee,{className:`w-3 h-3`})}):(0,S.jsx)(`button`,{type:`submit`,disabled:!m.trim(),className:nt(`flex items-center justify-center w-7 h-7 rounded-full transition-all flex-shrink-0`,m.trim()?`bg-foreground text-background scale-100`:`bg-accent text-muted-foreground/50 scale-90`),children:(0,S.jsx)(ht,{className:`w-3.5 h-3.5`})})]})]})]}),y!==`none`&&(0,S.jsx)(`div`,{className:`absolute bottom-full left-0 right-0 pointer-events-auto max-w-[480px] mx-auto animate-panel-in`,children:(0,S.jsxs)(`div`,{className:`bg-muted/95 backdrop-blur-xl rounded-t-xl border border-border border-b-0 shadow-2xl overflow-hidden`,children:[y===`inspections`&&l.length>0&&(0,S.jsx)(`div`,{className:`border-b border-border`,children:(0,S.jsx)(pee,{items:l,onRemove:u})}),y===`chat`&&(0,S.jsx)(`div`,{className:`h-[500px]`,children:(0,S.jsx)(U9t,{messages:a,status:o,selectedAgent:O})})]})})]}),N&&(()=>{let e=Ac.find(e=>e.name===N);return e?(0,S.jsx)(Lt,{open:!!N,onOpenChange:()=>P(null),children:(0,S.jsxs)(Rt,{onClose:()=>P(null),className:`w-80`,children:[(0,S.jsxs)(zt,{children:[(0,S.jsxs)(nee,{className:`flex items-center gap-3`,children:[e.meta?.icon&&(0,S.jsx)(`img`,{src:e.meta.icon,alt:``,className:`w-6 h-6`}),e.name]}),e.configHint&&(0,S.jsx)(Vt,{children:e.configHint})]}),e.configLink&&(0,S.jsx)(`a`,{href:e.configLink,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-sm text-blue-500 hover:text-blue-600 underline`,children:`View ACP Documentation →`})]})}):null})()]})};var Y9t=`vercel.ai.error`,X9t=Symbol.for(Y9t),Z9t,Q9t=class e extends Error{constructor({name:e,message:t,cause:n}){super(t),this[Z9t]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,Y9t)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}};Z9t=X9t;var W7=Q9t;function $9t(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}var een=`AI_InvalidArgumentError`,ten=`vercel.ai.error.${een}`,nen=Symbol.for(ten),ren,ien=class extends W7{constructor({message:e,cause:t,argument:n}){super({name:een,message:e,cause:t}),this[ren]=!0,this.argument=n}static isInstance(e){return W7.hasMarker(e,ten)}};ren=nen;var aen=`AI_JSONParseError`,oen=`vercel.ai.error.${aen}`,sen=Symbol.for(oen),cen,len=class extends W7{constructor({text:e,cause:t}){super({name:aen,message:`JSON parsing failed: Text: ${e}.
|
|
6886
6886
|
Error message: ${$9t(t)}`,cause:t}),this[cen]=!0,this.text=e}static isInstance(e){return W7.hasMarker(e,oen)}};cen=sen;var uen=`AI_TypeValidationError`,den=`vercel.ai.error.${uen}`,fen=Symbol.for(den),pen,men=class e extends W7{constructor({value:e,cause:t}){super({name:uen,message:`Type validation failed: Value: ${JSON.stringify(e)}.
|
|
6887
6887
|
Error message: ${$9t(t)}`,cause:t}),this[pen]=!0,this.value=e}static isInstance(e){return W7.hasMarker(e,den)}static wrap({value:t,cause:n}){return e.isInstance(n)&&n.value===t?n:new e({value:t,cause:n})}};pen=fen;var G7=men,hen=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=Lo({onEvent:e=>{i.enqueue(e)},onError(t){e===`terminate`?i.error(t):typeof e==`function`&&e(t)},onRetry:t,onComment:n})},transform(e){r.feed(e)}})}};Object.freeze({status:`aborted`});function K7(e,t,n){function r(n,r){var i;for(let a in Object.defineProperty(n,`_zod`,{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r),o.prototype)a in n||Object.defineProperty(n,a,{value:o.prototype[a].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var q7=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};let gen={};function J7(e){return e&&Object.assign(gen,e),gen}function _en(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function ven(e,t){return typeof t==`bigint`?t.toString():t}function yen(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function ben(e){return e==null}function xen(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Sen(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}function Y7(e,t,n){Object.defineProperty(e,t,{get(){{let r=n();return e[t]=r,r}throw Error(`cached value already set`)},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function X7(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Z7(e){return JSON.stringify(e)}let Cen=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function Q7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let wen=yen(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function $7(e){if(Q7(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(Q7(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}let Ten=new Set([`string`,`number`,`symbol`]);function e9(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function t9(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function n9(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Een(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}let Den={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Oen(e,t){let n={},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&(n[e]=r.shape[e])}return t9(e,{...e._zod.def,shape:n,checks:[]})}function ken(e,t){let n={...e._zod.def.shape},r=e._zod.def;for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return t9(e,{...e._zod.def,shape:n,checks:[]})}function Aen(e,t){if(!$7(t))throw Error(`Invalid input to extend: expected a plain object`);return t9(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return X7(this,`shape`,n),n},checks:[]})}function jen(e,t){return t9(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return X7(this,`shape`,n),n},catchall:t._zod.def.catchall,checks:[]})}function Men(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return t9(t,{...t._zod.def,shape:i,checks:[]})}function Nen(e,t,n){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return t9(t,{...t._zod.def,shape:i,checks:[]})}function r9(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function i9(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function a9(e){return typeof e==`string`?e:e?.message}function o9(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=a9(e.inst?._zod.def?.error?.(e))??a9(t?.error?.(e))??a9(n.customError?.(e))??a9(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Pen(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function s9(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}let Fen=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),Object.defineProperty(e,`message`,{get(){return JSON.stringify(t,ven,2)},enumerable:!0}),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},Ien=K7(`$ZodError`,Fen),Len=K7(`$ZodError`,Fen,{Parent:Error});function Ren(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function zen(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i];i===t.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}let Ben=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new q7;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>o9(e,a,J7())));throw Cen(t,i?.callee),t}return o.value},Ven=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>o9(e,a,J7())));throw Cen(t,i?.callee),t}return o.value},Hen=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new q7;return a.issues.length?{success:!1,error:new(e??Ien)(a.issues.map(e=>o9(e,i,J7())))}:{success:!0,data:a.value}},Uen=Hen(Len),Wen=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>o9(e,i,J7())))}:{success:!0,data:a.value}},Gen=Wen(Len),Ken=/^[cC][^\s-]{8,}$/,qen=/^[0-9a-z]+$/,Jen=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Yen=/^[0-9a-vA-V]{20}$/,Xen=/^[A-Za-z0-9]{27}$/,Zen=/^[a-zA-Z0-9_-]{21}$/,Qen=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,$en=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,etn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,ttn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function ntn(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}let rtn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,itn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,atn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,otn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,stn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ctn=/^[A-Za-z0-9_-]*$/,ltn=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,utn=/^\+(?:[0-9]){6,14}[0-9]$/,dtn=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,ftn=RegExp(`^${dtn}$`);function ptn(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function mtn(e){return RegExp(`^${ptn(e)}$`)}function htn(e){let t=ptn({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${dtn}T(?:${r})$`)}let gtn=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},_tn=/^\d+$/,vtn=/^-?\d+(?:\.\d+)?/i,ytn=/true|false/i,btn=/null/i,xtn=/^[^A-Z]*$/,Stn=/^[^a-z]*$/,c9=K7(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ctn={number:`number`,bigint:`bigint`,object:`date`},wtn=K7(`$ZodCheckLessThan`,(e,t)=>{c9.init(e,t);let n=Ctn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ttn=K7(`$ZodCheckGreaterThan`,(e,t)=>{c9.init(e,t);let n=Ctn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Etn=K7(`$ZodCheckMultipleOf`,(e,t)=>{c9.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Sen(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Dtn=K7(`$ZodCheckNumberFormat`,(e,t)=>{c9.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Den[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=_tn)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),Otn=K7(`$ZodCheckMaxLength`,(e,t)=>{var n;c9.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!ben(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Pen(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ktn=K7(`$ZodCheckMinLength`,(e,t)=>{var n;c9.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!ben(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Pen(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Atn=K7(`$ZodCheckLengthEquals`,(e,t)=>{var n;c9.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!ben(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Pen(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),l9=K7(`$ZodCheckStringFormat`,(e,t)=>{var n,r;c9.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),jtn=K7(`$ZodCheckRegex`,(e,t)=>{l9.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Mtn=K7(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=xtn,l9.init(e,t)}),Ntn=K7(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Stn,l9.init(e,t)}),Ptn=K7(`$ZodCheckIncludes`,(e,t)=>{c9.init(e,t);let n=e9(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ftn=K7(`$ZodCheckStartsWith`,(e,t)=>{c9.init(e,t);let n=RegExp(`^${e9(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Itn=K7(`$ZodCheckEndsWith`,(e,t)=>{c9.init(e,t);let n=RegExp(`.*${e9(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ltn=K7(`$ZodCheckOverwrite`,(e,t)=>{c9.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Rtn=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
6888
6888
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
package/dist/config-updater.cjs
CHANGED
|
@@ -88368,15 +88368,10 @@ function checkCommandExists(command) {
|
|
|
88368
88368
|
}
|
|
88369
88369
|
}
|
|
88370
88370
|
/**
|
|
88371
|
-
*
|
|
88372
|
-
* Key:
|
|
88371
|
+
* Session-scoped provider manager
|
|
88372
|
+
* Key: sessionId, Value: ProviderEntry
|
|
88373
88373
|
*/
|
|
88374
|
-
const
|
|
88375
|
-
/**
|
|
88376
|
-
* Session to provider mapping for quick lookup
|
|
88377
|
-
* Key: sessionId, Value: agentKey
|
|
88378
|
-
*/
|
|
88379
|
-
const sessionToProvider = /* @__PURE__ */ new Map();
|
|
88374
|
+
const sessionProviders = /* @__PURE__ */ new Map();
|
|
88380
88375
|
/**
|
|
88381
88376
|
* Generate a unique key for an agent configuration
|
|
88382
88377
|
*/
|
|
@@ -88410,15 +88405,22 @@ function callMcpMethodViaTransport(transport, method, params) {
|
|
|
88410
88405
|
/**
|
|
88411
88406
|
* Load MCP tools from transport in AI SDK v5 format
|
|
88412
88407
|
*/
|
|
88413
|
-
async function loadMcpToolsV5(
|
|
88408
|
+
async function loadMcpToolsV5(getTransport) {
|
|
88414
88409
|
const tools = {};
|
|
88415
|
-
const
|
|
88410
|
+
const initialTransport = getTransport();
|
|
88411
|
+
if (!initialTransport) {
|
|
88412
|
+
console.warn("[dev-inspector] [acp] No active MCP transport available, tools will not be loaded");
|
|
88413
|
+
return tools;
|
|
88414
|
+
}
|
|
88415
|
+
const { tools: toolsListFromServer } = await callMcpMethodViaTransport(initialTransport, "tools/list");
|
|
88416
88416
|
for (const toolInfo of toolsListFromServer) {
|
|
88417
88417
|
const toolName = toolInfo.name;
|
|
88418
88418
|
tools[toolName] = (0, ai.tool)({
|
|
88419
88419
|
description: toolInfo.description,
|
|
88420
88420
|
inputSchema: (0, ai.jsonSchema)(toolInfo.inputSchema),
|
|
88421
88421
|
execute: async (args) => {
|
|
88422
|
+
const transport = getTransport();
|
|
88423
|
+
if (!transport) throw new Error("No active MCP transport available");
|
|
88422
88424
|
console.log(`[dev-inspector] [acp] Executing MCP tool: ${toolName}`);
|
|
88423
88425
|
const result = await callMcpMethodViaTransport(transport, "tools/call", {
|
|
88424
88426
|
name: toolName,
|
|
@@ -88481,105 +88483,58 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88481
88483
|
const { agent, envVars } = JSON.parse(body);
|
|
88482
88484
|
const cwd$1 = process.cwd();
|
|
88483
88485
|
const agentKey = getAgentKey(agent.command, agent.args);
|
|
88484
|
-
console.log(`[dev-inspector] [acp]
|
|
88485
|
-
|
|
88486
|
-
|
|
88487
|
-
|
|
88488
|
-
if (
|
|
88489
|
-
|
|
88490
|
-
|
|
88491
|
-
|
|
88492
|
-
|
|
88493
|
-
|
|
88494
|
-
}
|
|
88495
|
-
if (!sessionId && providerEntry.initializationPromise) {
|
|
88496
|
-
console.log(`[dev-inspector] [acp] Joining pending initialization for ${agent.name}`);
|
|
88497
|
-
try {
|
|
88498
|
-
sessionId = await providerEntry.initializationPromise;
|
|
88499
|
-
} catch (e) {
|
|
88500
|
-
throw e;
|
|
88501
|
-
}
|
|
88502
|
-
}
|
|
88486
|
+
console.log(`[dev-inspector] [acp] Creating request-scoped session for agent: ${agent.name} (${agentKey})`);
|
|
88487
|
+
if (!checkCommandExists(agent.command)) {
|
|
88488
|
+
const hints = [`Agent "${agent.name}" command not found: "${agent.command}"`];
|
|
88489
|
+
if (agent.installCommand) hints.push(`Install with: ${agent.installCommand}`);
|
|
88490
|
+
if (agent.configHint) hints.push(agent.configHint);
|
|
88491
|
+
if (agent.configLink) hints.push(`Documentation: ${agent.configLink}`);
|
|
88492
|
+
console.error(`\n${hints.join("\n")}\n`);
|
|
88493
|
+
res.statusCode = 400;
|
|
88494
|
+
res.end(JSON.stringify({ error: hints.join("\n") }));
|
|
88495
|
+
return;
|
|
88503
88496
|
}
|
|
88504
|
-
|
|
88505
|
-
|
|
88506
|
-
|
|
88507
|
-
|
|
88508
|
-
|
|
88509
|
-
|
|
88510
|
-
|
|
88511
|
-
|
|
88512
|
-
|
|
88513
|
-
|
|
88514
|
-
|
|
88515
|
-
|
|
88516
|
-
|
|
88517
|
-
|
|
88518
|
-
|
|
88519
|
-
|
|
88520
|
-
|
|
88521
|
-
|
|
88522
|
-
|
|
88523
|
-
|
|
88524
|
-
|
|
88525
|
-
|
|
88526
|
-
|
|
88527
|
-
|
|
88528
|
-
|
|
88529
|
-
|
|
88530
|
-
|
|
88531
|
-
|
|
88532
|
-
|
|
88533
|
-
|
|
88534
|
-
|
|
88535
|
-
},
|
|
88536
|
-
session: {
|
|
88537
|
-
cwd: cwd$1,
|
|
88538
|
-
mcpServers: []
|
|
88539
|
-
},
|
|
88540
|
-
authMethodId: agent.authMethodId,
|
|
88541
|
-
persistSession: true
|
|
88542
|
-
});
|
|
88543
|
-
providerEntry = {
|
|
88544
|
-
provider,
|
|
88545
|
-
agentKey,
|
|
88546
|
-
sessions: /* @__PURE__ */ new Map(),
|
|
88547
|
-
createdAt: Date.now(),
|
|
88548
|
-
initializationPromise: void 0
|
|
88549
|
-
};
|
|
88550
|
-
providerManager.set(agentKey, providerEntry);
|
|
88551
|
-
}
|
|
88552
|
-
console.log(`[dev-inspector] [acp] Spawning new process/session for ${agent.name}`);
|
|
88553
|
-
const initPromise = (async () => {
|
|
88554
|
-
const transport = getInspectorTransport() || getActiveTransport();
|
|
88555
|
-
let initialTools = {};
|
|
88556
|
-
if (transport) try {
|
|
88557
|
-
const rawTools = await loadMcpToolsV5(transport);
|
|
88558
|
-
initialTools = acpTools(rawTools);
|
|
88559
|
-
console.log(`[dev-inspector] [acp] Pre-loading ${Object.keys(rawTools).length} tools for session init`);
|
|
88560
|
-
} catch (e) {
|
|
88561
|
-
console.warn("[dev-inspector] [acp] Failed to pre-load tools:", e);
|
|
88562
|
-
}
|
|
88563
|
-
const sid = (await provider.initSession(initialTools)).sessionId || `session-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
88564
|
-
if (providerEntry) {
|
|
88565
|
-
providerEntry.sessions.set(sid, {
|
|
88566
|
-
sessionId: sid,
|
|
88567
|
-
createdAt: Date.now()
|
|
88568
|
-
});
|
|
88569
|
-
providerEntry.initializationPromise = void 0;
|
|
88570
|
-
}
|
|
88571
|
-
sessionToProvider.set(sid, agentKey);
|
|
88572
|
-
return sid;
|
|
88573
|
-
})();
|
|
88574
|
-
if (providerEntry) providerEntry.initializationPromise = initPromise;
|
|
88575
|
-
try {
|
|
88576
|
-
sessionId = await initPromise;
|
|
88577
|
-
console.log(`[dev-inspector] [acp] Session initialized: ${sessionId}`);
|
|
88578
|
-
} catch (error) {
|
|
88579
|
-
if (providerEntry) providerEntry.initializationPromise = void 0;
|
|
88580
|
-
throw error;
|
|
88497
|
+
let command = agent.command;
|
|
88498
|
+
let args = agent.args;
|
|
88499
|
+
if (agent.npmPackage) {
|
|
88500
|
+
const binPath = resolveNpmPackageBin(agent.npmPackage);
|
|
88501
|
+
if (binPath) {
|
|
88502
|
+
command = binPath;
|
|
88503
|
+
args = agent.npmArgs || [];
|
|
88504
|
+
console.log(`[dev-inspector] [acp] Using resolved npm package: ${agent.npmPackage}`);
|
|
88505
|
+
} else console.log(`[dev-inspector] [acp] Failed to resolve npm package, falling back to: ${agent.command}`);
|
|
88506
|
+
}
|
|
88507
|
+
const provider = createACPProvider({
|
|
88508
|
+
command,
|
|
88509
|
+
args,
|
|
88510
|
+
env: {
|
|
88511
|
+
...process.env,
|
|
88512
|
+
...envVars
|
|
88513
|
+
},
|
|
88514
|
+
session: {
|
|
88515
|
+
cwd: cwd$1,
|
|
88516
|
+
mcpServers: []
|
|
88517
|
+
},
|
|
88518
|
+
authMethodId: agent.authMethodId
|
|
88519
|
+
});
|
|
88520
|
+
console.log(`[dev-inspector] [acp] Spawning new process/session for ${agent.name}`);
|
|
88521
|
+
const getTransport = () => getInspectorTransport() || getActiveTransport();
|
|
88522
|
+
let initialTools = {};
|
|
88523
|
+
try {
|
|
88524
|
+
const rawTools = await loadMcpToolsV5(getTransport);
|
|
88525
|
+
if (Object.keys(rawTools).length > 0) {
|
|
88526
|
+
initialTools = acpTools(rawTools);
|
|
88527
|
+
console.log(`[dev-inspector] [acp] Pre-loading ${Object.keys(rawTools).length} tools for session init`);
|
|
88581
88528
|
}
|
|
88529
|
+
} catch (e) {
|
|
88530
|
+
console.warn("[dev-inspector] [acp] Failed to pre-load tools:", e);
|
|
88582
88531
|
}
|
|
88532
|
+
const sessionId = (await provider.initSession(initialTools)).sessionId || `session-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
88533
|
+
sessionProviders.set(sessionId, {
|
|
88534
|
+
provider,
|
|
88535
|
+
createdAt: Date.now()
|
|
88536
|
+
});
|
|
88537
|
+
console.log(`[dev-inspector] [acp] Session initialized: ${sessionId}`);
|
|
88583
88538
|
res.setHeader("Content-Type", "application/json");
|
|
88584
88539
|
res.end(JSON.stringify({ sessionId }));
|
|
88585
88540
|
} catch (error) {
|
|
@@ -88606,23 +88561,15 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88606
88561
|
try {
|
|
88607
88562
|
const body = await readBody(req);
|
|
88608
88563
|
const { sessionId } = JSON.parse(body);
|
|
88609
|
-
const
|
|
88610
|
-
if (
|
|
88611
|
-
|
|
88612
|
-
|
|
88613
|
-
|
|
88614
|
-
|
|
88615
|
-
|
|
88616
|
-
console.log(`[dev-inspector] [acp] No active sessions for ${agentKey}, cleaning up provider`);
|
|
88617
|
-
try {
|
|
88618
|
-
providerEntry.provider.cleanup();
|
|
88619
|
-
} catch (e) {
|
|
88620
|
-
console.error("Error cleaning up provider:", e);
|
|
88621
|
-
}
|
|
88622
|
-
providerManager.delete(agentKey);
|
|
88623
|
-
}
|
|
88564
|
+
const providerEntry = sessionProviders.get(sessionId);
|
|
88565
|
+
if (providerEntry) {
|
|
88566
|
+
console.log(`[dev-inspector] [acp] Cleaning up session-scoped provider: ${sessionId}`);
|
|
88567
|
+
try {
|
|
88568
|
+
providerEntry.provider.cleanup();
|
|
88569
|
+
} catch (e) {
|
|
88570
|
+
console.error("Error cleaning up provider:", e);
|
|
88624
88571
|
}
|
|
88625
|
-
|
|
88572
|
+
sessionProviders.delete(sessionId);
|
|
88626
88573
|
}
|
|
88627
88574
|
res.setHeader("Content-Type", "application/json");
|
|
88628
88575
|
res.end(JSON.stringify({ success: true }));
|
|
@@ -88652,13 +88599,9 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88652
88599
|
const cwd$1 = process.cwd();
|
|
88653
88600
|
let provider;
|
|
88654
88601
|
let shouldCleanupProvider = true;
|
|
88655
|
-
|
|
88656
|
-
if (sessionId) {
|
|
88657
|
-
const agentKey = sessionToProvider.get(sessionId);
|
|
88658
|
-
if (agentKey) existingProviderEntry = providerManager.get(agentKey);
|
|
88659
|
-
}
|
|
88602
|
+
const existingProviderEntry = sessionId ? sessionProviders.get(sessionId) : void 0;
|
|
88660
88603
|
if (existingProviderEntry) {
|
|
88661
|
-
console.log(`[dev-inspector] [acp] Using existing
|
|
88604
|
+
console.log(`[dev-inspector] [acp] Using existing session-scoped provider for session: ${sessionId}`);
|
|
88662
88605
|
provider = existingProviderEntry.provider;
|
|
88663
88606
|
shouldCleanupProvider = false;
|
|
88664
88607
|
} else {
|
|
@@ -88688,10 +88631,9 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88688
88631
|
});
|
|
88689
88632
|
await provider.initSession();
|
|
88690
88633
|
}
|
|
88691
|
-
const transport = getInspectorTransport() || getActiveTransport();
|
|
88692
88634
|
let mcpTools = {};
|
|
88693
|
-
|
|
88694
|
-
|
|
88635
|
+
const getTransport = () => getInspectorTransport() || getActiveTransport();
|
|
88636
|
+
mcpTools = await loadMcpToolsV5(getTransport);
|
|
88695
88637
|
const mode = agent.acpMode ?? acpOptions?.acpMode;
|
|
88696
88638
|
const model = agent.acpModel ?? acpOptions?.acpModel;
|
|
88697
88639
|
const delay = agent.acpDelay ?? acpOptions?.acpDelay;
|
package/dist/config-updater.js
CHANGED
|
@@ -88403,15 +88403,10 @@ function checkCommandExists(command) {
|
|
|
88403
88403
|
}
|
|
88404
88404
|
}
|
|
88405
88405
|
/**
|
|
88406
|
-
*
|
|
88407
|
-
* Key:
|
|
88406
|
+
* Session-scoped provider manager
|
|
88407
|
+
* Key: sessionId, Value: ProviderEntry
|
|
88408
88408
|
*/
|
|
88409
|
-
const
|
|
88410
|
-
/**
|
|
88411
|
-
* Session to provider mapping for quick lookup
|
|
88412
|
-
* Key: sessionId, Value: agentKey
|
|
88413
|
-
*/
|
|
88414
|
-
const sessionToProvider = /* @__PURE__ */ new Map();
|
|
88409
|
+
const sessionProviders = /* @__PURE__ */ new Map();
|
|
88415
88410
|
/**
|
|
88416
88411
|
* Generate a unique key for an agent configuration
|
|
88417
88412
|
*/
|
|
@@ -88445,15 +88440,22 @@ function callMcpMethodViaTransport(transport, method, params) {
|
|
|
88445
88440
|
/**
|
|
88446
88441
|
* Load MCP tools from transport in AI SDK v5 format
|
|
88447
88442
|
*/
|
|
88448
|
-
async function loadMcpToolsV5(
|
|
88443
|
+
async function loadMcpToolsV5(getTransport) {
|
|
88449
88444
|
const tools = {};
|
|
88450
|
-
const
|
|
88445
|
+
const initialTransport = getTransport();
|
|
88446
|
+
if (!initialTransport) {
|
|
88447
|
+
console.warn("[dev-inspector] [acp] No active MCP transport available, tools will not be loaded");
|
|
88448
|
+
return tools;
|
|
88449
|
+
}
|
|
88450
|
+
const { tools: toolsListFromServer } = await callMcpMethodViaTransport(initialTransport, "tools/list");
|
|
88451
88451
|
for (const toolInfo of toolsListFromServer) {
|
|
88452
88452
|
const toolName = toolInfo.name;
|
|
88453
88453
|
tools[toolName] = tool({
|
|
88454
88454
|
description: toolInfo.description,
|
|
88455
88455
|
inputSchema: jsonSchema(toolInfo.inputSchema),
|
|
88456
88456
|
execute: async (args) => {
|
|
88457
|
+
const transport = getTransport();
|
|
88458
|
+
if (!transport) throw new Error("No active MCP transport available");
|
|
88457
88459
|
console.log(`[dev-inspector] [acp] Executing MCP tool: ${toolName}`);
|
|
88458
88460
|
const result = await callMcpMethodViaTransport(transport, "tools/call", {
|
|
88459
88461
|
name: toolName,
|
|
@@ -88516,105 +88518,58 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88516
88518
|
const { agent, envVars } = JSON.parse(body);
|
|
88517
88519
|
const cwd$1 = process.cwd();
|
|
88518
88520
|
const agentKey = getAgentKey(agent.command, agent.args);
|
|
88519
|
-
console.log(`[dev-inspector] [acp]
|
|
88520
|
-
|
|
88521
|
-
|
|
88522
|
-
|
|
88523
|
-
if (
|
|
88524
|
-
|
|
88525
|
-
|
|
88526
|
-
|
|
88527
|
-
|
|
88528
|
-
|
|
88529
|
-
}
|
|
88530
|
-
if (!sessionId && providerEntry.initializationPromise) {
|
|
88531
|
-
console.log(`[dev-inspector] [acp] Joining pending initialization for ${agent.name}`);
|
|
88532
|
-
try {
|
|
88533
|
-
sessionId = await providerEntry.initializationPromise;
|
|
88534
|
-
} catch (e) {
|
|
88535
|
-
throw e;
|
|
88536
|
-
}
|
|
88537
|
-
}
|
|
88521
|
+
console.log(`[dev-inspector] [acp] Creating request-scoped session for agent: ${agent.name} (${agentKey})`);
|
|
88522
|
+
if (!checkCommandExists(agent.command)) {
|
|
88523
|
+
const hints = [`Agent "${agent.name}" command not found: "${agent.command}"`];
|
|
88524
|
+
if (agent.installCommand) hints.push(`Install with: ${agent.installCommand}`);
|
|
88525
|
+
if (agent.configHint) hints.push(agent.configHint);
|
|
88526
|
+
if (agent.configLink) hints.push(`Documentation: ${agent.configLink}`);
|
|
88527
|
+
console.error(`\n${hints.join("\n")}\n`);
|
|
88528
|
+
res.statusCode = 400;
|
|
88529
|
+
res.end(JSON.stringify({ error: hints.join("\n") }));
|
|
88530
|
+
return;
|
|
88538
88531
|
}
|
|
88539
|
-
|
|
88540
|
-
|
|
88541
|
-
|
|
88542
|
-
|
|
88543
|
-
|
|
88544
|
-
|
|
88545
|
-
|
|
88546
|
-
|
|
88547
|
-
|
|
88548
|
-
|
|
88549
|
-
|
|
88550
|
-
|
|
88551
|
-
|
|
88552
|
-
|
|
88553
|
-
|
|
88554
|
-
|
|
88555
|
-
|
|
88556
|
-
|
|
88557
|
-
|
|
88558
|
-
|
|
88559
|
-
|
|
88560
|
-
|
|
88561
|
-
|
|
88562
|
-
|
|
88563
|
-
|
|
88564
|
-
|
|
88565
|
-
|
|
88566
|
-
|
|
88567
|
-
|
|
88568
|
-
|
|
88569
|
-
|
|
88570
|
-
},
|
|
88571
|
-
session: {
|
|
88572
|
-
cwd: cwd$1,
|
|
88573
|
-
mcpServers: []
|
|
88574
|
-
},
|
|
88575
|
-
authMethodId: agent.authMethodId,
|
|
88576
|
-
persistSession: true
|
|
88577
|
-
});
|
|
88578
|
-
providerEntry = {
|
|
88579
|
-
provider,
|
|
88580
|
-
agentKey,
|
|
88581
|
-
sessions: /* @__PURE__ */ new Map(),
|
|
88582
|
-
createdAt: Date.now(),
|
|
88583
|
-
initializationPromise: void 0
|
|
88584
|
-
};
|
|
88585
|
-
providerManager.set(agentKey, providerEntry);
|
|
88586
|
-
}
|
|
88587
|
-
console.log(`[dev-inspector] [acp] Spawning new process/session for ${agent.name}`);
|
|
88588
|
-
const initPromise = (async () => {
|
|
88589
|
-
const transport = getInspectorTransport() || getActiveTransport();
|
|
88590
|
-
let initialTools = {};
|
|
88591
|
-
if (transport) try {
|
|
88592
|
-
const rawTools = await loadMcpToolsV5(transport);
|
|
88593
|
-
initialTools = acpTools(rawTools);
|
|
88594
|
-
console.log(`[dev-inspector] [acp] Pre-loading ${Object.keys(rawTools).length} tools for session init`);
|
|
88595
|
-
} catch (e) {
|
|
88596
|
-
console.warn("[dev-inspector] [acp] Failed to pre-load tools:", e);
|
|
88597
|
-
}
|
|
88598
|
-
const sid = (await provider.initSession(initialTools)).sessionId || `session-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
88599
|
-
if (providerEntry) {
|
|
88600
|
-
providerEntry.sessions.set(sid, {
|
|
88601
|
-
sessionId: sid,
|
|
88602
|
-
createdAt: Date.now()
|
|
88603
|
-
});
|
|
88604
|
-
providerEntry.initializationPromise = void 0;
|
|
88605
|
-
}
|
|
88606
|
-
sessionToProvider.set(sid, agentKey);
|
|
88607
|
-
return sid;
|
|
88608
|
-
})();
|
|
88609
|
-
if (providerEntry) providerEntry.initializationPromise = initPromise;
|
|
88610
|
-
try {
|
|
88611
|
-
sessionId = await initPromise;
|
|
88612
|
-
console.log(`[dev-inspector] [acp] Session initialized: ${sessionId}`);
|
|
88613
|
-
} catch (error) {
|
|
88614
|
-
if (providerEntry) providerEntry.initializationPromise = void 0;
|
|
88615
|
-
throw error;
|
|
88532
|
+
let command = agent.command;
|
|
88533
|
+
let args = agent.args;
|
|
88534
|
+
if (agent.npmPackage) {
|
|
88535
|
+
const binPath = resolveNpmPackageBin(agent.npmPackage);
|
|
88536
|
+
if (binPath) {
|
|
88537
|
+
command = binPath;
|
|
88538
|
+
args = agent.npmArgs || [];
|
|
88539
|
+
console.log(`[dev-inspector] [acp] Using resolved npm package: ${agent.npmPackage}`);
|
|
88540
|
+
} else console.log(`[dev-inspector] [acp] Failed to resolve npm package, falling back to: ${agent.command}`);
|
|
88541
|
+
}
|
|
88542
|
+
const provider = createACPProvider({
|
|
88543
|
+
command,
|
|
88544
|
+
args,
|
|
88545
|
+
env: {
|
|
88546
|
+
...process.env,
|
|
88547
|
+
...envVars
|
|
88548
|
+
},
|
|
88549
|
+
session: {
|
|
88550
|
+
cwd: cwd$1,
|
|
88551
|
+
mcpServers: []
|
|
88552
|
+
},
|
|
88553
|
+
authMethodId: agent.authMethodId
|
|
88554
|
+
});
|
|
88555
|
+
console.log(`[dev-inspector] [acp] Spawning new process/session for ${agent.name}`);
|
|
88556
|
+
const getTransport = () => getInspectorTransport() || getActiveTransport();
|
|
88557
|
+
let initialTools = {};
|
|
88558
|
+
try {
|
|
88559
|
+
const rawTools = await loadMcpToolsV5(getTransport);
|
|
88560
|
+
if (Object.keys(rawTools).length > 0) {
|
|
88561
|
+
initialTools = acpTools(rawTools);
|
|
88562
|
+
console.log(`[dev-inspector] [acp] Pre-loading ${Object.keys(rawTools).length} tools for session init`);
|
|
88616
88563
|
}
|
|
88564
|
+
} catch (e) {
|
|
88565
|
+
console.warn("[dev-inspector] [acp] Failed to pre-load tools:", e);
|
|
88617
88566
|
}
|
|
88567
|
+
const sessionId = (await provider.initSession(initialTools)).sessionId || `session-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
88568
|
+
sessionProviders.set(sessionId, {
|
|
88569
|
+
provider,
|
|
88570
|
+
createdAt: Date.now()
|
|
88571
|
+
});
|
|
88572
|
+
console.log(`[dev-inspector] [acp] Session initialized: ${sessionId}`);
|
|
88618
88573
|
res.setHeader("Content-Type", "application/json");
|
|
88619
88574
|
res.end(JSON.stringify({ sessionId }));
|
|
88620
88575
|
} catch (error) {
|
|
@@ -88641,23 +88596,15 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88641
88596
|
try {
|
|
88642
88597
|
const body = await readBody(req);
|
|
88643
88598
|
const { sessionId } = JSON.parse(body);
|
|
88644
|
-
const
|
|
88645
|
-
if (
|
|
88646
|
-
|
|
88647
|
-
|
|
88648
|
-
|
|
88649
|
-
|
|
88650
|
-
|
|
88651
|
-
console.log(`[dev-inspector] [acp] No active sessions for ${agentKey}, cleaning up provider`);
|
|
88652
|
-
try {
|
|
88653
|
-
providerEntry.provider.cleanup();
|
|
88654
|
-
} catch (e) {
|
|
88655
|
-
console.error("Error cleaning up provider:", e);
|
|
88656
|
-
}
|
|
88657
|
-
providerManager.delete(agentKey);
|
|
88658
|
-
}
|
|
88599
|
+
const providerEntry = sessionProviders.get(sessionId);
|
|
88600
|
+
if (providerEntry) {
|
|
88601
|
+
console.log(`[dev-inspector] [acp] Cleaning up session-scoped provider: ${sessionId}`);
|
|
88602
|
+
try {
|
|
88603
|
+
providerEntry.provider.cleanup();
|
|
88604
|
+
} catch (e) {
|
|
88605
|
+
console.error("Error cleaning up provider:", e);
|
|
88659
88606
|
}
|
|
88660
|
-
|
|
88607
|
+
sessionProviders.delete(sessionId);
|
|
88661
88608
|
}
|
|
88662
88609
|
res.setHeader("Content-Type", "application/json");
|
|
88663
88610
|
res.end(JSON.stringify({ success: true }));
|
|
@@ -88687,13 +88634,9 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88687
88634
|
const cwd$1 = process.cwd();
|
|
88688
88635
|
let provider;
|
|
88689
88636
|
let shouldCleanupProvider = true;
|
|
88690
|
-
|
|
88691
|
-
if (sessionId) {
|
|
88692
|
-
const agentKey = sessionToProvider.get(sessionId);
|
|
88693
|
-
if (agentKey) existingProviderEntry = providerManager.get(agentKey);
|
|
88694
|
-
}
|
|
88637
|
+
const existingProviderEntry = sessionId ? sessionProviders.get(sessionId) : void 0;
|
|
88695
88638
|
if (existingProviderEntry) {
|
|
88696
|
-
console.log(`[dev-inspector] [acp] Using existing
|
|
88639
|
+
console.log(`[dev-inspector] [acp] Using existing session-scoped provider for session: ${sessionId}`);
|
|
88697
88640
|
provider = existingProviderEntry.provider;
|
|
88698
88641
|
shouldCleanupProvider = false;
|
|
88699
88642
|
} else {
|
|
@@ -88723,10 +88666,9 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
|
|
|
88723
88666
|
});
|
|
88724
88667
|
await provider.initSession();
|
|
88725
88668
|
}
|
|
88726
|
-
const transport = getInspectorTransport() || getActiveTransport();
|
|
88727
88669
|
let mcpTools = {};
|
|
88728
|
-
|
|
88729
|
-
|
|
88670
|
+
const getTransport = () => getInspectorTransport() || getActiveTransport();
|
|
88671
|
+
mcpTools = await loadMcpToolsV5(getTransport);
|
|
88730
88672
|
const mode = agent.acpMode ?? acpOptions?.acpMode;
|
|
88731
88673
|
const model = agent.acpModel ?? acpOptions?.acpModel;
|
|
88732
88674
|
const delay = agent.acpDelay ?? acpOptions?.acpDelay;
|
package/dist/index.cjs
CHANGED
|
@@ -17,22 +17,64 @@ let _code_inspector_core = require("@code-inspector/core");
|
|
|
17
17
|
|
|
18
18
|
//#region src/utils/browser-launcher.ts
|
|
19
19
|
var browser_launcher_exports = /* @__PURE__ */ require_chunk.__export({ launchBrowserWithDevTools: () => launchBrowserWithDevTools });
|
|
20
|
+
async function closeSharedClient(reason) {
|
|
21
|
+
const clientToClose = sharedClient;
|
|
22
|
+
sharedClient = null;
|
|
23
|
+
sharedSseUrl = null;
|
|
24
|
+
connectPromise = null;
|
|
25
|
+
if (!clientToClose) return;
|
|
26
|
+
try {
|
|
27
|
+
console.log(`[dev-inspector] Closing shared browser client: ${reason}`);
|
|
28
|
+
await clientToClose.close();
|
|
29
|
+
} catch {}
|
|
30
|
+
}
|
|
31
|
+
function registerProcessCleanupOnce() {
|
|
32
|
+
if (cleanupRegistered) return;
|
|
33
|
+
cleanupRegistered = true;
|
|
34
|
+
const requestCleanupThenReraise = (signal) => {
|
|
35
|
+
closeSharedClient(signal).finally(() => {
|
|
36
|
+
try {
|
|
37
|
+
process.kill(process.pid, signal);
|
|
38
|
+
} catch {
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
process.once("beforeExit", () => {
|
|
44
|
+
closeSharedClient("beforeExit");
|
|
45
|
+
});
|
|
46
|
+
process.once("SIGINT", () => requestCleanupThenReraise("SIGINT"));
|
|
47
|
+
process.once("SIGTERM", () => requestCleanupThenReraise("SIGTERM"));
|
|
48
|
+
process.once("SIGHUP", () => requestCleanupThenReraise("SIGHUP"));
|
|
49
|
+
}
|
|
50
|
+
async function getOrCreateClient(sseUrl) {
|
|
51
|
+
if (sharedClient && sharedSseUrl === sseUrl) return sharedClient;
|
|
52
|
+
if (connectPromise && sharedSseUrl === sseUrl) return connectPromise;
|
|
53
|
+
if (sharedClient && sharedSseUrl !== sseUrl) await closeSharedClient("sseUrl-changed");
|
|
54
|
+
sharedSseUrl = sseUrl;
|
|
55
|
+
sharedClient = new _modelcontextprotocol_sdk_client_index_js.Client({
|
|
56
|
+
name: "dev-inspector-auto-browser",
|
|
57
|
+
version: "1.0.0"
|
|
58
|
+
});
|
|
59
|
+
const transport = new _modelcontextprotocol_sdk_client_sse_js.SSEClientTransport(new URL(sseUrl));
|
|
60
|
+
connectPromise = sharedClient.connect(transport).then(() => sharedClient).catch(async (error) => {
|
|
61
|
+
await closeSharedClient("connect-failed");
|
|
62
|
+
throw error;
|
|
63
|
+
}).finally(() => {
|
|
64
|
+
connectPromise = null;
|
|
65
|
+
});
|
|
66
|
+
registerProcessCleanupOnce();
|
|
67
|
+
return connectPromise;
|
|
68
|
+
}
|
|
20
69
|
/**
|
|
21
70
|
* Launch browser via Chrome DevTools MCP
|
|
22
71
|
* Uses MCP Client to connect to the MCP server endpoint
|
|
23
72
|
*/
|
|
24
73
|
async function launchBrowserWithDevTools(options) {
|
|
25
74
|
const { url, serverContext } = options;
|
|
26
|
-
const sseUrl = `http://${serverContext.host === "0.0.0.0" ? "localhost" : serverContext.host || "localhost"}:${serverContext.port || 5173}/__mcp__/sse?clientId=
|
|
27
|
-
let client = null;
|
|
75
|
+
const sseUrl = `http://${serverContext.host === "0.0.0.0" ? "localhost" : serverContext.host || "localhost"}:${serverContext.port || 5173}/__mcp__/sse?clientId=browser-launcher-${process.pid}`;
|
|
28
76
|
try {
|
|
29
|
-
|
|
30
|
-
name: "dev-inspector-auto-browser",
|
|
31
|
-
version: "1.0.0"
|
|
32
|
-
});
|
|
33
|
-
const transport = new _modelcontextprotocol_sdk_client_sse_js.SSEClientTransport(new URL(sseUrl));
|
|
34
|
-
await client.connect(transport);
|
|
35
|
-
await client.callTool({
|
|
77
|
+
await (await getOrCreateClient(sseUrl)).callTool({
|
|
36
78
|
name: "chrome_devtools",
|
|
37
79
|
arguments: {
|
|
38
80
|
useTool: "chrome_navigate_page",
|
|
@@ -40,16 +82,19 @@ async function launchBrowserWithDevTools(options) {
|
|
|
40
82
|
chrome_navigate_page: { url }
|
|
41
83
|
}
|
|
42
84
|
});
|
|
43
|
-
await new Promise((r) => setTimeout(r, 1e3));
|
|
44
85
|
return true;
|
|
45
86
|
} catch (error) {
|
|
46
87
|
console.error(`[dev-inspector] ⚠️ Failed to auto-open browser:`, error instanceof Error ? error.message : String(error));
|
|
47
88
|
return false;
|
|
48
|
-
} finally {
|
|
49
|
-
await client?.close().catch(() => {});
|
|
50
89
|
}
|
|
51
90
|
}
|
|
52
|
-
var
|
|
91
|
+
var sharedClient, sharedSseUrl, connectPromise, cleanupRegistered;
|
|
92
|
+
var init_browser_launcher = require_chunk.__esmMin((() => {
|
|
93
|
+
sharedClient = null;
|
|
94
|
+
sharedSseUrl = null;
|
|
95
|
+
connectPromise = null;
|
|
96
|
+
cleanupRegistered = false;
|
|
97
|
+
}));
|
|
53
98
|
|
|
54
99
|
//#endregion
|
|
55
100
|
//#region src/utils/create-plugin.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as unplugin1 from "unplugin";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/config-updater.d.ts
|
|
4
4
|
type EditorId = "cursor" | "vscode" | "windsurf" | "claude-code" | "antigravity";
|
|
@@ -166,10 +166,10 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
|
|
|
166
166
|
}
|
|
167
167
|
//#endregion
|
|
168
168
|
//#region src/core.d.ts
|
|
169
|
-
declare const unplugin:
|
|
169
|
+
declare const unplugin: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
170
170
|
//#endregion
|
|
171
171
|
//#region src/core-external.d.ts
|
|
172
|
-
declare const unpluginExternal:
|
|
172
|
+
declare const unpluginExternal: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
173
173
|
//#endregion
|
|
174
174
|
//#region src/turbopack.d.ts
|
|
175
175
|
interface TurbopackDevInspectorOptions extends DevInspectorOptions {
|
|
@@ -194,7 +194,7 @@ interface TurbopackDevInspectorOptions extends DevInspectorOptions {
|
|
|
194
194
|
declare function turbopackDevInspector(options?: TurbopackDevInspectorOptions): any;
|
|
195
195
|
//#endregion
|
|
196
196
|
//#region src/index.d.ts
|
|
197
|
-
declare const external:
|
|
197
|
+
declare const external: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
|
|
198
198
|
declare module "virtual:dev-inspector-mcp" {}
|
|
199
199
|
//#endregion
|
|
200
200
|
export { type CustomEditorConfig, type DevInspectorOptions, type EditorId, type McpConfigOptions, type TurbopackDevInspectorOptions, unplugin as default, unplugin, external, turbopackDevInspector, unpluginExternal };
|
package/dist/index.js
CHANGED
|
@@ -13,22 +13,64 @@ import { transformCode } from "@code-inspector/core";
|
|
|
13
13
|
|
|
14
14
|
//#region src/utils/browser-launcher.ts
|
|
15
15
|
var browser_launcher_exports = /* @__PURE__ */ __export({ launchBrowserWithDevTools: () => launchBrowserWithDevTools });
|
|
16
|
+
async function closeSharedClient(reason) {
|
|
17
|
+
const clientToClose = sharedClient;
|
|
18
|
+
sharedClient = null;
|
|
19
|
+
sharedSseUrl = null;
|
|
20
|
+
connectPromise = null;
|
|
21
|
+
if (!clientToClose) return;
|
|
22
|
+
try {
|
|
23
|
+
console.log(`[dev-inspector] Closing shared browser client: ${reason}`);
|
|
24
|
+
await clientToClose.close();
|
|
25
|
+
} catch {}
|
|
26
|
+
}
|
|
27
|
+
function registerProcessCleanupOnce() {
|
|
28
|
+
if (cleanupRegistered) return;
|
|
29
|
+
cleanupRegistered = true;
|
|
30
|
+
const requestCleanupThenReraise = (signal) => {
|
|
31
|
+
closeSharedClient(signal).finally(() => {
|
|
32
|
+
try {
|
|
33
|
+
process.kill(process.pid, signal);
|
|
34
|
+
} catch {
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
process.once("beforeExit", () => {
|
|
40
|
+
closeSharedClient("beforeExit");
|
|
41
|
+
});
|
|
42
|
+
process.once("SIGINT", () => requestCleanupThenReraise("SIGINT"));
|
|
43
|
+
process.once("SIGTERM", () => requestCleanupThenReraise("SIGTERM"));
|
|
44
|
+
process.once("SIGHUP", () => requestCleanupThenReraise("SIGHUP"));
|
|
45
|
+
}
|
|
46
|
+
async function getOrCreateClient(sseUrl) {
|
|
47
|
+
if (sharedClient && sharedSseUrl === sseUrl) return sharedClient;
|
|
48
|
+
if (connectPromise && sharedSseUrl === sseUrl) return connectPromise;
|
|
49
|
+
if (sharedClient && sharedSseUrl !== sseUrl) await closeSharedClient("sseUrl-changed");
|
|
50
|
+
sharedSseUrl = sseUrl;
|
|
51
|
+
sharedClient = new Client({
|
|
52
|
+
name: "dev-inspector-auto-browser",
|
|
53
|
+
version: "1.0.0"
|
|
54
|
+
});
|
|
55
|
+
const transport = new SSEClientTransport(new URL(sseUrl));
|
|
56
|
+
connectPromise = sharedClient.connect(transport).then(() => sharedClient).catch(async (error) => {
|
|
57
|
+
await closeSharedClient("connect-failed");
|
|
58
|
+
throw error;
|
|
59
|
+
}).finally(() => {
|
|
60
|
+
connectPromise = null;
|
|
61
|
+
});
|
|
62
|
+
registerProcessCleanupOnce();
|
|
63
|
+
return connectPromise;
|
|
64
|
+
}
|
|
16
65
|
/**
|
|
17
66
|
* Launch browser via Chrome DevTools MCP
|
|
18
67
|
* Uses MCP Client to connect to the MCP server endpoint
|
|
19
68
|
*/
|
|
20
69
|
async function launchBrowserWithDevTools(options) {
|
|
21
70
|
const { url, serverContext } = options;
|
|
22
|
-
const sseUrl = `http://${serverContext.host === "0.0.0.0" ? "localhost" : serverContext.host || "localhost"}:${serverContext.port || 5173}/__mcp__/sse?clientId=
|
|
23
|
-
let client = null;
|
|
71
|
+
const sseUrl = `http://${serverContext.host === "0.0.0.0" ? "localhost" : serverContext.host || "localhost"}:${serverContext.port || 5173}/__mcp__/sse?clientId=browser-launcher-${process.pid}`;
|
|
24
72
|
try {
|
|
25
|
-
|
|
26
|
-
name: "dev-inspector-auto-browser",
|
|
27
|
-
version: "1.0.0"
|
|
28
|
-
});
|
|
29
|
-
const transport = new SSEClientTransport(new URL(sseUrl));
|
|
30
|
-
await client.connect(transport);
|
|
31
|
-
await client.callTool({
|
|
73
|
+
await (await getOrCreateClient(sseUrl)).callTool({
|
|
32
74
|
name: "chrome_devtools",
|
|
33
75
|
arguments: {
|
|
34
76
|
useTool: "chrome_navigate_page",
|
|
@@ -36,16 +78,19 @@ async function launchBrowserWithDevTools(options) {
|
|
|
36
78
|
chrome_navigate_page: { url }
|
|
37
79
|
}
|
|
38
80
|
});
|
|
39
|
-
await new Promise((r) => setTimeout(r, 1e3));
|
|
40
81
|
return true;
|
|
41
82
|
} catch (error) {
|
|
42
83
|
console.error(`[dev-inspector] ⚠️ Failed to auto-open browser:`, error instanceof Error ? error.message : String(error));
|
|
43
84
|
return false;
|
|
44
|
-
} finally {
|
|
45
|
-
await client?.close().catch(() => {});
|
|
46
85
|
}
|
|
47
86
|
}
|
|
48
|
-
var
|
|
87
|
+
var sharedClient, sharedSseUrl, connectPromise, cleanupRegistered;
|
|
88
|
+
var init_browser_launcher = __esmMin((() => {
|
|
89
|
+
sharedClient = null;
|
|
90
|
+
sharedSseUrl = null;
|
|
91
|
+
connectPromise = null;
|
|
92
|
+
cleanupRegistered = false;
|
|
93
|
+
}));
|
|
49
94
|
|
|
50
95
|
//#endregion
|
|
51
96
|
//#region src/utils/create-plugin.ts
|
package/package.json
CHANGED