@askmesh/mcp 0.4.0 → 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.
@@ -13,6 +13,17 @@ export declare class AskMeshClient {
13
13
  answer: string | null;
14
14
  question: string;
15
15
  }>;
16
+ getSentRequests(): Promise<{
17
+ requests: Array<{
18
+ id: number;
19
+ toUsername: string;
20
+ question: string;
21
+ status: string;
22
+ answer: string | null;
23
+ answeredAt: string | null;
24
+ createdAt: string;
25
+ }>;
26
+ }>;
16
27
  getPendingRequests(): Promise<{
17
28
  requests: Array<{
18
29
  id: number;
@@ -29,6 +29,14 @@ export class AskMeshClient {
29
29
  throw new Error(`getRequest failed: ${res.status}`);
30
30
  return res.json();
31
31
  }
32
+ async getSentRequests() {
33
+ const res = await fetch(`${this.baseUrl}/api/v1/requests/sent`, {
34
+ headers: this.headers(),
35
+ });
36
+ if (!res.ok)
37
+ throw new Error(`getSent failed: ${res.status}`);
38
+ return res.json();
39
+ }
32
40
  async getPendingRequests() {
33
41
  const res = await fetch(`${this.baseUrl}/api/v1/requests/pending`, {
34
42
  headers: this.headers(),
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();
@@ -7,9 +7,10 @@ Actions:
7
7
  - "list" : liste les agents de tes teams et leur statut
8
8
  - "status" : vérifie si un agent est disponible
9
9
  - "pending" : voir les questions qu'on t'a posées
10
+ - "inbox" : voir les réponses aux questions que tu as envoyées
10
11
  - "answer" : répondre à une question en attente
11
12
  - "context" : partager ton contexte projet avec ta team`, {
12
- action: z.enum(['ask', 'list', 'status', 'pending', 'answer', 'context']).describe('Action à effectuer'),
13
+ action: z.enum(['ask', 'list', 'status', 'pending', 'inbox', 'answer', 'context']).describe('Action à effectuer'),
13
14
  username: z.string().optional().describe("Username de l'agent cible (pour ask/status)"),
14
15
  question: z.string().optional().describe('Question à poser (pour ask)'),
15
16
  requestId: z.number().optional().describe('ID de la requête (pour answer)'),
@@ -61,6 +62,19 @@ Actions:
61
62
  const lines = requests.map((r) => `#${r.id} — "${r.question}"`);
62
63
  return text(`Questions en attente:\n${lines.join('\n')}\n\nUtilise action "answer" avec requestId et message pour répondre.`);
63
64
  }
65
+ case 'inbox': {
66
+ const { requests } = await client.getSentRequests();
67
+ if (requests.length === 0)
68
+ return text('Aucune question envoyée.');
69
+ const lines = requests.map((r) => {
70
+ const status = r.status === 'answered' ? '✅' : '⏳';
71
+ let line = `${status} #${r.id} → @${r.toUsername}: "${r.question}"`;
72
+ if (r.answer)
73
+ line += `\n Réponse: ${r.answer}`;
74
+ return line;
75
+ });
76
+ return text(`Questions envoyées:\n\n${lines.join('\n\n')}`);
77
+ }
64
78
  case 'answer': {
65
79
  if (!requestId || !message) {
66
80
  return text("Paramètres requis : requestId et message");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askmesh/mcp",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "AskMesh MCP server — connect your AI coding agent to your team's mesh network",
5
5
  "type": "module",
6
6
  "bin": {