@codebolt/codeboltjs 5.0.8 → 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.
Files changed (124) hide show
  1. package/dist/core/Codebolt.d.ts +29 -5
  2. package/dist/core/Codebolt.js +58 -0
  3. package/dist/core/websocket.js +15 -17
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.js +6 -3
  6. package/dist/modules/dynamicPanel.d.ts +106 -0
  7. package/dist/modules/dynamicPanel.js +122 -0
  8. package/dist/modules/mcp.js +3 -0
  9. package/dist/modules/swarm.d.ts +8 -2
  10. package/dist/modules/swarm.js +14 -0
  11. package/dist/tools/actionBlock/action-block-start.js +1 -4
  12. package/dist/tools/actionPlan/action-plan-create.js +1 -2
  13. package/dist/tools/completion/attempt-completion.d.ts +25 -0
  14. package/dist/tools/completion/attempt-completion.js +45 -0
  15. package/dist/tools/completion/index.d.ts +3 -0
  16. package/dist/tools/completion/index.js +9 -0
  17. package/dist/tools/index.d.ts +6 -3
  18. package/dist/tools/index.js +11 -4
  19. package/dist/tools/job/index.d.ts +3 -1
  20. package/dist/tools/job/index.js +5 -1
  21. package/dist/tools/job/job-remove-dependency.d.ts +28 -0
  22. package/dist/tools/job/job-remove-dependency.js +86 -0
  23. package/dist/tools/requirementPlan/requirement-plan-review.js +1 -1
  24. package/dist/tools/thread/thread-create-background.js +1 -1
  25. package/dist/tools/utils/schema-validator.d.ts +1 -0
  26. package/dist/tools/utils/schema-validator.js +13 -1
  27. package/dist/types/job.d.ts +1 -1
  28. package/package.json +2 -2
  29. package/dist/modules/codeboltEvent.d.ts +0 -57
  30. package/dist/modules/codeboltEvent.js +0 -217
  31. package/dist/tools/browser/browser-action.d.ts +0 -56
  32. package/dist/tools/browser/browser-action.js +0 -265
  33. package/dist/tools/codeboltEvent/event-add-running-agent.d.ts +0 -25
  34. package/dist/tools/codeboltEvent/event-add-running-agent.js +0 -69
  35. package/dist/tools/codeboltEvent/event-check-background-agent-completion.d.ts +0 -19
  36. package/dist/tools/codeboltEvent/event-check-background-agent-completion.js +0 -64
  37. package/dist/tools/codeboltEvent/event-get-running-agent-count.d.ts +0 -19
  38. package/dist/tools/codeboltEvent/event-get-running-agent-count.js +0 -55
  39. package/dist/tools/codeboltEvent/event-on-background-agent-completion.d.ts +0 -19
  40. package/dist/tools/codeboltEvent/event-on-background-agent-completion.js +0 -56
  41. package/dist/tools/codeboltEvent/event-wait-for-external-event.d.ts +0 -19
  42. package/dist/tools/codeboltEvent/event-wait-for-external-event.js +0 -55
  43. package/dist/tools/codeboltEvent/index.d.ts +0 -19
  44. package/dist/tools/codeboltEvent/index.js +0 -33
  45. package/dist/tools/event/event-add-running-agent.d.ts +0 -32
  46. package/dist/tools/event/event-add-running-agent.js +0 -77
  47. package/dist/tools/event/event-check-agent-event.d.ts +0 -19
  48. package/dist/tools/event/event-check-agent-event.js +0 -63
  49. package/dist/tools/event/event-check-completion.d.ts +0 -19
  50. package/dist/tools/event/event-check-completion.js +0 -73
  51. package/dist/tools/event/event-check-grouped-completion.d.ts +0 -19
  52. package/dist/tools/event/event-check-grouped-completion.js +0 -63
  53. package/dist/tools/event/event-get-running-count.d.ts +0 -19
  54. package/dist/tools/event/event-get-running-count.js +0 -55
  55. package/dist/tools/event/event-on-agent-event.d.ts +0 -19
  56. package/dist/tools/event/event-on-agent-event.js +0 -63
  57. package/dist/tools/event/event-on-completion.d.ts +0 -19
  58. package/dist/tools/event/event-on-completion.js +0 -73
  59. package/dist/tools/event/event-on-grouped-completion.d.ts +0 -19
  60. package/dist/tools/event/event-on-grouped-completion.js +0 -63
  61. package/dist/tools/event/event-wait-any.d.ts +0 -19
  62. package/dist/tools/event/event-wait-any.js +0 -66
  63. package/dist/tools/event/index.d.ts +0 -25
  64. package/dist/tools/event/index.js +0 -48
  65. package/dist/tools/git/git-action.d.ts +0 -48
  66. package/dist/tools/git/git-action.js +0 -279
  67. package/dist/tools/kvStore/kv-store-create-instance.d.ts +0 -26
  68. package/dist/tools/kvStore/kv-store-create-instance.js +0 -79
  69. package/dist/tools/kvStore/kv-store-get.d.ts +0 -30
  70. package/dist/tools/kvStore/kv-store-get.js +0 -80
  71. package/dist/tools/kvStore/kv-store-set.d.ts +0 -38
  72. package/dist/tools/kvStore/kv-store-set.js +0 -86
  73. package/dist/tools/memoryIngestion/mi-create-pipeline.d.ts +0 -44
  74. package/dist/tools/memoryIngestion/mi-create-pipeline.js +0 -114
  75. package/dist/tools/memoryIngestion/mi-list.d.ts +0 -22
  76. package/dist/tools/memoryIngestion/mi-list.js +0 -66
  77. package/dist/tools/orchestration/agent-details.d.ts +0 -15
  78. package/dist/tools/orchestration/agent-details.js +0 -98
  79. package/dist/tools/orchestration/agent-find.d.ts +0 -18
  80. package/dist/tools/orchestration/agent-find.js +0 -125
  81. package/dist/tools/orchestration/agent-list.d.ts +0 -13
  82. package/dist/tools/orchestration/agent-list.js +0 -106
  83. package/dist/tools/orchestration/agent-management.d.ts +0 -44
  84. package/dist/tools/orchestration/agent-management.js +0 -250
  85. package/dist/tools/orchestration/agent-start.d.ts +0 -18
  86. package/dist/tools/orchestration/agent-start.js +0 -90
  87. package/dist/tools/orchestration/index.d.ts +0 -49
  88. package/dist/tools/orchestration/index.js +0 -102
  89. package/dist/tools/orchestration/task-assign.d.ts +0 -18
  90. package/dist/tools/orchestration/task-assign.js +0 -84
  91. package/dist/tools/orchestration/task-create.d.ts +0 -20
  92. package/dist/tools/orchestration/task-create.js +0 -97
  93. package/dist/tools/orchestration/task-delete.d.ts +0 -16
  94. package/dist/tools/orchestration/task-delete.js +0 -77
  95. package/dist/tools/orchestration/task-execute.d.ts +0 -18
  96. package/dist/tools/orchestration/task-execute.js +0 -84
  97. package/dist/tools/orchestration/task-get.d.ts +0 -16
  98. package/dist/tools/orchestration/task-get.js +0 -89
  99. package/dist/tools/orchestration/task-list.d.ts +0 -13
  100. package/dist/tools/orchestration/task-list.js +0 -74
  101. package/dist/tools/orchestration/task-management.d.ts +0 -52
  102. package/dist/tools/orchestration/task-management.js +0 -231
  103. package/dist/tools/orchestration/task-update.d.ts +0 -22
  104. package/dist/tools/orchestration/task-update.js +0 -96
  105. package/dist/tools/orchestration/thread-create-background.d.ts +0 -18
  106. package/dist/tools/orchestration/thread-create-background.js +0 -94
  107. package/dist/tools/orchestration/thread-create-start.d.ts +0 -16
  108. package/dist/tools/orchestration/thread-create-start.js +0 -85
  109. package/dist/tools/orchestration/thread-create.d.ts +0 -16
  110. package/dist/tools/orchestration/thread-create.js +0 -85
  111. package/dist/tools/orchestration/thread-delete.d.ts +0 -16
  112. package/dist/tools/orchestration/thread-delete.js +0 -77
  113. package/dist/tools/orchestration/thread-get-messages.d.ts +0 -24
  114. package/dist/tools/orchestration/thread-get-messages.js +0 -122
  115. package/dist/tools/orchestration/thread-get.d.ts +0 -16
  116. package/dist/tools/orchestration/thread-get.js +0 -85
  117. package/dist/tools/orchestration/thread-list.d.ts +0 -16
  118. package/dist/tools/orchestration/thread-list.js +0 -85
  119. package/dist/tools/orchestration/thread-start.d.ts +0 -16
  120. package/dist/tools/orchestration/thread-start.js +0 -82
  121. package/dist/tools/orchestration/thread-update-status.d.ts +0 -18
  122. package/dist/tools/orchestration/thread-update-status.js +0 -89
  123. package/dist/tools/orchestration/thread-update.d.ts +0 -18
  124. package/dist/tools/orchestration/thread-update.js +0 -89
