nyxora 26.6.22-1 → 26.6.24

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 (64) hide show
  1. package/README.md +3 -4
  2. package/dist/packages/core/src/agent/cronManager.js +6 -3
  3. package/dist/packages/core/src/agent/llmProvider.js +250 -0
  4. package/dist/packages/core/src/agent/osAgent.js +389 -0
  5. package/dist/packages/core/src/agent/reasoning.js +155 -433
  6. package/dist/packages/core/src/agent/web3Agent.js +400 -0
  7. package/dist/packages/core/src/gateway/WebSocketManager.js +98 -0
  8. package/dist/packages/core/src/gateway/doctor.js +32 -4
  9. package/dist/packages/core/src/gateway/server.js +20 -0
  10. package/dist/packages/core/src/gateway/setup.js +28 -13
  11. package/dist/packages/core/src/gateway/telegram.js +40 -52
  12. package/dist/packages/core/src/gateway/tracker.js +49 -1
  13. package/dist/packages/core/src/system/skills/searchWeb.js +87 -11
  14. package/dist/packages/core/src/system/skills/summarizeText.js +3 -3
  15. package/dist/packages/core/src/utils/historySanitizer.js +36 -0
  16. package/dist/packages/core/src/utils/skillManager.js +11 -2
  17. package/dist/packages/core/src/web3/aggregator/defiRouter.js +2 -0
  18. package/dist/packages/core/src/web3/skills/bridgeToken.js +2 -0
  19. package/dist/packages/core/src/web3/skills/checkPortfolio.js +7 -6
  20. package/dist/packages/core/src/web3/skills/checkRegistryStatus.js +5 -5
  21. package/dist/packages/core/src/web3/skills/checkSecurity.js +1 -1
  22. package/dist/packages/core/src/web3/skills/getPrice.js +1 -1
  23. package/dist/packages/core/src/web3/skills/getTxHistory.js +2 -2
  24. package/dist/packages/core/src/web3/skills/marketAnalysis.js +1 -1
  25. package/dist/packages/core/src/web3/skills/nativeOpBridge.js +4 -3
  26. package/dist/packages/core/src/web3/skills/provideLiquidity.js +1 -1
  27. package/dist/packages/core/src/web3/utils/vaultClient.js +79 -29
  28. package/dist/packages/policy/src/server.js +56 -12
  29. package/package.json +19 -6
  30. package/packages/core/package.json +7 -6
  31. package/packages/core/src/agent/cronManager.ts +6 -4
  32. package/packages/core/src/agent/llmProvider.ts +272 -0
  33. package/packages/core/src/agent/osAgent.ts +445 -0
  34. package/packages/core/src/agent/reasoning.ts +185 -531
  35. package/packages/core/src/agent/web3Agent.ts +483 -0
  36. package/packages/core/src/config/parser.ts +2 -1
  37. package/packages/core/src/gateway/WebSocketManager.ts +114 -0
  38. package/packages/core/src/gateway/doctor.ts +32 -4
  39. package/packages/core/src/gateway/server.ts +22 -0
  40. package/packages/core/src/gateway/setup.ts +26 -12
  41. package/packages/core/src/gateway/telegram.ts +43 -54
  42. package/packages/core/src/gateway/tracker.ts +16 -1
  43. package/packages/core/src/system/skills/searchWeb.ts +83 -11
  44. package/packages/core/src/system/skills/summarizeText.ts +4 -4
  45. package/packages/core/src/utils/historySanitizer.ts +38 -0
  46. package/packages/core/src/utils/skillManager.ts +11 -2
  47. package/packages/core/src/web3/aggregator/defiRouter.ts +6 -4
  48. package/packages/core/src/web3/skills/bridgeToken.ts +2 -0
  49. package/packages/core/src/web3/skills/checkPortfolio.ts +7 -6
  50. package/packages/core/src/web3/skills/checkRegistryStatus.ts +5 -6
  51. package/packages/core/src/web3/skills/checkSecurity.ts +1 -1
  52. package/packages/core/src/web3/skills/getPrice.ts +1 -1
  53. package/packages/core/src/web3/skills/getTxHistory.ts +2 -2
  54. package/packages/core/src/web3/skills/marketAnalysis.ts +1 -1
  55. package/packages/core/src/web3/skills/nativeOpBridge.ts +4 -3
  56. package/packages/core/src/web3/skills/provideLiquidity.ts +1 -1
  57. package/packages/core/src/web3/utils/vaultClient.ts +86 -26
  58. package/packages/dashboard/dist/assets/{index-CmWZofn_.js → index-BLMS9VtQ.js} +1 -1
  59. package/packages/dashboard/dist/index.html +1 -1
  60. package/packages/dashboard/package.json +1 -1
  61. package/packages/mcp-server/package.json +1 -1
  62. package/packages/policy/package.json +2 -2
  63. package/packages/policy/src/server.ts +59 -11
  64. package/packages/signer/package.json +1 -1
