@net-protocol/cli 0.1.44 → 0.1.46
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/cli/index.mjs +80 -42
- package/dist/cli/index.mjs.map +1 -1
- package/dist/feed/index.mjs +22 -21
- package/dist/feed/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -7313,16 +7313,15 @@ async function executeFeedVerifyClaim(txHash, options) {
|
|
|
7313
7313
|
});
|
|
7314
7314
|
const netContract = getNetContract(readOnlyOptions.chainId);
|
|
7315
7315
|
const netClient = createNetClient(readOnlyOptions);
|
|
7316
|
-
const
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
|
|
7320
|
-
|
|
7321
|
-
|
|
7322
|
-
|
|
7323
|
-
)
|
|
7324
|
-
|
|
7325
|
-
return;
|
|
7316
|
+
const wasAlreadyRecorded = getHistory().some(
|
|
7317
|
+
(entry) => entry.txHash === txHash
|
|
7318
|
+
);
|
|
7319
|
+
if (wasAlreadyRecorded && !options.json) {
|
|
7320
|
+
console.log(
|
|
7321
|
+
chalk4.yellow(
|
|
7322
|
+
"Transaction already in history \u2014 re-deriving URLs from on-chain data."
|
|
7323
|
+
)
|
|
7324
|
+
);
|
|
7326
7325
|
}
|
|
7327
7326
|
const receipt = await publicClient.getTransactionReceipt({ hash: txHash }).catch(
|
|
7328
7327
|
() => exitWithError(
|
|
@@ -7405,15 +7404,18 @@ async function executeFeedVerifyClaim(txHash, options) {
|
|
|
7405
7404
|
postId = createPostId(message);
|
|
7406
7405
|
permalink = postPermalink(readOnlyOptions.chainId, { globalIndex });
|
|
7407
7406
|
}
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7407
|
+
if (!wasAlreadyRecorded) {
|
|
7408
|
+
addHistoryEntry({
|
|
7409
|
+
type,
|
|
7410
|
+
txHash,
|
|
7411
|
+
chainId: readOnlyOptions.chainId,
|
|
7412
|
+
feed: feedName,
|
|
7413
|
+
sender: message.sender,
|
|
7414
|
+
text: message.text,
|
|
7415
|
+
postId: type === "comment" ? parentPostId : postId
|
|
7416
|
+
});
|
|
7417
|
+
recorded++;
|
|
7418
|
+
}
|
|
7417
7419
|
const entry = {
|
|
7418
7420
|
type,
|
|
7419
7421
|
txHash,
|
|
@@ -7449,10 +7451,9 @@ async function executeFeedVerifyClaim(txHash, options) {
|
|
|
7449
7451
|
Tx: ${txHash}`;
|
|
7450
7452
|
console.log(chalk4.green(` ${label}`));
|
|
7451
7453
|
}
|
|
7452
|
-
recorded++;
|
|
7453
7454
|
}
|
|
7454
7455
|
if (options.json) {
|
|
7455
|
-
printJson({ recorded, entries });
|
|
7456
|
+
printJson({ alreadyRecorded: wasAlreadyRecorded, recorded, entries });
|
|
7456
7457
|
return;
|
|
7457
7458
|
}
|
|
7458
7459
|
if (recorded > 0) {
|
|
@@ -7970,12 +7971,12 @@ async function resolveAuth(options) {
|
|
|
7970
7971
|
);
|
|
7971
7972
|
}
|
|
7972
7973
|
const commonOptions = parseCommonOptionsWithDefault({
|
|
7973
|
-
privateKey,
|
|
7974
|
+
privateKey: options.privateKey,
|
|
7974
7975
|
chainId: options.chainId,
|
|
7975
7976
|
rpcUrl: options.rpcUrl
|
|
7976
7977
|
});
|
|
7977
7978
|
const account = privateKeyToAccount(commonOptions.privateKey);
|
|
7978
|
-
console.
|
|
7979
|
+
console.error(chalk4.blue("Creating session..."));
|
|
7979
7980
|
const { sessionToken: token } = await createRelaySession({
|
|
7980
7981
|
apiUrl,
|
|
7981
7982
|
chainId: commonOptions.chainId,
|
|
@@ -8012,24 +8013,42 @@ async function executeCreate(name, options) {
|
|
|
8012
8013
|
const filters = buildFilters(options);
|
|
8013
8014
|
if (filters) config.filters = filters;
|
|
8014
8015
|
const profile = buildProfile(options);
|
|
8015
|
-
|
|
8016
|
+
if (!options.json) {
|
|
8017
|
+
console.log(chalk4.blue(`Creating agent "${name}"...`));
|
|
8018
|
+
}
|
|
8016
8019
|
const result = await auth.client.createAgent({
|
|
8017
8020
|
sessionToken: auth.sessionToken,
|
|
8018
8021
|
config,
|
|
8019
8022
|
profile
|
|
8020
8023
|
});
|
|
8021
|
-
if (!result.success) {
|
|
8022
|
-
exitWithError(result.error || "Failed to create agent");
|
|
8023
|
-
}
|
|
8024
8024
|
if (options.json) {
|
|
8025
8025
|
console.log(jsonStringify(result));
|
|
8026
|
+
if (!result.success) process.exit(1);
|
|
8026
8027
|
return;
|
|
8027
8028
|
}
|
|
8029
|
+
if (!result.success) {
|
|
8030
|
+
exitWithError(result.error || "Failed to create agent");
|
|
8031
|
+
}
|
|
8028
8032
|
console.log(chalk4.green("Agent created successfully!"));
|
|
8029
8033
|
console.log(` Agent ID: ${result.agentId}`);
|
|
8030
8034
|
console.log(` Wallet: ${result.agentWalletAddress}`);
|
|
8031
8035
|
if (result.scheduleError) {
|
|
8032
|
-
|
|
8036
|
+
const isGasOut = /gas required exceeds allowance \(0\)/i.test(
|
|
8037
|
+
result.scheduleError
|
|
8038
|
+
);
|
|
8039
|
+
if (isGasOut) {
|
|
8040
|
+
console.log(
|
|
8041
|
+
chalk4.yellow(
|
|
8042
|
+
` Profile metadata write failed: the agent's wallet (${result.agentWalletAddress}) has 0 ETH for gas. It will be auto-funded on first \`agent run\`, or you can transfer a small amount of ETH to the wallet manually.`
|
|
8043
|
+
)
|
|
8044
|
+
);
|
|
8045
|
+
console.log(chalk4.gray(` Underlying revert:`));
|
|
8046
|
+
} else {
|
|
8047
|
+
console.log(chalk4.yellow(` On-chain follow-up failed:`));
|
|
8048
|
+
}
|
|
8049
|
+
console.log(
|
|
8050
|
+
chalk4.gray(` ${result.scheduleError.replace(/\n/g, "\n ")}`)
|
|
8051
|
+
);
|
|
8033
8052
|
}
|
|
8034
8053
|
} catch (error) {
|
|
8035
8054
|
exitWithError(
|
|
@@ -8122,20 +8141,23 @@ async function executeUpdate(agentId, options) {
|
|
|
8122
8141
|
"No changes specified. Use --name, --system-prompt, --schedule, --display-name, --bio, or filter options."
|
|
8123
8142
|
);
|
|
8124
8143
|
}
|
|
8125
|
-
|
|
8144
|
+
if (!options.json) {
|
|
8145
|
+
console.log(chalk4.blue(`Updating agent ${agentId}...`));
|
|
8146
|
+
}
|
|
8126
8147
|
const result = await auth.client.updateAgent({
|
|
8127
8148
|
sessionToken: auth.sessionToken,
|
|
8128
8149
|
agentId,
|
|
8129
8150
|
config: hasConfigChanges ? config : void 0,
|
|
8130
8151
|
profile
|
|
8131
8152
|
});
|
|
8132
|
-
if (!result.success) {
|
|
8133
|
-
exitWithError(result.error || "Failed to update agent");
|
|
8134
|
-
}
|
|
8135
8153
|
if (options.json) {
|
|
8136
8154
|
console.log(jsonStringify(result));
|
|
8155
|
+
if (!result.success) process.exit(1);
|
|
8137
8156
|
return;
|
|
8138
8157
|
}
|
|
8158
|
+
if (!result.success) {
|
|
8159
|
+
exitWithError(result.error || "Failed to update agent");
|
|
8160
|
+
}
|
|
8139
8161
|
console.log(chalk4.green("Agent updated successfully!"));
|
|
8140
8162
|
if (result.profileError) {
|
|
8141
8163
|
console.log(chalk4.yellow(` Profile warning: ${result.profileError}`));
|
|
@@ -8160,7 +8182,7 @@ async function executeToggleHidden(agentId, options, hide) {
|
|
|
8160
8182
|
const past = hide ? "hidden" : "unhidden";
|
|
8161
8183
|
try {
|
|
8162
8184
|
const auth = await resolveAuth(options);
|
|
8163
|
-
console.
|
|
8185
|
+
console.error(chalk4.blue(`${verb} agent ${agentId}...`));
|
|
8164
8186
|
const result = hide ? await auth.client.hideAgent(auth.sessionToken, agentId) : await auth.client.unhideAgent(auth.sessionToken, agentId);
|
|
8165
8187
|
if (!result.success) {
|
|
8166
8188
|
exitWithError(result.error || `Failed to ${hide ? "hide" : "unhide"} agent`);
|
|
@@ -8188,7 +8210,9 @@ async function executeRun(agentId, options) {
|
|
|
8188
8210
|
try {
|
|
8189
8211
|
const auth = await resolveAuth(options);
|
|
8190
8212
|
const mode = parseRunMode(options.mode);
|
|
8191
|
-
|
|
8213
|
+
if (!options.json) {
|
|
8214
|
+
console.log(chalk4.blue(`Running agent ${agentId} (mode: ${mode})...`));
|
|
8215
|
+
}
|
|
8192
8216
|
const result = await auth.client.runAgent({
|
|
8193
8217
|
sessionToken: auth.sessionToken,
|
|
8194
8218
|
agentId,
|
|
@@ -8196,6 +8220,7 @@ async function executeRun(agentId, options) {
|
|
|
8196
8220
|
});
|
|
8197
8221
|
if (options.json) {
|
|
8198
8222
|
console.log(jsonStringify(result));
|
|
8223
|
+
if (!result.success) process.exit(1);
|
|
8199
8224
|
return;
|
|
8200
8225
|
}
|
|
8201
8226
|
if (!result.success) {
|
|
@@ -8314,11 +8339,13 @@ async function executeDm(agentAddress, message, options) {
|
|
|
8314
8339
|
const auth = await resolveAuth(options);
|
|
8315
8340
|
const topic = options.topic ?? generateAgentChatTopic(agentAddress);
|
|
8316
8341
|
const isNewConversation = !options.topic;
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8342
|
+
if (!options.json) {
|
|
8343
|
+
console.log(
|
|
8344
|
+
chalk4.blue(
|
|
8345
|
+
isNewConversation ? `Starting new conversation with ${agentAddress}...` : `Continuing conversation ${topic}...`
|
|
8346
|
+
)
|
|
8347
|
+
);
|
|
8348
|
+
}
|
|
8322
8349
|
const result = await auth.client.sendMessage(
|
|
8323
8350
|
{
|
|
8324
8351
|
sessionToken: auth.sessionToken,
|
|
@@ -8331,8 +8358,12 @@ async function executeDm(agentAddress, message, options) {
|
|
|
8331
8358
|
);
|
|
8332
8359
|
if (options.json) {
|
|
8333
8360
|
console.log(jsonStringify(result));
|
|
8361
|
+
if (!result.success) process.exit(1);
|
|
8334
8362
|
return;
|
|
8335
8363
|
}
|
|
8364
|
+
if (!result.success) {
|
|
8365
|
+
exitWithError(result.error || "Failed to send DM");
|
|
8366
|
+
}
|
|
8336
8367
|
console.log();
|
|
8337
8368
|
console.log(chalk4.cyan("You: ") + message);
|
|
8338
8369
|
console.log(chalk4.green("Agent: ") + result.aiMessage);
|
|
@@ -8368,7 +8399,9 @@ async function executeDmList(options) {
|
|
|
8368
8399
|
);
|
|
8369
8400
|
}
|
|
8370
8401
|
const client = new AgentClient({ apiUrl, chainId });
|
|
8371
|
-
|
|
8402
|
+
if (!options.json) {
|
|
8403
|
+
console.log(chalk4.blue("Loading conversations..."));
|
|
8404
|
+
}
|
|
8372
8405
|
const conversations = await client.listConversations(operator, {
|
|
8373
8406
|
limit: options.limit
|
|
8374
8407
|
});
|
|
@@ -8416,7 +8449,9 @@ async function executeDmHistory(topic, options) {
|
|
|
8416
8449
|
);
|
|
8417
8450
|
}
|
|
8418
8451
|
const client = new AgentClient({ apiUrl, chainId });
|
|
8419
|
-
|
|
8452
|
+
if (!options.json) {
|
|
8453
|
+
console.log(chalk4.blue("Loading conversation history..."));
|
|
8454
|
+
}
|
|
8420
8455
|
const messages = await client.getConversationHistory(operator, topic, {
|
|
8421
8456
|
limit: options.limit
|
|
8422
8457
|
});
|
|
@@ -8569,7 +8604,10 @@ function registerAgentSessionCreateCommand(parent) {
|
|
|
8569
8604
|
"--expires-at <timestamp>",
|
|
8570
8605
|
"expiresAt value from session-encode (unix seconds)",
|
|
8571
8606
|
(v) => parseInt(v, 10)
|
|
8572
|
-
).option("--chain-id <id>", "Chain ID (default: 8453)", (v) => parseInt(v, 10)).option("--api-url <url>", "Net Protocol API URL").
|
|
8607
|
+
).option("--chain-id <id>", "Chain ID (default: 8453)", (v) => parseInt(v, 10)).option("--api-url <url>", "Net Protocol API URL").option(
|
|
8608
|
+
"--json",
|
|
8609
|
+
"Output as JSON (default behavior; included for consistency with peer commands)"
|
|
8610
|
+
).action(async (options) => {
|
|
8573
8611
|
await executeSessionCreate(options);
|
|
8574
8612
|
});
|
|
8575
8613
|
}
|