Skip to content

Commit 2c06f56

Browse files
authored
Merge pull request elizaOS#3739 from elizaOS/develop
chore: dev => main (rel 0.25.9 prep)
2 parents c04f89a + ae9ca51 commit 2c06f56

File tree

370 files changed

+11020
-5949
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

370 files changed

+11020
-5949
lines changed

.env.example

+6
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ LARGE_NANOGPT_MODEL= # Default: gpt-4o
290290

291291
# Anthropic Configuration
292292
ANTHROPIC_API_KEY= # For Claude
293+
ANTHROPIC_API_URL=
293294
SMALL_ANTHROPIC_MODEL= # Default: claude-3-haiku-20240307
294295
MEDIUM_ANTHROPIC_MODEL= # Default: claude-3-5-sonnet-20241022
295296
LARGE_ANTHROPIC_MODEL= # Default: claude-3-5-sonnet-20241022
@@ -445,6 +446,11 @@ STARKNET_RPC_URL=https://rpc.starknet-testnet.lava.build
445446
LENS_ADDRESS=
446447
LENS_PRIVATE_KEY=
447448

449+
# Viction Configuration
450+
VICTION_ADDRESS=
451+
VICTION_PRIVATE_KEY=
452+
VICTION_RPC_URL=
453+
448454
# Form Chain
449455
FORM_PRIVATE_KEY= # Form character account private key
450456
FORM_TESTNET=true # A flag indicating if connection is made to Form Testnet. Set to false for Mainnet connection.

README.md

+42
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,48 @@ pnpm install --include=optional sharp
159159

160160
---
161161

162+
## Using Your Custom Plugins
163+
Plugins that are not in the official registry for ElizaOS can be used as well. Here's how:
164+
165+
### Installation
166+
167+
1. Upload the custom plugin to the packages folder:
168+
169+
```
170+
packages/
171+
├─plugin-example/
172+
├── package.json
173+
├── tsconfig.json
174+
├── src/
175+
│ ├── index.ts # Main plugin entry
176+
│ ├── actions/ # Custom actions
177+
│ ├── providers/ # Data providers
178+
│ ├── types.ts # Type definitions
179+
│ └── environment.ts # Configuration
180+
├── README.md
181+
└── LICENSE
182+
```
183+
184+
2. Add the custom plugin to your project's dependencies in the agent's package.json:
185+
186+
```json
187+
{
188+
"dependencies": {
189+
"@elizaos/plugin-example": "workspace:*"
190+
}
191+
}
192+
```
193+
194+
3. Import the custom plugin to your agent's character.json
195+
196+
```json
197+
"plugins": [
198+
"@elizaos/plugin-example",
199+
],
200+
```
201+
202+
---
203+
162204
### Start Eliza with Gitpod
163205

164206
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/elizaos/eliza/tree/main)

agent/package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@elizaos/agent",
3-
"version": "0.25.8",
3+
"version": "0.25.9",
44
"main": "src/index.ts",
55
"type": "module",
66
"scripts": {
@@ -19,17 +19,17 @@
1919
},
2020
"dependencies": {
2121
"@elizaos/client-direct": "workspace:*",
22-
"@elizaos/plugin-bootstrap": "workspace:*",
2322
"@elizaos/core": "workspace:*",
24-
"readline": "1.3.0",
25-
"ws": "8.18.0",
23+
"@elizaos/plugin-bootstrap": "workspace:*",
24+
"@types/node": "^22.13.5",
25+
"json5": "2.2.3",
26+
"ts-node": "^10.9.2",
2627
"yargs": "17.7.2"
2728
},
2829
"devDependencies": {
30+
"@jest/globals": "^29.7.0",
2931
"@types/jest": "^29.5.14",
3032
"jest": "^29.7.0",
31-
"ts-jest": "^29.2.5",
32-
"ts-node": "10.9.2",
33-
"tsup": "8.3.5"
33+
"ts-jest": "^29.2.6"
3434
}
3535
}

agent/src/defaultCharacter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Character, ModelProviderName } from "@elizaos/core";
1+
import { type Character, ModelProviderName } from "@elizaos/core";
22

