Skip to content

Commit aa755ed

Browse files
Merge branch 'main' into fm/stg-489-add-regression-tests
i# Please enter a commit message to explain why this merge is necessary, merge main
2 parents ac43e5a + 046511f commit aa755ed

File tree

10 files changed

+39
-36
lines changed

10 files changed

+39
-36
lines changed

.changeset/daffy-rapid-turaco.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/masterful-amiable-leopard.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/sceptical-mutant-shrew.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/feature-parity.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
owner: context.repo.owner,
4848
repo: context.repo.repo,
4949
issue_number: context.issue.number,
50-
body: `❌ **Parity Label Removed**\n\n@${context.actor}, you do not have sufficient permissions to add the 'parity' label. Only users with write access can trigger feature parity issues.\n\nIf you believe this feature should be implemented in the Python SDK, please ask a maintainer to add the label.`
50+
body: `❌ **Parity Label Removed**\n\n@${context.actor}, you do not have sufficient permissions to add the 'parity' label. Only users with write access can trigger feature parity issues.\n\nIf you believe this feature should be implemented in the Typescript SDK, please ask a maintainer to add the label.`
5151
});
5252
5353
throw new Error(`User ${context.actor} does not have write access to add parity label`);
@@ -62,7 +62,7 @@ jobs:
6262
app-id: ${{ secrets.PARITY_APP_ID }}
6363
private-key: ${{ secrets.PARITY_APP_PRIVATE_KEY }}
6464
owner: browserbase
65-
repositories: stagehand
65+
repositories: stagehand-python
6666

6767
- name: Create issue in Python SDK repository
6868
uses: actions/github-script@v7
@@ -104,7 +104,7 @@ jobs:
104104
const issueTitle = `[Feature Parity] ${pullRequest.title}`;
105105
const issueBody = `## Feature Parity Request
106106
107-
This issue was automatically created from a pull request in the TypeScript Stagehand repository that was labeled with 'parity'.
107+
This issue was automatically created from a pull request in the Python Stagehand repository that was labeled with 'parity'.
108108
109109
### Original PR Details
110110
- **PR**: #${context.issue.number} - ${pullRequest.title}
@@ -120,12 +120,12 @@ jobs:
120120
${commentsSection}
121121
122122
### Action Required
123-
Please review the changes in the original PR and implement equivalent functionality in the Python SDK if applicable.
123+
Please review the changes in the original PR and implement equivalent functionality in the Typescript SDK if applicable.
124124
125125
---
126126
*This issue was automatically generated by the Feature Parity workflow.*`;
127127
128-
// Create the issue in the Python repository
128+
// Create the issue in the Typescript repository
129129
const { data: issue } = await github.rest.issues.create({
130130
owner: 'browserbase',
131131
repo: 'stagehand',
@@ -141,5 +141,5 @@ jobs:
141141
owner: context.repo.owner,
142142
repo: context.repo.repo,
143143
issue_number: context.issue.number,
144-
body: `🔄 **Feature Parity Issue Created**\n\nAn issue has been automatically created in the Python SDK repository to track parity implementation:\n${issue.html_url}`
144+
body: `🔄 **Feature Parity Issue Created**\n\nAn issue has been automatically created in the Typescript SDK repository to track parity implementation:\n${issue.html_url}`
145145
});

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Stagehand Python Changelog
22

