@mcpc-tech/unplugin-dev-inspector-mcp 0.0.10 → 0.0.13

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/README.md CHANGED
@@ -289,7 +289,25 @@ export default {
289
289
  - "This API call is failing" → AI analyzes network requests, timing, responses
290
290
  - "Where is this component?" → Jump to source file and line number
291
291
 
292
- ## MCP Tools
292
+ ## Two Workflow Modes
293
+
294
+ DevInspector offers two ways to interact with your AI, depending on your preference:
295
+
296
+ ### 1. Editor Mode
297
+ **Best for:** Code-heavy tasks, refactoring, and maintaining flow.
298
+
299
+ - **How it works:** You use your IDE's AI assistant (Cursor, Windsurf, Copilot).
300
+ - **The Flow:** Click an element in the browser -> The context (source, props, styles) is sent to your Editor via MCP -> You ask your Editor to fix it.
301
+ - **Why:** Keeps you in your coding environment.
302
+
303
+ ### 2. Inspector Bar Mode (Recommended)
304
+ **Best for:** Quick fixes, visual tweaks, or if you don't use an AI editor.
305
+
306
+ - **How it works:** You use the floating "Inspector Bar" directly in the browser.
307
+ - **The Flow:** Click "Ask AI" in the browser -> Select an agent (e.g., Claude Code, Custom Script) -> The agent runs in your terminal but interacts with the browser overlay.
308
+ - **Why:** No context switching. Great for "what is this?" questions or network debugging.
309
+
310
+ ## MCP Tools
293
311
 
294
312
  ### `capture_element_context`
295
313
  Activates visual selector. Returns source location, DOM hierarchy, styles, dimensions, and user notes.
@@ -689,10 +689,6 @@ ${t}
689
689
  pointer-events: none;
690
690
  }
691
691
 
692
- .collapse {
693
- visibility: collapse;
694
- }
695
-
696
692
  .visible {
697
693
  visibility: visible;
698
694
  }
