universal-mcp-agents 0.1.12__py3-none-any.whl → 0.1.13__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.
- universal_mcp/agents/__init__.py +1 -1
- universal_mcp/agents/cli.py +2 -2
- universal_mcp/agents/codeact/agent.py +1 -1
- universal_mcp/agents/codeact/sandbox.py +1 -5
- universal_mcp/agents/shared/tool_node.py +1 -34
- {universal_mcp_agents-0.1.12.dist-info → universal_mcp_agents-0.1.13.dist-info}/METADATA +1 -1
- {universal_mcp_agents-0.1.12.dist-info → universal_mcp_agents-0.1.13.dist-info}/RECORD +8 -10
- universal_mcp/agents/codeact0/langgraph_graph.py +0 -17
- universal_mcp/agents/codeact0/legacy_codeact.py +0 -104
- {universal_mcp_agents-0.1.12.dist-info → universal_mcp_agents-0.1.13.dist-info}/WHEEL +0 -0
universal_mcp/agents/__init__.py
CHANGED
|
@@ -3,8 +3,8 @@ from typing import Literal
|
|
|
3
3
|
from universal_mcp.agents.base import BaseAgent
|
|
4
4
|
from universal_mcp.agents.bigtool import BigToolAgent
|
|
5
5
|
from universal_mcp.agents.builder.builder import BuilderAgent
|
|
6
|
-
from universal_mcp.agents.codeact0 import CodeActAgent as CodeActRepl
|
|
7
6
|
from universal_mcp.agents.codeact import CodeActAgent as CodeActScript
|
|
7
|
+
from universal_mcp.agents.codeact0 import CodeActAgent as CodeActRepl
|
|
8
8
|
from universal_mcp.agents.react import ReactAgent
|
|
9
9
|
from universal_mcp.agents.simple import SimpleAgent
|
|
10
10
|
|
universal_mcp/agents/cli.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
|
|
1
3
|
from langgraph.checkpoint.memory import MemorySaver
|
|
2
4
|
from typer import Typer
|
|
3
5
|
from universal_mcp.agentr.client import AgentrClient
|
|
@@ -6,8 +8,6 @@ from universal_mcp.logger import setup_logger
|
|
|
6
8
|
|
|
7
9
|
from universal_mcp.agents import get_agent
|
|
8
10
|
|
|
9
|
-
import asyncio
|
|
10
|
-
|
|
11
11
|
app = Typer()
|
|
12
12
|
|
|
13
13
|
|
|
@@ -48,7 +48,7 @@ class CodeActAgent(BaseAgent):
|
|
|
48
48
|
memory=memory,
|
|
49
49
|
**kwargs,
|
|
50
50
|
)
|
|
51
|
-
self.model_instance = load_chat_model(model
|
|
51
|
+
self.model_instance = load_chat_model(model)
|
|
52
52
|
self.tools_config = tools or {}
|
|
53
53
|
self.registry = registry
|
|
54
54
|
self.eval_fn = eval_unsafe
|
|
@@ -51,17 +51,13 @@ SAFE_BUILTINS = {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
# (The SAFE_BUILTINS definition remains the same)
|
|
55
|
-
# ...
|
|
56
|
-
|
|
57
|
-
|
|
58
54
|
async def eval_unsafe(
|
|
59
55
|
code: str, _locals: dict[str, Callable], timeout: int = 10
|
|
60
56
|
) -> tuple[SandboxOutput, dict[str, Any]]:
|
|
61
57
|
"""Executes a string of Python code in a sandboxed environment."""
|
|
62
58
|
original_keys = set(_locals.keys())
|
|
63
59
|
execution_context = _locals.copy()
|
|
64
|
-
execution_context["__builtins__"] = SAFE_BUILTINS
|
|
60
|
+
execution_context["__builtins__"] = __builtins__ # TODO: Use SAFE_BUILTINS instead of __builtins__
|
|
65
61
|
|
|
66
62
|
stdout_capture = io.StringIO()
|
|
67
63
|
output = SandboxOutput(stdout="")
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import asyncio
|
|
2
1
|
from typing import Annotated, TypedDict
|
|
3
2
|
|
|
4
3
|
from langchain_core.language_models import BaseChatModel
|
|
5
|
-
from langchain_core.messages import AIMessage, AnyMessage
|
|
4
|
+
from langchain_core.messages import AIMessage, AnyMessage
|
|
6
5
|
from langgraph.graph import END, StateGraph
|
|
7
6
|
from langgraph.graph.message import add_messages
|
|
8
7
|
from loguru import logger
|
|
@@ -226,35 +225,3 @@ def build_tool_node_graph(llm: BaseChatModel, registry: ToolRegistry) -> StateGr
|
|
|
226
225
|
workflow.add_edge("handle_planning_failure", END)
|
|
227
226
|
|
|
228
227
|
return workflow.compile()
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
async def main():
|
|
232
|
-
"""Main function to run the agent."""
|
|
233
|
-
from universal_mcp.agentr.registry import AgentrRegistry
|
|
234
|
-
|
|
235
|
-
from universal_mcp.agents.llm import load_chat_model
|
|
236
|
-
|
|
237
|
-
registry = AgentrRegistry()
|
|
238
|
-
llm = load_chat_model("anthropic/claude-4-sonnet-20250514")
|
|
239
|
-
|
|
240
|
-
graph = build_tool_node_graph(llm, registry)
|
|
241
|
-
|
|
242
|
-
task = "Find my latest order confirmation in Gmail, search for reviews of the main product on perplexity, and then send an email to ankit@agentr.dev telling about the reviews"
|
|
243
|
-
|
|
244
|
-
initial_state = {
|
|
245
|
-
"original_task": task,
|
|
246
|
-
"messages": [HumanMessage(content=task)],
|
|
247
|
-
"decomposition_attempts": 0,
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
final_state = await graph.ainvoke(initial_state)
|
|
251
|
-
|
|
252
|
-
if final_state.get("execution_plan"):
|
|
253
|
-
for step in final_state["execution_plan"]:
|
|
254
|
-
pass
|
|
255
|
-
else:
|
|
256
|
-
pass
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if __name__ == "__main__":
|
|
260
|
-
asyncio.run(main())
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
universal_mcp/agents/__init__.py,sha256=
|
|
1
|
+
universal_mcp/agents/__init__.py,sha256=kM4mC6Pf6lmaaZF1volo7VtKgA8FDyzb1sNenpB7Ulk,1244
|
|
2
2
|
universal_mcp/agents/base.py,sha256=le5vy02eXN15u8ntHWCu6Y-LgOmE_DA8tWmPOmLohAk,6908
|
|
3
|
-
universal_mcp/agents/cli.py,sha256=
|
|
3
|
+
universal_mcp/agents/cli.py,sha256=AG9e4iSX3GazT537573YrYT1wSaZYOr42rrYQ7xP3YA,1016
|
|
4
4
|
universal_mcp/agents/hil.py,sha256=_5PCK6q0goGm8qylJq44aSp2MadP-yCPvhOJYKqWLMo,3808
|
|
5
5
|
universal_mcp/agents/llm.py,sha256=hVRwjZs3MHl5_3BWedmurs2Jt1oZDfFX0Zj9F8KH7fk,1787
|
|
6
6
|
universal_mcp/agents/react.py,sha256=8XQvJ0HLVgc-K0qn9Ml48WGcgUGuIKtL67HatlT6Da0,3334
|
|
@@ -20,18 +20,16 @@ universal_mcp/agents/builder/prompts.py,sha256=RFzDBdGxF5BsAQL09BVas9RjAwt_Q2ZAC
|
|
|
20
20
|
universal_mcp/agents/builder/state.py,sha256=7DeWllxfN-yD6cd9wJ3KIgjO8TctkJvVjAbZT8W_zqk,922
|
|
21
21
|
universal_mcp/agents/codeact/__init__.py,sha256=rLE8gvOo5H4YSr71DRq76b3RV3uuotxuAy_VnBVaVwk,60
|
|
22
22
|
universal_mcp/agents/codeact/__main__.py,sha256=W2cHXRwH1dZG3ETIkMwUqA_d62K3IctHP-FDZWDjxdw,1067
|
|
23
|
-
universal_mcp/agents/codeact/agent.py,sha256=
|
|
23
|
+
universal_mcp/agents/codeact/agent.py,sha256=sKZWokTHcuL68Y6SNyaaHe6_XkWxaIq36TrNmPJfQto,9762
|
|
24
24
|
universal_mcp/agents/codeact/models.py,sha256=2fdAcF5bxWDpljjEwDEdPBflTMShSPwwncHrphRjsYg,222
|
|
25
25
|
universal_mcp/agents/codeact/prompts.py,sha256=EMI-imnd0Ps0Bd2FOvSqgiicvvtFFu0MF9s93PiC_3k,4493
|
|
26
|
-
universal_mcp/agents/codeact/sandbox.py,sha256=
|
|
26
|
+
universal_mcp/agents/codeact/sandbox.py,sha256=NjN6ISj8psFtHf8V0w24ChJdUMUWkq7OrlbHdzm4wBc,2299
|
|
27
27
|
universal_mcp/agents/codeact/state.py,sha256=WTPfpxDlGRnlr5tZuXMg_KU7GS7TZbnrIKslOvZLbQI,565
|
|
28
28
|
universal_mcp/agents/codeact/utils.py,sha256=JUbT_HYGS_D1BzmzoVpORIe7SGur1KgJguTZ_1tZ4JY,1918
|
|
29
29
|
universal_mcp/agents/codeact0/__init__.py,sha256=rLE8gvOo5H4YSr71DRq76b3RV3uuotxuAy_VnBVaVwk,60
|
|
30
30
|
universal_mcp/agents/codeact0/__main__.py,sha256=V2wLWW9ym3rtiSvPEs-N0Mki7G5dYHzV5dAsAoF-ygQ,1148
|
|
31
31
|
universal_mcp/agents/codeact0/agent.py,sha256=e1v_XVRqblKrAgrkyiPz7bs4atgDRTVHPnZQUjnT_4o,6495
|
|
32
32
|
universal_mcp/agents/codeact0/config.py,sha256=H-1woj_nhSDwf15F63WYn723y4qlRefXzGxuH81uYF0,2215
|
|
33
|
-
universal_mcp/agents/codeact0/langgraph_graph.py,sha256=mP3JrZ1I-Cqhk6E2DMRHUdLFevpyyad-Y3qhERn45JA,550
|
|
34
|
-
universal_mcp/agents/codeact0/legacy_codeact.py,sha256=Lj4oH-AaP1zg6ifBkUxzWJcwMs9X5SepGzzZ6S5QMSg,4096
|
|
35
33
|
universal_mcp/agents/codeact0/llm_tool.py,sha256=GEG8L2crRPyO5la_wlHohuqI9m6xH9KXgQxcP5fCFuU,13814
|
|
36
34
|
universal_mcp/agents/codeact0/prompts.py,sha256=GTUwnxyyUVdeAoAwo4ODGOlEtZStMkoP_lJEFRbDglY,7324
|
|
37
35
|
universal_mcp/agents/codeact0/sandbox.py,sha256=tkrhQoV7sAIT5rtd5kpNYEgDz4y82WSHKpMGE6bqthE,3108
|
|
@@ -56,10 +54,10 @@ universal_mcp/agents/planner/graph.py,sha256=70hhIoEZOcYojpiyVSCedgYpnmxVP7aqdn8
|
|
|
56
54
|
universal_mcp/agents/planner/prompts.py,sha256=_JoHqiAvswtqCDu90AGUHmfsu8eWE1-_yI4LLn3pqMU,657
|
|
57
55
|
universal_mcp/agents/planner/state.py,sha256=qqyp-jSGsCxe1US-PRLT4-y1sITAcVE6nCMlQLnvop0,278
|
|
58
56
|
universal_mcp/agents/shared/prompts.py,sha256=VOsXSUEwBXPaAuxJTUF6bgDGr41u6uctUNQSMRt_OJc,6414
|
|
59
|
-
universal_mcp/agents/shared/tool_node.py,sha256=
|
|
57
|
+
universal_mcp/agents/shared/tool_node.py,sha256=KPF_nONfF12BmUTb9stHnxveqL7enGBi7wBGLrOjMsQ,9489
|
|
60
58
|
universal_mcp/applications/llm/__init__.py,sha256=xnpxq4Wl_pevvwtSUtEwcty8_d61ywO1V2YnEXyCREY,46
|
|
61
59
|
universal_mcp/applications/llm/app.py,sha256=iNLU6z2LRZc01GfSKvV0vNzT1LhKAjq_UrSJEmjthjw,6032
|
|
62
60
|
universal_mcp/applications/ui/app.py,sha256=56h9GvkHiELyAVOZvi0YjiowSymlqkJ5GW4O7LmGIPs,9459
|
|
63
|
-
universal_mcp_agents-0.1.
|
|
64
|
-
universal_mcp_agents-0.1.
|
|
65
|
-
universal_mcp_agents-0.1.
|
|
61
|
+
universal_mcp_agents-0.1.13.dist-info/METADATA,sha256=wiruytjCRQN0GSX6yMToFwnIlmqWJPZbdbUOHXpUXJY,878
|
|
62
|
+
universal_mcp_agents-0.1.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
63
|
+
universal_mcp_agents-0.1.13.dist-info/RECORD,,
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
from langgraph.checkpoint.memory import MemorySaver
|
|
2
|
-
from universal_mcp.agentr.registry import AgentrRegistry
|
|
3
|
-
|
|
4
|
-
from universal_mcp.agents.codeact0.agent import CodeActAgent
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
async def agent():
|
|
8
|
-
memory = MemorySaver()
|
|
9
|
-
agent_object = await CodeActAgent(
|
|
10
|
-
name="CodeAct Agent",
|
|
11
|
-
instructions="Be very concise in your answers.",
|
|
12
|
-
model="anthropic:claude-4-sonnet-20250514",
|
|
13
|
-
tools={"google_mail": ["list_messages"]},
|
|
14
|
-
registry=AgentrRegistry(),
|
|
15
|
-
memory=memory,
|
|
16
|
-
)._build_graph()
|
|
17
|
-
return agent_object
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import contextlib
|
|
2
|
-
import inspect
|
|
3
|
-
import io
|
|
4
|
-
import queue
|
|
5
|
-
import re
|
|
6
|
-
import socket
|
|
7
|
-
import threading
|
|
8
|
-
import types
|
|
9
|
-
from typing import Any
|
|
10
|
-
|
|
11
|
-
import yaml
|
|
12
|
-
from langchain.chat_models import init_chat_model
|
|
13
|
-
from langchain_anthropic import ChatAnthropic
|
|
14
|
-
from langchain_core.runnables import RunnableConfig
|
|
15
|
-
from langchain_google_vertexai.model_garden import ChatAnthropicVertex
|
|
16
|
-
from universal_mcp.agentr import Agentr
|
|
17
|
-
from universal_mcp.types import ToolFormat
|
|
18
|
-
|
|
19
|
-
from universal_mcp.agents.codeact0 import create_codeact
|
|
20
|
-
from universal_mcp.agents.codeact0.config import ContextSchema
|
|
21
|
-
from universal_mcp.agents.codeact0.utils import derive_context
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def eval(code: str, _locals: dict[str, Any], add_context: dict[str, Any]) -> tuple[str, dict[str, Any], dict[str, Any]]:
|
|
25
|
-
# print(_locals)
|
|
26
|
-
EXCLUDE_TYPES = (
|
|
27
|
-
types.ModuleType, # modules
|
|
28
|
-
type(re.match("", "")),
|
|
29
|
-
type(threading.Lock()), # instead of threading.Lock
|
|
30
|
-
type(threading.RLock()), # reentrant lock
|
|
31
|
-
threading.Event, # events
|
|
32
|
-
threading.Condition, # condition vars
|
|
33
|
-
threading.Semaphore, # semaphores
|
|
34
|
-
queue.Queue, # thread-safe queues
|
|
35
|
-
socket.socket, # network sockets
|
|
36
|
-
io.IOBase, # file handles (and StringIO/BytesIO)
|
|
37
|
-
)
|
|
38
|
-
try:
|
|
39
|
-
with contextlib.redirect_stdout(io.StringIO()) as f:
|
|
40
|
-
# Execute the code in the provided locals context
|
|
41
|
-
# Using exec to allow dynamic code execution
|
|
42
|
-
# This is a simplified version; in production, consider security implications
|
|
43
|
-
exec(code, _locals, _locals)
|
|
44
|
-
result = f.getvalue()
|
|
45
|
-
if not result:
|
|
46
|
-
result = "<code ran, no output printed to stdout>"
|
|
47
|
-
except Exception as e:
|
|
48
|
-
result = f"Error during execution: {repr(e)}"
|
|
49
|
-
|
|
50
|
-
# Return all variables in locals except __builtins__ and unpicklable objects (including tools)
|
|
51
|
-
all_vars = {}
|
|
52
|
-
for key, value in _locals.items():
|
|
53
|
-
if key == "__builtins__":
|
|
54
|
-
continue
|
|
55
|
-
|
|
56
|
-
# Skip coroutines, async generators, and coroutine functions
|
|
57
|
-
if inspect.iscoroutine(value) or inspect.iscoroutinefunction(value):
|
|
58
|
-
continue
|
|
59
|
-
if inspect.isasyncgen(value) or inspect.isasyncgenfunction(value):
|
|
60
|
-
continue
|
|
61
|
-
|
|
62
|
-
# Skip "obviously unpicklable" types
|
|
63
|
-
if isinstance(value, EXCLUDE_TYPES):
|
|
64
|
-
continue
|
|
65
|
-
|
|
66
|
-
# Keep if it's not a callable OR if it has no __name__ attribute
|
|
67
|
-
if not callable(value) or not hasattr(value, "__name__"):
|
|
68
|
-
all_vars[key] = value
|
|
69
|
-
|
|
70
|
-
new_add_context = derive_context(code, add_context)
|
|
71
|
-
return result, all_vars, new_add_context
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
async def agent(config: RunnableConfig):
|
|
75
|
-
cfg = ContextSchema(**config.get("configurable", {}))
|
|
76
|
-
|
|
77
|
-
if cfg.json_prompt_name and cfg.json_prompt_name.strip():
|
|
78
|
-
with open(f"usecases/{cfg.json_prompt_name}.yaml", encoding="utf-8") as f:
|
|
79
|
-
content = f.read()
|
|
80
|
-
data = yaml.safe_load(content)
|
|
81
|
-
if cfg.base_prompt and cfg.base_prompt.strip():
|
|
82
|
-
pass
|
|
83
|
-
else:
|
|
84
|
-
cfg.base_prompt = data["base_prompt"]
|
|
85
|
-
cfg.tool_names = data["tools"]
|
|
86
|
-
agentr = Agentr()
|
|
87
|
-
agentr.load_tools(cfg.tool_names)
|
|
88
|
-
tools = [] # can add custom tools here like get_weather, get_simple_weather, etc.
|
|
89
|
-
|
|
90
|
-
tools_agentr = agentr.list_tools(format=ToolFormat.NATIVE)
|
|
91
|
-
tools.extend(tools_agentr)
|
|
92
|
-
|
|
93
|
-
if cfg.model_provider == "google_anthropic_vertex":
|
|
94
|
-
# For Google Anthropic Vertex, we need to use the specific model initialization due to location
|
|
95
|
-
model = ChatAnthropicVertex(model=cfg.model, temperature=0.2, location="asia-east1")
|
|
96
|
-
elif cfg.model == "claude-4-sonnet-20250514":
|
|
97
|
-
model = ChatAnthropic(
|
|
98
|
-
model=cfg.model, temperature=1, thinking={"type": "enabled", "budget_tokens": 2048}, max_tokens=4096
|
|
99
|
-
) # pyright: ignore[reportCallIssue]
|
|
100
|
-
else:
|
|
101
|
-
model = init_chat_model(model=cfg.model, model_provider=cfg.model_provider, temperature=0.2)
|
|
102
|
-
|
|
103
|
-
code_act = create_codeact(model, cfg.base_prompt, tools, eval)
|
|
104
|
-
return code_act.compile()
|
|
File without changes
|