Skip to content

Commit 90cf596

Browse files
committed
release: sync v0.12.0 from internal repository
1 parent eafd70a commit 90cf596

File tree

86 files changed

+9062
-966
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+9062
-966
lines changed

.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Automatically create a GitHub Release when a version tag is pushed.
2+
# Extracts the changelog section for the tagged version from CHANGES.md.
3+
4+
name: Create Release
5+
6+
on:
7+
push:
8+
tags:
9+
- 'v*'
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
release:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Extract version from tag
22+
id: version
23+
run: |
24+
TAG="${GITHUB_REF#refs/tags/}"
25+
VERSION="${TAG#v}"
26+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
27+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
28+
echo "Releasing: $TAG (version $VERSION)"
29+
30+
- name: Extract changelog for this version
31+
id: changelog
32+
run: |
33+
VERSION="${{ steps.version.outputs.version }}"
34+
35+
# Extract the section between ## [VERSION] and the next ## [
36+
BODY=$(awk -v ver="$VERSION" '
37+
/^## \[/ {
38+
if (found) exit
39+
if (index($0, "[" ver "]")) { found=1; next }
40+
}
41+
found { print }
42+
' CHANGES.md)
43+
44+
if [ -z "$BODY" ]; then
45+
BODY="Release ${{ steps.version.outputs.tag }}"
46+
echo "Warning: No changelog entry found for version $VERSION"
47+
fi
48+
49+
# Write to file to preserve newlines
50+
echo "$BODY" > /tmp/release-body.md
51+
echo "body_file=/tmp/release-body.md" >> "$GITHUB_OUTPUT"
52+
53+
- name: Create GitHub Release
54+
uses: softprops/action-gh-release@v2
55+
with:
56+
tag_name: ${{ steps.version.outputs.tag }}
57+
name: ${{ steps.version.outputs.tag }}
58+
body_path: ${{ steps.changelog.outputs.body_file }}
59+
draft: false
60+
prerelease: false

CHANGES.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,46 @@
11
# Changelog
22

3+
## [0.12.0] - 2026-04-07
4+
5+
### New Features
6+
7+
- **WebSocket**: New websocket client module (`ws`) with integration tests; session-level websocket client initialization and cleanup with improved logging on deletion.
8+
- **MCP Tools**: Add support for MCP tools in session — tool list parsing, `callMcpTool` routing, session URL handling, and additional session fields.
9+
- **Screenshot (Python)**: `beta_take_screenshot` method in Screen module with fixed import order.
10+
- **Screenshot (TypeScript)**: Sync `betaTakeScreenshot` API with unit and integration tests.
11+
- **Execution Context**: New documentation for execution context module.
12+
13+
### Enhancements
14+
15+
- **MCP Routing**: MCP tool invocation smart routing pushed down to `BaseService`, aligning Python and TypeScript implementations.
16+
- **TypeScript Exceptions**: Refactor exception classes with factory functions to eliminate duplicate code.
17+
- **TypeScript**: Remove `enableBrowserReplay` feature; add union types for tool list and improve imports handling.
18+
- **FileSystem Monitoring**: Enhance directory monitoring logic with ready event, baseline establishment flag, and execution error handling.
19+
- **WebSocket**: Update ws exceptions with extra params; simplify ws client logic and error creation pattern.
20+
- **API Consistency**: Rename `run_code` to `_run_code` and update related methods and docs across modules; update method calls for consistency across Python and TypeScript.
21+
- **MIME Handling**: Improve MIME type handling and add default stream target.
22+
- **Data Retrieval**: Improve data retrieval logic and add helper functions for type safety.
23+
- **Testing**: Update session creation params and image ID for testing consistency across languages.
24+
25+
### Bug Fixes
26+
27+
- **Dependencies**: `websockets` is now a required dependency (was missing from install_requires).
28+
- **Screenshot**: Fix `screen.beta_take_screenshot` integration test error; fix unit and integration test errors in code and screenshot modules.
29+
- **TypeScript**: Add `callMcpTool` to mock sessions for `SessionLike` interface compliance; fix API doc generation error; add ws dependency and improve logging in TypeScript modules.
30+
- **Tool List**: Handle empty tool list and improve content check logic.
31+
- **Timeout**: Add timeout parameters to future results in sync client; improve exception handling in TypeScript modules.
32+
- **FileSystem**: Correct parameter name for stop event in directory monitoring example.
33+
- **Scripts**: Remove wrong option in CI script.
34+
35+
### Documentation, Testing & Chore
36+
37+
- **Release Automation**: Add release SOP, automation scripts, unified CI release pipeline, and GitHub Actions auto-release workflow.
38+
- **Docs**: Add real-time streaming and websocket documentation; use "remote browser" wording and document stealth option in TypeScript API.
39+
- **Docs Fixes**: Fix documentation issues found during review (dead links, formatting).
40+
- **Testing**: Add websockets dependency for testing.
41+
- **API Docs**: Auto-generated API reference documentation updated.
42+
- **CI/CD**: Add pipeline for SDK sync to GitHub; unified release pipeline, changelog generation, version bump, and doc-check automation scripts.
43+
344
## [0.11.0] - 2026-03-16
445

