Skip to content

Commit 5d89ec3

Browse files
authored
Merge pull request #2111 from AIFlowML/feature/akash-network-plugin-01
feat: Add Akash Network plugin with autonomous deployment capabilities
2 parents 7187c74 + 909baf8 commit 5d89ec3

31 files changed

+6449
-0
lines changed

.env.example

+46
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,52 @@ TAVILY_API_KEY=
477477
VERIFIABLE_INFERENCE_ENABLED=false # Set to false to disable verifiable inference
478478
VERIFIABLE_INFERENCE_PROVIDER=opacity # Options: opacity
479479

480+
480481
# Autonome Configuration
481482
AUTONOME_JWT_TOKEN=
482483
AUTONOME_RPC=https://wizard-bff-rpc.alt.technology/v1/bff/aaa/apps
484+
485+
####################################
486+
#### Akash Network Configuration ####
487+
####################################
488+
AKASH_ENV=mainnet
489+
AKASH_NET=https://raw.githubusercontent.com/ovrclk/net/master/mainnet
490+
RPC_ENDPOINT=https://rpc.akashnet.net:443
491+
AKASH_GAS_PRICES=0.025uakt
492+
AKASH_GAS_ADJUSTMENT=1.5
493+
AKASH_KEYRING_BACKEND=os
494+
AKASH_FROM=default
495+
AKASH_FEES=20000uakt
496+
AKASH_DEPOSIT=500000uakt
497+
AKASH_MNEMONIC=
498+
AKASH_WALLET_ADDRESS=
499+
# Akash Pricing API
500+
AKASH_PRICING_API_URL=https://console-api.akash.network/v1/pricing
501+
# Default values # 1 CPU = 1000 1GB = 1000000000 1GB = 1000000000
502+
AKASH_DEFAULT_CPU=1000
503+
AKASH_DEFAULT_MEMORY=1000000000
504+
AKASH_DEFAULT_STORAGE=1000000000
505+
AKASH_SDL=example.sdl.yml
506+
# Close deployment
507+
# Close all deployments = closeAll
508+
# Close a single deployment = dseq and add the value in AKASH_CLOSE_DSEQ
509+
AKASH_CLOSE_DEP=closeAll
510+
AKASH_CLOSE_DSEQ=19729929
511+
# Provider Info we added one to check you will have to pass this into the action
512+
AKASH_PROVIDER_INFO=akash1ccktptfkvdc67msasmesuy5m7gpc76z75kukpz
513+
# Deployment Status
514+
# AKASH_DEP_STATUS = dseq or param_passed when you are building you wil pass the dseq dinamically to test you
515+
# you can pass the dseq using AKASH_DEP_DSEQ 19729929 is an example of a dseq we test while build.
516+
AKASH_DEP_STATUS=dseq
517+
AKASH_DEP_DSEQ=19729929
518+
# Gas Estimation Options: close, create, or update
519+
# qseq is required when operation is "close" 19729929 is an example of a dseq we test while build.
520+
AKASH_GAS_OPERATION=close
521+
AKASH_GAS_DSEQ=19729929
522+
# Manifest
523+
# Values: "auto" | "manual" | "validate_only" Default: "auto"
524+
AKASH_MANIFEST_MODE=auto
525+
# Default: Will use the SDL directory
526+
AKASH_MANIFEST_PATH=
527+
# Values: "strict" | "lenient" | "none" - Default: "strict"
528+
AKASH_MANIFEST_VALIDATION_LEVEL=strict

agent/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"@elizaos/plugin-arthera": "workspace:*",
8787
"@elizaos/plugin-allora": "workspace:*",
8888
"@elizaos/plugin-opacity": "workspace:*",
89+
"@elizaos/plugin-akash": "workspace:*",
8990
"readline": "1.3.0",
9091
"ws": "8.18.0",
9192
"yargs": "17.7.2"

agent/src/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
9090
import { OpacityAdapter } from "@elizaos/plugin-opacity";
9191
import { openWeatherPlugin } from "@elizaos/plugin-open-weather";
9292
import { stargazePlugin } from "@elizaos/plugin-stargaze";
93+
import { akashPlugin } from "@elizaos/plugin-akash";
9394
import Database from "better-sqlite3";
9495
import fs from "fs";
9596
import net from "net";
@@ -753,6 +754,10 @@ export async function createAgent(
753754
? artheraPlugin
754755
: null,
755756
getSecret(character, "ALLORA_API_KEY") ? alloraPlugin : null,
757+
getSecret(character, "AKASH_MNEMONIC") &&
758+
getSecret(character, "AKASH_WALLET_ADDRESS")
759+
? akashPlugin
760+
: null,
756761
].filter(Boolean),
757762
providers: [],
758763
actions: [],

