codebolt 1.11.6 → 1.11.7
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/index.js +32 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -463674,6 +463674,9 @@ exports.toolCliService = {
|
|
|
463674
463674
|
const configFilePath = path_1.default.join(getGlobalCodeboltPath(), 'mcp_servers.json');
|
|
463675
463675
|
const serverName = finalMessage.mcpName;
|
|
463676
463676
|
const config = finalMessage.config;
|
|
463677
|
+
if (!fs.existsSync(configFilePath)) {
|
|
463678
|
+
fs.writeFileSync(configFilePath, JSON.stringify({ mcpServers: {}, enabled: [] }, null, 2));
|
|
463679
|
+
}
|
|
463677
463680
|
const data = fs.readFileSync(configFilePath, 'utf8');
|
|
463678
463681
|
const configData = JSON.parse(data);
|
|
463679
463682
|
if (configData.mcpServers.hasOwnProperty(serverName)) {
|
|
@@ -490672,6 +490675,9 @@ async function toggleMcpServer(req, res) {
|
|
|
490672
490675
|
try {
|
|
490673
490676
|
const { serverName, enabled } = req.body;
|
|
490674
490677
|
const configFilePath = path_1.default.join((0, serverPaths_1.getGlobalCodeboltPath)(), 'mcp_servers.json');
|
|
490678
|
+
if (!fs_1.default.existsSync(configFilePath)) {
|
|
490679
|
+
fs_1.default.writeFileSync(configFilePath, JSON.stringify({ mcpServers: {}, enabled: [] }, null, 2));
|
|
490680
|
+
}
|
|
490675
490681
|
const data = fs_1.default.readFileSync(configFilePath, 'utf8');
|
|
490676
490682
|
const mcpServer = JSON.parse(data);
|
|
490677
490683
|
if (!mcpServer.enabled) {
|
|
@@ -531074,11 +531080,9 @@ async function fetchAgents() {
|
|
|
531074
531080
|
try {
|
|
531075
531081
|
const response = await axios_1.default.get('https://api.codebolt.ai/api/agents/list');
|
|
531076
531082
|
const agents = response.data;
|
|
531077
|
-
// Save agents to
|
|
531078
|
-
|
|
531079
|
-
|
|
531080
|
-
// Save agents to a JSON file in assets
|
|
531081
|
-
const agentsFilePath = path_1.default.join(assetsDir, 'agents.json');
|
|
531083
|
+
// Save agents to the codebolt config directory
|
|
531084
|
+
ensureAgentCodeboltPath();
|
|
531085
|
+
const agentsFilePath = path_1.default.join(codeboltPath, 'agents.json');
|
|
531082
531086
|
await fs_extra_1.default.writeJson(agentsFilePath, agents, { spaces: 2 });
|
|
531083
531087
|
logger.info(`Successfully fetched ${agents.length} agents and saved to ${agentsFilePath}`);
|
|
531084
531088
|
return agents;
|
|
@@ -560427,15 +560431,29 @@ const getLocalAgentService = async (agentName) => {
|
|
|
560427
560431
|
};
|
|
560428
560432
|
};
|
|
560429
560433
|
exports.getLocalAgentService = getLocalAgentService;
|
|
560430
|
-
const getLLMPricingFromLocal = () => {
|
|
560431
|
-
|
|
560432
|
-
const llmpricing = path_1.default.join(
|
|
560434
|
+
const getLLMPricingFromLocal = async () => {
|
|
560435
|
+
const configPath = ensureLlmConfigPath();
|
|
560436
|
+
const llmpricing = path_1.default.join(configPath, 'llmpricing.json');
|
|
560433
560437
|
if (fs_1.default.existsSync(llmpricing)) {
|
|
560434
560438
|
return JSON.parse(fs_1.default.readFileSync(llmpricing, 'utf-8'));
|
|
560435
560439
|
}
|
|
560436
|
-
|
|
560437
|
-
|
|
560440
|
+
// File not found locally — fetch from API and cache
|
|
560441
|
+
logger.info(`[getLLMPricingFromLocal] llmpricing.json not found, fetching from API`);
|
|
560442
|
+
try {
|
|
560443
|
+
const pricingData = await (0, llmHelper_1.getLLMPricingFromApi)();
|
|
560444
|
+
if (pricingData) {
|
|
560445
|
+
if (!fs_1.default.existsSync(configPath)) {
|
|
560446
|
+
fs_1.default.mkdirSync(configPath, { recursive: true });
|
|
560447
|
+
}
|
|
560448
|
+
fs_1.default.writeFileSync(llmpricing, JSON.stringify(pricingData, null, 2));
|
|
560449
|
+
logger.info(`[getLLMPricingFromLocal] Fetched and cached llmpricing.json`);
|
|
560450
|
+
return pricingData;
|
|
560451
|
+
}
|
|
560452
|
+
}
|
|
560453
|
+
catch (error) {
|
|
560454
|
+
logger.error(`[getLLMPricingFromLocal] Failed to fetch LLM pricing from API: ${error}`);
|
|
560438
560455
|
}
|
|
560456
|
+
return [];
|
|
560439
560457
|
};
|
|
560440
560458
|
exports.getLLMPricingFromLocal = getLLMPricingFromLocal;
|
|
560441
560459
|
const updateLLMPricingIndex = async () => {
|
|
@@ -563912,6 +563930,9 @@ exports.testTool = testTool;
|
|
|
563912
563930
|
const configugeServer = async (updatedConfig, serverName) => {
|
|
563913
563931
|
try {
|
|
563914
563932
|
const configFilePath = path.join(ensureMcpCodeboltPath(), 'mcp_servers.json');
|
|
563933
|
+
if (!fs.existsSync(configFilePath)) {
|
|
563934
|
+
fs.writeFileSync(configFilePath, JSON.stringify({ mcpServers: {}, enabled: [] }, null, 2));
|
|
563935
|
+
}
|
|
563915
563936
|
const data = fs.readFileSync(configFilePath, 'utf8');
|
|
563916
563937
|
const mcpServer = JSON.parse(data);
|
|
563917
563938
|
if (!serverName) {
|
|
@@ -605424,11 +605445,7 @@ async function findAgentById(agentId) {
|
|
|
605424
605445
|
try {
|
|
605425
605446
|
const remoteAgents = await (0, agentService_1.fetchAgents)();
|
|
605426
605447
|
if (remoteAgents && remoteAgents.length > 0) {
|
|
605427
|
-
|
|
605428
|
-
const basePath = ensureAgentHelperCodeboltPath();
|
|
605429
|
-
const cachedPath = path_1.default.resolve(basePath, 'agents.json');
|
|
605430
|
-
fs_extra_1.default.writeFileSync(cachedPath, JSON.stringify(remoteAgents, null, 2));
|
|
605431
|
-
appLogger_1.default.info(`[findAgentById] Saved ${remoteAgents.length} agents from remote API to ${cachedPath}`);
|
|
605448
|
+
appLogger_1.default.info(`[findAgentById] Fetched ${remoteAgents.length} agents from remote API`);
|
|
605432
605449
|
agent = remoteAgents.find(a => a.agent_id === agentId || a.id === agentId || a.unique_id === agentId);
|
|
605433
605450
|
if (agent) {
|
|
605434
605451
|
agent.isLocal = false;
|