@kenhkl/agent-moss 0.12.6 → 0.12.8
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.
- package/dist/agents/__pycache__/base.cpython-312.pyc +0 -0
- package/dist/agents/base.py +41 -4
- package/dist/cli.js +4475 -916
- package/dist/cli.js.map +1 -1
- package/dist/engine/coordinator.d.ts +16 -6
- package/dist/engine/coordinator.js +3378 -708
- package/dist/engine/coordinator.js.map +1 -1
- package/dist/rules/l1_rules.json +21 -0
- package/dist/rules/l2_rules.json +136 -1
- package/dist/scenarios/__init__.py +119 -0
- package/dist/scenarios/__pycache__/__init__.cpython-312.pyc +0 -0
- package/dist/scenarios/bank/rules.json +23 -0
- package/dist/server.js +4180 -742
- package/dist/server.js.map +1 -1
- package/dist/static/index.html +119 -1
- package/package.json +2 -1
- package/dist/skills/brain_script_execution_php_r_system.md +0 -17
- package/dist/skills/brain_script_execution_python_c_import.md +0 -17
|
Binary file
|
package/dist/agents/base.py
CHANGED
|
@@ -59,11 +59,48 @@ class AgentExtensions:
|
|
|
59
59
|
extra_skills: list[dict] = field(default_factory=list)
|
|
60
60
|
|
|
61
61
|
@classmethod
|
|
62
|
-
def
|
|
62
|
+
def merge(cls, *exts: "AgentExtensions | None") -> "AgentExtensions | None":
|
|
63
|
+
"""合并多个 AgentExtensions(如 agent 规则 + 场景规则),追加式拼接各 extra_* 列表。
|
|
64
|
+
|
|
65
|
+
全部为 None 时返回 None(通用模式)。非 None 时以第一个非空实例为骨架,
|
|
66
|
+
其余实例的 extra_* / builtin_safe_* 列表依次追加在后(不覆盖)。
|
|
67
|
+
"""
|
|
68
|
+
non_null = [e for e in exts if e is not None]
|
|
69
|
+
if not non_null:
|
|
70
|
+
return None
|
|
71
|
+
base = non_null[0]
|
|
72
|
+
return cls(
|
|
73
|
+
agent_id=base.agent_id,
|
|
74
|
+
description=base.description,
|
|
75
|
+
extra_command_patterns=[
|
|
76
|
+
p for e in non_null for p in e.extra_command_patterns
|
|
77
|
+
],
|
|
78
|
+
extra_injection_keywords=[
|
|
79
|
+
k for e in non_null for k in e.extra_injection_keywords
|
|
80
|
+
],
|
|
81
|
+
extra_sensitive_paths=[
|
|
82
|
+
sp for e in non_null for sp in e.extra_sensitive_paths
|
|
83
|
+
],
|
|
84
|
+
builtin_safe_skills=[
|
|
85
|
+
s for e in non_null for s in e.builtin_safe_skills
|
|
86
|
+
],
|
|
87
|
+
builtin_safe_action_types=[
|
|
88
|
+
t for e in non_null for t in e.builtin_safe_action_types
|
|
89
|
+
],
|
|
90
|
+
extra_skills=[
|
|
91
|
+
sk for e in non_null for sk in e.extra_skills
|
|
92
|
+
],
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
@classmethod
|
|
96
|
+
def from_json(cls, rules_file: Path, id_key: str = "agent_id") -> "AgentExtensions":
|
|
63
97
|
"""从 rules.json 加载 AgentExtensions。
|
|
64
98
|
|
|
65
99
|
Args:
|
|
66
|
-
rules_file: agent_moss/agents/<id>/rules.json
|
|
100
|
+
rules_file: agent_moss/agents/<id>/rules.json 的绝对路径(场景规则传
|
|
101
|
+
agent_moss/scenarios/<id>/rules.json,id_key="scenario_id")
|
|
102
|
+
id_key: JSON 中的 id 字段名。agent 规则默认 "agent_id";
|
|
103
|
+
场景规则(agent_moss/scenarios/<id>/rules.json)用 "scenario_id"。
|
|
67
104
|
|
|
68
105
|
Returns:
|
|
69
106
|
AgentExtensions 实例
|
|
@@ -74,9 +111,9 @@ class AgentExtensions:
|
|
|
74
111
|
with open(rules_file, "r", encoding="utf-8") as f:
|
|
75
112
|
data = json.load(f)
|
|
76
113
|
|
|
77
|
-
agent_id = data.get(
|
|
114
|
+
agent_id = data.get(id_key, "")
|
|
78
115
|
if not agent_id:
|
|
79
|
-
raise ValueError(f"rules.json 缺少
|
|
116
|
+
raise ValueError(f"rules.json 缺少 {id_key} 字段: {rules_file}")
|
|
80
117
|
|
|
81
118
|
# extra_command_patterns: dict → CommandPattern
|
|
82
119
|
extra_cmd_patterns: list[CommandPattern] = []
|