Skip to content

Commit 16cdf9c

Browse files
authored
Merge branch 'develop' into develop
2 parents f97f2d8 + e9e5608 commit 16cdf9c

File tree

78 files changed

+13747
-511
lines changed

Some content is hidden

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

78 files changed

+13747
-511
lines changed

.env.example

+47
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ SUPABASE_ANON_KEY=
1818
# Comma separated list of remote character urls (optional)
1919
REMOTE_CHARACTER_URLS=
2020

21+
# Logging
22+
LOG_JSON_FORMAT= # Print everything in logger as json; false by default
23+
2124
###############################
2225
#### Client Configurations ####
2326
###############################
@@ -383,6 +386,13 @@ ZEROG_EVM_RPC=
383386
ZEROG_PRIVATE_KEY=
384387
ZEROG_FLOW_ADDRESS=
385388

389+
# IQ6900
390+
# Load json recorded on-chain through IQ
391+
# Inscribe your json character file here: https://elizacodein.com/
392+
393+
IQ_WALLET_ADDRESS= # If you enter the wallet address used on the site, the most recently inscribed json will be loaded.
394+
IQSOlRPC=
395+
386396
# Squid Router
387397
SQUID_SDK_URL=https://apiplus.squidrouter.com # Default: https://apiplus.squidrouter.com
388398
SQUID_INTEGRATOR_ID= # get integrator id through https://docs.squidrouter.com/
@@ -642,3 +652,40 @@ INSTAGRAM_POST_INTERVAL_MAX=120 # Default: 120 minutes
642652
INSTAGRAM_ENABLE_ACTION_PROCESSING=false # Enable/disable action processing
643653
INSTAGRAM_ACTION_INTERVAL=5 # Interval between actions in minutes
644654
INSTAGRAM_MAX_ACTIONS=1 # Maximum number of actions to process at once
655+
656+
####################################
657+
#### Pyth Plugin Configuration ####
658+
####################################
659+
# Network Environment (mainnet or testnet)git
660+
PYTH_NETWORK_ENV=mainnet
661+
662+
# Mainnet Network Configuration
663+
PYTH_MAINNET_HERMES_URL=https://hermes.pyth.network
664+
PYTH_MAINNET_WSS_URL=wss://hermes.pyth.network/ws
665+
PYTH_MAINNET_PYTHNET_URL=https://pythnet.rpcpool.com
666+
PYTH_MAINNET_CONTRACT_REGISTRY=https://pyth.network/developers/price-feed-ids
667+
PYTH_MAINNET_PROGRAM_KEY=
668+
669+
# Testnet Network Configuration
670+
PYTH_TESTNET_HERMES_URL=https://hermes.pyth.network
671+
PYTH_TESTNET_WSS_URL=wss://hermes.pyth.network/ws
672+
PYTH_TESTNET_PYTHNET_URL=https://pythnet.rpcpool.com
673+
PYTH_TESTNET_CONTRACT_REGISTRY=https://pyth.network/developers/price-feed-ids#testnet
674+
PYTH_TESTNET_PROGRAM_KEY=
675+
676+
# Connection Settings
677+
PYTH_MAX_RETRIES=3
678+
PYTH_RETRY_DELAY=1000
679+
PYTH_TIMEOUT=5000
680+
PYTH_GRANULAR_LOG=true
681+
PYTH_LOG_LEVEL=debug
682+
PYTH_LOG_LEVEL=info
683+
684+
# Runtime Settings
685+
RUNTIME_CHECK_MODE=false
686+
687+
# Pyth Price Streaming and test ID
688+
PYTH_ENABLE_PRICE_STREAMING=true
689+
PYTH_MAX_PRICE_STREAMS=2
690+
PYTH_TEST_ID01=0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43
691+
PYTH_TEST_ID02=0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace

