codexpanel 0.1.1 → 0.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/codexpanel.cjs +24 -8
  2. package/package.json +1 -1
@@ -11,7 +11,7 @@ const crypto = require("crypto");
11
11
  const readline = require("readline");
12
12
  const { spawn, spawnSync } = require("child_process");
13
13
 
14
- const VERSION = "0.1.1";
14
+ const VERSION = "0.1.2";
15
15
  const PROD_URL = "https://codexpanel.com";
16
16
  const TEST_URL = "https://jd.6a.gs";
17
17
  const LOCAL_HOST = "127.0.0.1";
@@ -246,7 +246,14 @@ function powershellPath() {
246
246
 
247
247
  function openBrowser(url) {
248
248
  const target = String(url);
249
- if (process.platform === "win32") return spawn("cmd.exe", ["/c", "start", "", target], { detached: true, stdio: "ignore", windowsHide: true }).unref();
249
+ if (process.platform === "win32") return spawn(powershellPath(), [
250
+ "-NoProfile",
251
+ "-ExecutionPolicy",
252
+ "Bypass",
253
+ "-Command",
254
+ "Start-Process -FilePath $args[0]",
255
+ target,
256
+ ], { detached: true, stdio: "ignore", windowsHide: true }).unref();
250
257
  if (process.platform === "darwin") return spawn("open", [target], { detached: true, stdio: "ignore" }).unref();
251
258
  return spawn("xdg-open", [target], { detached: true, stdio: "ignore" }).unref();
252
259
  }
@@ -337,13 +344,22 @@ function powershellCommand(url) {
337
344
 
338
345
  async function pollSetup(relayUrl, flowId, flowSecret) {
339
346
  const started = Date.now();
347
+ let transientFailures = 0;
340
348
  while (Date.now() - started < 10 * 60 * 1000) {
341
- const result = await requestJson("POST", relayUrl, "/api/desktop/setup/poll", { flowId, flowSecret }, {}, 30000);
342
- if (result.status === "approved") return result;
343
- if (result.status === "rejected") throw new Error(result.error || "Setup was rejected in the browser.");
344
- if (result.status === "expired") throw new Error("Setup login expired. Run npx -y codexpanel again.");
345
- const hint = result.message || "等待浏览器登录绑定 / Waiting for browser sign-in";
346
- process.stdout.write(`\rCodexPanel: ${hint}... `);
349
+ try {
350
+ const result = await requestJson("POST", relayUrl, "/api/desktop/setup/poll", { flowId, flowSecret }, {}, 30000);
351
+ transientFailures = 0;
352
+ if (result.status === "approved") return result;
353
+ if (result.status === "rejected") throw new Error(result.error || "Setup was rejected in the browser.");
354
+ if (result.status === "expired") throw new Error("Setup login expired. Run npx -y codexpanel again.");
355
+ const hint = result.message || "等待浏览器登录绑定 / Waiting for browser sign-in";
356
+ process.stdout.write(`\rCodexPanel: ${hint}... `);
357
+ } catch (error) {
358
+ if (![429, 502, 503, 504].includes(Number(error.statusCode))) throw error;
359
+ transientFailures += 1;
360
+ const detail = error.data?.error || error.data?.raw || error.message || `HTTP ${error.statusCode}`;
361
+ process.stdout.write(`\rCodexPanel: 服务端暂时不可用,正在重试 / Server temporarily unavailable, retrying (${error.statusCode}, ${transientFailures}): ${detail} `);
362
+ }
347
363
  await new Promise((resolve) => setTimeout(resolve, 2000));
348
364
  }
349
365
  throw new Error("Setup login timed out after 10 minutes.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codexpanel",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "CodexPanel mobile control plane monorepo.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,