Skip to content

Commit 7482e95

Browse files
committed
Added docs and made getters return undefined if mode is LOCAL
1 parent 7c9fd43 commit 7482e95

File tree

3 files changed

+41
-11
lines changed

3 files changed

+41
-11
lines changed

packages/core/lib/v3/v3.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ export class V3 {
137137
private readonly domSettleTimeoutMs?: number;
138138
private _isClosing = false;
139139
public browserbaseSessionId?: string;
140-
private browserbaseSessionUrl = "";
141-
private browserbaseDebugUrl = "";
140+
private browserbaseSessionUrl?: string;
141+
private browserbaseDebugUrl?: string;
142142
public get browserbaseSessionID(): string | undefined {
143143
return this.browserbaseSessionId;
144144
}
145-
public get browserbaseSessionURL(): string {
145+
public get browserbaseSessionURL(): string | undefined {
146146
return this.browserbaseSessionUrl;
147147
}
148-
public get browserbaseDebugURL(): string {
148+
public get browserbaseDebugURL(): string | undefined {
149149
return this.browserbaseDebugUrl;
150150
}
151151
private _onCdpClosed = (why: string) => {
@@ -862,7 +862,7 @@ export class V3 {
862862
}
863863
const sessionUrl = `https://www.browserbase.com/sessions/${sessionId}`;
864864
this.browserbaseSessionUrl = sessionUrl;
865-
this.browserbaseDebugUrl = debugUrl ?? "";
865+
this.browserbaseDebugUrl = debugUrl;
866866

867867
try {
868868
this.logger({
@@ -940,8 +940,8 @@ export class V3 {
940940

941941
private resetBrowserbaseSessionMetadata(): void {
942942
this.browserbaseSessionId = undefined;
943-
this.browserbaseSessionUrl = "";
944-
this.browserbaseDebugUrl = "";
943+
this.browserbaseSessionUrl = undefined;
944+
this.browserbaseDebugUrl = undefined;
945945
}
946946

947947
/**

packages/core/tests/browserbase-session-accessors.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ describe("browserbase accessors", () => {
8989
await v3.init();
9090
await v3.close();
9191

92-
expect(v3.browserbaseSessionURL).toBe("");
93-
expect(v3.browserbaseDebugURL).toBe("");
92+
expect(v3.browserbaseSessionURL).toBeUndefined();
93+
expect(v3.browserbaseDebugURL).toBeUndefined();
9494
});
9595
});
9696

@@ -107,8 +107,8 @@ describe("local accessors", () => {
107107

108108
try {
109109
await v3.init();
110-
expect(v3.browserbaseSessionURL).toBe("");
111-
expect(v3.browserbaseDebugURL).toBe("");
110+
expect(v3.browserbaseSessionURL).toBeUndefined();
111+
expect(v3.browserbaseDebugURL).toBeUndefined();
112112
} finally {
113113
await v3.close().catch(() => {});
114114
}

packages/docs/v3/references/stagehand.mdx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,36 @@ interface HistoryEntry {
379379
}
380380
```
381381

382+
### browserbaseSessionID
383+
384+
Browserbase session identifier for the active Browserbase run.
385+
386+
```typescript
387+
const sessionId = stagehand.browserbaseSessionID;
388+
```
389+
390+
**Type:** `string | undefined` — undefined for LOCAL runs or before `init()`.
391+
392+
### browserbaseSessionURL
393+
394+
Shareable link to the active Browserbase session dashboard.
395+
396+
```typescript
397+
const sessionUrl = stagehand.browserbaseSessionURL;
398+
```
399+
400+
**Type:** `string | undefined` — undefined until a Browserbase session is active.
401+
402+
### browserbaseDebugURL
403+
404+
Debugger URL returned by Browserbase for direct CDP inspection.
405+
406+
```typescript
407+
const debugUrl = stagehand.browserbaseDebugURL;
408+
```
409+
410+
**Type:** `string | undefined` — undefined for LOCAL runs or if Browserbase doesn’t provide one.
411+
382412
## Code Examples
383413

384414
<Tabs>

0 commit comments

Comments
 (0)