- 新增 pam_deploy_graph 包,包含 Agent runtime、ActionRouter、脚本/MCP/fake runner - 支持 hybrid_node_mcp 策略:PAM_HOME 走脚本 action,PAM_NODE 走 MCP - 支持 script_only 离线策略,全部 action 走现有脚本 action - 新增 LLM structured output 骨架和规则 fallback,支持意图识别、参数抽取、计划生成 - 新增 LangGraph StateGraph 工厂和 MCP client adapter - 新增 CLI:preview、analyze、run-global、run-deploy - 增加 fake 完整部署流程、单 IP 失败待回滚确认状态和报告输出 - 增加单元测试覆盖路由、parser、runner、Skill 加载、LLM 输出、MCP adapter 和 LangGraph 图 - 更新 README,记录当前代码骨架、进度、使用方式和下一步计划
29 lines
934 B
Python
29 lines
934 B
Python
from pam_deploy_graph.mcp_client import (
|
|
FunctionMcpToolClient,
|
|
SessionMcpToolClient,
|
|
normalize_mcp_sdk_result,
|
|
)
|
|
|
|
|
|
def test_function_mcp_client_wraps_callable():
|
|
client = FunctionMcpToolClient(lambda name, args: {"tool": name, "args": args})
|
|
assert client.call_tool("pam_get_online_ips", {"airportCode": "HET"})["tool"] == "pam_get_online_ips"
|
|
|
|
|
|
def test_normalize_mcp_sdk_result_structured_content():
|
|
result = type("Result", (), {"structuredContent": {"ok": True}})()
|
|
assert normalize_mcp_sdk_result(result) == {"ok": True}
|
|
|
|
|
|
def test_session_mcp_client_normalizes_text_json_content():
|
|
content = [type("Text", (), {"text": '{"ok": true}'})()]
|
|
result = type("Result", (), {"content": content})()
|
|
|
|
class Session:
|
|
def call_tool(self, tool_name, arguments):
|
|
return result
|
|
|
|
client = SessionMcpToolClient(Session())
|
|
assert client.call_tool("tool", {}) == {"ok": True}
|
|
|