Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/eliza introspector develop #40

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Secrets used
- OPENAI_API_KEY
- TURBO_TOKEN
- TURBO_TEAM
- NODE_AUTH_TOKEN

# fixme: why 4 different gihthub tokens?
- GH_PAT
- GITHUB_ACCESS_TOKEN
- GITHUB_TOKEN
- CHANGELOG_GITHUB_TOKEN
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
check:
runs-on: ubuntu-latest
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_REMOTE_ONLY: true
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v23.3.0
v23.9.0
62 changes: 2 additions & 60 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,65 +106,7 @@ function mergeCharacters(base: Character, child: Character): Character {
};
return mergeObjects(base, child);
}
/* function isAllStrings(arr: unknown[]): boolean {
return Array.isArray(arr) && arr.every((item) => typeof item === "string");
}
export async function loadCharacterFromOnchain(): Promise<Character[]> {
const jsonText = onchainJson;

console.log("JSON:", jsonText);
if (!jsonText) return [];
const loadedCharacters = [];
try {
const character = JSON5.parse(jsonText);
validateCharacterConfig(character);

// .id isn't really valid
const characterId = character.id || character.name;
const characterPrefix = `CHARACTER.${characterId
.toUpperCase()
.replace(/ /g, "_")}.`;

const characterSettings = Object.entries(process.env)
.filter(([key]) => key.startsWith(characterPrefix))
.reduce((settings, [key, value]) => {
const settingKey = key.slice(characterPrefix.length);
settings[settingKey] = value;
return settings;
}, {});

if (Object.keys(characterSettings).length > 0) {
character.settings = character.settings || {};
character.settings.secrets = {
...characterSettings,
...character.settings.secrets,
};
}

// Handle plugins
if (isAllStrings(character.plugins)) {
elizaLogger.info("Plugins are: ", character.plugins);
const importedPlugins = await Promise.all(
character.plugins.map(async (plugin) => {
const importedPlugin = await import(plugin);
return importedPlugin.default;
})
);
character.plugins = importedPlugins;
}

loadedCharacters.push(character);
elizaLogger.info(
`Successfully loaded character from: ${process.env.IQ_WALLET_ADDRESS}`
);
return loadedCharacters;
} catch (e) {
elizaLogger.error(
`Error parsing character from ${process.env.IQ_WALLET_ADDRESS}: ${e}`
);
process.exit(1);
}
} */