.github/workflows/block-mini.yml

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Block Minified JavaScript/TypeScript
2+
3+
on:
4+
pull_request:
5+
branches: ["main", "develop", "*"]
6+
push:
7+
branches: ["main", "develop", "*"]
8+
9+
jobs:
10+
block-minified-code:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out code
14+
uses: actions/checkout@v4
15+
16+
- name: Detect potential minified code
17+
shell: bash
18+
run: |
19+
echo "Scanning for potential minified JS/TS code..."
20+
21+
# We'll look in .ts, .tsx, .js, .jsx files, skipping common build dirs.
22+
FILES=$(find . \
23+
\( -name 'node_modules' -prune \) -o \
24+
\( -name 'dist' -prune \) -o \
25+
\( -name 'build' -prune \) -o \
26+
-type f \( -name '*.ts' -o -name '*.tsx' -o -name '*.js' -o -name '*.jsx' \) \
27+
-print)
28+
29+
if [ -z "$FILES" ]; then
30+
echo "No relevant JS/TS files found."
31+
exit 0
32+
fi
33+
34+
THRESHOLD=1000
35+
VIOLATIONS=0
36+
37+
for file in $FILES; do
38+
# Use grep -En to capture line number and text
39+
# If any line is ≥ THRESHOLD chars, we store those lines in RESULTS
40+
RESULTS=$(grep -En ".{${THRESHOLD},}" "$file" || true)
41+
if [ -n "$RESULTS" ]; then
42+
# We have potential minified lines
43+
while IFS= read -r match; do
44+
# 'match' will be something like "1234:the entire matched line"
45+
LINENUM=$(echo "$match" | cut -d: -f1)
46+
# If you want the text, you can do:
47+
# MATCHED_LINE=$(echo "$match" | cut -d: -f2-)
48+
49+
echo "::error file=$file,line=$LINENUM::Detected potential minified code (≥ $THRESHOLD chars)."
50+
done <<< "$RESULTS"
51+
VIOLATIONS=1
52+
fi
53+
done
54+
55+
if [ "$VIOLATIONS" -eq 1 ]; then
56+
echo "ERROR: Minified code detected. Please remove or exclude it."
57+
exit 1
58+
else
59+
echo "No minified code detected."
60+
fi

