agent-window 1.1.0 → 1.1.1
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 +1 -1
- package/src/api/routes/operations.js +39 -1
package/package.json
CHANGED
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
* - POST /api/instances/:name/restart - Restart instance
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import path from 'path';
|
|
11
|
+
import { fileURLToPath } from 'url';
|
|
12
|
+
import { dirname } from 'path';
|
|
10
13
|
import {
|
|
11
14
|
startProcess,
|
|
12
15
|
stopProcess,
|
|
@@ -14,6 +17,10 @@ import {
|
|
|
14
17
|
} from '../../core/instance/pm2-bridge.js';
|
|
15
18
|
import { getInstance } from '../../core/instance/manager.js';
|
|
16
19
|
|
|
20
|
+
// Get package root directory
|
|
21
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
const PACKAGE_ROOT = path.join(__dirname, '..', '..');
|
|
23
|
+
|
|
17
24
|
/**
|
|
18
25
|
* Register operation routes
|
|
19
26
|
*/
|
|
@@ -42,8 +49,39 @@ export async function registerOperationRoutes(fastify) {
|
|
|
42
49
|
});
|
|
43
50
|
}
|
|
44
51
|
|
|
52
|
+
// Determine script path based on instance type
|
|
53
|
+
let scriptPath;
|
|
54
|
+
const cwd = instance.projectPath;
|
|
55
|
+
|
|
56
|
+
switch (instance.instanceType) {
|
|
57
|
+
case 'bmad-plugin':
|
|
58
|
+
// BMAD plugin: start _agent-bridge/src/bot.js
|
|
59
|
+
scriptPath = path.join(instance.projectPath, '_agent-bridge', 'src', 'bot.js');
|
|
60
|
+
break;
|
|
61
|
+
case 'standalone':
|
|
62
|
+
// Standalone: start src/bot.js from project root
|
|
63
|
+
scriptPath = path.join(instance.projectPath, 'src', 'bot.js');
|
|
64
|
+
break;
|
|
65
|
+
case 'simple-config':
|
|
66
|
+
// Simple config: use global agent-window bot.js
|
|
67
|
+
scriptPath = path.join(PACKAGE_ROOT, 'src', 'bot.js');
|
|
68
|
+
break;
|
|
69
|
+
default:
|
|
70
|
+
return reply.code(400).send({
|
|
71
|
+
error: 'Unknown instance type',
|
|
72
|
+
instanceType: instance.instanceType
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
45
76
|
const botName = instance.botName || `bot-${name}`;
|
|
46
|
-
const
|
|
77
|
+
const options = {
|
|
78
|
+
cwd,
|
|
79
|
+
env: {
|
|
80
|
+
CONFIG_PATH: instance.configPath
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const result = await startProcess(scriptPath, botName, options);
|
|
47
85
|
|
|
48
86
|
if (!result.success) {
|
|
49
87
|
return reply.code(400).send({
|