vantuz 4.0.0 → 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 +483 -115
- 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/cli.js
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
* Vantuz Gateway entegrasyonlu komut satırı arayüzü
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
const path = require('path');;
|
|
9
|
+
const os = require('os');;
|
|
10
|
+
const fs = require('fs');;
|
|
11
|
+
const readline = require('readline');;
|
|
12
|
+
const { log, getLogs, clearLogs } = require('./core/ai-provider.js');;
|
|
13
|
+
const { getEngine } = require('./core/engine.js');;
|
|
14
|
+
const { getGateway } = require('./core/gateway.js');;
|
|
15
|
+
const { licenseManager } = require('./core/license.js');; // Lisans yöneticisi
|
|
16
|
+
const { Configurator } = require('./config.js');; // Import the new Configurator
|
|
17
17
|
|
|
18
18
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
19
19
|
// CONFIG
|
package/config.js
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* v3.2.7 - Gateway Entegrasyonlu
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const fs = require('fs');;
|
|
9
|
+
const path = require('path');;
|
|
10
|
+
const os = require('os');;
|
|
11
|
+
const readline = require('readline');;
|
|
12
|
+
const { fileURLToPath, pathToFileURL } = require('url');;
|
|
13
|
+
const { PROVIDER_CONFIG } = require('./core/ai-provider.js');; // Import PROVIDER_CONFIG
|
|
14
14
|
|
|
15
15
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
16
|
const VANTUZ_HOME = path.join(os.homedir(), '.vantuz');
|
package/core/agent-loop.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// The Heartbeat of Vantuz OS V2 — Autonomous Agent Loop
|
|
3
3
|
// Cron-driven cycle that orchestrates all intelligence modules.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const { log } = require('./ai-provider.js');
|
|
6
|
+
const { getLearning } = require('./learning.js');
|
|
7
|
+
const { getSelfHealer } = require('./self-healer.js');
|
|
8
|
+
const { CronJob } = require('cron');
|
|
9
9
|
|
|
10
10
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
11
11
|
// AGENT LOOP
|
|
@@ -180,11 +180,11 @@ class AgentLoop {
|
|
|
180
180
|
|
|
181
181
|
let loopInstance = null;
|
|
182
182
|
|
|
183
|
-
|
|
183
|
+
module.exports.getAgentLoop = function() {
|
|
184
184
|
if (!loopInstance) {
|
|
185
185
|
loopInstance = new AgentLoop();
|
|
186
186
|
}
|
|
187
187
|
return loopInstance;
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
|
|
190
|
+
module.exports = AgentLoop;
|
package/core/agent.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { exec } = require('child_process');
|
|
4
|
+
const https = require('https');
|
|
5
|
+
const http = require('http');
|
|
6
6
|
|
|
7
7
|
const DEFAULT_ALLOW_CMDS = [
|
|
8
8
|
'dir', 'ls', 'rg', 'cat', 'type', 'node', 'npm', 'git', 'curl'
|
|
@@ -60,7 +60,7 @@ function httpGet(url, timeoutMs = 15000) {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
module.exports.executeTool = async function(tool, args = {}, config = {}) {
|
|
64
64
|
switch (tool) {
|
|
65
65
|
case 'exec': {
|
|
66
66
|
const command = args.command || '';
|
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🤖 Vantuz AI Copilot v4.0
|
|
3
|
+
* Tam Sistem Erişimli Akıllı Asistan
|
|
4
|
+
* Dosya sistemi, veritabanı, marketplace ve görev yönetimi
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const os = require('os');
|
|
10
|
+
const { exec, execSync } = require('child_process');
|
|
11
|
+
|
|
12
|
+
// Paths
|
|
13
|
+
const VANTUZ_DIR = path.join(os.homedir(), '.vantuz');
|
|
14
|
+
const LOG_FILE = path.join(VANTUZ_DIR, 'vantuz.log');
|
|
15
|
+
const DB_PATH = path.join(process.cwd(), 'vantuz.sqlite');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Ana Copilot Sınıfı - Tüm sisteme erişim sağlar
|
|
19
|
+
*/
|
|
20
|
+
class AICopilot {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.name = 'VantuzCopilot';
|
|
23
|
+
this.version = '4.0.0';
|
|
24
|
+
this.context = {};
|
|
25
|
+
this.permissionLevel = 'full'; // full, restricted, read-only
|
|
26
|
+
this._db = null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async _getDb() {
|
|
30
|
+
if (this._db) return this._db;
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const initSqlJs = require('sql.js');
|
|
34
|
+
const SQL = await initSqlJs();
|
|
35
|
+
|
|
36
|
+
if (fs.existsSync(DB_PATH)) {
|
|
37
|
+
const buffer = fs.readFileSync(DB_PATH);
|
|
38
|
+
this._db = new SQL.Database(buffer);
|
|
39
|
+
} else {
|
|
40
|
+
this._db = new SQL.Database();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return this._db;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('Database init error:', error.message);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
51
|
+
// DOSYA SİSTEMİ ERİŞİMİ
|
|
52
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Dosya oku
|
|
56
|
+
*/
|
|
57
|
+
readFile(filePath, options = {}) {
|
|
58
|
+
try {
|
|
59
|
+
if (!fs.existsSync(filePath)) {
|
|
60
|
+
return { success: false, error: 'Dosya bulunamadı', path: filePath };
|
|
61
|
+
}
|
|
62
|
+
const content = fs.readFileSync(filePath, options.encoding || 'utf-8');
|
|
63
|
+
return { success: true, content, path: filePath };
|
|
64
|
+
} catch (error) {
|
|
65
|
+
return { success: false, error: error.message, path: filePath };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Dosya yaz
|
|
71
|
+
*/
|
|
72
|
+
writeFile(filePath, content, options = {}) {
|
|
73
|
+
try {
|
|
74
|
+
// Dizin yoksa oluştur
|
|
75
|
+
const dir = path.dirname(filePath);
|
|
76
|
+
if (!fs.existsSync(dir)) {
|
|
77
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
78
|
+
}
|
|
79
|
+
fs.writeFileSync(filePath, content, options.encoding || 'utf-8');
|
|
80
|
+
return { success: true, path: filePath, size: content.length };
|
|
81
|
+
} catch (error) {
|
|
82
|
+
return { success: false, error: error.message, path: filePath };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Dosya sil (geri dönüşümlü - backup alınır)
|
|
88
|
+
*/
|
|
89
|
+
deleteFile(filePath) {
|
|
90
|
+
try {
|
|
91
|
+
if (!fs.existsSync(filePath)) {
|
|
92
|
+
return { success: false, error: 'Dosya bulunamadı' };
|
|
93
|
+
}
|
|
94
|
+
// Backup al
|
|
95
|
+
const backupPath = filePath + '.backup.' + Date.now();
|
|
96
|
+
fs.renameSync(filePath, backupPath);
|
|
97
|
+
return { success: true, backupPath, message: 'Dosya backup alınarak silindi' };
|
|
98
|
+
} catch (error) {
|
|
99
|
+
return { success: false, error: error.message };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Dizin listele
|
|
105
|
+
*/
|
|
106
|
+
listDir(dirPath) {
|
|
107
|
+
try {
|
|
108
|
+
if (!fs.existsSync(dirPath)) {
|
|
109
|
+
return { success: false, error: 'Dizin bulunamadı' };
|
|
110
|
+
}
|
|
111
|
+
const items = fs.readdirSync(dirPath);
|
|
112
|
+
const result = items.map(item => {
|
|
113
|
+
const fullPath = path.join(dirPath, item);
|
|
114
|
+
const stats = fs.statSync(fullPath);
|
|
115
|
+
return {
|
|
116
|
+
name: item,
|
|
117
|
+
path: fullPath,
|
|
118
|
+
isDirectory: stats.isDirectory(),
|
|
119
|
+
size: stats.size,
|
|
120
|
+
modified: stats.mtime
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
return { success: true, items: result, path: dirPath };
|
|
124
|
+
} catch (error) {
|
|
125
|
+
return { success: false, error: error.message };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Dosya ara
|
|
131
|
+
*/
|
|
132
|
+
findFiles(pattern, rootDir = process.cwd()) {
|
|
133
|
+
const results = [];
|
|
134
|
+
|
|
135
|
+
function search(dir) {
|
|
136
|
+
try {
|
|
137
|
+
const items = fs.readdirSync(dir);
|
|
138
|
+
for (const item of items) {
|
|
139
|
+
const fullPath = path.join(dir, item);
|
|
140
|
+
if (item.includes(pattern)) {
|
|
141
|
+
results.push(fullPath);
|
|
142
|
+
}
|
|
143
|
+
if (fs.statSync(fullPath).isDirectory()) {
|
|
144
|
+
search(fullPath);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
} catch (e) { /* permission denied */ }
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
search(rootDir);
|
|
151
|
+
return { success: true, results, pattern };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
155
|
+
// VERİTABANI ERİŞİMİ (CRUD)
|
|
156
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* SQL sorgusu çalıştır
|
|
160
|
+
*/
|
|
161
|
+
async query(sql, params = []) {
|
|
162
|
+
try {
|
|
163
|
+
const db = await this._getDb();
|
|
164
|
+
if (!db) return { success: false, error: 'Database not initialized' };
|
|
165
|
+
|
|
166
|
+
const results = [];
|
|
167
|
+
const stmt = db.prepare(sql);
|
|
168
|
+
if (params.length > 0) stmt.bind(params);
|
|
169
|
+
while (stmt.step()) {
|
|
170
|
+
results.push(stmt.getAsObject());
|
|
171
|
+
}
|
|
172
|
+
stmt.free();
|
|
173
|
+
|
|
174
|
+
// Değişiklik varsa kaydet
|
|
175
|
+
if (sql.toUpperCase().startsWith('INSERT') ||
|
|
176
|
+
sql.toUpperCase().startsWith('UPDATE') ||
|
|
177
|
+
sql.toUpperCase().startsWith('DELETE')) {
|
|
178
|
+
fs.writeFileSync(DB_PATH, Buffer.from(db.export()));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return { success: true, results, count: results.length };
|
|
182
|
+
} catch (error) {
|
|
183
|
+
return { success: false, error: error.message, sql };
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Tabloyu oku
|
|
189
|
+
*/
|
|
190
|
+
async getTable(tableName) {
|
|
191
|
+
return this.query(`SELECT * FROM ${tableName}`);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Veri ekle
|
|
196
|
+
*/
|
|
197
|
+
async insert(tableName, data) {
|
|
198
|
+
const keys = Object.keys(data);
|
|
199
|
+
const values = Object.values(data).map(v =>
|
|
200
|
+
typeof v === 'object' ? JSON.stringify(v) : v
|
|
201
|
+
);
|
|
202
|
+
const placeholders = keys.map(() => '?').join(', ');
|
|
203
|
+
const sql = `INSERT INTO ${tableName} (${keys.join(', ')}) VALUES (${placeholders})`;
|
|
204
|
+
return this.query(sql, values);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Veri güncelle
|
|
209
|
+
*/
|
|
210
|
+
async update(tableName, data, where) {
|
|
211
|
+
const setClause = Object.keys(data).map(k => `${k} = ?`).join(', ');
|
|
212
|
+
const whereClause = Object.keys(where).map(k => `${k} = ?`).join(' AND ');
|
|
213
|
+
const values = [...Object.values(data), ...Object.values(where)];
|
|
214
|
+
const sql = `UPDATE ${tableName} SET ${setClause} WHERE ${whereClause}`;
|
|
215
|
+
return this.query(sql, values);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Veri sil
|
|
220
|
+
*/
|
|
221
|
+
async delete(tableName, where) {
|
|
222
|
+
const whereClause = Object.keys(where).map(k => `${k} = ?`).join(' AND ');
|
|
223
|
+
const values = Object.values(where);
|
|
224
|
+
const sql = `DELETE FROM ${tableName} WHERE ${whereClause}`;
|
|
225
|
+
return this.query(sql, values);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
229
|
+
// MARKETPLACE ENTEGRASYONLARI
|
|
230
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Marketplace durumunu kontrol et
|
|
234
|
+
*/
|
|
235
|
+
getMarketplaceStatus() {
|
|
236
|
+
const marketplaces = ['trendyol', 'hepsiburada', 'n11', 'amazon', 'ciceksepeti', 'pttavm', 'pazarama'];
|
|
237
|
+
const status = {};
|
|
238
|
+
|
|
239
|
+
for (const mp of marketplaces) {
|
|
240
|
+
const configPath = path.join(VANTUZ_DIR, `marketplaces`, `${mp}.json`);
|
|
241
|
+
const connected = fs.existsSync(configPath);
|
|
242
|
+
status[mp] = {
|
|
243
|
+
connected,
|
|
244
|
+
lastSync: connected ? fs.statSync(configPath).mtime : null
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return { success: true, marketplaces: status };
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Marketplace API'sini çağır
|
|
253
|
+
*/
|
|
254
|
+
async callMarketplaceAPI(marketplace, endpoint, method = 'GET', data = null) {
|
|
255
|
+
const configPath = path.join(VANTUZ_DIR, `marketplaces`, `${marketplace}.json`);
|
|
256
|
+
|
|
257
|
+
if (!fs.existsSync(configPath)) {
|
|
258
|
+
return { success: false, error: `${marketplace} bağlı değil` };
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
try {
|
|
262
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
263
|
+
const axios = require('axios');
|
|
264
|
+
|
|
265
|
+
const response = await axios({
|
|
266
|
+
method,
|
|
267
|
+
url: `${config.apiUrl}${endpoint}`,
|
|
268
|
+
headers: config.headers || {},
|
|
269
|
+
data
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
return { success: true, data: response.data };
|
|
273
|
+
} catch (error) {
|
|
274
|
+
return { success: false, error: error.message };
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
279
|
+
// SİSTEM YÖNETİMİ
|
|
280
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Vantuz'u yeniden başlat
|
|
284
|
+
*/
|
|
285
|
+
restartVantuz() {
|
|
286
|
+
try {
|
|
287
|
+
exec(`cd ${process.cwd()} && node index.js &`, { detached: true });
|
|
288
|
+
return { success: true, message: 'Vantuz yeniden başlatılıyor...' };
|
|
289
|
+
} catch (error) {
|
|
290
|
+
return { success: false, error: error.message };
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Sistem durumunu al
|
|
296
|
+
*/
|
|
297
|
+
getSystemStatus() {
|
|
298
|
+
const status = {
|
|
299
|
+
uptime: process.uptime(),
|
|
300
|
+
memory: process.memoryUsage(),
|
|
301
|
+
cpu: process.cpuUsage(),
|
|
302
|
+
platform: os.platform(),
|
|
303
|
+
nodeVersion: process.version
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// Veritabanı durumu
|
|
307
|
+
status.database = {
|
|
308
|
+
exists: fs.existsSync(DB_PATH),
|
|
309
|
+
size: fs.existsSync(DB_PATH) ? fs.statSync(DB_PATH).size : 0
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
// Log durumu
|
|
313
|
+
if (fs.existsSync(LOG_FILE)) {
|
|
314
|
+
status.log = {
|
|
315
|
+
exists: true,
|
|
316
|
+
size: fs.statSync(LOG_FILE).size,
|
|
317
|
+
lines: fs.readFileSync(LOG_FILE, 'utf-8').split('\n').length
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return { success: true, status };
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Log oku
|
|
326
|
+
*/
|
|
327
|
+
getLogs(lines = 50) {
|
|
328
|
+
try {
|
|
329
|
+
if (!fs.existsSync(LOG_FILE)) {
|
|
330
|
+
return { success: false, error: 'Log dosyası bulunamadı' };
|
|
331
|
+
}
|
|
332
|
+
const content = fs.readFileSync(LOG_FILE, 'utf-8');
|
|
333
|
+
const allLines = content.split('\n').filter(l => l.trim());
|
|
334
|
+
const recentLines = allLines.slice(-lines);
|
|
335
|
+
return { success: true, logs: recentLines.join('\n'), count: recentLines.length };
|
|
336
|
+
} catch (error) {
|
|
337
|
+
return { success: false, error: error.message };
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Log temizle
|
|
343
|
+
*/
|
|
344
|
+
clearLogs() {
|
|
345
|
+
try {
|
|
346
|
+
fs.writeFileSync(LOG_FILE, '');
|
|
347
|
+
return { success: true, message: 'Loglar temizlendi' };
|
|
348
|
+
} catch (error) {
|
|
349
|
+
return { success: false, error: error.message };
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
354
|
+
// YARDIMCI FONKSİYONLAR
|
|
355
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Shell komutu çalıştır
|
|
359
|
+
*/
|
|
360
|
+
runCommand(cmd, timeout = 30000) {
|
|
361
|
+
try {
|
|
362
|
+
const output = execSync(cmd, { encoding: 'utf-8', timeout });
|
|
363
|
+
return { success: true, output };
|
|
364
|
+
} catch (error) {
|
|
365
|
+
return { success: false, error: error.message, stdout: error.stdout, stderr: error.stderr };
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* JSON parse et
|
|
371
|
+
*/
|
|
372
|
+
parseJSON(data) {
|
|
373
|
+
try {
|
|
374
|
+
return { success: true, data: JSON.parse(data) };
|
|
375
|
+
} catch (error) {
|
|
376
|
+
return { success: false, error: error.message };
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Obje stringify et
|
|
382
|
+
*/
|
|
383
|
+
stringifyJSON(obj, indent = 2) {
|
|
384
|
+
try {
|
|
385
|
+
return { success: true, data: JSON.stringify(obj, null, indent) };
|
|
386
|
+
} catch (error) {
|
|
387
|
+
return { success: false, error: error.message };
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Tarih/saat al
|
|
393
|
+
*/
|
|
394
|
+
getDateTime(format = 'iso') {
|
|
395
|
+
const now = new Date();
|
|
396
|
+
|
|
397
|
+
if (format === 'iso') {
|
|
398
|
+
return { success: true, datetime: now.toISOString() };
|
|
399
|
+
} else if (format === 'human') {
|
|
400
|
+
return { success: true, datetime: now.toLocaleString('tr-TR') };
|
|
401
|
+
} else if (format === 'timestamp') {
|
|
402
|
+
return { success: true, datetime: now.getTime() };
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return { success: true, datetime: now.toISOString() };
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Yardım metni
|
|
410
|
+
*/
|
|
411
|
+
getHelp() {
|
|
412
|
+
return `
|
|
413
|
+
🤖 **Vantuz AI Copilot - Komut Listesi**
|
|
414
|
+
|
|
415
|
+
**📁 Dosya İşlemleri:**
|
|
416
|
+
- readFile <yol> - Dosya oku
|
|
417
|
+
- writeFile <yol> <içerik> - Dosya yaz
|
|
418
|
+
- deleteFile <yol> - Dosya sil (backup ile)
|
|
419
|
+
- listDir <yol> - Dizin içeriği
|
|
420
|
+
- findFiles <desen> - Dosya ara
|
|
421
|
+
|
|
422
|
+
**🗄️ Veritabanı:**
|
|
423
|
+
- query <SQL> - SQL sorgusu
|
|
424
|
+
- getTable <tablo> - Tablo oku
|
|
425
|
+
- insert <tablo> <veri> - Veri ekle
|
|
426
|
+
- update <tablo> <veri> <koşul> - Veri güncelle
|
|
427
|
+
- delete <tablo> <koşul> - Veri sil
|
|
428
|
+
|
|
429
|
+
**🛒 Marketplace:**
|
|
430
|
+
- marketplaceStatus - Bağlı marketplace'leri göster
|
|
431
|
+
- marketplaceAPI <mp> <endpoint> - Marketplace API çağır
|
|
432
|
+
|
|
433
|
+
**⚙️ Sistem:**
|
|
434
|
+
- systemStatus - Sistem durumu
|
|
435
|
+
- restartVantuz - Vantuz'u yeniden başlat
|
|
436
|
+
- getLogs <satır> - Log oku
|
|
437
|
+
- clearLogs - Log temizle
|
|
438
|
+
- runCommand <komut> - Shell komutu çalıştır
|
|
439
|
+
- getDateTime <format> - Tarih/saat
|
|
440
|
+
- help - Bu yardım
|
|
441
|
+
|
|
442
|
+
**💡 Örnekler:**
|
|
443
|
+
- "Stokta kaç ürün var?"
|
|
444
|
+
- "Trendyol'daki siparişleri listele"
|
|
445
|
+
- "Ürün fiyatlarını göster"
|
|
446
|
+
- "Son 100 satırı oku"
|
|
447
|
+
`.trim();
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// Singleton instance
|
|
452
|
+
let copilotInstance = null;
|
|
453
|
+
|
|
454
|
+
module.exports.getCopilot = function() {
|
|
455
|
+
if (!copilotInstance) {
|
|
456
|
+
copilotInstance = new AICopilot();
|
|
457
|
+
}
|
|
458
|
+
return copilotInstance;
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
module.exports.AICopilot = AICopilot;
|
package/core/ai-provider.js
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* Gerçek AI API çağrıları + Context desteği
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const axios = require('axios');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const os = require('os');
|
|
10
10
|
|
|
11
11
|
const LOG_FILE = path.join(os.homedir(), '.vantuz', 'vantuz.log');
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
module.exports.PROVIDER_CONFIG = {
|
|
14
14
|
gemini: {
|
|
15
15
|
url: (apiKey) => `https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=${apiKey}`,
|
|
16
16
|
body: (systemPrompt, message) => ({
|
|
@@ -110,7 +110,7 @@ export const PROVIDER_CONFIG = {
|
|
|
110
110
|
// LOGGING
|
|
111
111
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
module.exports.log = function(level, message, data = null) {
|
|
114
114
|
const timestamp = new Date().toISOString();
|
|
115
115
|
const logLine = `[${timestamp}] [${level}] ${message}${data ? ' | ' + JSON.stringify(data) : ''}\n`;
|
|
116
116
|
|
|
@@ -119,7 +119,7 @@ export function log(level, message, data = null) {
|
|
|
119
119
|
} catch (e) { }
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
module.exports.getLogs = function(lines = 50) {
|
|
123
123
|
try {
|
|
124
124
|
if (!fs.existsSync(LOG_FILE)) {
|
|
125
125
|
return 'Log dosyası bulunamadı.';
|
|
@@ -132,7 +132,7 @@ export function getLogs(lines = 50) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
module.exports.clearLogs = function() {
|
|
136
136
|
try {
|
|
137
137
|
fs.writeFileSync(LOG_FILE, '');
|
|
138
138
|
return true;
|
|
@@ -239,7 +239,7 @@ async function _makeApiRequest(providerName, providerConfig, message, apiKey, sy
|
|
|
239
239
|
return text;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
module.exports.chat = async function(message, config, env) {
|
|
243
243
|
const provider = config.aiProvider || 'gemini';
|
|
244
244
|
const providerConfig = PROVIDER_CONFIG[provider];
|
|
245
245
|
|
|
@@ -248,6 +248,12 @@ export async function chat(message, config, env) {
|
|
|
248
248
|
const workspaceIdentity = loadWorkspaceIdentity();
|
|
249
249
|
const fullSystemPrompt = VANTUZ_SYSTEM_PROMPT + contextInfo + (workspaceIdentity ? `\n\n## MARKA KİMLİĞİ VE STRATEJİ\nAşağıdaki kurallara MUTLAKA uy:${workspaceIdentity}` : '');
|
|
250
250
|
|
|
251
|
+
// Copilot fonksiyonlarını JSON olarak ekle
|
|
252
|
+
const copilotFunctions = getCopilotFunctions();
|
|
253
|
+
const toolsContext = `\n\n## KULLANABİLECEĞİN ARAÇLAR (FUNCTIONS)\nAI Copilot şu araçları kullanabilir:\n${copilotFunctions.help()}\n\nÖNEMLİ: Kullanıcı bir görev istediğinde, bu araçları kullanarak görevi yerine getir. Örneğin:\n- "Stok durumunu göster" derse → copilot.query() veya copilot.getTable() kullan\n- "Dosya oku" derse → copilot.readFile() kullan\n- "Komut çalıştır" derse → copilot.runCommand() kullan\n- "Marketplace durumunu göster" derse → copilot.marketplaceStatus() kullan`;
|
|
254
|
+
|
|
255
|
+
const finalSystemPrompt = fullSystemPrompt + toolsContext;
|
|
256
|
+
|
|
251
257
|
log('INFO', `AI isteği: ${provider}`, { message: message.slice(0, 100) });
|
|
252
258
|
|
|
253
259
|
if (!providerConfig) {
|
|
@@ -295,4 +301,48 @@ export async function chat(message, config, env) {
|
|
|
295
301
|
|
|
296
302
|
|
|
297
303
|
|
|
298
|
-
|
|
304
|
+
module.exports = { chat, log, getLogs, clearLogs, getCopilot, loadWorkspaceIdentity };
|
|
305
|
+
|
|
306
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
307
|
+
// AI COPILOT ENTEGRASYONU
|
|
308
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
309
|
+
|
|
310
|
+
const { getCopilot } = require('./ai-copilot');
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* AI Copilot fonksiyonlarını döndürür
|
|
314
|
+
* Chat fonksiyonuna context olarak eklenebilir
|
|
315
|
+
*/
|
|
316
|
+
function getCopilotFunctions() {
|
|
317
|
+
const copilot = getCopilot();
|
|
318
|
+
return {
|
|
319
|
+
// Dosya işlemleri
|
|
320
|
+
readFile: (path) => copilot.readFile(path),
|
|
321
|
+
writeFile: (path, content) => copilot.writeFile(path, content),
|
|
322
|
+
deleteFile: (path) => copilot.deleteFile(path),
|
|
323
|
+
listDir: (path) => copilot.listDir(path),
|
|
324
|
+
findFiles: (pattern, root) => copilot.findFiles(pattern, root),
|
|
325
|
+
|
|
326
|
+
// Veritabanı
|
|
327
|
+
query: (sql, params) => copilot.query(sql, params),
|
|
328
|
+
getTable: (table) => copilot.getTable(table),
|
|
329
|
+
insert: (table, data) => copilot.insert(table, data),
|
|
330
|
+
update: (table, data, where) => copilot.update(table, data, where),
|
|
331
|
+
delete: (table, where) => copilot.delete(table, where),
|
|
332
|
+
|
|
333
|
+
// Marketplace
|
|
334
|
+
marketplaceStatus: () => copilot.getMarketplaceStatus(),
|
|
335
|
+
marketplaceAPI: (mp, endpoint, method, data) => copilot.callMarketplaceAPI(mp, endpoint, method, data),
|
|
336
|
+
|
|
337
|
+
// Sistem
|
|
338
|
+
systemStatus: () => copilot.getSystemStatus(),
|
|
339
|
+
restartVantuz: () => copilot.restartVantuz(),
|
|
340
|
+
getLogs: (lines) => copilot.getLogs(lines),
|
|
341
|
+
clearLogs: () => copilot.clearLogs(),
|
|
342
|
+
runCommand: (cmd, timeout) => copilot.runCommand(cmd, timeout),
|
|
343
|
+
getDateTime: (format) => copilot.getDateTime(format),
|
|
344
|
+
help: () => copilot.getHelp()
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
module.exports.getCopilotFunctions = getCopilotFunctions;
|