agent/package.json

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@elizaos/agent",
33
"version": "0.1.9-alpha.1",
4+
"version": "0.1.9-alpha.1",
45
"main": "src/index.ts",
56
"type": "module",
67
"scripts": {
@@ -31,14 +32,18 @@
3132
"@elizaos/client-telegram": "workspace:*",
3233
"@elizaos/client-twitter": "workspace:*",
3334
"@elizaos/client-instagram": "workspace:*",
35+
"@elizaos/client-instagram": "workspace:*",
3436
"@elizaos/client-slack": "workspace:*",
3537
"@elizaos/core": "workspace:*",
3638
"@elizaos/plugin-0g": "workspace:*",
3739
"@elizaos/plugin-abstract": "workspace:*",
3840
"@elizaos/plugin-agentkit": "workspace:*",
41+
"@elizaos/plugin-agentkit": "workspace:*",
3942
"@elizaos/plugin-aptos": "workspace:*",
4043
"@elizaos/plugin-birdeye": "workspace:*",
4144
"@elizaos/plugin-coingecko": "workspace:*",
45+
"@elizaos/plugin-birdeye": "workspace:*",
46+
"@elizaos/plugin-coingecko": "workspace:*",
4247
"@elizaos/plugin-coinmarketcap": "workspace:*",
4348
"@elizaos/plugin-binance": "workspace:*",
4449
"@elizaos/plugin-avail": "workspace:*",
@@ -53,6 +58,7 @@
5358
"@elizaos/plugin-gitbook": "workspace:*",
5459
"@elizaos/plugin-story": "workspace:*",
5560
"@elizaos/plugin-gitcoin-passport": "workspace:*",
61+
"@elizaos/plugin-gitcoin-passport": "workspace:*",
5662
"@elizaos/plugin-goat": "workspace:*",
5763
"@elizaos/plugin-lensNetwork": "workspace:*",
5864
"@elizaos/plugin-icp": "workspace:*",
@@ -63,15 +69,18 @@
6369
"@elizaos/plugin-node": "workspace:*",
6470
"@elizaos/plugin-solana": "workspace:*",
6571
"@elizaos/plugin-injective": "workspace:*",
72+
"@elizaos/plugin-injective": "workspace:*",
6673
"@elizaos/plugin-solana-agentkit": "workspace:*",
6774
"@elizaos/plugin-squid-router": "workspace:*",
75+
"@elizaos/plugin-squid-router": "workspace:*",
6876
"@elizaos/plugin-autonome": "workspace:*",
6977
"@elizaos/plugin-starknet": "workspace:*",
7078
"@elizaos/plugin-stargaze": "workspace:*",
7179
"@elizaos/plugin-giphy": "workspace:*",
7280
"@elizaos/plugin-ton": "workspace:*",
7381
"@elizaos/plugin-sui": "workspace:*",
7482
"@elizaos/plugin-sgx": "workspace:*",
83+
"@elizaos/plugin-iq6900": "workspace:*",
7584
"@elizaos/plugin-tee": "workspace:*",
7685
"@elizaos/plugin-tee-log": "workspace:*",
7786
"@elizaos/plugin-tee-marlin": "workspace:*",
@@ -87,10 +96,12 @@
8796
"@elizaos/plugin-video-generation": "workspace:*",
8897
"@elizaos/plugin-web-search": "workspace:*",
8998
"@elizaos/plugin-dexscreener": "workspace:*",
99+
"@elizaos/plugin-dexscreener": "workspace:*",
90100
"@elizaos/plugin-letzai": "workspace:*",
91101
"@elizaos/plugin-thirdweb": "workspace:*",
92102
"@elizaos/plugin-genlayer": "workspace:*",
93103
"@elizaos/plugin-tee-verifiable-log": "workspace:*",
104+
"@elizaos/plugin-tee-verifiable-log": "workspace:*",
94105
"@elizaos/plugin-depin": "workspace:*",
95106
"@elizaos/plugin-open-weather": "workspace:*",
96107
"@elizaos/plugin-obsidian": "workspace:*",
@@ -102,6 +113,7 @@
102113
"@elizaos/plugin-quai": "workspace:*",
103114
"@elizaos/plugin-b2": "workspace:*",
104115
"@elizaos/plugin-nft-collections": "workspace:*",
116+
"@elizaos/plugin-pyth-data": "workspace:*",
105117
"readline": "1.3.0",
106118
"ws": "8.18.0",
107119
"yargs": "17.7.2"
@@ -113,4 +125,4 @@
113125
"ts-node": "10.9.2",
114126
"tsup": "8.3.5"
115127
}
116-
}
128+
}

agent/src/index.ts

+81-11
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import { SlackClientInterface } from "@elizaos/client-slack";
1111
import { TelegramClientInterface } from "@elizaos/client-telegram";
1212
import { TwitterClientInterface } from "@elizaos/client-twitter";
1313
import { FarcasterClientInterface } from "@elizaos/client-farcaster";
14+
import { DirectClient } from "@elizaos/client-direct";
1415
// import { ReclaimAdapter } from "@elizaos/plugin-reclaim";
1516
import { PrimusAdapter } from "@elizaos/plugin-primus";
17+
import { elizaCodeinPlugin, onchainJson } from "@elizaos/plugin-iq6900";
1618

