-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
179 lines (148 loc) Β· 4.88 KB
/
main.py
File metadata and controls
179 lines (148 loc) Β· 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/usr/bin/env python3
"""
HANERMA - Production Entry Point
APEX EDITION - Production-Grade Multi-Agent Intelligence System
This is the main entry point for HANERMA in production environments.
Provides both the 5-Line API and legacy compatibility.
Usage:
python main.py "Build a web scraper"
python main.py --legacy
python main.py --help
"""
import sys
import argparse
from typing import Optional
def main():
"""Main entry point for HANERMA production system."""
parser = argparse.ArgumentParser(
prog="hanerma",
description="HANERMA APEX Edition - Production Multi-Agent Intelligence System"
)
# Main execution
parser.add_argument(
"prompt",
nargs="?",
help="Natural language task description (5-Line API)"
)
# Configuration options
parser.add_argument(
"--model",
default="auto",
help="Model to use (auto, llama3, mistral, etc.)"
)
parser.add_argument(
"--style-adaptation",
action="store_true",
default=True,
help="Enable user style adaptation"
)
parser.add_argument(
"--no-style-adaptation",
action="store_true",
help="Disable user style adaptation"
)
# Legacy mode
parser.add_argument(
"--legacy",
action="store_true",
help="Enable legacy compatibility mode"
)
# Voice control
parser.add_argument(
"--voice",
action="store_true",
help="Enable voice control"
)
# verbosity
parser.add_argument(
"-v", "--verbose",
action="store_true",
help="Enable verbose output"
)
# Version
parser.add_argument(
"--version",
action="version",
version="HANERMA APEX Edition 1.0.0"
)
args = parser.parse_args()
# Handle legacy mode
if args.legacy:
print("[HANERMA] π Legacy mode enabled")
from hanerma import Legacy
legacy = Legacy()
if args.prompt:
# Legacy execution
result = legacy.run(args.prompt)
print(f"[HANERMA] Legacy result: {result}")
else:
print("[HANERMA] Legacy mode active - use with prompt")
return
# Handle CLI commands without prompt
if not args.prompt:
print("[HANERMA] Use 'hanerma' CLI for full command suite:")
print(" hanerma run 'prompt' - Execute mission")
print(" hanerma viz - Launch dashboard")
print(" hanerma deploy --prod - Production deployment")
print(" hanerma test --redteam - Security testing")
print(" hanerma listen - Voice control")
print(" hanerma --help - Show all options")
return
# 5-Line API execution
try:
# Import and initialize
import hanerma
# Style adaptation setting
style_adaptation = args.style_adaptation and not args.no_style_adaptation
# Create Natural API instance
app = hanerma.Natural(
prompt=args.prompt,
model=args.model,
style_adaptation=style_adaptation
)
# Enable voice if requested
if args.voice:
app.voice(enable=True)
# Set verbosity
if args.verbose:
print("[HANERMA] Verbose mode enabled")
# Execute the pipeline
print("[HANERMA] π Starting execution...")
result = app.run()
# Display results
if result.get("success", True):
print("[HANERMA] β
Execution completed successfully")
if args.verbose:
print(f"[HANERMA] Result: {result}")
else:
print("[HANERMA] β Execution failed")
print(f"[HANERMA] Error: {result.get('error', 'Unknown error')}")
if args.verbose:
print(f"[HANERMA] Traceback: {result.get('traceback', '')}")
sys.exit(1)
except KeyboardInterrupt:
print("[HANERMA] βΉ Execution interrupted by user")
sys.exit(130)
except Exception as e:
print(f"[HANERMA] β Fatal error: {e}")
if args.verbose:
import traceback
traceback.print_exc()
sys.exit(1)
def production_ready():
"""Check if system is production ready."""
try:
import hanerma
print("[HANERMA] β
Production system ready")
print(f"[HANERMA] Version: {hanerma.__version__}")
print("[HANERMA] Features: 5-Line API, Legacy Compatibility, Full CLI Suite")
return True
except ImportError as e:
print(f"[HANERMA] β Production system not ready: {e}")
return False
if __name__ == "__main__":
# Check production readiness
if not production_ready():
sys.exit(1)
# Run main application
main()