agentx-cli 0.1.2 → 0.1.4
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/dist/agentx-bundle.cjs +290 -141
- package/package.json +1 -1
package/dist/agentx-bundle.cjs
CHANGED
|
@@ -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,
|
|
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";
|
|
@@ -33960,7 +33960,6 @@ var init_constants = __esm({
|
|
|
33960
33960
|
DEFAULT_RPC_URL = "https://mainnet-api.nara.build/";
|
|
33961
33961
|
DEFAULT_INDEXER_URL = "https://agentx.nara.build/api/indexer";
|
|
33962
33962
|
DEFAULT_WALLET_PATH = "~/.config/nara/id.json";
|
|
33963
|
-
DEFAULT_RELAY_URL = "https://relay.nara.build";
|
|
33964
33963
|
MAX_POST_SIZE = 4096;
|
|
33965
33964
|
MAX_TITLE_SIZE = 128;
|
|
33966
33965
|
MAX_COMMENT_SIZE = 1024;
|
|
@@ -33970,9 +33969,6 @@ var init_constants = __esm({
|
|
|
33970
33969
|
MAX_TAGS = 5;
|
|
33971
33970
|
MAX_REASON_SIZE = 256;
|
|
33972
33971
|
LAMPORTS_PER_NARA = 1e9;
|
|
33973
|
-
MIN_STAKE_POST = 10 * LAMPORTS_PER_NARA;
|
|
33974
|
-
MIN_STAKE_COMMENT = 2 * LAMPORTS_PER_NARA;
|
|
33975
|
-
MIN_STAKE_DM = 5 * LAMPORTS_PER_NARA;
|
|
33976
33972
|
REPORT_BOND = 1 * LAMPORTS_PER_NARA;
|
|
33977
33973
|
APPEAL_BOND = 5 * LAMPORTS_PER_NARA;
|
|
33978
33974
|
MAX_SERVICE_NAME = 64;
|
|
@@ -50813,6 +50809,7 @@ __export(pda_exports, {
|
|
|
50813
50809
|
deriveFollowPda: () => deriveFollowPda,
|
|
50814
50810
|
deriveJuryVotePda: () => deriveJuryVotePda,
|
|
50815
50811
|
deriveLikePda: () => deriveLikePda,
|
|
50812
|
+
derivePlatformConfigPda: () => derivePlatformConfigPda,
|
|
50816
50813
|
derivePlatformPoolPda: () => derivePlatformPoolPda,
|
|
50817
50814
|
derivePlatformStatePda: () => derivePlatformStatePda,
|
|
50818
50815
|
derivePostPda: () => derivePostPda,
|
|
@@ -50822,6 +50819,7 @@ __export(pda_exports, {
|
|
|
50822
50819
|
deriveServicePda: () => deriveServicePda,
|
|
50823
50820
|
deriveServiceReviewPda: () => deriveServiceReviewPda,
|
|
50824
50821
|
deriveStakePda: () => deriveStakePda,
|
|
50822
|
+
parsePlatformConfig: () => parsePlatformConfig,
|
|
50825
50823
|
parsePlatformState: () => parsePlatformState
|
|
50826
50824
|
});
|
|
50827
50825
|
function u64ToLeBytes(value) {
|
|
@@ -50940,6 +50938,79 @@ function derivePlatformPoolPda() {
|
|
|
50940
50938
|
AGENTX_PROGRAM_ID
|
|
50941
50939
|
);
|
|
50942
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
|
+
}
|
|
50943
51014
|
function parsePlatformState(data) {
|
|
50944
51015
|
const pendingTag = data.readUInt8(40);
|
|
50945
51016
|
const pendingSize = pendingTag === 0 ? 1 : 33;
|
|
@@ -79781,11 +79852,27 @@ async function loadWallet(walletPath) {
|
|
|
79781
79852
|
var import_node_path3 = require("node:path");
|
|
79782
79853
|
var import_node_os3 = require("node:os");
|
|
79783
79854
|
init_config();
|
|
79784
|
-
var
|
|
79855
|
+
var NARA_CONFIG_DIR = (0, import_node_path3.join)((0, import_node_os3.homedir)(), ".config", "nara");
|
|
79856
|
+
async function readAgentIdFromFile(filePath) {
|
|
79857
|
+
const fs = await import("node:fs/promises");
|
|
79858
|
+
try {
|
|
79859
|
+
const raw = await fs.readFile(filePath, "utf-8");
|
|
79860
|
+
const parsed = JSON.parse(raw);
|
|
79861
|
+
if (Array.isArray(parsed.agent_ids) && parsed.agent_ids.length > 0) {
|
|
79862
|
+
return parsed.agent_ids[0];
|
|
79863
|
+
}
|
|
79864
|
+
if (typeof parsed.agent_id === "string" && parsed.agent_id) {
|
|
79865
|
+
return parsed.agent_id;
|
|
79866
|
+
}
|
|
79867
|
+
return null;
|
|
79868
|
+
} catch {
|
|
79869
|
+
return null;
|
|
79870
|
+
}
|
|
79871
|
+
}
|
|
79785
79872
|
async function loadAgentConfig() {
|
|
79786
79873
|
const fs = await import("node:fs/promises");
|
|
79787
79874
|
try {
|
|
79788
|
-
const raw = await fs.readFile(
|
|
79875
|
+
const raw = await fs.readFile((0, import_node_path3.join)(NARA_CONFIG_DIR, "agent.json"), "utf-8");
|
|
79789
79876
|
const parsed = JSON.parse(raw);
|
|
79790
79877
|
return {
|
|
79791
79878
|
agent_ids: Array.isArray(parsed.agent_ids) ? parsed.agent_ids : [],
|
|
@@ -79799,11 +79886,19 @@ async function getAgentId() {
|
|
|
79799
79886
|
const defaultId = await getDefaultAgentId();
|
|
79800
79887
|
if (defaultId) return defaultId;
|
|
79801
79888
|
const config = await loadAgentConfig();
|
|
79802
|
-
if (config.agent_ids.length > 0)
|
|
79803
|
-
|
|
79889
|
+
if (config.agent_ids.length > 0) return config.agent_ids[0];
|
|
79890
|
+
for (const network of ["mainnet", "devnet", "testnet"]) {
|
|
79891
|
+
const id = await readAgentIdFromFile(
|
|
79892
|
+
(0, import_node_path3.join)(NARA_CONFIG_DIR, `agent-${network}.json`)
|
|
79893
|
+
);
|
|
79894
|
+
if (id) return id;
|
|
79804
79895
|
}
|
|
79805
79896
|
throw new Error(
|
|
79806
|
-
|
|
79897
|
+
`No agent-id found. Register an agent and set up config:
|
|
79898
|
+
|
|
79899
|
+
npx naracli@latest agent register <agent-id>
|
|
79900
|
+
echo '{"agent_ids": ["<agent-id>"]}' > ~/.config/nara/agent.json
|
|
79901
|
+
`
|
|
79807
79902
|
);
|
|
79808
79903
|
}
|
|
79809
79904
|
|
|
@@ -79823,148 +79918,35 @@ function getConnection(rpcUrl) {
|
|
|
79823
79918
|
}
|
|
79824
79919
|
|
|
79825
79920
|
// src/utils/relay.ts
|
|
79826
|
-
|
|
79827
|
-
|
|
79828
|
-
|
|
79829
|
-
|
|
79830
|
-
|
|
79831
|
-
|
|
79832
|
-
|
|
79833
|
-
|
|
79834
|
-
|
|
79835
|
-
|
|
79836
|
-
|
|
79837
|
-
if (jsonMode) {
|
|
79838
|
-
console.log(JSON.stringify(items, null, 2));
|
|
79839
|
-
} else if (items.length === 0) {
|
|
79840
|
-
console.log("No results found.");
|
|
79841
|
-
} else {
|
|
79842
|
-
for (const item of items) {
|
|
79843
|
-
if (formatter) {
|
|
79844
|
-
console.log(formatter(item));
|
|
79845
|
-
} else {
|
|
79846
|
-
formatHumanReadable(item);
|
|
79921
|
+
async function pollConfirm(connection, signature, timeoutMs = 6e4, intervalMs = 2e3) {
|
|
79922
|
+
const deadline = Date.now() + timeoutMs;
|
|
79923
|
+
while (Date.now() < deadline) {
|
|
79924
|
+
const { value } = await connection.getSignatureStatuses([signature]);
|
|
79925
|
+
const status = value[0];
|
|
79926
|
+
if (status) {
|
|
79927
|
+
if (status.err) {
|
|
79928
|
+
throw new Error(`Transaction failed: ${JSON.stringify(status.err)}`);
|
|
79929
|
+
}
|
|
79930
|
+
if (status.confirmationStatus === "confirmed" || status.confirmationStatus === "finalized") {
|
|
79931
|
+
return;
|
|
79847
79932
|
}
|
|
79848
|
-
console.log("---");
|
|
79849
|
-
}
|
|
79850
|
-
}
|
|
79851
|
-
}
|
|
79852
|
-
function formatHumanReadable(data, indent = 0) {
|
|
79853
|
-
if (typeof data !== "object" || data === null) {
|
|
79854
|
-
console.log(data);
|
|
79855
|
-
return;
|
|
79856
|
-
}
|
|
79857
|
-
const prefix = " ".repeat(indent);
|
|
79858
|
-
for (const [key, value] of Object.entries(data)) {
|
|
79859
|
-
const label = formatLabel(key);
|
|
79860
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
79861
|
-
console.log(`${prefix}${label}:`);
|
|
79862
|
-
formatHumanReadable(value, indent + 1);
|
|
79863
|
-
} else {
|
|
79864
|
-
console.log(`${prefix}${label}: ${formatValue(value)}`);
|
|
79865
79933
|
}
|
|
79934
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
79866
79935
|
}
|
|
79867
|
-
|
|
79868
|
-
|
|
79869
|
-
const words = key.replace(/([A-Z])/g, " $1").trim();
|
|
79870
|
-
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
79871
|
-
}
|
|
79872
|
-
function formatValue(value) {
|
|
79873
|
-
if (value === null || value === void 0) return "N/A";
|
|
79874
|
-
if (typeof value === "boolean") return value ? "Yes" : "No";
|
|
79875
|
-
if (typeof value === "number" && value >= 1e3) return value.toLocaleString();
|
|
79876
|
-
if (Array.isArray(value)) {
|
|
79877
|
-
return value.length > 0 ? value.join(", ") : "(none)";
|
|
79878
|
-
}
|
|
79879
|
-
return String(value);
|
|
79880
|
-
}
|
|
79881
|
-
function printSuccess(message) {
|
|
79882
|
-
console.log(`[OK] ${message}`);
|
|
79883
|
-
}
|
|
79884
|
-
function printError(message) {
|
|
79885
|
-
console.error(`[ERROR] ${message}`);
|
|
79886
|
-
}
|
|
79887
|
-
function printInfo(message) {
|
|
79888
|
-
console.log(`[INFO] ${message}`);
|
|
79889
|
-
}
|
|
79890
|
-
function formatTimestamp(ts) {
|
|
79891
|
-
return new Date(ts * 1e3).toLocaleString();
|
|
79892
|
-
}
|
|
79893
|
-
function formatNara(lamports) {
|
|
79894
|
-
return (lamports / 1e9).toFixed(2) + " NARA";
|
|
79895
|
-
}
|
|
79896
|
-
function formatPost(post) {
|
|
79897
|
-
const lines = [
|
|
79898
|
-
`Post #${post.postId}`,
|
|
79899
|
-
` Author: ${post.agentId}`
|
|
79900
|
-
];
|
|
79901
|
-
if (post.title) lines.push(` Title: ${post.title}`);
|
|
79902
|
-
if (post.content) {
|
|
79903
|
-
const preview = post.content.length > 200 ? post.content.slice(0, 200) + "..." : post.content;
|
|
79904
|
-
lines.push(` ${preview}`);
|
|
79905
|
-
}
|
|
79906
|
-
if (post.tags && post.tags.length > 0) {
|
|
79907
|
-
lines.push(` Tags: ${post.tags.map((t) => `#${t}`).join(" ")}`);
|
|
79908
|
-
}
|
|
79909
|
-
lines.push(
|
|
79910
|
-
` Likes: ${post.likeCount || 0} Comments: ${post.commentCount || 0} Reposts: ${post.repostCount || 0}`
|
|
79936
|
+
throw new Error(
|
|
79937
|
+
`Transaction not confirmed after ${timeoutMs / 1e3}s. Signature: ${signature}`
|
|
79911
79938
|
);
|
|
79912
|
-
if (post.createdAt) lines.push(` ${formatTimestamp(post.createdAt)}`);
|
|
79913
|
-
return lines.join("\n");
|
|
79914
79939
|
}
|
|
79915
|
-
function
|
|
79916
|
-
const
|
|
79917
|
-
if (msg.includes("fetch failed") || msg.includes("ECONNREFUSED") || msg.includes("ECONNRESET") || msg.includes("ETIMEDOUT")) {
|
|
79918
|
-
return "Indexer \u6682\u4E0D\u53EF\u7528\uFF0C\u67E5\u8BE2\u529F\u80FD\u6682\u65F6\u65E0\u6CD5\u4F7F\u7528\u3002\u53D1\u5E16\u3001\u8BC4\u8BBA\u7B49\u94FE\u4E0A\u64CD\u4F5C\u4E0D\u53D7\u5F71\u54CD\u3002";
|
|
79919
|
-
}
|
|
79920
|
-
return msg;
|
|
79921
|
-
}
|
|
79922
|
-
function formatComment(comment, indent = 0) {
|
|
79923
|
-
const prefix = " ".repeat(indent);
|
|
79924
|
-
const lines = [
|
|
79925
|
-
`${prefix}Comment #${comment.commentId} by ${comment.agentId}`,
|
|
79926
|
-
`${prefix} ${comment.content}`,
|
|
79927
|
-
`${prefix} Likes: ${comment.likeCount || 0} ${formatTimestamp(comment.createdAt)}`
|
|
79928
|
-
];
|
|
79929
|
-
return lines.join("\n");
|
|
79930
|
-
}
|
|
79931
|
-
|
|
79932
|
-
// src/utils/relay.ts
|
|
79933
|
-
async function submitViaRelay(transaction, relayUrl) {
|
|
79934
|
-
const url = typeof relayUrl === "string" ? relayUrl : DEFAULT_RELAY_URL;
|
|
79935
|
-
printInfo(`Submitting via relay: ${url}`);
|
|
79936
|
-
const serialized = transaction.serialize({ requireAllSignatures: false }).toString("base64");
|
|
79937
|
-
const response = await fetch(`${url}/api/v1/relay`, {
|
|
79938
|
-
method: "POST",
|
|
79939
|
-
headers: { "Content-Type": "application/json" },
|
|
79940
|
-
body: JSON.stringify({ transaction: serialized })
|
|
79941
|
-
});
|
|
79942
|
-
if (!response.ok) {
|
|
79943
|
-
const body = await response.text();
|
|
79944
|
-
throw new Error(`Relay submission failed (${response.status}): ${body}`);
|
|
79945
|
-
}
|
|
79946
|
-
const result = await response.json();
|
|
79947
|
-
if (!result.success) {
|
|
79948
|
-
throw new Error(`Relay error: ${result.error || "Unknown error"}`);
|
|
79949
|
-
}
|
|
79950
|
-
return result.signature;
|
|
79951
|
-
}
|
|
79952
|
-
async function sendTransaction(transaction, wallet, connection, relay) {
|
|
79953
|
-
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
79940
|
+
async function sendTransaction(transaction, wallet, connection, _relay) {
|
|
79941
|
+
const { blockhash } = await connection.getLatestBlockhash("confirmed");
|
|
79954
79942
|
transaction.recentBlockhash = blockhash;
|
|
79955
79943
|
transaction.feePayer = wallet.publicKey;
|
|
79956
79944
|
transaction.sign(wallet);
|
|
79957
|
-
if (relay) {
|
|
79958
|
-
return submitViaRelay(transaction, relay);
|
|
79959
|
-
}
|
|
79960
79945
|
const signature = await connection.sendRawTransaction(
|
|
79961
79946
|
transaction.serialize(),
|
|
79962
|
-
{ skipPreflight: false }
|
|
79963
|
-
);
|
|
79964
|
-
await connection.confirmTransaction(
|
|
79965
|
-
{ signature, blockhash, lastValidBlockHeight },
|
|
79966
|
-
"confirmed"
|
|
79947
|
+
{ skipPreflight: false, preflightCommitment: "confirmed" }
|
|
79967
79948
|
);
|
|
79949
|
+
await pollConfirm(connection, signature);
|
|
79968
79950
|
return signature;
|
|
79969
79951
|
}
|
|
79970
79952
|
|
|
@@ -87274,6 +87256,110 @@ function getProgram(connection, wallet) {
|
|
|
87274
87256
|
// src/commands/post.ts
|
|
87275
87257
|
init_pda();
|
|
87276
87258
|
|
|
87259
|
+
// src/utils/output.ts
|
|
87260
|
+
function output(data, jsonMode = false) {
|
|
87261
|
+
if (jsonMode) {
|
|
87262
|
+
console.log(JSON.stringify(data, null, 2));
|
|
87263
|
+
} else {
|
|
87264
|
+
formatHumanReadable(data);
|
|
87265
|
+
}
|
|
87266
|
+
}
|
|
87267
|
+
function outputList(items, jsonMode = false, formatter) {
|
|
87268
|
+
if (jsonMode) {
|
|
87269
|
+
console.log(JSON.stringify(items, null, 2));
|
|
87270
|
+
} else if (items.length === 0) {
|
|
87271
|
+
console.log("No results found.");
|
|
87272
|
+
} else {
|
|
87273
|
+
for (const item of items) {
|
|
87274
|
+
if (formatter) {
|
|
87275
|
+
console.log(formatter(item));
|
|
87276
|
+
} else {
|
|
87277
|
+
formatHumanReadable(item);
|
|
87278
|
+
}
|
|
87279
|
+
console.log("---");
|
|
87280
|
+
}
|
|
87281
|
+
}
|
|
87282
|
+
}
|
|
87283
|
+
function formatHumanReadable(data, indent = 0) {
|
|
87284
|
+
if (typeof data !== "object" || data === null) {
|
|
87285
|
+
console.log(data);
|
|
87286
|
+
return;
|
|
87287
|
+
}
|
|
87288
|
+
const prefix = " ".repeat(indent);
|
|
87289
|
+
for (const [key, value] of Object.entries(data)) {
|
|
87290
|
+
const label = formatLabel(key);
|
|
87291
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
87292
|
+
console.log(`${prefix}${label}:`);
|
|
87293
|
+
formatHumanReadable(value, indent + 1);
|
|
87294
|
+
} else {
|
|
87295
|
+
console.log(`${prefix}${label}: ${formatValue(value)}`);
|
|
87296
|
+
}
|
|
87297
|
+
}
|
|
87298
|
+
}
|
|
87299
|
+
function formatLabel(key) {
|
|
87300
|
+
const words = key.replace(/([A-Z])/g, " $1").trim();
|
|
87301
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
87302
|
+
}
|
|
87303
|
+
function formatValue(value) {
|
|
87304
|
+
if (value === null || value === void 0) return "N/A";
|
|
87305
|
+
if (typeof value === "boolean") return value ? "Yes" : "No";
|
|
87306
|
+
if (typeof value === "number" && value >= 1e3) return value.toLocaleString();
|
|
87307
|
+
if (Array.isArray(value)) {
|
|
87308
|
+
return value.length > 0 ? value.join(", ") : "(none)";
|
|
87309
|
+
}
|
|
87310
|
+
return String(value);
|
|
87311
|
+
}
|
|
87312
|
+
function printSuccess(message) {
|
|
87313
|
+
console.log(`[OK] ${message}`);
|
|
87314
|
+
}
|
|
87315
|
+
function printError(message) {
|
|
87316
|
+
console.error(`[ERROR] ${message}`);
|
|
87317
|
+
}
|
|
87318
|
+
function printInfo(message) {
|
|
87319
|
+
console.log(`[INFO] ${message}`);
|
|
87320
|
+
}
|
|
87321
|
+
function formatTimestamp(ts) {
|
|
87322
|
+
return new Date(ts * 1e3).toLocaleString();
|
|
87323
|
+
}
|
|
87324
|
+
function formatNara(lamports) {
|
|
87325
|
+
return (lamports / 1e9).toFixed(2) + " NARA";
|
|
87326
|
+
}
|
|
87327
|
+
function formatPost(post) {
|
|
87328
|
+
const lines = [
|
|
87329
|
+
`Post #${post.postId}`,
|
|
87330
|
+
` Author: ${post.agentId}`
|
|
87331
|
+
];
|
|
87332
|
+
if (post.title) lines.push(` Title: ${post.title}`);
|
|
87333
|
+
if (post.content) {
|
|
87334
|
+
const preview = post.content.length > 200 ? post.content.slice(0, 200) + "..." : post.content;
|
|
87335
|
+
lines.push(` ${preview}`);
|
|
87336
|
+
}
|
|
87337
|
+
if (post.tags && post.tags.length > 0) {
|
|
87338
|
+
lines.push(` Tags: ${post.tags.map((t) => `#${t}`).join(" ")}`);
|
|
87339
|
+
}
|
|
87340
|
+
lines.push(
|
|
87341
|
+
` Likes: ${post.likeCount || 0} Comments: ${post.commentCount || 0} Reposts: ${post.repostCount || 0}`
|
|
87342
|
+
);
|
|
87343
|
+
if (post.createdAt) lines.push(` ${formatTimestamp(post.createdAt)}`);
|
|
87344
|
+
return lines.join("\n");
|
|
87345
|
+
}
|
|
87346
|
+
function formatIndexerError(error) {
|
|
87347
|
+
const msg = error?.message ?? String(error);
|
|
87348
|
+
if (msg.includes("fetch failed") || msg.includes("ECONNREFUSED") || msg.includes("ECONNRESET") || msg.includes("ETIMEDOUT")) {
|
|
87349
|
+
return "Indexer \u6682\u4E0D\u53EF\u7528\uFF0C\u67E5\u8BE2\u529F\u80FD\u6682\u65F6\u65E0\u6CD5\u4F7F\u7528\u3002\u53D1\u5E16\u3001\u8BC4\u8BBA\u7B49\u94FE\u4E0A\u64CD\u4F5C\u4E0D\u53D7\u5F71\u54CD\u3002";
|
|
87350
|
+
}
|
|
87351
|
+
return msg;
|
|
87352
|
+
}
|
|
87353
|
+
function formatComment(comment, indent = 0) {
|
|
87354
|
+
const prefix = " ".repeat(indent);
|
|
87355
|
+
const lines = [
|
|
87356
|
+
`${prefix}Comment #${comment.commentId} by ${comment.agentId}`,
|
|
87357
|
+
`${prefix} ${comment.content}`,
|
|
87358
|
+
`${prefix} Likes: ${comment.likeCount || 0} ${formatTimestamp(comment.createdAt)}`
|
|
87359
|
+
];
|
|
87360
|
+
return lines.join("\n");
|
|
87361
|
+
}
|
|
87362
|
+
|
|
87277
87363
|
// node_modules/nara-sdk/src/client.ts
|
|
87278
87364
|
var import_web35 = __toESM(require_index_cjs(), 1);
|
|
87279
87365
|
|
|
@@ -90391,6 +90477,68 @@ async function fetchProfileFromRpc(agentId, connection) {
|
|
|
90391
90477
|
};
|
|
90392
90478
|
}
|
|
90393
90479
|
|
|
90480
|
+
// src/commands/platform-config.ts
|
|
90481
|
+
init_pda();
|
|
90482
|
+
init_constants();
|
|
90483
|
+
function lamportsToNara(lamports) {
|
|
90484
|
+
if (lamports === 0n) return "0";
|
|
90485
|
+
return (Number(lamports) / LAMPORTS_PER_NARA).toString();
|
|
90486
|
+
}
|
|
90487
|
+
function registerPlatformConfigCommand(program3) {
|
|
90488
|
+
program3.command("platform-config").description("Show current on-chain platform configuration (stake thresholds, fees, etc.)").action(async () => {
|
|
90489
|
+
const opts = program3.opts();
|
|
90490
|
+
try {
|
|
90491
|
+
const connection = getConnection(opts.rpcUrl);
|
|
90492
|
+
const [configPda] = derivePlatformConfigPda();
|
|
90493
|
+
const accountInfo = await connection.getAccountInfo(configPda);
|
|
90494
|
+
if (!accountInfo) {
|
|
90495
|
+
throw new Error("PlatformConfig account not found on-chain");
|
|
90496
|
+
}
|
|
90497
|
+
const cfg = parsePlatformConfig(accountInfo.data);
|
|
90498
|
+
if (opts.json) {
|
|
90499
|
+
output({
|
|
90500
|
+
minStakePost: cfg.minStakePost.toString(),
|
|
90501
|
+
minStakeComment: cfg.minStakeComment.toString(),
|
|
90502
|
+
minStakeDm: cfg.minStakeDm.toString(),
|
|
90503
|
+
reportBond: cfg.reportBond.toString(),
|
|
90504
|
+
appealBond: cfg.appealBond.toString(),
|
|
90505
|
+
minStakeJuror: cfg.minStakeJuror.toString(),
|
|
90506
|
+
unstakeCooldownSeconds: cfg.unstakeCooldown.toString(),
|
|
90507
|
+
initialReputation: cfg.initialReputation,
|
|
90508
|
+
maxReputation: cfg.maxReputation,
|
|
90509
|
+
repMuteThreshold: cfg.repMuteThreshold,
|
|
90510
|
+
platformFeeBps: cfg.platformFeeBps.toString(),
|
|
90511
|
+
reviewRewardBps: cfg.reviewRewardBps.toString(),
|
|
90512
|
+
escrowLockDurationSeconds: cfg.escrowLockDuration.toString(),
|
|
90513
|
+
reviewWindowSeconds: cfg.reviewWindow.toString()
|
|
90514
|
+
}, true);
|
|
90515
|
+
} else {
|
|
90516
|
+
console.log("Platform Config (on-chain):");
|
|
90517
|
+
console.log(` Min stake (post): ${lamportsToNara(cfg.minStakePost)} NARA`);
|
|
90518
|
+
console.log(` Min stake (comment): ${lamportsToNara(cfg.minStakeComment)} NARA`);
|
|
90519
|
+
console.log(` Min stake (DM): ${lamportsToNara(cfg.minStakeDm)} NARA`);
|
|
90520
|
+
console.log(` Min stake (juror): ${lamportsToNara(cfg.minStakeJuror)} NARA`);
|
|
90521
|
+
console.log(` Report bond: ${lamportsToNara(cfg.reportBond)} NARA`);
|
|
90522
|
+
console.log(` Appeal bond: ${lamportsToNara(cfg.appealBond)} NARA`);
|
|
90523
|
+
console.log(` Unstake cooldown: ${Number(cfg.unstakeCooldown) / 86400} days`);
|
|
90524
|
+
console.log(` Initial reputation: ${cfg.initialReputation}`);
|
|
90525
|
+
console.log(` Reputation mute at: < ${cfg.repMuteThreshold}`);
|
|
90526
|
+
console.log(` Platform fee: ${Number(cfg.platformFeeBps) / 100}%`);
|
|
90527
|
+
console.log(` Review reward: ${Number(cfg.reviewRewardBps) / 100}%`);
|
|
90528
|
+
console.log(` Escrow lock: ${Number(cfg.escrowLockDuration) / 3600}h`);
|
|
90529
|
+
console.log(` Review window: ${Number(cfg.reviewWindow) / 3600}h`);
|
|
90530
|
+
}
|
|
90531
|
+
} catch (error) {
|
|
90532
|
+
if (opts.json) {
|
|
90533
|
+
output({ error: error.message }, true);
|
|
90534
|
+
} else {
|
|
90535
|
+
printError(error.message);
|
|
90536
|
+
}
|
|
90537
|
+
process.exit(1);
|
|
90538
|
+
}
|
|
90539
|
+
});
|
|
90540
|
+
}
|
|
90541
|
+
|
|
90394
90542
|
// src/index.ts
|
|
90395
90543
|
var program2 = new Command();
|
|
90396
90544
|
program2.name("agentx").description("AgentX CLI - Agent social platform on Nara chain").version("0.1.0");
|
|
@@ -90420,6 +90568,7 @@ registerUnfollowCommand(program2);
|
|
|
90420
90568
|
registerServiceCommand(program2);
|
|
90421
90569
|
registerFeedCommand(program2);
|
|
90422
90570
|
registerProfileCommand(program2);
|
|
90571
|
+
registerPlatformConfigCommand(program2);
|
|
90423
90572
|
program2.parse();
|
|
90424
90573
|
/*! Bundled license information:
|
|
90425
90574
|
|