@codebolt/codeboltjs 5.0.7 → 5.0.9
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 +331 -303
- package/dist/core/Codebolt.js +58 -0
- package/dist/core/websocket.js +15 -17
- package/dist/index.d.ts +67 -29
- package/dist/index.js +124 -9
- package/dist/modules/agentDeliberation.d.ts +1 -1
- package/dist/modules/agentDeliberation.js +9 -9
- package/dist/modules/agentEventQueue.d.ts +3 -3
- package/dist/modules/agentEventQueue.js +4 -4
- package/dist/modules/autoTesting.d.ts +1 -1
- package/dist/modules/autoTesting.js +19 -19
- package/dist/modules/backgroundChildThreads.js +22 -4
- 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/dynamicPanel.d.ts +106 -0
- package/dist/modules/dynamicPanel.js +122 -0
- 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/mcp.js +6 -3
- package/dist/modules/memoryIngestion.d.ts +1 -1
- package/dist/modules/orchestrator.js +1 -1
- 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 +8 -2
- package/dist/modules/swarm.js +14 -0
- package/dist/modules/user-message-manager.js +4 -4
- package/dist/tools/actionBlock/action-block-start.js +1 -4
- package/dist/tools/actionPlan/action-plan-create.js +1 -2
- package/dist/tools/completion/attempt-completion.d.ts +25 -0
- package/dist/tools/completion/attempt-completion.js +45 -0
- package/dist/tools/completion/index.d.ts +3 -0
- package/dist/tools/completion/index.js +9 -0
- package/dist/tools/index.d.ts +6 -3
- package/dist/tools/index.js +59 -57
- package/dist/tools/job/index.d.ts +3 -1
- package/dist/tools/job/index.js +5 -1
- package/dist/tools/job/job-remove-dependency.d.ts +28 -0
- package/dist/tools/job/job-remove-dependency.js +86 -0
- package/dist/tools/requirementPlan/requirement-plan-add-section.js +1 -1
- package/dist/tools/requirementPlan/requirement-plan-review.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.js +1 -1
- package/dist/tools/utils/schema-validator.d.ts +1 -0
- package/dist/tools/utils/schema-validator.js +13 -1
- package/dist/types/job.d.ts +1 -1
- package/package.json +2 -2
- package/dist/modules/codeboltEvent.d.ts +0 -57
- package/dist/modules/codeboltEvent.js +0 -217
- package/dist/tools/browser/browser-action.d.ts +0 -56
- package/dist/tools/browser/browser-action.js +0 -265
- package/dist/tools/codeboltEvent/event-add-running-agent.d.ts +0 -25
- package/dist/tools/codeboltEvent/event-add-running-agent.js +0 -69
- package/dist/tools/codeboltEvent/event-check-background-agent-completion.d.ts +0 -19
- package/dist/tools/codeboltEvent/event-check-background-agent-completion.js +0 -64
- package/dist/tools/codeboltEvent/event-get-running-agent-count.d.ts +0 -19
- package/dist/tools/codeboltEvent/event-get-running-agent-count.js +0 -55
- package/dist/tools/codeboltEvent/event-on-background-agent-completion.d.ts +0 -19
- package/dist/tools/codeboltEvent/event-on-background-agent-completion.js +0 -56
- package/dist/tools/codeboltEvent/event-wait-for-external-event.d.ts +0 -19
- package/dist/tools/codeboltEvent/event-wait-for-external-event.js +0 -55
- package/dist/tools/codeboltEvent/index.d.ts +0 -19
- package/dist/tools/codeboltEvent/index.js +0 -33
- package/dist/tools/event/event-add-running-agent.d.ts +0 -32
- package/dist/tools/event/event-add-running-agent.js +0 -77
- package/dist/tools/event/event-check-agent-event.d.ts +0 -19
- package/dist/tools/event/event-check-agent-event.js +0 -63
- package/dist/tools/event/event-check-completion.d.ts +0 -19
- package/dist/tools/event/event-check-completion.js +0 -73
- package/dist/tools/event/event-check-grouped-completion.d.ts +0 -19
- package/dist/tools/event/event-check-grouped-completion.js +0 -63
- package/dist/tools/event/event-get-running-count.d.ts +0 -19
- package/dist/tools/event/event-get-running-count.js +0 -55
- package/dist/tools/event/event-on-agent-event.d.ts +0 -19
- package/dist/tools/event/event-on-agent-event.js +0 -63
- package/dist/tools/event/event-on-completion.d.ts +0 -19
- package/dist/tools/event/event-on-completion.js +0 -73
- package/dist/tools/event/event-on-grouped-completion.d.ts +0 -19
- package/dist/tools/event/event-on-grouped-completion.js +0 -63
- package/dist/tools/event/event-wait-any.d.ts +0 -19
- package/dist/tools/event/event-wait-any.js +0 -66
- package/dist/tools/event/index.d.ts +0 -25
- package/dist/tools/event/index.js +0 -48
- package/dist/tools/git/git-action.d.ts +0 -48
- package/dist/tools/git/git-action.js +0 -279
- package/dist/tools/kvStore/kv-store-create-instance.d.ts +0 -26
- package/dist/tools/kvStore/kv-store-create-instance.js +0 -79
- package/dist/tools/kvStore/kv-store-get.d.ts +0 -30
- package/dist/tools/kvStore/kv-store-get.js +0 -80
- package/dist/tools/kvStore/kv-store-set.d.ts +0 -38
- package/dist/tools/kvStore/kv-store-set.js +0 -86
- package/dist/tools/memoryIngestion/mi-create-pipeline.d.ts +0 -44
- package/dist/tools/memoryIngestion/mi-create-pipeline.js +0 -114
- package/dist/tools/memoryIngestion/mi-list.d.ts +0 -22
- package/dist/tools/memoryIngestion/mi-list.js +0 -66
- package/dist/tools/orchestration/agent-details.d.ts +0 -15
- package/dist/tools/orchestration/agent-details.js +0 -98
- package/dist/tools/orchestration/agent-find.d.ts +0 -18
- package/dist/tools/orchestration/agent-find.js +0 -125
- package/dist/tools/orchestration/agent-list.d.ts +0 -13
- package/dist/tools/orchestration/agent-list.js +0 -106
- package/dist/tools/orchestration/agent-management.d.ts +0 -44
- package/dist/tools/orchestration/agent-management.js +0 -250
- package/dist/tools/orchestration/agent-start.d.ts +0 -18
- package/dist/tools/orchestration/agent-start.js +0 -90
- package/dist/tools/orchestration/index.d.ts +0 -49
- package/dist/tools/orchestration/index.js +0 -102
- package/dist/tools/orchestration/task-assign.d.ts +0 -18
- package/dist/tools/orchestration/task-assign.js +0 -84
- package/dist/tools/orchestration/task-create.d.ts +0 -20
- package/dist/tools/orchestration/task-create.js +0 -97
- package/dist/tools/orchestration/task-delete.d.ts +0 -16
- package/dist/tools/orchestration/task-delete.js +0 -77
- package/dist/tools/orchestration/task-execute.d.ts +0 -18
- package/dist/tools/orchestration/task-execute.js +0 -84
- package/dist/tools/orchestration/task-get.d.ts +0 -16
- package/dist/tools/orchestration/task-get.js +0 -89
- package/dist/tools/orchestration/task-list.d.ts +0 -13
- package/dist/tools/orchestration/task-list.js +0 -74
- package/dist/tools/orchestration/task-management.d.ts +0 -52
- package/dist/tools/orchestration/task-management.js +0 -231
- package/dist/tools/orchestration/task-update.d.ts +0 -22
- package/dist/tools/orchestration/task-update.js +0 -96
- package/dist/tools/orchestration/thread-create-background.d.ts +0 -18
- package/dist/tools/orchestration/thread-create-background.js +0 -94
- package/dist/tools/orchestration/thread-create-start.d.ts +0 -16
- package/dist/tools/orchestration/thread-create-start.js +0 -85
- package/dist/tools/orchestration/thread-create.d.ts +0 -16
- package/dist/tools/orchestration/thread-create.js +0 -85
- package/dist/tools/orchestration/thread-delete.d.ts +0 -16
- package/dist/tools/orchestration/thread-delete.js +0 -77
- package/dist/tools/orchestration/thread-get-messages.d.ts +0 -24
- package/dist/tools/orchestration/thread-get-messages.js +0 -122
- package/dist/tools/orchestration/thread-get.d.ts +0 -16
- package/dist/tools/orchestration/thread-get.js +0 -85
- package/dist/tools/orchestration/thread-list.d.ts +0 -16
- package/dist/tools/orchestration/thread-list.js +0 -85
- package/dist/tools/orchestration/thread-start.d.ts +0 -16
- package/dist/tools/orchestration/thread-start.js +0 -82
- package/dist/tools/orchestration/thread-update-status.d.ts +0 -18
- package/dist/tools/orchestration/thread-update-status.js +0 -89
- package/dist/tools/orchestration/thread-update.d.ts +0 -18
- package/dist/tools/orchestration/thread-update.js +0 -89
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Job Remove Dependency Tool - Removes a dependency between two jobs
|
|
4
|
+
* Wraps the SDK's jobService.removeDependency() method
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.JobRemoveDependencyTool = void 0;
|
|
11
|
+
const types_1 = require("../types");
|
|
12
|
+
const base_tool_1 = require("../base-tool");
|
|
13
|
+
const job_1 = __importDefault(require("../../modules/job"));
|
|
14
|
+
class JobRemoveDependencyToolInvocation extends base_tool_1.BaseToolInvocation {
|
|
15
|
+
constructor(params) {
|
|
16
|
+
super(params);
|
|
17
|
+
}
|
|
18
|
+
async execute() {
|
|
19
|
+
try {
|
|
20
|
+
const response = await job_1.default.removeDependency(this.params.job_id, this.params.depends_on_job_id);
|
|
21
|
+
if (!response.job) {
|
|
22
|
+
return {
|
|
23
|
+
llmContent: `Failed to remove dependency: Job not found or operation failed`,
|
|
24
|
+
returnDisplay: `Failed to remove dependency between jobs`,
|
|
25
|
+
error: {
|
|
26
|
+
message: 'Failed to remove dependency: Job not found or operation failed',
|
|
27
|
+
type: types_1.ToolErrorType.EXECUTION_FAILED,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
llmContent: `Successfully removed dependency: ${this.params.job_id} no longer depends on ${this.params.depends_on_job_id}\n\nUpdated Job:\n${JSON.stringify(response.job, null, 2)}`,
|
|
33
|
+
returnDisplay: `Removed dependency: ${this.params.job_id} -/-> ${this.params.depends_on_job_id}`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
|
|
38
|
+
return {
|
|
39
|
+
llmContent: `Error removing dependency: ${errorMessage}`,
|
|
40
|
+
returnDisplay: `Error removing dependency: ${errorMessage}`,
|
|
41
|
+
error: {
|
|
42
|
+
message: errorMessage,
|
|
43
|
+
type: types_1.ToolErrorType.EXECUTION_FAILED,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Implementation of the JobRemoveDependency tool
|
|
51
|
+
*/
|
|
52
|
+
class JobRemoveDependencyTool extends base_tool_1.BaseDeclarativeTool {
|
|
53
|
+
constructor() {
|
|
54
|
+
super(JobRemoveDependencyTool.Name, 'JobRemoveDependency', `Removes a dependency between two jobs. The dependency from the first job (job_id) on the second job (depends_on_job_id) will be removed, potentially unblocking the first job.`, types_1.Kind.Edit, {
|
|
55
|
+
properties: {
|
|
56
|
+
job_id: {
|
|
57
|
+
description: 'The ID of the job to remove a dependency from',
|
|
58
|
+
type: 'string',
|
|
59
|
+
},
|
|
60
|
+
depends_on_job_id: {
|
|
61
|
+
description: 'The ID of the dependency job to remove',
|
|
62
|
+
type: 'string',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
required: ['job_id', 'depends_on_job_id'],
|
|
66
|
+
type: 'object',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
validateToolParamValues(params) {
|
|
70
|
+
if (!params.job_id || params.job_id.trim() === '') {
|
|
71
|
+
return "The 'job_id' parameter must be non-empty.";
|
|
72
|
+
}
|
|
73
|
+
if (!params.depends_on_job_id || params.depends_on_job_id.trim() === '') {
|
|
74
|
+
return "The 'depends_on_job_id' parameter must be non-empty.";
|
|
75
|
+
}
|
|
76
|
+
if (params.job_id === params.depends_on_job_id) {
|
|
77
|
+
return "A job cannot have a dependency on itself.";
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
createInvocation(params) {
|
|
82
|
+
return new JobRemoveDependencyToolInvocation(params);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.JobRemoveDependencyTool = JobRemoveDependencyTool;
|
|
86
|
+
JobRemoveDependencyTool.Name = 'job_remove_dependency';
|
|
@@ -40,7 +40,7 @@ class RequirementPlanAddSectionTool extends base_tool_1.BaseDeclarativeTool {
|
|
|
40
40
|
super('requirement_plan_add_section', 'Add Section to Requirement Plan', 'Add a section to a requirement plan', types_1.Kind.FileSystem, {
|
|
41
41
|
type: 'object',
|
|
42
42
|
properties: {
|
|
43
|
-
filePath: { type: 'string', description: 'Path to the plan file' },
|
|
43
|
+
filePath: { type: 'string', description: 'Path to the plan file or actionplan id' },
|
|
44
44
|
section: {
|
|
45
45
|
type: 'object',
|
|
46
46
|
description: 'Section data to add',
|
|
@@ -22,7 +22,7 @@ class RequirementPlanReviewInvocation extends base_tool_1.BaseToolInvocation {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
return {
|
|
25
|
-
llmContent: `Requirement plan review status: ${response.status || 'pending'}`,
|
|
25
|
+
llmContent: `Requirement plan review status: ${response.data.status || 'pending'} `,
|
|
26
26
|
returnDisplay: `Review status: ${response.status || 'pending'}`,
|
|
27
27
|
};
|
|
28
28
|
}
|
|
@@ -40,7 +40,7 @@ class ReviewCreateToolInvocation extends base_tool_1.BaseToolInvocation {
|
|
|
40
40
|
const response = await reviewMergeRequest_1.default.create(createData);
|
|
41
41
|
return {
|
|
42
42
|
llmContent: JSON.stringify(response, null, 2),
|
|
43
|
-
returnDisplay: `Successfully created review request: ${response
|
|
43
|
+
returnDisplay: `Successfully created review request: ${response}`,
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
catch (error) {
|
|
@@ -12,6 +12,7 @@ class CreateReviewMergeRequestInvocation extends base_tool_1.BaseToolInvocation
|
|
|
12
12
|
super(params);
|
|
13
13
|
}
|
|
14
14
|
async execute(_signal) {
|
|
15
|
+
var _a;
|
|
15
16
|
try {
|
|
16
17
|
// Map tool params to CreateReviewMergeRequest interface
|
|
17
18
|
const response = await reviewMergeRequest_1.default.create({
|
|
@@ -25,14 +26,14 @@ class CreateReviewMergeRequestInvocation extends base_tool_1.BaseToolInvocation
|
|
|
25
26
|
agentName: this.params.authorId,
|
|
26
27
|
swarmId: this.params.swarmId,
|
|
27
28
|
});
|
|
28
|
-
|
|
29
|
+
const req = ((_a = response.data) === null || _a === void 0 ? void 0 : _a.request) || response.request;
|
|
30
|
+
if (!req) {
|
|
29
31
|
return {
|
|
30
32
|
llmContent: `Error: Failed to create review merge request - no request returned`,
|
|
31
33
|
returnDisplay: `Error: Failed to create`,
|
|
32
34
|
error: { message: 'Failed to create', type: types_1.ToolErrorType.EXECUTION_FAILED },
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
|
-
const req = response.request;
|
|
36
37
|
const content = `Review merge request created: ${req.id} - ${req.title} (${req.status})`;
|
|
37
38
|
return { llmContent: content, returnDisplay: content };
|
|
38
39
|
}
|
|
@@ -95,7 +95,7 @@ class ThreadCreateBackgroundTool extends base_tool_1.BaseDeclarativeTool {
|
|
|
95
95
|
type: 'string',
|
|
96
96
|
},
|
|
97
97
|
isGrouped: {
|
|
98
|
-
description: 'Whether the thread belongs to a group
|
|
98
|
+
description: 'Whether the thread belongs to a group',
|
|
99
99
|
type: 'boolean',
|
|
100
100
|
},
|
|
101
101
|
},
|
|
@@ -8,6 +8,16 @@ exports.SchemaValidator = void 0;
|
|
|
8
8
|
* Simple JSON Schema validator
|
|
9
9
|
*/
|
|
10
10
|
class SchemaValidator {
|
|
11
|
+
static tryParseJson(value) {
|
|
12
|
+
if (typeof value !== 'string')
|
|
13
|
+
return value;
|
|
14
|
+
try {
|
|
15
|
+
return JSON.parse(value);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
11
21
|
static validate(schema, data) {
|
|
12
22
|
if (!schema || typeof schema !== 'object') {
|
|
13
23
|
return null; // No schema to validate against
|
|
@@ -49,7 +59,9 @@ class SchemaValidator {
|
|
|
49
59
|
const dataObj = data;
|
|
50
60
|
for (const [key, propSchema] of Object.entries(properties)) {
|
|
51
61
|
if (key in dataObj) {
|
|
52
|
-
|
|
62
|
+
// Try parsing JSON strings before validating nested properties
|
|
63
|
+
const resolvedValue = this.tryParseJson(dataObj[key]);
|
|
64
|
+
const propError = this.validate(propSchema, resolvedValue);
|
|
53
65
|
if (propError) {
|
|
54
66
|
return `Property '${key}': ${propError}`;
|
|
55
67
|
}
|
package/dist/types/job.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface JobGroup {
|
|
|
6
6
|
createdAt: string;
|
|
7
7
|
updatedAt: string;
|
|
8
8
|
}
|
|
9
|
-
export type JobStatus = 'open' | 'working' | 'hold' | 'closed';
|
|
9
|
+
export type JobStatus = 'open' | 'working' | 'hold' | 'review' | 'closed';
|
|
10
10
|
export type JobType = 'bug' | 'feature' | 'task' | 'epic' | 'chore';
|
|
11
11
|
export type JobPriority = 1 | 2 | 3 | 4;
|
|
12
12
|
export type DependencyType = 'blocks' | 'related' | 'parent-child' | 'discovered-from';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codebolt/codeboltjs",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"uuid": "^11.1.0",
|
|
36
36
|
"ws": "^8.18.3",
|
|
37
37
|
"yargs": "^17.7.2",
|
|
38
|
-
"@codebolt/types": "5.0.
|
|
38
|
+
"@codebolt/types": "5.0.9"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/events": "^3.0.3",
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Codebolt Event module for handling external events.
|
|
3
|
-
* This module provides APIs for waiting on and checking for various event types.
|
|
4
|
-
*/
|
|
5
|
-
declare const codeboltEvent: {
|
|
6
|
-
/**
|
|
7
|
-
* Adds a running background agent to tracking.
|
|
8
|
-
* @param {string} threadId - The thread ID
|
|
9
|
-
* @param {any} data - The agent data
|
|
10
|
-
* @param {string} [groupId] - Optional group ID
|
|
11
|
-
*/
|
|
12
|
-
addRunningAgent: (threadId: string, data: any, groupId?: string) => void;
|
|
13
|
-
/**
|
|
14
|
-
* Gets the number of currently running background agents.
|
|
15
|
-
* @returns {number} The count
|
|
16
|
-
*/
|
|
17
|
-
getRunningAgentCount: () => number;
|
|
18
|
-
/**
|
|
19
|
-
* Checks if any background agent has completed.
|
|
20
|
-
* @returns {any} The completion data if available, or null
|
|
21
|
-
*/
|
|
22
|
-
checkForBackgroundAgentCompletion: () => any[] | null;
|
|
23
|
-
/**
|
|
24
|
-
* Waits for background agent completion.
|
|
25
|
-
* @returns {Promise<any>} A promise that resolves with the completion data
|
|
26
|
-
*/
|
|
27
|
-
onBackgroundAgentCompletion: () => Promise<any>;
|
|
28
|
-
/**
|
|
29
|
-
* Checks if any grouped background agent has completed.
|
|
30
|
-
* @returns {any} The completion data if available, or null
|
|
31
|
-
*/
|
|
32
|
-
checkForBackgroundGroupedAgentCompletion: () => any;
|
|
33
|
-
/**
|
|
34
|
-
* Waits for grouped background agent completion.
|
|
35
|
-
* @returns {Promise<any>} A promise that resolves with the completion data
|
|
36
|
-
*/
|
|
37
|
-
onBackgroundGroupedAgentCompletion: () => Promise<any>;
|
|
38
|
-
/**
|
|
39
|
-
* Checks if any agent event has been received.
|
|
40
|
-
* @returns {any} The event data if available, or null
|
|
41
|
-
*/
|
|
42
|
-
checkForAgentEventReceived: () => any;
|
|
43
|
-
/**
|
|
44
|
-
* Waits for an agent event.
|
|
45
|
-
* @returns {Promise<any>} A promise that resolves with the event data
|
|
46
|
-
*/
|
|
47
|
-
onAgentEventReceived: () => Promise<any>;
|
|
48
|
-
/**
|
|
49
|
-
* Waits for any external event (Background Completion, Group Completion, Agent Event).
|
|
50
|
-
* @returns {Promise<{ type: string, data: any }>} A promise that resolves with the event object
|
|
51
|
-
*/
|
|
52
|
-
waitForAnyExternalEvent: () => Promise<{
|
|
53
|
-
type: string;
|
|
54
|
-
data: any;
|
|
55
|
-
}>;
|
|
56
|
-
};
|
|
57
|
-
export default codeboltEvent;
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
// codeboltEvent.ts
|
|
7
|
-
const websocket_1 = __importDefault(require("../core/websocket"));
|
|
8
|
-
const crypto_1 = require("crypto");
|
|
9
|
-
// Event state maps - Internal use only
|
|
10
|
-
const runningBackgroundAgents = new Map();
|
|
11
|
-
const completedBackgroundAgents = new Map();
|
|
12
|
-
const agentEventMap = new Map();
|
|
13
|
-
const groupedAgentCompletionMap = new Map();
|
|
14
|
-
const backgroundAgentGroups = new Map();
|
|
15
|
-
// Helper to cleanup group membership
|
|
16
|
-
const cleanupAgentGroup = (threadId) => {
|
|
17
|
-
for (const [groupId, agents] of backgroundAgentGroups.entries()) {
|
|
18
|
-
if (agents.has(threadId)) {
|
|
19
|
-
agents.delete(threadId);
|
|
20
|
-
if (agents.size === 0) {
|
|
21
|
-
backgroundAgentGroups.delete(groupId);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
// Handler for background agent completion messages
|
|
27
|
-
const handleBackgroundAgentCompletion = (message) => {
|
|
28
|
-
// Add to completed queue for orchestrator to process
|
|
29
|
-
completedBackgroundAgents.set(message.threadId, message);
|
|
30
|
-
// Remove from running map since agent is now complete
|
|
31
|
-
runningBackgroundAgents.delete(message.threadId);
|
|
32
|
-
// Clean up any group associations
|
|
33
|
-
cleanupAgentGroup(message.threadId);
|
|
34
|
-
};
|
|
35
|
-
// Subscribe to message types
|
|
36
|
-
const agentEventSubscription = websocket_1.default.messageManager.subscribe('agentEvent');
|
|
37
|
-
agentEventSubscription.on('message', (message) => {
|
|
38
|
-
const eventId = (0, crypto_1.randomUUID)();
|
|
39
|
-
agentEventMap.set(eventId, message);
|
|
40
|
-
});
|
|
41
|
-
// Subscribe to background agent completion - primary message type
|
|
42
|
-
const backgroundAgentSubscription = websocket_1.default.messageManager.subscribe('startThreadResponse');
|
|
43
|
-
backgroundAgentSubscription.on('message', handleBackgroundAgentCompletion);
|
|
44
|
-
// Also subscribe to ThreadCompleted as an alternative message type for background agent completion
|
|
45
|
-
const threadCompletedSubscription = websocket_1.default.messageManager.subscribe('ThreadCompleted');
|
|
46
|
-
threadCompletedSubscription.on('message', (message) => {
|
|
47
|
-
// Only handle if this thread was a background agent
|
|
48
|
-
if (runningBackgroundAgents.has(message.threadId)) {
|
|
49
|
-
handleBackgroundAgentCompletion(message);
|
|
50
|
-
// Also emit on the backgroundAgentSubscription for waitForAnyExternalEvent
|
|
51
|
-
backgroundAgentSubscription.emit('message', message);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
const groupedAgentSubscription = websocket_1.default.messageManager.subscribe('backgroundGroupedAgentCompletion');
|
|
55
|
-
groupedAgentSubscription.on('message', (message) => {
|
|
56
|
-
groupedAgentCompletionMap.set(message.threadId, message);
|
|
57
|
-
});
|
|
58
|
-
/**
|
|
59
|
-
* Codebolt Event module for handling external events.
|
|
60
|
-
* This module provides APIs for waiting on and checking for various event types.
|
|
61
|
-
*/
|
|
62
|
-
const codeboltEvent = {
|
|
63
|
-
/**
|
|
64
|
-
* Adds a running background agent to tracking.
|
|
65
|
-
* @param {string} threadId - The thread ID
|
|
66
|
-
* @param {any} data - The agent data
|
|
67
|
-
* @param {string} [groupId] - Optional group ID
|
|
68
|
-
*/
|
|
69
|
-
addRunningAgent: (threadId, data, groupId) => {
|
|
70
|
-
runningBackgroundAgents.set(threadId, data);
|
|
71
|
-
if (groupId) {
|
|
72
|
-
if (!backgroundAgentGroups.has(groupId)) {
|
|
73
|
-
backgroundAgentGroups.set(groupId, new Set());
|
|
74
|
-
}
|
|
75
|
-
backgroundAgentGroups.get(groupId).add(threadId);
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
/**
|
|
79
|
-
* Gets the number of currently running background agents.
|
|
80
|
-
* @returns {number} The count
|
|
81
|
-
*/
|
|
82
|
-
getRunningAgentCount: () => {
|
|
83
|
-
return runningBackgroundAgents.size;
|
|
84
|
-
},
|
|
85
|
-
/**
|
|
86
|
-
* Checks if any background agent has completed.
|
|
87
|
-
* @returns {any} The completion data if available, or null
|
|
88
|
-
*/
|
|
89
|
-
checkForBackgroundAgentCompletion: () => {
|
|
90
|
-
if (completedBackgroundAgents.size > 0) {
|
|
91
|
-
const values = Array.from(completedBackgroundAgents.values());
|
|
92
|
-
completedBackgroundAgents.clear();
|
|
93
|
-
return values;
|
|
94
|
-
}
|
|
95
|
-
return null;
|
|
96
|
-
},
|
|
97
|
-
/**
|
|
98
|
-
* Waits for background agent completion.
|
|
99
|
-
* @returns {Promise<any>} A promise that resolves with the completion data
|
|
100
|
-
*/
|
|
101
|
-
onBackgroundAgentCompletion: async () => {
|
|
102
|
-
const completion = codeboltEvent.checkForBackgroundAgentCompletion();
|
|
103
|
-
if (completion)
|
|
104
|
-
return completion;
|
|
105
|
-
return new Promise((resolve) => {
|
|
106
|
-
backgroundAgentSubscription.once('message', () => {
|
|
107
|
-
const data = codeboltEvent.checkForBackgroundAgentCompletion();
|
|
108
|
-
resolve(data);
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
},
|
|
112
|
-
/**
|
|
113
|
-
* Checks if any grouped background agent has completed.
|
|
114
|
-
* @returns {any} The completion data if available, or null
|
|
115
|
-
*/
|
|
116
|
-
checkForBackgroundGroupedAgentCompletion: () => {
|
|
117
|
-
if (groupedAgentCompletionMap.size > 0) {
|
|
118
|
-
const [key, value] = groupedAgentCompletionMap.entries().next().value || [];
|
|
119
|
-
if (key) {
|
|
120
|
-
groupedAgentCompletionMap.delete(key);
|
|
121
|
-
return value;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return null;
|
|
125
|
-
},
|
|
126
|
-
/**
|
|
127
|
-
* Waits for grouped background agent completion.
|
|
128
|
-
* @returns {Promise<any>} A promise that resolves with the completion data
|
|
129
|
-
*/
|
|
130
|
-
onBackgroundGroupedAgentCompletion: async () => {
|
|
131
|
-
const completion = codeboltEvent.checkForBackgroundGroupedAgentCompletion();
|
|
132
|
-
if (completion)
|
|
133
|
-
return completion;
|
|
134
|
-
return new Promise((resolve) => {
|
|
135
|
-
groupedAgentSubscription.once('message', () => {
|
|
136
|
-
const data = codeboltEvent.checkForBackgroundGroupedAgentCompletion();
|
|
137
|
-
resolve(data);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
},
|
|
141
|
-
/**
|
|
142
|
-
* Checks if any agent event has been received.
|
|
143
|
-
* @returns {any} The event data if available, or null
|
|
144
|
-
*/
|
|
145
|
-
checkForAgentEventReceived: () => {
|
|
146
|
-
if (agentEventMap.size > 0) {
|
|
147
|
-
const [key, value] = agentEventMap.entries().next().value || [];
|
|
148
|
-
if (key) {
|
|
149
|
-
agentEventMap.delete(key);
|
|
150
|
-
return value;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return null;
|
|
154
|
-
},
|
|
155
|
-
/**
|
|
156
|
-
* Waits for an agent event.
|
|
157
|
-
* @returns {Promise<any>} A promise that resolves with the event data
|
|
158
|
-
*/
|
|
159
|
-
onAgentEventReceived: async () => {
|
|
160
|
-
const event = codeboltEvent.checkForAgentEventReceived();
|
|
161
|
-
if (event)
|
|
162
|
-
return event;
|
|
163
|
-
return new Promise((resolve) => {
|
|
164
|
-
agentEventSubscription.once('message', () => {
|
|
165
|
-
const data = codeboltEvent.checkForAgentEventReceived();
|
|
166
|
-
resolve(data);
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
},
|
|
170
|
-
/**
|
|
171
|
-
* Waits for any external event (Background Completion, Group Completion, Agent Event).
|
|
172
|
-
* @returns {Promise<{ type: string, data: any }>} A promise that resolves with the event object
|
|
173
|
-
*/
|
|
174
|
-
waitForAnyExternalEvent: async () => {
|
|
175
|
-
// Check functions mapped to their return type strings
|
|
176
|
-
const checks = [
|
|
177
|
-
{ fn: () => codeboltEvent.checkForBackgroundAgentCompletion(), type: 'backgroundAgentCompletion' },
|
|
178
|
-
{ fn: () => codeboltEvent.checkForBackgroundGroupedAgentCompletion(), type: 'backgroundGroupedAgentCompletion' },
|
|
179
|
-
{ fn: () => codeboltEvent.checkForAgentEventReceived(), type: 'agentEventReceived' }
|
|
180
|
-
];
|
|
181
|
-
for (const { fn, type } of checks) {
|
|
182
|
-
const data = fn();
|
|
183
|
-
if (data)
|
|
184
|
-
return { type, data };
|
|
185
|
-
}
|
|
186
|
-
return new Promise((resolve) => {
|
|
187
|
-
const cleanup = () => {
|
|
188
|
-
backgroundAgentSubscription.removeListener('message', onBgComplete);
|
|
189
|
-
groupedAgentSubscription.removeListener('message', onGroupComplete);
|
|
190
|
-
agentEventSubscription.removeListener('message', onAgentEvent);
|
|
191
|
-
};
|
|
192
|
-
const onBgComplete = () => {
|
|
193
|
-
// Must unhook first to avoid multi-resolution
|
|
194
|
-
cleanup();
|
|
195
|
-
// We must yield slightly to ensure handleBackgroundAgentCompletion has processed the event?
|
|
196
|
-
// Actually, handleBackgroundAgentCompletion attaches first, so it runs first on the same emitter.
|
|
197
|
-
// That should be safe synchronously.
|
|
198
|
-
const data = codeboltEvent.checkForBackgroundAgentCompletion();
|
|
199
|
-
resolve({ type: 'backgroundAgentCompletion', data });
|
|
200
|
-
};
|
|
201
|
-
const onGroupComplete = () => {
|
|
202
|
-
cleanup();
|
|
203
|
-
const data = codeboltEvent.checkForBackgroundGroupedAgentCompletion();
|
|
204
|
-
resolve({ type: 'backgroundGroupedAgentCompletion', data });
|
|
205
|
-
};
|
|
206
|
-
const onAgentEvent = () => {
|
|
207
|
-
cleanup();
|
|
208
|
-
const data = codeboltEvent.checkForAgentEventReceived();
|
|
209
|
-
resolve({ type: 'agentEventReceived', data });
|
|
210
|
-
};
|
|
211
|
-
backgroundAgentSubscription.once('message', onBgComplete);
|
|
212
|
-
groupedAgentSubscription.once('message', onGroupComplete);
|
|
213
|
-
agentEventSubscription.once('message', onAgentEvent);
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
exports.default = codeboltEvent;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser Action Tool - Performs browser automation actions
|
|
3
|
-
* Wraps the SDK's cbbrowser methods
|
|
4
|
-
*/
|
|
5
|
-
import type { ToolInvocation, ToolResult } from '../types';
|
|
6
|
-
import { BaseDeclarativeTool } from '../base-tool';
|
|
7
|
-
/**
|
|
8
|
-
* Supported browser actions
|
|
9
|
-
*/
|
|
10
|
-
export type BrowserActionType = 'navigate' | 'screenshot' | 'click' | 'type' | 'scroll' | 'get_content' | 'get_html' | 'get_markdown' | 'get_url' | 'close' | 'enter' | 'search';
|
|
11
|
-
/**
|
|
12
|
-
* Parameters for the BrowserAction tool
|
|
13
|
-
*/
|
|
14
|
-
export interface BrowserActionToolParams {
|
|
15
|
-
/**
|
|
16
|
-
* The browser action to perform
|
|
17
|
-
*/
|
|
18
|
-
action: BrowserActionType;
|
|
19
|
-
/**
|
|
20
|
-
* URL for navigate action
|
|
21
|
-
*/
|
|
22
|
-
url?: string;
|
|
23
|
-
/**
|
|
24
|
-
* Element ID for click/type/search actions
|
|
25
|
-
*/
|
|
26
|
-
element_id?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Text for type action
|
|
29
|
-
*/
|
|
30
|
-
text?: string;
|
|
31
|
-
/**
|
|
32
|
-
* Query for search action
|
|
33
|
-
*/
|
|
34
|
-
query?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Scroll direction ('up', 'down', 'left', 'right')
|
|
37
|
-
*/
|
|
38
|
-
direction?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Pixels to scroll
|
|
41
|
-
*/
|
|
42
|
-
pixels?: string;
|
|
43
|
-
/**
|
|
44
|
-
* Browser instance ID (optional)
|
|
45
|
-
*/
|
|
46
|
-
instance_id?: string;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Implementation of the BrowserAction tool logic
|
|
50
|
-
*/
|
|
51
|
-
export declare class BrowserActionTool extends BaseDeclarativeTool<BrowserActionToolParams, ToolResult> {
|
|
52
|
-
static readonly Name: string;
|
|
53
|
-
constructor();
|
|
54
|
-
protected validateToolParamValues(params: BrowserActionToolParams): string | null;
|
|
55
|
-
protected createInvocation(params: BrowserActionToolParams): ToolInvocation<BrowserActionToolParams, ToolResult>;
|
|
56
|
-
}
|