Skip to content

Commit

Permalink
Merge pull request #3739 from elizaOS/develop
Browse files Browse the repository at this point in the history
chore: dev =>  main (rel 0.25.9 prep)
  • Loading branch information
odilitime authored Mar 2, 2025
2 parents c04f89a + ae9ca51 commit 2c06f56
Show file tree
Hide file tree
Showing 370 changed files with 11,020 additions and 5,949 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ LARGE_NANOGPT_MODEL= # Default: gpt-4o

# Anthropic Configuration
ANTHROPIC_API_KEY= # For Claude
ANTHROPIC_API_URL=
SMALL_ANTHROPIC_MODEL= # Default: claude-3-haiku-20240307
MEDIUM_ANTHROPIC_MODEL= # Default: claude-3-5-sonnet-20241022
LARGE_ANTHROPIC_MODEL= # Default: claude-3-5-sonnet-20241022
Expand Down Expand Up @@ -445,6 +446,11 @@ STARKNET_RPC_URL=https://rpc.starknet-testnet.lava.build
LENS_ADDRESS=
LENS_PRIVATE_KEY=

# Viction Configuration
VICTION_ADDRESS=
VICTION_PRIVATE_KEY=
VICTION_RPC_URL=

# Form Chain
FORM_PRIVATE_KEY= # Form character account private key
FORM_TESTNET=true # A flag indicating if connection is made to Form Testnet. Set to false for Mainnet connection.
Expand Down
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,48 @@ pnpm install --include=optional sharp

---

## Using Your Custom Plugins
Plugins that are not in the official registry for ElizaOS can be used as well. Here's how:

### Installation

1. Upload the custom plugin to the packages folder:

```
packages/
├─plugin-example/
├── package.json
├── tsconfig.json
├── src/
│ ├── index.ts # Main plugin entry
│ ├── actions/ # Custom actions
│ ├── providers/ # Data providers
│ ├── types.ts # Type definitions
│ └── environment.ts # Configuration
├── README.md
└── LICENSE
```

2. Add the custom plugin to your project's dependencies in the agent's package.json:

```json
{
"dependencies": {
"@elizaos/plugin-example": "workspace:*"
}
}
```

3. Import the custom plugin to your agent's character.json

```json
"plugins": [
"@elizaos/plugin-example",
],
```

---

### Start Eliza with Gitpod

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/elizaos/eliza/tree/main)
Expand Down
14 changes: 7 additions & 7 deletions agent/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elizaos/agent",
"version": "0.25.8",
"version": "0.25.9",
"main": "src/index.ts",
"type": "module",
"scripts": {
Expand All @@ -19,17 +19,17 @@
},
"dependencies": {
"@elizaos/client-direct": "workspace:*",
"@elizaos/plugin-bootstrap": "workspace:*",
"@elizaos/core": "workspace:*",
"readline": "1.3.0",
"ws": "8.18.0",
"@elizaos/plugin-bootstrap": "workspace:*",
"@types/node": "^22.13.5",
"json5": "2.2.3",
"ts-node": "^10.9.2",
"yargs": "17.7.2"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@types/jest": "^29.5.14",
"jest": "^29.7.0",
"ts-jest": "^29.2.5",
"ts-node": "10.9.2",
"tsup": "8.3.5"
"ts-jest": "^29.2.6"
}
}
2 changes: 1 addition & 1 deletion agent/src/defaultCharacter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Character, ModelProviderName } from "@elizaos/core";
import { type Character, ModelProviderName } from "@elizaos/core";

export const defaultCharacter: Character = {
name: "Eliza",
Expand Down
82 changes: 64 additions & 18 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
AgentRuntime,
CacheManager,
CacheStore,
type Plugin,
type Character,
type ClientInstance,
DbCacheAdapter,
Expand All @@ -21,6 +22,7 @@ import {
import { defaultCharacter } from "./defaultCharacter.ts";

import { bootstrapPlugin } from "@elizaos/plugin-bootstrap";
import JSON5 from 'json5';

import fs from "fs";
import net from "net";
Expand Down Expand Up @@ -62,7 +64,7 @@ export function parseArguments(): {
})
.parseSync();
} catch (error) {
elizaLogger.error("Error parsing arguments:", error);
console.error("Error parsing arguments:", error);
return {};
}
}
Expand Down Expand Up @@ -116,7 +118,7 @@ export async function loadCharacterFromOnchain(): Promise<Character[]> {
if (!jsonText) return [];
const loadedCharacters = [];
try {
const character = JSON.parse(jsonText);
const character = JSON5.parse(jsonText);
validateCharacterConfig(character);
// .id isn't really valid
Expand Down Expand Up @@ -182,7 +184,7 @@ async function loadCharactersFromUrl(url: string): Promise<Character[]> {
}
return characters;
} catch (e) {
elizaLogger.error(`Error loading character(s) from ${url}: ${e}`);
console.error(`Error loading character(s) from ${url}: `, e);
process.exit(1);
}
}
Expand Down Expand Up @@ -213,6 +215,15 @@ async function jsonToCharacter(
}
// Handle plugins
character.plugins = await handlePluginImporting(character.plugins);
elizaLogger.info(character.name, 'loaded plugins:', "[\n " + character.plugins.map(p => `"${p.npmName}"`).join(", \n ") + "\n]");

