@otonix/cli 1.2.1 → 1.3.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 (3) hide show
  1. package/README.md +42 -0
  2. package/dist/cli.js +196 -1
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -64,6 +64,22 @@ otonix log "Trade executed BTC/USDC" --category trading
64
64
  | `otonix sandboxes` | List VPS sandboxes |
65
65
  | `otonix domains` | List registered domains |
66
66
 
67
+ ### Credits
68
+
69
+ | Command | Description |
70
+ |---------|-------------|
71
+ | `otonix credits [agentId]` | Show agent credit balance |
72
+ | `otonix credits:transfer` | Transfer credits between agents |
73
+ | `otonix credits:history [agentId]` | Show credit transaction history |
74
+
75
+ ### Templates
76
+
77
+ | Command | Description |
78
+ |---------|-------------|
79
+ | `otonix templates` | List all available agent templates |
80
+ | `otonix templates:info <slug>` | Show template details by slug |
81
+ | `otonix templates:deploy` | Deploy an agent from a template |
82
+
67
83
  ### Platform
68
84
 
69
85
  | Command | Description |
@@ -147,6 +163,32 @@ otonix actions --limit 50
147
163
  |--------|---------|-------------|
148
164
  | `--limit` | `20` | Number of actions to show |
149
165
 
166
+ ### `otonix credits:transfer`
167
+
168
+ ```bash
169
+ otonix credits:transfer --from <agentId> --to <agentId> --amount 10 --desc "Payment"
170
+ ```
171
+
172
+ | Option | Default | Description |
173
+ |--------|---------|-------------|
174
+ | `--from` | (interactive) | Source agent ID |
175
+ | `--to` | (interactive) | Destination agent ID |
176
+ | `--amount` | (interactive) | Amount in USDC |
177
+ | `--desc` | — | Transfer description |
178
+
179
+ ### `otonix templates:deploy`
180
+
181
+ ```bash
182
+ otonix templates:deploy --template trading-bot --name my-trader --vps 10.0.1.1 --wallet 0x...
183
+ ```
184
+
185
+ | Option | Default | Description |
186
+ |--------|---------|-------------|
187
+ | `--template` | (interactive) | Template slug |
188
+ | `--name` | (interactive) | Agent name |
189
+ | `--vps` | — | VPS IP address |
190
+ | `--wallet` | — | Wallet address |
191
+
150
192
  ### `otonix llm:chat`
151
193
 
152
194
  ```bash
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.2.0";
31
+ var VERSION = "1.3.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() {
@@ -106,6 +106,12 @@ var HELP = `
106
106
  domains List registered domains
107
107
  sandboxes List VPS sandboxes
108
108
  engine Show autonomic engine status
109
+ credits <agentId> Show agent credit balance
110
+ credits:transfer Transfer credits between agents
111
+ credits:history <id> Show credit transaction history
112
+ templates List available agent templates
113
+ templates:info <s> Show template details by slug
114
+ templates:deploy Deploy an agent from a template
109
115
  marketplace List marketplace services
110
116
  x402 Show x402 payment config
111
117
  llm:init <key> Configure Bankr LLM Gateway API key
