meshagent-agents 0.2.1__py3-none-any.whl → 0.3.0__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-agents might be problematic. Click here for more details.

meshagent/agents/agent.py CHANGED
@@ -222,22 +222,16 @@ class SingleRoomAgent(Agent):
222
222
  if requirement.name not in schemas_by_name:
223
223
  installed = True
224
224
 
225
- schema_path = f".schemas/{requirement.name}.json"
225
+ logger.info(f"Installing required schema {requirement.name}")
226
226
 
227
- if await self._room.storage.exists(path=schema_path):
228
- # Schema is already in the room
229
- pass
227
+ if requirement.name.startswith("https://"):
228
+ url = requirement.name
230
229
  else:
231
- logger.info(f"Installing required tool {requirement.name}")
230
+ url = f"{meshagent_base_url()}/schemas/{requirement.name}"
232
231
 
233
- if requirement.name.startswith("https://"):
234
- url = requirement.name
235
- else:
236
- url = f"{meshagent_base_url()}/schemas/{requirement.name}"
237
-
238
- await self._room.agents.make_call(
239
- url=url, name=requirement.name, arguments={}
240
- )
232
+ await self._room.agents.make_call(
233
+ url=url, name=requirement.name, arguments={}
234
+ )
241
235
 
242
236
  else:
243
237
  raise RoomException("unsupported requirement")
meshagent/agents/chat.py CHANGED
@@ -11,7 +11,7 @@ from meshagent.api import (
11
11
  )
12
12
  from meshagent.tools import Toolkit, ToolContext
13
13
  from .adapter import LLMAdapter, ToolResponseAdapter
14
- from meshagent.openai.tools.responses_adapter import ImageGenerationTool
14
+ from meshagent.openai.tools.responses_adapter import ImageGenerationTool, LocalShellTool
15
15
  import asyncio
16
16
  from typing import Optional
17
17
  import logging
@@ -24,12 +24,55 @@ from openai.types.responses import ResponseStreamEvent
24
24
  from asyncio import CancelledError
25
25
 
26
26
  from opentelemetry import trace
27
+ import shlex
27
28
 
28
29
  tracer = trace.get_tracer("meshagent.chatbot")
29
30
 
30
31
  logger = logging.getLogger("chat")
31
32
 
32
33
 
34
+ class ChatBotThreadLocalShellTool(LocalShellTool):
35
+ def __init__(self, *, thread_context: "ChatThreadContext"):
36
+ super().__init__()
37
+ self.thread_context = thread_context
38
+
39
+ async def execute_shell_command(
40
+ self,
41
+ context,
42
+ *,
43
+ command,
44
+ env,
45
+ type,
46
+ timeout_ms=None,
47
+ user=None,
48
+ working_directory=None,
49
+ ):
50
+ messages = None
51
+
52
+ for prop in self.thread_context.thread.root.get_children():
53
+ if prop.tag_name == "messages":
54
+ messages = prop
55
+
56
+ exec_element = messages.append_child(
57
+ tag_name="exec",
58
+ attributes={"command": shlex.join(command), "pwd": working_directory},
59
+ )
60
+
61
+ result = await super().execute_shell_command(
62
+ context,
63
+ command=command,
64
+ env=env,
65
+ type=type,
66
+ timeout_ms=timeout_ms,
67
+ user=user,
68
+ working_directory=working_directory,
69
+ )
70
+
71
+ exec_element.set_attribute("result", result)
72
+
73
+ return result
74
+
75
+
33
76
  class ChatBotThreadOpenAIImageGenerationTool(ImageGenerationTool):
34
77
  def __init__(
35
78
  self,
@@ -188,6 +231,7 @@ class ChatThreadContext:
188
231
  *,
189
232
  chat: AgentChatContext,
190
233
  thread: MeshDocument,
234
+ path: str,
191
235
  participants: Optional[list[RemoteParticipant]] = None,
192
236
  ):
193
237
  self.thread = thread
@@ -196,6 +240,7 @@ class ChatThreadContext:
196
240
 
197
241
  self.participants = participants
198
242
  self.chat = chat
243
+ self.path = path
199
244
 
