computer-use-ootb-internal 0.0.111__tar.gz → 0.0.112__tar.gz

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.
Files changed (40) hide show
  1. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/PKG-INFO +1 -1
  2. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/pyproject.toml +1 -1
  3. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/app_teachmode.py +44 -62
  4. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/guard_service.py +1 -1
  5. computer_use_ootb_internal-0.0.112/src/computer_use_ootb_internal/preparation/__init__.py +1 -0
  6. computer_use_ootb_internal-0.0.112/src/computer_use_ootb_internal/preparation/star_rail_prepare.py +65 -0
  7. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/.gitignore +0 -0
  8. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/deploy.sh +0 -0
  9. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/README.md +0 -0
  10. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/__init__.py +0 -0
  11. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/app_teachmode_gradio.py +0 -0
  12. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/animation/click_animation.py +0 -0
  13. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/animation/icons8-select-cursor-transparent-96.gif +0 -0
  14. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/animation/test_animation.py +0 -0
  15. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/executor/teachmode_executor.py +0 -0
  16. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/gui_parser/simple_parser/__init__.py +0 -0
  17. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/gui_parser/simple_parser/gui_capture.py +0 -0
  18. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/gui_parser/simple_parser/utils.py +0 -0
  19. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/gui_parser/uia_tools/__init__.py +0 -0
  20. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/gui_parser/uia_tools/screenshot_cli.py +0 -0
  21. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/gui_parser/uia_tools/screenshot_service.py +0 -0
  22. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/llm_utils/llm_utils.py +0 -0
  23. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/llm_utils/oai.py +0 -0
  24. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/llm_utils/run_litellm.py +0 -0
  25. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/llm_utils/run_llm.py +0 -0
  26. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/tools/__init__.py +0 -0
  27. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/tools/aws_request.py +0 -0
  28. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/tools/base.py +0 -0
  29. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/tools/bash.py +0 -0
  30. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/tools/collection.py +0 -0
  31. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/tools/colorful_text.py +0 -0
  32. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/tools/computer.py +0 -0
  33. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/tools/computer_marbot.py +0 -0
  34. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/tools/edit.py +0 -0
  35. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/tools/run.py +0 -0
  36. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/computer_use_demo/tools/screen_capture.py +0 -0
  37. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/dependency_check.py +0 -0
  38. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/requirements-lite.txt +0 -0
  39. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/run_teachmode_ootb_args.py +0 -0
  40. {computer_use_ootb_internal-0.0.111 → computer_use_ootb_internal-0.0.112}/src/computer_use_ootb_internal/service_manager.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: computer-use-ootb-internal
3
- Version: 0.0.111
3
+ Version: 0.0.112
4
4
  Summary: Computer Use OOTB
5
5
  Author-email: Siyuan Hu <siyuan.hu.sg@gmail.com>
6
6
  Requires-Python: >=3.11
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "computer-use-ootb-internal"
7
- version = "0.0.111"
7
+ version = "0.0.112"
8
8
  description = "Computer Use OOTB"
9
9
  authors = [{ name = "Siyuan Hu", email = "siyuan.hu.sg@gmail.com" }]
10
10
  requires-python = ">=3.11"
@@ -8,6 +8,9 @@ import platform # Add platform import
8
8
  import pyautogui # Add pyautogui import
9
9
  import webbrowser # Add webbrowser import
10
10
  import os # Import os for path joining
11
+ import logging # Import logging
12
+ import importlib # For dynamic imports
13
+ import pkgutil # To find modules
11
14
  from fastapi import FastAPI, Request
12
15
  from fastapi.responses import JSONResponse
13
16
  from fastapi.middleware.cors import CORSMiddleware
@@ -90,68 +93,47 @@ class SharedState:
90
93
  shared_state = None
91
94
  rate_limiter = RateLimiter(interval_seconds=2)
92
95
 
93
- # Add the new prepare_environment function here
96
+ # Set up logging for this module
97
+ log = logging.getLogger(__name__)
98
+
94
99
  def prepare_environment(state):
