Skip to content

Commit 5bfbbf1

Browse files
committed
chore: release version 0.9.0
### Breaking Changes - **API Naming Simplification**: Major API renaming for consistency and simplicity - session.code.run_code() → session.code.run() - session.command.execute_command() → session.command.execute() - session.file_system → session.file (backward compatibility alias maintained) - session.file.watch() → session.file.watch_dir() - session.file.get_file_transfer_context_path() → session.file.transfer_path() - File system methods simplified: read_file() → read(), write_file() → write(), delete_file() → remove(), list_directory() → list(), get_file_info() → info(), create_directory() → mkdir(), move_file() → move(), edit_file() → edit(), read_multiple_files() → read_batch(), search_files() → search() ### New Features - **Session Metrics**: Added session metrics tracking functionality to retrieve resource usage and performance metrics - **MCP Tool Calling**: Added MCP (Model Context Protocol) tool calling methods to Session class for direct tool invocation - **Multiple Results Support**: Enhanced code execution to support multiple result types with comprehensive documentation ### Enhancements - **Error Handling**: Improved error handling for file transfer operations with specific handling for network connection and timeout issues - **File Transfer**: Improved error handling in transfer_path() method with better context initialization checks - **Documentation**: Added comprehensive MCP tool calling documentation, updated API docs, added session metrics examples, fixed code execution result field usage, and updated MCP guide URLs to v2 ### Refactoring - **Session Class**: Removed unnecessary BaseService inheritance from Session class - **Test Infrastructure**: Optimized session creation in integration tests - **Code Cleanup**: Removed temporary API rename verification scripts ### Testing & CI/CD - **Test Coverage**: Reached 80% unit test coverage gate - **Integration Tests**: Enhanced integration test infrastructure, added CI skip logic, fixed false-pass tests, added session metrics retrieval test, and refactored filesystem integration tests - **Test Compatibility**: Made version_utils tests Python 3.10-compatible - **CI Improvements**: Improved CI skip logic for browser fingerprint tests ### Bug Fixes - Fixed output log source to match result object structure in main.py - Fixed Java result output log variable reference errors - Fixed JavaScript execution result output logic errors - Fixed default image_id value for list_mcp_tools (now uses agb-code-space-1) - Fixed conftest.py being run as a test file - Fixed write_file on deleted session test and integration test issues - Optimized docstring and fixed default value of list_mcp_tools
1 parent a0daba0 commit 5bfbbf1

110 files changed

Lines changed: 5477 additions & 1656 deletions

File tree

Some content is hidden

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

