Skip to content

Commit

Permalink
Merge branch 'develop' into issue-16
Browse files Browse the repository at this point in the history
  • Loading branch information
antman1p authored Jan 17, 2025
2 parents 31227ca + f70c1cd commit 3ffe168
Show file tree
Hide file tree
Showing 149 changed files with 34,248 additions and 1,165 deletions.
15 changes: 15 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ EMBEDDING_OPENAI_MODEL= # Default: text-embedding-3-small
IMAGE_OPENAI_MODEL= # Default: dall-e-3
USE_OPENAI_EMBEDDING= # Set to TRUE for OpenAI/1536, leave blank for local

# Atoma SDK Configuration
ATOMASDK_BEARER_AUTH= # Atoma SDK Bearer Auth token
ATOMA_API_URL= # Default: https://api.atoma.network/v1
SMALL_ATOMA_MODEL= # Default: meta-llama/Llama-3.3-70B-Instruct
MEDIUM_ATOMA_MODEL= # Default: meta-llama/Llama-3.3-70B-Instruct
LARGE_ATOMA_MODEL= # Default: meta-llama/Llama-3.3-70B-Instruct

# Eternal AI's Decentralized Inference API
ETERNALAI_URL=
ETERNALAI_MODEL= # Default: "NousResearch/Hermes-3-Llama-3.1-70B-FP8"
Expand Down Expand Up @@ -302,6 +309,10 @@ SOLANA_ADMIN_PRIVATE_KEY= # This wallet is used to verify NFTs
SOLANA_ADMIN_PUBLIC_KEY= # This wallet is used to verify NFTs
SOLANA_VERIFY_TOKEN= # Authentication token for calling the verification API

# Injective
INJECTIVE_PRIVATE_KEY= #
INJECTIVE_PUBLIC_KEY= #
INJECTIVE_NETWORK= #
# Fallback Wallet Configuration (deprecated)
WALLET_PRIVATE_KEY=
WALLET_PUBLIC_KEY=
Expand Down Expand Up @@ -543,6 +554,10 @@ AWS_SECRET_ACCESS_KEY=
AWS_REGION=
AWS_S3_BUCKET=
AWS_S3_UPLOAD_PATH=
AWS_S3_ENDPOINT=
AWS_S3_SSL_ENABLED=
AWS_S3_FORCE_PATH_STYLE=


# Deepgram
DEEPGRAM_API_KEY=
Expand Down
1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@elizaos/plugin-nft-generation": "workspace:*",
"@elizaos/plugin-node": "workspace:*",
"@elizaos/plugin-solana": "workspace:*",
"@elizaos/plugin-injective": "workspace:*",
"@elizaos/plugin-solana-agentkit": "workspace:*",
"@elizaos/plugin-squid-router": "workspace:*",
"@elizaos/plugin-autonome": "workspace:*",
Expand Down
18 changes: 14 additions & 4 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,9 @@ import { evmPlugin } from "@elizaos/plugin-evm";
import { flowPlugin } from "@elizaos/plugin-flow";
import { fuelPlugin } from "@elizaos/plugin-fuel";
import { genLayerPlugin } from "@elizaos/plugin-genlayer";
import { giphyPlugin } from "@elizaos/plugin-giphy";
import { gitcoinPassportPlugin } from "@elizaos/plugin-gitcoin-passport";
import { hyperliquidPlugin } from "@elizaos/plugin-hyperliquid";
import { imageGenerationPlugin } from "@elizaos/plugin-image-generation";
import { lensPlugin } from "@elizaos/plugin-lensNetwork";
import { letzAIPlugin } from "@elizaos/plugin-letzai";
import { multiversxPlugin } from "@elizaos/plugin-multiversx";
import { nearPlugin } from "@elizaos/plugin-near";
import createNFTCollectionsPlugin from "@elizaos/plugin-nft-collections";
Expand All @@ -96,9 +93,13 @@ import { TEEMode, teePlugin } from "@elizaos/plugin-tee";
import { teeLogPlugin } from "@elizaos/plugin-tee-log";
import { teeMarlinPlugin } from "@elizaos/plugin-tee-marlin";
import { verifiableLogPlugin } from "@elizaos/plugin-tee-verifiable-log";
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
import { tonPlugin } from "@elizaos/plugin-ton";
import { webSearchPlugin } from "@elizaos/plugin-web-search";
import { injectivePlugin } from "@elizaos/plugin-injective";
import { giphyPlugin } from "@elizaos/plugin-giphy";
import { letzAIPlugin } from "@elizaos/plugin-letzai";
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
import { hyperliquidPlugin } from "@elizaos/plugin-hyperliquid";
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
import { dexScreenerPlugin } from "@elizaos/plugin-dexscreener";

