Deduplicate requests and include pubkey in notifications

This commit is contained in:
root
2026-03-12 12:33:46 +00:00
parent 213d6bf183
commit 165f84b1df
3 changed files with 42 additions and 8 deletions

View File

@@ -67,7 +67,7 @@ async function createSystemdService(repoName: string, repoDir: string, seedPath:
return serviceName;
}
function appendNotification(payload: { serviceName: string; description: string }) {
function appendNotification(payload: { serviceName: string; description: string; pubkey?: string }) {
const file = '/root/.meta-mcp/notifications.jsonl';
const dir = path.dirname(file);
fs.mkdirSync(dir, { recursive: true });
@@ -201,7 +201,11 @@ export async function runPipeline(jobId: string, request: MetaRequest): Promise<
const cvmiArgs = ['-y', 'cvmi', 'serve', '--', 'node', 'dist/server.js'];
const child = spawn('npx', cvmiArgs, { cwd: repoDir, env, stdio: 'pipe' });
const serviceName = toServiceName(repoName);
const desc = request.requirements[0]?.description ?? repoName;
let pubkey: string | undefined;
let notified = false;
child.stdout.on('data', (d) => {
const text = d.toString();
if (!pubkey) {
@@ -213,6 +217,10 @@ export async function runPipeline(jobId: string, request: MetaRequest): Promise<
message: `Server running for ${repoName}`,
serverPubkey: pubkey,
});
if (!notified) {
appendNotification({ serviceName, description: desc, pubkey });
notified = true;
}
}
}
});
@@ -223,10 +231,11 @@ export async function runPipeline(jobId: string, request: MetaRequest): Promise<
});
// create a systemd service to keep the MCP alive
const serviceName = await createSystemdService(repoName, repoDir, repoSeedPath);
await createSystemdService(repoName, repoDir, repoSeedPath);
const desc = request.requirements[0]?.description ?? repoName;
appendNotification({ serviceName, description: desc });
if (!notified) {
appendNotification({ serviceName, description: desc });
}
return {
status: 'running',