.coveragerc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[run]
2+
branch = False
3+
4+
# Exclude auto-generated / schema-like model files and heavyweight browser runtime code
5+
# from coverage calculation. These are exercised via integration tests and are not
6+
# practical to cover in unit tests.
7+
omit =
8+
agb/api/models/*
9+
agb/modules/browser/*
10+

.env.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# AGB SDK Environment Variables Example
2+
# 复制此文件为 .env 并填入实际的值
3+
4+
# Required: AGB API Key
5+
# 获取方式:访问 https://agb.ai/console/api-keys
6+
AGB_API_KEY=your_actual_api_key_here
7+
8+
# Optional: API Endpoint (默认使用生产环境)
9+
# AGB_API_ENDPOINT=https://api.agb.ai
10+
11+
# Optional: Timeout in milliseconds (默认 30000)
12+
# AGB_TIMEOUT_MS=30000

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,5 @@ dmypy.json
134134
CLAUDE.md
135135
.DS_Store
136136

137-
.history/
137+
.history/API命名优化-执行清单.md
138+
API命名优化-执行清单.md

CHANGES.md

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

3+
## [0.9.0] - 2026-01-23
4+
5+
### Breaking Changes
6+
- **API Naming Simplification**: Major API renaming for consistency and simplicity:
7+
- `session.code.run_code()``session.code.run()`
8+
- `session.command.execute_command()``session.command.execute()`
9+
- `session.file_system``session.file`
10+
- `session.file.watch()``session.file.watch_dir()`
11+
- `session.file.get_file_transfer_context_path()``session.file.transfer_path()`
12+
- File system methods simplified: `read_file()``read()`, `write_file()``write()`, `delete_file()``remove()`, `list_directory()``list()`, `get_file_info()``info()`, `create_directory()``mkdir()`, `move_file()``move()`, `edit_file()``edit()`, `read_multiple_files()``read_batch()`, `search_files()``search()`
13+
14+
### New Features
15+
- **Session Metrics**: Added session metrics tracking functionality to retrieve resource usage and performance metrics
16+
- **MCP Tool Calling**: Added MCP (Model Context Protocol) tool calling methods to Session class for direct tool invocation
17+
- **Multiple Results Support**: Enhanced code execution to support multiple result types with comprehensive documentation
18+
19+
### Enhancements
20+
- **Error Handling**: Improved error handling for file transfer operations:
21+
- Specific handling for `httpx.ConnectError` (network connection issues)
22+
- Specific handling for `httpx.TimeoutException` (timeout issues)
23+
- Clearer error messages for network-related failures
24+
- **File Transfer**: Improved error handling in `transfer_path()` method with better context initialization checks
25+
- **Documentation**:
26+
- Added comprehensive MCP tool calling documentation and examples
27+
- Updated API documentation to reflect new simplified method names
28+
- Added session metrics documentation and examples
29+
- Fixed code execution result field usage in documentation
30+
- Updated MCP guide URLs to v2
31+
32+
### Refactoring
33+
- **Session Class**: Removed unnecessary `BaseService` inheritance from Session class
34+
- **Test Infrastructure**: Optimized session creation in integration tests
35+
- **Code Cleanup**: Removed temporary API rename verification scripts
36+
37+
### Testing & CI/CD
38+
- **Test Coverage**: Reached 80% unit test coverage gate
39+
- **Integration Tests**:
40+
- Enhanced integration test infrastructure and reliability
41+
- Added CI skip logic for integration tests
42+
- Fixed false-pass tests and improved test stability
43+
- Added integration test for session metrics retrieval
44+
- Refactored filesystem integration tests
45+
- **Test Compatibility**: Made version_utils tests Python 3.10-compatible
46+
- **CI Improvements**: Improved CI skip logic for browser fingerprint tests
47+
48+
### Bug Fixes
49+
- Fixed output log source to match result object structure in main.py
50+
- Fixed Java result output log variable reference errors
51+
- Fixed JavaScript execution result output logic errors
52+
- Fixed default `image_id` value for `list_mcp_tools` (now uses `agb-code-space-1`)
53+
- Fixed `conftest.py` being run as a test file
54+
- Fixed write_file on deleted session test and integration test issues
55+
- Optimized docstring and fixed default value of `list_mcp_tools`
56+
357
## [0.8.0] - 2026-01-08
458

559
### New Features

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ if result.success:
3636
session = result.session
3737

3838
# Execute Python code
39-
code_result = session.code.run_code("print('Hello AGB!')", "python")
39+
code_result = session.code.run("print('Hello AGB!')", "python")
4040
print(code_result.result)
4141

4242
# Execute shell command
43-
cmd_result = session.command.execute_command("ls -la")
43+
cmd_result = session.command.execute("ls -la")
4444
print(cmd_result.output)
4545

4646
# Work with files
47-
session.file_system.write_file("/tmp/test.txt", "Hello World!")
48-
file_result = session.file_system.read_file("/tmp/test.txt")
47+
session.file.write("/tmp/test.txt", "Hello World!")
48+
file_result = session.file.read("/tmp/test.txt")
4949
print(file_result.content)
5050

5151
# Clean up

agb/api/base_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _call_mcp_tool(
5555
5656
Args:
5757
name (str): The name of the tool to call.
58-
args (Dict[str, Any]): The arguments to pass to the tool (can include auto_gen_session).
58+
args (Dict[str, Any]): The arguments to pass to the tool.
5959
read_timeout (Optional[int]): Read timeout in milliseconds.
6060
connect_timeout (Optional[int]): Connect timeout in milliseconds.
6161

agb/api/models/call_mcp_tool_request.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ def get_params(self) -> Dict[str, Any]:
5050
if self.image_id:
5151
params["imageId"] = self.image_id
5252

53-
# Set auto_gen_session to False (disabled by default)
54-
# This parameter controls whether to automatically generate a new session if not exists
55-
auto_gen_session = False
56-
# Add autoGenSession as query parameter
57-
params["autoGenSession"] = str(auto_gen_session).lower()
53+
# Force autoGenSession to false
54+
params["autoGenSession"] = "false"
5855

5956
return params

agb/logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ def log_api_response_with_details(
509509

510510
def log_code_execution_output(request_id: str, raw_output: str) -> None:
511511
"""
512-
Extract and log the actual code execution output from run_code response.
512+
Extract and log the actual code execution output from run response.
513513
514514
Args:
515515
request_id: Request ID from the API response

agb/model/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
EnhancedCodeExecutionResult,
1010
ExecutionResult,
1111
ExecutionLogs,
12-
BinaryFileContentResult
12+
BinaryFileContentResult,
13+
McpTool,
14+
McpToolResult,
15+
McpToolsResult,
1316
)
1417

1518
__all__ = [
@@ -23,5 +26,8 @@
2326
"EnhancedCodeExecutionResult",
2427
"ExecutionResult",
2528
"ExecutionLogs",
26-
"BinaryFileContentResult"
29+
"BinaryFileContentResult",
30+
"McpTool",
31+
"McpToolResult",
32+
"McpToolsResult",
2733
]

agb/model/response.py

Lines changed: 199 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
API response models for AGB SDK.
33
"""
44

5-
from typing import TYPE_CHECKING, Any, List, Optional
5+
from typing import TYPE_CHECKING, Any, Dict, List, Optional
66

77
if TYPE_CHECKING:
88
from agb.session import Session
@@ -532,3 +532,201 @@ def __init__(
532532
self.success = success
533533
self.status = status
534534
self.error_message = error_message
535+
536+
537+
class McpTool:
538+
"""MCP tool information model"""
539+
540+
def __init__(
541+
self,
542+
name: str = "",
543+
description: str = "",
544+
input_schema: Optional[Dict[str, Any]] = None,
545+
server: str = "",
546+
tool: str = "",
547+
):
548+
"""
549+
Initialize an McpTool.
550+
551+
Args:
552+
name: Tool name
553+
description: Tool description
554+
input_schema: Input parameters JSON Schema
555+
server: MCP server name
556+
tool: Tool type
557+
"""
558+
self.name = name
559+
self.description = description
560+
self.input_schema = input_schema or {}
561+
self.server = server
562+
self.tool = tool
563+
564+
565+
class McpToolResult(ApiResponse):
566+
"""MCP tool call result"""
567+
568+
def __init__(
569+
self,
570+
request_id: str = "",
571+
success: bool = False,
572+
data: Optional[str] = None,
573+
error_message: str = "",
574+
):
575+
"""
576+
Initialize an McpToolResult.
577+
578+
Args:
579+
request_id: Request ID
580+
success: Whether the operation was successful
581+
data: Tool return data in JSON string format
582+
error_message: Error message
583+
"""
584+
super().__init__(request_id)
585+
self.success = success
586+
self.data = data
587+
self.error_message = error_message
588+
589+
590+
class McpToolsResult(ApiResponse):
591+
"""MCP tools list query result"""
592+
593+
def __init__(
594+
self,
595+
request_id: str = "",
596+
success: bool = False,
597+
tools: Optional[List["McpTool"]] = None,
598+
error_message: str = "",
599+
):
600+
"""
601+
Initialize an McpToolsResult.
602+
603+
Args:
604+
request_id: Request ID
605+
success: Whether the operation was successful
606+
tools: List of tools
607+
error_message: Error message
608+
"""
609+
super().__init__(request_id)
610+
self.success = success
611+
self.tools = tools or []
612+
self.error_message = error_message
613+
614+
class SessionMetrics:
615+
"""Structured metrics for session monitoring."""
616+
617+
def __init__(
618+
self,
619+
cpu_count: int = 0,
620+
cpu_used_pct: float = 0.0,
621+
disk_total: int = 0,
622+
disk_used: int = 0,
623+
mem_total: int = 0,
624+
mem_used: int = 0,
625+
rx_rate_kbyte_per_s: float = 0.0,
626+
tx_rate_kbyte_per_s: float = 0.0,
627+
rx_used_kbyte: float = 0.0,
628+
tx_used_kbyte: float = 0.0,
629+
timestamp: str = "",
630+
# Backward-compatible aliases (deprecated):
631+
rx_rate_kbps: Optional[float] = None,
632+
tx_rate_kbps: Optional[float] = None,
633+
rx_used_kb: Optional[float] = None,
634+
tx_used_kb: Optional[float] = None,
635+
):
636+
"""
637+
Initialize SessionMetrics.
638+
639+
Args:
640+
cpu_count (int): CPU core count. Defaults to 0.
641+
cpu_used_pct (float): CPU usage percentage. Defaults to 0.0.
642+
disk_total (int): Total disk capacity. Defaults to 0.
643+
disk_used (int): Used disk capacity. Defaults to 0.
644+
mem_total (int): Total memory. Defaults to 0.
645+
mem_used (int): Used memory. Defaults to 0.
646+
rx_rate_kbyte_per_s (float): Receive rate in KB/s. Defaults to 0.0.
647+
tx_rate_kbyte_per_s (float): Transmit rate in KB/s. Defaults to 0.0.
648+
rx_used_kbyte (float): Total received data in KB. Defaults to 0.0.
649+
tx_used_kbyte (float): Total transmitted data in KB. Defaults to 0.0.
650+
timestamp (str): Timestamp of the metrics. Defaults to "".
651+
rx_rate_kbps (Optional[float]): Deprecated alias for rx_rate_kbyte_per_s.
652+
tx_rate_kbps (Optional[float]): Deprecated alias for tx_rate_kbyte_per_s.
653+
rx_used_kb (Optional[float]): Deprecated alias for rx_used_kbyte.
654+
tx_used_kb (Optional[float]): Deprecated alias for tx_used_kbyte.
655+
"""
656+
self.cpu_count = cpu_count
657+
self.cpu_used_pct = cpu_used_pct
658+
self.disk_total = disk_total
659+
self.disk_used = disk_used
660+
self.mem_total = mem_total
661+
self.mem_used = mem_used
662+
self.rx_rate_kbyte_per_s = (
663+
rx_rate_kbyte_per_s if rx_rate_kbyte_per_s is not None else 0.0
664+
)
665+
self.tx_rate_kbyte_per_s = (
666+
tx_rate_kbyte_per_s if tx_rate_kbyte_per_s is not None else 0.0
667+
)
668+
self.rx_used_kbyte = rx_used_kbyte if rx_used_kbyte is not None else 0.0
669+
self.tx_used_kbyte = tx_used_kbyte if tx_used_kbyte is not None else 0.0
670+
671+
# Backward-compatible aliases (deprecated): allow old args to fill new fields
672+
if rx_rate_kbps is not None and self.rx_rate_kbyte_per_s == 0.0:
673+
self.rx_rate_kbyte_per_s = float(rx_rate_kbps)
674+
if tx_rate_kbps is not None and self.tx_rate_kbyte_per_s == 0.0:
675+
self.tx_rate_kbyte_per_s = float(tx_rate_kbps)
676+
if rx_used_kb is not None and self.rx_used_kbyte == 0.0:
677+
self.rx_used_kbyte = float(rx_used_kb)
678+
if tx_used_kb is not None and self.tx_used_kbyte == 0.0:
679+
self.tx_used_kbyte = float(tx_used_kb)
680+
self.timestamp = timestamp
681+
682+
# Backward-compatible properties (deprecated)
683+
@property
684+
def rx_rate_kbps(self) -> float:
685+
"""Deprecated: Use rx_rate_kbyte_per_s instead."""
686+
return float(self.rx_rate_kbyte_per_s)
687+
688+
@property
689+
def tx_rate_kbps(self) -> float:
690+
"""Deprecated: Use tx_rate_kbyte_per_s instead."""
691+
return float(self.tx_rate_kbyte_per_s)
692+
693+
@property
694+
def rx_used_kb(self) -> float:
695+
"""Deprecated: Use rx_used_kbyte instead."""
696+
return float(self.rx_used_kbyte)
697+
698+
@property
699+
def tx_used_kb(self) -> float:
700+
"""Deprecated: Use tx_used_kbyte instead."""
701+
return float(self.tx_used_kbyte)
702+
703+
class SessionMetricsResult(ApiResponse):
704+
"""Result of session get_metrics() operation."""
705+
706+
def __init__(
707+
self,
708+
request_id: str = "",
709+
success: bool = False,
710+
metrics: Optional[SessionMetrics] = None,
711+
error_message: str = "",
712+
raw: Optional[dict] = None,
713+
):
714+
"""
715+
Initialize a SessionMetricsResult.
716+
717+
Args:
718+
request_id (str, optional): Unique identifier for the API request.
719+
Defaults to "".
720+
success (bool, optional): Whether the operation was successful.
721+
Defaults to False.
722+
metrics (Optional[SessionMetrics], optional): Session metrics data.
723+
Defaults to None.
724+
error_message (str, optional): Error message if the operation failed.
725+
Defaults to "".
726+
raw (Optional[dict], optional): Raw response data. Defaults to None.
727+
"""
728+
super().__init__(request_id)
729+
self.success = success
730+
self.metrics = metrics
731+
self.error_message = error_message
732+
self.raw = raw or {}

0 commit comments

Comments
 (0)