@browserbasehq/sdk 1.1.5 → 1.1.6

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;
@@ -37,7 +38,7 @@ export type Session = {
37
38
  id: string;
38
39
  createdAt: string;
39
40
  startedAt: string;
40
- endedAt: string;
41
+ endedAt?: string;
41
42
  projectId: string;
42
43
  status?: 'NEW' | 'CREATED' | 'ERROR' | 'RUNNING' | 'REQUEST_RELEASE' | 'RELEASING' | 'COMPLETED';
43
44
  taskId?: string;
@@ -48,15 +49,16 @@ export type Session = {
48
49
  details?: string;
49
50
  logs?: string;
50
51
  };
51
- export type UpdateSessionOptions = {
52
- projectId?: string;
53
- status: Session['status'];
54
- };
55
52
  export type SessionRecording = {
56
53
  type?: string;
57
54
  time?: string;
58
55
  data?: object;
59
56
  };
57
+ export type DebugConnectionURLs = {
58
+ debuggerFullscreenUrl?: string;
59
+ debuggerUrl?: string;
60
+ wsUrl?: string;
61
+ };
60
62
  export type SessionLog = {
61
63
  sessionId?: string;
62
64
  id: string;
@@ -74,11 +76,6 @@ export type SessionLog = {
74
76
  };
75
77
  pageId?: string;
76
78
  };
77
- export type DebugConnectionURLs = {
78
- debuggerFullscreenUrl?: string;
79
- debuggerUrl?: string;
80
- wsUrl?: string;
81
- };
82
79
  export default class Browserbase {
83
80
  private apiKey;
84
81
  private projectId;
@@ -89,7 +86,6 @@ export default class Browserbase {
89
86
  listSessions(): Promise<Session[]>;
90
87
  createSession(options?: CreateSessionOptions): Promise<Session>;
91
88
  getSession(sessionId: string): Promise<Session>;
92
- updateSession(sessionId: string, options: UpdateSessionOptions): Promise<Session>;
93
89
  getSessionRecording(sessionId: string): Promise<SessionRecording[]>;
94
90
  getSessionDownloads(sessionId: string, retryInterval?: number, retryCount?: number): Promise<Buffer>;
95
91
  getDebugConnectionURLs(sessionId: string): Promise<DebugConnectionURLs>;
@@ -99,4 +95,4 @@ export default class Browserbase {
99
95
  loadURLs(urls: string[], options?: LoadOptions): AsyncGenerator<string>;
100
96
  screenshot(url: string, options?: ScreenshotOptions): Promise<Buffer>;
101
97
  }
102
- export { Browserbase };
98
+ 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.6",
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
@@ -43,7 +44,7 @@ export type Session = {
43
44
  id: string
44
45
  createdAt: string
45
46
  startedAt: string
46
- endedAt: string
47
+ endedAt?: string
47
48
  projectId: string
48
49
  status?:
49
50
  | 'NEW'
@@ -62,17 +63,18 @@ export type Session = {
62
63
  logs?: string
63
64
  }
64
65
 
65
- export type UpdateSessionOptions = {
66
- projectId?: string
67
- status: Session['status']
68
- }
69
-
70
66
  export type SessionRecording = {
71
67
  type?: string
72
68
  time?: string
73
69
  data?: object
74
70
  }
75
71
 
72
+ export type DebugConnectionURLs = {
73
+ debuggerFullscreenUrl?: string
74
+ debuggerUrl?: string
75
+ wsUrl?: string
76
+ }
77
+
76
78
  export type SessionLog = {
77
79
  sessionId?: string
78
80
  id: string
@@ -91,12 +93,6 @@ export type SessionLog = {
91
93
  pageId?: string
92
94
  }
93
95
 
94
- export type DebugConnectionURLs = {
95
- debuggerFullscreenUrl?: string
96
- debuggerUrl?: string
97
- wsUrl?: string
98
- }
99
-
100
96
  export default class Browserbase {
101
97
  private apiKey: string
102
98
  private projectId: string
@@ -155,25 +151,6 @@ export default class Browserbase {
155
151
  return await response.json()
156
152
  }
157
153
 
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
154
  async getSessionRecording(sessionId: string): Promise<SessionRecording[]> {
178
155
  const response = await fetch(
179
156
  `${this.baseAPIURL}/v1/sessions/${sessionId}/recording`,
@@ -346,4 +323,4 @@ export default class Browserbase {
346
323
  }
347
324
  }
348
325
 
349
- export { Browserbase }
326
+ 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')