Skip to content

Commit 40546f2

Browse files
committed
this is broken but structurally where we are going
2 parents 504890b + aed6ef1 commit 40546f2

File tree

128 files changed

+539
-582
lines changed

Some content is hidden

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

128 files changed

+539
-582
lines changed
File renamed without changes.

packages/core/.env.test .env.test

File renamed without changes.

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ embedding-cache.json
88
.DS_Store
99

1010
dist/
11+
# Allow models directory but ignore model files
12+
models/*.gguf
1113

1214
cookies.json
1315

package.json

+5
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,10 @@
3131
},
3232
"engines": {
3333
"node": ">=22"
34+
},
35+
"dependencies": {
36+
"ollama-ai-provider": "^0.16.1",
37+
"optional": "^0.1.4",
38+
"sharp": "^0.33.5"
3439
}
3540
}

packages/adapter-sqlite/package.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "@ai16z/adapter-sqljs",
3+
"version": "0.0.1",
4+
"main": "dist/index.js",
5+
"type": "module",
6+
"types": "dist/index.d.ts",
7+
"dependencies": {
8+
"@ai16z/eliza": "workspace:*",
9+
"tsup": "^8.3.5"
10+
},
11+
"scripts": {
12+
"build": "tsup --format esm --dts"
13+
},
14+
"peerDependencies": {
15+
"whatwg-url": "7.1.0"
16+
}
17+
}

packages/core/src/adapters/sqlite.ts packages/adapter-sqlite/src/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { v4 } from "uuid";
2-
import { load } from "./sqlite/sqlite_vec.ts";
2+
import { load } from "./sqlite_vec.ts";
33

4-
import { DatabaseAdapter } from "../core/database.ts";
4+
import { DatabaseAdapter } from "@ai16z/eliza/core/database.ts";
55
import {
66
Account,
77
Actor,
@@ -11,12 +11,12 @@ import {
1111
type Relationship,
1212
type UUID,
1313
Participant,
14-
} from "../core/types.ts";
14+
} from "@ai16z/eliza/core/types.ts";
1515

16-
import { sqliteTables } from "./sqlite/sqliteTables.ts";
16+
import { sqliteTables } from "./sqliteTables.ts";
1717

1818
import { Database } from "better-sqlite3";
19-
import { embeddingZeroVector } from "../core/memory.ts";
19+
import { embeddingZeroVector } from "@ai16z/eliza/core/memory.ts";
2020

2121
export class SqliteDatabaseAdapter extends DatabaseAdapter {
2222
async getRoom(roomId: UUID): Promise<UUID | null> {

packages/core/src/adapters/sqlite/sqlite_vec.ts packages/adapter-sqlite/src/sqlite_vec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as sqliteVec from "sqlite-vec";
22
import { Database } from "better-sqlite3";
3-
import { elizaLogger } from "../../index.ts";
3+
import { elizaLogger } from "../../core/src/index.ts";
44

55
// Loads the sqlite-vec extensions into the provided SQLite database
66
export function loadVecExtensions(db: Database): void {

packages/adapter-sqljs/package.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "@ai16z/adapter-sqlite",
3+
"version": "0.0.1",
4+
"main": "dist/index.js",
5+
"type": "module",
6+
"types": "dist/index.d.ts",
7+
"dependencies": {
8+
"@ai16z/eliza": "workspace:*",
9+
"tsup": "^8.3.5"
10+
},
11+
"scripts": {
12+
"build": "tsup --format esm --dts"
13+
},
14+
"peerDependencies": {
15+
"whatwg-url": "7.1.0"
16+
}
17+
}
+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
export const sqliteTables = `
2+
PRAGMA foreign_keys=OFF;
3+
BEGIN TRANSACTION;
4+
5+
-- Table: accounts
6+
CREATE TABLE IF NOT EXISTS "accounts" (
7+
"id" TEXT PRIMARY KEY,
8+
"createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
9+
"name" TEXT,
10+
"username" TEXT,
11+
"email" TEXT NOT NULL,
12+
"avatarUrl" TEXT,
13+
"details" TEXT DEFAULT '{}' CHECK(json_valid("details")) -- Ensuring details is a valid JSON field
14+
);
15+
16+
-- Table: memories
17+
CREATE TABLE IF NOT EXISTS "memories" (
18+
"id" TEXT PRIMARY KEY,
19+
"type" TEXT NOT NULL,
20+
"createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
21+
"content" TEXT NOT NULL,
22+
"embedding" BLOB NOT NULL, -- TODO: EMBEDDING ARRAY, CONVERT TO BEST FORMAT FOR SQLITE-VSS (JSON?)
23+
"userId" TEXT,
24+
"roomId" TEXT,
25+
"agentId" TEXT,
26+
"unique" INTEGER DEFAULT 1 NOT NULL,
27+
FOREIGN KEY ("userId") REFERENCES "accounts"("id"),
28+
FOREIGN KEY ("roomId") REFERENCES "rooms"("id"),
29+
FOREIGN KEY ("agentId") REFERENCES "accounts"("id")
30+
);
31+
32+
-- Table: goals
33+
CREATE TABLE IF NOT EXISTS "goals" (
34+
"id" TEXT PRIMARY KEY,
35+
"createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
36+
"userId" TEXT,
37+
"name" TEXT,
38+
"status" TEXT,
39+
"description" TEXT,
40+
"roomId" TEXT,
41+
"objectives" TEXT DEFAULT '[]' NOT NULL CHECK(json_valid("objectives")) -- Ensuring objectives is a valid JSON array
42+
);
43+
44+
-- Table: logs
45+
CREATE TABLE IF NOT EXISTS "logs" (
46+
"id" TEXT PRIMARY KEY,
47+
"createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
48+
"userId" TEXT NOT NULL,
49+
"body" TEXT NOT NULL,
50+
"type" TEXT NOT NULL,
51+
"roomId" TEXT NOT NULL
52+
);
53+
54+
-- Table: participants
55+
CREATE TABLE IF NOT EXISTS "participants" (
56+
"createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
57+
"userId" TEXT,
58+
"roomId" TEXT,
59+
"userState" TEXT,
60+
"id" TEXT PRIMARY KEY,
61+
"last_message_read" TEXT,
62+
FOREIGN KEY ("userId") REFERENCES "accounts"("id"),
63+
FOREIGN KEY ("roomId") REFERENCES "rooms"("id")
64+
);
65+
66+
-- Table: relationships
67+
CREATE TABLE IF NOT EXISTS "relationships" (
68+
"createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
69+
"userA" TEXT NOT NULL,
70+
"userB" TEXT NOT NULL,
71+
"status" "text",
72+
"id" TEXT PRIMARY KEY,
73+
"userId" TEXT NOT NULL,
74+
FOREIGN KEY ("userA") REFERENCES "accounts"("id"),
75+
FOREIGN KEY ("userB") REFERENCES "accounts"("id"),
76+
FOREIGN KEY ("userId") REFERENCES "accounts"("id")
77+
);
78+
79+
-- Table: rooms
80+
CREATE TABLE IF NOT EXISTS "rooms" (
81+
"id" TEXT PRIMARY KEY,
82+
"createdAt" TIMESTAMP DEFAULT CURRENT_TIMESTAMP
83+
);
84+
85+
-- Index: relationships_id_key
86+
CREATE UNIQUE INDEX IF NOT EXISTS "relationships_id_key" ON "relationships" ("id");
87+
88+
-- Index: memories_id_key
89+
CREATE UNIQUE INDEX IF NOT EXISTS "memories_id_key" ON "memories" ("id");
90+
91+
-- Index: participants_id_key
92+
CREATE UNIQUE INDEX IF NOT EXISTS "participants_id_key" ON "participants" ("id");
93+
94+
COMMIT;`;

packages/core/src/adapters/sqljs.ts packages/adapter-sqljs/src/sqljs.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { v4 } from "uuid";
22

3-
import { DatabaseAdapter } from "../core/database.ts";
3+
import { DatabaseAdapter } from "@ai16z/elizacore/src/core/database.ts";
44
import {
55
Account,
66
Actor,
@@ -10,9 +10,9 @@ import {
1010
type Relationship,
1111
type UUID,
1212
Participant,
13-
} from "../core/types.ts";
14-
import { sqliteTables } from "./sqlite/sqliteTables.ts";
15-
import { Database } from "./sqljs/types.ts";
13+
} from "../../core/src/core/types.ts";
14+
import { sqliteTables } from "../../adapter-sqlite/src/sqliteTables.ts";
15+
import { Database } from "./types"
1616

1717
export class SqlJsDatabaseAdapter extends DatabaseAdapter {
1818
async getRoom(roomId: UUID): Promise<UUID | null> {
File renamed without changes.

packages/core/src/cli/index.ts packages/agent/src/cli/index.ts

+9-21
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ export * from "./config.ts";
33
import fs from "fs";
44
import yargs from "yargs";
55
import * as Action from "../actions/index.ts";
6-
import { defaultActions } from "../core/actions.ts";
7-
import { defaultCharacter } from "../core/defaultCharacter.ts";
8-
import { AgentRuntime } from "../core/runtime.ts";
9-
import settings from "../core/settings.ts";
10-
import { Character, IAgentRuntime, ModelProvider } from "../core/types.ts";
11-
import { elizaLogger } from "../index.ts";
12-
import * as Provider from "../providers/index.ts";
13-
import { Arguments } from "../types/index.ts";
6+
import { defaultActions } from "../../../core/src/core/actions.ts";
7+
import { defaultCharacter } from "../../../core/src/core/defaultCharacter.ts";
8+
import { AgentRuntime } from "../../../core/src/core/runtime.ts";
9+
import settings from "../../../core/src/core/settings.ts";
10+
import { Character, IAgentRuntime, ModelProvider } from "../../../core/src/core/types.ts";
11+
import { elizaLogger } from "../../../core/src/index.ts";
12+
import * as Provider from "../../../core/src/providers/index.ts";
1413
import { loadActionConfigs, loadCustomActions } from "./config.ts";
1514

1615
export const wait = (minTime: number = 1000, maxTime: number = 3000) => {
@@ -19,7 +18,7 @@ export const wait = (minTime: number = 1000, maxTime: number = 3000) => {
1918
return new Promise((resolve) => setTimeout(resolve, waitTime));
2019
};
2120

22-
export function parseArguments(): Arguments {
21+
export function parseArguments() {
2322
try {
2423
return yargs(process.argv.slice(2))
2524
.option("character", {
@@ -36,7 +35,7 @@ export function parseArguments(): Arguments {
3635
description: "Enable Telegram client",
3736
default: false,
3837
})
39-
.parseSync() as Arguments;
38+
.parseSync();
4039
} catch (error) {
4140
console.error("Error parsing arguments:", error);
4241
return {};
@@ -131,8 +130,6 @@ export async function createAgentRuntime(
131130
const actionConfigs = loadActionConfigs(configPath);
132131
const customActions = await loadCustomActions(actionConfigs);
133132

134-
console.log("Creating runtime for character", character.name);
135-
136133
return new AgentRuntime({
137134
databaseAdapter: db,
138135
token,
@@ -141,15 +138,6 @@ export async function createAgentRuntime(
141138
character,
142139
providers: [Provider.timeProvider, Provider.boredomProvider],
143140
actions: [
144-
// Default actions
145-
...defaultActions,
146-
147-
// Custom actions
148-
Action.followRoom,
149-
Action.unfollowRoom,
150-
Action.unmuteRoom,
151-
Action.muteRoom,
152-
153141
// imported from elizaConfig.yaml
154142
...customActions,
155143
],

packages/agent/tsconfig.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
{
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "dist"
4+
"outDir": "dist",
5+
"rootDir": ".",
6+
"module": "ESNext",
7+
"moduleResolution": "Bundler",
8+
"types": ["node"]
59
},
6-
"include": ["."]
7-
}
10+
"include": ["src"]
11+
}

packages/core/elizaConfig.example.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Load custom actions from the actions directory
22

3-
# Close this into a elizaConfig.yaml file that is ignored by git
3+
# Clone this into a elizaConfig.yaml file that is ignored by git
44

55
# Paths are relative to the core/src directory
66

packages/core/src/core/actions.ts packages/core/src/actions.ts

-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import { names, uniqueNamesGenerator } from "unique-names-generator";
22
import { Action, ActionExample } from "./types.ts";
33

4-
import * as DefaultActions from "../actions/index.ts";
5-
6-
export const defaultActions: Action[] = [
7-
DefaultActions.ignore,
8-
DefaultActions.none,
9-
];
10-
114
/**
125
* Composes a set of example conversations based on provided actions and a specified count.
136
* It randomly selects examples from the provided actions and formats them with generated names.

packages/core/src/cli/config.ts

-46
This file was deleted.
File renamed without changes.

packages/core/src/core/index.ts

-19
This file was deleted.

packages/core/src/core/settings.ts

-6
This file was deleted.
File renamed without changes.

packages/core/src/core/defaultCharacter.ts packages/core/src/defaultCharacter.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { Character, ModelProvider } from "./types.ts";
1+
import { Character, ModelProvider, Clients } from "./types.ts";
22

33
export const defaultCharacter: Character = {
44
name: "Eliza",
55
plugins: [],
66
clients: [],
77
modelProvider: ModelProvider.LLAMALOCAL,
88
settings: {
9-
secrets: {},
9+
secrets: {
10+
},
1011
voice: {
1112
model: "en_US-hfc_female-medium",
1213
},
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)