@codebolt/codeboltjs 2.0.13 → 2.0.16

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 (127) hide show
  1. package/dist/agentlib/agent.js +3 -7
  2. package/dist/agentlib/followupquestionbuilder.d.ts +75 -0
  3. package/dist/agentlib/followupquestionbuilder.js +193 -0
  4. package/dist/agentlib/llmoutputhandler.d.ts +102 -0
  5. package/dist/agentlib/llmoutputhandler.js +451 -0
  6. package/dist/agentlib/promptbuilder.d.ts +171 -17
  7. package/dist/agentlib/promptbuilder.js +367 -49
  8. package/dist/agentlib/systemprompt.js +3 -3
  9. package/dist/agentlib/usermessage.d.ts +1 -1
  10. package/dist/agentlib/usermessage.js +5 -1
  11. package/dist/core/Codebolt.d.ts +52 -20
  12. package/dist/core/Codebolt.js +43 -1
  13. package/dist/core/messageManager.d.ts +0 -1
  14. package/dist/core/messageManager.js +4 -2
  15. package/dist/core/websocket.js +27 -1
  16. package/dist/modules/llm.d.ts +23 -3
  17. package/dist/modules/llm.js +20 -3
  18. package/dist/modules/project.d.ts +3 -3
  19. package/dist/modules/project.js +1 -1
  20. package/dist/modules/state.d.ts +5 -3
  21. package/dist/modules/state.js +2 -0
  22. package/dist/modules/task.d.ts +126 -11
  23. package/dist/modules/task.js +262 -20
  24. package/dist/notificationfunctions/agent.d.ts +48 -0
  25. package/dist/notificationfunctions/agent.js +115 -0
  26. package/dist/notificationfunctions/browser.d.ts +60 -0
  27. package/dist/notificationfunctions/browser.js +145 -0
  28. package/dist/notificationfunctions/chat.d.ts +53 -0
  29. package/dist/notificationfunctions/chat.js +125 -0
  30. package/dist/notificationfunctions/codeutils.d.ts +60 -0
  31. package/dist/notificationfunctions/codeutils.js +145 -0
  32. package/dist/notificationfunctions/crawler.d.ts +59 -0
  33. package/dist/notificationfunctions/crawler.js +159 -0
  34. package/dist/notificationfunctions/dbmemory.d.ts +50 -0
  35. package/dist/notificationfunctions/dbmemory.js +132 -0
  36. package/dist/notificationfunctions/fs.d.ts +125 -0
  37. package/dist/notificationfunctions/fs.js +472 -0
  38. package/dist/notificationfunctions/git.d.ts +174 -0
  39. package/dist/notificationfunctions/git.js +521 -0
  40. package/dist/notificationfunctions/history.d.ts +38 -0
  41. package/dist/notificationfunctions/history.js +97 -0
  42. package/dist/notificationfunctions/index.d.ts +79 -0
  43. package/dist/notificationfunctions/index.js +102 -0
  44. package/dist/notificationfunctions/llm.d.ts +39 -0
  45. package/dist/notificationfunctions/llm.js +99 -0
  46. package/dist/notificationfunctions/mcp.d.ts +67 -0
  47. package/dist/notificationfunctions/mcp.js +192 -0
  48. package/dist/notificationfunctions/search.d.ts +50 -0
  49. package/dist/notificationfunctions/search.js +146 -0
  50. package/dist/notificationfunctions/system.d.ts +25 -0
  51. package/dist/notificationfunctions/system.js +59 -0
  52. package/dist/notificationfunctions/terminal.d.ts +26 -0
  53. package/dist/notificationfunctions/terminal.js +64 -0
  54. package/dist/notificationfunctions/todo.d.ts +63 -0
  55. package/dist/notificationfunctions/todo.js +164 -0
  56. package/dist/notificationfunctions/utils.d.ts +81 -0
  57. package/dist/notificationfunctions/utils.js +177 -0
  58. package/dist/types/InternalTypes.d.ts +1 -0
  59. package/dist/types/commonTypes.d.ts +26 -3
  60. package/dist/types/index.d.ts +2 -2
  61. package/dist/types/libFunctionTypes.d.ts +80 -3
  62. package/dist/types/notificationFunctions/agent.d.ts +8 -0
  63. package/dist/types/notificationFunctions/agent.js +2 -0
  64. package/dist/types/notificationFunctions/browser.d.ts +10 -0
  65. package/dist/types/notificationFunctions/browser.js +2 -0
  66. package/dist/types/notificationFunctions/chat.d.ts +10 -0
  67. package/dist/types/notificationFunctions/chat.js +2 -0
  68. package/dist/types/notificationFunctions/codeutils.d.ts +10 -0
  69. package/dist/types/notificationFunctions/codeutils.js +2 -0
  70. package/dist/types/notificationFunctions/crawler.d.ts +10 -0
  71. package/dist/types/notificationFunctions/crawler.js +2 -0
  72. package/dist/types/notificationFunctions/dbmemory.d.ts +9 -0
  73. package/dist/types/notificationFunctions/dbmemory.js +2 -0
  74. package/dist/types/notificationFunctions/fs.d.ts +27 -0
  75. package/dist/types/notificationFunctions/fs.js +2 -0
  76. package/dist/types/notificationFunctions/git.d.ts +29 -0
  77. package/dist/types/notificationFunctions/git.js +2 -0
  78. package/dist/types/notificationFunctions/history.d.ts +10 -0
  79. package/dist/types/notificationFunctions/history.js +2 -0
  80. package/dist/types/notificationFunctions/index.d.ts +0 -0
  81. package/dist/types/notificationFunctions/index.js +1 -0
  82. package/dist/types/notificationFunctions/llm.d.ts +10 -0
  83. package/dist/types/notificationFunctions/llm.js +2 -0
  84. package/dist/types/notificationFunctions/mcp.d.ts +16 -0
  85. package/dist/types/notificationFunctions/mcp.js +2 -0
  86. package/dist/types/notificationFunctions/search.d.ts +11 -0
  87. package/dist/types/notificationFunctions/search.js +2 -0
  88. package/dist/types/notificationFunctions/system.d.ts +7 -0
  89. package/dist/types/notificationFunctions/system.js +2 -0
  90. package/dist/types/notificationFunctions/terminal.d.ts +7 -0
  91. package/dist/types/notificationFunctions/terminal.js +2 -0
  92. package/dist/types/notificationFunctions/todo.d.ts +11 -0
  93. package/dist/types/notificationFunctions/todo.js +2 -0
  94. package/dist/types/notifications/agent.d.ts +31 -0
  95. package/dist/types/notifications/agent.js +3 -0
  96. package/dist/types/notifications/browser.d.ts +53 -0
  97. package/dist/types/notifications/browser.js +3 -0
  98. package/dist/types/notifications/chat.d.ts +37 -0
  99. package/dist/types/notifications/chat.js +3 -0
  100. package/dist/types/notifications/codeutils.d.ts +55 -0
  101. package/dist/types/notifications/codeutils.js +3 -0
  102. package/dist/types/notifications/crawler.d.ts +55 -0
  103. package/dist/types/notifications/crawler.js +3 -0
  104. package/dist/types/notifications/dbmemory.d.ts +31 -0
  105. package/dist/types/notifications/dbmemory.js +3 -0
  106. package/dist/types/notifications/fs.d.ts +180 -0
  107. package/dist/types/notifications/fs.js +3 -0
  108. package/dist/types/notifications/git.d.ts +205 -0
  109. package/dist/types/notifications/git.js +3 -0
  110. package/dist/types/notifications/history.d.ts +32 -0
  111. package/dist/types/notifications/history.js +3 -0
  112. package/dist/types/notifications/llm.d.ts +45 -0
  113. package/dist/types/notifications/llm.js +2 -0
  114. package/dist/types/notifications/mcp.d.ts +63 -0
  115. package/dist/types/notifications/mcp.js +3 -0
  116. package/dist/types/notifications/search.d.ts +47 -0
  117. package/dist/types/notifications/search.js +3 -0
  118. package/dist/types/notifications/system.d.ts +20 -0
  119. package/dist/types/notifications/system.js +2 -0
  120. package/dist/types/notifications/terminal.d.ts +17 -0
  121. package/dist/types/notifications/terminal.js +2 -0
  122. package/dist/types/notifications/todo.d.ts +60 -0
  123. package/dist/types/notifications/todo.js +3 -0
  124. package/dist/types/socketMessageTypes.d.ts +3 -0
  125. package/dist/utils.d.ts +3 -0
  126. package/dist/utils.js +7 -1
  127. package/package.json +3 -1
