@maind-dev/mcp-bridge 0.6.0 → 0.8.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/build/index.js +764 -157
- package/build/meta.json +1 -1
- package/package.json +2 -1
- package/build/auth.js +0 -179
- package/build/auth.js.map +0 -1
- package/build/client-detect.js +0 -109
- package/build/client-detect.js.map +0 -1
- package/build/device-id.js +0 -149
- package/build/device-id.js.map +0 -1
- package/build/forward.js +0 -433
- package/build/forward.js.map +0 -1
- package/build/index.js.map +0 -1
- package/build/install/atomic-write.js +0 -115
- package/build/install/atomic-write.js.map +0 -1
- package/build/install/browser-pair.js +0 -139
- package/build/install/browser-pair.js.map +0 -1
- package/build/install/client-targets.js +0 -135
- package/build/install/client-targets.js.map +0 -1
- package/build/install/flags.js +0 -139
- package/build/install/flags.js.map +0 -1
- package/build/install/hook-merge.js +0 -195
- package/build/install/hook-merge.js.map +0 -1
- package/build/install/index.js +0 -187
- package/build/install/index.js.map +0 -1
- package/build/install/json-merge.js +0 -160
- package/build/install/json-merge.js.map +0 -1
- package/build/install/preamble.js +0 -119
- package/build/install/preamble.js.map +0 -1
- package/build/install/project-root.js +0 -120
- package/build/install/project-root.js.map +0 -1
- package/build/install/report.js +0 -89
- package/build/install/report.js.map +0 -1
- package/build/install/telemetry.js +0 -83
- package/build/install/telemetry.js.map +0 -1
- package/build/install/toml-merge.js +0 -148
- package/build/install/toml-merge.js.map +0 -1
- package/build/project-key.js +0 -73
- package/build/project-key.js.map +0 -1
- package/build/version.js +0 -7
- package/build/version.js.map +0 -1
package/build/forward.js
DELETED
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
// JSON-RPC forwarding between a local stdio MCP client (Claude Code, Cursor,
|
|
2
|
-
// Windsurf) and the remote maind Streamable-HTTP MCP server. The bridge stays
|
|
3
|
-
// intentionally thin: it does not parse, validate, or alter the JSON-RPC
|
|
4
|
-
// payloads. It only adds Bearer-auth + device-binding headers and demuxes
|
|
5
|
-
// SSE streams back to stdout line-by-line.
|
|
6
|
-
//
|
|
7
|
-
// Two channels per session:
|
|
8
|
-
// - stdin (line-delimited JSON-RPC frames from the local client)
|
|
9
|
-
// - stdout (line-delimited JSON-RPC frames going back to the client)
|
|
10
|
-
//
|
|
11
|
-
// The remote endpoint uses Streamable HTTP — each forwarded POST may return
|
|
12
|
-
// either a single JSON body or an SSE stream (text/event-stream). Both are
|
|
13
|
-
// unpacked to JSON-RPC frames on stdout.
|
|
14
|
-
import { createInterface } from "node:readline";
|
|
15
|
-
import { setTimeout as delay } from "node:timers/promises";
|
|
16
|
-
import { tryExtractInitializeClient } from "./client-detect.js";
|
|
17
|
-
/**
|
|
18
|
-
* Default Streamable-HTTP MCP endpoint for the production maind server.
|
|
19
|
-
* Override via env `MAIND_MCP_URL` for self-hosted/preview environments.
|
|
20
|
-
*/
|
|
21
|
-
const DEFAULT_MCP_URL = "https://mcp.maind.dev/mcp";
|
|
22
|
-
export class BridgeReauthNeeded extends Error {
|
|
23
|
-
reason;
|
|
24
|
-
constructor(reason) {
|
|
25
|
-
super(`re-authorization required: ${reason}`);
|
|
26
|
-
this.reason = reason;
|
|
27
|
-
this.name = "BridgeReauthNeeded";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Long-lived forwarder. One instance per bridge process. Tracks the
|
|
32
|
-
* Mcp-Session-Id header returned by the server's initialize response so
|
|
33
|
-
* subsequent calls land in the same MCP session.
|
|
34
|
-
*/
|
|
35
|
-
export class Forwarder {
|
|
36
|
-
mcpUrl;
|
|
37
|
-
apiKey;
|
|
38
|
-
deviceId;
|
|
39
|
-
bridgeVersion;
|
|
40
|
-
/**
|
|
41
|
-
* Mutable because auto-detection from the MCP `initialize` frame can fill it
|
|
42
|
-
* in for clients that didn't set MAIND_CLIENT_FAMILY. Constructor/ENV values
|
|
43
|
-
* remain authoritative — auto-detect only writes when both are absent.
|
|
44
|
-
*/
|
|
45
|
-
clientFamily;
|
|
46
|
-
clientVersion;
|
|
47
|
-
/**
|
|
48
|
-
* True once we've explicitly set clientFamily via constructor arg or ENV.
|
|
49
|
-
* Used to lock out auto-detect overwrites (priority chain documented in
|
|
50
|
-
* client-detect.ts).
|
|
51
|
-
*/
|
|
52
|
-
clientFamilyLocked;
|
|
53
|
-
clientVersionLocked;
|
|
54
|
-
/** Repo project_key (sha256, ADR-188) or null. Forwarded for B2 repo-scope. */
|
|
55
|
-
projectKey;
|
|
56
|
-
/** Set by the first response that carries an Mcp-Session-Id header. */
|
|
57
|
-
sessionId = null;
|
|
58
|
-
/**
|
|
59
|
-
* The MCP `initialize` request frame, cached the first time we forward it.
|
|
60
|
-
* Replayed to transparently re-establish a session after the server drops it
|
|
61
|
-
* (HTTP 404 "session expired", e.g. after a server restart/deploy) so a
|
|
62
|
-
* deploy doesn't surface as a hard error to the local client.
|
|
63
|
-
*/
|
|
64
|
-
initFrame = null;
|
|
65
|
-
/** Set true once an unrecoverable auth condition is detected. */
|
|
66
|
-
terminated = false;
|
|
67
|
-
constructor(cfg) {
|
|
68
|
-
this.apiKey = cfg.apiKey;
|
|
69
|
-
this.deviceId = cfg.deviceId;
|
|
70
|
-
this.bridgeVersion = cfg.bridgeVersion;
|
|
71
|
-
const rawFamily = cfg.clientFamily ?? process.env.MAIND_CLIENT_FAMILY ?? null;
|
|
72
|
-
this.clientFamily = normalizeClientFamily(rawFamily);
|
|
73
|
-
this.clientFamilyLocked = this.clientFamily !== null;
|
|
74
|
-
const rawVersion = cfg.clientVersion ?? process.env.MAIND_CLIENT_VERSION ?? null;
|
|
75
|
-
this.clientVersion = normalizeClientVersion(rawVersion);
|
|
76
|
-
this.clientVersionLocked = this.clientVersion !== null;
|
|
77
|
-
// Validate to 64-hex (sha256) — never forward a malformed value as a header.
|
|
78
|
-
const rawKey = (cfg.projectKey ?? null)?.trim().toLowerCase() ?? null;
|
|
79
|
-
this.projectKey = rawKey && /^[a-f0-9]{64}$/.test(rawKey) ? rawKey : null;
|
|
80
|
-
this.mcpUrl =
|
|
81
|
-
cfg.mcpUrl ??
|
|
82
|
-
process.env.MAIND_MCP_URL ??
|
|
83
|
-
DEFAULT_MCP_URL;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Read line-delimited JSON-RPC from stdin and forward each frame to the
|
|
87
|
-
* remote server. Returns when stdin is closed. Throws `BridgeReauthNeeded`
|
|
88
|
-
* if the server reports device_mismatch / device_revoked, so the caller can
|
|
89
|
-
* re-run the device flow and retry.
|
|
90
|
-
*/
|
|
91
|
-
async run() {
|
|
92
|
-
const rl = createInterface({
|
|
93
|
-
input: process.stdin,
|
|
94
|
-
crlfDelay: Infinity,
|
|
95
|
-
});
|
|
96
|
-
// Process frames sequentially. MCP allows concurrency, but doing this
|
|
97
|
-
// serially keeps the bridge simple and avoids out-of-order session-id
|
|
98
|
-
// capture on the initialize response. Latency cost is negligible — most
|
|
99
|
-
// tool-calls take >100ms server-side, far above the serialization overhead.
|
|
100
|
-
for await (const line of rl) {
|
|
101
|
-
if (this.terminated)
|
|
102
|
-
return;
|
|
103
|
-
const trimmed = line.trim();
|
|
104
|
-
if (trimmed.length === 0)
|
|
105
|
-
continue;
|
|
106
|
-
await this.forwardFrame(trimmed);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
async forwardFrame(frame, isRetry = false) {
|
|
110
|
-
// Auto-detect upstream client from the MCP `initialize` frame. Runs once
|
|
111
|
-
// per session — initialize is always the first JSON-RPC method. ENV /
|
|
112
|
-
// constructor values win (locked flags), so user overrides remain
|
|
113
|
-
// authoritative. See client-detect.ts for the full priority chain.
|
|
114
|
-
if (!this.clientFamilyLocked && this.clientFamily === null) {
|
|
115
|
-
const detected = tryExtractInitializeClient(frame);
|
|
116
|
-
if (detected !== null) {
|
|
117
|
-
this.clientFamily = detected.family;
|
|
118
|
-
if (!this.clientVersionLocked && this.clientVersion === null) {
|
|
119
|
-
this.clientVersion = detected.version;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
// Cache the initialize frame the first time we see it so we can replay it to
|
|
124
|
-
// recover a dropped session (see recoverSession). Only the first initialize
|
|
125
|
-
// matters — it carries the client's capabilities + clientInfo.
|
|
126
|
-
if (this.initFrame === null && isInitializeRequest(frame)) {
|
|
127
|
-
this.initFrame = frame;
|
|
128
|
-
}
|
|
129
|
-
const headers = this.buildHeaders(true);
|
|
130
|
-
let response;
|
|
131
|
-
try {
|
|
132
|
-
response = await fetch(this.mcpUrl, {
|
|
133
|
-
method: "POST",
|
|
134
|
-
headers,
|
|
135
|
-
body: frame,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
catch (err) {
|
|
139
|
-
// Network error — surface a JSON-RPC error on stdout so the local
|
|
140
|
-
// client doesn't hang. id may be missing if we can't parse the frame;
|
|
141
|
-
// best-effort.
|
|
142
|
-
const id = tryExtractId(frame);
|
|
143
|
-
emitJsonRpcError(id, -32603, `bridge network error: ${stringifyErr(err)}`);
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
// Capture session id once on the initialize response. Subsequent responses
|
|
147
|
-
// generally omit it (server expects the client to send it back), but if it
|
|
148
|
-
// changes we honor the latest.
|
|
149
|
-
const sid = response.headers.get("mcp-session-id");
|
|
150
|
-
if (sid && sid !== this.sessionId) {
|
|
151
|
-
this.sessionId = sid;
|
|
152
|
-
}
|
|
153
|
-
if (response.status === 401) {
|
|
154
|
-
await this.handle401(response, frame);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
// Session recovery: a 404 on a request that carried a session-id means the
|
|
158
|
-
// server no longer knows the session (typically a restart/deploy wiped its
|
|
159
|
-
// in-memory session map). Per the MCP spec the client must start a new
|
|
160
|
-
// session. We do it transparently — replay the cached initialize for a fresh
|
|
161
|
-
// session-id, then retry the original frame ONCE (isRetry guards the loop).
|
|
162
|
-
// Without this, every server deploy surfaces to the local client as a hard
|
|
163
|
-
// error until the bridge process is restarted.
|
|
164
|
-
if (response.status === 404 &&
|
|
165
|
-
!isRetry &&
|
|
166
|
-
this.initFrame !== null &&
|
|
167
|
-
this.sessionId !== null &&
|
|
168
|
-
!isInitializeRequest(frame)) {
|
|
169
|
-
const body = await response.text().catch(() => "");
|
|
170
|
-
if (isSessionLossBody(body) && (await this.recoverSession())) {
|
|
171
|
-
await this.forwardFrame(frame, true);
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
const id = tryExtractId(frame);
|
|
175
|
-
emitJsonRpcError(id, -32603, `bridge upstream error (HTTP 404): ${body.slice(0, 500)}`);
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
if (!response.ok) {
|
|
179
|
-
const id = tryExtractId(frame);
|
|
180
|
-
const body = await response.text().catch(() => "");
|
|
181
|
-
emitJsonRpcError(id, -32603, `bridge upstream error (HTTP ${response.status}): ${body.slice(0, 500)}`);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
185
|
-
if (contentType.startsWith("text/event-stream")) {
|
|
186
|
-
await pipeSseToStdout(response);
|
|
187
|
-
}
|
|
188
|
-
else if (response.status === 202) {
|
|
189
|
-
// Accepted — server acknowledged a notification, no body to emit.
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
const text = await response.text();
|
|
194
|
-
if (text.trim().length > 0) {
|
|
195
|
-
process.stdout.write(text + "\n");
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* 401 path. We inspect the body for the maind-specific hint to decide if a
|
|
201
|
-
* re-auth would help (device_mismatch / device_revoked / device_required)
|
|
202
|
-
* vs. a flat invalid-key (then re-auth would also help — clear the cached
|
|
203
|
-
* key and start fresh).
|
|
204
|
-
*/
|
|
205
|
-
async handle401(response, frame) {
|
|
206
|
-
const body = await response.text().catch(() => "");
|
|
207
|
-
const lower = body.toLowerCase();
|
|
208
|
-
const recoverable = lower.includes("device_mismatch") ||
|
|
209
|
-
lower.includes("device_revoked") ||
|
|
210
|
-
lower.includes("device_required") ||
|
|
211
|
-
lower.includes("invalid or revoked");
|
|
212
|
-
if (recoverable) {
|
|
213
|
-
this.terminated = true;
|
|
214
|
-
throw new BridgeReauthNeeded(extractHint(lower));
|
|
215
|
-
}
|
|
216
|
-
const id = tryExtractId(frame);
|
|
217
|
-
emitJsonRpcError(id, -32001, `bridge auth error: ${body.slice(0, 200)}`);
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Build the outbound header set. `includeSession` attaches the current
|
|
221
|
-
* Mcp-Session-Id (when set) — pass false for the recovery initialize, which
|
|
222
|
-
* must NOT carry the dead session-id so the server mints a fresh one.
|
|
223
|
-
*/
|
|
224
|
-
buildHeaders(includeSession) {
|
|
225
|
-
const headers = {
|
|
226
|
-
"content-type": "application/json",
|
|
227
|
-
// Streamable HTTP allows either a one-shot JSON body or an SSE stream
|
|
228
|
-
// back. Advertising both lets the server pick.
|
|
229
|
-
"accept": "application/json, text/event-stream",
|
|
230
|
-
"authorization": `Bearer ${this.apiKey}`,
|
|
231
|
-
"x-maind-device-id": this.deviceId,
|
|
232
|
-
"x-maind-bridge-version": this.bridgeVersion,
|
|
233
|
-
};
|
|
234
|
-
if (this.clientFamily !== null) {
|
|
235
|
-
headers["x-maind-client-family"] = this.clientFamily;
|
|
236
|
-
}
|
|
237
|
-
if (this.clientVersion !== null) {
|
|
238
|
-
headers["x-maind-client-version"] = this.clientVersion;
|
|
239
|
-
}
|
|
240
|
-
if (this.projectKey !== null) {
|
|
241
|
-
headers["x-maind-project-key"] = this.projectKey;
|
|
242
|
-
}
|
|
243
|
-
if (includeSession && this.sessionId !== null) {
|
|
244
|
-
headers["mcp-session-id"] = this.sessionId;
|
|
245
|
-
}
|
|
246
|
-
return headers;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Re-establish a session after the server dropped it. Replays the cached
|
|
250
|
-
* initialize frame (without a session-id) to mint a fresh Mcp-Session-Id, then
|
|
251
|
-
* sends the readiness notification — mirroring the original handshake. Both
|
|
252
|
-
* responses are drained but NEVER written to stdout: the local client already
|
|
253
|
-
* completed its handshake and must not see a duplicate initialize result.
|
|
254
|
-
* Returns true iff a new session-id was obtained.
|
|
255
|
-
*/
|
|
256
|
-
async recoverSession() {
|
|
257
|
-
if (this.initFrame === null)
|
|
258
|
-
return false;
|
|
259
|
-
this.sessionId = null; // drop the dead session before re-initializing
|
|
260
|
-
let res;
|
|
261
|
-
try {
|
|
262
|
-
res = await fetch(this.mcpUrl, {
|
|
263
|
-
method: "POST",
|
|
264
|
-
headers: this.buildHeaders(false),
|
|
265
|
-
body: this.initFrame,
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
catch {
|
|
269
|
-
return false;
|
|
270
|
-
}
|
|
271
|
-
const sid = res.headers.get("mcp-session-id");
|
|
272
|
-
await res.text().catch(() => ""); // drain, never emit
|
|
273
|
-
if (!res.ok || !sid)
|
|
274
|
-
return false;
|
|
275
|
-
this.sessionId = sid;
|
|
276
|
-
// Best-effort readiness notification on the new session (fire-and-forget).
|
|
277
|
-
try {
|
|
278
|
-
const notify = await fetch(this.mcpUrl, {
|
|
279
|
-
method: "POST",
|
|
280
|
-
headers: this.buildHeaders(true),
|
|
281
|
-
body: JSON.stringify({
|
|
282
|
-
jsonrpc: "2.0",
|
|
283
|
-
method: "notifications/initialized",
|
|
284
|
-
}),
|
|
285
|
-
});
|
|
286
|
-
await notify.text().catch(() => "");
|
|
287
|
-
}
|
|
288
|
-
catch {
|
|
289
|
-
// Advisory only — tool calls work off the session-id alone.
|
|
290
|
-
}
|
|
291
|
-
return true;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
function normalizeClientFamily(raw) {
|
|
295
|
-
if (raw === null)
|
|
296
|
-
return null;
|
|
297
|
-
const v = raw.trim().toLowerCase();
|
|
298
|
-
if (v.length === 0)
|
|
299
|
-
return null;
|
|
300
|
-
const allowed = new Set([
|
|
301
|
-
"claude-code",
|
|
302
|
-
"codex",
|
|
303
|
-
"copilot",
|
|
304
|
-
"cursor",
|
|
305
|
-
"windsurf",
|
|
306
|
-
"mcp-bridge",
|
|
307
|
-
"vscode-extension",
|
|
308
|
-
"claude-desktop",
|
|
309
|
-
"mcp-inspector",
|
|
310
|
-
]);
|
|
311
|
-
return allowed.has(v) ? v : null;
|
|
312
|
-
}
|
|
313
|
-
function normalizeClientVersion(raw) {
|
|
314
|
-
if (raw === null)
|
|
315
|
-
return null;
|
|
316
|
-
const v = raw.trim();
|
|
317
|
-
if (v.length === 0)
|
|
318
|
-
return null;
|
|
319
|
-
return v.slice(0, 64);
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Streams an SSE response body and emits each `data:` payload as a single
|
|
323
|
-
* line-delimited JSON-RPC frame on stdout. Per the SSE spec, multiple `data:`
|
|
324
|
-
* lines inside one event are joined with `\n` — we collapse and emit only if
|
|
325
|
-
* the resulting payload is non-empty.
|
|
326
|
-
*/
|
|
327
|
-
async function pipeSseToStdout(response) {
|
|
328
|
-
if (!response.body)
|
|
329
|
-
return;
|
|
330
|
-
const reader = response.body.getReader();
|
|
331
|
-
const decoder = new TextDecoder();
|
|
332
|
-
let buffer = "";
|
|
333
|
-
let dataLines = [];
|
|
334
|
-
const flushEvent = () => {
|
|
335
|
-
if (dataLines.length === 0)
|
|
336
|
-
return;
|
|
337
|
-
const payload = dataLines.join("\n").trim();
|
|
338
|
-
dataLines = [];
|
|
339
|
-
if (payload.length > 0) {
|
|
340
|
-
process.stdout.write(payload + "\n");
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
try {
|
|
344
|
-
while (true) {
|
|
345
|
-
const { value, done } = await reader.read();
|
|
346
|
-
if (done)
|
|
347
|
-
break;
|
|
348
|
-
buffer += decoder.decode(value, { stream: true });
|
|
349
|
-
let nlIdx;
|
|
350
|
-
while ((nlIdx = buffer.indexOf("\n")) !== -1) {
|
|
351
|
-
const rawLine = buffer.slice(0, nlIdx);
|
|
352
|
-
buffer = buffer.slice(nlIdx + 1);
|
|
353
|
-
const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
|
|
354
|
-
if (line === "") {
|
|
355
|
-
// Blank line terminates an SSE event.
|
|
356
|
-
flushEvent();
|
|
357
|
-
continue;
|
|
358
|
-
}
|
|
359
|
-
if (line.startsWith(":")) {
|
|
360
|
-
// SSE comment / keep-alive; ignore.
|
|
361
|
-
continue;
|
|
362
|
-
}
|
|
363
|
-
if (line.startsWith("data:")) {
|
|
364
|
-
dataLines.push(line.slice(5).replace(/^\s/, ""));
|
|
365
|
-
}
|
|
366
|
-
// Other SSE fields (event:, id:, retry:) are not used by MCP currently.
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
finally {
|
|
371
|
-
// Flush any trailing event the server didn't terminate with a blank line.
|
|
372
|
-
flushEvent();
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
function tryExtractId(frame) {
|
|
376
|
-
try {
|
|
377
|
-
const parsed = JSON.parse(frame);
|
|
378
|
-
return parsed.id ?? null;
|
|
379
|
-
}
|
|
380
|
-
catch {
|
|
381
|
-
return null;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
/** True if the frame is a JSON-RPC MCP `initialize` request. */
|
|
385
|
-
function isInitializeRequest(frame) {
|
|
386
|
-
try {
|
|
387
|
-
return JSON.parse(frame).method === "initialize";
|
|
388
|
-
}
|
|
389
|
-
catch {
|
|
390
|
-
return false;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
/**
|
|
394
|
-
* Heuristic: does a 404 body indicate the server lost our session (vs. a
|
|
395
|
-
* genuinely wrong endpoint)? Matches the maind server's session-expired message
|
|
396
|
-
* and generic MCP wording. Conservative — only a clear session-loss signal
|
|
397
|
-
* triggers recovery, so an unrelated 404 still surfaces as an error.
|
|
398
|
-
*/
|
|
399
|
-
function isSessionLossBody(body) {
|
|
400
|
-
const lower = body.toLowerCase();
|
|
401
|
-
return (lower.includes("session not found") ||
|
|
402
|
-
lower.includes("session expired") ||
|
|
403
|
-
lower.includes("no valid session") ||
|
|
404
|
-
lower.includes("reinitialize") ||
|
|
405
|
-
(lower.includes("session") && lower.includes("expired")));
|
|
406
|
-
}
|
|
407
|
-
function stringifyErr(err) {
|
|
408
|
-
if (err instanceof Error)
|
|
409
|
-
return err.message;
|
|
410
|
-
return String(err);
|
|
411
|
-
}
|
|
412
|
-
function emitJsonRpcError(id, code, message) {
|
|
413
|
-
const env = {
|
|
414
|
-
jsonrpc: "2.0",
|
|
415
|
-
id,
|
|
416
|
-
error: { code, message },
|
|
417
|
-
};
|
|
418
|
-
process.stdout.write(JSON.stringify(env) + "\n");
|
|
419
|
-
}
|
|
420
|
-
function extractHint(lowerBody) {
|
|
421
|
-
if (lowerBody.includes("device_mismatch"))
|
|
422
|
-
return "device_mismatch";
|
|
423
|
-
if (lowerBody.includes("device_revoked"))
|
|
424
|
-
return "device_revoked";
|
|
425
|
-
if (lowerBody.includes("device_required"))
|
|
426
|
-
return "device_required";
|
|
427
|
-
return "auth_failed";
|
|
428
|
-
}
|
|
429
|
-
// Re-export delay so callers can wait between retries without pulling in
|
|
430
|
-
// node:timers/promises themselves. Kept here because the forwarder is the
|
|
431
|
-
// only consumer.
|
|
432
|
-
export { delay };
|
|
433
|
-
//# sourceMappingURL=forward.js.map
|
package/build/forward.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"forward.js","sourceRoot":"","sources":["../src/forward.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,8EAA8E;AAC9E,yEAAyE;AACzE,0EAA0E;AAC1E,2CAA2C;AAC3C,EAAE;AACF,4BAA4B;AAC5B,mEAAmE;AACnE,uEAAuE;AACvE,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,yCAAyC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,IA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B,kBAAkB;QAClB,2BAA2B;QAC3B,iDAAiD;QACjD,SAAS;QACT,OAAO;QACP,KAAK;QACL,EAAE;KACH,CAAC;IACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC5B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,6BAA6B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAClF,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
// Cross-platform atomic file write + small fs/path helpers used across the
|
|
2
|
-
// install sub-command. Centralized so platform quirks live in one place.
|
|
3
|
-
//
|
|
4
|
-
// Atomic-write strategy:
|
|
5
|
-
// 1. Write to a sibling tmp file in the same directory.
|
|
6
|
-
// 2. fs.rename() the tmp file into place — atomic on POSIX, mostly-atomic on
|
|
7
|
-
// Windows when the target doesn't exist.
|
|
8
|
-
// 3. Windows fallback: if rename fails with EEXIST/EPERM, copy + unlink.
|
|
9
|
-
//
|
|
10
|
-
// The "write to sibling" detail matters: rename across filesystems isn't
|
|
11
|
-
// atomic and may fail (EXDEV). Using $TMPDIR could land us on a tmpfs that's
|
|
12
|
-
// a different filesystem than the target.
|
|
13
|
-
import * as fs from "node:fs/promises";
|
|
14
|
-
import * as path from "node:path";
|
|
15
|
-
/**
|
|
16
|
-
* Reads a UTF-8 file. Returns `null` if the file does not exist. Re-throws
|
|
17
|
-
* any other error (permission denied, IO error, etc.) so the caller can
|
|
18
|
-
* record it as a failed step.
|
|
19
|
-
*/
|
|
20
|
-
export async function readFileSafe(filepath) {
|
|
21
|
-
try {
|
|
22
|
-
return await fs.readFile(filepath, "utf8");
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
if (isNoEnt(err))
|
|
26
|
-
return null;
|
|
27
|
-
throw err;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export async function fileExists(filepath) {
|
|
31
|
-
try {
|
|
32
|
-
await fs.access(filepath);
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Idempotent `mkdir -p`. Creates the directory and any missing parents.
|
|
41
|
-
* Returns silently if the directory already exists.
|
|
42
|
-
*/
|
|
43
|
-
export async function ensureDir(dir) {
|
|
44
|
-
await fs.mkdir(dir, { recursive: true });
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Writes `content` to `filepath` atomically across macOS, Linux, and Windows.
|
|
48
|
-
*
|
|
49
|
-
* @param mode Optional POSIX file mode (e.g. 0o600 for user-private files).
|
|
50
|
-
* No-op on Windows where mode bits don't translate to ACLs.
|
|
51
|
-
*/
|
|
52
|
-
export async function atomicWriteFile(filepath, content, mode) {
|
|
53
|
-
const dir = path.dirname(filepath);
|
|
54
|
-
await ensureDir(dir);
|
|
55
|
-
// Sibling tmp file — same FS as the target, so rename is atomic.
|
|
56
|
-
const tmp = path.join(dir, `.maind-install-${process.pid}-${Date.now()}.tmp`);
|
|
57
|
-
await fs.writeFile(tmp, content, { encoding: "utf8", mode });
|
|
58
|
-
try {
|
|
59
|
-
await fs.rename(tmp, filepath);
|
|
60
|
-
}
|
|
61
|
-
catch (err) {
|
|
62
|
-
// Windows: rename can fail with EEXIST/EPERM when the target exists or is
|
|
63
|
-
// locked. Fallback: copy + unlink. This is NOT atomic — but the alternative
|
|
64
|
-
// (fail the whole install) is worse, and we minimize the window by doing
|
|
65
|
-
// it just for the one file.
|
|
66
|
-
if (isWindowsRenameFailure(err)) {
|
|
67
|
-
try {
|
|
68
|
-
await fs.copyFile(tmp, filepath);
|
|
69
|
-
await fs.unlink(tmp).catch(() => {
|
|
70
|
-
// tmp cleanup best-effort — leaking a tmp file is harmless
|
|
71
|
-
});
|
|
72
|
-
if (mode !== undefined) {
|
|
73
|
-
await fs.chmod(filepath, mode).catch(() => {
|
|
74
|
-
// chmod no-op on Windows is fine
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
catch (fallbackErr) {
|
|
80
|
-
await fs.unlink(tmp).catch(() => { });
|
|
81
|
-
throw fallbackErr;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
await fs.unlink(tmp).catch(() => { });
|
|
85
|
-
throw err;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Checks whether a file already contains a line that starts with the given
|
|
90
|
-
* marker (anchored to the start of a line). Used by the preamble-file logic
|
|
91
|
-
* to detect "## maind MCP integration" without false-matching nested headings.
|
|
92
|
-
*
|
|
93
|
-
* Returns `false` if the file does not exist.
|
|
94
|
-
*/
|
|
95
|
-
export async function hasLinePrefix(filepath, prefix) {
|
|
96
|
-
const content = await readFileSafe(filepath);
|
|
97
|
-
if (content === null)
|
|
98
|
-
return false;
|
|
99
|
-
const lines = content.split(/\r?\n/);
|
|
100
|
-
return lines.some((l) => l.startsWith(prefix));
|
|
101
|
-
}
|
|
102
|
-
function isNoEnt(err) {
|
|
103
|
-
return isNodeError(err) && err.code === "ENOENT";
|
|
104
|
-
}
|
|
105
|
-
function isWindowsRenameFailure(err) {
|
|
106
|
-
if (!isNodeError(err))
|
|
107
|
-
return false;
|
|
108
|
-
if (process.platform !== "win32")
|
|
109
|
-
return false;
|
|
110
|
-
return err.code === "EEXIST" || err.code === "EPERM" || err.code === "EACCES";
|
|
111
|
-
}
|
|
112
|
-
function isNodeError(err) {
|
|
113
|
-
return typeof err === "object" && err !== null && "code" in err;
|
|
114
|
-
}
|
|
115
|
-
//# sourceMappingURL=atomic-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