@mindstudio-ai/browser-agent 0.1.0
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/dist/index.js +1 -0
- package/package.json +22 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __MindStudioBrowserAgent=(()=>{var l="/__mindstudio_dev__/logs";var i=[],s=null;function p(){if(i.length===0)return;let t=i;i=[];try{let e=new XMLHttpRequest;e.open("POST",l,!0),e.setRequestHeader("Content-Type","application/json"),e.send(JSON.stringify(t))}catch{}}function T(){s||(s=setTimeout(()=>{s=null,p()},2e3))}function _(){s&&(clearTimeout(s),s=null),p()}function r(t){i.push(t),T()}function c(t){i.push(t),_()}function d(){window.addEventListener("beforeunload",()=>{i.length>0&&navigator.sendBeacon&&navigator.sendBeacon(l,JSON.stringify(i))})}function m(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t instanceof Error)return t.stack||t.message||String(t);if(typeof t=="object")try{return JSON.stringify(t)}catch{return String(t)}return String(t)}function g(t){if(!t||!t.tagName)return"";let e=t.tagName.toLowerCase();return t.id&&(e+="#"+t.id),t.className&&typeof t.className=="string"&&(e+="."+t.className.trim().split(/\s+/).join(".")),e}var L=["log","info","warn","error","debug"];function h(){for(let t of L){let e=console[t];console[t]=(...o)=>{e&&e.apply(console,o),r({type:"console",level:t,args:o.map(m),url:location.href})}}}function y(){window.addEventListener("error",t=>{c({type:"error",message:t.message,stack:t.error&&t.error.stack||"",source:t.filename,line:t.lineno,column:t.colno,url:location.href})}),window.addEventListener("unhandledrejection",t=>{let e=t.reason||{};c({type:"error",message:e.message||String(e),stack:e.stack||"",url:location.href})})}function w(){if(!window.fetch)return;let t=window.fetch;window.fetch=function(e,o){let a=o?.method||"GET",f=typeof e=="string"?e:e instanceof URL?e.href:e.url||String(e);return t.apply(this,[e,o]).then(n=>{if(!n.ok){let u={type:"network",method:a,url:f,status:n.status,statusText:n.statusText};try{n.clone().text().then(N=>{u.body=N.slice(0,1e3),r(u)}).catch(()=>r(u))}catch{r(u)}}return n},n=>{throw r({type:"network",method:a,url:f,error:n.message||String(n)}),n})}}function E(){document.addEventListener("click",t=>{let e=t.target,o=(e?.textContent||"").trim().slice(0,100);r({type:"interaction",event:"click",target:g(e),text:o,url:location.href})},!0)}window.__MINDSTUDIO_BROWSER_AGENT__||(window.__MINDSTUDIO_BROWSER_AGENT__=!0,d(),h(),y(),w(),E());})();
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mindstudio-ai/browser-agent",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Browser-side agent for MindStudio dev previews — captures logs, provides DOM snapshots, and enables remote interaction.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsup",
|
|
11
|
+
"serve": "npx -y serve dist -l 8787 --cors --no-clipboard",
|
|
12
|
+
"dev": "npx -y serve dist -l 8787 --cors --no-clipboard & tsup --watch"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/anthropics/mindstudio-browser-agent.git"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"tsup": "^8.5.0",
|
|
20
|
+
"typescript": "^5.7.0"
|
|
21
|
+
}
|
|
22
|
+
}
|