Files
mac_mcp/src/integrations/deco.js
T
2026-06-03 14:37:17 -04:00

31 lines
821 B
JavaScript

import { execFile } from "node:child_process";
import { loadEnvFile } from "node:process";
import { promisify } from "node:util";
try {
loadEnvFile();
} catch (error) {
if (error.code !== "ENOENT") {
throw error;
}
}
const execFileAsync = promisify(execFile);
const PYTHON = new URL("../../.venv/bin/python", import.meta.url).pathname;
const BRIDGE = new URL("../../scripts/deco_bridge.py", import.meta.url).pathname;
export async function getDecoStats(action) {
try {
const { stdout } = await execFileAsync(PYTHON, [BRIDGE, action], {
timeout: 45_000,
maxBuffer: 4 * 1024 * 1024,
env: process.env,
});
return JSON.parse(stdout);
} catch (error) {
const detail = error.stderr?.trim() || error.message;
throw new Error(`Deco stats request failed. ${detail}`);
}
}