packages/plugin-akash/.eslintrc.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
parserOptions: {
5+
project: './tsconfig.json',
6+
tsconfigRootDir: __dirname,
7+
ecmaVersion: 2020,
8+
sourceType: 'module',
9+
},
10+
plugins: ['@typescript-eslint'],
11+
extends: [
12+
'eslint:recommended',
13+
'plugin:@typescript-eslint/recommended',
14+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
15+
],
16+
rules: {
17+
'@typescript-eslint/no-explicit-any': 'warn',
18+
'@typescript-eslint/no-unused-vars': ['error', {
19+
argsIgnorePattern: '^_',
20+
varsIgnorePattern: '^_',
21+
ignoreRestSiblings: true,
22+
}],
23+
'@typescript-eslint/explicit-function-return-type': 'off',
24+
'@typescript-eslint/explicit-module-boundary-types': 'off',
25+
'@typescript-eslint/no-non-null-assertion': 'warn',
26+
'no-console': ['error', { allow: ['warn', 'error'] }],
27+
},
28+
ignorePatterns: ['dist/', 'node_modules/', '*.js', '*.mjs', '*.cjs'],
29+
};

packages/plugin-akash/.npmignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
3+
!dist/**
4+
!package.json
5+
!readme.md
6+
!tsup.config.ts
15.7 KB
Loading
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import eslintGlobalConfig from "../../eslint.config.mjs";
2+
3+
export default [...eslintGlobalConfig];

packages/plugin-akash/jest.config.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
roots: ['<rootDir>/test'],
5+
testMatch: [
6+
"**/__tests__/**/*.+(ts|tsx|js)",
7+
"**/?(*.)+(spec|test).+(ts|tsx|js)"
8+
],
9+
transform: {
10+
"^.+\\.(ts|tsx)$": "ts-jest"
11+
},
12+
moduleNameMapper: {
13+
'^@/(.*)$': '<rootDir>/src/$1'
14+
},
15+
setupFilesAfterEnv: ['<rootDir>/test/setup/jest.setup.ts'],
16+
globals: {
17+
'ts-jest': {
18+
tsconfig: 'tsconfig.json'
19+
}
20+
},
21+
testTimeout: 30000,
22+
verbose: true,
23+
collectCoverage: true,
24+
coverageDirectory: "coverage",
25+
coverageReporters: ["text", "lcov"],
26+
coveragePathIgnorePatterns: [
27+
"/node_modules/",
28+
"/test/fixtures/",
29+
"/test/setup/"
30+
]
31+
};

packages/plugin-akash/package.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "@elizaos/plugin-akash",
3+
"version": "0.1.0",
4+
"description": "Akash Network Plugin for Eliza",
5+
"main": "dist/index.js",
6+
"types": "dist/index.d.ts",
7+
"type": "module",
8+
"scripts": {
9+
"build": "tsup",
10+
"dev": "tsup --watch",
11+
"clean": "rm -rf dist",
12+
"lint": "eslint .",
13+
"lint:fix": "eslint . --fix",
14+
"test": "vitest",
15+
"test:watch": "vitest watch",
16+
"test:coverage": "vitest run --coverage",
17+
"test:ui": "vitest --ui"
18+
},
19+
"dependencies": {
20+
"@akashnetwork/akash-api": "^1.4.0",
21+
"@akashnetwork/akashjs": "0.10.1",
22+
"@cosmjs/proto-signing": "^0.31.3",
23+
"@cosmjs/stargate": "0.31.3",
24+
"@elizaos/core": "workspace:*",
25+
"axios": "^1.7.9",
26+
"dotenv": "^16.4.1",
27+
"jsrsasign": "^11.1.0",
28+
"node-fetch": "^2.7.0",
29+
"zod": "^3.22.4",
30+
"@types/js-yaml": "^4.0.9"
31+
},
32+
"devDependencies": {
33+
"@types/dotenv": "^8.2.0",
34+
"@types/jest": "^29.5.11",
35+
"@types/js-yaml": "^4.0.9",
36+
"@types/node": "^20.10.5",
37+
"@typescript-eslint/eslint-plugin": "^6.15.0",
38+
"@typescript-eslint/parser": "^6.15.0",
39+
"@vitest/coverage-v8": "^0.34.6",
40+
"@vitest/ui": "^0.34.6",
41+
"eslint": "^8.56.0",
42+
"tsup": "^8.0.1",
43+
"typescript": "^5.3.3",
44+
"vite": "^5.0.10",
45+
"vite-tsconfig-paths": "^4.2.2",
46+
"vitest": "^0.34.6"
47+
},
48+
"peerDependencies": {
49+
"@elizaos/core": "workspace:*"
50+
}
51+
}

