@codebolt/codeboltjs 5.0.8 → 5.1.10

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.
Files changed (160) hide show
  1. package/dist/core/Codebolt.d.ts +48 -5
  2. package/dist/core/Codebolt.js +76 -16
  3. package/dist/core/websocket.js +16 -18
  4. package/dist/index.d.ts +3 -0
  5. package/dist/index.js +9 -3
  6. package/dist/modules/agentDeliberation.js +3 -1
  7. package/dist/modules/dynamicPanel.d.ts +106 -0
  8. package/dist/modules/dynamicPanel.js +122 -0
  9. package/dist/modules/environment.d.ts +24 -0
  10. package/dist/modules/environment.js +51 -0
  11. package/dist/modules/mcp.js +3 -0
  12. package/dist/tools/actionBlock/action-block-start.js +1 -4
  13. package/dist/tools/actionPlan/action-plan-create.js +1 -2
  14. package/dist/tools/completion/attempt-completion.d.ts +25 -0
  15. package/dist/tools/completion/attempt-completion.js +45 -0
  16. package/dist/tools/completion/index.d.ts +3 -0
  17. package/dist/tools/completion/index.js +9 -0
  18. package/dist/tools/environment/environment-create.d.ts +23 -0
  19. package/dist/tools/environment/environment-create.js +90 -0
  20. package/dist/tools/environment/environment-delete.d.ts +17 -0
  21. package/dist/tools/environment/environment-delete.js +70 -0
  22. package/dist/tools/environment/environment-get.d.ts +17 -0
  23. package/dist/tools/environment/environment-get.js +73 -0
  24. package/dist/tools/environment/environment-list.d.ts +15 -0
  25. package/dist/tools/environment/environment-list.js +72 -0
  26. package/dist/tools/environment/environment-providers.d.ts +24 -0
  27. package/dist/tools/environment/environment-providers.js +130 -0
  28. package/dist/tools/environment/environment-restart.d.ts +17 -0
  29. package/dist/tools/environment/environment-restart.js +70 -0
  30. package/dist/tools/environment/environment-send-message.d.ts +19 -0
  31. package/dist/tools/environment/environment-send-message.js +74 -0
  32. package/dist/tools/environment/environment-start.d.ts +17 -0
  33. package/dist/tools/environment/environment-start.js +70 -0
  34. package/dist/tools/environment/environment-statistics.d.ts +15 -0
  35. package/dist/tools/environment/environment-statistics.js +69 -0
  36. package/dist/tools/environment/environment-status.d.ts +17 -0
  37. package/dist/tools/environment/environment-status.js +72 -0
  38. package/dist/tools/environment/environment-stop.d.ts +17 -0
  39. package/dist/tools/environment/environment-stop.js +70 -0
  40. package/dist/tools/environment/environment-update.d.ts +19 -0
  41. package/dist/tools/environment/environment-update.js +74 -0
  42. package/dist/tools/environment/index.d.ts +31 -0
  43. package/dist/tools/environment/index.js +61 -0
  44. package/dist/tools/index.d.ts +20 -3
  45. package/dist/tools/index.js +55 -8
  46. package/dist/tools/job/index.d.ts +3 -1
  47. package/dist/tools/job/index.js +5 -1
  48. package/dist/tools/job/job-remove-dependency.d.ts +28 -0
  49. package/dist/tools/job/job-remove-dependency.js +86 -0
  50. package/dist/tools/registry.d.ts +21 -0
  51. package/dist/tools/registry.js +38 -1
  52. package/dist/tools/requirementPlan/requirement-plan-review.js +1 -1
  53. package/dist/tools/thread/thread-create-background.js +1 -1
  54. package/dist/tools/tool-search.d.ts +49 -0
  55. package/dist/tools/tool-search.js +140 -0
  56. package/dist/tools/toolSearch/index.d.ts +9 -0
  57. package/dist/tools/toolSearch/index.js +15 -0
  58. package/dist/tools/toolSearch/tool-search-tool.d.ts +32 -0
  59. package/dist/tools/toolSearch/tool-search-tool.js +110 -0
  60. package/dist/tools/utils/schema-validator.d.ts +1 -0
  61. package/dist/tools/utils/schema-validator.js +13 -1
  62. package/dist/types/agentDeliberation.d.ts +15 -1
  63. package/dist/types/agentDeliberation.js +2 -0
  64. package/package.json +20 -19
  65. package/dist/modules/codeboltEvent.d.ts +0 -57
  66. package/dist/modules/codeboltEvent.js +0 -217
  67. package/dist/tools/browser/browser-action.d.ts +0 -56
  68. package/dist/tools/browser/browser-action.js +0 -265
  69. package/dist/tools/codeboltEvent/event-add-running-agent.d.ts +0 -25
  70. package/dist/tools/codeboltEvent/event-add-running-agent.js +0 -69
  71. package/dist/tools/codeboltEvent/event-check-background-agent-completion.d.ts +0 -19
  72. package/dist/tools/codeboltEvent/event-check-background-agent-completion.js +0 -64
  73. package/dist/tools/codeboltEvent/event-get-running-agent-count.d.ts +0 -19
  74. package/dist/tools/codeboltEvent/event-get-running-agent-count.js +0 -55
  75. package/dist/tools/codeboltEvent/event-on-background-agent-completion.d.ts +0 -19
  76. package/dist/tools/codeboltEvent/event-on-background-agent-completion.js +0 -56
  77. package/dist/tools/codeboltEvent/event-wait-for-external-event.d.ts +0 -19
  78. package/dist/tools/codeboltEvent/event-wait-for-external-event.js +0 -55
  79. package/dist/tools/codeboltEvent/index.d.ts +0 -19
  80. package/dist/tools/codeboltEvent/index.js +0 -33
  81. package/dist/tools/event/event-add-running-agent.d.ts +0 -32
  82. package/dist/tools/event/event-add-running-agent.js +0 -77
  83. package/dist/tools/event/event-check-agent-event.d.ts +0 -19
  84. package/dist/tools/event/event-check-agent-event.js +0 -63
  85. package/dist/tools/event/event-check-completion.d.ts +0 -19
  86. package/dist/tools/event/event-check-completion.js +0 -73
  87. package/dist/tools/event/event-check-grouped-completion.d.ts +0 -19
  88. package/dist/tools/event/event-check-grouped-completion.js +0 -63
  89. package/dist/tools/event/event-get-running-count.d.ts +0 -19
  90. package/dist/tools/event/event-get-running-count.js +0 -55
  91. package/dist/tools/event/event-on-agent-event.d.ts +0 -19
  92. package/dist/tools/event/event-on-agent-event.js +0 -63
  93. package/dist/tools/event/event-on-completion.d.ts +0 -19
  94. package/dist/tools/event/event-on-completion.js +0 -73
  95. package/dist/tools/event/event-on-grouped-completion.d.ts +0 -19
  96. package/dist/tools/event/event-on-grouped-completion.js +0 -63
  97. package/dist/tools/event/event-wait-any.d.ts +0 -19
  98. package/dist/tools/event/event-wait-any.js +0 -66
  99. package/dist/tools/event/index.d.ts +0 -25
  100. package/dist/tools/event/index.js +0 -48
  101. package/dist/tools/git/git-action.d.ts +0 -48
  102. package/dist/tools/git/git-action.js +0 -279
  103. package/dist/tools/kvStore/kv-store-create-instance.d.ts +0 -26
  104. package/dist/tools/kvStore/kv-store-create-instance.js +0 -79
  105. package/dist/tools/kvStore/kv-store-get.d.ts +0 -30
  106. package/dist/tools/kvStore/kv-store-get.js +0 -80
  107. package/dist/tools/kvStore/kv-store-set.d.ts +0 -38
  108. package/dist/tools/kvStore/kv-store-set.js +0 -86
  109. package/dist/tools/memoryIngestion/mi-create-pipeline.d.ts +0 -44
  110. package/dist/tools/memoryIngestion/mi-create-pipeline.js +0 -114
  111. package/dist/tools/memoryIngestion/mi-list.d.ts +0 -22
  112. package/dist/tools/memoryIngestion/mi-list.js +0 -66
  113. package/dist/tools/orchestration/agent-details.d.ts +0 -15
  114. package/dist/tools/orchestration/agent-details.js +0 -98
  115. package/dist/tools/orchestration/agent-find.d.ts +0 -18
  116. package/dist/tools/orchestration/agent-find.js +0 -125
  117. package/dist/tools/orchestration/agent-list.d.ts +0 -13
  118. package/dist/tools/orchestration/agent-list.js +0 -106
  119. package/dist/tools/orchestration/agent-management.d.ts +0 -44
  120. package/dist/tools/orchestration/agent-management.js +0 -250
  121. package/dist/tools/orchestration/agent-start.d.ts +0 -18
  122. package/dist/tools/orchestration/agent-start.js +0 -90
  123. package/dist/tools/orchestration/index.d.ts +0 -49
  124. package/dist/tools/orchestration/index.js +0 -102
  125. package/dist/tools/orchestration/task-assign.d.ts +0 -18
  126. package/dist/tools/orchestration/task-assign.js +0 -84
  127. package/dist/tools/orchestration/task-create.d.ts +0 -20
  128. package/dist/tools/orchestration/task-create.js +0 -97
  129. package/dist/tools/orchestration/task-delete.d.ts +0 -16
  130. package/dist/tools/orchestration/task-delete.js +0 -77
  131. package/dist/tools/orchestration/task-execute.d.ts +0 -18
  132. package/dist/tools/orchestration/task-execute.js +0 -84
  133. package/dist/tools/orchestration/task-get.d.ts +0 -16
  134. package/dist/tools/orchestration/task-get.js +0 -89
  135. package/dist/tools/orchestration/task-list.d.ts +0 -13
  136. package/dist/tools/orchestration/task-list.js +0 -74
  137. package/dist/tools/orchestration/task-management.d.ts +0 -52
  138. package/dist/tools/orchestration/task-management.js +0 -231
  139. package/dist/tools/orchestration/task-update.d.ts +0 -22
  140. package/dist/tools/orchestration/task-update.js +0 -96
  141. package/dist/tools/orchestration/thread-create-background.d.ts +0 -18
  142. package/dist/tools/orchestration/thread-create-background.js +0 -94
  143. package/dist/tools/orchestration/thread-create-start.d.ts +0 -16
  144. package/dist/tools/orchestration/thread-create-start.js +0 -85
  145. package/dist/tools/orchestration/thread-create.d.ts +0 -16
  146. package/dist/tools/orchestration/thread-create.js +0 -85
  147. package/dist/tools/orchestration/thread-delete.d.ts +0 -16
  148. package/dist/tools/orchestration/thread-delete.js +0 -77
  149. package/dist/tools/orchestration/thread-get-messages.d.ts +0 -24
  150. package/dist/tools/orchestration/thread-get-messages.js +0 -122
  151. package/dist/tools/orchestration/thread-get.d.ts +0 -16
  152. package/dist/tools/orchestration/thread-get.js +0 -85
  153. package/dist/tools/orchestration/thread-list.d.ts +0 -16
  154. package/dist/tools/orchestration/thread-list.js +0 -85
  155. package/dist/tools/orchestration/thread-start.d.ts +0 -16
  156. package/dist/tools/orchestration/thread-start.js +0 -82
  157. package/dist/tools/orchestration/thread-update-status.d.ts +0 -18
  158. package/dist/tools/orchestration/thread-update-status.js +0 -89
  159. package/dist/tools/orchestration/thread-update.d.ts +0 -18
  160. package/dist/tools/orchestration/thread-update.js +0 -89
