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.
@@ -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
- // Wait for next cycle
80
+ const cycleDuration = Date.now() - cycleStart;
81
+ // Wait for next cycle (adaptive: subtract cycle duration)
80
82
  if (this.config.cycleInterval > 0) {
81
- await new Promise(r => setTimeout(r, this.config.cycleInterval));
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
  }
@@ -19,7 +19,7 @@ export interface MessageFilter {
19
19
  }
20
20
  export declare class MessageBus {
21
21
  private subscriptions;
22
- private messageQueue;
22
+ private priorityQueues;
23
23
  private processing;
24
24
  private messageHistory;
25
25
  private maxHistorySize;
@@ -14,7 +14,13 @@ const crypto_1 = require("crypto");
14
14
  // ============================================================================
15
15
  class MessageBus {
16
16
  subscriptions = new Map();
17
- messageQueue = [];
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
- this.messageQueue.push(fullMessage);
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
- // Sort by priority
96
- this.messageQueue.sort((a, b) => {
97
- const priorityOrder = { critical: 0, high: 1, normal: 2, low: 3 };
98
- return priorityOrder[a.priority] - priorityOrder[b.priority];
99
- });
100
- while (this.messageQueue.length > 0) {
101
- const message = this.messageQueue.shift();
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: this.messageQueue.length,
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
- this.messageQueue = [];
252
+ // v10.3: Clear all priority queues
253
+ this.priorityQueues = { critical: [], high: [], normal: [], low: [] };
244
254
  this.messageHistory = [];
245
255
  }
246
256
  }
@@ -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
- if (args[0] === 'confirm') {
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 {
@@ -99,7 +99,7 @@ export declare class InteractiveSession {
99
99
  */
100
100
  private stopSpinner;
101
101
  /**
102
- * Show progress
102
+ * Show progress - always visible (v10.3: removed verbose gate)
103
103
  */
104
104
  private showProgress;
105
105
  /**
@@ -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
- await this.delay(Math.pow(2, attempt) * 500);
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
- const samples = [];
1192
- // Generate N samples
1193
- for (let i = 0; i < this.config.nSamples; i++) {
1194
- const result = await this.generate(query, context, thinkingContext, systemPrompt, this.config.samplingTemperature);
1195
- samples.push({
1196
- response: result.response,
1197
- score: result.confidence,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genesis-ai-cli",
3
- "version": "10.2.0",
3
+ "version": "10.3.0",
4
4
  "description": "Fully Autonomous AI System - Self-funding, Self-deploying, Production Memory, A2A Protocol & Governance",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",