@astramindapp/mcp-server 0.29.1 → 0.30.0
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/README.md +10 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +13 -0
- package/dist/cli.js.map +1 -1
- package/dist/integration-guide.d.ts +22 -4
- package/dist/integration-guide.d.ts.map +1 -1
- package/dist/integration-guide.js +286 -21
- package/dist/integration-guide.js.map +1 -1
- package/dist/mind-client.d.ts +225 -6
- package/dist/mind-client.d.ts.map +1 -1
- package/dist/mind-client.js +136 -1
- package/dist/mind-client.js.map +1 -1
- package/dist/poll.d.ts +97 -0
- package/dist/poll.d.ts.map +1 -0
- package/dist/poll.js +462 -0
- package/dist/poll.js.map +1 -0
- package/dist/server.d.ts +15 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +495 -22
- package/dist/server.js.map +1 -1
- package/package.json +2 -1
package/dist/poll.js
ADDED
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MIND reply poller — `mind-mcp poll --session <mind_session_id>`
|
|
4
|
+
*
|
|
5
|
+
* The AGENT SESSION REPLIES hard rule (integration-guide.ts) says an agent must
|
|
6
|
+
* keep receiving its owner's replies for as long as its session is active. Under
|
|
7
|
+
* Claude Code (or any runtime with a monitor / background-task tool) this
|
|
8
|
+
* subcommand is the poll:
|
|
9
|
+
*
|
|
10
|
+
* Monitor(command="npx -y @astramindapp/mcp-server poll --session <id>",
|
|
11
|
+
* description="BotsByMIND replies for this session")
|
|
12
|
+
*
|
|
13
|
+
* CONTRACT with the monitor: every line on STDOUT wakes the agent. So stdout carries
|
|
14
|
+
* exactly one thing, a line per owner reply:
|
|
15
|
+
*
|
|
16
|
+
* [BotsByMIND] <owner> replied in MIND (HH:MM): <content, newlines collapsed, max 2000 chars>
|
|
17
|
+
*
|
|
18
|
+
* Everything else (start-up note, HTTP errors, back-off, warnings) goes to STDERR.
|
|
19
|
+
* The API key is never printed anywhere.
|
|
20
|
+
*
|
|
21
|
+
* Mechanics (modelled on the proven ~/.claude/scripts/mind-reply-poll.py):
|
|
22
|
+
* - Every `--interval` seconds (default 10, min 5): a NON-consuming
|
|
23
|
+
* GET /developer/v1/agent-sessions/{id}?limit=30. Only when it shows owner replies
|
|
24
|
+
* not yet delivered (origin "mind", role "user", no delivered_at) does it call
|
|
25
|
+
* GET /{id}/inbox, which marks them delivered and is the arbiter of what to print,
|
|
26
|
+
* so a reply another consumer took a moment earlier is never printed twice.
|
|
27
|
+
* - HTTP errors back off exponentially to 60s and never end the process. A session
|
|
28
|
+
* that keeps answering 404 does end it (exit 3): the id is wrong, not transient.
|
|
29
|
+
* - `--ppid <pid>`: exit 0 when that process is gone.
|
|
30
|
+
*
|
|
31
|
+
* Key resolution: MIND_API_KEY, else the env.MIND_API_KEY of an mcpServers entry that
|
|
32
|
+
* runs this package / mind-mcp (or is named "mind"), found in Claude Code's config,
|
|
33
|
+
* ./.mcp.json, Cursor, Windsurf, VS Code and Claude Desktop — exactly the files
|
|
34
|
+
* `mind-mcp-setup` writes. Base URL: MIND_BASE_URL, else the entry's MIND_BASE_URL,
|
|
35
|
+
* else the same default the MCP client uses.
|
|
36
|
+
*/
|
|
37
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
38
|
+
if (k2 === undefined) k2 = k;
|
|
39
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
40
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
41
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
42
|
+
}
|
|
43
|
+
Object.defineProperty(o, k2, desc);
|
|
44
|
+
}) : (function(o, m, k, k2) {
|
|
45
|
+
if (k2 === undefined) k2 = k;
|
|
46
|
+
o[k2] = m[k];
|
|
47
|
+
}));
|
|
48
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
49
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
50
|
+
}) : function(o, v) {
|
|
51
|
+
o["default"] = v;
|
|
52
|
+
});
|
|
53
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
54
|
+
var ownKeys = function(o) {
|
|
55
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
56
|
+
var ar = [];
|
|
57
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
58
|
+
return ar;
|
|
59
|
+
};
|
|
60
|
+
return ownKeys(o);
|
|
61
|
+
};
|
|
62
|
+
return function (mod) {
|
|
63
|
+
if (mod && mod.__esModule) return mod;
|
|
64
|
+
var result = {};
|
|
65
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
66
|
+
__setModuleDefault(result, mod);
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
})();
|
|
70
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
71
|
+
exports.MAX_CONTENT_CHARS = exports.MAX_BACKOFF_SEC = exports.MIN_INTERVAL_SEC = exports.DEFAULT_INTERVAL_SEC = exports.DEFAULT_BASE_URL = void 0;
|
|
72
|
+
exports.resolveCredentials = resolveCredentials;
|
|
73
|
+
exports.hhmm = hhmm;
|
|
74
|
+
exports.formatReply = formatReply;
|
|
75
|
+
exports.runPoll = runPoll;
|
|
76
|
+
exports.pollUsage = pollUsage;
|
|
77
|
+
exports.parsePollArgs = parsePollArgs;
|
|
78
|
+
exports.pollMain = pollMain;
|
|
79
|
+
const fs = __importStar(require("fs"));
|
|
80
|
+
const os = __importStar(require("os"));
|
|
81
|
+
const path = __importStar(require("path"));
|
|
82
|
+
/** Same default the stdio MCP server (cli.ts) uses. */
|
|
83
|
+
exports.DEFAULT_BASE_URL = "https://www.m-i-n-d.ai";
|
|
84
|
+
const API_PREFIX = "/developer/v1/agent-sessions";
|
|
85
|
+
exports.DEFAULT_INTERVAL_SEC = 10;
|
|
86
|
+
exports.MIN_INTERVAL_SEC = 5;
|
|
87
|
+
exports.MAX_BACKOFF_SEC = 60;
|
|
88
|
+
exports.MAX_CONTENT_CHARS = 2000;
|
|
89
|
+
const MSG_LIMIT = 30;
|
|
90
|
+
const HTTP_TIMEOUT_MS = 15_000;
|
|
91
|
+
const MAX_CONSECUTIVE_404 = 5;
|
|
92
|
+
const SECRET_RE = /(api[_-]?key|secret|token|password)\s*=\s*\S+/gi;
|
|
93
|
+
function readJson(file) {
|
|
94
|
+
try {
|
|
95
|
+
return JSON.parse(fs.readFileSync(file, "utf-8"));
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function asRecord(v) {
|
|
102
|
+
return v && typeof v === "object" && !Array.isArray(v) ? v : undefined;
|
|
103
|
+
}
|
|
104
|
+
function entryRunsMind(name, entry) {
|
|
105
|
+
if (name.toLowerCase() === "mind")
|
|
106
|
+
return true;
|
|
107
|
+
const args = Array.isArray(entry.args) ? entry.args.map(String) : [];
|
|
108
|
+
const hay = [String(entry.command ?? ""), ...args].join(" ");
|
|
109
|
+
return /@astramindapp\/mcp-server|(^|[\s/\\])mind-mcp(-setup)?(\s|$)|mcp-server[\\/]dist[\\/]cli\.js|mind-mcp-server/.test(hay);
|
|
110
|
+
}
|
|
111
|
+
function headerKey(entry) {
|
|
112
|
+
const h = entry.headers;
|
|
113
|
+
if (!h)
|
|
114
|
+
return undefined;
|
|
115
|
+
for (const [k, v] of Object.entries(h)) {
|
|
116
|
+
const s = typeof v === "string" ? v.trim() : "";
|
|
117
|
+
if (k.toLowerCase() === "x-api-key" && s.startsWith("mind_"))
|
|
118
|
+
return s;
|
|
119
|
+
if (k.toLowerCase() === "authorization" && /^Bearer\s+mind_/.test(s))
|
|
120
|
+
return s.replace(/^Bearer\s+/, "");
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
function keyFromServers(servers, label) {
|
|
125
|
+
const map = asRecord(servers);
|
|
126
|
+
if (!map)
|
|
127
|
+
return undefined;
|
|
128
|
+
for (const [name, raw] of Object.entries(map)) {
|
|
129
|
+
const entry = asRecord(raw);
|
|
130
|
+
if (!entry)
|
|
131
|
+
continue;
|
|
132
|
+
const envKey = typeof entry.env?.MIND_API_KEY === "string" ? entry.env.MIND_API_KEY.trim() : "";
|
|
133
|
+
if (envKey && entryRunsMind(name, entry)) {
|
|
134
|
+
const base = typeof entry.env?.MIND_BASE_URL === "string" ? entry.env.MIND_BASE_URL.trim() : "";
|
|
135
|
+
return { apiKey: envKey, baseUrl: base || exports.DEFAULT_BASE_URL, source: `${label} mcpServers.${name}` };
|
|
136
|
+
}
|
|
137
|
+
const hk = headerKey(entry);
|
|
138
|
+
if (hk && /m-i-n-d\.ai|mindapp/i.test(String(entry.url ?? ""))) {
|
|
139
|
+
return { apiKey: hk, baseUrl: exports.DEFAULT_BASE_URL, source: `${label} mcpServers.${name} (hosted headers)` };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
/** Find the MIND API key + base URL. Never throws; undefined when nothing is found. */
|
|
145
|
+
function resolveCredentials(opts = {}) {
|
|
146
|
+
const env = opts.env ?? process.env;
|
|
147
|
+
const home = opts.home ?? os.homedir();
|
|
148
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
149
|
+
const envBase = (env.MIND_BASE_URL ?? "").trim();
|
|
150
|
+
const finish = (c) => ({
|
|
151
|
+
...c,
|
|
152
|
+
// An explicit MIND_BASE_URL in the environment always wins over a config file's.
|
|
153
|
+
baseUrl: (envBase || c.baseUrl).replace(/\/+$/, ""),
|
|
154
|
+
});
|
|
155
|
+
const envKey = (env.MIND_API_KEY ?? "").trim();
|
|
156
|
+
if (envKey)
|
|
157
|
+
return finish({ apiKey: envKey, baseUrl: exports.DEFAULT_BASE_URL, source: "MIND_API_KEY environment variable" });
|
|
158
|
+
// Claude Code: local scope (projects[cwd]) > project scope (./.mcp.json) > user scope.
|
|
159
|
+
const claudeJson = asRecord(readJson(path.join(home, ".claude.json")));
|
|
160
|
+
const projects = asRecord(claudeJson?.projects);
|
|
161
|
+
const local = keyFromServers(asRecord(projects?.[cwd])?.mcpServers, "~/.claude.json (this project)");
|
|
162
|
+
if (local)
|
|
163
|
+
return finish(local);
|
|
164
|
+
const projectFile = keyFromServers(asRecord(readJson(path.join(cwd, ".mcp.json")))?.mcpServers, "./.mcp.json");
|
|
165
|
+
if (projectFile)
|
|
166
|
+
return finish(projectFile);
|
|
167
|
+
const user = keyFromServers(claudeJson?.mcpServers, "~/.claude.json");
|
|
168
|
+
if (user)
|
|
169
|
+
return finish(user);
|
|
170
|
+
const desktop = process.platform === "darwin"
|
|
171
|
+
? path.join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json")
|
|
172
|
+
: process.platform === "win32"
|
|
173
|
+
? path.join(env.APPDATA ?? path.join(home, "AppData", "Roaming"), "Claude", "claude_desktop_config.json")
|
|
174
|
+
: path.join(home, ".config", "Claude", "claude_desktop_config.json");
|
|
175
|
+
// The same four files + Claude Desktop that mind-mcp-setup writes (setup.ts getToolConfigs).
|
|
176
|
+
const setupFiles = [
|
|
177
|
+
[path.join(home, ".cursor", "mcp.json"), "mcpServers", "~/.cursor/mcp.json"],
|
|
178
|
+
[path.join(home, ".windsurf", "mcp.json"), "mcpServers", "~/.windsurf/mcp.json"],
|
|
179
|
+
[path.join(home, ".vscode", "mcp.json"), "servers", "~/.vscode/mcp.json"],
|
|
180
|
+
[desktop, "mcpServers", "Claude Desktop config"],
|
|
181
|
+
];
|
|
182
|
+
for (const [file, key, label] of setupFiles) {
|
|
183
|
+
const found = keyFromServers(asRecord(readJson(file))?.[key], label);
|
|
184
|
+
if (found)
|
|
185
|
+
return finish(found);
|
|
186
|
+
}
|
|
187
|
+
// Last: any project in ~/.claude.json that registered MIND (key is per account, not per project).
|
|
188
|
+
for (const [dir, proj] of Object.entries(projects ?? {})) {
|
|
189
|
+
const found = keyFromServers(asRecord(proj)?.mcpServers, `~/.claude.json (${path.basename(dir) || dir})`);
|
|
190
|
+
if (found)
|
|
191
|
+
return finish(found);
|
|
192
|
+
}
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
function pad2(n) {
|
|
196
|
+
return n < 10 ? `0${n}` : String(n);
|
|
197
|
+
}
|
|
198
|
+
function hhmm(iso, now = new Date()) {
|
|
199
|
+
const d = typeof iso === "string" && iso ? new Date(iso) : now;
|
|
200
|
+
const t = Number.isNaN(d.getTime()) ? now : d;
|
|
201
|
+
return `${pad2(t.getHours())}:${pad2(t.getMinutes())}`;
|
|
202
|
+
}
|
|
203
|
+
/** One reply -> one stdout line. Newlines collapsed, secrets redacted, capped. */
|
|
204
|
+
function formatReply(r, ownerLabel, apiKey, now = new Date()) {
|
|
205
|
+
const by = r.meta && typeof r.meta.replied_by === "string" ? r.meta.replied_by.trim() : "";
|
|
206
|
+
const who = by ? `${by} (shared Editor)` : ownerLabel;
|
|
207
|
+
let content = String(r.content ?? "");
|
|
208
|
+
if (apiKey)
|
|
209
|
+
content = content.split(apiKey).join("[redacted]");
|
|
210
|
+
content = content.replace(SECRET_RE, (_m, k) => `${k}=[redacted]`).split(/\s+/).filter(Boolean).join(" ");
|
|
211
|
+
if (!content)
|
|
212
|
+
content = "(empty message)";
|
|
213
|
+
if (content.length > exports.MAX_CONTENT_CHARS)
|
|
214
|
+
content = content.slice(0, exports.MAX_CONTENT_CHARS - 1) + "…";
|
|
215
|
+
return `[BotsByMIND] ${who} replied in MIND (${hhmm(r.created_at, now)}): ${content}`;
|
|
216
|
+
}
|
|
217
|
+
class HttpError extends Error {
|
|
218
|
+
status;
|
|
219
|
+
label;
|
|
220
|
+
constructor(status, label) {
|
|
221
|
+
super(`HTTP ${status} ${label}`);
|
|
222
|
+
this.status = status;
|
|
223
|
+
this.label = label;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function pidGone(pid) {
|
|
227
|
+
try {
|
|
228
|
+
process.kill(pid, 0);
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
catch (e) {
|
|
232
|
+
return e.code === "ESRCH";
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function sleep(ms, signal) {
|
|
236
|
+
return new Promise((resolve) => {
|
|
237
|
+
if (signal?.aborted)
|
|
238
|
+
return resolve();
|
|
239
|
+
const t = setTimeout(done, ms);
|
|
240
|
+
function done() {
|
|
241
|
+
clearTimeout(t);
|
|
242
|
+
signal?.removeEventListener("abort", done);
|
|
243
|
+
resolve();
|
|
244
|
+
}
|
|
245
|
+
signal?.addEventListener("abort", done, { once: true });
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Runs until aborted, until `ppid` is gone, or until the session id proves bad.
|
|
250
|
+
* Resolves with the process exit code.
|
|
251
|
+
*/
|
|
252
|
+
async function runPoll(opts) {
|
|
253
|
+
const { session, apiKey, baseUrl, out, log, signal } = opts;
|
|
254
|
+
// The 5s floor is enforced where the interval is parsed (pollMain); tests pass fractions.
|
|
255
|
+
const interval = opts.intervalSec > 0 ? opts.intervalSec : exports.DEFAULT_INTERVAL_SEC;
|
|
256
|
+
const sid = encodeURIComponent(session);
|
|
257
|
+
const seenEmpty = new Set();
|
|
258
|
+
const printed = new Set();
|
|
259
|
+
let ownerLabel;
|
|
260
|
+
let fails = 0;
|
|
261
|
+
let notFound = 0;
|
|
262
|
+
async function get(pathAndQuery) {
|
|
263
|
+
const headers = { "X-API-Key": apiKey, Accept: "application/json" };
|
|
264
|
+
if (opts.bot)
|
|
265
|
+
headers["X-MIND-Bot"] = opts.bot;
|
|
266
|
+
const label = pathAndQuery.split("?")[0].replace(sid, ":session");
|
|
267
|
+
const res = await fetch(`${baseUrl}${pathAndQuery}`, {
|
|
268
|
+
headers,
|
|
269
|
+
signal: AbortSignal.timeout(HTTP_TIMEOUT_MS),
|
|
270
|
+
});
|
|
271
|
+
if (!res.ok) {
|
|
272
|
+
await res.text().catch(() => "");
|
|
273
|
+
throw new HttpError(res.status, `GET ${label}`);
|
|
274
|
+
}
|
|
275
|
+
const text = await res.text();
|
|
276
|
+
return text ? JSON.parse(text) : {};
|
|
277
|
+
}
|
|
278
|
+
async function owner() {
|
|
279
|
+
if (ownerLabel)
|
|
280
|
+
return ownerLabel;
|
|
281
|
+
try {
|
|
282
|
+
const p = await get("/developer/v1/profile");
|
|
283
|
+
ownerLabel = typeof p?.username === "string" && p.username ? p.username : "Your owner";
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
return "Your owner"; // best effort; retried at the next reply
|
|
287
|
+
}
|
|
288
|
+
return ownerLabel;
|
|
289
|
+
}
|
|
290
|
+
/** True when the cycle finished, throws on HTTP failure. */
|
|
291
|
+
async function cycle() {
|
|
292
|
+
const data = await get(`${API_PREFIX}/${sid}?limit=${MSG_LIMIT}`);
|
|
293
|
+
const candidates = (data?.messages || []).filter((m) => m && m.origin === "mind" && m.role === "user" && !m.delivered_at && !seenEmpty.has(m.message_id));
|
|
294
|
+
if (!candidates.length)
|
|
295
|
+
return;
|
|
296
|
+
const inbox = await get(`${API_PREFIX}/${sid}/inbox`);
|
|
297
|
+
const replies = inbox?.pending_replies || [];
|
|
298
|
+
if (!replies.length) {
|
|
299
|
+
// Visible as undelivered but /inbox does not treat it as a reply: stop asking about it.
|
|
300
|
+
for (const m of candidates)
|
|
301
|
+
seenEmpty.add(m.message_id);
|
|
302
|
+
if (seenEmpty.size > 500)
|
|
303
|
+
seenEmpty.clear();
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const label = await owner();
|
|
307
|
+
for (const r of replies) {
|
|
308
|
+
if (r.message_id && printed.has(r.message_id))
|
|
309
|
+
continue;
|
|
310
|
+
out(formatReply(r, label, apiKey));
|
|
311
|
+
if (r.message_id)
|
|
312
|
+
printed.add(r.message_id);
|
|
313
|
+
}
|
|
314
|
+
if (printed.size > 500)
|
|
315
|
+
printed.clear();
|
|
316
|
+
}
|
|
317
|
+
log(`polling session ${session} every ${interval}s at ${baseUrl}`);
|
|
318
|
+
for (;;) {
|
|
319
|
+
if (signal?.aborted)
|
|
320
|
+
return 0;
|
|
321
|
+
if (opts.ppid && pidGone(opts.ppid)) {
|
|
322
|
+
log(`parent process ${opts.ppid} is gone; exiting`);
|
|
323
|
+
return 0;
|
|
324
|
+
}
|
|
325
|
+
let delay = interval;
|
|
326
|
+
try {
|
|
327
|
+
await cycle();
|
|
328
|
+
fails = 0;
|
|
329
|
+
notFound = 0;
|
|
330
|
+
}
|
|
331
|
+
catch (e) {
|
|
332
|
+
if (signal?.aborted)
|
|
333
|
+
return 0;
|
|
334
|
+
fails += 1;
|
|
335
|
+
if (e instanceof HttpError) {
|
|
336
|
+
log(`${e.message} (retry ${fails})`);
|
|
337
|
+
if (e.status === 404 && ++notFound >= MAX_CONSECUTIVE_404) {
|
|
338
|
+
log(`session ${session} was not found ${MAX_CONSECUTIVE_404} times in a row; check the session id. exiting`);
|
|
339
|
+
return 3;
|
|
340
|
+
}
|
|
341
|
+
if (e.status !== 404)
|
|
342
|
+
notFound = 0;
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
notFound = 0;
|
|
346
|
+
log(`poll error: ${e.name}: ${e.message} (retry ${fails})`);
|
|
347
|
+
}
|
|
348
|
+
delay = Math.min(exports.MAX_BACKOFF_SEC, interval * 2 ** Math.min(fails, 6));
|
|
349
|
+
}
|
|
350
|
+
// Sleep in 1s slices so a vanished --ppid or an abort ends the wait early.
|
|
351
|
+
const end = Date.now() + delay * 1000;
|
|
352
|
+
while (Date.now() < end) {
|
|
353
|
+
if (signal?.aborted)
|
|
354
|
+
return 0;
|
|
355
|
+
if (opts.ppid && pidGone(opts.ppid)) {
|
|
356
|
+
log(`parent process ${opts.ppid} is gone; exiting`);
|
|
357
|
+
return 0;
|
|
358
|
+
}
|
|
359
|
+
await sleep(Math.min(1000, end - Date.now()), signal);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
// ─── CLI entry ───────────────────────────────────────────────
|
|
364
|
+
function pollUsage() {
|
|
365
|
+
return `mind-mcp poll — print each owner reply of a MIND agent session as one stdout line
|
|
366
|
+
|
|
367
|
+
Usage:
|
|
368
|
+
npx -y @astramindapp/mcp-server poll --session <mind_session_id>
|
|
369
|
+
mind-mcp poll --session <mind_session_id> [--interval <seconds>] [--ppid <pid>]
|
|
370
|
+
|
|
371
|
+
Options:
|
|
372
|
+
--session <id> The session_id mind_sessions action=open returned. Required.
|
|
373
|
+
--interval <sec> Seconds between checks. Default ${exports.DEFAULT_INTERVAL_SEC}, minimum ${exports.MIN_INTERVAL_SEC}.
|
|
374
|
+
--ppid <pid> Exit when this process is gone.
|
|
375
|
+
|
|
376
|
+
Run it under Claude Code's Monitor tool (description "BotsByMIND replies for this
|
|
377
|
+
session"); each stdout line is one reply from your owner and wakes the agent.
|
|
378
|
+
Monitor runs cap at 30 minutes, so re-arm it when it expires.
|
|
379
|
+
|
|
380
|
+
Key: MIND_API_KEY, else the MIND entry in your MCP config (written by mind-mcp-setup).
|
|
381
|
+
Base URL: MIND_BASE_URL, default ${exports.DEFAULT_BASE_URL}. Logs go to stderr only.`;
|
|
382
|
+
}
|
|
383
|
+
function parsePollArgs(argv) {
|
|
384
|
+
const out = {};
|
|
385
|
+
for (let i = 0; i < argv.length; i++) {
|
|
386
|
+
const raw = argv[i];
|
|
387
|
+
if (raw === "--help" || raw === "-h") {
|
|
388
|
+
out.help = true;
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
const eq = raw.indexOf("=");
|
|
392
|
+
const flag = eq > 0 ? raw.slice(0, eq) : raw;
|
|
393
|
+
const take = () => (eq > 0 ? raw.slice(eq + 1) : argv[++i]);
|
|
394
|
+
if (flag === "--session")
|
|
395
|
+
out.session = take();
|
|
396
|
+
else if (flag === "--interval") {
|
|
397
|
+
const v = Number(take());
|
|
398
|
+
if (!Number.isFinite(v) || v <= 0)
|
|
399
|
+
out.error = "--interval must be a number of seconds";
|
|
400
|
+
else
|
|
401
|
+
out.interval = v;
|
|
402
|
+
}
|
|
403
|
+
else if (flag === "--ppid") {
|
|
404
|
+
const v = Number(take());
|
|
405
|
+
if (!Number.isInteger(v) || v <= 0)
|
|
406
|
+
out.error = "--ppid must be a process id";
|
|
407
|
+
else
|
|
408
|
+
out.ppid = v;
|
|
409
|
+
}
|
|
410
|
+
else
|
|
411
|
+
out.error = `unknown option: ${raw}`;
|
|
412
|
+
}
|
|
413
|
+
if (!out.help && !out.error && !out.session)
|
|
414
|
+
out.error = "--session <mind_session_id> is required";
|
|
415
|
+
return out;
|
|
416
|
+
}
|
|
417
|
+
/** `mind-mcp poll ...` — argv excludes the word "poll". Resolves to the exit code. */
|
|
418
|
+
async function pollMain(argv) {
|
|
419
|
+
const args = parsePollArgs(argv);
|
|
420
|
+
const stderr = (m) => process.stderr.write(`mind-mcp poll: ${m}\n`);
|
|
421
|
+
if (args.help) {
|
|
422
|
+
process.stdout.write(pollUsage() + "\n");
|
|
423
|
+
return 0;
|
|
424
|
+
}
|
|
425
|
+
if (args.error) {
|
|
426
|
+
stderr(args.error + "\n" + pollUsage());
|
|
427
|
+
return 2;
|
|
428
|
+
}
|
|
429
|
+
const creds = resolveCredentials();
|
|
430
|
+
if (!creds) {
|
|
431
|
+
stderr("no MIND API key found. Set MIND_API_KEY, or run `npx -y --package=@astramindapp/mcp-server mind-mcp-setup --key <mind_...>` so your MCP config holds it.");
|
|
432
|
+
return 2;
|
|
433
|
+
}
|
|
434
|
+
let interval = args.interval ?? exports.DEFAULT_INTERVAL_SEC;
|
|
435
|
+
if (interval < exports.MIN_INTERVAL_SEC) {
|
|
436
|
+
stderr(`--interval raised to the ${exports.MIN_INTERVAL_SEC}s minimum`);
|
|
437
|
+
interval = exports.MIN_INTERVAL_SEC;
|
|
438
|
+
}
|
|
439
|
+
stderr(`key from ${creds.source}`);
|
|
440
|
+
const ctl = new AbortController();
|
|
441
|
+
for (const sig of ["SIGINT", "SIGTERM", "SIGHUP"])
|
|
442
|
+
process.on(sig, () => ctl.abort());
|
|
443
|
+
// The monitor reader going away closes stdout; nothing is left to wake.
|
|
444
|
+
process.stdout.on("error", (e) => {
|
|
445
|
+
if (e.code === "EPIPE")
|
|
446
|
+
ctl.abort();
|
|
447
|
+
});
|
|
448
|
+
return runPoll({
|
|
449
|
+
session: args.session,
|
|
450
|
+
apiKey: creds.apiKey,
|
|
451
|
+
baseUrl: creds.baseUrl,
|
|
452
|
+
intervalSec: interval,
|
|
453
|
+
ppid: args.ppid,
|
|
454
|
+
bot: (process.env.MIND_BOT || "").trim() || undefined,
|
|
455
|
+
out: (line) => {
|
|
456
|
+
process.stdout.write(line + "\n");
|
|
457
|
+
},
|
|
458
|
+
log: stderr,
|
|
459
|
+
signal: ctl.signal,
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
//# sourceMappingURL=poll.js.map
|
package/dist/poll.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poll.js","sourceRoot":"","sources":["../src/poll.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FH,gDAmDC;AAeD,oBAIC;AAGD,kCASC;AAoDD,0BAqGC;AAID,8BAkBC;AAUD,sCAwBC;AAGD,4BA6CC;AA5aD,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAE7B,uDAAuD;AAC1C,QAAA,gBAAgB,GAAG,wBAAwB,CAAC;AACzD,MAAM,UAAU,GAAG,8BAA8B,CAAC;AACrC,QAAA,oBAAoB,GAAG,EAAE,CAAC;AAC1B,QAAA,gBAAgB,GAAG,CAAC,CAAC;AACrB,QAAA,eAAe,GAAG,EAAE,CAAC;AACrB,QAAA,iBAAi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AO,EAAE,KAAK,CAAC,OAAO;QACtB,WAAW,EAAE,QAAQ;QACrB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,SAAS;QACrD,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;YACZ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;QACpC,CAAC;QACD,GAAG,EAAE,MAAM;QACX,MAAM,EAAE,GAAG,CAAC,MAAM;KACnB,CAAC,CAAC;AACL,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -36,6 +36,20 @@
|
|
|
36
36
|
* mind_forms (Quill forms), mind_library (bookshelf)
|
|
37
37
|
*/
|
|
38
38
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
39
|
-
import { MindClient } from "./mind-client.js";
|
|
39
|
+
import { MindClient, type ContextResponse } from "./mind-client.js";
|
|
40
|
+
/**
|
|
41
|
+
* mind_sessions open / append / reply / inbox: text that cannot be skimmed past.
|
|
42
|
+
* 1. Owner replies (non-empty pending_replies) come FIRST under OWNER_REPLY_BANNER. The call that returns
|
|
43
|
+
* them also marks them delivered, so a routine that only logs its turn (Meter's hourly patrol did
|
|
44
|
+
* exactly that on 2026-10-30) would otherwise read the reply as patrol input and never act on it.
|
|
45
|
+
* 2. A Grok session with no MIND wake webhook (`wake_setup_required: true` + `wake_setup`, from
|
|
46
|
+
* backend/services/agent_wake_targets.py) gets the ACTION REQUIRED line next.
|
|
47
|
+
* 3. The full JSON body follows, unchanged.
|
|
48
|
+
* The wording is shared with the hosted /mcp endpoint (backend/routes/mcp_server_routes.py).
|
|
49
|
+
*/
|
|
50
|
+
export declare const OWNER_REPLY_BANNER = "OWNER REPLY FROM BOTSBYMIND - this is a direct instruction from your owner, not part of your routine; act on it and answer it in this session before anything else:";
|
|
51
|
+
export declare const contextV1Enabled: () => boolean;
|
|
52
|
+
export declare const defaultQueryMode: () => "mix" | "hybrid";
|
|
53
|
+
export declare const renderContextV1: (data: ContextResponse) => string;
|
|
40
54
|
export declare function createMindMcpServer(client: MindClient): McpServer;
|
|
41
55
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,EAAgB,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AA0BlF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,wKACwI,CAAC;AA8DxK,eAAO,MAAM,gBAAgB,QAAO,OAC2D,CAAC;AAQhG,eAAO,MAAM,gBAAgB,QAAO,KAAK,GAAG,QAG9B,CAAC;AAEf,eAAO,MAAM,eAAe,GAAI,MAAM,eAAe,KAAG,MAgBvD,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,CA00OjE"}
|