@@ -9,6 +9,7 @@ var AgentDeliberationAction;
9
9
  AgentDeliberationAction["UPDATE"] = "agentdeliberation.update";
10
10
  AgentDeliberationAction["RESPOND"] = "agentdeliberation.respond";
11
11
  AgentDeliberationAction["VOTE"] = "agentdeliberation.vote";
12
+ AgentDeliberationAction["VOTE_OPTION"] = "agentdeliberation.vote-option";
12
13
  AgentDeliberationAction["WINNER"] = "agentdeliberation.winner";
13
14
  AgentDeliberationAction["SUMMARY"] = "agentdeliberation.summary";
14
15
  })(AgentDeliberationAction || (exports.AgentDeliberationAction = AgentDeliberationAction = {}));
@@ -20,6 +21,7 @@ var AgentDeliberationResponseType;
20
21
  AgentDeliberationResponseType["UPDATE_RESPONSE"] = "agentdeliberation.update.response";
21
22
  AgentDeliberationResponseType["RESPOND_RESPONSE"] = "agentdeliberation.respond.response";
22
23
  AgentDeliberationResponseType["VOTE_RESPONSE"] = "agentdeliberation.vote.response";
24
+ AgentDeliberationResponseType["VOTE_OPTION_RESPONSE"] = "agentdeliberation.vote-option.response";
23
25
  AgentDeliberationResponseType["WINNER_RESPONSE"] = "agentdeliberation.winner.response";
