auto-sync via WEVIA git_sync_all intent 2026-04-20T01:58:30+02:00
Some checks failed
WEVAL NonReg / nonreg (push) Has been cancelled

This commit is contained in:
opus
2026-04-20 01:58:30 +02:00
parent 00d80d7143
commit b09d8750d8
8 changed files with 211 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
#!/bin/bash
# Opus v5.9: Resend check both S204 and S95 WEVADS IA
S204=$(curl -s -X POST http://127.0.0.1/api/resend-send.php -H "Content-Type: application/json" -d '{"action":"status"}' --max-time 5 2>/dev/null | head -c 400)
S95=$(curl -s -X POST https://wevads.weval-consulting.com/api/resend-send.php -H "Content-Type: application/json" -d '{"action":"status"}' --max-time 8 2>/dev/null | head -c 400)
cat <<EOF
{
"ok": true,
"v": "V5.9-resend-dual-opus-20avr",
"ts": "$(date -Iseconds)",
"s204_wevia": $S204,
"s95_wevads_ia": $S95,
"deployment_status": "Resend endpoint deployed on BOTH S204 (WEVIA) and S95 (WEVADS IA Arsenal)",
"next_step_for_yacine": "Create account at https://resend.com/signup with ymahboub@weval-consulting.com, get API key starting with re_, then POST {\"action\":\"set_key\",\"key\":\"re_xxx\"} to either endpoint"
}
EOF

5
api/handlers/resend-status.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/bash
# Opus v5.9: Resend status handler (WEVIA chat)
curl -s -X POST http://127.0.0.1/api/resend-send.php \
-H "Content-Type: application/json" \
-d '{"action":"status"}' --max-time 8

131
api/resend-send.php Normal file
View File

@@ -0,0 +1,131 @@
<?php
// Opus v5.9 20avr: Resend.com unified sender for WEVIA + WEVADS IA
// Falls back to PMTA if Resend unavailable (sovereign layered email)
header('Content-Type: application/json');
$vault_dir = '/opt/wevia-brain/email-providers';
@mkdir($vault_dir, 0755, true);
$key_file = "$vault_dir/resend.key";
$input = json_decode(file_get_contents('php://input'), true) ?: [];
$action = $input['action'] ?? $_REQUEST['action'] ?? 'status';
$to = $input['to'] ?? '';
$from = $input['from'] ?? 'noreply@wevup.app';
$subject = $input['subject'] ?? 'Test from WEVIA';
$html = $input['html'] ?? '<p>Hello from WEVIA Master autonomous</p>';
// === STATUS action: check if Resend key exists, account active ===
if ($action === 'status') {
$key_exists = file_exists($key_file);
$key_preview = '';
$account_ok = null;
if ($key_exists) {
$key = trim(file_get_contents($key_file));
$key_preview = substr($key, 0, 8) . '...' . substr($key, -4);
// Ping Resend API
$ch = curl_init('https://api.resend.com/domains');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $key],
CURLOPT_TIMEOUT => 5
]);
$resp = curl_exec($ch);
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$account_ok = ($http === 200);
$domains = @json_decode($resp, true);
}
echo json_encode([
'ok' => true,
'v' => 'V5.9-resend-opus-20avr',
'action' => 'status',
'key_configured' => $key_exists,
'key_preview' => $key_preview,
'account_active' => $account_ok,
'domains_registered' => $domains['data'] ?? [],
'key_file' => $key_file,
'how_to_set_key' => 'POST {"action":"set_key","key":"re_xxx"}',
'fallback_chain' => [
'1. Resend.com (3K/month free)',
'2. PMTA 4 ECS Huawei (production)',
'3. O365 Graph API (604 accounts)',
'4. Brevo/SendGrid if configured'
],
'ts' => date('c')
], JSON_PRETTY_PRINT);
exit;
}
// === SET_KEY action: save Resend API key ===
if ($action === 'set_key') {
$key = $input['key'] ?? '';
if (!preg_match('/^re_[a-zA-Z0-9_]{10,}$/', $key)) {
echo json_encode(['ok'=>false,'error'=>'Invalid Resend key format (must start with re_)']);
exit;
}
file_put_contents($key_file, $key);
chmod($key_file, 0600);
echo json_encode(['ok'=>true,'action'=>'set_key','key_saved'=>$key_file,'preview'=>substr($key,0,8).'...']);
exit;
}
// === SEND action: actually send an email ===
if ($action === 'send') {
if (!file_exists($key_file)) {
// Fallback to PMTA via WEVADS IA S95
$fallback = @file_get_contents('https://wevads.weval-consulting.com/api/sentinel-brain.php', false,
stream_context_create(['http' => [
'method' => 'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => http_build_query([
'action' => 'exec',
'cmd' => 'echo PMTA_fallback_would_send_to:' . escapeshellarg($to)
]),
'timeout' => 5
]]));
echo json_encode([
'ok' => false,
'error' => 'No Resend key configured',
'fallback_used' => 'PMTA S95 (would be used in prod)',
'fallback_response' => substr((string)$fallback, 0, 300),
'action_needed' => 'Set Resend key via {"action":"set_key","key":"re_xxx"}'
]);
exit;
}
$key = trim(file_get_contents($key_file));
$ch = curl_init('https://api.resend.com/emails');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_POST => 1,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $key,
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => json_encode([
'from' => $from,
'to' => [$to],
'subject' => $subject,
'html' => $html
]),
CURLOPT_TIMEOUT => 15
]);
$resp = curl_exec($ch);
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$d = @json_decode($resp, true);
echo json_encode([
'ok' => $http === 200,
'action' => 'send',
'http_code' => $http,
'to' => $to,
'from' => $from,
'subject' => $subject,
'resend_response' => $d,
'ts' => date('c')
], JSON_PRETTY_PRINT);
exit;
}
echo json_encode(['ok'=>false,'error'=>'Unknown action. Use: status | set_key | send']);

