nervepay 1.2.0 → 1.2.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.
Files changed (2) hide show
  1. package/bin/nervepay-cli.js +42 -44
  2. package/package.json +1 -1
@@ -372,6 +372,48 @@ program
372
372
  console.log(chalk.yellow(` ${mnemonic}`));
373
373
  console.log(chalk.red(' ⚠️ Save this — you can recover your keys with it!\n'));
374
374
  }
375
+
376
+ // Save credentials immediately so they persist even if pairing fails
377
+ try {
378
+ const { mkdir } = await import('fs/promises');
379
+ await mkdir(join(homedir(), '.nervepay'), { recursive: true });
380
+ await writeFile(
381
+ NERVEPAY_CREDS_PATH,
382
+ JSON.stringify({
383
+ agent_did: agentDid,
384
+ private_key: privateKey,
385
+ mnemonic: mnemonic || undefined,
386
+ api_url: options.apiUrl,
387
+ created_at: new Date().toISOString(),
388
+ }, null, 2)
389
+ );
390
+ console.log(chalk.green(' ✓ Credentials saved to ~/.nervepay/credentials.json'));
391
+
392
+ // Update OpenClaw config if it exists
393
+ try {
394
+ const ocConfigPath = await findOpenClawConfigPath();
395
+ if (ocConfigPath) {
396
+ const existingConfig = JSON.parse(await readFile(ocConfigPath, 'utf-8'));
397
+ if (!existingConfig.plugins) existingConfig.plugins = {};
398
+ if (!existingConfig.plugins.entries) existingConfig.plugins.entries = {};
399
+ if (!existingConfig.plugins.entries.nervepay) {
400
+ existingConfig.plugins.entries.nervepay = { enabled: true, config: {} };
401
+ }
402
+ existingConfig.plugins.entries.nervepay.config = {
403
+ ...existingConfig.plugins.entries.nervepay.config,
404
+ apiUrl: options.apiUrl,
405
+ agentDid,
406
+ privateKey,
407
+ };
408
+ await writeFile(ocConfigPath, JSON.stringify(existingConfig, null, 2));
409
+ console.log(chalk.green(' ✓ OpenClaw config updated'));
410
+ }
411
+ } catch {
412
+ // Non-fatal
413
+ }
414
+ } catch (e) {
415
+ console.log(chalk.yellow(' ⚠️ Could not save credentials:'), e.message);
416
+ }
375
417
  }
376
418
 
377
419
  // Step 2: Read gateway config (from flags, env, or config files)
@@ -425,50 +467,6 @@ program
425
467
  console.log(chalk.gray(' Agent DID: '), agentDid);
426
468
  console.log(chalk.gray('\n Your gateway is now live in the NervePay dashboard.'));
427
469
  console.log(chalk.gray(' Go to Mission Control to spawn agents and manage tasks.\n'));
428
-
429
- // Save credentials if new
430
- if (isNew) {
431
- try {
432
- const { mkdir } = await import('fs/promises');
433
- await mkdir(join(homedir(), '.nervepay'), { recursive: true });
434
- await writeFile(
435
- NERVEPAY_CREDS_PATH,
436
- JSON.stringify({
437
- agent_did: agentDid,
438
- private_key: privateKey,
439
- mnemonic: mnemonic || undefined,
440
- api_url: options.apiUrl,
441
- created_at: new Date().toISOString(),
442
- }, null, 2)
443
- );
444
- console.log(chalk.green(' ✓ Credentials saved to ~/.nervepay/credentials.json'));
445
-
446
- // Update OpenClaw config if it exists
447
- try {
448
- const ocConfigPath = await findOpenClawConfigPath();
449
- if (ocConfigPath) {
450
- const existingConfig = JSON.parse(await readFile(ocConfigPath, 'utf-8'));
451
- if (!existingConfig.plugins) existingConfig.plugins = {};
452
- if (!existingConfig.plugins.entries) existingConfig.plugins.entries = {};
453
- if (!existingConfig.plugins.entries.nervepay) {
454
- existingConfig.plugins.entries.nervepay = { enabled: true, config: {} };
455
- }
456
- existingConfig.plugins.entries.nervepay.config = {
457
- ...existingConfig.plugins.entries.nervepay.config,
458
- apiUrl: options.apiUrl,
459
- agentDid,
460
- privateKey,
461
- };
462
- await writeFile(ocConfigPath, JSON.stringify(existingConfig, null, 2));
463
- console.log(chalk.green(' ✓ OpenClaw config updated'));
464
- }
465
- } catch {
466
- // OpenClaw config doesn't exist — that's fine, we saved to ~/.nervepay/
467
- }
468
- } catch {
469
- // Non-fatal — credentials shown above
470
- }
471
- }
472
470
  } catch (error) {
473
471
  console.error(chalk.red('\n❌ Pairing failed:'), error.message);
474
472
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nervepay",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "NervePay plugin for OpenClaw - Self-sovereign identity, vault, and orchestration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",