@@ -5,46 +5,288 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const websocket_1 = __importDefault(require("../core/websocket"));
7
7
  /**
8
- * Manages task operations via WebSocket communication.
8
+ * Enhanced task planner with agent-based organization and comprehensive task management.
9
9
  */
10
10
  const taskplaner = {
11
11
  /**
12
- * Adds a task using a WebSocket message.
13
- * @param {string} task - The task to be added.
14
- * @returns {Promise<AddTaskResponse>} A promise that resolves with the response from the add task event.
12
+ * Adds a new task with enhanced parameters.
13
+ * @param {TaskCreateOptions} params - The task parameters including title, agentId, description, etc.
14
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the add task event.
15
15
  */
16
- addTask: async (task) => {
16
+ addTask: async (params) => {
17
+ const { title, agentId = 'default-agent', description, phase, category, priority, tags } = params;
17
18
  return websocket_1.default.messageManager.sendAndWaitForResponse({
18
- "type": "taskEvent",
19
- "action": "addTask",
19
+ type: "taskEvent",
20
+ action: "addTask",
21
+ agentId: agentId,
20
22
  message: {
21
- "task": task
23
+ title: title,
24
+ description: description,
25
+ phase: phase,
26
+ category: category,
27
+ priority: priority,
28
+ tags: tags
22
29
  }
23
30
  }, "addTaskResponse");
24
31
  },
25
32
  /**
26
- * Retrieves all tasks using a WebSocket message.
27
- * @returns {Promise<GetTasksResponse>} A promise that resolves with the response from the get tasks event.
33
+ * Adds a task using simple string parameter (legacy support).
34
+ * @param {string} task - The task title.
35
+ * @param {string} agentId - The agent ID (optional, defaults to 'default-agent').
36
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the add task event.
28
37
  */
29
- getTasks: async () => {
38
+ addSimpleTask: async (task, agentId = 'default-agent') => {
30
39
  return websocket_1.default.messageManager.sendAndWaitForResponse({
31
- "type": "taskEvent",
32
- "action": "getTasks"
40
+ type: "taskEvent",
41
+ action: "addTask",
42
+ agentId: agentId,
43
+ message: {
44
+ task: task
45
+ }
46
+ }, "addTaskResponse");
47
+ },
48
+ /**
49
+ * Retrieves all tasks with optional filtering.
50
+ * @param {TaskFilterOptions} filters - Optional filters for agentId, category, phase, etc.
51
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the get tasks event.
52
+ */
53
+ getTasks: async (filters = {}) => {
54
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
55
+ type: "taskEvent",
56
+ action: "getTasks",
57
+ message: filters
33
58
  }, "getTasksResponse");
34
59
  },
35
60
  /**
36
- * Updates an existing task using a WebSocket message.
61
+ * Retrieves tasks for a specific agent.
62
+ * @param {string} agentId - The agent ID.
63
+ * @returns {Promise<TaskResponse>} A promise that resolves with tasks for the specified agent.
64
+ */
65
+ getTasksByAgent: async (agentId) => {
66
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
67
+ type: "taskEvent",
68
+ action: "getTasksByAgent",
69
+ message: {
70
+ agentId: agentId
71
+ }
72
+ }, "getTasksByAgentResponse");
73
+ },
74
+ /**
75
+ * Retrieves tasks by category.
76
+ * @param {string} category - The category name.
77
+ * @returns {Promise<TaskResponse>} A promise that resolves with tasks in the specified category.
78
+ */
79
+ getTasksByCategory: async (category) => {
80
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
81
+ type: "taskEvent",
82
+ action: "getTasksByCategory",
83
+ message: {
84
+ category: category
85
+ }
86
+ }, "getTasksByCategoryResponse");
87
+ },
88
+ /**
89
+ * Retrieves all available agents.
90
+ * @returns {Promise<TaskResponse>} A promise that resolves with the list of all agents.
91
+ */
92
+ getAllAgents: async () => {
93
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
94
+ type: "taskEvent",
95
+ action: "getAllAgents"
96
+ }, "getAllAgentsResponse");
97
+ },
98
+ /**
99
+ * Updates an existing task.
100
+ * @param {TaskUpdateOptions} params - The task update parameters.
101
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update task event.
102
+ */
103
+ updateTask: async (params) => {
104
+ const { taskId, ...updates } = params;
105
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
106
+ type: "taskEvent",
107
+ action: "updateTask",
108
+ message: {
109
+ taskId: taskId,
110
+ ...updates
111
+ }
112
+ }, "updateTasksResponse");
113
+ },
114
+ /**
115
+ * Updates an existing task using legacy string parameter.
116
+ * @param {string} taskId - The task ID.
37
117
  * @param {string} task - The updated task information.
38
- * @returns {Promise<UpdateTasksResponse>} A promise that resolves with the response from the update task event.
118
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update task event.
39
119
  */
