browser-devtools-mcp 0.2.2 → 0.2.4

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.
Files changed (50) hide show
  1. package/README.md +206 -29
  2. package/dist/cli/index.d.ts +1 -0
  3. package/dist/cli/runner.js +158 -0
  4. package/dist/core-B3VLZZCP.js +1 -0
  5. package/dist/core-IV5QBQ2N.js +13 -0
  6. package/dist/core-NLBNZBEB.js +1124 -0
  7. package/dist/daemon-server.js +1 -1
  8. package/dist/index.js +2 -209
  9. package/dist/platform/browser/cli/runner.js +2 -0
  10. package/dist/platform/browser/index.d.ts +2 -0
  11. package/dist/platform/browser/tools/a11y/index.d.ts +2 -0
  12. package/dist/platform/browser/tools/content/index.d.ts +2 -0
  13. package/dist/platform/browser/tools/debug/index.d.ts +2 -0
  14. package/dist/platform/browser/tools/figma/index.d.ts +2 -0
  15. package/dist/platform/browser/tools/index.d.ts +5 -0
  16. package/dist/platform/browser/tools/interaction/index.d.ts +2 -0
  17. package/dist/platform/browser/tools/navigation/index.d.ts +2 -0
  18. package/dist/platform/browser/tools/o11y/index.d.ts +2 -0
  19. package/dist/platform/browser/tools/react/index.d.ts +2 -0
  20. package/dist/platform/browser/tools/run/index.d.ts +2 -0
  21. package/dist/platform/browser/tools/stub/index.d.ts +2 -0
  22. package/dist/platform/browser/tools/sync/index.d.ts +2 -0
  23. package/dist/platform/index.d.ts +3 -0
  24. package/dist/platform/node/cli/runner.js +2 -0
  25. package/dist/platform/node/entry.js +2 -0
  26. package/dist/platform/node/index.d.ts +11 -0
  27. package/dist/platform/node/tools/debug/index.d.ts +6 -0
  28. package/dist/platform/node/tools/index.d.ts +10 -0
  29. package/dist/platform/node/tools/run/index.d.ts +2 -0
  30. package/dist/platform/types.d.ts +15 -0
  31. package/dist/tools/index.d.ts +1 -4
  32. package/dist/tools/types.d.ts +8 -3
  33. package/package.json +6 -2
  34. package/dist/cli.js +0 -179
  35. package/dist/core.js +0 -764
  36. package/dist/tools/a11y/index.d.ts +0 -2
  37. package/dist/tools/content/index.d.ts +0 -2
  38. package/dist/tools/debug/index.d.ts +0 -2
  39. package/dist/tools/figma/index.d.ts +0 -2
  40. package/dist/tools/interaction/index.d.ts +0 -2
  41. package/dist/tools/navigation/index.d.ts +0 -2
  42. package/dist/tools/o11y/index.d.ts +0 -2
  43. package/dist/tools/react/index.d.ts +0 -2
  44. package/dist/tools/run/index.d.ts +0 -2
  45. package/dist/tools/stub/index.d.ts +0 -2
  46. package/dist/tools/sync/index.d.ts +0 -2
  47. /package/dist/{otel → platform/browser/otel}/otel-initializer.bundle.js +0 -0
  48. /package/dist/{tools → platform/browser/tools}/figma/compare/index.d.ts +0 -0
  49. /package/dist/{tools → platform/browser/tools}/figma/compare/types.d.ts +0 -0
  50. /package/dist/{types.d.ts → platform/browser/types.d.ts} +0 -0
