Spaces:
Runtime error
Runtime error
Upload 28 files
Browse files- archive/__pycache__/archive_analyzer.cpython-311.pyc +0 -0
- archive/archive_analyzer.py +11 -0
- archive/archive_parser.py +12 -0
- archive/cross_reference.py +10 -0
- atp/atp_integration.py +14 -0
- auth/passkeys.py +30 -0
- backend/__pycache__/ai_chat.cpython-311.pyc +0 -0
- backend/__pycache__/code_parser.cpython-311.pyc +0 -0
- backend/__pycache__/pipeline_manager.cpython-311.pyc +0 -0
- backend/ai_chat.py +81 -0
- backend/code_parser.py +84 -0
- backend/pipeline_manager.py +82 -0
- backend/sentiment_analysis.py +11 -0
- chalk/index.d.ts +415 -0
- chalk/license +9 -0
- chalk/package.json +68 -0
- chalk/readme.md +341 -0
- chalk/source/index.js +229 -0
- chalk/source/templates.js +134 -0
- chalk/source/util.js +39 -0
- chatbot/app.py +408 -0
- chatbot/chatbot.py +401 -0
- chatbot/static/css/styles.css +45 -0
- chatbot/static/js/script.js +59 -0
- chatbot/static/styles.css +45 -0
- chatbot/templates/index.html +166 -0
- chatbot/templates/key_input.html +69 -0
- cli/cli_dashboard.py +10 -0
archive/__pycache__/archive_analyzer.cpython-311.pyc
ADDED
|
Binary file (2.83 kB). View file
|
|
|
archive/archive_analyzer.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
from archive.archive_parser import parse_sources
|
| 4 |
+
|
| 5 |
+
def analyze_sources():
|
| 6 |
+
try:
|
| 7 |
+
sources = parse_sources()
|
| 8 |
+
# Perform analysis on sources
|
| 9 |
+
print(sources)
|
| 10 |
+
except Exception as e:
|
| 11 |
+
print(f"Error during source analysis: {e}")
|
archive/archive_parser.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
|
| 4 |
+
def parse_sources():
|
| 5 |
+
try:
|
| 6 |
+
# Parse sources from archive
|
| 7 |
+
sources = []
|
| 8 |
+
# ...
|
| 9 |
+
return sources
|
| 10 |
+
except Exception as e:
|
| 11 |
+
print(f"Error during source parsing: {e}")
|
| 12 |
+
return []
|
archive/cross_reference.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
def cross_reference_results(results):
|
| 3 |
+
common_links = set.intersection(*[set(res.get("links", [])) for res in results if "links" in res])
|
| 4 |
+
return {
|
| 5 |
+
"common_links": list(common_links),
|
| 6 |
+
"unique_links": {
|
| 7 |
+
result["source"]: list(set(result.get("links", [])) - common_links)
|
| 8 |
+
for result in results
|
| 9 |
+
},
|
| 10 |
+
}
|
atp/atp_integration.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def atp_threat_mitigation(threat_id):
|
| 2 |
+
try:
|
| 3 |
+
print(f"Mitigating threat: {threat_id}")
|
| 4 |
+
return {"threat_id": threat_id, "status": "Mitigated"}
|
| 5 |
+
except Exception as e:
|
| 6 |
+
print(f"Error during threat mitigation: {e}")
|
| 7 |
+
return {"threat_id": threat_id, "status": "Error"}
|
| 8 |
+
|
| 9 |
+
if __name__ == "__main__":
|
| 10 |
+
try:
|
| 11 |
+
result = atp_threat_mitigation("THREAT-12345")
|
| 12 |
+
print(result)
|
| 13 |
+
except Exception as e:
|
| 14 |
+
print(f"Error in main execution: {e}")
|
auth/passkeys.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import os
|
| 3 |
+
import hashlib
|
| 4 |
+
import secrets
|
| 5 |
+
|
| 6 |
+
class PasskeyManager:
|
| 7 |
+
def __init__(self):
|
| 8 |
+
self.passkeys = {}
|
| 9 |
+
|
| 10 |
+
def generate_passkey(self, user_id):
|
| 11 |
+
"""Generate a secure passkey for a user."""
|
| 12 |
+
key = secrets.token_urlsafe(32)
|
| 13 |
+
hashed_key = hashlib.sha256(key.encode()).hexdigest()
|
| 14 |
+
self.passkeys[user_id] = hashed_key
|
| 15 |
+
return key
|
| 16 |
+
|
| 17 |
+
def validate_passkey(self, user_id, passkey):
|
| 18 |
+
"""Validate a given passkey for a user."""
|
| 19 |
+
hashed_key = hashlib.sha256(passkey.encode()).hexdigest()
|
| 20 |
+
return self.passkeys.get(user_id) == hashed_key
|
| 21 |
+
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
manager = PasskeyManager()
|
| 24 |
+
user_id = "user123"
|
| 25 |
+
key = manager.generate_passkey(user_id)
|
| 26 |
+
print(f"Generated passkey for {user_id}: {key}")
|
| 27 |
+
|
| 28 |
+
# Validate Passkey
|
| 29 |
+
valid = manager.validate_passkey(user_id, key)
|
| 30 |
+
print(f"Passkey validation result: {'Valid' if valid else 'Invalid'}")
|
backend/__pycache__/ai_chat.cpython-311.pyc
ADDED
|
Binary file (2.55 kB). View file
|
|
|
backend/__pycache__/code_parser.cpython-311.pyc
ADDED
|
Binary file (1.8 kB). View file
|
|
|
backend/__pycache__/pipeline_manager.cpython-311.pyc
ADDED
|
Binary file (1.27 kB). View file
|
|
|
backend/ai_chat.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import openai
|
| 2 |
+
import requests
|
| 3 |
+
import os
|
| 4 |
+
import logging
|
| 5 |
+
from backend.code_parser import CodeParser
|
| 6 |
+
from backend.pipeline_manager import PipelineManager
|
| 7 |
+
|
| 8 |
+
class MultiAIChat:
|
| 9 |
+
def __init__(self):
|
| 10 |
+
self.openai_key = os.getenv("OPENAI_API_KEY")
|
| 11 |
+
self.huggingface_key = os.getenv("HUGGINGFACE_API_KEY")
|
| 12 |
+
self.anthropic_key = os.getenv("ANTHROPIC_API_KEY")
|
| 13 |
+
self.code_parser = CodeParser("")
|
| 14 |
+
self.pipeline_manager = PipelineManager()
|
| 15 |
+
|
| 16 |
+
def openai_chat(self, prompt):
|
| 17 |
+
if not self.openai_key:
|
| 18 |
+
logging.error("Error: Missing OpenAI API key")
|
| 19 |
+
return ""
|
| 20 |
+
try:
|
| 21 |
+
openai.api_key = self.openai_key
|
| 22 |
+
response = openai.Completion.create(engine="text-davinci-003", prompt=prompt, max_tokens=100)
|
| 23 |
+
return response.choices[0].text.strip()
|
| 24 |
+
except Exception as e:
|
| 25 |
+
logging.error(f"Error during OpenAI chat: {e}")
|
| 26 |
+
return ""
|
| 27 |
+
|
| 28 |
+
def huggingface_chat(self, prompt):
|
| 29 |
+
if not self.huggingface_key:
|
| 30 |
+
logging.error("Error: Missing HuggingFace API key")
|
| 31 |
+
return ""
|
| 32 |
+
try:
|
| 33 |
+
url = "https://api-inference.huggingface.co/models/facebook/blenderbot-400M-distill"
|
| 34 |
+
headers = {"Authorization": f"Bearer {self.huggingface_key}"}
|
| 35 |
+
response = requests.post(url, json={"inputs": prompt}, headers=headers)
|
| 36 |
+
response.raise_for_status()
|
| 37 |
+
return response.json().get("generated_text", "")
|
| 38 |
+
except requests.exceptions.HTTPError as e:
|
| 39 |
+
logging.error(f"HTTP error during HuggingFace chat: {e}")
|
| 40 |
+
return ""
|
| 41 |
+
except Exception as e:
|
| 42 |
+
logging.error(f"Error during HuggingFace chat: {e}")
|
| 43 |
+
return ""
|
| 44 |
+
|
| 45 |
+
def anthropic_chat(self, prompt):
|
| 46 |
+
if not self.anthropic_key:
|
| 47 |
+
logging.error("Error: Missing Anthropic API key")
|
| 48 |
+
return ""
|
| 49 |
+
try:
|
| 50 |
+
url = "https://api.anthropic.com/v1/completion"
|
| 51 |
+
headers = {"Authorization": f"Bearer {self.anthropic_key}"}
|
| 52 |
+
response = requests.post(url, json={"prompt": prompt, "model": "claude-v1"})
|
| 53 |
+
response.raise_for_status()
|
| 54 |
+
return response.json().get("output", "")
|
| 55 |
+
except requests.exceptions.HTTPError as e:
|
| 56 |
+
logging.error(f"HTTP error during Anthropic chat: {e}")
|
| 57 |
+
return ""
|
| 58 |
+
except Exception as e:
|
| 59 |
+
logging.error(f"Error during Anthropic chat: {e}")
|
| 60 |
+
return ""
|
| 61 |
+
|
| 62 |
+
def parse_code(self, code):
|
| 63 |
+
try:
|
| 64 |
+
self.code_parser = CodeParser(code)
|
| 65 |
+
return self.code_parser.analyze_code()
|
| 66 |
+
except Exception as e:
|
| 67 |
+
logging.error(f"Error during code parsing: {e}")
|
| 68 |
+
return {}
|
| 69 |
+
|
| 70 |
+
def manage_pipeline(self, task):
|
| 71 |
+
try:
|
| 72 |
+
return self.pipeline_manager.autogpt_task(task)
|
| 73 |
+
except Exception as e:
|
| 74 |
+
logging.error(f"Error during pipeline management: {e}")
|
| 75 |
+
return ""
|
| 76 |
+
|
| 77 |
+
if __name__ == "__main__":
|
| 78 |
+
chat = MultiAIChat()
|
| 79 |
+
print(chat.openai_chat("Hello, how can I assist you today?"))
|
| 80 |
+
print(chat.parse_code("def example():\n return True"))
|
| 81 |
+
print(chat.manage_pipeline("Generate a weekly report."))
|
backend/code_parser.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import ast
|
| 2 |
+
import logging
|
| 3 |
+
from database.models import DocumentAnalysis
|
| 4 |
+
from sqlalchemy import create_engine
|
| 5 |
+
from sqlalchemy.orm import sessionmaker
|
| 6 |
+
|
| 7 |
+
DATABASE_URL = "sqlite:///document_analysis.db"
|
| 8 |
+
engine = create_engine(DATABASE_URL)
|
| 9 |
+
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
| 10 |
+
|
| 11 |
+
# Configure logging
|
| 12 |
+
logging.basicConfig(level=logging.ERROR, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 13 |
+
|
| 14 |
+
class CodeParser:
|
| 15 |
+
def __init__(self, code):
|
| 16 |
+
try:
|
| 17 |
+
if not code.strip():
|
| 18 |
+
raise ValueError("Input code cannot be empty")
|
| 19 |
+
self.tree = ast.parse(code)
|
| 20 |
+
except ValueError as e:
|
| 21 |
+
logging.error(f"ValueError: {e}")
|
| 22 |
+
raise
|
| 23 |
+
except SyntaxError as e:
|
| 24 |
+
logging.error(f"SyntaxError: {e}")
|
| 25 |
+
raise
|
| 26 |
+
except Exception as e:
|
| 27 |
+
logging.error(f"Unexpected error in CodeParser constructor: {e}")
|
| 28 |
+
raise
|
| 29 |
+
|
| 30 |
+
def find_functions(self):
|
| 31 |
+
try:
|
| 32 |
+
return [node.name for node in ast.walk(self.tree) if isinstance(node, ast.FunctionDef)]
|
| 33 |
+
except Exception as e:
|
| 34 |
+
logging.error(f"Unexpected error in find_functions: {e}")
|
| 35 |
+
return []
|
| 36 |
+
|
| 37 |
+
def analyze_code(self):
|
| 38 |
+
try:
|
| 39 |
+
if not self.tree.body:
|
| 40 |
+
return {"error": "Empty code input"}
|
| 41 |
+
analysis = {
|
| 42 |
+
"num_functions": len(self.find_functions()),
|
| 43 |
+
"lines_of_code": len(self.tree.body),
|
| 44 |
+
}
|
| 45 |
+
return analysis
|
| 46 |
+
except Exception as e:
|
| 47 |
+
logging.error(f"Unexpected error in analyze_code: {e}")
|
| 48 |
+
return {"error": "Analysis failed"}
|
| 49 |
+
|
| 50 |
+
def save_analysis_to_db(self, source, title, links, error):
|
| 51 |
+
session = SessionLocal()
|
| 52 |
+
try:
|
| 53 |
+
analysis_result = DocumentAnalysis(
|
| 54 |
+
source=source,
|
| 55 |
+
title=title,
|
| 56 |
+
links=links,
|
| 57 |
+
error=error
|
| 58 |
+
)
|
| 59 |
+
session.add(analysis_result)
|
| 60 |
+
session.commit()
|
| 61 |
+
except Exception as e:
|
| 62 |
+
logging.error(f"Error saving analysis to database: {e}")
|
| 63 |
+
finally:
|
| 64 |
+
session.close()
|
| 65 |
+
|
| 66 |
+
def verify_database_connection(self):
|
| 67 |
+
try:
|
| 68 |
+
session = SessionLocal()
|
| 69 |
+
session.execute('SELECT 1')
|
| 70 |
+
session.close()
|
| 71 |
+
print("Database connection verified.")
|
| 72 |
+
except Exception as e:
|
| 73 |
+
print(f"Database connection verification failed: {e}")
|
| 74 |
+
|
| 75 |
+
if __name__ == "__main__":
|
| 76 |
+
sample_code = "def example():\n return True"
|
| 77 |
+
parser = CodeParser(sample_code)
|
| 78 |
+
analysis = parser.analyze_code()
|
| 79 |
+
try:
|
| 80 |
+
parser.save_analysis_to_db("sample_code.py", "Code Analysis", str(analysis), None)
|
| 81 |
+
except Exception as e:
|
| 82 |
+
logging.error(f"Unexpected error in save_analysis_to_db: {e}")
|
| 83 |
+
parser.verify_database_connection()
|
| 84 |
+
print(analysis)
|
backend/pipeline_manager.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import openai
|
| 2 |
+
import requests
|
| 3 |
+
import logging
|
| 4 |
+
from database.models import DocumentAnalysis
|
| 5 |
+
from sqlalchemy import create_engine
|
| 6 |
+
from sqlalchemy.orm import sessionmaker
|
| 7 |
+
import os
|
| 8 |
+
|
| 9 |
+
DATABASE_URL = "sqlite:///document_analysis.db"
|
| 10 |
+
engine = create_engine(DATABASE_URL)
|
| 11 |
+
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
| 12 |
+
|
| 13 |
+
# Configure logging
|
| 14 |
+
logging.basicConfig(level=logging.ERROR, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 15 |
+
|
| 16 |
+
class PipelineManager:
|
| 17 |
+
def __init__(self):
|
| 18 |
+
pass
|
| 19 |
+
|
| 20 |
+
def autogpt_task(self, task):
|
| 21 |
+
try:
|
| 22 |
+
api_key = os.getenv("OPENAI_API_KEY")
|
| 23 |
+
if not api_key:
|
| 24 |
+
raise ValueError("Missing API key")
|
| 25 |
+
openai.api_key = api_key
|
| 26 |
+
response = openai.Completion.create(
|
| 27 |
+
engine="text-davinci-003",
|
| 28 |
+
prompt=task,
|
| 29 |
+
max_tokens=150
|
| 30 |
+
)
|
| 31 |
+
return response.choices[0].text.strip()
|
| 32 |
+
except openai.error.AuthenticationError as e:
|
| 33 |
+
logging.error(f"API key error during autogpt_task: {e}")
|
| 34 |
+
return "API key error"
|
| 35 |
+
except ValueError as e:
|
| 36 |
+
logging.error(f"ValueError during autogpt_task: {e}")
|
| 37 |
+
return "ValueError: Missing API key"
|
| 38 |
+
except Exception as e:
|
| 39 |
+
logging.error(f"Error during autogpt_task: {e}")
|
| 40 |
+
return ""
|
| 41 |
+
|
| 42 |
+
def pinocchio_fact_check(self, text):
|
| 43 |
+
try:
|
| 44 |
+
url = "https://factchecktools.googleapis.com/v1alpha1/claims:search"
|
| 45 |
+
params = {
|
| 46 |
+
"query": text,
|
| 47 |
+
"key": os.getenv("FACT_CHECK_API_KEY")
|
| 48 |
+
}
|
| 49 |
+
response = requests.get(url, params=params)
|
| 50 |
+
response.raise_for_status()
|
| 51 |
+
result = response.json()
|
| 52 |
+
if "claims" in result:
|
| 53 |
+
return result["claims"]
|
| 54 |
+
else:
|
| 55 |
+
return "No claims found."
|
| 56 |
+
except requests.exceptions.HTTPError as e:
|
| 57 |
+
logging.error(f"HTTP error during pinocchio_fact_check: {e}")
|
| 58 |
+
return f"Error: {e}"
|
| 59 |
+
except Exception as e:
|
| 60 |
+
logging.error(f"Error during pinocchio_fact_check: {e}")
|
| 61 |
+
return ""
|
| 62 |
+
|
| 63 |
+
def save_analysis_to_db(self, source, title, links, error):
|
| 64 |
+
session = SessionLocal()
|
| 65 |
+
try:
|
| 66 |
+
analysis_result = DocumentAnalysis(
|
| 67 |
+
source=source,
|
| 68 |
+
title=title,
|
| 69 |
+
links=links,
|
| 70 |
+
error=error
|
| 71 |
+
)
|
| 72 |
+
session.add(analysis_result)
|
| 73 |
+
session.commit()
|
| 74 |
+
except Exception as e:
|
| 75 |
+
logging.error(f"Error saving analysis to database: {e}")
|
| 76 |
+
finally:
|
| 77 |
+
session.close()
|
| 78 |
+
|
| 79 |
+
if __name__ == "__main__":
|
| 80 |
+
manager = PipelineManager()
|
| 81 |
+
print(manager.autogpt_task("Generate a weekly report."))
|
| 82 |
+
print(manager.pinocchio_fact_check("Earth is flat."))
|
backend/sentiment_analysis.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
def analyze_sentiment(text):
|
| 5 |
+
sentiment_analyzer = pipeline("sentiment-analysis")
|
| 6 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
Basic foreground colors.
|
| 3 |
+
|
| 4 |
+
[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
| 5 |
+
*/
|
| 6 |
+
declare type ForegroundColor =
|
| 7 |
+
| 'black'
|
| 8 |
+
| 'red'
|
| 9 |
+
| 'green'
|
| 10 |
+
| 'yellow'
|
| 11 |
+
| 'blue'
|
| 12 |
+
| 'magenta'
|
| 13 |
+
| 'cyan'
|
| 14 |
+
| 'white'
|
| 15 |
+
| 'gray'
|
| 16 |
+
| 'grey'
|
| 17 |
+
| 'blackBright'
|
| 18 |
+
| 'redBright'
|
| 19 |
+
| 'greenBright'
|
| 20 |
+
| 'yellowBright'
|
| 21 |
+
| 'blueBright'
|
| 22 |
+
| 'magentaBright'
|
| 23 |
+
| 'cyanBright'
|
| 24 |
+
| 'whiteBright';
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
Basic background colors.
|
| 28 |
+
|
| 29 |
+
[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
| 30 |
+
*/
|
| 31 |
+
declare type BackgroundColor =
|
| 32 |
+
| 'bgBlack'
|
| 33 |
+
| 'bgRed'
|
| 34 |
+
| 'bgGreen'
|
| 35 |
+
| 'bgYellow'
|
| 36 |
+
| 'bgBlue'
|
| 37 |
+
| 'bgMagenta'
|
| 38 |
+
| 'bgCyan'
|
| 39 |
+
| 'bgWhite'
|
| 40 |
+
| 'bgGray'
|
| 41 |
+
| 'bgGrey'
|
| 42 |
+
| 'bgBlackBright'
|
| 43 |
+
| 'bgRedBright'
|
| 44 |
+
| 'bgGreenBright'
|
| 45 |
+
| 'bgYellowBright'
|
| 46 |
+
| 'bgBlueBright'
|
| 47 |
+
| 'bgMagentaBright'
|
| 48 |
+
| 'bgCyanBright'
|
| 49 |
+
| 'bgWhiteBright';
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
Basic colors.
|
| 53 |
+
|
| 54 |
+
[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
| 55 |
+
*/
|
| 56 |
+
declare type Color = ForegroundColor | BackgroundColor;
|
| 57 |
+
|
| 58 |
+
declare type Modifiers =
|
| 59 |
+
| 'reset'
|
| 60 |
+
| 'bold'
|
| 61 |
+
| 'dim'
|
| 62 |
+
| 'italic'
|
| 63 |
+
| 'underline'
|
| 64 |
+
| 'inverse'
|
| 65 |
+
| 'hidden'
|
| 66 |
+
| 'strikethrough'
|
| 67 |
+
| 'visible';
|
| 68 |
+
|
| 69 |
+
declare namespace chalk {
|
| 70 |
+
/**
|
| 71 |
+
Levels:
|
| 72 |
+
- `0` - All colors disabled.
|
| 73 |
+
- `1` - Basic 16 colors support.
|
| 74 |
+
- `2` - ANSI 256 colors support.
|
| 75 |
+
- `3` - Truecolor 16 million colors support.
|
| 76 |
+
*/
|
| 77 |
+
type Level = 0 | 1 | 2 | 3;
|
| 78 |
+
|
| 79 |
+
interface Options {
|
| 80 |
+
/**
|
| 81 |
+
Specify the color support for Chalk.
|
| 82 |
+
|
| 83 |
+
By default, color support is automatically detected based on the environment.
|
| 84 |
+
|
| 85 |
+
Levels:
|
| 86 |
+
- `0` - All colors disabled.
|
| 87 |
+
- `1` - Basic 16 colors support.
|
| 88 |
+
- `2` - ANSI 256 colors support.
|
| 89 |
+
- `3` - Truecolor 16 million colors support.
|
| 90 |
+
*/
|
| 91 |
+
level?: Level;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
Return a new Chalk instance.
|
| 96 |
+
*/
|
| 97 |
+
type Instance = new (options?: Options) => Chalk;
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
Detect whether the terminal supports color.
|
| 101 |
+
*/
|
| 102 |
+
interface ColorSupport {
|
| 103 |
+
/**
|
| 104 |
+
The color level used by Chalk.
|
| 105 |
+
*/
|
| 106 |
+
level: Level;
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
Return whether Chalk supports basic 16 colors.
|
| 110 |
+
*/
|
| 111 |
+
hasBasic: boolean;
|
| 112 |
+
|
| 113 |
+
/**
|
| 114 |
+
Return whether Chalk supports ANSI 256 colors.
|
| 115 |
+
*/
|
| 116 |
+
has256: boolean;
|
| 117 |
+
|
| 118 |
+
/**
|
| 119 |
+
Return whether Chalk supports Truecolor 16 million colors.
|
| 120 |
+
*/
|
| 121 |
+
has16m: boolean;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
interface ChalkFunction {
|
| 125 |
+
/**
|
| 126 |
+
Use a template string.
|
| 127 |
+
|
| 128 |
+
@remarks Template literals are unsupported for nested calls (see [issue #341](https://github.com/chalk/chalk/issues/341))
|
| 129 |
+
|
| 130 |
+
@example
|
| 131 |
+
```
|
| 132 |
+
import chalk = require('chalk');
|
| 133 |
+
|
| 134 |
+
log(chalk`
|
| 135 |
+
CPU: {red ${cpu.totalPercent}%}
|
| 136 |
+
RAM: {green ${ram.used / ram.total * 100}%}
|
| 137 |
+
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
| 138 |
+
`);
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
@example
|
| 142 |
+
```
|
| 143 |
+
import chalk = require('chalk');
|
| 144 |
+
|
| 145 |
+
log(chalk.red.bgBlack`2 + 3 = {bold ${2 + 3}}`)
|
| 146 |
+
```
|
| 147 |
+
*/
|
| 148 |
+
(text: TemplateStringsArray, ...placeholders: unknown[]): string;
|
| 149 |
+
|
| 150 |
+
(...text: unknown[]): string;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
interface Chalk extends ChalkFunction {
|
| 154 |
+
/**
|
| 155 |
+
Return a new Chalk instance.
|
| 156 |
+
*/
|
| 157 |
+
Instance: Instance;
|
| 158 |
+
|
| 159 |
+
/**
|
| 160 |
+
The color support for Chalk.
|
| 161 |
+
|
| 162 |
+
By default, color support is automatically detected based on the environment.
|
| 163 |
+
|
| 164 |
+
Levels:
|
| 165 |
+
- `0` - All colors disabled.
|
| 166 |
+
- `1` - Basic 16 colors support.
|
| 167 |
+
- `2` - ANSI 256 colors support.
|
| 168 |
+
- `3` - Truecolor 16 million colors support.
|
| 169 |
+
*/
|
| 170 |
+
level: Level;
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
Use HEX value to set text color.
|
| 174 |
+
|
| 175 |
+
@param color - Hexadecimal value representing the desired color.
|
| 176 |
+
|
| 177 |
+
@example
|
| 178 |
+
```
|
| 179 |
+
import chalk = require('chalk');
|
| 180 |
+
|
| 181 |
+
chalk.hex('#DEADED');
|
| 182 |
+
```
|
| 183 |
+
*/
|
| 184 |
+
hex(color: string): Chalk;
|
| 185 |
+
|
| 186 |
+
/**
|
| 187 |
+
Use keyword color value to set text color.
|
| 188 |
+
|
| 189 |
+
@param color - Keyword value representing the desired color.
|
| 190 |
+
|
| 191 |
+
@example
|
| 192 |
+
```
|
| 193 |
+
import chalk = require('chalk');
|
| 194 |
+
|
| 195 |
+
chalk.keyword('orange');
|
| 196 |
+
```
|
| 197 |
+
*/
|
| 198 |
+
keyword(color: string): Chalk;
|
| 199 |
+
|
| 200 |
+
/**
|
| 201 |
+
Use RGB values to set text color.
|
| 202 |
+
*/
|
| 203 |
+
rgb(red: number, green: number, blue: number): Chalk;
|
| 204 |
+
|
| 205 |
+
/**
|
| 206 |
+
Use HSL values to set text color.
|
| 207 |
+
*/
|
| 208 |
+
hsl(hue: number, saturation: number, lightness: number): Chalk;
|
| 209 |
+
|
| 210 |
+
/**
|
| 211 |
+
Use HSV values to set text color.
|
| 212 |
+
*/
|
| 213 |
+
hsv(hue: number, saturation: number, value: number): Chalk;
|
| 214 |
+
|
| 215 |
+
/**
|
| 216 |
+
Use HWB values to set text color.
|
| 217 |
+
*/
|
| 218 |
+
hwb(hue: number, whiteness: number, blackness: number): Chalk;
|
| 219 |
+
|
| 220 |
+
/**
|
| 221 |
+
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set text color.
|
| 222 |
+
|
| 223 |
+
30 <= code && code < 38 || 90 <= code && code < 98
|
| 224 |
+
For example, 31 for red, 91 for redBright.
|
| 225 |
+
*/
|
| 226 |
+
ansi(code: number): Chalk;
|
| 227 |
+
|
| 228 |
+
/**
|
| 229 |
+
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
| 230 |
+
*/
|
| 231 |
+
ansi256(index: number): Chalk;
|
| 232 |
+
|
| 233 |
+
/**
|
| 234 |
+
Use HEX value to set background color.
|
| 235 |
+
|
| 236 |
+
@param color - Hexadecimal value representing the desired color.
|
| 237 |
+
|
| 238 |
+
@example
|
| 239 |
+
```
|
| 240 |
+
import chalk = require('chalk');
|
| 241 |
+
|
| 242 |
+
chalk.bgHex('#DEADED');
|
| 243 |
+
```
|
| 244 |
+
*/
|
| 245 |
+
bgHex(color: string): Chalk;
|
| 246 |
+
|
| 247 |
+
/**
|
| 248 |
+
Use keyword color value to set background color.
|
| 249 |
+
|
| 250 |
+
@param color - Keyword value representing the desired color.
|
| 251 |
+
|
| 252 |
+
@example
|
| 253 |
+
```
|
| 254 |
+
import chalk = require('chalk');
|
| 255 |
+
|
| 256 |
+
chalk.bgKeyword('orange');
|
| 257 |
+
```
|
| 258 |
+
*/
|
| 259 |
+
bgKeyword(color: string): Chalk;
|
| 260 |
+
|
| 261 |
+
/**
|
| 262 |
+
Use RGB values to set background color.
|
| 263 |
+
*/
|
| 264 |
+
bgRgb(red: number, green: number, blue: number): Chalk;
|
| 265 |
+
|
| 266 |
+
/**
|
| 267 |
+
Use HSL values to set background color.
|
| 268 |
+
*/
|
| 269 |
+
bgHsl(hue: number, saturation: number, lightness: number): Chalk;
|
| 270 |
+
|
| 271 |
+
/**
|
| 272 |
+
Use HSV values to set background color.
|
| 273 |
+
*/
|
| 274 |
+
bgHsv(hue: number, saturation: number, value: number): Chalk;
|
| 275 |
+
|
| 276 |
+
/**
|
| 277 |
+
Use HWB values to set background color.
|
| 278 |
+
*/
|
| 279 |
+
bgHwb(hue: number, whiteness: number, blackness: number): Chalk;
|
| 280 |
+
|
| 281 |
+
/**
|
| 282 |
+
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set background color.
|
| 283 |
+
|
| 284 |
+
30 <= code && code < 38 || 90 <= code && code < 98
|
| 285 |
+
For example, 31 for red, 91 for redBright.
|
| 286 |
+
Use the foreground code, not the background code (for example, not 41, nor 101).
|
| 287 |
+
*/
|
| 288 |
+
bgAnsi(code: number): Chalk;
|
| 289 |
+
|
| 290 |
+
/**
|
| 291 |
+
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
|
| 292 |
+
*/
|
| 293 |
+
bgAnsi256(index: number): Chalk;
|
| 294 |
+
|
| 295 |
+
/**
|
| 296 |
+
Modifier: Resets the current color chain.
|
| 297 |
+
*/
|
| 298 |
+
readonly reset: Chalk;
|
| 299 |
+
|
| 300 |
+
/**
|
| 301 |
+
Modifier: Make text bold.
|
| 302 |
+
*/
|
| 303 |
+
readonly bold: Chalk;
|
| 304 |
+
|
| 305 |
+
/**
|
| 306 |
+
Modifier: Emitting only a small amount of light.
|
| 307 |
+
*/
|
| 308 |
+
readonly dim: Chalk;
|
| 309 |
+
|
| 310 |
+
/**
|
| 311 |
+
Modifier: Make text italic. (Not widely supported)
|
| 312 |
+
*/
|
| 313 |
+
readonly italic: Chalk;
|
| 314 |
+
|
| 315 |
+
/**
|
| 316 |
+
Modifier: Make text underline. (Not widely supported)
|
| 317 |
+
*/
|
| 318 |
+
readonly underline: Chalk;
|
| 319 |
+
|
| 320 |
+
/**
|
| 321 |
+
Modifier: Inverse background and foreground colors.
|
| 322 |
+
*/
|
| 323 |
+
readonly inverse: Chalk;
|
| 324 |
+
|
| 325 |
+
/**
|
| 326 |
+
Modifier: Prints the text, but makes it invisible.
|
| 327 |
+
*/
|
| 328 |
+
readonly hidden: Chalk;
|
| 329 |
+
|
| 330 |
+
/**
|
| 331 |
+
Modifier: Puts a horizontal line through the center of the text. (Not widely supported)
|
| 332 |
+
*/
|
| 333 |
+
readonly strikethrough: Chalk;
|
| 334 |
+
|
| 335 |
+
/**
|
| 336 |
+
Modifier: Prints the text only when Chalk has a color support level > 0.
|
| 337 |
+
Can be useful for things that are purely cosmetic.
|
| 338 |
+
*/
|
| 339 |
+
readonly visible: Chalk;
|
| 340 |
+
|
| 341 |
+
readonly black: Chalk;
|
| 342 |
+
readonly red: Chalk;
|
| 343 |
+
readonly green: Chalk;
|
| 344 |
+
readonly yellow: Chalk;
|
| 345 |
+
readonly blue: Chalk;
|
| 346 |
+
readonly magenta: Chalk;
|
| 347 |
+
readonly cyan: Chalk;
|
| 348 |
+
readonly white: Chalk;
|
| 349 |
+
|
| 350 |
+
/*
|
| 351 |
+
Alias for `blackBright`.
|
| 352 |
+
*/
|
| 353 |
+
readonly gray: Chalk;
|
| 354 |
+
|
| 355 |
+
/*
|
| 356 |
+
Alias for `blackBright`.
|
| 357 |
+
*/
|
| 358 |
+
readonly grey: Chalk;
|
| 359 |
+
|
| 360 |
+
readonly blackBright: Chalk;
|
| 361 |
+
readonly redBright: Chalk;
|
| 362 |
+
readonly greenBright: Chalk;
|
| 363 |
+
readonly yellowBright: Chalk;
|
| 364 |
+
readonly blueBright: Chalk;
|
| 365 |
+
readonly magentaBright: Chalk;
|
| 366 |
+
readonly cyanBright: Chalk;
|
| 367 |
+
readonly whiteBright: Chalk;
|
| 368 |
+
|
| 369 |
+
readonly bgBlack: Chalk;
|
| 370 |
+
readonly bgRed: Chalk;
|
| 371 |
+
readonly bgGreen: Chalk;
|
| 372 |
+
readonly bgYellow: Chalk;
|
| 373 |
+
readonly bgBlue: Chalk;
|
| 374 |
+
readonly bgMagenta: Chalk;
|
| 375 |
+
readonly bgCyan: Chalk;
|
| 376 |
+
readonly bgWhite: Chalk;
|
| 377 |
+
|
| 378 |
+
/*
|
| 379 |
+
Alias for `bgBlackBright`.
|
| 380 |
+
*/
|
| 381 |
+
readonly bgGray: Chalk;
|
| 382 |
+
|
| 383 |
+
/*
|
| 384 |
+
Alias for `bgBlackBright`.
|
| 385 |
+
*/
|
| 386 |
+
readonly bgGrey: Chalk;
|
| 387 |
+
|
| 388 |
+
readonly bgBlackBright: Chalk;
|
| 389 |
+
readonly bgRedBright: Chalk;
|
| 390 |
+
readonly bgGreenBright: Chalk;
|
| 391 |
+
readonly bgYellowBright: Chalk;
|
| 392 |
+
readonly bgBlueBright: Chalk;
|
| 393 |
+
readonly bgMagentaBright: Chalk;
|
| 394 |
+
readonly bgCyanBright: Chalk;
|
| 395 |
+
readonly bgWhiteBright: Chalk;
|
| 396 |
+
}
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
/**
|
| 400 |
+
Main Chalk object that allows to chain styles together.
|
| 401 |
+
Call the last one as a method with a string argument.
|
| 402 |
+
Order doesn't matter, and later styles take precedent in case of a conflict.
|
| 403 |
+
This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
| 404 |
+
*/
|
| 405 |
+
declare const chalk: chalk.Chalk & chalk.ChalkFunction & {
|
| 406 |
+
supportsColor: chalk.ColorSupport | false;
|
| 407 |
+
Level: chalk.Level;
|
| 408 |
+
Color: Color;
|
| 409 |
+
ForegroundColor: ForegroundColor;
|
| 410 |
+
BackgroundColor: BackgroundColor;
|
| 411 |
+
Modifiers: Modifiers;
|
| 412 |
+
stderr: chalk.Chalk & {supportsColor: chalk.ColorSupport | false};
|
| 413 |
+
};
|
| 414 |
+
|
| 415 |
+
export = chalk;
|
chalk/license
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
| 6 |
+
|
| 7 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 8 |
+
|
| 9 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
chalk/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "chalk",
|
| 3 |
+
"version": "4.1.2",
|
| 4 |
+
"description": "Terminal string styling done right",
|
| 5 |
+
"license": "MIT",
|
| 6 |
+
"repository": "chalk/chalk",
|
| 7 |
+
"funding": "https://github.com/chalk/chalk?sponsor=1",
|
| 8 |
+
"main": "source",
|
| 9 |
+
"engines": {
|
| 10 |
+
"node": ">=10"
|
| 11 |
+
},
|
| 12 |
+
"scripts": {
|
| 13 |
+
"test": "xo && nyc ava && tsd",
|
| 14 |
+
"bench": "matcha benchmark.js"
|
| 15 |
+
},
|
| 16 |
+
"files": [
|
| 17 |
+
"source",
|
| 18 |
+
"index.d.ts"
|
| 19 |
+
],
|
| 20 |
+
"keywords": [
|
| 21 |
+
"color",
|
| 22 |
+
"colour",
|
| 23 |
+
"colors",
|
| 24 |
+
"terminal",
|
| 25 |
+
"console",
|
| 26 |
+
"cli",
|
| 27 |
+
"string",
|
| 28 |
+
"str",
|
| 29 |
+
"ansi",
|
| 30 |
+
"style",
|
| 31 |
+
"styles",
|
| 32 |
+
"tty",
|
| 33 |
+
"formatting",
|
| 34 |
+
"rgb",
|
| 35 |
+
"256",
|
| 36 |
+
"shell",
|
| 37 |
+
"xterm",
|
| 38 |
+
"log",
|
| 39 |
+
"logging",
|
| 40 |
+
"command-line",
|
| 41 |
+
"text"
|
| 42 |
+
],
|
| 43 |
+
"dependencies": {
|
| 44 |
+
"ansi-styles": "^4.1.0",
|
| 45 |
+
"supports-color": "^7.1.0"
|
| 46 |
+
},
|
| 47 |
+
"devDependencies": {
|
| 48 |
+
"ava": "^2.4.0",
|
| 49 |
+
"coveralls": "^3.0.7",
|
| 50 |
+
"execa": "^4.0.0",
|
| 51 |
+
"import-fresh": "^3.1.0",
|
| 52 |
+
"matcha": "^0.7.0",
|
| 53 |
+
"nyc": "^15.0.0",
|
| 54 |
+
"resolve-from": "^5.0.0",
|
| 55 |
+
"tsd": "^0.7.4",
|
| 56 |
+
"xo": "^0.28.2"
|
| 57 |
+
},
|
| 58 |
+
"xo": {
|
| 59 |
+
"rules": {
|
| 60 |
+
"unicorn/prefer-string-slice": "off",
|
| 61 |
+
"unicorn/prefer-includes": "off",
|
| 62 |
+
"@typescript-eslint/member-ordering": "off",
|
| 63 |
+
"no-redeclare": "off",
|
| 64 |
+
"unicorn/string-content": "off",
|
| 65 |
+
"unicorn/better-regex": "off"
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
}
|
chalk/readme.md
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 10 |
+
> Terminal string styling done right
|
| 11 |
+
|
| 12 |
+
[](https://travis-ci.org/chalk/chalk) [](https://coveralls.io/github/chalk/chalk?branch=master) [](https://www.npmjs.com/package/chalk?activeTab=dependents) [](https://www.npmjs.com/package/chalk) [](https://www.youtube.com/watch?v=9auOCbH5Ns4) [](https://github.com/xojs/xo)  [](https://repl.it/github/chalk/chalk)
|
| 13 |
+
|
| 14 |
+
<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
|
| 15 |
+
|
| 16 |
+
<br>
|
| 17 |
+
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
<div align="center">
|
| 21 |
+
<p>
|
| 22 |
+
<p>
|
| 23 |
+
<sup>
|
| 24 |
+
Sindre Sorhus' open source work is supported by the community on <a href="https://github.com/sponsors/sindresorhus">GitHub Sponsors</a> and <a href="https://stakes.social/0x44d871aebF0126Bf646753E2C976Aa7e68A66c15">Dev</a>
|
| 25 |
+
</sup>
|
| 26 |
+
</p>
|
| 27 |
+
<sup>Special thanks to:</sup>
|
| 28 |
+
<br>
|
| 29 |
+
<br>
|
| 30 |
+
<a href="https://standardresume.co/tech">
|
| 31 |
+
<img src="https://sindresorhus.com/assets/thanks/standard-resume-logo.svg" width="160"/>
|
| 32 |
+
</a>
|
| 33 |
+
<br>
|
| 34 |
+
<br>
|
| 35 |
+
<a href="https://retool.com/?utm_campaign=sindresorhus">
|
| 36 |
+
<img src="https://sindresorhus.com/assets/thanks/retool-logo.svg" width="230"/>
|
| 37 |
+
</a>
|
| 38 |
+
<br>
|
| 39 |
+
<br>
|
| 40 |
+
<a href="https://doppler.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=chalk&utm_source=github">
|
| 41 |
+
<div>
|
| 42 |
+
<img src="https://dashboard.doppler.com/imgs/logo-long.svg" width="240" alt="Doppler">
|
| 43 |
+
</div>
|
| 44 |
+
<b>All your environment variables, in one place</b>
|
| 45 |
+
<div>
|
| 46 |
+
<span>Stop struggling with scattered API keys, hacking together home-brewed tools,</span>
|
| 47 |
+
<br>
|
| 48 |
+
<span>and avoiding access controls. Keep your team and servers in sync with Doppler.</span>
|
| 49 |
+
</div>
|
| 50 |
+
</a>
|
| 51 |
+
<br>
|
| 52 |
+
<a href="https://uibakery.io/?utm_source=chalk&utm_medium=sponsor&utm_campaign=github">
|
| 53 |
+
<div>
|
| 54 |
+
<img src="https://sindresorhus.com/assets/thanks/uibakery-logo.jpg" width="270" alt="UI Bakery">
|
| 55 |
+
</div>
|
| 56 |
+
</a>
|
| 57 |
+
</p>
|
| 58 |
+
</div>
|
| 59 |
+
|
| 60 |
+
---
|
| 61 |
+
|
| 62 |
+
<br>
|
| 63 |
+
|
| 64 |
+
## Highlights
|
| 65 |
+
|
| 66 |
+
- Expressive API
|
| 67 |
+
- Highly performant
|
| 68 |
+
- Ability to nest styles
|
| 69 |
+
- [256/Truecolor color support](#256-and-truecolor-color-support)
|
| 70 |
+
- Auto-detects color support
|
| 71 |
+
- Doesn't extend `String.prototype`
|
| 72 |
+
- Clean and focused
|
| 73 |
+
- Actively maintained
|
| 74 |
+
- [Used by ~50,000 packages](https://www.npmjs.com/browse/depended/chalk) as of January 1, 2020
|
| 75 |
+
|
| 76 |
+
## Install
|
| 77 |
+
|
| 78 |
+
```console
|
| 79 |
+
$ npm install chalk
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
## Usage
|
| 83 |
+
|
| 84 |
+
```js
|
| 85 |
+
const chalk = require('chalk');
|
| 86 |
+
|
| 87 |
+
console.log(chalk.blue('Hello world!'));
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
|
| 91 |
+
|
| 92 |
+
```js
|
| 93 |
+
const chalk = require('chalk');
|
| 94 |
+
const log = console.log;
|
| 95 |
+
|
| 96 |
+
// Combine styled and normal strings
|
| 97 |
+
log(chalk.blue('Hello') + ' World' + chalk.red('!'));
|
| 98 |
+
|
| 99 |
+
// Compose multiple styles using the chainable API
|
| 100 |
+
log(chalk.blue.bgRed.bold('Hello world!'));
|
| 101 |
+
|
| 102 |
+
// Pass in multiple arguments
|
| 103 |
+
log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
|
| 104 |
+
|
| 105 |
+
// Nest styles
|
| 106 |
+
log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));
|
| 107 |
+
|
| 108 |
+
// Nest styles of the same type even (color, underline, background)
|
| 109 |
+
log(chalk.green(
|
| 110 |
+
'I am a green line ' +
|
| 111 |
+
chalk.blue.underline.bold('with a blue substring') +
|
| 112 |
+
' that becomes green again!'
|
| 113 |
+
));
|
| 114 |
+
|
| 115 |
+
// ES2015 template literal
|
| 116 |
+
log(`
|
| 117 |
+
CPU: ${chalk.red('90%')}
|
| 118 |
+
RAM: ${chalk.green('40%')}
|
| 119 |
+
DISK: ${chalk.yellow('70%')}
|
| 120 |
+
`);
|
| 121 |
+
|
| 122 |
+
// ES2015 tagged template literal
|
| 123 |
+
log(chalk`
|
| 124 |
+
CPU: {red ${cpu.totalPercent}%}
|
| 125 |
+
RAM: {green ${ram.used / ram.total * 100}%}
|
| 126 |
+
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
| 127 |
+
`);
|
| 128 |
+
|
| 129 |
+
// Use RGB colors in terminal emulators that support it.
|
| 130 |
+
log(chalk.keyword('orange')('Yay for orange colored text!'));
|
| 131 |
+
log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
|
| 132 |
+
log(chalk.hex('#DEADED').bold('Bold gray!'));
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
Easily define your own themes:
|
| 136 |
+
|
| 137 |
+
```js
|
| 138 |
+
const chalk = require('chalk');
|
| 139 |
+
|
| 140 |
+
const error = chalk.bold.red;
|
| 141 |
+
const warning = chalk.keyword('orange');
|
| 142 |
+
|
| 143 |
+
console.log(error('Error!'));
|
| 144 |
+
console.log(warning('Warning!'));
|
| 145 |
+
```
|
| 146 |
+
|
| 147 |
+
Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
|
| 148 |
+
|
| 149 |
+
```js
|
| 150 |
+
const name = 'Sindre';
|
| 151 |
+
console.log(chalk.green('Hello %s'), name);
|
| 152 |
+
//=> 'Hello Sindre'
|
| 153 |
+
```
|
| 154 |
+
|
| 155 |
+
## API
|
| 156 |
+
|
| 157 |
+
### chalk.`<style>[.<style>...](string, [string...])`
|
| 158 |
+
|
| 159 |
+
Example: `chalk.red.bold.underline('Hello', 'world');`
|
| 160 |
+
|
| 161 |
+
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
| 162 |
+
|
| 163 |
+
Multiple arguments will be separated by space.
|
| 164 |
+
|
| 165 |
+
### chalk.level
|
| 166 |
+
|
| 167 |
+
Specifies the level of color support.
|
| 168 |
+
|
| 169 |
+
Color support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all Chalk consumers.
|
| 170 |
+
|
| 171 |
+
If you need to change this in a reusable module, create a new instance:
|
| 172 |
+
|
| 173 |
+
```js
|
| 174 |
+
const ctx = new chalk.Instance({level: 0});
|
| 175 |
+
```
|
| 176 |
+
|
| 177 |
+
| Level | Description |
|
| 178 |
+
| :---: | :--- |
|
| 179 |
+
| `0` | All colors disabled |
|
| 180 |
+
| `1` | Basic color support (16 colors) |
|
| 181 |
+
| `2` | 256 color support |
|
| 182 |
+
| `3` | Truecolor support (16 million colors) |
|
| 183 |
+
|
| 184 |
+
### chalk.supportsColor
|
| 185 |
+
|
| 186 |
+
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
|
| 187 |
+
|
| 188 |
+
Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
|
| 189 |
+
|
| 190 |
+
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
| 191 |
+
|
| 192 |
+
### chalk.stderr and chalk.stderr.supportsColor
|
| 193 |
+
|
| 194 |
+
`chalk.stderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `chalk.supportsColor` apply to this too. `chalk.stderr.supportsColor` is exposed for convenience.
|
| 195 |
+
|
| 196 |
+
## Styles
|
| 197 |
+
|
| 198 |
+
### Modifiers
|
| 199 |
+
|
| 200 |
+
- `reset` - Resets the current color chain.
|
| 201 |
+
- `bold` - Make text bold.
|
| 202 |
+
- `dim` - Emitting only a small amount of light.
|
| 203 |
+
- `italic` - Make text italic. *(Not widely supported)*
|
| 204 |
+
- `underline` - Make text underline. *(Not widely supported)*
|
| 205 |
+
- `inverse`- Inverse background and foreground colors.
|
| 206 |
+
- `hidden` - Prints the text, but makes it invisible.
|
| 207 |
+
- `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)*
|
| 208 |
+
- `visible`- Prints the text only when Chalk has a color level > 0. Can be useful for things that are purely cosmetic.
|
| 209 |
+
|
| 210 |
+
### Colors
|
| 211 |
+
|
| 212 |
+
- `black`
|
| 213 |
+
- `red`
|
| 214 |
+
- `green`
|
| 215 |
+
- `yellow`
|
| 216 |
+
- `blue`
|
| 217 |
+
- `magenta`
|
| 218 |
+
- `cyan`
|
| 219 |
+
- `white`
|
| 220 |
+
- `blackBright` (alias: `gray`, `grey`)
|
| 221 |
+
- `redBright`
|
| 222 |
+
- `greenBright`
|
| 223 |
+
- `yellowBright`
|
| 224 |
+
- `blueBright`
|
| 225 |
+
- `magentaBright`
|
| 226 |
+
- `cyanBright`
|
| 227 |
+
- `whiteBright`
|
| 228 |
+
|
| 229 |
+
### Background colors
|
| 230 |
+
|
| 231 |
+
- `bgBlack`
|
| 232 |
+
- `bgRed`
|
| 233 |
+
- `bgGreen`
|
| 234 |
+
- `bgYellow`
|
| 235 |
+
- `bgBlue`
|
| 236 |
+
- `bgMagenta`
|
| 237 |
+
- `bgCyan`
|
| 238 |
+
- `bgWhite`
|
| 239 |
+
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
|
| 240 |
+
- `bgRedBright`
|
| 241 |
+
- `bgGreenBright`
|
| 242 |
+
- `bgYellowBright`
|
| 243 |
+
- `bgBlueBright`
|
| 244 |
+
- `bgMagentaBright`
|
| 245 |
+
- `bgCyanBright`
|
| 246 |
+
- `bgWhiteBright`
|
| 247 |
+
|
| 248 |
+
## Tagged template literal
|
| 249 |
+
|
| 250 |
+
Chalk can be used as a [tagged template literal](https://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
|
| 251 |
+
|
| 252 |
+
```js
|
| 253 |
+
const chalk = require('chalk');
|
| 254 |
+
|
| 255 |
+
const miles = 18;
|
| 256 |
+
const calculateFeet = miles => miles * 5280;
|
| 257 |
+
|
| 258 |
+
console.log(chalk`
|
| 259 |
+
There are {bold 5280 feet} in a mile.
|
| 260 |
+
In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
|
| 261 |
+
`);
|
| 262 |
+
```
|
| 263 |
+
|
| 264 |
+
Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
|
| 265 |
+
|
| 266 |
+
Template styles are chained exactly like normal Chalk styles. The following three statements are equivalent:
|
| 267 |
+
|
| 268 |
+
```js
|
| 269 |
+
console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
|
| 270 |
+
console.log(chalk.bold.rgb(10, 100, 200)`Hello!`);
|
| 271 |
+
console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
|
| 272 |
+
```
|
| 273 |
+
|
| 274 |
+
Note that function styles (`rgb()`, `hsl()`, `keyword()`, etc.) may not contain spaces between parameters.
|
| 275 |
+
|
| 276 |
+
All interpolated values (`` chalk`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
|
| 277 |
+
|
| 278 |
+
## 256 and Truecolor color support
|
| 279 |
+
|
| 280 |
+
Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
|
| 281 |
+
|
| 282 |
+
Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
|
| 283 |
+
|
| 284 |
+
Examples:
|
| 285 |
+
|
| 286 |
+
- `chalk.hex('#DEADED').underline('Hello, world!')`
|
| 287 |
+
- `chalk.keyword('orange')('Some orange text')`
|
| 288 |
+
- `chalk.rgb(15, 100, 204).inverse('Hello!')`
|
| 289 |
+
|
| 290 |
+
Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `keyword` for foreground colors and `bgKeyword` for background colors).
|
| 291 |
+
|
| 292 |
+
- `chalk.bgHex('#DEADED').underline('Hello, world!')`
|
| 293 |
+
- `chalk.bgKeyword('orange')('Some orange text')`
|
| 294 |
+
- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
|
| 295 |
+
|
| 296 |
+
The following color models can be used:
|
| 297 |
+
|
| 298 |
+
- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
|
| 299 |
+
- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
|
| 300 |
+
- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
|
| 301 |
+
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
|
| 302 |
+
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
|
| 303 |
+
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
|
| 304 |
+
- [`ansi`](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) - Example: `chalk.ansi(31).bgAnsi(93)('red on yellowBright')`
|
| 305 |
+
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
|
| 306 |
+
|
| 307 |
+
## Windows
|
| 308 |
+
|
| 309 |
+
If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
|
| 310 |
+
|
| 311 |
+
## Origin story
|
| 312 |
+
|
| 313 |
+
[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative.
|
| 314 |
+
|
| 315 |
+
## chalk for enterprise
|
| 316 |
+
|
| 317 |
+
Available as part of the Tidelift Subscription.
|
| 318 |
+
|
| 319 |
+
The maintainers of chalk and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-chalk?utm_source=npm-chalk&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
| 320 |
+
|
| 321 |
+
## Related
|
| 322 |
+
|
| 323 |
+
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
|
| 324 |
+
- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
|
| 325 |
+
- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
|
| 326 |
+
- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
|
| 327 |
+
- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Strip ANSI escape codes from a stream
|
| 328 |
+
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
|
| 329 |
+
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
|
| 330 |
+
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
|
| 331 |
+
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
|
| 332 |
+
- [color-convert](https://github.com/qix-/color-convert) - Converts colors between different models
|
| 333 |
+
- [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal
|
| 334 |
+
- [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings
|
| 335 |
+
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
|
| 336 |
+
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
|
| 337 |
+
|
| 338 |
+
## Maintainers
|
| 339 |
+
|
| 340 |
+
- [Sindre Sorhus](https://github.com/sindresorhus)
|
| 341 |
+
- [Josh Junon](https://github.com/qix-)
|
chalk/source/index.js
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
const ansiStyles = require('ansi-styles');
|
| 3 |
+
const {stdout: stdoutColor, stderr: stderrColor} = require('supports-color');
|
| 4 |
+
const {
|
| 5 |
+
stringReplaceAll,
|
| 6 |
+
stringEncaseCRLFWithFirstIndex
|
| 7 |
+
} = require('./util');
|
| 8 |
+
|
| 9 |
+
const {isArray} = Array;
|
| 10 |
+
|
| 11 |
+
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
| 12 |
+
const levelMapping = [
|
| 13 |
+
'ansi',
|
| 14 |
+
'ansi',
|
| 15 |
+
'ansi256',
|
| 16 |
+
'ansi16m'
|
| 17 |
+
];
|
| 18 |
+
|
| 19 |
+
const styles = Object.create(null);
|
| 20 |
+
|
| 21 |
+
const applyOptions = (object, options = {}) => {
|
| 22 |
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
| 23 |
+
throw new Error('The `level` option should be an integer from 0 to 3');
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
// Detect level if not set manually
|
| 27 |
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
| 28 |
+
object.level = options.level === undefined ? colorLevel : options.level;
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
+
class ChalkClass {
|
| 32 |
+
constructor(options) {
|
| 33 |
+
// eslint-disable-next-line no-constructor-return
|
| 34 |
+
return chalkFactory(options);
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
const chalkFactory = options => {
|
| 39 |
+
const chalk = {};
|
| 40 |
+
applyOptions(chalk, options);
|
| 41 |
+
|
| 42 |
+
chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
|
| 43 |
+
|
| 44 |
+
Object.setPrototypeOf(chalk, Chalk.prototype);
|
| 45 |
+
Object.setPrototypeOf(chalk.template, chalk);
|
| 46 |
+
|
| 47 |
+
chalk.template.constructor = () => {
|
| 48 |
+
throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
|
| 49 |
+
};
|
| 50 |
+
|
| 51 |
+
chalk.template.Instance = ChalkClass;
|
| 52 |
+
|
| 53 |
+
return chalk.template;
|
| 54 |
+
};
|
| 55 |
+
|
| 56 |
+
function Chalk(options) {
|
| 57 |
+
return chalkFactory(options);
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
| 61 |
+
styles[styleName] = {
|
| 62 |
+
get() {
|
| 63 |
+
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
| 64 |
+
Object.defineProperty(this, styleName, {value: builder});
|
| 65 |
+
return builder;
|
| 66 |
+
}
|
| 67 |
+
};
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
styles.visible = {
|
| 71 |
+
get() {
|
| 72 |
+
const builder = createBuilder(this, this._styler, true);
|
| 73 |
+
Object.defineProperty(this, 'visible', {value: builder});
|
| 74 |
+
return builder;
|
| 75 |
+
}
|
| 76 |
+
};
|
| 77 |
+
|
| 78 |
+
const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
|
| 79 |
+
|
| 80 |
+
for (const model of usedModels) {
|
| 81 |
+
styles[model] = {
|
| 82 |
+
get() {
|
| 83 |
+
const {level} = this;
|
| 84 |
+
return function (...arguments_) {
|
| 85 |
+
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
| 86 |
+
return createBuilder(this, styler, this._isEmpty);
|
| 87 |
+
};
|
| 88 |
+
}
|
| 89 |
+
};
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
for (const model of usedModels) {
|
| 93 |
+
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
| 94 |
+
styles[bgModel] = {
|
| 95 |
+
get() {
|
| 96 |
+
const {level} = this;
|
| 97 |
+
return function (...arguments_) {
|
| 98 |
+
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
| 99 |
+
return createBuilder(this, styler, this._isEmpty);
|
| 100 |
+
};
|
| 101 |
+
}
|
| 102 |
+
};
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
const proto = Object.defineProperties(() => {}, {
|
| 106 |
+
...styles,
|
| 107 |
+
level: {
|
| 108 |
+
enumerable: true,
|
| 109 |
+
get() {
|
| 110 |
+
return this._generator.level;
|
| 111 |
+
},
|
| 112 |
+
set(level) {
|
| 113 |
+
this._generator.level = level;
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
});
|
| 117 |
+
|
| 118 |
+
const createStyler = (open, close, parent) => {
|
| 119 |
+
let openAll;
|
| 120 |
+
let closeAll;
|
| 121 |
+
if (parent === undefined) {
|
| 122 |
+
openAll = open;
|
| 123 |
+
closeAll = close;
|
| 124 |
+
} else {
|
| 125 |
+
openAll = parent.openAll + open;
|
| 126 |
+
closeAll = close + parent.closeAll;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
return {
|
| 130 |
+
open,
|
| 131 |
+
close,
|
| 132 |
+
openAll,
|
| 133 |
+
closeAll,
|
| 134 |
+
parent
|
| 135 |
+
};
|
| 136 |
+
};
|
| 137 |
+
|
| 138 |
+
const createBuilder = (self, _styler, _isEmpty) => {
|
| 139 |
+
const builder = (...arguments_) => {
|
| 140 |
+
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
| 141 |
+
// Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
|
| 142 |
+
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
// Single argument is hot path, implicit coercion is faster than anything
|
| 146 |
+
// eslint-disable-next-line no-implicit-coercion
|
| 147 |
+
return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
| 148 |
+
};
|
| 149 |
+
|
| 150 |
+
// We alter the prototype because we must return a function, but there is
|
| 151 |
+
// no way to create a function with a different prototype
|
| 152 |
+
Object.setPrototypeOf(builder, proto);
|
| 153 |
+
|
| 154 |
+
builder._generator = self;
|
| 155 |
+
builder._styler = _styler;
|
| 156 |
+
builder._isEmpty = _isEmpty;
|
| 157 |
+
|
| 158 |
+
return builder;
|
| 159 |
+
};
|
| 160 |
+
|
| 161 |
+
const applyStyle = (self, string) => {
|
| 162 |
+
if (self.level <= 0 || !string) {
|
| 163 |
+
return self._isEmpty ? '' : string;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
let styler = self._styler;
|
| 167 |
+
|
| 168 |
+
if (styler === undefined) {
|
| 169 |
+
return string;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
const {openAll, closeAll} = styler;
|
| 173 |
+
if (string.indexOf('\u001B') !== -1) {
|
| 174 |
+
while (styler !== undefined) {
|
| 175 |
+
// Replace any instances already present with a re-opening code
|
| 176 |
+
// otherwise only the part of the string until said closing code
|
| 177 |
+
// will be colored, and the rest will simply be 'plain'.
|
| 178 |
+
string = stringReplaceAll(string, styler.close, styler.open);
|
| 179 |
+
|
| 180 |
+
styler = styler.parent;
|
| 181 |
+
}
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
// We can move both next actions out of loop, because remaining actions in loop won't have
|
| 185 |
+
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
|
| 186 |
+
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
|
| 187 |
+
const lfIndex = string.indexOf('\n');
|
| 188 |
+
if (lfIndex !== -1) {
|
| 189 |
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
return openAll + string + closeAll;
|
| 193 |
+
};
|
| 194 |
+
|
| 195 |
+
let template;
|
| 196 |
+
const chalkTag = (chalk, ...strings) => {
|
| 197 |
+
const [firstString] = strings;
|
| 198 |
+
|
| 199 |
+
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
| 200 |
+
// If chalk() was called by itself or with a string,
|
| 201 |
+
// return the string itself as a string.
|
| 202 |
+
return strings.join(' ');
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
const arguments_ = strings.slice(1);
|
| 206 |
+
const parts = [firstString.raw[0]];
|
| 207 |
+
|
| 208 |
+
for (let i = 1; i < firstString.length; i++) {
|
| 209 |
+
parts.push(
|
| 210 |
+
String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
|
| 211 |
+
String(firstString.raw[i])
|
| 212 |
+
);
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
if (template === undefined) {
|
| 216 |
+
template = require('./templates');
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
return template(chalk, parts.join(''));
|
| 220 |
+
};
|
| 221 |
+
|
| 222 |
+
Object.defineProperties(Chalk.prototype, styles);
|
| 223 |
+
|
| 224 |
+
const chalk = Chalk(); // eslint-disable-line new-cap
|
| 225 |
+
chalk.supportsColor = stdoutColor;
|
| 226 |
+
chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
|
| 227 |
+
chalk.stderr.supportsColor = stderrColor;
|
| 228 |
+
|
| 229 |
+
module.exports = chalk;
|
chalk/source/templates.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
| 3 |
+
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
| 4 |
+
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
| 5 |
+
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
| 6 |
+
|
| 7 |
+
const ESCAPES = new Map([
|
| 8 |
+
['n', '\n'],
|
| 9 |
+
['r', '\r'],
|
| 10 |
+
['t', '\t'],
|
| 11 |
+
['b', '\b'],
|
| 12 |
+
['f', '\f'],
|
| 13 |
+
['v', '\v'],
|
| 14 |
+
['0', '\0'],
|
| 15 |
+
['\\', '\\'],
|
| 16 |
+
['e', '\u001B'],
|
| 17 |
+
['a', '\u0007']
|
| 18 |
+
]);
|
| 19 |
+
|
| 20 |
+
function unescape(c) {
|
| 21 |
+
const u = c[0] === 'u';
|
| 22 |
+
const bracket = c[1] === '{';
|
| 23 |
+
|
| 24 |
+
if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
|
| 25 |
+
return String.fromCharCode(parseInt(c.slice(1), 16));
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
if (u && bracket) {
|
| 29 |
+
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
return ESCAPES.get(c) || c;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
function parseArguments(name, arguments_) {
|
| 36 |
+
const results = [];
|
| 37 |
+
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
| 38 |
+
let matches;
|
| 39 |
+
|
| 40 |
+
for (const chunk of chunks) {
|
| 41 |
+
const number = Number(chunk);
|
| 42 |
+
if (!Number.isNaN(number)) {
|
| 43 |
+
results.push(number);
|
| 44 |
+
} else if ((matches = chunk.match(STRING_REGEX))) {
|
| 45 |
+
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
| 46 |
+
} else {
|
| 47 |
+
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
return results;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
function parseStyle(style) {
|
| 55 |
+
STYLE_REGEX.lastIndex = 0;
|
| 56 |
+
|
| 57 |
+
const results = [];
|
| 58 |
+
let matches;
|
| 59 |
+
|
| 60 |
+
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
| 61 |
+
const name = matches[1];
|
| 62 |
+
|
| 63 |
+
if (matches[2]) {
|
| 64 |
+
const args = parseArguments(name, matches[2]);
|
| 65 |
+
results.push([name].concat(args));
|
| 66 |
+
} else {
|
| 67 |
+
results.push([name]);
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
return results;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
function buildStyle(chalk, styles) {
|
| 75 |
+
const enabled = {};
|
| 76 |
+
|
| 77 |
+
for (const layer of styles) {
|
| 78 |
+
for (const style of layer.styles) {
|
| 79 |
+
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
let current = chalk;
|
| 84 |
+
for (const [styleName, styles] of Object.entries(enabled)) {
|
| 85 |
+
if (!Array.isArray(styles)) {
|
| 86 |
+
continue;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
if (!(styleName in current)) {
|
| 90 |
+
throw new Error(`Unknown Chalk style: ${styleName}`);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
return current;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
module.exports = (chalk, temporary) => {
|
| 100 |
+
const styles = [];
|
| 101 |
+
const chunks = [];
|
| 102 |
+
let chunk = [];
|
| 103 |
+
|
| 104 |
+
// eslint-disable-next-line max-params
|
| 105 |
+
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
| 106 |
+
if (escapeCharacter) {
|
| 107 |
+
chunk.push(unescape(escapeCharacter));
|
| 108 |
+
} else if (style) {
|
| 109 |
+
const string = chunk.join('');
|
| 110 |
+
chunk = [];
|
| 111 |
+
chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
|
| 112 |
+
styles.push({inverse, styles: parseStyle(style)});
|
| 113 |
+
} else if (close) {
|
| 114 |
+
if (styles.length === 0) {
|
| 115 |
+
throw new Error('Found extraneous } in Chalk template literal');
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
chunks.push(buildStyle(chalk, styles)(chunk.join('')));
|
| 119 |
+
chunk = [];
|
| 120 |
+
styles.pop();
|
| 121 |
+
} else {
|
| 122 |
+
chunk.push(character);
|
| 123 |
+
}
|
| 124 |
+
});
|
| 125 |
+
|
| 126 |
+
chunks.push(chunk.join(''));
|
| 127 |
+
|
| 128 |
+
if (styles.length > 0) {
|
| 129 |
+
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
| 130 |
+
throw new Error(errMessage);
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
return chunks.join('');
|
| 134 |
+
};
|
chalk/source/util.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
const stringReplaceAll = (string, substring, replacer) => {
|
| 4 |
+
let index = string.indexOf(substring);
|
| 5 |
+
if (index === -1) {
|
| 6 |
+
return string;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
const substringLength = substring.length;
|
| 10 |
+
let endIndex = 0;
|
| 11 |
+
let returnValue = '';
|
| 12 |
+
do {
|
| 13 |
+
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
| 14 |
+
endIndex = index + substringLength;
|
| 15 |
+
index = string.indexOf(substring, endIndex);
|
| 16 |
+
} while (index !== -1);
|
| 17 |
+
|
| 18 |
+
returnValue += string.substr(endIndex);
|
| 19 |
+
return returnValue;
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
|
| 23 |
+
let endIndex = 0;
|
| 24 |
+
let returnValue = '';
|
| 25 |
+
do {
|
| 26 |
+
const gotCR = string[index - 1] === '\r';
|
| 27 |
+
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
|
| 28 |
+
endIndex = index + 1;
|
| 29 |
+
index = string.indexOf('\n', endIndex);
|
| 30 |
+
} while (index !== -1);
|
| 31 |
+
|
| 32 |
+
returnValue += string.substr(endIndex);
|
| 33 |
+
return returnValue;
|
| 34 |
+
};
|
| 35 |
+
|
| 36 |
+
module.exports = {
|
| 37 |
+
stringReplaceAll,
|
| 38 |
+
stringEncaseCRLFWithFirstIndex
|
| 39 |
+
};
|
chatbot/app.py
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, render_template, request, jsonify
|
| 2 |
+
from database.models import DocumentAnalysis
|
| 3 |
+
from sqlalchemy import create_engine
|
| 4 |
+
from sqlalchemy.orm import sessionmaker
|
| 5 |
+
|
| 6 |
+
from modules.real_time_threat_intelligence import RealTimeThreatIntelligence
|
| 7 |
+
from modules.real_time_monitoring import RealTimeMonitoring
|
| 8 |
+
from modules.threat_intelligence import ThreatIntelligence
|
| 9 |
+
from modules.predictive_analytics import PredictiveAnalytics
|
| 10 |
+
from modules.automated_incident_response import AutomatedIncidentResponse
|
| 11 |
+
from modules.ai_red_teaming import AIRedTeaming
|
| 12 |
+
from modules.apt_simulation import APTSimulation
|
| 13 |
+
from modules.machine_learning_ai import MachineLearningAI
|
| 14 |
+
from modules.data_visualization import DataVisualization
|
| 15 |
+
from modules.blockchain_logger import BlockchainLogger
|
| 16 |
+
from modules.cloud_exploitation import CloudExploitation
|
| 17 |
+
from modules.iot_exploitation import IoTExploitation
|
| 18 |
+
from modules.quantum_computing import QuantumComputing
|
| 19 |
+
from modules.edge_computing import EdgeComputing
|
| 20 |
+
from modules.serverless_computing import ServerlessComputing
|
| 21 |
+
from modules.microservices_architecture import MicroservicesArchitecture
|
| 22 |
+
from modules.cloud_native_applications import CloudNativeApplications
|
| 23 |
+
from modules.advanced_decryption import AdvancedDecryption
|
| 24 |
+
from modules.advanced_malware_analysis import AdvancedMalwareAnalysis
|
| 25 |
+
from modules.advanced_social_engineering import AdvancedSocialEngineering
|
| 26 |
+
from modules.alerts_notifications import AlertsNotifications
|
| 27 |
+
from modules.device_fingerprinting import DeviceFingerprinting
|
| 28 |
+
from modules.exploit_payloads import ExploitPayloads
|
| 29 |
+
from modules.fuzzing_engine import FuzzingEngine
|
| 30 |
+
from modules.mitm_stingray import MITMStingray
|
| 31 |
+
from modules.network_exploitation import NetworkExploitation
|
| 32 |
+
from modules.vulnerability_scanner import VulnerabilityScanner
|
| 33 |
+
from modules.wireless_exploitation import WirelessExploitation
|
| 34 |
+
from modules.zero_day_exploits import ZeroDayExploits
|
| 35 |
+
|
| 36 |
+
from backend.code_parser import CodeParser
|
| 37 |
+
from backend.pipeline_manager import PipelineManager
|
| 38 |
+
|
| 39 |
+
from kafka import KafkaProducer, KafkaConsumer
|
| 40 |
+
|
| 41 |
+
import os
|
| 42 |
+
import logging
|
| 43 |
+
|
| 44 |
+
app = Flask(__name__)
|
| 45 |
+
|
| 46 |
+
DATABASE_URL = "sqlite:///document_analysis.db"
|
| 47 |
+
engine = create_engine(DATABASE_URL)
|
| 48 |
+
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
| 49 |
+
|
| 50 |
+
# Configure logging
|
| 51 |
+
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 52 |
+
|
| 53 |
+
def scan_network():
|
| 54 |
+
try:
|
| 55 |
+
# Placeholder function for scanning network
|
| 56 |
+
devices = ["Device1", "Device2", "Device3"]
|
| 57 |
+
return devices
|
| 58 |
+
except Exception as e:
|
| 59 |
+
logging.error(f"Error during network scanning: {e}")
|
| 60 |
+
return []
|
| 61 |
+
|
| 62 |
+
def deploy_exploit(target):
|
| 63 |
+
try:
|
| 64 |
+
# Placeholder function for deploying exploit
|
| 65 |
+
if target in ["Device1", "Device2", "Device3"]:
|
| 66 |
+
return "Exploit deployed successfully!"
|
| 67 |
+
return "Exploit deployment failed."
|
| 68 |
+
except Exception as e:
|
| 69 |
+
logging.error(f"Error during exploit deployment: {e}")
|
| 70 |
+
return "Exploit deployment failed."
|
| 71 |
+
|
| 72 |
+
def save_scan_results_to_db(source, title, links, error):
|
| 73 |
+
session = SessionLocal()
|
| 74 |
+
try:
|
| 75 |
+
scan_result = DocumentAnalysis(
|
| 76 |
+
source=source,
|
| 77 |
+
title=title,
|
| 78 |
+
links=links,
|
| 79 |
+
error=error
|
| 80 |
+
)
|
| 81 |
+
session.add(scan_result)
|
| 82 |
+
session.commit()
|
| 83 |
+
except Exception as e:
|
| 84 |
+
logging.error(f"Error saving scan results to database: {e}")
|
| 85 |
+
finally:
|
| 86 |
+
session.close()
|
| 87 |
+
|
| 88 |
+
@app.route('/')
|
| 89 |
+
def index():
|
| 90 |
+
return render_template('index.html')
|
| 91 |
+
|
| 92 |
+
@app.route('/scan_network', methods=['POST'])
|
| 93 |
+
def scan_network_endpoint():
|
| 94 |
+
devices = scan_network()
|
| 95 |
+
vulnerabilities = assess_vulnerabilities(devices)
|
| 96 |
+
save_scan_results_to_db("network_scan", "Network Scan Results", str(vulnerabilities), None)
|
| 97 |
+
return jsonify(vulnerabilities)
|
| 98 |
+
|
| 99 |
+
@app.route('/deploy_exploit', methods=['POST'])
|
| 100 |
+
def deploy_exploit_endpoint():
|
| 101 |
+
target = request.json.get('target')
|
| 102 |
+
result = deploy_exploit(target)
|
| 103 |
+
save_scan_results_to_db("exploit_deployment", "Exploit Deployment Results", target, result)
|
| 104 |
+
return jsonify({"result": result})
|
| 105 |
+
|
| 106 |
+
# Initialize real-time threat intelligence and monitoring modules
|
| 107 |
+
try:
|
| 108 |
+
threat_intelligence = RealTimeThreatIntelligence(api_key=os.getenv("REAL_TIME_THREAT_INTELLIGENCE_API_KEY"))
|
| 109 |
+
monitoring = RealTimeMonitoring(threat_intelligence_module=threat_intelligence)
|
| 110 |
+
except Exception as e:
|
| 111 |
+
logging.error(f"Error initializing real-time threat intelligence and monitoring modules: {e}")
|
| 112 |
+
|
| 113 |
+
# Initialize and integrate new modules in the main function
|
| 114 |
+
try:
|
| 115 |
+
advanced_threat_intelligence = ThreatIntelligence()
|
| 116 |
+
predictive_analytics = PredictiveAnalytics()
|
| 117 |
+
automated_incident_response = AutomatedIncidentResponse()
|
| 118 |
+
ai_red_teaming = AIRedTeaming()
|
| 119 |
+
apt_simulation = APTSimulation()
|
| 120 |
+
machine_learning_ai = MachineLearningAI()
|
| 121 |
+
data_visualization = DataVisualization()
|
| 122 |
+
blockchain_logger = BlockchainLogger()
|
| 123 |
+
cloud_exploitation = CloudExploitation()
|
| 124 |
+
iot_exploitation = IoTExploitation()
|
| 125 |
+
quantum_computing = QuantumComputing()
|
| 126 |
+
edge_computing = EdgeComputing()
|
| 127 |
+
serverless_computing = ServerlessComputing()
|
| 128 |
+
microservices_architecture = MicroservicesArchitecture()
|
| 129 |
+
cloud_native_applications = CloudNativeApplications()
|
| 130 |
+
advanced_decryption = AdvancedDecryption()
|
| 131 |
+
advanced_malware_analysis = AdvancedMalwareAnalysis()
|
| 132 |
+
advanced_social_engineering = AdvancedSocialEngineering()
|
| 133 |
+
alerts_notifications = AlertsNotifications(smtp_server=os.getenv("SMTP_SERVER"), smtp_port=int(os.getenv("SMTP_PORT")), smtp_user=os.getenv("SMTP_USER"), smtp_password=os.getenv("SMTP_PASSWORD"))
|
| 134 |
+
device_fingerprinting = DeviceFingerprinting()
|
| 135 |
+
exploit_payloads = ExploitPayloads()
|
| 136 |
+
fuzzing_engine = FuzzingEngine()
|
| 137 |
+
mitm_stingray = MITMStingray(interface="wlan0")
|
| 138 |
+
network_exploitation = NetworkExploitation()
|
| 139 |
+
vulnerability_scanner = VulnerabilityScanner()
|
| 140 |
+
wireless_exploitation = WirelessExploitation()
|
| 141 |
+
zero_day_exploits = ZeroDayExploits()
|
| 142 |
+
code_parser = CodeParser("sample_code")
|
| 143 |
+
pipeline_manager = PipelineManager()
|
| 144 |
+
except Exception as e:
|
| 145 |
+
logging.error(f"Error initializing modules: {e}")
|
| 146 |
+
|
| 147 |
+
# Integrate the ThreatIntelligence module with RealTimeMonitoring
|
| 148 |
+
try:
|
| 149 |
+
monitoring.threat_intelligence_module = advanced_threat_intelligence
|
| 150 |
+
except Exception as e:
|
| 151 |
+
logging.error(f"Error integrating ThreatIntelligence module with RealTimeMonitoring: {e}")
|
| 152 |
+
|
| 153 |
+
# Add real-time threat data analysis using the ThreatIntelligence module
|
| 154 |
+
async def analyze_threat_data():
|
| 155 |
+
try:
|
| 156 |
+
threat_data = await advanced_threat_intelligence.get_threat_intelligence()
|
| 157 |
+
analyzed_data = advanced_threat_intelligence.process_data(threat_data)
|
| 158 |
+
return analyzed_data
|
| 159 |
+
except Exception as e:
|
| 160 |
+
logging.error(f"Error analyzing threat data: {e}")
|
| 161 |
+
|
| 162 |
+
# Update the RealTimeThreatIntelligence initialization to include the ThreatIntelligence module
|
| 163 |
+
try:
|
| 164 |
+
threat_intelligence_module = RealTimeThreatIntelligence(api_key="YOUR_API_KEY")
|
| 165 |
+
threat_intelligence_module.threat_intelligence = advanced_threat_intelligence
|
| 166 |
+
except Exception as e:
|
| 167 |
+
logging.error(f"Error updating RealTimeThreatIntelligence initialization: {e}")
|
| 168 |
+
|
| 169 |
+
# Add real-time threat data monitoring using the ThreatIntelligence module
|
| 170 |
+
async def monitor_threat_data():
|
| 171 |
+
try:
|
| 172 |
+
threat_data = await advanced_threat_intelligence.get_threat_intelligence()
|
| 173 |
+
for threat in threat_data:
|
| 174 |
+
if threat["severity"] > 0.8:
|
| 175 |
+
monitoring.trigger_alert(threat)
|
| 176 |
+
except Exception as e:
|
| 177 |
+
logging.error(f"Error monitoring threat data: {e}")
|
| 178 |
+
|
| 179 |
+
# Integrate the AutomatedIncidentResponse module with RealTimeMonitoring
|
| 180 |
+
try:
|
| 181 |
+
monitoring.automated_incident_response = automated_incident_response
|
| 182 |
+
except Exception as e:
|
| 183 |
+
logging.error(f"Error integrating AutomatedIncidentResponse module with RealTimeMonitoring: {e}")
|
| 184 |
+
|
| 185 |
+
# Integrate the AIRedTeaming module with RealTimeMonitoring
|
| 186 |
+
try:
|
| 187 |
+
monitoring.ai_red_teaming = ai_red_teaming
|
| 188 |
+
except Exception as e:
|
| 189 |
+
logging.error(f"Error integrating AIRedTeaming module with RealTimeMonitoring: {e}")
|
| 190 |
+
|
| 191 |
+
# Integrate the APTSimulation module with RealTimeMonitoring
|
| 192 |
+
try:
|
| 193 |
+
monitoring.apt_simulation = apt_simulation()
|
| 194 |
+
except Exception as e:
|
| 195 |
+
logging.error(f"Error integrating APTSimulation module with RealTimeMonitoring: {e}")
|
| 196 |
+
|
| 197 |
+
# Integrate the PredictiveAnalytics module with RealTimeMonitoring
|
| 198 |
+
try:
|
| 199 |
+
monitoring.predictive_analytics = predictive_analytics
|
| 200 |
+
except Exception as e:
|
| 201 |
+
logging.error(f"Error integrating PredictiveAnalytics module with RealTimeMonitoring: {e}")
|
| 202 |
+
|
| 203 |
+
# Integrate the MachineLearningAI module with RealTimeMonitoring
|
| 204 |
+
try:
|
| 205 |
+
monitoring.machine_learning_ai = machine_learning_ai
|
| 206 |
+
except Exception as e:
|
| 207 |
+
logging.error(f"Error integrating MachineLearningAI module with RealTimeMonitoring: {e}")
|
| 208 |
+
|
| 209 |
+
# Integrate the DataVisualization module with RealTimeMonitoring
|
| 210 |
+
try:
|
| 211 |
+
monitoring.data_visualization = data_visualization
|
| 212 |
+
except Exception as e:
|
| 213 |
+
logging.error(f"Error integrating DataVisualization module with RealTimeMonitoring: {e}")
|
| 214 |
+
|
| 215 |
+
# Integrate the CloudExploitation module with RealTimeMonitoring
|
| 216 |
+
try:
|
| 217 |
+
monitoring.cloud_exploitation = cloud_exploitation
|
| 218 |
+
except Exception as e:
|
| 219 |
+
logging.error(f"Error integrating CloudExploitation module with RealTimeMonitoring: {e}")
|
| 220 |
+
|
| 221 |
+
# Integrate the IoTExploitation module with RealTimeMonitoring
|
| 222 |
+
try:
|
| 223 |
+
monitoring.iot_exploitation = iot_exploitation
|
| 224 |
+
except Exception as e:
|
| 225 |
+
logging.error(f"Error integrating IoTExploitation module with RealTimeMonitoring: {e}")
|
| 226 |
+
|
| 227 |
+
# Integrate the QuantumComputing module with RealTimeMonitoring
|
| 228 |
+
try:
|
| 229 |
+
monitoring.quantum_computing = quantum_computing
|
| 230 |
+
except Exception as e:
|
| 231 |
+
logging.error(f"Error integrating QuantumComputing module with RealTimeMonitoring: {e}")
|
| 232 |
+
|
| 233 |
+
# Integrate the EdgeComputing module with RealTimeMonitoring
|
| 234 |
+
try:
|
| 235 |
+
monitoring.edge_computing = edge_computing
|
| 236 |
+
except Exception as e:
|
| 237 |
+
logging.error(f"Error integrating EdgeComputing module with RealTimeMonitoring: {e}")
|
| 238 |
+
|
| 239 |
+
# Integrate the ServerlessComputing module with RealTimeMonitoring
|
| 240 |
+
try:
|
| 241 |
+
monitoring.serverless_computing = serverless_computing
|
| 242 |
+
except Exception as e:
|
| 243 |
+
logging.error(f"Error integrating ServerlessComputing module with RealTimeMonitoring: {e}")
|
| 244 |
+
|
| 245 |
+
# Integrate the MicroservicesArchitecture module with RealTimeMonitoring
|
| 246 |
+
try:
|
| 247 |
+
monitoring.microservices_architecture = microservices_architecture
|
| 248 |
+
except Exception as e:
|
| 249 |
+
logging.error(f"Error integrating MicroservicesArchitecture module with RealTimeMonitoring: {e}")
|
| 250 |
+
|
| 251 |
+
# Integrate the CloudNativeApplications module with RealTimeMonitoring
|
| 252 |
+
try:
|
| 253 |
+
monitoring.cloud_native_applications = cloud_native_applications
|
| 254 |
+
except Exception as e:
|
| 255 |
+
logging.error(f"Error integrating CloudNativeApplications module with RealTimeMonitoring: {e}")
|
| 256 |
+
|
| 257 |
+
# Add tool tips and advanced help options for all functions
|
| 258 |
+
def add_tool_tips():
|
| 259 |
+
tool_tips = {
|
| 260 |
+
"advanced_threat_intelligence": "Provides advanced threat intelligence capabilities.",
|
| 261 |
+
"predictive_analytics": "Utilizes predictive analytics for threat detection.",
|
| 262 |
+
"automated_incident_response": "Automates incident response processes.",
|
| 263 |
+
"ai_red_teaming": "AI-driven red teaming for security testing.",
|
| 264 |
+
"apt_simulation": "Simulates advanced persistent threats.",
|
| 265 |
+
"machine_learning_ai": "Machine learning-based AI for threat detection.",
|
| 266 |
+
"data_visualization": "Visualizes data for better insights.",
|
| 267 |
+
"blockchain_logger": "Logs data using blockchain technology.",
|
| 268 |
+
"cloud_exploitation": "Exploits vulnerabilities in cloud environments.",
|
| 269 |
+
"iot_exploitation": "Exploits vulnerabilities in IoT devices.",
|
| 270 |
+
"quantum_computing": "Utilizes quantum computing for security.",
|
| 271 |
+
"edge_computing": "Secures edge computing environments.",
|
| 272 |
+
"serverless_computing": "Secures serverless computing environments.",
|
| 273 |
+
"microservices_architecture": "Secures microservices architectures.",
|
| 274 |
+
"cloud_native_applications": "Secures cloud-native applications.",
|
| 275 |
+
"advanced_decryption": "Advanced decryption capabilities.",
|
| 276 |
+
"advanced_malware_analysis": "Analyzes and detects advanced malware.",
|
| 277 |
+
"advanced_social_engineering": "Detects and prevents social engineering attacks.",
|
| 278 |
+
"alerts_notifications": "Sends alerts and notifications.",
|
| 279 |
+
"device_fingerprinting": "Identifies devices using fingerprinting.",
|
| 280 |
+
"exploit_payloads": "Manages exploit payloads.",
|
| 281 |
+
"fuzzing_engine": "Fuzzing engine for vulnerability detection.",
|
| 282 |
+
"mitm_stingray": "Manages MITM Stingray attacks.",
|
| 283 |
+
"network_exploitation": "Exploits network vulnerabilities.",
|
| 284 |
+
"vulnerability_scanner": "Scans for vulnerabilities.",
|
| 285 |
+
"wireless_exploitation": "Exploits wireless vulnerabilities.",
|
| 286 |
+
"zero_day_exploits": "Manages zero-day exploits."
|
| 287 |
+
}
|
| 288 |
+
return tool_tips
|
| 289 |
+
|
| 290 |
+
tool_tips = add_tool_tips()
|
| 291 |
+
|
| 292 |
+
# Add a continue button for the AI chatbot to continue incomplete responses
|
| 293 |
+
continue_button = pn.widgets.Button(name="Continue", button_type="primary")
|
| 294 |
+
|
| 295 |
+
# Add a download icon button for downloading zip files of projects
|
| 296 |
+
download_button = pn.widgets.Button(name="Download .zip", button_type="primary", icon="download")
|
| 297 |
+
|
| 298 |
+
# Update the dashboard to display real-time insights and analytics
|
| 299 |
+
dashboard = pn.Column(
|
| 300 |
+
"### Advanced Capabilities Dashboard",
|
| 301 |
+
pn.pane.Markdown("Welcome to the Advanced Capabilities Dashboard. Here you can monitor and manage advanced security features."),
|
| 302 |
+
advanced_threat_intelligence.render(),
|
| 303 |
+
predictive_analytics.render(),
|
| 304 |
+
automated_incident_response.render(),
|
| 305 |
+
ai_red_teaming.render(),
|
| 306 |
+
apt_simulation.render(),
|
| 307 |
+
machine_learning_ai.render(),
|
| 308 |
+
data_visualization.render(),
|
| 309 |
+
blockchain_logger.render(),
|
| 310 |
+
cloud_exploitation.render(),
|
| 311 |
+
iot_exploitation.render(),
|
| 312 |
+
quantum_computing.render(),
|
| 313 |
+
edge_computing.render(),
|
| 314 |
+
serverless_computing.render(),
|
| 315 |
+
microservices_architecture.render(),
|
| 316 |
+
cloud_native_applications.render(),
|
| 317 |
+
advanced_decryption.render(),
|
| 318 |
+
advanced_malware_analysis.render(),
|
| 319 |
+
advanced_social_engineering.render(),
|
| 320 |
+
alerts_notifications.render(),
|
| 321 |
+
device_fingerprinting.render(),
|
| 322 |
+
exploit_payloads.render(),
|
| 323 |
+
fuzzing_engine.render(),
|
| 324 |
+
mitm_stingray.render(),
|
| 325 |
+
network_exploitation.render(),
|
| 326 |
+
vulnerability_scanner.render(),
|
| 327 |
+
wireless_exploitation.render(),
|
| 328 |
+
zero_day_exploits.render(),
|
| 329 |
+
code_parser.render(),
|
| 330 |
+
pipeline_manager.render(),
|
| 331 |
+
continue_button,
|
| 332 |
+
download_button
|
| 333 |
+
)
|
| 334 |
+
|
| 335 |
+
main.append(dashboard)
|
| 336 |
+
|
| 337 |
+
# Implement best practices for integrating message queues
|
| 338 |
+
import pika
|
| 339 |
+
|
| 340 |
+
def setup_message_queue():
|
| 341 |
+
try:
|
| 342 |
+
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
|
| 343 |
+
channel = connection.channel()
|
| 344 |
+
channel.queue_declare(queue='task_queue', durable=True)
|
| 345 |
+
return channel
|
| 346 |
+
except Exception as e:
|
| 347 |
+
logging.error(f"Error setting up message queue: {e}")
|
| 348 |
+
return None
|
| 349 |
+
|
| 350 |
+
def send_message(channel, message):
|
| 351 |
+
try:
|
| 352 |
+
channel.basic_publish(
|
| 353 |
+
exchange='',
|
| 354 |
+
routing_key='task_queue',
|
| 355 |
+
body=message,
|
| 356 |
+
properties=pika.BasicProperties(
|
| 357 |
+
delivery_mode=2, # make message persistent
|
| 358 |
+
))
|
| 359 |
+
logging.info(f"Sent message: {message}")
|
| 360 |
+
except Exception as e:
|
| 361 |
+
logging.error(f"Error sending message: {e}")
|
| 362 |
+
|
| 363 |
+
def receive_message(channel):
|
| 364 |
+
def callback(ch, method, properties, body):
|
| 365 |
+
logging.info(f"Received message: {body}")
|
| 366 |
+
ch.basic_ack(delivery_tag=method.delivery_tag)
|
| 367 |
+
|
| 368 |
+
try:
|
| 369 |
+
channel.basic_consume(queue='task_queue', on_message_callback=callback)
|
| 370 |
+
logging.info('Waiting for messages. To exit press CTRL+C')
|
| 371 |
+
channel.start_consuming()
|
| 372 |
+
except Exception as e:
|
| 373 |
+
logging.error(f"Error receiving message: {e}")
|
| 374 |
+
|
| 375 |
+
def setup_kafka():
|
| 376 |
+
try:
|
| 377 |
+
producer = KafkaProducer(bootstrap_servers='localhost:9092')
|
| 378 |
+
consumer = KafkaConsumer('my_topic', bootstrap_servers='localhost:9092', auto_offset_reset='earliest', enable_auto_commit=True, group_id='my-group')
|
| 379 |
+
return producer, consumer
|
| 380 |
+
except Exception as e:
|
| 381 |
+
logging.error(f"Error setting up Kafka: {e}")
|
| 382 |
+
return None, None
|
| 383 |
+
|
| 384 |
+
def send_message_to_kafka(producer, topic, message):
|
| 385 |
+
try:
|
| 386 |
+
producer.send(topic, message.encode('utf-8'))
|
| 387 |
+
producer.flush()
|
| 388 |
+
logging.info(f"Sent message to Kafka topic {topic}: {message}")
|
| 389 |
+
except Exception as e:
|
| 390 |
+
logging.error(f"Error sending message to Kafka: {e}")
|
| 391 |
+
|
| 392 |
+
def receive_message_from_kafka(consumer):
|
| 393 |
+
try:
|
| 394 |
+
for message in consumer:
|
| 395 |
+
logging.info(f"Received message from Kafka: {message.value.decode('utf-8')}")
|
| 396 |
+
except Exception as e:
|
| 397 |
+
logging.error(f"Error receiving message from Kafka: {e}")
|
| 398 |
+
|
| 399 |
+
if __name__ == "__main__":
|
| 400 |
+
channel = setup_message_queue()
|
| 401 |
+
if channel:
|
| 402 |
+
send_message(channel, "Test message")
|
| 403 |
+
receive_message(channel)
|
| 404 |
+
|
| 405 |
+
producer, consumer = setup_kafka()
|
| 406 |
+
if producer and consumer:
|
| 407 |
+
send_message_to_kafka(producer, 'my_topic', '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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
import speech_recognition as sr # For voice-to-text
|
| 3 |
+
import json
|
| 4 |
+
from network_scanner import scan_network
|
| 5 |
+
from vulnerability_assessor import assess_vulnerabilities
|
| 6 |
+
from exploit_deployer import deploy_exploit
|
| 7 |
+
from database.models import DocumentAnalysis
|
| 8 |
+
from sqlalchemy import create_engine
|
| 9 |
+
from sqlalchemy.orm import sessionmaker
|
| 10 |
+
from modules.real_time_threat_intelligence import RealTimeThreatIntelligence
|
| 11 |
+
from modules.real_time_monitoring import RealTimeMonitoring
|
| 12 |
+
from modules.threat_intelligence import ThreatIntelligence
|
| 13 |
+
from modules.predictive_analytics import PredictiveAnalytics
|
| 14 |
+
from modules.automated_incident_response import AutomatedIncidentResponse
|
| 15 |
+
from modules.ai_red_teaming import AIRedTeaming
|
| 16 |
+
from modules.apt_simulation import APTSimulation
|
| 17 |
+
from modules.machine_learning_ai import MachineLearningAI
|
| 18 |
+
from modules.data_visualization import DataVisualization
|
| 19 |
+
from modules.blockchain_logger import BlockchainLogger
|
| 20 |
+
from modules.cloud_exploitation import CloudExploitation
|
| 21 |
+
from modules.iot_exploitation import IoTExploitation
|
| 22 |
+
from modules.quantum_computing import QuantumComputing
|
| 23 |
+
from modules.edge_computing import EdgeComputing
|
| 24 |
+
from modules.serverless_computing import ServerlessComputing
|
| 25 |
+
from modules.microservices_architecture import MicroservicesArchitecture
|
| 26 |
+
from modules.cloud_native_applications import CloudNativeApplications
|
| 27 |
+
from modules.advanced_decryption import AdvancedDecryption
|
| 28 |
+
from modules.advanced_malware_analysis import AdvancedMalwareAnalysis
|
| 29 |
+
from modules.advanced_social_engineering import AdvancedSocialEngineering
|
| 30 |
+
from modules.alerts_notifications import AlertsNotifications
|
| 31 |
+
from modules.device_fingerprinting import DeviceFingerprinting
|
| 32 |
+
from modules.exploit_payloads import ExploitPayloads
|
| 33 |
+
from modules.fuzzing_engine import FuzzingEngine
|
| 34 |
+
from modules.mitm_stingray import MITMStingray
|
| 35 |
+
from modules.network_exploitation import NetworkExploitation
|
| 36 |
+
from modules.vulnerability_scanner import VulnerabilityScanner
|
| 37 |
+
from modules.wireless_exploitation import WirelessExploitation
|
| 38 |
+
from modules.zero_day_exploits import ZeroDayExploits
|
| 39 |
+
from modules.device_control import DeviceControl
|
| 40 |
+
from modules.windows_control import WindowsControl
|
| 41 |
+
from modules.macos_control import MacOSControl
|
| 42 |
+
from modules.linux_control import LinuxControl
|
| 43 |
+
from modules.android_control import AndroidControl
|
| 44 |
+
from modules.ios_control import iOSControl
|
| 45 |
+
from modules.advanced_device_control import AdvancedDeviceControl
|
| 46 |
+
from backend.code_parser import CodeParser
|
| 47 |
+
from backend.pipeline_manager import PipelineManager
|
| 48 |
+
import pika
|
| 49 |
+
from kafka import KafkaProducer, KafkaConsumer
|
| 50 |
+
import logging
|
| 51 |
+
|
| 52 |
+
DATABASE_URL = "sqlite:///document_analysis.db"
|
| 53 |
+
engine = create_engine(DATABASE_URL)
|
| 54 |
+
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
| 55 |
+
|
| 56 |
+
# Configure logging
|
| 57 |
+
logging.basicConfig(level=logging.ERROR, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 58 |
+
|
| 59 |
+
def get_response(user_input):
|
| 60 |
+
"""Handle user input and provide responses."""
|
| 61 |
+
responses = {
|
| 62 |
+
"hi": "Hello! How can I assist you today?",
|
| 63 |
+
"audit status": "The last audit was completed successfully.",
|
| 64 |
+
"generate report": "Generating the audit report...",
|
| 65 |
+
"feedback": "We value your feedback! Please provide your comments.",
|
| 66 |
+
"scan networks": "Scanning networks for vulnerabilities...",
|
| 67 |
+
"deploy exploit": "Deploying the exploit...",
|
| 68 |
+
}
|
| 69 |
+
return responses.get(user_input.lower(), "I'm sorry, I didn't understand that.")
|
| 70 |
+
|
| 71 |
+
def handle_vulnerability_scanning():
|
| 72 |
+
"""Handle network scanning and vulnerability assessment."""
|
| 73 |
+
try:
|
| 74 |
+
devices = scan_network()
|
| 75 |
+
vulnerabilities = assess_vulnerabilities(devices)
|
| 76 |
+
|
| 77 |
+
# Save scan results to the database
|
| 78 |
+
session = SessionLocal()
|
| 79 |
+
try:
|
| 80 |
+
scan_result = DocumentAnalysis(
|
| 81 |
+
source="network_scan",
|
| 82 |
+
title="Network Scan Results",
|
| 83 |
+
links=str(vulnerabilities),
|
| 84 |
+
error=None
|
| 85 |
+
)
|
| 86 |
+
session.add(scan_result)
|
| 87 |
+
session.commit()
|
| 88 |
+
except Exception as e:
|
| 89 |
+
logging.error(f"Error saving scan results to database: {e}")
|
| 90 |
+
finally:
|
| 91 |
+
session.close()
|
| 92 |
+
|
| 93 |
+
return vulnerabilities
|
| 94 |
+
except Exception as e:
|
| 95 |
+
logging.error(f"Error during vulnerability scanning: {e}")
|
| 96 |
+
return []
|
| 97 |
+
|
| 98 |
+
def handle_exploit_deployment(target):
|
| 99 |
+
"""Handle the deployment of exploits."""
|
| 100 |
+
try:
|
| 101 |
+
result = deploy_exploit(target)
|
| 102 |
+
|
| 103 |
+
# Save exploit deployment results to the database
|
| 104 |
+
session = SessionLocal()
|
| 105 |
+
try:
|
| 106 |
+
exploit_result = DocumentAnalysis(
|
| 107 |
+
source="exploit_deployment",
|
| 108 |
+
title="Exploit Deployment Results",
|
| 109 |
+
links=target,
|
| 110 |
+
error=None if result else "Exploit deployment failed"
|
| 111 |
+
)
|
| 112 |
+
session.add(exploit_result)
|
| 113 |
+
session.commit()
|
| 114 |
+
except Exception as e:
|
| 115 |
+
logging.error(f"Error saving exploit deployment results to database: {e}")
|
| 116 |
+
finally:
|
| 117 |
+
session.close()
|
| 118 |
+
|
| 119 |
+
return "Exploit deployed successfully!" if result else "Exploit deployment failed."
|
| 120 |
+
except Exception as e:
|
| 121 |
+
logging.error(f"Error during exploit deployment: {e}")
|
| 122 |
+
return "Exploit deployment failed."
|
| 123 |
+
|
| 124 |
+
def setup_kafka():
|
| 125 |
+
try:
|
| 126 |
+
producer = KafkaProducer(bootstrap_servers='localhost:9092')
|
| 127 |
+
consumer = KafkaConsumer('my_topic', bootstrap_servers='localhost:9092', auto_offset_reset='earliest', enable_auto_commit=True, group_id='my-group')
|
| 128 |
+
return producer, consumer
|
| 129 |
+
except Exception as e:
|
| 130 |
+
print(f"Error setting up Kafka: {e}")
|
| 131 |
+
return None, None
|
| 132 |
+
|
| 133 |
+
def send_message_to_kafka(producer, topic, message):
|
| 134 |
+
try:
|
| 135 |
+
producer.send(topic, message.encode('utf-8'))
|
| 136 |
+
producer.flush()
|
| 137 |
+
print(f"Sent message to Kafka topic {topic}: {message}")
|
| 138 |
+
except Exception as e:
|
| 139 |
+
print(f"Error sending message to Kafka: {e}")
|
| 140 |
+
|
| 141 |
+
def receive_message_from_kafka(consumer):
|
| 142 |
+
try:
|
| 143 |
+
for message in consumer:
|
| 144 |
+
print(f"Received message from Kafka: {message.value.decode('utf-8')}")
|
| 145 |
+
except Exception as e:
|
| 146 |
+
print(f"Error receiving message from Kafka: {e}")
|
| 147 |
+
|
| 148 |
+
def chat():
|
| 149 |
+
"""Main chat function to interact with users."""
|
| 150 |
+
print("Welcome to the Corporate Device Security Audit Chatbot!")
|
| 151 |
+
while True:
|
| 152 |
+
user_input = input("You: ")
|
| 153 |
+
if user_input.lower() in ["exit", "quit"]:
|
| 154 |
+
print("Chatbot: Goodbye!")
|
| 155 |
+
break
|
| 156 |
+
|
| 157 |
+
# Check for voice input command
|
| 158 |
+
if user_input.lower() == "voice input":
|
| 159 |
+
print("Chatbot: Listening...")
|
| 160 |
+
recognizer = sr.Recognizer()
|
| 161 |
+
with sr.Microphone() as source:
|
| 162 |
+
audio = recognizer.listen(source)
|
| 163 |
+
try:
|
| 164 |
+
user_input = recognizer.recognize_google(audio)
|
| 165 |
+
print(f"You: {user_input}")
|
| 166 |
+
except sr.UnknownValueError:
|
| 167 |
+
print("Chatbot: Sorry, I didn't catch that.")
|
| 168 |
+
continue
|
| 169 |
+
|
| 170 |
+
# Process specific commands
|
| 171 |
+
if "scan networks" in user_input.lower():
|
| 172 |
+
vulnerabilities = handle_vulnerability_scanning()
|
| 173 |
+
print(f"Chatbot: Found vulnerabilities: {vulnerabilities}")
|
| 174 |
+
elif "deploy exploit" in user_input.lower():
|
| 175 |
+
target = input("Enter target for exploit deployment: ")
|
| 176 |
+
result = handle_exploit_deployment(target)
|
| 177 |
+
print(f"Chatbot: {result}")
|
| 178 |
+
else:
|
| 179 |
+
response = get_response(user_input)
|
| 180 |
+
print(f"Chatbot: {response}")
|
| 181 |
+
|
| 182 |
+
if __name__ == "__main__":
|
| 183 |
+
chat()
|
| 184 |
+
|
| 185 |
+
# Initialize real-time threat intelligence and monitoring modules
|
| 186 |
+
try:
|
| 187 |
+
threat_intelligence = RealTimeThreatIntelligence(api_key="YOUR_API_KEY")
|
| 188 |
+
monitoring = RealTimeMonitoring(threat_intelligence_module=threat_intelligence)
|
| 189 |
+
except Exception as e:
|
| 190 |
+
print(f"Error initializing real-time threat intelligence and monitoring modules: {e}")
|
| 191 |
+
|
| 192 |
+
# Integrate the ThreatIntelligence module with RealTimeMonitoring
|
| 193 |
+
try:
|
| 194 |
+
advanced_threat_intelligence = ThreatIntelligence()
|
| 195 |
+
monitoring.threat_intelligence_module = advanced_threat_intelligence
|
| 196 |
+
except Exception as e:
|
| 197 |
+
print(f"Error integrating ThreatIntelligence module with RealTimeMonitoring: {e}")
|
| 198 |
+
|
| 199 |
+
# Add real-time threat data analysis using the ThreatIntelligence module
|
| 200 |
+
async def analyze_threat_data():
|
| 201 |
+
try:
|
| 202 |
+
threat_data = await advanced_threat_intelligence.get_threat_intelligence()
|
| 203 |
+
analyzed_data = advanced_threat_intelligence.process_data(threat_data)
|
| 204 |
+
return analyzed_data
|
| 205 |
+
except Exception as e:
|
| 206 |
+
print(f"Error analyzing threat data: {e}")
|
| 207 |
+
|
| 208 |
+
# Update the RealTimeThreatIntelligence initialization to include the ThreatIntelligence module
|
| 209 |
+
try:
|
| 210 |
+
threat_intelligence_module = RealTimeThreatIntelligence(api_key="YOUR_API_KEY")
|
| 211 |
+
threat_intelligence_module.threat_intelligence = advanced_threat_intelligence
|
| 212 |
+
except Exception as e:
|
| 213 |
+
print(f"Error updating RealTimeThreatIntelligence initialization: {e}")
|
| 214 |
+
|
| 215 |
+
# Add real-time threat data monitoring using the ThreatIntelligence module
|
| 216 |
+
async def monitor_threat_data():
|
| 217 |
+
try:
|
| 218 |
+
threat_data = await advanced_threat_intelligence.get_threat_intelligence()
|
| 219 |
+
for threat in threat_data:
|
| 220 |
+
if threat["severity"] > 0.8:
|
| 221 |
+
monitoring.trigger_alert(threat)
|
| 222 |
+
except Exception as e:
|
| 223 |
+
print(f"Error monitoring threat data: {e}")
|
| 224 |
+
|
| 225 |
+
# Integrate the AutomatedIncidentResponse module with RealTimeMonitoring
|
| 226 |
+
try:
|
| 227 |
+
automated_incident_response = AutomatedIncidentResponse()
|
| 228 |
+
monitoring.automated_incident_response = automated_incident_response
|
| 229 |
+
except Exception as e:
|
| 230 |
+
print(f"Error integrating AutomatedIncidentResponse module with RealTimeMonitoring: {e}")
|
| 231 |
+
|
| 232 |
+
# Integrate the AIRedTeaming module with RealTimeMonitoring
|
| 233 |
+
try:
|
| 234 |
+
ai_red_teaming = AIRedTeaming()
|
| 235 |
+
monitoring.ai_red_teaming = ai_red_teaming
|
| 236 |
+
except Exception as e:
|
| 237 |
+
print(f"Error integrating AIRedTeaming module with RealTimeMonitoring: {e}")
|
| 238 |
+
|
| 239 |
+
# Integrate the APTSimulation module with RealTimeMonitoring
|
| 240 |
+
try:
|
| 241 |
+
apt_simulation = APTSimulation()
|
| 242 |
+
monitoring.apt_simulation = apt_simulation
|
| 243 |
+
except Exception as e:
|
| 244 |
+
print(f"Error integrating APTSimulation module with RealTimeMonitoring: {e}")
|
| 245 |
+
|
| 246 |
+
# Integrate the PredictiveAnalytics module with RealTimeMonitoring
|
| 247 |
+
try:
|
| 248 |
+
predictive_analytics = PredictiveAnalytics()
|
| 249 |
+
monitoring.predictive_analytics = predictive_analytics
|
| 250 |
+
except Exception as e:
|
| 251 |
+
print(f"Error integrating PredictiveAnalytics module with RealTimeMonitoring: {e}")
|
| 252 |
+
|
| 253 |
+
# Integrate the MachineLearningAI module with RealTimeMonitoring
|
| 254 |
+
try:
|
| 255 |
+
machine_learning_ai = MachineLearningAI()
|
| 256 |
+
monitoring.machine_learning_ai = machine_learning_ai
|
| 257 |
+
except Exception as e:
|
| 258 |
+
print(f"Error integrating MachineLearningAI module with RealTimeMonitoring: {e}")
|
| 259 |
+
|
| 260 |
+
# Integrate the DataVisualization module with RealTimeMonitoring
|
| 261 |
+
try:
|
| 262 |
+
data_visualization = DataVisualization()
|
| 263 |
+
monitoring.data_visualization = data_visualization
|
| 264 |
+
except Exception as e:
|
| 265 |
+
print(f"Error integrating DataVisualization module with RealTimeMonitoring: {e}")
|
| 266 |
+
|
| 267 |
+
# Integrate the CloudExploitation module with RealTimeMonitoring
|
| 268 |
+
try:
|
| 269 |
+
cloud_exploitation = CloudExploitation()
|
| 270 |
+
monitoring.cloud_exploitation = cloud_exploitation
|
| 271 |
+
except Exception as e:
|
| 272 |
+
print(f"Error integrating CloudExploitation module with RealTimeMonitoring: {e}")
|
| 273 |
+
|
| 274 |
+
# Integrate the IoTExploitation module with RealTimeMonitoring
|
| 275 |
+
try:
|
| 276 |
+
iot_exploitation = IoTExploitation()
|
| 277 |
+
monitoring.iot_exploitation = iot_exploitation
|
| 278 |
+
except Exception as e:
|
| 279 |
+
print(f"Error integrating IoTExploitation module with RealTimeMonitoring: {e}")
|
| 280 |
+
|
| 281 |
+
# Integrate the QuantumComputing module with RealTimeMonitoring
|
| 282 |
+
try:
|
| 283 |
+
quantum_computing = QuantumComputing()
|
| 284 |
+
monitoring.quantum_computing = quantum_computing
|
| 285 |
+
except Exception as e:
|
| 286 |
+
print(f"Error integrating QuantumComputing module with RealTimeMonitoring: {e}")
|
| 287 |
+
|
| 288 |
+
# Integrate the EdgeComputing module with RealTimeMonitoring
|
| 289 |
+
try:
|
| 290 |
+
edge_computing = EdgeComputing()
|
| 291 |
+
monitoring.edge_computing = edge_computing
|
| 292 |
+
except Exception as e:
|
| 293 |
+
print(f"Error integrating EdgeComputing module with RealTimeMonitoring: {e}")
|
| 294 |
+
|
| 295 |
+
# Integrate the ServerlessComputing module with RealTimeMonitoring
|
| 296 |
+
try:
|
| 297 |
+
serverless_computing = ServerlessComputing()
|
| 298 |
+
monitoring.serverless_computing = serverless_computing
|
| 299 |
+
except Exception as e:
|
| 300 |
+
print(f"Error integrating ServerlessComputing module with RealTimeMonitoring: {e}")
|
| 301 |
+
|
| 302 |
+
# Integrate the MicroservicesArchitecture module with RealTimeMonitoring
|
| 303 |
+
try:
|
| 304 |
+
microservices_architecture = MicroservicesArchitecture()
|
| 305 |
+
monitoring.microservices_architecture = microservices_architecture
|
| 306 |
+
except Exception as e:
|
| 307 |
+
print(f"Error integrating MicroservicesArchitecture module with RealTimeMonitoring: {e}")
|
| 308 |
+
|
| 309 |
+
# Integrate the CloudNativeApplications module with RealTimeMonitoring
|
| 310 |
+
try:
|
| 311 |
+
cloud_native_applications = CloudNativeApplications()
|
| 312 |
+
monitoring.cloud_native_applications = cloud_native_applications
|
| 313 |
+
except Exception as e:
|
| 314 |
+
print(f"Error integrating CloudNativeApplications module with RealTimeMonitoring: {e}")
|
| 315 |
+
|
| 316 |
+
# Integrate the DeviceControl module with RealTimeMonitoring
|
| 317 |
+
try:
|
| 318 |
+
device_control = DeviceControl()
|
| 319 |
+
monitoring.device_control = device_control
|
| 320 |
+
except Exception as e:
|
| 321 |
+
print(f"Error integrating DeviceControl module with RealTimeMonitoring: {e}")
|
| 322 |
+
|
| 323 |
+
# Integrate the WindowsControl module with RealTimeMonitoring
|
| 324 |
+
try:
|
| 325 |
+
windows_control = WindowsControl()
|
| 326 |
+
monitoring.windows_control = windows_control
|
| 327 |
+
except Exception as e:
|
| 328 |
+
print(f"Error integrating WindowsControl module with RealTimeMonitoring: {e}")
|
| 329 |
+
|
| 330 |
+
# Integrate the MacOSControl module with RealTimeMonitoring
|
| 331 |
+
try:
|
| 332 |
+
macos_control = MacOSControl()
|
| 333 |
+
monitoring.macos_control = macos_control
|
| 334 |
+
except Exception as e:
|
| 335 |
+
print(f"Error integrating MacOSControl module with RealTimeMonitoring: {e}")
|
| 336 |
+
|
| 337 |
+
# Integrate the LinuxControl module with RealTimeMonitoring
|
| 338 |
+
try:
|
| 339 |
+
linux_control = LinuxControl()
|
| 340 |
+
monitoring.linux_control = linux_control
|
| 341 |
+
except Exception as e:
|
| 342 |
+
print(f"Error integrating LinuxControl module with RealTimeMonitoring: {e}")
|
| 343 |
+
|
| 344 |
+
# Integrate the AndroidControl module with RealTimeMonitoring
|
| 345 |
+
try:
|
| 346 |
+
android_control = AndroidControl()
|
| 347 |
+
monitoring.android_control = android_control
|
| 348 |
+
except Exception as e:
|
| 349 |
+
print(f"Error integrating AndroidControl module with RealTimeMonitoring: {e}")
|
| 350 |
+
|
| 351 |
+
# Integrate the iOSControl module with RealTimeMonitoring
|
| 352 |
+
try:
|
| 353 |
+
ios_control = iOSControl()
|
| 354 |
+
monitoring.ios_control = ios_control
|
| 355 |
+
except Exception as e:
|
| 356 |
+
print(f"Error integrating iOSControl module with RealTimeMonitoring: {e}")
|
| 357 |
+
|
| 358 |
+
# Integrate the AdvancedDeviceControl module with RealTimeMonitoring
|
| 359 |
+
try:
|
| 360 |
+
advanced_device_control = AdvancedDeviceControl()
|
| 361 |
+
monitoring.advanced_device_control = advanced_device_control
|
| 362 |
+
except Exception as e:
|
| 363 |
+
print(f"Error integrating AdvancedDeviceControl module with RealTimeMonitoring: {e}")
|
| 364 |
+
|
| 365 |
+
# Implement best practices for integrating message queues
|
| 366 |
+
def setup_message_queue():
|
| 367 |
+
try:
|
| 368 |
+
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
|
| 369 |
+
channel = connection.channel()
|
| 370 |
+
channel.queue_declare(queue='task_queue', durable=True)
|
| 371 |
+
return channel
|
| 372 |
+
except Exception as e:
|
| 373 |
+
print(f"Error setting up message queue: {e}")
|
| 374 |
+
return None
|
| 375 |
+
|
| 376 |
+
message_queue_channel = setup_message_queue()
|
| 377 |
+
|
| 378 |
+
def send_message_to_queue(message):
|
| 379 |
+
try:
|
| 380 |
+
if message_queue_channel:
|
| 381 |
+
message_queue_channel.basic_publish(
|
| 382 |
+
exchange='',
|
| 383 |
+
routing_key='task_queue',
|
| 384 |
+
body=message,
|
| 385 |
+
properties=pika.BasicProperties(
|
| 386 |
+
delivery_mode=2, # make message persistent
|
| 387 |
+
))
|
| 388 |
+
print(f"Sent message to queue: {message}")
|
| 389 |
+
else:
|
| 390 |
+
print("Message queue channel is not available.")
|
| 391 |
+
except Exception as e:
|
| 392 |
+
print(f"Error sending message to queue: {e}")
|
| 393 |
+
|
| 394 |
+
# Example usage of sending a message to the queue
|
| 395 |
+
send_message_to_queue("Test message")
|
| 396 |
+
|
| 397 |
+
# Add a continue button for the AI chatbot to continue incomplete responses
|
| 398 |
+
continue_button = pn.widgets.Button(name="Continue", button_type="primary")
|
| 399 |
+
|
| 400 |
+
# Add a download icon button for downloading zip files of projects
|
| 401 |
+
download_button = pn.widgets.Button(name="Download .zip", button_type="primary", icon="download")
|
chatbot/static/css/styles.css
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
body {
|
| 2 |
+
font-family: Arial, sans-serif;
|
| 3 |
+
background-color: #f4f4f4;
|
| 4 |
+
margin: 0;
|
| 5 |
+
padding: 20px;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
.chat-container {
|
| 9 |
+
max-width: 600px;
|
| 10 |
+
margin: 0 auto;
|
| 11 |
+
padding: 20px;
|
| 12 |
+
border: 1px solid #ccc;
|
| 13 |
+
background: white;
|
| 14 |
+
border-radius: 10px;
|
| 15 |
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
#chat-box {
|
| 19 |
+
max-height: 400px;
|
| 20 |
+
overflow-y: auto;
|
| 21 |
+
margin-bottom: 10px;
|
| 22 |
+
padding: 10px;
|
| 23 |
+
border: 1px solid #ccc;
|
| 24 |
+
border-radius: 5px;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
input[type="text"] {
|
| 28 |
+
width: 80%;
|
| 29 |
+
padding: 10px;
|
| 30 |
+
border: 1px solid #ccc;
|
| 31 |
+
border-radius: 5px;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
button {
|
| 35 |
+
padding: 10px 15px;
|
| 36 |
+
border: none;
|
| 37 |
+
background-color: #007BFF;
|
| 38 |
+
color: white;
|
| 39 |
+
border-radius: 5px;
|
| 40 |
+
cursor: pointer;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
button:hover {
|
| 44 |
+
background-color: #0056b3;
|
| 45 |
+
}
|
chatbot/static/js/script.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
async function sendMessage() {
|
| 2 |
+
const inputField = document.getElementById("user-input");
|
| 3 |
+
const userMessage = inputField.value;
|
| 4 |
+
inputField.value = '';
|
| 5 |
+
appendMessage("You: " + userMessage);
|
| 6 |
+
|
| 7 |
+
let responseMessage = "I'm sorry, I didn't understand that.";
|
| 8 |
+
if (userMessage.toLowerCase().includes("scan networks")) {
|
| 9 |
+
const response = await fetch('/scan_network', { method: 'POST' });
|
| 10 |
+
const vulnerabilities = await response.json();
|
| 11 |
+
responseMessage = "Vulnerabilities found: " + JSON.stringify(vulnerabilities);
|
| 12 |
+
} else if (userMessage.toLowerCase().includes("deploy exploit")) {
|
| 13 |
+
const target = prompt("Enter target for exploit deployment:");
|
| 14 |
+
const response = await fetch('/deploy_exploit', {
|
| 15 |
+
method: 'POST',
|
| 16 |
+
headers: {
|
| 17 |
+
'Content-Type': 'application/json'
|
| 18 |
+
},
|
| 19 |
+
body: JSON.stringify({ target })
|
| 20 |
+
});
|
| 21 |
+
const result = await response.json();
|
| 22 |
+
responseMessage = "Exploit deployment result: " + result.result;
|
| 23 |
+
}
|
| 24 |
+
appendMessage("Chatbot: " + responseMessage);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
async function uploadImage() {
|
| 28 |
+
const fileInput = document.getElementById("image-input");
|
| 29 |
+
const file = fileInput.files[0];
|
| 30 |
+
const formData = new FormData();
|
| 31 |
+
formData.append('image', file);
|
| 32 |
+
|
| 33 |
+
const response = await fetch('/extract_text_from_image', {
|
| 34 |
+
method: 'POST',
|
| 35 |
+
body: formData
|
| 36 |
+
});
|
| 37 |
+
const data = await response.json();
|
| 38 |
+
appendMessage("Extracted Text: " + data.extracted_text);
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
async function uploadDocument() {
|
| 42 |
+
const fileInput = document.getElementById("document-input");
|
| 43 |
+
const file = fileInput.files[0];
|
| 44 |
+
const formData = new FormData();
|
| 45 |
+
formData.append('document', file);
|
| 46 |
+
|
| 47 |
+
const response = await fetch('/parse_document', {
|
| 48 |
+
method: 'POST',
|
| 49 |
+
body: formData
|
| 50 |
+
});
|
| 51 |
+
const data = await response.json();
|
| 52 |
+
appendMessage("Parsed Text: " + data.parsed_text);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
function appendMessage(message) {
|
| 56 |
+
const chatBox = document.getElementById("chat-box");
|
| 57 |
+
chatBox.innerHTML += "<div>" + message + "</div>";
|
| 58 |
+
chatBox.scrollTop = chatBox.scrollHeight; // Auto-scroll
|
| 59 |
+
}
|
chatbot/static/styles.css
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
body {
|
| 2 |
+
font-family: Arial, sans-serif;
|
| 3 |
+
background-color: #f4f4f4;
|
| 4 |
+
margin: 0;
|
| 5 |
+
padding: 20px;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
.chat-container {
|
| 9 |
+
max-width: 600px;
|
| 10 |
+
margin: 0 auto;
|
| 11 |
+
padding: 20px;
|
| 12 |
+
border: 1px solid #ccc;
|
| 13 |
+
background: white;
|
| 14 |
+
border-radius: 10px;
|
| 15 |
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
#chat-box {
|
| 19 |
+
max-height: 400px;
|
| 20 |
+
overflow-y: auto;
|
| 21 |
+
margin-bottom: 10px;
|
| 22 |
+
padding: 10px;
|
| 23 |
+
border: 1px solid #ccc;
|
| 24 |
+
border-radius: 5px;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
input[type="text"] {
|
| 28 |
+
width: 80%;
|
| 29 |
+
padding: 10px;
|
| 30 |
+
border: 1px solid #ccc;
|
| 31 |
+
border-radius: 5px;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
button {
|
| 35 |
+
padding: 10px 15px;
|
| 36 |
+
border: none;
|
| 37 |
+
background-color: #007BFF;
|
| 38 |
+
color: white;
|
| 39 |
+
border-radius: 5px;
|
| 40 |
+
cursor: pointer;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
button:hover {
|
| 44 |
+
background-color: #0056b3;
|
| 45 |
+
}
|
chatbot/templates/index.html
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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ename='styles.css') }}">
|
| 7 |
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
| 8 |
+
<title>Chatbot Interface</title>
|
| 9 |
+
</head>
|
| 10 |
+
<body>
|
| 11 |
+
<div class="chat-container">
|
| 12 |
+
<h1>Chatbot Interface</h1>
|
| 13 |
+
<div id="chat-box"></div>
|
| 14 |
+
<input type="text" id="user-input" placeholder="Type your message..." autofocus>
|
| 15 |
+
<button onclick="sendMessage()">Send</button>
|
| 16 |
+
<button onclick="startVoiceRecognition()">🎤 Voice Input</button>
|
| 17 |
+
<input type="file" id="image-upload" accept="image/*" onchange="handleImageUpload()" />
|
| 18 |
+
<input type="file" id="doc-upload" accept=".txt,.md,.pdf" onchange="handleDocUpload()" />
|
| 19 |
+
</div>
|
| 20 |
+
|
| 21 |
+
<h2>Network Scan and Vulnerability Test</h2>
|
| 22 |
+
<h2>Setup API Keys</h2>
|
| 23 |
+
<form id="apiKeysForm" method="POST" action="/setup_api_keys">
|
| 24 |
+
<div>
|
| 25 |
+
<h3>Gemini API Keys</h3>
|
| 26 |
+
<input type="text" name="gemini_key_1" placeholder="Enter Gemini API Key #1" required>
|
| 27 |
+
<input type="text" name="gemini_key_2" placeholder="Enter Gemini API Key #2">
|
| 28 |
+
<input type="text" name="gemini_key_3" placeholder="Enter Gemini API Key #3">
|
| 29 |
+
<input type="text" name="gemini_key_4" placeholder="Enter Gemini API Key #4">
|
| 30 |
+
<input type="text" name="gemini_key_5" placeholder="Enter Gemini API Key #5">
|
| 31 |
+
</div>
|
| 32 |
+
<div>
|
| 33 |
+
<h3>OpenAI Codex API Keys</h3>
|
| 34 |
+
<input type="text" name="open_codex_key_1" placeholder="Enter Open Codex API Key #1" required>
|
| 35 |
+
<input type="text" name="open_codex_key_2" placeholder="Enter Open Codex API Key #2">
|
| 36 |
+
<input type="text" name="open_codex_key_3" placeholder="Enter Open Codex API Key #3">
|
| 37 |
+
<input type="text" name="open_codex_key_4" placeholder="Enter Open Codex API Key #4">
|
| 38 |
+
<input type="text" name="open_codex_key_5" placeholder="Enter Open Codex API Key #5">
|
| 39 |
+
</div>
|
| 40 |
+
<div>
|
| 41 |
+
<h3>OpenAI 3.5 API Keys</h3>
|
| 42 |
+
<input type="text" name="openai_key_1" placeholder="Enter OpenAI 3.5 API Key #1" required>
|
| 43 |
+
<input type="text" name="openai_key_2" placeholder="Enter OpenAI 3.5 API Key #2">
|
| 44 |
+
<input type="text" name="openai_key_3" placeholder="Enter OpenAI 3.5 API Key #3">
|
| 45 |
+
<input type="text" name="openai_key_4" placeholder="Enter OpenAI 3.5 API Key #4">
|
| 46 |
+
<input type="text" name="openai_key_5" placeholder="Enter OpenAI 3.5 API Key #5">
|
| 47 |
+
</div>
|
| 48 |
+
<div>
|
| 49 |
+
<h3>Google AI Studio API Key</h3>
|
| 50 |
+
<input type="text" name="google_ai_studio_key" placeholder="Enter Google AI Studio API Key" required>
|
| 51 |
+
</div>
|
| 52 |
+
<button type="submit">Submit API Keys</button>
|
| 53 |
+
</form>
|
| 54 |
+
|
| 55 |
+
<h2>Setup Messaging Service</h2>
|
| 56 |
+
<form id="messagingServiceForm" method="POST" action="/setup_messaging_service">
|
| 57 |
+
<select name="service_selection" onchange="showServiceInputs(this.value)">
|
| 58 |
+
<option value="">Select a Messaging Service</option>
|
| 59 |
+
<option value="1">Google Voice</option>
|
| 60 |
+
<option value="2">Twilio</option>
|
| 61 |
+
<option value="3">Textbelt</option>
|
| 62 |
+
</select>
|
| 63 |
+
<div id="googleVoiceInputs" style="display: none;">
|
| 64 |
+
<input type="text" name="gv_client_id" placeholder="Google Voice API Client ID" required>
|
| 65 |
+
<input type="text" name="gv_client_secret" placeholder="Google Voice API Client Secret" required>
|
| 66 |
+
</div>
|
| 67 |
+
<div id="twilioInputs" style="display: none;">
|
| 68 |
+
<input type="text" name="twilio_sid" placeholder="Twilio Account SID" required>
|
| 69 |
+
<input type="text" name="twilio_auth_token" placeholder="Twilio Auth Token" required>
|
| 70 |
+
<input type="text" name="twilio_phone" placeholder="Twilio Phone Number" required>
|
| 71 |
+
</div>
|
| 72 |
+
<div id="textbeltInputs" style="display: none;">
|
| 73 |
+
<input type="text" name="textbelt_api_key" placeholder="Textbelt API Key" required>
|
| 74 |
+
</div>
|
| 75 |
+
<button type="submit">Submit Messaging Service</button>
|
| 76 |
+
</form>
|
| 77 |
+
|
| 78 |
+
<h2>Search GitHub Projects</h2>
|
| 79 |
+
<form id="githubSearchForm" method="POST" action="/search_github">
|
| 80 |
+
<input type="text" name="search_term" placeholder="Enter search term..." required>
|
| 81 |
+
<button type="submit">Search GitHub</button>
|
| 82 |
+
</form>
|
| 83 |
+
|
| 84 |
+
<script>
|
| 85 |
+
// Voice Recognition
|
| 86 |
+
function startVoiceRecognition() {
|
| 87 |
+
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
| 88 |
+
recognition.lang = 'en-US';
|
| 89 |
+
recognition.start();
|
| 90 |
+
|
| 91 |
+
recognition.onresult = (event) => {
|
| 92 |
+
const transcript = event.results[0][0].transcript;
|
| 93 |
+
document.getElementById("user-input").value = transcript;
|
| 94 |
+
sendMessage();
|
| 95 |
+
};
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
async function sendMessage() {
|
| 99 |
+
const inputField = document.getElementById("user-input");
|
| 100 |
+
const userMessage = inputField.value;
|
| 101 |
+
inputField.value = '';
|
| 102 |
+
appendMessage("You: " + userMessage);
|
| 103 |
+
|
| 104 |
+
let responseMessage = "I'm sorry, I didn't understand that.";
|
| 105 |
+
|
| 106 |
+
if (userMessage.toLowerCase().includes("scan networks")) {
|
| 107 |
+
const response = await fetch('/scan_network', { method: 'POST' });
|
| 108 |
+
const vulnerabilities = await response.json();
|
| 109 |
+
responseMessage = "Vulnerabilities found: " + JSON.stringify(vulnerabilities);
|
| 110 |
+
} else if (userMessage.toLowerCase().includes("deploy exploit")) {
|
| 111 |
+
const target = prompt("Enter target for exploit deployment:");
|
| 112 |
+
const response = await fetch('/deploy_exploit', {
|
| 113 |
+
method: 'POST',
|
| 114 |
+
headers: {
|
| 115 |
+
'Content-Type': 'application/json'
|
| 116 |
+
},
|
| 117 |
+
body: JSON.stringify({ target })
|
| 118 |
+
});
|
| 119 |
+
const result = await response.json();
|
| 120 |
+
responseMessage = "Exploit deployment result: " + result.status;
|
| 121 |
+
}
|
| 122 |
+
appendMessage("Chatbot: " + responseMessage);
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
function appendMessage(message) {
|
| 126 |
+
const chatBox = document.getElementById("chat-box");
|
| 127 |
+
chatBox.innerHTML += "<div>" + message + "</div>";
|
| 128 |
+
chatBox.scrollTop = chatBox.scrollHeight; // Auto-scroll
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
async function handleImageUpload() {
|
| 132 |
+
const file = document.getElementById('image-upload').files[0];
|
| 133 |
+
const formData = new FormData();
|
| 134 |
+
formData.append('image', file);
|
| 135 |
+
|
| 136 |
+
const response = await fetch('/extract_text_from_image', {
|
| 137 |
+
method: 'POST',
|
| 138 |
+
body: formData
|
| 139 |
+
});
|
| 140 |
+
|
| 141 |
+
const result = await response.json();
|
| 142 |
+
appendMessage("Extracted Text: " + result.text);
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
async function handleDocUpload() {
|
| 146 |
+
const file = document.getElementById('doc-upload').files[0];
|
| 147 |
+
const formData = new FormData();
|
| 148 |
+
formData.append('document', file);
|
| 149 |
+
|
| 150 |
+
const response = await fetch('/parse_document', {
|
| 151 |
+
method: 'POST',
|
| 152 |
+
body: formData
|
| 153 |
+
});
|
| 154 |
+
|
| 155 |
+
const result = await response.json();
|
| 156 |
+
appendMessage("Parsed Document Code: " + result.code);
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
function showServiceInputs(value) {
|
| 160 |
+
document.getElementById("googleVoiceInputs").style.display = value === "1" ? "block" : "none";
|
| 161 |
+
document.getElementById("twilioInputs").style.display = value === "2" ? "block" : "none";
|
| 162 |
+
document.getElementById("textbeltInputs").style.display = value === "3" ? "block" : "none";
|
| 163 |
+
}
|
| 164 |
+
</script>
|
| 165 |
+
</body>
|
| 166 |
+
</html>
|
chatbot/templates/key_input.html
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Network Scan and Vulnerability Test</title>
|
| 7 |
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
| 8 |
+
</head>
|
| 9 |
+
<body>
|
| 10 |
+
<h1>Network Scan and Vulnerability Test</h1>
|
| 11 |
+
|
| 12 |
+
<h2>Setup API Keys</h2>
|
| 13 |
+
<form id="apiKeysForm" method="POST" action="/setup_api_keys">
|
| 14 |
+
<div>
|
| 15 |
+
<h3>Gemini API Keys</h3>
|
| 16 |
+
<input type="text" name="gemini_key_1" placeholder="Enter Gemini API Key #1" required>
|
| 17 |
+
<input type="text" name="gemini_key_2" placeholder="Enter Gemini API Key #2">
|
| 18 |
+
<input type="text" name="gemini_key_3" placeholder="Enter Gemini API Key #3">
|
| 19 |
+
<input type="text" name="gemini_key_4" placeholder="Enter Gemini API Key #4">
|
| 20 |
+
<input type="text" name="gemini_key_5" placeholder="Enter Gemini API Key #5">
|
| 21 |
+
</div>
|
| 22 |
+
<div>
|
| 23 |
+
<h3>OpenAI Codex API Keys</h3>
|
| 24 |
+
<input type="text" name="open_codex_key_1" placeholder="Enter Open Codex API Key #1" required>
|
| 25 |
+
<input type="text" name="open_codex_key_2" placeholder="Enter Open Codex API Key #2">
|
| 26 |
+
<input type="text" name="open_codex_key_3" placeholder="Enter Open Codex API Key #3">
|
| 27 |
+
<input type="text" name="open_codex_key_4" placeholder="Enter Open Codex API Key #4">
|
| 28 |
+
<input type="text" name="open_codex_key_5" placeholder="Enter Open Codex API Key #5">
|
| 29 |
+
</div>
|
| 30 |
+
<div>
|
| 31 |
+
<h3>OpenAI 3.5 API Keys</h3>
|
| 32 |
+
<input type="text" name="openai_key_1" placeholder="Enter OpenAI 3.5 API Key #1" required>
|
| 33 |
+
<input type="text" name="openai_key_2" placeholder="Enter OpenAI 3.5 API Key #2">
|
| 34 |
+
<input type="text" name="openai_key_3" placeholder="Enter OpenAI 3.5 API Key #3">
|
| 35 |
+
<input type="text" name="openai_key_4" placeholder="Enter OpenAI 3.5 API Key #4">
|
| 36 |
+
<input type="text" name="openai_key_5" placeholder="Enter OpenAI 3.5 API Key #5">
|
| 37 |
+
</div>
|
| 38 |
+
<div>
|
| 39 |
+
<h3>Google AI Studio API Key</h3>
|
| 40 |
+
<input type="text" name="google_ai_studio_key" placeholder="Enter Google AI Studio API Key" required>
|
| 41 |
+
</div>
|
| 42 |
+
<button type="submit">Submit API Keys</button>
|
| 43 |
+
</form>
|
| 44 |
+
|
| 45 |
+
<h2>Setup Messaging Service</h2>
|
| 46 |
+
<form id="messagingServiceForm" method="POST" action="/setup_messaging_service">
|
| 47 |
+
<select name="service_selection">
|
| 48 |
+
<option value="1">Google Voice</option>
|
| 49 |
+
<option value="2">Twilio</option>
|
| 50 |
+
<option value="3">Textbelt</option>
|
| 51 |
+
</select>
|
| 52 |
+
<div id="googleVoiceInputs" style="display: none;">
|
| 53 |
+
<input type="text" name="gv_client_id" placeholder="Google Voice API Client ID" required>
|
| 54 |
+
<input type="text" name="gv_client_secret" placeholder="Google Voice API Client Secret" required>
|
| 55 |
+
</div>
|
| 56 |
+
<div id="twilioInputs" style="display: none;">
|
| 57 |
+
<input type="text" name="twilio_sid" placeholder="Twilio Account SID" required>
|
| 58 |
+
<input type="text" name="twilio_auth_token" placeholder="Twilio Auth Token" required>
|
| 59 |
+
<input type="text" name="twilio_phone" placeholder="Twilio Phone Number" required>
|
| 60 |
+
</div>
|
| 61 |
+
<div id="textbeltInputs" style="display: none;">
|
| 62 |
+
<input type="text" name="textbelt_api_key" placeholder="Textbelt API Key" required>
|
| 63 |
+
</div>
|
| 64 |
+
<button type="submit">Submit Messaging Service</button>
|
| 65 |
+
</form>
|
| 66 |
+
|
| 67 |
+
<h2>Search GitHub Projects</h2>
|
| 68 |
+
<form id="githubSearchForm" method="POST" action="/search_github">
|
| 69 |
+
<input type="text" name="search_term"
|
cli/cli_dashboard.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
def cli_dashboard():
|
| 5 |
+
secret_key = os.getenv("DASHBOARD_SECRET", "default_key")
|
| 6 |
+
print(f"Using secret key: {secret_key}")
|
| 7 |
+
print("CLI Dashboard Ready")
|
| 8 |
+
|
| 9 |
+
if __name__ == "__main__":
|
| 10 |
+
cli_dashboard()
|