meshagent-computers 0.0.32__py3-none-any.whl → 0.0.33__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.

Potentially problematic release.


This version of meshagent-computers might be problematic. Click here for more details.

@@ -14,11 +14,30 @@ import logging
14
14
  logger = logging.getLogger("computer")
15
15
  logger.setLevel(logging.WARN)
16
16
 
17
+ class ComputerToolkit(Toolkit):
18
+ def __init__(self, name: str, computer:Computer, operator: Operator, tools: list[Tool]):
19
+ super().__init__(name=name, tools=tools)
20
+ self.computer = computer
21
+ self.operator = operator
22
+ self.started = False
23
+ self._starting = None
24
+
25
+ async def ensure_started(self):
26
+
27
+ self.started = False
28
+
29
+ if self.started == False:
30
+
31
+ self.started = True
32
+ await self.computer.__aenter__()
33
+
34
+
35
+
17
36
  def make_computer_toolkit(*, operator_cls: Type[Operator], computer_cls: Type[Computer], render_screen: Callable[[bytes],None]):
18
37
 
19
38
  operator = operator_cls()
20
39
  computer = computer_cls()
21
- started = False
40
+
22
41
 
23
42
  class ComputerTool(OpenAIResponsesTool):
24
43
  def __init__(self, *, operator: Operator, computer: Computer, title = "computer_call", description = "handle computer calls from computer use preview", rules = [], thumbnail_url = None):
@@ -32,22 +51,23 @@ def make_computer_toolkit(*, operator_cls: Type[Operator], computer_cls: Type[Co
32
51
  )
33
52
  self.computer = computer
34
53
 
35
- def get_open_ai_tool_definition(self):
54
+ def get_open_ai_tool_definitions(self) -> list[dict]:
55
+ return [
56
+ {
57
+ "type": "computer_use_preview",
58
+ "display_width": self.computer.dimensions[0],
59
+ "display_height": self.computer.dimensions[1],
60
+ "environment": self.computer.environment,
61
+ }
62
+ ]
63
+
64
+ def get_open_ai_output_handlers(self):
36
65
  return {
37
- "type": "computer_use_preview",
38
- "display_width": self.computer.dimensions[0],
39
- "display_height": self.computer.dimensions[1],
40
- "environment": self.computer.environment,
41
- }
66
+ "computer_call" : self.handle_computer_call
67
+ }
42
68
 
43
- async def execute(self, context: ToolContext, *, arguments):
69
+ async def handle_computer_call(self, context: ToolContext, **arguments):
44
70
 
45
- nonlocal started
46
- if started == False:
47
- await self.computer.__aenter__()
48
- started = True
49
-
50
-
51
71
  outputs = await operator.play(computer=self.computer, item=arguments)
52
72
  for output in outputs:
53
73
  if output["type"] == "computer_call_output":
@@ -69,7 +89,7 @@ def make_computer_toolkit(*, operator_cls: Type[Operator], computer_cls: Type[Co
69
89
  ScreenshotTool(computer=computer),
70
90
  GotoURL(computer=computer),
71
91
  ])
72
- return RawOutputs(outputs=outputs)
92
+ return outputs[0]
73
93
 
74
94
  class ScreenshotTool(Tool):
75
95
  def __init__(self, computer: Computer):
