browser-devtools-mcp 0.2.4 → 0.2.6
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 +10 -4
- package/dist/cli/runner.js +1 -1
- package/dist/{core-NLBNZBEB.js → core-4DMVQUQB.js} +103 -89
- package/dist/daemon-server.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1229,6 +1229,7 @@ The server can be configured using environment variables. Configuration is divid
|
|
|
1229
1229
|
|
|
1230
1230
|
**Parameters:**
|
|
1231
1231
|
- `selector` (string, required): CSS selector for the element to click
|
|
1232
|
+
- `timeoutMs` (number, optional): Time to wait for the element in ms (default: 10000)
|
|
1232
1233
|
</details>
|
|
1233
1234
|
|
|
1234
1235
|
<details>
|
|
@@ -1237,6 +1238,7 @@ The server can be configured using environment variables. Configuration is divid
|
|
|
1237
1238
|
**Parameters:**
|
|
1238
1239
|
- `selector` (string, required): CSS selector for the input field
|
|
1239
1240
|
- `value` (string, required): Value to fill
|
|
1241
|
+
- `timeoutMs` (number, optional): Time to wait for the element in ms (default: 10000)
|
|
1240
1242
|
</details>
|
|
1241
1243
|
|
|
1242
1244
|
<details>
|
|
@@ -1244,6 +1246,7 @@ The server can be configured using environment variables. Configuration is divid
|
|
|
1244
1246
|
|
|
1245
1247
|
**Parameters:**
|
|
1246
1248
|
- `selector` (string, required): CSS selector for the element to hover
|
|
1249
|
+
- `timeoutMs` (number, optional): Time to wait for the element in ms (default: 10000)
|
|
1247
1250
|
</details>
|
|
1248
1251
|
|
|
1249
1252
|
<details>
|
|
@@ -1255,6 +1258,7 @@ The server can be configured using environment variables. Configuration is divid
|
|
|
1255
1258
|
- `holdMs` (number, optional): Duration in milliseconds to hold the key (repeat duration if `repeat` is true)
|
|
1256
1259
|
- `repeat` (boolean, optional, default: false): If true, simulates key auto-repeat by pressing repeatedly during `holdMs`
|
|
1257
1260
|
- `repeatIntervalMs` (number, optional, default: 50, min: 10): Interval between repeated key presses in ms (only when `repeat` is true)
|
|
1261
|
+
- `timeoutMs` (number, optional): Time to wait for the element when selector is set, in ms (default: 10000)
|
|
1258
1262
|
</details>
|
|
1259
1263
|
|
|
1260
1264
|
<details>
|
|
@@ -1263,6 +1267,7 @@ The server can be configured using environment variables. Configuration is divid
|
|
|
1263
1267
|
**Parameters:**
|
|
1264
1268
|
- `selector` (string, required): CSS selector for the select element
|
|
1265
1269
|
- `value` (string, required): Value to select
|
|
1270
|
+
- `timeoutMs` (number, optional): Time to wait for the element in ms (default: 10000)
|
|
1266
1271
|
</details>
|
|
1267
1272
|
|
|
1268
1273
|
<details>
|
|
@@ -1271,6 +1276,7 @@ The server can be configured using environment variables. Configuration is divid
|
|
|
1271
1276
|
**Parameters:**
|
|
1272
1277
|
- `sourceSelector` (string, required): CSS selector for the source element
|
|
1273
1278
|
- `targetSelector` (string, required): CSS selector for the target element
|
|
1279
|
+
- `timeoutMs` (number, optional): Time to wait for source and target elements in ms (default: 10000)
|
|
1274
1280
|
</details>
|
|
1275
1281
|
|
|
1276
1282
|
<details>
|
|
@@ -1487,8 +1493,8 @@ The server can be configured using environment variables. Configuration is divid
|
|
|
1487
1493
|
- `search` (string, optional): Text to search for in messages
|
|
1488
1494
|
- `timestamp` (number, optional): Start time filter (Unix epoch milliseconds)
|
|
1489
1495
|
- `sequenceNumber` (number, optional): Only return messages after this sequence number
|
|
1490
|
-
- `limit` (object, optional): Limit results
|
|
1491
|
-
- `count` (number): Maximum number of messages
|
|
1496
|
+
- `limit` (object, optional): Limit results (default: last 100). Omit or set `count: 0` for no limit.
|
|
1497
|
+
- `count` (number, default 100): Maximum number of messages; 0 = no limit
|
|
1492
1498
|
- `from` (enum): "start" or "end" (default: "end")
|
|
1493
1499
|
|
|
1494
1500
|
**Returns:**
|
|
@@ -1506,8 +1512,8 @@ The server can be configured using environment variables. Configuration is divid
|
|
|
1506
1512
|
- `ok` (boolean, optional): Filter by success/failure (2xx = success)
|
|
1507
1513
|
- `timestamp` (number, optional): Start time filter (Unix epoch milliseconds)
|
|
1508
1514
|
- `sequenceNumber` (number, optional): Only return requests after this sequence number
|
|
1509
|
-
- `limit` (object, optional): Limit results
|
|
1510
|
-
- `count` (number): Maximum number of requests
|
|
1515
|
+
- `limit` (object, optional): Limit results (default: last 100). Omit or set `count: 0` for no limit.
|
|
1516
|
+
- `count` (number, default 100): Maximum number of requests; 0 = no limit
|
|
1511
1517
|
- `from` (enum): "start" or "end" (default: "end")
|
|
1512
1518
|
|
|
1513
1519
|
**Returns:**
|
package/dist/cli/runner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as me}from"../core-
|
|
2
|
+
import{a as me}from"../core-4DMVQUQB.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
3
|
`).map(m=>`${l}${m}`).join(`
|
|
4
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
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(`
|