cua-agent 0.4.25__tar.gz → 0.4.27__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.

Potentially problematic release.


This version of cua-agent might be problematic. Click here for more details.

Files changed (51) hide show
  1. {cua_agent-0.4.25 → cua_agent-0.4.27}/PKG-INFO +1 -1
  2. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/agent.py +9 -1
  3. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/callbacks/__init__.py +2 -0
  4. cua_agent-0.4.27/agent/callbacks/prompt_instructions.py +47 -0
  5. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/integrations/hud/__init__.py +12 -3
  6. {cua_agent-0.4.25 → cua_agent-0.4.27}/pyproject.toml +1 -1
  7. {cua_agent-0.4.25 → cua_agent-0.4.27}/README.md +0 -0
  8. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/__init__.py +0 -0
  9. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/__main__.py +0 -0
  10. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/adapters/__init__.py +0 -0
  11. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/adapters/huggingfacelocal_adapter.py +0 -0
  12. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/adapters/human_adapter.py +0 -0
  13. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/adapters/mlxvlm_adapter.py +0 -0
  14. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/callbacks/base.py +0 -0
  15. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/callbacks/budget_manager.py +0 -0
  16. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/callbacks/image_retention.py +0 -0
  17. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/callbacks/logging.py +0 -0
  18. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/callbacks/operator_validator.py +0 -0
  19. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/callbacks/pii_anonymization.py +0 -0
  20. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/callbacks/telemetry.py +0 -0
  21. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/callbacks/trajectory_saver.py +0 -0
  22. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/cli.py +0 -0
  23. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/computers/__init__.py +0 -0
  24. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/computers/base.py +0 -0
  25. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/computers/cua.py +0 -0
  26. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/computers/custom.py +0 -0
  27. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/decorators.py +0 -0
  28. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/human_tool/__init__.py +0 -0
  29. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/human_tool/__main__.py +0 -0
  30. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/human_tool/server.py +0 -0
  31. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/human_tool/ui.py +0 -0
  32. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/integrations/hud/proxy.py +0 -0
  33. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/loops/__init__.py +0 -0
  34. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/loops/anthropic.py +0 -0
  35. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/loops/base.py +0 -0
  36. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/loops/composed_grounded.py +0 -0
  37. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/loops/glm45v.py +0 -0
  38. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/loops/gta1.py +0 -0
  39. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/loops/model_types.csv +0 -0
  40. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/loops/omniparser.py +0 -0
  41. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/loops/openai.py +0 -0
  42. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/loops/uitars.py +0 -0
  43. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/proxy/examples.py +0 -0
  44. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/proxy/handlers.py +0 -0
  45. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/responses.py +0 -0
  46. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/types.py +0 -0
  47. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/ui/__init__.py +0 -0
  48. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/ui/__main__.py +0 -0
  49. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/ui/gradio/__init__.py +0 -0
  50. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/ui/gradio/app.py +0 -0
  51. {cua_agent-0.4.25 → cua_agent-0.4.27}/agent/ui/gradio/ui_components.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cua-agent
3
- Version: 0.4.25
3
+ Version: 0.4.27
4
4
  Summary: CUA (Computer Use) Agent for AI-driven computer interaction
5
5
  Author-Email: TryCua <gh@trycua.com>
6
6
  Requires-Python: >=3.12
@@ -31,7 +31,8 @@ from .callbacks import (
31
31
  TrajectorySaverCallback,
32
32
  BudgetManagerCallback,
33
33
  TelemetryCallback,
34
- OperatorNormalizerCallback
34
+ OperatorNormalizerCallback,
35
+ PromptInstructionsCallback,
35
36
  )
