computer-use-ootb-internal 0.0.161__tar.gz → 0.0.162__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 (39) hide show
  1. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/PKG-INFO +1 -1
  2. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/pyproject.toml +1 -1
  3. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/guard_service.py +57 -110
  4. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/.gitignore +0 -0
  5. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/README.md +0 -0
  6. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/__init__.py +0 -0
  7. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/app_teachmode.py +0 -0
  8. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/animation/click_animation.py +0 -0
  9. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/animation/icons8-select-cursor-transparent-96.gif +0 -0
  10. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/animation/test_animation.py +0 -0
  11. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/executor/teachmode_executor.py +0 -0
  12. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/gui_parser/simple_parser/__init__.py +0 -0
  13. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/gui_parser/simple_parser/gui_capture.py +0 -0
  14. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/gui_parser/simple_parser/utils.py +0 -0
  15. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/gui_parser/uia_tools/__init__.py +0 -0
  16. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/gui_parser/uia_tools/screenshot_cli.py +0 -0
  17. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/gui_parser/uia_tools/screenshot_service.py +0 -0
  18. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/llm_utils/llm_utils.py +0 -0
  19. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/llm_utils/oai.py +0 -0
  20. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/llm_utils/run_litellm.py +0 -0
  21. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/llm_utils/run_llm.py +0 -0
  22. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/tools/__init__.py +0 -0
  23. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/tools/aws_request.py +0 -0
  24. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/tools/base.py +0 -0
  25. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/tools/bash.py +0 -0
  26. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/tools/collection.py +0 -0
  27. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/tools/colorful_text.py +0 -0
  28. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/tools/computer.py +0 -0
  29. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/tools/computer_marbot.py +0 -0
  30. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/tools/edit.py +0 -0
  31. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/tools/run.py +0 -0
  32. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/computer_use_demo/tools/screen_capture.py +0 -0
  33. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/dependency_check.py +0 -0
  34. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/preparation/__init__.py +0 -0
  35. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/preparation/star_rail_prepare.py +0 -0
  36. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/requirements-lite.txt +0 -0
  37. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/run_teachmode_ootb_args.py +0 -0
  38. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/service_manager.py +0 -0
  39. {computer_use_ootb_internal-0.0.161 → computer_use_ootb_internal-0.0.162}/src/computer_use_ootb_internal/signal_connection.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: computer-use-ootb-internal
3
- Version: 0.0.161
3
+ Version: 0.0.162
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.161"
7
+ version = "0.0.162"
8
8
  description = "Computer Use OOTB"
9
9
  authors = [{ name = "Siyuan Hu", email = "siyuan.hu.sg@gmail.com" }]
10
10
  requires-python = ">=3.11"
@@ -226,9 +226,7 @@ class GuardService(win32serviceutil.ServiceFramework):
226
226
  self.log_info(f"Using target executable: {self.target_executable_path}")
227
227
 
228
228
  _service_instance = self
229
- # Determine path to the signal script
230
- self.signal_script_path = self._find_signal_script()
231
- self.log_info(f"Service initialized. Target executable: {self.target_executable_path}. Signal script: {self.signal_script_path}")
229
+ self.log_info(f"Service initialized. Target executable: {self.target_executable_path}.")
232
230
 
233
231
  def SvcStop(self):
234
232
  self.log_info(f"Service stop requested.")
@@ -710,7 +708,7 @@ class GuardService(win32serviceutil.ServiceFramework):
710
708
  try:
711
709
  # 1. Ensure scheduled task exists (still useful fallback/persistence)
712
710
  try:
713
- task_created = self.create_or_update_logon_task(user)
711
+ task_created = self.create_or_update_logon_task(user, calculated_port)
714
712
  task_created_status = "task_success" if task_created else "task_failed"
715
713
  except Exception as task_err:
716
714
  self.log_error(f"Internal trigger: Exception creating/updating task for {user}: {task_err}", exc_info=True)
@@ -758,78 +756,58 @@ class GuardService(win32serviceutil.ServiceFramework):
758
756
  self.log_error(f"Internal trigger: Error checking existing processes for {user}: {e}")
