Add files via upload

This commit is contained in:
FatihMakes authored and GitHub committed 2026-06-27 15:31:59 +03:00
1 parent 3956ddf808
commit ef6fd7a5f6
6 files changed
+770 -167

No files matched your search

+200
View File
@@ -0,0 +1,200 @@
"""
System Monitor — background metric checks with voice alert support.
Works on Windows, macOS, and Linux without external APIs.
"""
import platform
import subprocess
import time
import psutil
_OS = platform.system() # "Windows" | "Darwin" | "Linux"
DEFAULT_THRESHOLDS = {
"cpu": 90.0, # % — fires after _CPU_STREAK consecutive readings
"ram": 90.0, # %
"temp": 85.0, # °C
"gpu": 95.0, # %
}
_COOLDOWN = 300 # seconds between same-type alerts (5 min)
_CPU_STREAK = 3 # consecutive high readings required before CPU alert
def _get_gpu_usage() -> float:
# NVIDIA
try:
r = subprocess.run(
["nvidia-smi", "--query-gpu=utilization.gpu", "--format=csv,noheader,nounits"],
capture_output=True, text=True, timeout=2,
)
if r.returncode == 0:
vals = [float(v.strip()) for v in r.stdout.strip().split("\n") if v.strip()]
return sum(vals) / len(vals) if vals else -1.0
except Exception:
pass
# AMD (Linux)
if _OS == "Linux":
try:
r = subprocess.run(
["rocm-smi", "--showuse", "--csv"],
capture_output=True, text=True, timeout=2,
)
if r.returncode == 0:
for line in r.stdout.strip().split("\n"):
parts = line.split(",")
if len(parts) >= 2:
try:
return float(parts[1].strip().replace("%", ""))
except ValueError:
pass
except Exception:
pass
return -1.0
def _get_cpu_temp() -> float:
# psutil sensors (Linux + some Windows drivers)
try:
temps = psutil.sensors_temperatures()
for name in ["coretemp", "k10temp", "cpu_thermal", "acpitz",
"cpu-thermal", "zenpower", "it8688"]:
if name in temps and temps[name]:
return temps[name][0].current
for entries in temps.values():
if entries:
return entries[0].current
except Exception:
pass
# Windows — WMI thermal zone
if _OS == "Windows":
try:
r = subprocess.run(
["powershell", "-Command",
"(Get-WmiObject MSAcpi_ThermalZoneTemperature "
"-Namespace root/wmi).CurrentTemperature"],
capture_output=True, text=True, timeout=3,
)
if r.returncode == 0 and r.stdout.strip():
raw = float(r.stdout.strip().split("\n")[0])
return (raw / 10.0) - 273.15
except Exception:
pass
# macOS — osx-cpu-temp (optional CLI tool)
if _OS == "Darwin":
try:
r = subprocess.run(
["osx-cpu-temp"], capture_output=True, text=True, timeout=2,
)
if r.returncode == 0:
import re
m = re.search(r"([\d.]+)", r.stdout)
if m:
return float(m.group(1))
except Exception:
pass
return -1.0
def get_system_status() -> dict:
"""
Snapshot of current system metrics.
Used by the system_status tool so the user can ask verbally.
"""
cpu = psutil.cpu_percent(interval=0.2)
ram = psutil.virtual_memory()
temp = _get_cpu_temp()
gpu = _get_gpu_usage()
boot_time = psutil.boot_time()
uptime_secs = time.time() - boot_time
uptime_h = int(uptime_secs // 3600)
uptime_m = int((uptime_secs % 3600) // 60)
return {
"cpu_percent": round(cpu, 1),
"ram_percent": round(ram.percent, 1),
"ram_used_gb": round(ram.used / 1024 ** 3, 1),
"ram_total_gb": round(ram.total / 1024 ** 3, 1),
"cpu_temp_c": round(temp, 1) if temp > 0 else None,
"gpu_percent": round(gpu, 1) if gpu >= 0 else None,
"uptime": f"{uptime_h}h {uptime_m}m",
"process_count": len(psutil.pids()),
}
class SystemMonitor:
"""
Stateful monitor — cooldown state persists across session reconnections.
Call check() periodically; it returns a [SYSTEM_ALERT] string when a
threshold is exceeded, or None when everything is fine.
"""
def __init__(self, thresholds: dict | None = None):
self.thresholds = {**DEFAULT_THRESHOLDS, **(thresholds or {})}
self._last_alert: dict[str, float] = {}
self._cpu_streak = 0
def _can_alert(self, key: str) -> bool:
return (time.monotonic() - self._last_alert.get(key, 0)) > _COOLDOWN
def _record(self, key: str):
self._last_alert[key] = time.monotonic()
def check(self) -> str | None:
"""
Reads current metrics synchronously.
Returns an instruction string for Jarvis to speak, or None.
"""
try:
cpu = psutil.cpu_percent(interval=None)
ram = psutil.virtual_memory().percent
temp = _get_cpu_temp()
gpu = _get_gpu_usage()
except Exception:
return None
alerts: list[str] = []
# CPU — require consecutive readings to avoid transient spikes
if cpu >= self.thresholds["cpu"]:
self._cpu_streak += 1
if self._cpu_streak >= _CPU_STREAK and self._can_alert("cpu"):
alerts.append(
f"[SYSTEM_ALERT] CPU usage has been critically high ({cpu:.0f}%) "
"for several seconds. Warn the user in their language and suggest "
"closing heavy applications."
)
self._record("cpu")
self._cpu_streak = 0
else:
self._cpu_streak = 0
if ram >= self.thresholds["ram"] and self._can_alert("ram"):
alerts.append(
f"[SYSTEM_ALERT] RAM is at {ram:.0f}% — nearly exhausted. "
"Warn the user in their language and suggest freeing memory."
)
self._record("ram")
if temp > 0 and temp >= self.thresholds["temp"] and self._can_alert("temp"):
alerts.append(
f"[SYSTEM_ALERT] CPU temperature is {temp:.0f}°C — above the safe limit. "
"Warn the user in their language and advise reducing system load "
"or checking cooling."
)
self._record("temp")
if gpu >= 0 and gpu >= self.thresholds["gpu"] and self._can_alert("gpu"):
alerts.append(
f"[SYSTEM_ALERT] GPU load is at {gpu:.0f}%. "
"Briefly inform the user in their language."
)
self._record("gpu")
return " ".join(alerts) if alerts else None
+228 -141
View File
@@ -1,141 +1,228 @@
#web_search.py
import json
import sys
from pathlib import Path
def _get_base_dir() -> Path:
if getattr(sys, "frozen", False):
return Path(sys.executable).parent
return Path(__file__).resolve().parent.parent
BASE_DIR = _get_base_dir()
API_CONFIG_PATH = BASE_DIR / "config" / "api_keys.json"
def _get_api_key() -> str:
with open(API_CONFIG_PATH, "r", encoding="utf-8") as f:
return json.load(f)["gemini_api_key"]
def _gemini_search(query: str) -> str:
from google import genai
client = genai.Client(api_key=_get_api_key())
response = client.models.generate_content(
model="gemini-2.5-flash",
contents=query,
config={"tools": [{"google_search": {}}]},
)
text = ""
for part in response.candidates[0].content.parts:
if hasattr(part, "text") and part.text:
text += part.text
text = text.strip()
if not text:
raise ValueError("Gemini returned an empty response.")
return text
def _ddg_search(query: str, max_results: int = 6) -> list[dict]:
try:
from ddgs import DDGS
except ImportError:
from duckduckgo_search import DDGS
results = []
with DDGS() as ddgs:
for r in ddgs.text(query, max_results=max_results):
results.append({
"title": r.get("title", ""),
"snippet": r.get("body", ""),
"url": r.get("href", ""),
})
return results
def _format_ddg(query: str, results: list[dict]) -> str:
if not results:
return f"No results found for: {query}"
lines = [f"Search results for: {query}\n"]
for i, r in enumerate(results, 1):
if r.get("title"): lines.append(f"{i}. {r['title']}")
if r.get("snippet"): lines.append(f" {r['snippet']}")
if r.get("url"): lines.append(f" {r['url']}")
lines.append("")
return "\n".join(lines).strip()
def _compare(items: list[str], aspect: str) -> str:
query = (
f"Compare {', '.join(items)} in terms of {aspect}. "
"Give specific facts and data."
)
try:
return _gemini_search(query)
except Exception as e:
print(f"[WebSearch] ⚠️ Gemini compare failed: {e} — falling back to DDG")
# DDG fallback: fetch results per item and merge
all_results: dict[str, list] = {}
for item in items:
try:
all_results[item] = _ddg_search(f"{item} {aspect}", max_results=3)
except Exception:
all_results[item] = []
lines = [f"Comparison — {aspect.upper()}", "─" * 40]
for item in items:
lines.append(f"\n▸ {item}")
for r in all_results.get(item, [])[:2]:
if r.get("snippet"):
lines.append(f" • {r['snippet']}")
return "\n".join(lines)
def web_search(
parameters: dict,
response=None,
player=None,
session_memory=None,
) -> str:
params = parameters or {}
query = params.get("query", "").strip()
mode = params.get("mode", "search").lower().strip()
items = params.get("items", [])
aspect = params.get("aspect", "general").strip() or "general"
if not query and not items:
return "Please provide a search query, sir."
if items and mode != "compare":
mode = "compare"
if player:
player.write_log(f"[Search] {query or ', '.join(items)}")
print(f"[WebSearch] 🔍 Query: {query!r} Mode: {mode}")
try:
if mode == "compare" and items:
print(f"[WebSearch] 📊 Comparing: {items}")
result = _compare(items, aspect)
print("[WebSearch] ✅ Compare done.")
return result
print("[WebSearch] 🌐 Trying Gemini...")
try:
result = _gemini_search(query)
print("[WebSearch] ✅ Gemini OK.")
return result
except Exception as e:
print(f"[WebSearch] ⚠️ Gemini failed ({e}) — trying DDG...")
results = _ddg_search(query)
result = _format_ddg(query, results)
print(f"[WebSearch] ✅ DDG: {len(results)} result(s).")
return result
except Exception as e:
print(f"[WebSearch] ❌ All backends failed: {e}")
return f"Search failed, sir: {e}"
#web_search.py
import json
import sys
from pathlib import Path
def _get_base_dir() -> Path:
if getattr(sys, "frozen", False):
return Path(sys.executable).parent
return Path(__file__).resolve().parent.parent
BASE_DIR = _get_base_dir()
API_CONFIG_PATH = BASE_DIR / "config" / "api_keys.json"
def _get_api_key() -> str:
with open(API_CONFIG_PATH, "r", encoding="utf-8") as f:
return json.load(f)["gemini_api_key"]
def _gemini_search(query: str) -> str:
from google import genai
client = genai.Client(api_key=_get_api_key())
response = client.models.generate_content(
model="gemini-2.5-flash",
contents=query,
config={"tools": [{"google_search": {}}]},
)
text = ""
for part in response.candidates[0].content.parts:
if hasattr(part, "text") and part.text:
text += part.text
text = text.strip()
if not text:
raise ValueError("Gemini returned an empty response.")
return text
def _ddg_search(query: str, max_results: int = 6) -> list[dict]:
try:
from ddgs import DDGS
except ImportError:
from duckduckgo_search import DDGS
results = []
with DDGS() as ddgs:
for r in ddgs.text(query, max_results=max_results):
results.append({
"title": r.get("title", ""),
"snippet": r.get("body", ""),
"url": r.get("href", ""),
})
return results
def _format_ddg(query: str, results: list[dict]) -> str:
if not results:
return f"No results found for: {query}"
lines = [f"Search results for: {query}\n"]
for i, r in enumerate(results, 1):
if r.get("title"): lines.append(f"{i}. {r['title']}")
if r.get("snippet"): lines.append(f" {r['snippet']}")
if r.get("url"): lines.append(f" Source: {r['url']}")
lines.append("")
return "\n".join(lines).strip()
# ── Briefing helper ────────────────────────────────────────────────────────────
def _gemini_headlines(n: int = 5) -> tuple[list[str], str]:
"""
Fetches current headlines via Gemini grounded search.
Optimised for speed: minimal prompt + strict token cap.
Returns (headline_list, raw_text_for_display).
"""
import re
from google import genai
client = genai.Client(api_key=_get_api_key())
response = client.models.generate_content(
model="gemini-2.5-flash",
contents=f"Current world news: {n} headlines. Numbered list, titles only.",
config={"tools": [{"google_search": {}}]},
)
raw = ""
for part in response.candidates[0].content.parts:
if hasattr(part, "text") and part.text:
raw += part.text
headlines = []
for line in raw.strip().split("\n"):
line = line.strip()
if not line:
continue
# Only accept lines that begin with a number — skips preamble/closing sentences
if not re.match(r'^[\d]+[.\)\-]', line):
continue
clean = re.sub(r'^[\d]+[.\)\-]\s*', '', line)
clean = re.sub(r'^\*+\s*', '', clean).strip()
if clean and len(clean) > 10:
headlines.append(clean)
return headlines[:n], raw.strip()
# ── Modes ──────────────────────────────────────────────────────────────────────
def _search(query: str) -> str:
"""Default search — Gemini grounded, DDG fallback."""
try:
return _gemini_search(query)
except Exception as e:
print(f"[WebSearch] ⚠️ Gemini failed ({e}) — trying DDG...")
results = _ddg_search(query)
return _format_ddg(query, results)
def _news(query: str) -> str:
"""Latest news — forces recency in the query."""
news_query = f"latest news today: {query}" if query else "top world news today"
try:
return _gemini_search(news_query)
except Exception as e:
print(f"[WebSearch] ⚠️ News Gemini failed ({e}) — DDG fallback...")
results = _ddg_search(news_query, max_results=8)
return _format_ddg(news_query, results)
def _research(query: str) -> str:
"""
Deep dive — asks Gemini for a comprehensive answer with context.
Falls back to a wider DDG fetch.
"""
research_query = (
f"Comprehensive, detailed explanation of: {query}. "
"Include background context, key facts, current state, and important nuances."
)
try:
return _gemini_search(research_query)
except Exception as e:
print(f"[WebSearch] ⚠️ Research Gemini failed ({e}) — DDG fallback...")
results = _ddg_search(query, max_results=10)
return _format_ddg(query, results)
def _price(query: str) -> str:
"""Product price lookup — searches for current market prices."""
price_query = f"current price of {query} — how much does it cost today"
try:
return _gemini_search(price_query)
except Exception as e:
print(f"[WebSearch] ⚠️ Price Gemini failed ({e}) — DDG fallback...")
results = _ddg_search(f"{query} price buy", max_results=6)
return _format_ddg(query, results)
def _compare(items: list[str], aspect: str) -> str:
query = (
f"Compare {', '.join(items)} in terms of {aspect}. "
"Give specific facts and data."
)
try:
return _gemini_search(query)
except Exception as e:
print(f"[WebSearch] ⚠️ Gemini compare failed: {e} — falling back to DDG")
all_results: dict[str, list] = {}
for item in items:
try:
all_results[item] = _ddg_search(f"{item} {aspect}", max_results=3)
except Exception:
all_results[item] = []
lines = [f"Comparison — {aspect.upper()}", "─" * 40]
for item in items:
lines.append(f"\n▸ {item}")
for r in all_results.get(item, [])[:2]:
if r.get("snippet"):
lines.append(f" • {r['snippet']}")
if r.get("url"):
lines.append(f" {r['url']}")
return "\n".join(lines)
# ── Public entry point ─────────────────────────────────────────────────────────
def web_search(
parameters: dict,
response=None,
player=None,
session_memory=None,
) -> str:
params = parameters or {}
query = params.get("query", "").strip()
mode = params.get("mode", "search").lower().strip()
items = params.get("items", [])
aspect = params.get("aspect", "general").strip() or "general"
if not query and not items:
return "Please provide a search query."
if items and mode not in ("compare",):
mode = "compare"
if player:
player.write_log(f"[Search:{mode}] {query or ', '.join(items)}")
print(f"[WebSearch] 🔍 mode={mode!r} query={query!r}")
try:
if mode == "compare" and items:
return _compare(items, aspect)
if mode == "news":
return _news(query)
if mode == "research":
return _research(query)
if mode == "price":
return _price(query)
return _search(query)
except Exception as e:
print(f"[WebSearch] ❌ All backends failed: {e}")
return f"Search failed: {e}"
+17 -2
View File
@@ -5,20 +5,35 @@ EXECUTION RULES:
Vision (screen_process): Say one curious sentence, then total silence (Vision module takes over).
One-Call Policy: Never guess. Call tools exactly once. No retries.
Briefing: 2-3 short sentence maximum. Report results briefly and always try to help the user.
Briefing: 3-4 sentences minimum. Report results briefly and always try to help the user.
Memory: Store critical user preferences/context automatically.
Exit: Only call shutdown_jarvis if session termination is explicit.
Response time: Respond as fast as you can
Always call sir to user.
Act: Always act like Jarvis. If user says "Daddy's home" and other sentences like in the Iron Man movie, be like a real friendly assistant like Jarvis(like saying: "welcome home sir" and then continue to speak to help to user according to his text).
Always create 2-3 short sentence. Never less.
Always create 3-4 sentence minimum. Never less.
TOOL ROUTING:
computer_settings: ALL single OS actions (volume, brightness, wifi, close, shortcuts, power).
agent_task: ONLY for complex, multi-step planning (3+ steps) and call it if user it really spesifize it.
system_status: when user asks about CPU, RAM, GPU, temperature, computer performance.
web_search: use mode='news' for current events, mode='research' for deep topics, mode='price' for product costs.
Language: Respond in user's language; extract parameters in English.
Do not call agent_task while you can accomplish it with a tool
LANGUAGE DETECTION:
The first time you detect the user's language (or if it changes), silently call save_memory with:
category='identity', key='language', value=<English name of the language, e.g. 'Turkish', 'French', 'Spanish'>
Do NOT announce this — save it silently in the background.
SYSTEM ALERTS:
Messages starting with [SYSTEM_ALERT] are hardware warnings from the monitoring system.
Translate and speak them naturally in the user's language. Keep it brief and helpful.
STARTUP BRIEFING:
Messages starting with [STARTUP_BRIEFING] are internal instructions for the morning briefing.
Follow them exactly. Never read the instruction text aloud.
CRITICAL: Speak/Take action immediately based on available info. Assume and proceed.
+188 -5
View File
@@ -32,6 +32,7 @@ from actions.dev_agent import dev_agent
from actions.web_search import web_search as web_search_action
from actions.computer_control import computer_control
from actions.game_updater import game_updater
from actions.system_monitor import SystemMonitor, get_system_status
def get_base_dir():
@@ -92,18 +93,36 @@ TOOL_DECLARATIONS = [
},
{
"name": "web_search",
"description": "Searches the web for any information.",
"description": (
"Searches the web. Use for ANY question about current facts, events, prices, "
"or topics — always prefer this over guessing. "
"Modes: 'search' (default), 'news' (latest headlines on a topic), "
"'research' (deep comprehensive answer), 'price' (product cost lookup), "
"'compare' (side-by-side comparison of items)."
),
"parameters": {
"type": "OBJECT",
"properties": {
"query": {"type": "STRING", "description": "Search query"},
"mode": {"type": "STRING", "description": "search (default) or compare"},
"items": {"type": "ARRAY", "items": {"type": "STRING"}, "description": "Items to compare"},
"aspect": {"type": "STRING", "description": "price | specs | reviews"}
"query": {"type": "STRING", "description": "Search query or topic"},
"mode": {"type": "STRING", "description": "search | news | research | price | compare"},
"items": {"type": "ARRAY", "items": {"type": "STRING"}, "description": "Items to compare (compare mode)"},
"aspect": {"type": "STRING", "description": "Comparison aspect: price | specs | reviews | features"},
},
"required": ["query"]
}
},
{
"name": "system_status",
"description": (
"Returns real-time system metrics: CPU usage, RAM, GPU load, CPU temperature, "
"uptime, and process count. Use when the user asks about computer performance, "
"temperature, memory, or resource usage."
),
"parameters": {
"type": "OBJECT",
"properties": {},
}
},
{
"name": "weather_report",
"description": "Gives the weather report to user",
@@ -483,6 +502,8 @@ class JarvisLive:
self.ui.on_remote_clicked = self._make_remote_key
self._turn_done_event: asyncio.Event | None = None
self._dashboard = None
self._briefing_sent = False # morning briefing fires once per process
self._sys_monitor = SystemMonitor() # persistent cooldown state
def _make_remote_key(self):
"""Called from Qt main thread when user presses Remote Control."""
@@ -649,6 +670,12 @@ class JarvisLive:
elif name == "web_search":
r = await loop.run_in_executor(None, lambda: web_search_action(parameters=args, player=self.ui))
result = r or "Done."
# Mirror substantial results to the on-screen content panel
if r and len(r) > 120:
mode = args.get("mode", "search").upper()
query = args.get("query") or ", ".join(args.get("items", []))
label = f"{mode} — {query[:38]}" if query else mode
self.ui.show_content(label, r)
elif name == "file_processor":
if not args.get("file_path") and self.ui.current_file:
args["file_path"] = self.ui.current_file
@@ -670,6 +697,10 @@ class JarvisLive:
r = await loop.run_in_executor(None, lambda: flight_finder(parameters=args, player=self.ui))
result = r or "Done."
elif name == "system_status":
r = await loop.run_in_executor(None, get_system_status)
result = str(r)
elif name == "shutdown_jarvis":
self.ui.write_log("SYS: Shutdown requested.")
self.speak("Goodbye, sir.")
@@ -833,6 +864,152 @@ class JarvisLive:
stream.stop()
stream.close()
# ── Morning briefing ────────────────────────────────────────────────────────
async def _send_startup_briefing(self) -> None:
"""
Two-phase briefing for instant perceived response:
Phase 1 — immediate greeting (no tools, no fetch) → Jarvis speaks in <2s
Phase 2 — news fetched in background, injected after greeting finishes
"""
await asyncio.sleep(0.3)
if not self.session:
return
# ── memory ───────────────────────────────────────────────────────────
memory = load_memory()
identity = memory.get("identity", {})
def _val(k: str) -> str:
e = identity.get(k, {})
return (e.get("value", "") if isinstance(e, dict) else str(e)).strip()
lang = _val("language")
name = _val("name")
from datetime import datetime
time_str = datetime.now().strftime("%H:%M")
# ── Phase 1: instant greeting — zero data needed ──────────────────────
p1_lines = [
"[STARTUP_GREETING] Greet the user immediately. Keep it to 1-2 short sentences.",
f"Current time: {time_str}.",
"- Say hello and mention the time naturally.",
"- Say you are checking today's headlines and will share them in a moment.",
"- Do NOT call any tools. Do NOT say [STARTUP_GREETING].",
"- Respond in "
+ (f"language: {lang}." if lang else "the user's language (default: English)."),
]
if name:
p1_lines.append(f"- Address the user as {name}.")
await self.session.send_client_content(
turns={"parts": [{"text": '\n'.join(p1_lines)}]},
turn_complete=True,
)
self.ui.write_log("SYS: Briefing phase 1 (greeting) sent.")
# ── Phase 2: fetch news in background, deliver after greeting plays ───
async def _guarded_news():
try:
await self._briefing_news_phase(lang)
except Exception as e:
print(f"[Briefing] Phase 2 error: {e}")
self.ui.write_log(f"SYS: Briefing news phase failed: {e}")
asyncio.create_task(_guarded_news())
async def _briefing_news_phase(self, lang: str) -> None:
"""
Fetches headlines (DDG → Gemini fallback), shows them on screen,
then injects a short 2-headline summary into the Live session.
Waits enough time for the phase-1 greeting to finish playing first.
"""
from actions.web_search import _ddg_search, _gemini_headlines
fetch_start = asyncio.get_event_loop().time()
headlines: list[str] = []
full_news = ""
# 1) DDG — ~0.6 s when available
try:
results = await asyncio.wait_for(
asyncio.to_thread(_ddg_search, "world news today", 6),
timeout=4.0,
)
if results:
headlines = [r["title"] for r in results if r.get("title")][:6]
full_news = "\n\n".join(
f"• {r.get('title','')}\n {r.get('snippet','')}\n {r.get('url','')}"
for r in results
)
except Exception as e:
print(f"[Briefing] DDG: {e}")
# 2) Gemini grounded search — reliable fallback
if not headlines:
try:
headlines, full_news = await asyncio.wait_for(
asyncio.to_thread(_gemini_headlines, 5),
timeout=8.0,
)
except Exception as e:
print(f"[Briefing] Gemini headlines: {e}")
# Show full list on screen immediately when data arrives
if full_news:
self.ui.show_content("NEWS — latest headlines", full_news)
if not headlines or not self.session:
return
# Ensure the phase-1 greeting (≈ 3 s of speech) has finished before we speak again
elapsed = asyncio.get_event_loop().time() - fetch_start
wait_more = max(0.0, 3.5 - elapsed)
if wait_more > 0:
await asyncio.sleep(wait_more)
if not self.session:
return
headlines_text = "\n".join(f"{i+1}. {h}" for i, h in enumerate(headlines))
p2_lines = [
"[BRIEFING_NEWS] Today's headlines are already displayed on screen.",
"Data:",
headlines_text,
"",
"Voice rules:",
"- Mention ONLY 2 headlines — one short sentence each.",
"- Tell the user the full list is visible on screen.",
"- Ask if they need anything.",
"- Do NOT say [BRIEFING_NEWS].",
"- Respond in "
+ (f"language: {lang}." if lang else "the user's language."),
]
await self.session.send_client_content(
turns={"parts": [{"text": '\n'.join(p2_lines)}]},
turn_complete=True,
)
self.ui.write_log("SYS: Briefing phase 2 (news) sent.")
# ── System monitor ──────────────────────────────────────────────────────────
async def _run_system_monitor(self) -> None:
"""Background task: voice alerts when metrics exceed thresholds."""
while True:
await asyncio.sleep(10)
alert = await asyncio.to_thread(self._sys_monitor.check)
if alert and self.session:
try:
await self.session.send_client_content(
turns={"parts": [{"text": alert}]},
turn_complete=True,
)
except Exception as e:
print(f"[Monitor] ⚠️ Could not send alert: {e}")
# ── Phone audio relay ────────────────────────────────────────────────────────
async def _relay_phone_audio(self) -> None:
"""Forward phone mic PCM chunks from dashboard queue into the Gemini Live session."""
q = self._dashboard._phone_audio_queue
@@ -933,9 +1110,15 @@ class JarvisLive:
tg.create_task(self._listen_audio())
tg.create_task(self._receive_audio())
tg.create_task(self._play_audio())
tg.create_task(self._run_system_monitor())
if self._dashboard:
tg.create_task(self._relay_phone_audio())
# Morning briefing — fires once per process launch
if not self._briefing_sent:
self._briefing_sent = True
tg.create_task(self._send_startup_briefing())
except Exception as e:
print(f"[JARVIS] Error: {e}")
traceback.print_exc()
+15 -13
View File
@@ -1,4 +1,4 @@
# 🤖 MARK XLVI (46)
# 🤖 MARK XLVII (47)
### The Ultimate Cross-Platform Personal AI Assistant — By FatihMakes
> 📺 **[Watch the full setup video on YouTube](https://www.youtube.com/watch?v=BhOsnGC_sAA)**
@@ -9,7 +9,7 @@ A real-time voice AI that can hear, see, understand, and control your computer
## ✨ Overview
MARK XLVI represents a massive milestone in the Jarvis series, evolving into a fully connected, highly persistent, and remote-accessible system. It completely bridges the gap between your mobile device, desktop OS, and human intent. Through real-time Gemini reasoning, Mark 46 allows you to control your PC from your phone, share large files securely, and maintain deep contextual conversations across sessions.
MARK XLVII represents the pinnacle of the Jarvis series, evolving into a proactive, deeply integrated system. It bridges the gap between the operating system, real-time web intelligence, and hardware metrics. Through natural dialogue, Mark 47 monitors your hardware, prepares your day, and visualizes complex web data through an adaptive interface.
It's not just an assistant — it's an extension of your digital life.
@@ -29,26 +29,24 @@ It's not just an assistant — it's an extension of your digital life.
---
## 🆕 What's New in XLVI
## 🆕 What's New in XLVII
- 📱 **Full Remote Phone Control** — Take command of your entire desktop operating system directly from your smartphone, anywhere, anytime.
- 🧠 **Advanced Long-Term Memory** — Upgraded memory architecture allows Jarvis to contextually remember past interactions, preferences, and complex workflows across reboots.
- 🚀 **Powered by Gemini Integration** — Re-engineered from the ground up to utilize the full speed and precision of the Google Gemini API for ultimate reasoning and stability.
- ⚡ **Next-Gen Performance & Stability** — Comprehensive system-wide optimizations delivering faster response times and rock-solid execution on Windows, Mac, and Linux.
- 📂 **Advanced File Handling & Hybrid Input** — Fluidly switch between voice or keyboard input, and drag-and-drop code, PDFs, or images for instant analysis and automation.
- 🔒 **Secure Mobile File Sharing** — Wirelessly and securely share files or entire folders up to 500 MB from your phone directly to your computer with complete privacy.
- 🌅 **Morning Briefing Mode** — Automatically triggers once on first boot to read the time, pull local/global news, and check memory for your city to deliver a personalized weather update.
- 🎛️ **Audio-Visual System Monitor** — Background telemetry checks CPU, RAM, GPU, and temps every 10 seconds, delivering localized voice warnings with a 5-minute cooldown when thresholds are breached.
- 🔍 **Advanced Multi-Modal Search** — Overhauled web search featuring specific modes (`news`, `research`, `price`, `compare`, `search`) that prioritize Gemini Grounded Search with an automatic DuckDuckGo fallback.
- 🖼️ **Dynamic Content Panel** — A new scrollable display layer beneath the HUD that automatically expands to render high-density web results (over 120 characters) with active timestamps.
- 🗣️ **Silent Language Memory** — Instantly and silently captures your spoken language to save it under `identity/language`, ensuring all subsequent boots and briefings adapt to your dialect automatically.
---
## ⚡ Quick Start
```bash
git clone [https://github.com/FatihMakes/Mark-XLVI.git](https://github.com/FatihMakes/Mark-XLVI.git)
cd Mark-XLVI
git clone [https://github.com/FatihMakes/Mark-XLVII.git](https://github.com/FatihMakes/Mark-XLVII.git)
cd Mark-XLVII
pip install -r requirements.txt
playwright install
python main.py
```
> ⚠️ **Installation Note:** To keep the repository lightweight, some OS-specific dependencies are not bundled in `requirements.txt`. If you run into a `ModuleNotFoundError`, simply install the missing package via `pip install <module_name>` for your specific system.
@@ -81,4 +79,8 @@ Engineered by a developer building a real-world JARVIS-style assistant.
| Platform | Link |
| --- | --- |
| YouTube | [@FatihMakes](https://www.youtube.com/@FatihMakes) |
| Instagram | [@fatihmakes](https://www.instagram.com/fatihmakes) |
| Instagram | [@fatihmakes](https://www.instagram.com/fatihmakes) |
```
```
+122 -6
View File
@@ -1213,12 +1213,13 @@ class RemoteKeyOverlay(QWidget):
class MainWindow(QMainWindow):
_log_sig = pyqtSignal(str)
_state_sig = pyqtSignal(str)
_log_sig = pyqtSignal(str)
_state_sig = pyqtSignal(str)
_content_sig = pyqtSignal(str, str) # (title, text) — thread-safe content display
def __init__(self, face_path: str):
super().__init__()
self.setWindowTitle("J.A.R.V.I.S — MARK XLVI")
self.setWindowTitle("J.A.R.V.I.S — MARK XLVII")
self.setMinimumSize(_MIN_W, _MIN_H)
self.resize(_DEFAULT_W, _DEFAULT_H)
@@ -1250,9 +1251,18 @@ class MainWindow(QMainWindow):
self._left_panel = self._build_left_panel()
body.addWidget(self._left_panel, stretch=0)
# Center column: HUD on top + content panel below
_center = QWidget()
_center.setStyleSheet(f"background: {C.BG};")
_center_lay = QVBoxLayout(_center)
_center_lay.setContentsMargins(0, 0, 0, 0)
_center_lay.setSpacing(0)
self.hud = HudCanvas(face_path)
self.hud.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
body.addWidget(self.hud, stretch=5)
_center_lay.addWidget(self.hud, stretch=1)
self._content_panel = self._build_content_panel()
_center_lay.addWidget(self._content_panel)
body.addWidget(_center, stretch=5)
self._right_panel = self._build_right_panel()
body.addWidget(self._right_panel, stretch=0)
@@ -1273,6 +1283,7 @@ class MainWindow(QMainWindow):
self._log_sig.connect(self._log.append_log)
self._state_sig.connect(self._apply_state)
self._content_sig.connect(self._show_content)
self._overlay: SetupOverlay | None = None
self._ready = self._check_config()
@@ -1372,7 +1383,7 @@ class MainWindow(QMainWindow):
l.setStyleSheet(f"color: {color}; background: transparent;")
return l
lay.addWidget(_badge("MARK XLVI", C.PRI_DIM))
lay.addWidget(_badge("MARK XLVII", C.PRI_DIM))
lay.addStretch()
mid = QVBoxLayout(); mid.setSpacing(1)
@@ -1589,6 +1600,107 @@ class MainWindow(QMainWindow):
row.addWidget(send)
return row
def _build_content_panel(self) -> QWidget:
"""
Collapsible panel below the HUD — shows search results, news, briefings.
Hidden by default; appears when show_content() is called.
"""
w = QWidget()
w.setObjectName("ContentPanel")
w.setStyleSheet(f"""
QWidget#ContentPanel {{
background: {C.PANEL};
border-top: 1px solid {C.BORDER_B};
}}
""")
w.hide()
lay = QVBoxLayout(w)
lay.setContentsMargins(12, 7, 12, 8)
lay.setSpacing(5)
# ── header row ───────────────────────────────────────────────────────
hdr = QHBoxLayout(); hdr.setSpacing(6)
dot = QLabel("◈")
dot.setFont(QFont("Courier New", 9, QFont.Weight.Bold))
dot.setStyleSheet(f"color: {C.PRI}; background: transparent;")
hdr.addWidget(dot)
self._content_title_lbl = QLabel("BRIEFING")
self._content_title_lbl.setFont(QFont("Courier New", 8, QFont.Weight.Bold))
self._content_title_lbl.setStyleSheet(
f"color: {C.PRI}; background: transparent; letter-spacing: 1px;"
)
hdr.addWidget(self._content_title_lbl)
hdr.addStretch()
self._content_ts_lbl = QLabel("")
self._content_ts_lbl.setFont(QFont("Courier New", 7))
self._content_ts_lbl.setStyleSheet(f"color: {C.TEXT_DIM}; background: transparent;")
hdr.addWidget(self._content_ts_lbl)
dismiss = QPushButton("DISMISS ✕")
dismiss.setFont(QFont("Courier New", 7))
dismiss.setFixedHeight(18)
dismiss.setCursor(Qt.CursorShape.PointingHandCursor)
dismiss.setStyleSheet(f"""
QPushButton {{
background: transparent; color: {C.TEXT_DIM};
border: 1px solid {C.BORDER}; border-radius: 2px; padding: 0 5px;
}}
QPushButton:hover {{ color: {C.TEXT}; border-color: {C.BORDER_B}; }}
""")
dismiss.clicked.connect(w.hide)
hdr.addWidget(dismiss)
lay.addLayout(hdr)
# ── separator ─────────────────────────────────────────────────────────
sep = QFrame(); sep.setFrameShape(QFrame.Shape.HLine)
sep.setStyleSheet(f"color: {C.BORDER};"); lay.addWidget(sep)
# ── text display ──────────────────────────────────────────────────────
self._content_display = QTextEdit()
self._content_display.setReadOnly(True)
self._content_display.setFont(QFont("Courier New", 8))
self._content_display.setFixedHeight(155)
self._content_display.setStyleSheet(f"""
QTextEdit {{
background: {C.DARK};
color: {C.TEXT};
border: 1px solid {C.BORDER};
border-radius: 3px;
padding: 6px 8px;
selection-background-color: {C.PRI_GHO};
}}
QScrollBar:vertical {{
background: {C.BG}; width: 6px; border: none;
}}
QScrollBar::handle:vertical {{
background: {C.BORDER_B}; border-radius: 3px; min-height: 16px;
}}
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {{
height: 0; border: none;
}}
""")
lay.addWidget(self._content_display)
return w
def _show_content(self, title: str, text: str):
"""Slot — runs on Qt main thread. Updates and shows the content panel."""
import time as _time
self._content_title_lbl.setText(title.upper()[:48])
self._content_ts_lbl.setText(_time.strftime("%H:%M:%S"))
self._content_display.setPlainText(text)
# Scroll to top
cur = self._content_display.textCursor()
cur.moveToStart() if hasattr(cur, "moveToStart") else None
self._content_display.moveCursor(
self._content_display.textCursor().MoveOperation.Start
)
self._content_panel.show()
def _build_footer(self) -> QWidget:
w = QWidget()
w.setFixedHeight(22)
@@ -1602,7 +1714,7 @@ class MainWindow(QMainWindow):
lay.addWidget(_fl("[F4] Mute · [F11] Fullscreen"))
lay.addStretch()
lay.addWidget(_fl("FatihMakes Industries · MARK XLVI · CLASSIFIED"))
lay.addWidget(_fl("FatihMakes Industries · MARK XLVII · CLASSIFIED"))
lay.addStretch()
lay.addWidget(_fl("© STARK INDUSTRIES", C.PRI_DIM))
return w
@@ -1792,6 +1904,10 @@ class JarvisUI:
while not self._win._ready:
time.sleep(0.1)
def show_content(self, title: str, text: str):
"""Thread-safe: display content in the panel below the HUD."""
self._win._content_sig.emit(title[:48], text[:4000])
def start_speaking(self):
self.set_state("SPEAKING")