@mcpc-tech/unplugin-dev-inspector-mcp 0.0.18 → 0.0.19
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 +4 -4
- package/client/dist/inspector.iife.js +1 -1
- package/dist/index.cjs +87 -1
- package/dist/index.js +85 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ tags:
|
|
|
18
18
|
[](https://www.npmjs.com/package/@mcpc-tech/unplugin-dev-inspector-mcp)
|
|
19
19
|
[](https://www.npmjs.com/package/@mcpc-tech/unplugin-dev-inspector-mcp)
|
|
20
20
|
|
|
21
|
-
**AI-powered visual debugging for React &
|
|
21
|
+
**AI-powered visual debugging for React, Vue, Svelte, Preact & Next.js via MCP and ACP.**
|
|
22
22
|
|
|
23
23
|
DevInspector connects your web app directly to your AI agent. Click any element to instantly send its source code, style, and network context to the AI for analysis and fixing.
|
|
24
24
|
|
|
@@ -93,7 +93,7 @@ Add DevInspector to your project:
|
|
|
93
93
|
```diff
|
|
94
94
|
// vite.config.ts
|
|
95
95
|
+import DevInspector from '@mcpc-tech/unplugin-dev-inspector-mcp';
|
|
96
|
-
import react from '@vitejs/plugin-react'; // or vue()
|
|
96
|
+
import react from '@vitejs/plugin-react'; // or vue(), svelte(), preact()
|
|
97
97
|
|
|
98
98
|
export default {
|
|
99
99
|
plugins: [
|
|
@@ -102,12 +102,12 @@ Add DevInspector to your project:
|
|
|
102
102
|
showInspectorBar: true, // Default: true. Set to false to hide the UI.
|
|
103
103
|
+ autoOpenBrowser: false, // Default: false. Automatically open browser when server starts.
|
|
104
104
|
}),
|
|
105
|
-
react(), // or vue()
|
|
105
|
+
react(), // or vue(), svelte(), preact()
|
|
106
106
|
],
|
|
107
107
|
};
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
> ⚠️ **Plugin order matters:** Place `DevInspector.vite()` **before** `react()`, `vue()`, or `preact()`. Otherwise source locations may show `unknown:0:0`.
|
|
110
|
+
> ⚠️ **Plugin order matters:** Place `DevInspector.vite()` **before** `react()`, `vue()`, `svelte()`, or `preact()`. Otherwise source locations may show `unknown:0:0`.
|
|
111
111
|
|
|
112
112
|
#### For Non-HTML Projects (Miniapps, Library Bundles)
|
|
113
113
|
|
|
@@ -6932,7 +6932,7 @@ ${e.themeCSS}`),e.fontFamily!==void 0&&(n+=`
|
|
|
6932
6932
|
`)||(e.endsWith("```\n")||e.endsWith("```"))&&t%2==0)return e;let r=e.match(Ntn);if(r&&!n){let t=r[2];if(!t||z7.test(t))return e;if(Ytn(e)%2==1)return`${e}\``}return e},Ztn=e=>{let t=e.match(Ptn);if(t){let n=t[2];if(!n||z7.test(n))return e;if((e.match(/~~/g)||[]).length%2==1)return`${e}~~`}return e},Qtn=e=>{if((e.match(/\$\$/g)||[]).length%2==0)return e;let t=e.indexOf(`$$`);return t!==-1&&e.indexOf(`
|
|
6933
6933
|
`,t)!==-1&&!e.endsWith(`
|
|
6934
6934
|
`)?`${e}
|
|
6935
|
-
$$`:`${e}$$`},$tn=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},enn=e=>{if(V7(e)||ztn.test(e))return e;let t=e.match(Atn);if(t){let n=t[2];if(!n||z7.test(n))return e;if($tn(e)%2==1)return`${e}***`}return e},tnn=e=>{if(!e||typeof e!=`string`)return e;let t=e,n=Btn(t);return n.endsWith(`](streamdown:incomplete-link)`)?n:(t=n,t=enn(t),t=Vtn(t),t=Htn(t),t=Wtn(t),t=qtn(t),t=Xtn(t),t=Ztn(t),t=Qtn(t),t)},nnn={harden:[fhe,{allowedImagePrefixes:[`*`],allowedLinkPrefixes:[`*`],defaultOrigin:void 0,allowDataImages:!0}],raw:XSe,katex:[Ay,{errorColor:`var(--color-muted-foreground)`}]},rnn={gfm:[hEe,{}],math:[DEe,{singleDollarTextMath:!1}],cjkFriendly:[kCe,{}],cjkFriendlyGfmStrikethrough:[jCe,{}]},inn=(0,_.createContext)([`github-light`,`github-dark`]),ann=(0,_.createContext)(void 0),onn=(0,_.createContext)(!0),H7=(0,_.createContext)({isAnimating:!1}),snn=(0,_.memo)(({content:e,shouldParseIncompleteMarkdown:t,...n})=>{let r=(0,_.useMemo)(()=>typeof e==`string`&&t?tnn(e.trim()):e,[e,t]);return(0,S.jsx)(she,{...n,children:r})},(e,t)=>e.content===t.content);snn.displayName=`Block`;var cnn=[`github-light`,`github-dark`],lnn=(0,_.memo)(({children:e,parseIncompleteMarkdown:t=!0,components:n,rehypePlugins:r=Object.values(nnn),remarkPlugins:i=Object.values(rnn),className:a,shikiTheme:o=cnn,mermaidConfig:s,controls:l=!0,isAnimating:u=!1,urlTransform:d=e=>e,BlockComponent:f=snn,parseMarkdownIntoBlocksFn:m=Etn,...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]===Ay:e===Ay)&&Promise.resolve().then(()=>p(xen(),1))},[r]);let y=(0,_.useMemo)(()=>({isAnimating:u}),[u]);return(0,S.jsx)(inn.Provider,{value:o,children:(0,S.jsx)(ann.Provider,{value:s,children:(0,S.jsx)(onn.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:{...xtn,...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);lnn.displayName=`Streamdown`;let unn=(0,_.createContext)(null),dnn=()=>{let e=(0,_.useContext)(unn);if(!e)throw Error(`Reasoning components must be used within Reasoning`);return e},fnn=(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)(unn.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:d},children:(0,S.jsx)(Ui,{className:nt(`not-prose mb-4`,e),onOpenChange:e=>{u(e)},open:l,...s,children:o})})}),pnn=(e,t)=>e||t===0?(0,S.jsx)(Bce,{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`]}),mnn=(0,_.memo)(({className:e,children:t,...n})=>{let{isStreaming:r,isOpen:i,duration:a}=dnn();return(0,S.jsx)(Wi,{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`}),pnn(r,a),(0,S.jsx)(ei,{className:nt(`size-4 transition-transform`,i?`rotate-180`:`rotate-0`)})]})})}),hnn=(0,_.memo)(({className:e,children:t,...n})=>(0,S.jsx)(Gi,{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)(lnn,{...n,children:t})}));fnn.displayName=`Reasoning`,mnn.displayName=`ReasoningTrigger`,hnn.displayName=`ReasoningContent`,(0,_.createContext)(null);let gnn=(0,_.memo)(({className:e,...t})=>(0,S.jsx)(lnn,{className:nt(`size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,e),...t}),(e,t)=>e.children===t.children);gnn.displayName=`MessageResponse`;let _nn=(0,_.createContext)({code:``}),vnn={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 ynn(e,t,n=!1){let r=n?[vnn]:[];return await Promise.all([hXe(e,{lang:t,theme:`one-light`,transformers:r}),hXe(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)(()=>(ynn(e,t,n).then(([e,t])=>{d.current||=(s(e),u(t),!0)}),()=>{d.current=!1}),[e,t,n]),(0,S.jsx)(_nn.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})]})})})},bnn=({className:e,...t})=>(0,S.jsx)(Ui,{className:nt(`not-prose mb-4 w-full rounded-md border`,e),...t}),xnn=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]]})},Snn=({className:e,title:t,type:n,state:r,...i})=>(0,S.jsxs)(Wi,{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(`-`)}),xnn(r)]}),(0,S.jsx)(ei,{className:`size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]}),Cnn=({className:e,...t})=>(0,S.jsx)(Gi,{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}),wnn=({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`})})]}),Tnn=({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 Enn({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 Dnn({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 Onn({className:e,...t}){return(0,S.jsx)(`div`,{"data-slot":`card-content`,className:nt(`px-6`,e),...t})}let knn=(0,_.createContext)(null),Ann=({className:e,isStreaming:t=!1,children:n,...r})=>(0,S.jsx)(knn.Provider,{value:{isStreaming:t},children:(0,S.jsx)(Ui,{asChild:!0,"data-slot":`plan`,...r,children:(0,S.jsx)(Enn,{className:nt(`shadow-none`,e),children:n})})}),jnn=({className:e,...t})=>(0,S.jsx)(Dnn,{className:nt(`flex items-start justify-between`,e),"data-slot":`plan-header`,...t}),Mnn=e=>(0,S.jsx)(Gi,{asChild:!0,children:(0,S.jsx)(Onn,{"data-slot":`plan-content`,...e})}),Nnn=({className:e,...t})=>(0,S.jsx)(Wi,{asChild:!0,children:(0,S.jsxs)(ki,{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 Pnn(e){let t=e;return typeof t.type==`string`&&t.type.startsWith(`tool-`)&&`state`in t}function Fnn(e,t,n,r,i){if(e.type===`text`&&e.text)return(0,S.jsx)(gnn,{className:`whitespace-pre-wrap`,children:e.text},`${t}-${n}`);if(e.type===`reasoning`)return(0,S.jsxs)(fnn,{className:`w-full`,isStreaming:r,children:[(0,S.jsx)(mnn,{}),(0,S.jsx)(hnn,{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)(Ann,{defaultOpen:!0,isStreaming:r,children:[(0,S.jsx)(jnn,{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)(Nnn,{className:`mb-2`})]})}),(0,S.jsx)(Mnn,{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(Pnn(e)){let r=e.input,i=r.toolName,a=e.state,o=a===`output-available`||a===`output-error`;return(0,S.jsxs)(bnn,{defaultOpen:o,children:[(0,S.jsx)(Snn,{title:i.length>20?`${i.slice(0,20)}...`:i,type:i,state:a}),(0,S.jsxs)(Cnn,{children:[e.input!==void 0&&(0,S.jsx)(wnn,{input:r}),o&&(0,S.jsx)(Tnn,{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 Inn=({messages:e,status:t,selectedAgent:n})=>{let r=nd.find(e=>e.name===(n||rd))||nd[0],i=t===`submitted`||t===`streaming`,a=e[e.length-1],o=i&&(!a||a.role===`user`);return(0,S.jsxs)(tle,{className:`w-full h-full`,children:[(0,S.jsx)(nle,{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)(Rle,{className:`items-start`,from:e.role,children:[(0,S.jsx)(zle,{children:e.parts.map((n,r)=>Fnn(n,e.id,r,t===`streaming`,e.metadata))}),e.role===`assistant`&&(0,S.jsx)(Ble,{name:r.name,src:r.meta?.icon??``})]},e.id)),o&&(0,S.jsxs)(Rle,{className:`items-start`,from:`assistant`,children:[(0,S.jsx)(zle,{children:(0,S.jsx)(Hle,{size:16})}),(0,S.jsx)(Ble,{name:r.name,src:r.meta?.icon??``})]})]})}),(0,S.jsx)(rle,{})]})};function Lnn(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 Rnn({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 znn=`AI_SELECTED_AGENT`,Bnn=e=>{let[t,n]=(0,_.useState)(e);return(0,_.useEffect)(()=>{typeof window<`u`&&cd().then(e=>{if(e&&e!==rd)n(e);else{let e=localStorage.getItem(znn);e&&n(e)}})},[]),{agent:t,setAgent:e=>{n(e),!(typeof window>`u`)&&(e?.trim()?localStorage.setItem(znn,e):localStorage.removeItem(znn))}}},Vnn=({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}=Bnn(rd),[k,A]=(0,_.useState)(!1),j=nd.find(e=>e.name===D)||nd[0],{elementRef:M,isDragging:N,handleMouseDown:P}=Rnn(),[F,I]=(0,_.useState)(null),[L,R]=(0,_.useState)(``),ee=Lnn(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=Uce(e),{displayText:n,toolCall:r}=Gce(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(``),z(``),I(null),ae.current=null,B.current=``,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)(Bce,{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:nd.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:nd.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)(ta,{items:l,onRemove:u})}),v===`chat`&&(0,S.jsx)(`div`,{className:`h-[500px]`,children:(0,S.jsx)(Inn,{messages:a,status:o,selectedAgent:D})})]})})]})};var Hnn=`vercel.ai.error`,Unn=Symbol.for(Hnn),Wnn,Gnn=class e extends Error{constructor({name:e,message:t,cause:n}){super(t),this[Wnn]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,Hnn)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}};Wnn=Unn;var W7=Gnn;function Knn(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}var qnn=`AI_InvalidArgumentError`,Jnn=`vercel.ai.error.${qnn}`,Ynn=Symbol.for(Jnn),Xnn,Znn=class extends W7{constructor({message:e,cause:t,argument:n}){super({name:qnn,message:e,cause:t}),this[Xnn]=!0,this.argument=n}static isInstance(e){return W7.hasMarker(e,Jnn)}};Xnn=Ynn;var Qnn=`AI_JSONParseError`,$nn=`vercel.ai.error.${Qnn}`,ern=Symbol.for($nn),trn,nrn=class extends W7{constructor({text:e,cause:t}){super({name:Qnn,message:`JSON parsing failed: Text: ${e}.
|
|
6935
|
+
$$`:`${e}$$`},$tn=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},enn=e=>{if(V7(e)||ztn.test(e))return e;let t=e.match(Atn);if(t){let n=t[2];if(!n||z7.test(n))return e;if($tn(e)%2==1)return`${e}***`}return e},tnn=e=>{if(!e||typeof e!=`string`)return e;let t=e,n=Btn(t);return n.endsWith(`](streamdown:incomplete-link)`)?n:(t=n,t=enn(t),t=Vtn(t),t=Htn(t),t=Wtn(t),t=qtn(t),t=Xtn(t),t=Ztn(t),t=Qtn(t),t)},nnn={harden:[fhe,{allowedImagePrefixes:[`*`],allowedLinkPrefixes:[`*`],defaultOrigin:void 0,allowDataImages:!0}],raw:XSe,katex:[Ay,{errorColor:`var(--color-muted-foreground)`}]},rnn={gfm:[hEe,{}],math:[DEe,{singleDollarTextMath:!1}],cjkFriendly:[kCe,{}],cjkFriendlyGfmStrikethrough:[jCe,{}]},inn=(0,_.createContext)([`github-light`,`github-dark`]),ann=(0,_.createContext)(void 0),onn=(0,_.createContext)(!0),H7=(0,_.createContext)({isAnimating:!1}),snn=(0,_.memo)(({content:e,shouldParseIncompleteMarkdown:t,...n})=>{let r=(0,_.useMemo)(()=>typeof e==`string`&&t?tnn(e.trim()):e,[e,t]);return(0,S.jsx)(she,{...n,children:r})},(e,t)=>e.content===t.content);snn.displayName=`Block`;var cnn=[`github-light`,`github-dark`],lnn=(0,_.memo)(({children:e,parseIncompleteMarkdown:t=!0,components:n,rehypePlugins:r=Object.values(nnn),remarkPlugins:i=Object.values(rnn),className:a,shikiTheme:o=cnn,mermaidConfig:s,controls:l=!0,isAnimating:u=!1,urlTransform:d=e=>e,BlockComponent:f=snn,parseMarkdownIntoBlocksFn:m=Etn,...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]===Ay:e===Ay)&&Promise.resolve().then(()=>p(xen(),1))},[r]);let y=(0,_.useMemo)(()=>({isAnimating:u}),[u]);return(0,S.jsx)(inn.Provider,{value:o,children:(0,S.jsx)(ann.Provider,{value:s,children:(0,S.jsx)(onn.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:{...xtn,...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);lnn.displayName=`Streamdown`;let unn=(0,_.createContext)(null),dnn=()=>{let e=(0,_.useContext)(unn);if(!e)throw Error(`Reasoning components must be used within Reasoning`);return e},fnn=(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)(unn.Provider,{value:{isStreaming:t,isOpen:l,setIsOpen:u,duration:d},children:(0,S.jsx)(Ui,{className:nt(`not-prose mb-4`,e),onOpenChange:e=>{u(e)},open:l,...s,children:o})})}),pnn=(e,t)=>e||t===0?(0,S.jsx)(Bce,{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`]}),mnn=(0,_.memo)(({className:e,children:t,...n})=>{let{isStreaming:r,isOpen:i,duration:a}=dnn();return(0,S.jsx)(Wi,{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`}),pnn(r,a),(0,S.jsx)(ei,{className:nt(`size-4 transition-transform`,i?`rotate-180`:`rotate-0`)})]})})}),hnn=(0,_.memo)(({className:e,children:t,...n})=>(0,S.jsx)(Gi,{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)(lnn,{...n,children:t})}));fnn.displayName=`Reasoning`,mnn.displayName=`ReasoningTrigger`,hnn.displayName=`ReasoningContent`,(0,_.createContext)(null);let gnn=(0,_.memo)(({className:e,...t})=>(0,S.jsx)(lnn,{className:nt(`size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0`,e),...t}),(e,t)=>e.children===t.children);gnn.displayName=`MessageResponse`;let _nn=(0,_.createContext)({code:``}),vnn={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 ynn(e,t,n=!1){let r=n?[vnn]:[];return await Promise.all([hXe(e,{lang:t,theme:`one-light`,transformers:r}),hXe(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)(()=>(ynn(e,t,n).then(([e,t])=>{d.current||=(s(e),u(t),!0)}),()=>{d.current=!1}),[e,t,n]),(0,S.jsx)(_nn.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})]})})})},bnn=({className:e,...t})=>(0,S.jsx)(Ui,{className:nt(`not-prose mb-4 w-full rounded-md border`,e),...t}),xnn=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]]})},Snn=({className:e,title:t,type:n,state:r,...i})=>(0,S.jsxs)(Wi,{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(`-`)}),xnn(r)]}),(0,S.jsx)(ei,{className:`size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180`})]}),Cnn=({className:e,...t})=>(0,S.jsx)(Gi,{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}),wnn=({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`})})]}),Tnn=({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 Enn({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 Dnn({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 Onn({className:e,...t}){return(0,S.jsx)(`div`,{"data-slot":`card-content`,className:nt(`px-6`,e),...t})}let knn=(0,_.createContext)(null),Ann=({className:e,isStreaming:t=!1,children:n,...r})=>(0,S.jsx)(knn.Provider,{value:{isStreaming:t},children:(0,S.jsx)(Ui,{asChild:!0,"data-slot":`plan`,...r,children:(0,S.jsx)(Enn,{className:nt(`shadow-none`,e),children:n})})}),jnn=({className:e,...t})=>(0,S.jsx)(Dnn,{className:nt(`flex items-start justify-between`,e),"data-slot":`plan-header`,...t}),Mnn=e=>(0,S.jsx)(Gi,{asChild:!0,children:(0,S.jsx)(Onn,{"data-slot":`plan-content`,...e})}),Nnn=({className:e,...t})=>(0,S.jsx)(Wi,{asChild:!0,children:(0,S.jsxs)(ki,{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 Pnn(e){let t=e;return typeof t.type==`string`&&t.type.startsWith(`tool-`)&&`state`in t}function Fnn(e,t,n,r,i){if(e.type===`text`&&e.text)return(0,S.jsx)(gnn,{className:`whitespace-pre-wrap`,children:e.text},`${t}-${n}`);if(e.type===`reasoning`)return(0,S.jsxs)(fnn,{className:`w-full`,isStreaming:r,children:[(0,S.jsx)(mnn,{}),(0,S.jsx)(hnn,{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)(Ann,{defaultOpen:!0,isStreaming:r,children:[(0,S.jsx)(jnn,{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)(Nnn,{className:`mb-2`})]})}),(0,S.jsx)(Mnn,{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(Pnn(e)){let r=e=>(e=e.replace(`acp-ai-sdk-tools`,``),e),i=e.input,a=r(i.toolName),o=e.state,s=o===`output-available`||o===`output-error`;return(0,S.jsxs)(bnn,{defaultOpen:s,children:[(0,S.jsx)(Snn,{title:r(a.length>20?`${a.slice(0,20)}...`:a),type:a,state:o}),(0,S.jsxs)(Cnn,{children:[e.input!==void 0&&(0,S.jsx)(wnn,{input:i}),s&&(0,S.jsx)(Tnn,{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 Inn=({messages:e,status:t,selectedAgent:n})=>{let r=nd.find(e=>e.name===(n||rd))||nd[0],i=t===`submitted`||t===`streaming`,a=e[e.length-1],o=i&&(!a||a.role===`user`);return(0,S.jsxs)(tle,{className:`w-full h-full`,children:[(0,S.jsx)(nle,{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)(Rle,{className:`items-start`,from:e.role,children:[(0,S.jsx)(zle,{children:e.parts.map((n,r)=>Fnn(n,e.id,r,t===`streaming`,e.metadata))}),e.role===`assistant`&&(0,S.jsx)(Ble,{name:r.name,src:r.meta?.icon??``})]},e.id)),o&&(0,S.jsxs)(Rle,{className:`items-start`,from:`assistant`,children:[(0,S.jsx)(zle,{children:(0,S.jsx)(Hle,{size:16})}),(0,S.jsx)(Ble,{name:r.name,src:r.meta?.icon??``})]})]})}),(0,S.jsx)(rle,{})]})};function Lnn(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 Rnn({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 znn=`AI_SELECTED_AGENT`,Bnn=e=>{let[t,n]=(0,_.useState)(e);return(0,_.useEffect)(()=>{typeof window<`u`&&cd().then(e=>{if(e&&e!==rd)n(e);else{let e=localStorage.getItem(znn);e&&n(e)}})},[]),{agent:t,setAgent:e=>{n(e),!(typeof window>`u`)&&(e?.trim()?localStorage.setItem(znn,e):localStorage.removeItem(znn))}}},Vnn=({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}=Bnn(rd),[k,A]=(0,_.useState)(!1),j=nd.find(e=>e.name===D)||nd[0],{elementRef:M,isDragging:N,handleMouseDown:P}=Rnn(),[F,I]=(0,_.useState)(null),[L,R]=(0,_.useState)(``),ee=Lnn(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=Uce(e),{displayText:n,toolCall:r}=Gce(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(``),z(``),I(null),ae.current=null,B.current=``,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)(Bce,{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:nd.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:nd.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)(ta,{items:l,onRemove:u})}),v===`chat`&&(0,S.jsx)(`div`,{className:`h-[500px]`,children:(0,S.jsx)(Inn,{messages:a,status:o,selectedAgent:D})})]})})]})};var Hnn=`vercel.ai.error`,Unn=Symbol.for(Hnn),Wnn,Gnn=class e extends Error{constructor({name:e,message:t,cause:n}){super(t),this[Wnn]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,Hnn)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}};Wnn=Unn;var W7=Gnn;function Knn(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}var qnn=`AI_InvalidArgumentError`,Jnn=`vercel.ai.error.${qnn}`,Ynn=Symbol.for(Jnn),Xnn,Znn=class extends W7{constructor({message:e,cause:t,argument:n}){super({name:qnn,message:e,cause:t}),this[Xnn]=!0,this.argument=n}static isInstance(e){return W7.hasMarker(e,Jnn)}};Xnn=Ynn;var Qnn=`AI_JSONParseError`,$nn=`vercel.ai.error.${Qnn}`,ern=Symbol.for($nn),trn,nrn=class extends W7{constructor({text:e,cause:t}){super({name:Qnn,message:`JSON parsing failed: Text: ${e}.
|
|
6936
6936
|
Error message: ${Knn(t)}`,cause:t}),this[trn]=!0,this.text=e}static isInstance(e){return W7.hasMarker(e,$nn)}};trn=ern;var rrn=`AI_TypeValidationError`,irn=`vercel.ai.error.${rrn}`,arn=Symbol.for(irn),orn,srn=class e extends W7{constructor({value:e,cause:t}){super({name:rrn,message:`Type validation failed: Value: ${JSON.stringify(e)}.
|
|
6937
6937
|
Error message: ${Knn(t)}`,cause:t}),this[orn]=!0,this.value=e}static isInstance(e){return W7.hasMarker(e,irn)}static wrap({value:t,cause:n}){return e.isInstance(n)&&n.value===t?n:new e({value:t,cause:n})}};orn=arn;var G7=srn,crn=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n}={}){let r;super({start(i){r=Tl({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 lrn={};function J7(e){return e&&Object.assign(lrn,e),lrn}function urn(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 drn(e,t){return typeof t==`bigint`?t.toString():t}function frn(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function prn(e){return e==null}function mrn(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function hrn(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 grn=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function Q7(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let _rn=frn(()=>{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 vrn=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 yrn(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}let brn={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function xrn(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 Srn(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 Crn(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 wrn(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 Trn(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 Ern(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 Drn(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 Orn=(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,drn,2)},enumerable:!0}),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},krn=K7(`$ZodError`,Orn),Arn=K7(`$ZodError`,Orn,{Parent:Error});function jrn(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 Mrn(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 Nrn=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 grn(t,i?.callee),t}return o.value},Prn=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 grn(t,i?.callee),t}return o.value},Frn=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??krn)(a.issues.map(e=>o9(e,i,J7())))}:{success:!0,data:a.value}},Irn=Frn(Arn),Lrn=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}},Rrn=Lrn(Arn),zrn=/^[cC][^\s-]{8,}$/,Brn=/^[0-9a-z]+$/,Vrn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Hrn=/^[0-9a-vA-V]{20}$/,Urn=/^[A-Za-z0-9]{27}$/,Wrn=/^[a-zA-Z0-9_-]{21}$/,Grn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Krn=/^([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})$/,qrn=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)$/,Jrn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Yrn(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}let Xrn=/^(?:(?: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])$/,Zrn=/^(([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})$/,Qrn=/^((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])$/,$rn=/^(([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])$/,ein=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,tin=/^[A-Za-z0-9_-]*$/,nin=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,rin=/^\+(?:[0-9]){6,14}[0-9]$/,iin=`(?:(?:\\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])))`,ain=RegExp(`^${iin}$`);function oin(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 sin(e){return RegExp(`^${oin(e)}$`)}function cin(e){let t=oin({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-]\\d{2}:\\d{2})`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${iin}T(?:${r})$`)}let lin=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},uin=/^\d+$/,din=/^-?\d+(?:\.\d+)?/i,fin=/true|false/i,pin=/null/i,min=/^[^A-Z]*$/,hin=/^[^a-z]*$/,c9=K7(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),gin={number:`number`,bigint:`bigint`,object:`date`},_in=K7(`$ZodCheckLessThan`,(e,t)=>{c9.init(e,t);let n=gin[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})}}),vin=K7(`$ZodCheckGreaterThan`,(e,t)=>{c9.init(e,t);let n=gin[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})}}),yin=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):hrn(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})}}),bin=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]=brn[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=uin)}),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})}}),xin=K7(`$ZodCheckMaxLength`,(e,t)=>{var n;c9.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!prn(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=Drn(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Sin=K7(`$ZodCheckMinLength`,(e,t)=>{var n;c9.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!prn(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=Drn(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Cin=K7(`$ZodCheckLengthEquals`,(e,t)=>{var n;c9.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!prn(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=Drn(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=()=>{})}),win=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})}}),Tin=K7(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=min,l9.init(e,t)}),Ein=K7(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=hin,l9.init(e,t)}),Din=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})}}),Oin=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})}}),kin=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})}}),Ain=K7(`$ZodCheckOverwrite`,(e,t)=>{c9.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var jin=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(`
|
|
6938
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/index.cjs
CHANGED
|
@@ -1,10 +1,87 @@
|
|
|
1
1
|
const require_chunk = require('./chunk.cjs');
|
|
2
2
|
const require_config_updater = require('./config-updater.cjs');
|
|
3
3
|
const require_vue_transform = require('./vue-transform.cjs');
|
|
4
|
+
let node_path = require("node:path");
|
|
5
|
+
node_path = require_chunk.__toESM(node_path);
|
|
4
6
|
let __modelcontextprotocol_sdk_client_index_js = require("@modelcontextprotocol/sdk/client/index.js");
|
|
5
7
|
let __modelcontextprotocol_sdk_client_sse_js = require("@modelcontextprotocol/sdk/client/sse.js");
|
|
6
8
|
let unplugin = require("unplugin");
|
|
9
|
+
let magic_string = require("magic-string");
|
|
10
|
+
magic_string = require_chunk.__toESM(magic_string);
|
|
11
|
+
let svelte_compiler = require("svelte/compiler");
|
|
7
12
|
|
|
13
|
+
//#region src/compiler/svelte-transform.ts
|
|
14
|
+
function normalizePath(id) {
|
|
15
|
+
return id.split(node_path.default.sep).join("/");
|
|
16
|
+
}
|
|
17
|
+
const DATA_SOURCE_ATTR = "data-source";
|
|
18
|
+
/**
|
|
19
|
+
* Transform Svelte code to inject data-source attributes for dev inspection.
|
|
20
|
+
*
|
|
21
|
+
* Handles:
|
|
22
|
+
* - Regular elements: <div>, <button>
|
|
23
|
+
* - Components: <Counter>, <MyComponent>
|
|
24
|
+
* - Svelte special elements: <svelte:window>, <svelte:head>, etc.
|
|
25
|
+
*
|
|
26
|
+
* Skips:
|
|
27
|
+
* - Fragments and elements that cannot have attributes
|
|
28
|
+
* - Elements that already have data-source
|
|
29
|
+
* - Parse errors (returns null gracefully)
|
|
30
|
+
*/
|
|
31
|
+
function compileSvelte({ code, id }) {
|
|
32
|
+
if (!code.includes("<")) return null;
|
|
33
|
+
let ast;
|
|
34
|
+
try {
|
|
35
|
+
ast = (0, svelte_compiler.parse)(code, {
|
|
36
|
+
filename: id,
|
|
37
|
+
modern: true
|
|
38
|
+
});
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const relativePath = normalizePath(node_path.default.relative(process.cwd(), id));
|
|
43
|
+
const s = new magic_string.default(code);
|
|
44
|
+
let hasModifications = false;
|
|
45
|
+
function traverse(node) {
|
|
46
|
+
if ("nodes" in node && Array.isArray(node.nodes)) {
|
|
47
|
+
for (const childNode of node.nodes) traverse(childNode);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if ("type" in node && node.type !== "Fragment" && isElementLike(node)) {
|
|
51
|
+
const element = node;
|
|
52
|
+
if (!element.start || !element.end) return;
|
|
53
|
+
if (!element.attributes?.some((attr) => attr.type === "Attribute" && attr.name === DATA_SOURCE_ATTR)) {
|
|
54
|
+
const lines = code.substring(0, element.start).split("\n");
|
|
55
|
+
const sourceValue = `${relativePath}:${lines.length}:${lines[lines.length - 1].length + 1}`;
|
|
56
|
+
const tagMatch = code.substring(element.start).match(/^<([^\s/>]+)/);
|
|
57
|
+
if (tagMatch) {
|
|
58
|
+
const insertPos = element.start + tagMatch[0].length;
|
|
59
|
+
s.appendLeft(insertPos, ` ${DATA_SOURCE_ATTR}="${sourceValue}"`);
|
|
60
|
+
hasModifications = true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if ("fragment" in node && node.fragment) traverse(node.fragment);
|
|
65
|
+
if ("consequent" in node && node.consequent) traverse(node.consequent);
|
|
66
|
+
if ("alternate" in node && node.alternate) traverse(node.alternate);
|
|
67
|
+
if ("body" in node && node.body) traverse(node.body);
|
|
68
|
+
if ("pending" in node && node.pending) traverse(node.pending);
|
|
69
|
+
if ("then" in node && node.then) traverse(node.then);
|
|
70
|
+
if ("catch" in node && node.catch) traverse(node.catch);
|
|
71
|
+
if ("fallback" in node && node.fallback) traverse(node.fallback);
|
|
72
|
+
}
|
|
73
|
+
function isElementLike(node) {
|
|
74
|
+
return node.type === "RegularElement" || node.type === "Component" || node.type === "SlotElement" || node.type === "TitleElement" || node.type === "SvelteBody" || node.type === "SvelteComponent" || node.type === "SvelteDocument" || node.type === "SvelteElement" || node.type === "SvelteHead" || node.type === "SvelteSelf" || node.type === "SvelteWindow" || node.type === "SvelteBoundary";
|
|
75
|
+
}
|
|
76
|
+
traverse(ast.fragment);
|
|
77
|
+
if (!hasModifications) return null;
|
|
78
|
+
return {
|
|
79
|
+
code: s.toString(),
|
|
80
|
+
map: s.generateMap({ hires: true })
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
8
85
|
//#region src/utils/browser-launcher.ts
|
|
9
86
|
/**
|
|
10
87
|
* Launch browser via Chrome DevTools MCP
|
|
@@ -103,6 +180,15 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
|
103
180
|
console.error(`[dev-inspector] Failed to transform ${id}:`, error);
|
|
104
181
|
return null;
|
|
105
182
|
}
|
|
183
|
+
if (id.match(/\.svelte$/)) try {
|
|
184
|
+
return await compileSvelte({
|
|
185
|
+
code,
|
|
186
|
+
id
|
|
187
|
+
});
|
|
188
|
+
} catch (error) {
|
|
189
|
+
console.error(`[dev-inspector] Failed to transform ${id}:`, error);
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
106
192
|
return null;
|
|
107
193
|
},
|
|
108
194
|
vite: {
|
|
@@ -182,7 +268,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
|
182
268
|
}, 1e3);
|
|
183
269
|
} else {
|
|
184
270
|
console.log(`[dev-inspector] ⚠️ autoOpenBrowser: false - Console/Network context unavailable`);
|
|
185
|
-
console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt to
|
|
271
|
+
console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt or "chrome_devtools" tool to open browser manually.\n`);
|
|
186
272
|
}
|
|
187
273
|
require_config_updater.setupInspectorMiddleware(server.middlewares, {
|
|
188
274
|
agents: options.agents,
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,84 @@
|
|
|
1
1
|
import { i as setupMcpMiddleware, n as setupAcpMiddleware, r as setupInspectorMiddleware, t as updateMcpConfigs } from "./config-updater.js";
|
|
2
2
|
import { n as transformJSX, t as compileVue } from "./vue-transform.js";
|
|
3
|
+
import path from "node:path";
|
|
3
4
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
4
5
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
5
6
|
import { createUnplugin } from "unplugin";
|
|
7
|
+
import MagicString from "magic-string";
|
|
8
|
+
import { parse } from "svelte/compiler";
|
|
6
9
|
|
|
10
|
+
//#region src/compiler/svelte-transform.ts
|
|
11
|
+
function normalizePath(id) {
|
|
12
|
+
return id.split(path.sep).join("/");
|
|
13
|
+
}
|
|
14
|
+
const DATA_SOURCE_ATTR = "data-source";
|
|
15
|
+
/**
|
|
16
|
+
* Transform Svelte code to inject data-source attributes for dev inspection.
|
|
17
|
+
*
|
|
18
|
+
* Handles:
|
|
19
|
+
* - Regular elements: <div>, <button>
|
|
20
|
+
* - Components: <Counter>, <MyComponent>
|
|
21
|
+
* - Svelte special elements: <svelte:window>, <svelte:head>, etc.
|
|
22
|
+
*
|
|
23
|
+
* Skips:
|
|
24
|
+
* - Fragments and elements that cannot have attributes
|
|
25
|
+
* - Elements that already have data-source
|
|
26
|
+
* - Parse errors (returns null gracefully)
|
|
27
|
+
*/
|
|
28
|
+
function compileSvelte({ code, id }) {
|
|
29
|
+
if (!code.includes("<")) return null;
|
|
30
|
+
let ast;
|
|
31
|
+
try {
|
|
32
|
+
ast = parse(code, {
|
|
33
|
+
filename: id,
|
|
34
|
+
modern: true
|
|
35
|
+
});
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const relativePath = normalizePath(path.relative(process.cwd(), id));
|
|
40
|
+
const s = new MagicString(code);
|
|
41
|
+
let hasModifications = false;
|
|
42
|
+
function traverse(node) {
|
|
43
|
+
if ("nodes" in node && Array.isArray(node.nodes)) {
|
|
44
|
+
for (const childNode of node.nodes) traverse(childNode);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if ("type" in node && node.type !== "Fragment" && isElementLike(node)) {
|
|
48
|
+
const element = node;
|
|
49
|
+
if (!element.start || !element.end) return;
|
|
50
|
+
if (!element.attributes?.some((attr) => attr.type === "Attribute" && attr.name === DATA_SOURCE_ATTR)) {
|
|
51
|
+
const lines = code.substring(0, element.start).split("\n");
|
|
52
|
+
const sourceValue = `${relativePath}:${lines.length}:${lines[lines.length - 1].length + 1}`;
|
|
53
|
+
const tagMatch = code.substring(element.start).match(/^<([^\s/>]+)/);
|
|
54
|
+
if (tagMatch) {
|
|
55
|
+
const insertPos = element.start + tagMatch[0].length;
|
|
56
|
+
s.appendLeft(insertPos, ` ${DATA_SOURCE_ATTR}="${sourceValue}"`);
|
|
57
|
+
hasModifications = true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if ("fragment" in node && node.fragment) traverse(node.fragment);
|
|
62
|
+
if ("consequent" in node && node.consequent) traverse(node.consequent);
|
|
63
|
+
if ("alternate" in node && node.alternate) traverse(node.alternate);
|
|
64
|
+
if ("body" in node && node.body) traverse(node.body);
|
|
65
|
+
if ("pending" in node && node.pending) traverse(node.pending);
|
|
66
|
+
if ("then" in node && node.then) traverse(node.then);
|
|
67
|
+
if ("catch" in node && node.catch) traverse(node.catch);
|
|
68
|
+
if ("fallback" in node && node.fallback) traverse(node.fallback);
|
|
69
|
+
}
|
|
70
|
+
function isElementLike(node) {
|
|
71
|
+
return node.type === "RegularElement" || node.type === "Component" || node.type === "SlotElement" || node.type === "TitleElement" || node.type === "SvelteBody" || node.type === "SvelteComponent" || node.type === "SvelteDocument" || node.type === "SvelteElement" || node.type === "SvelteHead" || node.type === "SvelteSelf" || node.type === "SvelteWindow" || node.type === "SvelteBoundary";
|
|
72
|
+
}
|
|
73
|
+
traverse(ast.fragment);
|
|
74
|
+
if (!hasModifications) return null;
|
|
75
|
+
return {
|
|
76
|
+
code: s.toString(),
|
|
77
|
+
map: s.generateMap({ hires: true })
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
7
82
|
//#region src/utils/browser-launcher.ts
|
|
8
83
|
/**
|
|
9
84
|
* Launch browser via Chrome DevTools MCP
|
|
@@ -102,6 +177,15 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
|
102
177
|
console.error(`[dev-inspector] Failed to transform ${id}:`, error);
|
|
103
178
|
return null;
|
|
104
179
|
}
|
|
180
|
+
if (id.match(/\.svelte$/)) try {
|
|
181
|
+
return await compileSvelte({
|
|
182
|
+
code,
|
|
183
|
+
id
|
|
184
|
+
});
|
|
185
|
+
} catch (error) {
|
|
186
|
+
console.error(`[dev-inspector] Failed to transform ${id}:`, error);
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
105
189
|
return null;
|
|
106
190
|
},
|
|
107
191
|
vite: {
|
|
@@ -181,7 +265,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
|
181
265
|
}, 1e3);
|
|
182
266
|
} else {
|
|
183
267
|
console.log(`[dev-inspector] ⚠️ autoOpenBrowser: false - Console/Network context unavailable`);
|
|
184
|
-
console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt to
|
|
268
|
+
console.log(`[dev-inspector] 💡 Use "launch_chrome_devtools" prompt or "chrome_devtools" tool to open browser manually.\n`);
|
|
185
269
|
}
|
|
186
270
|
setupInspectorMiddleware(server.middlewares, {
|
|
187
271
|
agents: options.agents,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcpc-tech/unplugin-dev-inspector-mcp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "Universal dev inspector plugin for React/Vue - inspect component sources and API calls in any bundler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -155,6 +155,7 @@
|
|
|
155
155
|
"shiki": "^3.15.0",
|
|
156
156
|
"sonner": "^2.0.7",
|
|
157
157
|
"streamdown": "^1.5.1",
|
|
158
|
+
"svelte": "^5.0.0",
|
|
158
159
|
"tailwind-merge": "^3.3.1",
|
|
159
160
|
"tokenlens": "^1.3.1",
|
|
160
161
|
"unplugin": "^2.3.10",
|