@holin-work/holin-cli 1.1.1 → 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.
Files changed (2) hide show
  1. package/bin/holin-cli.js +36 -16
  2. 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();
@@ -246,9 +254,9 @@ async function cmdAuthLogin() {
246
254
  writeCredentials(creds);
247
255
  console.log(`[holin-cli] Connected: ${creds.customer_name || creds.customer_id} (${creds.plan})`);
248
256
 
249
- // Auto-start proxy in background (detached)
257
+ // Auto-start proxy in background (detached), wait until it's listening
250
258
  try {
251
- startProxyDaemon();
259
+ await startProxyDaemon();
252
260
  console.log("[holin-cli] Local proxy started at http://127.0.0.1:18787/mcp");
253
261
  } catch (err) {
254
262
  console.error(`[holin-cli] Warning: Failed to start local proxy — ${err.message}`);
@@ -329,23 +337,35 @@ function cmdProxyStart() {
329
337
  }
330
338
 
331
339
  function startProxyDaemon() {
332
- if (isProxyRunning()) return;
340
+ return new Promise((resolve, reject) => {
341
+ if (isProxyRunning()) {
342
+ resolve();
343
+ return;
344
+ }
333
345
 
334
- ensureConfigDir();
335
- const logFd = openSync(LOG_FILE, "a");
346
+ ensureConfigDir();
347
+ const logFd = openSync(LOG_FILE, "a");
336
348
 
337
- const child = spawn(process.execPath, [process.argv[1], "proxy", "start", "--daemon"], {
338
- detached: true,
339
- stdio: ["ignore", logFd, logFd],
340
- });
349
+ const child = spawn(process.execPath, [process.argv[1], "proxy", "start", "--daemon"], {
350
+ detached: true,
351
+ stdio: ["ignore", logFd, logFd],
352
+ });
341
353
 
342
- child.unref();
343
- // Give it a moment to start and write pid file
344
- setTimeout(() => {
345
- if (!isProxyRunning()) {
346
- console.error("[holin-cli] Warning: Proxy failed to start. Check log:", LOG_FILE);
347
- }
348
- }, 1000);
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
+ });
349
369
  }
350
370
 
351
371
  function cmdProxyStop() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holin-work/holin-cli",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Holin CLI — Accio plugin authorization tool for ICBU batch listing",
5
5
  "type": "module",
6
6
  "bin": {