diff --git a/.gitignore b/.gitignore index 433374d..b8dd6b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .prism.log +.stdy.log _dev __pycache__ diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 2a266f8..da0b97f 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.7.0" + ".": "3.18.0" } diff --git a/.stats.yml b/.stats.yml index 4f6d212..c5e5d8a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 8 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-975ca868b31b1e45fb00b31a53d9df1ceec8663f6c2851bf40fdaa84171afadc.yml -openapi_spec_hash: 37891379e0f47e5c69769fbaa1064dab -config_hash: 0209737a4ab2a71afececb0ff7459998 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fstagehand-a4a5ea048bb50d06460d81d6828b53b12b19e9224121ee6338dcd1f0781e22a1.yml +openapi_spec_hash: 9b81c0ae04576318d13d7a80d4ab7b5a +config_hash: d6c6f623d03971bdba921650e5eb7e5f diff --git a/CHANGELOG.md b/CHANGELOG.md index b7705e0..2307002 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 3.18.0 (2026-03-24) + +Full Changelog: [v3.7.0...v3.18.0](https://github.com/browserbase/stagehand-python/compare/v3.7.0...v3.18.0) + +### Features + +* Add explicit SSE event names for local v3 streaming ([493abf4](https://github.com/browserbase/stagehand-python/commit/493abf4ee2023c3a88701c01bdd4bfdd1f4e0b63)) + + +### Chores + +* **internal:** update gitignore ([5acaa6f](https://github.com/browserbase/stagehand-python/commit/5acaa6f97a3fd926e3406c3af3504576a86a05bb)) + ## 3.7.0 (2026-03-23) Full Changelog: [v3.6.0...v3.7.0](https://github.com/browserbase/stagehand-python/compare/v3.6.0...v3.7.0) diff --git a/pyproject.toml b/pyproject.toml index b890e29..beb416c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stagehand" -version = "3.7.0" +version = "3.18.0" description = "The official Python library for the stagehand API" dynamic = ["readme"] license = "MIT" diff --git a/src/stagehand/_streaming.py b/src/stagehand/_streaming.py index 78f7b69..83a250a 100644 --- a/src/stagehand/_streaming.py +++ b/src/stagehand/_streaming.py @@ -59,10 +59,7 @@ def __stream__(self) -> Iterator[_T]: try: for sse in iterator: - if sse.data.startswith('{"data":{"status":"finished"'): - break - - if sse.data.startswith("error"): + if sse.event == "error": body = sse.data try: @@ -77,7 +74,12 @@ def __stream__(self) -> Iterator[_T]: response=self.response, ) - if sse.event is None: + if ( + sse.event == "starting" + or sse.event == "connected" + or sse.event == "running" + or sse.event == "finished" + ): yield process_data(data=sse.json(), cast_to=cast_to, response=response) finally: # Ensure the response is closed even if the consumer doesn't read all data @@ -144,10 +146,7 @@ async def __stream__(self) -> AsyncIterator[_T]: try: async for sse in iterator: - if sse.data.startswith('{"data":{"status":"finished"'): - break - - if sse.data.startswith("error"): + if sse.event == "error": body = sse.data try: @@ -162,7 +161,12 @@ async def __stream__(self) -> AsyncIterator[_T]: response=self.response, ) - if sse.event is None: + if ( + sse.event == "starting" + or sse.event == "connected" + or sse.event == "running" + or sse.event == "finished" + ): yield process_data(data=sse.json(), cast_to=cast_to, response=response) finally: # Ensure the response is closed even if the consumer doesn't read all data diff --git a/src/stagehand/_version.py b/src/stagehand/_version.py index 5c32ea2..e5144c2 100644 --- a/src/stagehand/_version.py +++ b/src/stagehand/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "stagehand" -__version__ = "3.7.0" # x-release-please-version +__version__ = "3.18.0" # x-release-please-version diff --git a/src/stagehand/types/stream_event.py b/src/stagehand/types/stream_event.py index 3d5b21e..6fd4758 100644 --- a/src/stagehand/types/stream_event.py +++ b/src/stagehand/types/stream_event.py @@ -32,7 +32,7 @@ class DataStreamEventLogDataOutput(BaseModel): class StreamEvent(BaseModel): """Server-Sent Event emitted during streaming responses. - Events are sent as `data: \n\n`. Key order: data (with status first), type, id. + Events are sent as `event: \ndata: \n\n`, where the JSON payload has the shape `{ data, type, id }`. """ id: str