trace.ai-cli 1.2.0 → 1.2.1

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/cli/traceAI.js CHANGED
@@ -26,16 +26,16 @@ class TraceAI {
26
26
  async start() {
27
27
  // Clear screen for clean start
28
28
  console.clear();
29
-
29
+
30
30
  // Animated startup sequence
31
31
  await this.showLoadingAnimation();
32
-
32
+
33
33
  // Main header with enhanced ASCII art
34
34
  await this.displayHeader();
35
-
35
+
36
36
  // Show welcome message and commands
37
37
  this.displayWelcomeMessage();
38
-
38
+
39
39
  // Start the interactive session
40
40
  this.promptUser();
41
41
  }
@@ -48,7 +48,7 @@ class TraceAI {
48
48
  'Preparing analysis engines...',
49
49
  'Ready to trace!'
50
50
  ];
51
-
51
+
52
52
  for (let i = 0; i < messages.length; i++) {
53
53
  for (let j = 0; j < 10; j++) {
54
54
  process.stdout.write(`\r${chalk.blueBright(frames[j % frames.length])} ${chalk.white(messages[i])}`);
@@ -66,14 +66,14 @@ class TraceAI {
66
66
  horizontalLayout: 'fitted',
67
67
  verticalLayout: 'default'
68
68
  });
69
-
69
+
70
70
  // Enhanced header with gradient effect
71
71
  console.log(chalk.bold.blueBright(asciiArt));
72
-
72
+
73
73
  // Subtitle and version info
74
74
  console.log(chalk.gray.bold(' ') + chalk.white.bold('AI powered CLI Platform'));
75
75
  console.log(chalk.gray(' ') + chalk.gray('v1.2.0 | Powered by Mixkey'));
76
-
76
+
77
77
  // Dynamic separator
78
78
  const width = process.stdout.columns || 80;
79
79
  console.log(chalk.blueBright('═'.repeat(Math.min(width, 80))));
@@ -82,11 +82,11 @@ class TraceAI {
82
82
  displayWelcomeMessage() {
83
83
  // Welcome section with better formatting
84
84
  console.log(chalk.bold.green('\nWelcome to Trace.AI CLI'));
85
- console.log();
85
+ console.log();
86
86
  // Enhanced command documentation
87
87
  console.log(chalk.bold.cyan('šŸ“‹ AVAILABLE COMMANDS'));
88
88
  console.log(chalk.gray('━'.repeat(50)));
89
-
89
+
90
90
  const commands = [
91
91
  {
92
92
  cmd: '/file <path> [question]',
@@ -174,10 +174,10 @@ class TraceAI {
174
174
  console.log(chalk.white('• Use ') + chalk.cyan('Tab') + chalk.white(' for auto-completion (when available)'));
175
175
  console.log(chalk.white('• Start with ') + chalk.cyan('/file "your-file.js"') + chalk.white(' to analyze code'));
176
176
  console.log(chalk.white('• Or just ask any question directly!'));
177
-
177
+
178
178
  // Status bar
179
179
  this.displayStatusBar();
180
-
180
+
181
181
  console.log(chalk.gray('\n' + '─'.repeat(60)));
182
182
 
183
183
  }
@@ -186,12 +186,12 @@ class TraceAI {
186
186
  const uptime = Math.floor((new Date() - this.sessionStartTime) / 1000);
187
187
  const contextCount = this.contexts.length;
188
188
  const modeLabel = this.mode === 1 ? 'Fast' : this.mode === 2 ? 'Balanced' : 'Think';
189
-
189
+
190
190
  console.log(chalk.gray('\nā”Œā”€ SESSION INFO ') + chalk.gray('─'.repeat(34)));
191
- console.log(chalk.gray('│ ') + chalk.white('Uptime: ') + chalk.green(`${uptime}s`) +
192
- chalk.gray(' │ ') + chalk.white('Contexts: ') + chalk.cyan(contextCount) +
193
- chalk.gray(' │ ') + chalk.white('Queries: ') + chalk.blueBright(this.queryCount) +
194
- chalk.gray(' │ ') + chalk.white('Mode: ') + chalk.magenta(modeLabel));
191
+ console.log(chalk.gray('│ ') + chalk.white('Uptime: ') + chalk.green(`${uptime}s`) +
192
+ chalk.gray(' │ ') + chalk.white('Contexts: ') + chalk.cyan(contextCount) +
193
+ chalk.gray(' │ ') + chalk.white('Queries: ') + chalk.blueBright(this.queryCount) +
194
+ chalk.gray(' │ ') + chalk.white('Mode: ') + chalk.magenta(modeLabel));
195
195
  console.log(chalk.gray('└─') + chalk.gray('─'.repeat(48)));
196
196
  }
197
197
 
@@ -199,7 +199,7 @@ class TraceAI {
199
199
  // Enhanced prompt with status indicators
200
200
  const contextIndicator = this.contexts.length > 0 ? chalk.cyan(`[${this.contexts.length}]`) : '';
201
201
  const prompt = `${chalk.bold.blueBright('Trace.Ai')} ${contextIndicator}${chalk.gray('>')} `;
202
-
202
+
203
203
  this.rl.question(prompt, async (input) => {
204
204
  try {
205
205
  if (input.trim()) {
@@ -215,7 +215,7 @@ class TraceAI {
215
215
 
216
216
  async handleInput(input) {
217
217
  const trimmedInput = input.trim();
218
-
218
+
219
219
  if (!trimmedInput) return;
220
220
 
221
221
  // Command routing with enhanced feedback
@@ -236,7 +236,7 @@ class TraceAI {
236
236
 
237
237
  // Find and execute command
238
238
  const commandKey = Object.keys(commands).find(cmd => trimmedInput.startsWith(cmd));
239
-
239
+
240
240
  if (commandKey) {
241
241
  await commands[commandKey]();
242
242
  } else {
@@ -336,12 +336,12 @@ class TraceAI {
336
336
 
337
337
  console.log(chalk.bold.green('\nšŸ“‹ ACTIVE CONTEXTS'));
338
338
  console.log(chalk.gray('━'.repeat(50)));
339
-
339
+
340
340
  this.contexts.forEach((ctx, index) => {
341
341
  const icon = ctx.type === 'file' ? 'šŸ“„' : 'šŸ’­';
342
342
  const preview = ctx.content.substring(0, 80).replace(/\n/g, ' ');
343
343
  const truncated = ctx.content.length > 80 ? '...' : '';
344
-
344
+
345
345
  console.log(`${chalk.blueBright(icon)} ${chalk.bold(`[${index + 1}]`)} ${chalk.gray(ctx.timestamp)}`);
346
346
  console.log(` ${chalk.white(preview)}${chalk.gray(truncated)}`);
347
347
  if (index < this.contexts.length - 1) console.log();
@@ -365,26 +365,26 @@ class TraceAI {
365
365
  }
366
366
 
367
367
  displayHelp() {
368
-
368
+
369
369
  console.log(chalk.bold.green('\nšŸ“– DETAILED HELP GUIDE'));
370
370
  console.log(chalk.gray('━'.repeat(60)));
371
-
371
+
372
372
  console.log(chalk.bold.cyan('\nšŸŽÆ GETTING STARTED'));
373
373
  console.log('Trace.AI is an intelligent CLI tool that helps you understand and analyze files,');
374
374
  console.log('folder structures, and images using advanced AI capabilities.\n');
375
-
375
+
376
376
  console.log(chalk.bold.cyan('šŸ’” TIPS FOR BETTER RESULTS'));
377
377
  console.log('• Be specific in your questions');
378
378
  console.log('• Use context to provide background information');
379
379
  console.log('• Combine multiple commands for comprehensive analysis');
380
380
  console.log('• File paths with spaces should be quoted\n');
381
-
381
+
382
382
  console.log(chalk.bold.cyan('šŸ”§ TROUBLESHOOTING'));
383
383
  console.log('• Ensure file paths are correct and accessible');
384
384
  console.log('• Check file permissions for read access');
385
385
  console.log('• Use /stats to monitor your session');
386
386
  console.log('• Use /clear screen to refresh the interface\n');
387
-
387
+
388
388
  console.log(chalk.gray('Press any key to continue...'));
389
389
 
390
390
  }
@@ -393,7 +393,7 @@ class TraceAI {
393
393
  const uptime = Math.floor((new Date() - this.sessionStartTime) / 1000);
394
394
  const minutes = Math.floor(uptime / 60);
395
395
  const seconds = uptime % 60;
396
-
396
+
397
397
  console.log(chalk.bold.green('\nšŸ“Š SESSION STATISTICS'));
398
398
  console.log(chalk.gray('━'.repeat(40)));
399
399
  console.log(`${chalk.blueBright('šŸ•')} Session Duration: ${chalk.white(`${minutes}m ${seconds}s`)}`);
@@ -403,10 +403,10 @@ class TraceAI {
403
403
  console.log(`${chalk.blueBright('šŸ“…')} Started: ${chalk.white(this.sessionStartTime.toLocaleString())}`);
404
404
  console.log(chalk.gray('━'.repeat(40)));
405
405
  }
406
-
406
+
407
407
  async handleSystemCommand(input) {
408
408
  const query = input.substring('/system'.length).trim();
409
-
409
+
410
410
  await this.executeWithSpinner(
411
411
  'Retrieving system information',
412
412
  async () => {
@@ -464,12 +464,12 @@ class TraceAI {
464
464
  async executeWithSpinner(message, task) {
465
465
  const frames = ['ā ‹', 'ā ™', 'ā ¹', 'ā ø', 'ā ¼', 'ā “', 'ā ¦', 'ā §', 'ā ‡', 'ā '];
466
466
  let frameIndex = 0;
467
-
467
+
468
468
  const spinner = setInterval(() => {
469
469
  process.stdout.write(`\r${chalk.blueBright(frames[frameIndex])} ${chalk.white(message)}`);
470
470
  frameIndex = (frameIndex + 1) % frames.length;
471
471
  }, 100);
472
-
472
+
473
473
  try {
474
474
  await task();
475
475
  clearInterval(spinner);
@@ -498,30 +498,30 @@ class TraceAI {
498
498
  }
499
499
 
500
500
  close() {
501
-
501
+
502
502
  // Farewell message
503
503
  const farewell = figlet.textSync('Goodbye!', {
504
504
  font: 'Small',
505
505
  horizontalLayout: 'fitted'
506
506
  });
507
-
507
+
508
508
  console.log(chalk.blueBright(farewell));
509
509
  console.log(chalk.gray('━'.repeat(50)));
510
510
  console.log(chalk.bold.green('Thank you for using Trace.AI!'));
511
-
511
+
512
512
  // Session summary
513
513
  const uptime = Math.floor((new Date() - this.sessionStartTime) / 1000);
514
514
  const minutes = Math.floor(uptime / 60);
515
515
  const seconds = uptime % 60;
516
-
516
+
517
517
  console.log(chalk.gray(`Session Duration: ${minutes}m ${seconds}s`));
518
518
  console.log(chalk.gray(`Total Queries: ${this.queryCount}`));
519
519
  console.log(chalk.gray(`Contexts Used: ${this.contexts.length}`));
520
-
520
+
521
521
  console.log(chalk.gray('━'.repeat(50)));
522
522
  console.log(chalk.cyan('Visit us at: https://traceai.netlify.app'));
523
523
  console.log(chalk.gray('Have a great day! šŸ‘‹\n'));
524
-
524
+
525
525
  this.rl.close();
526
526
  process.exit(0);
527
527
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trace.ai-cli",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "A powerful AI-powered CLI tool",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -37,10 +37,9 @@
37
37
  "ora": "^5.4.1",
38
38
  "os-utils": "^0.0.14",
39
39
  "pdf-parse": "^1.1.1",
40
- "systeminformation": "^5.27.1",
41
- "trace.ai-cli": "^1.1.8"
40
+ "systeminformation": "^5.27.1"
42
41
  },
43
42
  "engines": {
44
43
  "node": ">=14.0.0"
45
44
  }
46
- }
45
+ }
@@ -2,17 +2,17 @@ const fetch = require('node-fetch');
2
2
  const { encryptData, decryptData } = require('../utils/encryption');
3
3
  const { getSystemInfo, formatBytes } = require('./systemInfoService');
4
4
 
5
- // Model selection helpers
6
- function getTextModels(mode) {
5
+ // Mode selection helpers
6
+ function getMode(mode) {
7
7
  switch (Number(mode)) {
8
8
  case 1: // Fast
9
- return ['g1'];
9
+ return 'fast';
10
10
  case 2: // Balanced
11
- return ['sct', 'g1', 'gptoss20'];
11
+ return 'balance';
12
12
  case 3: // Think
13
- return ['kimi', 'mvrk', 'gma3', 'dsv3', 'sct', 'gptoss120', 'gptoss20', 'll70b', 'qw3', 'nlm3'];
13
+ return 'think';
14
14
  default:
15
- return ['sct', 'g1', 'gptoss20'];
15
+ return 'balance';
16
16
  }
17
17
  }
18
18
 
@@ -52,88 +52,82 @@ Examples:
52
52
  "Network and disk status" -> network disk
53
53
 
54
54
  Only respond with the category names, nothing else. Be precise and focus on what the user actually needs.`;
55
-
56
- // Use multiple AI models to analyze the query
57
- const models = getTextModels(2); // Balanced by default
58
-
59
- const modelRequests = models.map(async (model) => {
60
- try {
61
- const response = await fetch('https://traceai.dukeindustries7.workers.dev/', {
62
- method: 'POST',
63
- headers: { 'Content-Type': 'application/json' },
64
- body: encryptData({
65
- a: model,
66
- q: analysisPrompt,
67
- r: [],
68
- i: [],
69
- c: JSON.stringify({
70
- basicInfo,
71
- timestamp: currentTimestamp,
72
- user: basicInfo.user
73
- })
55
+
56
+ // Use AI to analyze the query with balanced mode
57
+ const mode = getMode(2); // Balanced by default
58
+
59
+ try {
60
+ const response = await fetch('https://traceai.dukeindustries7.workers.dev/', {
61
+ method: 'POST',
62
+ headers: { 'Content-Type': 'application/json' },
63
+ body: encryptData({
64
+ a: mode,
65
+ q: analysisPrompt,
66
+ i: [],
67
+ c: JSON.stringify({
68
+ basicInfo,
69
+ timestamp: currentTimestamp,
70
+ user: basicInfo.user
74
71
  })
75
- });
76
-
77
- const text = await response.text();
78
- const decrypted = decryptData(text);
79
- return decrypted;
80
- } catch (e) {
81
-
82
- return null;
83
- }
84
- });
85
-
86
- const responses = await Promise.all(modelRequests);
87
-
88
- // Filter out null responses and extract valid text
89
- const validResponses = responses
90
- .filter(r => r && r.text && typeof r.text === 'string')
91
- .map(r => r.text.toLowerCase().trim());
92
-
93
-
94
-
95
- // Analyze responses to determine categories
96
- let categories = new Set();
97
- const validCategories = ['basic', 'cpu', 'memory', 'disk', 'network', 'process', 'environment', 'all'];
98
-
99
- if (validResponses.length > 0) {
100
- // Process each response and count category occurrences
101
- const categoryCount = {};
102
-
103
- for (const response of validResponses) {
104
- const words = response.split(/\s+/);
105
- for (const word of words) {
106
- if (validCategories.includes(word)) {
107
- categoryCount[word] = (categoryCount[word] || 0) + 1;
108
- categories.add(word);
72
+ })
73
+ });
74
+
75
+ const text = await response.text();
76
+ const decrypted = decryptData(text);
77
+ const responses = [decrypted];
78
+
79
+ // Filter out null responses and extract valid text
80
+ const validResponses = responses
81
+ .filter(r => r && r.text && typeof r.text === 'string')
82
+ .map(r => r.text.toLowerCase().trim());
83
+
84
+
85
+
86
+ // Analyze responses to determine categories
87
+ let categories = new Set();
88
+ const validCategories = ['basic', 'cpu', 'memory', 'disk', 'network', 'process', 'environment', 'all'];
89
+
90
+ if (validResponses.length > 0) {
91
+ // Process each response and count category occurrences
92
+ const categoryCount = {};
93
+
94
+ for (const response of validResponses) {
95
+ const words = response.split(/\s+/);
96
+ for (const word of words) {
97
+ if (validCategories.includes(word)) {
98
+ categoryCount[word] = (categoryCount[word] || 0) + 1;
99
+ categories.add(word);
100
+ }
109
101
  }
110
102
  }
103
+
104
+ // If we found 'all', that takes precedence
105
+ if (categories.has('all')) {
106
+ return { query: 'all' };
107
+ }
108
+
109
+ // If we have valid categories, use the most commonly mentioned ones
110
+ if (categories.size > 0) {
111
+ // Sort categories by frequency and take top ones
112
+ const sortedCategories = Object.entries(categoryCount)
113
+ .sort(([, a], [, b]) => b - a)
114
+ .map(([category]) => category);
115
+
116
+ const query = sortedCategories.join(' ');
117
+ return { query };
118
+ }
111
119
  }
112
-
113
- // If we found 'all', that takes precedence
114
- if (categories.has('all')) {
115
- return { query: 'all' };
116
- }
117
-
118
- // If we have valid categories, use the most commonly mentioned ones
119
- if (categories.size > 0) {
120
- // Sort categories by frequency and take top ones
121
- const sortedCategories = Object.entries(categoryCount)
122
- .sort(([,a], [,b]) => b - a)
123
- .map(([category]) => category);
124
-
125
- const query = sortedCategories.join(' ');
126
- return { query };
127
- }
120
+ } catch (e) {
121
+ // If API call fails, fall through to keyword matching
128
122
  }
129
-
123
+
130
124
  // Fallback: use keyword matching if AI didn't provide valid responses
131
125
 
132
126
  const fallbackCategories = determineCategoriesByKeywords(prompt);
133
127
  return { query: fallbackCategories };
134
-
128
+
135
129
  } catch (error) {
136
-
130
+
137
131
  // Final fallback to basic info
138
132
  return { query: 'basic' };
139
133
  }
@@ -147,11 +141,11 @@ Only respond with the category names, nothing else. Be precise and focus on what
147
141
  function determineCategoriesByKeywords(prompt) {
148
142
  const lowerPrompt = prompt.toLowerCase();
149
143
  const categories = new Set();
150
-
144
+
151
145
  // Define comprehensive keyword patterns for each category
152
146
  const patterns = {
153
147
  cpu: [
154
- 'cpu', 'processor', 'core', 'thread', 'clock', 'speed', 'ghz', 'mhz',
148
+ 'cpu', 'processor', 'core', 'thread', 'clock', 'speed', 'ghz', 'mhz',
155
149
  'load', 'usage', 'temperature', 'intel', 'amd', 'arm', 'performance',
156
150
  'benchmark', 'processing', 'compute', 'cores', 'threads', 'frequency'
157
151
  ],
@@ -161,12 +155,12 @@ function determineCategoriesByKeywords(prompt) {
161
155
  'virtual memory', 'physical memory', 'memory usage'
162
156
  ],
163
157
  disk: [
164
- 'disk', 'drive', 'storage', 'space', 'filesystem', 'mount', 'partition',
158
+ 'disk', 'drive', 'storage', 'space', 'filesystem', 'mount', 'partition',
165
159
  'volume', 'hdd', 'ssd', 'nvme', 'capacity', 'free space', 'used space',
166
160
  'hard drive', 'solid state', 'storage device', 'file system'
167
161
  ],
168
162
  network: [
169
- 'network', 'internet', 'wifi', 'ip', 'address', 'connection', 'interface',
163
+ 'network', 'internet', 'wifi', 'ip', 'address', 'connection', 'interface',
170
164
  'ethernet', 'wireless', 'lan', 'wan', 'dns', 'gateway', 'router', 'subnet',
171
165
  'bandwidth', 'latency', 'ping', 'download', 'upload', 'mac address'
172
166
  ],
@@ -186,13 +180,13 @@ function determineCategoriesByKeywords(prompt) {
186
180
  'operating system', 'computer', 'device', 'hardware'
187
181
  ]
188
182
  };
189
-
183
+
190
184
  // Check for 'all' keywords first
191
185
  const allKeywords = ['all', 'everything', 'complete', 'full', 'entire', 'comprehensive'];
192
186
  if (allKeywords.some(keyword => lowerPrompt.includes(keyword))) {
193
187
  return 'all';
194
188
  }
195
-
189
+
196
190
  // Check each category and count matches
197
191
  const categoryMatches = {};
198
192
  for (const [category, keywords] of Object.entries(patterns)) {
@@ -202,12 +196,12 @@ function determineCategoriesByKeywords(prompt) {
202
196
  categoryMatches[category] = matches;
203
197
  }
204
198
  }
205
-
199
+
206
200
  // If no categories matched, default to basic
207
201
  if (categories.size === 0) {
208
202
  categories.add('basic');
209
203
  }
210
-
204
+
211
205
  const result = Array.from(categories).join(' ');
212
206
 
213
207
  return result;
@@ -223,11 +217,11 @@ async function formatSystemInfoResponse(sysInfo, prompt) {
223
217
  try {
224
218
  // Check if we have any system information
225
219
  const hasInfo = Object.keys(sysInfo).length > 0;
226
-
220
+
227
221
  if (!hasInfo) {
228
222
  return getHelpMessage(prompt);
229
223
  }
230
-
224
+
231
225
  // Use AI to format the response based on the user's specific question
232
226
  const formattingPrompt = `Current Date/Time: 2025-07-09 10:45:40 UTC
233
227
  User: m0v0dga_walmart
@@ -264,9 +258,8 @@ Make the response helpful and easy to understand for the user.`;
264
258
  method: 'POST',
265
259
  headers: { 'Content-Type': 'application/json' },
266
260
  body: encryptData({
267
- a: getTextModels(2)[0], // Use the first Balanced text model for formatting
261
+ a: getMode(2), // Use balanced mode for formatting
268
262
  q: formattingPrompt,
269
- r: [],
270
263
  i: [],
271
264
  c: JSON.stringify({
272
265
  timestamp: '2025-07-09 10:45:40',
@@ -278,18 +271,18 @@ Make the response helpful and easy to understand for the user.`;
278
271
 
279
272
  const encryptedResult = await response.text();
280
273
  const decryptedResult = decryptData(encryptedResult);
281
-
274
+
282
275
  if (decryptedResult.text && typeof decryptedResult.text === 'string') {
283
-
276
+
284
277
  return decryptedResult.text;
285
278
  }
286
279
  } catch (aiError) {
287
280
  }
288
-
281
+
289
282
  // Fallback to manual formatting if AI fails
290
283
 
291
284
  return formatSystemInfoManually(sysInfo, prompt);
292
-
285
+
293
286
  } catch (error) {
294
287
  // Fallback to manual formatting
295
288
  return formatSystemInfoManually(sysInfo, prompt);
@@ -305,7 +298,7 @@ Make the response helpful and easy to understand for the user.`;
305
298
  function formatSystemInfoManually(sysInfo, prompt) {
306
299
  let response = `Here's the system information you requested:\n\n`;
307
300
  response += `*System information as of 2025-07-09 10:45:40 UTC*\n\n`;
308
-
301
+
309
302
  if (sysInfo.basic) {
310
303
  const basic = sysInfo.basic;
311
304
  response += `šŸ“± **System Overview**\n`;
@@ -316,17 +309,17 @@ function formatSystemInfoManually(sysInfo, prompt) {
316
309
  if (basic.model) response += `- Model: ${basic.model}\n`;
317
310
  if (basic.distro) response += `- Distribution: ${basic.distro}\n`;
318
311
  if (basic.kernel) response += `- Kernel: ${basic.kernel}\n`;
319
-
312
+
320
313
  const uptimeHours = Math.floor((basic.uptime || 0) / 3600);
321
314
  const uptimeMinutes = Math.floor(((basic.uptime || 0) % 3600) / 60);
322
315
  response += `- Uptime: ${uptimeHours} hours ${uptimeMinutes} minutes\n`;
323
-
316
+
324
317
  if (basic.loadAvg && Array.isArray(basic.loadAvg)) {
325
318
  response += `- Load Average: ${basic.loadAvg.map(load => load.toFixed(2)).join(', ')}\n`;
326
319
  }
327
320
  response += `\n`;
328
321
  }
329
-
322
+
330
323
  if (sysInfo.cpu) {
331
324
  const cpu = sysInfo.cpu;
332
325
  response += `šŸ’» **CPU Information**\n`;
@@ -336,23 +329,23 @@ function formatSystemInfoManually(sysInfo, prompt) {
336
329
  if (cpu.physicalCores) response += `- Physical Cores: ${cpu.physicalCores}\n`;
337
330
  if (cpu.speed) response += `- Base Speed: ${cpu.speed} MHz\n`;
338
331
  if (cpu.speedMax) response += `- Max Speed: ${cpu.speedMax} MHz\n`;
339
-
332
+
340
333
  if (cpu.load) {
341
334
  if (cpu.load.currentLoad !== undefined) response += `- Current Load: ${cpu.load.currentLoad.toFixed(2)}%\n`;
342
335
  if (cpu.load.currentLoadUser !== undefined) response += `- User Load: ${cpu.load.currentLoadUser.toFixed(2)}%\n`;
343
336
  if (cpu.load.currentLoadSystem !== undefined) response += `- System Load: ${cpu.load.currentLoadSystem.toFixed(2)}%\n`;
344
337
  }
345
-
338
+
346
339
  if (cpu.temperature && cpu.temperature.main) {
347
340
  response += `- Temperature: ${cpu.temperature.main}°C\n`;
348
341
  }
349
-
342
+
350
343
  if (cpu.loadAvg && Array.isArray(cpu.loadAvg)) {
351
344
  response += `- Load Average: ${cpu.loadAvg.map(load => load.toFixed(2)).join(', ')}\n`;
352
345
  }
353
346
  response += `\n`;
354
347
  }
355
-
348
+
356
349
  if (sysInfo.memory) {
357
350
  const memory = sysInfo.memory;
358
351
  response += `🧠 **Memory Information**\n`;
@@ -361,13 +354,13 @@ function formatSystemInfoManually(sysInfo, prompt) {
361
354
  response += `- Free: ${memory.free || 'Unknown'}\n`;
362
355
  if (memory.available) response += `- Available: ${memory.available}\n`;
363
356
  if (memory.active) response += `- Active: ${memory.active}\n`;
364
-
357
+
365
358
  if (memory.swap) {
366
359
  response += `- Swap Total: ${memory.swap.total || 'Unknown'}\n`;
367
360
  response += `- Swap Used: ${memory.swap.used || 'Unknown'} (${memory.swap.usagePercent || 'Unknown'})\n`;
368
361
  response += `- Swap Free: ${memory.swap.free || 'Unknown'}\n`;
369
362
  }
370
-
363
+
371
364
  if (memory.layout && Array.isArray(memory.layout) && memory.layout.length > 0) {
372
365
  response += `- Memory Modules: ${memory.layout.length} installed\n`;
373
366
  memory.layout.forEach((module, index) => {
@@ -381,10 +374,10 @@ function formatSystemInfoManually(sysInfo, prompt) {
381
374
  }
382
375
  response += `\n`;
383
376
  }
384
-
377
+
385
378
  if (sysInfo.disk) {
386
379
  response += `šŸ’¾ **Disk Information**\n`;
387
-
380
+
388
381
  if (sysInfo.disk.fsSize && Array.isArray(sysInfo.disk.fsSize)) {
389
382
  response += `- File Systems:\n`;
390
383
  sysInfo.disk.fsSize.forEach(fs => {
@@ -412,7 +405,7 @@ function formatSystemInfoManually(sysInfo, prompt) {
412
405
  } else if (sysInfo.disk.error) {
413
406
  response += `- Error retrieving disk information: ${sysInfo.disk.error}\n`;
414
407
  }
415
-
408
+
416
409
  if (sysInfo.disk.diskLayout && Array.isArray(sysInfo.disk.diskLayout)) {
417
410
  response += `- Physical Disks: ${sysInfo.disk.diskLayout.length} detected\n`;
418
411
  sysInfo.disk.diskLayout.forEach((disk, index) => {
@@ -424,14 +417,14 @@ function formatSystemInfoManually(sysInfo, prompt) {
424
417
  }
425
418
  response += `\n`;
426
419
  }
427
-
420
+
428
421
  if (sysInfo.network) {
429
422
  response += `🌐 **Network Information**\n`;
430
-
423
+
431
424
  if (sysInfo.network.publicIp && sysInfo.network.publicIp !== 'Not available') {
432
425
  response += `- Public IP: ${sysInfo.network.publicIp}\n`;
433
426
  }
434
-
427
+
435
428
  if (sysInfo.network.interfaces && Array.isArray(sysInfo.network.interfaces)) {
436
429
  const activeInterfaces = sysInfo.network.interfaces.filter(iface => !iface.internal);
437
430
  if (activeInterfaces.length > 0) {
@@ -457,20 +450,20 @@ function formatSystemInfoManually(sysInfo, prompt) {
457
450
  });
458
451
  }
459
452
  }
460
-
453
+
461
454
  if (sysInfo.network.internetLatency && sysInfo.network.internetLatency !== 'N/A ms') {
462
455
  response += `- Internet Connectivity: ${sysInfo.network.internetLatency}\n`;
463
456
  }
464
-
457
+
465
458
  if (sysInfo.network.connections && typeof sysInfo.network.connections === 'number') {
466
459
  response += `- Active Connections: ${sysInfo.network.connections}\n`;
467
460
  }
468
461
  response += `\n`;
469
462
  }
470
-
463
+
471
464
  if (sysInfo.process) {
472
465
  response += `āš™ļø **Process Information**\n`;
473
-
466
+
474
467
  if (sysInfo.process.currentProcess) {
475
468
  const current = sysInfo.process.currentProcess;
476
469
  response += `- Current Process:\n`;
@@ -488,7 +481,7 @@ function formatSystemInfoManually(sysInfo, prompt) {
488
481
  response += `- Memory Usage: ${Math.round(sysInfo.process.memoryUsage.rss / (1024 * 1024))} MB\n`;
489
482
  }
490
483
  }
491
-
484
+
492
485
  if (sysInfo.process.summary) {
493
486
  const summary = sysInfo.process.summary;
494
487
  response += `- Process Summary:\n`;
@@ -497,7 +490,7 @@ function formatSystemInfoManually(sysInfo, prompt) {
497
490
  if (summary.sleeping) response += ` - Sleeping: ${summary.sleeping}\n`;
498
491
  if (summary.blocked) response += ` - Blocked: ${summary.blocked}\n`;
499
492
  }
500
-
493
+
501
494
  if (sysInfo.process.topProcesses && Array.isArray(sysInfo.process.topProcesses) && sysInfo.process.topProcesses.length > 0) {
502
495
  response += `- Top Processes (by CPU):\n`;
503
496
  sysInfo.process.topProcesses.slice(0, 5).forEach((proc, index) => {
@@ -506,10 +499,10 @@ function formatSystemInfoManually(sysInfo, prompt) {
506
499
  }
507
500
  response += `\n`;
508
501
  }
509
-
502
+
510
503
  if (sysInfo.environment) {
511
504
  response += `šŸ”§ **Environment Information**\n`;
512
-
505
+
513
506
  if (sysInfo.environment.variables) {
514
507
  const envVars = sysInfo.environment.variables;
515
508
  response += `- Key Environment Variables:\n`;
@@ -519,20 +512,20 @@ function formatSystemInfoManually(sysInfo, prompt) {
519
512
  response += ` - ${varName}: ${envVars[varName]}\n`;
520
513
  }
521
514
  });
522
-
515
+
523
516
  const otherVars = Object.keys(envVars).filter(key => !importantVars.includes(key));
524
517
  if (otherVars.length > 0) {
525
518
  response += ` - Other variables: ${otherVars.length} additional environment variables\n`;
526
519
  }
527
520
  }
528
-
521
+
529
522
  if (sysInfo.environment.users && Array.isArray(sysInfo.environment.users) && sysInfo.environment.users.length > 0) {
530
523
  response += `- Active Users: ${sysInfo.environment.users.length}\n`;
531
524
  }
532
525
  response += `\n`;
533
526
  }
534
-
535
- response ;
527
+
528
+ response;
536
529
  return response;
537
530
  }
538
531
 
@@ -543,73 +536,73 @@ function formatSystemInfoManually(sysInfo, prompt) {
543
536
  */
544
537
  function getHelpMessage(prompt) {
545
538
  return `I couldn't find specific system information for your query: "${prompt}"\n\n` +
546
- `*Available system information queries:*\n\n` +
547
- `šŸ“± **Basic System Info:**\n` +
548
- `- "What's my system info?" - Platform, OS, architecture\n` +
549
- `- "System overview" - Complete basic information\n\n` +
550
- `šŸ’» **CPU Information:**\n` +
551
- `- "What's my CPU usage?" - Processor load and performance\n` +
552
- `- "Show me processor info" - CPU specifications\n\n` +
553
- `🧠 **Memory Information:**\n` +
554
- `- "How much RAM do I have?" - Memory specifications\n` +
555
- `- "Memory usage" - Current memory utilization\n\n` +
556
- `šŸ’¾ **Disk Information:**\n` +
557
- `- "How much disk space?" - Storage capacity and usage\n` +
558
- `- "Storage info" - Disk and filesystem details\n\n` +
559
- `🌐 **Network Information:**\n` +
560
- `- "What's my IP address?" - Network interface details\n` +
561
- `- "Network status" - Connection and interface info\n\n` +
562
- `āš™ļø **Process Information:**\n` +
563
- `- "What processes are running?" - Active processes and services\n` +
564
- `- "Process info" - System process details\n\n` +
565
- `šŸ”§ **Environment Variables:**\n` +
566
- `- "Show environment variables" - System configuration\n` +
567
- `- "User info" - User and shell information\n\n` +
568
- `šŸ“Š **Complete Information:**\n` +
569
- `- "Show me all system information" - Everything available\n` +
570
- `- "Complete system report" - Comprehensive overview\n\n` +
571
- `*System information as of 2025-07-09 10:45:40 UTC*\n` +
572
- `*User: m0v0dga_walmart*`;
539
+ `*Available system information queries:*\n\n` +
540
+ `šŸ“± **Basic System Info:**\n` +
541
+ `- "What's my system info?" - Platform, OS, architecture\n` +
542
+ `- "System overview" - Complete basic information\n\n` +
543
+ `šŸ’» **CPU Information:**\n` +
544
+ `- "What's my CPU usage?" - Processor load and performance\n` +
545
+ `- "Show me processor info" - CPU specifications\n\n` +
546
+ `🧠 **Memory Information:**\n` +
547
+ `- "How much RAM do I have?" - Memory specifications\n` +
548
+ `- "Memory usage" - Current memory utilization\n\n` +
549
+ `šŸ’¾ **Disk Information:**\n` +
550
+ `- "How much disk space?" - Storage capacity and usage\n` +
551
+ `- "Storage info" - Disk and filesystem details\n\n` +
552
+ `🌐 **Network Information:**\n` +
553
+ `- "What's my IP address?" - Network interface details\n` +
554
+ `- "Network status" - Connection and interface info\n\n` +
555
+ `āš™ļø **Process Information:**\n` +
556
+ `- "What processes are running?" - Active processes and services\n` +
557
+ `- "Process info" - System process details\n\n` +
558
+ `šŸ”§ **Environment Variables:**\n` +
559
+ `- "Show environment variables" - System configuration\n` +
560
+ `- "User info" - User and shell information\n\n` +
561
+ `šŸ“Š **Complete Information:**\n` +
562
+ `- "Show me all system information" - Everything available\n` +
563
+ `- "Complete system report" - Comprehensive overview\n\n` +
564
+ `*System information as of 2025-07-09 10:45:40 UTC*\n` +
565
+ `*User: m0v0dga_walmart*`;
573
566
  }
574
567
 
575
568
  async function processWithAI(prompt, context = '', mode = 2) {
576
569
  try {
577
-
570
+
578
571
  // Enhanced system query detection - but EXCLUDE file/folder analysis prompts
579
572
  const systemKeywords = [
580
- 'system', 'cpu', 'memory', 'ram', 'disk', 'network', 'ip', 'process',
573
+ 'system', 'cpu', 'memory', 'ram', 'disk', 'network', 'ip', 'process',
581
574
  'environment', 'hardware', 'computer', 'machine', 'specs', 'info',
582
575
  'information', 'status', 'usage', 'performance', 'storage', 'processor'
583
576
  ];
584
-
577
+
585
578
  // Check if this is a file/folder analysis (these should NOT trigger system info)
586
- const isFileAnalysis = prompt.includes('File:') ||
587
- prompt.includes('Analyze this') ||
588
- prompt.includes('code file') ||
589
- prompt.includes('Content:') ||
590
- prompt.includes('User Question:');
591
-
579
+ const isFileAnalysis = prompt.includes('File:') ||
580
+ prompt.includes('Analyze this') ||
581
+ prompt.includes('code file') ||
582
+ prompt.includes('Content:') ||
583
+ prompt.includes('User Question:');
584
+
592
585
  const isSystemQuery = !isFileAnalysis && (
593
- systemKeywords.some(keyword => prompt.toLowerCase().includes(keyword)) ||
586
+ systemKeywords.some(keyword => prompt.toLowerCase().includes(keyword)) ||
594
587
  prompt.toLowerCase().startsWith('get system information') ||
595
588
  prompt.toLowerCase().includes('/system')
596
589
  );
597
-
590
+
598
591
  if (isSystemQuery) {
599
592
  try {
600
-
593
+
601
594
  // First get basic system info to provide context
602
595
  const basicInfo = await getSystemInfo('basic');
603
-
596
+
604
597
  // Use AI to determine what system information is being requested
605
598
  const aiResponse = await determineSystemInfoQuery(prompt, basicInfo);
606
-
599
+
607
600
  // Get the specific system information based on AI's determination
608
601
  const systemInfo = await getSystemInfo(aiResponse.query);
609
-
602
+
610
603
  // Format the response using AI
611
604
  const formattedResponse = await formatSystemInfoResponse(systemInfo, prompt);
612
-
605
+
613
606
  return formattedResponse;
614
607
  } catch (sysError) {
615
608
  console.error(`[${new Date().toISOString()}] āŒ System info error:`, sysError.message);
@@ -617,61 +610,35 @@ async function processWithAI(prompt, context = '', mode = 2) {
617
610
  return `I encountered an error retrieving system information: ${sysError.message}\n\nPlease try a more specific query or check the system status.`;
618
611
  }
619
612
  }
620
-
613
+
621
614
  // Regular AI processing for non-system queries
622
- const models = getTextModels(mode); // Use selected mode
623
-
624
- const modelRequests = models.map(async (model) => {
625
- try {
626
- const response = await fetch('https://traceai.dukeindustries7.workers.dev/', {
627
- method: 'POST',
628
- headers: { 'Content-Type': 'application/json' },
629
- body: encryptData({
630
- a: model,
631
- q: prompt,
632
- r: [],
633
- i: [],
634
- c: context
635
- })
636
- });
637
-
638
- const text = await response.text();
639
- return decryptData(text);
640
- } catch (error) {
641
- return { text: null };
642
- }
643
- });
615
+ const selectedMode = getMode(mode); // Use selected mode
616
+
617
+ try {
618
+ const response = await fetch('https://traceai.dukeindustries7.workers.dev/', {
619
+ method: 'POST',
620
+ headers: { 'Content-Type': 'application/json' },
621
+ body: encryptData({
622
+ a: selectedMode,
623
+ q: prompt,
624
+ i: [],
625
+ c: context
626
+ })
627
+ });
644
628
 
645
- const responses = await Promise.all(modelRequests);
646
- const responseTexts = responses
647
- .filter(r => r && r.text && typeof r.text === 'string')
648
- .map(r => r.text);
629
+ const text = await response.text();
630
+ const result = decryptData(text);
649
631
 
650
- if (responseTexts.length === 0) {
632
+ // The worker now handles orchestration internally
633
+ // It runs multiple models and synthesizes the response
634
+ if (result && result.text && typeof result.text === 'string') {
635
+ return result.text;
636
+ } else {
637
+ return 'I apologize, but I was unable to process your request at this time. Please try again.';
638
+ }
639
+ } catch (error) {
651
640
  return 'I apologize, but I was unable to process your request at this time. Please try again.';
652
641
  }
653
-
654
- // Fast mode: return the first model response without aggregation
655
- if (Number(mode) === 1) {
656
- return responseTexts[0];
657
- }
658
-
659
- const finalResponse = await fetch('https://traceai.dukeindustries7.workers.dev/', {
660
- method: 'POST',
661
- headers: { 'Content-Type': 'application/json' },
662
- body: encryptData({
663
- a: 'gfinal',
664
- q: prompt,
665
- r: responseTexts,
666
- i: [],
667
- c: context
668
- })
669
- });
670
-
671
- const encryptedResult = await finalResponse.text();
672
- const decryptedResult = decryptData(encryptedResult);
673
-
674
- return decryptedResult.text || 'No response generated';
675
642
  } catch (error) {
676
643
  console.error(`[${new Date().toISOString()}] āŒ Processing error:`, error.message);
677
644
  throw error;