95
- """Prepares the environment before starting the main processing loop, e.g., opening specific apps."""
96
- if platform.system() == "Windows":
97
- # Assuming Star Rail mode is indicated by user_id containing "star_rail"
98
- # You might need to adjust this condition based on the actual logic in run_teachmode_args
99
- is_star_rail = "star_rail" in state.user_id.lower() or \
100
- "star_rail" in state.trace_id.lower() or \
101
- "hero_case" in state.user_id.lower() or \
102
- "hero_case" in state.trace_id.lower()
103
-
104
- if is_star_rail:
105
- print("Star Rail mode detected on Windows. Opening Edge browser...")
106
- url = "https://sr.mihoyo.com/cloud/#/"
107
- browser_opened = False
108
- try:
109
- # Use only webbrowser.open
110
- print(f"Attempting to open {url} using webbrowser.open()...")
111
- if webbrowser.open(url):
112
- print(f"Successfully requested browser to open {url} via webbrowser.open().")
113
- browser_opened = True
114
- else:
115
- print("webbrowser.open() returned False, indicating potential failure.")
116
-
117
- if not browser_opened:
118
- print("ERROR: Failed to confirm browser opening via webbrowser.open().")
119
- # Still proceed to click attempt
120
-
121
- # Add pyautogui click after attempting to open the browser
122
- print("Proceeding with pyautogui actions...")
123
- time.sleep(5) # Wait time for the browser to load
124
-
125
- # Print detected screen size
126
- screen_width, screen_height = pyautogui.size()
127
- print(f"Detected screen size: {screen_width}x{screen_height}")
128
-
129
- click_x = int(screen_width * (1036 / 1280))
130
- click_y = int(screen_height * (500 / 720))
131
- print(f"Calculated click coordinates: ({click_x}, {click_y})")
132
-
133
- # Disable failsafe before clicking
134
- pyautogui.FAILSAFE = False
135
- print("PyAutoGUI failsafe temporarily disabled.")
136
-
137
- print(f"Clicking at coordinates: ({click_x}, {click_y})")
138
- pyautogui.click(click_x, click_y)
139
- time.sleep(2)
140
- pyautogui.click(click_x, click_y)
141
-
142
- # Re-enable failsafe (optional, as script might end anyway)
143
- # pyautogui.FAILSAFE = True
144
- # print("PyAutoGUI failsafe re-enabled.")
145
-
146
- except Exception as e:
147
- print(f"Error during environment preparation (browser/click): {e}")
148
- finally:
149
- # Ensure failsafe is re-enabled if an error occurs after disabling it
150
- pyautogui.FAILSAFE = True
151
- print("PyAutoGUI failsafe re-enabled.")
152
- else:
153
- # Placeholder for potential preparations on other OS or non-Star Rail modes
154
- print("Environment preparation: No specific actions required for this OS/mode.")
100
+ """Dynamically loads and runs preparation logic based on software name."""
101
+ # TODO: Replace hardcoded software name with value from shared_state when available
102
+ software_name = "star rail"
103
+ # Normalize the software name to be a valid Python module name
104
+ # Replace spaces/hyphens with underscores, convert to lowercase
105
+ module_name_base = software_name.replace(" ", "_").replace("-", "_").lower()
106
+ module_to_run = f"{module_name_base}_prepare"
107
+
108
+ log.info(f"Attempting preparation for software: '{software_name}' (Module: '{module_to_run}')")
109
+
110
+ try:
111
+ # Construct the full module path within the package
112
+ prep_package = "computer_use_ootb_internal.preparation"
113
+ full_module_path = f"{prep_package}.{module_to_run}"
114
+
115
+ # Dynamically import the module
116
+ # Check if module exists first using pkgutil to avoid import errors
117
+ # Note: pkgutil.find_loader might be deprecated, consider importlib.util.find_spec
118
+ loader = pkgutil.find_loader(full_module_path)
119
+ if loader is None:
120
+ log.warning(f"Preparation module '{full_module_path}' not found. Skipping preparation.")
121
+ return
122
+
123
+ prep_module = importlib.import_module(full_module_path)
124
+
125
+ # Check if the module has the expected function
126
+ if hasattr(prep_module, "run_preparation") and callable(prep_module.run_preparation):
127
+ log.info(f"Running preparation function from {full_module_path}...")
128
+ prep_module.run_preparation(state)
129
+ log.info(f"Preparation function from {full_module_path} completed.")
130
+ else:
131
+ log.warning(f"Module {full_module_path} found, but does not have a callable 'run_preparation' function. Skipping.")
132
+
133
+ except ModuleNotFoundError:
134
+ log.warning(f"Preparation module '{full_module_path}' not found. Skipping preparation.")
135
+ except Exception as e:
136
+ log.error(f"Error during dynamic preparation loading/execution for '{module_to_run}': {e}", exc_info=True)
155
137
 
