fix: harden Python hook command detection
This commit is contained in:
1 parent
12b28f2166
commit
dce36cc9dd
4 files changed
+44
-21
No files matched your search
@@ -174,16 +174,16 @@ class ClaudeCodePlugin(AgentPlugin):
|
||||
|
||||
def _is_elydora_hook(entry: dict, agent_id: str = "") -> bool:
|
||||
# Collect all command strings from the entry
|
||||
commands = []
|
||||
commands: list[str] = []
|
||||
inner_hooks = entry.get("hooks")
|
||||
if isinstance(inner_hooks, list):
|
||||
commands.extend(
|
||||
h.get("command", "")
|
||||
for h in inner_hooks
|
||||
if isinstance(h, dict)
|
||||
)
|
||||
for hook in inner_hooks:
|
||||
if isinstance(hook, dict) and isinstance(hook.get("command"), str):
|
||||
commands.append(hook["command"])
|
||||
else:
|
||||
commands.append(entry.get("command", ""))
|
||||
command = entry.get("command")
|
||||
if isinstance(command, str):
|
||||
commands.append(command)
|
||||
|
||||
for cmd in commands:
|
||||
cmd_lower = cmd.lower()
|
||||
|
||||
@@ -170,16 +170,16 @@ class GeminiPlugin(AgentPlugin):
|
||||
|
||||
def _is_elydora_hook(entry: dict, agent_id: str = "") -> bool:
|
||||
# Collect all command strings from the entry
|
||||
commands = []
|
||||
commands: list[str] = []
|
||||
inner_hooks = entry.get("hooks")
|
||||
if isinstance(inner_hooks, list):
|
||||
commands.extend(
|
||||
h.get("command", "")
|
||||
for h in inner_hooks
|
||||
if isinstance(h, dict)
|
||||
)
|
||||
for hook in inner_hooks:
|
||||
if isinstance(hook, dict) and isinstance(hook.get("command"), str):
|
||||
commands.append(hook["command"])
|
||||
else:
|
||||
commands.append(entry.get("command", ""))
|
||||
command = entry.get("command")
|
||||
if isinstance(command, str):
|
||||
commands.append(command)
|
||||
|
||||
for cmd in commands:
|
||||
cmd_lower = cmd.lower()
|
||||
|
||||
@@ -172,16 +172,16 @@ class LettaPlugin(AgentPlugin):
|
||||
|
||||
def _is_elydora_hook(entry: dict, agent_id: str = "") -> bool:
|
||||
# Collect all command strings from the entry
|
||||
commands = []
|
||||
commands: list[str] = []
|
||||
inner_hooks = entry.get("hooks")
|
||||
if isinstance(inner_hooks, list):
|
||||
commands.extend(
|
||||
h.get("command", "")
|
||||
for h in inner_hooks
|
||||
if isinstance(h, dict)
|
||||
)
|
||||
for hook in inner_hooks:
|
||||
if isinstance(hook, dict) and isinstance(hook.get("command"), str):
|
||||
commands.append(hook["command"])
|
||||
else:
|
||||
commands.append(entry.get("command", ""))
|
||||
command = entry.get("command")
|
||||
if isinstance(command, str):
|
||||
commands.append(command)
|
||||
|
||||
for cmd in commands:
|
||||
cmd_lower = cmd.lower()
|
||||
|
||||
Reference in new issue
Block a user