@introspection-ai/recipes 0.25.0 → 0.26.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/dist/mcp-chunks/{auth-command-4WFRNU2I.js → auth-command-JBYNHHMV.js} +23 -27
- package/dist/mcp-chunks/call-arguments-S4EGFKUQ.js +15 -0
- package/dist/mcp-chunks/{call-command-JBIKXOGC.js → call-command-467BVXTE.js} +32 -33
- package/dist/mcp-chunks/{chunk-IPNSPKQK.js → chunk-3Q2Q7SBU.js} +12 -14
- package/dist/mcp-chunks/chunk-66P5FXP3.js +31 -0
- package/dist/mcp-chunks/{chunk-TF2YTYE4.js → chunk-6DVS7RBO.js} +1 -1
- package/dist/mcp-chunks/{chunk-IME7DGLJ.js → chunk-AK5ZEDEF.js} +2 -2
- package/dist/mcp-chunks/{chunk-OP3IW2V6.js → chunk-AP5VHS73.js} +2 -2
- package/dist/mcp-chunks/{chunk-B2LNXGAP.js → chunk-AS27BTCS.js} +1 -1
- package/dist/mcp-chunks/{chunk-MOEZ43ZL.js → chunk-BC2HDCYV.js} +1 -1
- package/dist/mcp-chunks/{chunk-RSTKSBVF.js → chunk-BSCNF4NY.js} +2 -2
- package/dist/mcp-chunks/chunk-BTU34BUG.js +1182 -0
- package/dist/mcp-chunks/{chunk-HN7WPMCA.js → chunk-CN5YF3IQ.js} +21042 -3688
- package/dist/mcp-chunks/{chunk-G6OMDUNG.js → chunk-CZ43ZITK.js} +1 -1
- package/dist/mcp-chunks/{chunk-JG4TRUPF.js → chunk-D2P2IV4H.js} +1 -1
- package/dist/mcp-chunks/{chunk-3R2WK3NB.js → chunk-DMBE47LM.js} +6 -6
- package/dist/mcp-chunks/{chunk-WTMJMM3B.js → chunk-EP22XMWK.js} +3 -30
- package/dist/mcp-chunks/{chunk-ITCCROID.js → chunk-EUDC3ICZ.js} +5 -5
- package/dist/mcp-chunks/{chunk-FX5NYWBH.js → chunk-G4H535MI.js} +3 -21
- package/dist/mcp-chunks/{chunk-HCOKLSOB.js → chunk-GA4ZYSRX.js} +4 -4
- package/dist/mcp-chunks/{chunk-C2KNLFZR.js → chunk-GEVQ2GJW.js} +2 -2
- package/dist/mcp-chunks/{chunk-WYLHHXI6.js → chunk-GK4LA4E6.js} +26 -11
- package/dist/mcp-chunks/{chunk-QZUC2T72.js → chunk-GL4AA5QV.js} +2 -2
- package/dist/mcp-chunks/{chunk-KW3ANJ36.js → chunk-HBN3ESMH.js} +4 -4
- package/dist/mcp-chunks/{chunk-ELA77TDC.js → chunk-HKZZGSDV.js} +4 -4
- package/dist/mcp-chunks/{chunk-36VIJRYY.js → chunk-HTXQPQPB.js} +4 -4
- package/dist/mcp-chunks/{chunk-3JGS7LQB.js → chunk-I7JR2GIC.js} +2 -2
- package/dist/mcp-chunks/{chunk-AIKLVBYU.js → chunk-IO2IMWYS.js} +2 -2
- package/dist/mcp-chunks/{chunk-RD7NHCRK.js → chunk-J2WP6ERZ.js} +39 -42
- package/dist/mcp-chunks/{chunk-HLRCUHNO.js → chunk-KJNNO5Z6.js} +1 -1
- package/dist/mcp-chunks/{chunk-4ZNBWL65.js → chunk-L2LGMX5P.js} +2 -2
- package/dist/mcp-chunks/chunk-LG3GLOSA.js +513 -0
- package/dist/mcp-chunks/{chunk-CZKDJZER.js → chunk-LTR626QF.js} +1 -1
- package/dist/mcp-chunks/{chunk-FS5JIKT6.js → chunk-LYWEATXZ.js} +6 -6
- package/dist/mcp-chunks/{chunk-YIRGLKDA.js → chunk-M62ESEOY.js} +45 -14
- package/dist/mcp-chunks/{chunk-V5AYEKSL.js → chunk-MJHMXYMO.js} +52 -81
- package/dist/mcp-chunks/{chunk-7WOKCV6Q.js → chunk-N7ZWX3WW.js} +1 -1
- package/dist/mcp-chunks/chunk-NTABJCUL.js +123 -0
- package/dist/mcp-chunks/{chunk-EPT4MYOF.js → chunk-OABFKFSL.js} +11 -11
- package/dist/mcp-chunks/{chunk-SCOMDV54.js → chunk-OB256NMD.js} +1 -1
- package/dist/mcp-chunks/{chunk-IYWYVHHD.js → chunk-OZQTZWW4.js} +1 -1
- package/dist/mcp-chunks/{chunk-ITR7FQM3.js → chunk-QIBGY4IX.js} +2 -2
- package/dist/mcp-chunks/{chunk-ZOAQDFAO.js → chunk-REEFOL44.js} +1 -1
- package/dist/mcp-chunks/{chunk-ED2WN5BI.js → chunk-SUNOYTQJ.js} +3 -3
- package/dist/mcp-chunks/{chunk-Y3EDWN2P.js → chunk-TFU4NKFJ.js} +1 -1
- package/dist/mcp-chunks/{chunk-EMSNQHZZ.js → chunk-TGPIW6F6.js} +1 -1
- package/dist/mcp-chunks/{chunk-SNKXMWDB.js → chunk-UCJ7YDFN.js} +1 -1
- package/dist/mcp-chunks/{chunk-TPHPAEDH.js → chunk-WUEDIOR5.js} +1 -1
- package/dist/mcp-chunks/{chunk-FAJPJTOC.js → chunk-XCNWICLD.js} +1 -1
- package/dist/mcp-chunks/{chunk-6YZW3XAE.js → chunk-XFQSUC7T.js} +5 -5
- package/dist/mcp-chunks/{chunk-GQ6NSIDS.js → chunk-Y3L5LWBY.js} +3037 -747
- package/dist/mcp-chunks/{chunk-53NRFMB3.js → chunk-YI5SMRFH.js} +46 -25
- package/dist/mcp-chunks/{chunk-GUXMP7QB.js → chunk-YPTN46JQ.js} +2 -2
- package/dist/mcp-chunks/{chunk-I5GI2A2D.js → chunk-YVH36MGQ.js} +2 -2
- package/dist/mcp-chunks/{chunk-ASG4OY3M.js → chunk-Z6QEOUMK.js} +22 -23
- package/dist/mcp-chunks/{cli-XU26MUCN.js → cli-TN6JTLTS.js} +108 -77
- package/dist/mcp-chunks/client-G33HPQAC.js +29 -0
- package/dist/mcp-chunks/{config-command-UQMMIK2U.js → config-command-LICU56ZH.js} +27 -28
- package/dist/mcp-chunks/daemon-command-JLVHGWHB.js +29 -0
- package/dist/mcp-chunks/{dist-DM2RXZMU.js → dist-MFAWSKGH.js} +80 -46
- package/dist/mcp-chunks/{emit-ts-command-KAOL6DAN.js → emit-ts-command-FVX3JMSN.js} +18 -18
- package/dist/mcp-chunks/{generate-cli-runner-AK6XNRTK.js → generate-cli-runner-L2L7VMCA.js} +53 -51
- package/dist/mcp-chunks/generated-daemon-runtime-DC6IL7E7.js +29 -0
- package/dist/mcp-chunks/{inspect-cli-command-6FVJO7H2.js → inspect-cli-command-Y5D3GRE2.js} +9 -10
- package/dist/mcp-chunks/{launch-EIT73HX4.js → launch-ZFY6CM2A.js} +1 -1
- package/dist/mcp-chunks/{lifecycle-QH4TUI3K.js → lifecycle-H7DIW5DM.js} +1 -1
- package/dist/mcp-chunks/{list-command-UOB2XZK7.js → list-command-55LCLW4S.js} +34 -35
- package/dist/mcp-chunks/{output-utils-6YXH23T7.js → output-utils-YYHI637S.js} +3 -3
- package/dist/mcp-chunks/{prompt-CH6TK0bC-ZB6RFAXR.js → prompt-CH6TK0bC-DZLFAAPK.js} +1 -1
- package/dist/mcp-chunks/{record-command-FO5TTERC.js → record-command-PWIBYC5J.js} +5 -5
- package/dist/mcp-chunks/{replay-command-SCBPCGQ7.js → replay-command-QHZZZMXF.js} +6 -6
- package/dist/mcp-chunks/{resource-command-S2J7XEMV.js → resource-command-HMR2KXWK.js} +9 -10
- package/dist/mcp-chunks/{result-utils-OME6HGS6.js → result-utils-UGCQSRJ4.js} +3 -4
- package/dist/mcp-chunks/runtime-ZNFPZXKE.js +36 -0
- package/dist/mcp-chunks/runtime-wrapper-I4B3OROR.js +10 -0
- package/dist/mcp-chunks/{serve-command-DDBZZSG6.js → serve-command-NTDI3YPN.js} +29 -34
- package/dist/mcp-chunks/{timeouts-HNGNKDQN.js → timeouts-35UDWFA7.js} +3 -3
- package/dist/mcp-chunks/{vault-command-TJZYS3YI.js → vault-command-D5QZL4FI.js} +4 -6
- package/dist/mcp-daemon.js +26 -31
- package/dist/mcp-run-worker.js +26 -31
- package/dist/pi-extension.d.ts.map +1 -1
- package/dist/pi-extension.js +27 -0
- package/dist/pi-extension.js.map +1 -1
- package/docs/pi-extension.md +1 -1
- package/docs/recipe-format.md +7 -3
- package/docs/recipe-templates.md +46 -0
- package/package.json +14 -14
- package/dist/mcp-chunks/call-arguments-4DWPBLQP.js +0 -15
- package/dist/mcp-chunks/chunk-3Z7MFS6K.js +0 -86
- package/dist/mcp-chunks/chunk-AD3FQ73K.js +0 -39
- package/dist/mcp-chunks/chunk-BWW4XRUC.js +0 -1931
- package/dist/mcp-chunks/chunk-DTZHEVKC.js +0 -12
- package/dist/mcp-chunks/chunk-H3JCYHGS.js +0 -1018
- package/dist/mcp-chunks/chunk-IRTJXFWA.js +0 -28
- package/dist/mcp-chunks/chunk-NTHUNCXJ.js +0 -526
- package/dist/mcp-chunks/chunk-OD3MSMXY.js +0 -15
- package/dist/mcp-chunks/chunk-PZ323CXI.js +0 -17394
- package/dist/mcp-chunks/client-OT34CKRH.js +0 -21
- package/dist/mcp-chunks/daemon-command-YCIOZGPZ.js +0 -35
- package/dist/mcp-chunks/runtime-QIPMLIJI.js +0 -39
- package/dist/mcp-chunks/runtime-wrapper-X4YFKMJI.js +0 -16
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
launchDaemonDetached
|
|
4
|
+
} from "./chunk-GK4LA4E6.js";
|
|
5
|
+
import {
|
|
6
|
+
BrokerError,
|
|
7
|
+
DAEMON_PROTOCOL_VERSION,
|
|
8
|
+
DaemonBroker,
|
|
9
|
+
DaemonClient,
|
|
10
|
+
ProcessObservationError,
|
|
11
|
+
SocketFrames,
|
|
12
|
+
assertLegacyDrained,
|
|
13
|
+
authenticateServer,
|
|
14
|
+
daemonKey,
|
|
15
|
+
idleTimerDelay,
|
|
16
|
+
legacyDaemons,
|
|
17
|
+
requestDaemon,
|
|
18
|
+
resolveDaemonPaths,
|
|
19
|
+
resolveProgressInterval,
|
|
20
|
+
stopVerifiedLegacyDaemons,
|
|
21
|
+
waitForDaemonReady
|
|
22
|
+
} from "./chunk-BTU34BUG.js";
|
|
23
|
+
import {
|
|
24
|
+
canonicalUserConfiguration,
|
|
25
|
+
getDaemonLogPath,
|
|
26
|
+
secureDaemonDirectory
|
|
27
|
+
} from "./chunk-Y3L5LWBY.js";
|
|
28
|
+
import {
|
|
29
|
+
withFileLock,
|
|
30
|
+
writeJsonFile
|
|
31
|
+
} from "./chunk-QIBGY4IX.js";
|
|
32
|
+
import {
|
|
33
|
+
expandHome
|
|
34
|
+
} from "./chunk-EP22XMWK.js";
|
|
35
|
+
|
|
36
|
+
// node_modules/.pnpm/mcporter@0.13.10/node_modules/mcporter/dist/cli/daemon-command.js
|
|
37
|
+
import fsPromises from "node:fs/promises";
|
|
38
|
+
import path2 from "node:path";
|
|
39
|
+
|
|
40
|
+
// node_modules/.pnpm/mcporter@0.13.10/node_modules/mcporter/dist/daemon/host.js
|
|
41
|
+
import fs from "node:fs/promises";
|
|
42
|
+
import net from "node:net";
|
|
43
|
+
import { randomUUID } from "node:crypto";
|
|
44
|
+
|
|
45
|
+
// node_modules/.pnpm/mcporter@0.13.10/node_modules/mcporter/dist/daemon/log-context.js
|
|
46
|
+
import fsSync from "node:fs";
|
|
47
|
+
import path from "node:path";
|
|
48
|
+
function createLogContext(options) {
|
|
49
|
+
const derivedEnabled = options.enabled || options.logAllServers || options.servers.size > 0;
|
|
50
|
+
const context = {
|
|
51
|
+
enabled: derivedEnabled,
|
|
52
|
+
logAllServers: options.logAllServers,
|
|
53
|
+
servers: options.servers
|
|
54
|
+
};
|
|
55
|
+
if (derivedEnabled && options.logPath) {
|
|
56
|
+
try {
|
|
57
|
+
fsSync.mkdirSync(path.dirname(options.logPath), { recursive: true });
|
|
58
|
+
const writer = fsSync.createWriteStream(options.logPath, {
|
|
59
|
+
flags: "a"
|
|
60
|
+
});
|
|
61
|
+
writer.on("error", (error) => {
|
|
62
|
+
console.warn(`[daemon] Log file write error (${options.logPath}): ${error.message}`);
|
|
63
|
+
if (context.writer === writer) {
|
|
64
|
+
context.writer = void 0;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
context.writer = writer;
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.warn(`[daemon] Failed to open log file ${options.logPath}: ${error.message}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return context;
|
|
73
|
+
}
|
|
74
|
+
function logEvent(context, message) {
|
|
75
|
+
if (!context.enabled) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const line = `[daemon] ${(/* @__PURE__ */ new Date()).toISOString()} ${message}`;
|
|
79
|
+
console.log(line);
|
|
80
|
+
try {
|
|
81
|
+
context.writer?.write(`${line}
|
|
82
|
+
`);
|
|
83
|
+
} catch {
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function disposeLogContext(context) {
|
|
87
|
+
const writer = context.writer;
|
|
88
|
+
if (!writer) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
await new Promise((resolve) => {
|
|
92
|
+
writer.end(() => resolve());
|
|
93
|
+
writer.on("error", () => resolve());
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// node_modules/.pnpm/mcporter@0.13.10/node_modules/mcporter/dist/daemon/host.js
|
|
98
|
+
async function runDaemonHost(options) {
|
|
99
|
+
await secureDaemonDirectory();
|
|
100
|
+
await assertLegacyDrained();
|
|
101
|
+
const key = await daemonKey();
|
|
102
|
+
const canonical = await canonicalUserConfiguration();
|
|
103
|
+
const broker = new DaemonBroker(canonical.definitions);
|
|
104
|
+
const log = createLogContext({
|
|
105
|
+
enabled: Boolean(options.logPath),
|
|
106
|
+
logPath: options.logPath,
|
|
107
|
+
logAllServers: options.logAllServers ?? false,
|
|
108
|
+
servers: options.logServers ?? /* @__PURE__ */ new Set()
|
|
109
|
+
});
|
|
110
|
+
const startedAt = Date.now();
|
|
111
|
+
const status = () => ({
|
|
112
|
+
pid: process.pid,
|
|
113
|
+
protocolVersion: DAEMON_PROTOCOL_VERSION,
|
|
114
|
+
startedAt,
|
|
115
|
+
configPath: "",
|
|
116
|
+
socketPath: options.socketPath,
|
|
117
|
+
logPath: options.logPath,
|
|
118
|
+
...broker.status(),
|
|
119
|
+
idleTimeoutMs: canonical.idleTimeoutMs,
|
|
120
|
+
idleShutdownBlocked: !broker.canIdleShutdown()
|
|
121
|
+
});
|
|
122
|
+
let shuttingDown = false;
|
|
123
|
+
let closing;
|
|
124
|
+
let lastActivity = Date.now();
|
|
125
|
+
let idleTimer;
|
|
126
|
+
const scheduleIdle = () => {
|
|
127
|
+
clearTimeout(idleTimer);
|
|
128
|
+
if (!canonical.idleTimeoutMs || shuttingDown)
|
|
129
|
+
return;
|
|
130
|
+
idleTimer = setTimeout(checkIdle, idleTimerDelay(canonical.idleTimeoutMs, lastActivity));
|
|
131
|
+
idleTimer.unref();
|
|
132
|
+
};
|
|
133
|
+
const checkIdle = () => {
|
|
134
|
+
if (shuttingDown || !canonical.idleTimeoutMs)
|
|
135
|
+
return;
|
|
136
|
+
if (Date.now() - lastActivity >= canonical.idleTimeoutMs && broker.canIdleShutdown()) {
|
|
137
|
+
void close().catch(() => logEvent(log, "idle shutdown blocked: transport retirement failed"));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
scheduleIdle();
|
|
141
|
+
};
|
|
142
|
+
const onSignal = () => {
|
|
143
|
+
void close().catch(() => {
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
const close = () => {
|
|
147
|
+
closing ??= (async () => {
|
|
148
|
+
await broker.close();
|
|
149
|
+
shuttingDown = true;
|
|
150
|
+
clearTimeout(idleTimer);
|
|
151
|
+
process.off("SIGINT", onSignal);
|
|
152
|
+
process.off("SIGTERM", onSignal);
|
|
153
|
+
server.close();
|
|
154
|
+
await cleanupDaemonArtifactsIfOwned(options, process.pid);
|
|
155
|
+
await disposeLogContext(log);
|
|
156
|
+
key.fill(0);
|
|
157
|
+
})().catch((error) => {
|
|
158
|
+
closing = void 0;
|
|
159
|
+
throw error;
|
|
160
|
+
});
|
|
161
|
+
return closing;
|
|
162
|
+
};
|
|
163
|
+
const server = net.createServer((socket) => {
|
|
164
|
+
const frames = new SocketFrames(socket);
|
|
165
|
+
socket.setTimeout(3e4, () => socket.destroy());
|
|
166
|
+
void (async () => {
|
|
167
|
+
try {
|
|
168
|
+
await authenticateServer(frames, key);
|
|
169
|
+
} catch {
|
|
170
|
+
socket.destroy();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
let timer;
|
|
174
|
+
let id = "invalid";
|
|
175
|
+
try {
|
|
176
|
+
const request = await frames.read();
|
|
177
|
+
id = typeof request?.id === "string" && request.id.length <= 256 ? request.id : "invalid";
|
|
178
|
+
if (id === "invalid" || !request || typeof request.params !== "object" || !request.params)
|
|
179
|
+
throw new BrokerError("invalid_request", "Invalid daemon request.");
|
|
180
|
+
if (request.protocolVersion !== DAEMON_PROTOCOL_VERSION)
|
|
181
|
+
throw new BrokerError("incompatible_daemon", "Upgrade all invoking clients before cutover.");
|
|
182
|
+
socket.setTimeout(0);
|
|
183
|
+
lastActivity = Date.now();
|
|
184
|
+
scheduleIdle();
|
|
185
|
+
if (typeof request.progressIntervalMs === "number" && Number.isFinite(request.progressIntervalMs))
|
|
186
|
+
timer = setInterval(() => {
|
|
187
|
+
if (!socket.destroyed)
|
|
188
|
+
frames.write({ type: "progress", id });
|
|
189
|
+
}, resolveProgressInterval(request.progressIntervalMs));
|
|
190
|
+
let result;
|
|
191
|
+
let notices = [];
|
|
192
|
+
switch (request.method) {
|
|
193
|
+
case "status":
|
|
194
|
+
result = status();
|
|
195
|
+
break;
|
|
196
|
+
case "registerView":
|
|
197
|
+
result = broker.register(request.params);
|
|
198
|
+
break;
|
|
199
|
+
case "releaseView":
|
|
200
|
+
broker.release(request);
|
|
201
|
+
result = true;
|
|
202
|
+
break;
|
|
203
|
+
case "stop":
|
|
204
|
+
await close();
|
|
205
|
+
result = true;
|
|
206
|
+
break;
|
|
207
|
+
default:
|
|
208
|
+
logEvent(log, `${request.method} start`);
|
|
209
|
+
({ result, notices } = await broker.invokeWithNotices(request));
|
|
210
|
+
logEvent(log, `${request.method} success`);
|
|
211
|
+
}
|
|
212
|
+
frames.write({ id, ok: true, result, notices });
|
|
213
|
+
socket.end();
|
|
214
|
+
} catch (error) {
|
|
215
|
+
const code = error && typeof error === "object" && "code" in error ? String(error.code) : "runtime_error";
|
|
216
|
+
const message = error instanceof BrokerError || error instanceof ProcessObservationError || code === "browser_owner_conflict" ? error.message : `MCP operation failed (${code}); the request was not replayed.`;
|
|
217
|
+
frames.write({ id, ok: false, error: { code, message } });
|
|
218
|
+
socket.end();
|
|
219
|
+
} finally {
|
|
220
|
+
lastActivity = Date.now();
|
|
221
|
+
scheduleIdle();
|
|
222
|
+
if (timer)
|
|
223
|
+
clearInterval(timer);
|
|
224
|
+
}
|
|
225
|
+
})().catch(() => socket.destroy());
|
|
226
|
+
});
|
|
227
|
+
let claimed = false;
|
|
228
|
+
await withFileLock(options.metadataPath, async () => {
|
|
229
|
+
let live;
|
|
230
|
+
try {
|
|
231
|
+
const response = await requestDaemon(options.socketPath, { id: randomUUID(), method: "status", params: {}, protocolVersion: DAEMON_PROTOCOL_VERSION }, 1e3);
|
|
232
|
+
if (!response.ok || response.result?.protocolVersion !== DAEMON_PROTOCOL_VERSION)
|
|
233
|
+
throw new Error("Incompatible daemon owns the socket.");
|
|
234
|
+
live = response.result;
|
|
235
|
+
} catch (error) {
|
|
236
|
+
const code = error.code;
|
|
237
|
+
if (code !== "ENOENT" && code !== "ECONNREFUSED")
|
|
238
|
+
throw error;
|
|
239
|
+
}
|
|
240
|
+
if (live) {
|
|
241
|
+
await writeJsonFile(options.metadataPath, live);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const metadata = await fs.readFile(options.metadataPath, "utf8").then((value) => JSON.parse(value)).catch((error) => {
|
|
245
|
+
if (error.code !== "ENOENT")
|
|
246
|
+
throw error;
|
|
247
|
+
return void 0;
|
|
248
|
+
});
|
|
249
|
+
if (metadata)
|
|
250
|
+
throw new BrokerError("daemon_unresponsive", "Previous daemon retirement is unverified; inspect its transports before deliberate recovery.");
|
|
251
|
+
if (process.platform !== "win32")
|
|
252
|
+
await fs.unlink(options.socketPath).catch((error) => {
|
|
253
|
+
if (error.code !== "ENOENT")
|
|
254
|
+
throw error;
|
|
255
|
+
});
|
|
256
|
+
await new Promise((resolve, reject) => {
|
|
257
|
+
server.once("error", reject);
|
|
258
|
+
server.listen(options.socketPath, () => {
|
|
259
|
+
server.off("error", reject);
|
|
260
|
+
resolve();
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
if (process.platform !== "win32")
|
|
264
|
+
await fs.chmod(options.socketPath, 384);
|
|
265
|
+
await writeJsonFile(options.metadataPath, status());
|
|
266
|
+
claimed = true;
|
|
267
|
+
});
|
|
268
|
+
if (!claimed) {
|
|
269
|
+
server.close();
|
|
270
|
+
await disposeLogContext(log);
|
|
271
|
+
key.fill(0);
|
|
272
|
+
return { close: async () => {
|
|
273
|
+
}, status };
|
|
274
|
+
}
|
|
275
|
+
process.once("SIGINT", onSignal);
|
|
276
|
+
process.once("SIGTERM", onSignal);
|
|
277
|
+
scheduleIdle();
|
|
278
|
+
return { close, status };
|
|
279
|
+
}
|
|
280
|
+
async function cleanupDaemonArtifactsIfOwned(paths, ownerPid) {
|
|
281
|
+
const metadata = await fs.readFile(paths.metadataPath, "utf8").then((raw) => JSON.parse(raw)).catch(() => void 0);
|
|
282
|
+
if (metadata?.pid !== ownerPid || metadata.socketPath !== paths.socketPath)
|
|
283
|
+
return;
|
|
284
|
+
if (process.platform !== "win32")
|
|
285
|
+
await fs.unlink(paths.socketPath).catch((error) => {
|
|
286
|
+
if (error.code !== "ENOENT")
|
|
287
|
+
throw error;
|
|
288
|
+
});
|
|
289
|
+
await fs.unlink(paths.metadataPath);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// node_modules/.pnpm/mcporter@0.13.10/node_modules/mcporter/dist/cli/daemon-command.js
|
|
293
|
+
async function handleDaemonCli(args, options) {
|
|
294
|
+
const subcommand = args.shift();
|
|
295
|
+
if (!subcommand || subcommand === "help" || subcommand === "--help") {
|
|
296
|
+
printDaemonHelp();
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const client = new DaemonClient({
|
|
300
|
+
configPath: options.configPath,
|
|
301
|
+
configExplicit: options.configExplicit,
|
|
302
|
+
rootDir: options.rootDir
|
|
303
|
+
});
|
|
304
|
+
if (subcommand === "migrate") {
|
|
305
|
+
if (args.includes("--stop-legacy")) {
|
|
306
|
+
if (!args.includes("--confirmed-drained"))
|
|
307
|
+
throw new Error("Drain all legacy clients first, then pass --confirmed-drained.");
|
|
308
|
+
await stopVerifiedLegacyDaemons();
|
|
309
|
+
console.log("Daemon directory permissions verified; legacy daemons and observed owned children have retired.");
|
|
310
|
+
} else
|
|
311
|
+
console.log(JSON.stringify((await legacyDaemons()).map(({ pid, verified }) => ({ pid, verified }))));
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
if (subcommand === "start") {
|
|
315
|
+
await handleDaemonStart(args, options, client);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
if (subcommand === "status") {
|
|
319
|
+
if (args.includes("--json"))
|
|
320
|
+
console.log(JSON.stringify(await client.status()));
|
|
321
|
+
else
|
|
322
|
+
await handleDaemonStatus(client);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (subcommand === "stop") {
|
|
326
|
+
await client.stop();
|
|
327
|
+
console.log("Daemon stopped (if it was running).");
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
if (subcommand === "restart") {
|
|
331
|
+
await handleDaemonRestart(args, options, client);
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
throw new Error(`Unknown daemon subcommand '${subcommand}'.`);
|
|
335
|
+
}
|
|
336
|
+
function printDaemonHelp() {
|
|
337
|
+
console.log(`Usage: mcporter daemon <start|status|stop|restart|migrate>
|
|
338
|
+
|
|
339
|
+
Commands:
|
|
340
|
+
start Start the single-user daemon (configuration views register on demand).
|
|
341
|
+
status Show whether the daemon is running and which servers are active.
|
|
342
|
+
stop Shut down the daemon and all managed servers.
|
|
343
|
+
restart Drain and stop the daemon, then start a fresh instance.
|
|
344
|
+
migrate Inspect legacy ownership without changing directory permissions.
|
|
345
|
+
--stop-legacy --confirmed-drained upgrades owned legacy 0755 directories
|
|
346
|
+
and retires verified owners (also works when old daemons are already stopped).
|
|
347
|
+
|
|
348
|
+
Flags:
|
|
349
|
+
--foreground Run the daemon in the current process (debug only).
|
|
350
|
+
--json Print machine-readable status.
|
|
351
|
+
--log Enable bounded operation logging (OS-user .mcporter/daemon/user.log).
|
|
352
|
+
--log-file <path> Write daemon stdout/stderr to a specific log file.
|
|
353
|
+
--log-servers <csv> Only log call activity for the listed servers (implies --log).`);
|
|
354
|
+
}
|
|
355
|
+
async function handleDaemonStart(args, options, client) {
|
|
356
|
+
const foregroundFlag = consumeFlag(args, "--foreground");
|
|
357
|
+
const isChildLaunch = process.env.MCPORTER_DAEMON_CHILD === "1";
|
|
358
|
+
const foreground = foregroundFlag || isChildLaunch;
|
|
359
|
+
const paths = resolveDaemonPaths(options.configPath);
|
|
360
|
+
const socketPath = paths.socketPath;
|
|
361
|
+
const metadataPath = paths.metadataPath;
|
|
362
|
+
await secureDaemonDirectory();
|
|
363
|
+
const logging = await resolveDaemonLoggingOptions(args, paths.key);
|
|
364
|
+
if (foreground) {
|
|
365
|
+
await runDaemonHost({
|
|
366
|
+
socketPath,
|
|
367
|
+
metadataPath,
|
|
368
|
+
configPath: options.configPath,
|
|
369
|
+
configExplicit: options.configExplicit,
|
|
370
|
+
rootDir: options.rootDir,
|
|
371
|
+
logPath: logging.enabled ? logging.logPath : void 0,
|
|
372
|
+
logServers: logging.serverFilter,
|
|
373
|
+
logAllServers: logging.logAllServers
|
|
374
|
+
});
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
const existing = await client.status();
|
|
378
|
+
if (existing) {
|
|
379
|
+
console.log(`Daemon already running (pid ${existing.pid}).`);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const forwardedArgs = [];
|
|
383
|
+
if (logging.enabled && logging.logPath) {
|
|
384
|
+
forwardedArgs.push("--log-file", logging.logPath);
|
|
385
|
+
}
|
|
386
|
+
if (logging.serverFilter.size > 0) {
|
|
387
|
+
forwardedArgs.push("--log-servers", Array.from(logging.serverFilter).join(","));
|
|
388
|
+
}
|
|
389
|
+
await launchDaemonDetached({
|
|
390
|
+
configPath: options.configPath,
|
|
391
|
+
configExplicit: options.configExplicit,
|
|
392
|
+
rootDir: options.rootDir,
|
|
393
|
+
metadataPath,
|
|
394
|
+
socketPath,
|
|
395
|
+
extraArgs: forwardedArgs
|
|
396
|
+
});
|
|
397
|
+
await waitForDaemonReady((timeoutMs) => client.status(timeoutMs));
|
|
398
|
+
console.log("Single-user daemon started.");
|
|
399
|
+
}
|
|
400
|
+
async function handleDaemonRestart(args, options, client) {
|
|
401
|
+
await client.stop();
|
|
402
|
+
console.log("Daemon stopped (if it was running).");
|
|
403
|
+
const stopped = await waitFor(async () => {
|
|
404
|
+
const status = await client.status();
|
|
405
|
+
return status ? null : true;
|
|
406
|
+
}, 5e3, 100);
|
|
407
|
+
if (!stopped) {
|
|
408
|
+
throw new Error("Daemon did not stop before restart could begin.");
|
|
409
|
+
}
|
|
410
|
+
await handleDaemonStart(args, options, client);
|
|
411
|
+
}
|
|
412
|
+
async function handleDaemonStatus(client) {
|
|
413
|
+
const status = await client.status();
|
|
414
|
+
if (!status) {
|
|
415
|
+
console.log("Daemon is not running.");
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
console.log(`Daemon pid ${status.pid} \u2014 socket: ${status.socketPath}`);
|
|
419
|
+
if (status.logPath) {
|
|
420
|
+
console.log(`Log file: ${status.logPath}`);
|
|
421
|
+
}
|
|
422
|
+
if (status.servers.length === 0) {
|
|
423
|
+
console.log("No keep-alive servers registered.");
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
status.servers.forEach((server) => {
|
|
427
|
+
const state = server.connected ? "connected" : "idle";
|
|
428
|
+
const lastUsed = server.lastUsedAt ? ` (last used ${new Date(server.lastUsedAt).toISOString()})` : "";
|
|
429
|
+
console.log(`- ${server.name}: ${state}${lastUsed}`);
|
|
430
|
+
if (server.chromeDevtoolsRelay) {
|
|
431
|
+
const relay = server.chromeDevtoolsRelay;
|
|
432
|
+
const endpoint = relay.endpoint ? ` endpoint=${relay.endpoint}` : "";
|
|
433
|
+
const probe = relay.probeDurationMs === void 0 ? "" : ` probe=${relay.probeStatus ?? "no-status"}/${relay.probeDurationMs}ms`;
|
|
434
|
+
console.log(` chrome relay: route=${relay.route} policy=${relay.policy} reason=${relay.reason}${endpoint}${probe}`);
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
function consumeFlag(args, flag) {
|
|
439
|
+
const index = args.indexOf(flag);
|
|
440
|
+
if (index === -1) {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
args.splice(index, 1);
|
|
444
|
+
return true;
|
|
445
|
+
}
|
|
446
|
+
function consumeValueFlag(args, flag) {
|
|
447
|
+
const index = args.indexOf(flag);
|
|
448
|
+
if (index === -1) {
|
|
449
|
+
return void 0;
|
|
450
|
+
}
|
|
451
|
+
if (index + 1 >= args.length) {
|
|
452
|
+
throw new Error(`Flag '${flag}' requires a value.`);
|
|
453
|
+
}
|
|
454
|
+
const value = args[index + 1];
|
|
455
|
+
args.splice(index, 2);
|
|
456
|
+
return value;
|
|
457
|
+
}
|
|
458
|
+
async function waitFor(probe, timeoutMs, intervalMs) {
|
|
459
|
+
const deadline = Date.now() + timeoutMs;
|
|
460
|
+
while (Date.now() < deadline) {
|
|
461
|
+
const result = await probe();
|
|
462
|
+
if (result) {
|
|
463
|
+
return result;
|
|
464
|
+
}
|
|
465
|
+
await delay(intervalMs);
|
|
466
|
+
}
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
function delay(ms) {
|
|
470
|
+
return new Promise((resolve) => {
|
|
471
|
+
setTimeout(resolve, ms);
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
async function resolveDaemonLoggingOptions(args, configKey) {
|
|
475
|
+
const logFlag = consumeFlag(args, "--log");
|
|
476
|
+
const logFileValue = consumeValueFlag(args, "--log-file");
|
|
477
|
+
const logServersValue = consumeValueFlag(args, "--log-servers");
|
|
478
|
+
const envLogEnabled = process.env.MCPORTER_DAEMON_LOG === "1";
|
|
479
|
+
const envLogPath = process.env.MCPORTER_DAEMON_LOG_PATH;
|
|
480
|
+
const envLogServers = process.env.MCPORTER_DAEMON_LOG_SERVERS;
|
|
481
|
+
const serverFilter = parseServerList(logServersValue ?? envLogServers);
|
|
482
|
+
const explicitServerLogging = serverFilter.size > 0;
|
|
483
|
+
const resolvedFileFlag = logFileValue ? path2.resolve(expandHome(logFileValue)) : void 0;
|
|
484
|
+
const resolvedEnvFile = envLogPath ? path2.resolve(expandHome(envLogPath)) : void 0;
|
|
485
|
+
const enabled = logFlag || Boolean(resolvedFileFlag) || envLogEnabled || Boolean(resolvedEnvFile) || explicitServerLogging;
|
|
486
|
+
if (!enabled) {
|
|
487
|
+
return {
|
|
488
|
+
enabled: false,
|
|
489
|
+
logPath: void 0,
|
|
490
|
+
logAllServers: false,
|
|
491
|
+
serverFilter
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
const logPath = resolvedFileFlag ?? resolvedEnvFile ?? getDaemonLogPath(configKey);
|
|
495
|
+
await fsPromises.mkdir(path2.dirname(logPath), { recursive: true });
|
|
496
|
+
return {
|
|
497
|
+
enabled: true,
|
|
498
|
+
logPath,
|
|
499
|
+
logAllServers: serverFilter.size === 0,
|
|
500
|
+
serverFilter
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
function parseServerList(value) {
|
|
504
|
+
if (!value) {
|
|
505
|
+
return /* @__PURE__ */ new Set();
|
|
506
|
+
}
|
|
507
|
+
const entries = value.split(",").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
|
|
508
|
+
return new Set(entries);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export {
|
|
512
|
+
handleDaemonCli
|
|
513
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
|
|
3
|
-
// node_modules/.pnpm/mcporter@0.13.
|
|
3
|
+
// node_modules/.pnpm/mcporter@0.13.10/node_modules/mcporter/dist/cli/errors.js
|
|
4
4
|
var CliUsageError = class extends Error {
|
|
5
5
|
constructor(message) {
|
|
6
6
|
super(message);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
expandHome
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EP22XMWK.js";
|
|
5
5
|
|
|
6
|
-
// node_modules/.pnpm/mcporter@0.13.
|
|
6
|
+
// node_modules/.pnpm/mcporter@0.13.10/node_modules/mcporter/dist/paths.js
|
|
7
7
|
import os from "node:os";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
var XDG_HOME_ENV = {
|
|
@@ -25,11 +25,11 @@ function mcporterDir(kind) {
|
|
|
25
25
|
}
|
|
26
26
|
return legacyMcporterDir();
|
|
27
27
|
}
|
|
28
|
-
function mcporterConfigCandidates() {
|
|
29
|
-
const
|
|
28
|
+
function mcporterConfigCandidates(context) {
|
|
29
|
+
const legacy = context ? path.join(context.home, ".mcporter") : legacyMcporterDir();
|
|
30
|
+
const base = context ? context.configHome ? path.join(context.configHome, "mcporter") : legacy : mcporterDir("config");
|
|
30
31
|
const candidates = [path.join(base, "mcporter.json"), path.join(base, "mcporter.jsonc")];
|
|
31
|
-
if (base !==
|
|
32
|
-
const legacy = legacyMcporterDir();
|
|
32
|
+
if (base !== legacy) {
|
|
33
33
|
candidates.push(path.join(legacy, "mcporter.json"), path.join(legacy, "mcporter.jsonc"));
|
|
34
34
|
}
|
|
35
35
|
return candidates;
|
|
@@ -7,26 +7,31 @@ import {
|
|
|
7
7
|
reconcilePersistedTokens,
|
|
8
8
|
withRefreshLock,
|
|
9
9
|
withRefreshRequestTimeout
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-Z6QEOUMK.js";
|
|
11
11
|
import {
|
|
12
|
+
runtimeEnvironment,
|
|
12
13
|
sameOAuthTokenGeneration
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-YI5SMRFH.js";
|
|
14
15
|
import {
|
|
15
|
-
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
isFileLockTimeoutError
|
|
17
|
+
} from "./chunk-QIBGY4IX.js";
|
|
18
|
+
import {
|
|
19
|
+
analyzeConnectionError
|
|
20
|
+
} from "./chunk-GL4AA5QV.js";
|
|
17
21
|
import {
|
|
18
22
|
IssuerMismatchError,
|
|
19
23
|
auth,
|
|
20
24
|
validateClientMetadataUrl
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import {
|
|
23
|
-
suppressBrowserLaunchFromEnv
|
|
24
|
-
} from "./chunk-DTZHEVKC.js";
|
|
25
|
-
import {
|
|
26
|
-
isFileLockTimeoutError
|
|
27
|
-
} from "./chunk-ITR7FQM3.js";
|
|
25
|
+
} from "./chunk-CN5YF3IQ.js";
|
|
28
26
|
|
|
29
|
-
// node_modules/.pnpm/mcporter@0.13.
|
|
27
|
+
// node_modules/.pnpm/mcporter@0.13.10/node_modules/mcporter/dist/oauth-browser-suppression.js
|
|
28
|
+
var TRUE_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes"]);
|
|
29
|
+
function suppressBrowserLaunchFromEnv(env = runtimeEnvironment()) {
|
|
30
|
+
const raw = env.MCPORTER_OAUTH_NO_BROWSER;
|
|
31
|
+
return raw !== void 0 && TRUE_VALUES.has(raw.trim().toLowerCase());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// node_modules/.pnpm/mcporter@0.13.10/node_modules/mcporter/dist/oauth.js
|
|
30
35
|
import { spawn } from "node:child_process";
|
|
31
36
|
import { createHash, randomUUID } from "node:crypto";
|
|
32
37
|
import http from "node:http";
|
|
@@ -75,6 +80,8 @@ function openExternal(url, platform = process.platform, launch = spawn) {
|
|
|
75
80
|
try {
|
|
76
81
|
if (platform === "darwin") {
|
|
77
82
|
const child = launch("open", [url], { stdio, detached: true });
|
|
83
|
+
child.on("error", () => {
|
|
84
|
+
});
|
|
78
85
|
child.unref();
|
|
79
86
|
} else if (platform === "win32") {
|
|
80
87
|
const child = launch("rundll32", ["url.dll,FileProtocolHandler", url], {
|
|
@@ -82,6 +89,8 @@ function openExternal(url, platform = process.platform, launch = spawn) {
|
|
|
82
89
|
detached: true,
|
|
83
90
|
windowsHide: true
|
|
84
91
|
});
|
|
92
|
+
child.on("error", () => {
|
|
93
|
+
});
|
|
85
94
|
child.unref();
|
|
86
95
|
} else {
|
|
87
96
|
try {
|
|
@@ -537,7 +546,26 @@ var __oauthInternals = {
|
|
|
537
546
|
openExternal
|
|
538
547
|
};
|
|
539
548
|
|
|
540
|
-
// node_modules/.pnpm/mcporter@0.13.
|
|
549
|
+
// node_modules/.pnpm/mcporter@0.13.10/node_modules/mcporter/dist/runtime-oauth-support.js
|
|
550
|
+
function maybeEnableOAuth(definition, logger) {
|
|
551
|
+
if (definition.auth === "oauth" || definition.auth === "refreshable_bearer") {
|
|
552
|
+
return void 0;
|
|
553
|
+
}
|
|
554
|
+
if (definition.command.kind !== "http") {
|
|
555
|
+
return void 0;
|
|
556
|
+
}
|
|
557
|
+
logger.info(`Detected OAuth requirement for '${definition.name}'. Launching browser flow...`);
|
|
558
|
+
return {
|
|
559
|
+
...definition,
|
|
560
|
+
auth: "oauth"
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
function isUnauthorizedError(error) {
|
|
564
|
+
const issue = analyzeConnectionError(error);
|
|
565
|
+
return issue.kind === "auth";
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// node_modules/.pnpm/mcporter@0.13.10/node_modules/mcporter/dist/runtime/oauth.js
|
|
541
569
|
var DEFAULT_OAUTH_CODE_TIMEOUT_MS = 3e5;
|
|
542
570
|
var OAUTH_FLOW_ERROR = /* @__PURE__ */ Symbol("oauth-flow-error");
|
|
543
571
|
var POST_AUTH_CONNECT_ERROR = /* @__PURE__ */ Symbol("post-auth-connect-error");
|
|
@@ -810,11 +838,14 @@ function parseOAuthTimeout(raw) {
|
|
|
810
838
|
return parsed;
|
|
811
839
|
}
|
|
812
840
|
function resolveOAuthTimeoutFromEnv() {
|
|
813
|
-
return parseOAuthTimeout(
|
|
841
|
+
return parseOAuthTimeout(runtimeEnvironment().MCPORTER_OAUTH_TIMEOUT_MS ?? runtimeEnvironment().MCPORTER_OAUTH_TIMEOUT);
|
|
814
842
|
}
|
|
815
843
|
|
|
816
844
|
export {
|
|
845
|
+
suppressBrowserLaunchFromEnv,
|
|
817
846
|
createOAuthSession,
|
|
847
|
+
maybeEnableOAuth,
|
|
848
|
+
isUnauthorizedError,
|
|
818
849
|
OAuthTimeoutError,
|
|
819
850
|
isOAuthFlowError,
|
|
820
851
|
isPostAuthConnectError,
|