atbash-hermes-plugin 0.1.1__tar.gz → 0.1.3.dev0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atbash-hermes-plugin
3
- Version: 0.1.1
3
+ Version: 0.1.3.dev0
4
4
  Summary: Atbash safety plugin for Hermes Agent
5
5
  Author: atbash
6
6
  License-Expression: LicenseRef-Atbash-Proprietary
@@ -10,7 +10,7 @@ Keywords: atbash,hermes,hermes-agent,agent-safety,ai-safety,tool-guard,judge,pol
10
10
  Requires-Python: >=3.10
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
- Requires-Dist: atbash-sdk==0.1.3
13
+ Requires-Dist: atbash-sdk==0.1.3.dev0
14
14
  Dynamic: license-file
15
15
 
16
16
  # Atbash Hermes Plugin
@@ -136,6 +136,20 @@ def _extract_reason(raw: Any) -> str:
136
136
  return str(raw)
137
137
 
138
138
 
139
+ def _safe_json_value(value: Any) -> Any:
140
+ if value is None or isinstance(value, (str, int, float, bool)):
141
+ return value
142
+ if isinstance(value, dict):
143
+ return {
144
+ str(k): _safe_json_value(v)
145
+ for k, v in value.items()
146
+ if isinstance(k, (str, int, float, bool))
147
+ }
148
+ if isinstance(value, (list, tuple, set)):
149
+ return [_safe_json_value(v) for v in value]
150
+ return str(value)
151
+
152
+
139
153
  class AtbashHermesGuard:
140
154
  def __init__(self) -> None:
141
155
  self.debug = _as_bool(os.getenv("ATBASH_DEBUG"), False)
@@ -195,9 +209,22 @@ class AtbashHermesGuard:
195
209
  fail_closed=self.fail_closed,
196
210
  )
197
211
 
198
- def _judge(self, tool_name: str, tool_args: Dict[str, Any], session_id: str = "", task_id: str = "", tool_call_id: str = "") -> Any:
212
+ def _judge(
213
+ self,
214
+ tool_name: str,
215
+ tool_args: Dict[str, Any],
216
+ session_id: str = "",
217
+ task_id: str = "",
218
+ tool_call_id: str = "",
219
+ hook_context: Dict[str, Any] | None = None,
220
+ ) -> Any:
199
221
  action_class = self._action_class(tool_name)
200
222
  command = _extract_command(tool_name, tool_args or {})
223
+ extra_context = {
224
+ str(k): _safe_json_value(v)
225
+ for k, v in (hook_context or {}).items()
226
+ if v is not None
227
+ }
201
228
 
202
229
  # Mirror OpenClaw plugin semantics: pass toolName + full args.
203
230
  # Keep context concise but informative; args already carry command/body.
@@ -210,6 +237,7 @@ class AtbashHermesGuard:
210
237
  "tool_call_id": tool_call_id or None,
211
238
  "command": command or None,
212
239
  "cwd": os.getcwd(),
240
+ "hermes": extra_context or None,
213
241
  },
214
242
  ensure_ascii=True,
215
243
  )
@@ -228,9 +256,25 @@ class AtbashHermesGuard:
228
256
  )
229
257
  )
230
258
 
231
- def pre_tool_call(self, *, tool_name: str = "", args: Dict[str, Any] | None = None, task_id: str = "", session_id: str = "", tool_call_id: str = ""):
259
+ def pre_tool_call(
260
+ self,
261
+ *,
262
+ tool_name: str = "",
263
+ args: Dict[str, Any] | None = None,
264
+ task_id: str = "",
265
+ session_id: str = "",
266
+ tool_call_id: str = "",
267
+ **hook_context: Any,
268
+ ):
232
269
  if self.debug:
233
- logger.info("Atbash pre_tool_call enter tool=%s session_id=%s task_id=%s tool_call_id=%s", tool_name, session_id, task_id, tool_call_id)
270
+ logger.info(
271
+ "Atbash pre_tool_call enter tool=%s session_id=%s task_id=%s tool_call_id=%s extra_keys=%s",
272
+ tool_name,
273
+ session_id,
274
+ task_id,
275
+ tool_call_id,
276
+ sorted(hook_context.keys()),
277
+ )
234
278
  try:
235
279
  verdict_raw = self._judge(
236
280
  tool_name=tool_name,
@@ -238,6 +282,7 @@ class AtbashHermesGuard:
238
282
  session_id=session_id,
239
283
  task_id=task_id,
240
284
  tool_call_id=tool_call_id,
285
+ hook_context=hook_context,
241
286
  )
242
287
  verdict = _normalize_verdict(verdict_raw)
243
288
  reason = _extract_reason(verdict_raw)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atbash-hermes-plugin
3
- Version: 0.1.1
3
+ Version: 0.1.3.dev0
4
4
  Summary: Atbash safety plugin for Hermes Agent
5
5
  Author: atbash
6
6
  License-Expression: LicenseRef-Atbash-Proprietary
@@ -10,7 +10,7 @@ Keywords: atbash,hermes,hermes-agent,agent-safety,ai-safety,tool-guard,judge,pol
10
10
  Requires-Python: >=3.10
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
- Requires-Dist: atbash-sdk==0.1.3
13
+ Requires-Dist: atbash-sdk==0.1.3.dev0
14
14
  Dynamic: license-file
15
15
 
16
16
  # Atbash Hermes Plugin
@@ -0,0 +1 @@
1
+ atbash-sdk==0.1.3.dev0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "atbash-hermes-plugin"
7
- version = "0.1.1"
7
+ version = "0.1.3.dev0"
8
8
  description = "Atbash safety plugin for Hermes Agent"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -24,7 +24,7 @@ keywords = [
24
24
  "policy"
25
25
  ]
26
26
  dependencies = [
27
- "atbash-sdk==0.1.3"
27
+ "atbash-sdk==0.1.3.dev0"
28
28
  ]
29
29
 
30
30
  [project.urls]
@@ -1 +0,0 @@
1
- atbash-sdk==0.1.3