@codebolt/codeboltjs 5.0.6 → 5.0.8
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/core/Codebolt.d.ts +354 -350
- package/dist/core/Codebolt.js +2 -0
- package/dist/index.d.ts +65 -29
- package/dist/index.js +121 -9
- package/dist/modules/actionPlan.d.ts +6 -18
- package/dist/modules/agentDeliberation.d.ts +1 -1
- package/dist/modules/agentDeliberation.js +9 -9
- package/dist/modules/agentEventQueue.d.ts +45 -3
- package/dist/modules/agentEventQueue.js +172 -20
- package/dist/modules/autoTesting.d.ts +1 -1
- package/dist/modules/autoTesting.js +19 -19
- package/dist/modules/backgroundChildThreads.d.ts +16 -17
- package/dist/modules/backgroundChildThreads.js +39 -16
- package/dist/modules/browser.d.ts +7 -6
- package/dist/modules/browser.js +4 -4
- package/dist/modules/chat.d.ts +10 -14
- package/dist/modules/chat.js +7 -5
- package/dist/modules/codebaseSearch.d.ts +1 -1
- package/dist/modules/codemap.d.ts +1 -1
- package/dist/modules/contextAssembly.d.ts +1 -1
- package/dist/modules/contextRuleEngine.d.ts +1 -1
- package/dist/modules/eventLog.d.ts +1 -1
- package/dist/modules/fileUpdateIntent.d.ts +1 -1
- package/dist/modules/groupFeedback.d.ts +2 -2
- package/dist/modules/groupFeedback.js +8 -8
- package/dist/modules/hook.d.ts +1 -1
- package/dist/modules/job.d.ts +1 -1
- package/dist/modules/knowledgeGraph.d.ts +1 -1
- package/dist/modules/kvStore.d.ts +1 -1
- package/dist/modules/mail.d.ts +2 -91
- package/dist/modules/mcp.js +3 -3
- package/dist/modules/memoryIngestion.d.ts +1 -1
- package/dist/modules/orchestrator.d.ts +3 -43
- package/dist/modules/orchestrator.js +2 -2
- package/dist/modules/persistentMemory.d.ts +1 -1
- package/dist/modules/projectStructure.d.ts +1 -1
- package/dist/modules/projectStructureUpdateRequest.d.ts +1 -1
- package/dist/modules/reviewMergeRequest.d.ts +6 -2
- package/dist/modules/roadmap.d.ts +1 -1
- package/dist/modules/swarm.d.ts +2 -2
- package/dist/modules/terminal.d.ts +2 -2
- package/dist/modules/thread.d.ts +12 -10
- package/dist/modules/thread.js +11 -7
- package/dist/modules/user-message-manager.js +4 -4
- package/dist/tools/actionPlan/action-plan-add-task.d.ts +3 -2
- package/dist/tools/agentEventQueue/eventqueue-send-message.js +1 -1
- package/dist/tools/chat/chat-send.d.ts +1 -1
- package/dist/tools/index.d.ts +2 -2
- package/dist/tools/index.js +54 -59
- package/dist/tools/planning/plan-add-task.d.ts +2 -22
- package/dist/tools/requirementPlan/requirement-plan-add-section.js +1 -1
- package/dist/tools/review/review-create.js +1 -1
- package/dist/tools/reviewMergeRequest/rmr-create.js +3 -2
- package/dist/tools/thread/thread-create-background.d.ts +7 -3
- package/dist/tools/thread/thread-create-background.js +31 -11
- package/package.json +5 -4
|
@@ -11,22 +11,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.AgentEventPriority = exports.AgentEventStatus = exports.AgentEventType = void 0;
|
|
12
12
|
const websocket_1 = __importDefault(require("../core/websocket"));
|
|
13
13
|
const crypto_1 = require("crypto");
|
|
14
|
-
var
|
|
15
|
-
Object.defineProperty(exports, "AgentEventType", { enumerable: true, get: function () { return
|
|
16
|
-
Object.defineProperty(exports, "AgentEventStatus", { enumerable: true, get: function () { return
|
|
17
|
-
Object.defineProperty(exports, "AgentEventPriority", { enumerable: true, get: function () { return
|
|
14
|
+
var lib_1 = require("@codebolt/types/lib");
|
|
15
|
+
Object.defineProperty(exports, "AgentEventType", { enumerable: true, get: function () { return lib_1.AgentEventType; } });
|
|
16
|
+
Object.defineProperty(exports, "AgentEventStatus", { enumerable: true, get: function () { return lib_1.AgentEventStatus; } });
|
|
17
|
+
Object.defineProperty(exports, "AgentEventPriority", { enumerable: true, get: function () { return lib_1.AgentEventPriority; } });
|
|
18
18
|
// ============================================================================
|
|
19
19
|
// Local Event Cache
|
|
20
20
|
// ============================================================================
|
|
21
|
-
/** Local cache for events received via WebSocket */
|
|
21
|
+
/** Local cache for agent events received via WebSocket */
|
|
22
22
|
const localEventCache = new Map();
|
|
23
|
+
/** Unified cache for all external events (queue events, background completions, grouped completions) */
|
|
24
|
+
const pendingExternalEvents = [];
|
|
23
25
|
/** Registered event handlers */
|
|
24
26
|
const eventHandlers = new Set();
|
|
25
27
|
/** Event emitter for waiting promises */
|
|
26
28
|
const events_1 = require("events");
|
|
27
29
|
const eventEmitter = new events_1.EventEmitter();
|
|
28
30
|
// ============================================================================
|
|
29
|
-
// WebSocket
|
|
31
|
+
// WebSocket Subscriptions
|
|
30
32
|
// ============================================================================
|
|
31
33
|
// Subscribe to agentEvent messages from WebSocket
|
|
32
34
|
const agentEventSubscription = websocket_1.default.messageManager.subscribe('agentEvent');
|
|
@@ -35,8 +37,11 @@ agentEventSubscription.on('message', (message) => {
|
|
|
35
37
|
if (event && event.eventId) {
|
|
36
38
|
// Store in local cache
|
|
37
39
|
localEventCache.set(event.eventId, event);
|
|
40
|
+
// Also push to unified external events cache
|
|
41
|
+
pendingExternalEvents.push({ type: 'agentQueueEvent', data: event });
|
|
38
42
|
// Notify waiting promises
|
|
39
43
|
eventEmitter.emit('newEvent', event);
|
|
44
|
+
eventEmitter.emit('externalEvent', { type: 'agentQueueEvent', data: event });
|
|
40
45
|
// Call registered handlers
|
|
41
46
|
for (const handler of eventHandlers) {
|
|
42
47
|
try {
|
|
@@ -48,6 +53,33 @@ agentEventSubscription.on('message', (message) => {
|
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
55
|
});
|
|
56
|
+
// Subscribe to background agent completion messages
|
|
57
|
+
const backgroundAgentSubscription = websocket_1.default.messageManager.subscribe('startThreadResponse');
|
|
58
|
+
backgroundAgentSubscription.on('message', (message) => {
|
|
59
|
+
if (message.threadId) {
|
|
60
|
+
const externalEvent = { type: 'backgroundAgentCompletion', data: message };
|
|
61
|
+
pendingExternalEvents.push(externalEvent);
|
|
62
|
+
eventEmitter.emit('externalEvent', externalEvent);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
// Subscribe to ThreadCompleted as an alternative message type
|
|
66
|
+
const threadCompletedSubscription = websocket_1.default.messageManager.subscribe('ThreadCompleted');
|
|
67
|
+
threadCompletedSubscription.on('message', (message) => {
|
|
68
|
+
if (message.threadId) {
|
|
69
|
+
const externalEvent = { type: 'backgroundAgentCompletion', data: message };
|
|
70
|
+
pendingExternalEvents.push(externalEvent);
|
|
71
|
+
eventEmitter.emit('externalEvent', externalEvent);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
// Subscribe to grouped agent completion messages
|
|
75
|
+
const groupedAgentSubscription = websocket_1.default.messageManager.subscribe('backgroundGroupedAgentCompletion');
|
|
76
|
+
groupedAgentSubscription.on('message', (message) => {
|
|
77
|
+
if (message.threadId) {
|
|
78
|
+
const externalEvent = { type: 'backgroundGroupedAgentCompletion', data: message };
|
|
79
|
+
pendingExternalEvents.push(externalEvent);
|
|
80
|
+
eventEmitter.emit('externalEvent', externalEvent);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
51
83
|
// ============================================================================
|
|
52
84
|
// Agent Event Queue Module
|
|
53
85
|
// ============================================================================
|
|
@@ -66,7 +98,7 @@ const agentEventQueue = {
|
|
|
66
98
|
type: 'agentEventQueue.addEventForAgent',
|
|
67
99
|
requestId,
|
|
68
100
|
params
|
|
69
|
-
}, '
|
|
101
|
+
}, 'agentEventQueue.addEventForAgentResponse');
|
|
70
102
|
},
|
|
71
103
|
/**
|
|
72
104
|
* Send an inter-agent message (convenience wrapper)
|
|
@@ -79,7 +111,7 @@ const agentEventQueue = {
|
|
|
79
111
|
type: 'agentEventQueue.sendAgentMessage',
|
|
80
112
|
requestId,
|
|
81
113
|
params
|
|
82
|
-
}, '
|
|
114
|
+
}, 'agentEventQueue.sendAgentMessageResponse');
|
|
83
115
|
},
|
|
84
116
|
/**
|
|
85
117
|
* Get queue statistics
|
|
@@ -91,7 +123,7 @@ const agentEventQueue = {
|
|
|
91
123
|
type: 'agentEventQueue.getQueueStats',
|
|
92
124
|
requestId,
|
|
93
125
|
params: {}
|
|
94
|
-
}, '
|
|
126
|
+
}, 'agentEventQueue.getQueueStatsResponse');
|
|
95
127
|
},
|
|
96
128
|
/**
|
|
97
129
|
* Clear the queue for an agent
|
|
@@ -104,7 +136,7 @@ const agentEventQueue = {
|
|
|
104
136
|
type: 'agentEventQueue.clearQueue',
|
|
105
137
|
requestId,
|
|
106
138
|
params: { agentId }
|
|
107
|
-
}, '
|
|
139
|
+
}, 'agentEventQueue.clearQueueResponse');
|
|
108
140
|
},
|
|
109
141
|
// ========================================================================
|
|
110
142
|
// Internal Acknowledgement Helper
|
|
@@ -125,7 +157,7 @@ const agentEventQueue = {
|
|
|
125
157
|
success,
|
|
126
158
|
errorMessage
|
|
127
159
|
}
|
|
128
|
-
}, '
|
|
160
|
+
}, 'agentEventQueue.ackEventResponse');
|
|
129
161
|
},
|
|
130
162
|
/**
|
|
131
163
|
* Fetch pending events from backend
|
|
@@ -133,15 +165,37 @@ const agentEventQueue = {
|
|
|
133
165
|
*/
|
|
134
166
|
_fetchPendingFromBackend: async (params = {}) => {
|
|
135
167
|
const requestId = (0, crypto_1.randomUUID)();
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
168
|
+
try {
|
|
169
|
+
const response = await websocket_1.default.messageManager.sendAndWaitForResponse({
|
|
170
|
+
type: 'agentEventQueue.getPendingEvents',
|
|
171
|
+
requestId,
|
|
172
|
+
params
|
|
173
|
+
}, 'agentEventQueue.getPendingEventsResponse');
|
|
174
|
+
console.log('[AgentEventQueue] Backend response:', JSON.stringify(response, null, 2));
|
|
175
|
+
if (response.success && response.data) {
|
|
176
|
+
// Handle case where data itself is the array
|
|
177
|
+
if (Array.isArray(response.data)) {
|
|
178
|
+
return response.data;
|
|
179
|
+
}
|
|
180
|
+
// Handle case where events are nested under data.events
|
|
181
|
+
const events = response.data.events;
|
|
182
|
+
if (Array.isArray(events)) {
|
|
183
|
+
return events;
|
|
184
|
+
}
|
|
185
|
+
console.warn('[AgentEventQueue] response.data.events is not an array:', typeof events, events);
|
|
186
|
+
return [];
|
|
187
|
+
}
|
|
188
|
+
// Handle case where events are at response root level (not nested under data)
|
|
189
|
+
const responseAny = response;
|
|
190
|
+
if (response.success && Array.isArray(responseAny.events)) {
|
|
191
|
+
return responseAny.events;
|
|
192
|
+
}
|
|
193
|
+
return [];
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
console.error('[AgentEventQueue] Error fetching pending events from backend:', error);
|
|
197
|
+
return [];
|
|
143
198
|
}
|
|
144
|
-
return [];
|
|
145
199
|
},
|
|
146
200
|
// ========================================================================
|
|
147
201
|
// Local Event Management Functions
|
|
@@ -157,6 +211,7 @@ const agentEventQueue = {
|
|
|
157
211
|
getPendingQueueEvents: async (maxDepth) => {
|
|
158
212
|
const events = [];
|
|
159
213
|
const eventIds = Array.from(localEventCache.keys());
|
|
214
|
+
console.log('[AgentEventQueue] getPendingQueueEvents - localEventCache size:', localEventCache.size);
|
|
160
215
|
// Determine how many events to process
|
|
161
216
|
const limit = maxDepth !== undefined ? Math.min(maxDepth, eventIds.length) : eventIds.length;
|
|
162
217
|
// Get events from local cache
|
|
@@ -164,16 +219,27 @@ const agentEventQueue = {
|
|
|
164
219
|
const eventId = eventIds[i];
|
|
165
220
|
const event = localEventCache.get(eventId);
|
|
166
221
|
if (event) {
|
|
222
|
+
console.log('[AgentEventQueue] Local cache event:', eventId, 'has eventId field:', !!event.eventId);
|
|
167
223
|
events.push(event);
|
|
168
224
|
}
|
|
169
225
|
}
|
|
170
226
|
// If no local events, try fetching from backend
|
|
171
227
|
if (events.length === 0) {
|
|
172
228
|
const backendEvents = await agentEventQueue._fetchPendingFromBackend({ limit: maxDepth });
|
|
229
|
+
console.log('[AgentEventQueue] getPendingQueueEvents - backendEvents:', Array.isArray(backendEvents) ? `array of ${backendEvents.length}` : typeof backendEvents, JSON.stringify(backendEvents, null, 2));
|
|
230
|
+
// Ensure backendEvents is an array
|
|
231
|
+
if (!Array.isArray(backendEvents)) {
|
|
232
|
+
console.error('[AgentEventQueue] backendEvents is not an array, returning empty array');
|
|
233
|
+
return [];
|
|
234
|
+
}
|
|
173
235
|
// Acknowledge backend events
|
|
174
236
|
for (const event of backendEvents) {
|
|
175
237
|
try {
|
|
176
|
-
await agentEventQueue._acknowledgeEvent(event.eventId, true);
|
|
238
|
+
const ackResponse = await agentEventQueue._acknowledgeEvent(event.eventId, true);
|
|
239
|
+
console.log(`[AgentEventQueue] Ack response for ${event.eventId}:`, JSON.stringify(ackResponse));
|
|
240
|
+
if (!ackResponse.success) {
|
|
241
|
+
console.error(`[AgentEventQueue] Failed to acknowledge event ${event.eventId}:`, ackResponse.message);
|
|
242
|
+
}
|
|
177
243
|
}
|
|
178
244
|
catch (error) {
|
|
179
245
|
console.error(`[AgentEventQueue] Error acknowledging event ${event.eventId}:`, error);
|
|
@@ -283,6 +349,92 @@ const agentEventQueue = {
|
|
|
283
349
|
*/
|
|
284
350
|
clearLocalCache: () => {
|
|
285
351
|
localEventCache.clear();
|
|
352
|
+
},
|
|
353
|
+
// ========================================================================
|
|
354
|
+
// Unified External Event Handling
|
|
355
|
+
// ========================================================================
|
|
356
|
+
/**
|
|
357
|
+
* Check for any pending external events without waiting.
|
|
358
|
+
* Returns the first pending event or null if none available.
|
|
359
|
+
*
|
|
360
|
+
* @returns {UnifiedExternalEvent | null} The first pending event or null
|
|
361
|
+
*/
|
|
362
|
+
checkForPendingExternalEvent: () => {
|
|
363
|
+
if (pendingExternalEvents.length > 0) {
|
|
364
|
+
return pendingExternalEvents.shift() || null;
|
|
365
|
+
}
|
|
366
|
+
return null;
|
|
367
|
+
},
|
|
368
|
+
/**
|
|
369
|
+
* Get all pending external events.
|
|
370
|
+
* Returns all pending events and clears the cache.
|
|
371
|
+
*
|
|
372
|
+
* @returns {UnifiedExternalEvent[]} Array of pending events
|
|
373
|
+
*/
|
|
374
|
+
getPendingExternalEvents: () => {
|
|
375
|
+
const events = [...pendingExternalEvents];
|
|
376
|
+
pendingExternalEvents.length = 0;
|
|
377
|
+
return events;
|
|
378
|
+
},
|
|
379
|
+
/**
|
|
380
|
+
* Get the count of pending external events.
|
|
381
|
+
*
|
|
382
|
+
* @returns {number} Number of pending events
|
|
383
|
+
*/
|
|
384
|
+
getPendingExternalEventCount: () => {
|
|
385
|
+
return pendingExternalEvents.length;
|
|
386
|
+
},
|
|
387
|
+
/**
|
|
388
|
+
* Waits for any external event from multiple sources:
|
|
389
|
+
* - Agent queue events (from local cache or WebSocket)
|
|
390
|
+
* - Background agent completions
|
|
391
|
+
* - Grouped agent completions
|
|
392
|
+
*
|
|
393
|
+
* Returns the first event that occurs from any source.
|
|
394
|
+
*
|
|
395
|
+
* @returns {Promise<UnifiedExternalEvent>} A promise that resolves with the event type and data
|
|
396
|
+
*/
|
|
397
|
+
waitForAnyExternalEvent: async () => {
|
|
398
|
+
var _a;
|
|
399
|
+
// Check if there are already pending events
|
|
400
|
+
if (pendingExternalEvents.length > 0) {
|
|
401
|
+
const event = pendingExternalEvents.shift();
|
|
402
|
+
// If it's an agent queue event, acknowledge it
|
|
403
|
+
if (event.type === 'agentQueueEvent' && ((_a = event.data) === null || _a === void 0 ? void 0 : _a.eventId)) {
|
|
404
|
+
try {
|
|
405
|
+
await agentEventQueue._acknowledgeEvent(event.data.eventId, true);
|
|
406
|
+
localEventCache.delete(event.data.eventId);
|
|
407
|
+
}
|
|
408
|
+
catch (error) {
|
|
409
|
+
console.error(`[AgentEventQueue] Error acknowledging event ${event.data.eventId}:`, error);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return event;
|
|
413
|
+
}
|
|
414
|
+
// Wait for the next external event
|
|
415
|
+
return new Promise((resolve) => {
|
|
416
|
+
const handler = async (event) => {
|
|
417
|
+
var _a;
|
|
418
|
+
eventEmitter.removeListener('externalEvent', handler);
|
|
419
|
+
// Remove from pending queue (it was added by the subscription)
|
|
420
|
+
const index = pendingExternalEvents.findIndex(e => e === event);
|
|
421
|
+
if (index !== -1) {
|
|
422
|
+
pendingExternalEvents.splice(index, 1);
|
|
423
|
+
}
|
|
424
|
+
// If it's an agent queue event, acknowledge it
|
|
425
|
+
if (event.type === 'agentQueueEvent' && ((_a = event.data) === null || _a === void 0 ? void 0 : _a.eventId)) {
|
|
426
|
+
try {
|
|
427
|
+
await agentEventQueue._acknowledgeEvent(event.data.eventId, true);
|
|
428
|
+
localEventCache.delete(event.data.eventId);
|
|
429
|
+
}
|
|
430
|
+
catch (error) {
|
|
431
|
+
console.error(`[AgentEventQueue] Error acknowledging event ${event.data.eventId}:`, error);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
resolve(event);
|
|
435
|
+
};
|
|
436
|
+
eventEmitter.once('externalEvent', handler);
|
|
437
|
+
});
|
|
286
438
|
}
|
|
287
439
|
};
|
|
288
440
|
exports.default = agentEventQueue;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAddCaseToSuiteParams, IAddCaseToSuiteResponse, ICreateCaseParams, ICreateCaseResponse, ICreateRunParams, ICreateRunResponse, ICreateSuiteParams, ICreateSuiteResponse, IDeleteCaseParams, IDeleteCaseResponse, IDeleteSuiteParams, IDeleteSuiteResponse, IGetCaseParams, IGetCaseResponse, IGetRunParams, IGetRunResponse, IGetSuiteParams, IGetSuiteResponse, IListCasesParams, IListCasesResponse, IListRunsParams, IListRunsResponse, IListSuitesParams, IListSuitesResponse, IRemoveCaseFromSuiteParams, IRemoveCaseFromSuiteResponse, IUpdateCaseParams, IUpdateCaseResponse, IUpdateRunCaseParams, IUpdateRunCaseResponse, IUpdateRunStatusParams, IUpdateRunStatusResponse, IUpdateRunStepParams, IUpdateRunStepResponse, IUpdateSuiteParams, IUpdateSuiteResponse } from '
|
|
1
|
+
import { IAddCaseToSuiteParams, IAddCaseToSuiteResponse, ICreateCaseParams, ICreateCaseResponse, ICreateRunParams, ICreateRunResponse, ICreateSuiteParams, ICreateSuiteResponse, IDeleteCaseParams, IDeleteCaseResponse, IDeleteSuiteParams, IDeleteSuiteResponse, IGetCaseParams, IGetCaseResponse, IGetRunParams, IGetRunResponse, IGetSuiteParams, IGetSuiteResponse, IListCasesParams, IListCasesResponse, IListRunsParams, IListRunsResponse, IListSuitesParams, IListSuitesResponse, IRemoveCaseFromSuiteParams, IRemoveCaseFromSuiteResponse, IUpdateCaseParams, IUpdateCaseResponse, IUpdateRunCaseParams, IUpdateRunCaseResponse, IUpdateRunStatusParams, IUpdateRunStatusResponse, IUpdateRunStepParams, IUpdateRunStepResponse, IUpdateSuiteParams, IUpdateSuiteResponse } from '@codebolt/types/lib';
|
|
2
2
|
declare const cbautoTesting: {
|
|
3
3
|
createSuite: (params: ICreateSuiteParams) => Promise<ICreateSuiteResponse>;
|
|
4
4
|
getSuite: (params: IGetSuiteParams) => Promise<IGetSuiteResponse>;
|
|
@@ -4,28 +4,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const websocket_1 = __importDefault(require("../core/websocket"));
|
|
7
|
-
const
|
|
7
|
+
const lib_1 = require("@codebolt/types/lib");
|
|
8
8
|
const cbautoTesting = {
|
|
9
9
|
// ---- Test Suites ----
|
|
10
|
-
createSuite: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
11
|
-
getSuite: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
12
|
-
listSuites: async (_params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
13
|
-
updateSuite: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
14
|
-
deleteSuite: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
15
|
-
addCaseToSuite: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
16
|
-
removeCaseFromSuite: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
10
|
+
createSuite: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.SUITE_CREATE, ...params }, lib_1.AutoTestingResponseType.SUITE_CREATE_RESPONSE),
|
|
11
|
+
getSuite: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.SUITE_GET, ...params }, lib_1.AutoTestingResponseType.SUITE_GET_RESPONSE),
|
|
12
|
+
listSuites: async (_params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.SUITE_LIST }, lib_1.AutoTestingResponseType.SUITE_LIST_RESPONSE),
|
|
13
|
+
updateSuite: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.SUITE_UPDATE, ...params }, lib_1.AutoTestingResponseType.SUITE_UPDATE_RESPONSE),
|
|
14
|
+
deleteSuite: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.SUITE_DELETE, ...params }, lib_1.AutoTestingResponseType.SUITE_DELETE_RESPONSE),
|
|
15
|
+
addCaseToSuite: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.SUITE_CASE_ADD, ...params }, lib_1.AutoTestingResponseType.SUITE_CASE_ADD_RESPONSE),
|
|
16
|
+
removeCaseFromSuite: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.SUITE_CASE_REMOVE, ...params }, lib_1.AutoTestingResponseType.SUITE_CASE_REMOVE_RESPONSE),
|
|
17
17
|
// ---- Test Cases ----
|
|
18
|
-
createCase: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
19
|
-
getCase: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
20
|
-
listCases: async (_params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
21
|
-
updateCase: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
22
|
-
deleteCase: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
18
|
+
createCase: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.CASE_CREATE, ...params }, lib_1.AutoTestingResponseType.CASE_CREATE_RESPONSE),
|
|
19
|
+
getCase: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.CASE_GET, ...params }, lib_1.AutoTestingResponseType.CASE_GET_RESPONSE),
|
|
20
|
+
listCases: async (_params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.CASE_LIST }, lib_1.AutoTestingResponseType.CASE_LIST_RESPONSE),
|
|
21
|
+
updateCase: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.CASE_UPDATE, ...params }, lib_1.AutoTestingResponseType.CASE_UPDATE_RESPONSE),
|
|
22
|
+
deleteCase: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.CASE_DELETE, ...params }, lib_1.AutoTestingResponseType.CASE_DELETE_RESPONSE),
|
|
23
23
|
// ---- Test Runs ----
|
|
24
|
-
createRun: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
25
|
-
getRun: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
26
|
-
listRuns: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
27
|
-
updateRunStatus: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
28
|
-
updateRunCaseStatus: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
29
|
-
updateRunStepStatus: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type:
|
|
24
|
+
createRun: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.RUN_CREATE, ...params }, lib_1.AutoTestingResponseType.RUN_CREATE_RESPONSE),
|
|
25
|
+
getRun: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.RUN_GET, ...params }, lib_1.AutoTestingResponseType.RUN_GET_RESPONSE),
|
|
26
|
+
listRuns: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.RUN_LIST, ...(params || {}) }, lib_1.AutoTestingResponseType.RUN_LIST_RESPONSE),
|
|
27
|
+
updateRunStatus: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.RUN_UPDATE_STATUS, ...params }, lib_1.AutoTestingResponseType.RUN_UPDATE_STATUS_RESPONSE),
|
|
28
|
+
updateRunCaseStatus: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.RUN_CASE_UPDATE, ...params }, lib_1.AutoTestingResponseType.RUN_CASE_UPDATE_RESPONSE),
|
|
29
|
+
updateRunStepStatus: async (params) => websocket_1.default.messageManager.sendAndWaitForResponse({ type: lib_1.AutoTestingAction.RUN_STEP_UPDATE, ...params }, lib_1.AutoTestingResponseType.RUN_STEP_UPDATE_RESPONSE),
|
|
30
30
|
};
|
|
31
31
|
exports.default = cbautoTesting;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { BackgroundAgentData, BackgroundAgentCompletion, BackgroundExternalEvent } from '@codebolt/types/sdk';
|
|
2
|
+
export type { BackgroundAgentData, BackgroundAgentCompletion, BackgroundExternalEvent };
|
|
1
3
|
/**
|
|
2
4
|
* Background Child Threads module for tracking and managing background agent threads.
|
|
3
5
|
* This module provides APIs for tracking running background agents and their completion.
|
|
@@ -5,11 +7,11 @@
|
|
|
5
7
|
declare const backgroundChildThreads: {
|
|
6
8
|
/**
|
|
7
9
|
* Adds a running background agent to tracking.
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
10
|
+
* @param threadId - The thread ID
|
|
11
|
+
* @param data - The agent data
|
|
12
|
+
* @param groupId - Optional group ID
|
|
11
13
|
*/
|
|
12
|
-
addRunningAgent: (threadId: string, data:
|
|
14
|
+
addRunningAgent: (threadId: string, data: BackgroundAgentData, groupId?: string) => void;
|
|
13
15
|
/**
|
|
14
16
|
* Gets the number of currently running background agents.
|
|
15
17
|
* @returns {number} The count
|
|
@@ -17,32 +19,29 @@ declare const backgroundChildThreads: {
|
|
|
17
19
|
getRunningAgentCount: () => number;
|
|
18
20
|
/**
|
|
19
21
|
* Checks if any background agent has completed.
|
|
20
|
-
* @returns
|
|
22
|
+
* @returns The completion data if available, or null
|
|
21
23
|
*/
|
|
22
|
-
checkForBackgroundAgentCompletion: () =>
|
|
24
|
+
checkForBackgroundAgentCompletion: () => BackgroundAgentCompletion[] | null;
|
|
23
25
|
/**
|
|
24
26
|
* Waits for background agent completion.
|
|
25
|
-
* @returns
|
|
27
|
+
* @returns A promise that resolves with the completion data
|
|
26
28
|
*/
|
|
27
|
-
onBackgroundAgentCompletion: () => Promise<
|
|
29
|
+
onBackgroundAgentCompletion: () => Promise<BackgroundAgentCompletion[] | null>;
|
|
28
30
|
/**
|
|
29
31
|
* Checks if any grouped background agent has completed.
|
|
30
|
-
* @returns
|
|
32
|
+
* @returns The completion data if available, or null
|
|
31
33
|
*/
|
|
32
|
-
checkForBackgroundGroupedAgentCompletion: () =>
|
|
34
|
+
checkForBackgroundGroupedAgentCompletion: () => BackgroundAgentCompletion | null;
|
|
33
35
|
/**
|
|
34
36
|
* Waits for grouped background agent completion.
|
|
35
|
-
* @returns
|
|
37
|
+
* @returns A promise that resolves with the completion data
|
|
36
38
|
*/
|
|
37
|
-
onBackgroundGroupedAgentCompletion: () => Promise<
|
|
39
|
+
onBackgroundGroupedAgentCompletion: () => Promise<BackgroundAgentCompletion | null>;
|
|
38
40
|
/**
|
|
39
41
|
* Waits for any external event (background agent completion, grouped agent completion, or agent event).
|
|
40
42
|
* Returns the first event that occurs.
|
|
41
|
-
* @returns
|
|
43
|
+
* @returns A promise that resolves with the event type and data
|
|
42
44
|
*/
|
|
43
|
-
waitForAnyExternalEvent: () => Promise<
|
|
44
|
-
type: string;
|
|
45
|
-
data: any;
|
|
46
|
-
}>;
|
|
45
|
+
waitForAnyExternalEvent: () => Promise<BackgroundExternalEvent>;
|
|
47
46
|
};
|
|
48
47
|
export default backgroundChildThreads;
|
|
@@ -10,25 +10,45 @@ const runningBackgroundAgents = new Map();
|
|
|
10
10
|
const completedBackgroundAgents = new Map();
|
|
11
11
|
const groupedAgentCompletionMap = new Map();
|
|
12
12
|
const backgroundAgentGroups = new Map();
|
|
13
|
-
//
|
|
14
|
-
const
|
|
13
|
+
// Track completed agents per group for grouped completion
|
|
14
|
+
const groupCompletedAgents = new Map();
|
|
15
|
+
// Helper to cleanup group membership and check for group completion
|
|
16
|
+
const cleanupAgentGroup = (threadId, completion) => {
|
|
15
17
|
for (const [groupId, agents] of backgroundAgentGroups.entries()) {
|
|
16
18
|
if (agents.has(threadId)) {
|
|
19
|
+
// Track this completion in the group
|
|
20
|
+
if (!groupCompletedAgents.has(groupId)) {
|
|
21
|
+
groupCompletedAgents.set(groupId, []);
|
|
22
|
+
}
|
|
23
|
+
groupCompletedAgents.get(groupId).push(completion);
|
|
17
24
|
agents.delete(threadId);
|
|
25
|
+
// Check if all agents in the group have completed
|
|
18
26
|
if (agents.size === 0) {
|
|
27
|
+
// All agents in this group are done - emit grouped completion
|
|
28
|
+
const groupCompletions = groupCompletedAgents.get(groupId) || [];
|
|
29
|
+
groupedAgentSubscription.emit('message', {
|
|
30
|
+
groupId,
|
|
31
|
+
threadId, // Last completed thread
|
|
32
|
+
completions: groupCompletions,
|
|
33
|
+
success: groupCompletions.every(c => c.success !== false)
|
|
34
|
+
});
|
|
35
|
+
// Cleanup
|
|
19
36
|
backgroundAgentGroups.delete(groupId);
|
|
37
|
+
groupCompletedAgents.delete(groupId);
|
|
20
38
|
}
|
|
21
39
|
}
|
|
22
40
|
}
|
|
23
41
|
};
|
|
24
42
|
// Handler for background agent completion messages
|
|
25
43
|
const handleBackgroundAgentCompletion = (message) => {
|
|
44
|
+
if (!message.threadId)
|
|
45
|
+
return;
|
|
26
46
|
// Add to completed queue for orchestrator to process
|
|
27
47
|
completedBackgroundAgents.set(message.threadId, message);
|
|
28
48
|
// Remove from running map since agent is now complete
|
|
29
49
|
runningBackgroundAgents.delete(message.threadId);
|
|
30
|
-
// Clean up any group associations
|
|
31
|
-
cleanupAgentGroup(message.threadId);
|
|
50
|
+
// Clean up any group associations and check for group completion
|
|
51
|
+
cleanupAgentGroup(message.threadId, message);
|
|
32
52
|
};
|
|
33
53
|
// Subscribe to background agent completion - primary message type
|
|
34
54
|
const backgroundAgentSubscription = websocket_1.default.messageManager.subscribe('startThreadResponse');
|
|
@@ -37,7 +57,7 @@ backgroundAgentSubscription.on('message', handleBackgroundAgentCompletion);
|
|
|
37
57
|
const threadCompletedSubscription = websocket_1.default.messageManager.subscribe('ThreadCompleted');
|
|
38
58
|
threadCompletedSubscription.on('message', (message) => {
|
|
39
59
|
// Only handle if this thread was a background agent
|
|
40
|
-
if (runningBackgroundAgents.has(message.threadId)) {
|
|
60
|
+
if (message.threadId && runningBackgroundAgents.has(message.threadId)) {
|
|
41
61
|
handleBackgroundAgentCompletion(message);
|
|
42
62
|
// Also emit on the backgroundAgentSubscription for waiters
|
|
43
63
|
backgroundAgentSubscription.emit('message', message);
|
|
@@ -45,7 +65,9 @@ threadCompletedSubscription.on('message', (message) => {
|
|
|
45
65
|
});
|
|
46
66
|
const groupedAgentSubscription = websocket_1.default.messageManager.subscribe('backgroundGroupedAgentCompletion');
|
|
47
67
|
groupedAgentSubscription.on('message', (message) => {
|
|
48
|
-
|
|
68
|
+
if (message.threadId) {
|
|
69
|
+
groupedAgentCompletionMap.set(message.threadId, message);
|
|
70
|
+
}
|
|
49
71
|
});
|
|
50
72
|
/**
|
|
51
73
|
* Background Child Threads module for tracking and managing background agent threads.
|
|
@@ -54,9 +76,9 @@ groupedAgentSubscription.on('message', (message) => {
|
|
|
54
76
|
const backgroundChildThreads = {
|
|
55
77
|
/**
|
|
56
78
|
* Adds a running background agent to tracking.
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
79
|
+
* @param threadId - The thread ID
|
|
80
|
+
* @param data - The agent data
|
|
81
|
+
* @param groupId - Optional group ID
|
|
60
82
|
*/
|
|
61
83
|
addRunningAgent: (threadId, data, groupId) => {
|
|
62
84
|
runningBackgroundAgents.set(threadId, data);
|
|
@@ -76,7 +98,7 @@ const backgroundChildThreads = {
|
|
|
76
98
|
},
|
|
77
99
|
/**
|
|
78
100
|
* Checks if any background agent has completed.
|
|
79
|
-
* @returns
|
|
101
|
+
* @returns The completion data if available, or null
|
|
80
102
|
*/
|
|
81
103
|
checkForBackgroundAgentCompletion: () => {
|
|
82
104
|
if (completedBackgroundAgents.size > 0) {
|
|
@@ -88,7 +110,7 @@ const backgroundChildThreads = {
|
|
|
88
110
|
},
|
|
89
111
|
/**
|
|
90
112
|
* Waits for background agent completion.
|
|
91
|
-
* @returns
|
|
113
|
+
* @returns A promise that resolves with the completion data
|
|
92
114
|
*/
|
|
93
115
|
onBackgroundAgentCompletion: async () => {
|
|
94
116
|
const completion = backgroundChildThreads.checkForBackgroundAgentCompletion();
|
|
@@ -103,12 +125,13 @@ const backgroundChildThreads = {
|
|
|
103
125
|
},
|
|
104
126
|
/**
|
|
105
127
|
* Checks if any grouped background agent has completed.
|
|
106
|
-
* @returns
|
|
128
|
+
* @returns The completion data if available, or null
|
|
107
129
|
*/
|
|
108
130
|
checkForBackgroundGroupedAgentCompletion: () => {
|
|
109
131
|
if (groupedAgentCompletionMap.size > 0) {
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
132
|
+
const entry = groupedAgentCompletionMap.entries().next().value;
|
|
133
|
+
if (entry) {
|
|
134
|
+
const [key, value] = entry;
|
|
112
135
|
groupedAgentCompletionMap.delete(key);
|
|
113
136
|
return value;
|
|
114
137
|
}
|
|
@@ -117,7 +140,7 @@ const backgroundChildThreads = {
|
|
|
117
140
|
},
|
|
118
141
|
/**
|
|
119
142
|
* Waits for grouped background agent completion.
|
|
120
|
-
* @returns
|
|
143
|
+
* @returns A promise that resolves with the completion data
|
|
121
144
|
*/
|
|
122
145
|
onBackgroundGroupedAgentCompletion: async () => {
|
|
123
146
|
const completion = backgroundChildThreads.checkForBackgroundGroupedAgentCompletion();
|
|
@@ -133,7 +156,7 @@ const backgroundChildThreads = {
|
|
|
133
156
|
/**
|
|
134
157
|
* Waits for any external event (background agent completion, grouped agent completion, or agent event).
|
|
135
158
|
* Returns the first event that occurs.
|
|
136
|
-
* @returns
|
|
159
|
+
* @returns A promise that resolves with the event type and data
|
|
137
160
|
*/
|
|
138
161
|
waitForAnyExternalEvent: async () => {
|
|
139
162
|
// First check if there are any already completed events
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { GoToPageResponse, UrlResponse, GetMarkdownResponse, HtmlReceived, ExtractTextResponse, GetContentResponse, BrowserActionResponseData, BrowserScreenshotResponse, BrowserInfoResponse, BrowserSnapshotResponse } from '@codebolt/types/sdk';
|
|
1
|
+
import { GoToPageResponse, UrlResponse, GetMarkdownResponse, HtmlReceived, ExtractTextResponse, GetContentResponse, BrowserActionResponseData, BrowserScreenshotResponse, BrowserInfoResponse, BrowserSnapshotResponse, BrowserOperationType, BrowserOperationParams, BrowserOperationResponse } from '@codebolt/types/sdk';
|
|
2
2
|
import type { BrowserInstanceOptions, BrowserOperationOptions, BrowserInstanceInfo, BrowserScreenshotOptions } from '../types/libFunctionTypes';
|
|
3
|
+
export type { BrowserOperationType, BrowserOperationParams, BrowserOperationResponse };
|
|
3
4
|
/**
|
|
4
5
|
* A module for interacting with a browser through WebSockets.
|
|
5
6
|
*/
|
|
@@ -148,12 +149,12 @@ declare const cbbrowser: {
|
|
|
148
149
|
closeBrowserInstance: (instanceId: string) => Promise<boolean>;
|
|
149
150
|
/**
|
|
150
151
|
* Execute action on specific browser instance
|
|
151
|
-
* @param
|
|
152
|
-
* @param
|
|
153
|
-
* @param
|
|
154
|
-
* @returns
|
|
152
|
+
* @param instanceId - The instance ID to execute on
|
|
153
|
+
* @param operation - The operation to execute
|
|
154
|
+
* @param params - Parameters for the operation
|
|
155
|
+
* @returns The operation result
|
|
155
156
|
*/
|
|
156
|
-
executeOnInstance: (instanceId: string, operation:
|
|
157
|
+
executeOnInstance: (instanceId: string, operation: BrowserOperationType, params: BrowserOperationParams) => Promise<BrowserOperationResponse>;
|
|
157
158
|
};
|
|
158
159
|
export default cbbrowser;
|
|
159
160
|
/***
|
package/dist/modules/browser.js
CHANGED
|
@@ -360,10 +360,10 @@ const cbbrowser = {
|
|
|
360
360
|
},
|
|
361
361
|
/**
|
|
362
362
|
* Execute action on specific browser instance
|
|
363
|
-
* @param
|
|
364
|
-
* @param
|
|
365
|
-
* @param
|
|
366
|
-
* @returns
|
|
363
|
+
* @param instanceId - The instance ID to execute on
|
|
364
|
+
* @param operation - The operation to execute
|
|
365
|
+
* @param params - Parameters for the operation
|
|
366
|
+
* @returns The operation result
|
|
367
367
|
*/
|
|
368
368
|
executeOnInstance: async (instanceId, operation, params) => {
|
|
369
369
|
// This will be implemented with proper backend communication
|