Skip to content

Commit

Permalink
lint and fix some things revealed by lint
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Mar 4, 2025
1 parent c38d72d commit 226d299
Show file tree
Hide file tree
Showing 27 changed files with 69 additions and 61 deletions.
2 changes: 1 addition & 1 deletion packages/agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
parseBooleanFromText,
settings,
stringToUuid,
Plugin
type Plugin
} from "@elizaos/core";
import net from "node:net";
import yargs from "yargs";
Expand Down
2 changes: 1 addition & 1 deletion packages/agent/src/server/api/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,7 @@ export function agentRouter(
try {
const limit = req.query.limit ? Number.parseInt(req.query.limit as string, 10) : 20;
const before = req.query.before ? Number.parseInt(req.query.before as string, 10) : Date.now();
const worldId = req.query.worldId as string;
const _worldId = req.query.worldId as string;

const memories = await runtime.messageManager.getMemories({
roomId,
Expand Down
10 changes: 5 additions & 5 deletions packages/agent/src/swarm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import socialMediaManager from "./socialMediaManager";

export const swarm: {character: Character, init: (runtime: IAgentRuntime) => void, plugins?: Plugin[]}[] = [
investmentManager,
// communityManager,
// socialMediaManager,
// liaison,
// projectManager,
// devRel,
communityManager,
socialMediaManager,
liaison,
projectManager,
devRel,
];

export default swarm;
4 changes: 2 additions & 2 deletions packages/agent/src/swarm/investmentManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ const config: OnboardingConfig = {

export default {
plugins: [
// degenIntelPlugin,
// degenTraderPlugin,
degenIntelPlugin,
degenTraderPlugin,
communityTraderPlugin,
],
character,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { composeContext, type Content, type IAgentRuntime, logger, type Memory,
import { Connection, VersionedTransaction } from "@solana/web3.js";
import { v4 as uuidv4 } from "uuid";
import { REQUIRED_SETTINGS } from "./config/config";
import { BuySignalMessage, PriceSignalMessage, SellSignalMessage, ServiceTypes } from "./types";
import { type BuySignalMessage, type PriceSignalMessage, type SellSignalMessage, ServiceTypes } from "./types";
import { tradeAnalysisTemplate } from "./utils/analyzeTrade";
import { executeTrade, getWalletBalance, getWalletKeypair } from "./utils/wallet";

Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/components/app-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export function AppSidebar() {
});

// Split into enabled and disabled groups
const activeAgents = sortedAgents.filter((agent: Partial<Agent & { status: string }>) => agent.status == 'active');
const inactiveAgents = sortedAgents.filter((agent: Partial<Agent & { status: string }>) => agent.status == 'inactive');
const activeAgents = sortedAgents.filter((agent: Partial<Agent & { status: string }>) => agent.status === 'active');
const inactiveAgents = sortedAgents.filter((agent: Partial<Agent & { status: string }>) => agent.status === 'inactive');

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/hooks/use-agent-management.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { useQueryClient } from '@tanstack/react-query';
import { Agent, UUID } from '@elizaos/core';
import type { Agent, UUID } from '@elizaos/core';
import { useStartAgent, useStopAgent } from './use-query-hooks';
import { useToast } from './use-toast';

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/actions/settings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { z, ZodSchema } from "zod";
import type { z, ZodSchema } from "zod";
import { composeContext } from "../context";
import { createUniqueUuid } from "../entities";
import { logger } from "../logger";
Expand All @@ -12,7 +12,7 @@ import {
type HandlerCallback,
type IAgentRuntime,
type Memory,
ModelType,
type ModelType,
ModelTypes,
type OnboardingSetting,
type State,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ import {
type IMemoryManager,
type KnowledgeItem,
type Memory,
ModelType,
type ModelType,
ModelTypes,
type Plugin,
type Provider,
type RoomData,
type Route,
type Service,
ServiceType,
type ServiceType,
type State,
type TaskWorker,
type UUID,
Expand Down
6 changes: 1 addition & 5 deletions packages/core/src/services/taskService.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
// registered to runtime through plugin

import { type IAgentRuntime, Service, ServiceTypes, type UUID, ServiceType } from "../types";
import { type IAgentRuntime, Service, ServiceTypes, type UUID, type ServiceType } from "../types";

export class TaskService extends Service {
private timer: NodeJS.Timer | null = null;
private readonly TICK_INTERVAL = 1000; // Check every second
static serviceType: ServiceType = ServiceTypes.TASK;

constructor(runtime: IAgentRuntime) {
super(runtime);
}

static async start(runtime: IAgentRuntime): Promise<TaskService> {
const service = new TaskService(runtime);
await service.startTimer();
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import EventEmitter from "node:events";

/**
* Represents a UUID string in the format "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
*/
Expand Down Expand Up @@ -561,18 +563,20 @@ export enum ChannelType {
/**
* Client instance
*/
export abstract class Service {
export abstract class Service extends EventEmitter {
/** Additional keys */
[key: string]: any;

/** Runtime instance */
protected runtime!: IAgentRuntime;

constructor(runtime?: IAgentRuntime) {
super();
if (runtime) {
this.runtime = runtime;
}
}


/** Service type */
static serviceType: string;
Expand Down
9 changes: 4 additions & 5 deletions packages/plugin-discord/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@ import { DiscordTestSuite } from "./tests.ts";
import type { IDiscordService } from "./types.ts";
import { VoiceManager } from "./voice.ts";

export class DiscordService extends EventEmitter implements IDiscordService, Service {
export class DiscordService extends Service implements IDiscordService {
static serviceType: string = DISCORD_SERVICE_NAME;
client: DiscordJsClient;
runtime: IAgentRuntime;
character: Character;
messageManager: MessageManager;
voiceManager: VoiceManager;

constructor(runtime: IAgentRuntime) {
super();
super(runtime);

logger.log("Discord client constructor was engaged");

Expand All @@ -77,7 +76,7 @@ export class DiscordService extends EventEmitter implements IDiscordService, Ser
});

this.runtime = runtime;
this.voiceManager = new VoiceManager(this);
this.voiceManager = new VoiceManager(this, runtime);
this.messageManager = new MessageManager(this);

this.client.once(Events.ClientReady, this.onClientReady.bind(this));
Expand Down Expand Up @@ -204,7 +203,7 @@ export class DiscordService extends EventEmitter implements IDiscordService, Ser
});
}

static async start(runtime: IAgentRuntime) {
static async start(runtime: IAgentRuntime): Promise<DiscordService> {
const client = new DiscordService(runtime);
return client;
}
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-discord/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type {

export interface IDiscordService {
client: Client;
runtime: IAgentRuntime;
character: Character;
}

Expand Down
22 changes: 16 additions & 6 deletions packages/plugin-discord/src/voice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
joinVoiceChannel,
} from "@discordjs/voice";
import {
type ChannelType,
ChannelType,
type Content,
type HandlerCallback,
type IAgentRuntime,
Expand Down Expand Up @@ -148,19 +148,29 @@ export class VoiceManager extends EventEmitter {
{ channel: BaseGuildVoiceChannel; monitor: AudioMonitor }
> = new Map();
private ready: boolean;
private getChannelType: (channelId: string) => Promise<ChannelType>;

constructor(client: DiscordService) {
constructor(service: DiscordService, runtime: IAgentRuntime) {
super();
this.client = client.client;
this.runtime = client.runtime;
this.getChannelType = client.getChannelType;
this.client = service.client;
this.runtime = runtime;

this.client.on("voiceManagerReady", () => {
this.setReady(true);
});
}

async getChannelType(channelId: string): Promise<ChannelType> {
const channel = await this.client.channels.fetch(channelId);
switch (channel.type) {
case DiscordChannelType.DM:
return ChannelType.DM;
case DiscordChannelType.GuildText:
return ChannelType.GROUP;
case DiscordChannelType.GuildVoice:
return ChannelType.VOICE_GROUP;
}
}

private setReady(status: boolean) {
this.ready = status;
this.emit("ready");
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-local-ai/__tests__/test-utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
logger,
ModelTypes,
ModelType,
type ModelType,
type Character,
type IAgentRuntime,
type IDatabaseAdapter,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-node/src/services/awsS3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
type IAgentRuntime,
type IFileService,
Service,
ServiceType,
type ServiceType,
ServiceTypes,
logger,
} from "@elizaos/core";
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-node/src/services/browser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlaywrightBlocker } from "@cliqz/adblocker-playwright";
import { type IAgentRuntime, type IBrowserService, logger, ModelTypes, parseJSONObjectFromText, Service, ServiceType, ServiceTypes, settings, stringToUuid, trimTokens } from "@elizaos/core";
import { type IAgentRuntime, type IBrowserService, logger, ModelTypes, parseJSONObjectFromText, Service, type ServiceType, ServiceTypes, settings, stringToUuid, trimTokens } from "@elizaos/core";
import CaptchaSolver from "capsolver-npm";
import {
type Browser,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-node/src/services/pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
type IAgentRuntime,
type IPdfService,
Service,
ServiceType,
type ServiceType,
ServiceTypes,
} from "@elizaos/core";
import { getDocument, type PDFDocumentProxy } from "pdfjs-dist";
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-node/src/services/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type Media,
Service,
ServiceTypes,
ServiceType,
type ServiceType,
stringToUuid,
logger,
ModelTypes,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-solana/src/actions/swap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ModelTypes,
parseJSONObjectFromText,
settings,
type State
type State,
} from '@elizaos/core';
import { Connection, PublicKey, VersionedTransaction } from '@solana/web3.js';
import BigNumber from 'bignumber.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-solana/src/actions/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
type Memory,
ModelTypes,
parseJSONObjectFromText,
type State
type State,
} from '@elizaos/core';
import {
createAssociatedTokenAccountInstruction,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-solana/src/providers/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { WalletPortfolio } from '../types';
import { SOLANA_WALLET_DATA_CACHE_KEY } from '../constants';

export const walletProvider: Provider = {
name: "solana-wallet",
name: 'solana-wallet',
get: async (
runtime: IAgentRuntime,
_message: Memory,
Expand Down
7 changes: 2 additions & 5 deletions packages/plugin-solana/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,15 @@ export class SolanaService extends Service {
private connection: Connection;
private publicKey: PublicKey;

constructor(
protected runtime: IAgentRuntime,
) {
super()
constructor(protected runtime: IAgentRuntime) {
super();
const connection = new Connection(
runtime.getSetting('SOLANA_RPC_URL') || PROVIDER_CONFIG.DEFAULT_RPC,
);
this.connection = connection;
getWalletKey(runtime, false).then(({ publicKey }) => {
this.publicKey = publicKey;
});

}

static async start(runtime: IAgentRuntime): Promise<SolanaService> {
Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-tee/src/providers/deriveKeyProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class PhalaDeriveKeyProvider extends DeriveKeyProvider {
}

const phalaDeriveKeyProvider: Provider = {
name: "phala-derive-key",
name: 'phala-derive-key',
get: async (runtime: IAgentRuntime, _message?: Memory, _state?: State) => {
const teeMode = runtime.getSetting('TEE_MODE');
const provider = new PhalaDeriveKeyProvider(teeMode);
Expand Down Expand Up @@ -213,7 +213,7 @@ const phalaDeriveKeyProvider: Provider = {
class MarlinDeriveKeyProvider extends DeriveKeyProvider {}

const marlinDeriveKeyProvider: Provider = {
name: "marlin-derive-key",
name: 'marlin-derive-key',
get: async (_runtime: IAgentRuntime, _message?: Memory, _state?: State) => {
return 'Marlin Derive Key Provider';
},
Expand All @@ -229,7 +229,7 @@ const marlinDeriveKeyProvider: Provider = {
class FleekDeriveKeyProvider extends DeriveKeyProvider {}

const fleekDeriveKeyProvider: Provider = {
name: "fleek-derive-key",
name: 'fleek-derive-key',
get: async (_runtime: IAgentRuntime, _message?: Memory, _state?: State) => {
return 'Fleek Derive Key Provider';
},
Expand All @@ -245,7 +245,7 @@ const fleekDeriveKeyProvider: Provider = {
class SgxGramineDeriveKeyProvider extends DeriveKeyProvider {}

const sgxGramineDeriveKeyProvider: Provider = {
name: "sgx-gramine-derive-key",
name: 'sgx-gramine-derive-key',
get: async (_runtime: IAgentRuntime, _message?: Memory, _state?: State) => {
return 'SGX Gramine Derive Key Provider';
},
Expand Down
Loading

0 comments on commit 226d299

Please sign in to comment.