Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions gui_agents/s1/cli_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import platform
import signal
import subprocess
import sys
import time

Expand Down Expand Up @@ -138,16 +139,38 @@ def signal_handler(signum, frame):

def show_permission_dialog(code: str, action_description: str):
"""Show a platform-specific permission dialog and return True if approved."""
prompt_text = (
"Do you want to execute this action?\n\n"
f"{code}"
)
if action_description:
prompt_text += f" which will try to {action_description}"

if platform.system() == "Darwin":
result = os.system(
f'osascript -e \'display dialog "Do you want to execute this action?\n\n{code} which will try to {action_description}" with title "Action Permission" buttons {{"Cancel", "OK"}} default button "OK" cancel button "Cancel"\''
script = (
'display dialog argv item 1 with title "Action Permission" '
'buttons {"Cancel", "OK"} default button "OK" cancel button "Cancel"'
)
result = subprocess.run(
["osascript", "-e", script, prompt_text],
check=False,
)
return result == 0
return result.returncode == 0
elif platform.system() == "Linux":
result = os.system(
f'zenity --question --title="Action Permission" --text="Do you want to execute this action?\n\n{code}" --width=400 --height=200'
result = subprocess.run(
[
"zenity",
"--question",
"--title",
"Action Permission",
"--text",
prompt_text,
"--width=400",
"--height=200",
],
check=False,
)
return result == 0
return result.returncode == 0
return False


Expand Down
35 changes: 29 additions & 6 deletions gui_agents/s2/cli_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import platform
import pyautogui
import signal
import subprocess
import sys
import time

Expand Down Expand Up @@ -131,16 +132,38 @@ def signal_handler(signum, frame):

def show_permission_dialog(code: str, action_description: str):
"""Show a platform-specific permission dialog and return True if approved."""
prompt_text = (
"Do you want to execute this action?\n\n"
f"{code}"
)
if action_description:
prompt_text += f" which will try to {action_description}"

if platform.system() == "Darwin":
result = os.system(
f'osascript -e \'display dialog "Do you want to execute this action?\n\n{code} which will try to {action_description}" with title "Action Permission" buttons {{"Cancel", "OK"}} default button "OK" cancel button "Cancel"\''
script = (
'display dialog argv item 1 with title "Action Permission" '
'buttons {"Cancel", "OK"} default button "OK" cancel button "Cancel"'
)
result = subprocess.run(
["osascript", "-e", script, prompt_text],
check=False,
)
return result == 0
return result.returncode == 0
elif platform.system() == "Linux":
result = os.system(
f'zenity --question --title="Action Permission" --text="Do you want to execute this action?\n\n{code}" --width=400 --height=200'
result = subprocess.run(
[
"zenity",
"--question",
"--title",
"Action Permission",
"--text",
prompt_text,
"--width=400",
"--height=200",
],
check=False,
)
return result == 0
return result.returncode == 0
return False


Expand Down
35 changes: 29 additions & 6 deletions gui_agents/s2_5/cli_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import platform
import pyautogui
import signal
import subprocess
import sys
import time

Expand Down Expand Up @@ -131,16 +132,38 @@ def signal_handler(signum, frame):

def show_permission_dialog(code: str, action_description: str):
"""Show a platform-specific permission dialog and return True if approved."""
prompt_text = (
"Do you want to execute this action?\n\n"
f"{code}"
)
if action_description:
prompt_text += f" which will try to {action_description}"

if platform.system() == "Darwin":
result = os.system(
f'osascript -e \'display dialog "Do you want to execute this action?\n\n{code} which will try to {action_description}" with title "Action Permission" buttons {{"Cancel", "OK"}} default button "OK" cancel button "Cancel"\''
script = (
'display dialog argv item 1 with title "Action Permission" '
'buttons {"Cancel", "OK"} default button "OK" cancel button "Cancel"'
)
result = subprocess.run(
["osascript", "-e", script, prompt_text],
check=False,
)
return result == 0
return result.returncode == 0
elif platform.system() == "Linux":
result = os.system(
f'zenity --question --title="Action Permission" --text="Do you want to execute this action?\n\n{code}" --width=400 --height=200'
result = subprocess.run(
[
"zenity",
"--question",
"--title",
"Action Permission",
"--text",
prompt_text,
"--width=400",
"--height=200",
],
check=False,
)
return result == 0
return result.returncode == 0
return False


Expand Down
35 changes: 29 additions & 6 deletions gui_agents/s3/cli_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import platform
import pyautogui
import signal
import subprocess
import sys
import time

Expand Down Expand Up @@ -132,16 +133,38 @@ def signal_handler(signum, frame):

def show_permission_dialog(code: str, action_description: str):
"""Show a platform-specific permission dialog and return True if approved."""
prompt_text = (
"Do you want to execute this action?\n\n"
f"{code}"
)
if action_description:
prompt_text += f" which will try to {action_description}"

if platform.system() == "Darwin":
result = os.system(
f'osascript -e \'display dialog "Do you want to execute this action?\n\n{code} which will try to {action_description}" with title "Action Permission" buttons {{"Cancel", "OK"}} default button "OK" cancel button "Cancel"\''
script = (
'display dialog argv item 1 with title "Action Permission" '
'buttons {"Cancel", "OK"} default button "OK" cancel button "Cancel"'
)
result = subprocess.run(
["osascript", "-e", script, prompt_text],
check=False,
)
return result == 0
return result.returncode == 0
elif platform.system() == "Linux":
result = os.system(
f'zenity --question --title="Action Permission" --text="Do you want to execute this action?\n\n{code}" --width=400 --height=200'
result = subprocess.run(
[
"zenity",
"--question",
"--title",
"Action Permission",
"--text",
prompt_text,
"--width=400",
"--height=200",
],
check=False,
)
return result == 0
return result.returncode == 0
return False


Expand Down