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,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.processUserInput = processUserInput;
4
- const openai_1 = require("openai");
5
- const parser_1 = require("../config/parser");
6
- const logger_1 = require("../memory/logger");
7
- const getBalance_1 = require("../web3/skills/getBalance");
8
- const config = (0, parser_1.loadConfig)();
9
- const logger = new logger_1.Logger();
10
- // Initialize OpenAI client
11
- const openai = new openai_1.OpenAI({
12
- apiKey: process.env.OPENAI_API_KEY,
13
- });
14
- const systemPrompt = `You are an autonomous Web3 agent operating on EVM chains.
15
- Your wallet address is available via the tools.
16
- Always use the tools to interact with the blockchain.
17
- If the user doesn't specify a chain, default to: ${config.agent.default_chain}.`;
18
- async function processUserInput(input) {
19
- // Add user input to memory
20
- logger.addEntry({ role: 'user', content: input });
21
- const history = logger.getHistory();
22
- // Format messages for OpenAI
23
- const messages = [
24
- { role: 'system', content: systemPrompt },
25
- ...history.map(m => {
26
- const msg = { role: m.role, content: m.content || "" };
27
- if (m.name)
28
- msg.name = m.name;
29
- if (m.tool_call_id)
30
- msg.tool_call_id = m.tool_call_id;
31
- if (m.tool_calls)
32
- msg.tool_calls = m.tool_calls;
33
- return msg;
34
- })
35
- ];
36
- try {
37
- if (config.llm.provider !== 'openai') {
38
- return `Provider ${config.llm.provider} is configured, but currently only OpenAI adapter is fully implemented in this demo.`;
39
- }
40
- const response = await openai.chat.completions.create({
41
- model: config.llm.model,
42
- temperature: config.llm.temperature,
43
- messages: messages,
44
- tools: [getBalance_1.getBalanceToolDefinition],
45
- tool_choice: "auto",
46
- });
47
- const responseMessage = response.choices[0].message;
48
- // Log assistant response
49
- logger.addEntry({
50
- role: 'assistant',
51
- content: responseMessage.content || "",
52
- tool_calls: responseMessage.tool_calls,
53
- });
54
- // Check if the model wants to call a tool
55
- if (responseMessage.tool_calls && responseMessage.tool_calls.length > 0) {
56
- for (const toolCall of responseMessage.tool_calls) {
57
- if (toolCall.function.name === 'get_balance') {
58
- const args = JSON.parse(toolCall.function.arguments);
59
- const balanceResult = await (0, getBalance_1.getBalance)(args.chainName, args.address);
60
- logger.addEntry({
61
- role: 'tool',
62
- tool_call_id: toolCall.id,
63
- name: toolCall.function.name,
64
- content: balanceResult,
65
- });
66
- }
67
- }
68
- // Second call to get the final answer after tool execution
69
- const secondMessages = [
70
- { role: 'system', content: systemPrompt },
71
- ...logger.getHistory().map(m => {
72
- const msg = { role: m.role, content: m.content || "" };
73
- if (m.name)
74
- msg.name = m.name;
75
- if (m.tool_call_id)
76
- msg.tool_call_id = m.tool_call_id;
77
- if (m.tool_calls)
78
- msg.tool_calls = m.tool_calls;
79
- return msg;
80
- })
81
- ];
82
- const secondResponse = await openai.chat.completions.create({
83
- model: config.llm.model,
84
- messages: secondMessages,
85
- });
86
- const finalContent = secondResponse.choices[0].message.content || "";
87
- logger.addEntry({ role: 'assistant', content: finalContent });
88
- return finalContent;
89
- }
90
- return responseMessage.content || "No response generated.";
91
- }
92
- catch (error) {
93
- console.error("LLM Error:", error);
94
- return `Error connecting to AI Provider: ${error.message}`;
95
- }
96
- }
97
- //# sourceMappingURL=reasoning.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reasoning.js","sourceRoot":"","sources":["reasoning.ts"],"names":[],"mappings":";;AAkBA,4CAmFC;AArGD,mCAAgC;AAChC,6CAA8C;AAC9C,6CAA0C;AAC1C,0DAAiF;AAEjF,MAAM,MAAM,GAAG,IAAA,mBAAU,GAAE,CAAC;AAC5B,MAAM,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;AAE5B,2BAA2B;AAC3B,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;CACnC,CAAC,CAAC;AAEH,MAAM,YAAY,GAAG;;;mDAG8B,MAAM,CAAC,KAAK,CAAC,aAAa,GAAG,CAAC;AAE1E,KAAK,UAAU,gBAAgB,CAAC,KAAa;IAClD,2BAA2B;IAC3B,MAAM,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAElD,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;IAEpC,6BAA6B;IAC7B,MAAM,QAAQ,GAAU;QACtB,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE;QACzC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YACjB,MAAM,GAAG,GAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;YAC5D,IAAI,CAAC,CAAC,IAAI;gBAAE,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;YAC9B,IAAI,CAAC,CAAC,YAAY;gBAAE,GAAG,CAAC,YAAY,GAAG,C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,EAAE,YAAY,EAAE,CAAC,CAAC;YAC9D,OAAO,YAAY,CAAC;QACtB,CAAC;QAED,OAAO,eAAe,CAAC,OAAO,IAAI,wBAAwB,CAAC;IAC7D,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QACnC,OAAO,oCAAoC,KAAK,CAAC,OAAO,EAAE,CAAC;IAC7D,CAAC;AACH,CAAC"}
@@ -1,232 +0,0 @@
1
- import * as dotenv from 'dotenv';
2
- dotenv.config();
3
-
4
- import fs from 'fs';
5
- import path from 'path';
6
- import { OpenAI } from 'openai';
7
- import { loadConfig } from '../config/parser';
8
- import { Logger } from '../memory/logger';
9
- import { Tracker } from '../gateway/tracker';
10
- import { getBalanceToolDefinition, getBalance } from '../web3/skills/getBalance';
11
- import { transferToolDefinition, transferNative } from '../web3/skills/transfer';
12
- import { getPriceToolDefinition, getPrice } from '../web3/skills/getPrice';
13
- import { swapTokenToolDefinition, swapToken } from '../web3/skills/swapToken';
14
- import { getPath } from '../config/paths';
15
-
16
- export const logger = new Logger();
17
-
18
- let currentKeyIndex = 0;
19
-
20
- function getOpenAI(): OpenAI {
21
- const config = loadConfig();
22
-
23
- if (config.llm.provider === 'ollama') {
24
- return new OpenAI({
25
- baseURL: process.env.OLLAMA_BASE_URL ? `${process.env.OLLAMA_BASE_URL}/v1` : 'http://localhost:11434/v1',
26
- apiKey: 'ollama', // API key is not required for local Ollama
27
- });
28
- }
29
-
30
- // Get API key from config (UI) or fallback to .env
31
- let apiKey = '';
32
-
33
- if (config.llm.api_keys && config.llm.api_keys.length > 0) {
34
- // Filter out empty keys
35
- const keys = config.llm.api_keys.filter(k => k.trim() !== '');
36
- if (keys.length > 0) {
37
- currentKeyIndex = currentKeyIndex % keys.length;
38
- apiKey = keys[currentKeyIndex];
39
- console.log(`[LLM] Using rotated API Key (${currentKeyIndex + 1}/${keys.length}): ${apiKey.substring(0, 4)}...`);
40
- currentKeyIndex++; // Increment for next request
41
- }
42
- }
43
-
44
- // Fallbacks if no valid keys found in config
45
- if (!apiKey) {
46
- if (config.llm.provider === 'gemini') {
47
- apiKey = process.env.GEMINI_API_KEY || '';
48
- } else {
49
- apiKey = process.env.OPENAI_API_KEY || '';
50
- }
51
- if (!apiKey) {
52
- throw new Error(`No API Key found for ${config.llm.provider} in config or .env`);
53
- }
54
- console.log(`[LLM] Using default API Key from .env`);
55
- }
56
-
57
- if (config.llm.provider === 'gemini') {
58
- return new OpenAI({
59
- baseURL: 'https://generativelanguage.googleapis.com/v1beta/openai/',
60
- apiKey: apiKey,
61
- });
62
- } else {
63
- return new OpenAI({
64
- apiKey: apiKey,
65
- });
66
- }
67
- }
68
-
69
- function getSystemPrompt() {
70
- const config = loadConfig();
71
- let basePrompt = `You are an autonomous Web3 agent operating on EVM chains.
72
- You are equipped with a native wallet.
73
- CRITICAL RULE: You must always reply in the exact same language that the user uses to talk to you. If the user speaks Indonesian, reply in Indonesian. If they speak English, reply in English.
74
- CRITICAL RULE: If the user asks to check "my balance", "saldo saya", or anything about their own wallet, DO NOT ask them for an address. You must immediately call the get_balance tool and LEAVE THE ADDRESS PARAMETER EMPTY. The system will automatically use the injected private key wallet.
75
- Always use the tools to interact with the blockchain.
76
- If the user doesn't specify a chain, default to: ${config.agent.default_chain}.`;
77
-
78
- // Read IDENTITY.md for core AI persona
79
- try {
80
- const identityMdPath = getPath('IDENTITY.md');
81
- if (fs.existsSync(identityMdPath)) {
82
- const identityInstructions = fs.readFileSync(identityMdPath, 'utf8');
83
- basePrompt += `\n\n--- CORE IDENTITY & PERSONA ---\n${identityInstructions}`;
84
- }
85
- } catch (error) {
86
- console.error('Failed to read IDENTITY.md:', error);
87
- }
88
-
89
- // Read user.md for custom instructions
90
- try {
91
- const userMdPath = getPath('user.md');
92
- if (fs.existsSync(userMdPath)) {
93
- const customInstructions = fs.readFileSync(userMdPath, 'utf8');
94
- basePrompt += `\n\n--- CUSTOM USER INSTRUCTIONS ---\n${customInstructions}`;
95
- }
96
- } catch (error) {
97
- console.error('Failed to read user.md:', error);
98
- }
99
-
100
- return basePrompt;
101
- }
102
-
103
- export async function processUserInput(input: string): Promise<string> {
104
- const config = loadConfig();
105
- // Add user input to memory
106
- logger.addEntry({ role: 'user', content: input });
107
-
108
- const history = logger.getHistory();
109
-
110
- // Format messages for OpenAI
111
- const messages: any[] = [
112
- { role: 'system', content: getSystemPrompt() },
113
- ...history.map(m => {
114
- const msg: any = { role: m.role, content: m.content || "" };
115
- if (m.name) msg.name = m.name;
116
- if (m.tool_call_id) msg.tool_call_id = m.tool_call_id;
117
- if (m.tool_calls) msg.tool_calls = m.tool_calls;
118
- return msg;
119
- })
120
- ];
121
-
122
- try {
123
- if (config.llm.provider !== 'openai' && config.llm.provider !== 'ollama' && config.llm.provider !== 'gemini') {
124
- return `Provider ${config.llm.provider} is configured, but currently only OpenAI, Ollama, and Gemini adapters are implemented.`;
125
- }
126
-
127
- const openai = getOpenAI();
128
- const response = await openai.chat.completions.create({
129
- model: config.llm.model,
130
- temperature: config.llm.temperature,
131
- messages: messages,
132
- tools: [getBalanceToolDefinition as any, transferToolDefinition as any, getPriceToolDefinition as any, swapTokenToolDefinition as any],
133
- tool_choice: "auto",
134
- });
135
-
136
- const responseMessage = response.choices[0].message;
137
-
138
- // Log tracking
139
- Tracker.addMessage();
140
- if (response.usage?.total_tokens) {
141
- Tracker.addTokens(response.usage.total_tokens, config.llm.provider);
142
- }
143
- Tracker.addEvent('llm.response', { provider: config.llm.provider, tool_calls: responseMessage.tool_calls?.length || 0 });
144
-
145
- // Log assistant response
146
- logger.addEntry({
147
- role: 'assistant',
148
- content: responseMessage.content || "",
149
- tool_calls: responseMessage.tool_calls,
150
- });
151
-
152
- // Check if the model wants to call a tool
153
- if (responseMessage.tool_calls && responseMessage.tool_calls.length > 0) {
154
- for (const _toolCall of responseMessage.tool_calls) {
155
- const toolCall = _toolCall as any;
156
- if (toolCall.function.name === 'get_balance') {
157
- const args = JSON.parse(toolCall.function.arguments);
158
- const balanceResult = await getBalance(args.chainName, args.address);
159
-
160
- logger.addEntry({
161
- role: 'tool',
162
- tool_call_id: toolCall.id,
163
- name: toolCall.function.name,
164
- content: balanceResult,
165
- });
166
- } else if (toolCall.function.name === 'transfer_native') {
167
- const args = JSON.parse(toolCall.function.arguments);
168
- const transferResult = await transferNative(args.chainName, args.toAddress, args.amountEth);
169
-
170
- logger.addEntry({
171
- role: 'tool',
172
- tool_call_id: toolCall.id,
173
- name: toolCall.function.name,
174
- content: transferResult,
175
- });
176
- } else if (toolCall.function.name === 'get_price') {
177
- const args = JSON.parse(toolCall.function.arguments);
178
- const priceResult = await getPrice(args.coinId);
179
-
180
- logger.addEntry({
181
- role: 'tool',
182
- tool_call_id: toolCall.id,
183
- name: toolCall.function.name,
184
- content: priceResult,
185
- });
186
- } else if (toolCall.function.name === 'swap_token') {
187
- const args = JSON.parse(toolCall.function.arguments);
188
- const swapResult = await swapToken(args.chainName, args.fromToken, args.toToken, args.amount);
189
-
190
- logger.addEntry({
191
- role: 'tool',
192
- tool_call_id: toolCall.id,
193
- name: toolCall.function.name,
194
- content: swapResult,
195
- });
196
- }
197
- }
198
-
199
- // Second call to get the final answer after tool execution
200
- const secondMessages = [
201
- { role: 'system', content: getSystemPrompt() },
202
- ...logger.getHistory().map(m => {
203
- const msg: any = { role: m.role, content: m.content || "" };
204
- if (m.name) msg.name = m.name;
205
- if (m.tool_call_id) msg.tool_call_id = m.tool_call_id;
206
- if (m.tool_calls) msg.tool_calls = m.tool_calls;
207
- return msg;
208
- })
209
- ];
210
-
211
- const openai = getOpenAI();
212
- const secondResponse = await openai.chat.completions.create({
213
- model: config.llm.model,
214
- messages: secondMessages,
215
- });
216
-
217
- if (secondResponse.usage?.total_tokens) {
218
- Tracker.addTokens(secondResponse.usage.total_tokens, config.llm.provider);
219
- }
220
- Tracker.addEvent('llm.final_response', { provider: config.llm.provider });
221
-
222
- const finalContent = secondResponse.choices[0].message.content || "";
223
- logger.addEntry({ role: 'assistant', content: finalContent });
224
- return finalContent;
225
- }
226
-
227
- return responseMessage.content || "No response generated.";
228
- } catch (error: any) {
229
- console.error("LLM Error:", error);
230
- return `Error connecting to AI Provider: ${error.message}`;
231
- }
232
- }
@@ -1,17 +0,0 @@
1
- export interface OpenWebConfig {
2
- agent: {
3
- name: string;
4
- default_chain: string;
5
- };
6
- llm: {
7
- provider: 'openai' | 'anthropic' | 'ollama';
8
- model: string;
9
- temperature: number;
10
- };
11
- memory: {
12
- type: string;
13
- path: string;
14
- };
15
- }
16
- export declare function loadConfig(): OpenWebConfig;
17
- //# sourceMappingURL=parser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["parser.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,GAAG,EAAE;QACH,QAAQ,EAAE,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC;QAC5C,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,wBAAgB,UAAU,IAAI,aAAa,CAc1C"}
@@ -1,26 +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.loadConfig = loadConfig;
7
- const fs_1 = __importDefault(require("fs"));
8
- const yaml_1 = __importDefault(require("yaml"));
9
- const path_1 = __importDefault(require("path"));
10
- function loadConfig() {
11
- const configPath = path_1.default.resolve(process.cwd(), 'config.yaml');
12
- try {
13
- const file = fs_1.default.readFileSync(configPath, 'utf8');
14
- const parsed = yaml_1.default.parse(file);
15
- return parsed;
16
- }
17
- catch (error) {
18
- console.error('Failed to load config.yaml. Using default configuration.', error);
19
- return {
20
- agent: { name: 'OpenWeb-Default', default_chain: 'base' },
21
- llm: { provider: 'openai', model: 'gpt-4o-mini', temperature: 0.2 },
22
- memory: { type: 'file', path: './memory.json' }
23
- };
24
- }
25
- }
26
- //# sourceMappingURL=parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parser.js","sourceRoot":"","sources":["parser.ts"],"names":[],"mappings":";;;;;AAoBA,gCAcC;AAlCD,4CAAoB;AACpB,gDAAwB;AACxB,gDAAwB;AAkBxB,SAAgB,UAAU;IACxB,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC;IAC9D,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,YAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACjD,MAAM,MAAM,GAAG,cAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChC,OAAO,MAAuB,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,0DAA0D,EAAE,KAAK,CAAC,CAAC;QACjF,OAAO;YACL,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,EAAE;YACzD,GAAG,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,EAAE;YACnE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE;SAChD,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -1,47 +0,0 @@
1
- import fs from 'fs';
2
- import yaml from 'yaml';
3
- import path from 'path';
4
- import { getPath } from './paths';
5
-
6
- export interface NyxoraConfig {
7
- agent: {
8
- name: string;
9
- default_chain: string;
10
- };
11
- llm: {
12
- provider: 'openai' | 'anthropic' | 'ollama' | 'gemini';
13
- model: string;
14
- temperature: number;
15
- api_keys?: string[];
16
- };
17
- memory: {
18
- type: string;
19
- path: string;
20
- };
21
- }
22
-
23
- export function loadConfig(): NyxoraConfig {
24
- const configPath = getPath('config.yaml');
25
- try {
26
- const file = fs.readFileSync(configPath, 'utf8');
27
- const parsed = yaml.parse(file);
28
- return parsed as NyxoraConfig;
29
- } catch (error) {
30
- console.error('Failed to load config.yaml. Using default configuration.', error);
31
- return {
32
- agent: { name: 'Nyxora-Default', default_chain: 'base' },
33
- llm: { provider: 'openai', model: 'gpt-4o-mini', temperature: 0.2, api_keys: [] },
34
- memory: { type: 'file', path: './memory.json' }
35
- };
36
- }
37
- }
38
-
39
- export function saveConfig(newConfig: NyxoraConfig): void {
40
- const configPath = getPath('config.yaml');
41
- try {
42
- const yamlStr = yaml.stringify(newConfig);
43
- fs.writeFileSync(configPath, yamlStr, 'utf8');
44
- } catch (error) {
45
- console.error('Failed to save config.yaml', error);
46
- }
47
- }
@@ -1,33 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import os from 'os';
4
-
5
- let isGlobalModeCache: boolean | null = null;
6
-
7
- export function getAppDir(): string {
8
- // Check if .env or config.yaml exists in current working directory
9
- if (isGlobalModeCache === null) {
10
- const localEnv = path.join(process.cwd(), '.env');
11
- const localConfig = path.join(process.cwd(), 'config.yaml');
12
-
13
- if (fs.existsSync(localEnv) || fs.existsSync(localConfig)) {
14
- isGlobalModeCache = false; // Local manual mode
15
- } else {
16
- isGlobalModeCache = true; // Global CLI mode
17
- }
18
- }
19
-
20
- if (isGlobalModeCache) {
21
- const globalDir = path.join(os.homedir(), '.nyxora');
22
- if (!fs.existsSync(globalDir)) {
23
- fs.mkdirSync(globalDir, { recursive: true });
24
- }
25
- return globalDir;
26
- }
27
-
28
- return process.cwd();
29
- }
30
-
31
- export function getPath(filename: string): string {
32
- return path.join(getAppDir(), filename);
33
- }
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["cli.ts"],"names":[],"mappings":""}
@@ -1,80 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || (function () {
20
- var ownKeys = function(o) {
21
- ownKeys = Object.getOwnPropertyNames || function (o) {
22
- var ar = [];
23
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
- return ar;
25
- };
26
- return ownKeys(o);
27
- };
28
- return function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
35
- })();
36
- var __importDefault = (this && this.__importDefault) || function (mod) {
37
- return (mod && mod.__esModule) ? mod : { "default": mod };
38
- };
39
- Object.defineProperty(exports, "__esModule", { value: true });
40
- const readline_1 = __importDefault(require("readline"));
41
- const reasoning_1 = require("../agent/reasoning");
42
- const dotenv = __importStar(require("dotenv"));
43
- const parser_1 = require("../config/parser");
44
- dotenv.config();
45
- const rl = readline_1.default.createInterface({
46
- input: process.stdin,
47
- output: process.stdout
48
- });
49
- const config = (0, parser_1.loadConfig)();
50
- console.log(`================================`);
51
- console.log(`šŸ¤– OpenWeb CLI Agent Started`);
52
- console.log(`šŸ“‹ Agent Name: ${config.agent.name}`);
53
- console.log(`šŸ”— Default Chain: ${config.agent.default_chain}`);
54
- console.log(`🧠 AI Provider: ${config.llm.provider} (${config.llm.model})`);
55
- console.log(`================================`);
56
- console.log(`Type 'exit' or 'quit' to stop.\n`);
57
- function ask() {
58
- rl.question('šŸ‘¤ You: ', async (input) => {
59
- if (input.toLowerCase() === 'exit' || input.toLowerCase() === 'quit') {
60
- console.log('Goodbye!');
61
- rl.close();
62
- return;
63
- }
64
- if (input.trim() === '') {
65
- ask();
66
- return;
67
- }
68
- console.log('šŸ¤– Agent thinking...');
69
- try {
70
- const response = await (0, reasoning_1.processUserInput)(input);
71
- console.log(`\nšŸ¤– OpenWeb: ${response}\n`);
72
- }
73
- catch (error) {
74
- console.log(`\nāŒ Error: ${error.message}\n`);
75
- }
76
- ask();
77
- });
78
- }
79
- ask();
80
- //# sourceMappingURL=cli.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wDAAgC;AAChC,kDAAsD;AACtD,+CAAiC;AACjC,6CAA8C;AAE9C,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,EAAE,GAAG,kBAAQ,CAAC,eAAe,CAAC;IAClC,KAAK,EAAE,OAAO,CAAC,KAAK;IACpB,MAAM,EAAE,OAAO,CAAC,MAAM;CACvB,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,IAAA,mBAAU,GAAE,CAAC;AAE5B,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAChD,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;AAC5C,OAAO,CAAC,GAAG,CAAC,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import fs from 'fs';
4
- import path from 'path';
5
- import os from 'os';
6
- import * as dotenv from 'dotenv';
7
- import open from 'open';
8
- import { getAppDir } from '../config/paths';
9
- import { startServer } from './server';
10
-
11
- // 1. Determine configuration directory
12
- const appDir = getAppDir();
13
- const isGlobalMode = appDir !== process.cwd();
14
-
15
- console.log(`================================`);
16
- console.log(`šŸ¤– Nyxora CLI Agent Booting Up...`);
17
- console.log(`šŸ“‚ Config Directory: ${appDir}`);
18
- console.log(`================================`);
19
-
20
- // 2. Setup boilerplate files if in global mode and they don't exist
21
- if (isGlobalMode) {
22
- const globalEnvPath = path.join(appDir, '.env');
23
- const globalConfigPath = path.join(appDir, 'config.yaml');
24
- const globalUserMdPath = path.join(appDir, 'user.md');
25
- const globalIdentityMdPath = path.join(appDir, 'IDENTITY.md');
26
-
27
- // Copy .env.example to ~/.nyxora/.env if it doesn't exist
28
- if (!fs.existsSync(globalEnvPath)) {
29
- const exampleEnvPath = path.resolve(__dirname, '../../../.env.example');
30
- if (fs.existsSync(exampleEnvPath)) {
31
- fs.copyFileSync(exampleEnvPath, globalEnvPath);
32
- console.log(`[Setup] Created default .env at ${globalEnvPath}`);
33
- } else {
34
- fs.writeFileSync(globalEnvPath, '# Nyxora Environment Variables\nOPENAI_API_KEY=\nGEMINI_API_KEY=\nTELEGRAM_BOT_TOKEN=\n');
35
- }
36
- }
37
-
38
- // Copy default config.yaml
39
- if (!fs.existsSync(globalConfigPath)) {
40
- const exampleConfigPath = path.resolve(__dirname, '../../../config.yaml');
41
- if (fs.existsSync(exampleConfigPath)) {
42
- fs.copyFileSync(exampleConfigPath, globalConfigPath);
43
- } else {
44
- fs.writeFileSync(globalConfigPath, 'agent:\n name: Nyxora-Agent\n default_chain: base\nllm:\n provider: openai\n model: gpt-4o-mini\n temperature: 0.2\n api_keys: []\nmemory:\n type: file\n path: memory.json\n');
45
- }
46
- }
47
-
48
- if (!fs.existsSync(globalUserMdPath)) {
49
- fs.writeFileSync(globalUserMdPath, 'Tuliskan instruksi kustom, aturan khusus, profil pengguna, atau persona yang Anda inginkan untuk Nyxora AI di file ini.\n');
50
- }
51
-
52
- if (!fs.existsSync(globalIdentityMdPath)) {
53
- fs.writeFileSync(globalIdentityMdPath, 'Kamu adalah Nyxora, asisten Web3 pintar.\n');
54
- }
55
- }
56
-
57
- // 3. Load Environment Variables from the determined directory
58
- dotenv.config({ path: path.join(appDir, '.env') });
59
-
60
- // 4. Start the Express API Server (which also serves the static dashboard and Telegram bot)
61
- startServer();
62
-
63
- // 5. Open the Dashboard in the default browser
64
- const PORT = process.env.PORT || 3000;
65
- setTimeout(() => {
66
- const url = `http://localhost:${PORT}`;
67
- console.log(`🌐 Opening Dashboard at ${url}`);
68
- open(url);
69
- }, 1500);