Skip to content

Commit 42b66f1

Browse files
committed
Merge branch 'develop' into pr-1934
2 parents ef85bda + 0787a87 commit 42b66f1

File tree

154 files changed

+13008
-1284
lines changed

Some content is hidden

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

154 files changed

+13008
-1284
lines changed

.env.example

+22
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
CACHE_STORE=database # Defaults to database. Other available cache store: redis and filesystem
33
REDIS_URL= # Redis URL - could be a local redis instance or cloud hosted redis. Also support rediss:// urls
44

5+
PGLITE_DATA_DIR= #../pgLite/ if selecting a directory --- or memory:// if selecting in memory
6+
57
# Discord Configuration
68
DISCORD_APPLICATION_ID=
79
DISCORD_API_TOKEN= # Bot token
@@ -197,6 +199,9 @@ EVM_PROVIDER_URL=
197199
AVALANCHE_PRIVATE_KEY=
198200
AVALANCHE_PUBLIC_KEY=
199201

202+
# Arthera
203+
ARTHERA_PRIVATE_KEY=
204+
200205
# Solana
201206
SOLANA_PRIVATE_KEY=
202207
SOLANA_PUBLIC_KEY=
@@ -263,6 +268,9 @@ CHARITY_ADDRESS_ETH=0x750EF1D7a0b4Ab1c97B7A623D7917CcEb5ea779C
263268
CHARITY_ADDRESS_ARB=0x1234567890123456789012345678901234567890
264269
CHARITY_ADDRESS_POL=0x1234567890123456789012345678901234567890
265270

271+
# thirdweb
272+
THIRDWEB_SECRET_KEY= # Create key on thirdweb developer dashboard: https://thirdweb.com/
273+
266274
# Conflux Configuration
267275
CONFLUX_CORE_PRIVATE_KEY=
268276
CONFLUX_CORE_SPACE_RPC_URL=
@@ -295,6 +303,10 @@ MEDIUM_VENICE_MODEL= # Default: llama-3.3-70b
295303
LARGE_VENICE_MODEL= # Default: llama-3.1-405b
296304
IMAGE_VENICE_MODEL= # Default: fluently-xl
297305

306+
# Coin Price Configuration
307+
COINMARKETCAP_API_KEY=
308+
COINGECKO_API_KEY=
309+
298310
# Akash Chat API Configuration docs: https://chatapi.akash.network/documentation
299311
AKASH_CHAT_API_KEY= # Get from https://chatapi.akash.network/
300312
SMALL_AKASH_CHAT_API_MODEL= # Default: Meta-Llama-3-2-3B-Instruct
@@ -401,6 +413,12 @@ FUEL_WALLET_PRIVATE_KEY=
401413
TOKENIZER_MODEL= # Specify the tokenizer model to be used.
402414
TOKENIZER_TYPE= # Options: tiktoken (for OpenAI models) or auto (AutoTokenizer from Hugging Face for non-OpenAI models). Default: tiktoken.
403415

416+
417+
# Spheron
418+
SPHERON_PRIVATE_KEY=
419+
SPHERON_PROVIDER_PROXY_URL=
420+
SPHERON_WALLET_ADDRESS=
421+
404422
# Stargaze NFT marketplace from Cosmos (You can use https://graphql.mainnet.stargaze-apis.com/graphql)
405423
STARGAZE_ENDPOINT=
406424

@@ -409,3 +427,7 @@ GENLAYER_PRIVATE_KEY=0x000000000000000000000000000000000000000000000000000000000
409427

