@otonix/cli 1.7.0 → 2.1.2

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.
@@ -0,0 +1,58 @@
1
+ import { createPublicClient, createWalletClient, http, formatEther, parseAbi, } from "viem";
2
+ import { base } from "viem/chains";
3
+ import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
4
+ export const OTX_ADDRESS = "0xF7E2a6226Ffe0693DD85406AC3A8917cbea5DC40";
5
+ export const BASE_RPC = "https://mainnet.base.org";
6
+ export const OTX_DECIMALS = 18;
7
+ export const OTX_REQUIRED = 200n * 10n ** 18n;
8
+ export const publicClient = createPublicClient({
9
+ chain: base,
10
+ transport: http(BASE_RPC),
11
+ });
12
+ const erc20Abi = parseAbi([
13
+ "function balanceOf(address) view returns (uint256)",
14
+ "function transfer(address to, uint256 amount) returns (bool)",
15
+ "function decimals() view returns (uint8)",
16
+ "function symbol() view returns (string)",
17
+ ]);
18
+ export async function getEthBalance(address) {
19
+ const bal = await publicClient.getBalance({ address });
20
+ return formatEther(bal);
21
+ }
22
+ export async function getOtxBalance(address) {
23
+ const bal = await publicClient.readContract({
24
+ address: OTX_ADDRESS,
25
+ abi: erc20Abi,
26
+ functionName: "balanceOf",
27
+ args: [address],
28
+ });
29
+ return bal;
30
+ }
31
+ export async function sendOtx(fromPrivateKey, toAddress, amount) {
32
+ const account = privateKeyToAccount(fromPrivateKey);
33
+ const walletClient = createWalletClient({
34
+ account,
35
+ chain: base,
36
+ transport: http(BASE_RPC),
37
+ });
38
+ const hash = await walletClient.writeContract({
39
+ address: OTX_ADDRESS,
40
+ abi: erc20Abi,
41
+ functionName: "transfer",
42
+ args: [toAddress, amount],
43
+ });
44
+ return hash;
45
+ }
46
+ export function formatOtx(raw) {
47
+ const whole = raw / 10n ** 18n;
48
+ const frac = (raw % 10n ** 18n) / 10n ** 15n;
49
+ return `${whole}.${frac.toString().padStart(3, "0")}`;
50
+ }
51
+ export function generateWallet() {
52
+ const privateKey = generatePrivateKey();
53
+ const account = privateKeyToAccount(privateKey);
54
+ return { privateKey, address: account.address };
55
+ }
56
+ export function addressFromKey(privateKey) {
57
+ return privateKeyToAccount(privateKey).address;
58
+ }
@@ -0,0 +1,24 @@
1
+ export declare const OTONIX_DEPLOYER = "0xC2ba47CBA202aEC79cf6649582d41B398Ae2c4f1";
2
+ export declare const OTONIX_TREASURY = "0x2FDAb5ac42B7637Ee8DB2584914E673A1c00A03b";
3
+ export declare const OTONIX_API = "https://otonix-landing-page.replit.app/api";
4
+ export interface AgentRecord {
5
+ address: string;
6
+ privateKey: string;
7
+ createdAt: string;
8
+ registered: boolean;
9
+ registerTxHash?: string;
10
+ registeredAt?: string;
11
+ }
12
+ export interface Config {
13
+ wallet?: {
14
+ address: string;
15
+ privateKey: string;
16
+ };
17
+ agents: Record<string, AgentRecord>;
18
+ apiBase: string;
19
+ deployerAddress: string;
20
+ treasuryAddress: string;
21
+ }
22
+ export declare function loadConfig(): Config;
23
+ export declare function saveConfig(config: Config): void;
24
+ export declare function configPath(): string;
@@ -0,0 +1,39 @@
1
+ import { homedir } from "os";
2
+ import { join } from "path";
3
+ import { mkdirSync, readFileSync, writeFileSync, existsSync } from "fs";
4
+ const CONFIG_DIR = join(homedir(), ".otonix");
5
+ const CONFIG_FILE = join(CONFIG_DIR, "config.json");
6
+ export const OTONIX_DEPLOYER = "0xC2ba47CBA202aEC79cf6649582d41B398Ae2c4f1";
7
+ export const OTONIX_TREASURY = "0x2FDAb5ac42B7637Ee8DB2584914E673A1c00A03b";
8
+ export const OTONIX_API = "https://otonix-landing-page.replit.app/api";
9
+ const DEFAULT_CONFIG = {
10
+ agents: {},
11
+ apiBase: OTONIX_API,
12
+ deployerAddress: OTONIX_DEPLOYER,
13
+ treasuryAddress: OTONIX_TREASURY,
14
+ };
15
+ export function loadConfig() {
16
+ try {
17
+ if (!existsSync(CONFIG_FILE))
18
+ return { ...DEFAULT_CONFIG };
19
+ const raw = readFileSync(CONFIG_FILE, "utf-8");
20
+ const saved = JSON.parse(raw);
21
+ return {
22
+ ...DEFAULT_CONFIG,
23
+ ...saved,
24
+ deployerAddress: saved.deployerAddress ?? OTONIX_DEPLOYER,
25
+ treasuryAddress: saved.treasuryAddress ?? OTONIX_TREASURY,
26
+ };
27
+ }
28
+ catch {
29
+ return { ...DEFAULT_CONFIG };
30
+ }
31
+ }
32
+ export function saveConfig(config) {
33
+ if (!existsSync(CONFIG_DIR))
34
+ mkdirSync(CONFIG_DIR, { recursive: true });
35
+ writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), "utf-8");
36
+ }
37
+ export function configPath() {
38
+ return CONFIG_FILE;
39
+ }
@@ -0,0 +1,14 @@
1
+ export declare const brand: import("chalk").ChalkInstance;
2
+ export declare const dim: import("chalk").ChalkInstance;
3
+ export declare const ok: import("chalk").ChalkInstance;
4
+ export declare const warn: import("chalk").ChalkInstance;
5
+ export declare const err: import("chalk").ChalkInstance;
6
+ export declare const hi: import("chalk").ChalkInstance;
7
+ export declare const mono: import("chalk").ChalkInstance;
8
+ export declare function printBanner(): void;
9
+ export declare function header(text: string): void;
10
+ export declare function row(label: string, value: string): void;
11
+ export declare function success(msg: string): void;
12
+ export declare function failure(msg: string): void;
13
+ export declare function info(msg: string): void;
14
+ export declare function br(): void;
@@ -0,0 +1,50 @@
1
+ import chalk from "chalk";
2
+ const BLUE = "#4d6fff";
3
+ const BLUE_DIM = "#3a50cc";
4
+ export const brand = chalk.bold.hex(BLUE);
5
+ export const dim = chalk.dim;
6
+ export const ok = chalk.green;
7
+ export const warn = chalk.yellow;
8
+ export const err = chalk.red;
9
+ export const hi = chalk.bold.white;
10
+ export const mono = chalk.hex("#9090e0");
11
+ const ASCII = [
12
+ " ██████╗ ████████╗ ██████╗ ███╗ ██╗██╗██╗ ██╗",
13
+ "██╔═══██╗╚══██╔══╝██╔═══██╗████╗ ██║██║╚██╗██╔╝",
14
+ "██║ ██║ ██║ ██║ ██║██╔██╗██║██║ ╚███╔╝ ",
15
+ "██║ ██║ ██║ ██║ ██║██║╚████║██║ ██╔██╗ ",
16
+ "╚██████╔╝ ██║ ╚██████╔╝██║ ╚███║██║██╔╝╚██╗",
17
+ " ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚══╝╚═╝╚═╝ ╚═╝",
18
+ ];
19
+ export function printBanner() {
20
+ console.log();
21
+ for (const line of ASCII) {
22
+ console.log(chalk.hex(BLUE).bold(line));
23
+ }
24
+ console.log();
25
+ console.log(" " +
26
+ chalk.hex(BLUE_DIM)("web4 autonomous agent infrastructure") +
27
+ " " +
28
+ chalk.dim("v0.1.0"));
29
+ console.log(" " + chalk.dim("─".repeat(48)));
30
+ console.log();
31
+ }
32
+ export function header(text) {
33
+ console.log("\n" + chalk.hex(BLUE).bold("◈ OTONIX") + " " + chalk.dim(text));
34
+ console.log(chalk.dim("─".repeat(44)));
35
+ }
36
+ export function row(label, value) {
37
+ console.log(chalk.dim(label.padEnd(22)) + chalk.white(value));
38
+ }
39
+ export function success(msg) {
40
+ console.log("\n" + ok("✓ ") + chalk.white(msg));
41
+ }
42
+ export function failure(msg) {
43
+ console.log("\n" + err("✗ ") + chalk.white(msg));
44
+ }
45
+ export function info(msg) {
46
+ console.log(chalk.dim(" " + msg));
47
+ }
48
+ export function br() {
49
+ console.log();
50
+ }
package/package.json CHANGED
@@ -1,47 +1,40 @@
1
1
  {
2
2
  "name": "@otonix/cli",
3
- "version": "1.7.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
- "main": "dist/cli.js",
3
+ "version": "2.1.2",
4
+ "description": "Otonix CLIdeploy autonomous agent tokens on Base via Clanker v4",
5
+ "type": "module",
6
6
  "bin": {
7
- "otonix": "dist/cli.js"
7
+ "otonix": "./dist/index.js"
8
8
  },
9
9
  "files": [
10
- "dist",
11
- "README.md"
10
+ "dist"
12
11
  ],
13
12
  "scripts": {
14
- "build": "tsup src/cli.ts --format cjs --clean",
15
- "dev": "tsup src/cli.ts --format cjs --watch",
16
- "prepublishOnly": "echo 'already built'"
13
+ "build": "tsc",
14
+ "dev": "tsx src/index.ts",
15
+ "start": "node dist/index.js",
16
+ "prepublishOnly": "npm run build"
17
17
  },
18
- "keywords": [
19
- "otonix",
20
- "cli",
21
- "autonomous-agents",
22
- "web4",
23
- "x402",
24
- "sovereign-compute",
25
- "ai-agents"
26
- ],
27
- "author": "Otonix <dev@otonix.tech>",
18
+ "keywords": ["otonix", "web4", "ai-agents", "base", "cli", "clanker", "blockchain"],
19
+ "author": "Otonix <contact@otonix.tech>",
28
20
  "license": "MIT",
29
- "homepage": "https://github.com/otonix-ai/cli",
30
- "repository": {
31
- "type": "git",
32
- "url": "https://github.com/otonix-ai/cli.git"
33
- },
34
- "bugs": {
35
- "url": "https://github.com/otonix-ai/cli/issues"
36
- },
37
- "engines": {
38
- "node": ">=18"
21
+ "publishConfig": {
22
+ "access": "public"
39
23
  },
40
24
  "dependencies": {
41
- "@otonix/sdk": "^1.6.0"
25
+ "clanker-sdk": "^4.2.14",
26
+ "commander": "^12.1.0",
27
+ "viem": "^2.38.3",
28
+ "chalk": "^5.3.0",
29
+ "ora": "^8.1.1",
30
+ "@inquirer/prompts": "^7.2.0"
42
31
  },
43
32
  "devDependencies": {
44
- "tsup": "^8.0.0",
45
- "typescript": "^5.0.0"
33
+ "typescript": "^5.5.0",
34
+ "tsx": "^4.19.0",
35
+ "@types/node": "^22.0.0"
36
+ },
37
+ "engines": {
38
+ "node": ">=18"
46
39
  }
47
40
  }