automagik-forge 0.2.18 ā 0.2.19
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/bin/cli.js
CHANGED
|
@@ -113,9 +113,9 @@ Options:
|
|
|
113
113
|
--help, -h Show this help message
|
|
114
114
|
--version, -v Show version
|
|
115
115
|
--mcp Run only MCP server (STDIO mode)
|
|
116
|
-
--mcp-sse Run only MCP server (SSE
|
|
116
|
+
--mcp-sse Run only MCP server (SSE mode)
|
|
117
117
|
|
|
118
|
-
Without options: Runs
|
|
118
|
+
Without options: Runs only backend server (no MCP server)
|
|
119
119
|
|
|
120
120
|
Environment Variables:
|
|
121
121
|
BACKEND_PORT Backend server port (default: 8887)
|
|
@@ -123,9 +123,9 @@ Environment Variables:
|
|
|
123
123
|
HOST Server host (default: 127.0.0.1)
|
|
124
124
|
|
|
125
125
|
Examples:
|
|
126
|
-
npx automagik-forge # Start
|
|
126
|
+
npx automagik-forge # Start backend server only
|
|
127
127
|
npx automagik-forge --mcp # MCP server only (STDIO)
|
|
128
|
-
npx automagik-forge --mcp-sse # MCP server only (SSE
|
|
128
|
+
npx automagik-forge --mcp-sse # MCP server only (SSE)
|
|
129
129
|
`);
|
|
130
130
|
process.exit(0);
|
|
131
131
|
}
|
|
@@ -219,8 +219,8 @@ function extractAndRun(baseName, launch) {
|
|
|
219
219
|
|
|
220
220
|
if (isMcpMode || isMcpSseMode) {
|
|
221
221
|
extractAndRun("automagik-forge-mcp", (bin) => {
|
|
222
|
-
const mcpArgs = isMcpSseMode ? ["--mcp-sse"]
|
|
223
|
-
console.log(`Starting MCP server with ${isMcpSseMode ? 'SSE
|
|
222
|
+
const mcpArgs = isMcpSseMode ? [] : ["--mcp-sse"];
|
|
223
|
+
console.log(`Starting MCP server with ${isMcpSseMode ? 'SSE' : 'STDIO'} transport...`);
|
|
224
224
|
|
|
225
225
|
// Environment variables are already loaded from .env file
|
|
226
226
|
|
|
@@ -244,43 +244,18 @@ if (isMcpMode || isMcpSseMode) {
|
|
|
244
244
|
process.on("SIGTERM", () => proc.kill("SIGTERM"));
|
|
245
245
|
});
|
|
246
246
|
} else {
|
|
247
|
-
// Start
|
|
248
|
-
console.log(`š¦ Extracting automagik-forge
|
|
247
|
+
// Start only main backend server (no MCP server by default)
|
|
248
|
+
console.log(`š¦ Extracting automagik-forge...`);
|
|
249
249
|
|
|
250
250
|
// Environment variables are loaded from .env file
|
|
251
251
|
// Use safe defaults (localhost only) unless overridden
|
|
252
|
-
const mcpSsePort = process.env.MCP_SSE_PORT || "8889";
|
|
253
252
|
const backendPort = process.env.BACKEND_PORT || process.env.PORT || "8887";
|
|
254
253
|
const host = process.env.HOST || "127.0.0.1";
|
|
255
254
|
|
|
256
|
-
let mainServerProc, mcpServerProc;
|
|
257
|
-
let shutdownInProgress = false;
|
|
258
|
-
|
|
259
|
-
// Function to gracefully shutdown both servers
|
|
260
|
-
const shutdown = (signal) => {
|
|
261
|
-
if (shutdownInProgress) return;
|
|
262
|
-
shutdownInProgress = true;
|
|
263
|
-
|
|
264
|
-
console.log(`\nš Shutting down servers (${signal})...`);
|
|
265
|
-
|
|
266
|
-
if (mainServerProc && !mainServerProc.killed) {
|
|
267
|
-
mainServerProc.kill(signal);
|
|
268
|
-
}
|
|
269
|
-
if (mcpServerProc && !mcpServerProc.killed) {
|
|
270
|
-
mcpServerProc.kill(signal);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// Force exit after timeout
|
|
274
|
-
setTimeout(() => {
|
|
275
|
-
console.log("ā° Force exit after timeout");
|
|
276
|
-
process.exit(1);
|
|
277
|
-
}, 5000);
|
|
278
|
-
};
|
|
279
|
-
|
|
280
255
|
// Extract and start main backend server
|
|
281
256
|
extractAndRun("automagik-forge", (mainBin) => {
|
|
282
257
|
console.log(`š Starting main backend server on http://${host}:${backendPort}...`);
|
|
283
|
-
mainServerProc = spawn(mainBin, [], {
|
|
258
|
+
const mainServerProc = spawn(mainBin, [], {
|
|
284
259
|
stdio: ["pipe", "pipe", "pipe"],
|
|
285
260
|
env: {
|
|
286
261
|
...process.env,
|
|
@@ -291,59 +266,27 @@ if (isMcpMode || isMcpSseMode) {
|
|
|
291
266
|
});
|
|
292
267
|
|
|
293
268
|
mainServerProc.stdout.on("data", (data) => {
|
|
294
|
-
process.stdout.write(
|
|
269
|
+
process.stdout.write(`${data}`);
|
|
295
270
|
});
|
|
296
271
|
mainServerProc.stderr.on("data", (data) => {
|
|
297
|
-
process.stderr.write(
|
|
272
|
+
process.stderr.write(`${data}`);
|
|
298
273
|
});
|
|
299
274
|
|
|
300
275
|
mainServerProc.on("exit", (code) => {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
shutdown("SIGTERM");
|
|
304
|
-
}
|
|
276
|
+
console.error(`ā Backend server exited with code ${code}`);
|
|
277
|
+
process.exit(code || 1);
|
|
305
278
|
});
|
|
306
279
|
|
|
307
280
|
mainServerProc.on("error", (e) => {
|
|
308
|
-
console.error("ā
|
|
309
|
-
|
|
281
|
+
console.error("ā Backend server error:", e.message);
|
|
282
|
+
process.exit(1);
|
|
310
283
|
});
|
|
311
284
|
|
|
312
|
-
//
|
|
313
|
-
|
|
314
|
-
console.log(
|
|
315
|
-
|
|
316
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
317
|
-
env: {
|
|
318
|
-
...process.env,
|
|
319
|
-
MCP_SSE_PORT: mcpSsePort,
|
|
320
|
-
HOST: host
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
mcpServerProc.stdout.on("data", (data) => {
|
|
325
|
-
process.stdout.write(`[MCP] ${data}`);
|
|
326
|
-
});
|
|
327
|
-
mcpServerProc.stderr.on("data", (data) => {
|
|
328
|
-
process.stderr.write(`[MCP] ${data}`);
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
mcpServerProc.on("exit", (code) => {
|
|
332
|
-
if (!shutdownInProgress) {
|
|
333
|
-
console.error(`ā MCP server exited with code ${code}`);
|
|
334
|
-
shutdown("SIGTERM");
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
mcpServerProc.on("error", (e) => {
|
|
339
|
-
console.error("ā MCP server error:", e.message);
|
|
340
|
-
shutdown("SIGTERM");
|
|
341
|
-
});
|
|
285
|
+
// Handle shutdown signals
|
|
286
|
+
process.on("SIGINT", () => {
|
|
287
|
+
console.log("\nš Shutting down backend server...");
|
|
288
|
+
mainServerProc.kill("SIGINT");
|
|
342
289
|
});
|
|
290
|
+
process.on("SIGTERM", () => mainServerProc.kill("SIGTERM"));
|
|
343
291
|
});
|
|
344
|
-
|
|
345
|
-
// Handle shutdown signals
|
|
346
|
-
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
347
|
-
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
|
348
|
-
process.on("exit", () => shutdown("SIGTERM"));
|
|
349
292
|
}
|
|
Binary file
|
|
Binary file
|