60) { $plugins_cache = []; $cache_ts = time(); $store = "/opt/weval-plugins"; if (is_dir($store)) { foreach (scandir($store) as $d) { if ($d === '.' || $d === '..') continue; $meta = "$store/$d/plugin.json"; if (!file_exists($meta)) continue; $p = json_decode(@file_get_contents($meta), true); if (!$p || empty($p['intents'])) continue; foreach ($p['intents'] as $intent) { if (empty($intent['name']) || empty($intent['trigger_regex']) || empty($intent['script'])) continue; $script_path = "$store/$d/" . $intent['script']; if (!file_exists($script_path) || !is_executable($script_path)) continue; $plugins_cache[] = [ 'name' => $intent['name'], 'regex' => $intent['trigger_regex'], 'script' => $script_path, 'plugin' => $p['name'] ]; } } } } $m = mb_strtolower(trim($msg)); foreach ($plugins_cache as $p) { if (@preg_match('/' . $p['regex'] . '/iu', $m)) { $out = trim(@shell_exec(escapeshellcmd($p['script']) . ' 2>&1')); return [ "provider" => "plugin-store", "content" => "PLUGIN [{$p['plugin']}::{$p['name']}]:\n" . $out, "tool" => "plugin-store", "plugin" => $p['plugin'] ]; } } return null; }