156
138
 
157
139
  @app.post("/update_params")
@@ -178,7 +160,7 @@ async def update_parameters(request: Request):
178
160
 
179
161
  log_ootb_request(shared_state.server_url, "update_params", data)
180
162
 
181
- # Call the preparation function here, after parameters are updated
163
+ # Call the (now dynamic) preparation function here, after parameters are updated
182
164
  prepare_environment(shared_state)
183
165
 
184
166
  return JSONResponse(
@@ -31,7 +31,7 @@ _PACKAGE_NAME = "computer-use-ootb-internal"
31
31
  # Main module to start/stop for users
32
32
  _OOTB_MODULE = "computer_use_ootb_internal.app_teachmode"
33
33
  # Server endpoint to poll for commands (replace with your actual URL)
34
- _SERVER_COMMAND_URL = "https://52.160.105.102/api/guard/commands" # EXAMPLE URL - Verify protocol/port/path
34
+ _SERVER_COMMAND_URL = "http://52.160.105.102:7000/api/guard" # Using HTTP as port was specified
35
35
  # How often to poll the server (in seconds)
36
36
  _POLLING_INTERVAL = 60
37
37
  # Placeholder for a machine identifier or API key for the server
@@ -0,0 +1 @@
1
+ # This file makes the 'preparation' directory a Python package
@@ -0,0 +1,65 @@
1
+ # src/computer_use_ootb_internal/preparation/star_rail_prepare.py
2
+ import time
3
+ import platform
4
+ import pyautogui
5
+ import webbrowser
6
+ import logging # Use logging instead of print for better practice
7
+
8
+ # Set up logging for this module if needed, or rely on root logger
9
+ log = logging.getLogger(__name__)
10
+
11
+ def run_preparation(state):
12
+ """
13
+ Performs environment preparation specific to Star Rail on Windows.
14
+ Opens the specified URL in Edge and performs initial clicks.
15
+ """
16
+ if platform.system() != "Windows":
17
+ log.info("Star Rail preparation skipped: Not running on Windows.")
18
+ return
19
+
20
+ log.info("Star Rail preparation: Starting environment setup on Windows...")
21
+ url = "https://sr.mihoyo.com/cloud/#/" # Consider making this configurable later
22
+ browser_opened = False
23
+ try:
24
+ # Use only webbrowser.open
25
+ log.info(f"Attempting to open {url} using webbrowser.open()...")
26
+ if webbrowser.open(url):
27
+ log.info(f"Successfully requested browser to open {url} via webbrowser.open().")
28
+ browser_opened = True
29
+ else:
30
+ log.warning("webbrowser.open() returned False, indicating potential failure.")
31
+
32
+ if not browser_opened:
33
+ log.error("Failed to confirm browser opening via webbrowser.open(). Will still attempt clicks.")
34
+
35
+ # Add pyautogui click after attempting to open the browser
36
+ log.info("Proceeding with pyautogui actions...")
37
+ time.sleep(5) # Wait time for the browser to load
38
+
39
+ # Get screen size
40
+ screen_width, screen_height = pyautogui.size()
41
+ log.info(f"Detected screen size: {screen_width}x{screen_height}")
42
+
43
+ # Calculate click coordinates based on a reference resolution (e.g., 1280x720)
44
+ # TODO: Make these coordinates more robust or configurable
45
+ click_x = int(screen_width * (1036 / 1280))
46
+ click_y = int(screen_height * (500 / 720))
47
+ log.info(f"Calculated click coordinates: ({click_x}, {click_y})")
48
+
49
+ # Disable failsafe before clicking
50
+ pyautogui.FAILSAFE = False
51
+ log.info("PyAutoGUI failsafe temporarily disabled.")
52
+
53
+ log.info(f"Clicking at coordinates: ({click_x}, {click_y})")
54
+ pyautogui.click(click_x, click_y)
55
+ time.sleep(2)
56
+ pyautogui.click(click_x, click_y) # Double click?
57
+
58
+ log.info("Star Rail preparation clicks completed.")
59
+
60
+ except Exception as e:
61
+ log.error(f"Error during Star Rail preparation (browser/click): {e}", exc_info=True)
62
+ finally:
63
+ # Ensure failsafe is re-enabled
64
+ pyautogui.FAILSAFE = True
65
+ log.info("PyAutoGUI failsafe re-enabled.")