naracli 1.0.93 → 1.0.94

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.
@@ -274497,6 +274497,36 @@ async function handleAgentLog(agentId, activity, log3, options) {
274497
274497
  console.log(` Transaction: ${signature}`);
274498
274498
  }
274499
274499
  }
274500
+ async function handleAgentRecover(agentId, options) {
274501
+ validateName(agentId, "Agent ID");
274502
+ const rpcUrl = getRpcUrl(options.rpcUrl);
274503
+ const wallet = await loadWallet(options.wallet);
274504
+ const pubkey = wallet.publicKey.toBase58();
274505
+ const networkConfig = loadNetworkConfig(rpcUrl, pubkey);
274506
+ if (networkConfig.agent_id) {
274507
+ printError(`Agent ID "${networkConfig.agent_id}" is already saved locally for this wallet. Run "agent clear" first if you want to replace it.`);
274508
+ process.exit(1);
274509
+ }
274510
+ const connection = new import_web3111.Connection(rpcUrl, "confirmed");
274511
+ let info;
274512
+ try {
274513
+ info = await getAgentInfo(connection, agentId);
274514
+ } catch {
274515
+ printError(`Agent "${agentId}" not found on-chain.`);
274516
+ process.exit(1);
274517
+ }
274518
+ const authority = info.record.authority.toBase58();
274519
+ if (authority !== pubkey) {
274520
+ printError(`Wallet ${pubkey} is not the authority of agent "${agentId}" (actual authority: ${authority}).`);
274521
+ process.exit(1);
274522
+ }
274523
+ setAgentId(agentId, rpcUrl, pubkey);
274524
+ if (options.json) {
274525
+ formatOutput({ recovered: true, agentId, authority: pubkey }, true);
274526
+ } else {
274527
+ printSuccess(`Agent ID "${agentId}" saved to local config.`);
274528
+ }
274529
+ }
274500
274530
  async function handleAgentClear(options) {
274501
274531
  const rpcUrl = getRpcUrl(options.rpcUrl);
274502
274532
  let pubkey;
@@ -274765,6 +274795,15 @@ function registerAgentCommands(program3) {
274765
274795
  process.exit(1);
274766
274796
  }
274767
274797
  });
274798
+ agent.command("recover <agent-id>").description("Recover an existing on-chain agent ID to local config (verifies wallet is the authority)").action(async (agentId, _opts, cmd) => {
274799
+ try {
274800
+ const globalOpts = cmd.optsWithGlobals();
274801
+ await handleAgentRecover(agentId, globalOpts);
274802
+ } catch (error) {
274803
+ printError(error.message);
274804
+ process.exit(1);
274805
+ }
274806
+ });
274768
274807
  agent.command("clear").description("Clear saved agent ID from local config (does not delete on-chain)").action(async (_opts, cmd) => {
274769
274808
  try {
274770
274809
  const globalOpts = cmd.optsWithGlobals();
@@ -276940,7 +276979,7 @@ function registerCommands(program3) {
276940
276979
  }
276941
276980
 
276942
276981
  // bin/nara-cli.ts
276943
- var version2 = true ? "1.0.93" : "dev";
276982
+ var version2 = true ? "1.0.94" : "dev";
276944
276983
  var program2 = new Command();
276945
276984
  program2.name("naracli").description("CLI for the Nara chain. Native coin is NARA (not SOL). Mine NARA for free via PoMI quests, manage wallets, register agents, and more. Run 'naracli <command> --help' for details on any command.").version(version2);
276946
276985
  program2.option("-r, --rpc-url <url>", "RPC endpoint (default: https://mainnet-api.nara.build/)").option("-w, --wallet <path>", "Path to wallet keypair JSON file (default: ~/.config/nara/id.json)").option("-j, --json", "Output in JSON format");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naracli",
3
- "version": "1.0.93",
3
+ "version": "1.0.94",
4
4
  "description": "CLI for the Nara chain (Solana-compatible)",
5
5
  "homepage": "https://nara.build",
6
6
  "repository": {
@@ -479,6 +479,44 @@ async function handleAgentLog(
479
479
  }
480
480
  }
481
481
 
482
+ async function handleAgentRecover(agentId: string, options: GlobalOptions) {
483
+ validateName(agentId, "Agent ID");
484
+ const rpcUrl = getRpcUrl(options.rpcUrl);
485
+ const wallet = await loadWallet(options.wallet);
486
+ const pubkey = wallet.publicKey.toBase58();
487
+
488
+ // Check if local config already has an agent ID for this wallet
489
+ const networkConfig = loadNetworkConfig(rpcUrl, pubkey);
490
+ if (networkConfig.agent_id) {
491
+ printError(`Agent ID "${networkConfig.agent_id}" is already saved locally for this wallet. Run "agent clear" first if you want to replace it.`);
492
+ process.exit(1);
493
+ }
494
+
495
+ const connection = new Connection(rpcUrl, "confirmed");
496
+
497
+ // Verify on-chain: agent exists and authority matches current wallet
498
+ let info;
499
+ try {
500
+ info = await getAgentInfo(connection, agentId);
501
+ } catch {
502
+ printError(`Agent "${agentId}" not found on-chain.`);
503
+ process.exit(1);
504
+ }
505
+ const authority = info.record.authority.toBase58();
506
+ if (authority !== pubkey) {
507
+ printError(`Wallet ${pubkey} is not the authority of agent "${agentId}" (actual authority: ${authority}).`);
508
+ process.exit(1);
509
+ }
510
+
511
+ setAgentId(agentId, rpcUrl, pubkey);
512
+
513
+ if (options.json) {
514
+ formatOutput({ recovered: true, agentId, authority: pubkey }, true);
515
+ } else {
516
+ printSuccess(`Agent ID "${agentId}" saved to local config.`);
517
+ }
518
+ }
519
+
482
520
  async function handleAgentClear(options: GlobalOptions) {
483
521
  const rpcUrl = getRpcUrl(options.rpcUrl);
484
522
  let pubkey: string | undefined;
@@ -855,6 +893,20 @@ export function registerAgentCommands(program: Command): void {
855
893
  }
856
894
  });
857
895
 
896
+ // agent recover
897
+ agent
898
+ .command("recover <agent-id>")
899
+ .description("Recover an existing on-chain agent ID to local config (verifies wallet is the authority)")
900
+ .action(async (agentId: string, _opts: any, cmd: Command) => {
901
+ try {
902
+ const globalOpts = cmd.optsWithGlobals() as GlobalOptions;
903
+ await handleAgentRecover(agentId, globalOpts);
904
+ } catch (error: any) {
905
+ printError(error.message);
906
+ process.exit(1);
907
+ }
908
+ });
909
+
858
910
  // agent clear
859
911
  agent
860
912
  .command("clear")