1719
import {
1820
AgentRuntime,
@@ -40,7 +42,6 @@ import { zgPlugin } from "@elizaos/plugin-0g";
4042
import { bootstrapPlugin } from "@elizaos/plugin-bootstrap";
4143
import createGoatPlugin from "@elizaos/plugin-goat";
4244
// import { intifacePlugin } from "@elizaos/plugin-intiface";
43-
import { DirectClient } from "@elizaos/client-direct";
4445
import { ThreeDGenerationPlugin } from "@elizaos/plugin-3d-generation";
4546
import { abstractPlugin } from "@elizaos/plugin-abstract";
4647
import { akashPlugin } from "@elizaos/plugin-akash";
@@ -102,6 +103,7 @@ import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
102103
import { hyperliquidPlugin } from "@elizaos/plugin-hyperliquid";
103104
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
104105
import { dexScreenerPlugin } from "@elizaos/plugin-dexscreener";
106+
import { pythDataPlugin } from "@elizaos/plugin-pyth-data";
105107

106108
import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
107109
import Database from "better-sqlite3";
@@ -111,7 +113,6 @@ import path from "path";
111113
import { fileURLToPath } from "url";
112114
import yargs from "yargs";
113115

114-
115116
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
116117
const __dirname = path.dirname(__filename); // get the name of the directory
117118

@@ -189,6 +190,63 @@ function mergeCharacters(base: Character, child: Character): Character {
189190
};
190191
return mergeObjects(base, child);
191192
}
193+
function isAllStrings(arr: unknown[]): boolean {
194+
return Array.isArray(arr) && arr.every((item) => typeof item === "string");
195+
}
196+
export async function loadCharacterFromOnchain(): Promise<Character[]> {
197+
const jsonText = onchainJson;
198+
199+
console.log("JSON:", jsonText);
200+
if (jsonText == "null") return [];
201+
const loadedCharacters = [];
202+
try {
203+
const character = JSON.parse(jsonText);
204+
validateCharacterConfig(character);
205+
206+
// .id isn't really valid
207+
const characterId = character.id || character.name;
208+
const characterPrefix = `CHARACTER.${characterId.toUpperCase().replace(/ /g, "_")}.`;
209+
210+
const characterSettings = Object.entries(process.env)
211+
.filter(([key]) => key.startsWith(characterPrefix))
212+
.reduce((settings, [key, value]) => {
213+
const settingKey = key.slice(characterPrefix.length);
214+
settings[settingKey] = value;
215+
return settings;
216+
}, {});
217+
218+
if (Object.keys(characterSettings).length > 0) {
219+
character.settings = character.settings || {};
220+
character.settings.secrets = {
221+
...characterSettings,
222+
...character.settings.secrets,
223+
};
224+
}
225+
226+
// Handle plugins
227+
if (isAllStrings(character.plugins)) {
228+
elizaLogger.info("Plugins are: ", character.plugins);
229+
const importedPlugins = await Promise.all(
230+
character.plugins.map(async (plugin) => {
231+
const importedPlugin = await import(plugin);
232+
return importedPlugin.default;
233+
})
234+
);
235+
character.plugins = importedPlugins;
236+
}
237+
238+
loadedCharacters.push(character);
239+
elizaLogger.info(
240+
`Successfully loaded character from: ${process.env.IQ_WALLET_ADDRESS}`
241+
);
242+
return loadedCharacters;
243+
} catch (e) {
244+
elizaLogger.error(
245+
`Error parsing character from ${process.env.IQ_WALLET_ADDRESS}: ${e}`
246+
);
247+
process.exit(1);
248+
}
249+
}
192250

