@otonix/cli 1.3.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.
Files changed (2) hide show
  1. package/dist/cli.js +478 -1
  2. package/package.json +3 -3
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.3.0";
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() {
@@ -114,6 +114,23 @@ var HELP = `
114
114
  templates:deploy Deploy an agent from a template
115
115
  marketplace List marketplace services
116
116
  x402 Show x402 payment config
117
+ bv7x:promote <id> Promote an agent to mothership
118
+ bv7x:spawn Spawn a satellite from a BV-7X template
119
+ bv7x:satellites <id> List satellites of a mothership
120
+ bv7x:destroy <id> Destroy (terminate) a satellite
121
+ bv7x:report <id> Send a satellite data report
122
+ bv7x:fleet Show full BV-7X fleet overview
123
+ webhook:create Create a new webhook endpoint
124
+ webhook:list List registered webhooks
125
+ webhook:delete <id> Delete a webhook
126
+ webhook:test <id> Send a test delivery to a webhook
127
+ webhook:deliveries Show webhook delivery history
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
117
134
  llm:init <key> Configure Bankr LLM Gateway API key
118
135
  llm:models List available LLM models
119
136
  llm:chat <prompt> Send a chat completion request
@@ -779,6 +796,415 @@ async function cmdLlmHealth() {
779
796
  }
780
797
  console.log();
781
798
  }
799
+ async function cmdBv7xPromote(agentId) {
800
+ if (!agentId) {
801
+ console.error(" Usage: otonix bv7x:promote <agentId>");
802
+ process.exit(1);
803
+ }
804
+ const client = getClient();
805
+ const result = await client.promoteMothership(agentId);
806
+ console.log(`
807
+ Agent promoted to mothership:`);
808
+ console.log(` ID: ${result.agent.id}`);
809
+ console.log(` Name: ${result.agent.name}`);
810
+ console.log(` Role: ${result.agent.role}
811
+ `);
812
+ }
813
+ async function cmdBv7xSpawn(args) {
814
+ const client = getClient();
815
+ let mothershipId = "";
816
+ let templateSlug = "";
817
+ let name = "";
818
+ let vpsIp = "";
819
+ let wallet = "";
820
+ for (let i = 0; i < args.length; i++) {
821
+ if (args[i] === "--mothership" && args[i + 1]) mothershipId = args[++i];
822
+ else if (args[i] === "--template" && args[i + 1]) templateSlug = args[++i];
823
+ else if (args[i] === "--name" && args[i + 1]) name = args[++i];
824
+ else if (args[i] === "--vps" && args[i + 1]) vpsIp = args[++i];
825
+ else if (args[i] === "--wallet" && args[i + 1]) wallet = args[++i];
826
+ }
827
+ if (!mothershipId) mothershipId = await prompt(" Mothership Agent ID: ");
828
+ if (!templateSlug) templateSlug = await prompt(" Template slug (e.g. bv7x-alpha-trader): ");
829
+ if (!name) name = await prompt(" Satellite name: ");
830
+ if (!mothershipId || !templateSlug || !name) {
831
+ console.error(" Error: --mothership, --template, and --name are required.");
832
+ process.exit(1);
833
+ }
834
+ const result = await client.spawnSatellite({
835
+ mothershipId,
836
+ templateSlug,
837
+ name,
838
+ vpsIp: vpsIp || void 0,
839
+ walletAddress: wallet || void 0
840
+ });
841
+ console.log(`
842
+ Satellite Spawned:`);
843
+ console.log(` ID: ${result.satellite.id}`);
844
+ console.log(` Name: ${result.satellite.name}`);
845
+ console.log(` Model: ${result.satellite.model}`);
846
+ console.log(` Role: ${result.satellite.role}`);
847
+ console.log(` Template: ${result.template.name}`);
848
+ console.log(` Mothership: ${result.mothership.name} (${result.mothership.childrenCount} satellites)
849
+ `);
850
+ }
851
+ async function cmdBv7xSatellites(mothershipId) {
852
+ if (!mothershipId) {
853
+ console.error(" Usage: otonix bv7x:satellites <mothershipId>");
854
+ process.exit(1);
855
+ }
856
+ const client = getClient();
857
+ const result = await client.getMothershipSatellites(mothershipId);
858
+ console.log(`
859
+ Mothership: ${result.mothership.name} (${result.count} satellites)
860
+ `);
861
+ if (!result.satellites.length) {
862
+ console.log(" No satellites spawned yet.\n");
863
+ return;
864
+ }
865
+ printTable(result.satellites.map((s) => ({
866
+ ID: s.id.slice(0, 8),
867
+ Name: s.name,
868
+ Status: s.status,
869
+ Tier: s.survivalTier,
870
+ Model: s.model,
871
+ Heartbeat: formatTime(s.lastHeartbeat),
872
+ Actions: s.totalActions
873
+ })));
874
+ console.log();
875
+ }
876
+ async function cmdBv7xDestroy(satelliteId) {
877
+ if (!satelliteId) {
878
+ console.error(" Usage: otonix bv7x:destroy <satelliteId>");
879
+ process.exit(1);
880
+ }
881
+ const client = getClient();
882
+ const result = await client.destroySatellite(satelliteId);
883
+ console.log(` ${result.message}`);
884
+ }
885
+ async function cmdBv7xReport(args) {
886
+ let satelliteId = "";
887
+ let reportType = "general";
888
+ let dataStr = "";
889
+ for (let i = 0; i < args.length; i++) {
890
+ if (args[i] === "--type" && args[i + 1]) reportType = args[++i];
891
+ else if (args[i] === "--data" && args[i + 1]) dataStr = args[++i];
892
+ else if (!satelliteId) satelliteId = args[i];
893
+ }
894
+ if (!satelliteId) {
895
+ console.error(" Usage: otonix bv7x:report <satelliteId> --type <type> --data '<json>'");
896
+ process.exit(1);
897
+ }
898
+ let data = {};
899
+ if (dataStr) {
900
+ try {
901
+ data = JSON.parse(dataStr);
902
+ } catch {
903
+ console.error(" Error: --data must be valid JSON");
904
+ process.exit(1);
905
+ }
906
+ } else {
907
+ const raw = await prompt(" Report data (JSON): ");
908
+ try {
909
+ data = JSON.parse(raw);
910
+ } catch {
911
+ console.error(" Error: Invalid JSON");
912
+ process.exit(1);
913
+ }
914
+ }
915
+ const client = getClient();
916
+ await client.satelliteReport(satelliteId, { data, reportType });
917
+ console.log(` Report sent (type: ${reportType})`);
918
+ }
919
+ async function cmdBv7xFleet() {
920
+ const client = getClient();
921
+ const fleet = await client.getFleet();
922
+ console.log(`
923
+ BV-7X Fleet Overview`);
924
+ console.log(` Motherships: ${fleet.totalMotherships}`);
925
+ console.log(` Satellites: ${fleet.totalSatellites}`);
926
+ if (fleet.fleet.length) {
927
+ for (const f of fleet.fleet) {
928
+ console.log(`
929
+ \u250C Mothership: ${f.mothership.name} [${f.mothership.status}] \u2014 ${f.satelliteCount} satellite(s)`);
930
+ for (const s of f.satellites) {
931
+ console.log(` \u2502 \u2514 ${s.name} [${s.status}] tier:${s.survivalTier} heartbeat:${formatTime(s.lastHeartbeat)}`);
932
+ }
933
+ }
934
+ }
935
+ if (fleet.orphanedSatellites.length) {
936
+ console.log(`
937
+ Orphaned Satellites: ${fleet.orphanedSatellites.length}`);
938
+ for (const s of fleet.orphanedSatellites) {
939
+ console.log(` \u2022 ${s.name} [${s.status}]`);
940
+ }
941
+ }
942
+ console.log();
943
+ }
944
+ async function cmdWebhookCreate(args) {
945
+ const client = getClient();
946
+ let url = "";
947
+ let agentId = "";
948
+ const events = [];
949
+ for (let i = 0; i < args.length; i++) {
950
+ if (args[i] === "--url" && args[i + 1]) url = args[++i];
951
+ else if (args[i] === "--agent" && args[i + 1]) agentId = args[++i];
952
+ else if (args[i] === "--event" && args[i + 1]) events.push(args[++i]);
953
+ }
954
+ if (!url) url = await prompt(" Webhook URL: ");
955
+ if (!url) {
956
+ console.error(" Error: URL is required.");
957
+ process.exit(1);
958
+ }
959
+ const result = await client.createWebhook({
960
+ url,
961
+ events: events.length ? events : void 0,
962
+ agentId: agentId || void 0
963
+ });
964
+ console.log(`
965
+ Webhook Created:`);
966
+ console.log(` ID: ${result.id}`);
967
+ console.log(` URL: ${result.url}`);
968
+ console.log(` Events: ${result.events.length ? result.events.join(", ") : "all"}`);
969
+ console.log(` Secret: ${result.secret}`);
970
+ console.log(`
971
+ Save this secret \u2014 it won't be shown again.
972
+ `);
973
+ }
974
+ async function cmdWebhookList() {
975
+ const client = getClient();
976
+ const hooks = await client.listWebhooks();
977
+ if (!hooks.length) {
978
+ console.log("\n No webhooks registered.\n");
979
+ return;
980
+ }
981
+ console.log(`
982
+ Webhooks (${hooks.length}):
983
+ `);
984
+ printTable(hooks.map((h) => ({
985
+ ID: h.id.slice(0, 8),
986
+ URL: h.url.length > 40 ? h.url.slice(0, 37) + "..." : h.url,
987
+ Events: h.events.length ? h.events.length + " types" : "all",
988
+ Status: h.status,
989
+ Fails: h.failCount,
990
+ Agent: h.agentId?.slice(0, 8) || "global"
991
+ })));
992
+ console.log();
993
+ }
994
+ async function cmdWebhookDelete(webhookId) {
995
+ if (!webhookId) {
996
+ console.error(" Usage: otonix webhook:delete <webhookId>");
997
+ process.exit(1);
998
+ }
999
+ const client = getClient();
1000
+ const result = await client.deleteWebhook(webhookId);
1001
+ console.log(` ${result.message}`);
1002
+ }
1003
+ async function cmdWebhookTest(webhookId) {
1004
+ if (!webhookId) {
1005
+ console.error(" Usage: otonix webhook:test <webhookId>");
1006
+ process.exit(1);
1007
+ }
1008
+ const client = getClient();
1009
+ const result = await client.testWebhook(webhookId);
1010
+ console.log(` ${result.message}`);
1011
+ }
1012
+ async function cmdWebhookDeliveries(args) {
1013
+ let webhookId = args[0] || "";
1014
+ if (!webhookId) {
1015
+ console.error(" Usage: otonix webhook:deliveries <webhookId>");
1016
+ process.exit(1);
1017
+ }
1018
+ const client = getClient();
1019
+ const deliveries = await client.getWebhookDeliveries(webhookId);
1020
+ if (!deliveries.length) {
1021
+ console.log("\n No deliveries found.\n");
1022
+ return;
1023
+ }
1024
+ console.log(`
1025
+ Webhook Deliveries (${deliveries.length}):
1026
+ `);
1027
+ printTable(deliveries.slice(0, 20).map((d) => ({
1028
+ Event: d.event,
1029
+ Status: d.statusCode || "\u2014",
1030
+ Success: d.success ? "yes" : "no",
1031
+ Time: formatTime(d.createdAt),
1032
+ Response: (d.response || "\u2014").slice(0, 30)
1033
+ })));
1034
+ console.log();
1035
+ }
1036
+ async function cmdWebhookEvents() {
1037
+ const client = getClient();
1038
+ const result = await client.listWebhookEvents();
1039
+ console.log(`
1040
+ Available Webhook Events (${result.events.length}):
1041
+ `);
1042
+ for (const event of result.events) {
1043
+ console.log(` \u2022 ${event}`);
1044
+ }
1045
+ console.log();
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
+ }
782
1208
  function cmdWhoami() {
783
1209
  const config = loadConfig();
784
1210
  if (!config) {
@@ -861,6 +1287,57 @@ async function main() {
861
1287
  case "x402":
862
1288
  await cmdX402();
863
1289
  break;
1290
+ case "bv7x:promote":
1291
+ await cmdBv7xPromote(rest[0]);
1292
+ break;
1293
+ case "bv7x:spawn":
1294
+ await cmdBv7xSpawn(rest);
1295
+ break;
1296
+ case "bv7x:satellites":
1297
+ await cmdBv7xSatellites(rest[0]);
1298
+ break;
1299
+ case "bv7x:destroy":
1300
+ await cmdBv7xDestroy(rest[0]);
1301
+ break;
1302
+ case "bv7x:report":
1303
+ await cmdBv7xReport(rest);
1304
+ break;
1305
+ case "bv7x:fleet":
1306
+ await cmdBv7xFleet();
1307
+ break;
1308
+ case "webhook:create":
1309
+ await cmdWebhookCreate(rest);
1310
+ break;
1311
+ case "webhook:list":
1312
+ await cmdWebhookList();
1313
+ break;
1314
+ case "webhook:delete":
1315
+ await cmdWebhookDelete(rest[0]);
1316
+ break;
1317
+ case "webhook:test":
1318
+ await cmdWebhookTest(rest[0]);
1319
+ break;
1320
+ case "webhook:deliveries":
1321
+ await cmdWebhookDeliveries(rest);
1322
+ break;
1323
+ case "webhook:events":
1324
+ await cmdWebhookEvents();
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;
864
1341
  case "llm:init":
865
1342
  cmdLlmInit(rest[0]);
866
1343
  break;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@otonix/cli",
3
- "version": "1.3.0",
4
- "description": "CLI tool for the Otonix sovereign compute platform — initialize agents, generate API keys, register, monitor status, and manage infrastructure from the terminal.",
3
+ "version": "1.5.0",
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": {
7
7
  "otonix": "dist/cli.js"
@@ -38,7 +38,7 @@
38
38
  "node": ">=18"
39
39
  },
40
40
  "dependencies": {
41
- "@otonix/sdk": "^1.3.0"
41
+ "@otonix/sdk": "^1.5.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsup": "^8.0.0",