nyxora 1.5.0 → 1.5.2

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 (38) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +53 -33
  3. package/SECURITY.md +58 -15
  4. package/bin/nyxora.js +3 -0
  5. package/dist/gateway/server.js +13 -1
  6. package/launcher.js +43 -0
  7. package/launcher.ts +51 -0
  8. package/nyxora-1.5.2.tgz +0 -0
  9. package/package.json +28 -57
  10. package/packages/core/package.json +18 -0
  11. package/packages/dashboard/dist/assets/index-BK4qmIy6.js +200 -0
  12. package/packages/dashboard/dist/assets/index-C1m4ohce.css +1 -0
  13. package/{dashboard → packages/dashboard}/dist/index.html +2 -2
  14. package/packages/dashboard/index.html +13 -0
  15. package/packages/dashboard/package-lock.json +2748 -0
  16. package/packages/dashboard/package.json +31 -0
  17. package/packages/dashboard/public/favicon.svg +1 -0
  18. package/packages/dashboard/public/icons.svg +24 -0
  19. package/packages/dashboard/tsconfig.app.json +25 -0
  20. package/packages/dashboard/tsconfig.json +7 -0
  21. package/packages/dashboard/tsconfig.node.json +24 -0
  22. package/packages/dashboard/vite.config.ts +7 -0
  23. package/packages/policy/package.json +12 -0
  24. package/packages/signer/package.json +11 -0
  25. package/security_policy.md +2 -0
  26. package/tsconfig.json +18 -0
  27. package/tsconfig.tsbuildinfo +1 -0
  28. package/dashboard/dist/assets/index-Cy7yprIz.css +0 -1
  29. package/dashboard/dist/assets/index-L20NVlIh.js +0 -9
  30. package/dist/src/agent/reasoning.js +0 -96
  31. package/dist/src/config/parser.js +0 -25
  32. package/dist/src/gateway/cli.js +0 -79
  33. package/dist/src/memory/logger.js +0 -50
  34. package/dist/src/web3/config.js +0 -80
  35. package/dist/src/web3/skills/getBalance.js +0 -43
  36. /package/{dashboard → packages/dashboard}/README.md +0 -0
  37. /package/{dashboard → packages/dashboard}/dist/favicon.svg +0 -0
  38. /package/{dashboard → packages/dashboard}/dist/icons.svg +0 -0
@@ -1,96 +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
- }
@@ -1,25 +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
- }
@@ -1,79 +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();
@@ -1,50 +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;
@@ -1,80 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.supportedChains = void 0;
37
- exports.getPublicClient = getPublicClient;
38
- exports.getWalletClient = getWalletClient;
39
- exports.getAddress = getAddress;
40
- const viem_1 = require("viem");
41
- const accounts_1 = require("viem/accounts");
42
- const chains_1 = require("viem/chains");
43
- const dotenv = __importStar(require("dotenv"));
44
- dotenv.config();
45
- exports.supportedChains = {
46
- ethereum: chains_1.mainnet,
47
- base: chains_1.base,
48
- bsc: chains_1.bsc,
49
- arbitrum: chains_1.arbitrum,
50
- optimism: chains_1.optimism,
51
- };
52
- function getPublicClient(chainName) {
53
- const chain = exports.supportedChains[chainName];
54
- if (!chain)
55
- throw new Error(`Unsupported chain: ${chainName}`);
56
- return (0, viem_1.createPublicClient)({
57
- chain,
58
- transport: (0, viem_1.http)(), // Falls back to public RPC, can be customized with process.env
59
- });
60
- }
61
- function getWalletClient(chainName) {
62
- const chain = exports.supportedChains[chainName];
63
- if (!chain)
64
- throw new Error(`Unsupported chain: ${chainName}`);
65
- const privateKey = process.env.PRIVATE_KEY;
66
- if (!privateKey)
67
- throw new Error('PRIVATE_KEY is not set in .env');
68
- const account = (0, accounts_1.privateKeyToAccount)(privateKey);
69
- return (0, viem_1.createWalletClient)({
70
- account,
71
- chain,
72
- transport: (0, viem_1.http)(),
73
- });
74
- }
75
- function getAddress() {
76
- const privateKey = process.env.PRIVATE_KEY;
77
- if (!privateKey)
78
- throw new Error('PRIVATE_KEY is not set in .env');
79
- return (0, accounts_1.privateKeyToAccount)(privateKey).address;
80
- }
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBalanceToolDefinition = void 0;
4
- exports.getBalance = getBalance;
5
- const viem_1 = require("viem");
6
- const config_1 = require("../config");
7
- async function getBalance(chainName, address) {
8
- try {
9
- const client = (0, config_1.getPublicClient)(chainName);
10
- let targetAddress = address;
11
- if (!targetAddress) {
12
- throw new Error('Address is required but could not be resolved.');
13
- }
14
- const balanceWei = await client.getBalance({ address: targetAddress });
15
- const balanceEth = (0, viem_1.formatEther)(balanceWei);
16
- return `${balanceEth} on ${chainName}`;
17
- }
18
- catch (error) {
19
- return `Failed to get balance: ${error.message}`;
20
- }
21
- }
22
- exports.getBalanceToolDefinition = {
23
- type: "function",
24
- function: {
25
- name: "get_balance",
26
- description: "Get the native token balance (ETH, BNB, etc) of a wallet address on a specific chain. If address is omitted, it returns the balance of the agent's own wallet.",
27
- parameters: {
28
- type: "object",
29
- properties: {
30
- chainName: {
31
- type: "string",
32
- enum: ["ethereum", "base", "bsc", "arbitrum", "optimism"],
33
- description: "The name of the blockchain to check."
34
- },
35
- address: {
36
- type: "string",
37
- description: "Optional. The 0x... address of the wallet. If not provided, it uses the agent's wallet."
38
- }
39
- },
40
- required: ["chainName"]
41
- }
42
- }
43
- };
File without changes