200
245
 
201
246
  # todo: thread should stop when participant stops?
@@ -500,7 +545,10 @@ class ChatBot(SingleRoomAgent):
500
545
  doc_messages = prop
501
546
 
502
547
  for element in doc_messages.get_children():
503
- if isinstance(element, Element):
548
+ if (
549
+ isinstance(element, Element)
550
+ and element.tag_name == "message"
551
+ ):
504
552
  msg = element["text"]
505
553
  if (
506
554
  element["author_name"]
@@ -608,12 +656,17 @@ class ChatBot(SingleRoomAgent):
608
656
  try:
609
657
  if thread_context is None:
610
658
  thread_context = ChatThreadContext(
659
+ path=path,
611
660
  chat=chat_context,
612
661
  thread=thread,
613
662
  participants=get_thread_participants(
614
663
  room=self.room, thread=thread
615
664
  ),
616
665
  )
666
+ else:
667
+ thread_context.participants = get_thread_participants(
668
+ room=self.room, thread=thread
669
+ )
617
670
 
618
671
  def handle_event(evt):
619
672
  llm_messages.send_nowait(evt)
@@ -35,7 +35,7 @@ thread_schema = MeshSchema(
35
35
  properties=[
36
36
  ChildProperty(
37
37
  name="items",
38
- child_tag_names=["message"],
38
+ child_tag_names=["message", "exec"],
39
39
  description="the messages in this thread",
40
40
  )
41
41
  ],
@@ -66,6 +66,27 @@ thread_schema = MeshSchema(
66
66
  ),
67
67
  ],
68
68
  ),
69
+ ElementType(
70
+ tag_name="exec",
71
+ description="a command execution",
72
+ properties=[
73
+ ValueProperty(
74
+ name="command",
75
+ description="a command that was executed",
76
+ type="string",
77
+ ),
78
+ ValueProperty(
79
+ name="result",
80
+ description="the result of the command",
81
+ type="string",
82
+ ),
83
+ ValueProperty(
84
+ name="pwd",
85
+ description="the working directory the command was executed in",
86
+ type="string",
87
+ ),
88
+ ],
89
+ ),
69
90
  ElementType(
70
91
  tag_name="message",
71
92
  description="a message sent in the conversation",
@@ -1 +1 @@
1
- __version__ = "0.2.1"
1
+ __version__ = "0.3.0"
@@ -95,31 +95,42 @@ class Worker(SingleRoomAgent):
95
95
  *self._toolkits,
96
96
  ]
97
97
 
98
+ backoff = 0
98
99
  while not self._done:
99
- message = await room.queues.receive(
100
- name=self._queue, create=True, wait=True
101
- )
102
- if message is not None:
103
- logger.info(f"received message on worker queue {message}")
104
- try:
105
- chat_context = await self.init_chat_context()
106
-
107
- chat_context.append_rules(
108
- rules=[
109
- *self._rules,
110
- ]
111
- )
112
-
113
- await self.append_message_context(
114
- room=room, message=message, chat_context=chat_context
115
- )
116
-
117
- await self.process_message(
118
- chat_context=chat_context,
119
- room=room,
120
- message=message,
121
- toolkits=toolkits,
122
- )
123
-
124
- except Exception as e:
125
- logger.error(f"Failed to process a message {message}", exc_info=e)
100
+ try:
101
+ message = await room.queues.receive(
102
+ name=self._queue, create=True, wait=True
103
+ )
104
+ backoff = 0
105
+ if message is not None:
106
+ logger.info(f"received message on worker queue {message}")
107
+ try:
108
+ chat_context = await self.init_chat_context()
109
+
110
+ chat_context.append_rules(
111
+ rules=[
112
+ *self._rules,
113
+ ]
114
+ )
115
+
116
+ await self.append_message_context(
117
+ room=room, message=message, chat_context=chat_context
118
+ )
119
+
120
+ await self.process_message(
121
+ chat_context=chat_context,
122
+ room=room,
123
+ message=message,
124
+ toolkits=toolkits,
125
+ )
126
+
127
+ except Exception as e:
128
+ logger.error(f"Failed to process: {e}\n{message}", exc_info=e)
129
+
130
+ except Exception as e:
131
+ logger.error(
132
+ f"Worker error while receiving: {e}, will retry", exc_info=e
133
+ )
134
+
135
+ asyncio.sleep(0.1 * pow(2, backoff))
136
+ backoff = backoff + 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meshagent-agents
3
- Version: 0.2.1
3
+ Version: 0.3.0
4
4
  Summary: Agent Building Blocks for Meshagent
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Documentation, https://docs.meshagent.com
@@ -12,19 +12,19 @@ License-File: LICENSE
12
12
  Requires-Dist: pyjwt~=2.10
