pygpt-net 2.6.58__py3-none-any.whl → 2.6.59__py3-none-any.whl

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.
@@ -6,9 +6,11 @@
6
6
  # GitHub: https://github.com/szczyglis-dev/py-gpt #
7
7
  # MIT License #
8
8
  # Created By : Marcin Szczygliński #
9
- # Updated Date: 2025.08.15 23:00:00 #
9
+ # Updated Date: 2025.09.23 07:00:00 #
10
10
  # ================================================== #
11
11
 
12
+ import platform
13
+
12
14
  from pygpt_net.plugin.base.plugin import BasePlugin
13
15
  from pygpt_net.core.events import Event
14
16
  from pygpt_net.item.ctx import CtxItem
@@ -32,9 +34,45 @@ class Plugin(BasePlugin):
32
34
  'os',
33
35
  ]
34
36
  self.order = 100
37
+
38
+ # Core command(s)
39
+ self.winapi_cmds = [
40
+ # Windows window/query
41
+ "win_list",
42
+ "win_find",
43
+ "win_children",
44
+ "win_foreground",
45
+ "win_rect",
46
+ "win_get_state",
47
+ # Window control
48
+ "win_focus",
49
+ "win_move_resize",
50
+ "win_minimize",
51
+ "win_maximize",
52
+ "win_restore",
53
+ "win_close",
54
+ "win_show",
55
+ "win_hide",
56
+ "win_always_on_top",
57
+ "win_set_opacity",
58
+ # Screenshots
59
+ "win_screenshot",
60
+ "win_area_screenshot",
61
+ # Clipboard / input / cursor / monitors
62
+ "win_clipboard_get",
63
+ "win_clipboard_set",
64
+ "win_cursor_get",
65
+ "win_cursor_set",
66
+ "win_keys_text",
67
+ "win_keys_send",
68
+ "win_click",
69
+ "win_drag",
70
+ "win_monitors",
71
+ ]
35
72
  self.allowed_cmds = [
36
73
  "sys_exec",
37
- ]
74
+ ] + self.winapi_cmds
75
+
38
76
  self.use_locale = True
39
77
  self.docker = Docker(self)
40
78
  self.runner = Runner(self)
@@ -81,20 +119,26 @@ class Plugin(BasePlugin):
81
119
  :param data: event data dict
82
120
  """
83
121
  # get current working directory
84
- os = self.window.core.platforms.get_as_string(env_suffix=False)
122
+ os_name = self.window.core.platforms.get_as_string(env_suffix=False)
85
123
  cwd = self.window.core.config.get_user_dir('data')
86
- if self.get_option_value("sandbox_docker"):
87
- cwd = "/data (in docker sandbox, mapped on our host machine to: {})".format(cwd)
88
- os = "Linux" # docker image
124
+ is_windows = (platform.system() == "Windows")
125
+ winapi_enabled = self.get_option_value("winapi_enabled")
126
+
89
127
  for item in self.allowed_cmds:
128
+ # Gate WinAPI commands to Windows platform (and enabled flag)
129
+ if item in self.winapi_cmds:
130
+ if not is_windows or not winapi_enabled:
131
+ continue
132
+
90
133
  if self.has_cmd(item):
91
134
  cmd = self.get_cmd(item)
135
+ # Keep original sys_exec instruction enhancement
92
136
  if self.get_option_value("auto_cwd") and item == "sys_exec":
93
137
  cmd["instruction"] += "\nIMPORTANT: ALWAYS use absolute (not relative) path when passing " \
94
138
  "ANY command to \"command\" param. Current workdir is: {cwd}. " \
95
139
  "Current OS is: {os}".format(
96
140
  cwd=cwd,
97
- os=os)
141
+ os=os_name)
98
142
  data['cmd'].append(cmd) # append command
99
143
 
100
144
  def cmd(self, ctx: CtxItem, cmds: list, silent: bool = False):
@@ -162,4 +206,4 @@ class Plugin(BasePlugin):
162
206
  worker.run_async()
163
207
 
164
208
  except Exception as e:
165
- self.error(e)
209
+ self.error(e)