193251
async function loadCharacterFromUrl(url: string): Promise<Character> {
194252
const response = await fetch(url);
@@ -247,14 +305,13 @@ async function loadCharacter(filePath: string): Promise<Character> {
247305
}
248306

249307
function commaSeparatedStringToArray(commaSeparated: string): string[] {
250-
return commaSeparated?.split(",").map(value => value.trim())
308+
return commaSeparated?.split(",").map((value) => value.trim());
251309
}
252310

253-
254311
export async function loadCharacters(
255312
charactersArg: string
256313
): Promise<Character[]> {
257-
let characterPaths = commaSeparatedStringToArray(charactersArg)
314+
let characterPaths = commaSeparatedStringToArray(charactersArg);
258315
const loadedCharacters: Character[] = [];
259316

260317
if (characterPaths?.length > 0) {
@@ -328,7 +385,9 @@ export async function loadCharacters(
328385

329386
if (hasValidRemoteUrls()) {
330387
elizaLogger.info("Loading characters from remote URLs");
331-
let characterUrls = commaSeparatedStringToArray(process.env.REMOTE_CHARACTER_URLS)
388+
let characterUrls = commaSeparatedStringToArray(
389+
process.env.REMOTE_CHARACTER_URLS
390+
);
332391
for (const characterUrl of characterUrls) {
333392
const character = await loadCharacterFromUrl(characterUrl);
334393
loadedCharacters.push(character);
@@ -784,6 +843,10 @@ export async function createAgent(
784843
character,
785844
// character.plugins are handled when clients are added
786845
plugins: [
846+
getSecret(character, "IQ_WALLET_ADDRESS") &&
847+
getSecret(character, "IQSOlRPC")
848+
? elizaCodeinPlugin
849+
: null,
787850
bootstrapPlugin,
788851
getSecret(character, "DEXSCREENER_API_KEY")
789852
? dexScreenerPlugin
@@ -812,8 +875,9 @@ export async function createAgent(
812875
getSecret(character, "WALLET_PUBLIC_KEY")?.startsWith("0x"))
813876
? evmPlugin
814877
: null,
815-
((getSecret(character, "EVM_PUBLIC_KEY") || getSecret(character, "INJECTIVE_PUBLIC_KEY")) &&
816-
getSecret(character, "INJECTIVE_PRIVATE_KEY"))
878+
(getSecret(character, "EVM_PUBLIC_KEY") ||
879+
getSecret(character, "INJECTIVE_PUBLIC_KEY")) &&
880+
getSecret(character, "INJECTIVE_PRIVATE_KEY")
817881
? injectivePlugin
818882
: null,
819883
getSecret(character, "COSMOS_RECOVERY_PHRASE") &&
@@ -955,6 +1019,10 @@ export async function createAgent(
9551019
getSecret(character, "RESERVOIR_API_KEY")
9561020
? createNFTCollectionsPlugin()
9571021
: null,
1022+
getSecret(character, "PYTH_TESTNET_PROGRAM_KEY") ||
1023+
getSecret(character, "PYTH_MAINNET_PROGRAM_KEY")
1024+
? pythDataPlugin
1025+
: null,
9581026
].filter(Boolean),
9591027
providers: [],
9601028
actions: [],
@@ -1116,21 +1184,23 @@ const checkPortAvailable = (port: number): Promise<boolean> => {
11161184
});
11171185
};
11181186

1119-
11201187
const hasValidRemoteUrls = () =>
11211188
process.env.REMOTE_CHARACTER_URLS &&
11221189
process.env.REMOTE_CHARACTER_URLS !== "" &&
11231190
process.env.REMOTE_CHARACTER_URLS.startsWith("http");
11241191

1125-
11261192
const startAgents = async () => {
11271193
const directClient = new DirectClient();
11281194
let serverPort = parseInt(settings.SERVER_PORT || "3000");
11291195
const args = parseArguments();
11301196
let charactersArg = args.characters || args.character;
11311197
let characters = [defaultCharacter];
11321198

1133-
if (charactersArg || hasValidRemoteUrls()) {
1199+
if (process.env.IQ_WALLET_ADDRESS && process.env.IQSOlRPC) {
1200+
characters = await loadCharacterFromOnchain();
1201+
}
1202+
1203+
if ((onchainJson == "null" && charactersArg) || hasValidRemoteUrls()) {
11341204
characters = await loadCharacters(charactersArg);
11351205
}
11361206

0 commit comments

Comments
 (0)