Skip to content

Commit

Permalink
Merge pull request #2816 from AIFlowML/fix-akash-splash
Browse files Browse the repository at this point in the history
fix: akash splash
  • Loading branch information
shakkernerd authored Jan 27, 2025
2 parents 1cb34a8 + 3c8b1db commit 0707f51
Showing 1 changed file with 80 additions and 39 deletions.
119 changes: 80 additions & 39 deletions packages/plugin-akash/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { Plugin} from "@elizaos/core";
import { Plugin} from "@elizaos/core";
import chalk from 'chalk';
import Table from 'cli-table3';
import ora from 'ora';
import { getConfig } from "./environment";
import { createDeploymentAction } from "./actions/createDeployment";
import { closeDeploymentAction } from "./actions/closeDeployment";
import { getProviderInfoAction } from "./actions/getProviderInfo";
Expand All @@ -9,6 +13,14 @@ import { getGPU#Action } from "./actions/getGPU#";
import { getManifestAction } from "./actions/getManifest";
import { getProvidersListAction } from "./actions/getProvidersList";


// Start the loader
const spinner = ora({
text: chalk.cyan('Initializing Akash Network Plugin...'),
spinner: 'dots12',
color: 'cyan'
}).start();

const actions = [
createDeploymentAction,
closeDeploymentAction,
Expand All @@ -21,48 +33,77 @@ const actions = [
getProvidersListAction,
];

const AKASH_SPASH = getConfig().AKASH_WALLET_ADDRESS;

// Initial banner
console.log("\n┌════════════════════════════════════════┐");
console.log("│ AKASH NETWORK PLUGIN │");
console.log("├────────────────────────────────────────┤");
console.log("│ Initializing Akash Network Plugin... │");
console.log("│ Version: 0.1.0 │");
console.log("└════════════════════════════════════════┘");
// Only show splash screen if AKASH_SPASH is true
if (AKASH_SPASH) {
// Initial banner with chalk styling
console.log(`\n${chalk.cyan('┌────────────────────────────────────────┐')}`);
console.log(chalk.cyan('│') + chalk.yellow.bold(' AKASH NETWORK PLUGIN ') + chalk.cyan(' │'));
console.log(chalk.cyan('├────────────────────────────────────────┤'));
console.log(chalk.cyan('│') + chalk.white(' Initializing Akash Network Plugin... ') + chalk.cyan('│'));
console.log(chalk.cyan('│') + chalk.white(' Version: 0.1.1 ') + chalk.cyan('│'));
console.log(chalk.cyan('└────────────────────────────────────────┘'));

// Stop the loader
spinner.succeed(chalk.green('Akash Network Plugin initialized successfully!'));

// Create a beautiful table for actions
const actionTable = new Table({
head: [
chalk.cyan('Action'),
chalk.cyan('H'),
chalk.cyan('V'),
chalk.cyan('E'),
chalk.cyan('Similes')
],
style: {
head: [],
border: ['cyan']
}
});

// Format and add action information
for (const action of actions) {
actionTable.push([
chalk.white(action.name),
typeof action.handler === 'function' ? chalk.green('✓') : chalk.red('✗'),
typeof action.validate === 'function' ? chalk.green('✓') : chalk.red('✗'),
action.examples?.length > 0 ? chalk.green('✓') : chalk.red('✗'),
chalk.gray(action.similes?.join(', ') || 'none')
]);
}

// Format action registration message
const formatActionInfo = (action: any) => {
const name = action.name.padEnd(25);
const similes = (action.similes?.join(", ") || "none").padEnd(60);
const hasHandler = action.handler ? "✓" : "✗";
const hasValidator = action.validate ? "✓" : "✗";
const hasExamples = action.examples?.length > 0 ? "✓" : "✗";
// Display the action table
console.log(`\n${actionTable.toString()}`);

return `│ ${name}${hasHandler}${hasValidator}${hasExamples}${similes} │`;
};
// Plugin status with a nice table
const statusTable = new Table({
style: {
border: ['cyan']
}
});

// Log registered actions
console.log("\n┌───────────────────────────┬───┬───┬───┬───────────────────────────────────────────────────────────┐");
console.log("│ Action │ H │ V │ E │ Similes │");
console.log("├───────────────────────────┼───┼───┼───┼────────────────────────────────────────────────────────────┤");
actions.forEach(action => {
console.log(formatActionInfo(action));
});
console.log("└───────────────────────────┴───┴───┴───┴──────────────────────────────────────────────────────────┘");
statusTable.push(
[chalk.cyan('Plugin Status')],
[chalk.white('Name : ') + chalk.yellow('plugin-akash')],
[chalk.white('Actions : ') + chalk.green(actions.length.toString())],
[chalk.white('Status : ') + chalk.green('Loaded & Ready')]
);

// Plugin status
console.log("\n┌─────────────────────────────────────┐");
console.log("│ Plugin Status │");
console.log("├─────────────────────────────────────┤");
console.log(`│ Name : akash │`);
console.log(`│ Actions : ${actions.length.toString().padEnd(24)} │`);
console.log(`│ Status : Loaded & Ready │`);
console.log("└─────────────────────────────────────┘\n");
console.log(`\n${statusTable.toString()}\n`);
} else {
// Stop the loader silently if splash is disabled
spinner.stop();
}

export const akashPlugin: Plugin = {
name: "akash",
description: "Akash Network Plugin for deploying and managing cloud compute",
actions: actions,
evaluators: []
};
const akashPlugin: Plugin = {
name: "plugin-akash",
description: "Akash Network Plugin for deploying and managing cloud compute",
actions: actions,
evaluators: []
};

export default akashPlugin;
export { akashPlugin };
export default akashPlugin;

0 comments on commit 0707f51

Please # to comment.