759
757
  # Continue and attempt start despite error?
760
758
 
761
- # --- Removed CreateProcessAsUser logic ---
762
- # 4. Attempt immediate start directly via subprocess calling PowerShell
763
- immediate_start_status = "start_attempted_direct_subprocess"
764
- self.log_info(f"Internal trigger: User '{user}' is active and not running. Attempting immediate start via direct PowerShell subprocess...")
765
-
766
- if not self.target_executable_path:
767
- self.log_error("Internal trigger: Cannot start process - target executable path not found.")
768
- final_status = "failed_exe_not_found"
769
- return final_status
759
+ # 4. Create/Update and Trigger Scheduled Task
760
+ immediate_start_status = "start_attempted_task_trigger"
761
+ self.log_info(f"Internal trigger: User '{user}' is active and not running. Attempting start via Task Scheduler...")
770
762
 
763
+ # --- Start Task Scheduler logic ---
771
764
  try:
772
- # Prepare paths and arguments, escaping for PowerShell strings
773
- target_exe_unquoted = self.target_executable_path.strip('"')
774
- target_exe_for_ps = target_exe_unquoted.replace("'", "''")
775
- target_exe_dir_for_ps = os.path.dirname(target_exe_unquoted).replace("'", "''")
776
-
777
- # Build the exact Start-Process command string based on the working template as a single line
778
- # Need to escape quotes carefully for the final -Command '...' argument
779
- # 1. Build the second argument for the @() array element
780
- cmd_k_second_arg = f'"\\"{target_exe_for_ps}\\"" --port {calculated_port} --target_user \'\'{user}\'\''
781
- # 2. Escape single quotes within it for the PS literal array element
782
- cmd_k_second_arg_escaped_for_array = cmd_k_second_arg.replace("'", "''")
783
- # 3. Build the full script block content as a single line string
784
- ps_script_block_content = f"$cmdArgs = @('/K', '{cmd_k_second_arg_escaped_for_array}'); Start-Process -FilePath cmd.exe -ArgumentList $cmdArgs -WorkingDirectory '{target_exe_dir_for_ps}' -Verb RunAs"
785
- # 4. Escape single quotes in the whole script block for the outer -Command '...'
786
- ps_script_block_content_escaped = ps_script_block_content.replace("'", "''")
787
-
788
- # Command list for subprocess
789
- powershell_executable = "powershell.exe"
790
- command_list = [
791
- powershell_executable,
792
- "-NoProfile",
793
- "-ExecutionPolicy", "Bypass",
794
- "-Command",
795
- f"{{ {ps_script_block_content_escaped} }}" # Use script block {}
796
- ]
797
-
798
- self.log_info(f"Internal trigger: Executing subprocess: {command_list}")
799
-
800
- # Execute the command directly from the service context
765
+ # Step 4a: Ensure the task is created/updated correctly
766
+ # Pass calculated port to the task creation function
767
+ task_created = self.create_or_update_logon_task(user, calculated_port)
768
+ if not task_created:
769
+ self.log_error(f"Internal trigger: Failed to create/update scheduled task for user '{user}'. Cannot proceed with start.")
770
+ final_status = "failed_task_creation"
771
+ return final_status
772
+
773
+ # Step 4b: Trigger the task to run immediately
774
+ task_name = f"OOTB_UserConnect_{user}" # Must match the name used in create_or_update_logon_task
775
+ trigger_command = ["schtasks", "/Run", "/TN", task_name]
776
+ self.log_info(f"Internal trigger: Attempting to run task '{task_name}' immediately using: {trigger_command}")
777
+
801
778
  result = subprocess.run(
802
- command_list,
779
+ trigger_command,
803
780
  capture_output=True,
804
781
  text=True,
805
- check=False, # Don't raise exception on non-zero exit
782
+ check=False, # Check return code manually
806
783
  encoding='utf-8',
807
- errors='ignore'
784
+ errors='ignore'
808
785
  )
