Skip to content

Commit 464377e

Browse files
feat: clean
2 parents 6e05c0f + 7e8a627 commit 464377e

File tree

10 files changed

+507
-119
lines changed

10 files changed

+507
-119
lines changed

SECURITY.md

+51-46
Original file line numberDiff line numberDiff line change
@@ -17,74 +17,79 @@ We take the security of Eliza seriously. If you believe you have found a securit
1717

1818
1. **DO NOT** create a public GitHub issue for the vulnerability
1919
2. Send an email to security@eliza.builders with:
20-
- A detailed description of the vulnerability
21-
- Steps to reproduce the issue
22-
- Potential impact of the vulnerability
23-
- Any possible mitigations you've identified
20+
- A detailed description of the vulnerability
21+
- Steps to reproduce the issue
22+
- Potential impact of the vulnerability
23+
- Any possible mitigations you've identified
2424

2525
### What to Expect
2626

27-
- **Initial Response**: Within 48 hours, you will receive an acknowledgment of your report
28-
- **Updates**: We will provide updates every 5 business days about the progress
29-
- **Resolution Timeline**: We aim to resolve critical issues within 15 days
30-
- **Disclosure**: We will coordinate with you on the public disclosure timing
27+
- **Initial Response**: Within 48 hours, you will receive an acknowledgment of your report
28+
- **Updates**: We will provide updates every 5 business days about the progress
29+
- **Resolution Timeline**: We aim to resolve critical issues within 15 days
30+
- **Disclosure**: We will coordinate with you on the public disclosure timing
3131

3232
## Security Best Practices
3333

3434
### For Contributors
3535

3636
1. **API Keys and Secrets**
37-
- Never commit API keys, passwords, or other secrets to the repository
38-
- Use environment variables as described in our secrets management guide
39-
- Rotate any accidentally exposed credentials immediately
37+
38+
- Never commit API keys, passwords, or other secrets to the repository
39+
- Use environment variables as described in our secrets management guide
40+
- Rotate any accidentally exposed credentials immediately
4041

4142
2. **Dependencies**
42-
- Keep all dependencies up to date
43-
- Review security advisories for dependencies regularly
44-
- Use `pnpm audit` to check for known vulnerabilities
43+
44+
- Keep all dependencies up to date
45+
- Review security advisories for dependencies regularly
46+
- Use `pnpm audit` to check for known vulnerabilities
4547

4648
3. **Code Review**
47-
- All code changes must go through pull request review
48-
- Security-sensitive changes require additional review
49-
- Enable branch protection on main branches
49+
- All code changes must go through pull request review
50+
- Security-sensitive changes require additional review
51+
- Enable branch protection on main branches
5052

5153
### For Users
5254

5355
1. **Environment Setup**
54-
- Follow our [secrets management guide](docs/guides/secrets-management.md) for secure configuration
55-
- Use separate API keys for development and production
56-
- Regularly rotate credentials
56+
57+
- Follow our [secrets management guide](docs/guides/secrets-management.md) for secure configuration
58+
- Use separate API keys for development and production
59+
- Regularly rotate credentials
5760

5861
2. **Model Provider Security**
59-
- Use appropriate rate limiting for API calls
60-
- Monitor usage patterns for unusual activity
61-
- Implement proper authentication for exposed endpoints
62+
63+
- Use appropriate rate limiting for API calls
64+
- Monitor usage patterns for unusual activity
65+
- Implement proper authentication for exposed endpoints
6266

6367
3. **Platform Integration**
64-
- Use separate bot tokens for different environments
65-
- Implement proper permission scoping for platform APIs
66-
- Regular audit of platform access and permissions
68+
- Use separate bot tokens for different environments
69+
- Implement proper permission scoping for platform APIs
70+
- Regular audit of platform access and permissions
6771

6872
## Security Features
6973

7074
### Current Implementation
7175

72-
- Environment variable based secrets management
73-
- Type-safe API implementations
74-
- Automated dependency updates via Renovate
75-
- Continuous Integration security checks
76+
- Environment variable based secrets management
77+
- Type-safe API implementations
78+
- Automated dependency updates via Renovate
79+
- Continuous Integration security checks
7680

7781
### Planned Improvements
7882

7983
1. **Q4 2024**
80-
- Automated security scanning in CI pipeline
81-
- Enhanced rate limiting implementation
82-
- Improved audit logging
84+
85+
- Automated security scanning in CI pipeline
86+
- Enhanced rate limiting implementation
87+
- Improved audit logging
8388

8489
2. **Q1 2025**
85-
- Security-focused documentation improvements
86-
- Enhanced platform permission management
87-
- Automated vulnerability scanning
90+
- Security-focused documentation improvements
91+
- Enhanced platform permission management
92+
- Automated vulnerability scanning
8893

8994
## Vulnerability Disclosure Policy
9095

@@ -100,21 +105,21 @@ We follow a coordinated disclosure process:
100105

101106
We believe in recognizing security researchers who help improve our security. Contributors who report valid security issues will be:
102107