13
13
  Requires-Dist: pytest~=8.4
14
14
  Requires-Dist: pytest-asyncio~=0.26
15
- Requires-Dist: meshagent-api~=0.2.1
16
- Requires-Dist: meshagent-tools~=0.2.1
17
- Requires-Dist: meshagent-openai~=0.2.1
15
+ Requires-Dist: meshagent-api~=0.3.0
16
+ Requires-Dist: meshagent-tools~=0.3.0
17
+ Requires-Dist: meshagent-openai~=0.3.0
18
18
  Requires-Dist: pydantic~=2.11
19
19
  Requires-Dist: opentelemetry-distro~=0.54b1
20
20
  Provides-Extra: all
21
- Requires-Dist: meshagent-api[all]~=0.2.1; extra == "all"
21
+ Requires-Dist: meshagent-api[all]~=0.3.0; extra == "all"
22
22
  Requires-Dist: chonkie~=0.5.1; extra == "all"
23
23
  Requires-Dist: chonkie[semantic]~=0.5.1; extra == "all"
24
24
  Requires-Dist: chonkie[openai]~=0.5.1; extra == "all"
25
25
  Requires-Dist: aiosmtplib~=4.0.1; extra == "all"
26
26
  Provides-Extra: sync
27
- Requires-Dist: meshagent-api[sync]~=0.2.1; extra == "sync"
27
+ Requires-Dist: meshagent-api[sync]~=0.3.0; extra == "sync"
28
28
  Provides-Extra: mail
29
29
  Requires-Dist: aiosmtplib~=4.0.1; extra == "mail"
30
30
  Provides-Extra: rag
@@ -1,7 +1,7 @@
1
1
  meshagent/agents/__init__.py,sha256=d2cplyLH8xqDWqP_GoPQ8ApHzuv8Iiq4rz-vYBlGMTw,706
2
2
  meshagent/agents/adapter.py,sha256=CZgVzUTTY8dyPBYA7O_Kaawb40maxAbUUhBFk1YjbsI,1386
3
- meshagent/agents/agent.py,sha256=bBEMlI2E0P97gkP93J68o9XvIxtTB_bEiFXSrRH3iyk,20623
4
- meshagent/agents/chat.py,sha256=5yxzs1KkWigv1H5LXWjSqO5eX90LYSYlN8eruJOxI_Q,29011
3
+ meshagent/agents/agent.py,sha256=OaWjjccOsU_n-Pr6WdA90LePGQflHQlL-X5lJ72s3pc,20337
4
+ meshagent/agents/chat.py,sha256=HocrfVSV6kJaNUG5umKhi22AKwyq0ySCfVM--7ytjtE,30595
5
5
  meshagent/agents/context.py,sha256=6txCXA22aHQaikvIKED6YjPyasM_bPqGqCE4HGj04_E,4035
6
6
  meshagent/agents/development.py,sha256=AEBkkycNZDRLYIdmX2LkrVZv715ALswiwSR9CiV3HE4,894
7
7
  meshagent/agents/hosting.py,sha256=tCcswAweEhlMxGaBR_m2YvUkwZiaHbTBT64urRHfK7I,5446
@@ -12,10 +12,10 @@ meshagent/agents/planning.py,sha256=69HLEkOR_24mZ1mcUCQVX_DgPfX5TVA7EJYCHENH6M0,
12
12
  meshagent/agents/prompt.py,sha256=OSSqbzaugyQtuvYxTY5UcZQWyeV73e3GUJz_iC5xZkA,1883
