nyxora 1.0.2 → 1.0.3

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.
Files changed (63) hide show
  1. package/package.json +1 -1
  2. package/dashboard/public/favicon.svg +0 -1
  3. package/dashboard/public/icons.svg +0 -24
  4. package/dashboard/src/App.css +0 -184
  5. package/dashboard/src/App.tsx +0 -485
  6. package/dashboard/src/BalanceWidget.tsx +0 -65
  7. package/dashboard/src/MarketWidget.tsx +0 -73
  8. package/dashboard/src/Memory.tsx +0 -109
  9. package/dashboard/src/Overview.tsx +0 -156
  10. package/dashboard/src/Settings.tsx +0 -213
  11. package/dashboard/src/Skills.tsx +0 -97
  12. package/dashboard/src/SwapWidget.tsx +0 -130
  13. package/dashboard/src/TransactionWidget.tsx +0 -86
  14. package/dashboard/src/assets/hero.png +0 -0
  15. package/dashboard/src/assets/react.svg +0 -1
  16. package/dashboard/src/assets/vite.svg +0 -1
  17. package/dashboard/src/index.css +0 -508
  18. package/dashboard/src/main.tsx +0 -10
  19. package/dashboard/src/overview.css +0 -304
  20. package/dist/src/agent/reasoning.js +0 -96
  21. package/dist/src/config/parser.js +0 -25
  22. package/dist/src/gateway/cli.js +0 -79
  23. package/dist/src/memory/logger.js +0 -50
  24. package/dist/src/web3/config.js +0 -80
  25. package/dist/src/web3/skills/getBalance.js +0 -43
  26. package/src/agent/reasoning.d.ts +0 -2
  27. package/src/agent/reasoning.d.ts.map +0 -1
  28. package/src/agent/reasoning.js +0 -97
  29. package/src/agent/reasoning.js.map +0 -1
  30. package/src/agent/reasoning.ts +0 -232
  31. package/src/config/parser.d.ts +0 -17
  32. package/src/config/parser.d.ts.map +0 -1
  33. package/src/config/parser.js +0 -26
  34. package/src/config/parser.js.map +0 -1
  35. package/src/config/parser.ts +0 -47
  36. package/src/config/paths.ts +0 -33
  37. package/src/gateway/cli.d.ts +0 -3
  38. package/src/gateway/cli.d.ts.map +0 -1
  39. package/src/gateway/cli.js +0 -80
  40. package/src/gateway/cli.js.map +0 -1
  41. package/src/gateway/cli.ts +0 -69
  42. package/src/gateway/server.ts +0 -135
  43. package/src/gateway/telegram.ts +0 -47
  44. package/src/gateway/test.ts +0 -16
  45. package/src/gateway/tracker.ts +0 -70
  46. package/src/memory/logger.d.ts +0 -18
  47. package/src/memory/logger.d.ts.map +0 -1
  48. package/src/memory/logger.js +0 -51
  49. package/src/memory/logger.js.map +0 -1
  50. package/src/memory/logger.ts +0 -57
  51. package/src/web3/config.d.ts +0 -793
  52. package/src/web3/config.d.ts.map +0 -1
  53. package/src/web3/config.js +0 -81
  54. package/src/web3/config.js.map +0 -1
  55. package/src/web3/config.ts +0 -51
  56. package/src/web3/skills/getBalance.d.ts +0 -25
  57. package/src/web3/skills/getBalance.d.ts.map +0 -1
  58. package/src/web3/skills/getBalance.js +0 -46
  59. package/src/web3/skills/getBalance.js.map +0 -1
  60. package/src/web3/skills/getBalance.ts +0 -48
  61. package/src/web3/skills/getPrice.ts +0 -43
  62. package/src/web3/skills/swapToken.ts +0 -69
  63. package/src/web3/skills/transfer.ts +0 -47
