diff --git a/packages/plugin-akash/biome.json b/packages/plugin-akash/biome.json new file mode 100644 index 00000000000..818716a6219 --- /dev/null +++ b/packages/plugin-akash/biome.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.5.3/schema.json", + "organizeImports": { + "enabled": false + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "correctness": { + "noUnusedVariables": "error" + }, + "suspicious": { + "noExplicitAny": "error" + }, + "style": { + "useConst": "error", + "useImportType": "off" + } + } + }, + "formatter": { + "enabled": true, + "indentStyle": "space", + "indentWidth": 4, + "lineWidth": 100 + }, + "javascript": { + "formatter": { + "quoteStyle": "single", + "trailingCommas": "es5" + } + }, + "files": { + "ignore": [ + "dist/**/*", + "extra/**/*", + "node_modules/**/*" + ] + } +} \ No newline at end of file diff --git a/packages/plugin-akash/package.json b/packages/plugin-akash/package.json index 8da2ca91a7c..40bac98c74c 100644 --- a/packages/plugin-akash/package.json +++ b/packages/plugin-akash/package.json @@ -9,7 +9,10 @@ "build": "tsup", "dev": "tsup --watch", "clean": "rm -rf dist", - "lint:fix": "eslint . --fix", + "lint": "biome lint .", + "lint:fix": "biome check --apply .", + "format": "biome format .", + "format:fix": "biome format --write .", "test": "vitest", "test:watch": "vitest watch", "test:coverage": "vitest run --coverage", @@ -32,15 +35,13 @@ "ora": "^8.0.1" }, "devDependencies": { + "@biomejs/biome": "1.9.4", "@types/dotenv": "^8.2.0", "@types/jest": "^29.5.11", "@types/js-yaml": "^4.0.9", "@types/node": "^20.10.5", - "@typescript-eslint/eslint-plugin": "^6.15.0", - "@typescript-eslint/parser": "^6.15.0", "@vitest/coverage-v8": "^0.34.6", "@vitest/ui": "^0.34.6", - "eslint": "^9.16.0", "tsup": "^8.0.1", "typescript": "^5.3.3", "vite": "^5.0.10", diff --git a/packages/plugin-akash/src/actions/closeDeployment.ts b/packages/plugin-akash/src/actions/closeDeployment.ts index 47c7e17a64b..1b6b9a9fc6d 100644 --- a/packages/plugin-akash/src/actions/closeDeployment.ts +++ b/packages/plugin-akash/src/actions/closeDeployment.ts @@ -311,7 +311,7 @@ export const closeDeploymentAction: Action = { handler: async ( runtime: IAgentRuntime, message: Memory, - state: State | undefined, + _state: State | undefined, _options: { [key: string]: unknown } = {}, callback?: HandlerCallback ): Promise => { diff --git a/packages/plugin-akash/src/actions/createCertificate.ts b/packages/plugin-akash/src/actions/createCertificate.ts index 6e026596629..801d0e9863e 100644 --- a/packages/plugin-akash/src/actions/createCertificate.ts +++ b/packages/plugin-akash/src/actions/createCertificate.ts @@ -8,8 +8,8 @@ import type { CertificatePem } from "@akashnetwork/akashjs/build/certificates/ce import { getAkashTypeRegistry } from "@akashnetwork/akashjs/build/stargate"; import { validateAkashConfig } from "../environment"; import { AkashError, AkashErrorCode, withRetry } from "../error/error"; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import { Registry } from "@cosmjs/proto-signing"; import type { SigningStargateClient as AkashSigningStargateClient } from "@akashnetwork/akashjs/node_modules/@cosmjs/stargate"; import { getCertificatePath } from "../utils/paths"; @@ -271,7 +271,7 @@ export const createCertificateAction: Action = { handler: async ( runtime: IAgentRuntime, message: Memory, - state: State | undefined, + _state: State | undefined, options: { callback?: HandlerCallback } = {} ): Promise => { const actionId = Date.now().toString(); diff --git a/packages/plugin-akash/src/actions/createDeployment.ts b/packages/plugin-akash/src/actions/createDeployment.ts index 2032961fe44..d21cecd416c 100644 --- a/packages/plugin-akash/src/actions/createDeployment.ts +++ b/packages/plugin-akash/src/actions/createDeployment.ts @@ -13,8 +13,8 @@ import { DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing"; import { SigningStargateClient } from "@cosmjs/stargate"; import { validateAkashConfig } from "../environment"; import { AkashError, AkashErrorCode, withRetry } from "../error/error"; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import { getCertificatePath, getDefaultSDLPath } from "../utils/paths"; // import { fileURLToPath } from 'url'; import { inspectRuntime, isPluginLoaded } from "../runtime_inspect"; diff --git a/packages/plugin-akash/src/actions/getDeploymentApi.ts b/packages/plugin-akash/src/actions/getDeploymentApi.ts index 503be32530e..fc46ac9ed30 100644 --- a/packages/plugin-akash/src/actions/getDeploymentApi.ts +++ b/packages/plugin-akash/src/actions/getDeploymentApi.ts @@ -3,8 +3,8 @@ import type { IAgentRuntime, Memory, State, HandlerCallback, Content, ActionExam import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { validateAkashConfig } from "../environment"; import { AkashError, AkashErrorCode } from "../error/error"; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import { getDeploymentsPath } from "../utils/paths"; export interface DeploymentInfo { @@ -48,7 +48,7 @@ async function fetchWithRetry(url: string, options: RequestInit, retries = 3, de }); if (i < retries - 1) { - await sleep(delay * Math.pow(2, i)); // Exponential backoff + await sleep(delay * (2 ** i)); // Exponential backoff continue; } @@ -63,7 +63,7 @@ async function fetchWithRetry(url: string, options: RequestInit, retries = 3, de elizaLogger.warn(`API request error (attempt ${i + 1}/${retries})`, { error: error instanceof Error ? error.message : String(error) }); - await sleep(delay * Math.pow(2, i)); + await sleep(delay * (2 ** i)); } } throw new AkashError( @@ -336,7 +336,7 @@ export const getDeploymentApiAction: Action = { } as ActionExample ]], - validate: async (runtime: IAgentRuntime, message: Memory): Promise => { + validate: async (_runtime: IAgentRuntime, message: Memory): Promise => { elizaLogger.debug("Validating get deployments request", { message }); try { const params = message.content as Partial; @@ -381,7 +381,7 @@ export const getDeploymentApiAction: Action = { handler: async ( runtime: IAgentRuntime, message: Memory, - state: State | undefined, + _state: State | undefined, _options: { [key: string]: unknown } = {}, callback?: HandlerCallback ): Promise => { diff --git a/packages/plugin-akash/src/actions/getDeploymentStatus.ts b/packages/plugin-akash/src/actions/getDeploymentStatus.ts index b927a8961df..2dfd2abae5a 100644 --- a/packages/plugin-akash/src/actions/getDeploymentStatus.ts +++ b/packages/plugin-akash/src/actions/getDeploymentStatus.ts @@ -143,7 +143,7 @@ export const getDeploymentStatusAction: Action = { handler: async ( runtime: IAgentRuntime, message: Memory, - state: State | undefined, + _state: State | undefined, _options: { [key: string]: unknown } = {}, callback?: HandlerCallback ): Promise => { diff --git a/packages/plugin-akash/src/actions/getGPUPricing.ts b/packages/plugin-akash/src/actions/getGPUPricing.ts index a3a4073a2ea..395fa5796e2 100644 --- a/packages/plugin-akash/src/actions/getGPUPricing.ts +++ b/packages/plugin-akash/src/actions/getGPUPricing.ts @@ -58,23 +58,23 @@ export const getGPUPricingAction: Action = { } as ActionExample ]], - validate: async (runtime: IAgentRuntime, message: Memory): Promise => { + validate: async (_runtime: IAgentRuntime, message: Memory): Promise => { elizaLogger.debug("Validating GPU pricing request", { message }); try { const params = message.content as Partial; // Validate CPU if provided - if (params.cpu !== undefined && (isNaN(params.cpu) || params.cpu <= 0)) { + if (params.cpu !== undefined && (Number.isNaN(params.cpu) || params.cpu <= 0)) { throw new GPUPricingError("CPU units must be a positive number", "INVALID_CPU"); } // Validate memory if provided - if (params.memory !== undefined && (isNaN(params.memory) || params.memory <= 0)) { + if (params.memory !== undefined && (Number.isNaN(params.memory) || params.memory <= 0)) { throw new GPUPricingError("Memory must be a positive number", "INVALID_MEMORY"); } // Validate storage if provided - if (params.storage !== undefined && (isNaN(params.storage) || params.storage <= 0)) { + if (params.storage !== undefined && (Number.isNaN(params.storage) || params.storage <= 0)) { throw new GPUPricingError("Storage must be a positive number", "INVALID_STORAGE"); } @@ -91,9 +91,9 @@ export const getGPUPricingAction: Action = { }, handler: async ( - runtime: IAgentRuntime, + _runtime: IAgentRuntime, message: Memory, - state: State | undefined, + _state: State | undefined, _options: { [key: string]: unknown; } = {}, callback?: HandlerCallback ): Promise => { diff --git a/packages/plugin-akash/src/actions/getManifest.ts b/packages/plugin-akash/src/actions/getManifest.ts index 099ae0f412d..5760617d262 100644 --- a/packages/plugin-akash/src/actions/getManifest.ts +++ b/packages/plugin-akash/src/actions/getManifest.ts @@ -3,8 +3,8 @@ import type { IAgentRuntime, Memory, State, HandlerCallback, Content, ActionExam import { SDL } from "@akashnetwork/akashjs/build/sdl"; import { validateAkashConfig } from "../environment"; import { AkashError, AkashErrorCode } from "../error/error"; -import * as fs from 'fs'; -import * as path from 'path'; +import * as fs from 'node:fs'; +import * as path from 'node:path'; import yaml from 'js-yaml'; // import { getAkashTypeRegistry } from "@akashnetwork/akashjs/build/stargate"; import { getDefaultSDLPath } from "../utils/paths"; @@ -70,7 +70,7 @@ const loadSDLFromFile = (filePath: string): string => { // If we get here, none of the paths worked throw new AkashError( - `SDL file not found in any of the possible locations`, + 'SDL file not found in any of the possible locations', AkashErrorCode.VALIDATION_SDL_FAILED, { filePath, @@ -185,7 +185,7 @@ export const getManifestAction: Action = { handler: async ( runtime: IAgentRuntime, message: Memory, - state: State | undefined, + _state: State | undefined, _options: { [key: string]: unknown; } = {}, callback?: HandlerCallback ): Promise => { diff --git a/packages/plugin-akash/src/actions/getProvidersList.ts b/packages/plugin-akash/src/actions/getProvidersList.ts index 8a01783fd27..e8449b82e55 100644 --- a/packages/plugin-akash/src/actions/getProvidersList.ts +++ b/packages/plugin-akash/src/actions/getProvidersList.ts @@ -162,7 +162,7 @@ export const getProvidersListAction: Action = { } as ActionExample ]], - validate: async (runtime: IAgentRuntime, message: Memory): Promise => { + validate: async (_runtime: IAgentRuntime, message: Memory): Promise => { elizaLogger.debug("Validating get providers list request", { message }); try { const params = message.content as Partial; @@ -210,7 +210,7 @@ export const getProvidersListAction: Action = { handler: async ( runtime: IAgentRuntime, message: Memory, - state: State | undefined, + _state: State | undefined, _options: { [key: string]: unknown; } = {}, callback?: HandlerCallback ): Promise => { diff --git a/packages/plugin-akash/src/error/error.ts b/packages/plugin-akash/src/error/error.ts index 0ddbdc603ee..9b6adeed193 100644 --- a/packages/plugin-akash/src/error/error.ts +++ b/packages/plugin-akash/src/error/error.ts @@ -1,4 +1,3 @@ - export enum AkashErrorCategory { WALLET = 'WALLET', DEPLOYMENT = 'DEPLOYMENT', @@ -117,7 +116,7 @@ export async function withRetry( } catch (error) { lastError = error as Error; if (i < maxRetries - 1) { - await new Promise(resolve => setTimeout(resolve, delay * Math.pow(2, i))); + await new Promise(resolve => setTimeout(resolve, delay * (2 ** i))); } } } diff --git a/packages/plugin-akash/src/index.ts b/packages/plugin-akash/src/index.ts index fdd7f59f84d..5ff80a4aca3 100644 --- a/packages/plugin-akash/src/index.ts +++ b/packages/plugin-akash/src/index.ts @@ -1,4 +1,4 @@ -import { Plugin} from "@elizaos/core"; +import type { Plugin} from "@elizaos/core"; import chalk from 'chalk'; import Table from 'cli-table3'; import ora from 'ora'; diff --git a/packages/plugin-akash/src/runtime_inspect.ts b/packages/plugin-akash/src/runtime_inspect.ts index 25b5aee39fd..985b6d0d466 100644 --- a/packages/plugin-akash/src/runtime_inspect.ts +++ b/packages/plugin-akash/src/runtime_inspect.ts @@ -56,7 +56,7 @@ export function isPluginLoaded(runtime: IAgentRuntime, pluginName: string): bool // Check plugins array const plugins = (runtime as any).plugins as Plugin[]; if (!plugins) { - elizaLogger.warn(`No plugins array found in runtime`); + elizaLogger.warn('No plugins array found in runtime'); return false; } @@ -70,7 +70,7 @@ export function isPluginLoaded(runtime: IAgentRuntime, pluginName: string): bool // Check if actions are registered const actions = (runtime as any).actions as Action[]; if (!actions || !actions.length) { - elizaLogger.warn(`No actions found in runtime`); + elizaLogger.warn('No actions found in runtime'); return false; }