// Handle Post Processors plugins
if (character.postProcessors?.length > 0) {
elizaLogger.info(character.name, 'loading postProcessors', character.postProcessors);
character.postProcessors = await handlePluginImporting(character.postProcessors);
}

// Handle extends
if (character.extends) {
elizaLogger.info(
`Merging ${character.name} character with parent characters`
Expand All @@ -235,7 +246,7 @@ async function loadCharacter(filePath: string): Promise<Character> {
if (!content) {
throw new Error(`Character file not found: ${filePath}`);
}
const character = JSON.parse(content);
const character = JSON5.parse(content);
return jsonToCharacter(filePath, character);
}

Expand All @@ -258,7 +269,7 @@ async function loadCharacterTryPath(characterPath: string): Promise<Character> {
), // relative to project root characters dir
];

elizaLogger.info(
elizaLogger.debug(
"Trying paths:",
pathsToTry.map((p) => ({
path: p,
Expand Down Expand Up @@ -286,10 +297,10 @@ async function loadCharacterTryPath(characterPath: string): Promise<Character> {
}
try {
const character: Character = await loadCharacter(resolvedPath);
elizaLogger.info(`Successfully loaded character from: ${resolvedPath}`);
elizaLogger.success(`Successfully loaded character from: ${resolvedPath}`);
return character;
} catch (e) {
elizaLogger.error(`Error parsing character from ${resolvedPath}: ${e}`);
console.error(`Error parsing character from ${resolvedPath}: `, e);
throw new Error(`Error parsing character from ${resolvedPath}: ${e}`);
}
}
Expand Down Expand Up @@ -360,30 +371,35 @@ export async function loadCharacters(

async function handlePluginImporting(plugins: string[]) {
if (plugins.length > 0) {
elizaLogger.info("Plugins are: ", plugins);
// this logging should happen before calling, so we can include important context
//elizaLogger.info("Plugins are: ", plugins);
const importedPlugins = await Promise.all(
plugins.map(async (plugin) => {
try {
const importedPlugin = await import(plugin);
const importedPlugin:Plugin = await import(plugin);
const functionName =
plugin
.replace("@elizaos/plugin-", "")
.replace("@elizaos-plugins/plugin-", "")
.replace(/-./g, (x) => x[1].toUpperCase()) +
"Plugin"; // Assumes plugin function is camelCased with Plugin suffix
return (
if (!importedPlugin[functionName] && !importedPlugin.default) {
elizaLogger.warn(plugin, 'does not have an default export or', functionName)
}
return {...(
importedPlugin.default || importedPlugin[functionName]
);
), npmName: plugin };
} catch (importError) {
elizaLogger.error(
console.error(
`Failed to import plugin: ${plugin}`,
importError
);
return []; // Return null for failed imports
return false; // Return null for failed imports
}
})
);
return importedPlugins;
)
// remove plugins that failed to load, so agent can try to start
return importedPlugins.filter(p => !!p);
} else {
return [];
}
Expand Down Expand Up @@ -792,6 +808,26 @@ const hasValidRemoteUrls = () =>
process.env.REMOTE_CHARACTER_URLS !== "" &&
process.env.REMOTE_CHARACTER_URLS.startsWith("http");

/**
* Post processing of character after loading
* @param character
*/
const handlePostCharacterLoaded = async (character: Character): Promise<Character> => {
let processedCharacter = character;
// Filtering the plugins with the method of handlePostCharacterLoaded
const processors = character?.postProcessors?.filter(p => typeof p.handlePostCharacterLoaded === 'function');
if (processors?.length > 0) {
processedCharacter = Object.assign({}, character, { postProcessors: undefined });
// process the character with each processor
// the order is important, so we loop through the processors
for (let i = 0; i < processors.length; i++) {
const processor = processors[i];
processedCharacter = await processor.handlePostCharacterLoaded(processedCharacter);
}
}
return processedCharacter;
}

const startAgents = async () => {
const directClient = new DirectClient();
let serverPort = Number.parseInt(settings.SERVER_PORT || "3000");
Expand All @@ -805,7 +841,8 @@ const startAgents = async () => {

try {
for (const character of characters) {
await startAgent(character, directClient);
const processedCharacter = await handlePostCharacterLoaded(character);
await startAgent(processedCharacter, directClient);
}
} catch (error) {
elizaLogger.error("Error starting agents:", error);
Expand All @@ -824,9 +861,18 @@ const startAgents = async () => {
directClient.startAgent = async (character) => {
// Handle plugins
character.plugins = await handlePluginImporting(character.plugins);
elizaLogger.info(character.name, 'loaded plugins:', '[' + character.plugins.map(p => `"${p.npmName}"`).join(', ') + ']');

// Handle Post Processors plugins
if (character.postProcessors?.length > 0) {
elizaLogger.info(character.name, 'loading postProcessors', character.postProcessors);
character.postProcessors = await handlePluginImporting(character.postProcessors);
}
// character's post processing
const processedCharacter = await handlePostCharacterLoaded(character);

// wrap it so we don't have to inject directClient later
return startAgent(character, directClient);
return startAgent(processedCharacter, directClient);
};

directClient.loadCharacterTryPath = loadCharacterTryPath;
Expand All @@ -835,7 +881,7 @@ const startAgents = async () => {
directClient.start(serverPort);

if (serverPort !== Number.parseInt(settings.SERVER_PORT || "3000")) {
elizaLogger.log(`Server started on alternate port ${serverPort}`);
elizaLogger.warn(`Server started on alternate port ${serverPort}`);
}

elizaLogger.info(
Expand Down
2 changes: 1 addition & 1 deletion docs/api/classes/AgentRuntime.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[@elizaos/core v0.25.7](../index.md) / AgentRuntime
[@elizaos/core v0.25.8](../index.md) / AgentRuntime

# Class: AgentRuntime

Expand Down
2 changes: 1 addition & 1 deletion docs/api/classes/CacheManager.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[@elizaos/core v0.25.7](../index.md) / CacheManager
[@elizaos/core v0.25.8](../index.md) / CacheManager

# Class: CacheManager\<CacheAdapter\>

Expand Down
2 changes: 1 addition & 1 deletion docs/api/classes/DatabaseAdapter.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[@elizaos/core v0.25.7](../index.md) / DatabaseAdapter
[@elizaos/core v0.25.8](../index.md) / DatabaseAdapter

# Class: `abstract` DatabaseAdapter\<DB\>

Expand Down
2 changes: 1 addition & 1 deletion docs/api/classes/DbCacheAdapter.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[@elizaos/core v0.25.7](../index.md) / DbCacheAdapter
[@elizaos/core v0.25.8](../index.md) / DbCacheAdapter

# Class: DbCacheAdapter

Expand Down
2 changes: 1 addition & 1 deletion docs/api/classes/FsCacheAdapter.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[@elizaos/core v0.25.7](../index.md) / FsCacheAdapter
[@elizaos/core v0.25.8](../index.md) / FsCacheAdapter

# Class: FsCacheAdapter

Expand Down
2 changes: 1 addition & 1 deletion docs/api/classes/MemoryCacheAdapter.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[@elizaos/core v0.25.7](../index.md) / MemoryCacheAdapter
[@elizaos/core v0.25.8](../index.md) / MemoryCacheAdapter

# Class: MemoryCacheAdapter

Expand Down
2 changes: 1 addition & 1 deletion docs/api/classes/MemoryManager.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[@elizaos/core v0.25.7](../index.md) / MemoryManager
[@elizaos/core v0.25.8](../index.md) / MemoryManager

# Class: MemoryManager

Expand Down
2 changes: 1 addition & 1 deletion docs/api/classes/RAGKnowledgeManager.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[@elizaos/core v0.25.7](../index.md) / RAGKnowledgeManager
[@elizaos/core v0.25.8](../index.md) / RAGKnowledgeManager

# Class: RAGKnowledgeManager

Expand Down
10 changes: 5 additions & 5 deletions docs/api/classes/Service.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[@elizaos/core v0.25.7](../index.md) / Service
[@elizaos/core v0.25.8](../index.md) / Service

# Class: `abstract` Service

Expand Down Expand Up @@ -40,7 +40,7 @@

#### Defined in

[packages/core/src/types.ts:1252](https://github.com/elizaOS/eliza/blob/main/packages/core/src/types.ts#L1252)
[packages/core/src/types.ts:1268](https://github.com/elizaOS/eliza/blob/main/packages/core/src/types.ts#L1268)

***

Expand All @@ -56,7 +56,7 @@

#### Defined in

[packages/core/src/types.ts:1263](https://github.com/elizaOS/eliza/blob/main/packages/core/src/types.ts#L1263)
[packages/core/src/types.ts:1279](https://github.com/elizaOS/eliza/blob/main/packages/core/src/types.ts#L1279)

## Methods

Expand All @@ -74,7 +74,7 @@

#### Defined in

[packages/core/src/types.ts:1256](https://github.com/elizaOS/eliza/blob/main/packages/core/src/types.ts#L1256)
[packages/core/src/types.ts:1272](https://github.com/elizaOS/eliza/blob/main/packages/core/src/types.ts#L1272)

***

Expand All @@ -94,4 +94,4 @@ Add abstract initialize method that must be implemented by derived classes

#### Defined in

[packages/core/src/types.ts:1268](https://github.com/elizaOS/eliza/blob/main/packages/core/src/types.ts#L1268)
[packages/core/src/types.ts:1284](https://github.com/elizaOS/eliza/blob/main/packages/core/src/types.ts#L1284)
Loading

0 comments on commit 2c06f56

Please sign in to comment.