@@ -1,135 +0,0 @@
1
- import express from 'express';
2
- import cors from 'cors';
3
- import path from 'path';
4
- import * as dotenv from 'dotenv';
5
- import { getPath } from '../config/paths';
6
-
7
- dotenv.config({ path: getPath('.env') });
8
-
9
- import { processUserInput, logger } from '../agent/reasoning';
10
- import { loadConfig, saveConfig } from '../config/parser';
11
- import { Tracker } from './tracker';
12
- import { getBalanceToolDefinition } from '../web3/skills/getBalance';
13
- import { transferToolDefinition } from '../web3/skills/transfer';
14
- import { getPriceToolDefinition } from '../web3/skills/getPrice';
15
- import { swapTokenToolDefinition } from '../web3/skills/swapToken';
16
- import { startTelegramBot } from './telegram';
17
-
18
- // Intercept console.log and console.error
19
- const originalLog = console.log;
20
- const originalError = console.error;
21
-
22
- console.log = function (...args) {
23
- Tracker.addGatewayLog(args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' '));
24
- originalLog.apply(console, args);
25
- };
26
-
27
- console.error = function (...args) {
28
- Tracker.addGatewayLog(args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(' '), { level: 'error' });
29
- originalError.apply(console, args);
30
- };
31
-
32
- const app = express();
33
- app.use(cors());
34
- app.use(express.json());
35
-
36
- // Serve static frontend from dashboard/dist
37
- app.use(express.static(path.join(__dirname, '../../dashboard/dist')));
38
-
39
- app.get('/api/history', (req, res) => {
40
- try {
41
- const history = logger.getHistory();
42
- // Filter out internal system prompt for the frontend
43
- const cleanHistory = history.filter((msg: any) => msg.role !== 'system');
44
- res.json(cleanHistory);
45
- } catch (error: any) {
46
- res.status(500).json({ error: error.message });
47
- }
48
- });
49
-
50
- app.delete('/api/history', (req, res) => {
51
- try {
52
- logger.clear();
53
- Tracker.addEvent('memory.cleared');
54
- res.json({ success: true });
55
- } catch (error: any) {
56
- res.status(500).json({ error: error.message });
57
- }
58
- });
59
-
60
- app.get('/api/config', (req, res) => {
61
- try {
62
- const config = loadConfig();
63
- res.json(config);
64
- } catch (error: any) {
65
- res.status(500).json({ error: error.message });
66
- }
67
- });
68
-
69
- app.post('/api/config', (req, res) => {
70
- try {
71
- // Save new configuration to file
72
- saveConfig(req.body);
73
- Tracker.addEvent('config.updated', { provider: req.body.llm?.provider });
74
- res.json({ success: true });
75
- } catch (error: any) {
76
- res.status(500).json({ error: error.message });
77
- }
78
- });
79
-
80
- app.get('/api/stats', (req, res) => {
81
- res.json(Tracker.getStats());
82
- });
83
-
84
- app.get('/api/logs', (req, res) => {
85
- res.json(Tracker.getLogs());
86
- });
87
-
88
- app.get('/api/skills', (req, res) => {
89
- res.json([
90
- getBalanceToolDefinition,
91
- transferToolDefinition,
92
- getPriceToolDefinition,
93
- swapTokenToolDefinition
94
- ]);
95
- });
96
-
97
- app.post('/api/chat', async (req, res) => {
98
- try {
99
- const { message } = req.body;
100
- if (!message) {
101
- return res.status(400).json({ error: 'Message is required' });
102
- }
103
-
104
- // Process input (this will automatically add to memory)
105
- const response = await processUserInput(message);
106
-
107
- res.json({ response });
108
- } catch (error: any) {
109
- res.status(500).json({ error: error.message });
110
- }
111
- });
112
-
113
- // Fallback for React Router (Single Page Application)
114
- app.use((req, res, next) => {
115
- if (req.method === 'GET' && !req.path.startsWith('/api')) {
116
- res.sendFile(path.join(__dirname, '../../dashboard/dist/index.html'));
117
- } else {
118
- next();
119
- }
120
- });
121
-
122
- export function startServer() {
123
- const PORT = process.env.PORT || 3000;
124
- app.listen(PORT, () => {
125
- console.log(`🤖 Nyxora API Server running on port ${PORT}`);
126
-
127
- // Start the Telegram bot listener
128
- startTelegramBot();
129
- });
130
- }
131
-
132
- // Start server if this file is run directly
133
- if (require.main === module) {
134
- startServer();
135
- }
@@ -1,47 +0,0 @@
1
- import TelegramBot from 'node-telegram-bot-api';
2
- import { processUserInput } from '../agent/reasoning';
3
-
4
- export function startTelegramBot() {
5
- const token = process.env.TELEGRAM_BOT_TOKEN;
6
-
7
- if (!token) {
8
- console.log('[Telegram] No TELEGRAM_BOT_TOKEN found in .env. Bot is disabled.');
9
- return;
10
- }
11
-
12
- try {
13
- const bot = new TelegramBot(token, { polling: true });
14
-
15
- bot.on('message', async (msg) => {
16
- const chatId = msg.chat.id;
17
- const text = msg.text;
18
-
19
- if (!text) return;
20
-
21
- // Log incoming message
22
- console.log(`[Telegram] Received from ${msg.from?.first_name}: ${text}`);
23
-
24
- // Send typing action to Telegram
25
- bot.sendChatAction(chatId, 'typing');
26
-
27
- try {
28
- // Feed the message to the AI agent
29
- const response = await processUserInput(text);
30
-
31
- // Send the AI's response back to Telegram
32
- bot.sendMessage(chatId, response);
33
- } catch (error: any) {
34
- console.error('[Telegram] Error processing message:', error);
35
- bot.sendMessage(chatId, '❌ Maaf, saya mengalami gangguan saat memproses pesan Anda.');
36
- }
37
- });
38
-
39
- bot.on('polling_error', (error) => {
40
- console.error('[Telegram] Polling error:', error);
41
- });
42
-
43
- console.log('🤖 Telegram Bot is running and listening for messages...');
44
- } catch (error) {
45
- console.error('[Telegram] Failed to initialize bot:', error);
46
- }
47
- }
@@ -1,16 +0,0 @@
1
- import { processUserInput } from '../agent/reasoning';
2
- import * as dotenv from 'dotenv';
3
- dotenv.config();
4
-
5
- async function run() {
6
- console.log('🤖 Agent Test Started...');
7
- console.log('👤 You: Tolong cek saldo native di jaringan ethereum');
8
- try {
9
- const response = await processUserInput('Tolong cek saldo native di jaringan ethereum');
10
- console.log(`\n🤖 Nyxora Agent: ${response}\n`);
11
- } catch (err: any) {
12
- console.error(`Error: ${err.message}`);
13
- }
14
- }
15
-
16
- run();
@@ -1,70 +0,0 @@
1
- interface Stats {
2
- cost: number;
3
- tokens: number;
4
- messages: number;
5
- }
6
-
7
- interface EventLog {
8
- timestamp: string;
9
- event: string;
10
- meta: any;
11
- }
12
-
13
- interface GatewayLog {
14
- timestamp: string;
15
- message: string;
16
- meta?: any;
17
- }
18
-
19
- const stats: Stats = {
20
- cost: 0,
21
- tokens: 0,
22
- messages: 0
23
- };
24
-
25
- const eventLogs: EventLog[] = [];
26
- const gatewayLogs: GatewayLog[] = [];
27
- const MAX_LOGS = 100;
28
-
29
- function formatTime(): string {
30
- const now = new Date();
31
- return now.toTimeString().split(' ')[0]; // Returns HH:MM:SS
32
- }
33
-
34
- export const Tracker = {
35
- addTokens: (amount: number, provider: string) => {
36
- stats.tokens += amount;
37
-
38
- // Simple mock cost calculation
39
- let rate = 0;
40
- if (provider === 'openai') rate = 0.00002;
41
- else if (provider === 'gemini') rate = 0.00001;
42
-
43
- stats.cost += (amount * rate);
44
- },
45
-
46
- addMessage: () => {
47
- stats.messages += 1;
48
- },
49
-
50
- getStats: () => {
51
- return { ...stats, cost: Number(stats.cost.toFixed(4)) };
52
- },
53
-
54
- addEvent: (event: string, meta: any = {}) => {
55
- eventLogs.unshift({ timestamp: formatTime(), event, meta });
56
- if (eventLogs.length > MAX_LOGS) eventLogs.pop();
57
- },
58
-
59
- addGatewayLog: (message: string, meta?: any) => {
60
- gatewayLogs.unshift({ timestamp: formatTime(), message, meta });
61
- if (gatewayLogs.length > MAX_LOGS) gatewayLogs.pop();
62
- },
63
-
64
- getLogs: () => {
65
- return {
66
- events: eventLogs,
67
- gateway: gatewayLogs
68
- };
69
- }
70
- };
@@ -1,18 +0,0 @@
1
- export interface MemoryEntry {
2
- role: 'user' | 'assistant' | 'system' | 'tool';
3
- content: string;
4
- name?: string;
5
- tool_call_id?: string;
6
- tool_calls?: any[];
7
- }
8
- export declare class Logger {
9
- private logFilePath;
10
- private memory;
11
- constructor();
12
- private loadMemory;
13
- private saveMemory;
14
- getHistory(): MemoryEntry[];
15
- addEntry(entry: MemoryEntry): void;
16
- clear(): void;
17
- }
18
- //# sourceMappingURL=logger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["logger.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;CACpB;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,MAAM,CAAqB;;IAQnC,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,UAAU;IAQX,UAAU,IAAI,WAAW,EAAE;IAI3B,QAAQ,CAAC,KAAK,EAAE,WAAW;IAK3B,KAAK;CAIb"}
@@ -1,51 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Logger = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const parser_1 = require("../config/parser");
10
- class Logger {
11
- logFilePath;
12
- memory = [];
13
- constructor() {
14
- const config = (0, parser_1.loadConfig)();
15
- this.logFilePath = path_1.default.resolve(process.cwd(), config.memory.path || 'memory.json');
16
- this.loadMemory();
17
- }
18
- loadMemory() {
19
- if (fs_1.default.existsSync(this.logFilePath)) {
20
- try {
21
- const data = fs_1.default.readFileSync(this.logFilePath, 'utf-8');
22
- this.memory = JSON.parse(data);
23
- }
24
- catch (error) {
25
- console.error('Failed to read memory file. Starting fresh.');
26
- this.memory = [];
27
- }
28
- }
29
- }
30
- saveMemory() {
31
- try {
32
- fs_1.default.writeFileSync(this.logFilePath, JSON.stringify(this.memory, null, 2));
33
- }
34
- catch (error) {
35
- console.error('Failed to write memory file.');
36
- }
37
- }
38
- getHistory() {
39
- return [...this.memory];
40
- }
41
- addEntry(entry) {
42
- this.memory.push(entry);
43
- this.saveMemory();
44
- }
45
- clear() {
46
- this.memory = [];
47
- this.saveMemory();
48
- }
49
- }
50
- exports.Logger = Logger;
51
- //# sourceMappingURL=logger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["logger.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,6CAA8C;AAU9C,MAAa,MAAM;IACT,WAAW,CAAS;IACpB,MAAM,GAAkB,EAAE,CAAC;IAEnC;QACE,MAAM,MAAM,GAAG,IAAA,mBAAU,GAAE,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,aAAa,CAAC,CAAC;QACpF,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAEO,UAAU;QAChB,IAAI,YAAE,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YACpC,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,YAAE,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;gBACxD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACjC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAC;gBAC7D,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;YACnB,CAAC;QACH,CAAC;IACH,CAAC;IAEO,UAAU;QAChB,IAAI,CAAC;YACH,YAAE,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAEM,UAAU;QACf,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAEM,QAAQ,CAAC,KAAkB;QAChC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;CACF;AA3CD,wBA2CC"}
@@ -1,57 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import { loadConfig } from '../config/parser';
4
- import { getPath } from '../config/paths';
5
-
6
- export interface MemoryEntry {
7
- role: 'user' | 'assistant' | 'system' | 'tool';
8
- content: string;
9
- name?: string;
10
- tool_call_id?: string;
11
- tool_calls?: any[];
12
- }
13
-
14
- export class Logger {
15
- private logFilePath: string;
16
- private memory: MemoryEntry[] = [];
17
-
18
- constructor() {
19
- const config = loadConfig();
20
- this.logFilePath = getPath(config.memory.path || 'memory.json');
21
- this.loadMemory();
22
- }
23
-
24
- private loadMemory() {
25
- if (fs.existsSync(this.logFilePath)) {
26
- try {
27
- const data = fs.readFileSync(this.logFilePath, 'utf-8');
28
- this.memory = JSON.parse(data);
29
- } catch (error) {
30
- console.error('Failed to read memory file. Starting fresh.');
31
- this.memory = [];
32
- }
33
- }
34
- }
35
-
36
- private saveMemory() {
37
- try {
38
- fs.writeFileSync(this.logFilePath, JSON.stringify(this.memory, null, 2));
39
- } catch (error) {
40
- console.error('Failed to write memory file.');
41
- }
42
- }
43
-
44
- public getHistory(): MemoryEntry[] {
45
- return [...this.memory];
46
- }
47
-
48
- public addEntry(entry: MemoryEntry) {
49
- this.memory.push(entry);
50
- this.saveMemory();
51
- }
52
-
53
- public clear() {
54
- this.memory = [];
55
- this.saveMemory();
56
- }
57
- }