36
37
  from .computers import (
37
38
  AsyncComputerHandler,
@@ -162,6 +163,7 @@ class ComputerAgent:
162
163
  custom_loop: Optional[Callable] = None,
163
164
  only_n_most_recent_images: Optional[int] = None,
164
165
  callbacks: Optional[List[Any]] = None,
166
+ instructions: Optional[str] = None,
165
167
  verbosity: Optional[int] = None,
166
168
  trajectory_dir: Optional[str | Path | dict] = None,
167
169
  max_retries: Optional[int] = 3,
@@ -180,6 +182,7 @@ class ComputerAgent:
180
182
  custom_loop: Custom agent loop function to use instead of auto-selection
181
183
  only_n_most_recent_images: If set, only keep the N most recent images in message history. Adds ImageRetentionCallback automatically.
182
184
  callbacks: List of AsyncCallbackHandler instances for preprocessing/postprocessing
185
+ instructions: Optional system instructions to be passed to the model
183
186
  verbosity: Logging level (logging.DEBUG, logging.INFO, etc.). If set, adds LoggingCallback automatically
184
187
  trajectory_dir: If set, saves trajectory data (screenshots, responses) to this directory. Adds TrajectorySaverCallback automatically.
185
188
  max_retries: Maximum number of retries for failed API calls
@@ -198,6 +201,7 @@ class ComputerAgent:
198
201
  self.custom_loop = custom_loop
199
202
  self.only_n_most_recent_images = only_n_most_recent_images
200
203
  self.callbacks = callbacks or []
204
+ self.instructions = instructions
201
205
  self.verbosity = verbosity
202
206
  self.trajectory_dir = trajectory_dir
203
207
  self.max_retries = max_retries
@@ -211,6 +215,10 @@ class ComputerAgent:
211
215
  # Prepend operator normalizer callback
212
216
  self.callbacks.insert(0, OperatorNormalizerCallback())
213
217
 
218
+ # Add prompt instructions callback if provided
219
+ if self.instructions:
220
+ self.callbacks.append(PromptInstructionsCallback(self.instructions))
221
+
214
222
  # Add telemetry callback if telemetry_enabled is set
215
223
  if self.telemetry_enabled:
216
224
  if isinstance(self.telemetry_enabled, bool):
@@ -9,6 +9,7 @@ from .trajectory_saver import TrajectorySaverCallback
9
9
  from .budget_manager import BudgetManagerCallback
10
10
  from .telemetry import TelemetryCallback
11
11
  from .operator_validator import OperatorNormalizerCallback
12
+ from .prompt_instructions import PromptInstructionsCallback
12
13
 
13
14
  __all__ = [
14
15
  "AsyncCallbackHandler",
@@ -18,4 +19,5 @@ __all__ = [
18
19
  "BudgetManagerCallback",
19
20
  "TelemetryCallback",
20
21
  "OperatorNormalizerCallback",
22
+ "PromptInstructionsCallback",
21
23
  ]
@@ -0,0 +1,47 @@
1
+ """
2
+ Prompt instructions callback.
3
+
4
+ This callback allows simple prompt engineering by pre-pending a user
5
+ instructions message to the start of the conversation before each LLM call.
6
+
7
+ Usage:
8
+
9
+ from agent.callbacks import PromptInstructionsCallback
10
+ agent = ComputerAgent(
11
+ model="openai/computer-use-preview",
12
+ callbacks=[PromptInstructionsCallback("Follow these rules...")]
13
+ )
14
+
15
+ """
16
+
17
+ from typing import Any, Dict, List, Optional
18
+
19
+ from .base import AsyncCallbackHandler
20
+
21
+
22
+ class PromptInstructionsCallback(AsyncCallbackHandler):
23
+ """
24
+ Prepend a user instructions message to the message list.
25
+
26
+ This is a minimal, non-invasive way to guide the agent's behavior without
27
+ modifying agent loops or tools. It works with any provider/loop since it
28
+ only alters the messages array before sending to the model.
29
+ """
30
+
31
+ def __init__(self, instructions: Optional[str]) -> None:
32
+ self.instructions = instructions
33
+
34
+ async def on_llm_start(self, messages: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
35
+ # Pre-pend instructions message
36
+ if not self.instructions:
37
+ return messages
38
+
39
+ # Ensure we don't duplicate if already present at the front
40
+ if messages and isinstance(messages[0], dict):
41
+ first = messages[0]
42
+ if first.get("role") == "user" and first.get("content") == self.instructions:
43
+ return messages
44
+
45
+ return [
46
+ {"role": "user", "content": self.instructions},
47
+ ] + messages
@@ -20,6 +20,7 @@ from hud import trace
20
20
 
21
21
  from agent.agent import ComputerAgent as BaseComputerAgent
22
22
  from .proxy import FakeAsyncOpenAI
23
+ from agent.callbacks import PromptInstructionsCallback
23
24
 
24
25
 
25
26
  # ---------------------------------------------------------------------------
@@ -47,6 +48,7 @@ class ProxyOperatorAgent(OperatorAgent):
47
48
  custom_loop: Any | None = None,
48
49
  only_n_most_recent_images: int | None = None,
49
50
  callbacks: list[Any] | None = None,
51
+ instructions: str | None = None,
50
52
  verbosity: int | None = None,
51
53
  max_retries: int | None = 3,
52
54
  screenshot_delay: float | int = 0.5,
@@ -68,12 +70,17 @@ class ProxyOperatorAgent(OperatorAgent):
68
70
  if tools:
69
71
  agent_tools.extend(tools)
70
72
 
73
+ # Build callbacks, injecting prompt instructions if provided
74
+ agent_callbacks = list(callbacks or [])
75
+ if instructions:
76
+ agent_callbacks.append(PromptInstructionsCallback(instructions))
77
+
71
78
  computer_agent = BaseComputerAgent(
72
79
  model=model,
73
80
  tools=agent_tools,
74
81
  custom_loop=custom_loop,
75
82
  only_n_most_recent_images=only_n_most_recent_images,
76
- callbacks=callbacks,
83
+ callbacks=agent_callbacks,
77
84
  verbosity=verbosity,
78
85
  trajectory_dir=trajectory_dir,
79
86
  max_retries=max_retries,
@@ -96,7 +103,6 @@ class ProxyOperatorAgent(OperatorAgent):
96
103
  # Single-task runner
97
104
  # ---------------------------------------------------------------------------
98
105
 
99
-
100
106
  async def run_single_task(
101
107
  dataset: str | Dataset | list[dict[str, Any]],
102
108
  *,
@@ -108,6 +114,7 @@ async def run_single_task(
108
114
  custom_loop: Any | None = None,
109
115
  only_n_most_recent_images: int | None = None,
110
116
  callbacks: list[Any] | None = None,
117
+ instructions: str | None = None,
111
118
  verbosity: int | None = None,
112
119
  trajectory_dir: str | dict | None = None,
113
120
  max_retries: int | None = 3,
@@ -140,6 +147,7 @@ async def run_single_task(
140
147
  custom_loop=custom_loop,
141
148
  only_n_most_recent_images=only_n_most_recent_images,
142
149
  callbacks=callbacks,
150
+ instructions=instructions,
143
151
  verbosity=verbosity,
144
152
  trajectory_dir=trajectory_dir,
145
153
  max_retries=max_retries,
@@ -157,7 +165,6 @@ async def run_single_task(
157
165
  # Full-dataset runner
158
166
  # ---------------------------------------------------------------------------
159
167
 
160
-
161
168
  async def run_full_dataset(
162
169
  dataset: str | Dataset | list[dict[str, Any]],
163
170
  *,
@@ -173,6 +180,7 @@ async def run_full_dataset(
173
180
  custom_loop: Any | None = None,
174
181
  only_n_most_recent_images: int | None = 5,
175
182
  callbacks: list[Any] | None = None,
183
+ instructions: str | None = None,
176
184
  verbosity: int | None = None,
177
185
  max_retries: int | None = 3,
178
186
  screenshot_delay: float | int = 0.5,
@@ -207,6 +215,7 @@ async def run_full_dataset(
207
215
  "custom_loop": custom_loop,
208
216
  "only_n_most_recent_images": only_n_most_recent_images,
209
217
  "callbacks": callbacks,
218
+ "instructions": instructions,
210
219
  "verbosity": verbosity,
211
220
  "max_retries": max_retries,
212
221
  "screenshot_delay": screenshot_delay,
@@ -6,7 +6,7 @@ build-backend = "pdm.backend"
6
6
 
7
7
  [project]
8
8
  name = "cua-agent"
9
- version = "0.4.25"
9
+ version = "0.4.27"
10
10
  description = "CUA (Computer Use) Agent for AI-driven computer interaction"
11
11
  readme = "README.md"
12
12
  authors = [
File without changes
File without changes
File without changes
File without changes
File without changes