computer-use-ootb-internal 0.0.96.post1__py3-none-any.whl → 0.0.96.post2__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.
@@ -1,214 +1,81 @@
1
- """
2
- show_click(x, y, duration_ms=800)
3
- → 在屏幕 (x,y) 显示点击动画,停留 duration_ms 毫秒
4
- 依赖: pyside6
5
- 确保同目录有 click.gif
6
- """
7
- import sys, time
1
+ # click_anim_async.py ← put this in its own file (important for Windows "spawn")
2
+ import sys, multiprocessing as mp
8
3
  from pathlib import Path
9
- from PySide6.QtCore import Qt, QPoint, QTimer, QEventLoop, QSize, QEasingCurve, QPropertyAnimation
10
- from PySide6.QtGui import QPainter, QPixmap, QMovie
4
+ from PySide6.QtCore import Qt, QPoint, QTimer, QEasingCurve, QPropertyAnimation, QSize
5
+ from PySide6.QtGui import QMovie
11
6
  from PySide6.QtWidgets import QApplication, QWidget, QLabel
12
7
 
13
8
  CLICK_GIF = Path(__file__).with_name("icons8-select-cursor-transparent-96.gif")
14
9
 
10
+ # ---------------------------- tiny in‑process GUI helpers ----------------------------
15
11
  class ClickAnimation(QWidget):
16
- def __init__(self, pos: QPoint, life_ms: int):
12
+ def __init__(self, pos: QPoint, life_ms: int, size_px: int = 50):
17
13
  super().__init__(None,
18
14
  Qt.FramelessWindowHint | Qt.Tool | Qt.WindowStaysOnTopHint
19
15
  | Qt.WindowTransparentForInput)
20
16
  self.setAttribute(Qt.WA_TranslucentBackground)
21
-
22
- if not CLICK_GIF.exists():
23
- print(f"Error: click.gif not found at {CLICK_GIF}")
24
- return
25
-
26
- try:
27
- # 创建标签显示GIF
28
- self.label = QLabel(self)
29
- self.movie = QMovie(str(CLICK_GIF))
30
-
31
- # 获取原始尺寸并打印(仅供参考)
32
- self.movie.jumpToFrame(0)
33
- original_size = self.movie.currentPixmap().size()
34
- print(f"GIF original size: {original_size.width()}x{original_size.height()}")
35
-
36
- # 将GIF缩放到30x30像素
37
- target_size = QSize(50, 50)
38
- self.movie.setScaledSize(target_size)
39
-
40
- # 设置标签尺寸和GIF
41
- self.label.setMovie(self.movie)
42
- self.label.setFixedSize(target_size)
43
-
44
- # 设置窗口大小和位置
45
- self.resize(target_size)
46
- self.move(pos.x() - 15, pos.y() - 15) # 居中显示
47
-
48
- # 提高播放性能
49
- self.movie.setCacheMode(QMovie.CacheAll)
50
-
51
- # 开始播放动画
52
- self.movie.start()
53
-
54
- # 设置定时器关闭窗口
55
- QTimer.singleShot(life_ms, self.close)
56
-
57
- self.show()
58
- self.raise_()
59
- print(f"Click animation created at ({pos.x()}, {pos.y()}), size: 30x30, duration: {life_ms}ms")
60
- except Exception as e:
61
- print(f"Error creating click animation: {str(e)}")
62
17
 
63
- # ---------- 外部接口 ----------
64
- _app = None
65
- def _ensure_app():
66
- global _app
67
- if _app is None:
68
- if QApplication.instance() is None:
69
- print("Creating new QApplication instance")
70
- _app = QApplication(sys.argv)
71
- else:
72
- print("Using existing QApplication instance")
73
- _app = QApplication.instance()
18
+ self.label = QLabel(self)
19
+ movie = QMovie(str(CLICK_GIF))
20
+ movie.setScaledSize(QSize(size_px, size_px))
21
+ self.label.setMovie(movie)
22
+ self.label.setFixedSize(size_px, size_px)
74
23
 