809
786
 
810
- # Log results
811
787
  if result.stdout:
812
- self.log_info(f"Internal trigger: PowerShell STDOUT:\\n{result.stdout.strip()}")
788
+ self.log_info(f"Internal trigger: schtasks /Run STDOUT:\n{result.stdout.strip()}")
813
789
  if result.stderr:
814
- self.log_warning(f"Internal trigger: PowerShell STDERR:\\n{result.stderr.strip()}")
815
-
816
- if result.returncode == 0:
817
- self.log_info("Internal trigger: PowerShell subprocess command executed successfully (Exit Code 0). Process likely started elevated in background.")
818
- immediate_start_status = "start_success_direct_subprocess"
819
- final_status = "success_direct_subprocess"
790
+ # schtasks often prints success message to stderr, log as info
791
+ self.log_info(f"Internal trigger: schtasks /Run STDERR:\n{result.stderr.strip()}")
792
+
793
+ if result.returncode == 0 or "SUCCESS: Attempted to run the scheduled task" in result.stdout or "SUCCESS: Attempted to run the scheduled task" in result.stderr:
794
+ self.log_info(f"Internal trigger: Successfully triggered task '{task_name}' for user '{user}'.")
795
+ immediate_start_status = "start_success_task_triggered"
796
+ final_status = "success_task_triggered"
820
797
  else:
821
- self.log_error(f"Internal trigger: PowerShell subprocess command failed (Exit Code {result.returncode}).")
822
- immediate_start_status = f"start_failed_direct_subprocess_code_{result.returncode}"
823
- final_status = f"failed_direct_subprocess_code_{result.returncode}"
798
+ self.log_error(f"Internal trigger: Failed to trigger task '{task_name}' (Exit Code: {result.returncode}).")
799
+ immediate_start_status = f"start_failed_task_trigger_code_{result.returncode}"
800
+ final_status = f"failed_task_trigger_code_{result.returncode}"
824
801
 
825
802
  except FileNotFoundError:
826
- self.log_error("Internal trigger: 'powershell.exe' not found.")
827
- immediate_start_status = "start_failed_ps_not_found"
828
- final_status = "failed_ps_not_found"
829
- except Exception as subproc_err:
830
- self.log_error(f"Internal trigger: Exception during PowerShell subprocess execution for user '{user}': {subproc_err}", exc_info=True)
831
- immediate_start_status = "start_failed_subprocess_exception"
832
- final_status = "failed_subprocess_exception"
803
+ self.log_error("Internal trigger: 'schtasks.exe' not found.")
804
+ immediate_start_status = "start_failed_schtasks_not_found"
805
+ final_status = "failed_schtasks_not_found"
806
+ except Exception as task_trigger_err:
807
+ self.log_error(f"Internal trigger: Exception during task trigger for user '{user}': {task_trigger_err}", exc_info=True)
808
+ immediate_start_status = "start_failed_task_trigger_exception"
809
+ final_status = "failed_task_trigger_exception"
810
+ # --- End Task Scheduler logic ---
833
811
 
834
812
  # Combine results (mostly determined by start attempt now)
835
813
  # Example: final_status = f"{task_created_status}_{immediate_start_status}"
@@ -840,48 +818,35 @@ class GuardService(win32serviceutil.ServiceFramework):
840
818
  return "failed_trigger_exception"
841
819
 
842
820
 
843
- def create_or_update_logon_task(self, username):
821
+ def create_or_update_logon_task(self, username, port):
844
822
  """Creates/updates task to trigger the internal signal script on session connect."""
845
- if not self.signal_script_path:
846
- self.log_error(f"Cannot create task for {username}: Signal script path is not set.")
823
+ if not self.target_executable_path:
824
+ self.log_error(f"Cannot create task for {username}: Target executable path not found.")
847
825
  return False
848
- if not sys.executable:
849
- self.log_error(f"Cannot create task for {username}: sys.executable is not found.")
850
- return False
851
-
852
- # Use the python executable that the service itself is running under
853
- python_exe = sys.executable
854
- if ' ' in python_exe and not python_exe.startswith('"'):
855
- python_exe = f'"{python_exe}"'
856
826
 
