@codebolt/codeboltjs 2.0.12 → 2.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +138 -4
- package/dist/agentlib/agent.js +3 -7
- package/dist/agentlib/followupquestionbuilder.d.ts +75 -0
- package/dist/agentlib/followupquestionbuilder.js +193 -0
- package/dist/agentlib/llmoutputhandler.d.ts +102 -0
- package/dist/agentlib/llmoutputhandler.js +451 -0
- package/dist/agentlib/promptbuilder.d.ts +171 -17
- package/dist/agentlib/promptbuilder.js +367 -49
- package/dist/agentlib/systemprompt.js +3 -3
- package/dist/agentlib/usermessage.d.ts +1 -1
- package/dist/agentlib/usermessage.js +5 -1
- package/dist/core/Codebolt.d.ts +342 -0
- package/dist/core/Codebolt.js +201 -0
- package/dist/core/websocket.js +2 -1
- package/dist/index.d.ts +4 -300
- package/dist/index.js +11 -137
- package/dist/modules/llm.d.ts +23 -3
- package/dist/modules/llm.js +20 -3
- package/dist/modules/project.d.ts +3 -3
- package/dist/modules/project.js +1 -1
- package/dist/modules/state.d.ts +5 -3
- package/dist/modules/state.js +2 -0
- package/dist/modules/task.d.ts +126 -11
- package/dist/modules/task.js +262 -20
- package/dist/notificationfunctions/agent.d.ts +48 -0
- package/dist/notificationfunctions/agent.js +115 -0
- package/dist/notificationfunctions/browser.d.ts +60 -0
- package/dist/notificationfunctions/browser.js +145 -0
- package/dist/notificationfunctions/chat.d.ts +53 -0
- package/dist/notificationfunctions/chat.js +125 -0
- package/dist/notificationfunctions/codeutils.d.ts +60 -0
- package/dist/notificationfunctions/codeutils.js +145 -0
- package/dist/notificationfunctions/crawler.d.ts +59 -0
- package/dist/notificationfunctions/crawler.js +159 -0
- package/dist/notificationfunctions/dbmemory.d.ts +50 -0
- package/dist/notificationfunctions/dbmemory.js +132 -0
- package/dist/notificationfunctions/fs.d.ts +125 -0
- package/dist/notificationfunctions/fs.js +472 -0
- package/dist/notificationfunctions/git.d.ts +174 -0
- package/dist/notificationfunctions/git.js +521 -0
- package/dist/notificationfunctions/history.d.ts +38 -0
- package/dist/notificationfunctions/history.js +97 -0
- package/dist/notificationfunctions/index.d.ts +79 -0
- package/dist/notificationfunctions/index.js +102 -0
- package/dist/notificationfunctions/llm.d.ts +39 -0
- package/dist/notificationfunctions/llm.js +99 -0
- package/dist/notificationfunctions/mcp.d.ts +67 -0
- package/dist/notificationfunctions/mcp.js +192 -0
- package/dist/notificationfunctions/search.d.ts +50 -0
- package/dist/notificationfunctions/search.js +146 -0
- package/dist/notificationfunctions/system.d.ts +25 -0
- package/dist/notificationfunctions/system.js +59 -0
- package/dist/notificationfunctions/terminal.d.ts +26 -0
- package/dist/notificationfunctions/terminal.js +64 -0
- package/dist/notificationfunctions/todo.d.ts +63 -0
- package/dist/notificationfunctions/todo.js +164 -0
- package/dist/notificationfunctions/utils.d.ts +81 -0
- package/dist/notificationfunctions/utils.js +177 -0
- package/dist/types/InternalTypes.d.ts +1 -0
- package/dist/types/commonTypes.d.ts +26 -3
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.js +15 -0
- package/dist/types/libFunctionTypes.d.ts +110 -4
- package/dist/types/notificationFunctions/agent.d.ts +8 -0
- package/dist/types/notificationFunctions/agent.js +2 -0
- package/dist/types/notificationFunctions/browser.d.ts +10 -0
- package/dist/types/notificationFunctions/browser.js +2 -0
- package/dist/types/notificationFunctions/chat.d.ts +10 -0
- package/dist/types/notificationFunctions/chat.js +2 -0
- package/dist/types/notificationFunctions/codeutils.d.ts +10 -0
- package/dist/types/notificationFunctions/codeutils.js +2 -0
- package/dist/types/notificationFunctions/crawler.d.ts +10 -0
- package/dist/types/notificationFunctions/crawler.js +2 -0
- package/dist/types/notificationFunctions/dbmemory.d.ts +9 -0
- package/dist/types/notificationFunctions/dbmemory.js +2 -0
- package/dist/types/notificationFunctions/fs.d.ts +27 -0
- package/dist/types/notificationFunctions/fs.js +2 -0
- package/dist/types/notificationFunctions/git.d.ts +29 -0
- package/dist/types/notificationFunctions/git.js +2 -0
- package/dist/types/notificationFunctions/history.d.ts +10 -0
- package/dist/types/notificationFunctions/history.js +2 -0
- package/dist/types/notificationFunctions/index.d.ts +0 -0
- package/dist/types/notificationFunctions/index.js +1 -0
- package/dist/types/notificationFunctions/llm.d.ts +10 -0
- package/dist/types/notificationFunctions/llm.js +2 -0
- package/dist/types/notificationFunctions/mcp.d.ts +16 -0
- package/dist/types/notificationFunctions/mcp.js +2 -0
- package/dist/types/notificationFunctions/search.d.ts +11 -0
- package/dist/types/notificationFunctions/search.js +2 -0
- package/dist/types/notificationFunctions/system.d.ts +7 -0
- package/dist/types/notificationFunctions/system.js +2 -0
- package/dist/types/notificationFunctions/terminal.d.ts +7 -0
- package/dist/types/notificationFunctions/terminal.js +2 -0
- package/dist/types/notificationFunctions/todo.d.ts +11 -0
- package/dist/types/notificationFunctions/todo.js +2 -0
- package/dist/types/notifications/agent.d.ts +31 -0
- package/dist/types/notifications/agent.js +3 -0
- package/dist/types/notifications/browser.d.ts +53 -0
- package/dist/types/notifications/browser.js +3 -0
- package/dist/types/notifications/chat.d.ts +37 -0
- package/dist/types/notifications/chat.js +3 -0
- package/dist/types/notifications/codeutils.d.ts +55 -0
- package/dist/types/notifications/codeutils.js +3 -0
- package/dist/types/notifications/crawler.d.ts +55 -0
- package/dist/types/notifications/crawler.js +3 -0
- package/dist/types/notifications/dbmemory.d.ts +31 -0
- package/dist/types/notifications/dbmemory.js +3 -0
- package/dist/types/notifications/fs.d.ts +180 -0
- package/dist/types/notifications/fs.js +3 -0
- package/dist/types/notifications/git.d.ts +205 -0
- package/dist/types/notifications/git.js +3 -0
- package/dist/types/notifications/history.d.ts +32 -0
- package/dist/types/notifications/history.js +3 -0
- package/dist/types/notifications/llm.d.ts +45 -0
- package/dist/types/notifications/llm.js +2 -0
- package/dist/types/notifications/mcp.d.ts +63 -0
- package/dist/types/notifications/mcp.js +3 -0
- package/dist/types/notifications/search.d.ts +47 -0
- package/dist/types/notifications/search.js +3 -0
- package/dist/types/notifications/system.d.ts +20 -0
- package/dist/types/notifications/system.js +2 -0
- package/dist/types/notifications/terminal.d.ts +17 -0
- package/dist/types/notifications/terminal.js +2 -0
- package/dist/types/notifications/todo.d.ts +60 -0
- package/dist/types/notifications/todo.js +3 -0
- package/dist/types/socketMessageTypes.d.ts +3 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Search Notification Functions
|
|
4
|
+
*
|
|
5
|
+
* This module provides functions for sending search-related notifications,
|
|
6
|
+
* including search initialization and query operations.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.searchNotifications = exports.GetFirstLinkResultNotify = exports.GetFirstLinkRequestNotify = exports.SearchResultNotify = exports.SearchRequestNotify = exports.SearchInitResultNotify = exports.SearchInitRequestNotify = void 0;
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
// ===== SEARCH INIT FUNCTIONS =====
|
|
12
|
+
/**
|
|
13
|
+
* Sends a search init request notification
|
|
14
|
+
* @param engine - Optional search engine to initialize
|
|
15
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
16
|
+
*/
|
|
17
|
+
function SearchInitRequestNotify(engine, toolUseId) {
|
|
18
|
+
const notification = {
|
|
19
|
+
toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
|
|
20
|
+
type: "searchnotify",
|
|
21
|
+
action: "searchInitRequest",
|
|
22
|
+
data: {
|
|
23
|
+
engine: engine
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
(0, utils_1.sendNotification)(notification, 'search-init');
|
|
27
|
+
}
|
|
28
|
+
exports.SearchInitRequestNotify = SearchInitRequestNotify;
|
|
29
|
+
/**
|
|
30
|
+
* Sends a search init result notification
|
|
31
|
+
* @param content - The result content or error details
|
|
32
|
+
* @param isError - Whether this is an error response
|
|
33
|
+
* @param toolUseId - The toolUseId from the original request
|
|
34
|
+
*/
|
|
35
|
+
function SearchInitResultNotify(content, isError = false, toolUseId) {
|
|
36
|
+
if (!toolUseId) {
|
|
37
|
+
console.error('[SearchNotifications] toolUseId is required for response notifications');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const notification = {
|
|
41
|
+
toolUseId,
|
|
42
|
+
type: "searchnotify",
|
|
43
|
+
action: "searchInitResult",
|
|
44
|
+
content,
|
|
45
|
+
isError
|
|
46
|
+
};
|
|
47
|
+
(0, utils_1.sendNotification)(notification, 'search-init-result');
|
|
48
|
+
}
|
|
49
|
+
exports.SearchInitResultNotify = SearchInitResultNotify;
|
|
50
|
+
// ===== SEARCH REQUEST FUNCTIONS =====
|
|
51
|
+
/**
|
|
52
|
+
* Sends a search request notification
|
|
53
|
+
* @param query - The search query string
|
|
54
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
55
|
+
*/
|
|
56
|
+
function SearchRequestNotify(query, toolUseId) {
|
|
57
|
+
// Validate required fields
|
|
58
|
+
if (!(0, utils_1.validateRequiredFields)({ query }, ['query'], 'search-request')) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const notification = {
|
|
62
|
+
toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
|
|
63
|
+
type: "searchnotify",
|
|
64
|
+
action: "searchRequest",
|
|
65
|
+
data: {
|
|
66
|
+
query: query
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
(0, utils_1.sendNotification)(notification, 'search-request');
|
|
70
|
+
}
|
|
71
|
+
exports.SearchRequestNotify = SearchRequestNotify;
|
|
72
|
+
/**
|
|
73
|
+
* Sends a search result notification
|
|
74
|
+
* @param content - The search result content or error details
|
|
75
|
+
* @param isError - Whether this is an error response
|
|
76
|
+
* @param toolUseId - The toolUseId from the original request
|
|
77
|
+
*/
|
|
78
|
+
function SearchResultNotify(content, isError = false, toolUseId) {
|
|
79
|
+
if (!toolUseId) {
|
|
80
|
+
console.error('[SearchNotifications] toolUseId is required for response notifications');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const notification = {
|
|
84
|
+
toolUseId,
|
|
85
|
+
type: "searchnotify",
|
|
86
|
+
action: "searchResult",
|
|
87
|
+
content,
|
|
88
|
+
isError
|
|
89
|
+
};
|
|
90
|
+
(0, utils_1.sendNotification)(notification, 'search-result');
|
|
91
|
+
}
|
|
92
|
+
exports.SearchResultNotify = SearchResultNotify;
|
|
93
|
+
// ===== GET FIRST LINK FUNCTIONS =====
|
|
94
|
+
/**
|
|
95
|
+
* Sends a get first link request notification
|
|
96
|
+
* @param query - The search query to get the first link for
|
|
97
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
98
|
+
*/
|
|
99
|
+
function GetFirstLinkRequestNotify(query, toolUseId) {
|
|
100
|
+
// Validate required fields
|
|
101
|
+
if (!(0, utils_1.validateRequiredFields)({ query }, ['query'], 'get-first-link')) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const notification = {
|
|
105
|
+
toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
|
|
106
|
+
type: "searchnotify",
|
|
107
|
+
action: "getFirstLinkRequest",
|
|
108
|
+
data: {
|
|
109
|
+
query: query
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
(0, utils_1.sendNotification)(notification, 'search-get-first-link');
|
|
113
|
+
}
|
|
114
|
+
exports.GetFirstLinkRequestNotify = GetFirstLinkRequestNotify;
|
|
115
|
+
/**
|
|
116
|
+
* Sends a get first link result notification
|
|
117
|
+
* @param content - The first link result content or error details
|
|
118
|
+
* @param isError - Whether this is an error response
|
|
119
|
+
* @param toolUseId - The toolUseId from the original request
|
|
120
|
+
*/
|
|
121
|
+
function GetFirstLinkResultNotify(content, isError = false, toolUseId) {
|
|
122
|
+
if (!toolUseId) {
|
|
123
|
+
console.error('[SearchNotifications] toolUseId is required for response notifications');
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const notification = {
|
|
127
|
+
toolUseId,
|
|
128
|
+
type: "searchnotify",
|
|
129
|
+
action: "getFirstLinkResult",
|
|
130
|
+
content,
|
|
131
|
+
isError
|
|
132
|
+
};
|
|
133
|
+
(0, utils_1.sendNotification)(notification, 'search-get-first-link-result');
|
|
134
|
+
}
|
|
135
|
+
exports.GetFirstLinkResultNotify = GetFirstLinkResultNotify;
|
|
136
|
+
/**
|
|
137
|
+
* Search notification functions object
|
|
138
|
+
*/
|
|
139
|
+
exports.searchNotifications = {
|
|
140
|
+
SearchInitRequestNotify,
|
|
141
|
+
SearchInitResultNotify,
|
|
142
|
+
SearchRequestNotify,
|
|
143
|
+
SearchResultNotify,
|
|
144
|
+
GetFirstLinkRequestNotify,
|
|
145
|
+
GetFirstLinkResultNotify
|
|
146
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System Notification Functions
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions for sending system-related notifications,
|
|
5
|
+
* including agent initialization and completion states.
|
|
6
|
+
*/
|
|
7
|
+
import { SystemNotifications } from '../types/notificationFunctions/system';
|
|
8
|
+
/**
|
|
9
|
+
* Sends an agent init notification
|
|
10
|
+
* @param onStopClicked - Optional flag indicating if stop was clicked
|
|
11
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
12
|
+
*/
|
|
13
|
+
export declare function AgentInitNotify(onStopClicked?: boolean, toolUseId?: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Sends an agent completion notification
|
|
16
|
+
* @param resultString - The result string from the agent
|
|
17
|
+
* @param sessionId - Optional session ID
|
|
18
|
+
* @param duration - Optional duration string
|
|
19
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
20
|
+
*/
|
|
21
|
+
export declare function AgentCompletionNotify(resultString: string, sessionId?: string, duration?: string, toolUseId?: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* System notification functions object
|
|
24
|
+
*/
|
|
25
|
+
export declare const systemNotifications: SystemNotifications;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* System Notification Functions
|
|
4
|
+
*
|
|
5
|
+
* This module provides functions for sending system-related notifications,
|
|
6
|
+
* including agent initialization and completion states.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.systemNotifications = exports.AgentCompletionNotify = exports.AgentInitNotify = void 0;
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
// ===== AGENT INIT FUNCTIONS =====
|
|
12
|
+
/**
|
|
13
|
+
* Sends an agent init notification
|
|
14
|
+
* @param onStopClicked - Optional flag indicating if stop was clicked
|
|
15
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
16
|
+
*/
|
|
17
|
+
function AgentInitNotify(onStopClicked, toolUseId) {
|
|
18
|
+
const notification = {
|
|
19
|
+
toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
|
|
20
|
+
type: "chatnotify",
|
|
21
|
+
action: "processStartedRequest",
|
|
22
|
+
data: {
|
|
23
|
+
onStopClicked: onStopClicked
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
(0, utils_1.sendNotification)(notification, 'agent-init');
|
|
27
|
+
}
|
|
28
|
+
exports.AgentInitNotify = AgentInitNotify;
|
|
29
|
+
// ===== AGENT COMPLETION FUNCTIONS =====
|
|
30
|
+
/**
|
|
31
|
+
* Sends an agent completion notification
|
|
32
|
+
* @param resultString - The result string from the agent
|
|
33
|
+
* @param sessionId - Optional session ID
|
|
34
|
+
* @param duration - Optional duration string
|
|
35
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
36
|
+
*/
|
|
37
|
+
function AgentCompletionNotify(resultString, sessionId, duration, toolUseId) {
|
|
38
|
+
const notification = {
|
|
39
|
+
toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
|
|
40
|
+
type: "chatnotify",
|
|
41
|
+
action: "processStoppedRequest",
|
|
42
|
+
data: {
|
|
43
|
+
sessionId: sessionId,
|
|
44
|
+
duration: duration || "0ms",
|
|
45
|
+
result: {
|
|
46
|
+
resultString: resultString
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
(0, utils_1.sendNotification)(notification, 'agent-completion');
|
|
51
|
+
}
|
|
52
|
+
exports.AgentCompletionNotify = AgentCompletionNotify;
|
|
53
|
+
/**
|
|
54
|
+
* System notification functions object
|
|
55
|
+
*/
|
|
56
|
+
exports.systemNotifications = {
|
|
57
|
+
AgentInitNotify,
|
|
58
|
+
AgentCompletionNotify
|
|
59
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal Notification Functions
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions for sending terminal-related notifications,
|
|
5
|
+
* including command execution operations.
|
|
6
|
+
*/
|
|
7
|
+
import { TerminalNotifications } from '../types/notificationFunctions/terminal';
|
|
8
|
+
/**
|
|
9
|
+
* Sends a command execution request notification
|
|
10
|
+
* @param command - The command to execute
|
|
11
|
+
* @param returnEmptyStringOnSuccess - Optional flag to return empty string on success
|
|
12
|
+
* @param executeInMain - Optional flag to execute in main terminal
|
|
13
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
14
|
+
*/
|
|
15
|
+
export declare function CommandExecutionRequestNotify(command: string, returnEmptyStringOnSuccess?: boolean, executeInMain?: boolean, toolUseId?: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Sends a command execution response notification
|
|
18
|
+
* @param content - The command execution result or error details
|
|
19
|
+
* @param isError - Whether this is an error response
|
|
20
|
+
* @param toolUseId - The toolUseId from the original request
|
|
21
|
+
*/
|
|
22
|
+
export declare function CommandExecutionResponseNotify(content: string | any, isError?: boolean, toolUseId?: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Terminal notification functions object
|
|
25
|
+
*/
|
|
26
|
+
export declare const terminalNotifications: TerminalNotifications;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Terminal Notification Functions
|
|
4
|
+
*
|
|
5
|
+
* This module provides functions for sending terminal-related notifications,
|
|
6
|
+
* including command execution operations.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.terminalNotifications = exports.CommandExecutionResponseNotify = exports.CommandExecutionRequestNotify = void 0;
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
// ===== COMMAND EXECUTION FUNCTIONS =====
|
|
12
|
+
/**
|
|
13
|
+
* Sends a command execution request notification
|
|
14
|
+
* @param command - The command to execute
|
|
15
|
+
* @param returnEmptyStringOnSuccess - Optional flag to return empty string on success
|
|
16
|
+
* @param executeInMain - Optional flag to execute in main terminal
|
|
17
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
18
|
+
*/
|
|
19
|
+
function CommandExecutionRequestNotify(command, returnEmptyStringOnSuccess, executeInMain, toolUseId) {
|
|
20
|
+
// Validate required fields
|
|
21
|
+
if (!(0, utils_1.validateRequiredFields)({ command }, ['command'], 'terminal-command-execution')) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const notification = {
|
|
25
|
+
toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
|
|
26
|
+
type: "terminalnotify",
|
|
27
|
+
action: "executeCommandRequest",
|
|
28
|
+
data: {
|
|
29
|
+
command: command,
|
|
30
|
+
returnEmptyStringOnSuccess: returnEmptyStringOnSuccess,
|
|
31
|
+
executeInMain: executeInMain
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
(0, utils_1.sendNotification)(notification, 'terminal-command-execution');
|
|
35
|
+
}
|
|
36
|
+
exports.CommandExecutionRequestNotify = CommandExecutionRequestNotify;
|
|
37
|
+
/**
|
|
38
|
+
* Sends a command execution response notification
|
|
39
|
+
* @param content - The command execution result or error details
|
|
40
|
+
* @param isError - Whether this is an error response
|
|
41
|
+
* @param toolUseId - The toolUseId from the original request
|
|
42
|
+
*/
|
|
43
|
+
function CommandExecutionResponseNotify(content, isError = false, toolUseId) {
|
|
44
|
+
if (!toolUseId) {
|
|
45
|
+
console.error('[TerminalNotifications] toolUseId is required for response notifications');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const notification = {
|
|
49
|
+
toolUseId,
|
|
50
|
+
type: "terminalnotify",
|
|
51
|
+
action: "executeCommandResult",
|
|
52
|
+
content,
|
|
53
|
+
isError
|
|
54
|
+
};
|
|
55
|
+
(0, utils_1.sendNotification)(notification, 'terminal-command-execution-response');
|
|
56
|
+
}
|
|
57
|
+
exports.CommandExecutionResponseNotify = CommandExecutionResponseNotify;
|
|
58
|
+
/**
|
|
59
|
+
* Terminal notification functions object
|
|
60
|
+
*/
|
|
61
|
+
exports.terminalNotifications = {
|
|
62
|
+
CommandExecutionRequestNotify,
|
|
63
|
+
CommandExecutionResponseNotify
|
|
64
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Todo Notification Functions
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions for sending todo/task-related notifications,
|
|
5
|
+
* including task operations and lifecycle management.
|
|
6
|
+
*/
|
|
7
|
+
import { TodoNotifications } from '../types/notificationFunctions/todo';
|
|
8
|
+
/**
|
|
9
|
+
* Sends an add todo request notification
|
|
10
|
+
* @param title - Optional task title
|
|
11
|
+
* @param agentId - Optional agent ID
|
|
12
|
+
* @param description - Optional task description
|
|
13
|
+
* @param phase - Optional task phase
|
|
14
|
+
* @param category - Optional task category
|
|
15
|
+
* @param priority - Optional task priority
|
|
16
|
+
* @param tags - Optional array of tags
|
|
17
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
18
|
+
*/
|
|
19
|
+
export declare function AddTodoRequestNotify(title?: string, agentId?: string, description?: string, phase?: string, category?: string, priority?: string, tags?: string[], toolUseId?: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Sends an add todo response notification
|
|
22
|
+
* @param content - The response content or error details
|
|
23
|
+
* @param isError - Whether this is an error response
|
|
24
|
+
* @param toolUseId - The toolUseId from the original request
|
|
25
|
+
*/
|
|
26
|
+
export declare function AddTodoResponseNotify(content: string | any, isError?: boolean, toolUseId?: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Sends a get todo request notification
|
|
29
|
+
* @param filters - Optional filters for the todo request
|
|
30
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
31
|
+
*/
|
|
32
|
+
export declare function GetTodoRequestNotify(filters?: any, toolUseId?: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Sends a get todo response notification
|
|
35
|
+
* @param content - The response content or error details
|
|
36
|
+
* @param isError - Whether this is an error response
|
|
37
|
+
* @param toolUseId - The toolUseId from the original request
|
|
38
|
+
*/
|
|
39
|
+
export declare function GetTodoResponseNotify(content: string | any, isError?: boolean, toolUseId?: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Sends an edit todo task request notification
|
|
42
|
+
* @param taskId - Optional task ID to edit
|
|
43
|
+
* @param title - Optional new task title
|
|
44
|
+
* @param description - Optional new task description
|
|
45
|
+
* @param phase - Optional new task phase
|
|
46
|
+
* @param category - Optional new task category
|
|
47
|
+
* @param priority - Optional new task priority
|
|
48
|
+
* @param tags - Optional new array of tags
|
|
49
|
+
* @param status - Optional new task status
|
|
50
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
51
|
+
*/
|
|
52
|
+
export declare function EditTodoTaskRequestNotify(taskId?: string, title?: string, description?: string, phase?: string, category?: string, priority?: string, tags?: string[], status?: string, toolUseId?: string): void;
|
|
53
|
+
/**
|
|
54
|
+
* Sends an edit todo task response notification
|
|
55
|
+
* @param content - The response content or error details
|
|
56
|
+
* @param isError - Whether this is an error response
|
|
57
|
+
* @param toolUseId - The toolUseId from the original request
|
|
58
|
+
*/
|
|
59
|
+
export declare function EditTodoTaskResponseNotify(content: string | any, isError?: boolean, toolUseId?: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* Todo notification functions object
|
|
62
|
+
*/
|
|
63
|
+
export declare const todoNotifications: TodoNotifications;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Todo Notification Functions
|
|
4
|
+
*
|
|
5
|
+
* This module provides functions for sending todo/task-related notifications,
|
|
6
|
+
* including task operations and lifecycle management.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.todoNotifications = exports.EditTodoTaskResponseNotify = exports.EditTodoTaskRequestNotify = exports.GetTodoResponseNotify = exports.GetTodoRequestNotify = exports.AddTodoResponseNotify = exports.AddTodoRequestNotify = void 0;
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
// ===== ADD TODO FUNCTIONS =====
|
|
12
|
+
/**
|
|
13
|
+
* Sends an add todo request notification
|
|
14
|
+
* @param title - Optional task title
|
|
15
|
+
* @param agentId - Optional agent ID
|
|
16
|
+
* @param description - Optional task description
|
|
17
|
+
* @param phase - Optional task phase
|
|
18
|
+
* @param category - Optional task category
|
|
19
|
+
* @param priority - Optional task priority
|
|
20
|
+
* @param tags - Optional array of tags
|
|
21
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
22
|
+
*/
|
|
23
|
+
function AddTodoRequestNotify(title, agentId, description, phase, category, priority, tags, toolUseId) {
|
|
24
|
+
const notification = {
|
|
25
|
+
toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
|
|
26
|
+
type: "tasknotify",
|
|
27
|
+
action: "addTaskRequest",
|
|
28
|
+
data: {
|
|
29
|
+
title: title,
|
|
30
|
+
agentId: agentId,
|
|
31
|
+
description: description,
|
|
32
|
+
phase: phase,
|
|
33
|
+
category: category,
|
|
34
|
+
priority: priority,
|
|
35
|
+
tags: tags
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
(0, utils_1.sendNotification)(notification, 'todo-add-task');
|
|
39
|
+
}
|
|
40
|
+
exports.AddTodoRequestNotify = AddTodoRequestNotify;
|
|
41
|
+
/**
|
|
42
|
+
* Sends an add todo response notification
|
|
43
|
+
* @param content - The response content or error details
|
|
44
|
+
* @param isError - Whether this is an error response
|
|
45
|
+
* @param toolUseId - The toolUseId from the original request
|
|
46
|
+
*/
|
|
47
|
+
function AddTodoResponseNotify(content, isError = false, toolUseId) {
|
|
48
|
+
if (!toolUseId) {
|
|
49
|
+
console.error('[TodoNotifications] toolUseId is required for response notifications');
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const notification = {
|
|
53
|
+
toolUseId,
|
|
54
|
+
type: "tasknotify",
|
|
55
|
+
action: "addTaskResult",
|
|
56
|
+
content,
|
|
57
|
+
isError
|
|
58
|
+
};
|
|
59
|
+
(0, utils_1.sendNotification)(notification, 'todo-add-task-response');
|
|
60
|
+
}
|
|
61
|
+
exports.AddTodoResponseNotify = AddTodoResponseNotify;
|
|
62
|
+
// ===== GET TODO FUNCTIONS =====
|
|
63
|
+
/**
|
|
64
|
+
* Sends a get todo request notification
|
|
65
|
+
* @param filters - Optional filters for the todo request
|
|
66
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
67
|
+
*/
|
|
68
|
+
function GetTodoRequestNotify(filters, toolUseId) {
|
|
69
|
+
const notification = {
|
|
70
|
+
toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
|
|
71
|
+
type: "tasknotify",
|
|
72
|
+
action: "getTasksRequest",
|
|
73
|
+
data: {
|
|
74
|
+
filters: filters
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
(0, utils_1.sendNotification)(notification, 'todo-get-tasks');
|
|
78
|
+
}
|
|
79
|
+
exports.GetTodoRequestNotify = GetTodoRequestNotify;
|
|
80
|
+
/**
|
|
81
|
+
* Sends a get todo response notification
|
|
82
|
+
* @param content - The response content or error details
|
|
83
|
+
* @param isError - Whether this is an error response
|
|
84
|
+
* @param toolUseId - The toolUseId from the original request
|
|
85
|
+
*/
|
|
86
|
+
function GetTodoResponseNotify(content, isError = false, toolUseId) {
|
|
87
|
+
if (!toolUseId) {
|
|
88
|
+
console.error('[TodoNotifications] toolUseId is required for response notifications');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const notification = {
|
|
92
|
+
toolUseId,
|
|
93
|
+
type: "tasknotify",
|
|
94
|
+
action: "getTasksResult",
|
|
95
|
+
content,
|
|
96
|
+
isError
|
|
97
|
+
};
|
|
98
|
+
(0, utils_1.sendNotification)(notification, 'todo-get-tasks-response');
|
|
99
|
+
}
|
|
100
|
+
exports.GetTodoResponseNotify = GetTodoResponseNotify;
|
|
101
|
+
// ===== EDIT TODO TASK FUNCTIONS =====
|
|
102
|
+
/**
|
|
103
|
+
* Sends an edit todo task request notification
|
|
104
|
+
* @param taskId - Optional task ID to edit
|
|
105
|
+
* @param title - Optional new task title
|
|
106
|
+
* @param description - Optional new task description
|
|
107
|
+
* @param phase - Optional new task phase
|
|
108
|
+
* @param category - Optional new task category
|
|
109
|
+
* @param priority - Optional new task priority
|
|
110
|
+
* @param tags - Optional new array of tags
|
|
111
|
+
* @param status - Optional new task status
|
|
112
|
+
* @param toolUseId - Optional custom toolUseId, will be generated if not provided
|
|
113
|
+
*/
|
|
114
|
+
function EditTodoTaskRequestNotify(taskId, title, description, phase, category, priority, tags, status, toolUseId) {
|
|
115
|
+
const notification = {
|
|
116
|
+
toolUseId: toolUseId || (0, utils_1.generateToolUseId)(),
|
|
117
|
+
type: "tasknotify",
|
|
118
|
+
action: "updateTaskRequest",
|
|
119
|
+
data: {
|
|
120
|
+
taskId: taskId,
|
|
121
|
+
title: title,
|
|
122
|
+
description: description,
|
|
123
|
+
phase: phase,
|
|
124
|
+
category: category,
|
|
125
|
+
priority: priority,
|
|
126
|
+
tags: tags,
|
|
127
|
+
status: status
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
(0, utils_1.sendNotification)(notification, 'todo-edit-task');
|
|
131
|
+
}
|
|
132
|
+
exports.EditTodoTaskRequestNotify = EditTodoTaskRequestNotify;
|
|
133
|
+
/**
|
|
134
|
+
* Sends an edit todo task response notification
|
|
135
|
+
* @param content - The response content or error details
|
|
136
|
+
* @param isError - Whether this is an error response
|
|
137
|
+
* @param toolUseId - The toolUseId from the original request
|
|
138
|
+
*/
|
|
139
|
+
function EditTodoTaskResponseNotify(content, isError = false, toolUseId) {
|
|
140
|
+
if (!toolUseId) {
|
|
141
|
+
console.error('[TodoNotifications] toolUseId is required for response notifications');
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const notification = {
|
|
145
|
+
toolUseId,
|
|
146
|
+
type: "tasknotify",
|
|
147
|
+
action: "updateTaskResult",
|
|
148
|
+
content,
|
|
149
|
+
isError
|
|
150
|
+
};
|
|
151
|
+
(0, utils_1.sendNotification)(notification, 'todo-edit-task-response');
|
|
152
|
+
}
|
|
153
|
+
exports.EditTodoTaskResponseNotify = EditTodoTaskResponseNotify;
|
|
154
|
+
/**
|
|
155
|
+
* Todo notification functions object
|
|
156
|
+
*/
|
|
157
|
+
exports.todoNotifications = {
|
|
158
|
+
AddTodoRequestNotify,
|
|
159
|
+
AddTodoResponseNotify,
|
|
160
|
+
GetTodoRequestNotify,
|
|
161
|
+
GetTodoResponseNotify,
|
|
162
|
+
EditTodoTaskRequestNotify,
|
|
163
|
+
EditTodoTaskResponseNotify
|
|
164
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error class for notification-related errors
|
|
3
|
+
*/
|
|
4
|
+
export declare class NotificationError extends Error {
|
|
5
|
+
code: string;
|
|
6
|
+
category: string;
|
|
7
|
+
originalError?: Error | undefined;
|
|
8
|
+
constructor(message: string, code: string, category: string, originalError?: Error | undefined);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Error codes for notification operations
|
|
12
|
+
*/
|
|
13
|
+
export declare enum NotificationErrorCodes {
|
|
14
|
+
CONNECTION_NOT_READY = "CONNECTION_NOT_READY",
|
|
15
|
+
INVALID_DATA = "INVALID_DATA",
|
|
16
|
+
TIMEOUT = "TIMEOUT",
|
|
17
|
+
WEBSOCKET_ERROR = "WEBSOCKET_ERROR",
|
|
18
|
+
VALIDATION_FAILED = "VALIDATION_FAILED"
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Base interface for all notifications
|
|
22
|
+
*/
|
|
23
|
+
export interface BaseNotification {
|
|
24
|
+
toolUseId: string;
|
|
25
|
+
type: string;
|
|
26
|
+
action: string;
|
|
27
|
+
data?: any;
|
|
28
|
+
content?: string | any;
|
|
29
|
+
isError?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Generates a unique toolUseId for notifications
|
|
33
|
+
* @returns {string} A unique identifier in the format 'tool_timestamp_randomstring'
|
|
34
|
+
*/
|
|
35
|
+
export declare function generateToolUseId(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Validates the basic structure of a notification
|
|
38
|
+
* @param notification The notification to validate
|
|
39
|
+
* @returns {boolean} True if the notification has required fields
|
|
40
|
+
*/
|
|
41
|
+
export declare function validateNotificationStructure<T extends BaseNotification>(notification: T): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Sends a notification through the WebSocket connection
|
|
44
|
+
* This is a fire-and-forget operation that handles errors gracefully
|
|
45
|
+
* @param notification The notification to send
|
|
46
|
+
* @param category The category of notification for error reporting
|
|
47
|
+
*/
|
|
48
|
+
export declare function sendNotification<T extends BaseNotification>(notification: T, category?: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Validates that required data fields are present and not empty
|
|
51
|
+
* @param data The data object to validate
|
|
52
|
+
* @param requiredFields Array of field names that must be present
|
|
53
|
+
* @param category The category for error reporting
|
|
54
|
+
* @returns {boolean} True if all required fields are present
|
|
55
|
+
*/
|
|
56
|
+
export declare function validateRequiredFields(data: any, requiredFields: string[], category?: string): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a standardized error response notification
|
|
59
|
+
* @param toolUseId The toolUseId to use for the response
|
|
60
|
+
* @param type The notification type
|
|
61
|
+
* @param action The response action
|
|
62
|
+
* @param error The error that occurred
|
|
63
|
+
* @returns A standardized error response notification
|
|
64
|
+
*/
|
|
65
|
+
export declare function createErrorResponse(toolUseId: string, type: string, action: string, error: Error | string): BaseNotification;
|
|
66
|
+
/**
|
|
67
|
+
* Creates a standardized success response notification
|
|
68
|
+
* @param toolUseId The toolUseId to use for the response
|
|
69
|
+
* @param type The notification type
|
|
70
|
+
* @param action The response action
|
|
71
|
+
* @param content The success content
|
|
72
|
+
* @returns A standardized success response notification
|
|
73
|
+
*/
|
|
74
|
+
export declare function createSuccessResponse(toolUseId: string, type: string, action: string, content: string | any): BaseNotification;
|
|
75
|
+
/**
|
|
76
|
+
* Utility function to safely stringify objects for logging
|
|
77
|
+
* @param obj The object to stringify
|
|
78
|
+
* @param maxLength Maximum length of the resulting string
|
|
79
|
+
* @returns A safe string representation
|
|
80
|
+
*/
|
|
81
|
+
export declare function safeStringify(obj: any, maxLength?: number): string;
|