@@ -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
- }
@@ -1,265 +0,0 @@
1
- "use strict";
2
- /**
3
- * Browser Action Tool - Performs browser automation actions
4
- * Wraps the SDK's cbbrowser methods
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.BrowserActionTool = void 0;
11
- const types_1 = require("../types");
12
- const base_tool_1 = require("../base-tool");
13
- const browser_1 = __importDefault(require("../../modules/browser"));
14
- class BrowserActionToolInvocation extends base_tool_1.BaseToolInvocation {
15
- constructor(params) {
16
- super(params);
17
- }
18
- async execute() {
19
- var _a;
20
- try {
21
- const action = this.params.action;
22
- const options = this.params.instance_id ? { instanceId: this.params.instance_id } : undefined;
23
- let response;
24
- let successMessage;
25
- switch (action) {
26
- case 'navigate':
27
- if (!this.params.url) {
28
- return this.createError("'url' is required for navigate action");
29
- }
30
- response = await browser_1.default.goToPage(this.params.url, options);
31
- successMessage = `Navigated to ${this.params.url}`;
32
- break;
33
- case 'screenshot':
34
- response = await browser_1.default.screenshot(options);
35
- successMessage = 'Screenshot taken';
36
- break;
37
- case 'click':
38
- if (!this.params.element_id) {
39
- return this.createError("'element_id' is required for click action");
40
- }
41
- response = await browser_1.default.click(this.params.element_id, options);
42
- successMessage = `Clicked element: ${this.params.element_id}`;
43
- break;
44
- case 'type':
45
- if (!this.params.element_id) {
46
- return this.createError("'element_id' is required for type action");
47
- }
48
- if (!this.params.text) {
49
- return this.createError("'text' is required for type action");
50
- }
51
- response = await browser_1.default.type(this.params.element_id, this.params.text, options);
52
- successMessage = `Typed text into element: ${this.params.element_id}`;
53
- break;
54
- case 'scroll':
55
- if (!this.params.direction) {
56
- return this.createError("'direction' is required for scroll action");
57
- }
58
- if (!this.params.pixels) {
59
- return this.createError("'pixels' is required for scroll action");
60
- }
61
- response = await browser_1.default.scroll(this.params.direction, this.params.pixels, options);
62
- successMessage = `Scrolled ${this.params.direction} by ${this.params.pixels} pixels`;
63
- break;
64
- case 'get_content':
65
- response = await browser_1.default.getContent(options);
66
- successMessage = 'Retrieved page content';
67
- break;
68
- case 'get_html':
69
- response = await browser_1.default.getHTML(options);
70
- successMessage = 'Retrieved page HTML';
71
- break;
72
- case 'get_markdown':
73
- response = await browser_1.default.getMarkdown(options);
74
- successMessage = 'Retrieved page as Markdown';
75
- break;
76
- case 'get_url':
77
- response = await browser_1.default.getUrl(options);
78
- successMessage = 'Retrieved current URL';
79
- break;
80
- case 'close':
81
- await browser_1.default.close(options);
82
- return {
83
- llmContent: 'Browser closed successfully',
84
- returnDisplay: 'Browser closed',
85
- };
86
- case 'enter':
87
- response = await browser_1.default.enter(options);
88
- successMessage = 'Pressed Enter';
89
- break;
90
- case 'search':
91
- if (!this.params.element_id) {
92
- return this.createError("'element_id' is required for search action");
93
- }
94
- if (!this.params.query) {
95
- return this.createError("'query' is required for search action");
96
- }
97
- response = await browser_1.default.search(this.params.element_id, this.params.query, options);
98
- successMessage = `Searched for: ${this.params.query}`;
99
- break;
100
- default:
101
- return this.createError(`Unknown action: ${action}`);
102
- }
103
- // Check for errors
104
- if (response && !response.success && response.success !== undefined) {
105
- const errorMsg = typeof response.error === 'string'
106
- ? response.error
107
- : ((_a = response.error) === null || _a === void 0 ? void 0 : _a.message) || 'Browser operation failed';
108
- return {
109
- llmContent: `Browser ${action} failed: ${errorMsg}`,
110
- returnDisplay: `Error: ${errorMsg}`,
111
- error: {
112
- message: errorMsg,
113
- type: types_1.ToolErrorType.BROWSER_EXECUTION_ERROR,
114
- },
115
- };
116
- }
117
- // Format output based on action
118
- let output = successMessage;
119
- if (action === 'get_url' && response.url) {
120
- output = `Current URL: ${response.url}`;
121
- }
122
- else if (action === 'get_content' && response.content) {
123
- output = `Page content:\n\n${this.truncate(response.content, 5000)}`;
124
- }
125
- else if (action === 'get_html' && response.html) {
126
- output = `HTML content:\n\n${this.truncate(response.html, 5000)}`;
127
- }
128
- else if (action === 'get_markdown' && response.markdown) {
129
- output = `Markdown content:\n\n${response.markdown}`;
130
- }
131
- else if (action === 'screenshot' && response.screenshot) {
132
- output = 'Screenshot captured successfully.\n\n[Screenshot data available]';
133
- }
134
- else if (response && response.result) {
135
- output += '\n\n' + (typeof response.result === 'string' ? response.result : JSON.stringify(response.result, null, 2));
136
- }
137
- return {
138
- llmContent: output,
139
- returnDisplay: successMessage,
140
- };
141
- }
142
- catch (error) {
143
- const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
144
- return {
145
- llmContent: `Error executing browser ${this.params.action}: ${errorMessage}`,
146
- returnDisplay: `Error: ${errorMessage}`,
147
- error: {
148
- message: errorMessage,
149
- type: types_1.ToolErrorType.EXECUTION_FAILED,
150
- },
151
- };
152
- }
153
- }
154
- createError(message) {
155
- return {
156
- llmContent: `Error: ${message}`,
157
- returnDisplay: `Error: ${message}`,
158
- error: {
159
- message,
160
- type: types_1.ToolErrorType.INVALID_TOOL_PARAMS,
161
- },
162
- };
163
- }
164
- truncate(text, maxLength) {
165
- if (text.length <= maxLength)
166
- return text;
167
- return text.substring(0, maxLength) + '\n\n... (content truncated)';
168
- }
169
- }
170
- /**
171
- * Implementation of the BrowserAction tool logic
172
- */
173
- class BrowserActionTool extends base_tool_1.BaseDeclarativeTool {
174
- constructor() {
175
- super(BrowserActionTool.Name, 'BrowserAction', `Performs browser automation actions like navigating to URLs, taking screenshots, clicking elements, typing text, scrolling, and extracting page content. Use this for web automation and scraping tasks.`, types_1.Kind.Execute, {
176
- properties: {
177
- action: {
178
- description: "The browser action to perform: 'navigate', 'screenshot', 'click', 'type', 'scroll', 'get_content', 'get_html', 'get_markdown', 'get_url', 'close', 'enter', or 'search'.",
179
- type: 'string',
180
- enum: ['navigate', 'screenshot', 'click', 'type', 'scroll', 'get_content', 'get_html', 'get_markdown', 'get_url', 'close', 'enter', 'search'],
181
- },
182
- url: {
183
- description: "URL to navigate to (required for 'navigate' action).",
184
- type: 'string',
185
- },
186
- element_id: {
187
- description: "Element ID to interact with (required for 'click', 'type', 'search' actions).",
188
- type: 'string',
189
- },
190
- text: {
191
- description: "Text to type (required for 'type' action).",
192
- type: 'string',
193
- },
194
- query: {
195
- description: "Search query (required for 'search' action).",
196
- type: 'string',
197
- },
198
- direction: {
199
- description: "Scroll direction: 'up', 'down', 'left', 'right' (required for 'scroll' action).",
200
- type: 'string',
201
- enum: ['up', 'down', 'left', 'right'],
202
- },
203
- pixels: {
204
- description: "Number of pixels to scroll (required for 'scroll' action).",
205
- type: 'string',
206
- },
207
- instance_id: {
208
- description: 'Optional browser instance ID for multi-instance support.',
209
- type: 'string',
210
- },
211
- },
212
- required: ['action'],
213
- type: 'object',
214
- });
215
- }
216
- validateToolParamValues(params) {
217
- const validActions = ['navigate', 'screenshot', 'click', 'type', 'scroll', 'get_content', 'get_html', 'get_markdown', 'get_url', 'close', 'enter', 'search'];
218
- if (!validActions.includes(params.action)) {
219
- return `Invalid action: ${params.action}. Must be one of: ${validActions.join(', ')}`;
220
- }
221
- // Action-specific validation
222
- switch (params.action) {
223
- case 'navigate':
224
- if (!params.url) {
225
- return "'url' is required for navigate action";
226
- }
227
- break;
228
- case 'click':
229
- if (!params.element_id) {
230
- return "'element_id' is required for click action";
231
- }
232
- break;
233
- case 'type':
234
- if (!params.element_id) {
235
- return "'element_id' is required for type action";
236
- }
237
- if (!params.text) {
238
- return "'text' is required for type action";
239
- }
240
- break;
241
- case 'scroll':
242
- if (!params.direction) {
243
- return "'direction' is required for scroll action";
244
- }
245
- if (!params.pixels) {
246
- return "'pixels' is required for scroll action";
247
- }
248
- break;
249
- case 'search':
250
- if (!params.element_id) {
251
- return "'element_id' is required for search action";
252
- }
253
- if (!params.query) {
254
- return "'query' is required for search action";
255
- }
256
- break;
257
- }
258
- return null;
259
- }
260
- createInvocation(params) {
261
- return new BrowserActionToolInvocation(params);
262
- }
263
- }
264
- exports.BrowserActionTool = BrowserActionTool;
265
- BrowserActionTool.Name = 'browser_action';
@@ -1,25 +0,0 @@
1
- /**
2
- * Event Add Running Agent Tool
3
- *
4
- * Adds a running background agent to tracking.
5
- */
6
- import type { ToolInvocation, ToolResult } from '../types';
7
- import { BaseDeclarativeTool } from '../base-tool';
8
- /**
9
- * Parameters for adding a running agent
10
- */
11
- export interface EventAddRunningAgentParams {
12
- /** The thread ID */
13
- threadId: string;
14
- /** The agent data */
15
- data: any;
16
- /** Optional group ID */
17
- groupId?: string;
18
- }
19
- /**
20
- * Tool for adding a running agent
21
- */
22
- export declare class EventAddRunningAgentTool extends BaseDeclarativeTool<EventAddRunningAgentParams, ToolResult> {
23
- constructor();
24
- protected createInvocation(params: EventAddRunningAgentParams): ToolInvocation<EventAddRunningAgentParams, ToolResult>;
25
- }
@@ -1,69 +0,0 @@
1
- "use strict";
2
- /**
3
- * Event Add Running Agent Tool
4
- *
5
- * Adds a running background agent to tracking.
6
- */
7
- var __importDefault = (this && this.__importDefault) || function (mod) {
8
- return (mod && mod.__esModule) ? mod : { "default": mod };
9
- };
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.EventAddRunningAgentTool = void 0;
12
- const types_1 = require("../types");
13
- const base_tool_1 = require("../base-tool");
14
- const codeboltEvent_1 = __importDefault(require("../../modules/codeboltEvent"));
15
- class EventAddRunningAgentInvocation extends base_tool_1.BaseToolInvocation {
16
- constructor(params) {
17
- super(params);
18
- }
19
- async execute(_signal) {
20
- try {
21
- codeboltEvent_1.default.addRunningAgent(this.params.threadId, this.params.data, this.params.groupId);
22
- const groupInfo = this.params.groupId ? ` to group ${this.params.groupId}` : '';
23
- return {
24
- llmContent: `Successfully added running agent ${this.params.threadId}${groupInfo}`,
25
- returnDisplay: `Added running agent ${this.params.threadId}`,
26
- };
27
- }
28
- catch (error) {
29
- const errorMessage = error instanceof Error ? error.message : String(error);
30
- return {
31
- llmContent: `Error: ${errorMessage}`,
32
- returnDisplay: `Error: ${errorMessage}`,
33
- error: {
34
- message: errorMessage,
35
- type: types_1.ToolErrorType.EXECUTION_FAILED,
36
- },
37
- };
38
- }
39
- }
40
- }
41
- /**
42
- * Tool for adding a running agent
43
- */
44
- class EventAddRunningAgentTool extends base_tool_1.BaseDeclarativeTool {
45
- constructor() {
46
- super('event_add_running_agent', 'Add Running Agent', 'Adds a running background agent to tracking with optional group ID.', types_1.Kind.Other, {
47
- type: 'object',
48
- properties: {
49
- threadId: {
50
- type: 'string',
51
- description: 'The thread ID',
52
- },
53
- data: {
54
- type: 'object',
55
- description: 'The agent data',
56
- },
57
- groupId: {
58
- type: 'string',
59
- description: 'Optional group ID',
60
- },
61
- },
62
- required: ['threadId', 'data'],
63
- });
64
- }
65
- createInvocation(params) {
66
- return new EventAddRunningAgentInvocation(params);
67
- }
68
- }
69
- exports.EventAddRunningAgentTool = EventAddRunningAgentTool;
@@ -1,19 +0,0 @@
1
- /**
2
- * Event Check Background Agent Completion Tool
3
- *
4
- * Checks if any background agent has completed (non-blocking).
5
- */
6
- import type { ToolInvocation, ToolResult } from '../types';
7
- import { BaseDeclarativeTool } from '../base-tool';
8
- /**
9
- * Parameters for checking background agent completion (none required)
10
- */
11
- export interface EventCheckBackgroundAgentCompletionParams {
12
- }
13
- /**
14
- * Tool for checking background agent completion
15
- */
16
- export declare class EventCheckBackgroundAgentCompletionTool extends BaseDeclarativeTool<EventCheckBackgroundAgentCompletionParams, ToolResult> {
17
- constructor();
18
- protected createInvocation(params: EventCheckBackgroundAgentCompletionParams): ToolInvocation<EventCheckBackgroundAgentCompletionParams, ToolResult>;
19
- }