strix-agent 0.1.1__py3-none-any.whl
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.
- strix/__init__.py +0 -0
- strix/agents/StrixAgent/__init__.py +4 -0
- strix/agents/StrixAgent/strix_agent.py +60 -0
- strix/agents/StrixAgent/system_prompt.jinja +504 -0
- strix/agents/__init__.py +10 -0
- strix/agents/base_agent.py +394 -0
- strix/agents/state.py +139 -0
- strix/cli/__init__.py +4 -0
- strix/cli/app.py +1124 -0
- strix/cli/assets/cli.tcss +680 -0
- strix/cli/main.py +542 -0
- strix/cli/tool_components/__init__.py +39 -0
- strix/cli/tool_components/agents_graph_renderer.py +129 -0
- strix/cli/tool_components/base_renderer.py +61 -0
- strix/cli/tool_components/browser_renderer.py +107 -0
- strix/cli/tool_components/file_edit_renderer.py +95 -0
- strix/cli/tool_components/finish_renderer.py +32 -0
- strix/cli/tool_components/notes_renderer.py +108 -0
- strix/cli/tool_components/proxy_renderer.py +255 -0
- strix/cli/tool_components/python_renderer.py +34 -0
- strix/cli/tool_components/registry.py +72 -0
- strix/cli/tool_components/reporting_renderer.py +53 -0
- strix/cli/tool_components/scan_info_renderer.py +58 -0
- strix/cli/tool_components/terminal_renderer.py +99 -0
- strix/cli/tool_components/thinking_renderer.py +29 -0
- strix/cli/tool_components/user_message_renderer.py +43 -0
- strix/cli/tool_components/web_search_renderer.py +28 -0
- strix/cli/tracer.py +308 -0
- strix/llm/__init__.py +14 -0
- strix/llm/config.py +19 -0
- strix/llm/llm.py +310 -0
- strix/llm/memory_compressor.py +206 -0
- strix/llm/request_queue.py +63 -0
- strix/llm/utils.py +84 -0
- strix/prompts/__init__.py +113 -0
- strix/prompts/coordination/root_agent.jinja +41 -0
- strix/prompts/vulnerabilities/authentication_jwt.jinja +129 -0
- strix/prompts/vulnerabilities/business_logic.jinja +143 -0
- strix/prompts/vulnerabilities/csrf.jinja +168 -0
- strix/prompts/vulnerabilities/idor.jinja +164 -0
- strix/prompts/vulnerabilities/race_conditions.jinja +194 -0
- strix/prompts/vulnerabilities/rce.jinja +222 -0
- strix/prompts/vulnerabilities/sql_injection.jinja +216 -0
- strix/prompts/vulnerabilities/ssrf.jinja +168 -0
- strix/prompts/vulnerabilities/xss.jinja +221 -0
- strix/prompts/vulnerabilities/xxe.jinja +276 -0
- strix/runtime/__init__.py +19 -0
- strix/runtime/docker_runtime.py +298 -0
- strix/runtime/runtime.py +25 -0
- strix/runtime/tool_server.py +97 -0
- strix/tools/__init__.py +64 -0
- strix/tools/agents_graph/__init__.py +16 -0
- strix/tools/agents_graph/agents_graph_actions.py +610 -0
- strix/tools/agents_graph/agents_graph_actions_schema.xml +223 -0
- strix/tools/argument_parser.py +120 -0
- strix/tools/browser/__init__.py +4 -0
- strix/tools/browser/browser_actions.py +236 -0
- strix/tools/browser/browser_actions_schema.xml +183 -0
- strix/tools/browser/browser_instance.py +533 -0
- strix/tools/browser/tab_manager.py +342 -0
- strix/tools/executor.py +302 -0
- strix/tools/file_edit/__init__.py +4 -0
- strix/tools/file_edit/file_edit_actions.py +141 -0
- strix/tools/file_edit/file_edit_actions_schema.xml +128 -0
- strix/tools/finish/__init__.py +4 -0
- strix/tools/finish/finish_actions.py +167 -0
- strix/tools/finish/finish_actions_schema.xml +45 -0
- strix/tools/notes/__init__.py +14 -0
- strix/tools/notes/notes_actions.py +191 -0
- strix/tools/notes/notes_actions_schema.xml +150 -0
- strix/tools/proxy/__init__.py +20 -0
- strix/tools/proxy/proxy_actions.py +101 -0
- strix/tools/proxy/proxy_actions_schema.xml +267 -0
- strix/tools/proxy/proxy_manager.py +785 -0
- strix/tools/python/__init__.py +4 -0
- strix/tools/python/python_actions.py +47 -0
- strix/tools/python/python_actions_schema.xml +131 -0
- strix/tools/python/python_instance.py +172 -0
- strix/tools/python/python_manager.py +131 -0
- strix/tools/registry.py +196 -0
- strix/tools/reporting/__init__.py +6 -0
- strix/tools/reporting/reporting_actions.py +63 -0
- strix/tools/reporting/reporting_actions_schema.xml +30 -0
- strix/tools/terminal/__init__.py +4 -0
- strix/tools/terminal/terminal_actions.py +53 -0
- strix/tools/terminal/terminal_actions_schema.xml +114 -0
- strix/tools/terminal/terminal_instance.py +231 -0
- strix/tools/terminal/terminal_manager.py +191 -0
- strix/tools/thinking/__init__.py +4 -0
- strix/tools/thinking/thinking_actions.py +18 -0
- strix/tools/thinking/thinking_actions_schema.xml +52 -0
- strix/tools/web_search/__init__.py +4 -0
- strix/tools/web_search/web_search_actions.py +80 -0
- strix/tools/web_search/web_search_actions_schema.xml +83 -0
- strix_agent-0.1.1.dist-info/LICENSE +201 -0
- strix_agent-0.1.1.dist-info/METADATA +200 -0
- strix_agent-0.1.1.dist-info/RECORD +99 -0
- strix_agent-0.1.1.dist-info/WHEEL +4 -0
- strix_agent-0.1.1.dist-info/entry_points.txt +3 -0
strix/cli/main.py
ADDED
@@ -0,0 +1,542 @@
|
|
1
|
+
#!/usr/bin/env python3
|
2
|
+
"""
|
3
|
+
Strix Agent Command Line Interface
|
4
|
+
"""
|
5
|
+
|
6
|
+
import argparse
|
7
|
+
import asyncio
|
8
|
+
import logging
|
9
|
+
import os
|
10
|
+
import secrets
|
11
|
+
import sys
|
12
|
+
from pathlib import Path
|
13
|
+
from typing import Any
|
14
|
+
from urllib.parse import urlparse
|
15
|
+
|
16
|
+
import docker
|
17
|
+
import litellm
|
18
|
+
from docker.errors import DockerException
|
19
|
+
from rich.console import Console
|
20
|
+
from rich.panel import Panel
|
21
|
+
from rich.text import Text
|
22
|
+
|
23
|
+
from strix.cli.app import run_strix_cli
|
24
|
+
from strix.cli.tracer import get_global_tracer
|
25
|
+
from strix.runtime.docker_runtime import STRIX_IMAGE
|
26
|
+
|
27
|
+
|
28
|
+
logging.getLogger().setLevel(logging.ERROR)
|
29
|
+
|
30
|
+
|
31
|
+
def format_token_count(count: float) -> str:
|
32
|
+
count = int(count)
|
33
|
+
if count >= 1_000_000:
|
34
|
+
return f"{count / 1_000_000:.1f}M"
|
35
|
+
if count >= 1_000:
|
36
|
+
return f"{count / 1_000:.1f}K"
|
37
|
+
return str(count)
|
38
|
+
|
39
|
+
|
40
|
+
def validate_environment() -> None:
|
41
|
+
console = Console()
|
42
|
+
missing_required_vars = []
|
43
|
+
missing_optional_vars = []
|
44
|
+
|
45
|
+
if not os.getenv("STRIX_LLM"):
|
46
|
+
missing_required_vars.append("STRIX_LLM")
|
47
|
+
|
48
|
+
if not os.getenv("LLM_API_KEY"):
|
49
|
+
missing_required_vars.append("LLM_API_KEY")
|
50
|
+
|
51
|
+
if not os.getenv("PERPLEXITY_API_KEY"):
|
52
|
+
missing_optional_vars.append("PERPLEXITY_API_KEY")
|
53
|
+
|
54
|
+
if missing_required_vars:
|
55
|
+
error_text = Text()
|
56
|
+
error_text.append("❌ ", style="bold red")
|
57
|
+
error_text.append("MISSING REQUIRED ENVIRONMENT VARIABLES", style="bold red")
|
58
|
+
error_text.append("\n\n", style="white")
|
59
|
+
|
60
|
+
for var in missing_required_vars:
|
61
|
+
error_text.append(f"• {var}", style="bold yellow")
|
62
|
+
error_text.append(" is not set\n", style="white")
|
63
|
+
|
64
|
+
if missing_optional_vars:
|
65
|
+
error_text.append(
|
66
|
+
"\nOptional (but recommended) environment variables:\n", style="dim white"
|
67
|
+
)
|
68
|
+
for var in missing_optional_vars:
|
69
|
+
error_text.append(f"• {var}", style="dim yellow")
|
70
|
+
error_text.append(" is not set\n", style="dim white")
|
71
|
+
|
72
|
+
error_text.append("\nRequired environment variables:\n", style="white")
|
73
|
+
error_text.append("• ", style="white")
|
74
|
+
error_text.append("STRIX_LLM", style="bold cyan")
|
75
|
+
error_text.append(
|
76
|
+
" - Model name to use with litellm (e.g., 'anthropic/claude-sonnet-4-20250514')\n",
|
77
|
+
style="white",
|
78
|
+
)
|
79
|
+
error_text.append("• ", style="white")
|
80
|
+
error_text.append("LLM_API_KEY", style="bold cyan")
|
81
|
+
error_text.append(" - API key for the LLM provider\n", style="white")
|
82
|
+
|
83
|
+
if missing_optional_vars:
|
84
|
+
error_text.append("\nOptional environment variables:\n", style="white")
|
85
|
+
error_text.append("• ", style="white")
|
86
|
+
error_text.append("PERPLEXITY_API_KEY", style="bold cyan")
|
87
|
+
error_text.append(
|
88
|
+
" - API key for Perplexity AI web search (enables real-time research)\n",
|
89
|
+
style="white",
|
90
|
+
)
|
91
|
+
|
92
|
+
error_text.append("\nExample setup:\n", style="white")
|
93
|
+
error_text.append(
|
94
|
+
"export STRIX_LLM='anthropic/claude-sonnet-4-20250514'\n", style="dim white"
|
95
|
+
)
|
96
|
+
error_text.append("export LLM_API_KEY='your-api-key-here'\n", style="dim white")
|
97
|
+
if missing_optional_vars:
|
98
|
+
error_text.append(
|
99
|
+
"export PERPLEXITY_API_KEY='your-perplexity-key-here'", style="dim white"
|
100
|
+
)
|
101
|
+
|
102
|
+
panel = Panel(
|
103
|
+
error_text,
|
104
|
+
title="[bold red]🛡️ STRIX CONFIGURATION ERROR",
|
105
|
+
title_align="center",
|
106
|
+
border_style="red",
|
107
|
+
padding=(1, 2),
|
108
|
+
)
|
109
|
+
|
110
|
+
console.print("\n")
|
111
|
+
console.print(panel)
|
112
|
+
console.print()
|
113
|
+
sys.exit(1)
|
114
|
+
|
115
|
+
|
116
|
+
def _validate_llm_response(response: Any) -> None:
|
117
|
+
if not response or not response.choices or not response.choices[0].message.content:
|
118
|
+
raise RuntimeError("Invalid response from LLM")
|
119
|
+
|
120
|
+
|
121
|
+
async def warm_up_llm() -> None:
|
122
|
+
console = Console()
|
123
|
+
|
124
|
+
try:
|
125
|
+
model_name = os.getenv("STRIX_LLM", "anthropic/claude-sonnet-4-20250514")
|
126
|
+
api_key = os.getenv("LLM_API_KEY")
|
127
|
+
|
128
|
+
if api_key:
|
129
|
+
litellm.api_key = api_key
|
130
|
+
|
131
|
+
test_messages = [
|
132
|
+
{"role": "system", "content": "You are a helpful assistant."},
|
133
|
+
{"role": "user", "content": "Reply with just 'OK'."},
|
134
|
+
]
|
135
|
+
|
136
|
+
response = litellm.completion(
|
137
|
+
model=model_name,
|
138
|
+
messages=test_messages,
|
139
|
+
max_tokens=10,
|
140
|
+
)
|
141
|
+
|
142
|
+
_validate_llm_response(response)
|
143
|
+
|
144
|
+
except Exception as e: # noqa: BLE001
|
145
|
+
error_text = Text()
|
146
|
+
error_text.append("❌ ", style="bold red")
|
147
|
+
error_text.append("LLM CONNECTION FAILED", style="bold red")
|
148
|
+
error_text.append("\n\n", style="white")
|
149
|
+
error_text.append("Could not establish connection to the language model.\n", style="white")
|
150
|
+
error_text.append("Please check your configuration and try again.\n", style="white")
|
151
|
+
error_text.append(f"\nError: {e}", style="dim white")
|
152
|
+
|
153
|
+
panel = Panel(
|
154
|
+
error_text,
|
155
|
+
title="[bold red]🛡️ STRIX STARTUP ERROR",
|
156
|
+
title_align="center",
|
157
|
+
border_style="red",
|
158
|
+
padding=(1, 2),
|
159
|
+
)
|
160
|
+
|
161
|
+
console.print("\n")
|
162
|
+
console.print(panel)
|
163
|
+
console.print()
|
164
|
+
sys.exit(1)
|
165
|
+
|
166
|
+
|
167
|
+
def generate_run_name() -> str:
|
168
|
+
# fmt: off
|
169
|
+
adjectives = [
|
170
|
+
"stealthy", "sneaky", "crafty", "elite", "phantom", "shadow", "silent",
|
171
|
+
"rogue", "covert", "ninja", "ghost", "cyber", "digital", "binary",
|
172
|
+
"encrypted", "obfuscated", "masked", "cloaked", "invisible", "anonymous"
|
173
|
+
]
|
174
|
+
nouns = [
|
175
|
+
"exploit", "payload", "backdoor", "rootkit", "keylogger", "botnet", "trojan",
|
176
|
+
"worm", "virus", "packet", "buffer", "shell", "daemon", "spider", "crawler",
|
177
|
+
"scanner", "sniffer", "honeypot", "firewall", "breach"
|
178
|
+
]
|
179
|
+
# fmt: on
|
180
|
+
adj = secrets.choice(adjectives)
|
181
|
+
noun = secrets.choice(nouns)
|
182
|
+
number = secrets.randbelow(900) + 100
|
183
|
+
return f"{adj}-{noun}-{number}"
|
184
|
+
|
185
|
+
|
186
|
+
def infer_target_type(target: str) -> tuple[str, dict[str, str]]:
|
187
|
+
if not target or not isinstance(target, str):
|
188
|
+
raise ValueError("Target must be a non-empty string")
|
189
|
+
|
190
|
+
target = target.strip()
|
191
|
+
|
192
|
+
parsed = urlparse(target)
|
193
|
+
if parsed.scheme in ("http", "https"):
|
194
|
+
if any(
|
195
|
+
host in parsed.netloc.lower() for host in ["github.com", "gitlab.com", "bitbucket.org"]
|
196
|
+
):
|
197
|
+
return "repository", {"target_repo": target}
|
198
|
+
return "web_application", {"target_url": target}
|
199
|
+
|
200
|
+
path = Path(target)
|
201
|
+
try:
|
202
|
+
if path.exists():
|
203
|
+
if path.is_dir():
|
204
|
+
return "local_code", {"target_path": str(path.absolute())}
|
205
|
+
raise ValueError(f"Path exists but is not a directory: {target}")
|
206
|
+
except (OSError, RuntimeError) as e:
|
207
|
+
raise ValueError(f"Invalid path: {target} - {e!s}") from e
|
208
|
+
|
209
|
+
if target.startswith("git@") or target.endswith(".git"):
|
210
|
+
return "repository", {"target_repo": target}
|
211
|
+
|
212
|
+
if "." in target and "/" not in target and not target.startswith("."):
|
213
|
+
parts = target.split(".")
|
214
|
+
if len(parts) >= 2 and all(p and p.strip() for p in parts):
|
215
|
+
return "web_application", {"target_url": f"https://{target}"}
|
216
|
+
|
217
|
+
raise ValueError(
|
218
|
+
f"Invalid target: {target}\n"
|
219
|
+
"Target must be one of:\n"
|
220
|
+
"- A valid URL (http:// or https://)\n"
|
221
|
+
"- A Git repository URL (https://github.com/... or git@github.com:...)\n"
|
222
|
+
"- A local directory path\n"
|
223
|
+
"- A domain name (e.g., example.com)"
|
224
|
+
)
|
225
|
+
|
226
|
+
|
227
|
+
def parse_arguments() -> argparse.Namespace:
|
228
|
+
parser = argparse.ArgumentParser(
|
229
|
+
description="Strix Multi-Agent Cybersecurity Scanner",
|
230
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
231
|
+
epilog="""
|
232
|
+
Examples:
|
233
|
+
# Web application scan
|
234
|
+
strix --target https://example.com
|
235
|
+
|
236
|
+
# GitHub repository analysis
|
237
|
+
strix --target https://github.com/user/repo
|
238
|
+
strix --target git@github.com:user/repo.git
|
239
|
+
|
240
|
+
# Local code analysis
|
241
|
+
strix --target ./my-project
|
242
|
+
|
243
|
+
# Domain scan
|
244
|
+
strix --target example.com
|
245
|
+
|
246
|
+
# Custom instructions
|
247
|
+
strix --target example.com --instruction "Focus on authentication vulnerabilities"
|
248
|
+
""",
|
249
|
+
)
|
250
|
+
|
251
|
+
parser.add_argument(
|
252
|
+
"--target",
|
253
|
+
type=str,
|
254
|
+
required=True,
|
255
|
+
help="Target to scan (URL, repository, local directory path, or domain name)",
|
256
|
+
)
|
257
|
+
parser.add_argument(
|
258
|
+
"--instruction",
|
259
|
+
type=str,
|
260
|
+
help="Custom instructions for the scan. This can be "
|
261
|
+
"specific vulnerability types to focus on (e.g., 'Focus on IDOR and XSS'), "
|
262
|
+
"testing approaches (e.g., 'Perform thorough authentication testing'), "
|
263
|
+
"test credentials (e.g., 'Use the following credentials to access the app: "
|
264
|
+
"admin:password123'), "
|
265
|
+
"or areas of interest (e.g., 'Check login API endpoint for security issues')",
|
266
|
+
)
|
267
|
+
|
268
|
+
parser.add_argument(
|
269
|
+
"--run-name",
|
270
|
+
type=str,
|
271
|
+
help="Custom name for this scan run",
|
272
|
+
)
|
273
|
+
|
274
|
+
args = parser.parse_args()
|
275
|
+
|
276
|
+
try:
|
277
|
+
args.target_type, args.target_dict = infer_target_type(args.target)
|
278
|
+
except ValueError as e:
|
279
|
+
parser.error(str(e))
|
280
|
+
|
281
|
+
return args
|
282
|
+
|
283
|
+
|
284
|
+
def _build_stats_text(tracer: Any) -> Text:
|
285
|
+
stats_text = Text()
|
286
|
+
if not tracer:
|
287
|
+
return stats_text
|
288
|
+
|
289
|
+
vuln_count = len(tracer.vulnerability_reports)
|
290
|
+
tool_count = tracer.get_real_tool_count()
|
291
|
+
agent_count = len(tracer.agents)
|
292
|
+
|
293
|
+
if vuln_count > 0:
|
294
|
+
stats_text.append("🔍 Vulnerabilities Found: ", style="bold red")
|
295
|
+
stats_text.append(str(vuln_count), style="bold yellow")
|
296
|
+
stats_text.append(" • ", style="dim white")
|
297
|
+
|
298
|
+
stats_text.append("🤖 Agents Used: ", style="bold cyan")
|
299
|
+
stats_text.append(str(agent_count), style="bold white")
|
300
|
+
stats_text.append(" • ", style="dim white")
|
301
|
+
stats_text.append("🛠️ Tools Called: ", style="bold cyan")
|
302
|
+
stats_text.append(str(tool_count), style="bold white")
|
303
|
+
|
304
|
+
return stats_text
|
305
|
+
|
306
|
+
|
307
|
+
def _build_llm_stats_text(tracer: Any) -> Text:
|
308
|
+
llm_stats_text = Text()
|
309
|
+
if not tracer:
|
310
|
+
return llm_stats_text
|
311
|
+
|
312
|
+
llm_stats = tracer.get_total_llm_stats()
|
313
|
+
total_stats = llm_stats["total"]
|
314
|
+
|
315
|
+
if total_stats["requests"] > 0:
|
316
|
+
llm_stats_text.append("📥 Input Tokens: ", style="bold cyan")
|
317
|
+
llm_stats_text.append(format_token_count(total_stats["input_tokens"]), style="bold white")
|
318
|
+
|
319
|
+
if total_stats["cached_tokens"] > 0:
|
320
|
+
llm_stats_text.append(" • ", style="dim white")
|
321
|
+
llm_stats_text.append("⚡ Cached: ", style="bold green")
|
322
|
+
llm_stats_text.append(
|
323
|
+
format_token_count(total_stats["cached_tokens"]), style="bold green"
|
324
|
+
)
|
325
|
+
|
326
|
+
llm_stats_text.append(" • ", style="dim white")
|
327
|
+
llm_stats_text.append("📤 Output Tokens: ", style="bold cyan")
|
328
|
+
llm_stats_text.append(format_token_count(total_stats["output_tokens"]), style="bold white")
|
329
|
+
|
330
|
+
if total_stats["cost"] > 0:
|
331
|
+
llm_stats_text.append(" • ", style="dim white")
|
332
|
+
llm_stats_text.append("💰 Total Cost: $", style="bold cyan")
|
333
|
+
llm_stats_text.append(f"{total_stats['cost']:.4f}", style="bold yellow")
|
334
|
+
|
335
|
+
return llm_stats_text
|
336
|
+
|
337
|
+
|
338
|
+
def display_completion_message(args: argparse.Namespace, results_path: Path) -> None:
|
339
|
+
console = Console()
|
340
|
+
tracer = get_global_tracer()
|
341
|
+
|
342
|
+
target_value = next(iter(args.target_dict.values())) if args.target_dict else args.target
|
343
|
+
|
344
|
+
completion_text = Text()
|
345
|
+
completion_text.append("🦉 ", style="bold white")
|
346
|
+
completion_text.append("AGENT FINISHED", style="bold green")
|
347
|
+
completion_text.append(" • ", style="dim white")
|
348
|
+
completion_text.append("Security assessment completed", style="white")
|
349
|
+
|
350
|
+
stats_text = _build_stats_text(tracer)
|
351
|
+
|
352
|
+
llm_stats_text = _build_llm_stats_text(tracer)
|
353
|
+
|
354
|
+
target_text = Text()
|
355
|
+
target_text.append("🎯 Target: ", style="bold cyan")
|
356
|
+
target_text.append(str(target_value), style="bold white")
|
357
|
+
|
358
|
+
results_text = Text()
|
359
|
+
results_text.append("📊 Results Saved To: ", style="bold cyan")
|
360
|
+
results_text.append(str(results_path), style="bold yellow")
|
361
|
+
|
362
|
+
if stats_text.plain:
|
363
|
+
if llm_stats_text.plain:
|
364
|
+
panel_content = Text.assemble(
|
365
|
+
completion_text,
|
366
|
+
"\n\n",
|
367
|
+
target_text,
|
368
|
+
"\n",
|
369
|
+
stats_text,
|
370
|
+
"\n",
|
371
|
+
llm_stats_text,
|
372
|
+
"\n",
|
373
|
+
results_text,
|
374
|
+
)
|
375
|
+
else:
|
376
|
+
panel_content = Text.assemble(
|
377
|
+
completion_text, "\n\n", target_text, "\n", stats_text, "\n", results_text
|
378
|
+
)
|
379
|
+
elif llm_stats_text.plain:
|
380
|
+
panel_content = Text.assemble(
|
381
|
+
completion_text, "\n\n", target_text, "\n", llm_stats_text, "\n", results_text
|
382
|
+
)
|
383
|
+
else:
|
384
|
+
panel_content = Text.assemble(completion_text, "\n\n", target_text, "\n", results_text)
|
385
|
+
|
386
|
+
panel = Panel(
|
387
|
+
panel_content,
|
388
|
+
title="[bold green]🛡️ STRIX CYBERSECURITY AGENT",
|
389
|
+
title_align="center",
|
390
|
+
border_style="green",
|
391
|
+
padding=(1, 2),
|
392
|
+
)
|
393
|
+
|
394
|
+
console.print("\n")
|
395
|
+
console.print(panel)
|
396
|
+
console.print()
|
397
|
+
|
398
|
+
|
399
|
+
def _check_docker_connection() -> Any:
|
400
|
+
try:
|
401
|
+
return docker.from_env()
|
402
|
+
except DockerException:
|
403
|
+
console = Console()
|
404
|
+
error_text = Text()
|
405
|
+
error_text.append("❌ ", style="bold red")
|
406
|
+
error_text.append("DOCKER NOT AVAILABLE", style="bold red")
|
407
|
+
error_text.append("\n\n", style="white")
|
408
|
+
error_text.append("Cannot connect to Docker daemon.\n", style="white")
|
409
|
+
error_text.append("Please ensure Docker is installed and running.\n\n", style="white")
|
410
|
+
error_text.append("Try running: ", style="dim white")
|
411
|
+
error_text.append("sudo systemctl start docker", style="dim cyan")
|
412
|
+
|
413
|
+
panel = Panel(
|
414
|
+
error_text,
|
415
|
+
title="[bold red]🛡️ STRIX STARTUP ERROR",
|
416
|
+
title_align="center",
|
417
|
+
border_style="red",
|
418
|
+
padding=(1, 2),
|
419
|
+
)
|
420
|
+
console.print("\n", panel, "\n")
|
421
|
+
sys.exit(1)
|
422
|
+
|
423
|
+
|
424
|
+
def _image_exists(client: Any) -> bool:
|
425
|
+
try:
|
426
|
+
client.images.get(STRIX_IMAGE)
|
427
|
+
except docker.errors.ImageNotFound:
|
428
|
+
return False
|
429
|
+
else:
|
430
|
+
return True
|
431
|
+
|
432
|
+
|
433
|
+
def _update_layer_status(layers_info: dict[str, str], layer_id: str, layer_status: str) -> None:
|
434
|
+
if "Pull complete" in layer_status or "Already exists" in layer_status:
|
435
|
+
layers_info[layer_id] = "✓"
|
436
|
+
elif "Downloading" in layer_status:
|
437
|
+
layers_info[layer_id] = "↓"
|
438
|
+
elif "Extracting" in layer_status:
|
439
|
+
layers_info[layer_id] = "📦"
|
440
|
+
elif "Waiting" in layer_status:
|
441
|
+
layers_info[layer_id] = "⏳"
|
442
|
+
else:
|
443
|
+
layers_info[layer_id] = "•"
|
444
|
+
|
445
|
+
|
446
|
+
def _process_pull_line(
|
447
|
+
line: dict[str, Any], layers_info: dict[str, str], status: Any, last_update: str
|
448
|
+
) -> str:
|
449
|
+
if "id" in line and "status" in line:
|
450
|
+
layer_id = line["id"]
|
451
|
+
_update_layer_status(layers_info, layer_id, line["status"])
|
452
|
+
|
453
|
+
completed = sum(1 for v in layers_info.values() if v == "✓")
|
454
|
+
total = len(layers_info)
|
455
|
+
|
456
|
+
if total > 0:
|
457
|
+
update_msg = f"[bold cyan]Progress: {completed}/{total} layers complete"
|
458
|
+
if update_msg != last_update:
|
459
|
+
status.update(update_msg)
|
460
|
+
return update_msg
|
461
|
+
|
462
|
+
elif "status" in line and "id" not in line:
|
463
|
+
global_status = line["status"]
|
464
|
+
if "Pulling from" in global_status:
|
465
|
+
status.update("[bold cyan]Fetching image manifest...")
|
466
|
+
elif "Digest:" in global_status:
|
467
|
+
status.update("[bold cyan]Verifying image...")
|
468
|
+
elif "Status:" in global_status:
|
469
|
+
status.update("[bold cyan]Finalizing...")
|
470
|
+
|
471
|
+
return last_update
|
472
|
+
|
473
|
+
|
474
|
+
def pull_docker_image() -> None:
|
475
|
+
console = Console()
|
476
|
+
client = _check_docker_connection()
|
477
|
+
|
478
|
+
if _image_exists(client):
|
479
|
+
return
|
480
|
+
|
481
|
+
console.print()
|
482
|
+
console.print(f"[bold cyan]🐳 Pulling Docker image:[/bold cyan] {STRIX_IMAGE}")
|
483
|
+
console.print(
|
484
|
+
"[dim yellow]This only happens on first run and may take a few minutes...[/dim yellow]"
|
485
|
+
)
|
486
|
+
console.print()
|
487
|
+
|
488
|
+
with console.status("[bold cyan]Downloading image layers...", spinner="dots") as status:
|
489
|
+
try:
|
490
|
+
layers_info: dict[str, str] = {}
|
491
|
+
last_update = ""
|
492
|
+
|
493
|
+
for line in client.api.pull(STRIX_IMAGE, stream=True, decode=True):
|
494
|
+
last_update = _process_pull_line(line, layers_info, status, last_update)
|
495
|
+
|
496
|
+
except DockerException as e:
|
497
|
+
console.print()
|
498
|
+
error_text = Text()
|
499
|
+
error_text.append("❌ ", style="bold red")
|
500
|
+
error_text.append("FAILED TO PULL IMAGE", style="bold red")
|
501
|
+
error_text.append("\n\n", style="white")
|
502
|
+
error_text.append(f"Could not download: {STRIX_IMAGE}\n", style="white")
|
503
|
+
error_text.append(str(e), style="dim red")
|
504
|
+
|
505
|
+
panel = Panel(
|
506
|
+
error_text,
|
507
|
+
title="[bold red]🛡️ DOCKER PULL ERROR",
|
508
|
+
title_align="center",
|
509
|
+
border_style="red",
|
510
|
+
padding=(1, 2),
|
511
|
+
)
|
512
|
+
console.print(panel, "\n")
|
513
|
+
sys.exit(1)
|
514
|
+
|
515
|
+
success_text = Text()
|
516
|
+
success_text.append("✅ ", style="bold green")
|
517
|
+
success_text.append("Successfully pulled Docker image", style="green")
|
518
|
+
console.print(success_text)
|
519
|
+
console.print()
|
520
|
+
|
521
|
+
|
522
|
+
def main() -> None:
|
523
|
+
if sys.platform == "win32":
|
524
|
+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
525
|
+
|
526
|
+
pull_docker_image()
|
527
|
+
|
528
|
+
validate_environment()
|
529
|
+
asyncio.run(warm_up_llm())
|
530
|
+
|
531
|
+
args = parse_arguments()
|
532
|
+
if not args.run_name:
|
533
|
+
args.run_name = generate_run_name()
|
534
|
+
|
535
|
+
asyncio.run(run_strix_cli(args))
|
536
|
+
|
537
|
+
results_path = Path("agent_runs") / args.run_name
|
538
|
+
display_completion_message(args, results_path)
|
539
|
+
|
540
|
+
|
541
|
+
if __name__ == "__main__":
|
542
|
+
main()
|
@@ -0,0 +1,39 @@
|
|
1
|
+
from . import (
|
2
|
+
agents_graph_renderer,
|
3
|
+
browser_renderer,
|
4
|
+
file_edit_renderer,
|
5
|
+
finish_renderer,
|
6
|
+
notes_renderer,
|
7
|
+
proxy_renderer,
|
8
|
+
python_renderer,
|
9
|
+
reporting_renderer,
|
10
|
+
scan_info_renderer,
|
11
|
+
terminal_renderer,
|
12
|
+
thinking_renderer,
|
13
|
+
user_message_renderer,
|
14
|
+
web_search_renderer,
|
15
|
+
)
|
16
|
+
from .base_renderer import BaseToolRenderer
|
17
|
+
from .registry import ToolTUIRegistry, get_tool_renderer, register_tool_renderer, render_tool_widget
|
18
|
+
|
19
|
+
|
20
|
+
__all__ = [
|
21
|
+
"BaseToolRenderer",
|
22
|
+
"ToolTUIRegistry",
|
23
|
+
"agents_graph_renderer",
|
24
|
+
"browser_renderer",
|
25
|
+
"file_edit_renderer",
|
26
|
+
"finish_renderer",
|
27
|
+
"get_tool_renderer",
|
28
|
+
"notes_renderer",
|
29
|
+
"proxy_renderer",
|
30
|
+
"python_renderer",
|
31
|
+
"register_tool_renderer",
|
32
|
+
"render_tool_widget",
|
33
|
+
"reporting_renderer",
|
34
|
+
"scan_info_renderer",
|
35
|
+
"terminal_renderer",
|
36
|
+
"thinking_renderer",
|
37
|
+
"user_message_renderer",
|
38
|
+
"web_search_renderer",
|
39
|
+
]
|