61 lines
2.7 KiB
PHP
61 lines
2.7 KiB
PHP
<?php
|
|
// Intent blade_actions — list URLs surfaced by reconciler
|
|
// Doctrine 66 — exec réel pas simulation
|
|
|
|
if (!function_exists('wevia_blade_actions_list')) {
|
|
function wevia_blade_actions_list($msg) {
|
|
if (!$msg) return false;
|
|
// Match: "actions blade", "que dois-je faire", "todo", "clic kaouther", "ouvrir emails"
|
|
if (!preg_match('/\b(blade\s+actions?|actions?\s+(blade|a\s+faire|pending|todo|surface))|que\s+(dois|faut).*faire|clic.*kaouther|show\s+actions|list\s+actions\b/i', $msg)) return false;
|
|
|
|
$out = ['intent' => 'blade_actions', 'tool' => 'blade_reconciler_list'];
|
|
|
|
$json_file = '/var/www/html/api/blade-actions-surfaced.json';
|
|
if (is_readable($json_file)) {
|
|
$d = json_decode(@file_get_contents($json_file), true);
|
|
if ($d) {
|
|
$out['actions_count'] = count($d['actions'] ?? []);
|
|
$out['stats'] = $d['stats'] ?? [];
|
|
$out['generated_at'] = $d['generated_at'] ?? null;
|
|
|
|
// Surface 3 Kaouther actions in priorité
|
|
$kaouther = array_values(array_filter($d['actions'] ?? [], fn($a) => ($a['action'] ?? '') === 'kaouther_send'));
|
|
$chrome = array_values(array_filter($d['actions'] ?? [], fn($a) => ($a['action'] ?? '') === 'chrome_open'));
|
|
|
|
$out['kaouther'] = array_map(fn($a) => [
|
|
'label' => $a['label'] ?? '',
|
|
'url' => $a['url'] ?? '',
|
|
'task_id' => $a['task_id'] ?? '',
|
|
], $kaouther);
|
|
|
|
$out['chrome_other'] = array_map(fn($a) => [
|
|
'label' => $a['label'] ?? '',
|
|
'url' => substr($a['url'] ?? '', 0, 100),
|
|
], $chrome);
|
|
} else {
|
|
$out['error'] = 'actions JSON parse failed';
|
|
}
|
|
} else {
|
|
$out['error'] = 'actions JSON not found. Run /opt/weval-l99/blade-task-reconciler.py';
|
|
}
|
|
|
|
$out['dashboard'] = 'https://weval-consulting.com/blade-actions.html';
|
|
$out['next_step'] = 'Ouvre ' . $out['dashboard'] . ' et clique les boutons Kaouther (ouvre Gmail avec drafts prets, Send 3x)';
|
|
|
|
header("Content-Type: application/json");
|
|
echo json_encode($out, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
// Auto-dispatch
|
|
$_ba_msg = '';
|
|
$_body = @file_get_contents('php://input');
|
|
if ($_body) {
|
|
$_j = @json_decode($_body, true);
|
|
if (is_array($_j) && !empty($_j['message'])) $_ba_msg = $_j['message'];
|
|
}
|
|
if (!$_ba_msg) $_ba_msg = $_POST['message'] ?? $_GET['message'] ?? '';
|
|
|
|
if ($_ba_msg) wevia_blade_actions_list($_ba_msg);
|