@net-protocol/cli 0.1.37 → 0.1.39
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 +68 -0
- package/dist/cli/index.mjs.map +1 -1
- package/dist/feed/index.d.ts +6 -1
- package/dist/feed/index.mjs +69 -1
- package/dist/feed/index.mjs.map +1 -1
- package/package.json +2 -2
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
|
}
|
|
@@ -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
|