zyntry-verdict 0.1.0 → 0.1.1
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/zv.mjs +78 -4
- package/package.json +1 -1
package/bin/zv.mjs
CHANGED
|
@@ -420,18 +420,92 @@ async function cmdTopup(config, flags, positional) {
|
|
|
420
420
|
console.error("usage: zyntry-verdict topup <amount 5-500> — credit top-up via Bachs hosted checkout");
|
|
421
421
|
process.exit(2);
|
|
422
422
|
}
|
|
423
|
+
|
|
424
|
+
// Create the checkout
|
|
423
425
|
const body = await api(config, flags, "/v1/topups", {
|
|
424
426
|
method: "POST",
|
|
425
427
|
headers: authHeaders(config),
|
|
426
428
|
body: JSON.stringify({ amountUsd: amount }),
|
|
427
429
|
});
|
|
430
|
+
|
|
431
|
+
console.log("");
|
|
428
432
|
console.log(GREEN("✓ checkout created") + ` — $${amount.toFixed(2)} · reference ${body.reference}`);
|
|
429
433
|
console.log("");
|
|
430
|
-
|
|
431
|
-
|
|
434
|
+
|
|
435
|
+
// Auto-open the browser
|
|
436
|
+
const url = body.checkoutUrl;
|
|
437
|
+
console.log(BOLD("Opening checkout page..."));
|
|
438
|
+
console.log(DIM(` ${url}`));
|
|
439
|
+
console.log("");
|
|
440
|
+
|
|
441
|
+
try {
|
|
442
|
+
const { exec } = await import("node:child_process");
|
|
443
|
+
const platform = process.platform;
|
|
444
|
+
if (platform === "win32") exec(`start "" "${url}"`);
|
|
445
|
+
else if (platform === "darwin") exec(`open "${url}"`);
|
|
446
|
+
else exec(`xdg-open "${url}"`);
|
|
447
|
+
} catch {
|
|
448
|
+
// if auto-open fails, the URL is printed above for manual access
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// Wait for the payment to confirm (webhook fires, credits land)
|
|
452
|
+
console.log(BOLD("Waiting for payment..."));
|
|
453
|
+
console.log(DIM(" Complete the payment in your browser."));
|
|
454
|
+
console.log(DIM(" Credits land automatically once confirmed."));
|
|
455
|
+
console.log("");
|
|
456
|
+
|
|
457
|
+
const startTime = Date.now();
|
|
458
|
+
const timeoutMs = 5 * 60 * 1000; // 5 minutes
|
|
459
|
+
let dots = 0;
|
|
460
|
+
|
|
461
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
462
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
463
|
+
|
|
464
|
+
// Animate waiting
|
|
465
|
+
dots = (dots + 1) % 4;
|
|
466
|
+
const dotStr = ".".repeat(dots) + " ".repeat(3 - dots);
|
|
467
|
+
process.stdout.write(`\r ${DIM("waiting for payment")} ${dotStr} ${DIM(Math.floor((Date.now() - startTime) / 1000) + "s")}`);
|
|
468
|
+
|
|
469
|
+
try {
|
|
470
|
+
const status = await fetch(`${gatewayUrl(flags)}/v1/topups/${body.reference}`, {
|
|
471
|
+
headers: authHeaders(config),
|
|
472
|
+
});
|
|
473
|
+
const data = await status.json();
|
|
474
|
+
|
|
475
|
+
if (data.status === "credited") {
|
|
476
|
+
process.stdout.write("\r" + " ".repeat(50) + "\r");
|
|
477
|
+
console.log("");
|
|
478
|
+
console.log(GREEN(BOLD(" ✓ Payment confirmed!")) + ` $${amount.toFixed(2)} credited to your account.`);
|
|
479
|
+
console.log("");
|
|
480
|
+
|
|
481
|
+
// Show new balance
|
|
482
|
+
const me = await api(config, flags, "/v1/keys/me", { headers: authHeaders(config) });
|
|
483
|
+
console.log(` ${BOLD("New balance:")} $${me.creditsUsd.toFixed(2)}`);
|
|
484
|
+
console.log("");
|
|
485
|
+
console.log(DIM(" Run your first verdict:"));
|
|
486
|
+
console.log(DIM(" npx zyntry-verdict run multi-tenant-auth"));
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
if (data.status === "cancelled") {
|
|
491
|
+
process.stdout.write("\r" + " ".repeat(50) + "\r");
|
|
492
|
+
console.log("");
|
|
493
|
+
console.log(RED(" ✗ Payment cancelled."));
|
|
494
|
+
console.log("");
|
|
495
|
+
console.log(DIM(" Try again: npx zyntry-verdict topup " + amount));
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
} catch {
|
|
499
|
+
// network flake — keep waiting
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// Timeout
|
|
504
|
+
process.stdout.write("\r" + " ".repeat(50) + "\r");
|
|
432
505
|
console.log("");
|
|
433
|
-
console.log(DIM("
|
|
434
|
-
console.log(DIM(
|
|
506
|
+
console.log(DIM(" Still waiting for the payment to process..."));
|
|
507
|
+
console.log(DIM(` Check status: npx zyntry-verdict balance`));
|
|
508
|
+
console.log(DIM(` Or visit: ${url}`));
|
|
435
509
|
}
|
|
436
510
|
|
|
437
511
|
async function cmdStats(config, flags, positional) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zyntry-verdict",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
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": {
|