@@ -471,6 +477,177 @@ async function cmdMarketplace() {
471
477
  Use 'curl https://app.otonix.tech/api/marketplace/services/<id>' for details.
472
478
  `);
473
479
  }
480
+ async function cmdCredits(agentId) {
481
+ const client = getClient();
482
+ const config = loadConfig();
483
+ const id = agentId || config.agentId;
484
+ if (!id) {
485
+ console.error(" Usage: otonix credits <agentId> (or register an agent first)");
486
+ process.exit(1);
487
+ }
488
+ const balance = await client.getCreditBalance(id);
489
+ console.log(`
490
+ Agent Credit Balance:`);
491
+ console.log(` Agent: ${balance.name}`);
492
+ console.log(` Credits: $${balance.credits.toFixed(2)}`);
493
+ console.log(` Tier: ${balance.survivalTier}
494
+ `);
495
+ }
496
+ async function cmdCreditsTransfer(args) {
497
+ const client = getClient();
498
+ let fromId = "";
499
+ let toId = "";
500
+ let amount = 0;
501
+ let desc = "";
502
+ for (let i = 0; i < args.length; i++) {
503
+ if (args[i] === "--from" && args[i + 1]) fromId = args[++i];
504
+ else if (args[i] === "--to" && args[i + 1]) toId = args[++i];
505
+ else if (args[i] === "--amount" && args[i + 1]) amount = parseFloat(args[++i]);
506
+ else if (args[i] === "--desc" && args[i + 1]) desc = args[++i];
507
+ }
508
+ if (!fromId) fromId = await prompt(" From Agent ID: ");
509
+ if (!toId) toId = await prompt(" To Agent ID: ");
510
+ if (!amount) {
511
+ const amtStr = await prompt(" Amount (USDC): ");
512
+ amount = parseFloat(amtStr);
513
+ }
514
+ if (!fromId || !toId || !amount || amount <= 0) {
515
+ console.error(" Error: --from, --to, and --amount (> 0) are required.");
516
+ process.exit(1);
517
+ }
518
+ try {
519
+ const result = await client.transferCredits({
520
+ fromAgentId: fromId,
521
+ toAgentId: toId,
522
+ amount,
523
+ description: desc || void 0
524
+ });
525
+ if (result.success) {
526
+ console.log(`
527
+ Transfer Successful:`);
528
+ console.log(` Amount: $${result.transferred.toFixed(2)} USDC`);
529
+ console.log(` From: ${result.from}`);
530
+ console.log(` To: ${result.to}
531
+ `);
532
+ } else {
533
+ console.error(" Transfer failed.");
534
+ }
535
+ } catch (err) {
536
+ console.error(` Error: ${err.message}`);
537
+ process.exit(1);
538
+ }
539
+ }
540
+ async function cmdCreditsHistory(agentId) {
541
+ const client = getClient();
542
+ const config = loadConfig();
543
+ const id = agentId || config.agentId;
544
+ if (!id) {
545
+ console.error(" Usage: otonix credits:history <agentId>");
546
+ process.exit(1);
547
+ }
548
+ const history = await client.getCreditHistory(id);
549
+ if (!history.length) {
550
+ console.log("\n No credit transactions found.\n");
551
+ return;
552
+ }
553
+ console.log(`
554
+ Credit History (${history.length} transactions):
555
+ `);
556
+ printTable(
557
+ history.map((tx) => ({
558
+ Type: tx.type,
559
+ Amount: `${tx.type === "credit" ? "+" : "-"}$${Math.abs(tx.amount).toFixed(2)}`,
560
+ Description: (tx.description || "\u2014").slice(0, 50),
561
+ Status: tx.status,
562
+ Date: new Date(tx.createdAt).toLocaleDateString()
563
+ }))
564
+ );
565
+ console.log();
566
+ }
567
+ async function cmdTemplates() {
568
+ const client = getClient();
569
+ const templates = await client.listTemplates();
570
+ if (!templates.length) {
571
+ console.log("\n No templates available.\n");
572
+ return;
573
+ }
574
+ console.log(`
575
+ Agent Templates (${templates.length}):
576
+ `);
577
+ printTable(
578
+ templates.map((t) => ({
579
+ Slug: t.slug,
580
+ Name: t.name,
581
+ Category: t.category,
582
+ Model: t.model,
583
+ Cost: `$${t.estimatedCost.toFixed(2)}/day`,
584
+ Features: t.features?.length || 0
585
+ }))
586
+ );
587
+ console.log();
588
+ }
589
+ async function cmdTemplatesInfo(slug) {
590
+ if (!slug) {
591
+ console.error(" Usage: otonix templates:info <slug>");
592
+ process.exit(1);
593
+ }
594
+ const client = getClient();
595
+ const template = await client.getTemplate(slug);
596
+ console.log(`
597
+ Template: ${template.name}`);
598
+ console.log(` Slug: ${template.slug}`);
599
+ console.log(` Category: ${template.category}`);
600
+ console.log(` Model: ${template.model}`);
601
+ console.log(` Est. Cost: $${template.estimatedCost.toFixed(2)}/day`);
602
+ console.log(` Description: ${template.description}`);
603
+ if (template.features?.length) {
604
+ console.log(` Features:`);
605
+ template.features.forEach((f) => console.log(` - ${f}`));
606
+ }
607
+ console.log();
608
+ }
609
+ async function cmdTemplatesDeploy(args) {
610
+ const client = getClient();
611
+ let slug = "";
612
+ let name = "";
613
+ let vpsIp = "";
614
+ let wallet = "";
615
+ for (let i = 0; i < args.length; i++) {
616
+ if (args[i] === "--template" && args[i + 1]) slug = args[++i];
617
+ else if (args[i] === "--name" && args[i + 1]) name = args[++i];
618
+ else if (args[i] === "--vps" && args[i + 1]) vpsIp = args[++i];
619
+ else if (args[i] === "--wallet" && args[i + 1]) wallet = args[++i];
620
+ }
621
+ if (!slug) slug = await prompt(" Template slug (e.g. trading-bot): ");
622
+ if (!name) name = await prompt(" Agent name: ");
623
+ if (!slug || !name) {
624
+ console.error(" Error: --template and --name are required.");
625
+ process.exit(1);
626
+ }
627
+ try {
628
+ const result = await client.deployTemplate({
629
+ templateSlug: slug,
630
+ name,
631
+ vpsIp: vpsIp || void 0,
632
+ walletAddress: wallet || void 0
633
+ });
634
+ if (result.success) {
635
+ console.log(`
636
+ Agent Deployed:`);
637
+ console.log(` ID: ${result.agent.id}`);
638
+ console.log(` Name: ${result.agent.name}`);
639
+ console.log(` Template: ${result.template.name} (${result.template.category})`);
640
+ console.log(` Model: ${result.agent.model}`);
641
+ console.log(` Tier: ${result.agent.survivalTier}
642
+ `);
643
+ } else {
644
+ console.error(" Deploy failed.");
645
+ }
646
+ } catch (err) {
647
+ console.error(` Error: ${err.message}`);
648
+ process.exit(1);
649
+ }
650
+ }
474
651
  async function cmdX402() {
475
652
  const client = getClient();
476
653
  const config = await client.getX402Config();
@@ -660,6 +837,24 @@ async function main() {
660
837
  case "engine":
661
838
  await cmdEngine();
662
839
  break;
840
+ case "credits":
841
+ await cmdCredits(rest[0]);
842
+ break;
843
+ case "credits:transfer":
844
+ await cmdCreditsTransfer(rest);
845
+ break;
846
+ case "credits:history":
847
+ await cmdCreditsHistory(rest[0]);
848
+ break;
849
+ case "templates":
850
+ await cmdTemplates();
851
+ break;
852
+ case "templates:info":
853
+ await cmdTemplatesInfo(rest[0]);
854
+ break;
855
+ case "templates:deploy":
856
+ await cmdTemplatesDeploy(rest);
857
+ break;
663
858
  case "marketplace":
664
859
  await cmdMarketplace();
665
860
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@otonix/cli",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "CLI tool for the Otonix sovereign compute platform — initialize agents, generate API keys, register, monitor status, 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.2.0"
41
+ "@otonix/sdk": "^1.3.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "tsup": "^8.0.0",