vantuz 3.5.18 → 4.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.
- package/cli.js +9 -9
- package/config.js +6 -6
- package/core/agent-loop.js +6 -6
- package/core/agent.js +6 -6
- package/core/ai-copilot.js +461 -0
- package/core/ai-provider.js +60 -10
- package/core/automation.js +8 -8
- package/core/cache-manager.js +232 -0
- package/core/channels.js +8 -8
- package/core/dashboard.js +5 -5
- package/core/database-manager.js +331 -0
- package/core/database.js +124 -83
- package/core/eia-brain.js +2 -2
- package/core/eia-monitor.js +7 -7
- package/core/engine.js +24 -24
- package/core/error-handler.js +203 -0
- package/core/gateway.js +9 -9
- package/core/learning.js +7 -7
- package/core/license-manager.js +1 -1
- package/core/license.js +6 -6
- package/core/logger.js +228 -0
- package/core/marketplace-adapter.js +5 -5
- package/core/memory.js +6 -6
- package/core/multi-agent.js +180 -0
- package/core/openclaw-bridge.js +6 -6
- package/core/queue.js +3 -3
- package/core/scheduler.js +6 -6
- package/core/scrapers/Scraper.js +1 -1
- package/core/scrapers/TrendyolScraper.js +1 -1
- package/core/self-healer.js +8 -6
- package/core/unified-product.js +8 -8
- package/core/vector-db.js +5 -5
- package/core/vision-service.js +5 -5
- package/desktop/index.html +2804 -0
- package/desktop/main.js +97 -0
- package/desktop/preload.js +30 -0
- package/dev.sh +5 -0
- package/index.js +484 -116
- package/modules/crm/sentiment-crm.js +4 -4
- package/modules/healer/listing-healer.js +2 -2
- package/modules/oracle/predictor.js +5 -5
- package/modules/researcher/agent.js +4 -4
- package/modules/war-room/competitor-tracker.js +5 -5
- package/modules/war-room/pricing-engine.js +5 -5
- package/nodes/warehouse.js +5 -5
- package/onboard.js +1 -1
- package/package.json +11 -3
- package/pkg.json +26 -0
- package/plugins/vantuz/index.js +16 -17
- package/plugins/vantuz/memory/hippocampus.js +3 -3
- package/plugins/vantuz/platforms/_request.js +1 -1
- package/plugins/vantuz/platforms/_template.js +2 -2
- package/plugins/vantuz/platforms/amazon.js +3 -3
- package/plugins/vantuz/platforms/ciceksepeti.js +2 -2
- package/plugins/vantuz/platforms/hepsiburada.js +2 -2
- package/plugins/vantuz/platforms/index.js +9 -24
- package/plugins/vantuz/platforms/n11.js +3 -3
- package/plugins/vantuz/platforms/pazarama.js +2 -2
- package/plugins/vantuz/platforms/pttavm.js +2 -2
- package/plugins/vantuz/platforms/trendyol.js +3 -3
- package/plugins/vantuz/services/alerts.js +1 -1
- package/plugins/vantuz/services/scheduler.js +1 -1
- package/plugins/vantuz/tools/nl-parser.js +1 -1
- package/plugins/vantuz/tools/quick-report.js +2 -2
- package/plugins/vantuz/tools/repricer.js +1 -1
- package/plugins/vantuz/tools/vision.js +3 -3
- package/server/app.js +8 -8
- package/DOCS_TR.md +0 -80
- package/modules/team/agents/base.js +0 -92
- package/modules/team/agents/dev.js +0 -33
- package/modules/team/agents/josh.js +0 -40
- package/modules/team/agents/marketing.js +0 -33
- package/modules/team/agents/milo.js +0 -36
- package/modules/team/index.js +0 -78
- package/modules/team/shared-memory.js +0 -87
- package/n11docs.md +0 -1680
- package/openclawdocs.md +0 -3
- package/vantuz.sqlite +0 -0
- package/workspace/AGENTS.md +0 -73
- package/workspace/BRAND.md +0 -29
- package/workspace/SOUL.md +0 -72
- package/workspace/team/DECISIONS.md +0 -3
- package/workspace/team/GOALS.md +0 -3
- package/workspace/team/PROJECT_STATUS.md +0 -3
- package/workspace/team/agents/dev/SOUL.md +0 -12
- package/workspace/team/agents/josh/SOUL.md +0 -12
- package/workspace/team/agents/marketing/SOUL.md +0 -12
- package/workspace/team/agents/milo/SOUL.md +0 -12
package/core/learning.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Reinforcement Learning Module for Vantuz OS V2
|
|
3
3
|
// Weighted scoring system — tracks AI decisions and adjusts behavior.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const os = require('os');
|
|
8
|
+
const { log } = require('./ai-provider.js');
|
|
9
9
|
|
|
10
10
|
const LEARNING_FILE = path.join(os.homedir(), '.vantuz', 'memory', 'learning.json');
|
|
11
11
|
|
|
@@ -203,12 +203,12 @@ class LearningModule {
|
|
|
203
203
|
|
|
204
204
|
let learningInstance = null;
|
|
205
205
|
|
|
206
|
-
|
|
206
|
+
module.exports.getLearn = functioning() {
|
|
207
207
|
if (!learningInstance) {
|
|
208
208
|
learningInstance = new LearningModule();
|
|
209
209
|
}
|
|
210
210
|
return learningInstance;
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
module.exports = { SCORE_WEIGHTS, AUTONOMY_THRESHOLD };
|
|
214
|
+
module.exports = LearningModule;
|
package/core/license-manager.js
CHANGED
package/core/license.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const crypto = require('crypto');
|
|
4
|
+
const os = require('os');
|
|
5
5
|
|
|
6
6
|
const LICENSE_FILE = path.join(os.homedir(), '.vantuz', 'license.json');
|
|
7
7
|
|
|
8
8
|
// Basit anahtar doğrulama - VM için
|
|
9
9
|
const VALID_KEYS = new Set();
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
module.exports = LicenseManager {
|
|
12
12
|
constructor() {
|
|
13
13
|
this.data = this._load();
|
|
14
14
|
}
|
|
@@ -86,4 +86,4 @@ export class LicenseManager {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
module.exports.l =icenseManager = new LicenseManager();
|
package/core/logger.js
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🐙 VANTUZ Logger - Structured JSON Logging System
|
|
3
|
+
* Log seviyeleri: debug, info, warn, error
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
|
|
9
|
+
const LOG_LEVELS = {
|
|
10
|
+
DEBUG: 0,
|
|
11
|
+
INFO: 1,
|
|
12
|
+
WARN: 2,
|
|
13
|
+
ERROR: 3,
|
|
14
|
+
FATAL: 4
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const LOG_DIR = path.join(process.cwd(), 'logs');
|
|
18
|
+
const LOG_FILE = path.join(LOG_DIR, 'vantuz.log');
|
|
19
|
+
const SESSION_FILE = path.join(LOG_DIR, 'session.log');
|
|
20
|
+
|
|
21
|
+
// Log seviyesi - env'den veya varsayılan
|
|
22
|
+
const currentLevel = process.env.LOG_LEVEL ?
|
|
23
|
+
LOG_LEVELS[process.env.LOG_LEVEL.toUpperCase()] : LOG_LEVELS.INFO;
|
|
24
|
+
|
|
25
|
+
// Klasör yoksa oluştur
|
|
26
|
+
if (!fs.existsSync(LOG_DIR)) {
|
|
27
|
+
fs.mkdirSync(LOG_DIR, { recursive: true });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Structured log entry oluştur
|
|
32
|
+
*/
|
|
33
|
+
function createLogEntry(level, message, meta = {}) {
|
|
34
|
+
return {
|
|
35
|
+
timestamp: new Date().toISOString(),
|
|
36
|
+
level,
|
|
37
|
+
message,
|
|
38
|
+
meta: {
|
|
39
|
+
...meta,
|
|
40
|
+
pid: process.pid,
|
|
41
|
+
nodeVersion: process.version,
|
|
42
|
+
memoryUsage: process.memoryUsage(),
|
|
43
|
+
uptime: process.uptime()
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Log dosyasına yaz
|
|
50
|
+
*/
|
|
51
|
+
function writeToFile(entry) {
|
|
52
|
+
try {
|
|
53
|
+
fs.appendFileSync(LOG_FILE, JSON.stringify(entry) + '\n');
|
|
54
|
+
} catch (e) {
|
|
55
|
+
console.error('Log yazma hatası:', e.message);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Console output - renkli format
|
|
61
|
+
*/
|
|
62
|
+
function formatConsole(entry) {
|
|
63
|
+
const colors = {
|
|
64
|
+
DEBUG: '\x1b[36m', // Cyan
|
|
65
|
+
INFO: '\x1b[32m', // Green
|
|
66
|
+
WARN: '\x1b[33m', // Yellow
|
|
67
|
+
ERROR: '\x1b[31m', // Red
|
|
68
|
+
FATAL: '\x1b[35m', // Magenta
|
|
69
|
+
RESET: '\x1b[0m'
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const icons = {
|
|
73
|
+
DEBUG: '🔍',
|
|
74
|
+
INFO: 'ℹ️',
|
|
75
|
+
WARN: '⚠️',
|
|
76
|
+
ERROR: '❌',
|
|
77
|
+
FATAL: '💀'
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const color = colors[entry.level] || colors.INFO;
|
|
81
|
+
const icon = icons[entry.level] || icons.INFO;
|
|
82
|
+
|
|
83
|
+
let output = `${color}${icon} [${entry.timestamp}] ${entry.message}${colors.RESET}`;
|
|
84
|
+
|
|
85
|
+
if (Object.keys(entry.meta).length > 5) {
|
|
86
|
+
const metaStr = JSON.stringify(entry.meta, null, 2);
|
|
87
|
+
output += `\n${color}${metaStr}${colors.RESET}`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return output;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Ana logger object
|
|
95
|
+
*/
|
|
96
|
+
const logger = {
|
|
97
|
+
/**
|
|
98
|
+
* DEBUG seviyesi
|
|
99
|
+
*/
|
|
100
|
+
debug(message, meta = {}) {
|
|
101
|
+
if (currentLevel <= LOG_LEVELS.DEBUG) {
|
|
102
|
+
const entry = createLogEntry('DEBUG', message, meta);
|
|
103
|
+
writeToFile(entry);
|
|
104
|
+
console.log(formatConsole(entry));
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* INFO seviyesi
|
|
110
|
+
*/
|
|
111
|
+
info(message, meta = {}) {
|
|
112
|
+
if (currentLevel <= LOG_LEVELS.INFO) {
|
|
113
|
+
const entry = createLogEntry('INFO', message, meta);
|
|
114
|
+
writeToFile(entry);
|
|
115
|
+
console.log(formatConsole(entry));
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* WARN seviyesi
|
|
121
|
+
*/
|
|
122
|
+
warn(message, meta = {}) {
|
|
123
|
+
if (currentLevel <= LOG_LEVELS.WARN) {
|
|
124
|
+
const entry = createLogEntry('WARN', message, meta);
|
|
125
|
+
writeToFile(entry);
|
|
126
|
+
console.warn(formatConsole(entry));
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* ERROR seviyesi
|
|
132
|
+
*/
|
|
133
|
+
error(message, meta = {}) {
|
|
134
|
+
if (currentLevel <= LOG_LEVELS.ERROR) {
|
|
135
|
+
const entry = createLogEntry('ERROR', message, meta);
|
|
136
|
+
writeToFile(entry);
|
|
137
|
+
console.error(formatConsole(entry));
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* FATAL seviyesi
|
|
143
|
+
*/
|
|
144
|
+
fatal(message, meta = {}) {
|
|
145
|
+
if (currentLevel <= LOG_LEVELS.FATAL) {
|
|
146
|
+
const entry = createLogEntry('FATAL', message, meta);
|
|
147
|
+
writeToFile(entry);
|
|
148
|
+
console.error(formatConsole(entry));
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Session log başlat
|
|
154
|
+
*/
|
|
155
|
+
startSession(sessionId) {
|
|
156
|
+
const entry = createLogEntry('INFO', 'Session başladı', { sessionId });
|
|
157
|
+
writeToFile(entry);
|
|
158
|
+
try {
|
|
159
|
+
fs.appendFileSync(SESSION_FILE, JSON.stringify(entry) + '\n');
|
|
160
|
+
} catch (e) {}
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Session log bitir
|
|
165
|
+
*/
|
|
166
|
+
endSession(sessionId, duration, stats = {}) {
|
|
167
|
+
const entry = createLogEntry('INFO', 'Session bitti', { sessionId, duration, ...stats });
|
|
168
|
+
writeToFile(entry);
|
|
169
|
+
try {
|
|
170
|
+
fs.appendFileSync(SESSION_FILE, JSON.stringify(entry) + '\n');
|
|
171
|
+
} catch (e) {}
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Error reporting - crash dump
|
|
176
|
+
*/
|
|
177
|
+
reportError(error, context = {}) {
|
|
178
|
+
const entry = createLogEntry('ERROR', error.message, {
|
|
179
|
+
stack: error.stack,
|
|
180
|
+
...context
|
|
181
|
+
});
|
|
182
|
+
writeToFile(entry);
|
|
183
|
+
return entry;
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Log oku
|
|
188
|
+
*/
|
|
189
|
+
getLogs(count = 100) {
|
|
190
|
+
try {
|
|
191
|
+
if (!fs.existsSync(LOG_FILE)) return [];
|
|
192
|
+
const lines = fs.readFileSync(LOG_FILE, 'utf-8').split('\n').filter(Boolean);
|
|
193
|
+
return lines.slice(-count).map(line => JSON.parse(line));
|
|
194
|
+
} catch (e) {
|
|
195
|
+
return [];
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Session log oku
|
|
201
|
+
*/
|
|
202
|
+
getSessionLogs() {
|
|
203
|
+
try {
|
|
204
|
+
if (!fs.existsSync(SESSION_FILE)) return [];
|
|
205
|
+
const lines = fs.readFileSync(SESSION_FILE, 'utf-8').split('\n').filter(Boolean);
|
|
206
|
+
return lines.map(line => JSON.parse(line));
|
|
207
|
+
} catch (e) {
|
|
208
|
+
return [];
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Log temizle
|
|
214
|
+
*/
|
|
215
|
+
clearLogs() {
|
|
216
|
+
try {
|
|
217
|
+
if (fs.existsSync(LOG_FILE)) fs.unlinkSync(LOG_FILE);
|
|
218
|
+
if (fs.existsSync(SESSION_FILE)) fs.unlinkSync(SESSION_FILE);
|
|
219
|
+
return true;
|
|
220
|
+
} catch (e) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
LOG_LEVELS
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
module.exports = logger;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Formal MarketplaceAdapter Interface for Vantuz OS V2
|
|
3
3
|
// Validates that any platform plugin implements required methods.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const { log } = require('./ai-provider.js');
|
|
6
6
|
|
|
7
7
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
8
8
|
// REQUIRED METHODS DEFINITION
|
|
@@ -34,7 +34,7 @@ const OPTIONAL_METHODS = [
|
|
|
34
34
|
* @param {object} adapter - Adapter instance or export object
|
|
35
35
|
* @returns {{ valid: boolean, missing: string[] }}
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
module.exports.val = functionidateAdapter(name, adapter) {
|
|
38
38
|
const missing = [];
|
|
39
39
|
|
|
40
40
|
for (const method of REQUIRED_METHODS) {
|
|
@@ -59,7 +59,7 @@ export function validateAdapter(name, adapter) {
|
|
|
59
59
|
* @param {object} adapter
|
|
60
60
|
* @returns {string[]} List of supported optional method names.
|
|
61
61
|
*/
|
|
62
|
-
|
|
62
|
+
module.exports.getAdapterCapab = functionilities(adapter) {
|
|
63
63
|
return OPTIONAL_METHODS.filter(m => typeof adapter[m] === 'function');
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -158,11 +158,11 @@ class AdapterRegistry {
|
|
|
158
158
|
// Singleton
|
|
159
159
|
let registryInstance = null;
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
module.exports.getAdapterReg = functionistry() {
|
|
162
162
|
if (!registryInstance) {
|
|
163
163
|
registryInstance = new AdapterRegistry();
|
|
164
164
|
}
|
|
165
165
|
return registryInstance;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
module.exports = AdapterRegistry;
|
package/core/memory.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Persistent Memory Module for Vantuz AI
|
|
3
3
|
// Provides long-term fact storage and recall via JSON files.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const os = require('os');
|
|
8
|
+
const { log } = require('./ai-provider.js');
|
|
9
9
|
|
|
10
10
|
const MEMORY_DIR = path.join(os.homedir(), '.vantuz', 'memory');
|
|
11
11
|
const FACTS_FILE = path.join(MEMORY_DIR, 'facts.json');
|
|
@@ -180,11 +180,11 @@ class Memory {
|
|
|
180
180
|
|
|
181
181
|
let memoryInstance = null;
|
|
182
182
|
|
|
183
|
-
|
|
183
|
+
module.exports.getMemory = function() {
|
|
184
184
|
if (!memoryInstance) {
|
|
185
185
|
memoryInstance = new Memory();
|
|
186
186
|
}
|
|
187
187
|
return memoryInstance;
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
|
|
190
|
+
module.exports = Memory;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
const EventEmitter = require('events');
|
|
2
|
+
|
|
3
|
+
// Multi-Agent Communication Core
|
|
4
|
+
// Enables autonomous task delegation and inter-agent chat
|
|
5
|
+
|
|
6
|
+
class MultiAgentSystem extends EventEmitter {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.agents = new Map();
|
|
10
|
+
this.meetingMode = false;
|
|
11
|
+
this.meetingHistory = [];
|
|
12
|
+
this.logger = console;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Register an agent
|
|
17
|
+
* @param {string} id - Unique agent identifier
|
|
18
|
+
* @param {object} agent - Agent instance with 'name', 'role', and 'process' method
|
|
19
|
+
*/
|
|
20
|
+
register(id, agent) {
|
|
21
|
+
if (this.agents.has(id)) {
|
|
22
|
+
this.logger.warn(`Agent ${id} already registered. Updating instead.`);
|
|
23
|
+
}
|
|
24
|
+
this.agents.set(id, {
|
|
25
|
+
...agent,
|
|
26
|
+
id,
|
|
27
|
+
status: 'idle',
|
|
28
|
+
lastActive: new Date().toISOString()
|
|
29
|
+
});
|
|
30
|
+
this.logger.log(`🤖 Agent registered: ${agent.name} (${agent.role})`);
|
|
31
|
+
this.emit('agent:registered', { id, agent });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Send a message to all agents or specific ones
|
|
36
|
+
* @param {string} message - The content
|
|
37
|
+
* @param {object} options - { target: 'all' | 'market' | 'orders' | specificId, context: {} }
|
|
38
|
+
*/
|
|
39
|
+
async broadcast(message, options = {}) {
|
|
40
|
+
const { target = 'all', context = {} } = options;
|
|
41
|
+
const timestamp = new Date().toISOString();
|
|
42
|
+
|
|
43
|
+
const record = { message, target, context, timestamp, sender: 'user' };
|
|
44
|
+
this.meetingHistory.push(record);
|
|
45
|
+
this.emit('meeting:message', record);
|
|
46
|
+
|
|
47
|
+
const promises = [];
|
|
48
|
+
|
|
49
|
+
if (target === 'all') {
|
|
50
|
+
for (const [id, agent] of this.agents) {
|
|
51
|
+
promises.push(this.routeToAgent(id, message, context));
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
const targetAgents = [];
|
|
55
|
+
if (target === 'market') {
|
|
56
|
+
targetAgents.push('market-agent', 'competitor-agent');
|
|
57
|
+
} else if (target === 'orders') {
|
|
58
|
+
targetAgents.push('order-agent');
|
|
59
|
+
} else {
|
|
60
|
+
targetAgents.push(target);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
for (const id of targetAgents) {
|
|
64
|
+
if (this.agents.has(id)) {
|
|
65
|
+
promises.push(this.routeToAgent(id, message, context));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Wait for all (or timeout)
|
|
71
|
+
const results = await Promise.allSettled(promises);
|
|
72
|
+
return results.map((r, i) => ({
|
|
73
|
+
agentId: target === 'all' ? [...this.agents.keys()][i] : target,
|
|
74
|
+
status: r.status,
|
|
75
|
+
response: r.status === 'fulfilled' ? r.value : r.reason
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Internal method to route message to a specific agent
|
|
81
|
+
*/
|
|
82
|
+
async routeToAgent(agentId, message, context) {
|
|
83
|
+
const agent = this.agents.get(agentId);
|
|
84
|
+
if (!agent) return { error: 'Agent not found' };
|
|
85
|
+
|
|
86
|
+
agent.status = 'processing';
|
|
87
|
+
agent.lastActive = new Date().toISOString();
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
// Context includes who else is in the room if in meeting mode
|
|
91
|
+
const response = await agent.process(message, {
|
|
92
|
+
...context,
|
|
93
|
+
meetingMode: this.meetingMode,
|
|
94
|
+
agentsAvailable: [...this.agents.keys()]
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
agent.status = 'idle';
|
|
98
|
+
|
|
99
|
+
// If in meeting mode, emit the response so UI can show it
|
|
100
|
+
if (this.meetingMode) {
|
|
101
|
+
this.emit('meeting:response', {
|
|
102
|
+
agentId,
|
|
103
|
+
agentName: agent.name,
|
|
104
|
+
response,
|
|
105
|
+
timestamp: new Date().toISOString()
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return response;
|
|
110
|
+
} catch (error) {
|
|
111
|
+
agent.status = 'error';
|
|
112
|
+
return { error: error.message };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Enable Meeting Mode (UI integration)
|
|
118
|
+
*/
|
|
119
|
+
enableMeetingMode() {
|
|
120
|
+
this.meetingMode = true;
|
|
121
|
+
this.logger.log('🗣️ Meeting Mode ENABLED');
|
|
122
|
+
this.emit('meeting:status', { active: true });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
disableMeetingMode() {
|
|
126
|
+
this.meetingMode = false;
|
|
127
|
+
this.logger.log('🗣️ Meeting Mode DISABLED');
|
|
128
|
+
this.emit('meeting:status', { active: false });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
getMeetingHistory() {
|
|
132
|
+
return this.meetingHistory;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
getSystemStatus() {
|
|
136
|
+
const agents = [];
|
|
137
|
+
for (const [id, data] of this.agents) {
|
|
138
|
+
agents.push({ id, ...data, memory: undefined }); // exclude functions/memory
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
mode: this.meetingMode ? 'Meeting' : 'Standard',
|
|
142
|
+
agentCount: this.agents.size,
|
|
143
|
+
agents
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Singleton export
|
|
149
|
+
const mas = new MultiAgentSystem();
|
|
150
|
+
|
|
151
|
+
// Default Agents
|
|
152
|
+
class BaseAgent {
|
|
153
|
+
constructor(name, role) {
|
|
154
|
+
this.name = name;
|
|
155
|
+
this.role = role;
|
|
156
|
+
}
|
|
157
|
+
async process(msg, ctx) { return `Agent ${this.name} received: ${msg}`; }
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
class OrderAgent extends BaseAgent {
|
|
161
|
+
constructor() { super('OrderBot', 'orders'); }
|
|
162
|
+
async process(msg, ctx) {
|
|
163
|
+
// Simulated order logic
|
|
164
|
+
return `📦 Sipariş Ajansı: "${msg}" mesajını işledim. Mevcut siparişlerin analizi yapılıyor.`;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
class MarketAgent extends BaseAgent {
|
|
169
|
+
constructor() { super('MarketBot', 'market'); }
|
|
170
|
+
async process(msg, ctx) {
|
|
171
|
+
return `📊 Pazar Ajansı: "${msg}" için verileri topluyorum. Trend analizi yapılıyor.`;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Register defaults
|
|
176
|
+
mas.register('order-agent', new OrderAgent());
|
|
177
|
+
mas.register('market-agent', new MarketAgent());
|
|
178
|
+
|
|
179
|
+
module.exports = { mas, MultiAgentSystem };
|
|
180
|
+
module.exports = mas;
|
package/core/openclaw-bridge.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// core/openclaw-bridge.js
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const crypto = require('crypto');
|
|
5
|
+
const { log } = require('./ai-provider.js');
|
|
6
6
|
|
|
7
7
|
const DEFAULT_PORT = 18789;
|
|
8
8
|
|
|
@@ -88,7 +88,7 @@ function appendEventLog(evt) {
|
|
|
88
88
|
} catch { }
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
module.exports = OpenClawBridge {
|
|
92
92
|
constructor(engine, gateway) {
|
|
93
93
|
this.engine = engine;
|
|
94
94
|
this.gateway = gateway;
|
|
@@ -188,4 +188,4 @@ export class OpenClawBridge {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
module.exports = OpenClawBridge;
|
package/core/queue.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Critical Operation Queue (Lane Queue) for Vantuz AI
|
|
3
3
|
// Ensures write operations (price/stock updates) execute serially, never in parallel.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const { log } = require('./ai-provider.js');
|
|
6
6
|
|
|
7
7
|
class CriticalQueue {
|
|
8
8
|
constructor() {
|
|
@@ -110,11 +110,11 @@ class CriticalQueue {
|
|
|
110
110
|
|
|
111
111
|
let queueInstance = null;
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
module.exports.getCr = functioniticalQueue() {
|
|
114
114
|
if (!queueInstance) {
|
|
115
115
|
queueInstance = new CriticalQueue();
|
|
116
116
|
}
|
|
117
117
|
return queueInstance;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
module.exports = CriticalQueue;
|
package/core/scheduler.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Persistent Scheduler for Vantuz AI
|
|
3
3
|
// Jobs survive restarts via JSON file persistence.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const { CronJob } = require('cron');
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const os = require('os');
|
|
9
|
+
const { log } = require('./ai-provider.js');
|
|
10
10
|
|
|
11
11
|
const JOBS_FILE = path.join(os.homedir(), '.vantuz', 'cron', 'jobs.json');
|
|
12
12
|
|
|
@@ -152,7 +152,7 @@ class Scheduler {
|
|
|
152
152
|
|
|
153
153
|
let schedulerInstance = null;
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
module.exports.getScheduler = function() {
|
|
156
156
|
if (!schedulerInstance) {
|
|
157
157
|
schedulerInstance = new Scheduler();
|
|
158
158
|
}
|
package/core/scrapers/Scraper.js
CHANGED
package/core/self-healer.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Self-Healing Module for Vantuz OS V2
|
|
3
3
|
// Monitors errors, auto-repairs simple issues, and rolls back broken states.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const os = require('os');
|
|
8
|
+
const { log } = require('./ai-provider.js');
|
|
9
9
|
|
|
10
10
|
const SNAPSHOT_DIR = path.join(os.homedir(), '.vantuz', 'snapshots');
|
|
11
11
|
const ERROR_LOG_FILE = path.join(os.homedir(), '.vantuz', 'memory', 'error-log.json');
|
|
@@ -304,11 +304,13 @@ class SelfHealer {
|
|
|
304
304
|
|
|
305
305
|
let healerInstance = null;
|
|
306
306
|
|
|
307
|
-
|
|
307
|
+
function getSelfHealer() {
|
|
308
308
|
if (!healerInstance) {
|
|
309
309
|
healerInstance = new SelfHealer();
|
|
310
310
|
}
|
|
311
311
|
return healerInstance;
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
|
|
314
|
+
// Export both the class and the getter
|
|
315
|
+
module.exports = SelfHealer;
|
|
316
|
+
module.exports.getSelfHealer = getSelfHealer;
|