857
827
  task_name = f"OOTB_UserConnect_{username}"
858
- # Action: Run python.exe with the signal script and username argument
859
- action_executable = python_exe
860
- # Ensure script path is quoted if needed
861
- script_arg = self.signal_script_path # Should be quoted already by _find_signal_script
862
- # Username might need quoting if it contains spaces, though unlikely
863
- user_arg = username # Keep simple for now
864
- action_arguments = f'{script_arg} "{user_arg}"' # Pass username as quoted arg
865
- safe_action_executable = action_executable.replace("'", "''") # Escape for PS
866
- safe_action_arguments = action_arguments.replace("'", "''") # Escape for PS
867
-
868
- # Working directory for the script (likely its own directory)
828
+ target_exe_unquoted = self.target_executable_path.strip('"')
829
+ target_exe_for_ps = target_exe_unquoted.replace("'", "''")
830
+ action_arguments = f"--port {port} --target_user '{username}'".replace("'", "''") # Arguments for the target exe
831
+
832
+ # Working directory for the executable
869
833
  try:
870
- script_dir = os.path.dirname(self.signal_script_path.strip('"'))
871
- if not script_dir: script_dir = "."
872
- safe_working_directory = script_dir.replace("'", "''")
834
+ target_dir = os.path.dirname(target_exe_unquoted)
835
+ if not target_dir: target_dir = "."
836
+ safe_working_directory = target_dir.replace("'", "''")
873
837
  working_directory_setting = f"$action.WorkingDirectory = '{safe_working_directory}'"
874
838
  except Exception as e:
875
- self.log_error(f"Error determining working directory for signal script task: {e}. WD will not be set.")
839
+ self.log_error(f"Error determining working directory for target exe task: {e}. WD will not be set.")
876
840
  working_directory_setting = "# Could not set WorkingDirectory"
877
841
 
878
842
  # PowerShell command construction
879
843
  ps_command = f"""
880
844
  $taskName = "{task_name}"
881
- $principal = New-ScheduledTaskPrincipal -UserId "{username}" -LogonType Interactive
845
+ # Principal runs as the user, but with highest privileges
846
+ $principal = New-ScheduledTaskPrincipal -UserId "{username}" -LogonType Interactive -RunLevel Highest
882
847
 
883
- # Action: Run python signal script
884
- $action = New-ScheduledTaskAction -Execute '{safe_action_executable}' -Argument '{safe_action_arguments}'
848
+ # Action: Run the target executable directly with arguments
849
+ $action = New-ScheduledTaskAction -Execute '{target_exe_for_ps}' -Argument '{action_arguments}'
885
850
  {working_directory_setting}
886
851
 
887
852
  # Trigger: On session connect (Event ID 21)
@@ -951,24 +916,6 @@ class GuardService(win32serviceutil.ServiceFramework):
951
916
  self.log_info(f"Attempted removal of scheduled task '{task_name}' for user '{username}'.")
952
917
  return True
953
918
 
954
- def _find_signal_script(self):
955
- """Finds the signal_connection.py script relative to this service file."""
956
- try:
957
- base_dir = os.path.dirname(os.path.abspath(__file__))
958
- script_path = os.path.join(base_dir, "signal_connection.py")
959
- if os.path.exists(script_path):
960
- self.log_info(f"Found signal script at: {script_path}")
961
- # Quote if needed?
962
- if " " in script_path and not script_path.startswith('"'):
963
- return f'"{script_path}"'
964
- return script_path
965
- else:
966
- self.log_error(f"Signal script signal_connection.py not found near {base_dir}")
967
- return None
968
- except Exception as e:
969
- self.log_error(f"Error finding signal script: {e}")
970
- return None
971
-
972
919
  # --- Main Execution Block ---
973
920
  if __name__ == '__main__':
974
921
  if len(sys.argv) > 1 and sys.argv[1] == 'debug':