agent-window 1.3.4 → 1.3.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-window",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "A window to interact with AI agents through chat interfaces. Simplified interaction, powerful backend capabilities.",
5
5
  "type": "module",
6
6
  "main": "src/bot.js",
@@ -245,7 +245,10 @@ export async function registerInstanceRoutes(fastify) {
245
245
 
246
246
  // Use botName for PM2 lookup, default to bot-{name}
247
247
  const botName = instance.botName || `bot-${name}`;
248
- const status = await getStatus(botName, { instanceType: instance.instanceType });
248
+ const status = await getStatus(botName, {
249
+ instanceType: instance.instanceType,
250
+ configPath: instance.configPath
251
+ });
249
252
  return { ...status, instanceName: name };
250
253
  } catch (error) {
251
254
  reply.code(500).send({
@@ -157,10 +157,11 @@ export async function getLogs(name, options = {}) {
157
157
  * @param {string} name - Process name
158
158
  * @param {Object} options - Options
159
159
  * @param {string} options.instanceType - Instance type for type-aware checks
160
+ * @param {string} options.configPath - Config path for Docker container name
160
161
  * @returns {Promise<Object>} Status info
161
162
  */
162
163
  export async function getStatus(name, options = {}) {
163
- const { instanceType } = options;
164
+ const { instanceType, configPath } = options;
164
165
  const proc = await getProcess(name);
165
166
 
166
167
  if (!proc) {
@@ -189,12 +190,13 @@ export async function getStatus(name, options = {}) {
189
190
  const procStatus = proc.status || 'stopped';
190
191
 
191
192
  // Get container name from config for Docker check
193
+ // Priority: options.configPath > proc.configPath
192
194
  try {
193
195
  const { readFileSync } = await import('fs');
194
- const configPath = proc.configPath;
196
+ const effectiveConfigPath = configPath || proc.configPath;
195
197
 
196
- if (configPath) {
197
- const configContent = JSON.parse(readFileSync(configPath, 'utf-8'));
198
+ if (effectiveConfigPath) {
199
+ const configContent = JSON.parse(readFileSync(effectiveConfigPath, 'utf-8'));
198
200
  containerName = configContent.workspace?.containerName || null;
199
201
  }
200
202
  } catch (e) {
@@ -224,12 +226,14 @@ export async function getStatus(name, options = {}) {
224
226
  if (containerName && procStatus === 'online') {
225
227
  try {
226
228
  const { execSync } = await import('child_process');
229
+ // Use shorter timeout (2s) to avoid blocking status check
227
230
  const result = execSync(
228
231
  `docker inspect -f '{{.State.Running}}' ${containerName} 2>/dev/null`,
229
- { encoding: 'utf-8', timeout: 5000 }
232
+ { encoding: 'utf-8', timeout: 2000 }
230
233
  ).trim();
231
234
  dockerRunning = result === 'true';
232
235
  } catch (e) {
236
+ // Docker inspect failed (container not running or Docker daemon issue)
233
237
  dockerRunning = false;
234
238
  }
235
239
  }