mirror of
https://github.com/myronblair/jarvis
synced 2026-06-30 17:50:23 -05:00
Phase 3: Comms Protocol + Field Protocol
- chat.php: Add Tier 0.9a (gmail_triage), Tier 0.9b (remote_exec) detection; refactor arc submit into arcSubmitJob() helper; natural-language triggers for email triage (check my email, triage inbox) and remote exec (restart X on Y, run X on Y, get logs from X on Y) - arc.php: Add triage and triage_action endpoints (read/update email_triage table) - index.html: Add COMMS tab with triage card UI (filter bar, category badges, draft reply viewer, copy/dismiss actions); loadComms() with 8s polling; onArcJobStarted() routes gmail_triage jobs to COMMS tab - admin/index.php: Add GMAIL TRIAGE section under COMMUNICATIONS nav; triage_list/ triage_action/triage_run PHP actions; loadTriage() JS with full table + draft modal; triageRunNow() submits gmail_triage job to Arc Reactor
This commit is contained in:
+53
-1
@@ -49,7 +49,6 @@ switch ($action) {
|
||||
break;
|
||||
|
||||
// POST /api/arc — create a job
|
||||
// body: { action: "job_create", type: "ping", payload: {}, priority: 5 }
|
||||
case 'job_create':
|
||||
$type = $data['type'] ?? '';
|
||||
$payload = $data['payload'] ?? [];
|
||||
@@ -102,6 +101,59 @@ switch ($action) {
|
||||
echo json_encode($result);
|
||||
break;
|
||||
|
||||
// GET /api/arc?action=triage&limit=50&filter=priority
|
||||
// Returns email_triage rows for the COMMS tab
|
||||
case 'triage':
|
||||
$limit = min((int)($_GET['limit'] ?? 50), 100);
|
||||
$filter = $_GET['filter'] ?? 'priority';
|
||||
|
||||
if ($filter === 'urgent') {
|
||||
$sql = "SELECT id, account, from_name, from_email, subject, date_received,
|
||||
category, priority, summary, draft_reply, action_taken, created_at
|
||||
FROM email_triage
|
||||
WHERE action_taken != 'dismissed' AND category = 'urgent'
|
||||
ORDER BY priority DESC, created_at DESC LIMIT ?";
|
||||
} elseif ($filter === 'action') {
|
||||
$sql = "SELECT id, account, from_name, from_email, subject, date_received,
|
||||
category, priority, summary, draft_reply, action_taken, created_at
|
||||
FROM email_triage
|
||||
WHERE action_taken != 'dismissed' AND category IN ('urgent','action','reply','meeting')
|
||||
ORDER BY priority DESC, created_at DESC LIMIT ?";
|
||||
} elseif ($filter === 'priority') {
|
||||
$sql = "SELECT id, account, from_name, from_email, subject, date_received,
|
||||
category, priority, summary, draft_reply, action_taken, created_at
|
||||
FROM email_triage
|
||||
WHERE action_taken != 'dismissed' AND category IN ('urgent','action','reply','meeting')
|
||||
AND priority >= 5
|
||||
ORDER BY priority DESC, created_at DESC LIMIT ?";
|
||||
} else {
|
||||
$sql = "SELECT id, account, from_name, from_email, subject, date_received,
|
||||
category, priority, summary, draft_reply, action_taken, created_at
|
||||
FROM email_triage
|
||||
WHERE action_taken != 'dismissed'
|
||||
ORDER BY priority DESC, created_at DESC LIMIT ?";
|
||||
}
|
||||
$rows = JarvisDB::query($sql, [$limit]);
|
||||
echo json_encode($rows ?: []);
|
||||
break;
|
||||
|
||||
// POST /api/arc?action=triage_action&id=123 body: { action: "dismissed"|"replied"|"done" }
|
||||
case 'triage_action':
|
||||
$id = (int)($_GET['id'] ?? $data['id'] ?? 0);
|
||||
$actionTaken = $data['action'] ?? 'dismissed';
|
||||
$allowed = ['dismissed', 'replied', 'done', 'snoozed'];
|
||||
if (!$id || !in_array($actionTaken, $allowed)) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['error' => 'Invalid id or action']);
|
||||
break;
|
||||
}
|
||||
JarvisDB::execute(
|
||||
"UPDATE email_triage SET action_taken = ? WHERE id = ?",
|
||||
[$actionTaken, $id]
|
||||
);
|
||||
echo json_encode(['ok' => true, 'id' => $id, 'action_taken' => $actionTaken]);
|
||||
break;
|
||||
|
||||
default:
|
||||
http_response_code(404);
|
||||
echo json_encode(['error' => "Unknown arc action: {$action}"]);
|
||||
|
||||
Reference in New Issue
Block a user