@browserbasehq/sdk 1.1.5 → 1.1.7

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 CHANGED
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
+ import BrowserbaseAISDK from './integrations/ai-sdk.js';
2
3
  export type ClientOptions = {
3
4
  apiKey?: string;
4
5
  projectId?: string;
@@ -18,18 +19,24 @@ export type ScreenshotOptions = {
18
19
  export type CreateSessionOptions = {
19
20
  projectId?: string;
20
21
  extensionId?: string;
21
- fingerprint?: {
22
- browserListQuery?: string;
23
- httpVersion?: 1 | 2;
24
- browsers?: Array<'chrome' | 'firefox' | 'edge' | 'safari'>;
25
- devices?: Array<'desktop' | 'mobile'>;
26
- locales?: string[];
27
- operatingSystems?: Array<'windows' | 'macos' | 'linux' | 'ios' | 'android'>;
28
- screen?: {
29
- maxHeight?: number;
30
- maxWidth?: number;
31
- minHeight?: number;
32
- minWidth?: number;
22
+ browserSettings?: {
23
+ fingerprint?: {
24
+ browserListQuery?: string;
25
+ httpVersion?: 1 | 2;
26
+ browsers?: Array<'chrome' | 'firefox' | 'edge' | 'safari'>;
27
+ devices?: Array<'desktop' | 'mobile'>;
28
+ locales?: string[];
29
+ operatingSystems?: Array<'windows' | 'macos' | 'linux' | 'ios' | 'android'>;
30
+ screen?: {
31
+ maxHeight?: number;
32
+ maxWidth?: number;
33
+ minHeight?: number;
34
+ minWidth?: number;
35
+ };
36
+ };
37
+ viewport?: {
38
+ width?: number;
39
+ height?: number;
33
40
  };
34
41
  };
35
42
  };
@@ -37,7 +44,7 @@ export type Session = {
37
44
  id: string;
38
45
  createdAt: string;
39
46
  startedAt: string;
40
- endedAt: string;
47
+ endedAt?: string;
41
48
  projectId: string;
42
49
  status?: 'NEW' | 'CREATED' | 'ERROR' | 'RUNNING' | 'REQUEST_RELEASE' | 'RELEASING' | 'COMPLETED';
43
50
  taskId?: string;
@@ -48,15 +55,16 @@ export type Session = {
48
55
  details?: string;
49
56
  logs?: string;
50
57
  };
51
- export type UpdateSessionOptions = {
52
- projectId?: string;
53
- status: Session['status'];
54
- };
55
58
  export type SessionRecording = {
56
59
  type?: string;
57
60
  time?: string;
58
61
  data?: object;
59
62
  };
63
+ export type DebugConnectionURLs = {
64
+ debuggerFullscreenUrl?: string;
65
+ debuggerUrl?: string;
66
+ wsUrl?: string;
67
+ };
60
68
  export type SessionLog = {
61
69
  sessionId?: string;
62
70
  id: string;
@@ -74,11 +82,6 @@ export type SessionLog = {
74
82
  };
75
83
  pageId?: string;
76
84
  };
77
- export type DebugConnectionURLs = {
78
- debuggerFullscreenUrl?: string;
79
- debuggerUrl?: string;
80
- wsUrl?: string;
81
- };
82
85
  export default class Browserbase {
83
86
  private apiKey;
84
87
  private projectId;
@@ -89,7 +92,6 @@ export default class Browserbase {
89
92
  listSessions(): Promise<Session[]>;
90
93
  createSession(options?: CreateSessionOptions): Promise<Session>;
91
94
  getSession(sessionId: string): Promise<Session>;
92
- updateSession(sessionId: string, options: UpdateSessionOptions): Promise<Session>;
93
95
  getSessionRecording(sessionId: string): Promise<SessionRecording[]>;
94
96
  getSessionDownloads(sessionId: string, retryInterval?: number, retryCount?: number): Promise<Buffer>;
95
97
  getDebugConnectionURLs(sessionId: string): Promise<DebugConnectionURLs>;
@@ -99,4 +101,4 @@ export default class Browserbase {
99
101
  loadURLs(urls: string[], options?: LoadOptions): AsyncGenerator<string>;
100
102
  screenshot(url: string, options?: ScreenshotOptions): Promise<Buffer>;
101
103
  }
102
- export { Browserbase };
104
+ export { Browserbase, BrowserbaseAISDK };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { chromium } from 'playwright';
2
+ import BrowserbaseAISDK from './integrations/ai-sdk.js';
2
3
  export default class Browserbase {
3
4
  apiKey;
4
5
  projectId;
@@ -43,17 +44,6 @@ export default class Browserbase {
43
44
  });
44
45
  return await response.json();
45
46
  }
46
- async updateSession(sessionId, options) {
47
- const response = await fetch(`${this.baseAPIURL}/v1/sessions/${sessionId}`, {
48
- method: 'POST',
49
- headers: {
50
- 'x-bb-api-key': this.apiKey,
51
- 'Content-Type': 'application/json',
52
- },
53
- body: JSON.stringify({ projectId: this.projectId, ...options }),
54
- });
55
- return await response.json();
56
- }
57
47
  async getSessionRecording(sessionId) {
58
48
  const response = await fetch(`${this.baseAPIURL}/v1/sessions/${sessionId}/recording`, {
59
49
  headers: {
@@ -174,4 +164,4 @@ export default class Browserbase {
174
164
  return screenshot;
175
165
  }
176
166
  }
177
- export { Browserbase };
167
+ export { Browserbase, BrowserbaseAISDK };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@browserbasehq/sdk",
4
- "version": "1.1.5",
4
+ "version": "1.1.7",
5
5
  "description": "Browserbase JS SDK",
6
6
  "main": "dist/index.js",
7
7
  "scripts": {
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { chromium } from 'playwright'
2
+ import BrowserbaseAISDK from './integrations/ai-sdk.js'
2
3
 
3
4
  export type ClientOptions = {
4
5
  apiKey?: string
@@ -23,18 +24,24 @@ export type ScreenshotOptions = {
23
24
  export type CreateSessionOptions = {
24
25
  projectId?: string
25
26
  extensionId?: string
26
- fingerprint?: {
27
- browserListQuery?: string
28
- httpVersion?: 1 | 2
29
- browsers?: Array<'chrome' | 'firefox' | 'edge' | 'safari'>
30
- devices?: Array<'desktop' | 'mobile'>
31
- locales?: string[]
32
- operatingSystems?: Array<'windows' | 'macos' | 'linux' | 'ios' | 'android'>
33
- screen?: {
34
- maxHeight?: number
35
- maxWidth?: number
36
- minHeight?: number
37
- minWidth?: number
27
+ browserSettings?: {
28
+ fingerprint?: {
29
+ browserListQuery?: string
30
+ httpVersion?: 1 | 2
31
+ browsers?: Array<'chrome' | 'firefox' | 'edge' | 'safari'>
32
+ devices?: Array<'desktop' | 'mobile'>
33
+ locales?: string[]
34
+ operatingSystems?: Array<'windows' | 'macos' | 'linux' | 'ios' | 'android'>
35
+ screen?: {
36
+ maxHeight?: number
37
+ maxWidth?: number
38
+ minHeight?: number
39
+ minWidth?: number
40
+ }
41
+ }
42
+ viewport?: {
43
+ width?: number
44
+ height?: number
38
45
  }
39
46
  }
40
47
  }
@@ -43,7 +50,7 @@ export type Session = {
43
50
  id: string
44
51
  createdAt: string
45
52
  startedAt: string
46
- endedAt: string
53
+ endedAt?: string
47
54
  projectId: string
48
55
  status?:
49
56
  | 'NEW'
@@ -62,17 +69,18 @@ export type Session = {
62
69
  logs?: string
63
70
  }
64
71
 
65
- export type UpdateSessionOptions = {
66
- projectId?: string
67
- status: Session['status']
68
- }
69
-
70
72
  export type SessionRecording = {
71
73
  type?: string
72
74
  time?: string
73
75
  data?: object
74
76
  }
75
77
 
78
+ export type DebugConnectionURLs = {
79
+ debuggerFullscreenUrl?: string
80
+ debuggerUrl?: string
81
+ wsUrl?: string
82
+ }
83
+
76
84
  export type SessionLog = {
77
85
  sessionId?: string
78
86
  id: string
@@ -91,12 +99,6 @@ export type SessionLog = {
91
99
  pageId?: string
92
100
  }
93
101
 
94
- export type DebugConnectionURLs = {
95
- debuggerFullscreenUrl?: string
96
- debuggerUrl?: string
97
- wsUrl?: string
98
- }
99
-
100
102
  export default class Browserbase {
101
103
  private apiKey: string
102
104
  private projectId: string
@@ -155,25 +157,6 @@ export default class Browserbase {
155
157
  return await response.json()
156
158
  }
157
159
 
158
- async updateSession(
159
- sessionId: string,
160
- options: UpdateSessionOptions
161
- ): Promise<Session> {
162
- const response = await fetch(
163
- `${this.baseAPIURL}/v1/sessions/${sessionId}`,
164
- {
165
- method: 'POST',
166
- headers: {
167
- 'x-bb-api-key': this.apiKey,
168
- 'Content-Type': 'application/json',
169
- },
170
- body: JSON.stringify({ projectId: this.projectId, ...options }),
171
- }
172
- )
173
-
174
- return await response.json()
175
- }
176
-
177
160
  async getSessionRecording(sessionId: string): Promise<SessionRecording[]> {
178
161
  const response = await fetch(
179
162
  `${this.baseAPIURL}/v1/sessions/${sessionId}/recording`,
@@ -346,4 +329,4 @@ export default class Browserbase {
346
329
  }
347
330
  }
348
331
 
349
- export { Browserbase }
332
+ export { Browserbase, BrowserbaseAISDK }
package/test/lib.test.ts CHANGED
@@ -23,13 +23,6 @@ describe('Browserbase', () => {
23
23
  expect(session.id).to.equal(id)
24
24
  })
25
25
 
26
- it('shoud create and update session', async () => {
27
- const { id } = await browserbase.createSession()
28
- const updated = await browserbase.updateSession(id, { status: 'RELEASING' })
29
-
30
- expect(updated.status).to.equal('COMPLETED')
31
- })
32
-
33
26
  it('shoud create a session and retrieve a recording', async () => {
34
27
  const { id } = await browserbase.createSession()
35
28
  const recording = await browserbase.getSessionRecording(id)
@@ -42,6 +35,13 @@ describe('Browserbase', () => {
42
35
  const debug = await browserbase.getDebugConnectionURLs(id)
43
36
  })
44
37
 
38
+ it('shoud create a session and get session logs', async () => {
39
+ const { id } = await browserbase.createSession()
40
+ const logs = await browserbase.getSessionLogs(id)
41
+
42
+ expect(logs.length).to.equal(0)
43
+ })
44
+
45
45
  it('should load a webpage', async () => {
46
46
  const result = await browserbase.load('https://example.com')
47
47
  expect(result).contain('Example Domain')