computer-use-ootb-internal 0.0.160__tar.gz → 0.0.161__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.160 → computer_use_ootb_internal-0.0.161}/PKG-INFO +1 -1
  2. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/pyproject.toml +1 -1
  3. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/guard_service.py +64 -59
  4. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/.gitignore +0 -0
  5. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/README.md +0 -0
  6. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/__init__.py +0 -0
  7. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/app_teachmode.py +0 -0
  8. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/animation/click_animation.py +0 -0
  9. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/animation/icons8-select-cursor-transparent-96.gif +0 -0
  10. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/animation/test_animation.py +0 -0
  11. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/executor/teachmode_executor.py +0 -0
  12. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/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.160 → computer_use_ootb_internal-0.0.161}/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.160 → computer_use_ootb_internal-0.0.161}/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.160 → computer_use_ootb_internal-0.0.161}/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.160 → computer_use_ootb_internal-0.0.161}/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.160 → computer_use_ootb_internal-0.0.161}/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.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/llm_utils/llm_utils.py +0 -0
  19. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/llm_utils/oai.py +0 -0
  20. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/llm_utils/run_litellm.py +0 -0
  21. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/gui_agent/llm_utils/run_llm.py +0 -0
  22. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/tools/__init__.py +0 -0
  23. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/tools/aws_request.py +0 -0
  24. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/tools/base.py +0 -0
  25. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/tools/bash.py +0 -0
  26. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/tools/collection.py +0 -0
  27. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/tools/colorful_text.py +0 -0
  28. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/tools/computer.py +0 -0
  29. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/tools/computer_marbot.py +0 -0
  30. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/tools/edit.py +0 -0
  31. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/tools/run.py +0 -0
  32. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/computer_use_demo/tools/screen_capture.py +0 -0
  33. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/dependency_check.py +0 -0
  34. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/preparation/__init__.py +0 -0
  35. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/preparation/star_rail_prepare.py +0 -0
  36. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/requirements-lite.txt +0 -0
  37. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/run_teachmode_ootb_args.py +0 -0
  38. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/src/computer_use_ootb_internal/service_manager.py +0 -0
  39. {computer_use_ootb_internal-0.0.160 → computer_use_ootb_internal-0.0.161}/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.160
3
+ Version: 0.0.161
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.160"
7
+ version = "0.0.161"
8
8
  description = "Computer Use OOTB"
9
9
  authors = [{ name = "Siyuan Hu", email = "siyuan.hu.sg@gmail.com" }]
10
10
  requires-python = ">=3.11"
@@ -758,74 +758,79 @@ class GuardService(win32serviceutil.ServiceFramework):
758
758
  self.log_error(f"Internal trigger: Error checking existing processes for {user}: {e}")
759
759
  # Continue and attempt start despite error?
760
760
 
761
- # 4. Attempt immediate start (User is active and not running)
762
- immediate_start_status = "start_attempted"
763
- self.log_info(f"Internal trigger: User '{user}' is active and not running. Attempting immediate start via PowerShell elevation...")
764
-
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
+
765
766
  if not self.target_executable_path:
766
767
  self.log_error("Internal trigger: Cannot start process - target executable path not found.")
767
768
  final_status = "failed_exe_not_found"
768
- return final_status # Exit early if executable missing
769
+ return final_status
769
770
 
770
771
  try:
771
- token = win32ts.WTSQueryUserToken(session_id)
772
- env = win32profile.CreateEnvironmentBlock(token, False)
773
- startup = win32process.STARTUPINFO()
774
- # Use CREATE_NEW_CONSOLE to make the PS window visible and potentially the UAC prompt
775
- creation_flags = win32con.CREATE_NEW_CONSOLE
776
-
777
- # Command to run PowerShell, which then elevates the target executable
772
+ # Prepare paths and arguments, escaping for PowerShell strings
778
773
  target_exe_unquoted = self.target_executable_path.strip('"')
779
- target_exe_for_ps = target_exe_unquoted.replace("'", "''") # Escape single quotes for PS strings
774
+ target_exe_for_ps = target_exe_unquoted.replace("'", "''")
780
775
  target_exe_dir_for_ps = os.path.dirname(target_exe_unquoted).replace("'", "''")
