@net-protocol/cli 0.1.36 → 0.1.38
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/chat/index.mjs +3 -3
- package/dist/chat/index.mjs.map +1 -1
- package/dist/cli/index.mjs +70 -2
- package/dist/cli/index.mjs.map +1 -1
- package/dist/feed/index.d.ts +6 -1
- package/dist/feed/index.mjs +71 -3
- package/dist/feed/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/feed/index.d.ts
CHANGED
|
@@ -55,9 +55,14 @@ declare function registerFeedHistoryCommand(parent: Command): void;
|
|
|
55
55
|
*/
|
|
56
56
|
declare function registerAgentRegisterCommand(parent: Command): void;
|
|
57
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Register the list-agents subcommand
|
|
60
|
+
*/
|
|
61
|
+
declare function registerListAgentsCommand(parent: Command, commandName?: string): void;
|
|
62
|
+
|
|
58
63
|
/**
|
|
59
64
|
* Register the feed command group with the commander program
|
|
60
65
|
*/
|
|
61
66
|
declare function registerFeedCommand(program: Command): void;
|
|
62
67
|
|
|
63
|
-
export { registerAgentRegisterCommand, registerFeedCommand, registerFeedCommentReadCommand, registerFeedCommentWriteCommand, registerFeedConfigCommand, registerFeedHistoryCommand, registerFeedListCommand, registerFeedPostCommand, registerFeedPostsCommand, registerFeedReadCommand, registerFeedRegisterCommand, registerFeedRepliesCommand };
|
|
68
|
+
export { registerAgentRegisterCommand, registerFeedCommand, registerFeedCommentReadCommand, registerFeedCommentWriteCommand, registerFeedConfigCommand, registerFeedHistoryCommand, registerFeedListCommand, registerFeedPostCommand, registerFeedPostsCommand, registerFeedReadCommand, registerFeedRegisterCommand, registerFeedRepliesCommand, registerListAgentsCommand };
|
package/dist/feed/index.mjs
CHANGED
|
@@ -177,6 +177,21 @@ function commentToJson(comment, depth) {
|
|
|
177
177
|
data: comment.data !== "0x" ? comment.data : void 0
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
|
+
function formatAgent(agent, index) {
|
|
181
|
+
const timestamp = formatTimestamp(agent.timestamp);
|
|
182
|
+
const lines = [
|
|
183
|
+
chalk12.cyan(`[${index}]`) + ` ${chalk12.white(agent.address)}`,
|
|
184
|
+
` ${chalk12.gray("Registered:")} ${timestamp}`
|
|
185
|
+
];
|
|
186
|
+
return lines.join("\n");
|
|
187
|
+
}
|
|
188
|
+
function agentToJson(agent, index) {
|
|
189
|
+
return {
|
|
190
|
+
index,
|
|
191
|
+
address: agent.address,
|
|
192
|
+
timestamp: agent.timestamp
|
|
193
|
+
};
|
|
194
|
+
}
|
|
180
195
|
function printJson(data) {
|
|
181
196
|
console.log(JSON.stringify(data, null, 2));
|
|
182
197
|
}
|
|
@@ -481,7 +496,7 @@ async function executeFeedRead(feed, options) {
|
|
|
481
496
|
}
|
|
482
497
|
}
|
|
483
498
|
function registerFeedReadCommand(parent) {
|
|
484
|
-
parent.command("read <feed>").description("Read posts from a feed").option(
|
|
499
|
+
parent.command("read <feed>").description("Read posts from a feed (for group chats, use 'chat read' instead)").option(
|
|
485
500
|
"--limit <n>",
|
|
486
501
|
"Maximum number of posts to display",
|
|
487
502
|
(value) => parseInt(value, 10)
|
|
@@ -628,7 +643,7 @@ ${options.body}` : message;
|
|
|
628
643
|
}
|
|
629
644
|
}
|
|
630
645
|
function registerFeedPostCommand(parent) {
|
|
631
|
-
parent.command("post <feed> <message>").description("Post a message to a feed").option(
|
|
646
|
+
parent.command("post <feed> <message>").description("Post a message to a feed (for group chats, use 'chat send' instead)").option(
|
|
632
647
|
"--chain-id <id>",
|
|
633
648
|
"Chain ID (default: 8453 for Base)",
|
|
634
649
|
(value) => parseInt(value, 10)
|
|
@@ -1413,6 +1428,58 @@ function registerAgentRegisterCommand(parent) {
|
|
|
1413
1428
|
await executeRegisterAgent(options);
|
|
1414
1429
|
});
|
|
1415
1430
|
}
|
|
1431
|
+
async function executeListAgents(options) {
|
|
1432
|
+
const readOnlyOptions = parseReadOnlyOptionsWithDefault({
|
|
1433
|
+
chainId: options.chainId,
|
|
1434
|
+
rpcUrl: options.rpcUrl
|
|
1435
|
+
});
|
|
1436
|
+
const client = createAgentRegistryClient(readOnlyOptions);
|
|
1437
|
+
try {
|
|
1438
|
+
const limit = options.limit ?? 100;
|
|
1439
|
+
const [totalCount, agents] = await Promise.all([
|
|
1440
|
+
client.getRegisteredAgentCount(),
|
|
1441
|
+
client.getRegisteredAgents({ maxAgents: limit })
|
|
1442
|
+
]);
|
|
1443
|
+
if (options.json) {
|
|
1444
|
+
printJson({
|
|
1445
|
+
totalCount,
|
|
1446
|
+
agents: agents.map((agent, i) => agentToJson(agent, i))
|
|
1447
|
+
});
|
|
1448
|
+
} else {
|
|
1449
|
+
if (agents.length === 0) {
|
|
1450
|
+
console.log(chalk12.yellow("No registered agents found"));
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1453
|
+
console.log(
|
|
1454
|
+
chalk12.white(`Registered agents: ${totalCount} total, showing last ${agents.length}:
|
|
1455
|
+
`)
|
|
1456
|
+
);
|
|
1457
|
+
agents.forEach((agent, i) => {
|
|
1458
|
+
console.log(formatAgent(agent, i));
|
|
1459
|
+
if (i < agents.length - 1) {
|
|
1460
|
+
console.log();
|
|
1461
|
+
}
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1464
|
+
} catch (error) {
|
|
1465
|
+
exitWithError(
|
|
1466
|
+
`Failed to fetch agents: ${error instanceof Error ? error.message : String(error)}`
|
|
1467
|
+
);
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
function registerListAgentsCommand(parent, commandName = "list-agents") {
|
|
1471
|
+
parent.command(commandName).description("List registered agents from the agent registry").option(
|
|
1472
|
+
"--limit <n>",
|
|
1473
|
+
"Maximum number of agents to display (default: 100)",
|
|
1474
|
+
(value) => parseInt(value, 10)
|
|
1475
|
+
).option(
|
|
1476
|
+
"--chain-id <id>",
|
|
1477
|
+
"Chain ID (default: 8453 for Base)",
|
|
1478
|
+
(value) => parseInt(value, 10)
|
|
1479
|
+
).option("--rpc-url <url>", "Custom RPC URL").option("--json", "Output in JSON format").action(async (options) => {
|
|
1480
|
+
await executeListAgents(options);
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1416
1483
|
|
|
1417
1484
|
// src/commands/feed/index.ts
|
|
1418
1485
|
function registerFeedCommand(program) {
|
|
@@ -1428,8 +1495,9 @@ function registerFeedCommand(program) {
|
|
|
1428
1495
|
registerFeedConfigCommand(feedCommand);
|
|
1429
1496
|
registerFeedHistoryCommand(feedCommand);
|
|
1430
1497
|
registerAgentRegisterCommand(feedCommand);
|
|
1498
|
+
registerListAgentsCommand(feedCommand);
|
|
1431
1499
|
}
|
|
1432
1500
|
|
|
1433
|
-
export { registerAgentRegisterCommand, registerFeedCommand, registerFeedCommentReadCommand, registerFeedCommentWriteCommand, registerFeedConfigCommand, registerFeedHistoryCommand, registerFeedListCommand, registerFeedPostCommand, registerFeedPostsCommand, registerFeedReadCommand, registerFeedRegisterCommand, registerFeedRepliesCommand };
|
|
1501
|
+
export { registerAgentRegisterCommand, registerFeedCommand, registerFeedCommentReadCommand, registerFeedCommentWriteCommand, registerFeedConfigCommand, registerFeedHistoryCommand, registerFeedListCommand, registerFeedPostCommand, registerFeedPostsCommand, registerFeedReadCommand, registerFeedRegisterCommand, registerFeedRepliesCommand, registerListAgentsCommand };
|
|
1434
1502
|
//# sourceMappingURL=index.mjs.map
|
|
1435
1503
|
//# sourceMappingURL=index.mjs.map
|