codebolt 1.11.4 → 1.11.6

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 (2) hide show
  1. package/dist/index.js +57 -29
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -378638,8 +378638,8 @@ async function main() {
378638
378638
  userMessage: prompt,
378639
378639
  type: 'messageResponse',
378640
378640
  templateType: 'userChat',
378641
- selectedAgent: agentName !== 'codebolt-agent' ? { id: agentName, name: agentName } : { id: '', name: '' },
378642
- mentionedAgents: agentName !== 'codebolt-agent' ? [{ name: agentName }] : [],
378641
+ selectedAgent: { id: agentName, name: agentName },
378642
+ mentionedAgents: [{ name: agentName }],
378643
378643
  mentionedFiles: [],
378644
378644
  mentionedFolders: [],
378645
378645
  mentionedMultiFile: [],
@@ -446205,6 +446205,8 @@ class ChannelManager extends events_1.EventEmitter {
446205
446205
  /**
446206
446206
  * Initialize the channel manager for a project.
446207
446207
  * Disconnects any channels from a previous project before loading new ones.
446208
+ * Only eagerly connects adapters when auto-connect channels exist;
446209
+ * otherwise the store is ready and adapters are created on demand.
446208
446210
  */
446209
446211
  async initialize(projectPath) {
446210
446212
  // Disconnect adapters from a previous project before switching
@@ -446214,8 +446216,12 @@ class ChannelManager extends events_1.EventEmitter {
446214
446216
  }
446215
446217
  await this.store.initialize(projectPath);
446216
446218
  this.initialized = true;
446217
- // Auto-connect channels
446219
+ // Only connect adapters when channels are configured with autoConnect
446218
446220
  const autoChannels = this.store.getAutoConnect();
446221
+ if (autoChannels.length === 0) {
446222
+ appLogger_1.default.info('[ChannelManager] Initialized — no auto-connect channels, skipping adapter setup');
446223
+ return;
446224
+ }
446219
446225
  for (const config of autoChannels) {
446220
446226
  try {
446221
446227
  await this.connect(config.id);
@@ -516481,8 +516487,8 @@ class AgentProcessManager extends events_1.EventEmitter {
516481
516487
  super();
516482
516488
  this.processes = new Map();
516483
516489
  this.SPAWN_TIMEOUT = 500000; // 10 seconds
516484
- this.SHUTDOWN_TIMEOUT = 5000; // 5 seconds
516485
- this.FORCE_KILL_TIMEOUT = 3000; // 3 seconds
516490
+ this.FORCE_KILL_TIMEOUT = 3000; // 3 seconds after SIGTERM, send SIGKILL
516491
+ this.SHUTDOWN_TIMEOUT = 8000; // 8 seconds total — enough time for SIGTERM (3s) + SIGKILL (5s)
516486
516492
  this.STDOUT_THROTTLE_MS = 100;
516487
516493
  this.STDERR_THROTTLE_MS = 100;
516488
516494
  this.isShuttingDown = false;
@@ -516844,24 +516850,31 @@ class AgentProcessManager extends events_1.EventEmitter {
516844
516850
  // Force kill after timeout using tree-kill to ensure all child processes are killed
516845
516851
  setTimeout(() => {
516846
516852
  if (!resolved && this.processes.has(processId)) {
516847
- appLogger_1.default.warn(`[${processType} STOP] Forcing SIGKILL for process tree: ${processId} (pid: ${utilityProcess.pid})`);
516848
- // Send notification to UI
516849
- // sendNotificationToUi({
516850
- // type: 'agentProcessUpdate',
516851
- // actionType: WebSocketMessageType.AgentEvent,
516852
- // content: `Forcing SIGKILL for ${metadata.type}: ${metadata.name}`,
516853
- // templateType: TemplateEnum.AGENT,
516854
- // data: { text: `Forcing SIGKILL for ${metadata.type}: ${metadata.name}` },
516855
- // messageId: `agent_force_kill_${processId}_${Date.now()}`,
516856
- // threadId: metadata.threadId || ''
516857
- // });
516853
+ const pid = utilityProcess.pid;
516854
+ appLogger_1.default.warn(`[${processType} STOP] Forcing SIGKILL for process tree: ${processId} (pid: ${pid})`);
516858
516855
  try {
516859
- if (utilityProcess.pid) {
516856
+ if (pid) {
516860
516857
  // Use tree-kill with SIGKILL to forcefully terminate entire process tree
516861
- (0, tree_kill_1.default)(utilityProcess.pid, 'SIGKILL', (err) => {
516858
+ (0, tree_kill_1.default)(pid, 'SIGKILL', (err) => {
516862
516859
  if (err) {
516863
516860
  appLogger_1.default.warn(`[${processType} STOP] tree-kill SIGKILL warning: ${err.message}`);
516864
516861
  }
516862
+ // Verify the process is actually dead after a short delay
516863
+ setTimeout(() => {
516864
+ if (!resolved) {
516865
+ try {
516866
+ // process.kill(pid, 0) throws if process doesn't exist
516867
+ process.kill(pid, 0);
516868
+ appLogger_1.default.error(`[${processType} STOP] Process ${pid} still alive after SIGKILL, forcing cleanup`);
516869
+ }
516870
+ catch {
516871
+ // Process is dead — good
516872
+ appLogger_1.default.debug(`[${processType} STOP] Process ${pid} confirmed dead after SIGKILL`);
516873
+ }
516874
+ // Either way, trigger close to resolve the promise
516875
+ onClose(-1);
516876
+ }
516877
+ }, 1000);
516865
516878
  });
516866
516879
  }
516867
516880
  else {
@@ -516870,16 +516883,6 @@ class AgentProcessManager extends events_1.EventEmitter {
516870
516883
  }
516871
516884
  catch (error) {
516872
516885
  appLogger_1.default.error(`[${processType} STOP] Error sending SIGKILL: ${error.message}`);
516873
- // Send notification to UI
516874
- // sendNotificationToUi({
516875
- // type: 'agentProcessUpdate',
516876
- // actionType: WebSocketMessageType.AgentEvent,
516877
- // content: `Error sending SIGKILL to ${metadata.type}: ${metadata.name}. Error: ${(error as Error).message}`,
516878
- // templateType: TemplateEnum.AGENT,
516879
- // data: { text: `Error sending SIGKILL to ${metadata.type}: ${metadata.name}. Error: ${(error as Error).message}` },
516880
- // messageId: `agent_kill_error_${processId}_${Date.now()}`,
516881
- // threadId: metadata.threadId || ''
516882
- // });
516883
516886
  onClose(-1);
516884
516887
  }
516885
516888
  }
@@ -531010,6 +531013,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
531010
531013
  };
531011
531014
  Object.defineProperty(exports, "__esModule", ({ value: true }));
531012
531015
  exports.getLocalProjectAgents = exports.getInstalled = exports.getIntalledAgent = exports.updateAgent = exports.install = exports.installLocal = exports.getAgentFromLocal = exports.changeAgent = exports.stopAgent = exports.startAgent = exports.updateAgentIndex = exports.refreshAgentIndexFromServer = exports.initializeAgentIndex = void 0;
531016
+ exports.fetchAgents = fetchAgents;
531013
531017
  exports.getInstalledAgentsAction = getInstalledAgentsAction;
531014
531018
  exports.getAgentConfig = getAgentConfig;
531015
531019
  exports.getAgentConfigs = getAgentConfigs;
@@ -605415,7 +605419,29 @@ async function findAgentById(agentId) {
605415
605419
  appLogger_1.default.debug(`[findAgentById] Found agent in local project agents: ${agent.agent_id || agent.agentId || agent.id}`);
605416
605420
  }
605417
605421
  else {
605418
- appLogger_1.default.warn(`[findAgentById] Agent ${agentId} not found in any location`);
605422
+ // Fallback: fetch agents from remote API
605423
+ appLogger_1.default.info(`[findAgentById] Agent ${agentId} not found locally, fetching from remote API`);
605424
+ try {
605425
+ const remoteAgents = await (0, agentService_1.fetchAgents)();
605426
+ if (remoteAgents && remoteAgents.length > 0) {
605427
+ // Save to local cache for future lookups
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}`);
605432
+ agent = remoteAgents.find(a => a.agent_id === agentId || a.id === agentId || a.unique_id === agentId);
605433
+ if (agent) {
605434
+ agent.isLocal = false;
605435
+ appLogger_1.default.info(`[findAgentById] Found agent ${agentId} from remote API`);
605436
+ }
605437
+ else {
605438
+ appLogger_1.default.warn(`[findAgentById] Agent ${agentId} not found in remote API either`);
605439
+ }
605440
+ }
605441
+ }
605442
+ catch (remoteError) {
605443
+ appLogger_1.default.error(`[findAgentById] Failed to fetch agents from remote API: ${remoteError}`);
605444
+ }
605419
605445
  }
605420
605446
  }
605421
605447
  else {
@@ -607604,6 +607630,7 @@ const readFileSync = (filePath) => {
607604
607630
  catch (error) {
607605
607631
  if (error.code === 'ENOENT') {
607606
607632
  try {
607633
+ fs_extra_1.default.mkdirSync(path_1.default.dirname(filePath), { recursive: true });
607607
607634
  fs_extra_1.default.writeFileSync(filePath, '', 'utf8');
607608
607635
  console.log(`File not found. Created new file at ${filePath}`);
607609
607636
  return '{}';
@@ -607626,6 +607653,7 @@ const getDatabasePath = () => {
607626
607653
  exports.getDatabasePath = getDatabasePath;
607627
607654
  const writeFileSync = (filePath, data) => {
607628
607655
  try {
607656
+ fs_extra_1.default.mkdirSync(path_1.default.dirname(filePath), { recursive: true });
607629
607657
  fs_extra_1.default.writeFileSync(filePath, data, 'utf8');
607630
607658
  }
607631
607659
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebolt",
3
- "version": "1.11.4",
3
+ "version": "1.11.6",
4
4
  "description": "CodeBolt headless server CLI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",