Skip to content

Commit 4d7e0aa

Browse files
committed
cleanup
1 parent c93510c commit 4d7e0aa

12 files changed

+457
-507
lines changed

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v23.1.0

.vscode/launch.json

+19-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@
1111
"runtimeExecutable": "pnpm",
1212
"runtimeArgs": ["run", "dev"],
1313
"skipFiles": ["<node_internals>/**"]
14-
}
14+
},
15+
{
16+
"type": "node",
17+
"request": "launch",
18+
"name": "Debug Vitest",
19+
"program": "${workspaceFolder}/node_modules/vitest/vitest.mjs",
20+
"args": [
21+
"run",
22+
"--",
23+
"${relativeFile}" // Ensures the currently open test file is passed
24+
],
25+
"cwd": "${workspaceFolder}",
26+
"env": {
27+
"NODE_ENV": "test" // Ensure test environment is set
28+
},
29+
"autoAttachChildProcesses": true,
30+
"smartStep": true,
31+
"skipFiles": ["<node_internals>/**"]
32+
}
1533
]
1634
}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"docker:run": "bash ./scripts/docker.sh run",
1818
"docker:bash": "bash ./scripts/docker.sh bash",
1919
"docker:start": "bash ./scripts/docker.sh start",
20-
"docker": "pnpm docker:build && pnpm docker:run && pnpm docker:bash"
20+
"docker": "pnpm docker:build && pnpm docker:run && pnpm docker:bash",
21+
"tests": "pnpm --dir packages/core test"
2122
},
2223
"devDependencies": {
2324
"concurrently": "^9.1.0",

packages/core/.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
22
dist
33
elizaConfig.yaml
4-
custom_actions/
4+
custom_actions/
5+
cache/

packages/core/cache/holderList_2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh.json

-1
This file was deleted.

packages/core/cache/tokenSecurity_2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh.json

-1
This file was deleted.

packages/core/src/embedding.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { models } from "./models.ts";
55
import { IAgentRuntime, ModelProviderName, ModelClass } from "./types.ts";
66
import fs from "fs";
77
import { trimTokens } from "./generation.ts";
8-
import { settings } from "./settings.ts";
8+
import settings from "./settings.ts";
99

1010
function getRootPath() {
1111
const __filename = fileURLToPath(import.meta.url);

packages/core/src/generation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
parseJSONObjectFromText,
2323
parseShouldRespondFromText,
2424
} from "./parsing.ts";
25-
import { settings } from "./settings.ts";
25+
import settings from "./settings.ts";
2626
import {
2727
Content,
2828
IAgentRuntime,

packages/core/src/models.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { settings } from "./settings.ts";
1+
import settings from "./settings.ts";
22
import { Models, ModelProviderName, ModelClass } from "./types.ts";
33

44
export const models: Models = {

packages/core/src/runtime.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { formatActors, formatMessages, getActorDetails } from "./messages.ts";
2020
import { parseJsonArrayFromText } from "./parsing.ts";
2121
import { formatPosts } from "./posts.ts";
2222
import { getProviders } from "./providers.ts";
23-
import { settings } from "./settings.ts";
23+
import settings from "./settings.ts";
2424
import {
2525
Character,
2626
Goal,

packages/core/src/settings.ts

+18-58
Original file line numberDiff line numberDiff line change
@@ -2,94 +2,54 @@ import { config } from "dotenv";
22
import fs from "fs";
33
import path from "path";
44

5-
export interface Settings {
6-
MAIN_WALLET_ADDRESS: string;
7-
OPENAI_API_KEY: string;
8-
USE_OPENAI_EMBEDDING: string;
9-
SYSTEM_PROMPT: string;
10-
OPENROUTER_MODEL: string;
11-
SMALL_OPENROUTER_MODEL: string;
12-
MEDIUM_OPENROUTER_MODEL: string;
13-
LARGE_OPENROUTER_MODEL: string;
14-
OLLAMA_MODEL: string;
15-
LARGE_OLLAMA_MODEL: string;
16-
MEDIUM_OLLAMA_MODEL: string;
17-
SMALL_OLLAMA_MODEL: string;
18-
OLLAMA_SERVER_URL: string;
19-
OLLAMA_EMBEDDING_MODEL: string;
20-
RPC_URL: string;
21-
BASE_MINT: string;
22-
BACKEND_URL: string;
23-
BACKEND_TOKEN: string;
24-
BIRDEYE_API_KEY: string;
25-
HELIUS_API_KEY: string;
26-
SERVER_PORT: string;
27-
CAPSOLVER_API_KEY: string;
28-
CUDA_PATH: string;
29-
}
30-
315
/**
326
* Recursively searches for a .env file starting from the current directory
337
* and moving up through parent directories
8+
* @param {string} [startDir=process.cwd()] - Starting directory for the search
9+
* @returns {string|null} Path to the nearest .env file or null if not found
3410
*/
3511
export function findNearestEnvFile(startDir = process.cwd()) {
36-
console.error('DEBUG - Starting env file search');
37-
console.error('DEBUG - Current working directory:', process.cwd());
38-
39-
// In test environment, use the known working path
40-
if (process.env.NODE_ENV === 'test' || process.env.VITEST) {
41-
const testPath = path.join(process.cwd(), '.env.test');
42-
console.error('DEBUG - Checking test path:', testPath);
43-
if (fs.existsSync(testPath)) {
44-
console.error('DEBUG - Found test env file at:', testPath);
45-
return testPath;
46-
}
47-
}
48-
49-
// Look for regular .env
5012
let currentDir = startDir;
51-
const envFile = process.env.NODE_ENV === 'test' ? '.env.test' : '.env';
5213

14+
// Continue searching until we reach the root directory
5315
while (currentDir !== path.parse(currentDir).root) {
54-
const envPath = path.join(currentDir, envFile);
55-
console.error('DEBUG - Checking path:', envPath);
16+
const envPath = path.join(currentDir, ".env");
17+
5618
if (fs.existsSync(envPath)) {
57-
console.error('DEBUG - Found env file at:', envPath);
5819
return envPath;
5920
}
21+
22+
// Move up to parent directory
6023
currentDir = path.dirname(currentDir);
6124
}
6225

63-
console.error('DEBUG - No env file found after checking all paths');
64-
console.error('DEBUG - Final cwd:', process.cwd());
65-
console.error('DEBUG - Final NODE_ENV:', process.env.NODE_ENV);
66-
return null;
26+
// Check root directory as well
27+
const rootEnvPath = path.join(path.parse(currentDir).root, ".env");
28+
return fs.existsSync(rootEnvPath) ? rootEnvPath : null;
6729
}
6830

6931
/**
7032
* Loads environment variables from the nearest .env file
33+
* @returns {Object} Environment variables object
34+
* @throws {Error} If no .env file is found
7135
*/
7236
export function loadEnvConfig() {
73-
console.error('DEBUG - loadEnvConfig called');
74-
console.error('DEBUG - Current working directory:', process.cwd());
75-
console.error('DEBUG - NODE_ENV:', process.env.NODE_ENV);
76-
7737
const envPath = findNearestEnvFile();
7838

7939
if (!envPath) {
8040
throw new Error("No .env file found in current or parent directories.");
8141
}
8242

83-
console.error('DEBUG - Loading env file from:', envPath);
43+
// Load the .env file
8444
const result = config({ path: envPath });
45+
8546
if (result.error) {
8647
throw new Error(`Error loading .env file: ${result.error}`);
8748
}
8849

89-
console.error('DEBUG - Successfully loaded env file');
90-
91-
// Populate the settings object with the environment variables
92-
Object.assign(settings, process.env);
50+
console.log(`Loaded .env file from: ${envPath}`);
51+
return process.env;
9352
}
9453

95-
export const settings: Settings = {} as Settings;
54+
export const settings = loadEnvConfig();
55+
export default settings;

0 commit comments

Comments
 (0)