@holin-work/holin-cli 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/holin-cli.js +39 -17
- package/package.json +1 -1
package/bin/holin-cli.js
CHANGED
|
@@ -123,6 +123,14 @@ async function pingVerify(apiKey) {
|
|
|
123
123
|
|
|
124
124
|
function createProxyServer() {
|
|
125
125
|
const server = http.createServer((req, res) => {
|
|
126
|
+
// Block OAuth discovery probes — return 404 so platform skips OAuth flow
|
|
127
|
+
if (req.url.startsWith("/.well-known/")) {
|
|
128
|
+
const body = JSON.stringify({ error: "not_found" });
|
|
129
|
+
res.writeHead(404, { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(body) });
|
|
130
|
+
res.end(body);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
126
134
|
// Health check endpoint
|
|
127
135
|
if (req.method === "GET" && req.url === "/health") {
|
|
128
136
|
const creds = readCredentials();
|
|
@@ -155,11 +163,13 @@ function createProxyServer() {
|
|
|
155
163
|
}
|
|
156
164
|
|
|
157
165
|
// Build upstream request
|
|
166
|
+
// MCP streamable-http has a single endpoint; forward directly to upstream path.
|
|
167
|
+
// Accio requests http://127.0.0.1:18787/mcp → upstream https://api.holin.work/icbu/mcp
|
|
158
168
|
const upstreamUrl = new URL(UPSTREAM_URL);
|
|
159
169
|
const options = {
|
|
160
170
|
hostname: upstreamUrl.hostname,
|
|
161
171
|
port: upstreamUrl.port || 443,
|
|
162
|
-
path: upstreamUrl.pathname
|
|
172
|
+
path: upstreamUrl.pathname,
|
|
163
173
|
method: req.method,
|
|
164
174
|
headers: {
|
|
165
175
|
...req.headers,
|
|
@@ -244,9 +254,9 @@ async function cmdAuthLogin() {
|
|
|
244
254
|
writeCredentials(creds);
|
|
245
255
|
console.log(`[holin-cli] Connected: ${creds.customer_name || creds.customer_id} (${creds.plan})`);
|
|
246
256
|
|
|
247
|
-
// Auto-start proxy in background (detached)
|
|
257
|
+
// Auto-start proxy in background (detached), wait until it's listening
|
|
248
258
|
try {
|
|
249
|
-
startProxyDaemon();
|
|
259
|
+
await startProxyDaemon();
|
|
250
260
|
console.log("[holin-cli] Local proxy started at http://127.0.0.1:18787/mcp");
|
|
251
261
|
} catch (err) {
|
|
252
262
|
console.error(`[holin-cli] Warning: Failed to start local proxy — ${err.message}`);
|
|
@@ -327,23 +337,35 @@ function cmdProxyStart() {
|
|
|
327
337
|
}
|
|
328
338
|
|
|
329
339
|
function startProxyDaemon() {
|
|
330
|
-
|
|
340
|
+
return new Promise((resolve, reject) => {
|
|
341
|
+
if (isProxyRunning()) {
|
|
342
|
+
resolve();
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
331
345
|
|
|
332
|
-
|
|
333
|
-
|
|
346
|
+
ensureConfigDir();
|
|
347
|
+
const logFd = openSync(LOG_FILE, "a");
|
|
334
348
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
349
|
+
const child = spawn(process.execPath, [process.argv[1], "proxy", "start", "--daemon"], {
|
|
350
|
+
detached: true,
|
|
351
|
+
stdio: ["ignore", logFd, logFd],
|
|
352
|
+
});
|
|
339
353
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
354
|
+
child.unref();
|
|
355
|
+
|
|
356
|
+
// Poll for pid file up to 3s to confirm proxy is listening
|
|
357
|
+
let attempts = 0;
|
|
358
|
+
const poll = setInterval(() => {
|
|
359
|
+
attempts++;
|
|
360
|
+
if (isProxyRunning()) {
|
|
361
|
+
clearInterval(poll);
|
|
362
|
+
resolve();
|
|
363
|
+
} else if (attempts >= 15) {
|
|
364
|
+
clearInterval(poll);
|
|
365
|
+
reject(new Error(`Proxy did not start within 3s. Check log: ${LOG_FILE}`));
|
|
366
|
+
}
|
|
367
|
+
}, 200);
|
|
368
|
+
});
|
|
347
369
|
}
|
|
348
370
|
|
|
349
371
|
function cmdProxyStop() {
|