@@ -97,11 +117,6 @@ def make_computer_toolkit(*, operator_cls: Type[Operator], computer_cls: Type[Co
97
117
 
98
118
 
99
119
  async def execute(self, context: ToolContext, save_path: str, full_page: bool):
100
- nonlocal started
101
- if started == False:
102
- await self.computer.__aenter__()
103
- started = True
104
-
105
120
  screenshot_bytes = await self.computer.screenshot_bytes(full_page=full_page)
106
121
  handle = await context.room.storage.open(path=save_path, overwrite=True)
107
122
  await context.room.storage.write(handle=handle, data=screenshot_bytes)
@@ -132,10 +147,7 @@ def make_computer_toolkit(*, operator_cls: Type[Operator], computer_cls: Type[Co
132
147
 
133
148
 
134
149
  async def execute(self, context: ToolContext, url: str):
135
- nonlocal started
136
- if started == False:
137
- await self.computer.__aenter__()
138
- started = True
150
+
139
151
 
140
152
  if url.startswith("https://") == False and url.startswith("http://") == False:
141
153
  url = "https://"+url
@@ -147,7 +159,7 @@ def make_computer_toolkit(*, operator_cls: Type[Operator], computer_cls: Type[Co
147
159
 
148
160
  computer_tool = ComputerTool(computer=computer, operator=operator)
149
161
 
150
- computer_toolkit = Toolkit(name="meshagent.openai.computer", tools=[
162
+ computer_toolkit = ComputerToolkit(name="meshagent.openai.computer", computer=computer, operator=operator, tools=[
151
163
  computer_tool
152
164
  ])
153
165
 
@@ -191,6 +203,8 @@ class ComputerAgent(ChatBot):
191
203
  self.operator_cls = operator_cls
192
204
 
193
205
 
206
+
207
+
194
208
  async def get_thread_toolkits(self, *, thread_context: ChatThreadContext, participant: RemoteParticipant):
195
209
 
196
210
  toolkits = await super().get_thread_toolkits(thread_context=thread_context, participant=participant)
@@ -210,6 +224,12 @@ class ComputerAgent(ChatBot):
210
224
  computer_cls=self.computer_cls,
211
225
  render_screen=render_screen
212
226
  )
227
+
228
+ await computer_toolkit.ensure_started()
229
+
230
+ await computer_toolkit.computer.goto("https://www.flutterconusa.dev/agenda")
231
+
232
+
213
233
  return [
214
234
  computer_toolkit,
215
235
  *toolkits
@@ -1 +1 @@
1
- __version__ = "0.0.32"
1
+ __version__ = "0.0.33"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meshagent-computers
3
- Version: 0.0.32
3
+ Version: 0.0.33
4
4
  Summary: Computer Building Blocks for Meshagent
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Documentation, https://docs.meshagent.com
@@ -12,9 +12,9 @@ License-File: LICENSE
12
12
  Requires-Dist: pytest~=8.3.5
13
13
  Requires-Dist: pytest-asyncio~=0.26.0
14
14
  Requires-Dist: openai~=1.86.0
15
- Requires-Dist: meshagent-api~=0.0.32
16
- Requires-Dist: meshagent-agents~=0.0.32
17
- Requires-Dist: meshagent-tools~=0.0.32
15
+ Requires-Dist: meshagent-api~=0.0.33
16
+ Requires-Dist: meshagent-agents~=0.0.33
17
+ Requires-Dist: meshagent-tools~=0.0.33
18
18
  Requires-Dist: playwright~=1.51.0
19
19
  Requires-Dist: browserbase~=1.2.0
20
20
  Requires-Dist: scrapybara~=2.4.7
@@ -1,5 +1,5 @@
1
1
  meshagent/computers/__init__.py,sha256=PEzgkWE_sB6TrBA8crwWM7QaNPYWJisCKT81tk6pepQ,321
2
- meshagent/computers/agent.py,sha256=XNmAfkt5p67PJAXGXW3gJQHn4OkzbHJ5Bzk9j3EoqJc,8288
2
+ meshagent/computers/agent.py,sha256=9VD_oFVqb4ksfEhq0IEx2hu2f2d3p7GexVSBn6srJ9c,8769
3
3
  meshagent/computers/base_playwright.py,sha256=NhQoOzWmekBmobQ2kvN7w4I3hZeyMIuMKI2eHbG1_mk,6017
4
4
  meshagent/computers/browserbase.py,sha256=ZT-ZDndkBD-MHD3UjxXpwpx7-_VCkkanjW1rIJr7-98,8161
5
5
  meshagent/computers/computer.py,sha256=465GKDV3cJgzp1SB5B0xzLoftMKU0AxAuBVrZ9drBBc,1072
@@ -8,9 +8,9 @@ meshagent/computers/local_playwright.py,sha256=W7VhxIYEXn2BO3wZZVsc-hH-CU7NTssxF
8
8
  meshagent/computers/operator.py,sha256=JTyGvoPnKOqUDaZv58p_2n5Q6m6dm8V214VMIhVEu08,2913
9
9
  meshagent/computers/scrapybara.py,sha256=IoeV02QcBDkpW05A1NH-lc4jnBEmZ4SPsRo3nnXC3UE,7502
10
10
  meshagent/computers/utils.py,sha256=N7Ltjx3HfhJ-CYectNodGsBtddk6mSTHkCH0meqHT70,2080
11
- meshagent/computers/version.py,sha256=Yq1_Y0B3QxNEYpyakCBsRQ3wcIEwMrDY8dSH-jaBKa8,22
12
- meshagent_computers-0.0.32.dist-info/licenses/LICENSE,sha256=eTt0SPW-sVNdkZe9PS_S8WfCIyLjRXRl7sUBWdlteFg,10254
13
- meshagent_computers-0.0.32.dist-info/METADATA,sha256=_t--fw7clfBLnJIafvXQkxGgKonUCfJqvRNEA4Xv4Sw,740
14
- meshagent_computers-0.0.32.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- meshagent_computers-0.0.32.dist-info/top_level.txt,sha256=GlcXnHtRP6m7zlG3Df04M35OsHtNXy_DY09oFwWrH74,10
16
- meshagent_computers-0.0.32.dist-info/RECORD,,
11
+ meshagent/computers/version.py,sha256=OVBfA7gV0WEUFOPlDpSwglGiTHQIokMTgkKEviraGo8,22
12
+ meshagent_computers-0.0.33.dist-info/licenses/LICENSE,sha256=eTt0SPW-sVNdkZe9PS_S8WfCIyLjRXRl7sUBWdlteFg,10254
13
+ meshagent_computers-0.0.33.dist-info/METADATA,sha256=KLx98GCsz3ZVqPlaG1vtwDle_5uZc4G7ATTtiSWcydQ,740
14
+ meshagent_computers-0.0.33.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ meshagent_computers-0.0.33.dist-info/top_level.txt,sha256=GlcXnHtRP6m7zlG3Df04M35OsHtNXy_DY09oFwWrH74,10
16
+ meshagent_computers-0.0.33.dist-info/RECORD,,