@browserbasehq/sdk 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +113 -0
- package/dist/integrations/ai-sdk.d.ts +18 -0
- package/dist/integrations/ai-sdk.js +19 -0
- package/package.json +2 -2
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import BrowserbaseAISDK from './integrations/ai-sdk.js';
|
|
2
|
+
export type ClientOptions = {
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
projectId?: string;
|
|
5
|
+
baseURL?: string;
|
|
6
|
+
baseConnectURL?: string;
|
|
7
|
+
};
|
|
8
|
+
export type ConnectOptions = {
|
|
9
|
+
sessionId?: string;
|
|
10
|
+
proxy?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type LoadOptions = {
|
|
13
|
+
textContent?: boolean;
|
|
14
|
+
} & ConnectOptions;
|
|
15
|
+
export type ScreenshotOptions = {
|
|
16
|
+
fullPage?: boolean;
|
|
17
|
+
} & ConnectOptions;
|
|
18
|
+
export type CreateSessionOptions = {
|
|
19
|
+
projectId?: string;
|
|
20
|
+
extensionId?: string;
|
|
21
|
+
browserSettings?: {
|
|
22
|
+
fingerprint?: {
|
|
23
|
+
browserListQuery?: string;
|
|
24
|
+
httpVersion?: 1 | 2;
|
|
25
|
+
browsers?: Array<'chrome' | 'firefox' | 'edge' | 'safari'>;
|
|
26
|
+
devices?: Array<'desktop' | 'mobile'>;
|
|
27
|
+
locales?: string[];
|
|
28
|
+
operatingSystems?: Array<'windows' | 'macos' | 'linux' | 'ios' | 'android'>;
|
|
29
|
+
screen?: {
|
|
30
|
+
maxHeight?: number;
|
|
31
|
+
maxWidth?: number;
|
|
32
|
+
minHeight?: number;
|
|
33
|
+
minWidth?: number;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
viewport?: {
|
|
37
|
+
width?: number;
|
|
38
|
+
height?: number;
|
|
39
|
+
};
|
|
40
|
+
context?: {
|
|
41
|
+
id: string;
|
|
42
|
+
persist: boolean;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
keepAlive?: boolean;
|
|
46
|
+
timeout?: number;
|
|
47
|
+
};
|
|
48
|
+
export type Session = {
|
|
49
|
+
id: string;
|
|
50
|
+
createdAt: string;
|
|
51
|
+
startedAt: string;
|
|
52
|
+
endedAt?: string;
|
|
53
|
+
expiresAt: string;
|
|
54
|
+
projectId: string;
|
|
55
|
+
status: 'RUNNING' | 'COMPLETED' | 'ERROR' | 'TIMED_OUT';
|
|
56
|
+
taskId?: string;
|
|
57
|
+
proxyBytes?: number;
|
|
58
|
+
avg_cpu_usage?: number;
|
|
59
|
+
memory_usage?: number;
|
|
60
|
+
details?: string;
|
|
61
|
+
logs?: string;
|
|
62
|
+
};
|
|
63
|
+
export type SessionRecording = {
|
|
64
|
+
type?: number;
|
|
65
|
+
time?: string;
|
|
66
|
+
data?: any;
|
|
67
|
+
};
|
|
68
|
+
export type DebugConnectionURLs = {
|
|
69
|
+
debuggerFullscreenUrl?: string;
|
|
70
|
+
debuggerUrl?: string;
|
|
71
|
+
wsUrl?: string;
|
|
72
|
+
};
|
|
73
|
+
export type SessionLog = {
|
|
74
|
+
sessionId?: string;
|
|
75
|
+
id: string;
|
|
76
|
+
timestamp?: string;
|
|
77
|
+
method?: string;
|
|
78
|
+
request?: {
|
|
79
|
+
timestamp?: string;
|
|
80
|
+
params?: any;
|
|
81
|
+
rawBody?: string;
|
|
82
|
+
};
|
|
83
|
+
response?: {
|
|
84
|
+
timestamp?: string;
|
|
85
|
+
result?: any;
|
|
86
|
+
rawBody?: string;
|
|
87
|
+
};
|
|
88
|
+
pageId?: string;
|
|
89
|
+
};
|
|
90
|
+
export default class Browserbase {
|
|
91
|
+
private apiKey;
|
|
92
|
+
private projectId;
|
|
93
|
+
private baseAPIURL;
|
|
94
|
+
private baseConnectURL;
|
|
95
|
+
constructor(options?: ClientOptions);
|
|
96
|
+
getConnectURL({ sessionId, proxy }?: ConnectOptions): string;
|
|
97
|
+
listSessions(): Promise<Session[]>;
|
|
98
|
+
createSession(options?: CreateSessionOptions): Promise<Session>;
|
|
99
|
+
completeSession(sessionId: string): Promise<Session>;
|
|
100
|
+
getSession(sessionId: string): Promise<Session>;
|
|
101
|
+
getSessionRecording(sessionId: string): Promise<SessionRecording[]>;
|
|
102
|
+
getSessionDownloads(sessionId: string, retryInterval?: number, retryCount?: number): Promise<Buffer>;
|
|
103
|
+
getDebugConnectionURLs(sessionId: string): Promise<DebugConnectionURLs>;
|
|
104
|
+
getSessionLogs(sessionId: string): Promise<SessionLog[]>;
|
|
105
|
+
load(url: string | string[], options?: LoadOptions): Promise<string> | AsyncGenerator<string, any, unknown>;
|
|
106
|
+
loadURL(url: string, options?: LoadOptions): Promise<string>;
|
|
107
|
+
loadURLs(urls: string[], options?: LoadOptions): AsyncGenerator<string>;
|
|
108
|
+
screenshot(url: string, options?: ScreenshotOptions): Promise<Buffer>;
|
|
109
|
+
createContext(): Promise<{
|
|
110
|
+
id: string;
|
|
111
|
+
}>;
|
|
112
|
+
}
|
|
113
|
+
export { Browserbase, BrowserbaseAISDK };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import Browserbase, { LoadOptions } from '../index.js';
|
|
3
|
+
export default function BrowserbaseAISDK(b: Browserbase, options?: LoadOptions): {
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: z.ZodObject<{
|
|
6
|
+
url: z.ZodString;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
url?: string;
|
|
9
|
+
}, {
|
|
10
|
+
url?: string;
|
|
11
|
+
}>;
|
|
12
|
+
execute: ({ url }: {
|
|
13
|
+
url: string;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
page: string;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
export { BrowserbaseAISDK };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = BrowserbaseAISDK;
|
|
4
|
+
exports.BrowserbaseAISDK = BrowserbaseAISDK;
|
|
5
|
+
exports.default = BrowserbaseAISDK;
|
|
6
|
+
exports.BrowserbaseAISDK = BrowserbaseAISDK;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
function BrowserbaseAISDK(b, options = {}) {
|
|
9
|
+
return {
|
|
10
|
+
description: 'Load a webpage in a browser hosted by Browserbase and return its contents',
|
|
11
|
+
parameters: zod_1.z.object({
|
|
12
|
+
url: zod_1.z.string().describe('Page URL to be loaded'),
|
|
13
|
+
}),
|
|
14
|
+
execute: async ({ url }) => {
|
|
15
|
+
const page = await b.loadURL(url, options);
|
|
16
|
+
return { page };
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@browserbasehq/sdk",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Browserbase JS SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"@types/node": "^20.12.7",
|
|
32
32
|
"chai": "^5.1.0",
|
|
33
33
|
"tsx": "^4.7.2",
|
|
34
|
-
"typescript": "^
|
|
34
|
+
"typescript": "^5.5.2"
|
|
35
35
|
}
|
|
36
36
|
}
|