yaver-cli
Advanced tools
+1
-1
| { | ||
| "name": "yaver-cli", | ||
| "version": "1.99.304", | ||
| "version": "1.99.305", | ||
| "mcpName": "io.github.kivanccakmak/yaver", | ||
@@ -5,0 +5,0 @@ "description": "Unified npm bootstrap for the Yaver agent, SDK injection, and local-first developer runtime", |
+29
-10
@@ -6,3 +6,5 @@ const http = require('http'); | ||
| const BEACON_PORT = 19837; | ||
| const DISCOVERY_TIMEOUT = 5000; | ||
| const DISCOVERY_TIMEOUT = 1500; | ||
| const HEALTH_TIMEOUT = 1200; | ||
| const LAN_SCAN_TIMEOUT = 350; | ||
@@ -70,6 +72,6 @@ /** | ||
| /** Fetch /health from a device */ | ||
| function fetchHealth(device) { | ||
| function fetchHealth(device, timeout = HEALTH_TIMEOUT) { | ||
| return new Promise((resolve, reject) => { | ||
| const url = `http://${device.ip}:${device.port || YAVER_PORT}/health`; | ||
| const req = http.get(url, { timeout: 5000 }, (res) => { | ||
| const req = http.get(url, { timeout }, (res) => { | ||
| let data = ''; | ||
@@ -98,2 +100,3 @@ res.on('data', chunk => data += chunk); | ||
| const found = []; | ||
| const seen = new Set(); | ||
@@ -105,13 +108,17 @@ for (const [, addrs] of Object.entries(interfaces)) { | ||
| const subnet = addr.address.split('.').slice(0, 3).join('.'); | ||
| const promises = []; | ||
| const ips = []; | ||
| for (let i = 1; i <= 254; i++) { | ||
| const ip = `${subnet}.${i}`; | ||
| if (ip === addr.address) continue; | ||
| promises.push( | ||
| fetchHealth({ ip, port: YAVER_PORT }) | ||
| .then(h => found.push({ ip, port: YAVER_PORT, name: h.deviceName, platform: h.platform })) | ||
| .catch(() => {}) | ||
| ); | ||
| ips.push(ip); | ||
| } | ||
| await Promise.all(promises); | ||
| await runLimited(ips, 48, async (ip) => { | ||
| try { | ||
| const h = await fetchHealth({ ip, port: YAVER_PORT }, LAN_SCAN_TIMEOUT); | ||
| const key = h.deviceId || `${ip}:${YAVER_PORT}`; | ||
| if (seen.has(key)) return; | ||
| seen.add(key); | ||
| found.push({ ip, port: YAVER_PORT, name: h.deviceName, platform: h.platform }); | ||
| } catch {} | ||
| }); | ||
| } | ||
@@ -123,2 +130,14 @@ } | ||
| async function runLimited(items, limit, fn) { | ||
| let next = 0; | ||
| const workers = Array.from({ length: Math.min(limit, items.length) }, async () => { | ||
| for (;;) { | ||
| const idx = next++; | ||
| if (idx >= items.length) return; | ||
| await fn(items[idx]); | ||
| } | ||
| }); | ||
| await Promise.all(workers); | ||
| } | ||
| module.exports = { discoverDevice, fetchHealth, scanLAN, YAVER_PORT }; |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 4 instances
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 3 instances
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
12798362
04853
0.37%62
1.64%