Expand Down Expand Up @@ -476,6 +477,11 @@ export function getTokenForProvider(
character.settings?.secrets?.VENICE_API_KEY ||
settings.VENICE_API_KEY
);
case ModelProviderName.ATOMA:
return (
character.settings?.secrets?.ATOMASDK_BEARER_AUTH ||
settings.ATOMASDK_BEARER_AUTH
);
case ModelProviderName.AKASH_CHAT_API:
return (
character.settings?.secrets?.AKASH_CHAT_API_KEY ||
Expand Down Expand Up @@ -801,6 +807,10 @@ export async function createAgent(
getSecret(character, "WALLET_PUBLIC_KEY")?.startsWith("0x"))
? evmPlugin
: null,
((getSecret(character, "EVM_PUBLIC_KEY") || getSecret(character, "INJECTIVE_PUBLIC_KEY")) &&
getSecret(character, "INJECTIVE_PRIVATE_KEY"))
? injectivePlugin
: null,
getSecret(character, "COSMOS_RECOVERY_PHRASE") &&
getSecret(character, "COSMOS_AVAILABLE_CHAINS") &&
createCosmosPlugin(),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@0glabs/0g-ts-sdk": "0.2.1",
"@coinbase/coinbase-sdk": "0.10.0",
"@deepgram/sdk": "^3.9.0",
"@injectivelabs/sdk-ts": "^1.14.33",
"@vitest/eslint-plugin": "1.0.1",
"amqplib": "0.10.5",
"csv-parse": "5.6.0",
Expand Down
50 changes: 50 additions & 0 deletions packages/client-github/__tests__/environment.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { describe, it, expect, vi } from 'vitest';
import { validateGithubConfig, githubEnvSchema } from '../src/environment';
import { IAgentRuntime } from '@elizaos/core';

describe('GitHub Environment Configuration', () => {
const mockRuntime: IAgentRuntime = {
getSetting: vi.fn(),
} as unknown as IAgentRuntime;

it('validates correct GitHub configuration', async () => {
const validConfig = {
GITHUB_OWNER: 'testowner',
GITHUB_REPO: 'testrepo',
GITHUB_BRANCH: 'main',
GITHUB_PATH: 'src',
GITHUB_API_TOKEN: 'ghp_test123',
};

vi.mocked(mockRuntime.getSetting).mockImplementation((key: string) => validConfig[key as keyof typeof validConfig]);

const config = await validateGithubConfig(mockRuntime);
expect(config).toEqual(validConfig);
});

it('throws error for missing configuration', async () => {
const invalidConfig = {
GITHUB_OWNER: '',
GITHUB_REPO: '',
GITHUB_BRANCH: '',
GITHUB_PATH: '',
GITHUB_API_TOKEN: '',
};

vi.mocked(mockRuntime.getSetting).mockImplementation((key: string) => invalidConfig[key as keyof typeof invalidConfig]);

await expect(validateGithubConfig(mockRuntime)).rejects.toThrow();
});

it('throws error for partial configuration', async () => {
const partialConfig = {
GITHUB_OWNER: 'testowner',
GITHUB_REPO: 'testrepo',
// Missing other required fields
};

vi.mocked(mockRuntime.getSetting).mockImplementation((key: string) => partialConfig[key as keyof typeof partialConfig]);

await expect(validateGithubConfig(mockRuntime)).rejects.toThrow();
});
});
88 changes: 88 additions & 0 deletions packages/client-github/__tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { GitHubClient, GitHubClientInterface } from '../src';
import { AgentRuntime, IAgentRuntime } from '@elizaos/core';
import { Octokit } from '@octokit/rest';
import simpleGit from 'simple-git';
import fs from 'fs';
import fsPromises from 'fs/promises';

// Mock external dependencies
vi.mock('@octokit/rest', () => ({
Octokit: vi.fn(),
}));

vi.mock('simple-git', () => ({
default: vi.fn(() => ({
clone: vi.fn(),
pull: vi.fn(),
checkout: vi.fn(),
})),
}));

vi.mock('fs/promises', async (importOriginal) => {
const actual = await importOriginal() as typeof fsPromises;
return {
...actual,
mkdir: vi.fn(),
lstat: vi.fn(),
readdir: vi.fn(),
readFile: vi.fn(),
writeFile: vi.fn(),
};
});

vi.mock('fs', async (importOriginal) => {
const actual = await importOriginal() as typeof fs;
return {
...actual,
existsSync: vi.fn(),
realpathSync: vi.fn(),
lstatSync: vi.fn(),
readdirSync: vi.fn(),
};
});

describe('GitHubClient', () => {
let mockRuntime: AgentRuntime;
const mockConfig = {
GITHUB_OWNER: 'testowner',
GITHUB_REPO: 'testrepo',
GITHUB_BRANCH: 'main',
GITHUB_PATH: 'src',
GITHUB_API_TOKEN: 'ghp_test123',
};

beforeEach(() => {
vi.clearAllMocks();
mockRuntime = {
getSetting: vi.fn((key: string) => mockConfig[key as keyof typeof mockConfig]),
} as unknown as AgentRuntime;
});

it('initializes with correct configuration', () => {
const client = new GitHubClient(mockRuntime);
expect(Octokit).toHaveBeenCalledWith({ auth: mockConfig.GITHUB_API_TOKEN });
});

describe('GitHubClientInterface', () => {
it('has start and stop methods', () => {
expect(GitHubClientInterface.start).toBeDefined();
expect(GitHubClientInterface.stop).toBeDefined();
});

it('start method initializes client', async () => {
const runtime = {
getSetting: vi.fn((key: string) => mockConfig[key as keyof typeof mockConfig]),
} as unknown as IAgentRuntime;

await GitHubClientInterface.start(runtime);
// Add more specific assertions based on what start should do
});

it('stop method cleans up resources', () => {
const runtime = {} as IAgentRuntime;
GitHubClientInterface.stop(runtime);
// Add assertions for cleanup if needed
});
});
});
7 changes: 5 additions & 2 deletions packages/client-github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
},
"devDependencies": {
"@types/glob": "8.1.0",
"tsup": "8.3.5"
"tsup": "8.3.5",
"vitest": "^1.2.1"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"lint": "eslint --fix --cache ."
"lint": "eslint --fix --cache .",
"test": "vitest run",
"test:watch": "vitest"
}
}
3 changes: 3 additions & 0 deletions packages/client-instagram/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import eslintGlobalConfig from "../../eslint.config.mjs";

