Files
jarvis/api/endpoints/suggestions.php
T
myron 9f92e4d5e4 Add JARVIS improvements: mobile UI, sparklines, suggestions, multi-step commands, Arc Reactor health, tier badges
- Mobile UI: 3-button bottom nav with panel switcher
- Chat history search: search modal with keyword query
- News filtering: category filter with localStorage persistence
- Proactive reminders: planner/appointment alerts at login and every 5 min
- Proactive alerts: polls every 60s, speaks new critical/warning alerts
- Agent sparklines: 2h CPU+MEM sparkline on each online agent card
- Tier source badge: KB/GROQ/CLAUDE/OLLAMA pill shown after each reply
- VM suggestions: 24h resource analysis via voice command
- HA scene control: fuzzy-match scene activation via voice
- Jellyfin control: pause/stop/next/previous via voice and KB
- Pattern suggestions: usage_patterns table + proactive chips every 30 min
- Multi-step commands: compound "X and Y" command parsing (Tier 0.5)
- Arc Reactor health: warning=amber/1.2s, critical=red/0.6s pulse encoding
- Cross-session history: last 6 turns loaded from prior session
- Restart agent: voice command to restart any JARVIS agent
- New endpoints: history.php, metrics.php, suggestions.php, jellyfin.php

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-17 02:49:05 +00:00

45 lines
1.5 KiB
PHP

<?php
// Proactive suggestions endpoint — returns time-based command suggestions
require_once __DIR__ . '/../config.php';
require_once __DIR__ . '/../../includes/auth.php';
header('Content-Type: application/json');
AuthMiddleware::requireAuth();
$hour = (int)date('G');
$dow = (int)date('w'); // 0=Sun, 6=Sat
// Find intents used 3+ times at this hour and day-of-week
$rows = JarvisDB::query(
"SELECT intent_name, hit_count FROM usage_patterns
WHERE hour=? AND dow=? AND hit_count >= 3
ORDER BY hit_count DESC LIMIT 3",
[$hour, $dow]
) ?? [];
// Map intents to friendly suggestion prompts
$intentPrompts = [
'network_scan' => 'Run a network scan?',
'jellyfin_now_playing' => 'Check what\'s playing on Jellyfin?',
'jellyfin_library' => 'Check the Jellyfin library?',
'ha_scene' => 'Activate a home scene?',
'planner:briefing' => 'Get your daily briefing?',
'vm_suggestions' => 'Check VM resource usage?',
'jellyfin_pause' => 'Pause Jellyfin?',
'focus_mode' => 'Switch to focus mode?',
'show_panels' => 'Show all panels?',
];
$suggestions = [];
foreach ($rows as $r) {
$intent = $r['intent_name'];
if (isset($intentPrompts[$intent])) {
$suggestions[] = [
'intent' => $intent,
'prompt' => $intentPrompts[$intent],
'hit_count' => (int)$r['hit_count'],
];
}
}
echo json_encode(['suggestions' => $suggestions, 'hour' => $hour, 'dow' => $dow]);