781
-
782
- # 1. 准备 PowerShell 命令中需要的变量 (进行基本的 PowerShell 字符串转义)
783
- ps_target_exe = target_exe_for_ps
784
- ps_working_dir = target_exe_dir_for_ps
785
- # 用户名 'altair' 在最终命令里需要 ''altair'' 格式
786
- ps_user_arg_format = user.replace("'", "''") # 先转义用户名本身的单引号
787
-
788
- # 2. 构建最终的、完整的 PowerShell 命令字符串,严格按照模板
789
- # 模板: Start-Process -FilePath cmd.exe -ArgumentList @('/K', '"<exe_path>" --port <port> --target_user ''<username>''') -WorkingDirectory '<working_dir>' -Verb RunAs
790
- ps_command_string = f"Start-Process -FilePath cmd.exe -ArgumentList @('/K', '"""{ps_target_exe}""" --port {calculated_port} --target_user ''''{ps_user_arg_format}''''') -WorkingDirectory '{ps_working_dir}' -Verb RunAs"
791
-
792
- # 3. 为 powershell.exe -Command '...' 参数转义整个命令字符串中的单引号
793
- ps_command_string_escaped = ps_command_string.replace("'", "''")
794
-
795
- # 4. 生成最终传递给 CreateProcessAsUser 的命令行
796
- # 依然使用 powershell.exe -NoExit -Command '{ ... }' 以便观察,虽然不一定有效
797
- lpCommandLine = f"powershell.exe -NoProfile -ExecutionPolicy Bypass -NoExit -Command '{{ {ps_command_string_escaped} }}'"
798
-
799
- lpApplicationName = None # Must be None if using lpCommandLine
800
- cwd = os.path.dirname(target_exe_unquoted) if os.path.dirname(target_exe_unquoted) else None
801
776
 
802
- # Log details before call
803
- self.log_info(f"Internal trigger: Launching PowerShell directly for elevation:")
804
- self.log_info(f" lpCommandLine: {lpCommandLine}")
805
- self.log_info(f" lpCurrentDirectory: {cwd if cwd else 'Default'}")
806
-
807
- hProcess, hThread, dwPid, dwTid = win32process.CreateProcessAsUser(
808
- token, lpApplicationName, lpCommandLine, None, None, False,
809
- creation_flags, env, cwd, startup
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
801
+ result = subprocess.run(
802
+ command_list,
803
+ capture_output=True,
804
+ text=True,
805
+ check=False, # Don't raise exception on non-zero exit
806
+ encoding='utf-8',
807
+ errors='ignore'
810
808
  )
811
- # We get the PID of cmd.exe/powershell.exe here, not the final elevated process.
812
- # We can't easily track the elevated process PID across the UAC boundary.
813
- self.log_info(f"Internal trigger: CreateProcessAsUser call to initiate elevation succeeded for user '{user}' (Launcher PID: {dwPid}). UAC prompt expected if needed.")
814
- win32api.CloseHandle(hProcess)
815
- win32api.CloseHandle(hThread)
816
-
817
- # Assume success if the call didn't raise an exception.
818
- # We cannot easily verify if the *elevated* process actually started.
819
- immediate_start_status = "start_elevation_initiated"
820
- final_status = "success_elevation_initiated" # Report success based on initiating the elevation
821
-
822
- except Exception as proc_err:
823
- self.log_error(f"Internal trigger: Exception during CreateProcessAsUser for elevation attempt (user '{user}'): {proc_err}", exc_info=True)
824
- immediate_start_status = "start_failed_exception"
825
- final_status = "failed_start_exception"
826
- finally:
827
- if token: win32api.CloseHandle(token)
828
-
809
+
810
+ # Log results
811
+ if result.stdout:
812
+ self.log_info(f"Internal trigger: PowerShell STDOUT:\\n{result.stdout.strip()}")
813
+ 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"
820
+ 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}"
824
+
825
+ 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"
833
+
829
834
  # Combine results (mostly determined by start attempt now)
830
835
  # Example: final_status = f"{task_created_status}_{immediate_start_status}"
831
836
  return final_status