mxyhi/ok-skills / browser-trace
browser-trace
VerifiedCapture a full DevTools-protocol trace of any browser automation — CDP firehose, screenshots, and DOM dumps — then bisect the stream into per-page searchable buckets. Use when the user wants to debug a failed run, audit network/console/DOM activity, attach a trace to an in-progress session, or feed structured per-page summaries back into an agent loop so its next iteration learns from the last one.
| File | Kind | Size |
|---|---|---|
| EXAMPLES.md | markdown | 8.4 KB |
| LICENSE.txt | markdown | 1.0 KB |
| REFERENCE.md | markdown | 20.1 KB |
| SKILL.md | skill md | 14.7 KB |
| package.json | manifest | 91 B |
| scripts/bb-capture.mjsexecutable | script | 3.7 KB |
| scripts/bb-finalize.mjsexecutable | script | 3.2 KB |
| scripts/bisect-cdp.mjsexecutable | script | 7.6 KB |
| scripts/lib.mjsexecutable | script | 4.2 KB |
| scripts/query.mjsexecutable | script | 8.6 KB |
| scripts/snapshot-loop.mjsexecutable | script | 2.6 KB |
| scripts/start-capture.mjsexecutable | script | 2.9 KB |
| scripts/stop-capture.mjsexecutable | script | 1.5 KB |
scripts/bb-capture.mjs
View on GitHub#!/usr/bin/env node
// Start an observability capture against a Browserbase session.
//
// Usage:
// node scripts/bb-capture.mjs --new [run-id] [interval-seconds]
// node scripts/bb-capture.mjs <session-id> [run-id] [interval-seconds]
//
// Env:
// BROWSERBASE_API_KEY required
// BB_SESSION_TIMEOUT timeout for --new sessions, seconds (default: 600)
// O11Y_ROOT, O11Y_DOMAINS — same as start-capture.mjs
import path from 'node:path';
import { spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { runDir, readJson, writeJson, runCmd } from './lib.mjs';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
if (!process.env.BROWSERBASE_API_KEY) {
console.error('BROWSERBASE_API_KEY must be set');
process.exit(1);
}
const [target, runIdArg, intervalArg] = process.argv.slice(2);
if (!target) {
console.error('usage: bb-capture.mjs --new|<session-id> [run-id] [interval-seconds]');
process.exit(2);
}
let sessionJson;
if (target === '--new') {
const timeout = String(process.env.BB_SESSION_TIMEOUT || '600');
const r = runCmd('browse', ['cloud', 'sessions', 'create', '--keep-alive', '--timeout', timeout]);
if (!r.ok) { console.error(r.stderr || 'browse cloud sessions create failed'); process.exit(1); }
sessionJson = JSON.parse(r.stdout);
console.log(`Created Browserbase session: ${sessionJson.id}`);
} else {
const r = runCmd('browse', ['cloud', 'sessions', 'get', target]);
if (!r.ok) { console.error(r.stderr || 'browse cloud sessions get failed'); process.exit(1); }
sessionJson = JSON.parse(r.stdout);
if (sessionJson.status !== 'RUNNING') {
console.error(`Session ${target} is not RUNNING (status=${sessionJson.status}). Recreate with --keep-alive.`);
process.exit(1);
}
}
const sessionId = sessionJson.id;
const connectUrl = sessionJson.connectUrl;
let debugJson = null;
const dbg = runCmd('browse', ['cloud', 'sessions', 'debug', sessionId]);
if (dbg.ok) {
try { debugJson = JSON.parse(dbg.stdout); } catch {}
}
// Hand off to start-capture.mjs as a child process so it owns its own
// detached background processes (cdp + snapshot loop).
const startScript = path.join(__dirname, 'start-capture.mjs');
const startArgs = [startScript, connectUrl];
if (runIdArg) startArgs.push(runIdArg);
if (intervalArg) startArgs.push(intervalArg);
const start = spawnSync(process.execPath, startArgs, { stdio: ['ignore', 'pipe', 'inherit'] });
if (start.status !== 0) process.exit(start.status ?? 1);
// start-capture writes a status block to stdout; surface it minus the noisy
// signed connectUrl, then add the BB-specific lines.
const lines = start.stdout.toString().split('\n').filter(l => l && !l.startsWith('target='));
for (const l of lines) console.log(l);
// Patch the manifest with Browserbase metadata so traversal queries can later
// join CDP events back to platform info (region, debugger URL, project, etc.).
const runId = (lines.find(l => l.startsWith('run_id=')) || '').slice('run_id='.length);
if (!runId) { console.error('could not parse run_id from start-capture output'); process.exit(1); }
const manifestPath = path.join(runDir(runId), 'manifest.json');
const manifest = readJson(manifestPath, {});
const debuggerUrl = debugJson?.debuggerFullscreenUrl ?? debugJson?.debuggerUrl ?? null;
manifest.browserbase = {
session_id: sessionJson.id,
project_id: sessionJson.projectId,
region: sessionJson.region,
started_at: sessionJson.startedAt,
expires_at: sessionJson.expiresAt,
keep_alive: sessionJson.keepAlive,
debugger_url: debuggerUrl,
};
writeJson(manifestPath, manifest);
if (debuggerUrl) console.log(`Live debugger: ${debuggerUrl}`);
console.log(`session_id=${sessionId}`);
console.log(`connect_url=${(connectUrl || '').slice(0, 60)}…`);
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |