17 Commits

Author SHA1 Message Date
myron 90e4ded7c9 Fix 8 issues from code review
- ha-poller: replace recursive main() retry with while loop (stack overflow fix)
- ha-poller: advance last_push on empty HA response (log spam fix)
- ha-poller: use datetime.now(timezone.utc) instead of deprecated utcnow()
- ping-probe: always call update_status() unconditionally so offline devices register as offline
- agent.php: heartbeat reads status from payload instead of hardcoding 'online'
- phone-probe: delegate JSON building to python3 (bash concatenation injection fix)
- netscan + phone-probe: read registration key from /etc/jarvis-agent/reg-key
- admin/index.php: sync ha_list skipDomains with ha.php (14 missing domains added)
- facts_collector: self-check JARVIS via 127.0.0.1 instead of Cloudflare hairpin
2026-06-29 20:58:22 -05:00
myron c1275d47a6 Add PVE1 probe scripts to repo (netscan, ping-probe, phone-probe)
Scripts were running on PVE1 but not tracked in git. Pulling current
versions that push to http://10.48.200.211 (was old DO server IP).
2026-06-29 19:44:39 -05:00
myron 84cd2ded50 Add HA poller, fix domain filters, create missing DB tables, update schema
- jarvis-ha-poller.py: new service polling HA entities → JARVIS (running on VM211)
- ha.php: add camera/siren/remote/todo/lawn_mower to skipDomains
- db/schema.sql: add tasks, appointments, usage_patterns tables; fix registered_agents enum (windows/macos) + version column

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 15:44:28 -05:00
myron 89a82a1573 Add Windows agent installer, fix Linux install URL
- install-windows.ps1: one-liner PowerShell installs Python, pywin32,
  downloads agent, creates config, installs Windows Service (auto-start)
- install.sh: fix JARVIS_URL from hardcoded LAN IP to https://jarvis.orbishosting.com
- install.sh: fix ssl_verify default to true for external agents

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 13:56:37 -05:00
myron b85e8dd16f fix: include version in heartbeat payload so Workers tab shows real versions
Heartbeat was sending {} — version only appeared in registration.
Agents that never re-register (most of them) stayed NULL in the DB.
Now every heartbeat carries {"version": AGENT_VERSION} so agent.php
can update the column on every check-in.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-17 18:36:51 +00:00
myron c6549ee27e Agent self-healing: auto-migrate old config key names on startup
Instead of crash-looping with KeyError when config has old key names,
load_config() now detects and migrates automatically:
- server_url -> jarvis_url
- api_key -> registration_key
- adds hostname from gethostname() if missing
- adds ssl_verify (false if URL is a bare IP)
- falls back to /opt/jarvis-agent/config.json if /etc path missing

Migrated config is saved in place so the fix is permanent.
Agents self-update within 24h via the existing update_url mechanism.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-17 01:57:40 +00:00
myron 8d64320749 agent: add nordlynx VPN status to metrics
Detects nordlynx WireGuard interface on hosts that run NordVPN and
includes active/inactive status in the metrics payload. JARVIS alerts.php
will generate a critical alert and auto-restart nordvpnd if it goes down.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 00:09:19 +00:00
myron b19ce85d84 Windows agent: run as background Windows Service (Win 8.1+)
Replace the scheduled-task approach (required user to stay logged in) with a
proper Windows Service using pywin32. The service runs as LocalSystem, starts
at boot, and auto-restarts on failure — no PowerShell window needed.

Agent changes (jarvis-agent-windows.py):
- Add Windows Service class via pywin32 (JarvisAgentService)
- Cleanly handles SvcStop by setting a threading.Event
- main() loop uses _stop_event.wait() instead of time.sleep() so stop is immediate
- self_update() signals the stop event when running as a service (SCM restarts it)
- __main__ block dispatches to SCM entry point or HandleCommandLine (install/stop/remove)
- Falls back to direct run if pywin32 not installed (for debugging)

