Skip to content

Commit eb9d749

Browse files
authored
Merge branch 'develop' into feat/mint-NFT-with-collection-address
2 parents 5ef24d6 + 5b3385c commit eb9d749

File tree

13 files changed

+1371
-1126
lines changed

13 files changed

+1371
-1126
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ packages/core/src/providers/cache
4545
packages/core/src/providers/cache/*
4646
cache/*
4747
packages/plugin-coinbase/src/plugins/transactions.csv
48-
packages/plugin-coinbase/package-lock.json
4948

5049
tsup.config.bundled_*.mjs
5150

agent/src/index.ts

+19
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,25 @@ export async function loadCharacters(
179179
const character = JSON.parse(content);
180180
validateCharacterConfig(character);
181181

182+
// .id isn't really valid
183+
const characterId = character.id || character.name;
184+
const characterPrefix = `CHARACTER.${characterId.toUpperCase().replace(/ /g, '_')}.`;
185+
186+
const characterSettings = Object.entries(process.env)
187+
.filter(([key]) => key.startsWith(characterPrefix))
188+
.reduce((settings, [key, value]) => {
189+
const settingKey = key.slice(characterPrefix.length);
190+
return { ...settings, [settingKey]: value };
191+
}, {});
192+
193+
if (Object.keys(characterSettings).length > 0) {
194+
character.settings = character.settings || {};
195+
character.settings.secrets = {
196+
...characterSettings,
197+
...character.settings.secrets
198+
};
199+
}
200+
182201
// Handle plugins
183202
if (isAllStrings(character.plugins)) {
184203
elizaLogger.info("Plugins are: ", character.plugins);

docs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ You can run Grok models by setting the `XAI_MODEL` environment variable to `grok
6767

6868
### Run with OpenAI
6969

70-
You can run OpenAI models by setting the `XAI_MODEL` environment variable to `gpt-4o-mini` or `gpt-4o`
70+
You can run OpenAI models by setting the `XAI_MODEL` environment variable to `gpt-4-mini` or `gpt-4o`
7171

7272
## Additional Requirements
7373

docs/docs/guides/secrets-management.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ A comprehensive guide for managing secrets, API keys, and sensitive configuratio
1212

1313
Eliza uses a hierarchical environment variable system:
1414

15-
1. Character-specific secrets (highest priority)
16-
2. Environment variables
17-
3. Default values (lowest priority)
15+
1. Character-specific namespaced environment variables (highest priority)
16+
2. Character-specific secrets
17+
3. Environment variables
18+
4. Default values (lowest priority)
1819

1920
### Secret Types
2021

@@ -96,6 +97,8 @@ Define secrets in character files:
9697
}
9798
```
9899

100+
Alternatively, you can use the `CHARACTER.YOUR_CHARACTER_NAME.SECRET_NAME` format inside your `.env` file.
101+
99102
Access secrets in code:
100103

101104
```typescript

docs/docs/packages/agent.md

+14
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ export async function initializeClients(
160160

161161
### Token Management
162162

163+
Tokens can be configured in two ways:
164+
165+
1. Using namespaced environment variables:
166+
```env
167+
CHARACTER.YOUR_CHARACTER_NAME.OPENAI_API_KEY=sk-...
168+
CHARACTER.YOUR_CHARACTER_NAME.ANTHROPIC_API_KEY=sk-...
169+
```
170+
171+
2. Using character settings:
163172
```typescript
164173
export function getTokenForProvider(
165174
provider: ModelProviderName,
@@ -181,6 +190,11 @@ export function getTokenForProvider(
181190
}
182191
```
183192

193+
The system will check for tokens in the following order:
194+
1. Character-specific namespaced env variables
195+
2. Character settings from JSON
196+
3. Global environment variables
197+
184198
### Database Selection
185199

186200
```typescript

packages/core/src/generation.ts

+16-5
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,22 @@ export async function generateText({
146146

147147
elizaLogger.info("Selected model:", model);
148148

149-
const temperature = models[provider].settings.temperature;
150-
const frequency_penalty = models[provider].settings.frequency_penalty;
151-
const presence_penalty = models[provider].settings.presence_penalty;
152-
const max_context_length = models[provider].settings.maxInputTokens;
153-
const max_response_length = models[provider].settings.maxOutputTokens;
149+
const modelConfiguration = runtime.character?.settings?.modelConfig;
150+
const temperature =
151+
modelConfiguration?.temperature ||
152+
models[provider].settings.temperature;
153+
const frequency_penalty =
154+
modelConfiguration?.frequency_penalty ||
155+
models[provider].settings.frequency_penalty;
156+
const presence_penalty =
157+
modelConfiguration?.presence_penalty ||
158+
models[provider].settings.presence_penalty;
159+
const max_context_length =
160+
modelConfiguration?.maxInputTokens ||
161+
models[provider].settings.maxInputTokens;
162+
const max_response_length =
163+
modelConfiguration.max_response_length ||
164+
models[provider].settings.maxOutputTokens;
154165

155166
const apiKey = runtime.token;
156167

packages/core/src/settings.ts

+31
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ interface Settings {
2222
[key: string]: string | undefined;
2323
}
2424

25+
interface NamespacedSettings {
26+
[namespace: string]: Settings;
27+
}
28+
2529
let environmentSettings: Settings = {};
2630

2731
/**
@@ -91,6 +95,15 @@ export function loadEnvConfig(): Settings {
9195
if (!result.error) {
9296
console.log(`Loaded .env file from: ${envPath}`);
9397
}
98+
99+
// Parse namespaced settings
100+
const namespacedSettings = parseNamespacedSettings(process.env as Settings);
101+
102+
// Attach to process.env for backward compatibility
103+
Object.entries(namespacedSettings).forEach(([namespace, settings]) => {
104+
process.env[`__namespaced_${namespace}`] = JSON.stringify(settings);
105+
});
106+
94107
return process.env as Settings;
95108
}
96109

@@ -135,3 +148,21 @@ elizaLogger.info("Parsed settings:", {
135148
});
136149

137150
export default settings;
151+
152+
// Add this function to parse namespaced settings
153+
function parseNamespacedSettings(env: Settings): NamespacedSettings {
154+
const namespaced: NamespacedSettings = {};
155+
156+
for (const [key, value] of Object.entries(env)) {
157+
if (!value) continue;
158+
159+
const [namespace, ...rest] = key.split('.');
160+
if (!namespace || rest.length === 0) continue;
161+
162+
const settingKey = rest.join('.');
163+
namespaced[namespace] = namespaced[namespace] || {};
164+
namespaced[namespace][settingKey] = value;
165+
}
166+
167+
return namespaced;
168+
}

packages/core/src/tests/defaultCharacters.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe("defaultCharacter", () => {
4343
});
4444

4545
it("should have a topics array with at least one broad topic", () => {
46-
expect(defaultCharacter.topics).toContain("Learning");
46+
expect(defaultCharacter.topics).toContain("Classical art");
4747
});
4848

4949
it('should have style settings with "all" array', () => {

packages/core/src/types.ts

+9
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,14 @@ export interface IAgentConfig {
626626
[key: string]: string;
627627
}
628628

629+
export interface ModelConfiguration {
630+
temperature?: number;
631+
max_response_length?: number;
632+
frequency_penalty?: number;
633+
presence_penalty?: number;
634+
maxInputTokens?: number;
635+
}
636+
629637
/**
630638
* Configuration for an agent character
631639
*/
@@ -738,6 +746,7 @@ export type Character = {
738746
};
739747
};
740748
model?: string;
749+
modelConfig?: ModelConfiguration;
741750
embeddingModel?: string;
742751
chains?: {
743752
evm?: any[];

packages/plugin-3d-generation/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"types": "dist/index.d.ts",
77
"dependencies": {
88
"@elizaos/core": "workspace:*",
9-
"tsup": "8.3.5"
9+
"tsup": "8.3.5",
10+
"whatwg-url": "7.1.0"
1011
},
1112
"scripts": {
1213
"build": "tsup --format esm --dts",

packages/plugin-starknet/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"@elizaos/plugin-trustdb": "workspace:*",
1010
"@avnu/avnu-sdk": "2.1.1",
1111
"@uniswap/sdk-core": "6.0.0",
12+
"unruggable-sdk": "1.4.0",
1213
"@unruggable_starknet/core": "0.1.0",
1314
"starknet": "6.18.0",
1415
"tsup": "8.3.5",

packages/plugin-starknet/src/actions/unruggable.ts

+55-55
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ import {
99
Memory,
1010
ModelClass,
1111
State,
12+
type Action,
1213
} from "@elizaos/core";
1314
import { Percent } from "@uniswap/sdk-core";
15+
import { createMemecoin, launchOnEkubo } from "unruggable-sdk";
16+
import { constants } from "starknet";
17+
1418
import {
1519
getStarknetAccount,
1620
getStarknetProvider,
@@ -22,9 +26,20 @@ import { AMM, QUOTE_TOKEN_SYMBOL } from "@unruggable_starknet/core/constants";
2226
import { ACCOUNTS, TOKENS } from "../utils/constants.ts";
2327
import { validateStarknetConfig } from "../environment.ts";
2428

25-
export function isDeployTokenContent(
26-
content: DeployData
27-
): content is DeployData {
29+
interface SwapContent {
30+
sellTokenAddress: string;
31+
buyTokenAddress: string;
32+
sellAmount: string;
33+
}
34+
35+
interface DeployTokenContent {
36+
name: string;
37+
symbol: string;
38+
owner: string;
39+
initialSupply: string;
40+
}
41+
42+
export function isDeployTokenContent(content: DeployTokenContent) {
2843
// Validate types
2944
const validTypes =
3045
typeof content.name === "string" &&
@@ -122,77 +137,62 @@ export const deployToken: Action = {
122137
const provider = getStarknetProvider(runtime);
123138
const account = getStarknetAccount(runtime);
124139

125-
const factory = new Factory({
126-
provider,
127-
chainId: await provider.getChainId(),
128-
});
140+
const chainId = await provider.getChainId();
141+
const config = {
142+
starknetChainId: chainId,
143+
starknetProvider: provider,
144+
};
129145

130-
const { tokenAddress, calls: deployCalls } =
131-
factory.getDeployCalldata({
132-
name: response.name,
133-
symbol: response.symbol,
134-
owner: response.owner,
135-
initialSupply: response.initialSupply,
136-
});
137-
138-
const data = await factory.getMemecoinLaunchData(tokenAddress);
139-
140-
const { calls: launchCalls } = await factory.getEkuboLaunchCalldata(
146+
const { tokenAddress, transactionHash } = await createMemecoin(
147+
config,
141148
{
142-
address: tokenAddress,
143149
name: response.name,
144150
symbol: response.symbol,
145151
owner: response.owner,
146-
totalSupply: response.initialSupply,
147-
decimals: 18,
148-
...data,
149-
},
150-
{
151-
fees: parseFormatedPercentage("3"),
152-
amm: AMM.EKUBO,
153-
teamAllocations: [
154-
{
155-
address: ACCOUNTS.ELIZA,
156-
amount: new Percent(
157-
2.5,
158-
response.initialSupply
159-
).toFixed(0),
160-
},
161-
{
162-
address: ACCOUNTS.BLOBERT,
163-
amount: new Percent(
164-
2.5,
165-
response.initialSupply
166-
).toFixed(0),
167-
},
168-
],
169-
holdLimit: parseFormatedPercentage("2"),
170-
antiBotPeriod: 3600,
171-
quoteToken: {
172-
address: TOKENS.LORDS,
173-
symbol: "LORDS" as QUOTE_TOKEN_SYMBOL,
174-
name: "Lords",
175-
decimals: 18,
176-
camelCased: false,
177-
},
178-
startingMarketCap: parseFormatedAmount("5000"),
152+
initialSupply: response.initialSupply,
153+
starknetAccount: account,
179154
}
180155
);
181156

182157
elizaLogger.log(
183-
"Deployment has been initiated for coin: " +
158+
"Token deployment initiated for: " +
184159
response.name +
185160
" at address: " +
186161
tokenAddress
187162
);
188-
const tx = await account.execute([...deployCalls, ...launchCalls]);
163+
164+
await launchOnEkubo(config, {
165+
antiBotPeriodInSecs: 3600,
166+
currencyAddress: TOKENS.LORDS,
167+
fees: "3",
168+
holdLimit: "2",
169+
memecoinAddress: tokenAddress,
170+
starknetAccount: account,
171+
startingMarketCap: "5000",
172+
teamAllocations: [
173+
{
174+
address: ACCOUNTS.ELIZA,
175+
amount: new Percent(
176+
2.5,
177+
response.initialSupply
178+
).toFixed(0),
179+
},
180+
{
181+
address: ACCOUNTS.BLOBERT,
182+
amount: new Percent(
183+
2.5,
184+
response.initialSupply
185+
).toFixed(0),
186+
},
187+
],
188+
});
189189

190190
callback?.({
191191
text:
192192
"Token Deployment completed successfully!" +
193193
response.symbol +
194194
" deployed in tx: " +
195-
tx.transaction_hash,
195+
transactionHash,
196196
});
197197

198198
return true;

0 commit comments

Comments
 (0)