lybic-guiagents 0.2.2__py3-none-any.whl → 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of lybic-guiagents might be problematic. Click here for more details.

gui_agents/__init__.py CHANGED
@@ -37,7 +37,7 @@ from .agents.hardware_interface import HardwareInterface
37
37
  from .store.registry import Registry
38
38
  from .agents.global_state import GlobalState
39
39
 
40
- __version__ = "0.2.2"
40
+ __version__ = "0.3.0"
41
41
 
42
42
  # Primary exports (what users should typically use)
43
43
  __all__ = [
@@ -27,7 +27,7 @@ from gui_agents.agents.Backend.Backend import Backend
27
27
 
28
28
  # 导入官方Lybic SDK
29
29
  try:
30
- from lybic import LybicClient, Sandbox, ComputerUse, dto
30
+ from lybic import LybicClient, Sandbox, ComputerUse, dto, LybicAuth
31
31
  except ImportError:
32
32
  raise ImportError(
33
33
  "Lybic Python SDK not found. Please install it with: pip install --upgrade lybic"
@@ -57,18 +57,22 @@ class LybicBackend(Backend):
57
57
  precreate_sid: str = '',
58
58
  **kwargs):
59
59
  """
60
- 初始化LybicBackend
61
-
62
- Args:
63
- api_key: Lybic API密钥,如果为None则从环境变量LYBIC_API_KEY获取
64
- org_id: Lybic组织ID,如果为None则从环境变量LYBIC_ORG_ID获取
65
- endpoint: API端点,如果为None则从环境变量LYBIC_API_ENDPOINT获取
66
- timeout: API请求超时时间
67
- extra_headers: 额外的HTTP
68
- sandbox_opts: 创建沙盒时的额外选项
69
- max_retries: 最大重试次数
70
- precreate_sid: 预创建的沙盒ID,如果提供则不会创建新沙盒
71
- """
60
+ Initialize the LybicBackend, create and configure the Lybic SDK client, and ensure a sandbox is available.
61
+
62
+ Parameters:
63
+ api_key (Optional[str]): Lybic API key; if None the value is read from the LYBIC_API_KEY environment variable.
64
+ org_id (Optional[str]): Lybic organization ID; if None the value is read from the LYBIC_ORG_ID environment variable.
65
+ endpoint (Optional[str]): API endpoint; if None the value is read from LYBIC_API_ENDPOINT (default "https://api.lybic.cn").
66
+ timeout (int): Request timeout in seconds for the SDK client.
67
+ extra_headers (Optional[Dict[str, str]]): Additional HTTP headers to pass to the SDK via LybicAuth.
68
+ sandbox_opts (Optional[Dict[str, Any]]): Options used when creating a new sandbox; LYBIC_MAX_LIFE_SECONDS is applied as the default for `maxLifeSeconds` if not provided.
69
+ max_retries (int): Maximum number of retry attempts for action execution.
70
+ precreate_sid (str): Pre-created sandbox ID to use; if empty, a new sandbox will be created.
71
+
72
+ Raises:
73
+ ValueError: If neither api_key nor org_id are provided (and not present in the corresponding environment variables).
74
+ RuntimeError: If sandbox creation completes but no sandbox ID can be obtained from the SDK response.
75
+ """
72
76
  self.loop = asyncio.new_event_loop()
73
77
  asyncio.set_event_loop(self.loop)
74
78
 
@@ -84,11 +88,13 @@ class LybicBackend(Backend):
84
88
  # 初始化SDK客户端(仅在有必要参数时)
85
89
  if self.api_key and self.org_id:
86
90
  self.client = LybicClient(
87
- org_id=self.org_id,
88
- api_key=self.api_key,
89
- endpoint=self.endpoint,
91
+ LybicAuth(
92
+ org_id=self.org_id,
93
+ api_key=self.api_key,
94
+ endpoint=self.endpoint,
95
+ extra_headers=self.extra_headers or {}
96
+ ),
90
97
  timeout=self.timeout,
91
- extra_headers=self.extra_headers or {}
92
98
  )
93
99
  else:
94
100
  raise ValueError("LYBIC_API_KEY and LYBIC_ORG_ID are required. Please set them as environment variables or pass them as arguments.")
@@ -185,7 +191,7 @@ class LybicBackend(Backend):
185
191
  type="mouse:click",
186
192
  x=dto.PixelLength(type="px", value=act.x),
187
193
  y=dto.PixelLength(type="px", value=act.y),
188
- button=1 if act.button == 0 else 2, # 0=左键, 1=右键 -> 1=左键, 2=右键
194
+ button=act.button,
189
195
  holdKey=" ".join(act.holdKey) if act.holdKey else ""
190
196
  )
191
197
 
@@ -203,7 +209,7 @@ class LybicBackend(Backend):
203
209
  type="mouse:doubleClick",
204
210
  x=dto.PixelLength(type="px", value=act.x),
205
211
  y=dto.PixelLength(type="px", value=act.y),
206
- button=1 if act.button == 0 else 2,
212
+ button=act.button,
207
213
  holdKey=" ".join(act.holdKey) if act.holdKey else ""
208
214
  )
209
215