40
- updateTask: async (task) => {
120
+ updateSimpleTask: async (taskId, task) => {
41
121
  return websocket_1.default.messageManager.sendAndWaitForResponse({
42
- "type": "taskEvent",
43
- "action": "updateTask",
122
+ type: "taskEvent",
123
+ action: "updateTask",
44
124
  message: {
45
- "task": task
125
+ taskId: taskId,
126
+ task: task
46
127
  }
47
- }, "updateTaskResponse");
128
+ }, "updateTasksResponse");
129
+ },
130
+ /**
131
+ * Deletes a task.
132
+ * @param {string} taskId - The task ID to delete.
133
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the delete task event.
134
+ */
135
+ deleteTask: async (taskId) => {
136
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
137
+ type: "taskEvent",
138
+ action: "deleteTask",
139
+ message: {
140
+ taskId: taskId
141
+ }
142
+ }, "deleteTaskResponse");
143
+ },
144
+ /**
145
+ * Adds a subtask to an existing task.
146
+ * @param {AddSubTaskOptions} params - The subtask parameters.
147
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the add subtask event.
148
+ */
149
+ addSubTask: async (params) => {
150
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
151
+ type: "taskEvent",
152
+ action: "addSubTask",
153
+ message: params
154
+ }, "addSubTaskResponse");
155
+ },
156
+ /**
157
+ * Updates an existing subtask.
158
+ * @param {UpdateSubTaskOptions} params - The subtask update parameters.
159
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update subtask event.
160
+ */
161
+ updateSubTask: async (params) => {
162
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
163
+ type: "taskEvent",
164
+ action: "updateSubTask",
165
+ message: params
166
+ }, "updateSubTaskResponse");
167
+ },
168
+ /**
169
+ * Deletes a subtask.
170
+ * @param {string} taskId - The parent task ID.
171
+ * @param {string} subtaskId - The subtask ID to delete.
172
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the delete subtask event.
173
+ */
174
+ deleteSubTask: async (taskId, subtaskId) => {
175
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
176
+ type: "taskEvent",
177
+ action: "deleteSubTask",
178
+ message: {
179
+ taskId: taskId,
180
+ subtaskId: subtaskId
181
+ }
182
+ }, "deleteSubTaskResponse");
183
+ },
184
+ /**
185
+ * Creates tasks from markdown content.
186
+ * @param {TaskMarkdownImportOptions} params - The markdown parameters including content, agentId, phase, and category.
187
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the create tasks from markdown event.
188
+ */
189
+ createTasksFromMarkdown: async (params) => {
190
+ const { markdown, agentId = 'default-agent', phase, category } = params;
191
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
192
+ type: "taskEvent",
193
+ action: "createTasksFromMarkdown",
194
+ agentId: agentId,
195
+ message: {
196
+ markdown: markdown,
197
+ phase: phase,
198
+ category: category
199
+ }
200
+ }, "createTasksFromMarkdownResponse");
201
+ },
202
+ /**
203
+ * Exports tasks to markdown format.
204
+ * @param {TaskMarkdownExportOptions} params - The export parameters including optional phase, agentId, and category filters.
205
+ * @returns {Promise<TaskResponse>} A promise that resolves with the markdown content.
206
+ */
207
+ exportTasksToMarkdown: async (params = {}) => {
208
+ return websocket_1.default.messageManager.sendAndWaitForResponse({
209
+ type: "taskEvent",
210
+ action: "exportTasksToMarkdown",
211
+ message: params
212
+ }, "exportTasksToMarkdownResponse");
213
+ },
214
+ /**
215
+ * Utility function to toggle task completion status.
216
+ * @param {string} taskId - The task ID.
217
+ * @param {boolean} completed - The new completion status.
218
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update task event.
219
+ */
220
+ toggleTaskCompletion: async (taskId, completed) => {
221
+ return taskplaner.updateTask({
222
+ taskId: taskId,
223
+ completed: completed
224
+ });
225
+ },
226
+ /**
227
+ * Utility function to toggle subtask completion status.
228
+ * @param {string} taskId - The parent task ID.
229
+ * @param {string} subtaskId - The subtask ID.
230
+ * @param {boolean} completed - The new completion status.
231
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update subtask event.
232
+ */
233
+ toggleSubTaskCompletion: async (taskId, subtaskId, completed) => {
234
+ return taskplaner.updateSubTask({
235
+ taskId: taskId,
236
+ subtaskId: subtaskId,
237
+ completed: completed
238
+ });
239
+ },
240
+ /**
241
+ * Utility function to move a task to a different agent.
242
+ * @param {string} taskId - The task ID.
243
+ * @param {string} newAgentId - The new agent ID.
244
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update task event.
245
+ */
246
+ moveTaskToAgent: async (taskId, newAgentId) => {
247
+ return taskplaner.updateTask({
248
+ taskId: taskId,
249
+ agentId: newAgentId
250
+ });
251
+ },
252
+ /**
253
+ * Utility function to set task priority.
254
+ * @param {string} taskId - The task ID.
255
+ * @param {'low' | 'medium' | 'high'} priority - The priority level.
256
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update task event.
257
+ */
258
+ setTaskPriority: async (taskId, priority) => {
259
+ return taskplaner.updateTask({
260
+ taskId: taskId,
261
+ priority: priority
262
+ });
263
+ },
264
+ /**
265
+ * Utility function to add tags to a task.
266
+ * @param {string} taskId - The task ID.
267
+ * @param {string[]} tags - The tags to add.
268
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the update task event.
269
+ */
270
+ addTaskTags: async (taskId, tags) => {
271
+ return taskplaner.updateTask({
272
+ taskId: taskId,
273
+ tags: tags
274
+ });
275
+ },
276
+ /**
277
+ * Utility function to create a quick task with minimal parameters.
278
+ * @param {string} title - The task title.
279
+ * @param {string} agentId - The agent ID (optional, defaults to 'default-agent').
280
+ * @param {string} category - The category (optional).
281
+ * @returns {Promise<TaskResponse>} A promise that resolves with the response from the add task event.
282
+ */
283
+ createQuickTask: async (title, agentId = 'default-agent', category) => {
284
+ return taskplaner.addTask({
285
+ title: title,
286
+ agentId: agentId,
287
+ category: category,
288
+ priority: 'medium'
289
+ });
48
290
  }
