genesis-ai-cli 10.2.0 → 10.3.0
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/dist/src/active-inference/autonomous-loop.js +8 -3
- package/dist/src/agents/message-bus.d.ts +1 -1
- package/dist/src/agents/message-bus.js +22 -12
- package/dist/src/cli/chat.js +24 -1
- package/dist/src/cli/interactive.d.ts +1 -1
- package/dist/src/cli/interactive.js +1 -3
- package/dist/src/mcp/resilient.js +4 -2
- package/dist/src/thinking/index.js +7 -9
- package/package.json +1 -1
|
@@ -74,11 +74,16 @@ class AutonomousLoop {
|
|
|
74
74
|
this.stopReason = 'cycle_limit';
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
77
|
-
// Run one cycle
|
|
77
|
+
// Run one cycle with adaptive timing
|
|
78
|
+
const cycleStart = Date.now();
|
|
78
79
|
await this.cycle();
|
|
79
|
-
|
|
80
|
+
const cycleDuration = Date.now() - cycleStart;
|
|
81
|
+
// Wait for next cycle (adaptive: subtract cycle duration)
|
|
80
82
|
if (this.config.cycleInterval > 0) {
|
|
81
|
-
|
|
83
|
+
const remainingTime = Math.max(0, this.config.cycleInterval - cycleDuration);
|
|
84
|
+
if (remainingTime > 0) {
|
|
85
|
+
await new Promise(r => setTimeout(r, remainingTime));
|
|
86
|
+
}
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
89
|
}
|
|
@@ -14,7 +14,13 @@ const crypto_1 = require("crypto");
|
|
|
14
14
|
// ============================================================================
|
|
15
15
|
class MessageBus {
|
|
16
16
|
subscriptions = new Map();
|
|
17
|
-
|
|
17
|
+
// v10.3: Priority queues instead of O(n log n) sort
|
|
18
|
+
priorityQueues = {
|
|
19
|
+
critical: [],
|
|
20
|
+
high: [],
|
|
21
|
+
normal: [],
|
|
22
|
+
low: [],
|
|
23
|
+
};
|
|
18
24
|
processing = false;
|
|
19
25
|
messageHistory = [];
|
|
20
26
|
maxHistorySize = 1000;
|
|
@@ -56,7 +62,9 @@ class MessageBus {
|
|
|
56
62
|
id: (0, crypto_1.randomUUID)(),
|
|
57
63
|
timestamp: new Date(),
|
|
58
64
|
};
|
|
59
|
-
|
|
65
|
+
// v10.3: O(1) insertion into priority queue
|
|
66
|
+
const priority = fullMessage.priority || 'normal';
|
|
67
|
+
this.priorityQueues[priority].push(fullMessage);
|
|
60
68
|
this.metrics.messagesSent++;
|
|
61
69
|
// Store in history
|
|
62
70
|
this.addToHistory(fullMessage);
|
|
@@ -92,14 +100,13 @@ class MessageBus {
|
|
|
92
100
|
return;
|
|
93
101
|
this.processing = true;
|
|
94
102
|
try {
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
await this.deliverMessage(message);
|
|
103
|
+
// v10.3: O(1) extraction from priority queues (no sorting needed)
|
|
104
|
+
const priorities = ['critical', 'high', 'normal', 'low'];
|
|
105
|
+
for (const priority of priorities) {
|
|
106
|
+
while (this.priorityQueues[priority].length > 0) {
|
|
107
|
+
const message = this.priorityQueues[priority].shift();
|
|
108
|
+
await this.deliverMessage(message);
|
|
109
|
+
}
|
|
103
110
|
}
|
|
104
111
|
}
|
|
105
112
|
finally {
|
|
@@ -227,11 +234,13 @@ class MessageBus {
|
|
|
227
234
|
// Metrics
|
|
228
235
|
// ============================================================================
|
|
229
236
|
getMetrics() {
|
|
237
|
+
// v10.3: Sum all priority queues for total queue length
|
|
238
|
+
const queueLength = Object.values(this.priorityQueues).reduce((sum, q) => sum + q.length, 0);
|
|
230
239
|
return {
|
|
231
240
|
...this.metrics,
|
|
232
241
|
uptime: Date.now() - this.metrics.startTime.getTime(),
|
|
233
242
|
activeSubscriptions: this.subscriptions.size,
|
|
234
|
-
queueLength
|
|
243
|
+
queueLength,
|
|
235
244
|
historySize: this.messageHistory.length,
|
|
236
245
|
};
|
|
237
246
|
}
|
|
@@ -240,7 +249,8 @@ class MessageBus {
|
|
|
240
249
|
// ============================================================================
|
|
241
250
|
clear() {
|
|
242
251
|
this.subscriptions.clear();
|
|
243
|
-
|
|
252
|
+
// v10.3: Clear all priority queues
|
|
253
|
+
this.priorityQueues = { critical: [], high: [], normal: [], low: [] };
|
|
244
254
|
this.messageHistory = [];
|
|
245
255
|
}
|
|
246
256
|
}
|
package/dist/src/cli/chat.js
CHANGED
|
@@ -357,6 +357,24 @@ class ChatSession {
|
|
|
357
357
|
await this.handleCommand(input);
|
|
358
358
|
continue;
|
|
359
359
|
}
|
|
360
|
+
// v10.2: Implicit self-referential commands (Italian + English)
|
|
361
|
+
const implicitCommands = {
|
|
362
|
+
'migliorati': '/improve',
|
|
363
|
+
'migliora': '/improve',
|
|
364
|
+
'analizzati': '/analyze',
|
|
365
|
+
'analizza': '/analyze',
|
|
366
|
+
'guarisciti': '/heal',
|
|
367
|
+
'guarisci': '/heal',
|
|
368
|
+
'improve yourself': '/improve',
|
|
369
|
+
'analyze yourself': '/analyze',
|
|
370
|
+
'heal yourself': '/heal',
|
|
371
|
+
};
|
|
372
|
+
const lower = input.toLowerCase().trim();
|
|
373
|
+
if (implicitCommands[lower]) {
|
|
374
|
+
console.log((0, ui_js_1.c)(`→ ${implicitCommands[lower]}`, 'dim'));
|
|
375
|
+
await this.handleCommand(implicitCommands[lower]);
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
360
378
|
// Send to LLM
|
|
361
379
|
await this.sendMessage(input);
|
|
362
380
|
}
|
|
@@ -953,13 +971,18 @@ INSTRUCTION: You MUST report this error to the user. Do NOT fabricate or guess w
|
|
|
953
971
|
break;
|
|
954
972
|
// v7.0: Darwin-Gödel self-improvement commands
|
|
955
973
|
case 'heal':
|
|
974
|
+
case 'guarisci': // Italian
|
|
956
975
|
this.printHealingStatus();
|
|
957
976
|
break;
|
|
958
977
|
case 'analyze':
|
|
978
|
+
case 'analizza': // Italian
|
|
979
|
+
case 'analizzati': // Italian reflexive
|
|
959
980
|
this.runSelfAnalysis();
|
|
960
981
|
break;
|
|
961
982
|
case 'improve':
|
|
962
|
-
|
|
983
|
+
case 'migliora': // Italian
|
|
984
|
+
case 'migliorati': // Italian reflexive (improve yourself)
|
|
985
|
+
if (args[0] === 'confirm' || args[0] === 'conferma') {
|
|
963
986
|
this.runSelfImprovement();
|
|
964
987
|
}
|
|
965
988
|
else {
|
|
@@ -598,11 +598,9 @@ class InteractiveSession {
|
|
|
598
598
|
process.stdout.write('\r\x1b[K'); // Clear line
|
|
599
599
|
}
|
|
600
600
|
/**
|
|
601
|
-
* Show progress
|
|
601
|
+
* Show progress - always visible (v10.3: removed verbose gate)
|
|
602
602
|
*/
|
|
603
603
|
showProgress(status) {
|
|
604
|
-
if (!this.config.verbose)
|
|
605
|
-
return;
|
|
606
604
|
const pct = Math.round((status.current / status.total) * 100);
|
|
607
605
|
const bar = '█'.repeat(Math.floor(pct / 5)) + '░'.repeat(20 - Math.floor(pct / 5));
|
|
608
606
|
process.stdout.write(`\r [${bar}] ${pct}% ${status.message || ''}`);
|
|
@@ -123,9 +123,11 @@ class ResilientMCP {
|
|
|
123
123
|
if (this.config.logCalls) {
|
|
124
124
|
console.log(`[MCP] ${server}.${tool} attempt ${attempt + 1} failed: ${lastError}`);
|
|
125
125
|
}
|
|
126
|
-
// Exponential backoff before retry
|
|
126
|
+
// Exponential backoff with jitter before retry (v10.3: prevents retry storms)
|
|
127
127
|
if (attempt < maxRetries) {
|
|
128
|
-
|
|
128
|
+
const baseDelay = Math.pow(2, attempt) * 500;
|
|
129
|
+
const jitter = Math.random() * baseDelay * 0.5; // 0-50% jitter
|
|
130
|
+
await this.delay(baseDelay + jitter);
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
133
|
}
|
|
@@ -1188,15 +1188,13 @@ Question: ${query}`;
|
|
|
1188
1188
|
* Generate N samples and select the best
|
|
1189
1189
|
*/
|
|
1190
1190
|
async bestOfN(query, context, thinkingContext, systemPrompt) {
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
});
|
|
1199
|
-
}
|
|
1191
|
+
// v10.3: Parallel Best-of-N generation (3-5x speedup)
|
|
1192
|
+
const generatePromises = Array.from({ length: this.config.nSamples }, () => this.generate(query, context, thinkingContext, systemPrompt, this.config.samplingTemperature));
|
|
1193
|
+
const results = await Promise.all(generatePromises);
|
|
1194
|
+
const samples = results.map(result => ({
|
|
1195
|
+
response: result.response,
|
|
1196
|
+
score: result.confidence,
|
|
1197
|
+
}));
|
|
1200
1198
|
// Self-consistency: Check agreement among samples
|
|
1201
1199
|
const consensusScore = this.calculateConsensus(samples.map(s => s.response));
|
|
1202
1200
|
// Select best (highest score + bonus for consensus)
|
package/package.json
CHANGED