@reepoe/plugin 1.3.17 ā 1.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/clear-cache.js +12 -0
- package/bin/metrics.js +59 -9
- package/bin/start.js +14 -0
- package/binaries/reepoe-linux-x64 +0 -0
- package/package.json +1 -1
package/bin/clear-cache.js
CHANGED
|
@@ -64,6 +64,18 @@ async function clearCache() {
|
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
// FIX #5: Try to clear via API first (to handle in-memory state/locks)
|
|
68
|
+
try {
|
|
69
|
+
const axios = require('axios');
|
|
70
|
+
// Try default port 8000
|
|
71
|
+
await axios.post('http://localhost:8000/internal/clear-cache', {}, { timeout: 2000 });
|
|
72
|
+
console.log('ā
Cleared cache via running server API');
|
|
73
|
+
return;
|
|
74
|
+
} catch (e) {
|
|
75
|
+
// Server not running or error, fall back to file system deletion
|
|
76
|
+
// Continue to code below...
|
|
77
|
+
}
|
|
78
|
+
|
|
67
79
|
// Clear files
|
|
68
80
|
try {
|
|
69
81
|
if (storeExists) {
|
package/bin/metrics.js
CHANGED
|
@@ -24,16 +24,66 @@ async function showMetrics() {
|
|
|
24
24
|
console.log('\nš Loading your ReePoe metrics...\n');
|
|
25
25
|
|
|
26
26
|
try {
|
|
27
|
-
|
|
28
|
-
const API_BASE = activation.api_base || 'https://reepoe-api.onrender.com';
|
|
29
|
-
const res = await axios.get(`${API_BASE}/api/metrics/user/${activation.email}`);
|
|
30
|
-
const data = res.data;
|
|
27
|
+
let metricsData = null;
|
|
31
28
|
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
// FIX #7: Check for local server first to get real-time local metrics
|
|
30
|
+
try {
|
|
31
|
+
// Try default port 8000 or check config
|
|
32
|
+
let port = 8000;
|
|
33
|
+
const configPath = path.join(process.cwd(), 'reepoe.config.json');
|
|
34
|
+
if (fs.existsSync(configPath)) {
|
|
35
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
36
|
+
port = config.api?.port || 8000;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const localRes = await axios.get(`http://localhost:${port}/metrics`, { timeout: 1000 });
|
|
40
|
+
const localRaw = localRes.data;
|
|
41
|
+
|
|
42
|
+
// Transform raw local metrics to view structure
|
|
43
|
+
metricsData = {
|
|
44
|
+
metrics: {
|
|
45
|
+
today: {
|
|
46
|
+
queries: localRaw.daily?.[new Date().toISOString().split('T')[0]]?.total_queries || 0,
|
|
47
|
+
tokens_saved: localRaw.daily?.[new Date().toISOString().split('T')[0]]?.tokens_saved || 0,
|
|
48
|
+
cost_saved: 0 // Local cost tracking not yet implemented in raw endpoint
|
|
49
|
+
},
|
|
50
|
+
week: {
|
|
51
|
+
queries: 0, // Would need aggregation
|
|
52
|
+
tokens_saved: 0,
|
|
53
|
+
cost_saved: 0
|
|
54
|
+
},
|
|
55
|
+
alltime: {
|
|
56
|
+
queries: localRaw.lifetime?.total_queries || 0,
|
|
57
|
+
tokens_saved: localRaw.lifetime?.tokens_saved || 0,
|
|
58
|
+
cost_saved: 0,
|
|
59
|
+
patterns_learned: Object.keys(localRaw.query_types || {}).length, // Approx
|
|
60
|
+
patterns_active: 0
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
account: {
|
|
64
|
+
status: 'Local Dev',
|
|
65
|
+
expires_at: null
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
console.log('ā
Loaded from local server (real-time)');
|
|
69
|
+
} catch (e) {
|
|
70
|
+
// Local failed, fall back to remote API
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (!metricsData) {
|
|
74
|
+
// Use per-user metrics endpoint with api_base from activation
|
|
75
|
+
const API_BASE = activation.api_base || 'https://reepoe-api.onrender.com';
|
|
76
|
+
const res = await axios.get(`${API_BASE}/api/metrics/user/${activation.email}`);
|
|
77
|
+
const data = res.data;
|
|
78
|
+
|
|
79
|
+
// Per-user endpoint returns the correct structure already
|
|
80
|
+
metricsData = {
|
|
81
|
+
metrics: data.metrics, // Already has today, week, alltime
|
|
82
|
+
account: data.account // Already has activated_at, expires_at, status
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const metrics = metricsData;
|
|
37
87
|
|
|
38
88
|
console.log('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā');
|
|
39
89
|
console.log(`ā š ReePoe Metrics - ${activation.email.padEnd(39)}ā`);
|
package/bin/start.js
CHANGED
|
@@ -334,6 +334,14 @@ async function main() {
|
|
|
334
334
|
const configPath = path.join(process.cwd(), 'reepoe.config.json');
|
|
335
335
|
let port = 8000;
|
|
336
336
|
|
|
337
|
+
// FIX #6: Parse CLI arguments for port (priority: CLI > Config > Default)
|
|
338
|
+
const args = process.argv.slice(2);
|
|
339
|
+
const portIndex = args.indexOf('--port');
|
|
340
|
+
let cliPort = null;
|
|
341
|
+
if (portIndex !== -1 && args[portIndex + 1]) {
|
|
342
|
+
cliPort = parseInt(args[portIndex + 1], 10);
|
|
343
|
+
}
|
|
344
|
+
|
|
337
345
|
if (fs.existsSync(configPath)) {
|
|
338
346
|
try {
|
|
339
347
|
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
@@ -346,6 +354,12 @@ async function main() {
|
|
|
346
354
|
console.log('ā¹ļø No configuration found, using defaults');
|
|
347
355
|
}
|
|
348
356
|
|
|
357
|
+
// Apply CLI override
|
|
358
|
+
if (cliPort) {
|
|
359
|
+
port = cliPort;
|
|
360
|
+
console.log(`š Using port ${port} from command line`);
|
|
361
|
+
}
|
|
362
|
+
|
|
349
363
|
// Detect cloud environment
|
|
350
364
|
const isCloud = isCloudEnvironment();
|
|
351
365
|
|
|
Binary file
|