@@ -0,0 +1,158 @@
1
+ #!/usr/bin/env node
2
+ import{a as me}from"../core-NLBNZBEB.js";import{A as se,B as re,C as ie,D as ae,E as le,F as B,G as ce,H as de,a as u,p as Y,q as z,r as Q,u as X,v as ee,x as oe,y as ne,z as te}from"../core-IV5QBQ2N.js";import{Command as pe,Option as E}from"commander";import{ZodFirstPartyTypeKind as _}from"zod";function ve(o){let i=o,l=!1,m;for(;;){let b=i._def.typeName;if(b===_.ZodOptional)l=!0,i=i._def.innerType;else if(b===_.ZodDefault)l=!0,m=i._def.defaultValue(),i=i._def.innerType;else if(b===_.ZodNullable)l=!0,i=i._def.innerType;else break}return{innerType:i,isOptional:l,defaultValue:m}}u(ve,"_unwrapZodType");function we(o){return o._def.description}u(we,"_getDescription");function Oe(o){return o.replace(/[-_]([a-z])/g,(i,l)=>l.toUpperCase())}u(Oe,"_toCamelCase");function Te(o){return o.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}u(Te,"_toKebabCase");function _e(o,i){let{innerType:l,isOptional:m,defaultValue:b}=ve(i),p=we(i)||`The ${o} value`,O=Te(o),R=l._def.typeName,y;switch(R){case _.ZodString:y=new E(`--${O} <string>`,p);break;case _.ZodNumber:y=new E(`--${O} <number>`,p),y.argParser(c=>{let d=Number(c);if(!Number.isFinite(d))throw new Error(`Invalid number: ${c}`);return d});break;case _.ZodBoolean:y=new E(`--${O}`,p);break;case _.ZodEnum:let P=l._def.values;y=new E(`--${O} <choice>`,p).choices(P);break;case _.ZodArray:y=new E(`--${O} <value...>`,p);break;case _.ZodObject:case _.ZodRecord:y=new E(`--${O} <json>`,p),y.argParser(c=>{try{return JSON.parse(c)}catch{throw new Error(`Invalid JSON: ${c}`)}});break;case _.ZodAny:case _.ZodUnknown:y=new E(`--${O} <value>`,p),y.argParser(c=>{try{return JSON.parse(c)}catch{return c}});break;case _.ZodLiteral:let n=l._def.value;typeof n=="boolean"?y=new E(`--${O}`,p):(y=new E(`--${O} <value>`,p),y.default(n));break;case _.ZodUnion:let s=l._def.options;if(s.every(c=>c._def.typeName===_.ZodLiteral)){let c=s.map(d=>String(d._def.value));y=new E(`--${O} <choice>`,p).choices(c)}else y=new E(`--${O} <value>`,p),y.argParser(c=>{try{return JSON.parse(c)}catch{return c}});break;default:y=new E(`--${O} <value>`,p);break}return b!==void 0&&y.default(b),!m&&b===void 0&&y.makeOptionMandatory(!0),y}u(_e,"_createOption");function Se(o){let i=[];for(let[l,m]of Object.entries(o)){let b=_e(l,m);b&&i.push(b)}return i}u(Se,"_generateOptionsFromSchema");function Ce(o){let i={};for(let[l,m]of Object.entries(o)){let b=Oe(l);m!==void 0&&(i[b]=m)}return i}u(Ce,"_parseOptionsToToolInput");function Ee(o){let i=o.indexOf("_");return i===-1?{domain:"default",commandName:o}:{domain:o.substring(0,i),commandName:o.substring(i+1)}}u(Ee,"_parseToolName");function W(o,i,l){let m=new Map;for(let b of i){let{domain:p,commandName:O}=Ee(b.name()),R=m.get(p);R||(R=new pe(p).description(`${p.charAt(0).toUpperCase()+p.slice(1)} commands`),m.set(p,R),o.addCommand(R));let y=new pe(O).description(b.description().trim()),P=Se(b.inputSchema());for(let n of P)y.addOption(n);y.action(async n=>{let s=Ce(n),r=o.opts();await l(b.name(),s,r)}),R.addCommand(y)}}u(W,"registerToolCommands");import{spawn as De,execSync as Re}from"node:child_process";import{createRequire as Ae}from"node:module";import*as q from"node:path";import*as K from"node:readline";import{fileURLToPath as Ne}from"node:url";import{Command as D,Option as x}from"commander";var F=Ae(import.meta.url),Pe=Ne(import.meta.url),Ie=q.dirname(Pe),h=me.cliInfo.cliProvider,N=h.tools,S=3e4,ge=!1,be=!1;function w(o,i){if(ge){let l=new Date().toISOString();i!==void 0?console.error(`[${l}] [DEBUG] ${o}`,i):console.error(`[${l}] [DEBUG] ${o}`)}}u(w,"_debug");function e(o){be||console.log(o)}u(e,"_output");function f(o){console.error(o)}u(f,"_error");async function C(o){w(`Checking if daemon is running on port ${o}`);try{let i=await fetch(`http://localhost:${o}/health`,{method:"GET",signal:AbortSignal.timeout(3e3)});if(i.ok){let m=(await i.json()).status==="ok";return w(`Daemon health check result: ${m?"running":"not running"}`),m}return w(`Daemon health check failed: HTTP ${i.status}`),!1}catch(i){return w(`Daemon health check error: ${i.message}`),!1}}u(C,"_isDaemonRunning");function ke(o){return h.buildEnv(o)}u(ke,"_buildDaemonEnv");function G(o){let i=q.join(Ie,"..","daemon-server.js"),l=ke(o);w(`Starting daemon server from: ${i}`),w(`Daemon port: ${o.port}`);let m=De(process.execPath,[i,"--port",String(o.port)],{detached:!0,stdio:"ignore",env:l});m.unref(),w(`Daemon process spawned with PID: ${m.pid}`),e(`Started daemon server as detached process (PID: ${m.pid})`)}u(G,"_startDaemonDetached");async function k(o){if(await C(o.port))w("Daemon is already running");else{e(`Daemon server is not running on port ${o.port}, starting...`),G(o);let l=10,m=500;w(`Waiting for daemon to be ready (max ${l} retries, ${m}ms delay)`);for(let b=0;b<l;b++)if(await new Promise(p=>setTimeout(p,m)),w(`Retry ${b+1}/${l}: checking daemon status...`),await C(o.port)){w("Daemon is now ready"),e("Daemon server is ready");return}throw new Error(`Daemon server failed to start within ${l*m/1e3} seconds`)}}u(k,"_ensureDaemonRunning");async function U(o,i){try{return(await fetch(`http://localhost:${o}/shutdown`,{method:"POST",signal:AbortSignal.timeout(i)})).ok}catch{return!1}}u(U,"_stopDaemon");async function ue(o,i,l,m,b){let p={"Content-Type":"application/json"};m&&(p["session-id"]=m);let O={toolName:i,toolInput:l};w(`Calling tool: ${i}`),w("Tool input:",l),w(`Session ID: ${m||"(default)"}`),w(`Timeout: ${b||"none"}`);let R=Date.now(),y=await fetch(`http://localhost:${o}/call`,{method:"POST",headers:p,body:JSON.stringify(O),signal:b?AbortSignal.timeout(b):void 0}),P=Date.now()-R;if(w(`Tool call completed in ${P}ms, status: ${y.status}`),!y.ok){let s=await y.json().catch(()=>({}));throw w("Tool call error:",s),new Error(s?.error?.message||`HTTP ${y.status}: ${y.statusText}`)}let n=await y.json();return w("Tool call result:",n.toolError?{error:n.toolError}:{success:!0}),n}u(ue,"_callTool");async function je(o,i,l){try{return(await fetch(`http://localhost:${o}/session`,{method:"DELETE",headers:{"session-id":i},signal:AbortSignal.timeout(l)})).ok}catch{return!1}}u(je,"_deleteSession");async function J(o,i){try{let l=await fetch(`http://localhost:${o}/info`,{method:"GET",signal:AbortSignal.timeout(i)});return l.ok?await l.json():null}catch{return null}}u(J,"_getDaemonInfo");async function fe(o,i){try{let l=await fetch(`http://localhost:${o}/sessions`,{method:"GET",signal:AbortSignal.timeout(i)});return l.ok?await l.json():null}catch{return null}}u(fe,"_listSessions");async function xe(o,i,l){try{let m=await fetch(`http://localhost:${o}/session`,{method:"GET",headers:{"session-id":i},signal:AbortSignal.timeout(l)});return m.ok?await m.json():null}catch{return null}}u(xe,"_getSessionInfo");function j(o){let i=Math.floor(o/86400),l=Math.floor(o%86400/3600),m=Math.floor(o%3600/60),b=o%60,p=[];return i>0&&p.push(`${i}d`),l>0&&p.push(`${l}h`),m>0&&p.push(`${m}m`),p.push(`${b}s`),p.join(" ")}u(j,"_formatUptime");function V(o){return new Date(o).toISOString()}u(V,"_formatTimestamp");function Z(o){let i=o._def.typeName;return i==="ZodOptional"||i==="ZodNullable"||i==="ZodDefault"?Z(o._def.innerType):i==="ZodArray"?`${Z(o._def.type)}[]`:i==="ZodEnum"?o._def.values.join(" | "):i==="ZodLiteral"?JSON.stringify(o._def.value):i==="ZodUnion"?o._def.options.map(m=>Z(m)).join(" | "):{ZodString:"string",ZodNumber:"number",ZodBoolean:"boolean",ZodObject:"object",ZodRecord:"Record<string, any>",ZodAny:"any"}[i]||i.replace("Zod","").toLowerCase()}u(Z,"_getZodTypeName");function H(o){if(o._def.description)return o._def.description;if(o._def.typeName==="ZodOptional"||o._def.typeName==="ZodNullable"||o._def.typeName==="ZodDefault")return H(o._def.innerType)}u(H,"_getZodDescription");function Ze(o){let i=o._def.typeName;return i==="ZodOptional"||i==="ZodNullable"}u(Ze,"_isZodOptional");function ye(o){return o._def.typeName==="ZodDefault"?!0:o._def.typeName==="ZodOptional"||o._def.typeName==="ZodNullable"?ye(o._def.innerType):!1}u(ye,"_hasZodDefault");function $e(o){if(o._def.typeName==="ZodDefault")return o._def.defaultValue();if(o._def.typeName==="ZodOptional"||o._def.typeName==="ZodNullable")return $e(o._def.innerType)}u($e,"_getZodDefault");function L(o,i=0){let l=" ".repeat(i);if(o==null)return`${l}(empty)`;if(typeof o=="string")return o.split(`
3
+ `).map(m=>`${l}${m}`).join(`
4
+ `);if(typeof o=="number"||typeof o=="boolean")return`${l}${o}`;if(Array.isArray(o))return o.length===0?`${l}[]`:o.map(m=>L(m,i)).join(`
5
+ `);if(typeof o=="object"){let m=[];for(let[b,p]of Object.entries(o))p!==void 0&&(typeof p=="object"&&p!==null&&!Array.isArray(p)?(m.push(`${l}${b}:`),m.push(L(p,i+1))):Array.isArray(p)?(m.push(`${l}${b}:`),m.push(L(p,i+1))):m.push(`${l}${b}: ${p}`));return m.join(`
6
+ `)}return`${l}${String(o)}`}u(L,"_formatOutput");function $(o,i,l=!1){let m=i?JSON.stringify(o,null,2):String(o);l?console.error(m):console.log(m)}u($,"_printOutput");function Ge(o){return o.addOption(new x("--port <number>","Daemon server port").argParser(i=>{let l=Number(i);if(!Number.isInteger(l)||l<1||l>65535)throw new Error("Port must be an integer between 1 and 65535");return l}).default(B)).addOption(new x("--session-id <string>","Session ID for maintaining state across commands")).addOption(new x("--json","Output results as JSON")).addOption(new x("--quiet","Suppress log messages, only show output")).addOption(new x("--verbose","Enable verbose/debug output")).addOption(new x("--timeout <ms>","Timeout for operations in milliseconds").argParser(i=>{let l=Number(i);if(!Number.isFinite(l)||l<0)throw new Error("Timeout must be a positive number");return l}).default(S)),h.addOptions(o)}u(Ge,"_addGlobalOptions");async function Le(){let o=Ge(new D(h.cliName).description(h.cliDescription).version(F("../../package.json").version));o.hook("preAction",n=>{let s=n.opts();s.verbose&&(ge=!0),s.quiet&&(be=!0),w("Verbose mode enabled"),w("CLI version:",F("../../package.json").version),w("Node version:",process.version),w("Platform:",process.platform)});let i=new D("daemon").description("Manage the daemon server");i.command("start").description("Start the daemon server").action(async()=>{let n=o.opts();if(await C(n.port)){n.json?$({status:"already_running",port:n.port},!0):e(`Daemon server is already running on port ${n.port}`);return}G(n);let r=10,c=500;for(let d=0;d<r;d++)if(await new Promise(t=>setTimeout(t,c)),await C(n.port)){n.json?$({status:"started",port:n.port},!0):e(`Daemon server started on port ${n.port}`);return}n.json?$({status:"failed",error:"Daemon server failed to start"},!0,!0):f("Failed to start daemon server"),process.exit(1)}),i.command("stop").description("Stop the daemon server").action(async()=>{let n=o.opts();if(!await C(n.port)){n.json?$({status:"not_running",port:n.port},!0):e(`Daemon server is not running on port ${n.port}`);return}await U(n.port,n.timeout??S)?n.json?$({status:"stopped",port:n.port},!0):e(`Daemon server stopped on port ${n.port}`):(n.json?$({status:"failed",error:"Failed to stop daemon server"},!0,!0):f("Failed to stop daemon server"),process.exit(1))}),i.command("restart").description("Restart the daemon server (stop + start)").action(async()=>{let n=o.opts(),s=await C(n.port);s&&(w("Stopping daemon server..."),await U(n.port,n.timeout??S)||(n.json?$({status:"failed",error:"Failed to stop daemon server"},!0,!0):f("Failed to stop daemon server"),process.exit(1)),w("Waiting for port to be released..."),await new Promise(t=>setTimeout(t,1e3))),w("Starting daemon server..."),G(n);let r=10,c=500;for(let d=0;d<r;d++)if(await new Promise(t=>setTimeout(t,c)),await C(n.port)){n.json?$({status:"restarted",port:n.port},!0):e(`Daemon server ${s?"restarted":"started"} on port ${n.port}`);return}n.json?$({status:"failed",error:"Daemon server failed to start"},!0,!0):f("Failed to start daemon server"),process.exit(1)}),i.command("status").description("Check daemon server status").action(async()=>{let n=o.opts(),s=await C(n.port);n.json?$({status:s?"running":"stopped",port:n.port},!0):e(s?`Daemon server is running on port ${n.port}`:`Daemon server is not running on port ${n.port}`)}),i.command("info").description("Get detailed daemon server information").action(async()=>{let n=o.opts();await C(n.port)||(n.json?$({status:"not_running",port:n.port},!0,!0):f(`Daemon server is not running on port ${n.port}`),process.exit(1));let r=await J(n.port,n.timeout??S);r?n.json?$(r,!0):(e("Daemon Server Information:"),e(` Version: ${r.version}`),e(` Port: ${r.port}`),e(` Uptime: ${j(r.uptime)}`),e(` Sessions: ${r.sessionCount}`)):(n.json?$({status:"error",error:"Failed to get daemon info"},!0,!0):f("Failed to get daemon info"),process.exit(1))}),o.addCommand(i);let l=new D("session").description(h.sessionDescription);l.command("list").description("List all active sessions").action(async()=>{let n=o.opts();try{await k(n);let s=await fe(n.port,n.timeout??S);if(s)if(n.json)$(s,!0);else if(s.sessions.length===0)e("No active sessions");else{e(`Active Sessions (${s.sessions.length}):`);for(let r of s.sessions)e(` ${r.id}`),e(` Created: ${V(r.createdAt)}`),e(` Last Active: ${V(r.lastActiveAt)}`),e(` Idle: ${j(r.idleSeconds)}`)}else n.json?$({status:"error",error:"Failed to list sessions"},!0,!0):f("Failed to list sessions"),process.exit(1)}catch(s){n.json?$({status:"error",error:s.message},!0,!0):f(`Error: ${s.message}`),process.exit(1)}}),l.command("info <session-id>").description("Get information about a specific session").action(async n=>{let s=o.opts();try{await k(s);let r=await xe(s.port,n,s.timeout??S);r?s.json?$(r,!0):(e(`Session: ${r.id}`),e(` Created: ${V(r.createdAt)}`),e(` Last Active: ${V(r.lastActiveAt)}`),e(` Idle: ${j(r.idleSeconds)}`)):(s.json?$({status:"not_found",sessionId:n},!0,!0):f(`Session '${n}' not found`),process.exit(1))}catch(r){s.json?$({status:"error",error:r.message},!0,!0):f(`Error: ${r.message}`),process.exit(1)}}),l.command("delete <session-id>").description("Delete a specific session").action(async n=>{let s=o.opts();try{await k(s),await je(s.port,n,s.timeout??S)?s.json?$({status:"deleted",sessionId:n},!0):e(`Session '${n}' deleted`):(s.json?$({status:"not_found",sessionId:n},!0,!0):f(`Session '${n}' not found or already deleted`),process.exit(1))}catch(r){s.json?$({status:"error",error:r.message},!0,!0):f(`Error: ${r.message}`),process.exit(1)}}),o.addCommand(l);let m=new D("tools").description("List and inspect available tools");m.command("list").description("List all available tools").option("--domain <domain>","Filter by domain (e.g., navigation, content, interaction)").action(n=>{let s=o.opts(),r=new Map;for(let c of N){let t=c.name().split("_")[0];n.domain&&t!==n.domain||(r.has(t)||r.set(t,[]),r.get(t).push(c))}if(s.json){let c=[];for(let[d,t]of r)c.push({domain:d,tools:t.map(a=>({name:a.name(),description:a.description().trim().split(`
7
+ `)[0]}))});$(c,!0)}else{if(r.size===0){e("No tools found");return}e(`Available Tools (${N.length} total):
8
+ `);for(let[c,d]of r){e(` ${c}:`);for(let t of d){let a=t.name().split("_")[1]||t.name(),g=t.description().trim().split(`
9
+ `)[0];e(` ${a.padEnd(30)} ${g}`)}e("")}}}),m.command("info <tool-name>").description("Get detailed information about a specific tool").action(n=>{let s=o.opts(),r=N.find(t=>t.name()===n);r||(r=N.find(t=>t.name().split("_")[1]===n)),r||(s.json?$({status:"not_found",toolName:n},!0,!0):f(`Tool '${n}' not found`),process.exit(1));let c=r.inputSchema(),d=[];for(let[t,a]of Object.entries(c))d.push({name:t,type:Z(a),required:!Ze(a),description:H(a),default:ye(a)?$e(a):void 0});if(s.json)$({name:r.name(),description:r.description().trim(),parameters:d},!0);else{let t=r.name().split("_");if(e(`Tool: ${r.name()}`),e(`Domain: ${t[0]}`),e(`
10
+ Description:`),e(r.description().trim().split(`
11
+ `).map(a=>` ${a}`).join(`
12
+ `)),e(`
13
+ Parameters:`),d.length===0)e(" (none)");else for(let a of d){let g=a.required?"(required)":"(optional)";e(` --${a.name} <${a.type}> ${g}`),a.description&&e(` ${a.description}`),a.default!==void 0&&e(` Default: ${JSON.stringify(a.default)}`)}e(`
14
+ Usage:`),e(` ${h.cliName} ${t[0]} ${t[1]||r.name()} [options]`)}}),m.command("search <query>").description("Search tools by name or description").action(n=>{let s=o.opts(),r=n.toLowerCase(),c=N.filter(d=>{let t=d.name().toLowerCase(),a=d.description().toLowerCase();return t.includes(r)||a.includes(r)});if(s.json){let d=c.map(t=>{let a=t.name().split("_");return{name:t.name(),domain:a[0],description:t.description().trim().split(`
15
+ `)[0]}});$(d,!0)}else{if(c.length===0){e(`No tools found matching "${n}"`);return}e(`Tools matching "${n}" (${c.length} found):
16
+ `);for(let d of c){let t=d.name().split("_"),a=t[0],g=t[1]||d.name(),v=d.description().trim().split(`
17
+ `)[0];e(` ${a}/${g}`),e(` ${v}
18
+ `)}}}),o.addCommand(m);let b=new D("config").description("Show current configuration").action(()=>{let n=o.opts(),s={daemon:{port:B,sessionIdleSeconds:ce,sessionIdleCheckSeconds:de},[h.platform]:h.getConfig(),otel:{enabled:Y,serviceName:z,serviceVersion:Q,exporterType:X,exporterHttpUrl:ee},aws:{region:oe,profile:ne},bedrock:{enabled:te,imageEmbedModelId:se,textEmbedModelId:re,visionModelId:ie},figma:{accessToken:ae?"***":void 0,apiBaseUrl:le}};n.json?$(s,!0):(e(`Current Configuration:
19
+ `),e(" Daemon:"),e(` Port: ${s.daemon.port}`),e(` Session Idle (sec): ${s.daemon.sessionIdleSeconds}`),e(` Idle Check Interval: ${s.daemon.sessionIdleCheckSeconds}`),e(`
20
+ `+h.formatConfig(s[h.platform])),e(`
21
+ OpenTelemetry:`),e(` Enabled: ${s.otel.enabled}`),e(` Service Name: ${s.otel.serviceName}`),e(` Service Version: ${s.otel.serviceVersion||"(not set)"}`),e(` Exporter Type: ${s.otel.exporterType}`),e(` Exporter HTTP URL: ${s.otel.exporterHttpUrl||"(not set)"}`),e(`
22
+ AWS:`),e(` Region: ${s.aws.region||"(not set)"}`),e(` Profile: ${s.aws.profile||"(not set)"}`),e(`
23
+ Bedrock:`),e(` Enabled: ${s.bedrock.enabled}`),e(` Image Embed Model ID: ${s.bedrock.imageEmbedModelId||"(not set)"}`),e(` Text Embed Model ID: ${s.bedrock.textEmbedModelId||"(not set)"}`),e(` Vision Model ID: ${s.bedrock.visionModelId||"(not set)"}`),e(`
24
+ Figma:`),e(` Access Token: ${s.figma.accessToken||"(not set)"}`),e(` API Base URL: ${s.figma.apiBaseUrl}`))});o.addCommand(b);let p=new D("completion").description("Generate shell completion scripts");p.command("bash").description("Generate bash completion script").action(()=>{let n=`_${h.cliName.replace(/-/g,"_")}_completions`,s=`
25
+ # ${h.cliName} bash completion
26
+ ${n}() {
27
+ local cur="\${COMP_WORDS[COMP_CWORD]}"
28
+ local prev="\${COMP_WORDS[COMP_CWORD-1]}"
29
+
30
+ # Main commands
31
+ local commands="${h.bashCompletionCommands}"
32
+
33
+ # Daemon subcommands
34
+ local daemon_cmds="start stop restart status info"
35
+
36
+ # Session subcommands
37
+ local session_cmds="list info delete"
38
+
39
+ # Tools subcommands
40
+ local tools_cmds="list info search"
41
+
42
+ case "\${prev}" in
43
+ ${h.cliName})
44
+ COMPREPLY=( $(compgen -W "\${commands}" -- "\${cur}") )
45
+ return 0
46
+ ;;
47
+ daemon)
48
+ COMPREPLY=( $(compgen -W "\${daemon_cmds}" -- "\${cur}") )
49
+ return 0
50
+ ;;
51
+ session)
52
+ COMPREPLY=( $(compgen -W "\${session_cmds}" -- "\${cur}") )
53
+ return 0
54
+ ;;
55
+ tools)
56
+ COMPREPLY=( $(compgen -W "\${tools_cmds}" -- "\${cur}") )
57
+ return 0
58
+ ;;
59
+ esac
60
+
61
+ # Global options
62
+ if [[ "\${cur}" == -* ]]; then
63
+ local opts="--port --session-id --json --quiet --verbose --timeout ${h.bashCompletionOptions} --help --version"
64
+ COMPREPLY=( $(compgen -W "\${opts}" -- "\${cur}") )
65
+ return 0
66
+ fi
67
+ }
68
+
69
+ complete -F ${n} ${h.cliName}
70
+ `;console.log(s),f(`
71
+ # To enable, add to your ~/.bashrc:`),f(`# eval "$(${h.cliName} completion bash)"`)}),p.command("zsh").description("Generate zsh completion script").action(()=>{let n=`_${h.cliName.replace(/-/g,"_")}`,s=h.zshCompletionCommands.map(c=>` '${c.name}:${c.description}'`).join(`
72
+ `),r=`
73
+ #compdef ${h.cliName}
74
+
75
+ ${n}() {
76
+ local -a commands
77
+ commands=(
78
+ ${s}
79
+ )
80
+
81
+ local -a daemon_cmds
82
+ daemon_cmds=(
83
+ 'start:Start the daemon server'
84
+ 'stop:Stop the daemon server'
85
+ 'restart:Restart the daemon server'
86
+ 'status:Check daemon server status'
87
+ 'info:Get detailed daemon info'
88
+ )
89
+
90
+ local -a session_cmds
91
+ session_cmds=(
92
+ 'list:List all active sessions'
93
+ 'info:Get information about a session'
94
+ 'delete:Delete a specific session'
95
+ )
96
+
97
+ local -a tools_cmds
98
+ tools_cmds=(
99
+ 'list:List all available tools'
100
+ 'info:Get detailed tool information'
101
+ 'search:Search tools by keyword'
102
+ )
103
+
104
+ _arguments -C \\
105
+ '--port[Daemon server port]:port' \\
106
+ '--session-id[Session ID]:session_id' \\
107
+ '--json[Output as JSON]' \\
108
+ '--quiet[Suppress log messages]' \\
109
+ '--verbose[Enable verbose output]' \\
110
+ '--timeout[Operation timeout]:ms' \\
111
+ ${h.zshCompletionOptions}
112
+ '--help[Show help]' \\
113
+ '--version[Show version]' \\
114
+ '1: :->cmd' \\
115
+ '*:: :->args'
116
+
117
+ case "$state" in
118
+ cmd)
119
+ _describe 'command' commands
120
+ ;;
121
+ args)
122
+ case "$words[1]" in
123
+ daemon)
124
+ _describe 'subcommand' daemon_cmds
125
+ ;;
126
+ session)
127
+ _describe 'subcommand' session_cmds
128
+ ;;
129
+ tools)
130
+ _describe 'subcommand' tools_cmds
131
+ ;;
132
+ esac
133
+ ;;
134
+ esac
135
+ }
136
+
137
+ ${n}
138
+ `;console.log(r),f(`
139
+ # To enable, add to your ~/.zshrc:`),f(`# eval "$(${h.cliName} completion zsh)"`)}),o.addCommand(p);function O(n){let s=new D("repl").exitOverride().configureOutput({writeOut:u(t=>e(t.trimEnd()),"writeOut"),writeErr:u(t=>f(t.trimEnd()),"writeErr")}),r=new D("daemon").description("Manage daemon server").exitOverride();r.command("start").description("Start the daemon server").action(async()=>{let t=n;await C(t.port)?e(`Daemon server is already running on port ${t.port}`):(G(t),await k(t),e(`Daemon server started on port ${t.port}`))}),r.command("stop").description("Stop the daemon server").action(async()=>{let t=n;await C(t.port)?await U(t.port,t.timeout??S)?e("Daemon server stopped"):f("Failed to stop daemon server"):e("Daemon server is not running")}),r.command("restart").description("Restart the daemon server").action(async()=>{let t=n;await C(t.port)&&(await U(t.port,t.timeout??S),await new Promise(g=>setTimeout(g,1e3))),G(t),await k(t),e(`Daemon server restarted on port ${t.port}`)}),r.command("status").description("Check daemon server status").action(async()=>{let t=n,a=await C(t.port);e(a?`Daemon server is running on port ${t.port}`:"Daemon server is not running")}),r.command("info").description("Show daemon server information").action(async()=>{let t=n,a=await J(t.port,t.timeout??S);a?(e(`Version: ${a.version}`),e(`Uptime: ${j(a.uptime)}`),e(`Sessions: ${a.sessionCount}`),e(`Port: ${a.port}`)):e("Daemon server is not running")}),s.addCommand(r);let c=new D("session").description(h.sessionDescription).exitOverride();c.command("list").description("List active sessions").action(async()=>{let t=n,a=await fe(t.port,t.timeout??S);if(a&&a.sessions.length>0){e(`Active sessions: ${a.sessions.length}`);for(let g of a.sessions)e(` ${g.id} (idle: ${j(g.idleSeconds)})`)}else e("No active sessions")}),c.command("info <session-id>").description("Show session information").action(async t=>{let a=n;try{let g=await fetch(`http://localhost:${a.port}/session`,{method:"GET",headers:{"session-id":t},signal:AbortSignal.timeout(a.timeout??S)});if(g.ok){let v=await g.json();e(`Session: ${v.id}`),e(`Created: ${new Date(v.createdAt).toISOString()}`),e(`Last Active: ${new Date(v.lastActiveAt).toISOString()}`),e(`Idle: ${j(v.idleSeconds)}`)}else e(`Session not found: ${t}`)}catch(g){f(`Error: ${g.message}`)}}),c.command("delete <session-id>").description("Delete a session").action(async t=>{let a=n;try{(await fetch(`http://localhost:${a.port}/session`,{method:"DELETE",headers:{"session-id":t},signal:AbortSignal.timeout(a.timeout??S)})).ok?e(`Session deleted: ${t}`):e(`Session not found: ${t}`)}catch(g){f(`Error: ${g.message}`)}}),s.addCommand(c);let d=new D("tools").description("Discover and inspect available tools").exitOverride();return d.command("list").description("List all available tools").action(()=>{let t=new Set;for(let a of N)t.add(a.name().split("_")[0]);e(`Available domains: ${Array.from(t).join(", ")}`),e(`Total tools: ${N.length}`)}),d.command("search <query>").description("Search tools by name or description").action(t=>{let a=t.toLowerCase(),g=N.filter(v=>v.name().toLowerCase().includes(a)||v.description().toLowerCase().includes(a));if(g.length>0){e(`Found ${g.length} tools:`);for(let v of g)e(` ${v.name()} - ${v.description()}`)}else e(`No tools found matching "${t}"`)}),d.command("info <tool-name>").description("Show detailed information about a tool").action(t=>{let a=N.find(g=>g.name()===t);if(a){e(`
140
+ Tool: ${a.name()}`),e(`Description: ${a.description()}`),e("Input Schema:");let g=a.inputSchema();for(let[v,T]of Object.entries(g)){let I=Z(T),M=H(T)||"",A=T.isOptional();e(` --${v} <${I}>${A?" (optional)":""} ${M}`)}}else e(`Tool not found: ${t}`)}),s.addCommand(d),s.command("config").description("Show current configuration").action(()=>{let t=n;e(`
141
+ Current Configuration:`),e(` port = ${t.port}`),e(` session-id = ${t.sessionId||"(auto)"}`),e(h.formatConfigForRepl(t)),e(` timeout = ${t.timeout??S}`),e(` json = ${t.json??!1}`),e(` quiet = ${t.quiet??!1}`),e(` verbose = ${t.verbose??!1}`),e(`
142
+ Tip: Start interactive mode with options:`),e(` ${h.cliExamples[0]}`)}),s.command("update").description("Check for updates").option("--check","Only check for updates without installing").action(async t=>{let a=F("../../package.json").version,g=h.packageName;e(`Checking for updates...
143
+ `);try{let v=await fetch(`https://registry.npmjs.org/${g}/latest`,{signal:AbortSignal.timeout(1e4)});if(!v.ok){f("Failed to check for updates");return}let I=(await v.json()).version;e(`Current version: ${a}`),e(`Latest version: ${I}`),a===I?e(`
144
+ You are using the latest version!`):(e(`
145
+ A new version is available!`),t.check||e(`Run: npm install -g ${g}@latest`))}catch(v){f(`Error checking for updates: ${v.message}`)}}),s.command("status").description("Show daemon status summary").action(async()=>{let t=n,a=await J(t.port,t.timeout??S);e(a?`Daemon: running (v${a.version}, uptime: ${j(a.uptime)}, sessions: ${a.sessionCount})`:"Daemon: not running")}),W(s,N,async(t,a,g)=>{let v=n;try{let T=await ue(v.port,t,a,v.sessionId,v.timeout);T.toolError?f(`Error: ${T.toolError.message}`):T.toolOutput&&(v.json?e(JSON.stringify(T.toolOutput,null,2)):e(L(T.toolOutput)))}catch(T){f(`Error: ${T.message}`)}}),s}u(O,"_createReplProgram");function R(n){let s=[],r="",c=!1,d="";for(let t=0;t<n.length;t++){let a=n[t];c?a===d?(c=!1,s.push(r),r=""):r+=a:a==='"'||a==="'"?(c=!0,d=a):a===" "||a===" "?r&&(s.push(r),r=""):r+=a}return r&&s.push(r),s}u(R,"_parseReplInput");let y=new D("interactive").alias("repl").description("Start interactive REPL mode").action(async()=>{let n=o.opts();e(`${h.cliDescription} - Interactive Mode`),e(`Type "help" for available commands, "exit" to quit
146
+ `);try{await k(n)}catch(c){f(`Error: ${c.message}`),process.exit(1)}let s=O(n),r=K.createInterface({input:process.stdin,output:process.stdout,prompt:h.replPrompt});r.prompt(),r.on("line",async c=>{let d=c.trim();if(!d){r.prompt();return}if((d==="exit"||d==="quit")&&(e("Goodbye!"),r.close(),process.exit(0)),d==="help"){e(`
147
+ REPL Commands:`),e(" help Show this help"),e(" exit, quit Exit interactive mode"),e(`
148
+ Available Commands:`),e(" status Show daemon status summary"),e(" config Show current configuration"),e(" update Check for CLI updates"),e(" daemon <cmd> Daemon management (start, stop, restart, status, info)"),e(" session <cmd> Session management (list, info, delete)"),e(" tools <cmd> Tool discovery (list, search, info)"),e(" <domain> <tool> Execute a tool (e.g., navigation go-to --url ...)"),e(`
149
+ Examples:`),e(" # Daemon & Session"),e(" daemon status"),e(" daemon info"),e(" session list"),e(" session delete my-session"),e(""),e(" # Tool Discovery"),e(" tools list"),e(" tools search screenshot"),e(" tools info navigation_go-to"),e(""),e(" # Navigation"),e(' navigation go-to --url "https://example.com"'),e(" navigation go-back"),e(" navigation reload"),e(""),e(" # Content"),e(' content take-screenshot --name "test"'),e(" content get-as-text"),e(' content get-as-html --selector "#main"'),e(""),e(" # Interaction"),e(' interaction click --ref "Submit"'),e(' interaction fill --ref "Email" --value "test@example.com"'),e(' interaction hover --ref "Menu"'),e(""),e(" # Accessibility"),e(" a11y get-snapshot"),e(" a11y get-ax-tree-snapshot"),e(`
150
+ Tip: Use global options when starting interactive mode:`);for(let t of h.cliExamples)e(` ${t}`);e(""),r.prompt();return}try{let t=R(d);await s.parseAsync(["node","repl",...t])}catch(t){t.code==="commander.help"||(t.code==="commander.unknownCommand"?(e(`Unknown command: ${d}`),e('Type "help" for available commands')):t.code==="commander.missingArgument"?f(`Missing argument: ${t.message}`):t.code==="commander.invalidArgument"?f(`Invalid argument: ${t.message}`):t.code&&t.code.startsWith("commander.")||f(`Error: ${t.message}`))}r.prompt()}),r.on("close",()=>{process.exit(0)})});o.addCommand(y);let P=new D("update").description("Check for updates and optionally install them").option("--check","Only check for updates without installing").action(async n=>{let s=o.opts(),r=F("../../package.json").version,c=h.packageName;e(`Checking for updates...
151
+ `);try{let d=await fetch(`https://registry.npmjs.org/${c}/latest`,{method:"GET",signal:AbortSignal.timeout(1e4)});if(!d.ok)throw new Error(`Failed to check npm registry: HTTP ${d.status}`);let a=(await d.json()).version;if(s.json){$({currentVersion:r,latestVersion:a,updateAvailable:a!==r},!0);return}if(e(` Current version: ${r}`),e(` Latest version: ${a}`),e(""),a===r){e("\x1B[32m\u2713 You are using the latest version!\x1B[0m");return}let g=r.split(".").map(Number),v=a.split(".").map(Number),T=!1;for(let A=0;A<3;A++)if(v[A]>g[A]){T=!0;break}else if(v[A]<g[A])break;if(!T){e("\x1B[32m\u2713 You are using a newer version than published!\x1B[0m");return}if(e(`\x1B[33m\u26A0 Update available: ${r} \u2192 ${a}\x1B[0m
152
+ `),n.check){e("To update, run:"),e(` npm install -g ${c}@latest`),e("or"),e(` npx ${c}@latest`);return}let I=K.createInterface({input:process.stdin,output:process.stdout}),M=await new Promise(A=>{I.question("Do you want to update now? (y/N) ",he=>{I.close(),A(he.toLowerCase())})});if(M!=="y"&&M!=="yes"){e(`
153
+ Update cancelled.`);return}e(`
154
+ Updating...
155
+ `);try{Re(`npm install -g ${c}@latest`,{stdio:"inherit"}),e(`
156
+ \x1B[32m\u2713 Update complete!\x1B[0m`),e("Please restart your terminal or run a new command to use the updated version.")}catch{f(`
157
+ \x1B[31m\u2717 Update failed.\x1B[0m`),f("Try running manually with sudo:"),f(` sudo npm install -g ${c}@latest`),process.exit(1)}}catch(d){s.json?$({error:d.message,currentVersion:r},!0,!0):(f(`\x1B[31m\u2717 Failed to check for updates: ${d.message}\x1B[0m`),f(`
158
+ You can manually check at:`),f(` https://www.npmjs.com/package/${c}`)),process.exit(1)}});o.addCommand(P),W(o,N,async(n,s,r)=>{let c=r;try{await k(c);let d=await ue(c.port,n,s,c.sessionId,c.timeout);d.toolError&&(c.json?$({error:d.toolError},!0,!0):f(`Error: ${d.toolError.message||"Unknown error"}`),process.exit(1)),d.toolOutput&&(c.json?$(d.toolOutput,!0):e(L(d.toolOutput)))}catch(d){c.json?$({error:d.message},!0,!0):f(`Error: ${d.message}`),process.exit(1)}}),await o.parseAsync(process.argv)}u(Le,"main");Le().catch(o=>{f(`Fatal error: ${o.message}`),process.exit(1)});
@@ -0,0 +1 @@
1
+ import{$ as f,W as a,X as b,Y as c,Z as d,_ as e,aa as g,ba as h,ca as i,da as j,ea as k,fa as l,ga as m,ha as n,ia as o,ja as p,ka as q,la as r,ma as s,na as t,oa as u,pa as v,qa as w,ra as x,sa as y,ta as z,ua as A,va as B,wa as C,xa as D,ya as E}from"./core-IV5QBQ2N.js";export{b as DEFAULT_NODE_DEBUG_CONFIG,a as ProbeKind,w as addWatchExpression,p as clearProbes,s as clearSnapshots,t as clearSnapshotsByProbe,z as clearWatchExpressions,m as createProbe,f as detachDebugging,e as disableDebugging,d as enableDebugging,E as evaluateInNode,v as getConsoleMessages,l as getExceptionBreakpoint,C as getOriginalSources,D as getScripts,u as getSnapshotStats,q as getSnapshots,r as getSnapshotsByProbe,h as getStore,c as getStoreKey,B as hasSourceMaps,g as isDebuggingEnabled,o as listProbes,j as listStoreKeys,y as listWatchExpressions,A as loadSourceMaps,n as removeProbe,x as removeWatchExpression,i as resolveSourceLocation,k as setExceptionBreakpoint};
@@ -0,0 +1,13 @@
1
+ var ne=Object.defineProperty;var u=(r,e)=>ne(r,"name",{value:e,configurable:!0});import re from"node:path";function h(r){let e=process.env[r];if(!e)return;let t=e.trim();return t||void 0}u(h,"_envStr");function x(r){let e=h(r);if(!e)return;let t=Number(e);if(Number.isFinite(t))return Math.floor(t)}u(x,"_envInt");function _(r){let e=h(r);if(e)return e==="true"}u(_,"_envBool");function se(r){let e={};if(!r)return e;let t=r.split(",");for(let n of t){let s=n.trim();if(!s)continue;let i=s.indexOf("=");if(i===-1)continue;let c=s.slice(0,i).trim(),o=s.slice(i+1).trim();!c||!o||(e[c]=o)}return e}u(se,"_parseKeyValueFromEnv");var Ne=x("PORT")??3e3,F=h("PLATFORM"),we=F==="browser"||F==="node"?F:"browser",De=x("SESSION_IDLE_SECONDS")??300,Ce=x("SESSION_IDLE_CHECK_SECONDS")??30,Ae=_("SESSION_CLOSE_ON_SOCKET_CLOSE")??!1,Te=_("BROWSER_HEADLESS_ENABLE")??!0,Me=_("BROWSER_PERSISTENT_ENABLE")??!1,Le=h("BROWSER_PERSISTENT_USER_DATA_DIR")??re.join(process.cwd(),"browser-devtools-mcp"),ke=_("BROWSER_USE_INSTALLED_ON_SYSTEM")??!1,Be=h("BROWSER_EXECUTABLE_PATH"),Fe=h("BROWSER_LOCALE"),Ve=x("BROWSER_CONSOLE_MESSAGES_BUFFER_SIZE")??1e3,We=x("BROWSER_HTTP_REQUESTS_BUFFER_SIZE")??1e3,V=x("NODE_CONSOLE_MESSAGES_BUFFER_SIZE")??1e3,Ue=_("OTEL_ENABLE")??!1,$e=h("OTEL_SERVICE_NAME")??"frontend",Ge=h("OTEL_SERVICE_VERSION"),ze=h("OTEL_ASSETS_DIR"),He=h("OTEL_INSTRUMENTATION_USER_INTERACTION_EVENTS")?.split(",")??["click"],Ke=h("OTEL_EXPORTER_TYPE")??"none",qe=h("OTEL_EXPORTER_HTTP_URL"),Ze=se(h("OTEL_EXPORTER_HTTP_HEADERS")),Xe=h("AWS_REGION"),je=h("AWS_PROFILE"),Je=_("AMAZON_BEDROCK_ENABLE")??!1,Ye=h("AMAZON_BEDROCK_IMAGE_EMBED_MODEL_ID"),Qe=h("AMAZON_BEDROCK_TEXT_EMBED_MODEL_ID"),et=h("AMAZON_BEDROCK_VISION_MODEL_ID"),tt=h("FIGMA_ACCESS_TOKEN")??"",nt=h("FIGMA_API_BASE_URL")??"https://api.figma.com/v1",rt=x("DAEMON_PORT")??2020,st=x("DAEMON_SESSION_IDLE_SECONDS")??300,it=x("DAEMON_SESSION_IDLE_CHECK_SECONDS")??30;var K=(i=>(i.ALL="all",i.DEBUG="debug",i.INFO="info",i.WARNING="warning",i.ERROR="error",i))(K||{});var q={all:{code:-1},debug:{code:0},info:{code:1},warning:{code:2},error:{code:3}},ie=(o=>(o.GET="GET",o.POST="POST",o.PUT="PUT",o.PATCH="PATCH",o.DELETE="DELETE",o.HEAD="HEAD",o.OPTIONS="OPTIONS",o))(ie||{}),oe=(d=>(d.DOCUMENT="document",d.STYLESHEET="stylesheet",d.IMAGE="image",d.MEDIA="media",d.FONT="font",d.SCRIPT="script",d.TEXTTRACK="texttrack",d.XHR="xhr",d.FETCH="fetch",d.EVENTSOURCE="eventsource",d.WEBSOCKET="websocket",d.MANIFEST="manifest",d.OTHER="other",d))(oe||{});var A="[BROWSER-DEVTOOLS]",O=!0,ae=process.env.DEBUG_ENABLE==="true";function T(){return`${new Date().toLocaleTimeString(void 0,{hour:"numeric",minute:"numeric",second:"numeric",hour12:!1,timeZoneName:"short"})}`}u(T,"_timeAsString");function M(...r){return Z()?r:(r||[]).map(e=>e?e instanceof Error||e.name&&e.message&&e.stack?`${e.name}: ${e.message}`:e:"")}u(M,"_normalizeArgs");function ut(){O=!0}u(ut,"enable");function lt(){O=!1}u(lt,"disable");function Z(){return ae}u(Z,"isDebugEnabled");function N(...r){O&&Z()&&console.debug(A,T(),"|","DEBUG","-",...M(...r))}u(N,"debug");function pt(...r){O&&console.info(A,T(),"|","INFO ","-",...M(...r))}u(pt,"info");function dt(...r){O&&console.warn(A,T(),"|","WARN ","-",...M(...r))}u(dt,"warn");function mt(...r){O&&console.error(A,T(),"|","ERROR","-",...M(...r))}u(mt,"error");function ce(){let r=new WeakSet;return(e,t)=>{if(typeof t=="object"&&t!==null){if(r.has(t))return;r.add(t)}return t}}u(ce,"_getCircularReplacer");function gt(r){return JSON.stringify(r,ce())}u(gt,"toJson");var X="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",j=new Map;for(let r=0;r<X.length;r++)j.set(X[r],r);function le(r){let e=[],t=0,n=0;for(let s of r){let i=j.get(s);if(i===void 0)throw new Error(`Invalid base64 character: ${s}`);let c=(i&32)!==0;if(n+=(i&31)<<t,c)t+=5;else{let o=(n&1)!==0;n=n>>1,o&&(n=-n),e.push(n),n=0,t=0}}return e}u(le,"_decodeVLQ");function pe(r,e){let t=[],n=r.split(";"),s=0,i=0,c=0,o=0,p=0;for(let a of n){let l=0,b=a.split(",");for(let g of b){if(!g)continue;let d=le(g);if(d.length===0)continue;l+=d[0];let S={generatedLine:s,generatedColumn:l};d.length>=4&&(i+=d[1],c+=d[2],o+=d[3],S.source=e[i],S.originalLine=c,S.originalColumn=o,d.length>=5&&(p+=d[4])),t.push(S)}s++}return t}u(pe,"_parseMappings");var L=class{static{u(this,"SourceMapResolver")}scripts=new Map;scriptsByUrl=new Map;sourceToScripts=new Map;fetchCache=new Map;page;customFetcher;constructor(e){typeof e=="function"?this.customFetcher=e:this.page=e}registerScript(e){let t={scriptId:e.scriptId,url:e.url,sourceMapURL:e.sourceMapURL,originalSources:[]};if(this.scripts.set(e.scriptId,t),e.url){let n=this.scriptsByUrl.get(e.url)||[];n.push(t),this.scriptsByUrl.set(e.url,n)}}async loadSourceMap(e){let t=this.scripts.get(e);if(!t||!t.sourceMapURL)return!1;if(t.sourceMap)return!0;try{let n=await this._fetchSourceMap(t.sourceMapURL,t.url);if(!n)return!1;t.sourceMap=n,t.mappings=pe(n.mappings,n.sources),t.originalSources=n.sources.map(s=>this._resolveSourcePath(s,n.sourceRoot,t.url));for(let s of t.originalSources){let i=this.sourceToScripts.get(s)||[];i.push(t),this.sourceToScripts.set(s,i)}return!0}catch(n){return N(`Failed to load source map for ${t.url}:`,n),!1}}async loadAllSourceMaps(){let e=0;for(let t of this.scripts.keys())await this.loadSourceMap(t)&&e++;return e}originalToGenerated(e,t,n=0){let s=this._normalizeSourcePath(e),i=this._findScriptsForSource(s);if(i.length!==0)for(let c of i){if(!c.mappings)continue;let o=c.originalSources.findIndex(l=>this._normalizeSourcePath(l)===s||l.endsWith(s)||s.endsWith(l));if(o===-1)continue;let p,a=1/0;for(let l of c.mappings)if(l.source===c.sourceMap?.sources[o]&&l.originalLine!==void 0&&l.originalLine===t){let b=l.originalColumn!==void 0?Math.abs(l.originalColumn-n):0;b<a&&(a=b,p=l)}if(p)return{scriptId:c.scriptId,location:{line:p.generatedLine,column:p.generatedColumn}}}}async resolveLocationByUrl(e,t,n=1){let s=Math.max(0,t-1),i=Math.max(0,n-1),c=this.scriptsByUrl.get(e)||[];if(c.length===0)for(let o of this.scripts.values())(o.url===e||o.url.endsWith(e)||e.endsWith(o.url))&&c.push(o);for(let o of c){if(!await this.loadSourceMap(o.scriptId)||!o.mappings)continue;let a=this.generatedToOriginal(o.scriptId,s,i);if(a)return a}return null}generatedToOriginal(e,t,n=0){let s=this.scripts.get(e);if(!s?.mappings)return;let i,c=1/0;for(let o of s.mappings){if(o.generatedLine!==t||o.source===void 0)continue;let p=Math.abs(o.generatedColumn-n);p<c&&(c=p,i=o)}if(i&&i.source!==void 0&&i.originalLine!==void 0){let o=s.sourceMap?.sources.indexOf(i.source);return{source:o!==void 0&&o>=0?s.originalSources[o]:i.source,line:i.originalLine,column:i.originalColumn??0,name:i.name}}}getOriginalSources(){return Array.from(this.sourceToScripts.keys())}findScriptsForSource(e){let t=this._normalizeSourcePath(e);return this._findScriptsForSource(t)}hasSourceMaps(){for(let e of this.scripts.values())if(e.sourceMap)return!0;return!1}clear(){this.scripts.clear(),this.scriptsByUrl.clear(),this.sourceToScripts.clear(),this.fetchCache.clear()}_findScriptsForSource(e){let t=this.sourceToScripts.get(e);if(t&&t.length>0)return t;let n=[];for(let[s,i]of this.sourceToScripts.entries()){let c=this._normalizeSourcePath(s);(c.endsWith(e)||e.endsWith(c))&&n.push(...i)}return n}_normalizeSourcePath(e){let t=e.replace(/^webpack:\/\/[^/]*\//,"").replace(/^file:\/\//,"").replace(/^\.*\//,"");for(t=t.replace(/\\/g,"/");t.startsWith("./");)t=t.slice(2);return t}_resolveSourcePath(e,t,n){return e.startsWith("webpack://")||e.startsWith("http://")||e.startsWith("https://")||t&&(e=t.replace(/\/$/,"")+"/"+e),e}async _fetchSourceMap(e,t){if(e.startsWith("data:"))return this._parseDataUrl(e);let n=this._resolveUrl(e,t);if(this.fetchCache.has(n))return this.fetchCache.get(n)||null;try{let s=null;if(this.customFetcher){let i=await this.customFetcher(n,t);i&&(s=JSON.parse(i))}else this.page&&(s=await this._fetchViaBrowser(n));return this.fetchCache.set(n,s),s}catch(s){return N(`Failed to fetch source map from ${n}:`,s),this.fetchCache.set(n,null),null}}_parseDataUrl(e){try{let t=e.match(/^data:[^,]*(?:;base64)?,(.*)$/);if(!t)return null;let n=e.includes(";base64,"),s=t[1],i=n?Buffer.from(s,"base64").toString("utf-8"):decodeURIComponent(s);return JSON.parse(i)}catch{return null}}_resolveUrl(e,t){if(e.startsWith("http://")||e.startsWith("https://"))return e;try{return new URL(e,t).href}catch{return t.replace(/[^/]*$/,"")+e}}async _fetchViaBrowser(e){if(!this.page)return null;try{let t=await this.page.evaluate(async n=>{try{let s=await fetch(n);return s.ok?{data:await s.text()}:{error:`HTTP ${s.status}`}}catch(s){return{error:s.message||"Fetch failed"}}},e);return"error"in t?(N(`Browser fetch error for ${e}: ${t.error}`),null):JSON.parse(t.data)}catch(t){return N(`Failed to fetch ${e} via browser:`,t),null}}};var de={maxDepth:3,maxProperties:50,maxArrayLength:100,maxStringLength:1e3},k=class{static{u(this,"V8Api")}cdp=null;enabled=!1;scripts=new Map;scriptsByUrl=new Map;eventHandlers={};options;cdpProvider;constructor(e,t){if(this.options={...de,...t},typeof e=="function")this.cdpProvider=e;else if(e&&typeof e.context=="function"){let n=e;this.cdpProvider=async()=>await n.context().newCDPSession(n)}else if(e&&typeof e.send=="function"){let n=e;this.cdp=n,this.cdpProvider=async()=>n}else throw new Error("V8Api: Invalid source. Expected Page, CDPSessionProvider, or ICDPSession.")}getOptions(){return{...this.options}}isEnabled(){return this.enabled}async getCdp(){return this.cdp||(this.cdp=await this.cdpProvider()),this.cdp}on(e,t){this.eventHandlers[e]=t}off(e){delete this.eventHandlers[e]}async enable(){if(this.enabled)return;let e=await this.getCdp();e.on("Debugger.scriptParsed",t=>{let n=t;if(this.scripts.set(n.scriptId,n),n.url){let s=this.scriptsByUrl.get(n.url)||[];s.push(n),this.scriptsByUrl.set(n.url,s)}this.eventHandlers.scriptParsed&&this.eventHandlers.scriptParsed(n)}),e.on("Debugger.paused",t=>{let n=t;this.eventHandlers.paused&&this.eventHandlers.paused(n)}),e.on("Debugger.resumed",()=>{this.eventHandlers.resumed&&this.eventHandlers.resumed()}),await e.send("Debugger.enable",{maxScriptsCacheSize:1e8}),await e.send("Runtime.enable"),this.enabled=!0}async disable(){if(!(!this.enabled||!this.cdp)){try{await this.cdp.send("Debugger.disable"),await this.cdp.send("Runtime.disable")}catch{}this.scripts.clear(),this.scriptsByUrl.clear(),this.enabled=!1}}async detach(){if(await this.disable(),this.cdp){try{await this.cdp.detach()}catch{}this.cdp=null}}getScripts(){return Array.from(this.scripts.values())}getScript(e){return this.scripts.get(e)}findScriptsByUrl(e){let t=new RegExp(e),n=[];for(let s of this.scripts.values())s.url&&t.test(s.url)&&n.push(s);return n}async setBreakpointByUrl(e){let t=await this.getCdp(),n={lineNumber:e.lineNumber};e.urlRegex?n.urlRegex=e.urlRegex:e.url&&(n.url=e.url),e.columnNumber!==void 0&&(n.columnNumber=e.columnNumber),e.condition&&(n.condition=e.condition);let s=await t.send("Debugger.setBreakpointByUrl",n);return{breakpointId:s.breakpointId,locations:s.locations||[]}}async setBreakpoint(e,t){let n=await this.getCdp(),s={location:{scriptId:e.scriptId,lineNumber:e.lineNumber,columnNumber:e.columnNumber}};t&&(s.condition=t);let i=await n.send("Debugger.setBreakpoint",s);return{breakpointId:i.breakpointId,actualLocation:i.actualLocation}}async removeBreakpoint(e){await(await this.getCdp()).send("Debugger.removeBreakpoint",{breakpointId:e})}async resume(){await(await this.getCdp()).send("Debugger.resume")}async stepOver(){await(await this.getCdp()).send("Debugger.stepOver")}async stepInto(){await(await this.getCdp()).send("Debugger.stepInto")}async stepOut(){await(await this.getCdp()).send("Debugger.stepOut")}async pause(){await(await this.getCdp()).send("Debugger.pause")}async setPauseOnExceptions(e){await(await this.getCdp()).send("Debugger.setPauseOnExceptions",{state:e})}async evaluateOnCallFrame(e,t,n){let i=await(await this.getCdp()).send("Debugger.evaluateOnCallFrame",{callFrameId:e,expression:t,returnByValue:n?.returnByValue??!0,generatePreview:n?.generatePreview??!0,throwOnSideEffect:n?.throwOnSideEffect??!1});return{result:i.result,exceptionDetails:i.exceptionDetails}}async getProperties(e,t){let s=await(await this.getCdp()).send("Runtime.getProperties",{objectId:e,ownProperties:t?.ownProperties??!0,accessorPropertiesOnly:t?.accessorPropertiesOnly??!1,generatePreview:t?.generatePreview??!0});return{result:s.result||[],internalProperties:s.internalProperties,privateProperties:s.privateProperties}}async getScopeVariables(e,t){if(!e.object.objectId)return{};let n={maxDepth:t?.maxDepth??this.options.maxDepth,maxProperties:t?.maxProperties??this.options.maxProperties,maxArrayLength:t?.maxArrayLength??this.options.maxArrayLength},{result:s}=await this.getProperties(e.object.objectId,{ownProperties:!0,generatePreview:!0}),i={},c=new Set,o=0;for(let p of s){if(o>=n.maxProperties){i.__truncated__=`${s.length-o} more properties`;break}p.value&&(i[p.name]=await this.extractValueDeep(p.value,n.maxDepth,n.maxProperties,n.maxArrayLength,c),o++)}return i}extractValue(e){return this._extractValueShallow(e)}async extractValueDeep(e,t,n,s,i=new Set){let c=t??this.options.maxDepth,o=n??this.options.maxProperties,p=s??this.options.maxArrayLength;if(e.value!==void 0)return typeof e.value=="string"&&e.value.length>this.options.maxStringLength?e.value.slice(0,this.options.maxStringLength)+`... (${e.value.length} chars)`:e.value;if(e.unserializableValue)return e.unserializableValue==="NaN"?NaN:e.unserializableValue==="Infinity"?1/0:e.unserializableValue==="-Infinity"?-1/0:e.unserializableValue==="-0"?-0:e.unserializableValue.endsWith("n")?`BigInt(${e.unserializableValue.slice(0,-1)})`:e.unserializableValue;if(e.subtype==="null")return null;if(e.type!=="undefined"){if(e.type==="function")return`[function${e.description?`: ${e.description.split(`
2
+ `)[0]}`:""}]`;if(!e.objectId)return this._extractValueShallow(e);if(c<=0)return this._getShallowDescription(e);if(i.has(e.objectId))return"[Circular]";i.add(e.objectId);try{return e.subtype==="array"?await this._extractArray(e.objectId,c-1,o,p,i):e.subtype==="map"?await this._extractMap(e.objectId,c-1,o,p,i):e.subtype==="set"?await this._extractSet(e.objectId,c-1,p,i):e.subtype==="date"?e.description||"[Date]":e.subtype==="regexp"?e.description||"[RegExp]":e.subtype==="error"?e.description||"[Error]":e.subtype==="promise"?`[Promise: ${e.description||"pending"}]`:e.subtype==="node"||e.className?.includes("Element")||e.className?.includes("Node")?`[DOM: ${e.description||e.className||"Node"}]`:e.type==="object"?await this._extractObject(e.objectId,c-1,o,p,i,e.className):this._extractValueShallow(e)}catch{return this._getShallowDescription(e)}}}async _extractArray(e,t,n,s,i){let{result:c}=await this.getProperties(e,{ownProperties:!0,generatePreview:!0}),o=[],p=0;for(let a of c)if(a.name==="length"&&a.value?.value!==void 0){p=a.value.value;break}for(let a of c){let l=parseInt(a.name,10);if(!(isNaN(l)||l<0)){if(o.length>=s)break;a.value&&(o[l]=await this.extractValueDeep(a.value,t,n,s,i))}}return p>s&&(o.__truncated__=`${p-s} more items`),o}async _extractMap(e,t,n,s,i){let{internalProperties:c}=await this.getProperties(e,{ownProperties:!0,generatePreview:!0}),o={__type__:"Map"},p=[],a=c?.find(l=>l.name==="[[Entries]]");if(a?.value?.objectId){let{result:l}=await this.getProperties(a.value.objectId,{ownProperties:!0,generatePreview:!0}),b=0;for(let g of l){if(b>=s)break;let d=parseInt(g.name,10);if(isNaN(d)||!g.value?.objectId)continue;let{result:S}=await this.getProperties(g.value.objectId,{ownProperties:!0,generatePreview:!0}),v=S.find(E=>E.name==="key"),P=S.find(E=>E.name==="value");if(v?.value&&P?.value){let E=await this.extractValueDeep(v.value,t,n,s,i),f=await this.extractValueDeep(P.value,t,n,s,i);p.push([E,f])}b++}}return o.entries=p,o}async _extractSet(e,t,n,s){let{internalProperties:i}=await this.getProperties(e,{ownProperties:!0,generatePreview:!0}),c={__type__:"Set"},o=[],p=i?.find(a=>a.name==="[[Entries]]");if(p?.value?.objectId){let{result:a}=await this.getProperties(p.value.objectId,{ownProperties:!0,generatePreview:!0}),l=0;for(let b of a){if(l>=n)break;let g=parseInt(b.name,10);isNaN(g)||(b.value&&o.push(await this.extractValueDeep(b.value,t,50,n,s)),l++)}}return c.values=o,c}async _extractObject(e,t,n,s,i,c){let{result:o}=await this.getProperties(e,{ownProperties:!0,generatePreview:!0}),p={};c&&c!=="Object"&&(p.__class__=c);let a=0;for(let l of o){if(a>=n){p.__truncated__=`${o.length-a} more properties`;break}l.isOwn&&(l.name.startsWith("__")&&l.name.endsWith("__")||l.value&&(p[l.name]=await this.extractValueDeep(l.value,t,n,s,i),a++))}return p}_extractValueShallow(e){if(e.value!==void 0)return e.value;if(e.unserializableValue)return e.unserializableValue==="NaN"?NaN:e.unserializableValue==="Infinity"?1/0:e.unserializableValue==="-Infinity"?-1/0:e.unserializableValue==="-0"?-0:e.unserializableValue.endsWith("n")?`BigInt(${e.unserializableValue.slice(0,-1)})`:e.unserializableValue;if(e.subtype==="null")return null;if(e.type!=="undefined")return this._getShallowDescription(e)}_getShallowDescription(e){if(e.description){let t=e.description.split(`
3
+ `)[0];return t.length>100?`[${e.type}${e.subtype?`:${e.subtype}`:""}] ${t.slice(0,100)}...`:`[${e.type}${e.subtype?`:${e.subtype}`:""}] ${t}`}return`[${e.type}${e.subtype?`:${e.subtype}`:""}]`}async getScriptSource(e){return await(await this.getCdp()).send("Debugger.getScriptSource",{scriptId:e})}async setScriptSource(e,t,n){let i=await(await this.getCdp()).send("Debugger.setScriptSource",{scriptId:e,scriptSource:t,dryRun:n??!1});return{callFrames:i.callFrames,stackChanged:i.stackChanged,asyncStackTrace:i.asyncStackTrace,exceptionDetails:i.exceptionDetails}}};import*as J from"node:fs";import*as me from"node:http";import*as ge from"node:https";import*as R from"node:path";var fe=(t=>(t.TRACEPOINT="tracepoint",t.LOGPOINT="logpoint",t))(fe||{}),W={maxSnapshots:1e3,maxCallStackDepth:20,maxFramesWithScopes:5,maxAsyncStackSegments:10,maxFramesPerAsyncSegment:10},m=new Map;function U(){let r=Date.now(),e=Math.floor(Math.random()*1e6);return`${r.toString(36)}-${e.toString(36)}`}u(U,"_generateId");function be(r){switch(r){case"error":return"error";case"warning":case"warn":return"warning";case"info":return"info";case"debug":return"debug";default:return"info"}}u(be,"_cdpConsoleTypeToLevelName");function Se(r){return!r||r.length===0?"":r.map(e=>e.type==="string"&&e.value!==void 0||e.value!==void 0?String(e.value):e.description?e.description:"[object]").join(" ")}u(Se,"_cdpArgsToText");function he(r,e){try{let t=r.trim();return/^[=<>!%]/.test(t)&&(t=`hitCount ${t}`),!!new Function("hitCount",`return (${t});`)(e)}catch{return!1}}u(he,"_evaluateHitCondition");async function Ee(r){let e=`(function(){
4
+ try {
5
+ var api = require('@opentelemetry/api');
6
+ var span = api.trace.getActiveSpan();
7
+ if (!span) return null;
8
+ var ctx = span.spanContext();
9
+ return ctx.traceId && ctx.spanId ? { traceId: ctx.traceId, spanId: ctx.spanId } : null;
10
+ } catch (e) {
11
+ return null;
12
+ }
13
+ })()`;try{let t=await r.send("Runtime.evaluate",{expression:e,returnByValue:!0,timeout:500});if(t.exceptionDetails)return null;let n=t.result?.value;if(n&&typeof n.traceId=="string"&&typeof n.spanId=="string")return{traceId:n.traceId,spanId:n.spanId}}catch{}return null}u(Ee,"_getOtelTraceContext");function ye(){return async(r,e)=>{let t=null;if(r.startsWith("file://"))t=r.replace("file://","");else if(r.startsWith("/")||r.match(/^[a-zA-Z]:\\/))t=r;else if(e.startsWith("file://")){let n=R.dirname(e.replace("file://",""));t=R.resolve(n,r)}else if(!r.startsWith("http://")&&!r.startsWith("https://")){let n=R.dirname(e.replace(/^file:\/\//,""));t=R.resolve(n,r)}if(t)try{return J.readFileSync(t,"utf-8")}catch{}return r.startsWith("http://")||r.startsWith("https://")?new Promise(n=>{let i=(r.startsWith("https://")?ge:me).get(r,c=>{if(c.statusCode!==200){n(null);return}let o="";c.on("data",p=>{o+=p}),c.on("end",()=>n(o))});i.on("error",()=>n(null)),i.setTimeout(5e3,()=>{i.destroy(),n(null)})}):null}}u(ye,"_createNodeSourceMapFetcher");async function xe(r,e,t=3){let n=[];for(let s of e.scopeChain)if(!(s.type==="global"||s.type==="script"||s.type==="with"||s.type==="eval"||s.type==="wasm-expression-stack")){if(n.length>=t)break;try{let i=await r.getScopeVariables(s),c=[];for(let[o,p]of Object.entries(i))c.push({name:o,value:p,type:typeof p});n.push({type:s.type,name:s.name,variables:c})}catch{}}return n}u(xe,"_captureScopes");async function ve(r,e,t,n){let s=[];t&&(s=await xe(r,e));let i;if(n){let c=n.generatedToOriginal(e.location.scriptId,e.location.lineNumber,e.location.columnNumber??0);c&&(i={source:c.source,line:c.line+1,column:c.column!==void 0?c.column+1:void 0,name:c.name})}return{functionName:e.functionName||"(anonymous)",url:e.url||"",lineNumber:e.location.lineNumber+1,columnNumber:e.location.columnNumber!==void 0?e.location.columnNumber+1:void 0,scriptId:e.location.scriptId,scopes:s,originalLocation:i}}u(ve,"_callFrameToSnapshot");function Pe(r,e,t,n){if(!r)return;let s=t??W.maxAsyncStackSegments,i=n??W.maxFramesPerAsyncSegment,c=[],o=r,p=0;for(;o&&p<s;){let a=[];for(let l of o.callFrames.slice(0,i)){let b;if(e){let g=e.generatedToOriginal(l.location.scriptId,l.location.lineNumber,l.location.columnNumber??0);g&&(b={source:g.source,line:g.line+1,column:g.column!==void 0?g.column+1:void 0,name:g.name})}a.push({functionName:l.functionName||"(anonymous)",url:l.url||"",lineNumber:l.location.lineNumber+1,columnNumber:l.location.columnNumber!==void 0?l.location.columnNumber+1:void 0,originalLocation:b})}a.length>0&&c.push({description:o.description,callFrames:a}),o=o.parent,p++}return c.length===0?void 0:{segments:c}}u(Pe,"_convertAsyncStackTrace");async function Ie(r,e,t){let n={};for(let s of t.values())try{let i=await r.evaluateOnCallFrame(e,s.expression);i.exceptionDetails?n[s.expression]=`[Error: ${i.exceptionDetails.text||"Evaluation failed"}]`:n[s.expression]=await r.extractValueDeep(i.result,2)}catch(i){n[s.expression]=`[Error: ${i.message||"Unknown error"}]`}return n}u(Ie,"_evaluateWatchExpressionsOnFrame");function Lt(r,e){return e||`pid:${r}`}u(Lt,"getStoreKey");async function kt(r,e,t,n,s){if(m.get(r)?.enabled)return;let c=new k(e,n),o=new L(ye()),p={...W,...s},a={v8Api:c,sourceMapResolver:o,probes:new Map,watchExpressions:new Map,snapshots:[],snapshotSequence:0,consoleMessages:[],consoleMessageSequence:0,config:p,enabled:!1,sourceMapsLoaded:!1,exceptionBreakpoint:"none",session:e,processInfo:t};m.set(r,a),await a.v8Api.enable(),e.on("Runtime.consoleAPICalled",l=>{let b=l.type||"log",g=l.args||[],d=Se(g),S=be(b),v=q[S]?.code??1,P,E=l.stackTrace;if(E?.callFrames?.length){let f=E.callFrames[0];P={url:f.url||"",lineNumber:f.lineNumber??0,columnNumber:f.columnNumber??0}}a.consoleMessageSequence++,a.consoleMessages.push({type:b,text:d,level:{name:S,code:v},location:P,timestamp:Date.now(),sequenceNumber:a.consoleMessageSequence}),a.consoleMessages.length>V&&a.consoleMessages.splice(0,a.consoleMessages.length-V)}),a.v8Api.on("scriptParsed",l=>{a.sourceMapResolver.registerScript(l)});for(let l of a.v8Api.getScripts())a.sourceMapResolver.registerScript(l);a.v8Api.on("paused",async l=>{let b=Date.now();try{let g=l.reason==="exception"||l.reason==="promiseRejection",d=l.hitBreakpoints||[],S,v=!0;for(let f of a.probes.values()){if(!f.enabled)continue;if(f.v8BreakpointIds.some(D=>d.includes(D))){S=f,f.hitCondition&&(v=he(f.hitCondition,f.hitCount+1));break}}let P=S!==void 0&&v,E=g&&a.exceptionBreakpoint!=="none";if(S&&(S.hitCount++,S.lastHitAt=Date.now()),(P||E)&&l.callFrames.length>0){let f=l.callFrames[0],w;if(S?.kind==="logpoint"&&S.logExpression)try{let y=await a.v8Api.evaluateOnCallFrame(f.callFrameId,S.logExpression,{returnByValue:!0,generatePreview:!0});w=a.v8Api.extractValue(y.result)}catch{w="[evaluation error]"}let D;if(g&&l.data){let y=l.data;D={type:l.reason==="promiseRejection"?"promiseRejection":"exception",message:y.description||y.value||String(y),name:y.className,stack:y.description}}let $,I=a.sourceMapResolver.generatedToOriginal(f.location.scriptId,f.location.lineNumber,f.location.columnNumber??0);I&&($={source:I.source,line:I.line+1,column:I.column!==void 0?I.column+1:void 0,name:I.name});let Y=S?.id??"__exception__",B=S?.kind==="logpoint",G=[];if(!B){let y=l.callFrames.slice(0,a.config.maxCallStackDepth);for(let C=0;C<y.length;C++){let te=await ve(a.v8Api,y[C],C<a.config.maxFramesWithScopes,a.sourceMapResolver);G.push(te)}}let z;B||(z=Pe(l.asyncStackTrace,a.sourceMapResolver,a.config.maxAsyncStackSegments,a.config.maxFramesPerAsyncSegment));let H;!B&&a.watchExpressions.size>0&&(H=await Ie(a.v8Api,f.callFrameId,a.watchExpressions));let Q=await Ee(a.session),ee={id:U(),probeId:Y,timestamp:Date.now(),sequenceNumber:++a.snapshotSequence,url:f.url||"",lineNumber:f.location.lineNumber+1,columnNumber:f.location.columnNumber!==void 0?f.location.columnNumber+1:void 0,originalLocation:$,exception:D,callStack:G,asyncStackTrace:z,logResult:w,watchResults:H,captureTimeMs:Date.now()-b,traceContext:Q??void 0};a.snapshots.push(ee),a.snapshots.length>a.config.maxSnapshots&&a.snapshots.splice(0,a.snapshots.length-a.config.maxSnapshots)}}finally{await a.v8Api.resume()}}),a.enabled=!0,a.sourceMapResolver.loadAllSourceMaps().then(()=>{a.sourceMapsLoaded=!0}).catch(()=>{})}u(kt,"enableDebugging");async function _e(r){let e=m.get(r);if(e?.enabled){for(let t of e.probes.values())for(let n of t.v8BreakpointIds)try{await e.v8Api.removeBreakpoint(n)}catch{}e.probes.clear(),e.snapshots.length=0,e.snapshotSequence=0,e.consoleMessages.length=0,e.consoleMessageSequence=0,await e.v8Api.disable(),e.enabled=!1}}u(_e,"disableDebugging");async function Bt(r){let e=m.get(r);e&&(await _e(r),await e.v8Api.detach(),m.delete(r))}u(Bt,"detachDebugging");function Ft(r){return m.get(r)?.enabled??!1}u(Ft,"isDebuggingEnabled");function Vt(r){return m.get(r)}u(Vt,"getStore");async function Wt(r,e,t,n=1){let s=m.get(r);if(!s?.enabled)throw new Error("Not connected to Node.js process or debugging not enabled. Call debug_connect first.");let i=await s.sourceMapResolver.resolveLocationByUrl(e,t,n);return i?{source:i.source,line:i.line+1,column:i.column+1,name:i.name}:null}u(Wt,"resolveSourceLocation");function Ut(){return Array.from(m.keys())}u(Ut,"listStoreKeys");async function $t(r,e){let t=m.get(r);if(!t?.enabled)throw new Error("Debugging is not enabled");await t.v8Api.setPauseOnExceptions(e),t.exceptionBreakpoint=e}u($t,"setExceptionBreakpoint");function Gt(r){return m.get(r)?.exceptionBreakpoint??"none"}u(Gt,"getExceptionBreakpoint");async function zt(r,e){let t=m.get(r);if(!t?.enabled)throw new Error("Debugging is not enabled");let n=U(),s=e.condition?`(${e.condition})`:"true",i=e.lineNumber-1,c=(e.columnNumber??1)-1,o=t.sourceMapResolver.originalToGenerated(e.urlPattern,i,c),p,a=0;if(o)p=(await t.v8Api.setBreakpoint({scriptId:o.scriptId,lineNumber:o.location.line,columnNumber:o.location.column},s)).breakpointId,a=1;else{let g=e.urlPattern.replace(/\\([.*+?^${}()|[\]\\/-])/g,"$1").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\*/g,".*").replace(/\\\?/g,"."),d=await t.v8Api.setBreakpointByUrl({urlRegex:g,lineNumber:e.lineNumber-1,columnNumber:e.columnNumber?e.columnNumber-1:void 0,condition:s});p=d.breakpointId,a=d.locations.length}let l={id:n,kind:e.kind,enabled:!0,urlPattern:e.urlPattern,lineNumber:e.lineNumber,columnNumber:e.columnNumber,condition:e.condition,logExpression:e.logExpression,hitCondition:e.hitCondition,v8BreakpointIds:[p],resolvedLocations:a,hitCount:0,createdAt:Date.now()};return t.probes.set(n,l),l}u(zt,"createProbe");async function Ht(r,e){let t=m.get(r);if(!t)return!1;let n=t.probes.get(e);if(!n)return!1;for(let s of n.v8BreakpointIds)try{await t.v8Api.removeBreakpoint(s)}catch{}return t.probes.delete(e),!0}u(Ht,"removeProbe");function Kt(r){return Array.from(m.get(r)?.probes.values()??[])}u(Kt,"listProbes");async function qt(r){let e=m.get(r);if(!e)return 0;let t=e.probes.size;for(let n of e.probes.values())for(let s of n.v8BreakpointIds)try{await e.v8Api.removeBreakpoint(s)}catch{}return e.probes.clear(),t}u(qt,"clearProbes");function Zt(r){return[...m.get(r)?.snapshots??[]]}u(Zt,"getSnapshots");function Xt(r,e){return(m.get(r)?.snapshots??[]).filter(t=>t.probeId===e)}u(Xt,"getSnapshotsByProbe");function jt(r){let e=m.get(r);if(!e)return 0;let t=e.snapshots.length;return e.snapshots.length=0,t}u(jt,"clearSnapshots");function Jt(r,e){let t=m.get(r);if(!t)return 0;let n=t.snapshots.length;return t.snapshots=t.snapshots.filter(s=>s.probeId!==e),n-t.snapshots.length}u(Jt,"clearSnapshotsByProbe");function Yt(r){let e=m.get(r);if(!e||e.snapshots.length===0)return{totalSnapshots:0,snapshotsByProbe:{},averageCaptureTimeMs:0};let t={},n=0;for(let s of e.snapshots)t[s.probeId]=(t[s.probeId]||0)+1,n+=s.captureTimeMs;return{totalSnapshots:e.snapshots.length,snapshotsByProbe:t,oldestTimestamp:e.snapshots[0].timestamp,newestTimestamp:e.snapshots[e.snapshots.length-1].timestamp,averageCaptureTimeMs:n/e.snapshots.length}}u(Yt,"getSnapshotStats");function Qt(r){return[...m.get(r)?.consoleMessages??[]]}u(Qt,"getConsoleMessages");function en(r,e){let t=m.get(r);if(!t)throw new Error("Debug store not initialized");let n=U(),s={id:n,expression:e,createdAt:Date.now()};return t.watchExpressions.set(n,s),s}u(en,"addWatchExpression");function tn(r,e){return m.get(r)?.watchExpressions.delete(e)??!1}u(tn,"removeWatchExpression");function nn(r){return Array.from(m.get(r)?.watchExpressions.values()??[])}u(nn,"listWatchExpressions");function rn(r){let e=m.get(r);if(!e)return 0;let t=e.watchExpressions.size;return e.watchExpressions.clear(),t}u(rn,"clearWatchExpressions");async function sn(r){let e=m.get(r);if(!e?.enabled)throw new Error("Debugging is not enabled");let t=await e.sourceMapResolver.loadAllSourceMaps(),n=e.sourceMapResolver.getOriginalSources();return e.sourceMapsLoaded=!0,{loaded:t,sources:n}}u(sn,"loadSourceMaps");function on(r){return m.get(r)?.sourceMapResolver.hasSourceMaps()??!1}u(on,"hasSourceMaps");function an(r){return m.get(r)?.sourceMapResolver.getOriginalSources()??[]}u(an,"getOriginalSources");function cn(r){return m.get(r)?.v8Api.getScripts()??[]}u(cn,"getScripts");async function un(r,e,t=5e3){let n=m.get(r);if(!n?.enabled)throw new Error("Not connected to Node.js process or debugging not enabled. Call debug_connect first.");let s=await n.session.send("Runtime.evaluate",{expression:e,returnByValue:!0,timeout:Math.min(t,3e4)});if(s.exceptionDetails){let i=s.exceptionDetails,c=i.text??i.description??i.exception?.description;throw new Error(`Node evaluation failed: ${c??JSON.stringify(i)}`)}return n.v8Api.extractValue(s.result)}u(un,"evaluateInNode");export{u as a,Ne as b,we as c,De as d,Ce as e,Ae as f,Te as g,Me as h,Le as i,ke as j,Be as k,Fe as l,Ve as m,We as n,V as o,Ue as p,$e as q,Ge as r,ze as s,He as t,Ke as u,qe as v,Ze as w,Xe as x,je as y,Je as z,Ye as A,Qe as B,et as C,tt as D,nt as E,rt as F,st as G,it as H,ut as I,lt as J,Z as K,N as L,pt as M,dt as N,mt as O,gt as P,k as Q,L as R,K as S,q as T,ie as U,oe as V,fe as W,W as X,Lt as Y,kt as Z,_e as _,Bt as $,Ft as aa,Vt as ba,Wt as ca,Ut as da,$t as ea,Gt as fa,zt as ga,Ht as ha,Kt as ia,qt as ja,Zt as ka,Xt as la,jt as ma,Jt as na,Yt as oa,Qt as pa,en as qa,tn as ra,nn as sa,rn as ta,sn as ua,on as va,an as wa,cn as xa,un as ya};