103-
- Credited in our security acknowledgments (unless they wish to remain anonymous)
104-
- Added to our security hall of fame
105-
- Considered for our bug bounty program (coming soon)
108+
- Credited in our security acknowledgments (unless they wish to remain anonymous)
109+
- Added to our security hall of fame
110+
- Considered for our bug bounty program (coming soon)
106111

107112
## License Considerations
108113

109114
As an MIT licensed project, users should understand:
110115

111-
- The software is provided "as is"
112-
- No warranty is provided
113-
- Users are responsible for their own security implementations
114-
- Contributors grant perpetual license to their contributions
116+
- The software is provided "as is"
117+
- No warranty is provided
118+
- Users are responsible for their own security implementations
119+
- Contributors grant perpetual license to their contributions
115120

116121
## Contact
117122

118-
- Security Issues: security@eliza.builders
119-
- General Questions: Join our [Discord](https://discord.gg/ai16z)
120-
- Updates: Follow our [security advisory page](https://github.com/ai16z/eliza/security/advisories)
123+
- Security Issues: security@eliza.builders
124+
- General Questions: Join our [Discord](https://discord.gg/ai16z)
125+
- Updates: Follow our [security advisory page](https://github.com/ai16z/eliza/security/advisories)

agent/src/index.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import readline from "readline";
3131
import yargs from "yargs";
3232
import path from "path";
3333
import { fileURLToPath } from "url";
34-
import { character } from "./character.ts";
34+
import blobert from "./blobert.ts";
3535
import type { DirectClient } from "@ai16z/client-direct";
3636

3737
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
@@ -258,13 +258,6 @@ export function createAgent(
258258
});
259259
}
260260

261-
function intializeFsCache(baseDir: string, character: Character) {
262-
const cacheDir = path.resolve(baseDir, character.id, "cache");
263-
264-
const cache = new CacheManager(new FsCacheAdapter(cacheDir));
265-
return cache;
266-
}
267-
268261
function intializeDbCache(character: Character, db: IDatabaseCacheAdapter) {
269262
const cache = new CacheManager(new DbCacheAdapter(db, character.id));
270263
return cache;
@@ -312,7 +305,7 @@ const startAgents = async () => {
312305

313306
let charactersArg = args.characters || args.character;
314307

315-
let characters = [character];
308+
let characters = [blobert];
316309

317310
if (charactersArg) {
318311
characters = await loadCharacters(charactersArg);

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"dependencies": {
4848
"ollama-ai-provider": "^0.16.1",
4949
"optional": "^0.1.4",
50-
"sharp": "^0.33.5"
50+
"sharp": "^0.33.5",
51+
"tslog": "^4.9.3"
5152
},
5253
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
5354
}

packages/core/src/embedding.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ export async function embed(runtime: IAgentRuntime, input: string) {
8686
// 3. Fallback to OpenAI embedding model
8787
const embeddingModel = settings.USE_OPENAI_EMBEDDING
8888
? "text-embedding-3-small"
89-
: modelProvider.model?.[ModelClass.EMBEDDING] ||
90-
models[ModelProviderName.OPENAI].model[ModelClass.EMBEDDING];
89+
: runtime.character.modelProvider === ModelProviderName.OLLAMA
90+
? settings.OLLAMA_EMBEDDING_MODEL || "mxbai-embed-large"
91+
: modelProvider.model?.[ModelClass.EMBEDDING] ||
92+
models[ModelProviderName.OPENAI].model[ModelClass.EMBEDDING];
9193

9294
if (!embeddingModel) {
9395
throw new Error("No embedding model configured");

packages/core/src/generation.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ export async function generateText({
6262
return "";
6363
}
6464

65-
elizaLogger.log("Genarating text...");
65+
elizaLogger.log("Generating text...");
66+
67+
elizaLogger.info("Generating text with options:", {
68+
modelProvider: runtime.modelProvider,
69+
model: modelClass,
70+
});
6671

6772
const provider = runtime.modelProvider;
6873
const endpoint =
@@ -84,6 +89,8 @@ export async function generateText({
8489
model = runtime.getSetting("LLAMACLOUD_MODEL_SMALL");
8590
}
8691

92+
elizaLogger.info("Selected model:", model);
93+
8794
const temperature = models[provider].settings.temperature;
8895
const frequency_penalty = models[provider].settings.frequency_penalty;
8996
const presence_penalty = models[provider].settings.presence_penalty;
@@ -709,7 +716,7 @@ export async function generateMessageResponse({
709716
let retryLength = 1000; // exponential backoff
710717
while (true) {
711718
try {
712-
elizaLogger.log("Genarating message response..");
719+
elizaLogger.log("Generating message response..");
713720

714721
const response = await generateText({
715722
runtime,

packages/core/src/logger.ts

+34-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
class ElizaLogger {
1+
import settings from "./settings.ts";
2+
import { Logger } from "tslog";
3+
4+
interface IElizaLogger extends Logger<IElizaLogger> {
5+
progress(message: string): void;
6+
}
7+
8+
class ElizaLogger implements IElizaLogger {
29
constructor() {
310
// Check if we're in Node.js environment
411
this.isNode =
@@ -7,7 +14,7 @@ class ElizaLogger {
714
process.versions.node != null;
815

916
// Set verbose based on environment
10-
this.verbose = this.isNode ? process.env.verbose === "true" : false;
17+
this.verbose = this.isNode ? settings.VERBOSE === "true" : false;
1118
}
1219

1320
private isNode: boolean;
@@ -173,6 +180,7 @@ class ElizaLogger {
173180
}
174181
}
175182

183+
// @ts-expect-error- custom implementation
176184
log(...strings) {
177185
this.#logWithStyle(strings, {
178186
fg: "white",
@@ -182,6 +190,7 @@ class ElizaLogger {
182190
});
183191
}
184192

193+
// @ts-expect-error- custom implementation
185194
warn(...strings) {
186195
this.#logWithStyle(strings, {
187196
fg: "yellow",
@@ -191,6 +200,7 @@ class ElizaLogger {
191200
});
192201
}
193202

203+
// @ts-expect-error- custom implementation
194204
error(...strings) {
195205
this.#logWithStyle(strings, {
196206
fg: "red",
@@ -200,6 +210,7 @@ class ElizaLogger {
200210
});
201211
}
202212

213+
// @ts-expect-error- custom implementation
203214
info(...strings) {
204215
this.#logWithStyle(strings, {
205216
fg: "blue",
@@ -209,15 +220,7 @@ class ElizaLogger {
209220
});
210221
}
211222

212-
success(...strings) {
213-
this.#logWithStyle(strings, {
214-
fg: "green",
215-
bg: "",
216-
icon: "\u2713",
217-
groupTitle: ` ${this.successesTitle}`,
218-
});
219-
}
220-
223+
// @ts-expect-error- custom implementation
221224
debug(...strings) {
222225
if (!this.verbose) return;
223226
this.#logWithStyle(strings, {
@@ -228,6 +231,15 @@ class ElizaLogger {
228231
});
229232
}
230233

234+
success(...strings) {
235+
this.#logWithStyle(strings, {
236+
fg: "green",
237+
bg: "",
238+
icon: "\u2713",
239+
groupTitle: ` ${this.successesTitle}`,
240+
});
241+
}
242+
231243
assert(...strings) {
232244
this.#logWithStyle(strings, {
233245
fg: "cyan",
@@ -236,6 +248,17 @@ class ElizaLogger {
236248
groupTitle: ` ${this.assertsTitle}`,
237249
});
238250
}
251+
252+
progress(message: string) {
253+
if (this.isNode) {
254+
// Clear the current line and move cursor to beginning
255+
process.stdout.clearLine(0);
256+
process.stdout.cursorTo(0);
257+
process.stdout.write(message);
258+
} else {
259+
console.log(message);
260+
}
261+
}
239262
}
240263

241264
export const elizaLogger = new ElizaLogger();

packages/core/src/runtime.ts

+30
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ export class AgentRuntime implements IAgentRuntime {
176176
return;
177177
}
178178

179+
// Add the service to the services map
179180
this.services.set(serviceType, service);
181+
elizaLogger.success(`Service ${serviceType} registered successfully`);
180182
}
181183

182184
/**
@@ -217,6 +219,12 @@ export class AgentRuntime implements IAgentRuntime {
217219
cacheManager: ICacheManager;
218220
logging?: boolean;
219221
}) {
222+
elizaLogger.info("Initializing AgentRuntime with options:", {
223+
character: opts.character?.name,
224+
modelProvider: opts.modelProvider,
225+
characterModelProvider: opts.character?.modelProvider,
226+
});
227+
220228
this.#conversationLength =
221229
opts.conversationLength ?? this.#conversationLength;
222230
this.databaseAdapter = opts.databaseAdapter;
@@ -280,10 +288,32 @@ export class AgentRuntime implements IAgentRuntime {
280288
});
281289

282290
this.serverUrl = opts.serverUrl ?? this.serverUrl;
291+
292+
elizaLogger.info("Setting model provider...");
293+
elizaLogger.info(
294+
"- Character model provider:",
295+
this.character.modelProvider
296+
);
297+
elizaLogger.info("- Opts model provider:", opts.modelProvider);
298+
elizaLogger.info("- Current model provider:", this.modelProvider);
299+
283300
this.modelProvider =
284301
this.character.modelProvider ??
285302
opts.modelProvider ??
286303
this.modelProvider;
304+
305+
elizaLogger.info("Selected model provider:", this.modelProvider);
306+
307+
// Validate model provider
308+
if (!Object.values(ModelProviderName).includes(this.modelProvider)) {
309+
elizaLogger.error("Invalid model provider:", this.modelProvider);
310+
elizaLogger.error(
311+
"Available providers:",
312+
Object.values(ModelProviderName)
313+
);
314+
throw new Error(`Invalid model provider: ${this.modelProvider}`);
315+
}
316+
287317
if (!this.serverUrl) {
288318
elizaLogger.warn("No serverUrl provided, defaulting to localhost");
289319
}

0 commit comments

Comments
 (0)