546
### Breaking Changes

docs/api-reference/python/capabilities/code_execution.md

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ It supports multiple programming languages including Python, JavaScript, and mor
1616

1717

1818

19+
#### LANGUAGE\_ALIASES
20+
21+
```python
22+
LANGUAGE_ALIASES = {
23+
"py": "python",
24+
"python3": "python",
25+
"js": "javascript",
26+
"node" ...
27+
```
28+
29+
#### SUPPORTED\_LANGUAGES
30+
31+
```python
32+
SUPPORTED_LANGUAGES = {"python", "javascript", "java", "r"}
33+
```
34+
1935
## Code
2036

2137
```python
@@ -27,33 +43,45 @@ Handles code execution operations in the AGB cloud environment.
2743
### run
2844

2945
```python
30-
def run(code: str,
31-
language: str,
32-
timeout_s: int = 60) -> EnhancedCodeExecutionResult
46+
def run(
47+
code: str,
48+
language: str,
49+
timeout_s: int = 60,
50+
stream_beta: bool = False,
51+
on_stdout: Optional[Callable[[str], None]] = None,
52+
on_stderr: Optional[Callable[[str], None]] = None,
53+
on_error: Optional[Callable[[Any], None]] = None
54+
) -> EnhancedCodeExecutionResult
3355
```
3456

3557
Execute code in the specified language with a timeout.
3658

59+
This is the primary public method for code execution. For real-time
60+
streaming output, set stream_beta=True and provide callback functions.
61+
3762
**Arguments**:
3863

39-
- `code` _str_ - The code to execute.
40-
- `language` _str_ - The programming language of the code. Supported languages are:
41-
'python', 'javascript', 'java', 'r'.
42-
- `timeout_s` _int_ - The timeout for the code execution in seconds. Default is 60s.
64+
code: The code to execute.
65+
language: The programming language of the code. Case-insensitive.
66+
Supported values: 'python', 'javascript', 'r', 'java'.
67+
Aliases: 'py' -> 'python', 'js'/'node' -> 'javascript'.
68+
timeout_s: The timeout for the code execution in seconds. Default is 60s.
69+
stream_beta: If True, use WebSocket streaming for real-time stdout/stderr
70+
output. Requires the session to have a valid ws_url. Default is False.
71+
on_stdout: Callback invoked with each stdout chunk during streaming.
72+
Only used when stream_beta=True.
73+
on_stderr: Callback invoked with each stderr chunk during streaming.
74+
Only used when stream_beta=True.
75+
on_error: Callback invoked when an error occurs during streaming.
76+
Only used when stream_beta=True.
4377

4478

4579
**Returns**:
4680

47-
EnhancedCodeExecutionResult: Enhanced result object containing success status,
81+
EnhancedCodeExecutionResult: Result object containing success status,
4882
execution results with rich format support (HTML, images, charts, etc.),
4983
logs, and error information if any.
5084

51-
52-
**Raises**:
53-
54-
CommandError: If the code execution fails or if an unsupported language is
55-
specified.
56-
5785
## Best Practices
5886

5987
1. Validate code syntax before execution

docs/api-reference/python/capabilities/computer.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,42 @@ Gets the screen size and DPI scaling factor.
710710
- DPI scaling factor affects coordinate calculations on high-DPI displays
711711
- Use this to determine valid coordinate ranges for mouse operations
712712

713+
### beta\_take\_screenshot
714+
715+
```python
716+
def beta_take_screenshot(format: str = "png") -> ScreenshotResult
717+
```
718+
719+
Takes a screenshot of the Computer and returns raw binary image data.
720+
721+
This API uses the MCP tool `screenshot` (wuying_capture) and returns raw
722+
binary image data. The backend also returns the captured image dimensions
723+
(width/height in pixels), which are exposed on `ScreenshotResult.width`
724+
and `ScreenshotResult.height`. The backend metadata fields `type` and
725+
`mime_type` are exposed on `ScreenshotResult.type` and `ScreenshotResult.mime_type`.
726+
727+
**Arguments**:
728+
729+
format: The desired image format (default: "png"). Supported: "png", "jpeg", "jpg".
730+
731+
732+
**Returns**:
733+
734+
ScreenshotResult: Object containing the screenshot image data (bytes) and metadata
735+
including `type`, `mime_type`, `width`, and `height` when provided by the backend.
736+
737+
738+
**Raises**:
739+
740+
ScreenError: If screenshot fails or response cannot be decoded.
741+
ValueError: If `format` is invalid.
742+
743+
744+
**Notes**:
745+
746+
This method only works in environments with link_url (e.g., Browser Use images).
747+
For other environments, use `capture()` instead.
748+
713749
Computer module main class - container for all computer automation controllers.
714750

715751
## Computer

docs/api-reference/python/capabilities/file_system.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,12 @@ Watch a directory for file changes and call the callback function when changes o
496496
**Returns**:
497497

498498
threading.Thread: The monitoring thread. Call thread.start() to begin monitoring.
499-
Use the thread's stop_event attribute to stop monitoring.
499+
The thread has two event attributes:
500+
501+
- ``stop_event``set this to stop monitoring.
502+
- ``ready_event`` – wait on this after calling ``start()`` to
503+
ensure the filesystem baseline has been established before
504+
performing any file operations.
500505

501506
## Best Practices
502507

docs/api-reference/python/reference/exceptions.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ class ClearanceTimeoutError(AGBError)
7979

8080
Raised when the clearance task times out.
8181

82+
## ScreenError
83+
84+
```python
85+
class ScreenError(AGBError)
86+
```
87+
88+
Raised for errors related to screen operations.
89+
8290
---
8391

8492
*Documentation generated automatically from source code using pydoc-markdown.*

docs/api-reference/python/session.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ class Session()
2020

2121
Session represents a session in the AGB cloud environment.
2222

23+
### get\_link\_url
24+
25+
```python
26+
def get_link_url() -> str
27+
```
28+
29+
### get\_token
30+
31+
```python
32+
def get_token() -> str
33+
```
34+
2335
### set\_labels
2436

2537
```python
@@ -183,6 +195,10 @@ def call_mcp_tool(tool_name: str,
183195

184196
Call the specified MCP tool.
185197

198+
This method intelligently routes the call to either:
199+
1. LinkUrl route (direct HTTP) - when link_url, token, and server_name are available
200+
2. Traditional API route - fallback method
201+
186202
**Arguments**:
187203

188204
- `tool_name` _str_ - Tool name (e.g., "tap", "get_ui_elements").

0 commit comments

Comments
 (0)