export default [...eslintGlobalConfig];
90 changes: 46 additions & 44 deletions packages/client-instagram/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,52 @@ import { InstagramInteractionService } from "./services/interaction";
import { InstagramPostService } from "./services/post";

export const InstagramClientInterface: Client = {
async start(runtime: IAgentRuntime) {
try {
// Validate configuration
const config = await validateInstagramConfig(runtime);
elizaLogger.log("Instagram client configuration validated");

// Initialize client and get initial state
const state = await initializeClient(runtime, config);
elizaLogger.log("Instagram client initialized");

// Create services
const postService = new InstagramPostService(runtime, state);
const interactionService = new InstagramInteractionService(runtime, state);

// Start services
if (!config.INSTAGRAM_DRY_RUN) {
await postService.start();
elizaLogger.log("Instagram post service started");

if (config.INSTAGRAM_ENABLE_ACTION_PROCESSING) {
await interactionService.start();
elizaLogger.log("Instagram interaction service started");
async start(runtime: IAgentRuntime) {
try {
// Validate configuration
const config = await validateInstagramConfig(runtime);
elizaLogger.log("Instagram client configuration validated");

// Initialize client and get initial state
const state = await initializeClient(runtime, config);
elizaLogger.log("Instagram client initialized");

// Create services
const postService = new InstagramPostService(runtime, state);
const interactionService = new InstagramInteractionService(
runtime,
state
);

// Start services
if (!config.INSTAGRAM_DRY_RUN) {
await postService.start();
elizaLogger.log("Instagram post service started");

if (config.INSTAGRAM_ENABLE_ACTION_PROCESSING) {
await interactionService.start();
elizaLogger.log("Instagram interaction service started");
}
} else {
elizaLogger.log("Instagram client running in dry-run mode");
}

// Return manager instance
return {
post: postService,
interaction: interactionService,
state,
};
} catch (error) {
elizaLogger.error("Failed to start Instagram client:", error);
throw error;
}
} else {
elizaLogger.log("Instagram client running in dry-run mode");
}

// Return manager instance
return {
post: postService,
interaction: interactionService,
state
};

} catch (error) {
elizaLogger.error("Failed to start Instagram client:", error);
throw error;
}
},

async stop(runtime: IAgentRuntime) {
elizaLogger.log("Stopping Instagram client services...");
// Cleanup will be handled by the services themselves
}
},

async stop(_runtime: IAgentRuntime) {
elizaLogger.log("Stopping Instagram client services...");
// Cleanup will be handled by the services themselves
},
};

export default InstagramClientInterface;
export default InstagramClientInterface;
Loading

0 comments on commit 3ffe168

Please sign in to comment.