zyntry-verdict 0.1.0 → 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/zv.mjs +84 -4
  2. package/package.json +2 -2
package/bin/zv.mjs CHANGED
@@ -381,6 +381,7 @@ async function cmdSignup(flags) {
381
381
  await saveConfig({ ...((await loadConfig()) ?? {}), key: body.key, gateway: gatewayUrl(flags) });
382
382
  console.log(GREEN("✓ key created") + ` — $${body.creditsUsd.toFixed(2)} trial credits`);
383
383
  console.log(` stored at ${CONFIG_PATH}`);
384
+ console.log(DIM(" next: zyntry-verdict cases · docs: https://verdict.zyntry.space/docs"));
384
385
  }
385
386
 
386
387
  async function cmdBalance(config, flags) {
@@ -420,18 +421,92 @@ async function cmdTopup(config, flags, positional) {
420
421
  console.error("usage: zyntry-verdict topup <amount 5-500> — credit top-up via Bachs hosted checkout");
421
422
  process.exit(2);
422
423
  }
424
+
425
+ // Create the checkout
423
426
  const body = await api(config, flags, "/v1/topups", {
424
427
  method: "POST",
425
428
  headers: authHeaders(config),
426
429
  body: JSON.stringify({ amountUsd: amount }),
427
430
  });
431
+
432
+ console.log("");
428
433
  console.log(GREEN("✓ checkout created") + ` — $${amount.toFixed(2)} · reference ${body.reference}`);
429
434
  console.log("");
430
- console.log(BOLD("Open this link to pay (card, bank transfer, mobile money, crypto):"));
431
- console.log(` ${GOLD(body.checkoutUrl)}`);
435
+
436
+ // Auto-open the browser
437
+ const url = body.checkoutUrl;
438
+ console.log(BOLD("Opening checkout page..."));
439
+ console.log(DIM(` ${url}`));
440
+ console.log("");
441
+
442
+ try {
443
+ const { exec } = await import("node:child_process");
444
+ const platform = process.platform;
445
+ if (platform === "win32") exec(`start "" "${url}"`);
446
+ else if (platform === "darwin") exec(`open "${url}"`);
447
+ else exec(`xdg-open "${url}"`);
448
+ } catch {
449
+ // if auto-open fails, the URL is printed above for manual access
450
+ }
451
+
452
+ // Wait for the payment to confirm (webhook fires, credits land)
453
+ console.log(BOLD("Waiting for payment..."));
454
+ console.log(DIM(" Complete the payment in your browser."));
455
+ console.log(DIM(" Credits land automatically once confirmed."));
456
+ console.log("");
457
+
458
+ const startTime = Date.now();
459
+ const timeoutMs = 5 * 60 * 1000; // 5 minutes
460
+ let dots = 0;
461
+
462
+ while (Date.now() - startTime < timeoutMs) {
463
+ await new Promise((r) => setTimeout(r, 2000));
464
+
465
+ // Animate waiting
466
+ dots = (dots + 1) % 4;
467
+ const dotStr = ".".repeat(dots) + " ".repeat(3 - dots);
468
+ process.stdout.write(`\r ${DIM("waiting for payment")} ${dotStr} ${DIM(Math.floor((Date.now() - startTime) / 1000) + "s")}`);
469
+
470
+ try {
471
+ const status = await fetch(`${gatewayUrl(flags)}/v1/topups/${body.reference}`, {
472
+ headers: authHeaders(config),
473
+ });
474
+ const data = await status.json();
475
+
476
+ if (data.status === "credited") {
477
+ process.stdout.write("\r" + " ".repeat(50) + "\r");
478
+ console.log("");
479
+ console.log(GREEN(BOLD(" ✓ Payment confirmed!")) + ` $${amount.toFixed(2)} credited to your account.`);
480
+ console.log("");
481
+
482
+ // Show new balance
483
+ const me = await api(config, flags, "/v1/keys/me", { headers: authHeaders(config) });
484
+ console.log(` ${BOLD("New balance:")} $${me.creditsUsd.toFixed(2)}`);
485
+ console.log("");
486
+ console.log(DIM(" Run your first verdict:"));
487
+ console.log(DIM(" npx zyntry-verdict run multi-tenant-auth"));
488
+ return;
489
+ }
490
+
491
+ if (data.status === "cancelled") {
492
+ process.stdout.write("\r" + " ".repeat(50) + "\r");
493
+ console.log("");
494
+ console.log(RED(" ✗ Payment cancelled."));
495
+ console.log("");
496
+ console.log(DIM(" Try again: npx zyntry-verdict topup " + amount));
497
+ return;
498
+ }
499
+ } catch {
500
+ // network flake — keep waiting
501
+ }
502
+ }
503
+
504
+ // Timeout
505
+ process.stdout.write("\r" + " ".repeat(50) + "\r");
432
506
  console.log("");
433
- console.log(DIM("Credits land automatically once the payment confirms."));
434
- console.log(DIM("Then check: zyntry-verdict balance"));
507
+ console.log(DIM(" Still waiting for the payment to process..."));
508
+ console.log(DIM(` Check status: npx zyntry-verdict balance`));
509
+ console.log(DIM(` Or visit: ${url}`));
435
510
  }
436
511
 
437
512
  async function cmdStats(config, flags, positional) {
@@ -631,6 +706,11 @@ switch (command) {
631
706
 
632
707
  git hook: zyntry-verdict gate --case my-case # in .git/hooks/pre-commit
633
708
 
709
+ links: docs & API https://zyntry.space/products/zyntry-verdict/docs
710
+ results https://verdict.zyntry.space/docs/results
711
+ dogfood https://verdict.zyntry.space/docs/dogfood
712
+ security https://verdict.zyntry.space/docs/security-audit
713
+
634
714
  env: ZV_GATEWAY (default https://verdict.zyntry.space)`);
635
715
  process.exit(command ? 2 : 0);
636
716
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zyntry-verdict",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Thin client for the Zyntry Verdict hosted AI courtroom — submit code, watch the adversarial courtroom stream live, get a verdict that can withstand scrutiny.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -30,4 +30,4 @@
30
30
  "engines": {
31
31
  "node": ">=18"
32
32
  }
33
- }
33
+ }