package/README.md CHANGED
@@ -2,10 +2,11 @@
2
2
  **Your Personal Web3 Assistant.**
3
3
 
4
4
 
5
+ [![Status: Alpha](https://img.shields.io/badge/Status-Alpha-red.svg)](#)
5
6
  [![Built on Arbitrum](https://img.shields.io/badge/Built_on-Arbitrum-28A0F0?style=flat&logo=arbitrum&logoColor=white)](https://arbitrum.io/)
6
7
  [![MCP Supported](https://img.shields.io/badge/MCP-Supported-blue.svg)](#)
7
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
- [![Security: Production-Grade](https://img.shields.io/badge/Security-Production--Grade-blue.svg)](#️-advanced-security-threat-model)
9
+ [![Security: Defense-in-Depth](https://img.shields.io/badge/Security-Defense--in--Depth-blue.svg)](#️-advanced-security-threat-model)
9
10
  [![Execution: Cryptographic Approval](https://img.shields.io/badge/Execution-Cryptographic--Approval-orange.svg)](#️-advanced-security-threat-model)
10
11
  [![Privacy: Local-Only Keys](https://img.shields.io/badge/Privacy-Local--Only--Keys-success.svg)](#️-advanced-security-threat-model)
11
12
 
@@ -90,7 +91,7 @@ Within the AI Brain, the Web3 codebase is strictly divided to prevent the LLM fr
90
91
 
91
92
  ## 🛡️ Advanced Security & Threat Model
92
93
 
93
- To dive deeper into the technical details of our Zero-Knowledge security architecture, please visit the [Nyxora Security Blueprint](https://nyxoraai.github.io/Nyxora/).
94
+ To dive deeper into the technical details of our Zero-Knowledge security architecture, please visit the [Nyxora Security](https://nyxoraai.github.io/Nyxora/).
94
95
 
95
96
  ---
96
97
 
@@ -182,8 +183,6 @@ For complete technical deep-dives into our Cryptographic Architecture, please vi
182
183
 
183
184
  > **🔗 [Read the Full Nyxora Documentation Here](https://nyxoraai.github.io/Nyxora/)**
184
185
 
185
- *(Includes guides on Secure Wallet Imports, Architecture Blueprints, Troubleshooting, and Custom Skill Development).*
186
-
187
186
  ---
188
187
 
189
188
  **❤️ Support the Project**
@@ -37,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.cronManager = void 0;
40
- const cron = __importStar(require("node-cron"));
40
+ const croner_1 = require("croner");
41
41
  const parser_1 = require("../config/parser");
42
42
  const telegram_1 = require("../gateway/telegram");
43
43
  const crypto_1 = require("crypto");
@@ -47,10 +47,13 @@ class CronManager {
47
47
  addJob(expression, prompt) {
48
48
  const id = (0, crypto_1.randomUUID)();
49
49
  // Validate expression
50
- if (!cron.validate(expression)) {
50
+ try {
51
+ new croner_1.Cron(expression);
52
+ }
53
+ catch (e) {
51
54
  throw new Error(`Invalid cron expression: ${expression}`);
52
55
  }
53
- const task = cron.schedule(expression, async () => {
56
+ const task = new croner_1.Cron(expression, async () => {
54
57
  console.log(picocolors_1.default.cyan(`[Cron] Executing job ${id}: "${prompt}"`));
55
58
  try {
56
59
  // Dynamically import processUserInput to avoid circular dependencies
@@ -0,0 +1,250 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GeminiAdapter = exports.AnthropicAdapter = exports.OpenAIAdapter = void 0;
4
+ const genai_1 = require("@google/genai");
5
+ class OpenAIAdapter {
6
+ client;
7
+ constructor(client) {
8
+ this.client = client;
9
+ }
10
+ async chat(request) {
11
+ const response = await this.client.chat.completions.create(request);
12
+ return {
13
+ message: {
14
+ content: response.choices[0].message.content,
15
+ tool_calls: response.choices[0].message.tool_calls
16
+ }
17
+ };
18
+ }
19
+ }
20
+ exports.OpenAIAdapter = OpenAIAdapter;
21
+ class AnthropicAdapter {
22
+ client;
23
+ constructor(client) {
24
+ this.client = client;
25
+ }
26
+ async chat(request) {
27
+ let systemPrompt = '';
28
+ const anthropicMessages = [];
29
+ for (const m of request.messages) {
30
+ if (m.role === 'system') {
31
+ systemPrompt = m.content;
32
+ continue;
33
+ }
34
+ if (m.role === 'user') {
35
+ anthropicMessages.push({ role: 'user', content: m.content });
36
+ }
37
+ else if (m.role === 'assistant') {
38
+ const blocks = [];
39
+ if (m.content)
40
+ blocks.push({ type: 'text', text: m.content });
41
+ if (m.tool_calls) {
42
+ m.tool_calls.forEach((tc) => {
43
+ try {
44
+ blocks.push({
45
+ type: 'tool_use',
46
+ id: tc.id,
47
+ name: tc.function.name,
48
+ input: JSON.parse(tc.function.arguments)
49
+ });
50
+ }
51
+ catch (e) { }
52
+ });
53
+ }
54
+ anthropicMessages.push({ role: 'assistant', content: blocks.length > 0 ? blocks : m.content });
55
+ }
56
+ else if (m.role === 'tool') {
57
+ anthropicMessages.push({
58
+ role: 'user',
59
+ content: [
60
+ {
61
+ type: 'tool_result',
62
+ tool_use_id: m.tool_call_id,
63
+ content: m.content
64
+ }
65
+ ]
66
+ });
67
+ }
68
+ }
69
+ // Merge consecutive roles (Anthropic strictly requires alternating user/assistant)
70
+ const mergedAnthropic = [];
71
+ for (const m of anthropicMessages) {
72
+ const last = mergedAnthropic[mergedAnthropic.length - 1];
73
+ if (last && last.role === m.role) {
74
+ if (Array.isArray(last.content) && Array.isArray(m.content)) {
75
+ last.content.push(...m.content);
76
+ }
77
+ else if (typeof last.content === 'string' && typeof m.content === 'string') {
78
+ last.content += '\n\n' + m.content;
79
+ }
80
+ else if (Array.isArray(last.content) && typeof m.content === 'string') {
81
+ last.content.push({ type: 'text', text: m.content });
82
+ }
83
+ else if (typeof last.content === 'string' && Array.isArray(m.content)) {
84
+ last.content = [{ type: 'text', text: last.content }, ...m.content];
85
+ }
86
+ }
87
+ else {
88
+ mergedAnthropic.push(m);
89
+ }
90
+ }
91
+ let anthropicTools = undefined;
92
+ if (request.tools) {
93
+ anthropicTools = request.tools.map(t => ({
94
+ name: t.function.name,
95
+ description: t.function.description,
96
+ input_schema: t.function.parameters
97
+ }));
98
+ }
99
+ const response = await this.client.messages.create({
100
+ model: request.model,
101
+ system: systemPrompt,
102
+ messages: mergedAnthropic,
103
+ tools: anthropicTools,
104
+ temperature: request.temperature,
105
+ max_tokens: request.max_tokens || 4096
106
+ });
107
+ let contentStr = null;
108
+ let toolCalls = [];
109
+ for (const block of response.content) {
110
+ if (block.type === 'text') {
111
+ contentStr = (contentStr || '') + block.text;
112
+ }
113
+ else if (block.type === 'tool_use') {
114
+ toolCalls.push({
115
+ id: block.id,
116
+ type: 'function',
117
+ function: {
118
+ name: block.name,
119
+ arguments: JSON.stringify(block.input)
120
+ }
121
+ });
122
+ }
123
+ }
124
+ return {
125
+ message: {
126
+ content: contentStr,
127
+ tool_calls: toolCalls.length > 0 ? toolCalls : undefined
128
+ }
129
+ };
130
+ }
131
+ }
132
+ exports.AnthropicAdapter = AnthropicAdapter;
133
+ class GeminiAdapter {
134
+ client;
135
+ constructor(client) {
136
+ this.client = client;
137
+ }
138
+ async chat(request) {
139
+ let systemInstruction = '';
140
+ const rawGemini = [];
141
+ for (const m of request.messages) {
142
+ if (m.role === 'system') {
143
+ systemInstruction = m.content;
144
+ continue;
145
+ }
146
+ if (m.role === 'user') {
147
+ rawGemini.push({ role: 'user', parts: [{ text: m.content }] });
148
+ }
149
+ else if (m.role === 'assistant') {
150
+ const parts = [];
151
+ if (m.content)
152
+ parts.push({ text: m.content });
153
+ if (m.tool_calls) {
154
+ m.tool_calls.forEach((tc) => {
155
+ try {
156
+ parts.push({
157
+ functionCall: {
158
+ name: tc.function.name,
159
+ args: JSON.parse(tc.function.arguments)
160
+ }
161
+ });
162
+ }
163
+ catch (e) { }
164
+ });
165
+ }
166
+ rawGemini.push({ role: 'model', parts: parts });
167
+ }
168
+ else if (m.role === 'tool') {
169
+ rawGemini.push({
170
+ role: 'user',
171
+ parts: [{
172
+ functionResponse: {
173
+ name: m.name || 'unknown_tool',
174
+ response: { result: m.content }
175
+ }
176
+ }]
177
+ });
178
+ }
179
+ }
180
+ const geminiMessages = [];
181
+ for (const m of rawGemini) {
182
+ const last = geminiMessages[geminiMessages.length - 1];
183
+ if (last && last.role === m.role) {
184
+ last.parts.push(...m.parts);
185
+ }
186
+ else {
187
+ geminiMessages.push(m);
188
+ }
189
+ }
190
+ let tools = undefined;
191
+ if (request.tools) {
192
+ tools = [{
193
+ functionDeclarations: request.tools.map(t => ({
194
+ name: t.function.name,
195
+ description: t.function.description,
196
+ parameters: t.function.parameters
197
+ }))
198
+ }];
199
+ }
200
+ const response = await this.client.models.generateContent({
201
+ model: request.model,
202
+ contents: geminiMessages,
203
+ config: {
204
+ systemInstruction: systemInstruction,
205
+ tools: tools,
206
+ temperature: request.temperature,
207
+ safetySettings: [
208
+ { category: genai_1.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT, threshold: genai_1.HarmBlockThreshold.BLOCK_NONE },
209
+ { category: genai_1.HarmCategory.HARM_CATEGORY_HARASSMENT, threshold: genai_1.HarmBlockThreshold.BLOCK_NONE },
210
+ { category: genai_1.HarmCategory.HARM_CATEGORY_HATE_SPEECH, threshold: genai_1.HarmBlockThreshold.BLOCK_NONE },
211
+ { category: genai_1.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT, threshold: genai_1.HarmBlockThreshold.BLOCK_NONE }
212
+ ]
213
+ }
214
+ });
215
+ let contentStr = null;
216
+ let toolCalls = [];
217
+ if (response.candidates && response.candidates.length > 0) {
218
+ const candidate = response.candidates[0];
219
+ // Log finish reason for debugging safety blocks
220
+ if (candidate.finishReason && candidate.finishReason !== 'STOP') {
221
+ console.warn(`[LLM] Gemini API returned finishReason: ${candidate.finishReason}`);
222
+ }
223
+ if (candidate.content && candidate.content.parts) {
224
+ const parts = candidate.content.parts;
225
+ for (const part of parts) {
226
+ if (part.text) {
227
+ contentStr = (contentStr || '') + part.text;
228
+ }
229
+ else if (part.functionCall) {
230
+ toolCalls.push({
231
+ id: `call_${Math.random().toString(36).substring(7)}`,
232
+ type: 'function',
233
+ function: {
234
+ name: part.functionCall.name,
235
+ arguments: JSON.stringify(part.functionCall.args)
236
+ }
237
+ });
238
+ }
239
+ }
240
+ }
241
+ }
242
+ return {
243
+ message: {
244
+ content: contentStr,
245
+ tool_calls: toolCalls.length > 0 ? toolCalls : undefined
246
+ }
247
+ };
248
+ }
249
+ }
250
+ exports.GeminiAdapter = GeminiAdapter;