75
- # Keep references to animations to prevent garbage collection
76
- _active_animations = []
77
-
78
- def show_click(x: int, y: int, duration_ms: int = 2000, existing_ms: int = 1000): # 增加默认播放时间和静止时间
79
- """非阻塞式点击动画:立即返回,动画在后台运行
80
-
81
- Args:
82
- x, y : 屏幕坐标
83
- duration_ms : 动画播放时长
84
- existing_ms : 动画结束后静止显示的时间
85
- """
86
- print(f"Attempting to show click at ({x}, {y})")
87
-
88
- if not CLICK_GIF.exists():
89
- raise FileNotFoundError(f"click.gif not found at {CLICK_GIF}")
90
-
91
- _ensure_app()
92
-
93
- try:
94
- # 总生存时间 = 动画时间 + 静止显示时间
95
- total_life_ms = duration_ms + existing_ms
96
- animation = ClickAnimation(QPoint(x, y), total_life_ms)
97
-
98
- # Store reference to prevent garbage collection
99
- global _active_animations
100
- _active_animations.append(animation)
101
-
102
- # Set up cleanup after animation completes + existing time
103
- QTimer.singleShot(total_life_ms + 150, lambda: _clean_animation(animation))
104
-
105
- print(f"Click animation started (non-blocking, will exist for {total_life_ms}ms)")
106
- except Exception as e:
107
- print(f"Error during show_click: {str(e)}")
24
+ self.resize(size_px, size_px)
25
+ self.move(pos.x() - size_px//2, pos.y() - size_px//2)
108
26
 
27
+ movie.setCacheMode(QMovie.CacheAll)
28
+ movie.start()
29
+ QTimer.singleShot(life_ms, self.close)
30
+ self.show()
31
+ self.raise_()
109
32
 
110
- def _clean_animation(animation):
111
- """Remove animation from reference list after it completes"""
112
- global _active_animations
113
- if animation in _active_animations:
114
- _active_animations.remove(animation)
115
- print("Animation cleaned up")
33
+ # ------------------------- worker functions that live in a **child** -----------------
34
+ def _worker_click(x, y, duration_ms, existing_ms):
35
+ app = QApplication(sys.argv)
36
+ total = duration_ms + existing_ms
37
+ widget = ClickAnimation(QPoint(x, y), total) # Store in variable to prevent garbage collection
38
+ QTimer.singleShot(total + 200, app.quit) # close event‑loop afterwards
39
+ app.exec()
116
40
 
41
+ def _worker_move(x1, y1, x2, y2, duration_ms, existing_ms):
42
+ app = QApplication(sys.argv)
43
+ total = duration_ms + existing_ms
44
+ widget = ClickAnimation(QPoint(x1, y1), total)
117
45
 
118
- # ---------- 新增函数 ----------
119
- def show_move_to(x1: int, y1: int, x2: int, y2: int, duration_ms: int = 1000, existing_ms: int = 1000):
120
- """
121
- 非阻塞式移动动画:在 (x1, y1) 处出现光标 GIF,
122
- 并在 duration_ms 毫秒内平滑移动到 (x2, y2)
123
- 然后在终点静止显示 existing_ms 毫秒。
124
- 立即返回,动画在后台运行。
46
+ anim = QPropertyAnimation(widget, b"pos")
47
+ anim.setDuration(duration_ms)
48
+ anim.setStartValue(widget.pos())
49
+ anim.setEndValue(QPoint(x2 - widget.width()//2, y2 - widget.height()//2))
50
+ anim.setEasingCurve(QEasingCurve.OutQuad)
51
+ anim.start()
125
52
 
126
- Args:
127
- x1, y1 : 起点屏幕坐标
128
- x2, y2 : 终点屏幕坐标
129
- duration_ms : 移动总时长
130
- existing_ms : 移动结束后在终点静止显示的时间
131
- """
132
- print(f"Attempting to move click from ({x1}, {y1}) → ({x2}, {y2}) "
133
- f"in {duration_ms} ms, then stay for {existing_ms} ms")
53
+ QTimer.singleShot(total + 200, app.quit)
54
+ app.exec()
134
55
 
56
+ # ------------------------------- public API (non‑blocking) ---------------------------
57
+ def show_click(x: int, y: int, duration_ms: int = 800, existing_ms: int = 800):
135
58
  if not CLICK_GIF.exists():
136
- raise FileNotFoundError(f"click.gif not found at {CLICK_GIF}")
59
+ raise FileNotFoundError(f"GIF not found at {CLICK_GIF}")
60
+ mp.get_context("spawn").Process(
61
+ target=_worker_click,
62
+ args=(x, y, duration_ms, existing_ms),
63
+ daemon=False # keep running even if parent exits
64
+ ).start()
137
65
 
138
- _ensure_app()
66
+ def show_move_to(x1: int, y1: int, x2: int, y2: int,
67
+ duration_ms: int = 1000, existing_ms: int = 800):
68
+ if not CLICK_GIF.exists():
69
+ raise FileNotFoundError(f"GIF not found at {CLICK_GIF}")
70
+ mp.get_context("spawn").Process(
71
+ target=_worker_move,
72
+ args=(x1, y1, x2, y2, duration_ms, existing_ms),
73
+ daemon=False
74
+ ).start()
139
75
 
140
- # 总生存时间 = 动画时间 + 静止显示时间
141
- total_life_ms = duration_ms + existing_ms
142
- widget = ClickAnimation(QPoint(x1, y1), total_life_ms)
143
-
144
- # 用 QPropertyAnimation 平滑移动窗口
145
- anim = QPropertyAnimation(widget, b"pos")
146
- anim.setDuration(duration_ms)
147
- # ClickAnimation 内部已经向左上偏移了 15px,这里沿用同样的偏移
148
- anim.setStartValue(QPoint(x1 - 15, y1 - 15))
149
- anim.setEndValue(QPoint(x2 - 15, y2 - 15))
150
- anim.setEasingCurve(QEasingCurve.OutQuad) # 可自行更换缓动曲线
151
-
152
- # Store references to both widget and animation to prevent garbage collection
153
- global _active_animations
154
- # Store them as a tuple to keep both references
155
- animation_pair = (widget, anim)
156
- _active_animations.append(animation_pair)
157
-
158
- # Clean up both widget and animation after completion of total life time
159
- def cleanup():
160
- if animation_pair in _active_animations:
161
- _active_animations.remove(animation_pair)
162
- print("Move animation cleaned up")
163
-
164
- # Connect finished signal only to print a message
165
- anim.finished.connect(lambda: print("Movement finished, now staying still"))
166
-
167
- # Start the animation
168
- anim.start()
169
-
170
- # Process events immediately to kickstart the animation
171
- QApplication.processEvents()
172
-
173
- # Set up final cleanup after animation + existing time
174
- QTimer.singleShot(total_life_ms, cleanup)
175
-
176
- print("Move-to animation started (non-blocking)")
177
76
 
178
77
 
179
- # ---------- 命令行测试 ----------
180
78
  if __name__ == "__main__":
181
- # 确保应用程序实例存在
182
- # _ensure_app()
183
-
184
- # 测试点击
185
- print("Testing non-blocking click animation...")
186
- x, y = 500, 500
187
- show_click(x, y)
188
-
189
- # 测试同时运行两个动画
190
- print("\nTesting simultaneous animations...")
191
- x1, y1 = 200, 200
192
- x2, y2 = 600, 600
193
- # show_click(x1, y1)
194
- show_move_to(x1, y1, x2, y2)
195
-
196
- # # 测试先移动,然后点击
197
- print("\nTesting sequence with pyautogui simulation...")
198
- x3, y3 = 800, 300
199
- x4, y4 = 400, 500
200
-
201
- # 启动移动动画
202
- show_move_to(x3, y3, x4, y4)
203
-
204
- # 模拟移动完成后的点击动画(延迟1.5秒)
205
- QTimer.singleShot(1500, lambda: show_click(x4, y4))
206
-
207
- # 保持主程序运行,等待所有动画完成
208
- print("\nWaiting for all animations to complete...")
209
- loop = QEventLoop()
210
- # 等待足够长的时间,确保所有动画都完成(最长的动画是2000ms + 清理时间)
211
- QTimer.singleShot(4000, loop.quit)
212
- loop.exec()
213
-
214
- print("All animations completed, exiting test.")
79
+ # from click_anim_async import show_click
80
+ show_click(500, 500)
81
+ show_move_to(300, 300, 600, 600)
@@ -0,0 +1,40 @@
1
+ """
2
+ Test script to verify cursor animation is working
3
+ """
4
+ import asyncio
5
+ import sys
6
+ import time
7
+ from pathlib import Path
8
+ from computer_use_ootb_internal.computer_use_demo.tools.computer import ComputerTool
9
+
10
+ async def test_animations():
11
+
12
+ # Initialize the computer tool
13
+ computer = ComputerTool()
14
+
15
+ # Test mouse move animation
16
+ print("Testing mouse move animation...")
17
+ await computer(action="mouse_move_windll", coordinate=(500, 500))
18
+ print("Waiting 2 seconds...")
19
+ await asyncio.sleep(2)
20
+
21
+ # Test click animation
22
+ print("Testing click animation...")
23
+ await computer(action="left_click_windll", coordinate=(700, 300))
24
+ print("Waiting 2 seconds...")
25
+ await asyncio.sleep(2)
26
+
27
+ # Test another move
28
+ print("Testing move and click sequence...")
29
+ await computer(action="mouse_move_windll", coordinate=(300, 300))
30
+ await asyncio.sleep(1)
31
+ await computer(action="left_click_windll", coordinate=(300, 300))
32
+
33
+ # Wait for animations to complete
34
+ print("Waiting for animations to complete...")
35
+ await asyncio.sleep(3)
36
+
37
+ print("Test completed")
38
+
39
+ if __name__ == "__main__":
40
+ asyncio.run(test_animations())
@@ -249,9 +249,6 @@ class TeachmodeExecutor:
249
249
  else:
250
250
  parsed_action_list.append(action)
251
251
 
252
- # parsed_action_list.extend([{"action": "key_down_windll", "text": "alt", "coordinate": None}])
253
- # parsed_action_list.extend(action_list)
254
- # parsed_action_list.extend([{"action": "key_up_windll", "text": "alt", "coordinate": None}])
255
252
  return parsed_action_list
256
253
 
257
254
 
@@ -317,7 +317,6 @@ class ComputerTool(BaseAnthropicTool):
317
317
  pyautogui.mouseDown()
318
318
  time.sleep(1)
319
319
  pyautogui.mouseUp()
320
- show_click(x, y)
321
320
  elif action == "scroll_down":
322
321
  pyautogui.scroll(-200) # Adjust scroll amount as needed
323
322
  return ToolResult(output="Scrolled down")
@@ -41,7 +41,7 @@ def simple_teachmode_sampling_loop(
41
41
  if "star_rail" in user_id or "star_rail" in user_id:
42
42
  full_screen_game_mode = 1
43
43
 
44
- if "star_rail_dev" in trace_id or "star_rail_dev" in user_id or "hero_case" in trace_id:
44
+ if "star_rail_dev" in trace_id or "star_rail_dev" in user_id or "hero_case" in user_id:
45
45
  full_screen_game_mode = 2
46
46
 
47
47
  print(f"Full Screen Game Mode: {full_screen_game_mode}")
@@ -102,7 +102,7 @@ def simple_teachmode_sampling_loop(
102
102
 
103
103
  try:
104
104
  step_plan = infer_server_response["generated_plan"]
105
- step_info = infer_server_response["generated_action"]["step_info"]
105
+ step_info = infer_server_response["generated_plan"]["step_info"]
106
106
  step_action = infer_server_response["generated_action"]["content"]
107
107
  step_traj_idx = infer_server_response["current_traj_step"]
108
108
 
@@ -125,8 +125,6 @@ def simple_teachmode_sampling_loop(
125
125
 
126
126
 
127
127
 
128
-
129
-
130
128
  if __name__ == "__main__":
131
129
  parser = argparse.ArgumentParser(
132
130
  description="Run a synchronous sampling loop for assistant/tool interactions in teach-mode."
@@ -138,8 +136,6 @@ if __name__ == "__main__":
138
136
  )
139
137
  parser.add_argument(
140
138
  "--task",
141
- # default="Help me to complete the extraction of the viewer data of Downald Trump's first video on youtube,\
142
- # fill in the excel sheet.",
143
139
  default="Click on the Google Chorme icon",
144
140
  help="The task to be completed by the assistant (e.g., 'Complete some data extraction.').",
145
141
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: computer-use-ootb-internal
3
- Version: 0.0.96.post1
3
+ Version: 0.0.96.post2
4
4
  Summary: Computer Use OOTB
5
5
  Author-email: Siyuan Hu <siyuan.hu.sg@gmail.com>
6
6
  Requires-Python: >=3.11
@@ -3,10 +3,11 @@ computer_use_ootb_internal/app_teachmode.py,sha256=zmUPvFjqdhysnN1bD2QQhaAKONnAt
3
3
  computer_use_ootb_internal/app_teachmode_gradio.py,sha256=zAw-n3s20j1Jr0S4TzXHwllKV6APJ8HEHB1KqBuzriY,7907
4
4
  computer_use_ootb_internal/dependency_check.py,sha256=y8RMEP6RXQzTgU1MS_1piBLtz4J-Hfn9RjUZg59dyvo,1333
5
5
  computer_use_ootb_internal/requirements-lite.txt,sha256=5DAHomz4A_P2BmTIXNkNqkHbnIF0AyZ4_1XAlb1LaYs,290
6
- computer_use_ootb_internal/run_teachmode_ootb_args.py,sha256=djr4E7_G_qG9H6qmRz1mrM9Yrcxf1tnlSPH5ZqykF5Y,6845
7
- computer_use_ootb_internal/computer_use_demo/animation/click_animation.py,sha256=BsHW1yFLHE5DqLUofnR-D3jnglLcYCaVN34jquWvh94,7725
6
+ computer_use_ootb_internal/run_teachmode_ootb_args.py,sha256=UEiwLSdERzBqbCH2Em20b4UNzAb__S8cJSnkceVcBsY,6686
7
+ computer_use_ootb_internal/computer_use_demo/animation/click_animation.py,sha256=QR_DEDk7bVON5EQ_xsJGrxNa3NoxqubYyXPFRB12pmQ,3183
8
8
  computer_use_ootb_internal/computer_use_demo/animation/icons8-select-cursor-transparent-96.gif,sha256=4LfwsfFQnREXrNRs32aJU2jO65JXianJoL_8q7-8elg,30966
9
- computer_use_ootb_internal/computer_use_demo/executor/teachmode_executor.py,sha256=y7lg_PjMif2WwCKWWC7g8Ys2zPRMh08Vtt42fStujY4,16623
9
+ computer_use_ootb_internal/computer_use_demo/animation/test_animation.py,sha256=SOJz2yffXTkjuAHqk0IZLcMriR0KQYTo7W1b8wGyRGY,1222
10
+ computer_use_ootb_internal/computer_use_demo/executor/teachmode_executor.py,sha256=Rr_I0Uk8hsqTmq3Fr3KOtjkXTqSb4pkNxmutENbv8dc,16368
10
11
  computer_use_ootb_internal/computer_use_demo/gui_agent/gui_parser/simple_parser/__init__.py,sha256=h2CNeuACklxVpJC65QR8_6AvSybEZLmeO45hY_-lLBs,61
11
12
  computer_use_ootb_internal/computer_use_demo/gui_agent/gui_parser/simple_parser/gui_capture.py,sha256=CxFJbsSb68ERKH7-C4RaaZy7FIhhzrzGx5qQJ4C37cA,13907
12
13
  computer_use_ootb_internal/computer_use_demo/gui_agent/gui_parser/simple_parser/gui_parser.py,sha256=KSTJ0cMwh3ahUMzHRaDgA2sVNUL4MNlF7qEBGN3G0SI,28993
@@ -30,12 +31,12 @@ computer_use_ootb_internal/computer_use_demo/tools/base.py,sha256=QDqpuuKlhUKJT2
30
31
  computer_use_ootb_internal/computer_use_demo/tools/bash.py,sha256=rHetQ80_v-TTi-1oxIA7ncFEwJxFTh8FJCErIoZbGeY,4236
31
32
  computer_use_ootb_internal/computer_use_demo/tools/collection.py,sha256=8RzHLobL44_Jjt8ltXS6I8XJlEAQOfc75dmnDUaHE-8,922
32
33
  computer_use_ootb_internal/computer_use_demo/tools/colorful_text.py,sha256=cvlmnhAImDTwoRRwhT5au7mNFhfAD7ZfeoDEVdVzDKw,892
33
- computer_use_ootb_internal/computer_use_demo/tools/computer.py,sha256=bKOkCtE4iYmPpRxldslAAa5yQOs6NkhITJYCfZllWXI,25526
34
+ computer_use_ootb_internal/computer_use_demo/tools/computer.py,sha256=kpcp3orAdSwzBJMvL8zt_OgF6kT9UdZaJuqkjja7bic,25493
34
35
  computer_use_ootb_internal/computer_use_demo/tools/computer_marbot.py,sha256=zZuWz9ArfP3Zss-afnscrPkgCtB5UWbCy7HwAOvO2bo,5970
35
36
  computer_use_ootb_internal/computer_use_demo/tools/edit.py,sha256=b0PwUitxckHCQqFP3ZwlthWdqNkn7WETeTHeB6-o98c,11486
36
37
  computer_use_ootb_internal/computer_use_demo/tools/run.py,sha256=xhXdnBK1di9muaO44CEirL9hpGy3NmKbjfMpyeVmn8Y,1595
37
38
  computer_use_ootb_internal/computer_use_demo/tools/screen_capture.py,sha256=L8qfvtUkPPQGt92N-2Zfw5ZTDBzLsDps39uMnX3_uSA,6857
38
- computer_use_ootb_internal-0.0.96.post1.dist-info/METADATA,sha256=45BKygjaYFw3snR8rr1qk9pH9cVJYmjZP9T5O5PSjAo,915
39
- computer_use_ootb_internal-0.0.96.post1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
40
- computer_use_ootb_internal-0.0.96.post1.dist-info/entry_points.txt,sha256=-AbmawU7IRQuDZihgVMVDrFoY4E6rnXYOUB-5vSeBKs,93
41
- computer_use_ootb_internal-0.0.96.post1.dist-info/RECORD,,
39
+ computer_use_ootb_internal-0.0.96.post2.dist-info/METADATA,sha256=Q_cRfIeXWR-MO_d4c-GLxnC2wQZw68BPsvgrBYcaX7c,915
40
+ computer_use_ootb_internal-0.0.96.post2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
41
+ computer_use_ootb_internal-0.0.96.post2.dist-info/entry_points.txt,sha256=-AbmawU7IRQuDZihgVMVDrFoY4E6rnXYOUB-5vSeBKs,93
42
+ computer_use_ootb_internal-0.0.96.post2.dist-info/RECORD,,