@codebolt/codeboltjs 2.0.15 → 2.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/Codebolt.d.ts +1 -1
- package/dist/core/messageManager.d.ts +0 -1
- package/dist/core/messageManager.js +4 -2
- package/dist/core/websocket.js +26 -1
- package/dist/modules/mcp.d.ts +1 -2
- package/dist/modules/mcp.js +2 -0
- package/dist/utils.d.ts +0 -7
- package/dist/utils.js +1 -15
- package/package.json +3 -1
- package/dist/agentlib/agent.d.ts +0 -86
- package/dist/agentlib/agent.js +0 -326
- package/dist/agentlib/followupquestionbuilder.d.ts +0 -75
- package/dist/agentlib/followupquestionbuilder.js +0 -193
- package/dist/agentlib/llmoutputhandler.d.ts +0 -102
- package/dist/agentlib/llmoutputhandler.js +0 -451
- package/dist/agentlib/promptbuilder.d.ts +0 -382
- package/dist/agentlib/promptbuilder.js +0 -805
- package/dist/agentlib/systemprompt.d.ts +0 -20
- package/dist/agentlib/systemprompt.js +0 -48
- package/dist/agentlib/taskInstruction.d.ts +0 -37
- package/dist/agentlib/taskInstruction.js +0 -57
- package/dist/agentlib/usermessage.d.ts +0 -70
- package/dist/agentlib/usermessage.js +0 -124
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SystemPrompt class for loading and managing system prompts from YAML files
|
|
3
|
-
*/
|
|
4
|
-
declare class SystemPrompt {
|
|
5
|
-
private filepath;
|
|
6
|
-
private key;
|
|
7
|
-
/**
|
|
8
|
-
* Creates a SystemPrompt instance
|
|
9
|
-
* @param {string} filepath - Path to the YAML file containing prompts
|
|
10
|
-
* @param {string} key - Key identifier for the specific prompt
|
|
11
|
-
*/
|
|
12
|
-
constructor(filepath?: string, key?: string);
|
|
13
|
-
/**
|
|
14
|
-
* Loads and returns the prompt text
|
|
15
|
-
* @returns {string} The prompt text
|
|
16
|
-
* @throws {Error} If file cannot be read or parsed
|
|
17
|
-
*/
|
|
18
|
-
toPromptText(): string;
|
|
19
|
-
}
|
|
20
|
-
export { SystemPrompt };
|
|
@@ -1,48 +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
|
-
exports.SystemPrompt = void 0;
|
|
7
|
-
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
/**
|
|
11
|
-
* SystemPrompt class for loading and managing system prompts from YAML files
|
|
12
|
-
*/
|
|
13
|
-
class SystemPrompt {
|
|
14
|
-
/**
|
|
15
|
-
* Creates a SystemPrompt instance
|
|
16
|
-
* @param {string} filepath - Path to the YAML file containing prompts
|
|
17
|
-
* @param {string} key - Key identifier for the specific prompt
|
|
18
|
-
*/
|
|
19
|
-
constructor(filepath = "", key = "") {
|
|
20
|
-
this.filepath = filepath;
|
|
21
|
-
this.key = key;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Loads and returns the prompt text
|
|
25
|
-
* @returns {string} The prompt text
|
|
26
|
-
* @throws {Error} If file cannot be read or parsed
|
|
27
|
-
*/
|
|
28
|
-
toPromptText() {
|
|
29
|
-
try {
|
|
30
|
-
const absolutePath = path_1.default.resolve(this.filepath);
|
|
31
|
-
const fileContents = fs_1.default.readFileSync(absolutePath, 'utf8');
|
|
32
|
-
const data = js_yaml_1.default.load(fileContents);
|
|
33
|
-
if (!data || typeof data !== 'object') {
|
|
34
|
-
throw new Error('Invalid YAML structure');
|
|
35
|
-
}
|
|
36
|
-
if (!data[this.key]) {
|
|
37
|
-
throw new Error(`Prompt not found for key: ${this.key}`);
|
|
38
|
-
}
|
|
39
|
-
const promptData = data[this.key];
|
|
40
|
-
return typeof promptData === 'string' ? promptData : promptData.prompt;
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
console.error(`SystemPrompt Error: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
44
|
-
throw error; // Re-throw to allow caller handling
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.SystemPrompt = SystemPrompt;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { UserMessage } from "./usermessage";
|
|
2
|
-
import type { UserMessageContent } from "../types/libFunctionTypes";
|
|
3
|
-
import type { Tools, UserMessages } from "../types/InternalTypes";
|
|
4
|
-
/**
|
|
5
|
-
* Class representing a task instruction.
|
|
6
|
-
* Handles loading task data and converting it to prompts.
|
|
7
|
-
*/
|
|
8
|
-
declare class TaskInstruction {
|
|
9
|
-
/** Available tools for the task */
|
|
10
|
-
tools: Tools;
|
|
11
|
-
/** Messages from the user for this task */
|
|
12
|
-
userMessages: UserMessageContent[];
|
|
13
|
-
/** The user message object containing input */
|
|
14
|
-
userMessage: UserMessage;
|
|
15
|
-
/** Path to the YAML file with task instructions */
|
|
16
|
-
filepath: string;
|
|
17
|
-
/** The section reference within the YAML file */
|
|
18
|
-
refsection: string;
|
|
19
|
-
/**
|
|
20
|
-
* Creates a new TaskInstruction instance.
|
|
21
|
-
*
|
|
22
|
-
* @param tools - Tools available for this task
|
|
23
|
-
* @param userMessage - User message containing task instructions
|
|
24
|
-
* @param filepath - Path to the YAML file with task data
|
|
25
|
-
* @param refsection - Section name within the YAML file
|
|
26
|
-
*/
|
|
27
|
-
constructor(tools: Tools | undefined, userMessage: UserMessage, filepath?: string, refsection?: string);
|
|
28
|
-
/**
|
|
29
|
-
* Converts the task instruction to a prompt format.
|
|
30
|
-
* Loads data from YAML file and combines with user message.
|
|
31
|
-
*
|
|
32
|
-
* @returns Promise with an array of user message content blocks
|
|
33
|
-
* @throws Error if there's an issue processing the task instruction
|
|
34
|
-
*/
|
|
35
|
-
toPrompt(): Promise<UserMessages[]>;
|
|
36
|
-
}
|
|
37
|
-
export { TaskInstruction };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TaskInstruction = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Encapsulates task instructions and their related metadata.
|
|
6
|
-
* Handles loading and processing of task instructions from YAML files.
|
|
7
|
-
*/
|
|
8
|
-
const yaml = require('js-yaml');
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
const path = require('path');
|
|
11
|
-
/**
|
|
12
|
-
* Class representing a task instruction.
|
|
13
|
-
* Handles loading task data and converting it to prompts.
|
|
14
|
-
*/
|
|
15
|
-
class TaskInstruction {
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new TaskInstruction instance.
|
|
18
|
-
*
|
|
19
|
-
* @param tools - Tools available for this task
|
|
20
|
-
* @param userMessage - User message containing task instructions
|
|
21
|
-
* @param filepath - Path to the YAML file with task data
|
|
22
|
-
* @param refsection - Section name within the YAML file
|
|
23
|
-
*/
|
|
24
|
-
constructor(tools = {}, userMessage, filepath = "", refsection = "") {
|
|
25
|
-
/** Messages from the user for this task */
|
|
26
|
-
this.userMessages = [];
|
|
27
|
-
this.tools = tools;
|
|
28
|
-
this.userMessage = userMessage;
|
|
29
|
-
this.filepath = filepath;
|
|
30
|
-
this.refsection = refsection;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Converts the task instruction to a prompt format.
|
|
34
|
-
* Loads data from YAML file and combines with user message.
|
|
35
|
-
*
|
|
36
|
-
* @returns Promise with an array of user message content blocks
|
|
37
|
-
* @throws Error if there's an issue processing the task instruction
|
|
38
|
-
*/
|
|
39
|
-
async toPrompt() {
|
|
40
|
-
try {
|
|
41
|
-
this.userMessages = await this.userMessage.toPrompt();
|
|
42
|
-
const fileContents = fs.readFileSync(path.resolve(this.filepath), 'utf8');
|
|
43
|
-
const data = yaml.load(fileContents);
|
|
44
|
-
const task = data[this.refsection];
|
|
45
|
-
this.userMessages.push({
|
|
46
|
-
type: "text",
|
|
47
|
-
text: `Task Description: ${task.description}\nExpected Output: ${task.expected_output}`
|
|
48
|
-
});
|
|
49
|
-
return this.userMessages;
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
console.error(`Error processing task instruction: ${error}`);
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.TaskInstruction = TaskInstruction;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { UserMessageContent } from "../types/libFunctionTypes";
|
|
2
|
-
import type { Agent } from "../types/commonTypes";
|
|
3
|
-
import type { Message } from "../types/InternalTypes";
|
|
4
|
-
/**
|
|
5
|
-
* Class that processes and manages user messages.
|
|
6
|
-
* Handles converting messages to prompts and extracting mentioned entities.
|
|
7
|
-
*/
|
|
8
|
-
declare class UserMessage {
|
|
9
|
-
/** The message content and metadata */
|
|
10
|
-
message: Message;
|
|
11
|
-
/** Whether to override the default prompt generation */
|
|
12
|
-
promptOverride: boolean;
|
|
13
|
-
/** Array of content blocks for the user message */
|
|
14
|
-
userMessages: UserMessageContent[];
|
|
15
|
-
/** List of MCP tools mentioned in the message */
|
|
16
|
-
mentionedMCPs: {
|
|
17
|
-
toolbox: string;
|
|
18
|
-
toolName: string;
|
|
19
|
-
}[];
|
|
20
|
-
/**
|
|
21
|
-
* Creates a new UserMessage instance.
|
|
22
|
-
*
|
|
23
|
-
* @param message - The message content and metadata
|
|
24
|
-
* @param promptOverride - Whether to override default prompt generation
|
|
25
|
-
*/
|
|
26
|
-
constructor(message: Message, promptOverride?: boolean);
|
|
27
|
-
/**
|
|
28
|
-
* Gets files mentioned in the message.
|
|
29
|
-
* Currently a placeholder for implementation.
|
|
30
|
-
*/
|
|
31
|
-
getFiles(): void;
|
|
32
|
-
/**
|
|
33
|
-
* Converts the user message to a prompt format.
|
|
34
|
-
*
|
|
35
|
-
* @param bAttachFiles - Whether to attach file contents
|
|
36
|
-
* @param bAttachImages - Whether to attach images
|
|
37
|
-
* @param bAttachEnvironment - Whether to attach environment details
|
|
38
|
-
* @returns Promise with an array of content blocks for the prompt
|
|
39
|
-
*/
|
|
40
|
-
toPrompt(bAttachFiles?: boolean, bAttachImages?: boolean, bAttachEnvironment?: boolean, supportRemix?: boolean): Promise<UserMessageContent[]>;
|
|
41
|
-
/**
|
|
42
|
-
* Gets agents mentioned in the message.
|
|
43
|
-
*
|
|
44
|
-
* @returns Array of agent objects
|
|
45
|
-
*/
|
|
46
|
-
getMentionedAgents(): Agent[];
|
|
47
|
-
/**
|
|
48
|
-
* Gets MCP tools mentioned in the message.
|
|
49
|
-
*
|
|
50
|
-
* @returns Array of MCP tool names
|
|
51
|
-
*/
|
|
52
|
-
getMentionedMcps(): {
|
|
53
|
-
toolbox: string;
|
|
54
|
-
toolName: string;
|
|
55
|
-
}[];
|
|
56
|
-
/**
|
|
57
|
-
* Gets MCP tools in a format suitable for the LLM.
|
|
58
|
-
*
|
|
59
|
-
* @returns Promise with an array of MCP tools
|
|
60
|
-
*/
|
|
61
|
-
getMentionedMcpsTools(): Promise<any[] | undefined>;
|
|
62
|
-
/**
|
|
63
|
-
* Gets environment details for the current working directory.
|
|
64
|
-
*
|
|
65
|
-
* @param cwd - The current working directory path
|
|
66
|
-
* @returns Promise with a string containing environment details
|
|
67
|
-
*/
|
|
68
|
-
private getEnvironmentDetail;
|
|
69
|
-
}
|
|
70
|
-
export { UserMessage };
|
|
@@ -1,124 +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
|
-
exports.UserMessage = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("../modules/fs"));
|
|
8
|
-
const project_1 = __importDefault(require("../modules/project"));
|
|
9
|
-
const mcp_1 = __importDefault(require("../modules/mcp"));
|
|
10
|
-
// All interfaces moved to appropriate type files
|
|
11
|
-
/**
|
|
12
|
-
* Class that processes and manages user messages.
|
|
13
|
-
* Handles converting messages to prompts and extracting mentioned entities.
|
|
14
|
-
*/
|
|
15
|
-
class UserMessage {
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new UserMessage instance.
|
|
18
|
-
*
|
|
19
|
-
* @param message - The message content and metadata
|
|
20
|
-
* @param promptOverride - Whether to override default prompt generation
|
|
21
|
-
*/
|
|
22
|
-
constructor(message, promptOverride = false) {
|
|
23
|
-
/**
|
|
24
|
-
* Gets environment details for the current working directory.
|
|
25
|
-
*
|
|
26
|
-
* @param cwd - The current working directory path
|
|
27
|
-
* @returns Promise with a string containing environment details
|
|
28
|
-
*/
|
|
29
|
-
this.getEnvironmentDetail = async (cwd) => {
|
|
30
|
-
let details = "";
|
|
31
|
-
const { success, result } = await fs_1.default.listFile(cwd, true);
|
|
32
|
-
details += `\n\n# Current Working Directory (${cwd}) Files\n${result}
|
|
33
|
-
? "\n(Note: Only top-level contents shown for Desktop by default. Use list_files to explore further if necessary.)"
|
|
34
|
-
: ""
|
|
35
|
-
}`;
|
|
36
|
-
return `<environment_details>\n${details.trim()}\n</environment_details>`;
|
|
37
|
-
};
|
|
38
|
-
this.message = message;
|
|
39
|
-
this.promptOverride = promptOverride;
|
|
40
|
-
this.userMessages = [];
|
|
41
|
-
this.mentionedMCPs = message.mentionedMCPs || [];
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Gets files mentioned in the message.
|
|
45
|
-
* Currently a placeholder for implementation.
|
|
46
|
-
*/
|
|
47
|
-
getFiles() {
|
|
48
|
-
// Implementation to be added
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Converts the user message to a prompt format.
|
|
52
|
-
*
|
|
53
|
-
* @param bAttachFiles - Whether to attach file contents
|
|
54
|
-
* @param bAttachImages - Whether to attach images
|
|
55
|
-
* @param bAttachEnvironment - Whether to attach environment details
|
|
56
|
-
* @returns Promise with an array of content blocks for the prompt
|
|
57
|
-
*/
|
|
58
|
-
async toPrompt(bAttachFiles = true, bAttachImages = true, bAttachEnvironment = true, supportRemix = true) {
|
|
59
|
-
var _a;
|
|
60
|
-
if (bAttachFiles) {
|
|
61
|
-
if (this.promptOverride) {
|
|
62
|
-
// Use a rendering engine
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
let finalPrompt = `
|
|
66
|
-
The user has sent the following query:
|
|
67
|
-
<user_query> ${this.message.userMessage} </user_query>.
|
|
68
|
-
`;
|
|
69
|
-
if ((_a = this.message.mentionedFiles) === null || _a === void 0 ? void 0 : _a.length) {
|
|
70
|
-
finalPrompt += `The Attached files are:`;
|
|
71
|
-
for (const file of this.message.mentionedFiles) {
|
|
72
|
-
let filedata = await fs_1.default.readFile(file);
|
|
73
|
-
finalPrompt += `File Name: ${file}, File Path: ${file}, Filedata: ${filedata}`;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
this.userMessages.push({ type: "text", text: finalPrompt });
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (bAttachEnvironment) {
|
|
80
|
-
let { projectPath } = await project_1.default.getProjectPath();
|
|
81
|
-
if (projectPath) {
|
|
82
|
-
const environmentDetail = await this.getEnvironmentDetail(projectPath);
|
|
83
|
-
this.userMessages.push({ type: "text", text: environmentDetail });
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (supportRemix) {
|
|
87
|
-
if (this.message.remixPrompt)
|
|
88
|
-
this.userMessages.push({ type: "text", text: this.message.remixPrompt });
|
|
89
|
-
}
|
|
90
|
-
return this.userMessages;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Gets agents mentioned in the message.
|
|
94
|
-
*
|
|
95
|
-
* @returns Array of agent objects
|
|
96
|
-
*/
|
|
97
|
-
getMentionedAgents() {
|
|
98
|
-
//TODO : get config in tool format if neede
|
|
99
|
-
return this.message.mentionedAgents || [];
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Gets MCP tools mentioned in the message.
|
|
103
|
-
*
|
|
104
|
-
* @returns Array of MCP tool names
|
|
105
|
-
*/
|
|
106
|
-
getMentionedMcps() {
|
|
107
|
-
return this.message.mentionedMCPs || [];
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Gets MCP tools in a format suitable for the LLM.
|
|
111
|
-
*
|
|
112
|
-
* @returns Promise with an array of MCP tools
|
|
113
|
-
*/
|
|
114
|
-
async getMentionedMcpsTools() {
|
|
115
|
-
if (this.mentionedMCPs.length > 0) {
|
|
116
|
-
const { data } = await mcp_1.default.getTools(this.mentionedMCPs);
|
|
117
|
-
return data;
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
return [];
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
exports.UserMessage = UserMessage;
|