@ulpi/browse 0.10.0 → 1.0.1
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 +6 -6
- package/dist/browse.mjs +6756 -0
- package/package.json +17 -13
- package/skill/SKILL.md +2 -3
- package/bin/browse.ts +0 -11
- package/src/auth-vault.ts +0 -196
- package/src/browser-manager.ts +0 -976
- package/src/buffers.ts +0 -81
- package/src/bun.d.ts +0 -65
- package/src/chrome-discover.ts +0 -73
- package/src/cli.ts +0 -783
- package/src/commands/meta.ts +0 -986
- package/src/commands/read.ts +0 -375
- package/src/commands/write.ts +0 -704
- package/src/config.ts +0 -44
- package/src/constants.ts +0 -14
- package/src/cookie-import.ts +0 -410
- package/src/diff.d.ts +0 -12
- package/src/domain-filter.ts +0 -140
- package/src/encryption.ts +0 -48
- package/src/har.ts +0 -66
- package/src/install-skill.ts +0 -98
- package/src/png-compare.ts +0 -247
- package/src/policy.ts +0 -94
- package/src/rebrowser.d.ts +0 -7
- package/src/record-export.ts +0 -98
- package/src/runtime.ts +0 -161
- package/src/sanitize.ts +0 -11
- package/src/server.ts +0 -526
- package/src/session-manager.ts +0 -240
- package/src/session-persist.ts +0 -192
- package/src/snapshot.ts +0 -606
- package/src/types.ts +0 -12
package/src/buffers.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared buffers and types — extracted to break circular dependency
|
|
3
|
-
* between server.ts and browser-manager.ts
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { DEFAULTS } from './constants';
|
|
7
|
-
|
|
8
|
-
export interface LogEntry {
|
|
9
|
-
timestamp: number;
|
|
10
|
-
level: string;
|
|
11
|
-
text: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface NetworkEntry {
|
|
15
|
-
timestamp: number;
|
|
16
|
-
method: string;
|
|
17
|
-
url: string;
|
|
18
|
-
status?: number;
|
|
19
|
-
duration?: number;
|
|
20
|
-
size?: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Per-session buffer container.
|
|
25
|
-
* Each session (or parallel agent) gets its own instance so buffers
|
|
26
|
-
* don't bleed across concurrent operations.
|
|
27
|
-
*/
|
|
28
|
-
export class SessionBuffers {
|
|
29
|
-
consoleBuffer: LogEntry[] = [];
|
|
30
|
-
networkBuffer: NetworkEntry[] = [];
|
|
31
|
-
consoleTotalAdded = 0;
|
|
32
|
-
networkTotalAdded = 0;
|
|
33
|
-
// Flush cursors — used by server.ts flush logic
|
|
34
|
-
lastConsoleFlushed = 0;
|
|
35
|
-
lastNetworkFlushed = 0;
|
|
36
|
-
|
|
37
|
-
addConsoleEntry(entry: LogEntry) {
|
|
38
|
-
if (this.consoleBuffer.length >= DEFAULTS.BUFFER_HIGH_WATER_MARK) {
|
|
39
|
-
this.consoleBuffer.shift();
|
|
40
|
-
}
|
|
41
|
-
this.consoleBuffer.push(entry);
|
|
42
|
-
this.consoleTotalAdded++;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
addNetworkEntry(entry: NetworkEntry) {
|
|
46
|
-
if (this.networkBuffer.length >= DEFAULTS.BUFFER_HIGH_WATER_MARK) {
|
|
47
|
-
this.networkBuffer.shift();
|
|
48
|
-
}
|
|
49
|
-
this.networkBuffer.push(entry);
|
|
50
|
-
this.networkTotalAdded++;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// ─── Default (singleton) buffers — backward compatibility ────────────
|
|
55
|
-
// Existing code that imports consoleBuffer, networkBuffer, addConsoleEntry,
|
|
56
|
-
// addNetworkEntry, consoleTotalAdded, networkTotalAdded continues to work
|
|
57
|
-
// unchanged against these module-level exports.
|
|
58
|
-
|
|
59
|
-
export const consoleBuffer: LogEntry[] = [];
|
|
60
|
-
export const networkBuffer: NetworkEntry[] = [];
|
|
61
|
-
|
|
62
|
-
// Total entries ever added — used by server.ts flush logic as a cursor
|
|
63
|
-
// that keeps advancing even after the ring buffer wraps.
|
|
64
|
-
export let consoleTotalAdded = 0;
|
|
65
|
-
export let networkTotalAdded = 0;
|
|
66
|
-
|
|
67
|
-
export function addConsoleEntry(entry: LogEntry) {
|
|
68
|
-
if (consoleBuffer.length >= DEFAULTS.BUFFER_HIGH_WATER_MARK) {
|
|
69
|
-
consoleBuffer.shift();
|
|
70
|
-
}
|
|
71
|
-
consoleBuffer.push(entry);
|
|
72
|
-
consoleTotalAdded++;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function addNetworkEntry(entry: NetworkEntry) {
|
|
76
|
-
if (networkBuffer.length >= DEFAULTS.BUFFER_HIGH_WATER_MARK) {
|
|
77
|
-
networkBuffer.shift();
|
|
78
|
-
}
|
|
79
|
-
networkBuffer.push(entry);
|
|
80
|
-
networkTotalAdded++;
|
|
81
|
-
}
|
package/src/bun.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bun runtime type declarations
|
|
3
|
-
*
|
|
4
|
-
* Covers the Bun globals used in this project so tsc --noEmit passes
|
|
5
|
-
* without pulling in the broken bun-types package.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
declare module 'bun' {
|
|
9
|
-
export function serve(options: {
|
|
10
|
-
port: number;
|
|
11
|
-
hostname?: string;
|
|
12
|
-
fetch: (req: Request) => Response | Promise<Response>;
|
|
13
|
-
}): BunServer;
|
|
14
|
-
|
|
15
|
-
export function spawn(cmd: string[], options?: {
|
|
16
|
-
stdio?: Array<'ignore' | 'pipe' | 'inherit'>;
|
|
17
|
-
stdout?: 'pipe' | 'ignore' | 'inherit';
|
|
18
|
-
stderr?: 'pipe' | 'ignore' | 'inherit';
|
|
19
|
-
env?: Record<string, string | undefined>;
|
|
20
|
-
}): BunSubprocess;
|
|
21
|
-
|
|
22
|
-
export function sleep(ms: number): Promise<void>;
|
|
23
|
-
|
|
24
|
-
export const stdin: { text(): Promise<string> };
|
|
25
|
-
|
|
26
|
-
interface BunServer {
|
|
27
|
-
port: number;
|
|
28
|
-
stop(): void;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface BunSubprocess {
|
|
32
|
-
pid: number;
|
|
33
|
-
stderr: ReadableStream<Uint8Array> | null;
|
|
34
|
-
stdout: ReadableStream<Uint8Array> | null;
|
|
35
|
-
exited: Promise<number>;
|
|
36
|
-
unref(): void;
|
|
37
|
-
kill(signal?: number): void;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
declare module 'bun:sqlite' {
|
|
42
|
-
export class Database {
|
|
43
|
-
constructor(filename: string, options?: { readonly?: boolean; create?: boolean });
|
|
44
|
-
query(sql: string): Statement;
|
|
45
|
-
close(): void;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
interface Statement {
|
|
49
|
-
all(...params: any[]): any[];
|
|
50
|
-
get(...params: any[]): any;
|
|
51
|
-
run(...params: any[]): void;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
declare var Bun: {
|
|
56
|
-
serve: typeof import('bun').serve;
|
|
57
|
-
spawn: typeof import('bun').spawn;
|
|
58
|
-
sleep: typeof import('bun').sleep;
|
|
59
|
-
stdin: typeof import('bun').stdin;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
interface ImportMeta {
|
|
63
|
-
dir: string;
|
|
64
|
-
main: boolean;
|
|
65
|
-
}
|
package/src/chrome-discover.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Discover a running Chrome instance for CDP connection.
|
|
3
|
-
*
|
|
4
|
-
* Strategy (first match wins):
|
|
5
|
-
* 1. Read DevToolsActivePort file from known browser profile paths
|
|
6
|
-
* 2. Probe well-known CDP ports (9222, 9229)
|
|
7
|
-
* 3. Return null if nothing found
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import * as os from 'os';
|
|
11
|
-
import * as fs from 'fs';
|
|
12
|
-
import * as path from 'path';
|
|
13
|
-
|
|
14
|
-
const PROFILE_PATHS = [
|
|
15
|
-
'Google/Chrome',
|
|
16
|
-
'Arc/User Data',
|
|
17
|
-
'BraveSoftware/Brave-Browser',
|
|
18
|
-
'Microsoft Edge',
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
const PROBE_PORTS = [9222, 9229];
|
|
22
|
-
|
|
23
|
-
/** Fetch the CDP WebSocket URL from a Chrome /json/version endpoint. */
|
|
24
|
-
async function fetchWsUrl(port: number): Promise<string | null> {
|
|
25
|
-
try {
|
|
26
|
-
const res = await fetch(`http://127.0.0.1:${port}/json/version`, {
|
|
27
|
-
signal: AbortSignal.timeout(2000),
|
|
28
|
-
});
|
|
29
|
-
if (!res.ok) return null;
|
|
30
|
-
const data = (await res.json()) as { webSocketDebuggerUrl?: string };
|
|
31
|
-
return data.webSocketDebuggerUrl ?? null;
|
|
32
|
-
} catch {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** Read a DevToolsActivePort file and extract the port number. */
|
|
38
|
-
function readDevToolsPort(filePath: string): number | null {
|
|
39
|
-
try {
|
|
40
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
41
|
-
const port = parseInt(content.split('\n')[0], 10);
|
|
42
|
-
return Number.isFinite(port) && port > 0 ? port : null;
|
|
43
|
-
} catch {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Discover a running Chrome instance and return its CDP WebSocket URL.
|
|
50
|
-
* Returns null if no reachable Chrome is found.
|
|
51
|
-
*/
|
|
52
|
-
export async function discoverChrome(): Promise<string | null> {
|
|
53
|
-
const home = os.homedir();
|
|
54
|
-
|
|
55
|
-
// 1. Try DevToolsActivePort files
|
|
56
|
-
for (const profile of PROFILE_PATHS) {
|
|
57
|
-
const filePath = path.join(home, 'Library', 'Application Support', profile, 'DevToolsActivePort');
|
|
58
|
-
const port = readDevToolsPort(filePath);
|
|
59
|
-
if (port) {
|
|
60
|
-
const wsUrl = await fetchWsUrl(port);
|
|
61
|
-
if (wsUrl) return wsUrl;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// 2. Probe well-known ports
|
|
66
|
-
for (const port of PROBE_PORTS) {
|
|
67
|
-
const wsUrl = await fetchWsUrl(port);
|
|
68
|
-
if (wsUrl) return wsUrl;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// 3. Nothing found
|
|
72
|
-
return null;
|
|
73
|
-
}
|