agent-window 1.3.6 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-window",
3
- "version": "1.3.6",
3
+ "version": "1.3.7",
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",
@@ -107,7 +107,19 @@ export async function registerOperationRoutes(fastify) {
107
107
  }
108
108
  };
109
109
 
110
- const result = await startProcess(scriptPath, botName, options);
110
+ // Check if process already exists in PM2
111
+ const { getProcess } = await import('../../core/instance/pm2-bridge.js');
112
+ const existingProc = await getProcess(botName);
113
+
114
+ let result;
115
+ if (existingProc && existingProc.status !== 'stopped') {
116
+ // Process is already running or in errored state - restart it
117
+ const { restartProcess } = await import('../../core/instance/pm2-bridge.js');
118
+ result = await restartProcess(botName);
119
+ } else {
120
+ // Process doesn't exist or is stopped - start it
121
+ result = await startProcess(scriptPath, botName, options);
122
+ }
111
123
 
112
124
  if (!result.success) {
113
125
  return reply.code(400).send({