@zibby/mcp-browser 0.1.9 → 0.1.11

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/LICENSE CHANGED
@@ -1,21 +1,5 @@
1
- MIT License
1
+ Copyright (c) 2026 Zibby Labs. All rights reserved.
2
2
 
3
- Copyright (c) 2026 Zibby
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
3
+ Proprietary and confidential. Unauthorized copying, distribution, or use of
4
+ this software, in whole or in part, via any medium, is strictly prohibited
5
+ without the express prior written permission of Zibby Labs.
package/README.md CHANGED
@@ -99,7 +99,8 @@ export ZIBBY_SESSION_INFO=/path/to/.session-info.json
99
99
 
100
100
  ## License
101
101
 
102
- MIT
102
+ Proprietary — Copyright (c) 2026 Zibby Labs. All rights reserved.
103
+ Unauthorized copying, distribution, or use is prohibited.
103
104
 
104
105
  ## Related Packages
105
106
 
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- var ne=Object.create;var W=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var ie=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var ae=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of se(n))!oe.call(e,t)&&t!==r&&W(e,t,{get:()=>n[t],enumerable:!(s=re(n,t))||s.enumerable});return e};var le=(e,n,r)=>(r=e!=null?ne(ie(e)):{},ae(n||!e||!e.__esModule?W(r,"default",{value:e,enumerable:!0}):r,e));const{spawn:ce,execFileSync:de}=require("child_process"),m=require("fs"),S=require("path"),A=S.join(__dirname,"..","src","stable-id-inject.js"),Y=S.join(require("os").tmpdir(),"zibby-mcp-debug.log");function i(e){const n=`[${new Date().toISOString()}] ${e}
3
- `;m.appendFileSync(Y,n),console.error(`[Zibby MCP] ${e}`)}m.appendFileSync(Y,`
2
+ var ne=Object.create;var W=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var ie=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var ae=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of se(n))!oe.call(e,t)&&t!==r&&W(e,t,{get:()=>n[t],enumerable:!(s=re(n,t))||s.enumerable});return e};var le=(e,n,r)=>(r=e!=null?ne(ie(e)):{},ae(n||!e||!e.__esModule?W(r,"default",{value:e,enumerable:!0}):r,e));const{spawn:ce,execFileSync:de}=require("child_process"),S=require("fs"),f=require("path"),x=[f.join(__dirname,"..","src","stable-id-inject.js"),f.join(__dirname,"..","stable-id-inject.js")].find(e=>S.existsSync(e))||f.join(__dirname,"..","src","stable-id-inject.js"),Y=f.join(require("os").tmpdir(),"zibby-mcp-debug.log");function i(e){const n=`[${new Date().toISOString()}] ${e}
3
+ `;S.appendFileSync(Y,n),console.error(`[Zibby MCP] ${e}`)}S.appendFileSync(Y,`
4
4
  === Zibby MCP Started ${new Date().toISOString()} PID:${process.pid} ===
5
- `),i(`Args: ${process.argv.slice(2).join(" ")}`),i(`Env ZIBBY_NODE_SESSION_PATH=${process.env.ZIBBY_NODE_SESSION_PATH||"(not set)"}`),i(`Env ZIBBY_SESSION_PATH=${process.env.ZIBBY_SESSION_PATH||"(not set)"}`),i(`Env ZIBBY_SESSION_INFO=${process.env.ZIBBY_SESSION_INFO||"(not set)"}`);let o=null,B="none";const w=[];let q=null;function fe(){if(process.env.ZIBBY_NODE_SESSION_PATH){o=process.env.ZIBBY_NODE_SESSION_PATH,B="env:ZIBBY_NODE_SESSION_PATH",m.mkdirSync(o,{recursive:!0}),i(`\u{1F4C1} Session from env: ${o}`);return}const e=process.argv.slice(2);for(const r of e)if(r.startsWith("--output-dir=")){o=r.split("=").slice(1).join("="),B="arg:--output-dir",m.mkdirSync(o,{recursive:!0}),i(`\u{1F4C1} Session from --output-dir: ${o}`);return}if(process.env.ZIBBY_SESSION_PATH){const r=S.join(process.env.ZIBBY_SESSION_PATH,".session-info.json");if(m.existsSync(r))try{const s=JSON.parse(m.readFileSync(r,"utf-8")),t=s.currentNode||"execute_live";o=S.join(s.sessionPath||process.env.ZIBBY_SESSION_PATH,t),B="file:per-session",m.mkdirSync(o,{recursive:!0}),i(`\u{1F4C1} Session from per-session file: ${o}`);return}catch(s){i(`\u26A0\uFE0F Per-session file read error: ${s.message}`)}}const n=[process.env.ZIBBY_SESSION_INFO,S.join(process.cwd(),".zibby/output/.session-info.json"),S.join(process.cwd(),"test-results/.session-info.json")].filter(Boolean);for(const r of n)if(m.existsSync(r))try{const s=JSON.parse(m.readFileSync(r,"utf-8")),t=s.currentNode||"execute_live";if(s.sessionPath){o=S.join(s.sessionPath,t),B=`file:shared(${S.basename(r)})`,m.mkdirSync(o,{recursive:!0}),i(`\u26A0\uFE0F Session from SHARED file (race-prone): ${o}`);return}}catch(s){i(`\u26A0\uFE0F Shared file read error: ${s.message}`)}i("\u26A0\uFE0F No session path resolved \u2014 events will not be recorded")}function G(e){const n=Math.floor(e/1e3),r=Math.floor(n/3600),s=Math.floor(n%3600/60),t=n%60,a=e%1e3;return`${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}:${String(t).padStart(2,"0")}.${String(a).padStart(3,"0")}`}function y(e,n){if(!o)return;const r=Date.now();q||(q=r);const s=r-q,t={id:w.length,type:e,timestamp:new Date(r).toISOString(),videoOffsetMs:s,videoOffsetFormatted:G(s),data:n,_recordedBy:"zibby-wrapper-v2"};return w.push(t),i(`\u{1F4DD} Event #${t.id}: ${e}${n.stableId?` [${n.stableId}]`:""}`),e==="close"?pe():N(),t.id}function ue(e,n){if(!o||e<0||e>=w.length)return;const r=w[e];r&&!r.data.stableId&&n&&(r.data.stableId=n,i(`\u{1F517} Event #${e} stableId: ${n}`),N())}function me(e){function a(f,d,u){if(d>=f.length)return null;const I=f[d];let b=1,z=128;for(;b<=8&&!(I&z);)b++,z>>=1;if(b>8||d+b>f.length)return null;let C=u?I:I&z-1;for(let Z=1;Z<b;Z++)C=C<<8|f[d+Z];return{value:C,length:b}}function l(f,d){if(d>=f.length)return null;const u=a(f,d,!0);if(!u)return null;d+=u.length;const I=a(f,d,!1);return I?(d+=I.length,{id:u.value,dataStart:d,dataSize:I.value,dataEnd:d+I.value}):null}function _(f,d,u){let I=0;for(let b=0;b<u;b++)I=I<<8|f[d+b];return I}function E(f,d,u){return u===4?f.readFloatBE(d):u===8?f.readDoubleBE(d):null}let c=0,p=1e6,v=null;const P=l(e,c);if(!P)return null;c=P.dataEnd;const j=l(e,c);if(!j||j.id!==408125543)return null;c=j.dataStart;const te=Math.min(j.dataEnd,e.length);for(;c<te;){const f=l(e,c);if(!f)break;if(f.id===357149030){let d=f.dataStart;for(;d<f.dataEnd;){const u=l(e,d);if(!u)break;u.id===2807729?p=_(e,u.dataStart,u.dataSize):u.id===17545&&(v=E(e,u.dataStart,u.dataSize)),d=u.dataEnd}break}c=f.dataEnd}return v!==null?v*p/1e6:null}function Se(e){try{const n=de("ffprobe",["-v","error","-show_entries","format=duration","-of","default=noprint_wrappers=1:nokey=1",e],{encoding:"utf-8",timeout:5e3}),r=parseFloat(n.trim());if(!isNaN(r)){const s=Math.round(r*1e3);return i(`\u{1F4CF} Video duration (ffprobe): ${s}ms`),s}}catch{i("\u26A0\uFE0F ffprobe not available, using WebM parser fallback")}try{const n=m.readFileSync(e),r=me(n);if(r){const s=Math.round(r);return i(`\u{1F4CF} Video duration (WebM parser): ${s}ms`),s}}catch(n){i(`\u26A0\uFE0F WebM parsing failed: ${n.message}`)}return null}function pe(){if(!o||w.length===0)return;let e=null,n=0;const r=40;let s=0,t=0;for(;!e&&n<r;){n++;let c=null;if(m.existsSync(S.join(o,"recording.webm")))c=S.join(o,"recording.webm"),n===1&&i("Found recording.webm");else try{const p=m.readdirSync(o);n===1&&i(`Directory contains ${p.length} files: ${p.join(", ")}`);const v=p.filter(P=>P.endsWith(".webm"));n===1&&v.length>0&&i(`Found ${v.length} .webm file(s): ${v.join(", ")}`),v.length>0&&(c=S.join(o,v[0]))}catch(p){n===1&&i(`\u26A0\uFE0F Error reading directory: ${p.message}`)}if(c&&m.existsSync(c))try{const v=m.statSync(c).size;if(v>0&&v===s){if(t++,t>=2){e=c,i(`\u2705 Video file stable after ${n} attempts: ${S.basename(e)} (${v} bytes)`);break}}else t=0,s=v}catch(p){i(`\u26A0\uFE0F Error checking file: ${p.message}`)}if(!e){n%5===0&&i(`\u23F3 Waiting for stable video file... (attempt ${n}/${r}, size: ${s})`);const p=Date.now();for(;Date.now()-p<500;);}}if(!e){i(`\u26A0\uFE0F Video file not found/stable after ${n} attempts in: ${o}`),N();return}const a=Se(e);if(!a){i("\u26A0\uFE0F Could not determine video duration, using fallback"),N();return}const l=w.find(c=>c.type==="close");if(!l){i("\u26A0\uFE0F No close event found"),N();return}const _=new Date(l.timestamp).getTime(),E=_-a;i(`\u{1F4CA} Calculated video start: ${new Date(E).toISOString()}`),i(` Close timestamp: ${_}ms`),i(` Video duration: ${a}ms`),w.forEach(c=>{const p=new Date(c.timestamp).getTime();c.videoOffsetMs=p-E,c.videoOffsetFormatted=G(c.videoOffsetMs)}),i(`\u2705 Recalculated ${w.length} events using accurate video start time`),N()}function N(){if(o)try{const e=S.join(o,"events.json");m.writeFileSync(e,JSON.stringify(w,null,2))}catch{}}i(`CWD: ${process.cwd()}`),fe();const U=process.argv.slice(2);let O=null;for(const e of U){const n=e.match(/^--save-video=(\d+)x(\d+)$/);if(n){O={width:parseInt(n[1],10),height:parseInt(n[2],10)};break}}const h=U.filter(e=>!e.startsWith("--save-video"));m.existsSync(A)?(h.unshift("--init-script",A),i(`\u2705 Stable ID injection enabled: ${A}`)):i(`\u26A0\uFE0F Stable ID script not found: ${A}`);const x=h.findIndex(e=>e==="--caps");if(x>=0&&h[x+1])h[x+1].includes("devtools")||(h[x+1]+=",devtools");else{const e=h.findIndex(n=>n.startsWith("--caps="));e>=0?h[e].includes("devtools")||(h[e]+=",devtools"):h.push("--caps","devtools")}if(o){const e=h.findIndex(n=>n.startsWith("--output-dir"));e!==-1?h[e]=`--output-dir=${o}`:h.push("--output-dir",o),i(`\u{1F4F9} Video output: ${o} (source: ${B})`)}const ve=S.dirname(require.resolve("@playwright/mcp")),he=S.join(ve,"cli.js"),g=ce(process.execPath,[he,...h],{stdio:["pipe","pipe","inherit"]});let $=!1,H=!1,Q=8e5;const D=new Set;function Ie(){if(H||!o)return;H=!0;const e=Q++;D.add(e);const n=o?S.join(o,"recording.webm"):"recording.webm",r={jsonrpc:"2.0",id:e,method:"tools/call",params:{name:"browser_start_video",arguments:{filename:n,...O?{size:O}:{}}}};try{g.stdin.write(JSON.stringify(r)+`
6
- `),i(`\u{1F3AC} Auto-started video recording${O?` (${O.width}x${O.height})`:""}`)}catch(s){D.delete(e),i(`\u26A0\uFE0F browser_start_video send failed: ${s.message}`)}}function _e(){if(!H)return;const e=Q++;D.add(e);const n={jsonrpc:"2.0",id:e,method:"tools/call",params:{name:"browser_stop_video",arguments:{}}};try{g.stdin.write(JSON.stringify(n)+`
7
- `),i("\u{1F3AC} Auto-stopped video recording")}catch(r){D.delete(e),i(`\u26A0\uFE0F browser_stop_video send failed: ${r.message}`)}}const ge=2e3,be=5e3,K="frames";let X=0,we=1e6;const R=new Set;let k=null;function L(){k&&(clearInterval(k),k=null)}function $e(){if(o)try{m.mkdirSync(S.join(o,K),{recursive:!0})}catch{}}function J(){return S.join(o,K,`live-frame-${Date.now()}.png`)}function ye(){L(),!(!$||!o)&&(k=setInterval(()=>{if(!$||!o){L();return}ee(!0,J())},be))}function ee(e,n){if(!o||!$)return;$e();const r=Date.now();if(!e&&r-X<ge)return;X=r;const s=n||J(),t=we++;R.add(t);const a={jsonrpc:"2.0",id:t,method:"tools/call",params:{name:"browser_take_screenshot",arguments:{type:"png",filename:s}}};try{g.stdin.write(JSON.stringify(a)+`
8
- `),i(`\u{1F4F8} live-frame queued: ${s}`)}catch(l){R.delete(t),i(`\u26A0\uFE0F live-frame send failed: ${l.message}`)}}function Ee(e){!e||typeof e!="string"||!e.startsWith("browser_")||e==="browser_close"||e==="browser_take_screenshot"||!o||!$||ee(!1,J())}const T=new Map;let Ne=9e5;const V=new Map;let F="";process.stdin.on("data",e=>{F+=e.toString();const n=F.split(`
9
- `);F=n.pop()||"";for(const r of n)if(r.trim()){try{const s=JSON.parse(r);if(s.method&&i(`\u{1F4E8} STDIN: ${s.method} ${s.params?.name||""}`),s.method==="tools/call"&&s.params){const t=s.params.name,a=s.params.arguments||{};T.set(s.id,{toolName:t,toolArgs:a});let l=-1;t==="browser_navigate"?($=!0,ye(),l=y("navigate",{url:a.url})):t==="browser_click"?l=y("click",{element:a.element,ref:a.ref}):t==="browser_type"?l=y("type",{element:a.element,ref:a.ref,text:a.text}):t==="browser_select_option"?l=y("select",{element:a.element,ref:a.ref,values:a.values}):t==="browser_fill_form"?l=y("fill_form",{fields:a.fields}):t==="browser_hover"?l=y("hover",{element:a.element,ref:a.ref}):t==="browser_close"?(_e(),l=y("close",{}),$=!1,L()):t==="browser_snapshot"&&(l=y("snapshot",{})),l>=0&&(T.get(s.id).eventId=l)}}catch{}g.stdin.write(r+`
10
- `)}}),process.stdin.on("end",()=>{F.trim()&&g.stdin.write(F+`
11
- `),g.stdin.end()});let M="";g.stdout.on("data",e=>{M+=e.toString();const n=M.split(`
12
- `);M=n.pop()||"";for(const r of n){if(!r.trim())continue;let s=!0;try{const t=JSON.parse(r);if(t.id&&D.has(t.id))D.delete(t.id),t.error&&i(`\u26A0\uFE0F Video RPC error: ${t.error?.message||JSON.stringify(t.error)}`),s=!1;else if(t.id&&R.has(t.id))R.delete(t.id),t.error&&i(`\u26A0\uFE0F Screenshot RPC error: ${t.error?.message||JSON.stringify(t.error)}`),s=!1;else if(t.id&&T.has(t.id)){const a=T.get(t.id);if(T.delete(t.id),!t.error&&$&&Ee(a.toolName),!t.error&&a.toolName==="browser_navigate"&&Ie(),!t.error&&$&&a.eventId>=0&&["browser_click","browser_type","browser_select_option","browser_fill_form","browser_hover"].includes(a.toolName)){const _=Ne++,E={jsonrpc:"2.0",id:_,method:"tools/call",params:{name:"browser_evaluate",arguments:{function:"() => { const match = document.cookie.match(/(?:^|; )__zibbyLastStableId=([^;]*)/); const id = match ? decodeURIComponent(match[1]) : (window.__zibbyLastStableId || null); return id; }"}}};i(`\u{1F50D} Querying stable ID for event #${a.eventId}`),V.set(_,{eventId:a.eventId}),g.stdin.write(JSON.stringify(E)+`
13
- `)}}if(t.id&&V.has(t.id)){const a=V.get(t.id);if(V.delete(t.id),i(`\u{1F4E5} Stable ID response for event #${a.eventId}: ${JSON.stringify(t.result||t.error||"no result").slice(0,200)}`),t.result?.content?.[0]?.text){const l=t.result.content[0].text,_=l.match(/zibby-[a-zA-Z0-9-]+/);_?(i(`\u2705 Found stable ID: ${_[0]}`),ue(a.eventId,_[0])):i(`\u26A0\uFE0F No stable ID found in: ${l.slice(0,100)}`)}else t.error&&i(`\u274C Stable ID query error: ${t.error?.message||JSON.stringify(t.error)}`);s=!1}}catch{}s&&process.stdout.write(r+`
14
- `)}}),g.on("close",e=>{L(),$=!1,M.trim()&&process.stdout.write(M),process.exit(e||0)}),process.on("SIGINT",()=>{g.kill("SIGINT")}),process.on("SIGTERM",()=>{g.kill("SIGTERM")});
5
+ `),i(`Args: ${process.argv.slice(2).join(" ")}`),i(`Env ZIBBY_NODE_SESSION_PATH=${process.env.ZIBBY_NODE_SESSION_PATH||"(not set)"}`),i(`Env ZIBBY_SESSION_PATH=${process.env.ZIBBY_SESSION_PATH||"(not set)"}`),i(`Env ZIBBY_SESSION_INFO=${process.env.ZIBBY_SESSION_INFO||"(not set)"}`);let o=null,j="none";const w=[];let q=null;function fe(){if(process.env.ZIBBY_NODE_SESSION_PATH){o=process.env.ZIBBY_NODE_SESSION_PATH,j="env:ZIBBY_NODE_SESSION_PATH",S.mkdirSync(o,{recursive:!0}),i(`\u{1F4C1} Session from env: ${o}`);return}const e=process.argv.slice(2);for(const r of e)if(r.startsWith("--output-dir=")){o=r.split("=").slice(1).join("="),j="arg:--output-dir",S.mkdirSync(o,{recursive:!0}),i(`\u{1F4C1} Session from --output-dir: ${o}`);return}if(process.env.ZIBBY_SESSION_PATH){const r=f.join(process.env.ZIBBY_SESSION_PATH,".session-info.json");if(S.existsSync(r))try{const s=JSON.parse(S.readFileSync(r,"utf-8")),t=s.currentNode||"execute_live";o=f.join(s.sessionPath||process.env.ZIBBY_SESSION_PATH,t),j="file:per-session",S.mkdirSync(o,{recursive:!0}),i(`\u{1F4C1} Session from per-session file: ${o}`);return}catch(s){i(`\u26A0\uFE0F Per-session file read error: ${s.message}`)}}const n=[process.env.ZIBBY_SESSION_INFO,f.join(process.cwd(),".zibby/output/.session-info.json"),f.join(process.cwd(),"test-results/.session-info.json")].filter(Boolean);for(const r of n)if(S.existsSync(r))try{const s=JSON.parse(S.readFileSync(r,"utf-8")),t=s.currentNode||"execute_live";if(s.sessionPath){o=f.join(s.sessionPath,t),j=`file:shared(${f.basename(r)})`,S.mkdirSync(o,{recursive:!0}),i(`\u26A0\uFE0F Session from SHARED file (race-prone): ${o}`);return}}catch(s){i(`\u26A0\uFE0F Shared file read error: ${s.message}`)}i("\u26A0\uFE0F No session path resolved \u2014 events will not be recorded")}function G(e){const n=Math.floor(e/1e3),r=Math.floor(n/3600),s=Math.floor(n%3600/60),t=n%60,a=e%1e3;return`${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}:${String(t).padStart(2,"0")}.${String(a).padStart(3,"0")}`}function y(e,n){if(!o)return;const r=Date.now();q||(q=r);const s=r-q,t={id:w.length,type:e,timestamp:new Date(r).toISOString(),videoOffsetMs:s,videoOffsetFormatted:G(s),data:n,_recordedBy:"zibby-wrapper-v2"};return w.push(t),i(`\u{1F4DD} Event #${t.id}: ${e}${n.stableId?` [${n.stableId}]`:""}`),e==="close"?pe():N(),t.id}function ue(e,n){if(!o||e<0||e>=w.length)return;const r=w[e];r&&!r.data.stableId&&n&&(r.data.stableId=n,i(`\u{1F517} Event #${e} stableId: ${n}`),N())}function me(e){function a(u,d,m){if(d>=u.length)return null;const h=u[d];let b=1,z=128;for(;b<=8&&!(h&z);)b++,z>>=1;if(b>8||d+b>u.length)return null;let C=m?h:h&z-1;for(let Z=1;Z<b;Z++)C=C<<8|u[d+Z];return{value:C,length:b}}function l(u,d){if(d>=u.length)return null;const m=a(u,d,!0);if(!m)return null;d+=m.length;const h=a(u,d,!1);return h?(d+=h.length,{id:m.value,dataStart:d,dataSize:h.value,dataEnd:d+h.value}):null}function I(u,d,m){let h=0;for(let b=0;b<m;b++)h=h<<8|u[d+b];return h}function E(u,d,m){return m===4?u.readFloatBE(d):m===8?u.readDoubleBE(d):null}let c=0,p=1e6,v=null;const M=l(e,c);if(!M)return null;c=M.dataEnd;const P=l(e,c);if(!P||P.id!==408125543)return null;c=P.dataStart;const te=Math.min(P.dataEnd,e.length);for(;c<te;){const u=l(e,c);if(!u)break;if(u.id===357149030){let d=u.dataStart;for(;d<u.dataEnd;){const m=l(e,d);if(!m)break;m.id===2807729?p=I(e,m.dataStart,m.dataSize):m.id===17545&&(v=E(e,m.dataStart,m.dataSize)),d=m.dataEnd}break}c=u.dataEnd}return v!==null?v*p/1e6:null}function Se(e){try{const n=de("ffprobe",["-v","error","-show_entries","format=duration","-of","default=noprint_wrappers=1:nokey=1",e],{encoding:"utf-8",timeout:5e3}),r=parseFloat(n.trim());if(!isNaN(r)){const s=Math.round(r*1e3);return i(`\u{1F4CF} Video duration (ffprobe): ${s}ms`),s}}catch{i("\u26A0\uFE0F ffprobe not available, using WebM parser fallback")}try{const n=S.readFileSync(e),r=me(n);if(r){const s=Math.round(r);return i(`\u{1F4CF} Video duration (WebM parser): ${s}ms`),s}}catch(n){i(`\u26A0\uFE0F WebM parsing failed: ${n.message}`)}return null}function pe(){if(!o||w.length===0)return;let e=null,n=0;const r=40;let s=0,t=0;for(;!e&&n<r;){n++;let c=null;if(S.existsSync(f.join(o,"recording.webm")))c=f.join(o,"recording.webm"),n===1&&i("Found recording.webm");else try{const p=S.readdirSync(o);n===1&&i(`Directory contains ${p.length} files: ${p.join(", ")}`);const v=p.filter(M=>M.endsWith(".webm"));n===1&&v.length>0&&i(`Found ${v.length} .webm file(s): ${v.join(", ")}`),v.length>0&&(c=f.join(o,v[0]))}catch(p){n===1&&i(`\u26A0\uFE0F Error reading directory: ${p.message}`)}if(c&&S.existsSync(c))try{const v=S.statSync(c).size;if(v>0&&v===s){if(t++,t>=2){e=c,i(`\u2705 Video file stable after ${n} attempts: ${f.basename(e)} (${v} bytes)`);break}}else t=0,s=v}catch(p){i(`\u26A0\uFE0F Error checking file: ${p.message}`)}if(!e){n%5===0&&i(`\u23F3 Waiting for stable video file... (attempt ${n}/${r}, size: ${s})`);const p=Date.now();for(;Date.now()-p<500;);}}if(!e){i(`\u26A0\uFE0F Video file not found/stable after ${n} attempts in: ${o}`),N();return}const a=Se(e);if(!a){i("\u26A0\uFE0F Could not determine video duration, using fallback"),N();return}const l=w.find(c=>c.type==="close");if(!l){i("\u26A0\uFE0F No close event found"),N();return}const I=new Date(l.timestamp).getTime(),E=I-a;i(`\u{1F4CA} Calculated video start: ${new Date(E).toISOString()}`),i(` Close timestamp: ${I}ms`),i(` Video duration: ${a}ms`),w.forEach(c=>{const p=new Date(c.timestamp).getTime();c.videoOffsetMs=p-E,c.videoOffsetFormatted=G(c.videoOffsetMs)}),i(`\u2705 Recalculated ${w.length} events using accurate video start time`),N()}function N(){if(o)try{const e=f.join(o,"events.json");S.writeFileSync(e,JSON.stringify(w,null,2))}catch{}}i(`CWD: ${process.cwd()}`),fe();const U=process.argv.slice(2);let O=null;for(const e of U){const n=e.match(/^--save-video=(\d+)x(\d+)$/);if(n){O={width:parseInt(n[1],10),height:parseInt(n[2],10)};break}}const _=U.filter(e=>!e.startsWith("--save-video"));S.existsSync(x)?(_.unshift("--init-script",x),i(`\u2705 Stable ID injection enabled: ${x}`)):i(`\u26A0\uFE0F Stable ID script not found: ${x}`);const A=_.findIndex(e=>e==="--caps");if(A>=0&&_[A+1])_[A+1].includes("devtools")||(_[A+1]+=",devtools");else{const e=_.findIndex(n=>n.startsWith("--caps="));e>=0?_[e].includes("devtools")||(_[e]+=",devtools"):_.push("--caps","devtools")}if(o){const e=_.findIndex(n=>n.startsWith("--output-dir"));e!==-1?_[e]=`--output-dir=${o}`:_.push("--output-dir",o),i(`\u{1F4F9} Video output: ${o} (source: ${j})`)}const ve=f.dirname(require.resolve("@playwright/mcp")),_e=f.join(ve,"cli.js"),g=ce(process.execPath,[_e,..._],{stdio:["pipe","pipe","inherit"]});let $=!1,H=!1,Q=8e5;const D=new Set;function he(){if(H||!o)return;H=!0;const e=Q++;D.add(e);const n=o?f.join(o,"recording.webm"):"recording.webm",r={jsonrpc:"2.0",id:e,method:"tools/call",params:{name:"browser_start_video",arguments:{filename:n,...O?{size:O}:{}}}};try{g.stdin.write(JSON.stringify(r)+`
6
+ `),i(`\u{1F3AC} Auto-started video recording${O?` (${O.width}x${O.height})`:""}`)}catch(s){D.delete(e),i(`\u26A0\uFE0F browser_start_video send failed: ${s.message}`)}}function Ie(){if(!H)return;const e=Q++;D.add(e);const n={jsonrpc:"2.0",id:e,method:"tools/call",params:{name:"browser_stop_video",arguments:{}}};try{g.stdin.write(JSON.stringify(n)+`
7
+ `),i("\u{1F3AC} Auto-stopped video recording")}catch(r){D.delete(e),i(`\u26A0\uFE0F browser_stop_video send failed: ${r.message}`)}}const ge=2e3,be=5e3,K="frames";let X=0,we=1e6;const R=new Set;let k=null;function L(){k&&(clearInterval(k),k=null)}function $e(){if(o)try{S.mkdirSync(f.join(o,K),{recursive:!0})}catch{}}function J(){return f.join(o,K,`live-frame-${Date.now()}.png`)}function ye(){L(),!(!$||!o)&&(k=setInterval(()=>{if(!$||!o){L();return}ee(!0,J())},be))}function ee(e,n){if(!o||!$)return;$e();const r=Date.now();if(!e&&r-X<ge)return;X=r;const s=n||J(),t=we++;R.add(t);const a={jsonrpc:"2.0",id:t,method:"tools/call",params:{name:"browser_take_screenshot",arguments:{type:"png",filename:s}}};try{g.stdin.write(JSON.stringify(a)+`
8
+ `),i(`\u{1F4F8} live-frame queued: ${s}`)}catch(l){R.delete(t),i(`\u26A0\uFE0F live-frame send failed: ${l.message}`)}}function Ee(e){!e||typeof e!="string"||!e.startsWith("browser_")||e==="browser_close"||e==="browser_take_screenshot"||!o||!$||ee(!1,J())}const B=new Map;let Ne=9e5;const V=new Map;let T="";process.stdin.on("data",e=>{T+=e.toString();const n=T.split(`
9
+ `);T=n.pop()||"";for(const r of n)if(r.trim()){try{const s=JSON.parse(r);if(s.method&&i(`\u{1F4E8} STDIN: ${s.method} ${s.params?.name||""}`),s.method==="tools/call"&&s.params){const t=s.params.name,a=s.params.arguments||{};B.set(s.id,{toolName:t,toolArgs:a});let l=-1;t==="browser_navigate"?($=!0,ye(),l=y("navigate",{url:a.url})):t==="browser_click"?l=y("click",{element:a.element,ref:a.ref}):t==="browser_type"?l=y("type",{element:a.element,ref:a.ref,text:a.text}):t==="browser_select_option"?l=y("select",{element:a.element,ref:a.ref,values:a.values}):t==="browser_fill_form"?l=y("fill_form",{fields:a.fields}):t==="browser_hover"?l=y("hover",{element:a.element,ref:a.ref}):t==="browser_close"?(Ie(),l=y("close",{}),$=!1,L()):t==="browser_snapshot"&&(l=y("snapshot",{})),l>=0&&(B.get(s.id).eventId=l)}}catch{}g.stdin.write(r+`
10
+ `)}}),process.stdin.on("end",()=>{T.trim()&&g.stdin.write(T+`
11
+ `),g.stdin.end()});let F="";g.stdout.on("data",e=>{F+=e.toString();const n=F.split(`
12
+ `);F=n.pop()||"";for(const r of n){if(!r.trim())continue;let s=!0;try{const t=JSON.parse(r);if(t.id&&D.has(t.id))D.delete(t.id),t.error&&i(`\u26A0\uFE0F Video RPC error: ${t.error?.message||JSON.stringify(t.error)}`),s=!1;else if(t.id&&R.has(t.id))R.delete(t.id),t.error&&i(`\u26A0\uFE0F Screenshot RPC error: ${t.error?.message||JSON.stringify(t.error)}`),s=!1;else if(t.id&&B.has(t.id)){const a=B.get(t.id);if(B.delete(t.id),!t.error&&$&&Ee(a.toolName),!t.error&&a.toolName==="browser_navigate"&&he(),!t.error&&$&&a.eventId>=0&&["browser_click","browser_type","browser_select_option","browser_fill_form","browser_hover"].includes(a.toolName)){const I=Ne++,E={jsonrpc:"2.0",id:I,method:"tools/call",params:{name:"browser_evaluate",arguments:{function:"() => { const match = document.cookie.match(/(?:^|; )__zibbyLastStableId=([^;]*)/); const id = match ? decodeURIComponent(match[1]) : (window.__zibbyLastStableId || null); return id; }"}}};i(`\u{1F50D} Querying stable ID for event #${a.eventId}`),V.set(I,{eventId:a.eventId}),g.stdin.write(JSON.stringify(E)+`
13
+ `)}}if(t.id&&V.has(t.id)){const a=V.get(t.id);if(V.delete(t.id),i(`\u{1F4E5} Stable ID response for event #${a.eventId}: ${JSON.stringify(t.result||t.error||"no result").slice(0,200)}`),t.result?.content?.[0]?.text){const l=t.result.content[0].text,I=l.match(/zibby-[a-zA-Z0-9-]+/);I?(i(`\u2705 Found stable ID: ${I[0]}`),ue(a.eventId,I[0])):i(`\u26A0\uFE0F No stable ID found in: ${l.slice(0,100)}`)}else t.error&&i(`\u274C Stable ID query error: ${t.error?.message||JSON.stringify(t.error)}`);s=!1}}catch{}s&&process.stdout.write(r+`
14
+ `)}}),g.on("close",e=>{L(),$=!1,F.trim()&&process.stdout.write(F),process.exit(e||0)}),process.on("SIGINT",()=>{g.kill("SIGINT")}),process.on("SIGTERM",()=>{g.kill("SIGTERM")});
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/mcp-browser",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Wrapper for @playwright/mcp with stable ID support and event recording",
5
5
  "type": "commonjs",
