Open-source release for Alpha version
This commit is contained in:
60
strix/agents/StrixAgent/strix_agent.py
Normal file
60
strix/agents/StrixAgent/strix_agent.py
Normal file
@@ -0,0 +1,60 @@
|
||||
from typing import Any
|
||||
|
||||
from strix.agents.base_agent import BaseAgent
|
||||
from strix.llm.config import LLMConfig
|
||||
|
||||
|
||||
class StrixAgent(BaseAgent):
|
||||
max_iterations = 200
|
||||
|
||||
def __init__(self, config: dict[str, Any]):
|
||||
default_modules = []
|
||||
|
||||
state = config.get("state")
|
||||
if state is None or (hasattr(state, "parent_id") and state.parent_id is None):
|
||||
default_modules = ["root_agent"]
|
||||
|
||||
self.default_llm_config = LLMConfig(prompt_modules=default_modules)
|
||||
|
||||
super().__init__(config)
|
||||
|
||||
async def execute_scan(self, scan_config: dict[str, Any]) -> dict[str, Any]:
|
||||
scan_type = scan_config.get("scan_type", "general")
|
||||
target = scan_config.get("target", {})
|
||||
user_instructions = scan_config.get("user_instructions", "")
|
||||
|
||||
task_parts = []
|
||||
|
||||
if scan_type == "repository":
|
||||
task_parts.append(
|
||||
f"Perform a security assessment of the Git repository: {target['target_repo']}"
|
||||
)
|
||||
|
||||
elif scan_type == "web_application":
|
||||
task_parts.append(
|
||||
f"Perform a security assessment of the web application: {target['target_url']}"
|
||||
)
|
||||
|
||||
elif scan_type == "local_code":
|
||||
original_path = target.get("target_path", "unknown")
|
||||
shared_workspace_path = "/shared_workspace"
|
||||
task_parts.append(
|
||||
f"Perform a security assessment of the local codebase. "
|
||||
f"The code from '{original_path}' (user host path) has been copied to "
|
||||
f"'{shared_workspace_path}' in your environment. "
|
||||
f"Analyze the codebase at: {shared_workspace_path}"
|
||||
)
|
||||
|
||||
else:
|
||||
task_parts.append(
|
||||
f"Perform a general security assessment of: {next(iter(target.values()))}"
|
||||
)
|
||||
|
||||
task_description = " ".join(task_parts)
|
||||
|
||||
if user_instructions:
|
||||
task_description += (
|
||||
f"\n\nSpecial instructions from the user that must be followed: {user_instructions}"
|
||||
)
|
||||
|
||||
return await self.agent_loop(task=task_description)
|
||||
Reference in New Issue
Block a user