33
export const defaultCharacter: Character = {
44
name: "Eliza",

agent/src/index.ts

+64-18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
AgentRuntime,
55
CacheManager,
66
CacheStore,
7+
type Plugin,
78
type Character,
89
type ClientInstance,
910
DbCacheAdapter,
@@ -21,6 +22,7 @@ import {
2122
import { defaultCharacter } from "./defaultCharacter.ts";
2223

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

2527
import fs from "fs";
2628
import net from "net";
@@ -62,7 +64,7 @@ export function parseArguments(): {
6264
})
6365
.parseSync();
6466
} catch (error) {
65-
elizaLogger.error("Error parsing arguments:", error);
67+
console.error("Error parsing arguments:", error);
6668
return {};
6769
}
6870
}
@@ -116,7 +118,7 @@ export async function loadCharacterFromOnchain(): Promise<Character[]> {
116118
if (!jsonText) return [];
117119
const loadedCharacters = [];
118120
try {
119-
const character = JSON.parse(jsonText);
121+
const character = JSON5.parse(jsonText);
120122
validateCharacterConfig(character);
121123
122124
// .id isn't really valid
@@ -182,7 +184,7 @@ async function loadCharactersFromUrl(url: string): Promise<Character[]> {
182184
}
183185
return characters;
184186
} catch (e) {
185-
elizaLogger.error(`Error loading character(s) from ${url}: ${e}`);
187+
console.error(`Error loading character(s) from ${url}: `, e);
186188
process.exit(1);
187189
}
188190
}
@@ -213,6 +215,15 @@ async function jsonToCharacter(
213215
}
214216
// Handle plugins
215217
character.plugins = await handlePluginImporting(character.plugins);
218+
elizaLogger.info(character.name, 'loaded plugins:', "[\n " + character.plugins.map(p => `"${p.npmName}"`).join(", \n ") + "\n]");
219+
220+
// Handle Post Processors plugins
221+
if (character.postProcessors?.length > 0) {
222+
elizaLogger.info(character.name, 'loading postProcessors', character.postProcessors);
223+
character.postProcessors = await handlePluginImporting(character.postProcessors);
224+
}
225+
226+
// Handle extends
216227
if (character.extends) {
217228
elizaLogger.info(
218229
`Merging ${character.name} character with parent characters`
@@ -235,7 +246,7 @@ async function loadCharacter(filePath: string): Promise<Character> {
235246
if (!content) {
236247
throw new Error(`Character file not found: ${filePath}`);
237248
}
238-
const character = JSON.parse(content);
249+
const character = JSON5.parse(content);
239250
return jsonToCharacter(filePath, character);
240251
}
241252

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

261-
elizaLogger.info(
272+
elizaLogger.debug(
262273
"Trying paths:",
263274
pathsToTry.map((p) => ({
264275
path: p,
@@ -286,10 +297,10 @@ async function loadCharacterTryPath(characterPath: string): Promise<Character> {
286297
}
287298
try {
288299
const character: Character = await loadCharacter(resolvedPath);
289-
elizaLogger.info(`Successfully loaded character from: ${resolvedPath}`);
300+
elizaLogger.success(`Successfully loaded character from: ${resolvedPath}`);
290301
return character;
291302
} catch (e) {
292-
elizaLogger.error(`Error parsing character from ${resolvedPath}: ${e}`);
303+
console.error(`Error parsing character from ${resolvedPath}: `, e);
293304
throw new Error(`Error parsing character from ${resolvedPath}: ${e}`);
294305
}
295306
}
@@ -360,30 +371,35 @@ export async function loadCharacters(
360371

361372
async function handlePluginImporting(plugins: string[]) {
362373
if (plugins.length > 0) {
363-
elizaLogger.info("Plugins are: ", plugins);
374+
// this logging should happen before calling, so we can include important context
375+
//elizaLogger.info("Plugins are: ", plugins);
364376
const importedPlugins = await Promise.all(
365377
plugins.map(async (plugin) => {
366378
try {
367-
const importedPlugin = await import(plugin);
379+
const importedPlugin:Plugin = await import(plugin);
368380
const functionName =
369381
plugin
370382
.replace("@elizaos/plugin-", "")
371383
.replace("@elizaos-plugins/plugin-", "")
372384
.replace(/-./g, (x) => x[1].toUpperCase()) +
373385
"Plugin"; // Assumes plugin function is camelCased with Plugin suffix
374-
return (
386+
if (!importedPlugin[functionName] && !importedPlugin.default) {
387+
elizaLogger.warn(plugin, 'does not have an default export or', functionName)
388+
}
389+
return {...(
375390
importedPlugin.default || importedPlugin[functionName]
376-
);
391+
), npmName: plugin };
377392
} catch (importError) {
378-
elizaLogger.error(
393+
console.error(
379394
`Failed to import plugin: ${plugin}`,
380395
importError
381396
);
382-
return []; // Return null for failed imports
397+
return false; // Return null for failed imports
383398
}
384399
})
385-
);
386-
return importedPlugins;
400+
)
401+
// remove plugins that failed to load, so agent can try to start
402+
return importedPlugins.filter(p => !!p);
387403
} else {
388404
return [];
389405
}
@@ -792,6 +808,26 @@ const hasValidRemoteUrls = () =>
792808
process.env.REMOTE_CHARACTER_URLS !== "" &&
793809
process.env.REMOTE_CHARACTER_URLS.startsWith("http");
794810

811+
/**
812+
* Post processing of character after loading
813+
* @param character
814+
*/
815+
const handlePostCharacterLoaded = async (character: Character): Promise<Character> => {
816+
let processedCharacter = character;
817+
// Filtering the plugins with the method of handlePostCharacterLoaded
818+
const processors = character?.postProcessors?.filter(p => typeof p.handlePostCharacterLoaded === 'function');
819+
if (processors?.length > 0) {
820+
processedCharacter = Object.assign({}, character, { postProcessors: undefined });
821+
// process the character with each processor
822+
// the order is important, so we loop through the processors
823+
for (let i = 0; i < processors.length; i++) {
824+
const processor = processors[i];
825+
processedCharacter = await processor.handlePostCharacterLoaded(processedCharacter);
826+
}
827+
}
828+
return processedCharacter;
829+
}
830+
795831
const startAgents = async () => {
796832
const directClient = new DirectClient();
797833
let serverPort = Number.parseInt(settings.SERVER_PORT || "3000");
@@ -805,7 +841,8 @@ const startAgents = async () => {
805841

806842
try {
807843
for (const character of characters) {
808-
await startAgent(character, directClient);
844+
const processedCharacter = await handlePostCharacterLoaded(character);
845+
await startAgent(processedCharacter, directClient);
809846
}
810847
} catch (error) {
811848
elizaLogger.error("Error starting agents:", error);
@@ -824,9 +861,18 @@ const startAgents = async () => {
824861
directClient.startAgent = async (character) => {
825862
// Handle plugins
826863
character.plugins = await handlePluginImporting(character.plugins);
864+
elizaLogger.info(character.name, 'loaded plugins:', '[' + character.plugins.map(p => `"${p.npmName}"`).join(', ') + ']');
865+
866+
// Handle Post Processors plugins
867+
if (character.postProcessors?.length > 0) {
868+
elizaLogger.info(character.name, 'loading postProcessors', character.postProcessors);
869+
character.postProcessors = await handlePluginImporting(character.postProcessors);
870+
}
871+
// character's post processing
872+
const processedCharacter = await handlePostCharacterLoaded(character);
827873

828874
// wrap it so we don't have to inject directClient later
829-
return startAgent(character, directClient);
875+
return startAgent(processedCharacter, directClient);
830876
};
831877

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

837883
if (serverPort !== Number.parseInt(settings.SERVER_PORT || "3000")) {
838-
elizaLogger.log(`Server started on alternate port ${serverPort}`);
884+
elizaLogger.warn(`Server started on alternate port ${serverPort}`);
839885
}
840886

841887
elizaLogger.info(

docs/api/classes/AgentRuntime.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[@elizaos/core v0.25.7](../index.md) / AgentRuntime
1+
[@elizaos/core v0.25.8](../index.md) / AgentRuntime
22

33
# Class: AgentRuntime
44

docs/api/classes/CacheManager.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[@elizaos/core v0.25.7](../index.md) / CacheManager
1+
[@elizaos/core v0.25.8](../index.md) / CacheManager
22

33
# Class: CacheManager\<CacheAdapter\>
44

docs/api/classes/DatabaseAdapter.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[@elizaos/core v0.25.7](../index.md) / DatabaseAdapter
1+
[@elizaos/core v0.25.8](../index.md) / DatabaseAdapter
22

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

docs/api/classes/DbCacheAdapter.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[@elizaos/core v0.25.7](../index.md) / DbCacheAdapter
1+
[@elizaos/core v0.25.8](../index.md) / DbCacheAdapter
22

33
# Class: DbCacheAdapter
44

docs/api/classes/FsCacheAdapter.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[@elizaos/core v0.25.7](../index.md) / FsCacheAdapter
1+
[@elizaos/core v0.25.8](../index.md) / FsCacheAdapter
22

33
# Class: FsCacheAdapter
44

docs/api/classes/MemoryCacheAdapter.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[@elizaos/core v0.25.7](../index.md) / MemoryCacheAdapter
1+
[@elizaos/core v0.25.8](../index.md) / MemoryCacheAdapter
22

33
# Class: MemoryCacheAdapter
44

docs/api/classes/MemoryManager.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[@elizaos/core v0.25.7](../index.md) / MemoryManager
1+
[@elizaos/core v0.25.8](../index.md) / MemoryManager
22

33
# Class: MemoryManager
44

docs/api/classes/RAGKnowledgeManager.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[@elizaos/core v0.25.7](../index.md) / RAGKnowledgeManager
1+
[@elizaos/core v0.25.8](../index.md) / RAGKnowledgeManager
22

33
# Class: RAGKnowledgeManager
44

docs/api/classes/Service.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[@elizaos/core v0.25.7](../index.md) / Service
1+
[@elizaos/core v0.25.8](../index.md) / Service
22

33
# Class: `abstract` Service
44

@@ -40,7 +40,7 @@
4040

4141
#### Defined in
4242

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

4545
***
4646

@@ -56,7 +56,7 @@
5656

5757
#### Defined in
5858

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

6161
## Methods
6262

@@ -74,7 +74,7 @@
7474

7575
#### Defined in
7676

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

7979
***
8080

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

9595
#### Defined in
9696

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

0 commit comments

Comments
 (0)