6
6
  "main": "dist/bin/mcp-browser-zibby.js",
@@ -27,10 +27,10 @@
27
27
  ],
28
28
  "repository": {
29
29
  "type": "git",
30
- "url": "https://github.com/ZibbyHQ/zibby-agent"
30
+ "url": "https://github.com/ZibbyDev/zibby-agent"
31
31
  },
32
32
  "bugs": {
33
- "url": "https://github.com/ZibbyHQ/zibby-agent/issues"
33
+ "url": "https://github.com/ZibbyDev/zibby-agent/issues"
34
34
  },
35
35
  "dependencies": {
36
36
  "@playwright/mcp": "^0.0.70"
@@ -38,7 +38,7 @@
38
38
  "engines": {
39
39
  "node": ">=18.0.0"
40
40
  },
41
- "license": "MIT",
41
+ "license": "UNLICENSED",
42
42
  "author": "Zibby",
43
43
  "homepage": "https://zibby.dev",
44
44
  "devDependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zibby/mcp-browser",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Wrapper for @playwright/mcp with stable ID support and event recording",
5
5
  "type": "commonjs",
6
6
  "main": "dist/bin/mcp-browser-zibby.js",
@@ -27,10 +27,10 @@
27
27
  ],
28
28
  "repository": {
29
29
  "type": "git",
30
- "url": "https://github.com/ZibbyHQ/zibby-agent"
30
+ "url": "https://github.com/ZibbyDev/zibby-agent"
31
31
  },
32
32
  "bugs": {
33
- "url": "https://github.com/ZibbyHQ/zibby-agent/issues"
33
+ "url": "https://github.com/ZibbyDev/zibby-agent/issues"
34
34
  },
35
35
  "dependencies": {
36
36
  "@playwright/mcp": "^0.0.70"
@@ -38,7 +38,7 @@
38
38
  "engines": {
39
39
  "node": ">=18.0.0"
40
40
  },
41
- "license": "MIT",
41
+ "license": "UNLICENSED",
42
42
  "author": "Zibby",
43
43
  "homepage": "https://zibby.dev",
44
44
  "devDependencies": {