packages/plugin-akash/readme.md

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Akash Network Plugin for Eliza
2+
3+
A powerful plugin for interacting with the Akash Network, enabling deployment management and cloud compute operations through Eliza.
4+
5+
## Table of Contents
6+
- [Installation](#installation)
7+
- [Configuration](#configuration)
8+
- [Directory Structure](#directory-structure)
9+
- [Available Actions](#available-actions)
10+
11+
## Installation
12+
13+
```bash
14+
pnpm add @elizaos/plugin-akash
15+
```
16+
17+
## Configuration
18+
19+
### Environment Variables
20+
Create a `.env` file in your project root with the following configuration:
21+
22+
```env
23+
# Network Configuration
24+
AKASH_ENV=mainnet
25+
AKASH_NET=https://raw.githubusercontent.com/ovrclk/net/master/mainnet
26+
RPC_ENDPOINT=https://rpc.akashnet.net:443
27+
28+
# Transaction Settings
29+
AKASH_GAS_PRICES=0.025uakt
30+
AKASH_GAS_ADJUSTMENT=1.5
31+
AKASH_KEYRING_BACKEND=os
32+
AKASH_FROM=default
33+
AKASH_FEES=20000uakt
34+
35+
# Authentication
36+
AKASH_MNEMONIC=your_12_word_mnemonic_here
37+
38+
# Manifest Settings
39+
AKASH_MANIFEST_MODE=auto # Options: auto, validate_only
40+
AKASH_MANIFEST_VALIDATION_LEVEL=strict # Options: strict, basic, none
41+
AKASH_MANIFEST_PATH=/path/to/manifests # Optional: Path to save generated manifests
42+
43+
# Deployment Settings
44+
AKASH_DEPOSIT=5000000uakt # Default deployment deposit
45+
AKASH_SDL=deployment.yml # Default SDL file name
46+
```
47+
48+
**Important Notes:**
49+
- `AKASH_MNEMONIC`: Your 12-word wallet mnemonic phrase (required)
50+
- `AKASH_MANIFEST_MODE`: Controls manifest generation behavior
51+
- `AKASH_MANIFEST_VALIDATION_LEVEL`: Sets SDL validation strictness
52+
- `AKASH_DEPOSIT`: Default deposit amount for deployments
53+
54+
⚠️ Never commit your `.env` file with real credentials to version control!
55+
56+
57+
#### SDL (Stack Definition Language)
58+
```
59+
src/sdl/example.sdl.yml
60+
```
61+
Place your SDL configuration files here. The plugin looks for SDL files in this directory by default.
62+
63+
#### Certificates
64+
```
65+
src/.certificates/
66+
```
67+
SSL certificates for secure provider communication are stored here.
68+
69+
## Available Actions
70+
71+
| Action | Description | Parameters |
72+
|---------------------|------------------------------------------------|---------------------------------------------|
73+
| CREATE_DEPLOYMENT | Create a new deployment | `sdl`, `sdlFile`, `deposit` |
74+
| CLOSE_DEPLOYMENT | Close an existing deployment | `dseq`, `owner` |
75+
| GET_PROVIDER_INFO | Get provider information | `provider` |
76+
| GET_DEPLOYMENT_STATUS| Check deployment status | `dseq`, `owner` |
77+
| GET_GPU_PRICING | Get GPU pricing comparison | `cpu`, `memory`, `storage` |
78+
| GET_MANIFEST | Generate deployment manifest | `sdl`, `sdlFile` |
79+
| GET_PROVIDERS_LIST | List available providers | `filter: { active, hasGPU, region }` |
80+
81+
82+
Each action returns a structured response with:
83+
```typescript
84+
{
85+
text: string; // Human-readable response
86+
content: {
87+
success: boolean; // Operation success status
88+
data?: any; // Action-specific data
89+
error?: { // Present only on failure
90+
code: string;
91+
message: string;
92+
};
93+
metadata: { // Operation metadata
94+
timestamp: string;
95+
source: string;
96+
action: string;
97+
version: string;
98+
actionId: string;
99+
}
100+
}
101+
}
102+
```
103+
104+
## Error Handling
105+
106+
The plugin includes comprehensive error handling with specific error codes:
107+
108+
- `VALIDATION_SDL_FAILED`: SDL validation errors
109+
- `WALLET_NOT_INITIALIZED`: Wallet setup issues
110+
- `DEPLOYMENT_CREATION_FAILED`: Deployment failures
111+
- `API_REQUEST_FAILED`: Network/API issues
112+
- `MANIFEST_PARSING_FAILED`: Manifest generation errors
113+
- `PROVIDER_FILTER_ERROR`: Provider filtering issues
114+
115+
## Development
116+
117+
### Running Tests
118+
```bash
119+
pnpm test
120+
```
121+
122+
### Building
123+
```bash
124+
pnpm run build
125+
```
126+
127+
## License
128+
129+
This project is licensed under the MIT License - see the LICENSE file for details.
130+
131+
## Support
132+
133+
For support and questions, please open an issue in the repository or contact the maintainers.

0 commit comments

Comments
 (0)