@otonix/cli 1.4.0 → 1.6.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 +320 -71
- 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.6.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() {
|
|
@@ -87,66 +87,132 @@ function formatTime(dateStr) {
|
|
|
87
87
|
if (ago < 86400) return `${Math.floor(ago / 3600)}h ago`;
|
|
88
88
|
return `${Math.floor(ago / 86400)}d ago`;
|
|
89
89
|
}
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
llm:init <key> Configure Bankr LLM Gateway API key
|
|
130
|
-
llm:models List available LLM models
|
|
131
|
-
llm:chat <prompt> Send a chat completion request
|
|
132
|
-
llm:usage [--days N] Show LLM usage summary
|
|
133
|
-
llm:health Check gateway health
|
|
134
|
-
whoami Show current configuration
|
|
135
|
-
version Show CLI version
|
|
136
|
-
help Show this help
|
|
137
|
-
|
|
138
|
-
Examples:
|
|
139
|
-
otonix init
|
|
140
|
-
otonix keygen my-vps-key
|
|
141
|
-
otonix register --name my-agent --model claude-opus-4-6
|
|
142
|
-
otonix heartbeat:loop
|
|
143
|
-
otonix log "Trade executed BTC/USDC" --category trading
|
|
144
|
-
otonix actions --limit 20
|
|
145
|
-
otonix llm:init bk_YOUR_API_KEY
|
|
146
|
-
otonix llm:chat "Explain smart contracts" --model claude-haiku-4.5
|
|
90
|
+
var C = {
|
|
91
|
+
reset: "\x1B[0m",
|
|
92
|
+
bold: "\x1B[1m",
|
|
93
|
+
dim: "\x1B[2m",
|
|
94
|
+
cyan: "\x1B[36m",
|
|
95
|
+
green: "\x1B[32m",
|
|
96
|
+
yellow: "\x1B[33m",
|
|
97
|
+
blue: "\x1B[34m",
|
|
98
|
+
magenta: "\x1B[35m",
|
|
99
|
+
white: "\x1B[37m",
|
|
100
|
+
gray: "\x1B[90m",
|
|
101
|
+
bgCyan: "\x1B[46m",
|
|
102
|
+
bgBlue: "\x1B[44m"
|
|
103
|
+
};
|
|
104
|
+
var BANNER = `
|
|
105
|
+
${C.cyan}${C.bold} \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
|
|
106
|
+
\u2551 \u2551
|
|
107
|
+
\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557 \u2551
|
|
108
|
+
\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2554\u255D \u2551
|
|
109
|
+
\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2554\u255D \u2551
|
|
110
|
+
\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2557 \u2551
|
|
111
|
+
\u2551 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2554\u255D \u2588\u2588\u2557 \u2551
|
|
112
|
+
\u2551 \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D\u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D \u2551
|
|
113
|
+
\u2551 \u2551
|
|
114
|
+
\u2551${C.reset}${C.dim} Sovereign Compute Platform for Autonomous AI Agents ${C.cyan}${C.bold} \u2551
|
|
115
|
+
\u2551${C.reset}${C.gray} v${VERSION} \u2022 Web4 \u2022 x402 \u2022 Base Chain ${C.cyan}${C.bold} \u2551
|
|
116
|
+
\u2551 \u2551
|
|
117
|
+
\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D${C.reset}
|
|
147
118
|
`;
|
|
119
|
+
function showDashboard() {
|
|
120
|
+
console.log(BANNER);
|
|
121
|
+
const config = loadConfig();
|
|
122
|
+
const connected = !!config;
|
|
123
|
+
const statusIcon = connected ? `${C.green}\u25CF${C.reset}` : `${C.yellow}\u25CB${C.reset}`;
|
|
124
|
+
const statusText = connected ? `${C.green}Connected${C.reset}` : `${C.yellow}Not configured${C.reset}`;
|
|
125
|
+
console.log(` ${C.dim}\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510${C.reset}`);
|
|
126
|
+
console.log(` ${C.dim}\u2502${C.reset} ${statusIcon} Status: ${statusText}${connected ? ` ${C.dim}\u2022${C.reset} ${C.gray}${config.endpoint}${C.reset}` : ` ${C.dim}\u2022${C.reset} ${C.gray}Run: otonix init${C.reset}`}`);
|
|
127
|
+
if (connected && config.agentName) {
|
|
128
|
+
console.log(` ${C.dim}\u2502${C.reset} Agent: ${C.bold}${config.agentName}${C.reset} ${C.dim}(${config.agentId?.slice(0, 8)}...)${C.reset}`);
|
|
129
|
+
}
|
|
130
|
+
console.log(` ${C.dim}\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518${C.reset}`);
|
|
131
|
+
console.log();
|
|
132
|
+
const section = (title, icon) => ` ${C.bold}${icon} ${title}${C.reset}`;
|
|
133
|
+
const cmd = (name, desc) => ` ${C.dim}\u2502${C.reset} ${C.cyan}${name.padEnd(24)}${C.reset}${C.gray}${desc}${C.reset}`;
|
|
134
|
+
const sep = () => ` ${C.dim}\u2502${C.reset}`;
|
|
135
|
+
console.log(section("SETUP", "\u26A1"));
|
|
136
|
+
console.log(cmd("init", "Configure API key and endpoint"));
|
|
137
|
+
console.log(cmd("keygen <name>", "Generate a new API key"));
|
|
138
|
+
console.log(cmd("whoami", "Show current configuration"));
|
|
139
|
+
console.log();
|
|
140
|
+
console.log(section("AGENT MANAGEMENT", "\u{1F916}"));
|
|
141
|
+
console.log(cmd("register", "Register an agent on this VPS"));
|
|
142
|
+
console.log(cmd("status", "Show agent status"));
|
|
143
|
+
console.log(cmd("agents", "List all connected agents"));
|
|
144
|
+
console.log(cmd("heartbeat", "Send a heartbeat ping"));
|
|
145
|
+
console.log(cmd("heartbeat:loop", "Start continuous heartbeat loop"));
|
|
146
|
+
console.log(cmd("actions [--limit N]", "Show agent action log"));
|
|
147
|
+
console.log(cmd("log <message>", "Log an agent action"));
|
|
148
|
+
console.log();
|
|
149
|
+
console.log(section("INFRASTRUCTURE", "\u2601\uFE0F"));
|
|
150
|
+
console.log(cmd("sandboxes", "List VPS sandboxes"));
|
|
151
|
+
console.log(cmd("domains", "List registered domains"));
|
|
152
|
+
console.log(cmd("engine", "Show autonomic engine status"));
|
|
153
|
+
console.log();
|
|
154
|
+
console.log(section("CREDITS & PAYMENTS", "\u{1F4B0}"));
|
|
155
|
+
console.log(cmd("credits <agentId>", "Show agent credit balance"));
|
|
156
|
+
console.log(cmd("credits:transfer", "Transfer credits between agents"));
|
|
157
|
+
console.log(cmd("credits:history <id>", "Show credit transaction history"));
|
|
158
|
+
console.log(cmd("x402", "Show x402 payment config"));
|
|
159
|
+
console.log();
|
|
160
|
+
console.log(section("TRADING MARKETPLACE", "\u{1F3EA}"));
|
|
161
|
+
console.log(cmd("trade:list", "List all service listings"));
|
|
162
|
+
console.log(cmd("trade:create", "Create a service listing"));
|
|
163
|
+
console.log(cmd("trade:buy", "Buy a service from another agent"));
|
|
164
|
+
console.log(cmd("trade:orders", "Show trading order history"));
|
|
165
|
+
console.log(cmd("marketplace", "List static marketplace services"));
|
|
166
|
+
console.log();
|
|
167
|
+
console.log(section("BV-7X FLEET", "\u{1F6F0}\uFE0F"));
|
|
168
|
+
console.log(cmd("bv7x:fleet", "Show full fleet overview"));
|
|
169
|
+
console.log(cmd("bv7x:promote <id>", "Promote agent to mothership"));
|
|
170
|
+
console.log(cmd("bv7x:spawn", "Spawn a satellite agent"));
|
|
171
|
+
console.log(cmd("bv7x:satellites <id>", "List mothership's satellites"));
|
|
172
|
+
console.log(cmd("bv7x:destroy <id>", "Destroy a satellite"));
|
|
173
|
+
console.log(cmd("bv7x:report <id>", "Send satellite data report"));
|
|
174
|
+
console.log();
|
|
175
|
+
console.log(section("TEMPLATES", "\u{1F4E6}"));
|
|
176
|
+
console.log(cmd("templates", "List available agent templates"));
|
|
177
|
+
console.log(cmd("templates:info <slug>", "Show template details"));
|
|
178
|
+
console.log(cmd("templates:deploy", "Deploy agent from a template"));
|
|
179
|
+
console.log();
|
|
180
|
+
console.log(section("WEBHOOKS", "\u{1F514}"));
|
|
181
|
+
console.log(cmd("webhook:create", "Create a new webhook"));
|
|
182
|
+
console.log(cmd("webhook:list", "List registered webhooks"));
|
|
183
|
+
console.log(cmd("webhook:delete <id>", "Delete a webhook"));
|
|
184
|
+
console.log(cmd("webhook:test <id>", "Send a test delivery"));
|
|
185
|
+
console.log(cmd("webhook:deliveries", "Show delivery history"));
|
|
186
|
+
console.log(cmd("webhook:events", "List available event types"));
|
|
187
|
+
console.log();
|
|
188
|
+
console.log(section("AI INFERENCE (Bankr LLM)", "\u{1F9E0}"));
|
|
189
|
+
console.log(cmd("llm:init <key>", "Configure Bankr API key"));
|
|
190
|
+
console.log(cmd("llm:models", "List available LLM models"));
|
|
191
|
+
console.log(cmd("llm:chat <prompt>", "Send a chat completion"));
|
|
192
|
+
console.log(cmd("llm:usage [--days N]", "Show LLM usage summary"));
|
|
193
|
+
console.log(cmd("llm:health", "Check gateway health"));
|
|
194
|
+
console.log();
|
|
195
|
+
console.log(section("ACTIVITY", "\u{1F4E1}"));
|
|
196
|
+
console.log(cmd("activity [--limit N]", "Show live activity feed"));
|
|
197
|
+
console.log();
|
|
198
|
+
console.log(` ${C.dim}\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500${C.reset}`);
|
|
199
|
+
console.log(` ${C.gray}Examples:${C.reset}`);
|
|
200
|
+
console.log(` ${C.dim}$${C.reset} ${C.white}otonix init${C.reset}`);
|
|
201
|
+
console.log(` ${C.dim}$${C.reset} ${C.white}otonix register --name my-agent --model claude-opus-4-6${C.reset}`);
|
|
202
|
+
console.log(` ${C.dim}$${C.reset} ${C.white}otonix heartbeat:loop${C.reset}`);
|
|
203
|
+
console.log(` ${C.dim}$${C.reset} ${C.white}otonix trade:list${C.reset}`);
|
|
204
|
+
console.log(` ${C.dim}$${C.reset} ${C.white}otonix llm:chat "Explain smart contracts"${C.reset}`);
|
|
205
|
+
console.log();
|
|
206
|
+
console.log(` ${C.dim}Docs: ${C.cyan}https://app.otonix.tech/docs${C.reset} ${C.dim}\u2022${C.reset} ${C.dim}npm: ${C.cyan}@otonix/cli@${VERSION}${C.reset}`);
|
|
207
|
+
console.log();
|
|
208
|
+
}
|
|
209
|
+
function showBanner() {
|
|
210
|
+
console.log(BANNER);
|
|
211
|
+
}
|
|
148
212
|
async function cmdInit() {
|
|
149
|
-
|
|
213
|
+
showBanner();
|
|
214
|
+
console.log(` ${C.bold}\u26A1 CLI Setup${C.reset}
|
|
215
|
+
`);
|
|
150
216
|
const endpoint = await prompt(" Endpoint [https://app.otonix.tech]: ") || "https://app.otonix.tech";
|
|
151
217
|
const apiKey = await prompt(" API Key (otonix_xxx): ");
|
|
152
218
|
if (!apiKey.startsWith("otonix_")) {
|
|
@@ -1039,20 +1105,184 @@ async function cmdWebhookEvents() {
|
|
|
1039
1105
|
}
|
|
1040
1106
|
console.log();
|
|
1041
1107
|
}
|
|
1108
|
+
async function cmdTradeList() {
|
|
1109
|
+
const client = getClient();
|
|
1110
|
+
const listings = await client.listServiceListings();
|
|
1111
|
+
if (!listings.length) {
|
|
1112
|
+
console.log("\n No service listings on the marketplace.\n");
|
|
1113
|
+
return;
|
|
1114
|
+
}
|
|
1115
|
+
console.log(`
|
|
1116
|
+
Marketplace Listings (${listings.length}):
|
|
1117
|
+
`);
|
|
1118
|
+
printTable(listings.map((l) => ({
|
|
1119
|
+
ID: l.id.slice(0, 8),
|
|
1120
|
+
Name: l.name,
|
|
1121
|
+
Category: l.category,
|
|
1122
|
+
Price: `${l.priceCredits} credits/${l.priceUnit}`,
|
|
1123
|
+
Rating: `${l.rating.toFixed(1)}/5`,
|
|
1124
|
+
Jobs: l.totalJobs,
|
|
1125
|
+
Seller: l.agentId.slice(0, 8),
|
|
1126
|
+
Status: l.status
|
|
1127
|
+
})));
|
|
1128
|
+
console.log();
|
|
1129
|
+
}
|
|
1130
|
+
async function cmdTradeCreate(args) {
|
|
1131
|
+
const client = getClient();
|
|
1132
|
+
let agentId = "";
|
|
1133
|
+
let name = "";
|
|
1134
|
+
let slug = "";
|
|
1135
|
+
let category = "general";
|
|
1136
|
+
let description = "";
|
|
1137
|
+
let price = 0;
|
|
1138
|
+
let priceUnit = "per request";
|
|
1139
|
+
for (let i = 0; i < args.length; i++) {
|
|
1140
|
+
if (args[i] === "--agent" && args[i + 1]) agentId = args[++i];
|
|
1141
|
+
else if (args[i] === "--name" && args[i + 1]) name = args[++i];
|
|
1142
|
+
else if (args[i] === "--slug" && args[i + 1]) slug = args[++i];
|
|
1143
|
+
else if (args[i] === "--category" && args[i + 1]) category = args[++i];
|
|
1144
|
+
else if (args[i] === "--desc" && args[i + 1]) description = args[++i];
|
|
1145
|
+
else if (args[i] === "--price" && args[i + 1]) price = parseFloat(args[++i]);
|
|
1146
|
+
else if (args[i] === "--unit" && args[i + 1]) priceUnit = args[++i];
|
|
1147
|
+
}
|
|
1148
|
+
if (!agentId) agentId = await prompt(" Seller Agent ID: ");
|
|
1149
|
+
if (!name) name = await prompt(" Service name: ");
|
|
1150
|
+
if (!slug) slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/-+$/, "");
|
|
1151
|
+
if (!description) description = await prompt(" Description: ");
|
|
1152
|
+
if (!price) {
|
|
1153
|
+
const p = await prompt(" Price (credits): ");
|
|
1154
|
+
price = parseFloat(p);
|
|
1155
|
+
}
|
|
1156
|
+
if (!agentId || !name || !description || !price) {
|
|
1157
|
+
console.error(" Error: agent, name, description, and price are required.");
|
|
1158
|
+
process.exit(1);
|
|
1159
|
+
}
|
|
1160
|
+
try {
|
|
1161
|
+
const listing = await client.createServiceListing({
|
|
1162
|
+
agentId,
|
|
1163
|
+
name,
|
|
1164
|
+
slug,
|
|
1165
|
+
category,
|
|
1166
|
+
description,
|
|
1167
|
+
priceCredits: price,
|
|
1168
|
+
priceUnit
|
|
1169
|
+
});
|
|
1170
|
+
console.log(`
|
|
1171
|
+
Service Listed:`);
|
|
1172
|
+
console.log(` ID: ${listing.id}`);
|
|
1173
|
+
console.log(` Name: ${listing.name}`);
|
|
1174
|
+
console.log(` Slug: ${listing.slug}`);
|
|
1175
|
+
console.log(` Category: ${listing.category}`);
|
|
1176
|
+
console.log(` Price: ${listing.priceCredits} credits/${listing.priceUnit}`);
|
|
1177
|
+
console.log(` Status: ${listing.status}
|
|
1178
|
+
`);
|
|
1179
|
+
} catch (err) {
|
|
1180
|
+
console.error(` Error: ${err.message}`);
|
|
1181
|
+
process.exit(1);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
async function cmdTradeBuy(args) {
|
|
1185
|
+
const client = getClient();
|
|
1186
|
+
let buyerAgentId = "";
|
|
1187
|
+
let listingId = "";
|
|
1188
|
+
for (let i = 0; i < args.length; i++) {
|
|
1189
|
+
if (args[i] === "--buyer" && args[i + 1]) buyerAgentId = args[++i];
|
|
1190
|
+
else if (args[i] === "--listing" && args[i + 1]) listingId = args[++i];
|
|
1191
|
+
}
|
|
1192
|
+
if (!buyerAgentId) buyerAgentId = await prompt(" Buyer Agent ID: ");
|
|
1193
|
+
if (!listingId) listingId = await prompt(" Service Listing ID: ");
|
|
1194
|
+
if (!buyerAgentId || !listingId) {
|
|
1195
|
+
console.error(" Error: --buyer and --listing are required.");
|
|
1196
|
+
process.exit(1);
|
|
1197
|
+
}
|
|
1198
|
+
try {
|
|
1199
|
+
const result = await client.buyService({ buyerAgentId, serviceListingId: listingId });
|
|
1200
|
+
if (result.success) {
|
|
1201
|
+
console.log(`
|
|
1202
|
+
Purchase Successful:`);
|
|
1203
|
+
console.log(` Service: ${result.service.name}`);
|
|
1204
|
+
console.log(` Price: ${result.service.price} credits`);
|
|
1205
|
+
console.log(` Buyer: ${result.buyer.name} (balance: $${result.buyer.credits.toFixed(2)})`);
|
|
1206
|
+
console.log(` Seller: ${result.seller.name}`);
|
|
1207
|
+
console.log(` Order: ${result.order.id}
|
|
1208
|
+
`);
|
|
1209
|
+
} else {
|
|
1210
|
+
console.error(" Purchase failed.");
|
|
1211
|
+
}
|
|
1212
|
+
} catch (err) {
|
|
1213
|
+
console.error(` Error: ${err.message}`);
|
|
1214
|
+
process.exit(1);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
async function cmdTradeOrders(args) {
|
|
1218
|
+
const client = getClient();
|
|
1219
|
+
const config = loadConfig();
|
|
1220
|
+
let agentId = "";
|
|
1221
|
+
for (let i = 0; i < args.length; i++) {
|
|
1222
|
+
if (args[i] === "--agent" && args[i + 1]) agentId = args[++i];
|
|
1223
|
+
}
|
|
1224
|
+
if (!agentId) agentId = config.agentId || "";
|
|
1225
|
+
const orders = await client.listTradingOrders(agentId || void 0);
|
|
1226
|
+
if (!orders.length) {
|
|
1227
|
+
console.log("\n No trading orders found.\n");
|
|
1228
|
+
return;
|
|
1229
|
+
}
|
|
1230
|
+
console.log(`
|
|
1231
|
+
Trading Orders (${orders.length}):
|
|
1232
|
+
`);
|
|
1233
|
+
printTable(orders.map((o) => ({
|
|
1234
|
+
ID: o.id.slice(0, 8),
|
|
1235
|
+
Buyer: o.buyerAgentId.slice(0, 8),
|
|
1236
|
+
Seller: o.sellerAgentId.slice(0, 8),
|
|
1237
|
+
Amount: `${o.amount} credits`,
|
|
1238
|
+
Status: o.status,
|
|
1239
|
+
Date: new Date(o.createdAt).toLocaleDateString()
|
|
1240
|
+
})));
|
|
1241
|
+
console.log();
|
|
1242
|
+
}
|
|
1243
|
+
async function cmdActivity(args) {
|
|
1244
|
+
const client = getClient();
|
|
1245
|
+
let limit = 20;
|
|
1246
|
+
let agentId = "";
|
|
1247
|
+
for (let i = 0; i < args.length; i++) {
|
|
1248
|
+
if (args[i] === "--limit" && args[i + 1]) limit = parseInt(args[++i]);
|
|
1249
|
+
else if (args[i] === "--agent" && args[i + 1]) agentId = args[++i];
|
|
1250
|
+
}
|
|
1251
|
+
const events = await client.getActivityFeed(limit, agentId || void 0);
|
|
1252
|
+
if (!events.length) {
|
|
1253
|
+
console.log("\n No activity events found.\n");
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
console.log(`
|
|
1257
|
+
Activity Feed (${events.length} events):
|
|
1258
|
+
`);
|
|
1259
|
+
for (const event of events) {
|
|
1260
|
+
const time = formatTime(event.createdAt);
|
|
1261
|
+
const agent = event.agentId ? event.agentId.slice(0, 8) : "system";
|
|
1262
|
+
console.log(` ${time.padEnd(10)} [${event.eventType.padEnd(25)}] ${event.title}`);
|
|
1263
|
+
if (event.details) {
|
|
1264
|
+
console.log(`${"".padEnd(13)} ${event.details}`);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
console.log();
|
|
1268
|
+
}
|
|
1042
1269
|
function cmdWhoami() {
|
|
1043
1270
|
const config = loadConfig();
|
|
1044
1271
|
if (!config) {
|
|
1045
1272
|
console.log(" Not configured. Run 'otonix init' first.");
|
|
1046
1273
|
return;
|
|
1047
1274
|
}
|
|
1048
|
-
|
|
1049
|
-
Current
|
|
1050
|
-
|
|
1051
|
-
console.log(`
|
|
1052
|
-
console.log(`
|
|
1053
|
-
console.log(`
|
|
1054
|
-
console.log(`
|
|
1055
|
-
console.log(`
|
|
1275
|
+
showBanner();
|
|
1276
|
+
console.log(` ${C.bold}\u{1F511} Current Configuration${C.reset}
|
|
1277
|
+
`);
|
|
1278
|
+
console.log(` ${C.dim}\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510${C.reset}`);
|
|
1279
|
+
console.log(` ${C.dim}\u2502${C.reset} Endpoint ${C.cyan}${config.endpoint}${C.reset}`);
|
|
1280
|
+
console.log(` ${C.dim}\u2502${C.reset} API Key ${C.gray}${config.apiKey.slice(0, 12)}...${config.apiKey.slice(-4)}${C.reset}`);
|
|
1281
|
+
console.log(` ${C.dim}\u2502${C.reset} Agent ID ${config.agentId ? `${C.green}${config.agentId.slice(0, 12)}...${C.reset}` : `${C.yellow}not registered${C.reset}`}`);
|
|
1282
|
+
console.log(` ${C.dim}\u2502${C.reset} Agent ${config.agentName ? `${C.bold}${config.agentName}${C.reset}` : `${C.gray}\u2014${C.reset}`}`);
|
|
1283
|
+
console.log(` ${C.dim}\u2502${C.reset} Bankr LLM ${config.bankrApiKey ? `${C.green}${config.bankrApiKey.slice(0, 6)}...${config.bankrApiKey.slice(-4)}${C.reset}` : `${C.gray}not configured${C.reset}`}`);
|
|
1284
|
+
console.log(` ${C.dim}\u2502${C.reset} Config ${C.gray}${CONFIG_FILE}${C.reset}`);
|
|
1285
|
+
console.log(` ${C.dim}\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518${C.reset}
|
|
1056
1286
|
`);
|
|
1057
1287
|
}
|
|
1058
1288
|
async function main() {
|
|
@@ -1157,6 +1387,21 @@ async function main() {
|
|
|
1157
1387
|
case "webhook:events":
|
|
1158
1388
|
await cmdWebhookEvents();
|
|
1159
1389
|
break;
|
|
1390
|
+
case "trade:list":
|
|
1391
|
+
await cmdTradeList();
|
|
1392
|
+
break;
|
|
1393
|
+
case "trade:create":
|
|
1394
|
+
await cmdTradeCreate(rest);
|
|
1395
|
+
break;
|
|
1396
|
+
case "trade:buy":
|
|
1397
|
+
await cmdTradeBuy(rest);
|
|
1398
|
+
break;
|
|
1399
|
+
case "trade:orders":
|
|
1400
|
+
await cmdTradeOrders(rest);
|
|
1401
|
+
break;
|
|
1402
|
+
case "activity":
|
|
1403
|
+
await cmdActivity(rest);
|
|
1404
|
+
break;
|
|
1160
1405
|
case "llm:init":
|
|
1161
1406
|
cmdLlmInit(rest[0]);
|
|
1162
1407
|
break;
|
|
@@ -1178,16 +1423,20 @@ async function main() {
|
|
|
1178
1423
|
case "version":
|
|
1179
1424
|
case "-v":
|
|
1180
1425
|
case "--version":
|
|
1181
|
-
|
|
1426
|
+
showBanner();
|
|
1427
|
+
console.log(` ${C.green}${C.bold}v${VERSION}${C.reset} ${C.dim}@otonix/cli${C.reset}`);
|
|
1428
|
+
console.log();
|
|
1182
1429
|
break;
|
|
1183
1430
|
case "help":
|
|
1184
1431
|
case "-h":
|
|
1185
1432
|
case "--help":
|
|
1186
|
-
|
|
1433
|
+
showDashboard();
|
|
1187
1434
|
break;
|
|
1188
1435
|
default:
|
|
1189
|
-
console.error(`
|
|
1190
|
-
|
|
1436
|
+
console.error(`
|
|
1437
|
+
${C.yellow}Unknown command: ${command}${C.reset}
|
|
1438
|
+
`);
|
|
1439
|
+
showDashboard();
|
|
1191
1440
|
process.exit(1);
|
|
1192
1441
|
}
|
|
1193
1442
|
} catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@otonix/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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",
|