bangonit 0.4.3 → 0.5.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/README.md +2 -1
- package/app/desktopapp/dist/main/index.js +10 -4
- package/app/desktopapp/dist/main/ipc.js +9 -24
- package/app/desktopapp/dist/main/preload.js +0 -7
- package/app/desktopapp/dist/main/tabs.js +10 -5
- package/app/desktopapp/package.json +0 -1
- package/app/replay/dist/replay.js +2 -2
- package/app/webapp/.next/standalone/app/webapp/.next/BUILD_ID +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/app-build-manifest.json +11 -11
- package/app/webapp/.next/standalone/app/webapp/.next/app-path-routes-manifest.json +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/build-manifest.json +3 -3
- package/app/webapp/.next/standalone/app/webapp/.next/prerender-manifest.json +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/required-server-files.json +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/_not-found/page.js +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/_not-found.html +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/_not-found.rsc +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/api/chat/route.js +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/api/screenshot/route.js +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/app/page.js +6 -6
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/app/page_client-reference-manifest.js +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/app.html +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/app.rsc +2 -2
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/index.html +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/index.rsc +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/page.js +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app/page_client-reference-manifest.js +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/app-paths-manifest.json +3 -3
- package/app/webapp/.next/standalone/app/webapp/.next/server/chunks/679.js +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/chunks/708.js +3 -3
- package/app/webapp/.next/standalone/app/webapp/.next/server/middleware-build-manifest.js +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/pages/404.html +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/pages/500.html +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/server/server-reference-manifest.json +1 -1
- package/app/webapp/.next/standalone/app/webapp/.next/static/chunks/app/app/page-533a30559a8f39fa.js +1 -0
- package/app/webapp/.next/standalone/app/webapp/.next/static/chunks/app/layout-40f50d9380154ecf.js +1 -0
- package/app/webapp/.next/{static/chunks/main-app-106dd83f859b9dfa.js → standalone/app/webapp/.next/static/chunks/main-app-76384b941f0b51cb.js} +1 -1
- package/app/webapp/.next/standalone/app/webapp/package.json +2 -6
- package/app/webapp/.next/standalone/app/webapp/server.js +1 -1
- package/app/webapp/.next/standalone/package.json +18 -5
- package/app/webapp/.next/static/chunks/app/app/page-533a30559a8f39fa.js +1 -0
- package/app/webapp/.next/static/chunks/app/layout-40f50d9380154ecf.js +1 -0
- package/app/webapp/.next/{standalone/app/webapp/.next/static/chunks/main-app-106dd83f859b9dfa.js → static/chunks/main-app-76384b941f0b51cb.js} +1 -1
- package/app/webapp/package.json +2 -6
- package/app/webapp/skills/document-review.md +1 -0
- package/app/webapp/skills/gmail.md +2 -0
- package/app/webapp/src/app/globals.css +8 -3
- package/app/webapp/src/app/layout.tsx +2 -8
- package/app/webapp/src/shared/api/chat.ts +49 -25
- package/app/webapp/src/shared/api/screenshot.ts +11 -10
- package/app/webapp/src/shared/components/AppShell.tsx +80 -109
- package/app/webapp/src/shared/components/SessionView.tsx +335 -248
- package/app/webapp/src/shared/components/VirtualCursor.tsx +13 -14
- package/app/webapp/src/shared/lib/browser/cursor.ts +2 -7
- package/app/webapp/src/shared/lib/browser/index.ts +56 -36
- package/app/webapp/src/shared/lib/browser/mouse.ts +86 -21
- package/app/webapp/src/shared/lib/browser/navigate.ts +1 -4
- package/app/webapp/src/shared/lib/browser/recorder.ts +12 -5
- package/app/webapp/src/shared/lib/browser/screenshot.ts +4 -4
- package/app/webapp/src/shared/lib/browser/snapshot.ts +9 -5
- package/app/webapp/src/shared/lib/browser/tabs.ts +1 -1
- package/app/webapp/src/shared/lib/browser/types.ts +3 -2
- package/app/webapp/src/shared/lib/browser/wait.ts +1 -1
- package/app/webapp/src/shared/lib/recorder/session-recorder.ts +1 -1
- package/app/webapp/src/shared/types/global.d.ts +8 -19
- package/app/webapp/tailwind.config.js +1 -3
- package/bin/src/cli/bangonit.js +59 -21
- package/package.json +18 -5
- package/app/webapp/.next/standalone/app/webapp/.next/static/chunks/app/app/page-03dbc2fc67c26b74.js +0 -1
- package/app/webapp/.next/standalone/app/webapp/.next/static/chunks/app/layout-57acb80d8da0067a.js +0 -1
- package/app/webapp/.next/static/chunks/app/app/page-03dbc2fc67c26b74.js +0 -1
- package/app/webapp/.next/static/chunks/app/layout-57acb80d8da0067a.js +0 -1
- /package/app/webapp/.next/standalone/app/webapp/.next/static/{z2gRF0NKwztPLZ9d7ok06 → oyP-lwTb7W3NCCryjxA6T}/_buildManifest.js +0 -0
- /package/app/webapp/.next/standalone/app/webapp/.next/static/{z2gRF0NKwztPLZ9d7ok06 → oyP-lwTb7W3NCCryjxA6T}/_ssgManifest.js +0 -0
- /package/app/webapp/.next/static/{z2gRF0NKwztPLZ9d7ok06 → oyP-lwTb7W3NCCryjxA6T}/_buildManifest.js +0 -0
- /package/app/webapp/.next/static/{z2gRF0NKwztPLZ9d7ok06 → oyP-lwTb7W3NCCryjxA6T}/_ssgManifest.js +0 -0
package/bin/src/cli/bangonit.js
CHANGED
|
@@ -230,7 +230,9 @@ async function uploadToS3(localDir, opts) {
|
|
|
230
230
|
function createPrompter() {
|
|
231
231
|
let closed = false;
|
|
232
232
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
233
|
-
rl.on("close", () => {
|
|
233
|
+
rl.on("close", () => {
|
|
234
|
+
closed = true;
|
|
235
|
+
});
|
|
234
236
|
return {
|
|
235
237
|
ask(question, defaultVal) {
|
|
236
238
|
if (closed)
|
|
@@ -245,7 +247,7 @@ function createPrompter() {
|
|
|
245
247
|
askChoice(question, choices, defaultVal) {
|
|
246
248
|
if (closed)
|
|
247
249
|
return Promise.resolve(defaultVal);
|
|
248
|
-
const choiceStr = choices.map((ch) => ch === defaultVal ? `${c.bold}${ch}${c.reset}${c.dim}` : ch).join("/");
|
|
250
|
+
const choiceStr = choices.map((ch) => (ch === defaultVal ? `${c.bold}${ch}${c.reset}${c.dim}` : ch)).join("/");
|
|
249
251
|
return new Promise((resolve) => {
|
|
250
252
|
rl.question(` ${c.cyan}?${c.reset} ${question} ${c.dim}(${choiceStr})${c.reset} `, (answer) => {
|
|
251
253
|
const val = answer.trim().toLowerCase() || defaultVal;
|
|
@@ -253,19 +255,28 @@ function createPrompter() {
|
|
|
253
255
|
});
|
|
254
256
|
});
|
|
255
257
|
},
|
|
256
|
-
close() {
|
|
258
|
+
close() {
|
|
259
|
+
rl.close();
|
|
260
|
+
},
|
|
257
261
|
};
|
|
258
262
|
}
|
|
259
263
|
// --- init command ---
|
|
260
264
|
// Common timezone offsets from UTC (standard time)
|
|
261
265
|
const TIMEZONE_OFFSETS = {
|
|
262
|
-
"us/eastern": -5,
|
|
263
|
-
"
|
|
264
|
-
"
|
|
266
|
+
"us/eastern": -5,
|
|
267
|
+
"us/central": -6,
|
|
268
|
+
"us/mountain": -7,
|
|
269
|
+
"us/pacific": -8,
|
|
270
|
+
"europe/london": 0,
|
|
271
|
+
"europe/berlin": 1,
|
|
272
|
+
"europe/paris": 1,
|
|
273
|
+
"asia/tokyo": 9,
|
|
274
|
+
"asia/shanghai": 8,
|
|
275
|
+
"asia/kolkata": 5,
|
|
265
276
|
"australia/sydney": 11,
|
|
266
277
|
};
|
|
267
278
|
function localHourToUtc(localHour, utcOffset) {
|
|
268
|
-
return ((localHour - utcOffset) % 24 + 24) % 24;
|
|
279
|
+
return (((localHour - utcOffset) % 24) + 24) % 24;
|
|
269
280
|
}
|
|
270
281
|
async function initProject() {
|
|
271
282
|
const p = createPrompter();
|
|
@@ -642,13 +653,18 @@ async function run(argv, config) {
|
|
|
642
653
|
die(`Webapp server crashed (exit code ${code}). Check logs/webapp.log for details.`);
|
|
643
654
|
}
|
|
644
655
|
});
|
|
645
|
-
// Save terminal state before Electron (which inherits stdin) can modify it
|
|
656
|
+
// Save terminal state before Electron (which inherits stdin) can modify it.
|
|
657
|
+
// stty is not available on Windows.
|
|
646
658
|
let savedTtyState = null;
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
659
|
+
if (process.platform !== "win32") {
|
|
660
|
+
try {
|
|
661
|
+
savedTtyState = (0, child_process_1.execSync)("stty -g", { stdio: ["inherit", "pipe", "ignore"] })
|
|
662
|
+
.toString()
|
|
663
|
+
.trim();
|
|
664
|
+
}
|
|
665
|
+
catch (e) {
|
|
666
|
+
console.error("[cli] stty save failed:", e.message);
|
|
667
|
+
}
|
|
652
668
|
}
|
|
653
669
|
let electronProc = null;
|
|
654
670
|
const cleanup = () => {
|
|
@@ -676,8 +692,14 @@ async function run(argv, config) {
|
|
|
676
692
|
}
|
|
677
693
|
};
|
|
678
694
|
process.on("exit", cleanup);
|
|
679
|
-
process.on("SIGINT", () => {
|
|
680
|
-
|
|
695
|
+
process.on("SIGINT", () => {
|
|
696
|
+
cleanup();
|
|
697
|
+
process.exit(1);
|
|
698
|
+
});
|
|
699
|
+
process.on("SIGTERM", () => {
|
|
700
|
+
cleanup();
|
|
701
|
+
process.exit(1);
|
|
702
|
+
});
|
|
681
703
|
await waitForPort(PORT);
|
|
682
704
|
const electronMain = path.join(DESKTOP_DIR, "dist", "main", "index.js");
|
|
683
705
|
if (!fs.existsSync(electronMain)) {
|
|
@@ -702,7 +724,8 @@ async function run(argv, config) {
|
|
|
702
724
|
die("Error: electron not found. Run `npm install` in app/desktopapp.");
|
|
703
725
|
}
|
|
704
726
|
}
|
|
705
|
-
|
|
727
|
+
const electronExtraArgs = process.env.CI ? ["--no-sandbox", "--disable-gpu"] : [];
|
|
728
|
+
electronProc = (0, child_process_1.spawn)(electronPath, [".", ...electronExtraArgs], {
|
|
706
729
|
cwd: DESKTOP_DIR,
|
|
707
730
|
env: {
|
|
708
731
|
...process.env,
|
|
@@ -710,13 +733,18 @@ async function run(argv, config) {
|
|
|
710
733
|
WEBAPP_URL: `http://localhost:${PORT}/app`,
|
|
711
734
|
NODE_ENV: process.env.NODE_ENV || "production",
|
|
712
735
|
},
|
|
713
|
-
stdio: ["inherit", "inherit", "
|
|
736
|
+
stdio: ["inherit", "inherit", "pipe"],
|
|
714
737
|
});
|
|
738
|
+
const electronLog = fs.createWriteStream(path.join(LOGS_DIR, "electron.log"));
|
|
739
|
+
electronProc.stderr.pipe(electronLog);
|
|
740
|
+
electronProc.stderr.pipe(process.stderr, { end: false });
|
|
715
741
|
electronProc.on("exit", async (code) => {
|
|
716
742
|
// Upload recordings to S3 if configured
|
|
717
743
|
if (config.s3?.bucket && argv.record) {
|
|
718
744
|
if (fs.existsSync(recordingsDir)) {
|
|
719
|
-
const dirs = fs
|
|
745
|
+
const dirs = fs
|
|
746
|
+
.readdirSync(recordingsDir)
|
|
747
|
+
.filter((d) => fs.existsSync(path.join(recordingsDir, d, "index.html")));
|
|
720
748
|
const s3Prefix = config.s3.prefix || "bangonit";
|
|
721
749
|
for (const dir of dirs) {
|
|
722
750
|
const localPath = path.join(recordingsDir, dir);
|
|
@@ -746,7 +774,9 @@ const ciDefaults = is_ci_1.default ? { headless: true, exit: true } : {};
|
|
|
746
774
|
(0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
747
775
|
.scriptName("boi")
|
|
748
776
|
.usage("Usage: $0 <command> [options]")
|
|
749
|
-
.command("init", "Set up Bang On It! (config, test plans, and optionally CI)", {}, () => {
|
|
777
|
+
.command("init", "Set up Bang On It! (config, test plans, and optionally CI)", {}, () => {
|
|
778
|
+
initProject();
|
|
779
|
+
})
|
|
750
780
|
.command(["run [files..]", "$0"], "Run test plans (or launch interactive UI)", (y) => y
|
|
751
781
|
.positional("files", { type: "string", array: true, default: [], describe: "Test plan files" })
|
|
752
782
|
.option("filter", { alias: "t", type: "string", describe: "Filter test plans by name substring" })
|
|
@@ -755,8 +785,16 @@ const ciDefaults = is_ci_1.default ? { headless: true, exit: true } : {};
|
|
|
755
785
|
.option("prompt", { type: "string", describe: "Additional instructions appended to test plan" })
|
|
756
786
|
.option("record", { type: "boolean", default: false, describe: "Record session replay" })
|
|
757
787
|
.option("retries", { type: "number", describe: "Retry failed tests N times (overrides test plan frontmatter)" })
|
|
758
|
-
.option("headless", {
|
|
759
|
-
|
|
788
|
+
.option("headless", {
|
|
789
|
+
type: "boolean",
|
|
790
|
+
default: ciDefaults.headless ?? false,
|
|
791
|
+
describe: "Run without showing the browser window",
|
|
792
|
+
})
|
|
793
|
+
.option("exit", {
|
|
794
|
+
type: "boolean",
|
|
795
|
+
default: ciDefaults.exit ?? false,
|
|
796
|
+
describe: "Exit immediately after tests complete",
|
|
797
|
+
})
|
|
760
798
|
.option("json", { type: "boolean", default: false, describe: "Stream NDJSON events to stdout" })
|
|
761
799
|
.option("console", { type: "boolean", default: false, describe: "Forward browser console logs to stdout" })
|
|
762
800
|
.option("output", { type: "string", describe: "Write JSON results to file" })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bangonit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "AI-powered E2E testing tool",
|
|
5
5
|
"bin": {
|
|
6
6
|
"bangonit": "bin/src/cli/bangonit.js",
|
|
@@ -14,7 +14,16 @@
|
|
|
14
14
|
"build:webapp": "cd app/webapp && npm run build && cp -r .next/static .next/standalone/app/webapp/.next/static",
|
|
15
15
|
"build:electron": "cd app/desktopapp && npx tsc",
|
|
16
16
|
"build:replay": "cd app/replay && npx vite build",
|
|
17
|
-
"test": "node --test test/*.test.ts"
|
|
17
|
+
"test": "node --test test/*.test.ts",
|
|
18
|
+
"format": "prettier --write .",
|
|
19
|
+
"format:check": "prettier --check .",
|
|
20
|
+
"lint": "eslint .",
|
|
21
|
+
"lint:fix": "eslint --fix .",
|
|
22
|
+
"typecheck": "concurrently npm:typecheck:cli npm:typecheck:webapp npm:typecheck:desktop npm:typecheck:replay",
|
|
23
|
+
"typecheck:cli": "tsc --noEmit -p tsconfig.cli.json",
|
|
24
|
+
"typecheck:webapp": "cd app/webapp && npx tsc --noEmit",
|
|
25
|
+
"typecheck:desktop": "cd app/desktopapp && npx tsc --noEmit",
|
|
26
|
+
"typecheck:replay": "cd app/replay && npx tsc --noEmit"
|
|
18
27
|
},
|
|
19
28
|
"workspaces": [
|
|
20
29
|
"app/*"
|
|
@@ -52,16 +61,20 @@
|
|
|
52
61
|
"@iarna/toml": "^2.2.5",
|
|
53
62
|
"dotenv": "^17.3.1",
|
|
54
63
|
"electron": "^40.8.0",
|
|
55
|
-
"electron-store": "^8.1.0",
|
|
56
64
|
"is-ci": "^4.1.0",
|
|
57
65
|
"minio": "^8.0.7",
|
|
58
66
|
"yargs": "^18.0.0",
|
|
59
67
|
"zod": "^3.25.0"
|
|
60
68
|
},
|
|
61
69
|
"devDependencies": {
|
|
70
|
+
"@eslint/js": "^9.39.4",
|
|
62
71
|
"@types/is-ci": "^3.0.4",
|
|
63
72
|
"@types/yargs": "^17.0.35",
|
|
64
73
|
"concurrently": "^9.2.1",
|
|
65
|
-
"
|
|
74
|
+
"eslint": "^9.39.4",
|
|
75
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
76
|
+
"playwright": "^1.58.2",
|
|
77
|
+
"prettier": "^3.5.3",
|
|
78
|
+
"typescript-eslint": "^8.57.1"
|
|
66
79
|
}
|
|
67
|
-
}
|
|
80
|
+
}
|
package/app/webapp/.next/standalone/app/webapp/.next/static/chunks/app/app/page-03dbc2fc67c26b74.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[191],{6421:function(e,t,n){Promise.resolve().then(n.bind(n,5274))},5274:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return B}});var a=n(7573),i=n(7653),r=n(774),o=n(1446),s=n(2574),l=n(3334);function c(e,t,n,a){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;if(i<=0)return;e.save(),e.globalAlpha=i;let r=a?.8:1;e.save(),e.translate(t-2,n-1),e.scale(28/24*r,28/24*r);let o=new Path2D("M5 3l14 8.5-6.5 1.5-3.5 6z");e.shadowColor="rgba(0,0,0,0.5)",e.shadowBlur=2,e.shadowOffsetY=1,e.fillStyle="white",e.strokeStyle="black",e.lineWidth=1.5,e.lineJoin="round",e.fill(o),e.stroke(o),e.restore(),e.restore()}function u(e,t,n,a){a>=1||(e.save(),e.beginPath(),e.arc(t,n,24*a,0,2*Math.PI),e.fillStyle="rgba(96, 165, 250, ".concat(.8*(1-a),")"),e.fill(),e.restore(),e.save(),e.beginPath(),e.arc(t,n,32*a,0,2*Math.PI),e.strokeStyle="rgba(96, 165, 250, ".concat(.9*(1-a),")"),e.lineWidth=2,e.stroke(),e.restore())}function d(e){let{agentId:t}=e,n=(0,i.useRef)(null),r=(0,i.useRef)({x:0,y:0,clicking:!1,lastActiveTs:0,hasPos:!1,ripples:[],rafId:0}),o=(0,i.useCallback)(()=>{r.current.lastActiveTs=Date.now()},[]);return(0,i.useEffect)(()=>{let e=n.current;if(!e)return;let t=e.getContext("2d"),a=window.devicePixelRatio||1,i=()=>{let n=e.parentElement;if(!n)return;let i=n.clientWidth,r=n.clientHeight;e.width=i*a,e.height=r*a,e.style.width=i+"px",e.style.height=r+"px",t.setTransform(a,0,0,a,0,0)};i();let o=new ResizeObserver(i);o.observe(e.parentElement);let s=()=>{let n=r.current,i=e.width/a,o=e.height/a;if(t.clearRect(0,0,i,o),n.hasPos){let e=Date.now(),a=e-n.lastActiveTs;for(let a=n.ripples.length-1;a>=0;a--){let i=n.ripples[a],r=e-i.startTs;if(r>=400){n.ripples.splice(a,1);continue}u(t,i.x,i.y,r/400)}c(t,n.x,n.y,n.clicking,a<2e3?1:Math.max(0,1-(a-2e3)/400))}r.current.rafId=requestAnimationFrame(s)};return r.current.rafId=requestAnimationFrame(s),()=>{cancelAnimationFrame(r.current.rafId),o.disconnect()}},[]),(0,i.useEffect)(()=>{var e,n,a;let i=[],s=r.current;return i.push(null===(e=window.bangonit)||void 0===e?void 0:e.onCursorMove(e=>{e.agentId===t&&(s.x=e.x,s.y=e.y,s.hasPos=!0,o())})),i.push(null===(n=window.bangonit)||void 0===n?void 0:n.onCursorDown(e=>{e.agentId===t&&(s.x=e.x,s.y=e.y,s.hasPos=!0,s.clicking=!0,s.ripples.push({x:e.x,y:e.y,startTs:Date.now()}),o())})),i.push(null===(a=window.bangonit)||void 0===a?void 0:a.onCursorUp(e=>{e.agentId===t&&(s.clicking=!1,o())})),()=>{i.forEach(e=>null==e?void 0:e())}},[t,o]),(0,a.jsx)("canvas",{ref:n,className:"pointer-events-none absolute inset-0 z-20"})}async function h(e,t,n,a){let[{result:i},r,o,{result:s}]=await Promise.all([window.bangonit.cdpSend(e,"Runtime.evaluate",{expression:"\n(function() {\n var MAX_CHARS = 60000;\n var MAX_ELEMENTS = 5000;\n var MAX_DEPTH = 1500;\n var totalChars = 0;\n var visited = 0;\n var truncated = false;\n var refCounter = 0;\n\n window.__dmjRefs = new Map();\n\n var SKIP_TAGS = {SCRIPT:1,STYLE:1,NOSCRIPT:1,SVG:1,PATH:1,META:1,LINK:1,TEMPLATE:1,IFRAME:1,BR:1,HR:1,WBR:1,CANVAS:1,VIDEO:1,AUDIO:1,MAP:1,AREA:1,PICTURE:1,SOURCE:1,TRACK:1,OBJECT:1,EMBED:1};\n var INTERACTIVE_ROLES = {button:1,link:1,textbox:1,checkbox:1,radio:1,combobox:1,menuitem:1,tab:1,switch:1,option:1};\n var INPUT_ROLE = {checkbox:'checkbox',radio:'radio',submit:'button',button:'button',search:'searchbox',file:'file'};\n var TAG_ROLE = {A:'link',BUTTON:'button',SELECT:'combobox',TEXTAREA:'textbox',IMG:'img',H1:'heading',H2:'heading',H3:'heading',H4:'heading',H5:'heading',H6:'heading',NAV:'navigation',MAIN:'main',FORM:'form',TABLE:'table',UL:'list',OL:'list',LI:'listitem'};\n\n function isVisible(el) {\n if (el.hidden || el.getAttribute('aria-hidden') === 'true') return false;\n if (!el.offsetParent && el.tagName !== 'BODY' && el.tagName !== 'HTML') {\n var pos = getComputedStyle(el).position;\n if (pos !== 'fixed' && pos !== 'sticky') return false;\n }\n var s = el.style;\n if (s.display === 'none' || s.visibility === 'hidden') return false;\n return true;\n }\n\n function isInteractive(el) {\n var tag = el.tagName;\n if (tag === 'A' || tag === 'BUTTON' || tag === 'SELECT' || tag === 'TEXTAREA') return true;\n if (tag === 'INPUT' && el.type !== 'hidden') return true;\n var role = el.getAttribute('role');\n if (role && INTERACTIVE_ROLES[role]) return true;\n var tabindex = el.getAttribute('tabindex');\n if (el.onclick || (tabindex !== null && tabindex >= '0')) return true;\n if (el.contentEditable === 'true') return true;\n return false;\n }\n\n function getRole(el) {\n var r = el.getAttribute('role');\n if (r) return r;\n if (el.tagName === 'INPUT') return INPUT_ROLE[(el.type||'text').toLowerCase()] || 'textbox';\n return TAG_ROLE[el.tagName] || null;\n }\n\n function getLabel(el) {\n return (el.getAttribute('aria-label') || el.getAttribute('placeholder') || el.getAttribute('alt') || el.getAttribute('title') || '').slice(0, 50);\n }\n\n function directText(el) {\n var t = '';\n for (var n = el.firstChild; n; n = n.nextSibling) {\n if (n.nodeType === 3) t += n.data;\n if (t.length > 60) break;\n }\n return t.trim().replace(/\\s+/g, ' ').slice(0, 60);\n }\n\n function walk(el, depth) {\n if (truncated || !el || el.nodeType !== 1) return '';\n if (SKIP_TAGS[el.tagName]) return '';\n if (!isVisible(el)) return '';\n if (depth > MAX_DEPTH) return '';\n if (++visited > MAX_ELEMENTS) { truncated = true; return ''; }\n\n var role = getRole(el);\n var interactive = isInteractive(el);\n var showThis = !!(role || interactive);\n var lines = [];\n\n if (showThis) {\n var label = getLabel(el);\n var dtext = directText(el);\n var line = '[' + (role || el.tagName.toLowerCase());\n var txt = label || dtext;\n if (txt) line += ' \"' + txt.replace(/\"/g, \"'\") + '\"';\n if (interactive) {\n var ref = 'e' + (++refCounter);\n window.__dmjRefs.set(ref, new WeakRef(el));\n line += ' ref=' + ref;\n }\n line += ']';\n if (el === document.activeElement) line += ' [focused]';\n if ((el.tagName === 'INPUT' || el.tagName === 'TEXTAREA') && el.value) line += ' val=\"' + el.value.slice(0,40) + '\"';\n if (el.tagName === 'INPUT' && (el.type === 'checkbox' || el.type === 'radio')) line += el.checked ? ' [x]' : ' [ ]';\n\n totalChars += line.length;\n if (totalChars > MAX_CHARS) { truncated = true; return ''; }\n lines.push(line);\n }\n\n for (var c = el.firstElementChild; c; c = c.nextElementSibling) {\n if (truncated) break;\n var out = walk(c, showThis ? depth + 1 : depth);\n if (out) lines.push(showThis ? out.split('\\n').map(function(l){return ' '+l}).join('\\n') : out);\n }\n\n if (!showThis) {\n var dt = directText(el);\n if (dt.length > 2) {\n totalChars += dt.length;\n if (totalChars > MAX_CHARS) { truncated = true; return ''; }\n lines.push('\"' + dt + '\"');\n }\n }\n\n return lines.join('\\n');\n }\n\n var tree = walk(document.body, 0);\n var h = 'URL: ' + location.href + '\\nTitle: ' + document.title;\n if (truncated) h += '\\n[TRUNCATED - page too large]';\n return h + '\\n\\n' + tree;\n})()\n",returnByValue:!0}),window.bangonit.getDownloads(e),window.bangonit.getFileChooserState(e),window.bangonit.cdpSend(e,"Runtime.evaluate",{expression:"JSON.stringify({w:window.innerWidth,h:window.innerHeight})",returnByValue:!0})]),l=(()=>{try{return JSON.parse(s.value)}catch(e){return null}})(),c=l?"\nViewport: ".concat(l.w,"x").concat(l.h):"",u=(i.value||"Empty page")+"\n\nMouse position: ".concat(t,",").concat(n).concat(c)+a;if(o.open&&(u+="\n\n[File picker is open — use upload action with paths to select files, or cancel: true to dismiss]"),r.length>0){let e=r.map(e=>"- ".concat(e.filename," (").concat(e.bytes," bytes) [").concat(e.state,"]"));u+="\n\nDownloads:\n".concat(e.join("\n"))}return u}async function p(e,t,n){let a=window.bangonit;if(t.ref){let{result:r}=await a.cdpSend(e,"Runtime.evaluate",{expression:'(function() { var r = window.__dmjRefs && window.__dmjRefs.get("'.concat(t.ref,'"); return r ? r.deref() || null : null; })()'),returnByValue:!1});if(!r.objectId)throw Error('Element ref "'.concat(t.ref,'" not found — take a new snapshot'));try{let{model:i}=await a.cdpSend(e,"DOM.getBoxModel",{objectId:r.objectId}),o=i.content,s=Math.round((o[0]+o[2]+o[4]+o[6])/4),l=Math.round((o[1]+o[3]+o[5]+o[7])/4);if(n){let{result:t}=await a.cdpSend(e,"Runtime.evaluate",{expression:"JSON.stringify({ w: window.innerWidth, h: window.innerHeight })",returnByValue:!0}),n=JSON.parse(t.value);if(s<0||s>n.w||l<0||l>n.h){await a.cdpSend(e,"Runtime.callFunctionOn",{objectId:r.objectId,functionDeclaration:'function() { this.scrollIntoView({ block: "center", inline: "center", behavior: "instant" }); }',returnByValue:!0}),await new Promise(e=>setTimeout(e,100));let{model:t}=await a.cdpSend(e,"DOM.getBoxModel",{objectId:r.objectId}),n=t.content;s=Math.round((n[0]+n[2]+n[4]+n[6])/4),l=Math.round((n[1]+n[3]+n[5]+n[7])/4)}}else if(s<0||l<0){let{result:n}=await a.cdpSend(e,"Runtime.callFunctionOn",{objectId:r.objectId,functionDeclaration:"function() {\n var r = this.getBoundingClientRect();\n return { top: r.top, bottom: r.bottom, left: r.left, right: r.right, vh: window.innerHeight, vw: window.innerWidth };\n }",returnByValue:!0}),i=n.value;if(i){let e=i.top<0?Math.round(i.top-100):i.bottom>i.vh?Math.round(i.bottom-i.vh+100):0,n=0!==e?" Scroll ".concat(e>0?"down":"up"," ~").concat(Math.abs(e),"px (wheel dy=").concat(e," at current mouse position)"):"";throw Error('Element ref "'.concat(t.ref,'" is not in the viewport and cannot auto-scroll because this batch contains x,y coordinates that would be invalidated by scrolling.').concat(n))}}return{x:s,y:l}}catch(o){var i;if(null===(i=o.message)||void 0===i?void 0:i.includes("not in the viewport"))throw o;if(n)try{await a.cdpSend(e,"Runtime.callFunctionOn",{objectId:r.objectId,functionDeclaration:'function() { this.scrollIntoView({ block: "center", inline: "center", behavior: "instant" }); }',returnByValue:!0}),await new Promise(e=>setTimeout(e,100));let{model:t}=await a.cdpSend(e,"DOM.getBoxModel",{objectId:r.objectId}),n=t.content;return{x:Math.round((n[0]+n[2]+n[4]+n[6])/4),y:Math.round((n[1]+n[3]+n[5]+n[7])/4)}}catch(e){throw Error('Element ref "'.concat(t.ref,'" could not be scrolled into view'))}try{let{result:n}=await a.cdpSend(e,"Runtime.callFunctionOn",{objectId:r.objectId,functionDeclaration:"function() {\n var r = this.getBoundingClientRect();\n return { top: r.top, bottom: r.bottom, left: r.left, right: r.right, vh: window.innerHeight, vw: window.innerWidth };\n }",returnByValue:!0}),i=n.value;if(i){let e=i.top<0?Math.round(i.top-100):i.bottom>i.vh?Math.round(i.bottom-i.vh+100):0,n=0!==e?" Scroll ".concat(e>0?"down":"up"," ~").concat(Math.abs(e),"px (wheel dy=").concat(e," at current mouse position)"):"";throw Error('Element ref "'.concat(t.ref,'" is not in the viewport and cannot auto-scroll because this batch contains x,y coordinates that would be invalidated by scrolling.').concat(n))}}catch(e){if(e.message.includes("not in the viewport"))throw e}throw Error('Element ref "'.concat(t.ref,'" is not visible in the viewport — use only refs or scroll manually first'))}finally{a.cdpSend(e,"Runtime.releaseObject",{objectId:r.objectId}).catch(e=>console.error(e))}}return{x:t.x,y:t.y}}async function m(e,t,n,a,i,r){let o=window.bangonit,s=Math.hypot(a-t,i-n);if(s<1){null==r||r(a,i);return}let l=Math.min(Math.max(Math.round(s/15),3),40),c=Math.min(Math.max(.8*s,30),300);for(let s=1;s<=l;s++){let u=s/l,d=u<.5?4*u*u*u:1-Math.pow(-2*u+2,3)/2,h=Math.round(t+(a-t)*d),p=Math.round(n+(i-n)*d);await o.cdpSend(e,"Input.dispatchMouseEvent",{type:"mouseMoved",x:h,y:p}),null==r||r(h,p),s<l&&await new Promise(e=>setTimeout(e,c/l))}}async function w(e,t,n,a,i){var r,o,s,l,c,u,d,h;let w=window.bangonit;null===(r=i.onMouseLock)||void 0===r||r.call(i);let g=!t.some(e=>"wait"!==e.action&&void 0!==e.x),b=n,f=a;try{let n=[];for(let a of t){if("wait"===a.action){await new Promise(e=>setTimeout(e,Math.min(a.ms||100,2e3))),n.push("wait(".concat(a.ms||100,"ms)"));continue}let t=a.ref?{ref:a.ref}:{x:a.x,y:a.y},r=await p(e,t,g),h="".concat(r.x,",").concat(r.y),{x:v,y:x}=r;switch(a.action){case"down":await m(e,b,f,v,x,i.onCursorMove),b=v,f=x,null===(o=i.onCursorDown)||void 0===o||o.call(i,v,x),await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mousePressed",x:v,y:x,button:"left",clickCount:1}),n.push("down(".concat(h,")"));break;case"move":await m(e,b,f,v,x,i.onCursorMove),b=v,f=x,n.push("move(".concat(h,")"));break;case"up":await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mouseReleased",x:v,y:x,button:"left",clickCount:1}),null===(s=i.onCursorUp)||void 0===s||s.call(i,v,x),n.push("up(".concat(h,")"));break;case"click":await m(e,b,f,v,x,i.onCursorMove),b=v,f=x,null===(l=i.onCursorDown)||void 0===l||l.call(i,v,x),await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mousePressed",x:v,y:x,button:"left",clickCount:1}),await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mouseReleased",x:v,y:x,button:"left",clickCount:1}),null===(c=i.onCursorUp)||void 0===c||c.call(i,v,x),n.push("click(".concat(h,")"));break;case"dblclick":await m(e,b,f,v,x,i.onCursorMove),b=v,f=x,null===(u=i.onCursorDown)||void 0===u||u.call(i,v,x),await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mousePressed",x:v,y:x,button:"left",clickCount:1}),await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mouseReleased",x:v,y:x,button:"left",clickCount:1}),await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mousePressed",x:v,y:x,button:"left",clickCount:2}),await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mouseReleased",x:v,y:x,button:"left",clickCount:2}),null===(d=i.onCursorUp)||void 0===d||d.call(i,v,x),n.push("dblclick(".concat(h,")"));break;case"wheel":{await m(e,b,f,v,x,i.onCursorMove),b=v,f=x;let t=a.dx||0,r=a.dy||0;await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mouseWheel",x:v,y:x,deltaX:t,deltaY:r}),n.push("wheel(".concat(h,",").concat(t,",").concat(r,")"))}}}return{result:"Mouse: ".concat(n.join(" → ")),mouseX:b,mouseY:f}}finally{null===(h=i.onMouseUnlock)||void 0===h||h.call(i)}}async function g(e,t){let n=window.bangonit;for(let a of t)await n.sendInputEvent(e,{type:"keyDown",keyCode:a}),await n.sendInputEvent(e,{type:"char",keyCode:a}),await n.sendInputEvent(e,{type:"keyUp",keyCode:a}),await new Promise(e=>setTimeout(e,30+70*Math.random()));return'Typed "'.concat(t.slice(0,50),'"')}async function b(e,t){let n=window.bangonit,a=t.split("+"),i=a.pop(),r=a.map(e=>e.toLowerCase()),o=[];for(let e of r)"control"===e||"ctrl"===e?o.push("control"):"meta"===e||"command"===e||"cmd"===e?o.push("meta"):"alt"===e||"option"===e?o.push("alt"):"shift"===e&&o.push("shift");return await n.sendInputEvent(e,{type:"keyDown",keyCode:i,modifiers:o}),0===o.length&&("Enter"===i?await n.sendInputEvent(e,{type:"char",keyCode:"\r"}):1===i.length&&await n.sendInputEvent(e,{type:"char",keyCode:i})),await n.sendInputEvent(e,{type:"keyUp",keyCode:i,modifiers:o}),"Pressed ".concat(t)}let f=new Map;async function v(e){let t=new TextEncoder().encode(e);return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",t))).map(e=>e.toString(16).padStart(2,"0")).join("")}async function x(e){let t;let n=window.bangonit;try{t=await n.capturePage(e)}catch(e){throw Error("could not capture page (page may be navigating)")}let{activeTabId:a}=await n.getTabInfo(e),i="".concat(e,":").concat(null!=a?a:0),r=await v(t);return f.get(i)===r?{type:"not_changed"}:(f.set(i,r),{type:"changed",base64:t})}async function y(e,t){let n=window.bangonit;t.startsWith("http://")||t.startsWith("https://")||(t="https://"+t);let{url:a}=await n.loadURL(e,t);return"Navigated to ".concat(a)}async function k(e){let{ok:t,url:n,reason:a}=await window.bangonit.goBack(e);return t?"Navigated back to ".concat(n):"Cannot go back — ".concat(a)}async function I(e){let{ok:t,url:n,reason:a}=await window.bangonit.goForward(e);return t?"Navigated forward to ".concat(n):"Cannot go forward — ".concat(a)}async function T(e,t){let n=window.bangonit,a=t.action;switch(a){case"list":{let{tabs:t,activeTabId:a}=await n.getTabInfo(e);if(!t.length)return"No tabs open";return t.map(e=>{let t=e.tabId===a?" (active)":"",n=e.isPopup?" (popup)":"";return"Tab ".concat(e.tabId,": ").concat(e.title||"(untitled)"," — ").concat(e.url).concat(t).concat(n)}).join("\n")}case"new":{await n.requestNewTab(e,t.url||"about:blank"),await new Promise(e=>setTimeout(e,3e3));let{activeTabId:a}=await n.getTabInfo(e);return"Opened new tab".concat(t.url?": "+t.url:"",". Active tab is now ").concat(a,".")}case"select":{let a=t.tabId;if(void 0===a)return"Error: tabId required for select";let{tabs:i}=await n.getTabInfo(e);if(!i.find(e=>e.tabId===a))return"Error: tab ".concat(a,' not found. Use browser_tabs with action "list" to see available tabs.');await n.setActiveTab(e,a),await n.requestSelectTab(e,a);let r=i.find(e=>e.tabId===a);return"Switched to tab ".concat(a,": ").concat(null==r?void 0:r.url)}case"close":{var i;let{tabs:a,activeTabId:r}=await n.getTabInfo(e),o=null!==(i=t.tabId)&&void 0!==i?i:r;if(null===o)return"Error: no tab to close";if(!a.find(e=>e.tabId===o))return"Error: tab ".concat(o," not found.");if(a.length<=1)return"Cannot close the last tab.";return await n.requestCloseTab(e,o),"Closed tab ".concat(o)}default:return'Error: unknown tab action "'.concat(a,'". Use list, new, select, or close.')}}async function N(e){let{tabs:t,activeTabId:n}=await window.bangonit.getTabInfo(e);return t.length<=1?"":"\n\nOpen tabs:\n"+t.map(e=>{let t=e.tabId===n?" (active)":"",a=e.isPopup?" (popup)":"";return" Tab ".concat(e.tabId,": ").concat(e.title||"(untitled)"," — ").concat(e.url).concat(t).concat(a)}).join("\n")}async function C(e,t){let n=window.bangonit,a=Math.min(Math.max((null==t?void 0:t.timeout)||10,.1),30),i=null==t?void 0:t.text,r="visible"===((null==t?void 0:t.state)||"visible");if(!i)return await new Promise(e=>setTimeout(e,1e3*a)),"Waited ".concat(a," seconds");let o=Date.now()+1e3*a;for(;Date.now()<o;){let{result:t}=await n.cdpSend(e,"Runtime.evaluate",{expression:"document.body.innerText.includes(".concat(JSON.stringify(i),")"),returnByValue:!0}),a=t.value;if(r&&a)return'Text "'.concat(i,'" is now visible on the page.');if(!r&&!a)return'Text "'.concat(i,'" is no longer visible on the page.');await new Promise(e=>setTimeout(e,500))}return'Timeout: text "'.concat(i,'" ').concat(r?"did not appear":"did not disappear"," within ").concat(a,"s.")}class j{start(){!this.cleanup&&window.bangonit&&(this.cleanup=window.bangonit.onCdpEvent(e=>{"Network.requestWillBeSent"===e.method?this.inflightRequests++:("Network.loadingFinished"===e.method||"Network.loadingFailed"===e.method)&&(this.inflightRequests=Math.max(0,this.inflightRequests-1))}))}stop(){var e;null===(e=this.cleanup)||void 0===e||e.call(this),this.cleanup=null,this.inflightRequests=0}async waitForIdle(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:500,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3,n=Date.now()+t,a=0===this.inflightRequests?Date.now():null;for(;Date.now()<n;){if(0===this.inflightRequests){if(a||(a=Date.now()),Date.now()-a>=e)return}else a=null;await new Promise(e=>setTimeout(e,50))}}constructor(){this.inflightRequests=0,this.cleanup=null}}let E={navigate:"browser_navigate",back:"browser_navigate_back",forward:"browser_go_forward",mouse:"browser_mouse",type:"browser_type",press:"browser_press_key",tabs:"browser_tabs",upload:"browser_upload",wait:"browser_wait_for",close:"browser_close"};var S=n(8204);let R=S.VK("type",[S.Ry({type:S.i0("not_changed")}),S.Ry({type:S.i0("changed"),base64:S.Z_()})]);S.Ry({textOutput:S.Z_(),imageOutput:R.nullable()});let M=Promise.resolve();class P{destroy(){this.networkTracker.stop()}enableRecording(e){this.recorder=e}cursorCallbacks(){let e=this.agentId,t=window.bangonit,n=this.recorder;return{onCursorMove:(a,i)=>{t.emitCursorMove(e,a,i),null==n||n.updateCursor(a,i)},onCursorDown:(a,i)=>{t.emitCursorDown(e,a,i),null==n||n.setCursorDown()},onCursorUp:(a,i)=>{t.emitCursorUp(e,a,i),null==n||n.setCursorUp()},onMouseLock:()=>t.emitMouseLock(e),onMouseUnlock:()=>t.emitMouseUnlock(e)}}async callTool(e,t){switch(e){case"browser_navigate":return y(this.agentId,t.url);case"browser_navigate_back":return k(this.agentId);case"browser_go_forward":return I(this.agentId);case"browser_mouse":{let{result:e,mouseX:n,mouseY:a}=await w(this.agentId,t.steps,this.mouseX,this.mouseY,this.cursorCallbacks());return this.mouseX=n,this.mouseY=a,e}case"browser_type":return g(this.agentId,t.text);case"browser_press_key":return b(this.agentId,t.key);case"browser_close":return T(this.agentId,{action:"close"});case"browser_upload":{var n;if(t.cancel){let e=await window.bangonit.handleFileChooser(this.agentId,"cancel");if(!e.ok)return"Error: ".concat(e.error);return"File picker cancelled."}if(!(null===(n=t.paths)||void 0===n?void 0:n.length))return"Error: provide paths to upload, or cancel: true";let e=await window.bangonit.handleFileChooser(this.agentId,"accept",t.paths);if(!e.ok)return"Error: ".concat(e.error);return"Uploaded ".concat(t.paths.length," file(s).")}case"browser_wait_for":return C(this.agentId,t);case"browser_tabs":return T(this.agentId,t);default:throw Error("Unknown tool: ".concat(e))}}async exec(e){let t=function(){let e;let t=new Promise(t=>{e=t}),n=M;return M=M.then(()=>t),{promise:n,release:e}}();await t.promise;try{return await this._exec(e)}finally{t.release()}}async _exec(e){let{actions:t,observe:n}=e,a=[],i=null;if(this.recorder)try{var r,o,s;let e=await (null===(r=window.bangonit)||void 0===r?void 0:r.getTabInfo(this.agentId)),t=null!==(s=null==e?void 0:e.activeTabId)&&void 0!==s?s:0,n=null==e?void 0:null===(o=e.tabs)||void 0===o?void 0:o.find(e=>e.tabId===t);await this.recorder.startClip(t,null==n?void 0:n.url)}catch(e){console.warn("Failed to start recording clip:",e)}for(let e=0;e<t.length;e++){let n=t[e];if(!n||!n.action)continue;let i=E[n.action];if(!i){a.push("".concat(n.action,": Error — unknown action"));continue}try{let e=this.actionToToolArgs(n),t=await this.callTool(i,e);a.push(t||"OK")}catch(e){a.push("".concat(this.actionLabel(n),": Error — ").concat(e.message))}}if(n){t.length>0&&await this.networkTracker.waitForIdle(500,2e3);try{let e=await N(this.agentId),t=await h(this.agentId,this.mouseX,this.mouseY,e);a.push(t),"snapshot_and_screenshot"===n&&(i=await x(this.agentId))}catch(e){a.push("observe: Error — ".concat(e.message))}}if(this.recorder)try{await this.recorder.stopClip()}catch(e){console.warn("Failed to stop recording clip:",e)}return{textOutput:a.join("\n\n"),imageOutput:i}}actionToToolArgs(e){switch(e.action){case"navigate":return{url:e.url};case"back":case"forward":case"close":default:return{};case"mouse":return{steps:(e.mouseActions||[]).map(e=>{if("wait"===e.action)return{action:"wait",ms:e.ms||100};let t=e.ref?{ref:e.ref}:{x:e.x,y:e.y};return"wheel"===e.action?{action:"wheel",...t,dx:e.dx||0,dy:e.dy||0}:{action:e.action,...t}})};case"type":return{text:e.text};case"press":return{key:e.key};case"upload":return{paths:e.paths,cancel:e.cancel};case"tabs":return{action:e.tabAction,tabId:e.tabId,url:e.url};case"wait":return{timeout:e.timeout}}}actionLabel(e){switch(e.action){case"navigate":return"navigate ".concat(e.url);case"mouse":{let t=(e.mouseActions||[]).map(e=>"wait"===e.action?"wait ".concat(e.ms,"ms"):"wheel"===e.action?"wheel ".concat(e.x,",").concat(e.y," ").concat(e.dx,",").concat(e.dy):"".concat(e.action," ").concat(e.x,",").concat(e.y)).join(" → ");return"mouse ".concat(t)}case"type":return'type "'.concat((e.text||"").slice(0,30),'"');case"press":return"press ".concat(e.key);case"upload":return e.cancel?"upload cancel":"upload ".concat((e.paths||[]).join(", "));case"tabs":return"tabs ".concat(e.tabAction).concat(e.tabId?" "+e.tabId:"");case"wait":return"wait ".concat(e.timeout||10,"s");default:return e.action}}constructor(e){this.mouseX=0,this.mouseY=0,this.networkTracker=new j,this.recorder=null,this.agentId=e,this.networkTracker.start()}}class z{async captureFrame(){let e=window.bangonit;try{let t=await e.capturePage(this.agentId),{result:n}=await e.cdpSend(this.agentId,"Runtime.evaluate",{expression:"JSON.stringify({w:window.innerWidth,h:window.innerHeight})",returnByValue:!0}),a=JSON.parse(n.value);this.currentFrames.push({imageData:t,cursor:{...this.cursorPos},clicking:this.clicking,ts:Date.now(),sessionId:0,deviceWidth:a.w,deviceHeight:a.h,scrollOffsetX:0,scrollOffsetY:0})}catch(e){console.warn("Failed to capture frame:",e)}}async startClip(e,t){this.currentUrl=t||"",this.recording&&await this.cancelClip(),this.recording=!0,this.currentTabId=e,this.currentFrames=[],this.cursorTrail=[],this.clipStartTime=Date.now(),await this.captureFrame();let n=window.bangonit;this.cdpCleanup=n.onCdpEvent(e=>{if(e.agentId!==this.agentId||"Page.screencastFrame"!==e.method||!this.recording)return;let{data:t,metadata:a,sessionId:i}=e.params;this.currentFrames.push({imageData:t,cursor:{...this.cursorPos},clicking:this.clicking,ts:Date.now(),sessionId:i,deviceWidth:(null==a?void 0:a.deviceWidth)||0,deviceHeight:(null==a?void 0:a.deviceHeight)||0,scrollOffsetX:(null==a?void 0:a.scrollOffsetX)||0,scrollOffsetY:(null==a?void 0:a.scrollOffsetY)||0}),n.cdpSend(this.agentId,"Page.screencastFrameAck",{sessionId:i}).catch(e=>console.error(e))}),await n.cdpSend(this.agentId,"Page.startScreencast",{format:"png",quality:100,maxWidth:1920,maxHeight:1080})}async stopClip(){if(!this.recording)return null;await this.captureFrame(),this.recording=!1;let e=Date.now();await window.bangonit.cdpSend(this.agentId,"Page.stopScreencast").catch(e=>console.error(e)),this.cdpCleanup&&(this.cdpCleanup(),this.cdpCleanup=null);let t=this.currentFrames;if(this.currentFrames=[],0===t.length)return null;let n=await this.compositeAndEncode(t);if(!n||0===n.size)return null;let a=new Uint8Array(await n.arrayBuffer()),i="";for(let e=0;e<a.length;e++)i+=String.fromCharCode(a[e]);let r=btoa(i),o={agentId:this.agentId,tabId:this.currentTabId,index:this.clips.length,startTime:this.clipStartTime,endTime:e,url:this.currentUrl||void 0,data:r};return this.clips.push(o),{meta:o}}async cancelClip(){var e;this.recording=!1,this.currentFrames=[],this.cursorTrail=[],this.cdpCleanup&&(this.cdpCleanup(),this.cdpCleanup=null),await (null===(e=window.bangonit)||void 0===e?void 0:e.cdpSend(this.agentId,"Page.stopScreencast").catch(e=>console.error(e)))}async compositeAndEncode(e){if(0===e.length)return null;let t=await this.decodeFrame(e[0].imageData);if(!t)return null;let n=t.width,a=t.height,i=document.createElement("canvas");i.width=n,i.height=a;let r=i.getContext("2d"),o=i.captureStream(0),s=o.getVideoTracks()[0],l=new MediaRecorder(o,{mimeType:"video/webm;codecs=vp8",videoBitsPerSecond:8e6}),d=[];l.ondataavailable=e=>{e.data.size>0&&d.push(e.data)};let h=new Promise(e=>{l.onstop=()=>{e(new Blob(d,{type:"video/webm"}))}});l.start();let p=[],m=this.cursorTrail,w=0,g=(e,t,i,o,l,d,h)=>{let m=t*d,w=i*h;o&&(!p.length||p[p.length-1].x!==m||p[p.length-1].y!==w)&&p.push({x:m,y:w,startTs:l}),r.clearRect(0,0,n,a),r.drawImage(e,0,0,n,a);for(let e=p.length-1;e>=0;e--){let t=p[e],n=l-t.startTs;if(n>=400){p.splice(e,1);continue}u(r,t.x,t.y,n/400)}c(r,m,w,o),s&&"function"==typeof s.requestFrame&&s.requestFrame()};for(let i=0;i<e.length;i++){let r=e[i],o=0===i?t:await this.decodeFrame(r.imageData);if(!o)continue;let s=r.deviceWidth>0?n/r.deviceWidth:1,l=r.deviceHeight>0?a/r.deviceHeight:1,c=i<e.length-1?e[i+1].ts:r.ts+100;for(g(o,r.cursor.x,r.cursor.y,r.clicking,r.ts,s,l);w<m.length&&m[w].ts<=r.ts;)w++;let u=r.ts;for(;w<m.length&&m[w].ts<c;){let e=m[w],t=e.ts-u;t>0&&await new Promise(e=>setTimeout(e,Math.min(t,16))),g(o,e.x,e.y,e.clicking,e.ts,s,l),u=e.ts,w++}if(i<e.length-1){let e=c-u;e>0&&await new Promise(t=>setTimeout(t,Math.min(e,100)))}}return await new Promise(e=>setTimeout(e,100)),l.stop(),h}async decodeFrame(e){try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);let a=new Blob([n],{type:"image/png"});return createImageBitmap(a)}catch(e){return console.warn("Failed to decode frame:",e),null}}updateCursor(e,t){this.cursorPos={x:e,y:t},this.recording&&this.cursorTrail.push({ts:Date.now(),x:e,y:t,clicking:this.clicking})}setCursorDown(){this.clicking=!0,this.recording&&this.cursorTrail.push({ts:Date.now(),...this.cursorPos,clicking:!0})}setCursorUp(){this.clicking=!1,this.recording&&this.cursorTrail.push({ts:Date.now(),...this.cursorPos,clicking:!1})}getClipsMeta(){return[...this.clips]}constructor(e){this.clips=[],this.currentFrames=[],this.cursorPos={x:0,y:0},this.clicking=!1,this.recording=!1,this.currentTabId=0,this.clipStartTime=0,this.cdpCleanup=null,this.ripples=[],this.cursorTrail=[],this.currentUrl="",this.agentId=e}}function A(e){var t;let{agentId:n,agentName:s,initialPrompt:l,onStatusChange:c,onRerun:u,initialMessages:h,initialTabs:p,initialActiveTabId:m,initialTodos:w,record:g,sessionRecorder:b,onRegisterRecorder:f,planDir:v}=e,[x,y]=(0,i.useState)((null==p?void 0:p.map(e=>({...e,initialUrl:e.url})))||[{id:0,url:"about:blank",title:"",initialUrl:"about:blank"}]),[k,I]=(0,i.useState)(null!=m?m:0),[T,N]=(0,i.useState)(()=>{let e=null==p?void 0:p.find(e=>e.id===(null!=m?m:0));return(null==e?void 0:e.url)||""}),[C,j]=(0,i.useState)(null),[E,S]=(0,i.useState)(!1),[R,M]=(0,i.useState)(!1),A=(0,i.useRef)(new Map),[_,O]=(0,i.useState)(w||[]),U=(0,i.useRef)(null),F=(0,i.useRef)(!1),L=(0,i.useRef)(p?Math.max(...p.map(e=>e.id))+1:1),B=(0,i.useRef)(new Set),[H,W]=(0,i.useState)(0),V=(0,i.useRef)(null),J=(0,i.useRef)(null);!J.current&&window.bangonit&&(J.current=new P(n));let X=(0,i.useRef)(null);g&&!X.current&&J.current&&(X.current=new z(n),J.current.enableRecording(X.current),null==f||f(n,X.current));let q=(0,i.useRef)(b);q.current=b;let Y=(0,i.useMemo)(()=>new o.PD({api:"/api/chat",headers:()=>({"X-Client-Platform":navigator.platform})}),[]),G=(0,i.useRef)(!1),K=(0,i.useCallback)((e,t)=>{var a,i;null===(i=window.bangonit)||void 0===i||null===(a=i.emitAgentOutput)||void 0===a||a.call(i,{agentId:n,type:e,text:t,name:s})},[n,s]),{messages:Z,setMessages:Q,sendMessage:$,addToolOutput:ee,stop:et,status:en,error:ea}=(0,r.RJ)({transport:Y,messages:h,sendAutomaticallyWhen:e=>{let{messages:t}=e;return!G.current&&!E&&(0,o.Qk)({messages:t})},async onToolCall(e){var t,a,i,r,o,l,c,u,d;let{toolCall:h}=e;if("report_result"===h.toolName){let e=h.input,u=(null==e?void 0:e.result)==="pass"?"pass":"fail",d=(null==e?void 0:e.summary)||"";if(K("status","".concat(u.toUpperCase(),": ").concat(d)),j({result:u,summary:d}),q.current){q.current.addEvent({ts:Date.now(),agentId:n,type:"result",data:{result:u,summary:d}});try{let e=await (null===(r=window.bangonit)||void 0===r?void 0:null===(i=r.getRunDir)||void 0===i?void 0:i.call(r));if(e){let t=(null===(o=X.current)||void 0===o?void 0:o.getClipsMeta())||[],a=[{id:n,name:s,result:u,summary:d}],i=q.current.toJSON(a,t);await (null===(c=window.bangonit)||void 0===c?void 0:null===(l=c.generateReplayHtml)||void 0===l?void 0:l.call(c,{runDir:e,data:JSON.stringify(i)}))}}catch(e){console.error(e)}}null===(a=window.bangonit)||void 0===a||null===(t=a.reportTestResult)||void 0===t||t.call(a,{agentId:n,status:u,summary:d}),ee({tool:h.toolName,toolCallId:h.toolCallId,output:"Test result recorded: ".concat(u)});return}if("todos"===h.toolName){let e=h.input,t=(null==e?void 0:e.todos)||_;(null==e?void 0:e.todos)&&O(e.todos),ee({tool:h.toolName,toolCallId:h.toolCallId,output:JSON.stringify(t)});return}if("browser"===h.toolName){try{let e=h.input,t=((null==e?void 0:e.actions)||[]).map(e=>"navigate"===e.action?"navigate ".concat(e.url):"type"===e.action?'type "'.concat((e.text||"").slice(0,30),'"'):"press"===e.action?"press ".concat(e.key):"mouse"===e.action?"mouse ".concat((e.mouseActions||[]).map(e=>"".concat(e.action," ").concat(e.ref||"".concat(e.x,",").concat(e.y))).join(" > ")):e.action).join(", ");K("tool","browser: ".concat(t).concat((null==e?void 0:e.observe)?" [".concat(e.observe,"]"):"")),null===(u=q.current)||void 0===u||u.addEvent({ts:Date.now(),agentId:n,type:"tool-start",data:{tool:"browser",label:t}});let a=J.current,i=a?await a.exec({actions:(null==e?void 0:e.actions)||[],observe:null==e?void 0:e.observe,prompts:null==e?void 0:e.prompts}):{error:"Error: browser tools not available"};null===(d=q.current)||void 0===d||d.addEvent({ts:Date.now(),agentId:n,type:"tool-end",data:{tool:"browser"}}),ee({tool:h.toolName,toolCallId:h.toolCallId,output:G.current?{error:"[Stopped by user]"}:JSON.stringify(i)})}catch(e){ee({tool:h.toolName,toolCallId:h.toolCallId,...G.current?{output:"[Stopped by user]"}:{state:"output-error",errorText:e.message}})}return}}});(0,i.useCallback)(()=>{G.current=!0,et()},[et]);let ei="submitted"===en||"streaming"===en;(0,i.useEffect)(()=>{ei&&(G.current=!1)},[ei]);let er=Z.length>0,eo=null!==C;(0,i.useEffect)(()=>{if(er&&!V.current&&(V.current=Date.now()),!er||eo)return;let e=setInterval(()=>{V.current&&W(Math.floor((Date.now()-V.current)/1e3))},1e3);return()=>clearInterval(e)},[er,eo]);let es=(0,i.useRef)(null),el=(0,i.useRef)(0);(0,i.useEffect)(()=>{var e;if(0===Z.length)return;let t=Z[Z.length-1];if("assistant"!==t.role)return;let n=(null===(e=t.parts)||void 0===e?void 0:e.filter(e=>"text"===e.type).map(e=>e.text).join(""))||"";t.id!==es.current&&(es.current=t.id,el.current=0);let a=n.slice(el.current);a&&(K("text",a),el.current=n.length)},[Z,K]);let ec=(0,i.useRef)(ei),eu=(0,i.useRef)(!1);(0,i.useEffect)(()=>{!eu.current&&ec.current!==ei&&(ec.current=ei,ei?null==c||c(n,"running"):(null==c||c(n,"idle",null==C?void 0:C.result),(null==C?void 0:C.result)&&(eu.current=!0)))},[ei,n,c,C]);let ed=(0,i.useRef)(!1),eh=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(eh.current&&(clearTimeout(eh.current),eh.current=null),!ei&&!eo&&!E&&!ed.current&&!(Z.length<2))return eh.current=setTimeout(()=>{eh.current=null,ed.current||eo||(ed.current=!0,$({text:"You must call the report_result tool to finalize this test run. Call it now with the result (pass or fail) and a summary."}))},5e3),()=>{eh.current&&clearTimeout(eh.current)}},[ei,eo,E,Z.length,$]),(0,i.useEffect)(()=>{var e,t;null===(t=window.bangonit)||void 0===t||null===(e=t.clearPartition)||void 0===e||e.call(t,n)},[n]),(0,i.useEffect)(()=>{q.current&&Z.length>0&&q.current.setMessages(n,Z)},[Z,n]),(0,i.useEffect)(()=>{if(Z.length>0){var e,t,a,i;null===(a=window.bangonit)||void 0===a||a.setAgentSession(n,{messages:Z,initialPrompt:l,tabs:x.filter(e=>!e.isPopup).map(e=>{let{id:t,url:n,title:a}=e;return{id:t,url:n,title:a}}),activeTabId:(null===(e=x.find(e=>e.id===k))||void 0===e?void 0:e.isPopup)?null!==(i=null===(t=x.find(e=>!e.isPopup))||void 0===t?void 0:t.id)&&void 0!==i?i:0:k,todos:_})}},[Z,x,k,n,l,_]);let ep=(0,i.useCallback)(e=>{var t;let a=L.current++;y(t=>[...t,{id:a,url:"about:blank",title:"",initialUrl:e}]),I(a),N("about:blank"===e?"":e),null===(t=window.bangonit)||void 0===t||t.setActiveTab(n,a)},[n]),em=(0,i.useCallback)(e=>{y(t=>{let a=t.findIndex(t=>t.id===e);if(-1===a)return t;let i=t.filter(t=>t.id!==e);return 0===i.length?t:(I(t=>{if(t===e){var r;let e=i[Math.max(0,a-1)].id,t=i.find(t=>t.id===e);return t&&N("about:blank"===t.url?"":t.url),null===(r=window.bangonit)||void 0===r||r.setActiveTab(n,e),e}return t}),i)})},[n]),ew=(0,i.useCallback)(e=>{var t;I(e),null===(t=window.bangonit)||void 0===t||t.setActiveTab(n,e),y(t=>{let n=t.find(t=>t.id===e);return n&&N("about:blank"===n.url?"":n.url),t})},[n]),eg=(0,i.useRef)(ep),eb=(0,i.useRef)(em),ef=(0,i.useRef)(ew);eg.current=ep,eb.current=em,ef.current=ew,(0,i.useEffect)(()=>{var e,t,a,i,r;let o=[],s=e=>{e&&o.push(e)};return s(null===(e=window.bangonit)||void 0===e?void 0:e.onTabUpdated(e=>{if(e.agentId!==n)return;let t="about:blank"===e.url,a="about:blank"===e.title;y(n=>n.map(n=>n.id===e.tabId?{...n,...!t&&void 0!==e.url&&{url:e.url},...!a&&void 0!==e.title&&{title:e.title}}:n)),void 0===e.url||t||I(t=>(t===e.tabId&&N(e.url),t))})),s(null===(t=window.bangonit)||void 0===t?void 0:t.onOpenNewTab(e=>{e.agentId===n&&eg.current(e.url)})),s(null===(a=window.bangonit)||void 0===a?void 0:a.onPopupOpened(e=>{e.agentId===n&&y(t=>[...t,{id:e.tabId,url:e.url||"about:blank",title:"",initialUrl:e.url||"about:blank",isPopup:!0}])})),s(null===(i=window.bangonit)||void 0===i?void 0:i.onCloseTab(e=>{e.agentId===n&&eb.current(e.tabId)})),s(null===(r=window.bangonit)||void 0===r?void 0:r.onSelectTab(e=>{e.agentId===n&&ef.current(e.tabId)})),()=>o.forEach(e=>null==e?void 0:e())},[n]),(0,i.useEffect)(()=>{F.current||(null==h?void 0:h.length)||(F.current=!0,$({text:l}))},[l,$,h]),(0,i.useEffect)(()=>{var e;null===(e=U.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[Z]);let ev=(0,i.useCallback)((e,t,a)=>{if(!e)return;A.current.set(t,e);let i=()=>{if(!B.current.has(t))try{var i,r,o;let s=null===(i=e.getWebContentsId)||void 0===i?void 0:i.call(e);s&&(B.current.add(t),null===(r=window.bangonit)||void 0===r||r.registerTab(n,t,s,a,v),t===k&&(null===(o=window.bangonit)||void 0===o||o.setActiveTab(n,t)))}catch(e){console.error(e)}};i(),e.addEventListener("did-attach",i),e.addEventListener("close",()=>eb.current(t)),e._consoleListenerAttached||(e._consoleListenerAttached=!0,e.addEventListener("console-message",e=>{var t,a,i;null===(a=window.bangonit)||void 0===a||null===(t=a.emitConsoleMessage)||void 0===t||t.call(a,{agentId:n,level:e.level,message:e.message,url:e.sourceId||"",line:e.lineNumber||0}),null===(i=q.current)||void 0===i||i.addConsoleLog(n,e.level,e.message,e.sourceId||"",e.lineNumber||0)}))},[n,k]),ex=e=>"".concat(Math.floor(e/60),":").concat((e%60).toString().padStart(2,"0"));return(0,a.jsxs)("div",{className:"flex h-full w-full bg-zinc-950 overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex-1 flex flex-col border-r border-zinc-800 min-w-0",children:[(0,a.jsx)("div",{className:"flex items-center bg-zinc-900 border-b border-zinc-800 overflow-x-auto",children:x.map(e=>(0,a.jsx)("button",{onClick:()=>ew(e.id),className:"flex items-center gap-1.5 px-3 py-2 text-xs border-r border-zinc-800 min-w-0 max-w-[200px] shrink-0\n ".concat(e.id===k?"bg-zinc-800 text-zinc-200":"text-zinc-500 hover:text-zinc-300 hover:bg-zinc-850"),children:(0,a.jsxs)("span",{className:"truncate",children:[e.isPopup?"↗ ":"",e.title||(e.url&&"about:blank"!==e.url?e.url:"New Tab")]})},e.id))}),(0,a.jsx)("div",{className:"flex items-center gap-2 px-3 py-2 bg-zinc-900 border-b border-zinc-800",children:(0,a.jsx)("div",{className:"flex-1 px-3 py-1.5 bg-zinc-800 border border-zinc-700 rounded-lg text-xs text-zinc-400 truncate",children:T||"about:blank"})}),(0,a.jsxs)("div",{className:"flex-1 relative bg-white overflow-hidden",onWheel:e=>e.stopPropagation(),children:[x.map(e=>e.isPopup?e.id===k&&(0,a.jsxs)("div",{className:"absolute inset-0 flex items-center justify-center bg-zinc-900 text-zinc-400 text-sm z-[1]",children:["Popup window open — ",e.title||e.url]},e.id):(0,a.jsx)("webview",{ref:t=>ev(t,e.id,e.initialUrl),src:"about:blank",partition:"persist:agent-".concat(n),allowpopups:"",style:{width:"100%",height:"100%",position:"absolute",backgroundColor:"white",top:0,left:0,pointerEvents:e.id===k?"auto":"none",zIndex:e.id===k?1:0}},e.id)),!(null===(t=x.find(e=>e.id===k))||void 0===t?void 0:t.isPopup)&&(0,a.jsx)(d,{agentId:n}),!eo&&(0,a.jsx)("div",{className:"absolute inset-0 z-10 cursor-not-allowed"})]})]}),(0,a.jsxs)("div",{className:"w-[420px] flex flex-col h-full shrink-0",children:[(0,a.jsxs)("div",{className:"flex items-center px-4 py-3 border-b border-zinc-800",children:[(0,a.jsx)("h2",{className:"text-sm font-medium text-zinc-300",children:s}),(0,a.jsx)("div",{className:"flex-1"})]}),C&&(0,a.jsxs)("div",{className:"px-4 py-2 text-sm border-b flex items-center gap-3 ".concat("pass"===C.result?"bg-green-950/30 border-green-900/50":"bg-red-950/30 border-red-900/50"),children:[(0,a.jsx)("span",{className:"font-medium ".concat("pass"===C.result?"text-green-400":"text-red-400"),children:"pass"===C.result?"PASSED":"FAILED"}),(0,a.jsx)("span",{className:"text-zinc-500 text-xs",children:ex(H)}),C.summary&&(0,a.jsx)("span",{className:"text-zinc-400 text-xs truncate flex-1",children:C.summary})]}),_.length>0&&(0,a.jsx)("div",{className:"text-xs space-y-1 px-4 py-2 border-b border-zinc-800 bg-zinc-900/80 shrink-0 max-h-48 overflow-y-auto",children:_.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center gap-2 ".concat("completed"===e.status?"text-zinc-500":"text-zinc-300"),children:[(0,a.jsx)("span",{className:"shrink-0",children:"completed"===e.status?"✓":"in_progress"===e.status?(0,a.jsx)("span",{className:"inline-block w-2 h-2 bg-blue-500 rounded-full animate-pulse"}):"○"}),(0,a.jsx)("span",{className:"completed"===e.status?"line-through":"",children:e.content})]},t))}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-3",children:[Z.map(e=>(0,a.jsx)(D,{message:e,agentName:s},e.id)),ea&&(0,a.jsx)("div",{className:"text-sm px-3 py-2 bg-red-950/30 border border-red-900/50 rounded-lg text-red-400",children:ea.message}),(0,a.jsx)("div",{ref:U})]}),(0,a.jsx)("div",{className:"px-4 py-2 border-t border-zinc-800 flex items-center gap-3 shrink-0",children:eo?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"inline-block w-2 h-2 rounded-full shrink-0 ".concat("pass"===C.result?"bg-green-500":"bg-red-500")}),(0,a.jsxs)("span",{className:"text-xs font-medium ".concat("pass"===C.result?"text-green-400":"text-red-400"),children:["pass"===C.result?"Passed":"Failed"," in ",ex(H)]}),(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("button",{onClick:()=>{let e=A.current.get(k);e&&(R?e.closeDevTools():e.openDevTools(),M(!R))},className:"text-xs px-2 py-1 rounded border transition-colors ".concat(R?"border-blue-600 text-blue-400 bg-blue-950/30":"border-zinc-700 hover:border-zinc-500 text-zinc-500 hover:text-zinc-300"),title:"Toggle DevTools",children:"DevTools"}),(0,a.jsx)("button",{onClick:()=>{var e,t;null===(t=window.bangonit)||void 0===t||null===(e=t.emitTestRerun)||void 0===e||e.call(t),null==u||u()},className:"text-xs px-3 py-1 rounded border border-zinc-700 hover:border-zinc-500 text-zinc-400 hover:text-zinc-200 transition-colors",children:"Rerun"})]}):er?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"inline-block w-2 h-2 rounded-full shrink-0 ".concat(E?"bg-amber-500":"bg-blue-500 animate-pulse")}),(0,a.jsxs)("span",{className:"text-xs text-zinc-400",children:[E?"Paused":"Working"," ",ex(H)]}),(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("button",{onClick:()=>{let e=A.current.get(k);e&&(R?e.closeDevTools():e.openDevTools(),M(!R))},className:"text-xs px-2 py-1 rounded border transition-colors ".concat(R?"border-blue-600 text-blue-400 bg-blue-950/30":"border-zinc-700 hover:border-zinc-500 text-zinc-500 hover:text-zinc-300"),title:"Toggle DevTools",children:"DevTools"}),(0,a.jsx)("button",{onClick:()=>S(!E),className:"text-xs px-2 py-1 rounded border border-zinc-700 hover:border-zinc-500 text-zinc-400 hover:text-zinc-200 transition-colors",children:E?"Continue":"Pause"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"inline-block w-2 h-2 bg-zinc-600 rounded-full shrink-0"}),(0,a.jsx)("span",{className:"text-xs text-zinc-500",children:"Queued"})]})})]})]})}function D(e){var t,n;let{message:i,agentName:r}=e;if("user"===i.role){let e=null===(n=i.parts)||void 0===n?void 0:n.find(e=>"text"===e.type);return(0,a.jsxs)("div",{className:"text-sm",children:[(0,a.jsx)("span",{className:"text-xs text-zinc-500 block mb-1",children:"Test Plan"}),(0,a.jsx)("div",{className:"text-zinc-200 prose prose-invert prose-sm max-w-none",children:(0,a.jsx)(s.UG,{remarkPlugins:[l.Z],children:(null==e?void 0:e.text)||""})})]})}return(0,a.jsx)("div",{className:"text-sm space-y-2",children:null===(t=i.parts)||void 0===t?void 0:t.map((e,t)=>{var n,i;if("text"===e.type&&e.text)return(null===(i=e.providerMetadata)||void 0===i?void 0:null===(n=i.anthropic)||void 0===n?void 0:n.type)==="compaction"?null:(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-xs text-zinc-500 block mb-1",children:r}),(0,a.jsx)("div",{className:"text-zinc-300 prose prose-invert prose-sm max-w-none",children:(0,a.jsx)(s.UG,{remarkPlugins:[l.Z],children:e.text})})]},t);if("dynamic-tool"===e.type||"string"==typeof e.type&&e.type.startsWith("tool-")){let n=e.toolName||("string"==typeof e.type?e.type.replace(/^tool-/,""):"");return"todos"===n||"report_result"===n?null:(0,a.jsx)(_,{part:e},t)}return null})})}function _(e){let{part:t}=e,[n,r]=(0,i.useState)(!1),o=t.input||{},s=t.output,l=t.state||"input-available",c=t.toolName||("string"==typeof t.type?t.type.replace(/^tool-/,""):""),u="input-streaming"===l?"":"browser"===c?(()=>{let e=(o.actions||[]).map(e=>{switch(e.action){case"navigate":return"navigate ".concat(e.url||"");case"mouse":{let t=(e.mouseActions||[]).map(e=>"wait"===e.action?"wait ".concat(e.ms,"ms"):"wheel"===e.action?"wheel ".concat(e.ref||"".concat(e.x,",").concat(e.y)):"".concat(e.action," ").concat(e.ref||"".concat(e.x,",").concat(e.y))).join(" → ");return"mouse ".concat(t)}case"type":return'type "'.concat((e.text||"").slice(0,40),'"');case"press":return"press ".concat(e.key||"");case"tabs":return"tabs ".concat(e.tabAction||"").concat(e.tabId?" "+e.tabId:"");default:return e.action||""}});return o.observe&&e.push(o.observe),e.join(", ")})():o.command||(Object.keys(o).length>0?JSON.stringify(o):"");return(0,a.jsxs)("div",{className:"text-sm",children:[(0,a.jsxs)("button",{onClick:()=>r(!n),className:"flex items-center gap-2 text-xs px-2 py-1.5 bg-zinc-900 border border-zinc-800 rounded-lg hover:border-zinc-700 transition-colors w-full text-left min-w-0",children:["input-streaming"===l||"input-available"===l?(0,a.jsx)("span",{className:"inline-block w-2 h-2 bg-amber-500 rounded-full animate-pulse shrink-0"}):(0,a.jsx)("span",{className:"text-green-500 shrink-0",children:"✓"}),(0,a.jsx)("span",{className:"text-zinc-400 font-mono truncate",children:u}),(0,a.jsx)("span",{className:"ml-auto transition-transform text-zinc-600 shrink-0 ".concat(n?"rotate-90":""),children:"▶"})]}),n&&(0,a.jsxs)("pre",{className:"mt-1 px-3 py-2 bg-zinc-900/50 rounded-lg border border-zinc-800 text-xs whitespace-pre-wrap overflow-x-auto max-h-60 overflow-y-auto",children:[u&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"text-zinc-300 select-all",children:["$ ",u]}),"\n"]}),null!=s&&(()=>{if("browser"===c&&"string"==typeof s)try{let e=JSON.parse(s);if(void 0!==e.textOutput)return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-zinc-500",children:e.textOutput}),e.imageOutput&&(0,a.jsxs)(a.Fragment,{children:["\n",(0,a.jsx)("span",{className:"changed"===e.imageOutput.type?"text-blue-400":"text-zinc-600",children:"changed"===e.imageOutput.type?"[screenshot: changed]":"[screenshot: unchanged]"})]})]})}catch(e){console.error(e)}return(0,a.jsx)("span",{className:"text-zinc-500",children:"string"==typeof s?s:JSON.stringify(s,null,2)})})()]})]})}let O={0:"debug",1:"log",2:"warn",3:"error"};class U{addEvent(e){this.events.push(e)}setMessages(e,t){let n=Date.now(),a=JSON.parse(JSON.stringify(t));for(let t=0;t<a.length;t++){let i=a[t],r="".concat(e,":").concat(t);if(this.seenParts.has(r)||this.seenParts.set(r,n),i._ts=this.seenParts.get(r),i.parts)for(let a=0;a<i.parts.length;a++){let r="".concat(e,":").concat(t,":").concat(a);this.seenParts.has(r)||this.seenParts.set(r,n),i.parts[a]._ts=this.seenParts.get(r)}}this.messages.set(e,a)}addConsoleLog(e,t,n,a,i){this.consoleLogs.has(e)||this.consoleLogs.set(e,[]),this.consoleLogs.get(e).push({ts:Date.now(),level:O[t]||"log",message:n,url:a,line:i})}toJSON(e,t){return{runId:this.runId,startTime:this.startTime,endTime:Date.now(),agents:e,timeline:[...this.events].sort((e,t)=>e.ts-t.ts),messages:Object.fromEntries(this.messages),consoleLogs:Object.fromEntries(this.consoleLogs),clips:t}}constructor(e){this.events=[],this.messages=new Map,this.consoleLogs=new Map,this.seenParts=new Map,this.runId=e,this.startTime=Date.now()}}function F(){let[e,t]=(0,i.useState)([]),[n,r]=(0,i.useState)({}),[o,s]=(0,i.useState)({}),[l,c]=(0,i.useState)(!1),[u,d]=(0,i.useState)({}),h=(0,i.useRef)(new Map),[p,m]=(0,i.useState)(null),[w,g]=(0,i.useState)(!1),[b,f]=(0,i.useState)(!1),v=(0,i.useRef)(null),x=(0,i.useRef)(new Map);(0,i.useEffect)(()=>{(async()=>{var e,n,a,i,o;let l=await (null===(e=window.bangonit)||void 0===e?void 0:e.getAgents())||[];if(0===l.length){let e={id:crypto.randomUUID(),name:"Test 1",createdAt:Date.now()};l.push(e),await (null===(a=window.bangonit)||void 0===a?void 0:a.setAgents(l))}t(l);let u={},d={};for(let e of l){let t=await (null===(i=window.bangonit)||void 0===i?void 0:i.getAgentSession(e.id));t&&(null===(o=t.messages)||void 0===o?void 0:o.length)>0&&(u[e.id]={initialPrompt:t.initialPrompt,initialMessages:t.messages.map(e=>{if("assistant"!==e.role||!e.parts)return e;let t=e.parts.map(e=>"tool-invocation"===e.type&&"result"!==e.state?{...e,state:"result",output:"[Interrupted — app was restarted]"}:e);return{...e,parts:t}}),initialTabs:t.tabs,initialActiveTabId:t.activeTabId,initialTodos:t.todos},d[e.id]="idle")}s(u),r(d),m((null===(n=l[0])||void 0===n?void 0:n.id)||null),c(!0)})()},[]);let y=(0,i.useRef)(e);y.current=e,(0,i.useEffect)(()=>{if(l&&e.length>0){var t;null===(t=window.bangonit)||void 0===t||t.setAgents(e)}},[e,l]);let k=(0,i.useCallback)(async e=>{var t,n;await (null===(n=window.bangonit)||void 0===n?void 0:null===(t=n.clearPartition)||void 0===t?void 0:t.call(n,e));let a=o[e];a&&(r(t=>({...t,[e]:"running"})),d(t=>({...t,[e]:(t[e]||0)+1})),s(t=>({...t,[e]:{initialPrompt:a.initialPrompt}})))},[o]),I=(0,i.useCallback)((e,t)=>{x.current.set(e,t)},[]),T=(0,i.useRef)(n);T.current=n;let N=(0,i.useCallback)(async(e,t)=>{var n,a,i,r;let o=v.current;if(!o)return;let s=await (null===(a=window.bangonit)||void 0===a?void 0:null===(n=a.getRunDir)||void 0===n?void 0:n.call(a));if(!s)return;let l=[];for(let e of x.current.values())l.push(...e.getClipsMeta());let c={...T.current,[e]:t},u=y.current.map(e=>{let t=c[e.id];return{id:e.id,name:e.name,result:"completed"===t?"pass":"failed"===t?"fail":void 0}}),d=o.toJSON(u,l);await (null===(r=window.bangonit)||void 0===r?void 0:null===(i=r.generateReplayHtml)||void 0===i?void 0:i.call(r,{runDir:s,data:JSON.stringify(d)}))},[]),C=(0,i.useCallback)((e,t,n)=>{let a;if(a="running"===t?"running":"pass"===n?"completed":"fail"===n?"failed":"idle",r(t=>({...t,[e]:a})),w&&("pass"===n||"fail"===n)&&N(e,a),"fail"===n){let t=h.current.get(e);if(t&&t.attempt<t.maxRetries){var i,o;t.attempt++,null===(o=window.bangonit)||void 0===o||null===(i=o.emitTestRetry)||void 0===i||i.call(o,{agentId:e,attempt:t.attempt,maxRetries:t.maxRetries}),setTimeout(()=>k(e),1e3)}}},[k,w,N]),j=(0,i.useCallback)((e,n,a)=>{a&&t(t=>t.map(t=>t.id===e?{...t,name:a}:t)),s(t=>({...t,[e]:{initialPrompt:n}})),r(t=>({...t,[e]:"running"})),m(e)},[]),E=(0,i.useCallback)(()=>{let n=crypto.randomUUID(),a={id:n,name:"Test ".concat(e.length+1),createdAt:Date.now()};t(e=>[...e,a]),m(n)},[e.length]);if((0,i.useEffect)(()=>{var e,n;let a=null===(n=window.bangonit)||void 0===n?void 0:null===(e=n.onTestPlan)||void 0===e?void 0:e.call(n,e=>{f(!0);let{agentIndex:n,testPlan:a,name:i,retries:o,extraPrompt:l,record:c,planDir:u}=e;if(c&&!v.current){let e=new Date().toISOString().replace(/[:.]/g,"-");v.current=new U(e),g(!0)}t(e=>{let t=n+1,a=[...e];for(;a.length<t;)a.push({id:crypto.randomUUID(),name:i||"Test ".concat(a.length+1),createdAt:Date.now()});return i&&(a=a.map((e,t)=>t===n?{...e,name:i}:e)),a}),setTimeout(()=>{t(e=>{let t=e[n];if(!t)return e;let i=l?"".concat(a,"\n\n## Additional Instructions\n").concat(l):a;return s(e=>({...e,[t.id]:{initialPrompt:i,planDir:u}})),r(e=>({...e,[t.id]:"running"})),o&&o>0&&h.current.set(t.id,{maxRetries:o,attempt:0,testPlan:i}),0===n&&m(t.id),e})},100)});return()=>null==a?void 0:a()},[]),(0,i.useEffect)(()=>{var e,t;let n=null===(t=window.bangonit)||void 0===t?void 0:null===(e=t.onFocusAgent)||void 0===e?void 0:e.call(t,e=>{m(e.agentId)});return()=>null==n?void 0:n()},[]),!l)return(0,a.jsx)("div",{className:"flex h-screen bg-zinc-950"});e.some(e=>o[e.id]);let S=e.find(e=>e.id===p),R=!!p&&!!o[p];return(0,a.jsxs)("div",{className:"flex h-screen bg-zinc-950 overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex flex-col bg-zinc-900 border-r border-zinc-800 shrink-0 w-48 overflow-y-auto",children:[(0,a.jsxs)("div",{className:"flex items-center px-3 py-2 border-b border-zinc-800",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-zinc-500 uppercase tracking-wider",children:"Tests"}),(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("button",{onClick:E,className:"text-zinc-500 hover:text-zinc-300 transition-colors text-lg leading-none",title:"Add test",children:"+"})]}),e.map(e=>{let t=n[e.id];return o[e.id],(0,a.jsx)("button",{onClick:()=>m(e.id),className:"px-3 py-2 text-xs text-left border-b border-zinc-800 transition-colors\n ".concat(e.id===p?"bg-zinc-800 text-zinc-200":"text-zinc-500 hover:text-zinc-300"),children:(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block w-2 h-2 rounded-full shrink-0 ".concat("running"===t?"bg-blue-500 animate-pulse":"completed"===t?"bg-green-500":"failed"===t?"bg-red-500":"bg-zinc-600")}),(0,a.jsx)("span",{className:"truncate",children:e.name})]})},e.id)})]}),(0,a.jsxs)("div",{className:"flex-1 min-w-0 h-full relative",children:[e.map(e=>o[e.id]?(0,a.jsx)("div",{className:"absolute inset-0 z-0",style:{display:"flex",zIndex:e.id===p?1:0,pointerEvents:e.id===p?"auto":"none"},children:(0,a.jsx)(A,{agentId:e.id,agentName:e.name,initialPrompt:o[e.id].initialPrompt,initialMessages:o[e.id].initialMessages,initialTabs:o[e.id].initialTabs,initialActiveTabId:o[e.id].initialActiveTabId,initialTodos:o[e.id].initialTodos,onStatusChange:C,onRerun:()=>k(e.id),record:w,sessionRecorder:v.current||void 0,onRegisterRecorder:I,planDir:o[e.id].planDir})},"".concat(e.id,"-").concat(u[e.id]||0)):null),S&&!R&&!b&&(0,a.jsx)(L,{agentId:S.id,agentName:S.name,onSubmit:j})]})]})}function L(e){let{agentId:t,agentName:n,onSubmit:r}=e,[o,s]=(0,i.useState)(""),l=(0,i.useRef)(null);(0,i.useEffect)(()=>{var e;null===(e=l.current)||void 0===e||e.focus()},[t]);let c=()=>{let e=o.trim();e&&r(t,e)};return(0,a.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-10 bg-zinc-950",children:(0,a.jsxs)("div",{className:"w-full max-w-xl px-6",children:[(0,a.jsx)("h2",{className:"text-lg font-medium text-zinc-200 mb-4",children:"What would you like to test?"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("textarea",{ref:l,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),c())},placeholder:"Describe what to test in plain English...",className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-700 rounded-lg text-sm text-zinc-200 placeholder-zinc-500 resize-none focus:outline-none focus:border-zinc-500 transition-colors",rows:4}),(0,a.jsx)("button",{onClick:c,disabled:!o.trim(),className:"absolute bottom-3 right-3 px-3 py-1.5 bg-blue-600 hover:bg-blue-500 disabled:bg-zinc-700 disabled:text-zinc-500 text-white text-xs font-medium rounded transition-colors",children:"Run"})]}),(0,a.jsx)("p",{className:"text-xs text-zinc-600 mt-2",children:"Press Enter to run. Shift+Enter for a new line."}),(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsx)("p",{className:"text-xs text-zinc-600 mb-2",children:"Examples:"}),(0,a.jsx)("div",{className:"flex flex-col gap-1.5",children:["Go to example.com and verify the homepage loads with a heading","Navigate to my-app.com/login, sign in with test@example.com / password123, and verify the dashboard loads","Go to localhost:3000, add an item to the cart, proceed to checkout, and verify the order summary"].map((e,t)=>(0,a.jsx)("button",{onClick:()=>s(e),className:"text-left text-xs text-zinc-500 hover:text-zinc-300 bg-zinc-900 hover:bg-zinc-800 px-3 py-2 rounded border border-zinc-800 transition-colors",children:e},t))})]})]})})}function B(){return(0,a.jsx)(F,{})}}},function(e){e.O(0,[46,631,293,528,744],function(){return e(e.s=6421)}),_N_E=e.O()}]);
|
package/app/webapp/.next/standalone/app/webapp/.next/static/chunks/app/layout-57acb80d8da0067a.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[185],{4143:function(n,e,u){Promise.resolve().then(u.t.bind(u,2625,23))},2625:function(){}},function(n){n.O(0,[387,293,528,744],function(){return n(n.s=4143)}),_N_E=n.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[191],{6421:function(e,t,n){Promise.resolve().then(n.bind(n,5274))},5274:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return B}});var a=n(7573),i=n(7653),r=n(774),o=n(1446),s=n(2574),l=n(3334);function c(e,t,n,a){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;if(i<=0)return;e.save(),e.globalAlpha=i;let r=a?.8:1;e.save(),e.translate(t-2,n-1),e.scale(28/24*r,28/24*r);let o=new Path2D("M5 3l14 8.5-6.5 1.5-3.5 6z");e.shadowColor="rgba(0,0,0,0.5)",e.shadowBlur=2,e.shadowOffsetY=1,e.fillStyle="white",e.strokeStyle="black",e.lineWidth=1.5,e.lineJoin="round",e.fill(o),e.stroke(o),e.restore(),e.restore()}function u(e,t,n,a){a>=1||(e.save(),e.beginPath(),e.arc(t,n,24*a,0,2*Math.PI),e.fillStyle="rgba(96, 165, 250, ".concat(.8*(1-a),")"),e.fill(),e.restore(),e.save(),e.beginPath(),e.arc(t,n,32*a,0,2*Math.PI),e.strokeStyle="rgba(96, 165, 250, ".concat(.9*(1-a),")"),e.lineWidth=2,e.stroke(),e.restore())}function d(e){let{agentId:t}=e,n=(0,i.useRef)(null),r=(0,i.useRef)({x:0,y:0,clicking:!1,lastActiveTs:0,hasPos:!1,ripples:[],rafId:0}),o=(0,i.useCallback)(()=>{r.current.lastActiveTs=Date.now()},[]);return(0,i.useEffect)(()=>{let e=n.current;if(!e)return;let t=e.getContext("2d"),a=window.devicePixelRatio||1,i=()=>{let n=e.parentElement;if(!n)return;let i=n.clientWidth,r=n.clientHeight;e.width=i*a,e.height=r*a,e.style.width=i+"px",e.style.height=r+"px",t.setTransform(a,0,0,a,0,0)};i();let o=new ResizeObserver(i);o.observe(e.parentElement);let s=()=>{let n=r.current,i=e.width/a,o=e.height/a;if(t.clearRect(0,0,i,o),n.hasPos){let e=Date.now(),a=e-n.lastActiveTs;for(let a=n.ripples.length-1;a>=0;a--){let i=n.ripples[a],r=e-i.startTs;if(r>=400){n.ripples.splice(a,1);continue}u(t,i.x,i.y,r/400)}c(t,n.x,n.y,n.clicking,a<2e3?1:Math.max(0,1-(a-2e3)/400))}r.current.rafId=requestAnimationFrame(s)};return r.current.rafId=requestAnimationFrame(s),()=>{cancelAnimationFrame(r.current.rafId),o.disconnect()}},[]),(0,i.useEffect)(()=>{var e,n,a;let i=[],s=r.current;return i.push(null===(e=window.bangonit)||void 0===e?void 0:e.onCursorMove(e=>{e.agentId===t&&(s.x=e.x,s.y=e.y,s.hasPos=!0,o())})),i.push(null===(n=window.bangonit)||void 0===n?void 0:n.onCursorDown(e=>{e.agentId===t&&(s.x=e.x,s.y=e.y,s.hasPos=!0,s.clicking=!0,s.ripples.push({x:e.x,y:e.y,startTs:Date.now()}),o())})),i.push(null===(a=window.bangonit)||void 0===a?void 0:a.onCursorUp(e=>{e.agentId===t&&(s.clicking=!1,o())})),()=>{i.forEach(e=>null==e?void 0:e())}},[t,o]),(0,a.jsx)("canvas",{ref:n,className:"pointer-events-none absolute inset-0 z-20"})}async function h(e,t,n,a){let[{result:i},r,o,{result:s}]=await Promise.all([window.bangonit.cdpSend(e,"Runtime.evaluate",{expression:"\n(function() {\n var MAX_CHARS = 60000;\n var MAX_ELEMENTS = 5000;\n var MAX_DEPTH = 1500;\n var totalChars = 0;\n var visited = 0;\n var truncated = false;\n var refCounter = 0;\n\n window.__dmjRefs = new Map();\n\n var SKIP_TAGS = {SCRIPT:1,STYLE:1,NOSCRIPT:1,SVG:1,PATH:1,META:1,LINK:1,TEMPLATE:1,IFRAME:1,BR:1,HR:1,WBR:1,CANVAS:1,VIDEO:1,AUDIO:1,MAP:1,AREA:1,PICTURE:1,SOURCE:1,TRACK:1,OBJECT:1,EMBED:1};\n var INTERACTIVE_ROLES = {button:1,link:1,textbox:1,checkbox:1,radio:1,combobox:1,menuitem:1,tab:1,switch:1,option:1};\n var INPUT_ROLE = {checkbox:'checkbox',radio:'radio',submit:'button',button:'button',search:'searchbox',file:'file'};\n var TAG_ROLE = {A:'link',BUTTON:'button',SELECT:'combobox',TEXTAREA:'textbox',IMG:'img',H1:'heading',H2:'heading',H3:'heading',H4:'heading',H5:'heading',H6:'heading',NAV:'navigation',MAIN:'main',FORM:'form',TABLE:'table',UL:'list',OL:'list',LI:'listitem'};\n\n function isVisible(el) {\n if (el.hidden || el.getAttribute('aria-hidden') === 'true') return false;\n if (!el.offsetParent && el.tagName !== 'BODY' && el.tagName !== 'HTML') {\n var pos = getComputedStyle(el).position;\n if (pos !== 'fixed' && pos !== 'sticky') return false;\n }\n var s = el.style;\n if (s.display === 'none' || s.visibility === 'hidden') return false;\n return true;\n }\n\n function isInteractive(el) {\n var tag = el.tagName;\n if (tag === 'A' || tag === 'BUTTON' || tag === 'SELECT' || tag === 'TEXTAREA') return true;\n if (tag === 'INPUT' && el.type !== 'hidden') return true;\n var role = el.getAttribute('role');\n if (role && INTERACTIVE_ROLES[role]) return true;\n var tabindex = el.getAttribute('tabindex');\n if (el.onclick || (tabindex !== null && tabindex >= '0')) return true;\n if (el.contentEditable === 'true') return true;\n return false;\n }\n\n function getRole(el) {\n var r = el.getAttribute('role');\n if (r) return r;\n if (el.tagName === 'INPUT') return INPUT_ROLE[(el.type||'text').toLowerCase()] || 'textbox';\n return TAG_ROLE[el.tagName] || null;\n }\n\n function getLabel(el) {\n return (el.getAttribute('aria-label') || el.getAttribute('placeholder') || el.getAttribute('alt') || el.getAttribute('title') || '').slice(0, 50);\n }\n\n function directText(el) {\n var t = '';\n for (var n = el.firstChild; n; n = n.nextSibling) {\n if (n.nodeType === 3) t += n.data;\n if (t.length > 60) break;\n }\n return t.trim().replace(/\\s+/g, ' ').slice(0, 60);\n }\n\n function walk(el, depth) {\n if (truncated || !el || el.nodeType !== 1) return '';\n if (SKIP_TAGS[el.tagName]) return '';\n if (!isVisible(el)) return '';\n if (depth > MAX_DEPTH) return '';\n if (++visited > MAX_ELEMENTS) { truncated = true; return ''; }\n\n var role = getRole(el);\n var interactive = isInteractive(el);\n var showThis = !!(role || interactive);\n var lines = [];\n\n if (showThis) {\n var label = getLabel(el);\n var dtext = directText(el);\n var line = '[' + (role || el.tagName.toLowerCase());\n var txt = label || dtext;\n if (txt) line += ' \"' + txt.replace(/\"/g, \"'\") + '\"';\n if (interactive) {\n var ref = 'e' + (++refCounter);\n window.__dmjRefs.set(ref, new WeakRef(el));\n line += ' ref=' + ref;\n }\n line += ']';\n if (el === document.activeElement) line += ' [focused]';\n if ((el.tagName === 'INPUT' || el.tagName === 'TEXTAREA') && el.value) line += ' val=\"' + el.value.slice(0,40) + '\"';\n if (el.tagName === 'INPUT' && (el.type === 'checkbox' || el.type === 'radio')) line += el.checked ? ' [x]' : ' [ ]';\n\n totalChars += line.length;\n if (totalChars > MAX_CHARS) { truncated = true; return ''; }\n lines.push(line);\n }\n\n for (var c = el.firstElementChild; c; c = c.nextElementSibling) {\n if (truncated) break;\n var out = walk(c, showThis ? depth + 1 : depth);\n if (out) lines.push(showThis ? out.split('\\n').map(function(l){return ' '+l}).join('\\n') : out);\n }\n\n if (!showThis) {\n var dt = directText(el);\n if (dt.length > 2) {\n totalChars += dt.length;\n if (totalChars > MAX_CHARS) { truncated = true; return ''; }\n lines.push('\"' + dt + '\"');\n }\n }\n\n return lines.join('\\n');\n }\n\n var tree = walk(document.body, 0);\n var h = 'URL: ' + location.href + '\\nTitle: ' + document.title;\n if (truncated) h += '\\n[TRUNCATED - page too large]';\n return h + '\\n\\n' + tree;\n})()\n",returnByValue:!0}),window.bangonit.getDownloads(e),window.bangonit.getFileChooserState(e),window.bangonit.cdpSend(e,"Runtime.evaluate",{expression:"JSON.stringify({w:window.innerWidth,h:window.innerHeight})",returnByValue:!0})]),l=(()=>{try{return JSON.parse(s.value)}catch(e){return null}})(),c=l?"\nViewport: ".concat(l.w,"x").concat(l.h):"",u=(i.value||"Empty page")+"\n\nMouse position: ".concat(t,",").concat(n).concat(c)+a;if(o.open&&(u+="\n\n[File picker is open — use upload action with paths to select files, or cancel: true to dismiss]"),r.length>0){let e=r.map(e=>"- ".concat(e.filename," (").concat(e.bytes," bytes) [").concat(e.state,"]"));u+="\n\nDownloads:\n".concat(e.join("\n"))}return u}async function p(e,t,n){let a=window.bangonit;if(t.ref){let{result:r}=await a.cdpSend(e,"Runtime.evaluate",{expression:'(function() { var r = window.__dmjRefs && window.__dmjRefs.get("'.concat(t.ref,'"); return r ? r.deref() || null : null; })()'),returnByValue:!1});if(!r.objectId)throw Error('Element ref "'.concat(t.ref,'" not found — take a new snapshot'));try{let{model:i}=await a.cdpSend(e,"DOM.getBoxModel",{objectId:r.objectId}),o=i.content,s=Math.round((o[0]+o[2]+o[4]+o[6])/4),l=Math.round((o[1]+o[3]+o[5]+o[7])/4);if(n){let{result:t}=await a.cdpSend(e,"Runtime.evaluate",{expression:"JSON.stringify({ w: window.innerWidth, h: window.innerHeight })",returnByValue:!0}),n=JSON.parse(t.value);if(s<0||s>n.w||l<0||l>n.h){await a.cdpSend(e,"Runtime.callFunctionOn",{objectId:r.objectId,functionDeclaration:'function() { this.scrollIntoView({ block: "center", inline: "center", behavior: "instant" }); }',returnByValue:!0}),await new Promise(e=>setTimeout(e,100));let{model:t}=await a.cdpSend(e,"DOM.getBoxModel",{objectId:r.objectId}),n=t.content;s=Math.round((n[0]+n[2]+n[4]+n[6])/4),l=Math.round((n[1]+n[3]+n[5]+n[7])/4)}}else if(s<0||l<0){let{result:n}=await a.cdpSend(e,"Runtime.callFunctionOn",{objectId:r.objectId,functionDeclaration:"function() {\n var r = this.getBoundingClientRect();\n return { top: r.top, bottom: r.bottom, left: r.left, right: r.right, vh: window.innerHeight, vw: window.innerWidth };\n }",returnByValue:!0}),i=n.value;if(i){let e=i.top<0?Math.round(i.top-100):i.bottom>i.vh?Math.round(i.bottom-i.vh+100):0,n=0!==e?" Scroll ".concat(e>0?"down":"up"," ~").concat(Math.abs(e),"px (wheel dy=").concat(e," at current mouse position)"):"";throw Error('Element ref "'.concat(t.ref,'" is not in the viewport and cannot auto-scroll because this batch contains x,y coordinates that would be invalidated by scrolling.').concat(n))}}return{x:s,y:l}}catch(o){var i;if(null===(i=o.message)||void 0===i?void 0:i.includes("not in the viewport"))throw o;if(n)try{await a.cdpSend(e,"Runtime.callFunctionOn",{objectId:r.objectId,functionDeclaration:'function() { this.scrollIntoView({ block: "center", inline: "center", behavior: "instant" }); }',returnByValue:!0}),await new Promise(e=>setTimeout(e,100));let{model:t}=await a.cdpSend(e,"DOM.getBoxModel",{objectId:r.objectId}),n=t.content;return{x:Math.round((n[0]+n[2]+n[4]+n[6])/4),y:Math.round((n[1]+n[3]+n[5]+n[7])/4)}}catch(e){throw Error('Element ref "'.concat(t.ref,'" could not be scrolled into view'))}try{let{result:n}=await a.cdpSend(e,"Runtime.callFunctionOn",{objectId:r.objectId,functionDeclaration:"function() {\n var r = this.getBoundingClientRect();\n return { top: r.top, bottom: r.bottom, left: r.left, right: r.right, vh: window.innerHeight, vw: window.innerWidth };\n }",returnByValue:!0}),i=n.value;if(i){let e=i.top<0?Math.round(i.top-100):i.bottom>i.vh?Math.round(i.bottom-i.vh+100):0,n=0!==e?" Scroll ".concat(e>0?"down":"up"," ~").concat(Math.abs(e),"px (wheel dy=").concat(e," at current mouse position)"):"";throw Error('Element ref "'.concat(t.ref,'" is not in the viewport and cannot auto-scroll because this batch contains x,y coordinates that would be invalidated by scrolling.').concat(n))}}catch(e){if(e.message.includes("not in the viewport"))throw e}throw Error('Element ref "'.concat(t.ref,'" is not visible in the viewport — use only refs or scroll manually first'))}finally{a.cdpSend(e,"Runtime.releaseObject",{objectId:r.objectId}).catch(e=>console.error(e))}}return{x:t.x,y:t.y}}async function m(e,t,n,a,i,r){let o=window.bangonit,s=Math.hypot(a-t,i-n);if(s<1){null==r||r(a,i);return}let l=Math.min(Math.max(Math.round(s/15),3),40),c=Math.min(Math.max(.8*s,30),300);for(let s=1;s<=l;s++){let u=s/l,d=u<.5?4*u*u*u:1-Math.pow(-2*u+2,3)/2,h=Math.round(t+(a-t)*d),p=Math.round(n+(i-n)*d);await o.cdpSend(e,"Input.dispatchMouseEvent",{type:"mouseMoved",x:h,y:p}),null==r||r(h,p),s<l&&await new Promise(e=>setTimeout(e,c/l))}}async function w(e,t,n,a,i){var r,o,s,l,c,u,d,h;let w=window.bangonit;null===(r=i.onMouseLock)||void 0===r||r.call(i);let g=!t.some(e=>"wait"!==e.action&&void 0!==e.x),b=n,f=a;try{let n=[];for(let a of t){if("wait"===a.action){await new Promise(e=>setTimeout(e,Math.min(a.ms||100,2e3))),n.push("wait(".concat(a.ms||100,"ms)"));continue}let t=a.ref?{ref:a.ref}:{x:a.x,y:a.y},r=await p(e,t,g),h="".concat(r.x,",").concat(r.y),{x:v,y:x}=r;switch(a.action){case"down":await m(e,b,f,v,x,i.onCursorMove),b=v,f=x,null===(o=i.onCursorDown)||void 0===o||o.call(i,v,x),await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mousePressed",x:v,y:x,button:"left",clickCount:1}),n.push("down(".concat(h,")"));break;case"move":await m(e,b,f,v,x,i.onCursorMove),b=v,f=x,n.push("move(".concat(h,")"));break;case"up":await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mouseReleased",x:v,y:x,button:"left",clickCount:1}),null===(s=i.onCursorUp)||void 0===s||s.call(i,v,x),n.push("up(".concat(h,")"));break;case"click":await m(e,b,f,v,x,i.onCursorMove),b=v,f=x,null===(l=i.onCursorDown)||void 0===l||l.call(i,v,x),await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mousePressed",x:v,y:x,button:"left",clickCount:1}),await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mouseReleased",x:v,y:x,button:"left",clickCount:1}),null===(c=i.onCursorUp)||void 0===c||c.call(i,v,x),n.push("click(".concat(h,")"));break;case"dblclick":await m(e,b,f,v,x,i.onCursorMove),b=v,f=x,null===(u=i.onCursorDown)||void 0===u||u.call(i,v,x),await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mousePressed",x:v,y:x,button:"left",clickCount:1}),await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mouseReleased",x:v,y:x,button:"left",clickCount:1}),await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mousePressed",x:v,y:x,button:"left",clickCount:2}),await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mouseReleased",x:v,y:x,button:"left",clickCount:2}),null===(d=i.onCursorUp)||void 0===d||d.call(i,v,x),n.push("dblclick(".concat(h,")"));break;case"wheel":{await m(e,b,f,v,x,i.onCursorMove),b=v,f=x;let t=a.dx||0,r=a.dy||0;await w.cdpSend(e,"Input.dispatchMouseEvent",{type:"mouseWheel",x:v,y:x,deltaX:t,deltaY:r}),n.push("wheel(".concat(h,",").concat(t,",").concat(r,")"))}}}return{result:"Mouse: ".concat(n.join(" → ")),mouseX:b,mouseY:f}}finally{null===(h=i.onMouseUnlock)||void 0===h||h.call(i)}}async function g(e,t){let n=window.bangonit;for(let a of t)await n.sendInputEvent(e,{type:"keyDown",keyCode:a}),await n.sendInputEvent(e,{type:"char",keyCode:a}),await n.sendInputEvent(e,{type:"keyUp",keyCode:a}),await new Promise(e=>setTimeout(e,30+70*Math.random()));return'Typed "'.concat(t.slice(0,50),'"')}async function b(e,t){let n=window.bangonit,a=t.split("+"),i=a.pop(),r=a.map(e=>e.toLowerCase()),o=[];for(let e of r)"control"===e||"ctrl"===e?o.push("control"):"meta"===e||"command"===e||"cmd"===e?o.push("meta"):"alt"===e||"option"===e?o.push("alt"):"shift"===e&&o.push("shift");return await n.sendInputEvent(e,{type:"keyDown",keyCode:i,modifiers:o}),0===o.length&&("Enter"===i?await n.sendInputEvent(e,{type:"char",keyCode:"\r"}):1===i.length&&await n.sendInputEvent(e,{type:"char",keyCode:i})),await n.sendInputEvent(e,{type:"keyUp",keyCode:i,modifiers:o}),"Pressed ".concat(t)}let f=new Map;async function v(e){let t=new TextEncoder().encode(e);return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",t))).map(e=>e.toString(16).padStart(2,"0")).join("")}async function x(e){let t;let n=window.bangonit;try{t=await n.capturePage(e)}catch(e){throw Error("could not capture page (page may be navigating)")}let{activeTabId:a}=await n.getTabInfo(e),i="".concat(e,":").concat(null!=a?a:0),r=await v(t);return f.get(i)===r?{type:"not_changed"}:(f.set(i,r),{type:"changed",base64:t})}async function y(e,t){let n=window.bangonit;t.startsWith("http://")||t.startsWith("https://")||(t="https://"+t);let{url:a}=await n.loadURL(e,t);return"Navigated to ".concat(a)}async function k(e){let{ok:t,url:n,reason:a}=await window.bangonit.goBack(e);return t?"Navigated back to ".concat(n):"Cannot go back — ".concat(a)}async function I(e){let{ok:t,url:n,reason:a}=await window.bangonit.goForward(e);return t?"Navigated forward to ".concat(n):"Cannot go forward — ".concat(a)}async function T(e,t){let n=window.bangonit,a=t.action;switch(a){case"list":{let{tabs:t,activeTabId:a}=await n.getTabInfo(e);if(!t.length)return"No tabs open";return t.map(e=>{let t=e.tabId===a?" (active)":"",n=e.isPopup?" (popup)":"";return"Tab ".concat(e.tabId,": ").concat(e.title||"(untitled)"," — ").concat(e.url).concat(t).concat(n)}).join("\n")}case"new":{await n.requestNewTab(e,t.url||"about:blank"),await new Promise(e=>setTimeout(e,3e3));let{activeTabId:a}=await n.getTabInfo(e);return"Opened new tab".concat(t.url?": "+t.url:"",". Active tab is now ").concat(a,".")}case"select":{let a=t.tabId;if(void 0===a)return"Error: tabId required for select";let{tabs:i}=await n.getTabInfo(e);if(!i.find(e=>e.tabId===a))return"Error: tab ".concat(a,' not found. Use browser_tabs with action "list" to see available tabs.');await n.setActiveTab(e,a),await n.requestSelectTab(e,a);let r=i.find(e=>e.tabId===a);return"Switched to tab ".concat(a,": ").concat(null==r?void 0:r.url)}case"close":{var i;let{tabs:a,activeTabId:r}=await n.getTabInfo(e),o=null!==(i=t.tabId)&&void 0!==i?i:r;if(null===o)return"Error: no tab to close";if(!a.find(e=>e.tabId===o))return"Error: tab ".concat(o," not found.");if(a.length<=1)return"Cannot close the last tab.";return await n.requestCloseTab(e,o),"Closed tab ".concat(o)}default:return'Error: unknown tab action "'.concat(a,'". Use list, new, select, or close.')}}async function N(e){let{tabs:t,activeTabId:n}=await window.bangonit.getTabInfo(e);return t.length<=1?"":"\n\nOpen tabs:\n"+t.map(e=>{let t=e.tabId===n?" (active)":"",a=e.isPopup?" (popup)":"";return" Tab ".concat(e.tabId,": ").concat(e.title||"(untitled)"," — ").concat(e.url).concat(t).concat(a)}).join("\n")}async function C(e,t){let n=window.bangonit,a=Math.min(Math.max((null==t?void 0:t.timeout)||10,.1),30),i=null==t?void 0:t.text,r="visible"===((null==t?void 0:t.state)||"visible");if(!i)return await new Promise(e=>setTimeout(e,1e3*a)),"Waited ".concat(a," seconds");let o=Date.now()+1e3*a;for(;Date.now()<o;){let{result:t}=await n.cdpSend(e,"Runtime.evaluate",{expression:"document.body.innerText.includes(".concat(JSON.stringify(i),")"),returnByValue:!0}),a=t.value;if(r&&a)return'Text "'.concat(i,'" is now visible on the page.');if(!r&&!a)return'Text "'.concat(i,'" is no longer visible on the page.');await new Promise(e=>setTimeout(e,500))}return'Timeout: text "'.concat(i,'" ').concat(r?"did not appear":"did not disappear"," within ").concat(a,"s.")}class j{start(){!this.cleanup&&window.bangonit&&(this.cleanup=window.bangonit.onCdpEvent(e=>{"Network.requestWillBeSent"===e.method?this.inflightRequests++:("Network.loadingFinished"===e.method||"Network.loadingFailed"===e.method)&&(this.inflightRequests=Math.max(0,this.inflightRequests-1))}))}stop(){var e;null===(e=this.cleanup)||void 0===e||e.call(this),this.cleanup=null,this.inflightRequests=0}async waitForIdle(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:500,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3,n=Date.now()+t,a=0===this.inflightRequests?Date.now():null;for(;Date.now()<n;){if(0===this.inflightRequests){if(a||(a=Date.now()),Date.now()-a>=e)return}else a=null;await new Promise(e=>setTimeout(e,50))}}constructor(){this.inflightRequests=0,this.cleanup=null}}let E={navigate:"browser_navigate",back:"browser_navigate_back",forward:"browser_go_forward",mouse:"browser_mouse",type:"browser_type",press:"browser_press_key",tabs:"browser_tabs",upload:"browser_upload",wait:"browser_wait_for",close:"browser_close"};var S=n(8204);let R=S.VK("type",[S.Ry({type:S.i0("not_changed")}),S.Ry({type:S.i0("changed"),base64:S.Z_()})]);S.Ry({textOutput:S.Z_(),imageOutput:R.nullable()});let M=Promise.resolve();class P{destroy(){this.networkTracker.stop()}enableRecording(e){this.recorder=e}cursorCallbacks(){let e=this.agentId,t=window.bangonit,n=this.recorder;return{onCursorMove:(a,i)=>{t.emitCursorMove(e,a,i),null==n||n.updateCursor(a,i)},onCursorDown:(a,i)=>{t.emitCursorDown(e,a,i),null==n||n.setCursorDown()},onCursorUp:(a,i)=>{t.emitCursorUp(e,a,i),null==n||n.setCursorUp()},onMouseLock:()=>t.emitMouseLock(e),onMouseUnlock:()=>t.emitMouseUnlock(e)}}async callTool(e,t){switch(e){case"browser_navigate":return y(this.agentId,t.url);case"browser_navigate_back":return k(this.agentId);case"browser_go_forward":return I(this.agentId);case"browser_mouse":{let{result:e,mouseX:n,mouseY:a}=await w(this.agentId,t.steps,this.mouseX,this.mouseY,this.cursorCallbacks());return this.mouseX=n,this.mouseY=a,e}case"browser_type":return g(this.agentId,t.text);case"browser_press_key":return b(this.agentId,t.key);case"browser_close":return T(this.agentId,{action:"close"});case"browser_upload":{var n;if(t.cancel){let e=await window.bangonit.handleFileChooser(this.agentId,"cancel");if(!e.ok)return"Error: ".concat(e.error);return"File picker cancelled."}if(!(null===(n=t.paths)||void 0===n?void 0:n.length))return"Error: provide paths to upload, or cancel: true";let e=await window.bangonit.handleFileChooser(this.agentId,"accept",t.paths);if(!e.ok)return"Error: ".concat(e.error);return"Uploaded ".concat(t.paths.length," file(s).")}case"browser_wait_for":return C(this.agentId,t);case"browser_tabs":return T(this.agentId,t);default:throw Error("Unknown tool: ".concat(e))}}async exec(e){let t=function(){let e;let t=new Promise(t=>{e=t}),n=M;return M=M.then(()=>t),{promise:n,release:e}}();await t.promise;try{return await this._exec(e)}finally{t.release()}}async _exec(e){let{actions:t,observe:n}=e,a=[],i=null;if(this.recorder)try{var r,o,s;let e=await (null===(r=window.bangonit)||void 0===r?void 0:r.getTabInfo(this.agentId)),t=null!==(s=null==e?void 0:e.activeTabId)&&void 0!==s?s:0,n=null==e?void 0:null===(o=e.tabs)||void 0===o?void 0:o.find(e=>e.tabId===t);await this.recorder.startClip(t,null==n?void 0:n.url)}catch(e){console.warn("Failed to start recording clip:",e)}for(let e=0;e<t.length;e++){let n=t[e];if(!n||!n.action)continue;let i=E[n.action];if(!i){a.push("".concat(n.action,": Error — unknown action"));continue}try{let e=this.actionToToolArgs(n),t=await this.callTool(i,e);a.push(t||"OK")}catch(e){a.push("".concat(this.actionLabel(n),": Error — ").concat(e.message))}}if(n){t.length>0&&await this.networkTracker.waitForIdle(500,2e3);try{let e=await N(this.agentId),t=await h(this.agentId,this.mouseX,this.mouseY,e);a.push(t),"snapshot_and_screenshot"===n&&(i=await x(this.agentId))}catch(e){a.push("observe: Error — ".concat(e.message))}}if(this.recorder)try{await this.recorder.stopClip()}catch(e){console.warn("Failed to stop recording clip:",e)}return{textOutput:a.join("\n\n"),imageOutput:i}}actionToToolArgs(e){switch(e.action){case"navigate":return{url:e.url};case"back":case"forward":case"close":default:return{};case"mouse":return{steps:(e.mouseActions||[]).map(e=>{if("wait"===e.action)return{action:"wait",ms:e.ms||100};let t=e.ref?{ref:e.ref}:{x:e.x,y:e.y};return"wheel"===e.action?{action:"wheel",...t,dx:e.dx||0,dy:e.dy||0}:{action:e.action,...t}})};case"type":return{text:e.text};case"press":return{key:e.key};case"upload":return{paths:e.paths,cancel:e.cancel};case"tabs":return{action:e.tabAction,tabId:e.tabId,url:e.url};case"wait":return{timeout:e.timeout}}}actionLabel(e){switch(e.action){case"navigate":return"navigate ".concat(e.url);case"mouse":{let t=(e.mouseActions||[]).map(e=>"wait"===e.action?"wait ".concat(e.ms,"ms"):"wheel"===e.action?"wheel ".concat(e.x,",").concat(e.y," ").concat(e.dx,",").concat(e.dy):"".concat(e.action," ").concat(e.x,",").concat(e.y)).join(" → ");return"mouse ".concat(t)}case"type":return'type "'.concat((e.text||"").slice(0,30),'"');case"press":return"press ".concat(e.key);case"upload":return e.cancel?"upload cancel":"upload ".concat((e.paths||[]).join(", "));case"tabs":return"tabs ".concat(e.tabAction).concat(e.tabId?" "+e.tabId:"");case"wait":return"wait ".concat(e.timeout||10,"s");default:return e.action}}constructor(e){this.mouseX=0,this.mouseY=0,this.networkTracker=new j,this.recorder=null,this.agentId=e,this.networkTracker.start()}}class z{async captureFrame(){let e=window.bangonit;try{let t=await e.capturePage(this.agentId),{result:n}=await e.cdpSend(this.agentId,"Runtime.evaluate",{expression:"JSON.stringify({w:window.innerWidth,h:window.innerHeight})",returnByValue:!0}),a=JSON.parse(n.value);this.currentFrames.push({imageData:t,cursor:{...this.cursorPos},clicking:this.clicking,ts:Date.now(),sessionId:0,deviceWidth:a.w,deviceHeight:a.h,scrollOffsetX:0,scrollOffsetY:0})}catch(e){console.warn("Failed to capture frame:",e)}}async startClip(e,t){this.currentUrl=t||"",this.recording&&await this.cancelClip(),this.recording=!0,this.currentTabId=e,this.currentFrames=[],this.cursorTrail=[],this.clipStartTime=Date.now(),await this.captureFrame();let n=window.bangonit;this.cdpCleanup=n.onCdpEvent(e=>{if(e.agentId!==this.agentId||"Page.screencastFrame"!==e.method||!this.recording)return;let{data:t,metadata:a,sessionId:i}=e.params;this.currentFrames.push({imageData:t,cursor:{...this.cursorPos},clicking:this.clicking,ts:Date.now(),sessionId:i,deviceWidth:(null==a?void 0:a.deviceWidth)||0,deviceHeight:(null==a?void 0:a.deviceHeight)||0,scrollOffsetX:(null==a?void 0:a.scrollOffsetX)||0,scrollOffsetY:(null==a?void 0:a.scrollOffsetY)||0}),n.cdpSend(this.agentId,"Page.screencastFrameAck",{sessionId:i}).catch(e=>console.error(e))}),await n.cdpSend(this.agentId,"Page.startScreencast",{format:"png",quality:100,maxWidth:1920,maxHeight:1080})}async stopClip(){if(!this.recording)return null;await this.captureFrame(),this.recording=!1;let e=Date.now();await window.bangonit.cdpSend(this.agentId,"Page.stopScreencast").catch(e=>console.error(e)),this.cdpCleanup&&(this.cdpCleanup(),this.cdpCleanup=null);let t=this.currentFrames;if(this.currentFrames=[],0===t.length)return null;let n=await this.compositeAndEncode(t);if(!n||0===n.size)return null;let a=new Uint8Array(await n.arrayBuffer()),i="";for(let e=0;e<a.length;e++)i+=String.fromCharCode(a[e]);let r=btoa(i),o={agentId:this.agentId,tabId:this.currentTabId,index:this.clips.length,startTime:this.clipStartTime,endTime:e,url:this.currentUrl||void 0,data:r};return this.clips.push(o),{meta:o}}async cancelClip(){var e;this.recording=!1,this.currentFrames=[],this.cursorTrail=[],this.cdpCleanup&&(this.cdpCleanup(),this.cdpCleanup=null),await (null===(e=window.bangonit)||void 0===e?void 0:e.cdpSend(this.agentId,"Page.stopScreencast").catch(e=>console.error(e)))}async compositeAndEncode(e){if(0===e.length)return null;let t=await this.decodeFrame(e[0].imageData);if(!t)return null;let n=t.width,a=t.height,i=document.createElement("canvas");i.width=n,i.height=a;let r=i.getContext("2d"),o=i.captureStream(0),s=o.getVideoTracks()[0],l=new MediaRecorder(o,{mimeType:"video/webm;codecs=vp8",videoBitsPerSecond:8e6}),d=[];l.ondataavailable=e=>{e.data.size>0&&d.push(e.data)};let h=new Promise(e=>{l.onstop=()=>{e(new Blob(d,{type:"video/webm"}))}});l.start();let p=[],m=this.cursorTrail,w=0,g=(e,t,i,o,l,d,h)=>{let m=t*d,w=i*h;o&&(!p.length||p[p.length-1].x!==m||p[p.length-1].y!==w)&&p.push({x:m,y:w,startTs:l}),r.clearRect(0,0,n,a),r.drawImage(e,0,0,n,a);for(let e=p.length-1;e>=0;e--){let t=p[e],n=l-t.startTs;if(n>=400){p.splice(e,1);continue}u(r,t.x,t.y,n/400)}c(r,m,w,o),s&&"function"==typeof s.requestFrame&&s.requestFrame()};for(let i=0;i<e.length;i++){let r=e[i],o=0===i?t:await this.decodeFrame(r.imageData);if(!o)continue;let s=r.deviceWidth>0?n/r.deviceWidth:1,l=r.deviceHeight>0?a/r.deviceHeight:1,c=i<e.length-1?e[i+1].ts:r.ts+100;for(g(o,r.cursor.x,r.cursor.y,r.clicking,r.ts,s,l);w<m.length&&m[w].ts<=r.ts;)w++;let u=r.ts;for(;w<m.length&&m[w].ts<c;){let e=m[w],t=e.ts-u;t>0&&await new Promise(e=>setTimeout(e,Math.min(t,16))),g(o,e.x,e.y,e.clicking,e.ts,s,l),u=e.ts,w++}if(i<e.length-1){let e=c-u;e>0&&await new Promise(t=>setTimeout(t,Math.min(e,100)))}}return await new Promise(e=>setTimeout(e,100)),l.stop(),h}async decodeFrame(e){try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);let a=new Blob([n],{type:"image/png"});return createImageBitmap(a)}catch(e){return console.warn("Failed to decode frame:",e),null}}updateCursor(e,t){this.cursorPos={x:e,y:t},this.recording&&this.cursorTrail.push({ts:Date.now(),x:e,y:t,clicking:this.clicking})}setCursorDown(){this.clicking=!0,this.recording&&this.cursorTrail.push({ts:Date.now(),...this.cursorPos,clicking:!0})}setCursorUp(){this.clicking=!1,this.recording&&this.cursorTrail.push({ts:Date.now(),...this.cursorPos,clicking:!1})}getClipsMeta(){return[...this.clips]}constructor(e){this.clips=[],this.currentFrames=[],this.cursorPos={x:0,y:0},this.clicking=!1,this.recording=!1,this.currentTabId=0,this.clipStartTime=0,this.cdpCleanup=null,this.ripples=[],this.cursorTrail=[],this.currentUrl="",this.agentId=e}}function A(e){var t;let{agentId:n,agentName:s,initialPrompt:l,onStatusChange:c,onRerun:u,initialMessages:h,initialTabs:p,initialActiveTabId:m,initialTodos:w,record:g,sessionRecorder:b,onRegisterRecorder:f,planDir:v}=e,[x,y]=(0,i.useState)((null==p?void 0:p.map(e=>({...e,initialUrl:e.url})))||[{id:0,url:"about:blank",title:"",initialUrl:"about:blank"}]),[k,I]=(0,i.useState)(null!=m?m:0),[T,N]=(0,i.useState)(()=>{let e=null==p?void 0:p.find(e=>e.id===(null!=m?m:0));return(null==e?void 0:e.url)||""}),[C,j]=(0,i.useState)(null),[E,S]=(0,i.useState)(!1),[R,M]=(0,i.useState)(!1),A=(0,i.useRef)(new Map),[_,O]=(0,i.useState)(w||[]),U=(0,i.useRef)(null),F=(0,i.useRef)(!1),L=(0,i.useRef)(p?Math.max(...p.map(e=>e.id))+1:1),B=(0,i.useRef)(new Set),[H,W]=(0,i.useState)(0),V=(0,i.useRef)(null),J=(0,i.useRef)(null);!J.current&&window.bangonit&&(J.current=new P(n));let X=(0,i.useRef)(null);g&&!X.current&&J.current&&(X.current=new z(n),J.current.enableRecording(X.current),null==f||f(n,X.current));let q=(0,i.useRef)(b);q.current=b;let Y=(0,i.useMemo)(()=>new o.PD({api:"/api/chat",headers:()=>({"X-Client-Platform":navigator.platform})}),[]),G=(0,i.useRef)(!1),K=(0,i.useCallback)((e,t)=>{var a,i;null===(i=window.bangonit)||void 0===i||null===(a=i.emitAgentOutput)||void 0===a||a.call(i,{agentId:n,type:e,text:t,name:s})},[n,s]),{messages:Z,setMessages:Q,sendMessage:$,addToolOutput:ee,stop:et,status:en,error:ea}=(0,r.RJ)({transport:Y,messages:h,sendAutomaticallyWhen:e=>{let{messages:t}=e;return!G.current&&!E&&(0,o.Qk)({messages:t})},async onToolCall(e){var t,a,i,r,o,l,c,u,d;let{toolCall:h}=e;if("report_result"===h.toolName){let e=h.input,u=(null==e?void 0:e.result)==="pass"?"pass":"fail",d=(null==e?void 0:e.summary)||"";if(K("status","".concat(u.toUpperCase(),": ").concat(d)),j({result:u,summary:d}),q.current){q.current.addEvent({ts:Date.now(),agentId:n,type:"result",data:{result:u,summary:d}});try{let e=await (null===(r=window.bangonit)||void 0===r?void 0:null===(i=r.getRunDir)||void 0===i?void 0:i.call(r));if(e){let t=(null===(o=X.current)||void 0===o?void 0:o.getClipsMeta())||[],a=[{id:n,name:s,result:u,summary:d}],i=q.current.toJSON(a,t);await (null===(c=window.bangonit)||void 0===c?void 0:null===(l=c.generateReplayHtml)||void 0===l?void 0:l.call(c,{runDir:e,data:JSON.stringify(i)}))}}catch(e){console.error(e)}}null===(a=window.bangonit)||void 0===a||null===(t=a.reportTestResult)||void 0===t||t.call(a,{agentId:n,status:u,summary:d}),ee({tool:h.toolName,toolCallId:h.toolCallId,output:"Test result recorded: ".concat(u)});return}if("todos"===h.toolName){let e=h.input,t=(null==e?void 0:e.todos)||_;(null==e?void 0:e.todos)&&O(e.todos),ee({tool:h.toolName,toolCallId:h.toolCallId,output:JSON.stringify(t)});return}if("browser"===h.toolName){try{let e=h.input,t=((null==e?void 0:e.actions)||[]).map(e=>"navigate"===e.action?"navigate ".concat(e.url):"type"===e.action?'type "'.concat((e.text||"").slice(0,30),'"'):"press"===e.action?"press ".concat(e.key):"mouse"===e.action?"mouse ".concat((e.mouseActions||[]).map(e=>"".concat(e.action," ").concat(e.ref||"".concat(e.x,",").concat(e.y))).join(" > ")):e.action).join(", ");K("tool","browser: ".concat(t).concat((null==e?void 0:e.observe)?" [".concat(e.observe,"]"):"")),null===(u=q.current)||void 0===u||u.addEvent({ts:Date.now(),agentId:n,type:"tool-start",data:{tool:"browser",label:t}});let a=J.current,i=a?await a.exec({actions:(null==e?void 0:e.actions)||[],observe:null==e?void 0:e.observe,prompts:null==e?void 0:e.prompts}):{error:"Error: browser tools not available"};null===(d=q.current)||void 0===d||d.addEvent({ts:Date.now(),agentId:n,type:"tool-end",data:{tool:"browser"}}),ee({tool:h.toolName,toolCallId:h.toolCallId,output:G.current?{error:"[Stopped by user]"}:JSON.stringify(i)})}catch(e){ee({tool:h.toolName,toolCallId:h.toolCallId,...G.current?{output:"[Stopped by user]"}:{state:"output-error",errorText:e.message}})}return}}});(0,i.useCallback)(()=>{G.current=!0,et()},[et]);let ei="submitted"===en||"streaming"===en;(0,i.useEffect)(()=>{ei&&(G.current=!1)},[ei]);let er=Z.length>0,eo=null!==C;(0,i.useEffect)(()=>{if(er&&!V.current&&(V.current=Date.now()),!er||eo)return;let e=setInterval(()=>{V.current&&W(Math.floor((Date.now()-V.current)/1e3))},1e3);return()=>clearInterval(e)},[er,eo]);let es=(0,i.useRef)(null),el=(0,i.useRef)(0);(0,i.useEffect)(()=>{var e;if(0===Z.length)return;let t=Z[Z.length-1];if("assistant"!==t.role)return;let n=(null===(e=t.parts)||void 0===e?void 0:e.filter(e=>"text"===e.type).map(e=>e.text).join(""))||"";t.id!==es.current&&(es.current=t.id,el.current=0);let a=n.slice(el.current);a&&(K("text",a),el.current=n.length)},[Z,K]);let ec=(0,i.useRef)(ei),eu=(0,i.useRef)(!1);(0,i.useEffect)(()=>{!eu.current&&ec.current!==ei&&(ec.current=ei,ei?null==c||c(n,"running"):(null==c||c(n,"idle",null==C?void 0:C.result),(null==C?void 0:C.result)&&(eu.current=!0)))},[ei,n,c,C]);let ed=(0,i.useRef)(!1),eh=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(eh.current&&(clearTimeout(eh.current),eh.current=null),!ei&&!eo&&!E&&!ed.current&&!(Z.length<2))return eh.current=setTimeout(()=>{eh.current=null,ed.current||eo||(ed.current=!0,$({text:"You must call the report_result tool to finalize this test run. Call it now with the result (pass or fail) and a summary."}))},5e3),()=>{eh.current&&clearTimeout(eh.current)}},[ei,eo,E,Z.length,$]),(0,i.useEffect)(()=>{var e,t;null===(t=window.bangonit)||void 0===t||null===(e=t.clearPartition)||void 0===e||e.call(t,n)},[n]),(0,i.useEffect)(()=>{q.current&&Z.length>0&&q.current.setMessages(n,Z)},[Z,n]),(0,i.useEffect)(()=>{if(Z.length>0){var e,t,a,i;null===(a=window.bangonit)||void 0===a||a.setAgentSession(n,{messages:Z,initialPrompt:l,tabs:x.filter(e=>!e.isPopup).map(e=>{let{id:t,url:n,title:a}=e;return{id:t,url:n,title:a}}),activeTabId:(null===(e=x.find(e=>e.id===k))||void 0===e?void 0:e.isPopup)?null!==(i=null===(t=x.find(e=>!e.isPopup))||void 0===t?void 0:t.id)&&void 0!==i?i:0:k,todos:_})}},[Z,x,k,n,l,_]);let ep=(0,i.useCallback)(e=>{var t;let a=L.current++;y(t=>[...t,{id:a,url:"about:blank",title:"",initialUrl:e}]),I(a),N("about:blank"===e?"":e),null===(t=window.bangonit)||void 0===t||t.setActiveTab(n,a)},[n]),em=(0,i.useCallback)(e=>{y(t=>{let a=t.findIndex(t=>t.id===e);if(-1===a)return t;let i=t.filter(t=>t.id!==e);return 0===i.length?t:(I(t=>{if(t===e){var r;let e=i[Math.max(0,a-1)].id,t=i.find(t=>t.id===e);return t&&N("about:blank"===t.url?"":t.url),null===(r=window.bangonit)||void 0===r||r.setActiveTab(n,e),e}return t}),i)})},[n]),ew=(0,i.useCallback)(e=>{var t;I(e),null===(t=window.bangonit)||void 0===t||t.setActiveTab(n,e),y(t=>{let n=t.find(t=>t.id===e);return n&&N("about:blank"===n.url?"":n.url),t})},[n]),eg=(0,i.useRef)(ep),eb=(0,i.useRef)(em),ef=(0,i.useRef)(ew);eg.current=ep,eb.current=em,ef.current=ew,(0,i.useEffect)(()=>{var e,t,a,i,r;let o=[],s=e=>{e&&o.push(e)};return s(null===(e=window.bangonit)||void 0===e?void 0:e.onTabUpdated(e=>{if(e.agentId!==n)return;let t="about:blank"===e.url,a="about:blank"===e.title;y(n=>n.map(n=>n.id===e.tabId?{...n,...!t&&void 0!==e.url&&{url:e.url},...!a&&void 0!==e.title&&{title:e.title}}:n)),void 0===e.url||t||I(t=>(t===e.tabId&&N(e.url),t))})),s(null===(t=window.bangonit)||void 0===t?void 0:t.onOpenNewTab(e=>{e.agentId===n&&eg.current(e.url)})),s(null===(a=window.bangonit)||void 0===a?void 0:a.onPopupOpened(e=>{e.agentId===n&&y(t=>[...t,{id:e.tabId,url:e.url||"about:blank",title:"",initialUrl:e.url||"about:blank",isPopup:!0}])})),s(null===(i=window.bangonit)||void 0===i?void 0:i.onCloseTab(e=>{e.agentId===n&&eb.current(e.tabId)})),s(null===(r=window.bangonit)||void 0===r?void 0:r.onSelectTab(e=>{e.agentId===n&&ef.current(e.tabId)})),()=>o.forEach(e=>null==e?void 0:e())},[n]),(0,i.useEffect)(()=>{F.current||(null==h?void 0:h.length)||(F.current=!0,$({text:l}))},[l,$,h]),(0,i.useEffect)(()=>{var e;null===(e=U.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[Z]);let ev=(0,i.useCallback)((e,t,a)=>{if(!e)return;A.current.set(t,e);let i=()=>{if(!B.current.has(t))try{var i,r,o;let s=null===(i=e.getWebContentsId)||void 0===i?void 0:i.call(e);s&&(B.current.add(t),null===(r=window.bangonit)||void 0===r||r.registerTab(n,t,s,a,v),t===k&&(null===(o=window.bangonit)||void 0===o||o.setActiveTab(n,t)))}catch(e){console.error(e)}};i(),e.addEventListener("did-attach",i),e.addEventListener("close",()=>eb.current(t)),e._consoleListenerAttached||(e._consoleListenerAttached=!0,e.addEventListener("console-message",e=>{var t,a,i;null===(a=window.bangonit)||void 0===a||null===(t=a.emitConsoleMessage)||void 0===t||t.call(a,{agentId:n,level:e.level,message:e.message,url:e.sourceId||"",line:e.lineNumber||0}),null===(i=q.current)||void 0===i||i.addConsoleLog(n,e.level,e.message,e.sourceId||"",e.lineNumber||0)}))},[n,k]),ex=e=>"".concat(Math.floor(e/60),":").concat((e%60).toString().padStart(2,"0"));return(0,a.jsxs)("div",{className:"flex h-full w-full bg-zinc-950 overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex-1 flex flex-col border-r border-zinc-800 min-w-0",children:[(0,a.jsx)("div",{className:"flex items-center bg-zinc-900 border-b border-zinc-800 overflow-x-auto",children:x.map(e=>(0,a.jsx)("button",{onClick:()=>ew(e.id),className:"flex items-center gap-1.5 px-3 py-2 text-xs border-r border-zinc-800 min-w-0 max-w-[200px] shrink-0\n ".concat(e.id===k?"bg-zinc-800 text-zinc-200":"text-zinc-500 hover:text-zinc-300 hover:bg-zinc-850"),children:(0,a.jsxs)("span",{className:"truncate",children:[e.isPopup?"↗ ":"",e.title||(e.url&&"about:blank"!==e.url?e.url:"New Tab")]})},e.id))}),(0,a.jsx)("div",{className:"flex items-center gap-2 px-3 py-2 bg-zinc-900 border-b border-zinc-800",children:(0,a.jsx)("div",{className:"flex-1 px-3 py-1.5 bg-zinc-800 border border-zinc-700 rounded-lg text-xs text-zinc-400 truncate",children:T||"about:blank"})}),(0,a.jsxs)("div",{className:"flex-1 relative bg-white overflow-hidden",onWheel:e=>e.stopPropagation(),children:[x.map(e=>e.isPopup?e.id===k&&(0,a.jsxs)("div",{className:"absolute inset-0 flex items-center justify-center bg-zinc-900 text-zinc-400 text-sm z-[1]",children:["Popup window open — ",e.title||e.url]},e.id):(0,a.jsx)("webview",{ref:t=>ev(t,e.id,e.initialUrl),src:"about:blank",partition:"persist:agent-".concat(n),allowpopups:"",style:{width:"100%",height:"100%",position:"absolute",backgroundColor:"white",top:0,left:0,pointerEvents:e.id===k?"auto":"none",zIndex:e.id===k?1:0}},e.id)),!(null===(t=x.find(e=>e.id===k))||void 0===t?void 0:t.isPopup)&&(0,a.jsx)(d,{agentId:n}),!eo&&(0,a.jsx)("div",{className:"absolute inset-0 z-10 cursor-not-allowed"})]})]}),(0,a.jsxs)("div",{className:"w-[420px] flex flex-col h-full shrink-0",children:[(0,a.jsxs)("div",{className:"flex items-center px-4 py-3 border-b border-zinc-800",children:[(0,a.jsx)("h2",{className:"text-sm font-medium text-zinc-300",children:s}),(0,a.jsx)("div",{className:"flex-1"})]}),C&&(0,a.jsxs)("div",{className:"px-4 py-2 text-sm border-b flex items-center gap-3 ".concat("pass"===C.result?"bg-green-950/30 border-green-900/50":"bg-red-950/30 border-red-900/50"),children:[(0,a.jsx)("span",{className:"font-medium ".concat("pass"===C.result?"text-green-400":"text-red-400"),children:"pass"===C.result?"PASSED":"FAILED"}),(0,a.jsx)("span",{className:"text-zinc-500 text-xs",children:ex(H)}),C.summary&&(0,a.jsx)("span",{className:"text-zinc-400 text-xs truncate flex-1",children:C.summary})]}),_.length>0&&(0,a.jsx)("div",{className:"text-xs space-y-1 px-4 py-2 border-b border-zinc-800 bg-zinc-900/80 shrink-0 max-h-48 overflow-y-auto",children:_.map((e,t)=>(0,a.jsxs)("div",{className:"flex items-center gap-2 ".concat("completed"===e.status?"text-zinc-500":"text-zinc-300"),children:[(0,a.jsx)("span",{className:"shrink-0",children:"completed"===e.status?"✓":"in_progress"===e.status?(0,a.jsx)("span",{className:"inline-block w-2 h-2 bg-blue-500 rounded-full animate-pulse"}):"○"}),(0,a.jsx)("span",{className:"completed"===e.status?"line-through":"",children:e.content})]},t))}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-3",children:[Z.map(e=>(0,a.jsx)(D,{message:e,agentName:s},e.id)),ea&&(0,a.jsx)("div",{className:"text-sm px-3 py-2 bg-red-950/30 border border-red-900/50 rounded-lg text-red-400",children:ea.message}),(0,a.jsx)("div",{ref:U})]}),(0,a.jsx)("div",{className:"px-4 py-2 border-t border-zinc-800 flex items-center gap-3 shrink-0",children:eo?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"inline-block w-2 h-2 rounded-full shrink-0 ".concat("pass"===C.result?"bg-green-500":"bg-red-500")}),(0,a.jsxs)("span",{className:"text-xs font-medium ".concat("pass"===C.result?"text-green-400":"text-red-400"),children:["pass"===C.result?"Passed":"Failed"," in ",ex(H)]}),(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("button",{onClick:()=>{let e=A.current.get(k);e&&(R?e.closeDevTools():e.openDevTools(),M(!R))},className:"text-xs px-2 py-1 rounded border transition-colors ".concat(R?"border-blue-600 text-blue-400 bg-blue-950/30":"border-zinc-700 hover:border-zinc-500 text-zinc-500 hover:text-zinc-300"),title:"Toggle DevTools",children:"DevTools"}),(0,a.jsx)("button",{onClick:()=>{var e,t;null===(t=window.bangonit)||void 0===t||null===(e=t.emitTestRerun)||void 0===e||e.call(t),null==u||u()},className:"text-xs px-3 py-1 rounded border border-zinc-700 hover:border-zinc-500 text-zinc-400 hover:text-zinc-200 transition-colors",children:"Rerun"})]}):er?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"inline-block w-2 h-2 rounded-full shrink-0 ".concat(E?"bg-amber-500":"bg-blue-500 animate-pulse")}),(0,a.jsxs)("span",{className:"text-xs text-zinc-400",children:[E?"Paused":"Working"," ",ex(H)]}),(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("button",{onClick:()=>{let e=A.current.get(k);e&&(R?e.closeDevTools():e.openDevTools(),M(!R))},className:"text-xs px-2 py-1 rounded border transition-colors ".concat(R?"border-blue-600 text-blue-400 bg-blue-950/30":"border-zinc-700 hover:border-zinc-500 text-zinc-500 hover:text-zinc-300"),title:"Toggle DevTools",children:"DevTools"}),(0,a.jsx)("button",{onClick:()=>S(!E),className:"text-xs px-2 py-1 rounded border border-zinc-700 hover:border-zinc-500 text-zinc-400 hover:text-zinc-200 transition-colors",children:E?"Continue":"Pause"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"inline-block w-2 h-2 bg-zinc-600 rounded-full shrink-0"}),(0,a.jsx)("span",{className:"text-xs text-zinc-500",children:"Queued"})]})})]})]})}function D(e){var t,n;let{message:i,agentName:r}=e;if("user"===i.role){let e=null===(n=i.parts)||void 0===n?void 0:n.find(e=>"text"===e.type);return(0,a.jsxs)("div",{className:"text-sm",children:[(0,a.jsx)("span",{className:"text-xs text-zinc-500 block mb-1",children:"Test Plan"}),(0,a.jsx)("div",{className:"text-zinc-200 prose prose-invert prose-sm max-w-none",children:(0,a.jsx)(s.UG,{remarkPlugins:[l.Z],children:(null==e?void 0:e.text)||""})})]})}return(0,a.jsx)("div",{className:"text-sm space-y-2",children:null===(t=i.parts)||void 0===t?void 0:t.map((e,t)=>{var n,i;if("text"===e.type&&e.text)return(null===(i=e.providerMetadata)||void 0===i?void 0:null===(n=i.anthropic)||void 0===n?void 0:n.type)==="compaction"?null:(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-xs text-zinc-500 block mb-1",children:r}),(0,a.jsx)("div",{className:"text-zinc-300 prose prose-invert prose-sm max-w-none",children:(0,a.jsx)(s.UG,{remarkPlugins:[l.Z],children:e.text})})]},t);if("dynamic-tool"===e.type||"string"==typeof e.type&&e.type.startsWith("tool-")){let n=e.toolName||("string"==typeof e.type?e.type.replace(/^tool-/,""):"");return"todos"===n||"report_result"===n?null:(0,a.jsx)(_,{part:e},t)}return null})})}function _(e){let{part:t}=e,[n,r]=(0,i.useState)(!1),o=t.input||{},s=t.output,l=t.state||"input-available",c=t.toolName||("string"==typeof t.type?t.type.replace(/^tool-/,""):""),u="input-streaming"===l?"":"browser"===c?(()=>{let e=(o.actions||[]).map(e=>{switch(e.action){case"navigate":return"navigate ".concat(e.url||"");case"mouse":{let t=(e.mouseActions||[]).map(e=>"wait"===e.action?"wait ".concat(e.ms,"ms"):"wheel"===e.action?"wheel ".concat(e.ref||"".concat(e.x,",").concat(e.y)):"".concat(e.action," ").concat(e.ref||"".concat(e.x,",").concat(e.y))).join(" → ");return"mouse ".concat(t)}case"type":return'type "'.concat((e.text||"").slice(0,40),'"');case"press":return"press ".concat(e.key||"");case"tabs":return"tabs ".concat(e.tabAction||"").concat(e.tabId?" "+e.tabId:"");default:return e.action||""}});return o.observe&&e.push(o.observe),e.join(", ")})():o.command||(Object.keys(o).length>0?JSON.stringify(o):"");return(0,a.jsxs)("div",{className:"text-sm",children:[(0,a.jsxs)("button",{onClick:()=>r(!n),className:"flex items-center gap-2 text-xs px-2 py-1.5 bg-zinc-900 border border-zinc-800 rounded-lg hover:border-zinc-700 transition-colors w-full text-left min-w-0",children:["input-streaming"===l||"input-available"===l?(0,a.jsx)("span",{className:"inline-block w-2 h-2 bg-amber-500 rounded-full animate-pulse shrink-0"}):(0,a.jsx)("span",{className:"text-green-500 shrink-0",children:"✓"}),(0,a.jsx)("span",{className:"text-zinc-400 font-mono truncate",children:u}),(0,a.jsx)("span",{className:"ml-auto transition-transform text-zinc-600 shrink-0 ".concat(n?"rotate-90":""),children:"▶"})]}),n&&(0,a.jsxs)("pre",{className:"mt-1 px-3 py-2 bg-zinc-900/50 rounded-lg border border-zinc-800 text-xs whitespace-pre-wrap overflow-x-auto max-h-60 overflow-y-auto",children:[u&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"text-zinc-300 select-all",children:["$ ",u]}),"\n"]}),null!=s&&(()=>{if("browser"===c&&"string"==typeof s)try{let e=JSON.parse(s);if(void 0!==e.textOutput)return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-zinc-500",children:e.textOutput}),e.imageOutput&&(0,a.jsxs)(a.Fragment,{children:["\n",(0,a.jsx)("span",{className:"changed"===e.imageOutput.type?"text-blue-400":"text-zinc-600",children:"changed"===e.imageOutput.type?"[screenshot: changed]":"[screenshot: unchanged]"})]})]})}catch(e){console.error(e)}return(0,a.jsx)("span",{className:"text-zinc-500",children:"string"==typeof s?s:JSON.stringify(s,null,2)})})()]})]})}let O={0:"debug",1:"log",2:"warn",3:"error"};class U{addEvent(e){this.events.push(e)}setMessages(e,t){let n=Date.now(),a=JSON.parse(JSON.stringify(t));for(let t=0;t<a.length;t++){let i=a[t],r="".concat(e,":").concat(t);if(this.seenParts.has(r)||this.seenParts.set(r,n),i._ts=this.seenParts.get(r),i.parts)for(let a=0;a<i.parts.length;a++){let r="".concat(e,":").concat(t,":").concat(a);this.seenParts.has(r)||this.seenParts.set(r,n),i.parts[a]._ts=this.seenParts.get(r)}}this.messages.set(e,a)}addConsoleLog(e,t,n,a,i){this.consoleLogs.has(e)||this.consoleLogs.set(e,[]),this.consoleLogs.get(e).push({ts:Date.now(),level:O[t]||"log",message:n,url:a,line:i})}toJSON(e,t){return{runId:this.runId,startTime:this.startTime,endTime:Date.now(),agents:e,timeline:[...this.events].sort((e,t)=>e.ts-t.ts),messages:Object.fromEntries(this.messages),consoleLogs:Object.fromEntries(this.consoleLogs),clips:t}}constructor(e){this.events=[],this.messages=new Map,this.consoleLogs=new Map,this.seenParts=new Map,this.runId=e,this.startTime=Date.now()}}function F(){let[e,t]=(0,i.useState)([]),[n,r]=(0,i.useState)({}),[o,s]=(0,i.useState)({}),[l,c]=(0,i.useState)(!1),[u,d]=(0,i.useState)({}),h=(0,i.useRef)(new Map),[p,m]=(0,i.useState)(null),[w,g]=(0,i.useState)(!1),[b,f]=(0,i.useState)(!1),v=(0,i.useRef)(null),x=(0,i.useRef)(new Map);(0,i.useEffect)(()=>{(async()=>{var e,n,a,i,o;let l=await (null===(e=window.bangonit)||void 0===e?void 0:e.getAgents())||[];if(0===l.length){let e={id:crypto.randomUUID(),name:"Test 1",createdAt:Date.now()};l.push(e),await (null===(a=window.bangonit)||void 0===a?void 0:a.setAgents(l))}t(l);let u={},d={};for(let e of l){let t=await (null===(i=window.bangonit)||void 0===i?void 0:i.getAgentSession(e.id));t&&(null===(o=t.messages)||void 0===o?void 0:o.length)>0&&(u[e.id]={initialPrompt:t.initialPrompt,initialMessages:t.messages.map(e=>{if("assistant"!==e.role||!e.parts)return e;let t=e.parts.map(e=>"tool-invocation"===e.type&&"result"!==e.state?{...e,state:"result",output:"[Interrupted — app was restarted]"}:e);return{...e,parts:t}}),initialTabs:t.tabs,initialActiveTabId:t.activeTabId,initialTodos:t.todos},d[e.id]="idle")}s(u),r(d),m((null===(n=l[0])||void 0===n?void 0:n.id)||null),c(!0)})()},[]);let y=(0,i.useRef)(e);y.current=e,(0,i.useEffect)(()=>{if(l&&e.length>0){var t;null===(t=window.bangonit)||void 0===t||t.setAgents(e)}},[e,l]);let k=(0,i.useCallback)(async e=>{var t,n;await (null===(n=window.bangonit)||void 0===n?void 0:null===(t=n.clearPartition)||void 0===t?void 0:t.call(n,e));let a=o[e];a&&(r(t=>({...t,[e]:"running"})),d(t=>({...t,[e]:(t[e]||0)+1})),s(t=>({...t,[e]:{initialPrompt:a.initialPrompt}})))},[o]),I=(0,i.useCallback)((e,t)=>{x.current.set(e,t)},[]),T=(0,i.useRef)(n);T.current=n;let N=(0,i.useCallback)(async(e,t)=>{var n,a,i,r;let o=v.current;if(!o)return;let s=await (null===(a=window.bangonit)||void 0===a?void 0:null===(n=a.getRunDir)||void 0===n?void 0:n.call(a));if(!s)return;let l=[];for(let e of x.current.values())l.push(...e.getClipsMeta());let c={...T.current,[e]:t},u=y.current.map(e=>{let t=c[e.id];return{id:e.id,name:e.name,result:"completed"===t?"pass":"failed"===t?"fail":void 0}}),d=o.toJSON(u,l);await (null===(r=window.bangonit)||void 0===r?void 0:null===(i=r.generateReplayHtml)||void 0===i?void 0:i.call(r,{runDir:s,data:JSON.stringify(d)}))},[]),C=(0,i.useCallback)((e,t,n)=>{let a;if(a="running"===t?"running":"pass"===n?"completed":"fail"===n?"failed":"idle",r(t=>({...t,[e]:a})),w&&("pass"===n||"fail"===n)&&N(e,a),"fail"===n){let t=h.current.get(e);if(t&&t.attempt<t.maxRetries){var i,o;t.attempt++,null===(o=window.bangonit)||void 0===o||null===(i=o.emitTestRetry)||void 0===i||i.call(o,{agentId:e,attempt:t.attempt,maxRetries:t.maxRetries}),setTimeout(()=>k(e),1e3)}}},[k,w,N]),j=(0,i.useCallback)((e,n,a)=>{a&&t(t=>t.map(t=>t.id===e?{...t,name:a}:t)),s(t=>({...t,[e]:{initialPrompt:n}})),r(t=>({...t,[e]:"running"})),m(e)},[]),E=(0,i.useCallback)(()=>{let n=crypto.randomUUID(),a={id:n,name:"Test ".concat(e.length+1),createdAt:Date.now()};t(e=>[...e,a]),m(n)},[e.length]);if((0,i.useEffect)(()=>{var e,n;let a=null===(n=window.bangonit)||void 0===n?void 0:null===(e=n.onTestPlan)||void 0===e?void 0:e.call(n,e=>{f(!0);let{agentIndex:n,testPlan:a,name:i,retries:o,extraPrompt:l,record:c,planDir:u}=e;if(c&&!v.current){let e=new Date().toISOString().replace(/[:.]/g,"-");v.current=new U(e),g(!0)}t(e=>{let t=n+1,a=[...e];for(;a.length<t;)a.push({id:crypto.randomUUID(),name:i||"Test ".concat(a.length+1),createdAt:Date.now()});return i&&(a=a.map((e,t)=>t===n?{...e,name:i}:e)),a}),setTimeout(()=>{t(e=>{let t=e[n];if(!t)return e;let i=l?"".concat(a,"\n\n## Additional Instructions\n").concat(l):a;return s(e=>({...e,[t.id]:{initialPrompt:i,planDir:u}})),r(e=>({...e,[t.id]:"running"})),o&&o>0&&h.current.set(t.id,{maxRetries:o,attempt:0,testPlan:i}),0===n&&m(t.id),e})},100)});return()=>null==a?void 0:a()},[]),(0,i.useEffect)(()=>{var e,t;let n=null===(t=window.bangonit)||void 0===t?void 0:null===(e=t.onFocusAgent)||void 0===e?void 0:e.call(t,e=>{m(e.agentId)});return()=>null==n?void 0:n()},[]),!l)return(0,a.jsx)("div",{className:"flex h-screen bg-zinc-950"});e.some(e=>o[e.id]);let S=e.find(e=>e.id===p),R=!!p&&!!o[p];return(0,a.jsxs)("div",{className:"flex h-screen bg-zinc-950 overflow-hidden",children:[(0,a.jsxs)("div",{className:"flex flex-col bg-zinc-900 border-r border-zinc-800 shrink-0 w-48 overflow-y-auto",children:[(0,a.jsxs)("div",{className:"flex items-center px-3 py-2 border-b border-zinc-800",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-zinc-500 uppercase tracking-wider",children:"Tests"}),(0,a.jsx)("div",{className:"flex-1"}),(0,a.jsx)("button",{onClick:E,className:"text-zinc-500 hover:text-zinc-300 transition-colors text-lg leading-none",title:"Add test",children:"+"})]}),e.map(e=>{let t=n[e.id];return o[e.id],(0,a.jsx)("button",{onClick:()=>m(e.id),className:"px-3 py-2 text-xs text-left border-b border-zinc-800 transition-colors\n ".concat(e.id===p?"bg-zinc-800 text-zinc-200":"text-zinc-500 hover:text-zinc-300"),children:(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-block w-2 h-2 rounded-full shrink-0 ".concat("running"===t?"bg-blue-500 animate-pulse":"completed"===t?"bg-green-500":"failed"===t?"bg-red-500":"bg-zinc-600")}),(0,a.jsx)("span",{className:"truncate",children:e.name})]})},e.id)})]}),(0,a.jsxs)("div",{className:"flex-1 min-w-0 h-full relative",children:[e.map(e=>o[e.id]?(0,a.jsx)("div",{className:"absolute inset-0 z-0",style:{display:"flex",zIndex:e.id===p?1:0,pointerEvents:e.id===p?"auto":"none"},children:(0,a.jsx)(A,{agentId:e.id,agentName:e.name,initialPrompt:o[e.id].initialPrompt,initialMessages:o[e.id].initialMessages,initialTabs:o[e.id].initialTabs,initialActiveTabId:o[e.id].initialActiveTabId,initialTodos:o[e.id].initialTodos,onStatusChange:C,onRerun:()=>k(e.id),record:w,sessionRecorder:v.current||void 0,onRegisterRecorder:I,planDir:o[e.id].planDir})},"".concat(e.id,"-").concat(u[e.id]||0)):null),S&&!R&&!b&&(0,a.jsx)(L,{agentId:S.id,agentName:S.name,onSubmit:j})]})]})}function L(e){let{agentId:t,agentName:n,onSubmit:r}=e,[o,s]=(0,i.useState)(""),l=(0,i.useRef)(null);(0,i.useEffect)(()=>{var e;null===(e=l.current)||void 0===e||e.focus()},[t]);let c=()=>{let e=o.trim();e&&r(t,e)};return(0,a.jsx)("div",{className:"absolute inset-0 flex items-center justify-center z-10 bg-zinc-950",children:(0,a.jsxs)("div",{className:"w-full max-w-xl px-6",children:[(0,a.jsx)("h2",{className:"text-lg font-medium text-zinc-200 mb-4",children:"What would you like to test?"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("textarea",{ref:l,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),c())},placeholder:"Describe what to test in plain English...",className:"w-full px-4 py-3 bg-zinc-800 border border-zinc-700 rounded-lg text-sm text-zinc-200 placeholder-zinc-500 resize-none focus:outline-none focus:border-zinc-500 transition-colors",rows:4}),(0,a.jsx)("button",{onClick:c,disabled:!o.trim(),className:"absolute bottom-3 right-3 px-3 py-1.5 bg-blue-600 hover:bg-blue-500 disabled:bg-zinc-700 disabled:text-zinc-500 text-white text-xs font-medium rounded transition-colors",children:"Run"})]}),(0,a.jsx)("p",{className:"text-xs text-zinc-600 mt-2",children:"Press Enter to run. Shift+Enter for a new line."}),(0,a.jsxs)("div",{className:"mt-4",children:[(0,a.jsx)("p",{className:"text-xs text-zinc-600 mb-2",children:"Examples:"}),(0,a.jsx)("div",{className:"flex flex-col gap-1.5",children:["Go to example.com and verify the homepage loads with a heading","Navigate to my-app.com/login, sign in with test@example.com / password123, and verify the dashboard loads","Go to localhost:3000, add an item to the cart, proceed to checkout, and verify the order summary"].map((e,t)=>(0,a.jsx)("button",{onClick:()=>s(e),className:"text-left text-xs text-zinc-500 hover:text-zinc-300 bg-zinc-900 hover:bg-zinc-800 px-3 py-2 rounded border border-zinc-800 transition-colors",children:e},t))})]})]})})}function B(){return(0,a.jsx)(F,{})}}},function(e){e.O(0,[46,631,293,528,744],function(){return e(e.s=6421)}),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[185],{4143:function(n,e,u){Promise.resolve().then(u.t.bind(u,2625,23))},2625:function(){}},function(n){n.O(0,[387,293,528,744],function(){return n(n.s=4143)}),_N_E=n.O()}]);
|
|
File without changes
|
|
File without changes
|
/package/app/webapp/.next/static/{z2gRF0NKwztPLZ9d7ok06 → oyP-lwTb7W3NCCryjxA6T}/_buildManifest.js
RENAMED
|
File without changes
|
/package/app/webapp/.next/static/{z2gRF0NKwztPLZ9d7ok06 → oyP-lwTb7W3NCCryjxA6T}/_ssgManifest.js
RENAMED
|
File without changes
|