@@ -6936,7 +6932,7 @@ ${e.themeCSS}`),e.fontFamily!==void 0&&(n+=`
6936
6932
  `)||(e.endsWith("```\n")||e.endsWith("```"))&&t%2==0)return e;let r=e.match(Mtn);if(r&&!n){let t=r[2];if(!t||z7.test(t))return e;if(Jtn(e)%2==1)return`${e}\``}return e},Xtn=e=>{let t=e.match(Ntn);if(t){let n=t[2];if(!n||z7.test(n))return e;if((e.match(/~~/g)||[]).length%2==1)return`${e}~~`}return e},Ztn=e=>{if((e.match(/\$\$/g)||[]).length%2==0)return e;let t=e.indexOf(`$$`);return t!==-1&&e.indexOf(`
6937
6933
  `,t)!==-1&&!e.endsWith(`
6938
6934
  `)?`${e}
6939
- $$`:`${e}$$`},Qtn=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},$tn=e=>{if(V7(e)||Rtn.test(e))return e;let t=e.match(ktn);if(t){let n=t[2];if(!n||z7.test(n))return e;if(Qtn(e)%2==1)return`${e}***`}return e},enn=e=>{if(!e||typeof e!=`string`)return e;let t=e,n=ztn(t);return n.endsWith(`](streamdown:incomplete-link)`)?n:(t=n,t=$tn(t),t=Btn(t),t=Vtn(t),t=Utn(t),t=Ktn(t),t=Ytn(t),t=Xtn(t),t=Ztn(t),t)},tnn={harden:[ehe,{allowedImagePrefixes:[`*`],allowedLinkPrefixes:[`*`],defaultOrigin:void 0,allowDataImages:!0}],raw:BSe,katex:[Dve,{errorColor:`var(--color-muted-foreground)`}]},nnn={gfm:[aEe,{}],math:[_Ee,{singleDollarTextMath:!1}],cjkFriendly:[yCe,{}],cjkFriendlyGfmStrikethrough:[xCe,{}]},rnn=(0,_.createContext)([`github-light`,`github-dark`]),inn=(0,_.createContext)(void 0),ann=(0,_.createContext)(!0),H7=(0,_.createContext)({isAnimating:!1}),onn=(0,_.memo)(({content:e,shouldParseIncompleteMarkdown:t,...n})=>{let r=(0,_.useMemo)(()=>typeof e==`string`&&t?enn(e.trim()):e,[e,t]);return(0,S.jsx)(Yme,{...n,children:r})},(e,t)=>e.content===t.content);onn.displayName=`Block`;var snn=[`github-light`,`github-dark`],cnn=(0,_.memo)(({children:e,parseIncompleteMarkdown:t=!0,components:n,rehypePlugins:r=Object.values(tnn),remarkPlugins:i=Object.values(nnn),className:a,shikiTheme:o=snn,mermaidConfig:s,controls:l=!0,isAnimating:u=!1,urlTransform:d=e=>e,BlockComponent:f=onn,parseMarkdownIntoBlocksFn:m=Ttn,...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]===Dve:e===Dve)&&Promise.resolve().then(()=>p(ben(),1))},[r]);let y=(0,_.useMemo)(()=>({isAnimating:u}),[u]);return(0,S.jsx)(rnn.Provider,{value:o,children:(0,S.jsx)(inn.Provider,{value:s,children:(0,S.jsx)(ann.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:{...btn,...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);cnn.displayName=`Streamdown`;let lnn=(0,_.createContext)(null),unn=()=>{let e=(0,_.useContext)(lnn);if(!e)throw Error(`Reasoning components must be used within Reasoning`);return e},dnn=(0,_.memo)(({className:e,isStreaming:t=!1,open:n,defaultOpen:r=!0,onOpenChange:i,duration:a,children:o,...s})=>{let[l,u]=ht({prop:n,defaultProp:r,onChange:i}),[d,f]=ht({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)(lnn.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:d},children:(0,S.jsx)(Hi,{className:nt(`not-prose mb-4`,e),onOpenChange:e=>{u(e)},open:l,...s,children:o})})}),fnn=(e,t)=>e||t===0?(0,S.jsx)(Uce,{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`]}),pnn=(0,_.memo)(({className:e,children:t,...n})=>{let{isStreaming:r,isOpen:i,duration:a}=unn();return(0,S.jsx)(Ui,{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)($r,{className:`size-4`}),fnn(r,a),(0,S.jsx)(ei,{className:nt(`size-4 transition-transform`,i?`rotate-180`:`rotate-0`)})]})})}),mnn=(0,_.memo)(({className:e,children:t,...n})=>(0,S.jsx)(Wi,{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)(cnn,{...n,children:t})}));dnn.displayName=`Reasoning`,pnn.displayName=`ReasoningTrigger`,mnn.displayName=`ReasoningContent`,(0,_.createContext)(null);let hnn=(0,_.memo)(({className:e,...t})=>(0,S.jsx)(cnn,{className:nt(`size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,e),...t}),(e,t)=>e.children===t.children);hnn.displayName=`MessageResponse`;let gnn=(0,_.createContext)({code:``}),_nn={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 vnn(e,t,n=!1){let r=n?[_nn]:[];return await Promise.all([xXe(e,{lang:t,theme:`one-light`,transformers:r}),xXe(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)(()=>(vnn(e,t,n).then(([e,t])=>{d.current||=(s(e),u(t),!0)}),()=>{d.current=!1}),[e,t,n]),(0,S.jsx)(gnn.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-hidden 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-hidden 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})]})})})},ynn=({className:e,...t})=>(0,S.jsx)(Hi,{className:nt(`not-prose mb-4 w-full rounded-md border`,e),...t}),bnn=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)(si,{className:`size-4`}),"input-available":(0,S.jsx)(ci,{className:`size-4 animate-pulse`}),"approval-requested":(0,S.jsx)(ci,{className:`size-4 text-yellow-600`}),"approval-responded":(0,S.jsx)(ii,{className:`size-4 text-blue-600`}),"output-available":(0,S.jsx)(ii,{className:`size-4 text-green-600`}),"output-error":(0,S.jsx)(oi,{className:`size-4 text-red-600`}),"output-denied":(0,S.jsx)(oi,{className:`size-4 text-orange-600`})}[e],t[e]]})},xnn=({className:e,title:t,type:n,state:r,...i})=>(0,S.jsxs)(Ui,{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)(bi,{className:`size-4 text-muted-foreground`}),(0,S.jsx)(`span`,{className:`font-medium text-sm`,children:t??n.split(`-`).slice(1).join(`-`)}),bnn(r)]}),(0,S.jsx)(ei,{className:`size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]}),Snn=({className:e,...t})=>(0,S.jsx)(Wi,{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}),Cnn=({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`})})]}),wnn=({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 Tnn({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 Enn({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 Dnn({className:e,...t}){return(0,S.jsx)(`div`,{"data-slot":`card-content`,className:nt(`px-6`,e),...t})}let Onn=(0,_.createContext)(null),knn=({className:e,isStreaming:t=!1,children:n,...r})=>(0,S.jsx)(Onn.Provider,{value:{isStreaming:t},children:(0,S.jsx)(Hi,{asChild:!0,"data-slot":`plan`,...r,children:(0,S.jsx)(Tnn,{className:nt(`shadow-none`,e),children:n})})}),Ann=({className:e,...t})=>(0,S.jsx)(Enn,{className:nt(`flex items-start justify-between`,e),"data-slot":`plan-header`,...t}),jnn=e=>(0,S.jsx)(Wi,{asChild:!0,children:(0,S.jsx)(Dnn,{"data-slot":`plan-content`,...e})}),Mnn=({className:e,...t})=>(0,S.jsx)(Ui,{asChild:!0,children:(0,S.jsxs)(Oi,{className:nt(`size-8`,e),"data-slot":`plan-trigger`,size:`icon`,variant:`ghost`,...t,children:[(0,S.jsx)(ni,{className:`size-4`}),(0,S.jsx)(`span`,{className:`sr-only`,children:`Toggle plan`})]})});function Nnn(e){let t=e;return typeof t.type==`string`&&t.type.startsWith(`tool-`)&&`state`in t}function Pnn(e,t,n,r,i){if(e.type===`text`&&e.text)return(0,S.jsx)(hnn,{className:`whitespace-pre-wrap`,children:e.text},`${t}-${n}`);if(e.type===`reasoning`)return(0,S.jsxs)(dnn,{className:`w-full`,isStreaming:r,children:[(0,S.jsx)(pnn,{}),(0,S.jsx)(mnn,{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)(knn,{defaultOpen:!0,isStreaming:r,children:[(0,S.jsx)(Ann,{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)(Mnn,{className:`mb-2`})]})}),(0,S.jsx)(jnn,{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(Nnn(e)){let r=e.input,i=r.toolName,a=e.state,o=a===`output-available`||a===`output-error`;return(0,S.jsxs)(ynn,{defaultOpen:o,children:[(0,S.jsx)(xnn,{title:i.length>20?`${i.slice(0,20)}...`:i,type:i,state:a}),(0,S.jsxs)(Snn,{children:[e.input!==void 0&&(0,S.jsx)(Cnn,{input:r}),o&&(0,S.jsx)(wnn,{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 Fnn=({messages:e,status:t,selectedAgent:n})=>{let r=dd.find(e=>e.name===(n||fd))||dd[0];return(0,S.jsxs)(tle,{className:`w-full h-full`,children:[(0,S.jsxs)(nle,{className:`p-3 space-y-3`,children:[e.length===0?(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`})]})}):e.map(e=>(0,S.jsxs)(Ile,{className:`items-start`,from:e.role,children:[(0,S.jsx)(Lle,{children:e.parts.map((n,r)=>Pnn(n,e.id,r,t===`streaming`,e.metadata))}),e.role===`assistant`&&(0,S.jsx)(Rle,{name:r.name,src:r.meta?.icon??``})]},e.id)),t===`submitted`&&e.length===0&&(0,S.jsx)(Ble,{})]}),(0,S.jsx)(rle,{})]})};function Inn(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 Lnn({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 Rnn=`AI_SELECTED_AGENT`,znn=e=>{let[t,n]=(0,_.useState)(e);return(0,_.useEffect)(()=>{typeof window<`u`&&_d().then(e=>{if(e&&e!==fd)n(e);else{let e=localStorage.getItem(Rnn);e&&n(e)}})},[]),{agent:t,setAgent:e=>{n(e),!(typeof window>`u`)&&(e?.trim()?localStorage.setItem(Rnn,e):localStorage.removeItem(Rnn))}}},Bnn=({isActive:e,onToggleInspector:t,onSubmitAgent:n,onCancel:r,isAgentWorking:i,messages:a,status:o,inspectionCount:s=0,inspectionItems:l=[],onRemoveInspection:u=()=>{}})=>{let[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(`none`),[b,x]=(0,_.useState)(!1),[C,w]=(0,_.useState)(!1),[T,E]=(0,_.useState)(!0),{agent:D,setAgent:O}=znn(fd),[k,A]=(0,_.useState)(!1),j=dd.find(e=>e.name===D)||dd[0],{elementRef:M,isDragging:N,handleMouseDown:P}=Lnn(),[F,I]=(0,_.useState)(null),[L,R]=(0,_.useState)(``),ee=Inn(L,i,50),[te,z]=(0,_.useState)(``),B=(0,_.useRef)(``),ne=(0,_.useRef)(``);(0,_.useEffect)(()=>{let e=ee,t=B.current;if(e.length<t.length||!e.startsWith(t)){z(e),B.current=e;return}if(e.length>t.length){let n=e.slice(t.length).trim();n&&z(n),B.current=e}},[ee]);let re=(0,_.useRef)(null),ie=(0,_.useRef)(null),ae=(0,_.useRef)(null),oe=(0,_.useRef)(!1);(0,_.useEffect)(()=>{if(a.length===0){R(``),g(null),ae.current=null,oe.current=!1,z(``),B.current=``;return}let e=a[a.length-1];if(e.role!==`assistant`)return;let t=Kce(e),{displayText:n,toolCall:r}=Jce(e,t||ae.current);R(n||``),t&&(ae.current=t),r?(ie.current&&=(clearTimeout(ie.current),null),g(r),oe.current=!0):oe.current=!1},[a]),(0,_.useEffect)(()=>{te!==ne.current&&(oe.current||g(null),ne.current=te)},[te]),(0,_.useEffect)(()=>{d&&re.current&&re.current.focus()},[d]),(0,_.useEffect)(()=>{if(!i&&C){x(!1),w(!1),E(!1);let e=setTimeout(()=>{E(!0)},2e3);return()=>clearTimeout(e)}},[i,C]),(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;I({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;I({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 se=e=>{e.preventDefault(),p.trim()&&(ie.current&&=(clearTimeout(ie.current),null),g(null),R(``),ae.current=null,x(!0),w(!0),n(p,D),m(``),v===`none`&&(f(!1),re.current?.blur()))},ce=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),se(e)),e.key===`Escape`&&(f(!1),re.current?.blur())},le=o===`error`,ue=a.length>0,de=d&&!b,fe=(!d||b)&&(i||ue||F);return(0,S.jsxs)(`div`,{ref:M,className:nt(`fixed bottom-8 left-1/2 z-[999999]`,`transition-all duration-300 ease-[cubic-bezier(0.23,1,0.32,1)]`,d?`w-[450px]`:fe?`w-auto min-w-[200px] max-w-[450px]`:`w-[160px]`,N?`cursor-grabbing`:`cursor-grab`),onMouseDown:P,onMouseEnter:()=>{N||(i||C?(f(!0),y(`chat`)):T&&f(!0))},onMouseLeave:()=>{!p.trim()&&!C&&!N&&(f(!1),y(`none`)),E(!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`,d?`h-12 p-2 pl-4`:`h-9 px-2 py-1`,v===`none`?`bg-muted/90 rounded-full`:`bg-muted/95 rounded-b-lg rounded-t-none border-t-0`,le&&!d&&`bg-destructive/10 border-destructive/20`),children:[(0,S.jsxs)(`div`,{className:nt(`flex items-center transition-opacity duration-300 w-full relative`,de?`absolute left-3 opacity-0 pointer-events-none`:`relative opacity-100`),children:[!fe&&(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)(gi,{className:`w-3.5 h-3.5 text-foreground`})}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground/70 ml-3`,children:`Hover to inspect`})]}),fe&&(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)(gi,{className:`w-3.5 h-3.5 animate-pulse text-foreground`})]}):F?F.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)(vi,{className:`w-3.5 h-3.5 animate-pulse text-blue-500`})]}):F.status===`completed`?(0,S.jsx)(ai,{className:`w-5 h-5 text-green-500`}):(0,S.jsx)(oi,{className:`w-5 h-5 text-red-500`}):le?(0,S.jsx)(oi,{className:`w-5 h-5 text-red-500`}):(0,S.jsx)(ai,{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:F&&F.status===`in-progress`&&F.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)(vi,{className:`w-4 h-4 flex-shrink-0`}),(0,S.jsxs)(`span`,{className:`truncate min-w-0`,children:[`Step `,F.currentStep.index,`/`,F.currentStep.total,`: `,F.currentStep.title]})]}):F?.message?(0,S.jsx)(`div`,{className:`text-sm font-medium leading-[1.4] text-foreground truncate min-w-0`,children:F.message}):h?(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground min-w-0`,children:[(0,S.jsx)(vi,{className:`w-4 h-4 flex-shrink-0`}),(0,S.jsx)(`span`,{className:`truncate min-w-0`,children:h})]}):(0,S.jsx)(`div`,{className:`text-sm font-medium leading-[1.4] text-foreground truncate min-w-0`,children:i&&!te?(0,S.jsx)(Uce,{duration:2,spread:2,children:o===`submitted`&&j?.command===`npx`?`Starting ${j.name}... This may take a moment.`:`Thinking...`}):te||`Processing...`})})})]})]}),(0,S.jsxs)(`div`,{className:nt(`flex items-center w-full gap-3 transition-all duration-500 delay-75`,de?`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`,children:(0,S.jsx)(li,{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:()=>y(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`,v===`inspections`&&`bg-accent/50 text-foreground`),title:`View Inspections`,children:[(0,S.jsx)(ui,{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:se,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:()=>A(!k),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:dd.find(e=>e.name===D)?.meta?.icon,alt:D,className:`w-3.5 h-3.5`})}),k&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`fixed inset-0 z-[999998]`,onClick:()=>A(!1)}),(0,S.jsx)(`div`,{className:`absolute bottom-full left-0 mb-2 w-48 bg-popover border border-border rounded-lg shadow-lg overflow-hidden z-[999999] animate-in fade-in zoom-in-95 duration-200`,children:dd.map(e=>(0,S.jsxs)(`button`,{onClick:()=>{O(e.name),A(!1)},className:nt(`w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-accent transition-colors`,D===e.name&&`bg-accent/50 font-medium`),children:[e.meta?.icon&&(0,S.jsx)(`img`,{src:e.meta.icon,alt:``,className:`w-4 h-4`}),e.name]},e.name))})]})]}),(0,S.jsx)(`input`,{ref:re,type:`text`,value:p,onChange:e=>m(e.target.value),onKeyDown:ce,placeholder:`Ask ${D}...`,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||C)&&(0,S.jsx)(`button`,{type:`button`,onClick:()=>y(e=>e===`chat`?`none`:`chat`),className:nt(`flex items-center justify-center w-7 h-7 rounded-full transition-all flex-shrink-0`,v===`chat`?`bg-foreground text-background`:`bg-accent text-muted-foreground hover:bg-accent/80 hover:text-foreground`),title:v===`chat`?`Collapse`:`Expand messages`,children:(0,S.jsx)(ti,{className:nt(`w-3.5 h-3.5 transition-transform duration-300`,v===`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)(_i,{className:`w-3 h-3`})}):(0,S.jsx)(`button`,{type:`submit`,disabled:!p.trim(),className:nt(`flex items-center justify-center w-7 h-7 rounded-full transition-all flex-shrink-0`,p.trim()?`bg-foreground text-background scale-100`:`bg-accent text-muted-foreground/50 scale-90`),children:(0,S.jsx)(Qr,{className:`w-3.5 h-3.5`})})]})]})]}),v!==`none`&&(0,S.jsx)(`div`,{className:`absolute bottom-full left-0 right-0 pointer-events-auto max-w-[450px] 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:[v===`inspections`&&l.length>0&&(0,S.jsx)(`div`,{className:`border-b border-border`,children:(0,S.jsx)(ea,{items:l,onRemove:u})}),v===`chat`&&(0,S.jsx)(`div`,{className:`h-[500px]`,children:(0,S.jsx)(Fnn,{messages:a,status:o,selectedAgent:D})})]})})]})};var Vnn=`vercel.ai.error`,Hnn=Symbol.for(Vnn),Unn,Wnn=class e extends Error{constructor({name:e,message:t,cause:n}){super(t),this[Unn]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,Vnn)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}};Unn=Hnn;var W7=Wnn;function Gnn(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}var Knn=`AI_InvalidArgumentError`,qnn=`vercel.ai.error.${Knn}`,Jnn=Symbol.for(qnn),Ynn,Xnn=class extends W7{constructor({message:e,cause:t,argument:n}){super({name:Knn,message:e,cause:t}),this[Ynn]=!0,this.argument=n}static isInstance(e){return W7.hasMarker(e,qnn)}};Ynn=Jnn;var Znn=`AI_JSONParseError`,Qnn=`vercel.ai.error.${Znn}`,$nn=Symbol.for(Qnn),ern,trn=class extends W7{constructor({text:e,cause:t}){super({name:Znn,message:`JSON parsing failed: Text: ${e}.
6935
+ $$`:`${e}$$`},Qtn=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},$tn=e=>{if(V7(e)||Rtn.test(e))return e;let t=e.match(ktn);if(t){let n=t[2];if(!n||z7.test(n))return e;if(Qtn(e)%2==1)return`${e}***`}return e},enn=e=>{if(!e||typeof e!=`string`)return e;let t=e,n=ztn(t);return n.endsWith(`](streamdown:incomplete-link)`)?n:(t=n,t=$tn(t),t=Btn(t),t=Vtn(t),t=Utn(t),t=Ktn(t),t=Ytn(t),t=Xtn(t),t=Ztn(t),t)},tnn={harden:[ehe,{allowedImagePrefixes:[`*`],allowedLinkPrefixes:[`*`],defaultOrigin:void 0,allowDataImages:!0}],raw:BSe,katex:[Dve,{errorColor:`var(--color-muted-foreground)`}]},nnn={gfm:[aEe,{}],math:[_Ee,{singleDollarTextMath:!1}],cjkFriendly:[yCe,{}],cjkFriendlyGfmStrikethrough:[xCe,{}]},rnn=(0,_.createContext)([`github-light`,`github-dark`]),inn=(0,_.createContext)(void 0),ann=(0,_.createContext)(!0),H7=(0,_.createContext)({isAnimating:!1}),onn=(0,_.memo)(({content:e,shouldParseIncompleteMarkdown:t,...n})=>{let r=(0,_.useMemo)(()=>typeof e==`string`&&t?enn(e.trim()):e,[e,t]);return(0,S.jsx)(Yme,{...n,children:r})},(e,t)=>e.content===t.content);onn.displayName=`Block`;var snn=[`github-light`,`github-dark`],cnn=(0,_.memo)(({children:e,parseIncompleteMarkdown:t=!0,components:n,rehypePlugins:r=Object.values(tnn),remarkPlugins:i=Object.values(nnn),className:a,shikiTheme:o=snn,mermaidConfig:s,controls:l=!0,isAnimating:u=!1,urlTransform:d=e=>e,BlockComponent:f=onn,parseMarkdownIntoBlocksFn:m=Ttn,...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]===Dve:e===Dve)&&Promise.resolve().then(()=>p(ben(),1))},[r]);let y=(0,_.useMemo)(()=>({isAnimating:u}),[u]);return(0,S.jsx)(rnn.Provider,{value:o,children:(0,S.jsx)(inn.Provider,{value:s,children:(0,S.jsx)(ann.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:{...btn,...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);cnn.displayName=`Streamdown`;let lnn=(0,_.createContext)(null),unn=()=>{let e=(0,_.useContext)(lnn);if(!e)throw Error(`Reasoning components must be used within Reasoning`);return e},dnn=(0,_.memo)(({className:e,isStreaming:t=!1,open:n,defaultOpen:r=!0,onOpenChange:i,duration:a,children:o,...s})=>{let[l,u]=ht({prop:n,defaultProp:r,onChange:i}),[d,f]=ht({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)(lnn.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:d},children:(0,S.jsx)(Hi,{className:nt(`not-prose mb-4`,e),onOpenChange:e=>{u(e)},open:l,...s,children:o})})}),fnn=(e,t)=>e||t===0?(0,S.jsx)(Uce,{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`]}),pnn=(0,_.memo)(({className:e,children:t,...n})=>{let{isStreaming:r,isOpen:i,duration:a}=unn();return(0,S.jsx)(Ui,{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)($r,{className:`size-4`}),fnn(r,a),(0,S.jsx)(ei,{className:nt(`size-4 transition-transform`,i?`rotate-180`:`rotate-0`)})]})})}),mnn=(0,_.memo)(({className:e,children:t,...n})=>(0,S.jsx)(Wi,{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)(cnn,{...n,children:t})}));dnn.displayName=`Reasoning`,pnn.displayName=`ReasoningTrigger`,mnn.displayName=`ReasoningContent`,(0,_.createContext)(null);let hnn=(0,_.memo)(({className:e,...t})=>(0,S.jsx)(cnn,{className:nt(`size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,e),...t}),(e,t)=>e.children===t.children);hnn.displayName=`MessageResponse`;let gnn=(0,_.createContext)({code:``}),_nn={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 vnn(e,t,n=!1){let r=n?[_nn]:[];return await Promise.all([xXe(e,{lang:t,theme:`one-light`,transformers:r}),xXe(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)(()=>(vnn(e,t,n).then(([e,t])=>{d.current||=(s(e),u(t),!0)}),()=>{d.current=!1}),[e,t,n]),(0,S.jsx)(gnn.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-hidden 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-hidden 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})]})})})},ynn=({className:e,...t})=>(0,S.jsx)(Hi,{className:nt(`not-prose mb-4 w-full rounded-md border`,e),...t}),bnn=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)(si,{className:`size-4`}),"input-available":(0,S.jsx)(ci,{className:`size-4 animate-pulse`}),"approval-requested":(0,S.jsx)(ci,{className:`size-4 text-yellow-600`}),"approval-responded":(0,S.jsx)(ii,{className:`size-4 text-blue-600`}),"output-available":(0,S.jsx)(ii,{className:`size-4 text-green-600`}),"output-error":(0,S.jsx)(oi,{className:`size-4 text-red-600`}),"output-denied":(0,S.jsx)(oi,{className:`size-4 text-orange-600`})}[e],t[e]]})},xnn=({className:e,title:t,type:n,state:r,...i})=>(0,S.jsxs)(Ui,{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)(bi,{className:`size-4 text-muted-foreground`}),(0,S.jsx)(`span`,{className:`font-medium text-sm`,children:t??n.split(`-`).slice(1).join(`-`)}),bnn(r)]}),(0,S.jsx)(ei,{className:`size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]}),Snn=({className:e,...t})=>(0,S.jsx)(Wi,{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}),Cnn=({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`})})]}),wnn=({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 Tnn({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 Enn({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 Dnn({className:e,...t}){return(0,S.jsx)(`div`,{"data-slot":`card-content`,className:nt(`px-6`,e),...t})}let Onn=(0,_.createContext)(null),knn=({className:e,isStreaming:t=!1,children:n,...r})=>(0,S.jsx)(Onn.Provider,{value:{isStreaming:t},children:(0,S.jsx)(Hi,{asChild:!0,"data-slot":`plan`,...r,children:(0,S.jsx)(Tnn,{className:nt(`shadow-none`,e),children:n})})}),Ann=({className:e,...t})=>(0,S.jsx)(Enn,{className:nt(`flex items-start justify-between`,e),"data-slot":`plan-header`,...t}),jnn=e=>(0,S.jsx)(Wi,{asChild:!0,children:(0,S.jsx)(Dnn,{"data-slot":`plan-content`,...e})}),Mnn=({className:e,...t})=>(0,S.jsx)(Ui,{asChild:!0,children:(0,S.jsxs)(Oi,{className:nt(`size-8`,e),"data-slot":`plan-trigger`,size:`icon`,variant:`ghost`,...t,children:[(0,S.jsx)(ni,{className:`size-4`}),(0,S.jsx)(`span`,{className:`sr-only`,children:`Toggle plan`})]})});function Nnn(e){let t=e;return typeof t.type==`string`&&t.type.startsWith(`tool-`)&&`state`in t}function Pnn(e,t,n,r,i){if(e.type===`text`&&e.text)return(0,S.jsx)(hnn,{className:`whitespace-pre-wrap`,children:e.text},`${t}-${n}`);if(e.type===`reasoning`)return(0,S.jsxs)(dnn,{className:`w-full`,isStreaming:r,children:[(0,S.jsx)(pnn,{}),(0,S.jsx)(mnn,{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)(knn,{defaultOpen:!0,isStreaming:r,children:[(0,S.jsx)(Ann,{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)(Mnn,{className:`mb-2`})]})}),(0,S.jsx)(jnn,{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(Nnn(e)){let r=e.input,i=r.toolName,a=e.state,o=a===`output-available`||a===`output-error`;return(0,S.jsxs)(ynn,{defaultOpen:o,children:[(0,S.jsx)(xnn,{title:i.length>20?`${i.slice(0,20)}...`:i,type:i,state:a}),(0,S.jsxs)(Snn,{children:[e.input!==void 0&&(0,S.jsx)(Cnn,{input:r}),o&&(0,S.jsx)(wnn,{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 Fnn=({messages:e,status:t,selectedAgent:n})=>{let r=dd.find(e=>e.name===(n||fd))||dd[0];return(0,S.jsxs)(tle,{className:`w-full h-full`,children:[(0,S.jsxs)(nle,{className:`p-3 space-y-3`,children:[e.length===0?(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`})]})}):e.map(e=>(0,S.jsxs)(Ile,{className:`items-start`,from:e.role,children:[(0,S.jsx)(Lle,{children:e.parts.map((n,r)=>Pnn(n,e.id,r,t===`streaming`,e.metadata))}),e.role===`assistant`&&(0,S.jsx)(Rle,{name:r.name,src:r.meta?.icon??``})]},e.id)),t===`submitted`&&e.length===0&&(0,S.jsx)(Ble,{})]}),(0,S.jsx)(rle,{})]})};function Inn(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 Lnn({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 Rnn=`AI_SELECTED_AGENT`,znn=e=>{let[t,n]=(0,_.useState)(e);return(0,_.useEffect)(()=>{typeof window<`u`&&_d().then(e=>{if(e&&e!==fd)n(e);else{let e=localStorage.getItem(Rnn);e&&n(e)}})},[]),{agent:t,setAgent:e=>{n(e),!(typeof window>`u`)&&(e?.trim()?localStorage.setItem(Rnn,e):localStorage.removeItem(Rnn))}}},Bnn=({isActive:e,onToggleInspector:t,onSubmitAgent:n,onCancel:r,isAgentWorking:i,messages:a,status:o,inspectionCount:s=0,inspectionItems:l=[],onRemoveInspection:u=()=>{}})=>{let[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(`none`),[b,x]=(0,_.useState)(!1),[C,w]=(0,_.useState)(!1),[T,E]=(0,_.useState)(!0),{agent:D,setAgent:O}=znn(fd),[k,A]=(0,_.useState)(!1),j=dd.find(e=>e.name===D)||dd[0],{elementRef:M,isDragging:N,handleMouseDown:P}=Lnn(),[F,I]=(0,_.useState)(null),[L,R]=(0,_.useState)(``),ee=Inn(L,i,50),[te,z]=(0,_.useState)(``),B=(0,_.useRef)(``),ne=(0,_.useRef)(``);(0,_.useEffect)(()=>{let e=ee,t=B.current;if(e.length<t.length||!e.startsWith(t)){z(e),B.current=e;return}if(e.length>t.length){let n=e.slice(t.length).trim();n&&z(n),B.current=e}},[ee]);let re=(0,_.useRef)(null),ie=(0,_.useRef)(null),ae=(0,_.useRef)(null),oe=(0,_.useRef)(!1);(0,_.useEffect)(()=>{if(a.length===0){R(``),g(null),ae.current=null,oe.current=!1,z(``),B.current=``;return}let e=a[a.length-1];if(e.role!==`assistant`)return;let t=Kce(e),{displayText:n,toolCall:r}=Jce(e,t||ae.current);R(n||``),t&&(ae.current=t),r?(ie.current&&=(clearTimeout(ie.current),null),g(r),oe.current=!0):oe.current=!1},[a]),(0,_.useEffect)(()=>{te!==ne.current&&(oe.current||g(null),ne.current=te)},[te]),(0,_.useEffect)(()=>{d&&re.current&&re.current.focus()},[d]),(0,_.useEffect)(()=>{if(!i&&C){x(!1),w(!1),E(!1);let e=setTimeout(()=>{E(!0)},2e3);return()=>clearTimeout(e)}},[i,C]),(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;I({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;I({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 se=e=>{e.preventDefault(),p.trim()&&(ie.current&&=(clearTimeout(ie.current),null),g(null),R(``),ae.current=null,x(!0),w(!0),n(p,D),m(``),f(!0),y(`chat`))},ce=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),se(e)),e.key===`Escape`&&(f(!1),re.current?.blur())},le=o===`error`,ue=a.length>0,de=d&&!b,fe=(!d||b)&&(i||ue||F);return(0,S.jsxs)(`div`,{ref:M,className:nt(`fixed bottom-8 left-1/2 z-[999999]`,`transition-all duration-300 ease-[cubic-bezier(0.23,1,0.32,1)]`,d?`w-[450px]`:fe?`w-auto min-w-[200px] max-w-[450px]`:`w-[160px]`,N?`cursor-grabbing`:`cursor-grab`),onMouseDown:P,onMouseEnter:()=>{N||(i||C?(f(!0),y(`chat`)):T&&f(!0))},onMouseLeave:()=>{!p.trim()&&!C&&!N&&(f(!1),y(`none`)),E(!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`,d?`h-12 p-2 pl-4`:`h-9 px-2 py-1`,v===`none`?`bg-muted/90 rounded-full`:`bg-muted/95 rounded-b-lg rounded-t-none border-t-0`,le&&!d&&`bg-destructive/10 border-destructive/20`),children:[(0,S.jsxs)(`div`,{className:nt(`flex items-center transition-opacity duration-300 w-full relative`,de?`absolute left-3 opacity-0 pointer-events-none`:`relative opacity-100`),children:[!fe&&(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)(gi,{className:`w-3.5 h-3.5 text-foreground`})}),(0,S.jsx)(`span`,{className:`text-xs text-muted-foreground/70 ml-3`,children:`Hover to inspect`})]}),fe&&(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)(gi,{className:`w-3.5 h-3.5 animate-pulse text-foreground`})]}):F?F.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)(vi,{className:`w-3.5 h-3.5 animate-pulse text-blue-500`})]}):F.status===`completed`?(0,S.jsx)(ai,{className:`w-5 h-5 text-green-500`}):(0,S.jsx)(oi,{className:`w-5 h-5 text-red-500`}):le?(0,S.jsx)(oi,{className:`w-5 h-5 text-red-500`}):(0,S.jsx)(ai,{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:F&&F.status===`in-progress`&&F.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)(vi,{className:`w-4 h-4 flex-shrink-0`}),(0,S.jsxs)(`span`,{className:`truncate min-w-0`,children:[`Step `,F.currentStep.index,`/`,F.currentStep.total,`: `,F.currentStep.title]})]}):F?.message?(0,S.jsx)(`div`,{className:`text-sm font-medium leading-[1.4] text-foreground truncate min-w-0`,children:F.message}):h?(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-foreground min-w-0`,children:[(0,S.jsx)(vi,{className:`w-4 h-4 flex-shrink-0`}),(0,S.jsx)(`span`,{className:`truncate min-w-0`,children:h})]}):(0,S.jsx)(`div`,{className:`text-sm font-medium leading-[1.4] text-foreground truncate min-w-0`,children:i&&!te?(0,S.jsx)(Uce,{duration:2,spread:2,children:o===`submitted`&&j?.command===`npx`?`Starting ${j.name}... This may take a moment.`:`Thinking...`}):te||`Processing...`})})})]})]}),(0,S.jsxs)(`div`,{className:nt(`flex items-center w-full gap-3 transition-all duration-500 delay-75`,de?`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`,children:(0,S.jsx)(li,{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:()=>y(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`,v===`inspections`&&`bg-accent/50 text-foreground`),title:`View Inspections`,children:[(0,S.jsx)(ui,{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:se,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:()=>A(!k),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:dd.find(e=>e.name===D)?.meta?.icon,alt:D,className:`w-3.5 h-3.5`})}),k&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`div`,{className:`fixed inset-0 z-[999998]`,onClick:()=>A(!1)}),(0,S.jsx)(`div`,{className:`absolute bottom-full left-0 mb-2 w-48 bg-popover border border-border rounded-lg shadow-lg overflow-hidden z-[999999] animate-in fade-in zoom-in-95 duration-200`,children:dd.map(e=>(0,S.jsxs)(`button`,{onClick:()=>{O(e.name),A(!1)},className:nt(`w-full flex items-center gap-2 px-3 py-2 text-sm text-left hover:bg-accent transition-colors`,D===e.name&&`bg-accent/50 font-medium`),children:[e.meta?.icon&&(0,S.jsx)(`img`,{src:e.meta.icon,alt:``,className:`w-4 h-4`}),e.name]},e.name))})]})]}),(0,S.jsx)(`input`,{ref:re,type:`text`,value:p,onChange:e=>m(e.target.value),onKeyDown:ce,placeholder:`Ask ${D}...`,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||C)&&(0,S.jsx)(`button`,{type:`button`,onClick:()=>y(e=>e===`chat`?`none`:`chat`),className:nt(`flex items-center justify-center w-7 h-7 rounded-full transition-all flex-shrink-0`,v===`chat`?`bg-foreground text-background`:`bg-accent text-muted-foreground hover:bg-accent/80 hover:text-foreground`),title:v===`chat`?`Collapse`:`Expand messages`,children:(0,S.jsx)(ti,{className:nt(`w-3.5 h-3.5 transition-transform duration-300`,v===`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)(_i,{className:`w-3 h-3`})}):(0,S.jsx)(`button`,{type:`submit`,disabled:!p.trim(),className:nt(`flex items-center justify-center w-7 h-7 rounded-full transition-all flex-shrink-0`,p.trim()?`bg-foreground text-background scale-100`:`bg-accent text-muted-foreground/50 scale-90`),children:(0,S.jsx)(Qr,{className:`w-3.5 h-3.5`})})]})]})]}),v!==`none`&&(0,S.jsx)(`div`,{className:`absolute bottom-full left-0 right-0 pointer-events-auto max-w-[450px] 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:[v===`inspections`&&l.length>0&&(0,S.jsx)(`div`,{className:`border-b border-border`,children:(0,S.jsx)(ea,{items:l,onRemove:u})}),v===`chat`&&(0,S.jsx)(`div`,{className:`h-[500px]`,children:(0,S.jsx)(Fnn,{messages:a,status:o,selectedAgent:D})})]})})]})};var Vnn=`vercel.ai.error`,Hnn=Symbol.for(Vnn),Unn,Wnn=class e extends Error{constructor({name:e,message:t,cause:n}){super(t),this[Unn]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,Vnn)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}};Unn=Hnn;var W7=Wnn;function Gnn(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}var Knn=`AI_InvalidArgumentError`,qnn=`vercel.ai.error.${Knn}`,Jnn=Symbol.for(qnn),Ynn,Xnn=class extends W7{constructor({message:e,cause:t,argument:n}){super({name:Knn,message:e,cause:t}),this[Ynn]=!0,this.argument=n}static isInstance(e){return W7.hasMarker(e,qnn)}};Ynn=Jnn;var Znn=`AI_JSONParseError`,Qnn=`vercel.ai.error.${Znn}`,$nn=Symbol.for(Qnn),ern,trn=class extends W7{constructor({text:e,cause:t}){super({name:Znn,message:`JSON parsing failed: Text: ${e}.
6940
6936
  Error message: ${Gnn(t)}`,cause:t}),this[ern]=!0,this.text=e}static isInstance(e){return W7.hasMarker(e,Qnn)}};ern=$nn;var nrn=`AI_TypeValidationError`,rrn=`vercel.ai.error.${nrn}`,irn=Symbol.for(rrn),arn,orn=class e extends W7{constructor({value:e,cause:t}){super({name:nrn,message:`Type validation failed: Value: ${JSON.stringify(e)}.
6941
6937
  Error message: ${Gnn(t)}`,cause:t}),this[arn]=!0,this.value=e}static isInstance(e){return W7.hasMarker(e,rrn)}static wrap({value:t,cause:n}){return e.isInstance(n)&&n.value===t?n:new e({value:t,cause:n})}};arn=irn;var G7=orn,srn=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=Cl({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 crn={};function J7(e){return e&&Object.assign(crn,e),crn}function lrn(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 urn(e,t){return typeof t==`bigint`?t.toString():t}function drn(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function frn(e){return e==null}function prn(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function mrn(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 hrn=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function Q7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let grn=drn(()=>{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 _rn=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 vrn(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}let yrn={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function brn(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 xrn(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 Srn(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 Crn(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 wrn(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 Trn(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 Ern(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 Drn=(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,urn,2)},enumerable:!0}),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},Orn=K7(`$ZodError`,Drn),krn=K7(`$ZodError`,Drn,{Parent:Error});function Arn(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 jrn(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 Mrn=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 hrn(t,i?.callee),t}return o.value},Nrn=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 hrn(t,i?.callee),t}return o.value},Prn=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??Orn)(a.issues.map(e=>o9(e,i,J7())))}:{success:!0,data:a.value}},Frn=Prn(krn),Irn=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}},Lrn=Irn(krn),Rrn=/^[cC][^\s-]{8,}$/,zrn=/^[0-9a-z]+$/,Brn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Vrn=/^[0-9a-vA-V]{20}$/,Hrn=/^[A-Za-z0-9]{27}$/,Urn=/^[a-zA-Z0-9_-]{21}$/,Wrn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Grn=/^([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})$/,Krn=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)$/,qrn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Jrn(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}let Yrn=/^(?:(?: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])$/,Xrn=/^(([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})$/,Zrn=/^((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])$/,Qrn=/^(([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])$/,$rn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ein=/^[A-Za-z0-9_-]*$/,tin=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,nin=/^\+(?:[0-9]){6,14}[0-9]$/,rin=`(?:(?:\\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])))`,iin=RegExp(`^${rin}$`);function ain(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 oin(e){return RegExp(`^${ain(e)}$`)}function sin(e){let t=ain({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${rin}T(?:${r})$`)}let cin=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},lin=/^\d+$/,uin=/^-?\d+(?:\.\d+)?/i,din=/true|false/i,fin=/null/i,pin=/^[^A-Z]*$/,min=/^[^a-z]*$/,c9=K7(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),hin={number:`number`,bigint:`bigint`,object:`date`},gin=K7(`$ZodCheckLessThan`,(e,t)=>{c9.init(e,t);let n=hin[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})}}),_in=K7(`$ZodCheckGreaterThan`,(e,t)=>{c9.init(e,t);let n=hin[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})}}),vin=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):mrn(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})}}),yin=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]=yrn[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=lin)}),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})}}),bin=K7(`$ZodCheckMaxLength`,(e,t)=>{var n;c9.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!frn(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=Ern(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xin=K7(`$ZodCheckMinLength`,(e,t)=>{var n;c9.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!frn(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=Ern(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Sin=K7(`$ZodCheckLengthEquals`,(e,t)=>{var n;c9.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!frn(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=Ern(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=()=>{})}),Cin=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})}}),win=K7(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=pin,l9.init(e,t)}),Tin=K7(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=min,l9.init(e,t)}),Ein=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})}}),Din=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})}}),Oin=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})}}),kin=K7(`$ZodCheckOverwrite`,(e,t)=>{c9.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Ain=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(`
6942
6938
  `).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/cli.cjs ADDED
@@ -0,0 +1,180 @@
1
+ #!/usr/bin/env node
2
+ const require_chunk = require('./chunk.cjs');
3
+ const require_config_updater = require('./config-updater.cjs');
4
+ let node_http = require("node:http");
5
+ node_http = require_chunk.__toESM(node_http);
6
+
7
+ //#region src/utils/standalone-server.ts
8
+ var StandaloneServer = class {
9
+ server;
10
+ middlewares = [];
11
+ port = 0;
12
+ host = "localhost";
13
+ stack = [];
14
+ constructor() {
15
+ this.server = node_http.default.createServer(async (req, res) => {
16
+ let index = 0;
17
+ const next = async () => {
18
+ if (index >= this.middlewares.length) {
19
+ if (!res.writableEnded) {
20
+ res.statusCode = 404;
21
+ res.end("Not Found");
22
+ }
23
+ return;
24
+ }
25
+ const layer = this.middlewares[index++];
26
+ if ((req.url || "/").startsWith(layer.route)) try {
27
+ const originalUrl = req.url;
28
+ if (layer.route !== "/" && req.url) {}
29
+ await layer.handle(req, res, next);
30
+ if (layer.route !== "/") req.url = originalUrl;
31
+ } catch (error) {
32
+ console.error("Middleware error:", error);
33
+ if (!res.writableEnded) {
34
+ res.statusCode = 500;
35
+ res.end("Internal Server Error");
36
+ }
37
+ }
38
+ else next();
39
+ };
40
+ await next();
41
+ });
42
+ }
43
+ use(routeOrHandle, handle) {
44
+ let route = "/";
45
+ let handler;
46
+ if (typeof routeOrHandle === "string") {
47
+ route = routeOrHandle;
48
+ if (!handle) throw new Error("Handler is required when route is provided");
49
+ handler = handle;
50
+ } else handler = routeOrHandle;
51
+ this.middlewares.push({
52
+ route,
53
+ handle: handler
54
+ });
55
+ return this;
56
+ }
57
+ listen(...args) {
58
+ return this.server.listen(...args);
59
+ }
60
+ async start(options = {}) {
61
+ const startPort = options.port || 8888;
62
+ this.host = options.host || "localhost";
63
+ for (let port = startPort; port < startPort + 100; port++) try {
64
+ await new Promise((resolve, reject) => {
65
+ this.server.listen(port, this.host, () => {
66
+ this.port = port;
67
+ resolve();
68
+ });
69
+ this.server.on("error", (err) => {
70
+ if (err.code === "EADDRINUSE") {
71
+ this.server.close();
72
+ reject(err);
73
+ } else reject(err);
74
+ });
75
+ });
76
+ return {
77
+ host: this.host,
78
+ port: this.port
79
+ };
80
+ } catch (error) {
81
+ if (error.code !== "EADDRINUSE") throw error;
82
+ }
83
+ throw new Error(`Could not find a free port starting from ${startPort}`);
84
+ }
85
+ close() {
86
+ this.server.close();
87
+ }
88
+ };
89
+ let globalServer = null;
90
+ async function startStandaloneServer(options = {}) {
91
+ if (globalServer) return {
92
+ server: globalServer,
93
+ host: globalServer.host,
94
+ port: globalServer.port
95
+ };
96
+ globalServer = new StandaloneServer();
97
+ const { host, port } = await globalServer.start(options);
98
+ return {
99
+ server: globalServer,
100
+ host,
101
+ port
102
+ };
103
+ }
104
+
105
+ //#endregion
106
+ //#region src/cli.ts
107
+ /**
108
+ * Standalone dev-inspector server for Turbopack/other non-webpack builds
109
+ *
110
+ * Usage:
111
+ * npx dev-inspector-server
112
+ * npx dev-inspector-server --port 8888 --host localhost
113
+ */
114
+ async function main() {
115
+ const args = process.argv.slice(2);
116
+ let port = 8888;
117
+ let host = "localhost";
118
+ for (let i = 0; i < args.length; i++) if (args[i] === "--port" && args[i + 1]) {
119
+ port = parseInt(args[i + 1], 10);
120
+ i++;
121
+ } else if (args[i] === "--host" && args[i + 1]) {
122
+ host = args[i + 1];
123
+ i++;
124
+ } else if (args[i] === "--help" || args[i] === "-h") {
125
+ console.log(`
126
+ dev-inspector-server - Standalone MCP server for dev-inspector
127
+
128
+ Usage:
129
+ npx dev-inspector-server [options]
130
+
131
+ Options:
132
+ --port <number> Port to run the server on (default: 8888)
133
+ --host <string> Host to bind to (default: localhost)
134
+ --help, -h Show this help message
135
+
136
+ Example:
137
+ npx dev-inspector-server --port 3001
138
+ `);
139
+ process.exit(0);
140
+ }
141
+ try {
142
+ const { server, host: actualHost, port: actualPort } = await startStandaloneServer({
143
+ port,
144
+ host
145
+ });
146
+ const serverContext = {
147
+ host: actualHost,
148
+ port: actualPort
149
+ };
150
+ const baseUrl = `http://${actualHost === "0.0.0.0" ? "localhost" : actualHost}:${actualPort}/__mcp__/sse`;
151
+ console.log(`
152
+ ╔══════════════════════════════════════════════════════════╗
153
+ ║ 🔍 Dev Inspector MCP Server ║
154
+ ╠══════════════════════════════════════════════════════════╣
155
+ ║ ║
156
+ ║ MCP Endpoint: ${baseUrl.padEnd(40)}║
157
+ ║ ║
158
+ ║ Use this in your editor's MCP config or with ║
159
+ ║ the DevInspector React component. ║
160
+ ║ ║
161
+ ╚══════════════════════════════════════════════════════════╝
162
+ `);
163
+ require_config_updater.setupMcpMiddleware(server, serverContext);
164
+ require_config_updater.setupAcpMiddleware(server, serverContext, {});
165
+ require_config_updater.setupInspectorMiddleware(server, {});
166
+ await require_config_updater.updateMcpConfigs(process.cwd(), baseUrl, {});
167
+ process.on("SIGINT", () => {
168
+ console.log("\n👋 Shutting down dev-inspector server...");
169
+ process.exit(0);
170
+ });
171
+ } catch (error) {
172
+ console.error("Failed to start dev-inspector server:", error);
173
+ process.exit(1);
174
+ }
175
+ }
176
+ main();
177
+
178
+ //#endregion
179
+ exports.StandaloneServer = StandaloneServer;
180
+ exports.startStandaloneServer = startStandaloneServer;
package/dist/cli.d.cts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/cli.js ADDED
@@ -0,0 +1,177 @@
1
+ #!/usr/bin/env node
2
+ import { i as setupMcpMiddleware, n as setupAcpMiddleware, r as setupInspectorMiddleware, t as updateMcpConfigs } from "./config-updater.js";
3
+ import http from "node:http";
4
+
5
+ //#region src/utils/standalone-server.ts
6
+ var StandaloneServer = class {
7
+ server;
8
+ middlewares = [];
9
+ port = 0;
10
+ host = "localhost";
11
+ stack = [];
12
+ constructor() {
13
+ this.server = http.createServer(async (req, res) => {
14
+ let index = 0;
15
+ const next = async () => {
16
+ if (index >= this.middlewares.length) {
17
+ if (!res.writableEnded) {
18
+ res.statusCode = 404;
19
+ res.end("Not Found");
20
+ }
21
+ return;
22
+ }
23
+ const layer = this.middlewares[index++];
24
+ if ((req.url || "/").startsWith(layer.route)) try {
25
+ const originalUrl = req.url;
26
+ if (layer.route !== "/" && req.url) {}
27
+ await layer.handle(req, res, next);
28
+ if (layer.route !== "/") req.url = originalUrl;
29
+ } catch (error) {
30
+ console.error("Middleware error:", error);
31
+ if (!res.writableEnded) {
32
+ res.statusCode = 500;
33
+ res.end("Internal Server Error");
34
+ }
35
+ }
36
+ else next();
37
+ };
38
+ await next();
39
+ });
40
+ }
41
+ use(routeOrHandle, handle) {
42
+ let route = "/";
43
+ let handler;
44
+ if (typeof routeOrHandle === "string") {
45
+ route = routeOrHandle;
46
+ if (!handle) throw new Error("Handler is required when route is provided");
47
+ handler = handle;
48
+ } else handler = routeOrHandle;
49
+ this.middlewares.push({
50
+ route,
51
+ handle: handler
52
+ });
53
+ return this;
54
+ }
55
+ listen(...args) {
56
+ return this.server.listen(...args);
57
+ }
58
+ async start(options = {}) {
59
+ const startPort = options.port || 8888;
60
+ this.host = options.host || "localhost";
61
+ for (let port = startPort; port < startPort + 100; port++) try {
62
+ await new Promise((resolve, reject) => {
63
+ this.server.listen(port, this.host, () => {
64
+ this.port = port;
65
+ resolve();
66
+ });
67
+ this.server.on("error", (err) => {
68
+ if (err.code === "EADDRINUSE") {
69
+ this.server.close();
70
+ reject(err);
71
+ } else reject(err);
72
+ });
73
+ });
74
+ return {
75
+ host: this.host,
76
+ port: this.port
77
+ };
78
+ } catch (error) {
79
+ if (error.code !== "EADDRINUSE") throw error;
80
+ }
81
+ throw new Error(`Could not find a free port starting from ${startPort}`);
82
+ }
83
+ close() {
84
+ this.server.close();
85
+ }
86
+ };
87
+ let globalServer = null;
88
+ async function startStandaloneServer(options = {}) {
89
+ if (globalServer) return {
90
+ server: globalServer,
91
+ host: globalServer.host,
92
+ port: globalServer.port
93
+ };
94
+ globalServer = new StandaloneServer();
95
+ const { host, port } = await globalServer.start(options);
96
+ return {
97
+ server: globalServer,
98
+ host,
99
+ port
100
+ };
101
+ }
102
+
103
+ //#endregion
104
+ //#region src/cli.ts
105
+ /**
106
+ * Standalone dev-inspector server for Turbopack/other non-webpack builds
107
+ *
108
+ * Usage:
109
+ * npx dev-inspector-server
110
+ * npx dev-inspector-server --port 8888 --host localhost
111
+ */
112
+ async function main() {
113
+ const args = process.argv.slice(2);
114
+ let port = 8888;
115
+ let host = "localhost";
116
+ for (let i = 0; i < args.length; i++) if (args[i] === "--port" && args[i + 1]) {
117
+ port = parseInt(args[i + 1], 10);
118
+ i++;
119
+ } else if (args[i] === "--host" && args[i + 1]) {
120
+ host = args[i + 1];
121
+ i++;
122
+ } else if (args[i] === "--help" || args[i] === "-h") {
123
+ console.log(`
124
+ dev-inspector-server - Standalone MCP server for dev-inspector
125
+
126
+ Usage:
127
+ npx dev-inspector-server [options]
128
+
129
+ Options:
130
+ --port <number> Port to run the server on (default: 8888)
131
+ --host <string> Host to bind to (default: localhost)
132
+ --help, -h Show this help message
133
+
134
+ Example:
135
+ npx dev-inspector-server --port 3001
136
+ `);
137
+ process.exit(0);
138
+ }
139
+ try {
140
+ const { server, host: actualHost, port: actualPort } = await startStandaloneServer({
141
+ port,
142
+ host
143
+ });
144
+ const serverContext = {
145
+ host: actualHost,
146
+ port: actualPort
147
+ };
148
+ const baseUrl = `http://${actualHost === "0.0.0.0" ? "localhost" : actualHost}:${actualPort}/__mcp__/sse`;
149
+ console.log(`
150
+ ╔══════════════════════════════════════════════════════════╗
151
+ ║ 🔍 Dev Inspector MCP Server ║
152
+ ╠══════════════════════════════════════════════════════════╣
153
+ ║ ║
154
+ ║ MCP Endpoint: ${baseUrl.padEnd(40)}║
155
+ ║ ║
156
+ ║ Use this in your editor's MCP config or with ║
157
+ ║ the DevInspector React component. ║
158
+ ║ ║
159
+ ╚══════════════════════════════════════════════════════════╝
160
+ `);
161
+ setupMcpMiddleware(server, serverContext);
162
+ setupAcpMiddleware(server, serverContext, {});
163
+ setupInspectorMiddleware(server, {});
164
+ await updateMcpConfigs(process.cwd(), baseUrl, {});
165
+ process.on("SIGINT", () => {
166
+ console.log("\n👋 Shutting down dev-inspector server...");
167
+ process.exit(0);
168
+ });
169
+ } catch (error) {
170
+ console.error("Failed to start dev-inspector server:", error);
171
+ process.exit(1);
172
+ }
173
+ }
174
+ main();
175
+
176
+ //#endregion
177
+ export { startStandaloneServer as n, StandaloneServer as t };