@otonix/cli 1.3.0 → 1.4.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 +297 -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.4.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,18 @@ 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
117
129
  llm:init <key> Configure Bankr LLM Gateway API key
118
130
  llm:models List available LLM models
119
131
  llm:chat <prompt> Send a chat completion request
@@ -779,6 +791,254 @@ async function cmdLlmHealth() {
779
791
  }
780
792
  console.log();
781
793
  }
794
+ async function cmdBv7xPromote(agentId) {
795
+ if (!agentId) {
796
+ console.error(" Usage: otonix bv7x:promote <agentId>");
797
+ process.exit(1);
798
+ }
799
+ const client = getClient();
800
+ const result = await client.promoteMothership(agentId);
801
+ console.log(`
802
+ Agent promoted to mothership:`);
803
+ console.log(` ID: ${result.agent.id}`);
804
+ console.log(` Name: ${result.agent.name}`);
805
+ console.log(` Role: ${result.agent.role}
806
+ `);
807
+ }
808
+ async function cmdBv7xSpawn(args) {
809
+ const client = getClient();
810
+ let mothershipId = "";
811
+ let templateSlug = "";
812
+ let name = "";
813
+ let vpsIp = "";
814
+ let wallet = "";
815
+ for (let i = 0; i < args.length; i++) {
816
+ if (args[i] === "--mothership" && args[i + 1]) mothershipId = args[++i];
817
+ else if (args[i] === "--template" && args[i + 1]) templateSlug = args[++i];
818
+ else if (args[i] === "--name" && args[i + 1]) name = args[++i];
819
+ else if (args[i] === "--vps" && args[i + 1]) vpsIp = args[++i];
820
+ else if (args[i] === "--wallet" && args[i + 1]) wallet = args[++i];
821
+ }
822
+ if (!mothershipId) mothershipId = await prompt(" Mothership Agent ID: ");
823
+ if (!templateSlug) templateSlug = await prompt(" Template slug (e.g. bv7x-alpha-trader): ");
824
+ if (!name) name = await prompt(" Satellite name: ");
825
+ if (!mothershipId || !templateSlug || !name) {
826
+ console.error(" Error: --mothership, --template, and --name are required.");
827
+ process.exit(1);
828
+ }
829
+ const result = await client.spawnSatellite({
830
+ mothershipId,
831
+ templateSlug,
832
+ name,
833
+ vpsIp: vpsIp || void 0,
834
+ walletAddress: wallet || void 0
835
+ });
836
+ console.log(`
837
+ Satellite Spawned:`);
838
+ console.log(` ID: ${result.satellite.id}`);
839
+ console.log(` Name: ${result.satellite.name}`);
840
+ console.log(` Model: ${result.satellite.model}`);
841
+ console.log(` Role: ${result.satellite.role}`);
842
+ console.log(` Template: ${result.template.name}`);
843
+ console.log(` Mothership: ${result.mothership.name} (${result.mothership.childrenCount} satellites)
844
+ `);
845
+ }
846
+ async function cmdBv7xSatellites(mothershipId) {
847
+ if (!mothershipId) {
848
+ console.error(" Usage: otonix bv7x:satellites <mothershipId>");
849
+ process.exit(1);
850
+ }
851
+ const client = getClient();
852
+ const result = await client.getMothershipSatellites(mothershipId);
853
+ console.log(`
854
+ Mothership: ${result.mothership.name} (${result.count} satellites)
855
+ `);
856
+ if (!result.satellites.length) {
857
+ console.log(" No satellites spawned yet.\n");
858
+ return;
859
+ }
860
+ printTable(result.satellites.map((s) => ({
861
+ ID: s.id.slice(0, 8),
862
+ Name: s.name,
863
+ Status: s.status,
864
+ Tier: s.survivalTier,
865
+ Model: s.model,
866
+ Heartbeat: formatTime(s.lastHeartbeat),
867
+ Actions: s.totalActions
868
+ })));
869
+ console.log();
870
+ }
871
+ async function cmdBv7xDestroy(satelliteId) {
872
+ if (!satelliteId) {
873
+ console.error(" Usage: otonix bv7x:destroy <satelliteId>");
874
+ process.exit(1);
875
+ }
876
+ const client = getClient();
877
+ const result = await client.destroySatellite(satelliteId);
878
+ console.log(` ${result.message}`);
879
+ }
880
+ async function cmdBv7xReport(args) {
881
+ let satelliteId = "";
882
+ let reportType = "general";
883
+ let dataStr = "";
884
+ for (let i = 0; i < args.length; i++) {
885
+ if (args[i] === "--type" && args[i + 1]) reportType = args[++i];
886
+ else if (args[i] === "--data" && args[i + 1]) dataStr = args[++i];
887
+ else if (!satelliteId) satelliteId = args[i];
888
+ }
889
+ if (!satelliteId) {
890
+ console.error(" Usage: otonix bv7x:report <satelliteId> --type <type> --data '<json>'");
891
+ process.exit(1);
892
+ }
893
+ let data = {};
894
+ if (dataStr) {
895
+ try {
896
+ data = JSON.parse(dataStr);
897
+ } catch {
898
+ console.error(" Error: --data must be valid JSON");
899
+ process.exit(1);
900
+ }
901
+ } else {
902
+ const raw = await prompt(" Report data (JSON): ");
903
+ try {
904
+ data = JSON.parse(raw);
905
+ } catch {
906
+ console.error(" Error: Invalid JSON");
907
+ process.exit(1);
908
+ }
909
+ }
910
+ const client = getClient();
911
+ await client.satelliteReport(satelliteId, { data, reportType });
912
+ console.log(` Report sent (type: ${reportType})`);
913
+ }
914
+ async function cmdBv7xFleet() {
915
+ const client = getClient();
916
+ const fleet = await client.getFleet();
917
+ console.log(`
918
+ BV-7X Fleet Overview`);
919
+ console.log(` Motherships: ${fleet.totalMotherships}`);
920
+ console.log(` Satellites: ${fleet.totalSatellites}`);
921
+ if (fleet.fleet.length) {
922
+ for (const f of fleet.fleet) {
923
+ console.log(`
924
+ \u250C Mothership: ${f.mothership.name} [${f.mothership.status}] \u2014 ${f.satelliteCount} satellite(s)`);
925
+ for (const s of f.satellites) {
926
+ console.log(` \u2502 \u2514 ${s.name} [${s.status}] tier:${s.survivalTier} heartbeat:${formatTime(s.lastHeartbeat)}`);
927
+ }
928
+ }
929
+ }
930
+ if (fleet.orphanedSatellites.length) {
931
+ console.log(`
932
+ Orphaned Satellites: ${fleet.orphanedSatellites.length}`);
933
+ for (const s of fleet.orphanedSatellites) {
934
+ console.log(` \u2022 ${s.name} [${s.status}]`);
935
+ }
936
+ }
937
+ console.log();
938
+ }
939
+ async function cmdWebhookCreate(args) {
940
+ const client = getClient();
941
+ let url = "";
942
+ let agentId = "";
943
+ const events = [];
944
+ for (let i = 0; i < args.length; i++) {
945
+ if (args[i] === "--url" && args[i + 1]) url = args[++i];
946
+ else if (args[i] === "--agent" && args[i + 1]) agentId = args[++i];
947
+ else if (args[i] === "--event" && args[i + 1]) events.push(args[++i]);
948
+ }
949
+ if (!url) url = await prompt(" Webhook URL: ");
950
+ if (!url) {
951
+ console.error(" Error: URL is required.");
952
+ process.exit(1);
953
+ }
954
+ const result = await client.createWebhook({
955
+ url,
956
+ events: events.length ? events : void 0,
957
+ agentId: agentId || void 0
958
+ });
959
+ console.log(`
960
+ Webhook Created:`);
961
+ console.log(` ID: ${result.id}`);
962
+ console.log(` URL: ${result.url}`);
963
+ console.log(` Events: ${result.events.length ? result.events.join(", ") : "all"}`);
964
+ console.log(` Secret: ${result.secret}`);
965
+ console.log(`
966
+ Save this secret \u2014 it won't be shown again.
967
+ `);
968
+ }
969
+ async function cmdWebhookList() {
970
+ const client = getClient();
971
+ const hooks = await client.listWebhooks();
972
+ if (!hooks.length) {
973
+ console.log("\n No webhooks registered.\n");
974
+ return;
975
+ }
976
+ console.log(`
977
+ Webhooks (${hooks.length}):
978
+ `);
979
+ printTable(hooks.map((h) => ({
980
+ ID: h.id.slice(0, 8),
981
+ URL: h.url.length > 40 ? h.url.slice(0, 37) + "..." : h.url,
982
+ Events: h.events.length ? h.events.length + " types" : "all",
983
+ Status: h.status,
984
+ Fails: h.failCount,
985
+ Agent: h.agentId?.slice(0, 8) || "global"
986
+ })));
987
+ console.log();
988
+ }
989
+ async function cmdWebhookDelete(webhookId) {
990
+ if (!webhookId) {
991
+ console.error(" Usage: otonix webhook:delete <webhookId>");
992
+ process.exit(1);
993
+ }
994
+ const client = getClient();
995
+ const result = await client.deleteWebhook(webhookId);
996
+ console.log(` ${result.message}`);
997
+ }
998
+ async function cmdWebhookTest(webhookId) {
999
+ if (!webhookId) {
1000
+ console.error(" Usage: otonix webhook:test <webhookId>");
1001
+ process.exit(1);
1002
+ }
1003
+ const client = getClient();
1004
+ const result = await client.testWebhook(webhookId);
1005
+ console.log(` ${result.message}`);
1006
+ }
1007
+ async function cmdWebhookDeliveries(args) {
1008
+ let webhookId = args[0] || "";
1009
+ if (!webhookId) {
1010
+ console.error(" Usage: otonix webhook:deliveries <webhookId>");
1011
+ process.exit(1);
1012
+ }
1013
+ const client = getClient();
1014
+ const deliveries = await client.getWebhookDeliveries(webhookId);
1015
+ if (!deliveries.length) {
1016
+ console.log("\n No deliveries found.\n");
1017
+ return;
1018
+ }
1019
+ console.log(`
1020
+ Webhook Deliveries (${deliveries.length}):
1021
+ `);
1022
+ printTable(deliveries.slice(0, 20).map((d) => ({
1023
+ Event: d.event,
1024
+ Status: d.statusCode || "\u2014",
1025
+ Success: d.success ? "yes" : "no",
1026
+ Time: formatTime(d.createdAt),
1027
+ Response: (d.response || "\u2014").slice(0, 30)
1028
+ })));
1029
+ console.log();
1030
+ }
1031
+ async function cmdWebhookEvents() {
1032
+ const client = getClient();
1033
+ const result = await client.listWebhookEvents();
1034
+ console.log(`
1035
+ Available Webhook Events (${result.events.length}):
1036
+ `);
1037
+ for (const event of result.events) {
1038
+ console.log(` \u2022 ${event}`);
1039
+ }
1040
+ console.log();
1041
+ }
782
1042
  function cmdWhoami() {
783
1043
  const config = loadConfig();
784
1044
  if (!config) {
@@ -861,6 +1121,42 @@ async function main() {
861
1121
  case "x402":
862
1122
  await cmdX402();
863
1123
  break;
1124
+ case "bv7x:promote":
1125
+ await cmdBv7xPromote(rest[0]);
1126
+ break;
1127
+ case "bv7x:spawn":
1128
+ await cmdBv7xSpawn(rest);
1129
+ break;
1130
+ case "bv7x:satellites":
1131
+ await cmdBv7xSatellites(rest[0]);
1132
+ break;
1133
+ case "bv7x:destroy":
1134
+ await cmdBv7xDestroy(rest[0]);
1135
+ break;
1136
+ case "bv7x:report":
1137
+ await cmdBv7xReport(rest);
1138
+ break;
1139
+ case "bv7x:fleet":
1140
+ await cmdBv7xFleet();
1141
+ break;
1142
+ case "webhook:create":
1143
+ await cmdWebhookCreate(rest);
1144
+ break;
1145
+ case "webhook:list":
1146
+ await cmdWebhookList();
1147
+ break;
1148
+ case "webhook:delete":
1149
+ await cmdWebhookDelete(rest[0]);
1150
+ break;
1151
+ case "webhook:test":
1152
+ await cmdWebhookTest(rest[0]);
1153
+ break;
1154
+ case "webhook:deliveries":
1155
+ await cmdWebhookDeliveries(rest);
1156
+ break;
1157
+ case "webhook:events":
1158
+ await cmdWebhookEvents();
1159
+ break;
864
1160
  case "llm:init":
865
1161
  cmdLlmInit(rest[0]);
866
1162
  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.4.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.4.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsup": "^8.0.0",