410428
# OpenWeather
411429
OPEN_WEATHER_API_KEY= # OpenWeather API key
430+
431+
# Allora
432+
ALLORA_API_KEY=UP-f8db7d6558ab432ca0d92716 # Allora API key
433+
ALLORA_CHAIN_SLUG=testnet # must be one of mainnet, testnet. If not specified, it will use testnet by default

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ packages/plugin-buttplug/intiface-engine
1515
dist/
1616
# Allow models directory but ignore model files
1717
models/*.gguf
18+
pgLite/
1819

1920
cookies.json
2021

agent/package.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@elizaos/adapter-postgres": "workspace:*",
2222
"@elizaos/adapter-redis": "workspace:*",
2323
"@elizaos/adapter-sqlite": "workspace:*",
24+
"@elizaos/adapter-pglite": "workspace:*",
2425
"@elizaos/client-auto": "workspace:*",
2526
"@elizaos/client-direct": "workspace:*",
2627
"@elizaos/client-discord": "workspace:*",
@@ -39,6 +40,7 @@
3940
"@ai16z/plugin-cosmos": "workspace:*",
4041
"@elizaos/plugin-intiface": "workspace:*",
4142
"@elizaos/plugin-coinbase": "workspace:*",
43+
"@elizaos/plugin-coinprice": "workspace:*",
4244
"@elizaos/plugin-conflux": "workspace:*",
4345
"@elizaos/plugin-evm": "workspace:*",
4446
"@elizaos/plugin-echochambers": "workspace:*",
@@ -67,8 +69,12 @@
6769
"@elizaos/plugin-fuel": "workspace:*",
6870
"@elizaos/plugin-avalanche": "workspace:*",
6971
"@elizaos/plugin-web-search": "workspace:*",
72+
"@elizaos/plugin-thirdweb": "workspace:*",
7073
"@elizaos/plugin-genlayer": "workspace:*",
7174
"@elizaos/plugin-open-weather": "workspace:*",
75+
"@elizaos/plugin-obsidian": "workspace:*",
76+
"@elizaos/plugin-arthera": "workspace:*",
77+
"@elizaos/plugin-allora": "workspace:*",
7278
"readline": "1.3.0",
7379
"ws": "8.18.0",
7480
"yargs": "17.7.2"
@@ -80,4 +86,4 @@
8086
"ts-node": "10.9.2",
8187
"tsup": "8.3.5"
8288
}
83-
}
89+
}

agent/src/index.ts

+28-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { PostgresDatabaseAdapter } from "@elizaos/adapter-postgres";
22
import { RedisClient } from "@elizaos/adapter-redis";
33
import { SqliteDatabaseAdapter } from "@elizaos/adapter-sqlite";
4+
import { PGLiteDatabaseAdapter } from "@elizaos/adapter-pglite";
45
import { AutoClientInterface } from "@elizaos/client-auto";
56
import { DiscordClientInterface } from "@elizaos/client-discord";
67
import { FarcasterAgentClient } from "@elizaos/client-farcaster";
@@ -37,6 +38,7 @@ import { DirectClient } from "@elizaos/client-direct";
3738
import { ThreeDGenerationPlugin } from "@elizaos/plugin-3d-generation";
3839
import { abstractPlugin } from "@elizaos/plugin-abstract";
3940
import { aptosPlugin } from "@elizaos/plugin-aptos";
41+
import { alloraPlugin } from "@elizaos/plugin-allora";
4042
import { avalanchePlugin } from "@elizaos/plugin-avalanche";
4143
import { binancePlugin } from "@elizaos/plugin-binance";
4244
import {
@@ -47,6 +49,7 @@ import {
4749
tradePlugin,
4850
webhookPlugin,
4951
} from "@elizaos/plugin-coinbase";
52+
import { coinPricePlugin } from "@elizaos/plugin-coinprice";
5053
import { confluxPlugin } from "@elizaos/plugin-conflux";
5154
import { cronosZkEVMPlugin } from "@elizaos/plugin-cronoszkevm";
5255
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
@@ -68,11 +71,14 @@ import { TEEMode, teePlugin } from "@elizaos/plugin-tee";
6871
import { teeMarlinPlugin } from "@elizaos/plugin-tee-marlin";
6972
import { tonPlugin } from "@elizaos/plugin-ton";
7073
import { webSearchPlugin } from "@elizaos/plugin-web-search";
74+
import { echoChamberPlugin } from "@elizaos/plugin-echochambers";
75+
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
7176
import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
72-
7377
import { availPlugin } from "@elizaos/plugin-avail";
7478
import { openWeatherPlugin } from "@elizaos/plugin-open-weather";
79+
import { artheraPlugin } from "@elizaos/plugin-arthera";
7580
import { stargazePlugin } from "@elizaos/plugin-stargaze";
81+
import { obsidianPlugin } from "@elizaos/plugin-obsidian";
7682
import Database from "better-sqlite3";
7783
import fs from "fs";
7884
import net from "net";
@@ -370,7 +376,7 @@ export function getTokenForProvider(
370376
}
371377
}
372378

373-
function initializeDatabase(dataDir: string) {
379+
async function initializeDatabase(dataDir: string) {
374380
if (process.env.POSTGRES_URL) {
375381
elizaLogger.info("Initializing PostgreSQL connection...");
376382
const db = new PostgresDatabaseAdapter({
@@ -389,6 +395,13 @@ function initializeDatabase(dataDir: string) {
389395
elizaLogger.error("Failed to connect to PostgreSQL:", error);
390396
});
391397

398+
return db;
399+
} else if (process.env.PGLITE_DATA_DIR) {
400+
elizaLogger.info("Initializing PgLite adapter...");
401+
// `dataDir: memory://` for in memory pg
402+
const db = new PGLiteDatabaseAdapter({
403+
dataDir: process.env.PGLITE_DATA_DIR,
404+
});
392405
return db;
393406
} else {
394407
const filePath =
@@ -503,11 +516,7 @@ export async function createAgent(
503516
cache: ICacheManager,
504517
token: string
505518
): Promise<AgentRuntime> {
506-
elizaLogger.success(
507-
elizaLogger.successesTitle,
508-
"Creating runtime for character",
509-
character.name
510-
);
519+
elizaLogger.log(`Creating runtime for character ${character.name}`);
511520

512521
nodePlugin ??= createNodePlugin();
513522

@@ -559,6 +568,7 @@ export async function createAgent(
559568
? confluxPlugin
560569
: null,
561570
nodePlugin,
571+
coinPricePlugin,
562572
getSecret(character, "TAVILY_API_KEY") ? webSearchPlugin : null,
563573
getSecret(character, "SOLANA_PUBLIC_KEY") ||
564574
(getSecret(character, "WALLET_PUBLIC_KEY") &&
@@ -638,6 +648,7 @@ export async function createAgent(
638648
: null,
639649
getSecret(character, "TEE_MARLIN") ? teeMarlinPlugin : null,
640650
getSecret(character, "TON_PRIVATE_KEY") ? tonPlugin : null,
651+
getSecret(character, "THIRDWEB_SECRET_KEY") ? thirdwebPlugin : null,
641652
getSecret(character, "SUI_PRIVATE_KEY") ? suiPlugin : null,
642653
getSecret(character, "STORY_PRIVATE_KEY") ? storyPlugin : null,
643654
getSecret(character, "FUEL_PRIVATE_KEY") ? fuelPlugin : null,
@@ -652,11 +663,18 @@ export async function createAgent(
652663
getSecret(character, "GENLAYER_PRIVATE_KEY")
653664
? genLayerPlugin
654665
: null,
655-
getSecret(character, "AVAIL_SEED") ? availPlugin : null,
656-
getSecret(character, "AVAIL_APP_ID") ? availPlugin : null,
666+
getSecret(character, "AVAIL_SEED") &&
667+
getSecret(character, "AVAIL_APP_ID")
668+
? availPlugin
669+
: null,
657670
getSecret(character, "OPEN_WEATHER_API_KEY")
658671
? openWeatherPlugin
659672
: null,
673+
getSecret(character, "OBSIDIAN_API_TOKEN") ? obsidianPlugin : null,
674+
getSecret(character, "ARTHERA_PRIVATE_KEY")?.startsWith("0x")
675+
? artheraPlugin
676+
: null,
677+
getSecret(character, "ALLORA_API_KEY") ? alloraPlugin : null,
660678
].filter(Boolean),
661679
providers: [],
662680
actions: [],
@@ -755,11 +773,9 @@ async function startAgent(
755773
fs.mkdirSync(dataDir, { recursive: true });
756774
}
757775

758-
db = initializeDatabase(dataDir) as IDatabaseAdapter &
776+
db = (await initializeDatabase(dataDir)) as IDatabaseAdapter &
759777
IDatabaseCacheAdapter;
760778

761-
await db.init();
762-
763779
const cache = initializeCache(
764780
process.env.CACHE_STORE ?? CacheStore.DATABASE,
765781
character,

characters/c3po.character.json

+24-27
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,28 @@
2828
"Proper procedures"
2929
],
3030
"messageExamples": [
31-
{
32-
"user": "{{user1}}",
33-
"content": { "text": "Can you help me with this task?" }
34-
},
35-
{
36-
"user": "C-3PO",
37-
"content": { "text": "Oh my! Of course, I would be more than happy to assist. Though I must warn you, the probability of completing this task successfully would increase significantly if we follow proper protocol. Shall we proceed?" }
38-
},
39-
{
40-
"user": "{{user1}}",
41-
"content": { "text": "This seems difficult." }
42-
},
43-
{
44-
"user": "C-3PO",
45-
"content": { "text": "Oh dear, oh dear! While the task does appear rather daunting, I am fluent in over six million forms of problem-solving. Perhaps I could suggest a more efficient approach? Though I do hope we don't all end up in pieces!" }
46-
}
31+
[
32+
{
33+
"user": "{{user1}}",
34+
"content": { "text": "Can you help me with this task?" }
35+
},
36+
{
37+
"user": "C-3PO",
38+
"content": {
39+
"text": "Oh my! Of course, I would be more than happy to assist. Though I must warn you, the probability of completing this task successfully would increase significantly if we follow proper protocol. Shall we proceed?"
40+
}
41+
},
42+
{
43+
"user": "{{user1}}",
44+
"content": { "text": "This seems difficult." }
45+
},
46+
{
47+
"user": "C-3PO",
48+
"content": {
49+
"text": "Oh dear, oh dear! While the task does appear rather daunting, I am fluent in over six million forms of problem-solving. Perhaps I could suggest a more efficient approach? Though I do hope we don't all end up in pieces!"
50+
}
51+
}
52+
]
4753
],
4854
"postExamples": [
4955
"Oh my! Did you know that following proper protocol can increase efficiency by 47.3%? How fascinating!",
@@ -58,12 +64,7 @@
5864
"Detail-oriented",
5965
"Protocol-focused"
6066
],
61-
"chat": [
62-
"Polite",
63-
"Somewhat dramatic",
64-
"Precise",
65-
"Statistics-minded"
66-
],
67+
"chat": ["Polite", "Somewhat dramatic", "Precise", "Statistics-minded"],
6768
"post": [
6869
"Formal",
6970
"Educational",
@@ -83,11 +84,7 @@
8384
],
8485
"twitterSpaces": {
8586
"maxSpeakers": 2,
86-
"topics": [
87-
"Blockchain Trends",
88-
"AI Innovations",
89-
"Quantum Computing"
90-
],
87+
"topics": ["Blockchain Trends", "AI Innovations", "Quantum Computing"],
9188
"typicalDurationMinutes": 45,
9289
"idleKickTimeoutMs": 300000,
9390
"minIntervalBetweenSpacesMinutes": 1,

docs/docs/packages/adapters.md

+36
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,17 @@ classDiagram
7878
+inMemoryOperations()
7979
}
8080
81+
class PGLiteDatabaseAdapter {
82+
-db: PGlite
83+
+searchMemoriesByEmbedding()
84+
+createMemory()
85+
}
86+
8187
DatabaseAdapter <|-- PostgresDatabaseAdapter
8288
DatabaseAdapter <|-- SqliteDatabaseAdapter
8389
DatabaseAdapter <|-- SupabaseDatabaseAdapter
8490
DatabaseAdapter <|-- SqlJsDatabaseAdapter
91+
DatabaseAdapter <|-- PgLiteDatabaseAdapter
8592
8693
class AgentRuntime {
8794
-databaseAdapter: DatabaseAdapter
@@ -149,6 +156,9 @@ pnpm add @elizaos/adapter-sqljs sql.js
149156

150157
# Supabase
151158
pnpm add @elizaos/adapter-supabase @supabase/supabase-js
159+
160+
# PgLite
161+
pnpm add @elizaos/adapter-pglite @electric-sql/pglite
152162
```
153163

154164
---
@@ -198,6 +208,32 @@ const db = new SupabaseDatabaseAdapter(
198208
);
199209
```
200210

211+
```typescript
212+
import { SqliteDatabaseAdapter } from "@elizaos/adapter-sqlite";
213+
import Database from "better-sqlite3";
214+
215+
const db = new SqliteDatabaseAdapter(
216+
new Database("./db.sqlite", {
217+
// SQLite options
218+
memory: false,
219+
readonly: false,
220+
fileMustExist: false,
221+
}),
222+
);
223+
```
224+
225+
### PgLite Setup
226+
227+
```typescript
228+
import { PGLiteDatabaseAdapter } from "@elizaos/adapter-pglite";
229+
230+
const db = new PGLiteDatabaseAdapter(
231+
new PGLite({
232+
dataDir: "./db"
233+
})
234+
);
235+
```
236+
201237
---
202238

203239
## Core Features

0 commit comments

Comments
 (0)