Paritosh Upadhyay commited on
Commit
9ea4e09
Β·
1 Parent(s): eb2ebb3

Local Hunter Protocol: External Ingest Portal & Mac Scout Script

Browse files
backend/app/scratch/subconscious_loop.py CHANGED
@@ -3,9 +3,11 @@ import os
3
  import time
4
  import logging
5
  import threading
6
- from fastapi import FastAPI
7
  from fastapi.staticfiles import StaticFiles
8
  from fastapi.responses import FileResponse
 
 
9
  import uvicorn
10
  from fastapi.middleware.cors import CORSMiddleware
11
 
@@ -42,6 +44,39 @@ async def get_dashboard():
42
  dashboard_path = os.path.join(static_path, "sovereign.html")
43
  return FileResponse(dashboard_path)
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  @app.get("/system/status")
46
  async def get_system_status():
47
  with database.SessionLocal() as db:
 
3
  import time
4
  import logging
5
  import threading
6
+ from fastapi import FastAPI, BackgroundTasks, Request
7
  from fastapi.staticfiles import StaticFiles
8
  from fastapi.responses import FileResponse
9
+ from pydantic import BaseModel
10
+ from typing import List, Dict, Optional
11
  import uvicorn
12
  from fastapi.middleware.cors import CORSMiddleware
13
 
 
44
  dashboard_path = os.path.join(static_path, "sovereign.html")
45
  return FileResponse(dashboard_path)
46
 
47
+ class IngestionItem(BaseModel):
48
+ title: str
49
+ url: str
50
+ body: str
51
+
52
+ class ExternalIngest(BaseModel):
53
+ topic: str
54
+ results: List[IngestionItem]
55
+ secret: str
56
+
57
+ @app.post("/system/external-ingest")
58
+ async def external_ingest(data: ExternalIngest):
59
+ # Secure via simple PIN check (Sovereign 1978)
60
+ if data.secret != "1978":
61
+ return {"status": "denied", "message": "Identity Not Recognized"}
62
+
63
+ logger.info(f"πŸš€ [EXTERNAL INGEST] Receiving intelligence on: {data.topic}")
64
+ count = 0
65
+ for item in data.results:
66
+ try:
67
+ name = f"External Discovery: {item.title[:50]}"
68
+ holocron.add_knowledge_node(
69
+ name=name,
70
+ category=data.topic,
71
+ content=item.body,
72
+ metadata={"url": item.url, "source": "local_hunter"}
73
+ )
74
+ count += 1
75
+ except Exception as e:
76
+ logger.error(f"Ingest failed for {item.url}: {e}")
77
+
78
+ return {"status": "success", "ingested": count}
79
+
80
  @app.get("/system/status")
81
  async def get_system_status():
82
  with database.SessionLocal() as db:
backend/requirements_cloud.txt CHANGED
@@ -26,3 +26,4 @@ httpx==0.28.1
26
  rich==14.0.0
27
  duckduckgo_search==7.3.2
28
  phonemizer==3.2.1
 
 
26
  rich==14.0.0
27
  duckduckgo_search==7.3.2
28
  phonemizer==3.2.1
29
+ googlesearch-python==1.3.0
scripts/local_hunter.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import json
3
+ import time
4
+ import random
5
+ from duckduckgo_search import DDGS
6
+ import trafilatura
7
+
8
+ # --- CONFIGURATION ---
9
+ CLOUD_URL = "https://paritosh-sovereign-friday-subconscious.hf.space/system/external-ingest"
10
+ SOVEREIGN_PIN = "1978"
11
+
12
+ STRATEGIC_TOPICS = [
13
+ "Regional Demographics and Residential Trends India 2024",
14
+ "Strategic Infrastructure development and upcoming projects by Area",
15
+ "Autonomous CRM Automation and OttoPilot strategies",
16
+ "Deep Learning for Agentic Workflow Orchestration",
17
+ "Strategic Finance & Venture Capital Risk Management"
18
+ ]
19
+
20
+ def scrape_url(url):
21
+ """Local scraper logic using trafilatura."""
22
+ try:
23
+ downloaded = trafilatura.fetch_url(url)
24
+ content = trafilatura.extract(downloaded)
25
+ return content[:3000] if content else None
26
+ except:
27
+ return None
28
+
29
+ def hunt():
30
+ print("πŸš€ [LOCAL HUNTER] Starting Sovereign Foraging Protocol...")
31
+ print(f"πŸ“ TARGET: {CLOUD_URL}")
32
+ print("═" * 50)
33
+
34
+ for topic in STRATEGIC_TOPICS:
35
+ print(f"\nπŸ” Hunting Intelligence: {topic}")
36
+ results = []
37
+
38
+ try:
39
+ with DDGS(timeout=30) as ddgs:
40
+ ddg_results = list(ddgs.text(topic, max_results=3))
41
+
42
+ for r in ddg_results:
43
+ print(f" ↳ Capturing Source: {r['href']}")
44
+ body = scrape_url(r['href'])
45
+ if body:
46
+ results.append({
47
+ "title": r['title'],
48
+ "url": r['href'],
49
+ "body": body
50
+ })
51
+ time.sleep(random.uniform(2, 5)) # Human-like jitter
52
+
53
+ # PUSH TO CLOUD
54
+ if results:
55
+ payload = {
56
+ "topic": topic,
57
+ "results": results,
58
+ "secret": SOVEREIGN_PIN
59
+ }
60
+ resp = requests.post(CLOUD_URL, json=payload)
61
+ if resp.status_code == 200:
62
+ print(f"βœ… SUCCESS: {len(results)} intelligence packages beamed to Cloud.")
63
+ else:
64
+ print(f"⚠️ CLOUD REJECTION: {resp.status_code} - {resp.text}")
65
+
66
+ except Exception as e:
67
+ print(f"❌ HUNT ERROR for {topic}: {e}")
68
+
69
+ time.sleep(random.randint(10, 20)) # Cool down between topics
70
+
71
+ print("\n═" * 50)
72
+ print("🏁 [LOCAL HUNTER] Mission Complete. Grid Rejuvenated.")
73
+
74
+ if __name__ == "__main__":
75
+ hunt()