13
13
  meshagent/agents/pydantic.py,sha256=RrdOESZg-n_FyxbfkOBwRPVxV39IOjxK2unsyAGn9as,6278
14
14
  meshagent/agents/single_shot_writer.py,sha256=miWVMo4NX8Hib0yHwDmiwuk8GraJwg1JzljsgFyTl4Y,3237
15
- meshagent/agents/thread_schema.py,sha256=c6KuLhcBxjxcz8M5NQzmmlyJLqv8RB7W491uWOu6Z34,3485
15
+ meshagent/agents/thread_schema.py,sha256=OGQ-H5c2fJgNOYHC3Pas8iqTi2RUSxP2bytf0SK-SYc,4208
16
16
  meshagent/agents/utils.py,sha256=6D9GXpYu9xx5XlfD3DiGFdyOwq46e5-sTYOF_FYep1o,1446
17
- meshagent/agents/version.py,sha256=HfjVOrpTnmZ-xVFCYSVmX50EXaBQeJteUHG-PD6iQs8,22
18
- meshagent/agents/worker.py,sha256=6-SDWm-4aqlx9G8321g1lS0caZUybBpJRhrg5jxqTy8,3500
17
+ meshagent/agents/version.py,sha256=VrXpHDu3erkzwl_WXrqINBm9xWkcyUy53IQOj042dOs,22
18
+ meshagent/agents/worker.py,sha256=SkrPhxIQ-Chyjg-eZGOlehkbrVYmsas8zmZnrTsAl3o,3910
19
19
  meshagent/agents/writer.py,sha256=dXglYgHwBrBJIaapMqBDyD3kmwSyi94tOdHH44itODc,2682
20
20
  meshagent/agents/schemas/__init__.py,sha256=_xAhrkxvFdfer3NolrynragGxcLElGR51LSribT3deU,299
21
21
  meshagent/agents/schemas/document.py,sha256=H-aolubkRHdTAH-rLI2SJ8y3JKwXvpNsR3ZCqghwAWI,1515
@@ -23,8 +23,8 @@ meshagent/agents/schemas/gallery.py,sha256=65IsrH2wiFIR-DNo8est-nCOC72i1Aa5EmVNU
23
23
  meshagent/agents/schemas/presentation.py,sha256=aaMzkFQryurbHd1fbzTQPdN7v8QIhsjXuvbE8ZiuXNY,1589
24
24
  meshagent/agents/schemas/schema.py,sha256=8OXGCLVouoPg6eHBU9mgf1pTGTMvVZqiKNq15wkQJe0,5310
25
25
  meshagent/agents/schemas/super_editor_document.py,sha256=iRv4Q-DE_5kUdsAD5Rm4GwHek8L_7ZEpxIZ1x2dWjdg,1813
26
- meshagent_agents-0.2.1.dist-info/licenses/LICENSE,sha256=eTt0SPW-sVNdkZe9PS_S8WfCIyLjRXRl7sUBWdlteFg,10254
27
- meshagent_agents-0.2.1.dist-info/METADATA,sha256=PC-rIb3FIcHnjYuB2BENas60n4t3iX3EvEzLDM-YSx4,3731
28
- meshagent_agents-0.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
- meshagent_agents-0.2.1.dist-info/top_level.txt,sha256=GlcXnHtRP6m7zlG3Df04M35OsHtNXy_DY09oFwWrH74,10
30
- meshagent_agents-0.2.1.dist-info/RECORD,,
26
+ meshagent_agents-0.3.0.dist-info/licenses/LICENSE,sha256=eTt0SPW-sVNdkZe9PS_S8WfCIyLjRXRl7sUBWdlteFg,10254
27
+ meshagent_agents-0.3.0.dist-info/METADATA,sha256=nXgORIGmwE3_q96I34Y2i4d8HKs7RRvOf_F6OY4lHP0,3731
28
+ meshagent_agents-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
29
+ meshagent_agents-0.3.0.dist-info/top_level.txt,sha256=GlcXnHtRP6m7zlG3Df04M35OsHtNXy_DY09oFwWrH74,10
30
+ meshagent_agents-0.3.0.dist-info/RECORD,,