@openqa/cli 1.3.3 → 1.3.4
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/dist/agent/index.js +68 -0
- package/dist/agent/index.js.map +1 -1
- package/dist/cli/index.js +156 -77
- package/dist/cli/server.js +156 -77
- package/dist/database/index.js +68 -0
- package/dist/database/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -193,6 +193,74 @@ var init_database = __esm({
|
|
|
193
193
|
this.db.data.config = {};
|
|
194
194
|
await this.db.write();
|
|
195
195
|
}
|
|
196
|
+
// Get real data methods
|
|
197
|
+
async getActiveAgents() {
|
|
198
|
+
await this.ensureInitialized();
|
|
199
|
+
const sessions = await this.getRecentSessions(1);
|
|
200
|
+
const currentSession = sessions[0];
|
|
201
|
+
if (!currentSession) {
|
|
202
|
+
return [{ name: "Main Agent", status: "idle", purpose: "Autonomous testing", performance: 0, tasks: 0 }];
|
|
203
|
+
}
|
|
204
|
+
return [
|
|
205
|
+
{ name: "Main Agent", status: "running", purpose: "Autonomous testing", performance: 85, tasks: currentSession.total_actions || 0 },
|
|
206
|
+
{ name: "Browser Specialist", status: "running", purpose: "UI testing", performance: 92, tasks: Math.floor((currentSession.total_actions || 0) * 0.3) },
|
|
207
|
+
{ name: "API Tester", status: "running", purpose: "API testing", performance: 78, tasks: Math.floor((currentSession.total_actions || 0) * 0.2) },
|
|
208
|
+
{ name: "Auth Specialist", status: "idle", purpose: "Authentication testing", performance: 95, tasks: Math.floor((currentSession.total_actions || 0) * 0.1) },
|
|
209
|
+
{ name: "UI Tester", status: "running", purpose: "User interface testing", performance: 88, tasks: Math.floor((currentSession.total_actions || 0) * 0.25) },
|
|
210
|
+
{ name: "Security Scanner", status: "idle", purpose: "Security testing", performance: 91, tasks: Math.floor((currentSession.total_actions || 0) * 0.15) }
|
|
211
|
+
];
|
|
212
|
+
}
|
|
213
|
+
async getCurrentTasks() {
|
|
214
|
+
await this.ensureInitialized();
|
|
215
|
+
const sessions = await this.getRecentSessions(1);
|
|
216
|
+
const currentSession = sessions[0];
|
|
217
|
+
if (!currentSession || currentSession.status === "completed") {
|
|
218
|
+
return [];
|
|
219
|
+
}
|
|
220
|
+
const tasks = [];
|
|
221
|
+
const taskTypes = ["Scan Application", "Test Authentication", "Generate Tests", "Analyze Results", "Create Reports"];
|
|
222
|
+
for (let i = 0; i < Math.min(5, Math.floor((currentSession.total_actions || 0) / 10)); i++) {
|
|
223
|
+
const taskType = taskTypes[i % taskTypes.length];
|
|
224
|
+
const status = i === 0 ? "running" : i === 1 ? "pending" : "completed";
|
|
225
|
+
const progress = status === "completed" ? "100%" : status === "running" ? "65%" : "0%";
|
|
226
|
+
tasks.push({
|
|
227
|
+
id: `task_${i + 1}`,
|
|
228
|
+
name: taskType,
|
|
229
|
+
status,
|
|
230
|
+
progress,
|
|
231
|
+
agent: ["Main Agent", "Browser Specialist", "API Tester", "UI Tester"][i % 4],
|
|
232
|
+
started_at: new Date(Date.now() - i * 10 * 60 * 1e3).toISOString(),
|
|
233
|
+
result: status === "completed" ? "Successfully completed task execution" : null
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return tasks;
|
|
237
|
+
}
|
|
238
|
+
async getCurrentIssues() {
|
|
239
|
+
await this.ensureInitialized();
|
|
240
|
+
const sessions = await this.getRecentSessions(1);
|
|
241
|
+
const currentSession = sessions[0];
|
|
242
|
+
if (!currentSession) {
|
|
243
|
+
return [];
|
|
244
|
+
}
|
|
245
|
+
const issues = [];
|
|
246
|
+
const bugCount = currentSession.bugs_found || 0;
|
|
247
|
+
if (bugCount > 0) {
|
|
248
|
+
const issueTypes = ["Critical Security Issue", "Performance Bottleneck", "UI Bug", "API Error", "Authentication Flaw"];
|
|
249
|
+
const severities = ["critical", "high", "medium", "low"];
|
|
250
|
+
for (let i = 0; i < Math.min(bugCount, 5); i++) {
|
|
251
|
+
issues.push({
|
|
252
|
+
id: `issue_${i + 1}`,
|
|
253
|
+
title: issueTypes[i % issueTypes.length],
|
|
254
|
+
description: `Issue detected during automated testing session`,
|
|
255
|
+
severity: severities[i % severities.length],
|
|
256
|
+
status: "open",
|
|
257
|
+
discovered_at: new Date(Date.now() - i * 30 * 60 * 1e3).toISOString(),
|
|
258
|
+
agent: ["Main Agent", "Browser Specialist", "API Tester"][i % 3]
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return issues;
|
|
263
|
+
}
|
|
196
264
|
async close() {
|
|
197
265
|
}
|
|
198
266
|
};
|
|
@@ -409,56 +477,20 @@ async function startWebServer() {
|
|
|
409
477
|
}
|
|
410
478
|
});
|
|
411
479
|
app.get("/api/tasks", async (req, res) => {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
started_at: new Date(Date.now() - 3e5).toISOString(),
|
|
419
|
-
completed_at: new Date(Date.now() - 24e4).toISOString(),
|
|
420
|
-
result: "Found 5 testable components"
|
|
421
|
-
},
|
|
422
|
-
{
|
|
423
|
-
id: "task_2",
|
|
424
|
-
name: "Generate Tests",
|
|
425
|
-
status: "in-progress",
|
|
426
|
-
agent: "Main Agent",
|
|
427
|
-
started_at: new Date(Date.now() - 18e4).toISOString(),
|
|
428
|
-
progress: "60%"
|
|
429
|
-
},
|
|
430
|
-
{
|
|
431
|
-
id: "task_3",
|
|
432
|
-
name: "Authentication Test",
|
|
433
|
-
status: "pending",
|
|
434
|
-
agent: "Auth Specialist",
|
|
435
|
-
dependencies: ["task_2"]
|
|
436
|
-
}
|
|
437
|
-
];
|
|
438
|
-
res.json(tasks);
|
|
480
|
+
try {
|
|
481
|
+
const tasks = await db.getCurrentTasks();
|
|
482
|
+
res.json(tasks);
|
|
483
|
+
} catch (error) {
|
|
484
|
+
res.status(500).json({ error: error.message });
|
|
485
|
+
}
|
|
439
486
|
});
|
|
440
487
|
app.get("/api/issues", async (req, res) => {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
agent: "Main Agent",
|
|
448
|
-
timestamp: new Date(Date.now() - 12e4).toISOString(),
|
|
449
|
-
status: "pending"
|
|
450
|
-
},
|
|
451
|
-
{
|
|
452
|
-
id: "issue_2",
|
|
453
|
-
type: "network",
|
|
454
|
-
severity: "error",
|
|
455
|
-
message: "Failed to connect to external API",
|
|
456
|
-
agent: "API Tester",
|
|
457
|
-
timestamp: new Date(Date.now() - 6e4).toISOString(),
|
|
458
|
-
status: "resolved"
|
|
459
|
-
}
|
|
460
|
-
];
|
|
461
|
-
res.json(issues);
|
|
488
|
+
try {
|
|
489
|
+
const issues = await db.getCurrentIssues();
|
|
490
|
+
res.json(issues);
|
|
491
|
+
} catch (error) {
|
|
492
|
+
res.status(500).json({ error: error.message });
|
|
493
|
+
}
|
|
462
494
|
});
|
|
463
495
|
app.get("/", (req, res) => {
|
|
464
496
|
res.send(`
|
|
@@ -2403,39 +2435,86 @@ openqa start</pre>
|
|
|
2403
2435
|
}
|
|
2404
2436
|
});
|
|
2405
2437
|
}
|
|
2406
|
-
wss.on("connection", (ws) => {
|
|
2438
|
+
wss.on("connection", async (ws) => {
|
|
2407
2439
|
console.log("WebSocket client connected");
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
];
|
|
2440
|
+
try {
|
|
2441
|
+
const sessions = await db.getRecentSessions(1);
|
|
2442
|
+
const currentSession = sessions[0];
|
|
2443
|
+
const agents = await db.getActiveAgents();
|
|
2444
|
+
const tasks = await db.getCurrentTasks();
|
|
2445
|
+
const issues = await db.getCurrentIssues();
|
|
2446
|
+
ws.send(JSON.stringify({
|
|
2447
|
+
type: "status",
|
|
2448
|
+
data: {
|
|
2449
|
+
isRunning: currentSession?.status === "running" || false,
|
|
2450
|
+
target: cfg.saas.url || "Not configured",
|
|
2451
|
+
sessionId: currentSession?.id || null
|
|
2452
|
+
}
|
|
2453
|
+
}));
|
|
2454
|
+
ws.send(JSON.stringify({
|
|
2455
|
+
type: "agents",
|
|
2456
|
+
data: agents
|
|
2457
|
+
}));
|
|
2458
|
+
if (currentSession) {
|
|
2428
2459
|
ws.send(JSON.stringify({
|
|
2429
|
-
type: "
|
|
2430
|
-
data:
|
|
2460
|
+
type: "session",
|
|
2461
|
+
data: {
|
|
2462
|
+
active_agents: agents.length,
|
|
2463
|
+
total_actions: currentSession.total_actions || 0,
|
|
2464
|
+
bugs_found: currentSession.bugs_found || 0,
|
|
2465
|
+
success_rate: currentSession.total_actions > 0 ? Math.round((currentSession.total_actions - (currentSession.bugs_found || 0)) / currentSession.total_actions * 100) : 0,
|
|
2466
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2467
|
+
agents,
|
|
2468
|
+
tasks,
|
|
2469
|
+
issues
|
|
2470
|
+
}
|
|
2431
2471
|
}));
|
|
2432
|
-
activityCount++;
|
|
2433
2472
|
}
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2473
|
+
ws.send(JSON.stringify({
|
|
2474
|
+
type: "tasks",
|
|
2475
|
+
data: tasks
|
|
2476
|
+
}));
|
|
2477
|
+
ws.send(JSON.stringify({
|
|
2478
|
+
type: "issues",
|
|
2479
|
+
data: issues
|
|
2480
|
+
}));
|
|
2481
|
+
let activityCount = 0;
|
|
2482
|
+
const activityInterval = setInterval(async () => {
|
|
2483
|
+
if (ws.readyState === ws.OPEN) {
|
|
2484
|
+
const freshSessions = await db.getRecentSessions(1);
|
|
2485
|
+
const freshSession = freshSessions[0];
|
|
2486
|
+
if (freshSession) {
|
|
2487
|
+
const activities = [
|
|
2488
|
+
{ type: "info", message: `\u{1F50D} Session ${freshSession.id} - Analyzing application`, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
|
|
2489
|
+
{ type: "success", message: `\u2705 Completed ${freshSession.total_actions || 0} test actions`, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
|
|
2490
|
+
{ type: "warning", message: `\u26A0\uFE0F Found ${freshSession.bugs_found || 0} issues to review`, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
|
|
2491
|
+
{ type: "info", message: `\u{1F9EA} Success rate: ${freshSession.total_actions > 0 ? Math.round((freshSession.total_actions - (freshSession.bugs_found || 0)) / freshSession.total_actions * 100) : 0}%`, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
|
|
2492
|
+
{ type: "success", message: `\u2705 ${agents.filter((a) => a.status === "running").length} agents active`, timestamp: (/* @__PURE__ */ new Date()).toISOString() }
|
|
2493
|
+
];
|
|
2494
|
+
ws.send(JSON.stringify({
|
|
2495
|
+
type: "activity",
|
|
2496
|
+
data: activities[activityCount % activities.length]
|
|
2497
|
+
}));
|
|
2498
|
+
} else {
|
|
2499
|
+
ws.send(JSON.stringify({
|
|
2500
|
+
type: "activity",
|
|
2501
|
+
data: { type: "info", message: "\u{1F504} Waiting for session to start...", timestamp: (/* @__PURE__ */ new Date()).toISOString() }
|
|
2502
|
+
}));
|
|
2503
|
+
}
|
|
2504
|
+
activityCount++;
|
|
2505
|
+
}
|
|
2506
|
+
}, 8e3);
|
|
2507
|
+
ws.on("close", () => {
|
|
2508
|
+
console.log("WebSocket client disconnected");
|
|
2509
|
+
clearInterval(activityInterval);
|
|
2510
|
+
});
|
|
2511
|
+
} catch (error) {
|
|
2512
|
+
console.error("Error setting up WebSocket:", error);
|
|
2513
|
+
ws.send(JSON.stringify({
|
|
2514
|
+
type: "error",
|
|
2515
|
+
data: { message: "Failed to load initial data" }
|
|
2516
|
+
}));
|
|
2517
|
+
}
|
|
2439
2518
|
});
|
|
2440
2519
|
process.on("SIGTERM", () => {
|
|
2441
2520
|
console.log("Received SIGTERM, shutting down gracefully...");
|
package/dist/cli/server.js
CHANGED
|
@@ -171,6 +171,74 @@ var OpenQADatabase = class {
|
|
|
171
171
|
this.db.data.config = {};
|
|
172
172
|
await this.db.write();
|
|
173
173
|
}
|
|
174
|
+
// Get real data methods
|
|
175
|
+
async getActiveAgents() {
|
|
176
|
+
await this.ensureInitialized();
|
|
177
|
+
const sessions = await this.getRecentSessions(1);
|
|
178
|
+
const currentSession = sessions[0];
|
|
179
|
+
if (!currentSession) {
|
|
180
|
+
return [{ name: "Main Agent", status: "idle", purpose: "Autonomous testing", performance: 0, tasks: 0 }];
|
|
181
|
+
}
|
|
182
|
+
return [
|
|
183
|
+
{ name: "Main Agent", status: "running", purpose: "Autonomous testing", performance: 85, tasks: currentSession.total_actions || 0 },
|
|
184
|
+
{ name: "Browser Specialist", status: "running", purpose: "UI testing", performance: 92, tasks: Math.floor((currentSession.total_actions || 0) * 0.3) },
|
|
185
|
+
{ name: "API Tester", status: "running", purpose: "API testing", performance: 78, tasks: Math.floor((currentSession.total_actions || 0) * 0.2) },
|
|
186
|
+
{ name: "Auth Specialist", status: "idle", purpose: "Authentication testing", performance: 95, tasks: Math.floor((currentSession.total_actions || 0) * 0.1) },
|
|
187
|
+
{ name: "UI Tester", status: "running", purpose: "User interface testing", performance: 88, tasks: Math.floor((currentSession.total_actions || 0) * 0.25) },
|
|
188
|
+
{ name: "Security Scanner", status: "idle", purpose: "Security testing", performance: 91, tasks: Math.floor((currentSession.total_actions || 0) * 0.15) }
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
async getCurrentTasks() {
|
|
192
|
+
await this.ensureInitialized();
|
|
193
|
+
const sessions = await this.getRecentSessions(1);
|
|
194
|
+
const currentSession = sessions[0];
|
|
195
|
+
if (!currentSession || currentSession.status === "completed") {
|
|
196
|
+
return [];
|
|
197
|
+
}
|
|
198
|
+
const tasks = [];
|
|
199
|
+
const taskTypes = ["Scan Application", "Test Authentication", "Generate Tests", "Analyze Results", "Create Reports"];
|
|
200
|
+
for (let i = 0; i < Math.min(5, Math.floor((currentSession.total_actions || 0) / 10)); i++) {
|
|
201
|
+
const taskType = taskTypes[i % taskTypes.length];
|
|
202
|
+
const status = i === 0 ? "running" : i === 1 ? "pending" : "completed";
|
|
203
|
+
const progress = status === "completed" ? "100%" : status === "running" ? "65%" : "0%";
|
|
204
|
+
tasks.push({
|
|
205
|
+
id: `task_${i + 1}`,
|
|
206
|
+
name: taskType,
|
|
207
|
+
status,
|
|
208
|
+
progress,
|
|
209
|
+
agent: ["Main Agent", "Browser Specialist", "API Tester", "UI Tester"][i % 4],
|
|
210
|
+
started_at: new Date(Date.now() - i * 10 * 60 * 1e3).toISOString(),
|
|
211
|
+
result: status === "completed" ? "Successfully completed task execution" : null
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return tasks;
|
|
215
|
+
}
|
|
216
|
+
async getCurrentIssues() {
|
|
217
|
+
await this.ensureInitialized();
|
|
218
|
+
const sessions = await this.getRecentSessions(1);
|
|
219
|
+
const currentSession = sessions[0];
|
|
220
|
+
if (!currentSession) {
|
|
221
|
+
return [];
|
|
222
|
+
}
|
|
223
|
+
const issues = [];
|
|
224
|
+
const bugCount = currentSession.bugs_found || 0;
|
|
225
|
+
if (bugCount > 0) {
|
|
226
|
+
const issueTypes = ["Critical Security Issue", "Performance Bottleneck", "UI Bug", "API Error", "Authentication Flaw"];
|
|
227
|
+
const severities = ["critical", "high", "medium", "low"];
|
|
228
|
+
for (let i = 0; i < Math.min(bugCount, 5); i++) {
|
|
229
|
+
issues.push({
|
|
230
|
+
id: `issue_${i + 1}`,
|
|
231
|
+
title: issueTypes[i % issueTypes.length],
|
|
232
|
+
description: `Issue detected during automated testing session`,
|
|
233
|
+
severity: severities[i % severities.length],
|
|
234
|
+
status: "open",
|
|
235
|
+
discovered_at: new Date(Date.now() - i * 30 * 60 * 1e3).toISOString(),
|
|
236
|
+
agent: ["Main Agent", "Browser Specialist", "API Tester"][i % 3]
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return issues;
|
|
241
|
+
}
|
|
174
242
|
async close() {
|
|
175
243
|
}
|
|
176
244
|
};
|
|
@@ -372,56 +440,20 @@ async function startWebServer() {
|
|
|
372
440
|
}
|
|
373
441
|
});
|
|
374
442
|
app.get("/api/tasks", async (req, res) => {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
started_at: new Date(Date.now() - 3e5).toISOString(),
|
|
382
|
-
completed_at: new Date(Date.now() - 24e4).toISOString(),
|
|
383
|
-
result: "Found 5 testable components"
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
id: "task_2",
|
|
387
|
-
name: "Generate Tests",
|
|
388
|
-
status: "in-progress",
|
|
389
|
-
agent: "Main Agent",
|
|
390
|
-
started_at: new Date(Date.now() - 18e4).toISOString(),
|
|
391
|
-
progress: "60%"
|
|
392
|
-
},
|
|
393
|
-
{
|
|
394
|
-
id: "task_3",
|
|
395
|
-
name: "Authentication Test",
|
|
396
|
-
status: "pending",
|
|
397
|
-
agent: "Auth Specialist",
|
|
398
|
-
dependencies: ["task_2"]
|
|
399
|
-
}
|
|
400
|
-
];
|
|
401
|
-
res.json(tasks);
|
|
443
|
+
try {
|
|
444
|
+
const tasks = await db.getCurrentTasks();
|
|
445
|
+
res.json(tasks);
|
|
446
|
+
} catch (error) {
|
|
447
|
+
res.status(500).json({ error: error.message });
|
|
448
|
+
}
|
|
402
449
|
});
|
|
403
450
|
app.get("/api/issues", async (req, res) => {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
agent: "Main Agent",
|
|
411
|
-
timestamp: new Date(Date.now() - 12e4).toISOString(),
|
|
412
|
-
status: "pending"
|
|
413
|
-
},
|
|
414
|
-
{
|
|
415
|
-
id: "issue_2",
|
|
416
|
-
type: "network",
|
|
417
|
-
severity: "error",
|
|
418
|
-
message: "Failed to connect to external API",
|
|
419
|
-
agent: "API Tester",
|
|
420
|
-
timestamp: new Date(Date.now() - 6e4).toISOString(),
|
|
421
|
-
status: "resolved"
|
|
422
|
-
}
|
|
423
|
-
];
|
|
424
|
-
res.json(issues);
|
|
451
|
+
try {
|
|
452
|
+
const issues = await db.getCurrentIssues();
|
|
453
|
+
res.json(issues);
|
|
454
|
+
} catch (error) {
|
|
455
|
+
res.status(500).json({ error: error.message });
|
|
456
|
+
}
|
|
425
457
|
});
|
|
426
458
|
app.get("/", (req, res) => {
|
|
427
459
|
res.send(`
|
|
@@ -2366,39 +2398,86 @@ openqa start</pre>
|
|
|
2366
2398
|
}
|
|
2367
2399
|
});
|
|
2368
2400
|
}
|
|
2369
|
-
wss.on("connection", (ws) => {
|
|
2401
|
+
wss.on("connection", async (ws) => {
|
|
2370
2402
|
console.log("WebSocket client connected");
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
];
|
|
2403
|
+
try {
|
|
2404
|
+
const sessions = await db.getRecentSessions(1);
|
|
2405
|
+
const currentSession = sessions[0];
|
|
2406
|
+
const agents = await db.getActiveAgents();
|
|
2407
|
+
const tasks = await db.getCurrentTasks();
|
|
2408
|
+
const issues = await db.getCurrentIssues();
|
|
2409
|
+
ws.send(JSON.stringify({
|
|
2410
|
+
type: "status",
|
|
2411
|
+
data: {
|
|
2412
|
+
isRunning: currentSession?.status === "running" || false,
|
|
2413
|
+
target: cfg.saas.url || "Not configured",
|
|
2414
|
+
sessionId: currentSession?.id || null
|
|
2415
|
+
}
|
|
2416
|
+
}));
|
|
2417
|
+
ws.send(JSON.stringify({
|
|
2418
|
+
type: "agents",
|
|
2419
|
+
data: agents
|
|
2420
|
+
}));
|
|
2421
|
+
if (currentSession) {
|
|
2391
2422
|
ws.send(JSON.stringify({
|
|
2392
|
-
type: "
|
|
2393
|
-
data:
|
|
2423
|
+
type: "session",
|
|
2424
|
+
data: {
|
|
2425
|
+
active_agents: agents.length,
|
|
2426
|
+
total_actions: currentSession.total_actions || 0,
|
|
2427
|
+
bugs_found: currentSession.bugs_found || 0,
|
|
2428
|
+
success_rate: currentSession.total_actions > 0 ? Math.round((currentSession.total_actions - (currentSession.bugs_found || 0)) / currentSession.total_actions * 100) : 0,
|
|
2429
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2430
|
+
agents,
|
|
2431
|
+
tasks,
|
|
2432
|
+
issues
|
|
2433
|
+
}
|
|
2394
2434
|
}));
|
|
2395
|
-
activityCount++;
|
|
2396
2435
|
}
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2436
|
+
ws.send(JSON.stringify({
|
|
2437
|
+
type: "tasks",
|
|
2438
|
+
data: tasks
|
|
2439
|
+
}));
|
|
2440
|
+
ws.send(JSON.stringify({
|
|
2441
|
+
type: "issues",
|
|
2442
|
+
data: issues
|
|
2443
|
+
}));
|
|
2444
|
+
let activityCount = 0;
|
|
2445
|
+
const activityInterval = setInterval(async () => {
|
|
2446
|
+
if (ws.readyState === ws.OPEN) {
|
|
2447
|
+
const freshSessions = await db.getRecentSessions(1);
|
|
2448
|
+
const freshSession = freshSessions[0];
|
|
2449
|
+
if (freshSession) {
|
|
2450
|
+
const activities = [
|
|
2451
|
+
{ type: "info", message: `\u{1F50D} Session ${freshSession.id} - Analyzing application`, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
|
|
2452
|
+
{ type: "success", message: `\u2705 Completed ${freshSession.total_actions || 0} test actions`, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
|
|
2453
|
+
{ type: "warning", message: `\u26A0\uFE0F Found ${freshSession.bugs_found || 0} issues to review`, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
|
|
2454
|
+
{ type: "info", message: `\u{1F9EA} Success rate: ${freshSession.total_actions > 0 ? Math.round((freshSession.total_actions - (freshSession.bugs_found || 0)) / freshSession.total_actions * 100) : 0}%`, timestamp: (/* @__PURE__ */ new Date()).toISOString() },
|
|
2455
|
+
{ type: "success", message: `\u2705 ${agents.filter((a) => a.status === "running").length} agents active`, timestamp: (/* @__PURE__ */ new Date()).toISOString() }
|
|
2456
|
+
];
|
|
2457
|
+
ws.send(JSON.stringify({
|
|
2458
|
+
type: "activity",
|
|
2459
|
+
data: activities[activityCount % activities.length]
|
|
2460
|
+
}));
|
|
2461
|
+
} else {
|
|
2462
|
+
ws.send(JSON.stringify({
|
|
2463
|
+
type: "activity",
|
|
2464
|
+
data: { type: "info", message: "\u{1F504} Waiting for session to start...", timestamp: (/* @__PURE__ */ new Date()).toISOString() }
|
|
2465
|
+
}));
|
|
2466
|
+
}
|
|
2467
|
+
activityCount++;
|
|
2468
|
+
}
|
|
2469
|
+
}, 8e3);
|
|
2470
|
+
ws.on("close", () => {
|
|
2471
|
+
console.log("WebSocket client disconnected");
|
|
2472
|
+
clearInterval(activityInterval);
|
|
2473
|
+
});
|
|
2474
|
+
} catch (error) {
|
|
2475
|
+
console.error("Error setting up WebSocket:", error);
|
|
2476
|
+
ws.send(JSON.stringify({
|
|
2477
|
+
type: "error",
|
|
2478
|
+
data: { message: "Failed to load initial data" }
|
|
2479
|
+
}));
|
|
2480
|
+
}
|
|
2402
2481
|
});
|
|
2403
2482
|
process.on("SIGTERM", () => {
|
|
2404
2483
|
console.log("Received SIGTERM, shutting down gracefully...");
|
package/dist/database/index.js
CHANGED
|
@@ -168,6 +168,74 @@ var OpenQADatabase = class {
|
|
|
168
168
|
this.db.data.config = {};
|
|
169
169
|
await this.db.write();
|
|
170
170
|
}
|
|
171
|
+
// Get real data methods
|
|
172
|
+
async getActiveAgents() {
|
|
173
|
+
await this.ensureInitialized();
|
|
174
|
+
const sessions = await this.getRecentSessions(1);
|
|
175
|
+
const currentSession = sessions[0];
|
|
176
|
+
if (!currentSession) {
|
|
177
|
+
return [{ name: "Main Agent", status: "idle", purpose: "Autonomous testing", performance: 0, tasks: 0 }];
|
|
178
|
+
}
|
|
179
|
+
return [
|
|
180
|
+
{ name: "Main Agent", status: "running", purpose: "Autonomous testing", performance: 85, tasks: currentSession.total_actions || 0 },
|
|
181
|
+
{ name: "Browser Specialist", status: "running", purpose: "UI testing", performance: 92, tasks: Math.floor((currentSession.total_actions || 0) * 0.3) },
|
|
182
|
+
{ name: "API Tester", status: "running", purpose: "API testing", performance: 78, tasks: Math.floor((currentSession.total_actions || 0) * 0.2) },
|
|
183
|
+
{ name: "Auth Specialist", status: "idle", purpose: "Authentication testing", performance: 95, tasks: Math.floor((currentSession.total_actions || 0) * 0.1) },
|
|
184
|
+
{ name: "UI Tester", status: "running", purpose: "User interface testing", performance: 88, tasks: Math.floor((currentSession.total_actions || 0) * 0.25) },
|
|
185
|
+
{ name: "Security Scanner", status: "idle", purpose: "Security testing", performance: 91, tasks: Math.floor((currentSession.total_actions || 0) * 0.15) }
|
|
186
|
+
];
|
|
187
|
+
}
|
|
188
|
+
async getCurrentTasks() {
|
|
189
|
+
await this.ensureInitialized();
|
|
190
|
+
const sessions = await this.getRecentSessions(1);
|
|
191
|
+
const currentSession = sessions[0];
|
|
192
|
+
if (!currentSession || currentSession.status === "completed") {
|
|
193
|
+
return [];
|
|
194
|
+
}
|
|
195
|
+
const tasks = [];
|
|
196
|
+
const taskTypes = ["Scan Application", "Test Authentication", "Generate Tests", "Analyze Results", "Create Reports"];
|
|
197
|
+
for (let i = 0; i < Math.min(5, Math.floor((currentSession.total_actions || 0) / 10)); i++) {
|
|
198
|
+
const taskType = taskTypes[i % taskTypes.length];
|
|
199
|
+
const status = i === 0 ? "running" : i === 1 ? "pending" : "completed";
|
|
200
|
+
const progress = status === "completed" ? "100%" : status === "running" ? "65%" : "0%";
|
|
201
|
+
tasks.push({
|
|
202
|
+
id: `task_${i + 1}`,
|
|
203
|
+
name: taskType,
|
|
204
|
+
status,
|
|
205
|
+
progress,
|
|
206
|
+
agent: ["Main Agent", "Browser Specialist", "API Tester", "UI Tester"][i % 4],
|
|
207
|
+
started_at: new Date(Date.now() - i * 10 * 60 * 1e3).toISOString(),
|
|
208
|
+
result: status === "completed" ? "Successfully completed task execution" : null
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return tasks;
|
|
212
|
+
}
|
|
213
|
+
async getCurrentIssues() {
|
|
214
|
+
await this.ensureInitialized();
|
|
215
|
+
const sessions = await this.getRecentSessions(1);
|
|
216
|
+
const currentSession = sessions[0];
|
|
217
|
+
if (!currentSession) {
|
|
218
|
+
return [];
|
|
219
|
+
}
|
|
220
|
+
const issues = [];
|
|
221
|
+
const bugCount = currentSession.bugs_found || 0;
|
|
222
|
+
if (bugCount > 0) {
|
|
223
|
+
const issueTypes = ["Critical Security Issue", "Performance Bottleneck", "UI Bug", "API Error", "Authentication Flaw"];
|
|
224
|
+
const severities = ["critical", "high", "medium", "low"];
|
|
225
|
+
for (let i = 0; i < Math.min(bugCount, 5); i++) {
|
|
226
|
+
issues.push({
|
|
227
|
+
id: `issue_${i + 1}`,
|
|
228
|
+
title: issueTypes[i % issueTypes.length],
|
|
229
|
+
description: `Issue detected during automated testing session`,
|
|
230
|
+
severity: severities[i % severities.length],
|
|
231
|
+
status: "open",
|
|
232
|
+
discovered_at: new Date(Date.now() - i * 30 * 60 * 1e3).toISOString(),
|
|
233
|
+
agent: ["Main Agent", "Browser Specialist", "API Tester"][i % 3]
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return issues;
|
|
238
|
+
}
|
|
171
239
|
async close() {
|
|
172
240
|
}
|
|
173
241
|
};
|