codebolt 1.11.5 → 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 +46 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -516487,8 +516487,8 @@ class AgentProcessManager extends events_1.EventEmitter {
516487
516487
  super();
516488
516488
  this.processes = new Map();
516489
516489
  this.SPAWN_TIMEOUT = 500000; // 10 seconds
516490
- this.SHUTDOWN_TIMEOUT = 5000; // 5 seconds
516491
- 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)
516492
516492
  this.STDOUT_THROTTLE_MS = 100;
516493
516493
  this.STDERR_THROTTLE_MS = 100;
516494
516494
  this.isShuttingDown = false;
@@ -516850,24 +516850,31 @@ class AgentProcessManager extends events_1.EventEmitter {
516850
516850
  // Force kill after timeout using tree-kill to ensure all child processes are killed
516851
516851
  setTimeout(() => {
516852
516852
  if (!resolved && this.processes.has(processId)) {
516853
- appLogger_1.default.warn(`[${processType} STOP] Forcing SIGKILL for process tree: ${processId} (pid: ${utilityProcess.pid})`);
516854
- // Send notification to UI
516855
- // sendNotificationToUi({
516856
- // type: 'agentProcessUpdate',
516857
- // actionType: WebSocketMessageType.AgentEvent,
516858
- // content: `Forcing SIGKILL for ${metadata.type}: ${metadata.name}`,
516859
- // templateType: TemplateEnum.AGENT,
516860
- // data: { text: `Forcing SIGKILL for ${metadata.type}: ${metadata.name}` },
516861
- // messageId: `agent_force_kill_${processId}_${Date.now()}`,
516862
- // threadId: metadata.threadId || ''
516863
- // });
516853
+ const pid = utilityProcess.pid;
516854
+ appLogger_1.default.warn(`[${processType} STOP] Forcing SIGKILL for process tree: ${processId} (pid: ${pid})`);
516864
516855
  try {
516865
- if (utilityProcess.pid) {
516856
+ if (pid) {
516866
516857
  // Use tree-kill with SIGKILL to forcefully terminate entire process tree
516867
- (0, tree_kill_1.default)(utilityProcess.pid, 'SIGKILL', (err) => {
516858
+ (0, tree_kill_1.default)(pid, 'SIGKILL', (err) => {
516868
516859
  if (err) {
516869
516860
  appLogger_1.default.warn(`[${processType} STOP] tree-kill SIGKILL warning: ${err.message}`);
516870
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);
516871
516878
  });
516872
516879
  }
516873
516880
  else {
@@ -516876,16 +516883,6 @@ class AgentProcessManager extends events_1.EventEmitter {
516876
516883
  }
516877
516884
  catch (error) {
516878
516885
  appLogger_1.default.error(`[${processType} STOP] Error sending SIGKILL: ${error.message}`);
516879
- // Send notification to UI
516880
- // sendNotificationToUi({
516881
- // type: 'agentProcessUpdate',
516882
- // actionType: WebSocketMessageType.AgentEvent,
516883
- // content: `Error sending SIGKILL to ${metadata.type}: ${metadata.name}. Error: ${(error as Error).message}`,
516884
- // templateType: TemplateEnum.AGENT,
516885
- // data: { text: `Error sending SIGKILL to ${metadata.type}: ${metadata.name}. Error: ${(error as Error).message}` },
516886
- // messageId: `agent_kill_error_${processId}_${Date.now()}`,
516887
- // threadId: metadata.threadId || ''
516888
- // });
516889
516886
  onClose(-1);
516890
516887
  }
516891
516888
  }
@@ -531016,6 +531013,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
531016
531013
  };
531017
531014
  Object.defineProperty(exports, "__esModule", ({ value: true }));
531018
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;
531019
531017
  exports.getInstalledAgentsAction = getInstalledAgentsAction;
531020
531018
  exports.getAgentConfig = getAgentConfig;
531021
531019
  exports.getAgentConfigs = getAgentConfigs;
@@ -605421,7 +605419,29 @@ async function findAgentById(agentId) {
605421
605419
  appLogger_1.default.debug(`[findAgentById] Found agent in local project agents: ${agent.agent_id || agent.agentId || agent.id}`);
605422
605420
  }
605423
605421
  else {
605424
- 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
+ }
605425
605445
  }
605426
605446
  }
605427
605447
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codebolt",
3
- "version": "1.11.5",
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",