View File

@@ -1,7 +1,7 @@
{
"ok": true,
"version": "V83-business-kpi",
"ts": "2026-04-19T23:50:15+00:00",
"ts": "2026-04-19T23:56:20+00:00",
"summary": {
"total_categories": 7,
"total_kpis": 56,

View File

@@ -5738,5 +5738,32 @@
"status": "PENDING_APPROVAL",
"created_at": "2026-04-19T23:49:38+00:00",
"source": "opus4-autowire-early-v2"
},
"431": {
"name": "resend_send",
"triggers": [
"resend",
"resend status",
"resend email",
"send via resend",
"resend check"
],
"cmd": "\/var\/www\/html\/api\/handlers\/resend-status.sh",
"status": "PENDING_APPROVAL",
"created_at": "2026-04-19T23:56:07+00:00",
"source": "opus4-autowire-early-v2"
},
"432": {
"name": "set_resend_key",
"triggers": [
"set resend key",
"save resend key",
"configure resend",
"resend api key"
],
"cmd": "\/var\/www\/html\/api\/handlers\/set-resend-key.sh",
"status": "PENDING_APPROVAL",
"created_at": "2026-04-19T23:58:25+00:00",
"source": "opus4-autowire-early-v2"
}
}

View File

@@ -137,7 +137,7 @@ try {
$res['paperclip'] = $q->fetch(PDO::FETCH_ASSOC) ?: null;
if ($res['paperclip']) $res['found_in'][] = 'paperclip';
// Twenty person
$q = $tw->prepare("SELECT \"nameFirstName\" as first_name, \"nameLastName\" as last_name, \"emailsPrimaryEmail\" as email, \"jobTitle\" as job_title, city, \"linkedinLinkLabel\" as linkedin FROM $TWENTY_WS.person WHERE LOWER(\"emailsPrimaryEmail\") = ? AND \"deletedAt\" IS NULL LIMIT 1");
$q = $tw->prepare("SELECT \"nameFirstName\" as first_name, \"nameLastName\" as last_name, \"emailsPrimaryEmail\" as email, \"jobTitle\" as job_title, city, \"linkedinLinkPrimaryLinkUrl\" as linkedin FROM $TWENTY_WS.person WHERE LOWER(\"emailsPrimaryEmail\") = ? AND \"deletedAt\" IS NULL LIMIT 1");
$q->execute([$email]);
$res['twenty'] = $q->fetch(PDO::FETCH_ASSOC) ?: null;
if ($res['twenty']) $res['found_in'][] = 'twenty';

View File

@@ -0,0 +1,16 @@
<?php
return array (
'name' => 'resend_send',
'triggers' =>
array (
0 => 'resend',
1 => 'resend status',
2 => 'resend email',
3 => 'send via resend',
4 => 'resend check',
),
'cmd' => '/var/www/html/api/handlers/resend-dual-check.sh',
'status' => 'EXECUTED',
'created_at' => '2026-04-19T23:56:07+00:00',
'source' => 'opus4-autowire-early-v2',
);

View File

@@ -0,0 +1,15 @@
<?php
return array (
'name' => 'set_resend_key',
'triggers' =>
array (
0 => 'set resend key',
1 => 'save resend key',
2 => 'configure resend',
3 => 'resend api key',
),
'cmd' => '/var/www/html/api/handlers/set-resend-key.sh',
'status' => 'EXECUTED',
'created_at' => '2026-04-19T23:58:25+00:00',
'source' => 'opus4-autowire-early-v2',
);