3+
## 0.5.0
4+
5+
### Minor Changes
6+
[#167](https://github.com/browserbase/stagehand-python/pull/167) [`76669f0`](https://github.com/browserbase/stagehand-python/commit/76669f0) Thanks @miguelg719! - Enable access to iframes on api
7+
8+
### Patch Changes
9+
10+
[#168](https://github.com/browserbase/stagehand-python/pull/168) [`a7d8c5e`](https://github.com/browserbase/stagehand-python/commit/a7d8c5e) Thanks @miguelg719! - Patch issue with passing a created session_id to init on api mode
11+
[#155](https://github.com/browserbase/stagehand-python/pull/155) [`8d55709`](https://github.com/browserbase/stagehand-python/commit/8d55709) Thanks @Zach10za! - Fix error in press_key act util function
12+
[#158](https://github.com/browserbase/stagehand-python/pull/158) [`426df10`](https://github.com/browserbase/stagehand-python/commit/426df10) Thanks @miguelg719! - Fix parsing schema for extract with no arguments (full page extract)
13+
[#166](https://github.com/browserbase/stagehand-python/pull/166) [`15fd40b`](https://github.com/browserbase/stagehand-python/commit/15fd40b) Thanks @filip-michalsky! - fix logging param name
14+
[#159](https://github.com/browserbase/stagehand-python/pull/159) [`cd3dc7f`](https://github.com/browserbase/stagehand-python/commit/cd3dc7f) Thanks @tkattkat! - Add support for claude 4 sonnet in agent & remove all images but the last two from anthropic cua client
15+
316
## 0.4.1
417

518
### Patch Changes

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "stagehand"
7-
version = "0.4.1"
7+
version = "0.5.0"
88
description = "Python SDK for Stagehand"
99
readme = "README.md"
1010
classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent",]

stagehand/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ async def _create_session(self):
3030
"modelName": self.model_name,
3131
"verbose": 2 if self.verbose == 3 else self.verbose,
3232
"domSettleTimeoutMs": self.dom_settle_timeout_ms,
33+
"browserbaseSessionID": self.session_id,
3334
"browserbaseSessionCreateParams": (
3435
browserbase_session_create_params
3536
if browserbase_session_create_params

stagehand/main.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -399,15 +399,7 @@ async def init(self):
399399
if self.env == "BROWSERBASE":
400400
# Create session if we don't have one
401401
if self.use_api:
402-
if not self.session_id:
403-
await self._create_session() # Uses self._client and api_url
404-
self.logger.debug(
405-
f"Created new Browserbase session via Stagehand server: {self.session_id}"
406-
)
407-
else:
408-
self.logger.debug(
409-
f"Using existing Browserbase session: {self.session_id}"
410-
)
402+
await self._create_session() # Uses self._client and api_url
411403

412404
# Connect to remote browser
413405
try:

stagehand/page.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,14 @@ async def act(
137137
elif isinstance(action_or_result, ActOptions):
138138
payload = action_or_result.model_dump(exclude_none=True, by_alias=True)
139139
elif isinstance(action_or_result, dict):
140-
payload = ObserveResult(**action_or_result).model_dump(
141-
exclude_none=True, by_alias=True
142-
)
140+
if "description" in action_or_result:
141+
payload = ObserveResult(**action_or_result).model_dump(
142+
exclude_none=True, by_alias=True
143+
)
144+
else:
145+
payload = ActOptions(**action_or_result).model_dump(
146+
exclude_none=True, by_alias=True
147+
)
143148
else:
144149
raise TypeError(
145150
"Invalid arguments for 'act'. Expected str, ObserveResult, or ActOptions."
@@ -156,6 +161,10 @@ async def act(
156161
self, self._stagehand, "", self._stagehand.self_heal
157162
)
158163
self._stagehand.logger.debug("act", category="act", auxiliary=payload)
164+
if payload.get("iframes"):
165+
raise ValueError(
166+
"iframes is not yet supported without API (to enable make sure you set env=BROWSERBASE and use_api=true)"
167+
)
159168
result = await self._act_handler.act(payload)
160169
return result
161170

@@ -606,7 +615,7 @@ async def sweep_stalled_requests():
606615
meta.pop(request_id, None)
607616
self._stagehand.logger.debug(
608617
"⏳ forcing completion of stalled iframe document",
609-
extra={"url": request_meta["url"][:120]},
618+
auxiliary={"url": request_meta["url"][:120]},
610619
)
611620
maybe_quiet()
612621

@@ -620,7 +629,7 @@ async def timeout_guard():
620629
if len(inflight) > 0:
621630
self._stagehand.logger.debug(
622631
"⚠️ DOM-settle timeout reached – network requests still pending",
623-
extra={"count": len(inflight)},
632+
auxiliary={"count": len(inflight)},
624633
)
625634
resolve_done()
626635

stagehand/schemas.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class ActOptions(StagehandBaseModel):
5353
dom_settle_timeout_ms: Optional[int] = None
5454
timeout_ms: Optional[int] = None
5555
model_client_options: Optional[dict[str, Any]] = None
56+
iframes: Optional[bool] = None
5657

5758

5859
class ActResult(StagehandBaseModel):
@@ -98,6 +99,7 @@ class ExtractOptions(StagehandBaseModel):
9899
use_text_extract: Optional[bool] = None
99100
dom_settle_timeout_ms: Optional[int] = None
100101
model_client_options: Optional[dict[Any, Any]] = None
102+
iframes: Optional[bool] = None
101103

102104
@field_serializer("schema_definition")
103105
def serialize_schema_definition(
@@ -196,6 +198,7 @@ class ObserveOptions(StagehandBaseModel):
196198
draw_overlay: Optional[bool] = None
197199
dom_settle_timeout_ms: Optional[int] = None
198200
model_client_options: Optional[dict[str, Any]] = None
201+
iframes: Optional[bool] = None
199202

200203

201204
class ObserveResult(StagehandBaseModel):

0 commit comments

Comments
 (0)