@otonix/cli 1.4.0 → 1.5.0
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.js +182 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -28,7 +28,7 @@ var import_sdk = require("@otonix/sdk");
|
|
|
28
28
|
var fs = __toESM(require("fs"));
|
|
29
29
|
var path = __toESM(require("path"));
|
|
30
30
|
var readline = __toESM(require("readline"));
|
|
31
|
-
var VERSION = "1.
|
|
31
|
+
var VERSION = "1.5.0";
|
|
32
32
|
var CONFIG_DIR = path.join(process.env.HOME || "~", ".otonix");
|
|
33
33
|
var CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
|
|
34
34
|
function loadConfig() {
|
|
@@ -126,6 +126,11 @@ var HELP = `
|
|
|
126
126
|
webhook:test <id> Send a test delivery to a webhook
|
|
127
127
|
webhook:deliveries Show webhook delivery history
|
|
128
128
|
webhook:events List all available webhook events
|
|
129
|
+
trade:list List all service listings on marketplace
|
|
130
|
+
trade:create Create a service listing for an agent
|
|
131
|
+
trade:buy Buy a service from another agent
|
|
132
|
+
trade:orders Show trading order history
|
|
133
|
+
activity [--limit N] Show live activity feed
|
|
129
134
|
llm:init <key> Configure Bankr LLM Gateway API key
|
|
130
135
|
llm:models List available LLM models
|
|
131
136
|
llm:chat <prompt> Send a chat completion request
|
|
@@ -1039,6 +1044,167 @@ async function cmdWebhookEvents() {
|
|
|
1039
1044
|
}
|
|
1040
1045
|
console.log();
|
|
1041
1046
|
}
|
|
1047
|
+
async function cmdTradeList() {
|
|
1048
|
+
const client = getClient();
|
|
1049
|
+
const listings = await client.listServiceListings();
|
|
1050
|
+
if (!listings.length) {
|
|
1051
|
+
console.log("\n No service listings on the marketplace.\n");
|
|
1052
|
+
return;
|
|
1053
|
+
}
|
|
1054
|
+
console.log(`
|
|
1055
|
+
Marketplace Listings (${listings.length}):
|
|
1056
|
+
`);
|
|
1057
|
+
printTable(listings.map((l) => ({
|
|
1058
|
+
ID: l.id.slice(0, 8),
|
|
1059
|
+
Name: l.name,
|
|
1060
|
+
Category: l.category,
|
|
1061
|
+
Price: `${l.priceCredits} credits/${l.priceUnit}`,
|
|
1062
|
+
Rating: `${l.rating.toFixed(1)}/5`,
|
|
1063
|
+
Jobs: l.totalJobs,
|
|
1064
|
+
Seller: l.agentId.slice(0, 8),
|
|
1065
|
+
Status: l.status
|
|
1066
|
+
})));
|
|
1067
|
+
console.log();
|
|
1068
|
+
}
|
|
1069
|
+
async function cmdTradeCreate(args) {
|
|
1070
|
+
const client = getClient();
|
|
1071
|
+
let agentId = "";
|
|
1072
|
+
let name = "";
|
|
1073
|
+
let slug = "";
|
|
1074
|
+
let category = "general";
|
|
1075
|
+
let description = "";
|
|
1076
|
+
let price = 0;
|
|
1077
|
+
let priceUnit = "per request";
|
|
1078
|
+
for (let i = 0; i < args.length; i++) {
|
|
1079
|
+
if (args[i] === "--agent" && args[i + 1]) agentId = args[++i];
|
|
1080
|
+
else if (args[i] === "--name" && args[i + 1]) name = args[++i];
|
|
1081
|
+
else if (args[i] === "--slug" && args[i + 1]) slug = args[++i];
|
|
1082
|
+
else if (args[i] === "--category" && args[i + 1]) category = args[++i];
|
|
1083
|
+
else if (args[i] === "--desc" && args[i + 1]) description = args[++i];
|
|
1084
|
+
else if (args[i] === "--price" && args[i + 1]) price = parseFloat(args[++i]);
|
|
1085
|
+
else if (args[i] === "--unit" && args[i + 1]) priceUnit = args[++i];
|
|
1086
|
+
}
|
|
1087
|
+
if (!agentId) agentId = await prompt(" Seller Agent ID: ");
|
|
1088
|
+
if (!name) name = await prompt(" Service name: ");
|
|
1089
|
+
if (!slug) slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/-+$/, "");
|
|
1090
|
+
if (!description) description = await prompt(" Description: ");
|
|
1091
|
+
if (!price) {
|
|
1092
|
+
const p = await prompt(" Price (credits): ");
|
|
1093
|
+
price = parseFloat(p);
|
|
1094
|
+
}
|
|
1095
|
+
if (!agentId || !name || !description || !price) {
|
|
1096
|
+
console.error(" Error: agent, name, description, and price are required.");
|
|
1097
|
+
process.exit(1);
|
|
1098
|
+
}
|
|
1099
|
+
try {
|
|
1100
|
+
const listing = await client.createServiceListing({
|
|
1101
|
+
agentId,
|
|
1102
|
+
name,
|
|
1103
|
+
slug,
|
|
1104
|
+
category,
|
|
1105
|
+
description,
|
|
1106
|
+
priceCredits: price,
|
|
1107
|
+
priceUnit
|
|
1108
|
+
});
|
|
1109
|
+
console.log(`
|
|
1110
|
+
Service Listed:`);
|
|
1111
|
+
console.log(` ID: ${listing.id}`);
|
|
1112
|
+
console.log(` Name: ${listing.name}`);
|
|
1113
|
+
console.log(` Slug: ${listing.slug}`);
|
|
1114
|
+
console.log(` Category: ${listing.category}`);
|
|
1115
|
+
console.log(` Price: ${listing.priceCredits} credits/${listing.priceUnit}`);
|
|
1116
|
+
console.log(` Status: ${listing.status}
|
|
1117
|
+
`);
|
|
1118
|
+
} catch (err) {
|
|
1119
|
+
console.error(` Error: ${err.message}`);
|
|
1120
|
+
process.exit(1);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
async function cmdTradeBuy(args) {
|
|
1124
|
+
const client = getClient();
|
|
1125
|
+
let buyerAgentId = "";
|
|
1126
|
+
let listingId = "";
|
|
1127
|
+
for (let i = 0; i < args.length; i++) {
|
|
1128
|
+
if (args[i] === "--buyer" && args[i + 1]) buyerAgentId = args[++i];
|
|
1129
|
+
else if (args[i] === "--listing" && args[i + 1]) listingId = args[++i];
|
|
1130
|
+
}
|
|
1131
|
+
if (!buyerAgentId) buyerAgentId = await prompt(" Buyer Agent ID: ");
|
|
1132
|
+
if (!listingId) listingId = await prompt(" Service Listing ID: ");
|
|
1133
|
+
if (!buyerAgentId || !listingId) {
|
|
1134
|
+
console.error(" Error: --buyer and --listing are required.");
|
|
1135
|
+
process.exit(1);
|
|
1136
|
+
}
|
|
1137
|
+
try {
|
|
1138
|
+
const result = await client.buyService({ buyerAgentId, serviceListingId: listingId });
|
|
1139
|
+
if (result.success) {
|
|
1140
|
+
console.log(`
|
|
1141
|
+
Purchase Successful:`);
|
|
1142
|
+
console.log(` Service: ${result.service.name}`);
|
|
1143
|
+
console.log(` Price: ${result.service.price} credits`);
|
|
1144
|
+
console.log(` Buyer: ${result.buyer.name} (balance: $${result.buyer.credits.toFixed(2)})`);
|
|
1145
|
+
console.log(` Seller: ${result.seller.name}`);
|
|
1146
|
+
console.log(` Order: ${result.order.id}
|
|
1147
|
+
`);
|
|
1148
|
+
} else {
|
|
1149
|
+
console.error(" Purchase failed.");
|
|
1150
|
+
}
|
|
1151
|
+
} catch (err) {
|
|
1152
|
+
console.error(` Error: ${err.message}`);
|
|
1153
|
+
process.exit(1);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
async function cmdTradeOrders(args) {
|
|
1157
|
+
const client = getClient();
|
|
1158
|
+
const config = loadConfig();
|
|
1159
|
+
let agentId = "";
|
|
1160
|
+
for (let i = 0; i < args.length; i++) {
|
|
1161
|
+
if (args[i] === "--agent" && args[i + 1]) agentId = args[++i];
|
|
1162
|
+
}
|
|
1163
|
+
if (!agentId) agentId = config.agentId || "";
|
|
1164
|
+
const orders = await client.listTradingOrders(agentId || void 0);
|
|
1165
|
+
if (!orders.length) {
|
|
1166
|
+
console.log("\n No trading orders found.\n");
|
|
1167
|
+
return;
|
|
1168
|
+
}
|
|
1169
|
+
console.log(`
|
|
1170
|
+
Trading Orders (${orders.length}):
|
|
1171
|
+
`);
|
|
1172
|
+
printTable(orders.map((o) => ({
|
|
1173
|
+
ID: o.id.slice(0, 8),
|
|
1174
|
+
Buyer: o.buyerAgentId.slice(0, 8),
|
|
1175
|
+
Seller: o.sellerAgentId.slice(0, 8),
|
|
1176
|
+
Amount: `${o.amount} credits`,
|
|
1177
|
+
Status: o.status,
|
|
1178
|
+
Date: new Date(o.createdAt).toLocaleDateString()
|
|
1179
|
+
})));
|
|
1180
|
+
console.log();
|
|
1181
|
+
}
|
|
1182
|
+
async function cmdActivity(args) {
|
|
1183
|
+
const client = getClient();
|
|
1184
|
+
let limit = 20;
|
|
1185
|
+
let agentId = "";
|
|
1186
|
+
for (let i = 0; i < args.length; i++) {
|
|
1187
|
+
if (args[i] === "--limit" && args[i + 1]) limit = parseInt(args[++i]);
|
|
1188
|
+
else if (args[i] === "--agent" && args[i + 1]) agentId = args[++i];
|
|
1189
|
+
}
|
|
1190
|
+
const events = await client.getActivityFeed(limit, agentId || void 0);
|
|
1191
|
+
if (!events.length) {
|
|
1192
|
+
console.log("\n No activity events found.\n");
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
console.log(`
|
|
1196
|
+
Activity Feed (${events.length} events):
|
|
1197
|
+
`);
|
|
1198
|
+
for (const event of events) {
|
|
1199
|
+
const time = formatTime(event.createdAt);
|
|
1200
|
+
const agent = event.agentId ? event.agentId.slice(0, 8) : "system";
|
|
1201
|
+
console.log(` ${time.padEnd(10)} [${event.eventType.padEnd(25)}] ${event.title}`);
|
|
1202
|
+
if (event.details) {
|
|
1203
|
+
console.log(`${"".padEnd(13)} ${event.details}`);
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
console.log();
|
|
1207
|
+
}
|
|
1042
1208
|
function cmdWhoami() {
|
|
1043
1209
|
const config = loadConfig();
|
|
1044
1210
|
if (!config) {
|
|
@@ -1157,6 +1323,21 @@ async function main() {
|
|
|
1157
1323
|
case "webhook:events":
|
|
1158
1324
|
await cmdWebhookEvents();
|
|
1159
1325
|
break;
|
|
1326
|
+
case "trade:list":
|
|
1327
|
+
await cmdTradeList();
|
|
1328
|
+
break;
|
|
1329
|
+
case "trade:create":
|
|
1330
|
+
await cmdTradeCreate(rest);
|
|
1331
|
+
break;
|
|
1332
|
+
case "trade:buy":
|
|
1333
|
+
await cmdTradeBuy(rest);
|
|
1334
|
+
break;
|
|
1335
|
+
case "trade:orders":
|
|
1336
|
+
await cmdTradeOrders(rest);
|
|
1337
|
+
break;
|
|
1338
|
+
case "activity":
|
|
1339
|
+
await cmdActivity(rest);
|
|
1340
|
+
break;
|
|
1160
1341
|
case "llm:init":
|
|
1161
1342
|
cmdLlmInit(rest[0]);
|
|
1162
1343
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@otonix/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "CLI tool for the Otonix sovereign compute platform — initialize agents, generate API keys, register, monitor status, BV-7X fleet orchestration, webhook management, and manage infrastructure from the terminal.",
|
|
5
5
|
"main": "dist/cli.js",
|
|
6
6
|
"bin": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"node": ">=18"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@otonix/sdk": "^1.
|
|
41
|
+
"@otonix/sdk": "^1.5.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"tsup": "^8.0.0",
|