async function loadCharactersFromUrl(url: string): Promise<Character[]> {
try {
Expand Down Expand Up @@ -956,8 +898,8 @@ const setProxy = () => {

setProxy();

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

startAgents().catch((error) => {
elizaLogger.error("Unhandled error in startAgents:", error);
Expand Down
2 changes: 1 addition & 1 deletion agent/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"rootDir": ".",
"module": "ESNext",
"moduleResolution": "Bundler",
"types": ["node", "jest"]
"types": ["node"]
},
"ts-node": {
"experimentalSpecifierResolution": "node",
Expand Down
3 changes: 3 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"preview": "vite preview"
},
"dependencies": {
"@hapi/shot": "^6.0.1",
"@types/hapi__shot": "4.1.6",
"@types/hapi": "^18.0.14",
"@elizaos/core": "workspace:*",
"@radix-ui/react-avatar": "^1.1.2",
"@radix-ui/react-collapsible": "^1.1.2",
Expand Down
19 changes: 19 additions & 0 deletions delete.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -e
# Delete all images in a repository
# Usage: ./delete.sh <repository-name>
# Example: ./delete.sh agent/eliza
# Note: This script will not delete the repository itself, only the images in it


if [ -z "$1" ]; then
echo "Error: Repository name is required."
echo "Usage: ./delete.sh <repository-name>"
exit 1
fi

echo "Deleting all images in repository: $1"
aws ecr batch-delete-image \
--repository-name "$1" \
--image-ids "$(aws ecr list-images --repository-name "$1" --query 'imageIds[*]' --output json)" || true
echo "Deletion process completed."
17 changes: 17 additions & 0 deletions doit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

nvm use 23
pnpm clean
pnpm install --no-frozen-lockfile
pnpm build


pushd packages/adapter-sqlite
pnpm rebuild
popd


pushd scripts/jsdoc-automation
pnpm install --no-frozen-lockfile
pnpm build

popd
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
"node": "23.3.0"
},
"dependencies": {
"@hapi/shot": "^6.0.1",
"@types/hapi": "^18.0.14",
"@0glabs/0g-ts-sdk": "0.2.1",
"@coinbase/coinbase-sdk": "0.10.0",
"@deepgram/sdk": "^3.9.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/adapter-sqlite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"dist"
],
"dependencies": {
"@hapi/shot": "^6.0.1",
"@types/hapi__shot": "4.1.6",
"@types/hapi": "^18.0.14",
"@elizaos/core": "workspace:*",
"@types/better-sqlite3": "7.6.12",
"better-sqlite3": "11.8.1",
Expand Down
5 changes: 3 additions & 2 deletions packages/adapter-sqlite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ export class SqliteDatabaseAdapter
ORDER BY levenshtein_score ASC
LIMIT ?
`;

console.log("similarity",sql)
const rows = this.db
.prepare(sql)
.all(
Expand All @@ -439,7 +439,7 @@ export class SqliteDatabaseAdapter
opts.query_input,
opts.query_match_count
) as { embedding: Buffer; levenshtein_score: number }[];

console.log("found these",rows)
return rows.map((row) => ({
embedding: Array.from(new Float32Array(row.embedding as Buffer)),
levenshtein_score: row.levenshtein_score,
Expand Down Expand Up @@ -1114,6 +1114,7 @@ const sqliteDatabaseAdapter: Adapter = {
})
.catch((error) => {
elizaLogger.error("Failed to connect to SQLite:", error);
throw error;
});

return db;
Expand Down
13 changes: 8 additions & 5 deletions packages/client-direct/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@
"@elizaos/core": "workspace:*",
"@types/body-parser": "1.19.5",
"@types/cors": "2.8.17",
"body-parser": "1.20.3",
"body-parser": "2.1.0",
"cors": "2.8.5",
"express": "4.21.1",
"express": "5.0.1",
"multer": "1.4.5-lts.1",
"openai": "4.73.0",
"path-to-regexp": "^1.7.0",
"zod": "^3.24.2"
"path-to-regexp": "8.2.0",
"zod": "^3.24.2",
"@hapi/shot": "^6.0.1",
"@types/hapi__shot": "4.1.6",
"@types/hapi": "^18.0.14"
},
"devDependencies": {
"@types/express": "4.17.21",
"@types/multer": "^1.4.12",
"@types/multer": "1.4.12",
"tsup": "8.3.5"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/client-direct/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ export class DirectClient {
elizaLogger.error(
"Could not close connections in time, forcefully shutting down"
);
process.exit(1);
process.exit(11);
}, 5000);
};

Expand Down
2 changes: 1 addition & 1 deletion packages/core/__tests__/goals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const mockRuntime: IAgentRuntime = {
databaseAdapter: mockDatabaseAdapter as any,
cacheManager: new CacheManager(new MemoryCacheAdapter()),
agentId: "qweqew-qweqwe-qweqwe-qweqwe-qweeqw",
serverUrl: "",
//serverUrl: "",
token: null,
messageManager: {
addEmbeddingToMemory: (_memory: Memory): Promise<Memory> => {
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import dotenv from "dotenv";
import path from "path";
import { fileURLToPath } from "url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// const __filename = fileURLToPath(import.meta.url);
// const __dirname = path.dirname(__filename);

// Load environment variables from root .env file
dotenv.config({ path: path.resolve(__dirname, "../../../.env") });
// // Load environment variables from root .env file
// dotenv.config({ path: path.resolve(__dirname, "../../../.env") });
5 changes: 5 additions & 0 deletions packages/core/src/embedding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,11 @@ export async function embed(runtime: IAgentRuntime, input: string) {
elizaLogger.log("No input to retrieve cached embedding for");
return null;
}
if (! runtime.messageManager) {
elizaLogger.log("No message manager");
throw Error("No message manager");
return null;
}

const similaritySearchResult =
await runtime.messageManager.getCachedEmbeddings(input);
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/localembeddingManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class LocalEmbeddingModelManager {
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const rootPath = path.resolve(__dirname, "..");
console.log("ROOT",rootPath);
return rootPath.includes("/eliza/")
? rootPath.split("/eliza/")[0] + "/eliza/"
: path.resolve(__dirname, "..");
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ export class MemoryManager implements IMemoryManager {
levenshtein_score: number;
}[]
> {
if (!this.runtime.databaseAdapter){
throw Error("Database adapter not initialized");

}
return await this.runtime.databaseAdapter.getCachedEmbeddings({
query_table_name: this.tableName,
query_threshold: 2,
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class AgentRuntime implements IAgentRuntime {
/**
* The base URL of the server where the agent's requests are processed.
*/
serverUrl = "http://localhost:7998";
//serverUrl = "http://localhost:7998";

/**
* The database adapter used for interacting with the database.
Expand Down Expand Up @@ -346,7 +346,7 @@ export class AgentRuntime implements IAgentRuntime {
this.registerService(service);
});

this.serverUrl = opts.serverUrl ?? this.serverUrl;
//this.serverUrl = opts.serverUrl ?? this.serverUrl;

elizaLogger.info(`${this.character.name}(${this.agentId}) - Setting Model Provider:`, {
characterModelProvider: this.character.modelProvider,
Expand Down Expand Up @@ -394,9 +394,9 @@ export class AgentRuntime implements IAgentRuntime {
throw new Error(`Invalid model provider: ${this.modelProvider}`);
}

if (!this.serverUrl) {
elizaLogger.warn("No serverUrl provided, defaulting to localhost");
}
//if (!this.serverUrl) {
// elizaLogger.warn("No serverUrl provided, defaulting to localhost");
//}

this.token = opts.token;

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/test_resources/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { UUID } from "../types.ts";

export const SERVER_URL = "http://localhost:7998";
//export const SERVER_URL = "http://localhost:7998";
export const SUPABASE_URL = "https://pronvzrzfwsptkojvudd.supabase.co";
export const SUPABASE_ANON_KEY =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InByb252enJ6ZndzcHRrb2p2dWRkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDY4NTYwNDcsImV4cCI6MjAyMjQzMjA0N30.I6_-XrqssUb2SWYg5DjsUqSodNS3_RPoET3-aPdqywM";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@ export abstract class Service {
export interface IAgentRuntime {
// Properties
agentId: UUID;
serverUrl: string;
//serverUrl: string;
databaseAdapter: IDatabaseAdapter;
token: string | null;
modelProvider: ModelProviderName;
Expand Down
4 changes: 3 additions & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"noEmitOnError": false,
"moduleDetection": "force",
"allowArbitraryExtensions": true,
"customConditions": ["@elizaos/source"]
"typeRoots":["./node_modules/@types"],
"customConditions": ["@elizaos/source"],
"sourceMap": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "src/**/*.d.ts", "types/**/*.test.ts"]
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-bootstrap/fileGroups.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
8 changes: 8 additions & 0 deletions packages/plugin-bootstrap/organizedDocs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"classes": [],
"methods": [],
"interfaces": [],
"types": [],
"functions": [],
"variables": []
}
5 changes: 4 additions & 1 deletion packages/plugin-bootstrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
"dist"
],
"dependencies": {
"@elizaos/core": "workspace:*"
"@elizaos/core": "workspace:*",
"@hapi/shot": "^6.0.1",
"@types/hapi__shot": "4.1.6",
"@types/hapi": "^18.0.14"
},
"devDependencies": {
"@types/node": "^22.10.5",
Expand Down
Loading