24
26
  AgentDeliberationResponseType["SUMMARY_RESPONSE"] = "agentdeliberation.summary.response";
25
27
  })(AgentDeliberationResponseType || (exports.AgentDeliberationResponseType = AgentDeliberationResponseType = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/codeboltjs",
3
- "version": "5.0.8",
3
+ "version": "5.1.10",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -12,6 +12,21 @@
12
12
  "LICENSE",
13
13
  "package.json"
14
14
  ],
15
+ "scripts": {
16
+ "build": "tsc -p tsconfig.build.json && node script/copy-wasm.js",
17
+ "build:webpack": "webpack",
18
+ "build:all": "npm run build && npm run build:webpack",
19
+ "build:docs": "typedoc --plugin typedoc-plugin-missing-exports",
20
+ "build:docs:md": "node script/gen-docusaurus-types.js --clean",
21
+ "build:jsondocs": "typedoc --plugin typedoc-plugin-missing-exports --json out.json --pretty",
22
+ "test": "jest",
23
+ "test:watch": "jest --watch",
24
+ "test:coverage": "jest --coverage",
25
+ "test:verbose": "jest --verbose",
26
+ "test:debug": "DEBUG_TESTS=true jest",
27
+ "clean": "powershell -Command \"Remove-Item -Path 'dist' -Recurse -Force -ErrorAction SilentlyContinue; Remove-Item -Path 'build' -Recurse -Force -ErrorAction SilentlyContinue\"",
28
+ "lint": "eslint src/**/*.ts && tsc -p tsconfig.json --noEmit"
29
+ },
15
30
  "repository": {
16
31
  "type": "git",
17
32
  "url": "git+https://github.com/codeboltai/codeboltjs.git",
@@ -23,10 +38,12 @@
23
38
  "access": "public"
24
39
  },
25
40
  "dependencies": {
41
+ "@codebolt/types": "5.1.10",
26
42
  "@types/uuid": "^10.0.0",
27
43
  "buffer": "^6.0.3",
28
44
  "execa": "^9.5.2",
29
45
  "js-yaml": "^4.1.0",
46
+ "minisearch": "^7.2.0",
30
47
  "os-browserify": "^0.3.0",
31
48
  "path-browserify": "^1.0.1",
32
49
  "stream-browserify": "^3.0.0",
@@ -34,8 +51,7 @@
34
51
  "util": "^0.12.5",
35
52
  "uuid": "^11.1.0",
36
53
  "ws": "^8.18.3",
37
- "yargs": "^17.7.2",
38
- "@codebolt/types": "5.0.8"
54
+ "yargs": "^17.7.2"
39
55
  },
40
56
  "devDependencies": {
41
57
  "@types/events": "^3.0.3",
@@ -61,20 +77,5 @@
61
77
  "types": "./dist/index.d.ts",
62
78
  "default": "./dist/index.js"
63
79
  }
64
- },
65
- "scripts": {
66
- "build": "tsc -p tsconfig.build.json && node script/copy-wasm.js",
67
- "build:webpack": "webpack",
68
- "build:all": "npm run build && npm run build:webpack",
69
- "build:docs": "typedoc --plugin typedoc-plugin-missing-exports",
70
- "build:docs:md": "node script/gen-docusaurus-types.js --clean",
71
- "build:jsondocs": "typedoc --plugin typedoc-plugin-missing-exports --json out.json --pretty",
72
- "test": "jest",
73
- "test:watch": "jest --watch",
74
- "test:coverage": "jest --coverage",
75
- "test:verbose": "jest --verbose",
76
- "test:debug": "DEBUG_TESTS=true jest",
77
- "clean": "powershell -Command \"Remove-Item -Path 'dist' -Recurse -Force -ErrorAction SilentlyContinue; Remove-Item -Path 'build' -Recurse -Force -ErrorAction SilentlyContinue\"",
78
- "lint": "eslint src/**/*.ts && tsc -p tsconfig.json --noEmit"
79
80
  }
80
- }
81
+ }
@@ -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
- }