Installer changes (install-windows.ps1):
- pip install pywin32 + postinstall (registers service runner DLLs)
- Python search prefers system-wide install (accessible by LocalSystem)
- Downloads Python 3.11 directly from python.org for Win 8.1 machines without winget
- Removes legacy JARVIS-Agent scheduled task if present
- Registers JARVISAgent service with --startup auto
- Configures sc.exe failure recovery (restart at 5s/10s/30s)
- Updated management commands in summary (Start-Service, Stop-Service, etc.)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 12:11:38 +00:00
myron 04bd412b65 Fix 3 arc reactor bugs: metrics_json→metric_data, system nesting, message→content in conversations
- guardian_loop + sitrep: SELECT metric_data (not metrics_json which does not exist)
- guardian_loop: metrics are flat (cpu_percent at top level), not nested under system key
- guardian_loop + sitrep: filter metric_type=system to avoid parsing proxmox blobs
- guardian_loop: disk.mount key (not mountpoint) + fallback for both key names
- sitrep: same metric_data + root-level key fixes
- _guardian_inject_chat (x2): INSERT into conversations.content (not message)
- /guardian/chat endpoint (x2): SELECT content (not message) from conversations

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 01:59:58 +00:00
myron 0469b31829 Agent version tracking — workers tab shows current vs latest version
- Add version column to registered_agents table
- Agents send version on registration (Linux 3.1, Windows 3.0, macOS 3.0)
- workers_list API returns latest_versions per platform
- Workers tab: VERSION column with green check (up-to-date) or red (outdated)
- Outdated agents highlight row and show blue UPDATE button
- Up-to-date agents show dimmed UPDATE button
- Update button dispatches update command immediately

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 01:44:59 +00:00
myron 4c67efe715 Agent v3.1/3.0 — Mac agent, Windows self-update, all capabilities parity
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 01:20:38 +00:00
myron 6eb387899e agent v3.0: always re-register on startup to refresh capabilities
Previously agents only registered when api_key was missing (first run).
After updating to v3.0 with screenshot capability, restarted agents never
refreshed their capabilities in the DB. Now register() is called every
startup — server does UPDATE on existing agent_id so api_key is preserved.
2026-06-11 21:21:04 +00:00
myron 8b7f597e76 agent: v3.0 — fix cfg scope bug in execute_command (update + shell commands)
self_update(cfg) and shell allow_shell_commands check both referenced cfg
from run() scope, but execute_command() is a standalone function. Fixed by
calling load_config() locally in each branch that needs it.
2026-06-11 21:10:08 +00:00
myron f8d815fed9 Phase 9+10: update reactor.py (clearance protocol + memory core) 2026-06-11 12:33:21 +00:00
myron 56c9e2d914 Phase 4: Vision Protocol — screenshot + Claude vision
- reactor.py: v4.0.0; adds screenshot, vision, sysinfo handlers;
  _dispatch_agent_command() shared helper; FastAPI /screenshots endpoints
- jarvis-agent.py: v3.0; screenshot command handler (scrot/import/fbcat/
  ImageMagick render fallback); sysinfo command returns structured snapshot;
  detect_capabilities() advertises screenshot + sysinfo caps
- chat.php: Tier 0.9c detects screenshot (show screen on X, screenshot X)
  and sysinfo (check status of X) voice/text commands
- arc.php: screenshots, screenshot_get, screenshot_delete actions
- index.html: VISION PROTOCOL lightbox overlay; SCREENSHOT + SYSINFO
  buttons on each online agent card; keyboard Escape to close
- admin/index.php: VISION PROTOCOL tab under ARC REACTOR nav; gallery view
  with image thumbnails + analysis; take screenshot modal; purge action
2026-06-11 04:42:21 +00:00
myron ecbc2e09a5 Fix 8 code-review findings: security + reliability
1. agent.py: shell allow-check reads cfg, not server payload (RCE fix)
2. webhook.php: move WEBHOOK_SECRET to gitignored config.php; rotate secret
3. agent.py: replace recursive main() with while loop (RecursionError fix)
4. jarvis-deploy.sh: push force-revert to GitHub on syntax fail (loop fix)
5. agent.py: self_update() verifies SHA-256 before exec (integrity fix)
6. agent.php: remove JARVIS_IP from browser-action bypass (auth fix)
7. jarvis-watchdog.sh: escape SQL vars in alert() to prevent injection
8. jarvis-deploy.sh: atomic mv instead of cat+truncate (TOCTOU fix)

Also: distribute jarvis-agent.py.sha256 alongside agent for integrity checks
2026-05-25 14:27:27 +00:00
myron d3156b98b3 Add DB schema, agent script, vhost config, deploy cron
- db/schema.sql: full jarvis_db schema (15 tables)
- agent/jarvis-agent.py: production agent script
- config/vhost/: OpenLiteSpeed vhost configuration
- deploy/jarvis-agent.service: systemd unit
- deploy/cron-jarvis.txt: JARVIS cron entries
- .gitignore: exclude system dirs and logs
2026-05-25 13:51:12 +00:00