@roveapi/browser 1.0.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 +77 -0
- package/dist/client.d.ts +52 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +94 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +26 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +51 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +3 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +31 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/session.d.ts +65 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +51 -0
- package/dist/session.js.map +1 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @roveapi/browser
|
|
2
|
+
|
|
3
|
+
Browser automation SDK for AI agents. Wraps the [Rove API](https://roveapi.com) — Playwright-as-a-Service with accessibility trees for 77% fewer tokens.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @roveapi/browser
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quickstart
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { BrowserClient } from '@roveapi/browser'
|
|
15
|
+
|
|
16
|
+
const client = new BrowserClient({ apiKey: 'rvp_live_...' })
|
|
17
|
+
|
|
18
|
+
// One-shot screenshot
|
|
19
|
+
const screenshot = await client.screenshot({ url: 'https://example.com' })
|
|
20
|
+
console.log(screenshot.url) // signed S3 URL
|
|
21
|
+
|
|
22
|
+
// Session-based workflow
|
|
23
|
+
const session = await client.session()
|
|
24
|
+
await session.navigate('https://example.com')
|
|
25
|
+
const tree = await session.getA11yTree()
|
|
26
|
+
console.log(tree.result.tree) // accessibility tree (~26K tokens vs ~114K for screenshot)
|
|
27
|
+
await session.click({ label: 'Get Started' })
|
|
28
|
+
await session.fill({ selector: '#email', value: 'user@example.com' })
|
|
29
|
+
await session.close()
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Error Handling
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { BrowserClient, InsufficientCreditsError, RateLimitError } from '@roveapi/browser'
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const session = await client.session()
|
|
39
|
+
} catch (err) {
|
|
40
|
+
if (err instanceof InsufficientCreditsError) {
|
|
41
|
+
console.log('Top up credits at roveapi.com')
|
|
42
|
+
}
|
|
43
|
+
if (err instanceof RateLimitError) {
|
|
44
|
+
console.log(`Retry after ${err.retryAfter} seconds`)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## API
|
|
50
|
+
|
|
51
|
+
### `BrowserClient`
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
new BrowserClient({ apiKey, baseUrl?, retries?, retryDelay? })
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- `client.session(options?)` → `Session`
|
|
58
|
+
- `client.screenshot({ url, selector?, fullPage?, format? })` → `ScreenshotResponse`
|
|
59
|
+
- `client.extract({ url, schema, waitForSelector? })` → `ExtractResponse`
|
|
60
|
+
- `client.usage()` → `UsageResponse`
|
|
61
|
+
|
|
62
|
+
### `Session`
|
|
63
|
+
|
|
64
|
+
- `session.navigate(url, options?)` — load URL, return title + status
|
|
65
|
+
- `session.getA11yTree(options?)` — accessibility tree (primary tool for LLMs)
|
|
66
|
+
- `session.click({ selector?, label? })` — click element
|
|
67
|
+
- `session.fill({ selector?, label?, value })` — type into input
|
|
68
|
+
- `session.select({ selector?, value? })` — select dropdown option
|
|
69
|
+
- `session.scroll({ direction?, amount? })` — scroll page
|
|
70
|
+
- `session.waitFor({ type, value })` — wait for condition
|
|
71
|
+
- `session.screenshot({ fullPage?, format? })` — capture page
|
|
72
|
+
- `session.getText(selector)` — extract text
|
|
73
|
+
- `session.getAttribute(selector, attribute)` — get attribute
|
|
74
|
+
- `session.evaluate(expression)` — run JavaScript
|
|
75
|
+
- `session.close()` — close session, finalize artifacts
|
|
76
|
+
|
|
77
|
+
Auto-retry on 503 (pool exhausted, browser crash) with exponential backoff. No retry on 402 (insufficient credits) or 410 (session expired).
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Session } from './session';
|
|
2
|
+
import type { ScreenshotResponse, ExtractResponse, UsageResponse } from './types';
|
|
3
|
+
export type BrowserClientOptions = {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
retries?: number;
|
|
7
|
+
retryDelay?: number;
|
|
8
|
+
};
|
|
9
|
+
export declare class BrowserClient {
|
|
10
|
+
private readonly apiKey;
|
|
11
|
+
private readonly baseUrl;
|
|
12
|
+
private readonly retries;
|
|
13
|
+
private readonly retryDelay;
|
|
14
|
+
constructor(options: BrowserClientOptions);
|
|
15
|
+
/** Create a persistent browser session */
|
|
16
|
+
session(options?: {
|
|
17
|
+
viewport?: {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
};
|
|
21
|
+
recordVideo?: boolean;
|
|
22
|
+
locale?: string;
|
|
23
|
+
timezone?: string;
|
|
24
|
+
userAgent?: string;
|
|
25
|
+
blockResources?: string[];
|
|
26
|
+
}): Promise<Session>;
|
|
27
|
+
/** One-shot screenshot (no persistent session) */
|
|
28
|
+
screenshot(params: {
|
|
29
|
+
url: string;
|
|
30
|
+
selector?: string;
|
|
31
|
+
fullPage?: boolean;
|
|
32
|
+
format?: 'png' | 'jpeg';
|
|
33
|
+
viewport?: {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
};
|
|
37
|
+
}): Promise<ScreenshotResponse>;
|
|
38
|
+
/** One-shot structured data extraction */
|
|
39
|
+
extract(params: {
|
|
40
|
+
url: string;
|
|
41
|
+
schema: Record<string, string>;
|
|
42
|
+
waitForSelector?: string;
|
|
43
|
+
}): Promise<ExtractResponse>;
|
|
44
|
+
/** Get usage and credit balance */
|
|
45
|
+
usage(): Promise<UsageResponse>;
|
|
46
|
+
/** @internal — used by Session class */
|
|
47
|
+
request<T>(path: string, init: {
|
|
48
|
+
method: string;
|
|
49
|
+
body?: unknown;
|
|
50
|
+
}): Promise<T>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEjF,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;gBAEvB,OAAO,EAAE,oBAAoB;IAOzC,0CAA0C;IACpC,OAAO,CAAC,OAAO,CAAC,EAAE;QACtB,QAAQ,CAAC,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;QAC5C,WAAW,CAAC,EAAE,OAAO,CAAA;QACrB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;KAC1B,GAAG,OAAO,CAAC,OAAO,CAAC;IAapB,kDAAkD;IAC5C,UAAU,CAAC,MAAM,EAAE;QACvB,GAAG,EAAE,MAAM,CAAA;QACX,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;QACvB,QAAQ,CAAC,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;KAC7C,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAa/B,0CAA0C;IACpC,OAAO,CAAC,MAAM,EAAE;QACpB,GAAG,EAAE,MAAM,CAAA;QACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAC9B,eAAe,CAAC,EAAE,MAAM,CAAA;KACzB,GAAG,OAAO,CAAC,eAAe,CAAC;IAW5B,mCAAmC;IAC7B,KAAK,IAAI,OAAO,CAAC,aAAa,CAAC;IAIrC,wCAAwC;IAClC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,CAAC,CAAC;CAsCrF"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Session } from './session';
|
|
2
|
+
import { mapApiError } from './http';
|
|
3
|
+
export class BrowserClient {
|
|
4
|
+
apiKey;
|
|
5
|
+
baseUrl;
|
|
6
|
+
retries;
|
|
7
|
+
retryDelay;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.apiKey = options.apiKey;
|
|
10
|
+
this.baseUrl = options.baseUrl ?? 'https://api.roveapi.com';
|
|
11
|
+
this.retries = options.retries ?? 3;
|
|
12
|
+
this.retryDelay = options.retryDelay ?? 1000;
|
|
13
|
+
}
|
|
14
|
+
/** Create a persistent browser session */
|
|
15
|
+
async session(options) {
|
|
16
|
+
const body = {
|
|
17
|
+
viewport: options?.viewport,
|
|
18
|
+
record_video: options?.recordVideo,
|
|
19
|
+
locale: options?.locale,
|
|
20
|
+
timezone: options?.timezone,
|
|
21
|
+
user_agent: options?.userAgent,
|
|
22
|
+
block_resources: options?.blockResources,
|
|
23
|
+
};
|
|
24
|
+
const data = await this.request('/v1/browser/session', { method: 'POST', body });
|
|
25
|
+
return new Session(data.session_id, this);
|
|
26
|
+
}
|
|
27
|
+
/** One-shot screenshot (no persistent session) */
|
|
28
|
+
async screenshot(params) {
|
|
29
|
+
return this.request('/v1/browser/screenshot', {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
body: {
|
|
32
|
+
url: params.url,
|
|
33
|
+
selector: params.selector,
|
|
34
|
+
full_page: params.fullPage,
|
|
35
|
+
format: params.format,
|
|
36
|
+
viewport: params.viewport,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/** One-shot structured data extraction */
|
|
41
|
+
async extract(params) {
|
|
42
|
+
return this.request('/v1/browser/extract', {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
body: {
|
|
45
|
+
url: params.url,
|
|
46
|
+
schema: params.schema,
|
|
47
|
+
wait_for_selector: params.waitForSelector,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** Get usage and credit balance */
|
|
52
|
+
async usage() {
|
|
53
|
+
return this.request('/v1/account/usage', { method: 'GET' });
|
|
54
|
+
}
|
|
55
|
+
/** @internal — used by Session class */
|
|
56
|
+
async request(path, init) {
|
|
57
|
+
let lastError;
|
|
58
|
+
for (let attempt = 0; attempt <= this.retries; attempt++) {
|
|
59
|
+
try {
|
|
60
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
61
|
+
method: init.method,
|
|
62
|
+
headers: {
|
|
63
|
+
'content-type': 'application/json',
|
|
64
|
+
authorization: `Bearer ${this.apiKey}`,
|
|
65
|
+
},
|
|
66
|
+
body: init.body ? JSON.stringify(init.body) : undefined,
|
|
67
|
+
});
|
|
68
|
+
if (!response.ok) {
|
|
69
|
+
const error = await mapApiError(response);
|
|
70
|
+
// Don't retry on client errors (except 429 and 503)
|
|
71
|
+
if (response.status < 500 && response.status !== 429) {
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
return (await response.json());
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
lastError = err instanceof Error ? err : new Error(String(err));
|
|
80
|
+
// Don't retry non-retryable errors
|
|
81
|
+
if (lastError.name === 'InsufficientCreditsError' || lastError.name === 'SessionExpiredError' || lastError.name === 'InvalidParamsError') {
|
|
82
|
+
throw lastError;
|
|
83
|
+
}
|
|
84
|
+
if (attempt < this.retries) {
|
|
85
|
+
const jitter = Math.random() * 0.3 + 0.85; // 0.85-1.15x
|
|
86
|
+
const delay = this.retryDelay * Math.pow(2, attempt) * jitter;
|
|
87
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
throw lastError;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAUpC,MAAM,OAAO,aAAa;IACP,MAAM,CAAQ;IACd,OAAO,CAAQ;IACf,OAAO,CAAQ;IACf,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AAC;oBACD,MAAM,KAAK,CAAA;gBACb,CAAC;gBAED,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAA;YACrC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,SAAS,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;gBAC/D,mCAAmC;gBACnC,IAAI,SAAS,CAAC,IAAI,KAAK,0BAA0B,IAAI,SAAS,CAAC,IAAI,KAAK,qBAAqB,IAAI,SAAS,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;oBACzI,MAAM,SAAS,CAAA;gBACjB,CAAC;gBACD,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;oBAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,IAAI,CAAA,CAAC,aAAa;oBACvD,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,MAAM,CAAA;oBAC7D,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;gBAChD,CAAC;YACH,CAAC;QACH,CAAC;QACD,MAAM,SAAU,CAAA;IAClB,CAAC;CACF"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare class RoveError extends Error {
|
|
2
|
+
readonly status: number;
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly detail?: string | undefined;
|
|
5
|
+
constructor(message: string, status: number, code: string, detail?: string | undefined);
|
|
6
|
+
}
|
|
7
|
+
export declare class InsufficientCreditsError extends RoveError {
|
|
8
|
+
constructor(detail?: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class SessionExpiredError extends RoveError {
|
|
11
|
+
constructor(detail?: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class RateLimitError extends RoveError {
|
|
14
|
+
readonly retryAfter: number;
|
|
15
|
+
constructor(retryAfter: number, detail?: string);
|
|
16
|
+
}
|
|
17
|
+
export declare class BrowserCrashError extends RoveError {
|
|
18
|
+
constructor(detail?: string);
|
|
19
|
+
}
|
|
20
|
+
export declare class PoolExhaustedError extends RoveError {
|
|
21
|
+
constructor(detail?: string);
|
|
22
|
+
}
|
|
23
|
+
export declare class InvalidParamsError extends RoveError {
|
|
24
|
+
constructor(detail?: string);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAU,SAAQ,KAAK;aAGhB,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,MAAM;aACZ,MAAM,CAAC,EAAE,MAAM;gBAH/B,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,YAAA;CAKlC;AAED,qBAAa,wBAAyB,SAAQ,SAAS;gBACzC,MAAM,CAAC,EAAE,MAAM;CAI5B;AAED,qBAAa,mBAAoB,SAAQ,SAAS;gBACpC,MAAM,CAAC,EAAE,MAAM;CAI5B;AAED,qBAAa,cAAe,SAAQ,SAAS;aAEzB,UAAU,EAAE,MAAM;gBAAlB,UAAU,EAAE,MAAM,EAClC,MAAM,CAAC,EAAE,MAAM;CAKlB;AAED,qBAAa,iBAAkB,SAAQ,SAAS;gBAClC,MAAM,CAAC,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,MAAM,CAAC,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,MAAM,CAAC,EAAE,MAAM;CAI5B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export class RoveError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
code;
|
|
4
|
+
detail;
|
|
5
|
+
constructor(message, status, code, detail) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.status = status;
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.detail = detail;
|
|
10
|
+
this.name = 'RoveError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class InsufficientCreditsError extends RoveError {
|
|
14
|
+
constructor(detail) {
|
|
15
|
+
super('Insufficient credits', 402, 'insufficient-credits', detail);
|
|
16
|
+
this.name = 'InsufficientCreditsError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class SessionExpiredError extends RoveError {
|
|
20
|
+
constructor(detail) {
|
|
21
|
+
super('Session expired', 410, 'session-expired', detail);
|
|
22
|
+
this.name = 'SessionExpiredError';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class RateLimitError extends RoveError {
|
|
26
|
+
retryAfter;
|
|
27
|
+
constructor(retryAfter, detail) {
|
|
28
|
+
super('Rate limit exceeded', 429, 'rate-limit-exceeded', detail);
|
|
29
|
+
this.retryAfter = retryAfter;
|
|
30
|
+
this.name = 'RateLimitError';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export class BrowserCrashError extends RoveError {
|
|
34
|
+
constructor(detail) {
|
|
35
|
+
super('Browser crash', 503, 'browser-crash', detail);
|
|
36
|
+
this.name = 'BrowserCrashError';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export class PoolExhaustedError extends RoveError {
|
|
40
|
+
constructor(detail) {
|
|
41
|
+
super('Pool exhausted', 503, 'pool-exhausted', detail);
|
|
42
|
+
this.name = 'PoolExhaustedError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export class InvalidParamsError extends RoveError {
|
|
46
|
+
constructor(detail) {
|
|
47
|
+
super('Invalid parameters', 400, 'invalid-params', detail);
|
|
48
|
+
this.name = 'InvalidParamsError';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,SAAU,SAAQ,KAAK;IAGhB;IACA;IACA;IAJlB,YACE,OAAe,EACC,MAAc,EACd,IAAY,EACZ,MAAe;QAE/B,KAAK,CAAC,OAAO,CAAC,CAAA;QAJE,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAS;QAG/B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAA;IACzB,CAAC;CACF;AAED,MAAM,OAAO,wBAAyB,SAAQ,SAAS;IACrD,YAAY,MAAe;QACzB,KAAK,CAAC,sBAAsB,EAAE,GAAG,EAAE,sBAAsB,EAAE,MAAM,CAAC,CAAA;QAClE,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAA;IACxC,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAChD,YAAY,MAAe;QACzB,KAAK,CAAC,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,CAAC,CAAA;QACxD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;IACnC,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,SAAS;IAEzB;IADlB,YACkB,UAAkB,EAClC,MAAe;QAEf,KAAK,CAAC,qBAAqB,EAAE,GAAG,EAAE,qBAAqB,EAAE,MAAM,CAAC,CAAA;QAHhD,eAAU,GAAV,UAAU,CAAQ;QAIlC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAA;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC9C,YAAY,MAAe;QACzB,KAAK,CAAC,eAAe,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,CAAC,CAAA;QACpD,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;IACjC,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,YAAY,MAAe;QACzB,KAAK,CAAC,gBAAgB,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAA;QACtD,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAA;IAClC,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,YAAY,MAAe;QACzB,KAAK,CAAC,oBAAoB,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAA;QAC1D,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAA;IAClC,CAAC;CACF"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAOV,MAAM,UAAU,CAAA;AASjB,wBAAsB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CA4BxE"}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RoveError, InsufficientCreditsError, SessionExpiredError, RateLimitError, BrowserCrashError, PoolExhaustedError, InvalidParamsError, } from './errors';
|
|
2
|
+
export async function mapApiError(response) {
|
|
3
|
+
let problem = {};
|
|
4
|
+
try {
|
|
5
|
+
problem = (await response.json());
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
// ignore parse errors
|
|
9
|
+
}
|
|
10
|
+
const detail = problem.detail ?? response.statusText;
|
|
11
|
+
const code = problem.type?.split('/').pop() ?? 'unknown';
|
|
12
|
+
switch (response.status) {
|
|
13
|
+
case 400:
|
|
14
|
+
return new InvalidParamsError(detail);
|
|
15
|
+
case 402:
|
|
16
|
+
return new InsufficientCreditsError(detail);
|
|
17
|
+
case 410:
|
|
18
|
+
return new SessionExpiredError(detail);
|
|
19
|
+
case 429: {
|
|
20
|
+
const retryAfter = Number(response.headers.get('retry-after') ?? 60);
|
|
21
|
+
return new RateLimitError(retryAfter, detail);
|
|
22
|
+
}
|
|
23
|
+
case 503:
|
|
24
|
+
if (code === 'pool-exhausted')
|
|
25
|
+
return new PoolExhaustedError(detail);
|
|
26
|
+
return new BrowserCrashError(detail);
|
|
27
|
+
default:
|
|
28
|
+
return new RoveError(detail, response.status, code, detail);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,wBAAwB,EACxB,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,UAAU,CAAA;AASjB,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAkB;IAClD,IAAI,OAAO,GAAmB,EAAE,CAAA;IAChC,IAAI,CAAC;QACH,OAAO,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAmB,CAAA;IACrD,CAAC;IAAC,MAAM,CAAC;QACP,sBAAsB;IACxB,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,CAAA;IACpD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,SAAS,CAAA;IAExD,QAAQ,QAAQ,CAAC,MAAM,EAAE,CAAC;QACxB,KAAK,GAAG;YACN,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAA;QACvC,KAAK,GAAG;YACN,OAAO,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAA;QAC7C,KAAK,GAAG;YACN,OAAO,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAA;QACxC,KAAK,GAAG,CAAC,CAAC,CAAC;YACT,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAA;YACpE,OAAO,IAAI,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;QAC/C,CAAC;QACD,KAAK,GAAG;YACN,IAAI,IAAI,KAAK,gBAAgB;gBAAE,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAA;YACpE,OAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,CAAA;QACtC;YACE,OAAO,IAAI,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IAC/D,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { BrowserClient, type BrowserClientOptions } from './client';
|
|
2
|
+
export { Session } from './session';
|
|
3
|
+
export { RoveError, InsufficientCreditsError, SessionExpiredError, RateLimitError, BrowserCrashError, PoolExhaustedError, InvalidParamsError, } from './errors';
|
|
4
|
+
export type { SessionCreateResponse, ActionResponse, ScreenshotResponse, ExtractResponse, UsageResponse, A11yTreeResult, NavigateResult, ClickResult, FillResult, } from './types';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EACL,SAAS,EACT,wBAAwB,EACxB,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,UAAU,CAAA;AACjB,YAAY,EACV,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,EACX,UAAU,GACX,MAAM,SAAS,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { BrowserClient } from './client';
|
|
2
|
+
export { Session } from './session';
|
|
3
|
+
export { RoveError, InsufficientCreditsError, SessionExpiredError, RateLimitError, BrowserCrashError, PoolExhaustedError, InvalidParamsError, } from './errors';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA6B,MAAM,UAAU,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EACL,SAAS,EACT,wBAAwB,EACxB,mBAAmB,EACnB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { BrowserClient } from './client';
|
|
2
|
+
import type { ActionResponse, NavigateResult, A11yTreeResult, ClickResult, FillResult } from './types';
|
|
3
|
+
export declare class Session {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
private readonly client;
|
|
6
|
+
constructor(id: string, client: BrowserClient);
|
|
7
|
+
private action;
|
|
8
|
+
navigate(url: string, options?: {
|
|
9
|
+
waitUntil?: 'load' | 'domcontentloaded' | 'networkidle';
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
}): Promise<ActionResponse<NavigateResult>>;
|
|
12
|
+
getA11yTree(options?: {
|
|
13
|
+
includeHidden?: boolean;
|
|
14
|
+
rootSelector?: string;
|
|
15
|
+
}): Promise<ActionResponse<A11yTreeResult>>;
|
|
16
|
+
click(target: {
|
|
17
|
+
selector?: string;
|
|
18
|
+
label?: string;
|
|
19
|
+
button?: 'left' | 'right' | 'middle';
|
|
20
|
+
clickCount?: number;
|
|
21
|
+
waitAfterMs?: number;
|
|
22
|
+
}): Promise<ActionResponse<ClickResult>>;
|
|
23
|
+
fill(target: {
|
|
24
|
+
selector?: string;
|
|
25
|
+
label?: string;
|
|
26
|
+
value: string;
|
|
27
|
+
clearFirst?: boolean;
|
|
28
|
+
}): Promise<ActionResponse<FillResult>>;
|
|
29
|
+
select(params: {
|
|
30
|
+
selector?: string;
|
|
31
|
+
value?: string;
|
|
32
|
+
labelText?: string;
|
|
33
|
+
}): Promise<ActionResponse<unknown>>;
|
|
34
|
+
scroll(params?: {
|
|
35
|
+
direction?: 'up' | 'down' | 'left' | 'right';
|
|
36
|
+
amount?: number;
|
|
37
|
+
selector?: string;
|
|
38
|
+
}): Promise<ActionResponse<unknown>>;
|
|
39
|
+
waitFor(params: {
|
|
40
|
+
type: 'selector' | 'text' | 'url' | 'timeout';
|
|
41
|
+
value: string;
|
|
42
|
+
state?: string;
|
|
43
|
+
timeoutMs?: number;
|
|
44
|
+
}): Promise<ActionResponse<unknown>>;
|
|
45
|
+
screenshot(params?: {
|
|
46
|
+
selector?: string;
|
|
47
|
+
fullPage?: boolean;
|
|
48
|
+
format?: 'png' | 'jpeg';
|
|
49
|
+
}): Promise<ActionResponse<unknown>>;
|
|
50
|
+
getText(selector: string, trim?: boolean): Promise<ActionResponse<{
|
|
51
|
+
text: string;
|
|
52
|
+
selector: string;
|
|
53
|
+
}>>;
|
|
54
|
+
getAttribute(selector: string, attribute: string): Promise<ActionResponse<{
|
|
55
|
+
attribute: string;
|
|
56
|
+
value: string | null;
|
|
57
|
+
selector: string;
|
|
58
|
+
}>>;
|
|
59
|
+
evaluate(expression: string): Promise<ActionResponse<{
|
|
60
|
+
value: unknown;
|
|
61
|
+
type: string;
|
|
62
|
+
}>>;
|
|
63
|
+
close(): Promise<ActionResponse<unknown>>;
|
|
64
|
+
}
|
|
65
|
+
//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,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;IAIxE,MAAM,CAAC,MAAM,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;IAIpG,OAAO,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;IAIpH,UAAU,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;KAAE;IAItF,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,UAAO;cACd,MAAM;kBAAY,MAAM;;IAG/C,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;mBACpB,MAAM;eAAS,MAAM,GAAG,IAAI;kBAAY,MAAM;;IAG1E,QAAQ,CAAC,UAAU,EAAE,MAAM;eACH,OAAO;cAAQ,MAAM;;IAG7C,KAAK;CAGZ"}
|
package/dist/session.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export class Session {
|
|
2
|
+
id;
|
|
3
|
+
client;
|
|
4
|
+
constructor(id, client) {
|
|
5
|
+
this.id = id;
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
action(action, params = {}) {
|
|
9
|
+
return this.client.request('/v1/browser/action', {
|
|
10
|
+
method: 'POST',
|
|
11
|
+
body: { session_id: this.id, action, params },
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async navigate(url, options) {
|
|
15
|
+
return this.action('navigate', { url, wait_until: options?.waitUntil, timeout_ms: options?.timeoutMs });
|
|
16
|
+
}
|
|
17
|
+
async getA11yTree(options) {
|
|
18
|
+
return this.action('get_a11y_tree', { include_hidden: options?.includeHidden, root_selector: options?.rootSelector });
|
|
19
|
+
}
|
|
20
|
+
async click(target) {
|
|
21
|
+
return this.action('click', { selector: target.selector, label: target.label, button: target.button, click_count: target.clickCount, wait_after_ms: target.waitAfterMs });
|
|
22
|
+
}
|
|
23
|
+
async fill(target) {
|
|
24
|
+
return this.action('fill', { selector: target.selector, label: target.label, value: target.value, clear_first: target.clearFirst });
|
|
25
|
+
}
|
|
26
|
+
async select(params) {
|
|
27
|
+
return this.action('select', { selector: params.selector, value: params.value, label_text: params.labelText });
|
|
28
|
+
}
|
|
29
|
+
async scroll(params) {
|
|
30
|
+
return this.action('scroll', { direction: params?.direction, amount: params?.amount, selector: params?.selector });
|
|
31
|
+
}
|
|
32
|
+
async waitFor(params) {
|
|
33
|
+
return this.action('wait_for', { type: params.type, value: params.value, state: params.state, timeout_ms: params.timeoutMs });
|
|
34
|
+
}
|
|
35
|
+
async screenshot(params) {
|
|
36
|
+
return this.action('screenshot', { selector: params?.selector, full_page: params?.fullPage, format: params?.format });
|
|
37
|
+
}
|
|
38
|
+
async getText(selector, trim = true) {
|
|
39
|
+
return this.action('get_text', { selector, trim });
|
|
40
|
+
}
|
|
41
|
+
async getAttribute(selector, attribute) {
|
|
42
|
+
return this.action('get_attribute', { selector, attribute });
|
|
43
|
+
}
|
|
44
|
+
async evaluate(expression) {
|
|
45
|
+
return this.action('evaluate', { expression });
|
|
46
|
+
}
|
|
47
|
+
async close() {
|
|
48
|
+
return this.action('close_session');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,OA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gB,EAAE,SAAiB;QACpD,OAAO,IAAI,CAAC,MAAM,CAAgE,eAAe,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAA;IAC7H,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,UAAkB;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAmC,UAAU,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;IAClF,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAA;IACrC,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export type SessionCreateResponse = {
|
|
2
|
+
session_id: string;
|
|
3
|
+
connection_token: string;
|
|
4
|
+
expires_at: string;
|
|
5
|
+
environment: 'live' | 'test';
|
|
6
|
+
};
|
|
7
|
+
export type ActionResponse<T = Record<string, unknown>> = {
|
|
8
|
+
success: boolean;
|
|
9
|
+
result: T;
|
|
10
|
+
credits_used: number;
|
|
11
|
+
duration_ms: number;
|
|
12
|
+
environment: 'live' | 'test';
|
|
13
|
+
};
|
|
14
|
+
export type NavigateResult = {
|
|
15
|
+
url: string;
|
|
16
|
+
title: string;
|
|
17
|
+
status_code: number;
|
|
18
|
+
load_time_ms: number;
|
|
19
|
+
};
|
|
20
|
+
export type A11yTreeResult = {
|
|
21
|
+
tree: string;
|
|
22
|
+
node_count: number;
|
|
23
|
+
estimated_tokens: number;
|
|
24
|
+
};
|
|
25
|
+
export type ClickResult = {
|
|
26
|
+
clicked: boolean;
|
|
27
|
+
element: {
|
|
28
|
+
tag: string;
|
|
29
|
+
text: string;
|
|
30
|
+
selector: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export type FillResult = {
|
|
34
|
+
filled: boolean;
|
|
35
|
+
selector: string;
|
|
36
|
+
length: number;
|
|
37
|
+
};
|
|
38
|
+
export type ScreenshotResponse = {
|
|
39
|
+
url: string;
|
|
40
|
+
expires_at: string;
|
|
41
|
+
file_size_bytes?: number;
|
|
42
|
+
width_px?: number;
|
|
43
|
+
height_px?: number;
|
|
44
|
+
source_url?: string;
|
|
45
|
+
artifact_id?: string;
|
|
46
|
+
};
|
|
47
|
+
export type ExtractResponse = {
|
|
48
|
+
data: Record<string, unknown>;
|
|
49
|
+
};
|
|
50
|
+
export type UsageResponse = {
|
|
51
|
+
api_key: string;
|
|
52
|
+
plan: string;
|
|
53
|
+
credits_total: number;
|
|
54
|
+
credits_used: number;
|
|
55
|
+
credits_remaining: number;
|
|
56
|
+
current_period_actions: {
|
|
57
|
+
sessions: number;
|
|
58
|
+
navigations: number;
|
|
59
|
+
interactions: number;
|
|
60
|
+
screenshots: number;
|
|
61
|
+
extractions: number;
|
|
62
|
+
};
|
|
63
|
+
credits_expire: string | null;
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,GAAG,MAAM,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACxD,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,CAAC,CAAA;IACT,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,GAAG,MAAM,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAA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AAc,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B,CAAA"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@roveapi/browser",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Browser automation SDK for AI agents — Playwright-as-a-Service with accessibility trees",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"keywords": [
|
|
12
|
+
"browser",
|
|
13
|
+
"automation",
|
|
14
|
+
"playwright",
|
|
15
|
+
"a11y",
|
|
16
|
+
"accessibility",
|
|
17
|
+
"mcp",
|
|
18
|
+
"ai-agent"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"typescript": "^5"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc",
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
31
|
+
"test": "echo 'no tests yet'"
|
|
32
|
+
}
|
|
33
|
+
}
|