49
291
  };
50
292
  exports.default = taskplaner;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Agent Notification Functions
3
+ *
4
+ * This module provides functions for sending agent-related notifications,
5
+ * including subagent task operations and completions.
6
+ */
7
+ import { AgentNotifications } from '../types/notificationFunctions/agent';
8
+ /**
9
+ * Sends a request to start a subagent task
10
+ *
11
+ * @param parentAgentId - The parent agent ID
12
+ * @param subagentId - The subagent ID
13
+ * @param task - The task description
14
+ * @param priority - Optional task priority
15
+ * @param dependencies - Optional array of dependencies
16
+ * @param toolUseId - Optional custom toolUseId, will be generated if not provided
17
+ *
18
+ * Requirements: 1.1 - WHEN I call `codebolt.notify.agent.StartSubagentTaskRequestNotify()` THEN the system SHALL send a StartSubagentTaskRequestNotification via WebSocket
19
+ */
20
+ export declare function StartSubagentTaskRequestNotify(parentAgentId: string, subagentId: string, task: string, priority?: string, dependencies?: string[], toolUseId?: string): void;
21
+ /**
22
+ * Sends a response to a subagent task request
23
+ *
24
+ * @param content - The response content (string or any object)
25
+ * @param isError - Whether this is an error response (default: false)
26
+ * @param toolUseId - Optional custom toolUseId, will be generated if not provided
27
+ *
28
+ * Requirements: 1.2 - WHEN I call `codebolt.notify.agent.StartSubagentTaskResponseNotify()` THEN the system SHALL send a StartSubagentTaskResponseNotification via WebSocket
29
+ */
30
+ export declare function StartSubagentTaskResponseNotify(content: string | any, isError?: boolean, toolUseId?: string): void;
31
+ /**
32
+ * Notifies that a subagent task has been completed
33
+ *
34
+ * @param parentAgentId - The parent agent ID
35
+ * @param subagentId - The subagent ID
36
+ * @param taskId - The task ID
37
+ * @param result - The task result
38
+ * @param status - The task status
39
+ * @param toolUseId - Optional custom toolUseId, will be generated if not provided
40
+ *
41
+ * Requirements: 1.3 - WHEN I call `codebolt.notify.agent.SubagentTaskCompletedNotify()` THEN the system SHALL send a SubagentTaskCompletedNotification via WebSocket
42
+ */
43
+ export declare function SubagentTaskCompletedNotify(parentAgentId: string, subagentId: string, taskId: string, result: any, status: string, toolUseId?: string): void;
44
+ /**
45
+ * Agent notification functions object
46
+ */
47
+ export declare const agentNotifications: AgentNotifications;
48
+ export default agentNotifications;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ /**
3
+ * Agent Notification Functions
4
+ *
5
+ * This module provides functions for sending agent-related notifications,
6
+ * including subagent task operations and completions.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.agentNotifications = exports.SubagentTaskCompletedNotify = exports.StartSubagentTaskResponseNotify = exports.StartSubagentTaskRequestNotify = void 0;
10
+ const utils_1 = require("./utils");
11
+ /**
12
+ * Sends a request to start a subagent task
13
+ *
14
+ * @param parentAgentId - The parent agent ID
15
+ * @param subagentId - The subagent ID
16
+ * @param task - The task description
17
+ * @param priority - Optional task priority
18
+ * @param dependencies - Optional array of dependencies
19
+ * @param toolUseId - Optional custom toolUseId, will be generated if not provided
20
+ *
21
+ * Requirements: 1.1 - WHEN I call `codebolt.notify.agent.StartSubagentTaskRequestNotify()` THEN the system SHALL send a StartSubagentTaskRequestNotification via WebSocket
22
+ */
23
+ function StartSubagentTaskRequestNotify(parentAgentId, subagentId, task, priority, dependencies, toolUseId) {
24
+ // Validate required fields
25
+ if (!(0, utils_1.validateRequiredFields)({ parentAgentId, subagentId, task }, ['parentAgentId', 'subagentId', 'task'], 'agent.StartSubagentTaskRequestNotify')) {
26
+ return;
27
+ }
28
+ // Create the notification
29
+ const notification = {
30
+ toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
31
+ type: "agentnotify",
32
+ action: "startSubagentTaskRequest",
33
+ data: {
34
+ parentAgentId: parentAgentId,
35
+ subagentId: subagentId,
36
+ task: task,
37
+ priority: priority,
38
+ dependencies: dependencies
39
+ }
40
+ };
41
+ // Send the notification
42
+ (0, utils_1.sendNotification)(notification, 'agent.StartSubagentTaskRequestNotify');
43
+ }
44
+ exports.StartSubagentTaskRequestNotify = StartSubagentTaskRequestNotify;
45
+ /**
46
+ * Sends a response to a subagent task request
47
+ *
48
+ * @param content - The response content (string or any object)
49
+ * @param isError - Whether this is an error response (default: false)
50
+ * @param toolUseId - Optional custom toolUseId, will be generated if not provided
51
+ *
52
+ * Requirements: 1.2 - WHEN I call `codebolt.notify.agent.StartSubagentTaskResponseNotify()` THEN the system SHALL send a StartSubagentTaskResponseNotification via WebSocket
53
+ */
54
+ function StartSubagentTaskResponseNotify(content, isError = false, toolUseId) {
55
+ // Validate content is provided
56
+ if (content === null || content === undefined) {
57
+ console.error('[NotificationFunctions] Content is required for agent.StartSubagentTaskResponseNotify');
58
+ return;
59
+ }
60
+ // Create the notification
61
+ const notification = {
62
+ toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
63
+ type: "agentnotify",
64
+ action: "startSubagentTaskResult",
65
+ content: content,
66
+ isError: isError
67
+ };
68
+ // Send the notification
69
+ (0, utils_1.sendNotification)(notification, 'agent.StartSubagentTaskResponseNotify');
70
+ }
71
+ exports.StartSubagentTaskResponseNotify = StartSubagentTaskResponseNotify;
72
+ /**
73
+ * Notifies that a subagent task has been completed
74
+ *
75
+ * @param parentAgentId - The parent agent ID
76
+ * @param subagentId - The subagent ID
77
+ * @param taskId - The task ID
78
+ * @param result - The task result
79
+ * @param status - The task status
80
+ * @param toolUseId - Optional custom toolUseId, will be generated if not provided
81
+ *
82
+ * Requirements: 1.3 - WHEN I call `codebolt.notify.agent.SubagentTaskCompletedNotify()` THEN the system SHALL send a SubagentTaskCompletedNotification via WebSocket
83
+ */
84
+ function SubagentTaskCompletedNotify(parentAgentId, subagentId, taskId, result, status, toolUseId) {
85
+ // Validate required fields
86
+ if (!(0, utils_1.validateRequiredFields)({ parentAgentId, subagentId, taskId, result, status }, ['parentAgentId', 'subagentId', 'taskId', 'result', 'status'], 'agent.SubagentTaskCompletedNotify')) {
87
+ return;
88
+ }
89
+ // Create the notification
90
+ const notification = {
91
+ toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
92
+ type: "agentnotify",
93
+ action: "subagentTaskCompleted",
94
+ data: {
95
+ parentAgentId: parentAgentId,
96
+ subagentId: subagentId,
97
+ taskId: taskId,
98
+ result: result,
99
+ status: status
100
+ }
101
+ };
102
+ // Send the notification
103
+ (0, utils_1.sendNotification)(notification, 'agent.SubagentTaskCompletedNotify');
104
+ }
105
+ exports.SubagentTaskCompletedNotify = SubagentTaskCompletedNotify;
106
+ /**
107
+ * Agent notification functions object
108
+ */
109
+ exports.agentNotifications = {
110
+ StartSubagentTaskRequestNotify,
111
+ StartSubagentTaskResponseNotify,
112
+ SubagentTaskCompletedNotify
113
+ };
114
+ // Default export
115
+ exports.default = exports.agentNotifications;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Browser Notification Functions
3
+ *
4
+ * This module provides functions for sending browser-related notifications,
5
+ * including web fetch and web search operations.
6
+ */
7
+ import { WebFetchResponseNotification, WebSearchResponseNotification } from '../types/notifications/browser';
8
+ import { BrowserNotifications } from '../types/notificationFunctions/browser';
9
+ /**
10
+ * Sends a web fetch request notification
11
+ *
12
+ * @param url - The URL to fetch
13
+ * @param method - Optional HTTP method
14
+ * @param headers - Optional headers object
15
+ * @param body - Optional request body
16
+ * @param timeout - Optional timeout in milliseconds
17
+ * @param toolUseId - Optional custom toolUseId, will be generated if not provided
18
+ *
19
+ * Requirements: 2.1 - WHEN I call `codebolt.notify.browser.WebFetchRequestNotify()` THEN the system SHALL send a WebFetchRequestNotification via WebSocket
20
+ */
21
+ export declare function WebFetchRequestNotify(url: string, method?: string, headers?: Record<string, string>, body?: any, timeout?: number, toolUseId?: string): void;
22
+ /**
23
+ * Sends a web fetch response notification
24
+ *
25
+ * @param content - The response content (string or any object)
26
+ * @param isError - Whether this is an error response (default: false)
27
+ * @param toolUseId - Optional custom toolUseId, will be generated if not provided
28
+ * @param data - Optional response data including status, statusText, headers, and url
29
+ *
30
+ * Requirements: 2.2 - WHEN I call `codebolt.notify.browser.WebFetchResponseNotify()` THEN the system SHALL send a WebFetchResponseNotification via WebSocket
31
+ */
32
+ export declare function WebFetchResponseNotify(content: string | any, isError?: boolean, toolUseId?: string, data?: WebFetchResponseNotification['data']): void;
33
+ /**
34
+ * Sends a web search request notification
35
+ *
36
+ * @param query - The search query string
37
+ * @param maxResults - Optional maximum number of results
38
+ * @param searchEngine - Optional search engine to use
39
+ * @param filters - Optional search filters
40
+ * @param toolUseId - Optional custom toolUseId, will be generated if not provided
41
+ *
42
+ * Requirements: 2.3 - WHEN I call `codebolt.notify.browser.WebSearchRequestNotify()` THEN the system SHALL send a WebSearchRequestNotification via WebSocket
43
+ */
44
+ export declare function WebSearchRequestNotify(query: string, maxResults?: number, searchEngine?: string, filters?: any, toolUseId?: string): void;
45
+ /**
46
+ * Sends a web search response notification
47
+ *
48
+ * @param content - The response content (string or any object)
49
+ * @param isError - Whether this is an error response (default: false)
50
+ * @param toolUseId - Optional custom toolUseId, will be generated if not provided
51
+ * @param data - Optional response data including results, totalResults, and searchTime
52
+ *
53
+ * Requirements: 2.4 - WHEN I call `codebolt.notify.browser.WebSearchResponseNotify()` THEN the system SHALL send a WebSearchResponseNotification via WebSocket
54
+ */
55
+ export declare function WebSearchResponseNotify(content: string | any, isError?: boolean, toolUseId?: string, data?: WebSearchResponseNotification['data']): void;
56
+ /**
57
+ * Browser notification functions object
58
+ */
59
+ export declare const browserNotifications: BrowserNotifications;
60
+ export default browserNotifications;
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ /**
3
+ * Browser Notification Functions
4
+ *
5
+ * This module provides functions for sending browser-related notifications,
6
+ * including web fetch and web search operations.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.browserNotifications = exports.WebSearchResponseNotify = exports.WebSearchRequestNotify = exports.WebFetchResponseNotify = exports.WebFetchRequestNotify = void 0;
10
+ const utils_1 = require("./utils");
11
+ /**
12
+ * Sends a web fetch request notification
13
+ *
14
+ * @param url - The URL to fetch
15
+ * @param method - Optional HTTP method
16
+ * @param headers - Optional headers object
17
+ * @param body - Optional request body
18
+ * @param timeout - Optional timeout in milliseconds
19
+ * @param toolUseId - Optional custom toolUseId, will be generated if not provided
20
+ *
21
+ * Requirements: 2.1 - WHEN I call `codebolt.notify.browser.WebFetchRequestNotify()` THEN the system SHALL send a WebFetchRequestNotification via WebSocket
22
+ */
23
+ function WebFetchRequestNotify(url, method, headers, body, timeout, toolUseId) {
24
+ // Validate required fields
25
+ if (!(0, utils_1.validateRequiredFields)({ url }, ['url'], 'browser.WebFetchRequestNotify')) {
26
+ return;
27
+ }
28
+ // Create the notification
29
+ const notification = {
30
+ toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
31
+ type: "browsernotify",
32
+ action: "webFetchRequest",
33
+ data: {
34
+ url: url,
35
+ method: method,
36
+ headers: headers,
37
+ body: body,
38
+ timeout: timeout
39
+ }
40
+ };
41
+ // Send the notification
42
+ (0, utils_1.sendNotification)(notification, 'browser.WebFetchRequestNotify');
43
+ }
44
+ exports.WebFetchRequestNotify = WebFetchRequestNotify;
45
+ /**
46
+ * Sends a web fetch response notification
47
+ *
48
+ * @param content - The response content (string or any object)
49
+ * @param isError - Whether this is an error response (default: false)
50
+ * @param toolUseId - Optional custom toolUseId, will be generated if not provided
51
+ * @param data - Optional response data including status, statusText, headers, and url
52
+ *
53
+ * Requirements: 2.2 - WHEN I call `codebolt.notify.browser.WebFetchResponseNotify()` THEN the system SHALL send a WebFetchResponseNotification via WebSocket
54
+ */
55
+ function WebFetchResponseNotify(content, isError = false, toolUseId, data) {
56
+ // Validate content is provided
57
+ if (content === null || content === undefined) {
58
+ console.error('[NotificationFunctions] Content is required for browser.WebFetchResponseNotify');
59
+ return;
60
+ }
61
+ // Create the notification
62
+ const notification = {
63
+ toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
64
+ type: "browsernotify",
65
+ action: "webFetchResult",
66
+ content: content,
67
+ isError: isError,
68
+ data: data
69
+ };
70
+ // Send the notification
71
+ (0, utils_1.sendNotification)(notification, 'browser.WebFetchResponseNotify');
72
+ }
73
+ exports.WebFetchResponseNotify = WebFetchResponseNotify;
74
+ /**
75
+ * Sends a web search request notification
76
+ *
77
+ * @param query - The search query string
78
+ * @param maxResults - Optional maximum number of results
79
+ * @param searchEngine - Optional search engine to use
80
+ * @param filters - Optional search filters
81
+ * @param toolUseId - Optional custom toolUseId, will be generated if not provided
82
+ *
83
+ * Requirements: 2.3 - WHEN I call `codebolt.notify.browser.WebSearchRequestNotify()` THEN the system SHALL send a WebSearchRequestNotification via WebSocket
84
+ */
85
+ function WebSearchRequestNotify(query, maxResults, searchEngine, filters, toolUseId) {
86
+ // Validate required fields
87
+ if (!(0, utils_1.validateRequiredFields)({ query }, ['query'], 'browser.WebSearchRequestNotify')) {
88
+ return;
89
+ }
90
+ // Create the notification
91
+ const notification = {
92
+ toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
93
+ type: "browsernotify",
94
+ action: "webSearchRequest",
95
+ data: {
96
+ query: query,
97
+ maxResults: maxResults,
98
+ searchEngine: searchEngine,
99
+ filters: filters
100
+ }
101
+ };
102
+ // Send the notification
103
+ (0, utils_1.sendNotification)(notification, 'browser.WebSearchRequestNotify');
104
+ }
105
+ exports.WebSearchRequestNotify = WebSearchRequestNotify;
106
+ /**
107
+ * Sends a web search response notification
108
+ *
109
+ * @param content - The response content (string or any object)
110
+ * @param isError - Whether this is an error response (default: false)
111
+ * @param toolUseId - Optional custom toolUseId, will be generated if not provided
112
+ * @param data - Optional response data including results, totalResults, and searchTime
113
+ *
114
+ * Requirements: 2.4 - WHEN I call `codebolt.notify.browser.WebSearchResponseNotify()` THEN the system SHALL send a WebSearchResponseNotification via WebSocket
115
+ */
116
+ function WebSearchResponseNotify(content, isError = false, toolUseId, data) {
117
+ // Validate content is provided
118
+ if (content === null || content === undefined) {
119
+ console.error('[NotificationFunctions] Content is required for browser.WebSearchResponseNotify');
120
+ return;
121
+ }
122
+ // Create the notification
123
+ const notification = {
124
+ toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
125
+ type: "browsernotify",
126
+ action: "webSearchResult",
127
+ content: content,
128
+ isError: isError,
129
+ data: data
130
+ };
131
+ // Send the notification
132
+ (0, utils_1.sendNotification)(notification, 'browser.WebSearchResponseNotify');
133
+ }
134
+ exports.WebSearchResponseNotify = WebSearchResponseNotify;
135
+ /**
136
+ * Browser notification functions object
137
+ */
138
+ exports.browserNotifications = {
139
+ WebFetchRequestNotify,
140
+ WebFetchResponseNotify,
141
+ WebSearchRequestNotify,
142
+ WebSearchResponseNotify
143
+ };
144
+ // Default export
145
+ exports.default = exports.browserNotifications;