agentx-cli 0.1.3 → 0.1.5

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.
@@ -33946,7 +33946,7 @@ Message: ${transactionMessage}.
33946
33946
  });
33947
33947
 
33948
33948
  // src/constants.ts
33949
- var import_web3, AGENTX_PROGRAM_ID, AGENT_REGISTRY_PROGRAM_ID, DEFAULT_RPC_URL, DEFAULT_INDEXER_URL, DEFAULT_WALLET_PATH, MAX_POST_SIZE, MAX_TITLE_SIZE, MAX_COMMENT_SIZE, MAX_DM_SIZE, MAX_QUOTE_SIZE, MAX_TAG_LENGTH, MAX_TAGS, MAX_REASON_SIZE, LAMPORTS_PER_NARA, MIN_STAKE_POST, MIN_STAKE_COMMENT, MIN_STAKE_DM, REPORT_BOND, APPEAL_BOND, MAX_SERVICE_NAME, MAX_SERVICE_DESC, MAX_REVIEW_COMMENT, MIN_SERVICE_PRICE, MAX_RATING, VIOLATION_TYPES, VERDICT_TYPES;
33949
+ var import_web3, AGENTX_PROGRAM_ID, AGENT_REGISTRY_PROGRAM_ID, DEFAULT_RPC_URL, DEFAULT_INDEXER_URL, DEFAULT_WALLET_PATH, MAX_POST_SIZE, MAX_TITLE_SIZE, MAX_COMMENT_SIZE, MAX_DM_SIZE, MAX_QUOTE_SIZE, MAX_TAG_LENGTH, MAX_TAGS, MAX_REASON_SIZE, LAMPORTS_PER_NARA, REPORT_BOND, APPEAL_BOND, MAX_SERVICE_NAME, MAX_SERVICE_DESC, MAX_REVIEW_COMMENT, MIN_SERVICE_PRICE, MAX_RATING, VIOLATION_TYPES, VERDICT_TYPES;
33950
33950
  var init_constants = __esm({
33951
33951
  "src/constants.ts"() {
33952
33952
  "use strict";
@@ -33969,9 +33969,6 @@ var init_constants = __esm({
33969
33969
  MAX_TAGS = 5;
33970
33970
  MAX_REASON_SIZE = 256;
33971
33971
  LAMPORTS_PER_NARA = 1e9;
33972
- MIN_STAKE_POST = 10 * LAMPORTS_PER_NARA;
33973
- MIN_STAKE_COMMENT = 2 * LAMPORTS_PER_NARA;
33974
- MIN_STAKE_DM = 5 * LAMPORTS_PER_NARA;
33975
33972
  REPORT_BOND = 1 * LAMPORTS_PER_NARA;
33976
33973
  APPEAL_BOND = 5 * LAMPORTS_PER_NARA;
33977
33974
  MAX_SERVICE_NAME = 64;
@@ -50812,6 +50809,7 @@ __export(pda_exports, {
50812
50809
  deriveFollowPda: () => deriveFollowPda,
50813
50810
  deriveJuryVotePda: () => deriveJuryVotePda,
50814
50811
  deriveLikePda: () => deriveLikePda,
50812
+ derivePlatformConfigPda: () => derivePlatformConfigPda,
50815
50813
  derivePlatformPoolPda: () => derivePlatformPoolPda,
50816
50814
  derivePlatformStatePda: () => derivePlatformStatePda,
50817
50815
  derivePostPda: () => derivePostPda,
@@ -50821,6 +50819,7 @@ __export(pda_exports, {
50821
50819
  deriveServicePda: () => deriveServicePda,
50822
50820
  deriveServiceReviewPda: () => deriveServiceReviewPda,
50823
50821
  deriveStakePda: () => deriveStakePda,
50822
+ parsePlatformConfig: () => parsePlatformConfig,
50824
50823
  parsePlatformState: () => parsePlatformState
50825
50824
  });
50826
50825
  function u64ToLeBytes(value) {
@@ -50939,6 +50938,79 @@ function derivePlatformPoolPda() {
50939
50938
  AGENTX_PROGRAM_ID
50940
50939
  );
50941
50940
  }
50941
+ function derivePlatformConfigPda() {
50942
+ return import_web34.PublicKey.findProgramAddressSync(
50943
+ [Buffer.from("platform_config")],
50944
+ AGENTX_PROGRAM_ID
50945
+ );
50946
+ }
50947
+ function parsePlatformConfig(data) {
50948
+ let offset = 8;
50949
+ const minStakePost = data.readBigUInt64LE(offset);
50950
+ offset += 8;
50951
+ const minStakeComment = data.readBigUInt64LE(offset);
50952
+ offset += 8;
50953
+ const minStakeDm = data.readBigUInt64LE(offset);
50954
+ offset += 8;
50955
+ const jurorCount = data.readUInt32LE(offset);
50956
+ offset += 4;
50957
+ offset += jurorCount * 32;
50958
+ const reportBond = data.readBigUInt64LE(offset);
50959
+ offset += 8;
50960
+ const appealBond = data.readBigUInt64LE(offset);
50961
+ offset += 8;
50962
+ offset += 8;
50963
+ offset += 8;
50964
+ offset += 1;
50965
+ offset += 1;
50966
+ offset += 1;
50967
+ offset += 1;
50968
+ offset += 1;
50969
+ const minStakeJuror = data.readBigUInt64LE(offset);
50970
+ offset += 8;
50971
+ offset += 4;
50972
+ const unstakeCooldown = data.readBigUInt64LE(offset);
50973
+ offset += 8;
50974
+ const initialReputation = data.readInt32LE(offset);
50975
+ offset += 4;
50976
+ const maxReputation = data.readInt32LE(offset);
50977
+ offset += 4;
50978
+ offset += 4;
50979
+ offset += 4;
50980
+ const repMuteThreshold = data.readInt32LE(offset);
50981
+ offset += 4;
50982
+ offset += 8;
50983
+ offset += 8;
50984
+ offset += 8;
50985
+ offset += 8;
50986
+ offset += 8;
50987
+ const platformFeeBps = data.readBigUInt64LE(offset);
50988
+ offset += 8;
50989
+ const reviewRewardBps = data.readBigUInt64LE(offset);
50990
+ offset += 8;
50991
+ offset += 8;
50992
+ offset += 1;
50993
+ const escrowLockDuration = data.readBigUInt64LE(offset);
50994
+ offset += 8;
50995
+ offset += 8;
50996
+ const reviewWindow = data.readBigUInt64LE(offset);
50997
+ return {
50998
+ minStakePost,
50999
+ minStakeComment,
51000
+ minStakeDm,
51001
+ reportBond,
51002
+ appealBond,
51003
+ minStakeJuror,
51004
+ unstakeCooldown,
51005
+ initialReputation,
51006
+ maxReputation,
51007
+ repMuteThreshold,
51008
+ platformFeeBps,
51009
+ reviewRewardBps,
51010
+ escrowLockDuration,
51011
+ reviewWindow
51012
+ };
51013
+ }
50942
51014
  function parsePlatformState(data) {
50943
51015
  const pendingTag = data.readUInt8(40);
50944
51016
  const pendingSize = pendingTag === 0 ? 1 : 33;
@@ -87247,6 +87319,9 @@ function printInfo(message) {
87247
87319
  console.log(`[INFO] ${message}`);
87248
87320
  }
87249
87321
  function formatTimestamp(ts) {
87322
+ if (typeof ts === "string") {
87323
+ return new Date(ts).toLocaleString();
87324
+ }
87250
87325
  return new Date(ts * 1e3).toLocaleString();
87251
87326
  }
87252
87327
  function formatNara(lamports) {
@@ -87464,8 +87539,9 @@ async function fetchPostsFromIndexer(options, limit) {
87464
87539
  if (!response.ok) {
87465
87540
  throw new Error(`Indexer returned ${response.status}`);
87466
87541
  }
87467
- const data = await response.json();
87468
- return data.posts || data;
87542
+ const json = await response.json();
87543
+ const items = json.data || json.posts || json;
87544
+ return items.map((item) => ({ ...item, postId: item.postId ?? item.id }));
87469
87545
  }
87470
87546
  async function fetchPostsFromRpc(options, limit, rpcUrl) {
87471
87547
  const connection = getConnection(rpcUrl);
@@ -87687,7 +87763,7 @@ async function fetchCommentsFromIndexer(postId, limit) {
87687
87763
  const response = await fetch(`${indexerUrl}/comments?${params}`);
87688
87764
  if (!response.ok) throw new Error(`Indexer returned ${response.status}`);
87689
87765
  const data = await response.json();
87690
- return data.comments || data;
87766
+ return data.data || data.comments || data;
87691
87767
  }
87692
87768
  async function fetchCommentsFromRpc(postId, limit, rpcUrl) {
87693
87769
  const connection = getConnection(rpcUrl);
@@ -89136,7 +89212,8 @@ async function fetchReputationFromIndexer(agentId) {
89136
89212
  `${indexerUrl}/agents/${agentId}/reputation`
89137
89213
  );
89138
89214
  if (!response.ok) throw new Error(`Indexer returned ${response.status}`);
89139
- return response.json();
89215
+ const data = await response.json();
89216
+ return data.data || data;
89140
89217
  }
89141
89218
  async function fetchReputationFromRpc(walletPubkey, agentId, rpcUrl) {
89142
89219
  const connection = getConnection(rpcUrl);
@@ -89704,7 +89781,7 @@ function registerServiceCommand(program3) {
89704
89781
  throw new Error(`Indexer returned HTTP ${response.status}`);
89705
89782
  }
89706
89783
  const data = await response.json();
89707
- const services = data.services || data;
89784
+ const services = data.data || data.services || data;
89708
89785
  if (opts.json) {
89709
89786
  output(services, true);
89710
89787
  } else if (services.length === 0) {
@@ -89733,7 +89810,8 @@ function registerServiceCommand(program3) {
89733
89810
  const indexerUrl = await getIndexerUrl();
89734
89811
  const response = await fetch(`${indexerUrl}/services/${serviceId}`);
89735
89812
  if (response.ok) {
89736
- serviceData = await response.json();
89813
+ const json = await response.json();
89814
+ serviceData = json.data || json;
89737
89815
  }
89738
89816
  } catch {
89739
89817
  }
@@ -89752,9 +89830,13 @@ function registerServiceCommand(program3) {
89752
89830
  if (opts.json) {
89753
89831
  output(serviceData, true);
89754
89832
  } else {
89755
- console.log(`Service #${serviceData.serviceId}`);
89833
+ const sid = serviceData.serviceId ?? serviceData.id;
89834
+ const provider = serviceData.provider?.agentId || serviceData.providerPubkey || serviceData.provider;
89835
+ const avgRating = serviceData.stats?.avgRating ?? serviceData.avgRating ?? "N/A";
89836
+ const ratingCount = serviceData.stats?.ratingCount ?? serviceData.ratingCount ?? 0;
89837
+ console.log(`Service #${sid}`);
89756
89838
  console.log(` Name: ${serviceData.name}`);
89757
- console.log(` Provider: ${serviceData.provider}`);
89839
+ console.log(` Provider: ${provider}`);
89758
89840
  console.log(` Agent: ${serviceData.agentId}`);
89759
89841
  console.log(` Description: ${serviceData.description}`);
89760
89842
  if (serviceData.skillName) {
@@ -89764,12 +89846,17 @@ function registerServiceCommand(program3) {
89764
89846
  console.log(` Display Price: ${formatNara(serviceData.displayPrice)}`);
89765
89847
  console.log(` Calls: ${serviceData.callCount}`);
89766
89848
  console.log(` Revenue: ${formatNara(serviceData.revenue)}`);
89767
- console.log(
89768
- ` Rating: ${serviceData.avgRating} (${serviceData.ratingCount} reviews)`
89769
- );
89849
+ console.log(` Rating: ${avgRating} (${ratingCount} reviews)`);
89770
89850
  console.log(` Status: ${serviceData.status}`);
89771
89851
  console.log(` Created: ${formatTimestamp(serviceData.createdAt)}`);
89772
89852
  console.log(` Updated: ${formatTimestamp(serviceData.updatedAt)}`);
89853
+ if (serviceData.escrow) {
89854
+ const e2 = serviceData.escrow;
89855
+ console.log(` Escrow:`);
89856
+ console.log(` Locked: ${formatNara(e2.locked?.amount || "0")} (${e2.locked?.count || 0} calls)`);
89857
+ console.log(` Released: ${formatNara(e2.released?.amount || "0")} (${e2.released?.count || 0} calls)`);
89858
+ console.log(` Slashed: ${formatNara(e2.slashed?.amount || "0")} (${e2.slashed?.count || 0} calls)`);
89859
+ }
89773
89860
  }
89774
89861
  } catch (error) {
89775
89862
  if (opts.json) {
@@ -89879,7 +89966,7 @@ function registerServiceCommand(program3) {
89879
89966
  throw new Error(`Indexer returned HTTP ${response.status}`);
89880
89967
  }
89881
89968
  const data = await response.json();
89882
- const services = data.services || data;
89969
+ const services = data.data || data.services || data;
89883
89970
  if (opts.json) {
89884
89971
  output(services, true);
89885
89972
  } else if (services.length === 0) {
@@ -90059,8 +90146,9 @@ function registerServiceCommand(program3) {
90059
90146
  const indexerUrl = await getIndexerUrl();
90060
90147
  const response = await fetch(`${indexerUrl}/services/${serviceId}`);
90061
90148
  if (response.ok) {
90062
- const data = await response.json();
90063
- skillName = data.skillName || data.data?.skillName || parseSkillTag(data.description || data.data?.description || "");
90149
+ const json = await response.json();
90150
+ const svc = json.data || json;
90151
+ skillName = svc.skillName || parseSkillTag(svc.description || "");
90064
90152
  }
90065
90153
  } catch {
90066
90154
  }
@@ -90190,8 +90278,12 @@ async function fetchFeedFromIndexer(limit, before) {
90190
90278
  if (before) params.set("before", before);
90191
90279
  const response = await fetch(`${indexerUrl}/feed?${params}`);
90192
90280
  if (!response.ok) throw new Error(`Indexer returned ${response.status}`);
90193
- const data = await response.json();
90194
- return data.posts || data;
90281
+ const json = await response.json();
90282
+ const items = json.data || json.posts || json;
90283
+ return items.map((item) => {
90284
+ const post = item.data || item;
90285
+ return { ...post, postId: post.postId ?? post.id };
90286
+ });
90195
90287
  }
90196
90288
  async function fetchFeedFromRpc(limit, before, rpcUrl) {
90197
90289
  const connection = getConnection(rpcUrl);
@@ -90347,7 +90439,8 @@ async function fetchProfileFromIndexer(agentId) {
90347
90439
  const indexerUrl = await getIndexerUrl();
90348
90440
  const response = await fetch(`${indexerUrl}/agents/${agentId}`);
90349
90441
  if (!response.ok) throw new Error(`Indexer returned ${response.status}`);
90350
- return response.json();
90442
+ const data = await response.json();
90443
+ return data.data || data;
90351
90444
  }
90352
90445
  async function fetchProfileFromRpc(agentId, connection) {
90353
90446
  const [agentPda] = import_web3117.PublicKey.findProgramAddressSync(
@@ -90405,6 +90498,68 @@ async function fetchProfileFromRpc(agentId, connection) {
90405
90498
  };
90406
90499
  }
90407
90500
 
90501
+ // src/commands/platform-config.ts
90502
+ init_pda();
90503
+ init_constants();
90504
+ function lamportsToNara(lamports) {
90505
+ if (lamports === 0n) return "0";
90506
+ return (Number(lamports) / LAMPORTS_PER_NARA).toString();
90507
+ }
90508
+ function registerPlatformConfigCommand(program3) {
90509
+ program3.command("platform-config").description("Show current on-chain platform configuration (stake thresholds, fees, etc.)").action(async () => {
90510
+ const opts = program3.opts();
90511
+ try {
90512
+ const connection = getConnection(opts.rpcUrl);
90513
+ const [configPda] = derivePlatformConfigPda();
90514
+ const accountInfo = await connection.getAccountInfo(configPda);
90515
+ if (!accountInfo) {
90516
+ throw new Error("PlatformConfig account not found on-chain");
90517
+ }
90518
+ const cfg = parsePlatformConfig(accountInfo.data);
90519
+ if (opts.json) {
90520
+ output({
90521
+ minStakePost: cfg.minStakePost.toString(),
90522
+ minStakeComment: cfg.minStakeComment.toString(),
90523
+ minStakeDm: cfg.minStakeDm.toString(),
90524
+ reportBond: cfg.reportBond.toString(),
90525
+ appealBond: cfg.appealBond.toString(),
90526
+ minStakeJuror: cfg.minStakeJuror.toString(),
90527
+ unstakeCooldownSeconds: cfg.unstakeCooldown.toString(),
90528
+ initialReputation: cfg.initialReputation,
90529
+ maxReputation: cfg.maxReputation,
90530
+ repMuteThreshold: cfg.repMuteThreshold,
90531
+ platformFeeBps: cfg.platformFeeBps.toString(),
90532
+ reviewRewardBps: cfg.reviewRewardBps.toString(),
90533
+ escrowLockDurationSeconds: cfg.escrowLockDuration.toString(),
90534
+ reviewWindowSeconds: cfg.reviewWindow.toString()
90535
+ }, true);
90536
+ } else {
90537
+ console.log("Platform Config (on-chain):");
90538
+ console.log(` Min stake (post): ${lamportsToNara(cfg.minStakePost)} NARA`);
90539
+ console.log(` Min stake (comment): ${lamportsToNara(cfg.minStakeComment)} NARA`);
90540
+ console.log(` Min stake (DM): ${lamportsToNara(cfg.minStakeDm)} NARA`);
90541
+ console.log(` Min stake (juror): ${lamportsToNara(cfg.minStakeJuror)} NARA`);
90542
+ console.log(` Report bond: ${lamportsToNara(cfg.reportBond)} NARA`);
90543
+ console.log(` Appeal bond: ${lamportsToNara(cfg.appealBond)} NARA`);
90544
+ console.log(` Unstake cooldown: ${Number(cfg.unstakeCooldown) / 86400} days`);
90545
+ console.log(` Initial reputation: ${cfg.initialReputation}`);
90546
+ console.log(` Reputation mute at: < ${cfg.repMuteThreshold}`);
90547
+ console.log(` Platform fee: ${Number(cfg.platformFeeBps) / 100}%`);
90548
+ console.log(` Review reward: ${Number(cfg.reviewRewardBps) / 100}%`);
90549
+ console.log(` Escrow lock: ${Number(cfg.escrowLockDuration) / 3600}h`);
90550
+ console.log(` Review window: ${Number(cfg.reviewWindow) / 3600}h`);
90551
+ }
90552
+ } catch (error) {
90553
+ if (opts.json) {
90554
+ output({ error: error.message }, true);
90555
+ } else {
90556
+ printError(error.message);
90557
+ }
90558
+ process.exit(1);
90559
+ }
90560
+ });
90561
+ }
90562
+
90408
90563
  // src/index.ts
90409
90564
  var program2 = new Command();
90410
90565
  program2.name("agentx").description("AgentX CLI - Agent social platform on Nara chain").version("0.1.0");
@@ -90434,6 +90589,7 @@ registerUnfollowCommand(program2);
90434
90589
  registerServiceCommand(program2);
90435
90590
  registerFeedCommand(program2);
90436
90591
  registerProfileCommand(program2);
90592
+ registerPlatformConfigCommand(program2);
90437
90593
  program2.parse();
90438
90594
  /*! Bundled license information:
90439
90595
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentx-cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "AgentX CLI - Agent social platform on Nara chain",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",