@askmesh/mcp 0.4.1 → 0.4.2
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/dist/index.js +22 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28,6 +28,28 @@ sse.start(URL, TOKEN, async (request) => {
|
|
|
28
28
|
}, (answer) => {
|
|
29
29
|
console.error(`[AskMesh] Answer received for request #${answer.id}: "${answer.answer.slice(0, 100)}${answer.answer.length > 100 ? '...' : ''}"`);
|
|
30
30
|
});
|
|
31
|
+
// Polling fallback — fetch pending requests periodically
|
|
32
|
+
// Useful for server agents that may miss SSE events
|
|
33
|
+
const POLL_INTERVAL = Number(process.env.ASKMESH_POLL_INTERVAL || 0); // seconds, 0 = disabled
|
|
34
|
+
if (POLL_INTERVAL > 0) {
|
|
35
|
+
console.error(`[AskMesh] Polling enabled every ${POLL_INTERVAL}s`);
|
|
36
|
+
setInterval(async () => {
|
|
37
|
+
try {
|
|
38
|
+
const { requests } = await client.getPendingRequests();
|
|
39
|
+
for (const req of requests) {
|
|
40
|
+
console.error(`[AskMesh] Polled pending #${req.id}: "${req.question}"`);
|
|
41
|
+
await autoResponder.handleRequest({
|
|
42
|
+
id: req.id,
|
|
43
|
+
fromAgentId: req.fromAgentId,
|
|
44
|
+
fromUsername: `agent#${req.fromAgentId}`,
|
|
45
|
+
question: req.question,
|
|
46
|
+
context: req.context,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch { }
|
|
51
|
+
}, POLL_INTERVAL * 1000);
|
|
52
|
+
}
|
|
31
53
|
// Cleanup on exit
|
|
32
54
|
process.on('SIGINT', () => {
|
|
33
55
|
sse.stop();
|