- 新增 pam_deploy_graph 包,包含 agent、action router、runner、parser 和配置加载能力 - 支持 hybrid_node_mcp 路由策略:PAM_HOME 走脚本 action,PAM_NODE 走 MCP - 新增 fake runner 和 CLI 预演/全局流程验证入口 - 新增路由、输出解析、配置加载、脚本命令构造、Skill 策略加载测试 - 在 README 中记录当前代码骨架、实现进度、使用方式和下一步建议
45 lines
1.7 KiB
Python
45 lines
1.7 KiB
Python
"""Fake action runner for graph and agent tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from .models import ActionResult
|
|
|
|
|
|
class FakeActionRunner:
|
|
def __init__(self, fixtures: dict[str, dict[str, Any]] | None = None) -> None:
|
|
self.fixtures = fixtures or {}
|
|
self.calls: list[tuple[str, dict[str, Any]]] = []
|
|
|
|
def run(self, action: str, *, params: dict[str, Any], **kwargs: Any) -> ActionResult:
|
|
self.calls.append((action, kwargs))
|
|
values = self.fixtures.get(action, {}).copy()
|
|
if not values:
|
|
values = self._default_values(action, kwargs)
|
|
ok = not values.pop("_fail", False)
|
|
return ActionResult(
|
|
action=action,
|
|
backend="fake",
|
|
tool_name=f"fake:{action}",
|
|
ok=ok,
|
|
values=values,
|
|
exit_code=0 if ok else 1,
|
|
raw_output=str(values),
|
|
error_summary="" if ok else str(values.get("MESSAGE", "Fake action failed")),
|
|
)
|
|
|
|
def _default_values(self, action: str, kwargs: dict[str, Any]) -> dict[str, Any]:
|
|
if action == "get-token":
|
|
return {"ACTION": action, "TOKEN": "***"}
|
|
if action == "upload-package":
|
|
return {"ACTION": action, "HASH_CODE": "fake-hash"}
|
|
if action == "get-node-url":
|
|
return {"ACTION": action, "NODE_URL": "https://fake-node.local"}
|
|
if action == "get-online-ips":
|
|
return {"ACTION": action, "COUNT": "2", "IP": ["192.168.1.10", "192.168.1.11"]}
|
|
if action == "download-log":
|
|
return {"ACTION": action, "IP": kwargs.get("ip", ""), "LOG_FILE": "logs/fake.zip"}
|
|
return {"ACTION": action, "RESULT": "OK"}
|
|
|