Start the Fortress MCP bridge when FORTRESS_ENABLED=true
This commit is contained in:
22
src/main.ts
22
src/main.ts
@@ -13,6 +13,7 @@ import { Outbound } from "./telegram/outbound.js";
|
||||
import { createDeviceFlowClient, type DeviceFlowClient } from "./telegram/google-device-flow.js";
|
||||
import { createCalendarTool } from "./tools/calendar.js";
|
||||
import { createGoogleTokenStore, type GoogleTokenStore } from "./tools/google-token-store.js";
|
||||
import { createFortressMcpBridge } from "./agent/fortress-mcp.js";
|
||||
import { createPlaywrightMcpBridge } from "./agent/playwright-mcp.js";
|
||||
import { createScheduleTool } from "./tools/schedule.js";
|
||||
import { createSendTool } from "./tools/send.js";
|
||||
@@ -71,6 +72,7 @@ async function main(): Promise<void> {
|
||||
await bot.stop().catch(() => undefined);
|
||||
await Promise.race([host?.abort().catch(() => undefined), sleep(5000)]);
|
||||
await playwrightDispose?.().catch((err) => logger.warn("playwright dispose failed", err));
|
||||
await fortressDispose?.().catch((err) => logger.warn("fortress dispose failed", err));
|
||||
await scheduler.stop();
|
||||
// Give in-flight Telegram API calls (the online message, a reply being sent, progress-message
|
||||
// cleanup triggered by the abort) time to finish before the process exits.
|
||||
@@ -129,11 +131,31 @@ async function main(): Promise<void> {
|
||||
} else {
|
||||
logger.info("playwright tools disabled (set PLAYWRIGHT_ENABLED=true to enable)");
|
||||
}
|
||||
let fortressDispose: (() => Promise<void>) | undefined;
|
||||
if (config.fortress?.enabled) {
|
||||
try {
|
||||
const bridge = await createFortressMcpBridge({
|
||||
command: config.fortress.command,
|
||||
headless: config.fortress.headless,
|
||||
writeDir: path.join(config.workspaceDir, "fortress"),
|
||||
passthroughEnv: config.fortress.env,
|
||||
logger,
|
||||
});
|
||||
customTools.push(...bridge.tools);
|
||||
fortressDispose = bridge.dispose;
|
||||
logger.info(`fortress tools enabled (${bridge.tools.length} tools)`);
|
||||
} catch (err) {
|
||||
logger.error("fortress bridge failed to start, continuing without stealth browser tools", err);
|
||||
}
|
||||
} else {
|
||||
logger.info("fortress tools disabled (set FORTRESS_ENABLED=true to enable)");
|
||||
}
|
||||
const backend = createPiBackend({
|
||||
workspaceDir: config.workspaceDir,
|
||||
piModel: config.piModel,
|
||||
timezone: config.timezone,
|
||||
customTools,
|
||||
fortressEnabled: fortressDispose !== undefined,
|
||||
logger,
|
||||
onShutdownRequest: () => void shutdown("extension request"),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user