Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interpreter.computer.keyboard.write method fails when run by a macOS background service #1292

Open
getvictor opened this issue Jun 4, 2024 · 2 comments

Comments

@getvictor
Copy link

Describe the bug

I have a background macOS service (fleetd) that's trying to run a script using interpreter APIs.

It fails keyboard.write because it doesn't seem to have access to NSPasteboard.generalPasteboard

I'm not sure why it can't get a handle to the generalPasteboard. The service has System Events TCC permissions and all other requests for TCC permissions that popped up (Accessibility, Recording Screen and Audio).

Looking at the error, the method should work even without access to the generalPasteboard. interpreter should write one character at a time instead of trying to copy/paste.

Traceback (most recent call last):
  File "/Users/victor/work/migrate-to-fleet/main.py", line 44, in <module>
    interpreter.computer.keyboard.write("Profiles")
  File "/opt/homebrew/lib/python3.11/site-packages/interpreter/core/computer/keyboard/keyboard.py", line 40, in write
    self.computer.clipboard.copy(line)
  File "/opt/homebrew/lib/python3.11/site-packages/interpreter/core/computer/clipboard/clipboard.py", line 27, in copy
    pyperclip.copy(text)
  File "/opt/homebrew/lib/python3.11/site-packages/pyperclip/__init__.py", line 139, in copy_osx_pyobjc
    board.declareTypes_owner_([AppKit.NSStringPboardType], None)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'declareTypes_owner_'

Reproduce

  1. Set up Fleet server and install a Fleet agent on your macOS device.
  2. Execute a script via your Fleet agent. The script can be like:
#!/bin/sh
/Users/<myUsername>/myPythonScript.py

The python script should try and use interpreter.computer.keyboard.write("Profiles")

Expected behavior

I expected interpreter.computer.keyboard.write("Profiles") to work.

Screenshots

No response

Open Interpreter version

0.2.5

Python version

3.11.9

Operating System name and version

macOS 14

Additional context

I'm trying to create a demo where I use an Open Interpreter script to remediate an IT policy failure.

@KillianLucas
Copy link
Collaborator

KillianLucas commented Jun 15, 2024

Hey @getvictor! Thanks for discovering this and making such an incredible demo!

Were you able to find a way around this? Does pyautogui work in this environment, or another library like pynput? Would be happy to swap out the keyboard controlling library to make it work with fleet.

@getvictor
Copy link
Author

Hey @getvictor! Thanks for discovering this and making such an incredible demo!

Were you able to find a way around this? Does pyautogui work in this environment, or another library like pynput? Would be happy to swap out the keyboard controlling library to make it work with fleet.

I ended up writing 1 character at a time as a workaround. It was definitely slower.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants