@useorgx/wizard 0.1.1 → 0.1.3

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/cli.js CHANGED
@@ -578,15 +578,12 @@ async function checkOrgxAuth(options = {}) {
578
578
  ok: false,
579
579
  skipped: true,
580
580
  source: "none",
581
- error: "No OrgX API key found in ORGX_API_KEY, the wizard auth store, or OpenClaw config.",
581
+ error: "No OrgX account connected. Run `orgx-wizard auth login` to connect.",
582
582
  url: buildOrgxApiUrl("/client/sync", DEFAULT_ORGX_BASE_URL)
583
583
  };
584
584
  }
585
585
  return verifyOrgxAuth(auth);
586
586
  }
587
- function describeSetupStatusScope() {
588
- return "The setup-status endpoint is still service-key-only and uses ORGX_SERVICE_KEY.";
589
- }
590
587
 
591
588
  // src/lib/browser-auth.ts
592
589
  function asString(value) {
@@ -745,48 +742,6 @@ function openBrowser(url) {
745
742
  return { ok: true };
746
743
  }
747
744
 
748
- // src/lib/setup-status.ts
749
- async function fetchSetupStatus(apiKey = process.env.ORGX_SERVICE_KEY?.trim()) {
750
- if (!apiKey) {
751
- return {
752
- ok: false,
753
- skipped: true,
754
- error: "ORGX_SERVICE_KEY is not set; /api/setup/status is a service-level check and was skipped.",
755
- url: ORGX_SETUP_STATUS_URL
756
- };
757
- }
758
- try {
759
- const response = await fetch(ORGX_SETUP_STATUS_URL, {
760
- headers: {
761
- Authorization: `Bearer ${apiKey}`
762
- },
763
- signal: AbortSignal.timeout(7e3)
764
- });
765
- const text2 = await response.text();
766
- let data = text2;
767
- try {
768
- data = text2.length > 0 ? JSON.parse(text2) : null;
769
- } catch {
770
- data = text2;
771
- }
772
- return {
773
- ok: response.ok,
774
- skipped: false,
775
- status: response.status,
776
- data,
777
- url: ORGX_SETUP_STATUS_URL,
778
- ...response.ok ? {} : { error: `HTTP ${response.status}` }
779
- };
780
- } catch (error) {
781
- return {
782
- ok: false,
783
- skipped: false,
784
- error: error instanceof Error ? error.message : String(error),
785
- url: ORGX_SETUP_STATUS_URL
786
- };
787
- }
788
- }
789
-
790
745
  // src/lib/openclaw-health.ts
791
746
  import { spawnSync as spawnSync2 } from "child_process";
792
747
  function trimOutput(value) {
@@ -2288,9 +2243,8 @@ async function runDoctor() {
2288
2243
  const hostedMcpTool = await checkHostedMcpToolAccess();
2289
2244
  const npmRegistry = await checkNpmRegistryHealth();
2290
2245
  const workspace = await checkWorkspaceConnectivity();
2291
- const remote = await fetchSetupStatus();
2292
2246
  const openclaw = openclawSurface?.detected ? await checkOpenClawHealth(openclawSurface.path) : skippedOpenClawHealth();
2293
- return { surfaces, auth, hostedMcp, hostedMcpTool, npmRegistry, workspace, remote, openclaw };
2247
+ return { surfaces, auth, hostedMcp, hostedMcpTool, npmRegistry, workspace, openclaw };
2294
2248
  }
2295
2249
  function assessDoctorReport(report) {
2296
2250
  const issues = [];
@@ -2342,13 +2296,6 @@ function assessDoctorReport(report) {
2342
2296
  suggestion: "Run `openclaw doctor` or `openclaw doctor --repair` before relying on local bridge clients like Cursor."
2343
2297
  });
2344
2298
  }
2345
- if (!report.remote.skipped && !report.remote.ok) {
2346
- issues.push({
2347
- level: "warning",
2348
- title: "Remote setup status check failed.",
2349
- suggestion: "If you expected the service-key check to pass, verify ORGX_SERVICE_KEY before trusting setup-status output."
2350
- });
2351
- }
2352
2299
  return {
2353
2300
  ok: !issues.some((issue) => issue.level === "error"),
2354
2301
  issues
@@ -3383,24 +3330,6 @@ function printAuthStatus(status) {
3383
3330
  console.log(` error: ${status.error}`);
3384
3331
  }
3385
3332
  }
3386
- function printRemoteSetupStatus(status) {
3387
- if (status.skipped) {
3388
- console.log(pc3.yellow(status.error ?? "Remote setup check skipped."));
3389
- console.log(pc3.dim(describeSetupStatusScope()));
3390
- return;
3391
- }
3392
- if (!status.ok) {
3393
- console.log(pc3.red(`Remote setup check failed: ${status.error ?? "unknown error"}`));
3394
- if (status.status) {
3395
- console.log(`status: ${status.status}`);
3396
- }
3397
- return;
3398
- }
3399
- console.log(pc3.green(`Remote setup check passed via ${status.url}`));
3400
- if (status.data) {
3401
- console.log(JSON.stringify(status.data, null, 2));
3402
- }
3403
- }
3404
3333
  function printWorkspaceConnectivity(check) {
3405
3334
  console.log(pc3.bold("workspace connectivity"));
3406
3335
  if (!check.configured) {
@@ -3487,8 +3416,6 @@ async function main() {
3487
3416
  console.log("");
3488
3417
  printOpenClawHealth(doctor2.openclaw);
3489
3418
  console.log("");
3490
- printRemoteSetupStatus(doctor2.remote);
3491
- console.log("");
3492
3419
  const assessment2 = assessDoctorReport(doctor2);
3493
3420
  printDoctorAssessment(assessment2);
3494
3421
  if (!assessment2.ok) {
@@ -3501,12 +3428,34 @@ async function main() {
3501
3428
  const results = await setupDetectedSurfaces();
3502
3429
  spinner.succeed("Detected surfaces configured");
3503
3430
  printMutationResults(results);
3504
- const resolvedAuth = await resolveOrgxAuth();
3431
+ let resolvedAuth = await resolveOrgxAuth();
3505
3432
  if (!resolvedAuth) {
3506
3433
  console.log("");
3507
- console.log(
3508
- `${pc3.yellow("No OrgX API key configured.")} Run ${pc3.cyan("orgx-wizard auth login")} to connect your account and enable workspace + tool access.`
3509
- );
3434
+ const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY);
3435
+ if (interactive) {
3436
+ const choice = await selectPrompt({
3437
+ message: "Connect your OrgX account to enable workspace and AI tool access",
3438
+ options: [
3439
+ { value: "login", label: "Open browser to connect", hint: "recommended" },
3440
+ { value: "skip", label: "Skip for now", hint: "run `orgx-wizard auth login` later" }
3441
+ ]
3442
+ });
3443
+ if (!clack.isCancel(choice) && choice === "login") {
3444
+ const loginOk = await runBrowserLogin();
3445
+ if (loginOk) {
3446
+ resolvedAuth = await resolveOrgxAuth();
3447
+ }
3448
+ } else if (clack.isCancel(choice)) {
3449
+ clack.cancel("Setup cancelled.");
3450
+ return;
3451
+ } else {
3452
+ console.log(pc3.dim(`Run ${pc3.cyan("orgx-wizard auth login")} to connect later.`));
3453
+ }
3454
+ } else {
3455
+ console.log(
3456
+ `${pc3.yellow("No OrgX account connected.")} Run ${pc3.cyan("orgx-wizard auth login")} to connect.`
3457
+ );
3458
+ }
3510
3459
  }
3511
3460
  if (resolvedAuth) {
3512
3461
  console.log("");
@@ -3549,59 +3498,26 @@ async function main() {
3549
3498
  console.log("");
3550
3499
  printOpenClawHealth(doctor.openclaw);
3551
3500
  console.log("");
3552
- printRemoteSetupStatus(doctor.remote);
3553
- console.log("");
3554
3501
  const assessment = assessDoctorReport(doctor);
3555
3502
  printDoctorAssessment(assessment);
3556
3503
  if (!assessment.ok) {
3557
3504
  process.exitCode = 1;
3558
3505
  }
3559
3506
  });
3560
- const auth = program.command("auth").description("Manage OrgX API key auth for the wizard.");
3561
- auth.command("status").description("Show the resolved OrgX API key source and verify it against OrgX.").action(async () => {
3562
- const spinner = createOrgxSpinner("Checking OrgX auth");
3563
- spinner.start();
3564
- const status = await checkOrgxAuth();
3565
- spinner.stop();
3566
- printAuthStatus(status);
3567
- });
3568
- auth.command("login").description("Start browser pairing for OrgX auth, with direct API key fallback for CI and blocked browsers.").option("--api-key <key>", "Bypass browser pairing and verify this OrgX API key directly.").option("--base-url <url>", "OrgX base URL").option("--device-name <name>", "Device name shown during browser approval.").option("--no-open", "Do not automatically open the browser connect URL.").option("--timeout <seconds>", "How long to wait for browser pairing before giving up.", parseTimeoutSeconds, 600).action(async (options) => {
3569
- if (options.apiKey) {
3570
- const spinner2 = createOrgxSpinner("Verifying OrgX API key");
3571
- spinner2.start();
3572
- const result = await verifyAndPersistAuth(options.apiKey, options);
3573
- if (!("stored" in result)) {
3574
- spinner2.fail("OrgX API key verification failed");
3575
- printAuthStatus(result.verification);
3576
- return;
3577
- }
3578
- spinner2.succeed("OrgX API key verified and saved");
3579
- await syncContinuityAfterAuth();
3580
- printAuthStatus({
3581
- ...result.verification,
3582
- source: "wizard-store",
3583
- path: ORGX_WIZARD_AUTH_PATH,
3584
- verifiedAt: result.stored.verifiedAt
3585
- });
3586
- if (result.openclawResults.length > 0) {
3587
- console.log("");
3588
- printMutationResults(result.openclawResults);
3589
- }
3590
- return;
3591
- }
3507
+ async function runBrowserLogin(opts = {}) {
3592
3508
  const installationId = getOrCreateWizardInstallationId();
3593
3509
  const spinner = createOrgxSpinner("Starting OrgX browser pairing");
3594
3510
  spinner.start();
3595
3511
  try {
3596
3512
  const pairing = await startBrowserPairing({
3597
3513
  installationId,
3598
- baseUrl: options.baseUrl,
3599
- deviceName: options.deviceName ?? hostname(),
3514
+ baseUrl: opts.baseUrl,
3515
+ deviceName: opts.deviceName ?? hostname(),
3600
3516
  platform: process.platform
3601
3517
  });
3602
3518
  spinner.succeed("OrgX browser pairing started");
3603
3519
  console.log(`Open to continue: ${pairing.connectUrl}`);
3604
- if (options.open !== false) {
3520
+ if (opts.open !== false) {
3605
3521
  const openResult = openBrowser(pairing.connectUrl);
3606
3522
  if (!openResult.ok && openResult.error) {
3607
3523
  console.log(pc3.yellow(`Browser open failed: ${openResult.error}`));
@@ -3610,21 +3526,23 @@ async function main() {
3610
3526
  spinner.start();
3611
3527
  spinner.text = pc3.cyan("Waiting for OrgX browser approval");
3612
3528
  const ready = await waitForBrowserPairing({
3613
- baseUrl: options.baseUrl,
3529
+ baseUrl: opts.baseUrl,
3614
3530
  pairingId: pairing.pairingId,
3615
3531
  pollIntervalMs: pairing.pollIntervalMs,
3616
3532
  pollToken: pairing.pollToken,
3617
- timeoutMs: options.timeout * 1e3
3533
+ timeoutMs: (opts.timeout ?? 600) * 1e3
3618
3534
  });
3619
3535
  spinner.text = pc3.cyan("Verifying OrgX API key");
3620
- const result = await verifyAndPersistAuth(ready.key, options);
3536
+ const result = await verifyAndPersistAuth(ready.key, {
3537
+ ...opts.baseUrl !== void 0 ? { baseUrl: opts.baseUrl } : {}
3538
+ });
3621
3539
  if (!("stored" in result)) {
3622
3540
  spinner.fail("OrgX browser pairing delivered an invalid API key");
3623
3541
  printAuthStatus(result.verification);
3624
- return;
3542
+ return false;
3625
3543
  }
3626
3544
  await acknowledgeBrowserPairing({
3627
- baseUrl: options.baseUrl,
3545
+ baseUrl: opts.baseUrl,
3628
3546
  pairingId: pairing.pairingId,
3629
3547
  pollToken: pairing.pollToken
3630
3548
  }).catch((error) => {
@@ -3648,10 +3566,51 @@ async function main() {
3648
3566
  console.log("");
3649
3567
  printMutationResults(result.openclawResults);
3650
3568
  }
3569
+ return true;
3651
3570
  } catch (error) {
3652
3571
  spinner.fail("OrgX browser pairing failed");
3653
3572
  console.log(pc3.red(describeBrowserPairingFailure(error)));
3573
+ return false;
3574
+ }
3575
+ }
3576
+ const auth = program.command("auth").description("Manage OrgX API key auth for the wizard.");
3577
+ auth.command("status").description("Show the resolved OrgX API key source and verify it against OrgX.").action(async () => {
3578
+ const spinner = createOrgxSpinner("Checking OrgX auth");
3579
+ spinner.start();
3580
+ const status = await checkOrgxAuth();
3581
+ spinner.stop();
3582
+ printAuthStatus(status);
3583
+ });
3584
+ auth.command("login").description("Start browser pairing for OrgX auth, with direct API key fallback for CI and blocked browsers.").option("--api-key <key>", "Bypass browser pairing and verify this OrgX API key directly.").option("--base-url <url>", "OrgX base URL").option("--device-name <name>", "Device name shown during browser approval.").option("--no-open", "Do not automatically open the browser connect URL.").option("--timeout <seconds>", "How long to wait for browser pairing before giving up.", parseTimeoutSeconds, 600).action(async (options) => {
3585
+ if (options.apiKey) {
3586
+ const spinner = createOrgxSpinner("Verifying OrgX API key");
3587
+ spinner.start();
3588
+ const result = await verifyAndPersistAuth(options.apiKey, options);
3589
+ if (!("stored" in result)) {
3590
+ spinner.fail("OrgX API key verification failed");
3591
+ printAuthStatus(result.verification);
3592
+ return;
3593
+ }
3594
+ spinner.succeed("OrgX API key verified and saved");
3595
+ await syncContinuityAfterAuth();
3596
+ printAuthStatus({
3597
+ ...result.verification,
3598
+ source: "wizard-store",
3599
+ path: ORGX_WIZARD_AUTH_PATH,
3600
+ verifiedAt: result.stored.verifiedAt
3601
+ });
3602
+ if (result.openclawResults.length > 0) {
3603
+ console.log("");
3604
+ printMutationResults(result.openclawResults);
3605
+ }
3606
+ return;
3654
3607
  }
3608
+ await runBrowserLogin({
3609
+ ...options.baseUrl !== void 0 ? { baseUrl: options.baseUrl } : {},
3610
+ ...options.deviceName !== void 0 ? { deviceName: options.deviceName } : {},
3611
+ ...options.open !== void 0 ? { open: options.open } : {},
3612
+ timeout: options.timeout
3613
+ });
3655
3614
  });
3656
3615
  auth.command("set-key").description("Verify and persist a per-user OrgX API key for the wizard.").argument("<apiKey>", "per-user OrgX API key (oxk_...)").option("--base-url <url>", "OrgX base URL").action(async (apiKey, options) => {
3657
3616
  const spinner = createOrgxSpinner("Verifying OrgX API key");
@@ -3773,8 +3732,6 @@ async function main() {
3773
3732
  console.log("");
3774
3733
  printOpenClawHealth(report.openclaw);
3775
3734
  console.log("");
3776
- printRemoteSetupStatus(report.remote);
3777
- console.log("");
3778
3735
  const assessment = assessDoctorReport(report);
3779
3736
  printDoctorAssessment(assessment);
3780
3737
  if (!assessment.ok) {