Skip to content

Commit

Permalink
Merge branch 'v2-develop' into init-clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsayo committed Feb 11, 2025
2 parents dc9f881 + a5d7e9b commit c801a9a
Show file tree
Hide file tree
Showing 100 changed files with 1,415 additions and 806 deletions.
31 changes: 0 additions & 31 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "warn",
"noArrayIndexKey": "warn",
"noPrototypeBuiltins": "warn",
"noDuplicateObjectKeys": "warn",
"noGlobalIsNan": "warn",
"noDuplicateFontNames": "warn",
"noSelfCompare": "warn",
"noDoubleEquals": "warn",
"noImplicitAnyLet": "warn",
"noAssignInExpressions": "warn",
"noExportsInTest": "warn",
"noConstEnum": "warn",
"noEmptyInterface": "warn"
},
Expand All @@ -30,42 +26,15 @@
"noUnnecessaryContinue": "warn",
"noInnerDeclarations": "warn"
},
"style": {
"useConst": "warn",
"useTemplate": "warn",
"useImportType": "warn",
"useNodejsImportProtocol": "warn",
"noUselessElse": "warn",
"useSelfClosingElements": "warn",
"useNumberNamespace": "warn",
"noUnusedTemplateLiteral": "warn",
"noInferrableTypes": "warn",
"noNonNullAssertion": "warn",
"noParameterAssign": "warn",
"useDefaultParameterLast": "warn",
"useExponentiationOperator": "warn",
"noVar": "warn",
"useSingleVarDeclarator": "warn",
"useExportType": "warn"
},
"a11y": {
"useAltText": "warn",
"useFocusableInteractive": "warn",
"useMediaCaption": "warn",
"noSvgWithoutTitle": "warn",
"useKeyWithClickEvents": "warn"
},
"complexity": {
"noForEach": "warn",
"useOptionalChain": "warn",
"useArrowFunction": "warn",
"useFlatMap": "warn",
"useLiteralKeys": "warn",
"noBannedTypes": "warn",
"noStaticOnlyClass": "warn",
"noThisInStatic": "warn",
"noUselessConstructor": "warn",
"noUselessTernary": "warn",
"noUselessSwitchCase": "warn",
"noUselessCatch": "warn"
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"scripts": {
"format": "biome format --write .",
"cli": "bun --filter=@elizaos/cli cli",
"lint": "biome lint . --write",
"lint": "turbo run lint:fix --filter=./packages/*",
"check": "biome check --apply .",
"preinstall": "npx only-allow bun",
"build": "turbo run build --filter=./packages/core && turbo run build --filter=./packages/*",
Expand Down
6 changes: 3 additions & 3 deletions packages/agent/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
type Character,
getEnvVariable,
IAgentRuntime,
ITeeLogService,
type IAgentRuntime,
type ITeeLogService,
logger,
ServiceType,
TeeLogQuery,
type TeeLogQuery,
type UUID,
validateCharacterConfig,
validateUuid
Expand Down
3 changes: 2 additions & 1 deletion packages/agent/src/defaultCharacter.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { type Character } from "@elizaos/core";
import type { Character } from "@elizaos/core";

export const defaultCharacter: Character = {
name: "Eliza",
username: "eliza",
plugins: [
"@elizaos/plugin-anthropic",
"@elizaos/plugin-openai",
"@elizaos/plugin-local-ai",
"@elizaos/plugin-discord",
"@elizaos/plugin-node",
"@elizaos/plugin-telegram",
Expand Down
2 changes: 1 addition & 1 deletion packages/agent/src/plugins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
DbCacheAdapter,
logger,
stringToUuid,
TestSuite,
type TestSuite,
type IAgentRuntime
} from "@elizaos/core";
import { afterAll, beforeAll, describe, it } from 'vitest';
Expand Down
14 changes: 7 additions & 7 deletions packages/agent/src/reply.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
type Action,
type ActionExample,
type HandlerCallback,
type IAgentRuntime,
type Memory,
type State,
import type {
Action,
ActionExample,
HandlerCallback,
IAgentRuntime,
Memory,
State,
} from "@elizaos/core";

const replyAction = {
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/commands/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ agent
try {
// If input is a number, get agent ID from index
if (!isNaN(Number(agentIdOrIndex))) {
agentIdOrIndex = await getAgentIdFromIndex(parseInt(agentIdOrIndex))
agentIdOrIndex = await getAgentIdFromIndex(Number.parseInt(agentIdOrIndex))
}

const response = await fetch(`${AGENT_RUNTIME_URL}/agents/${agentIdOrIndex}`)
Expand Down Expand Up @@ -122,7 +122,7 @@ agent
.action(async (agentIdOrIndex) => {
try {
if (!isNaN(Number(agentIdOrIndex))) {
agentIdOrIndex = await getAgentIdFromIndex(parseInt(agentIdOrIndex))
agentIdOrIndex = await getAgentIdFromIndex(Number.parseInt(agentIdOrIndex))
}

const response = await fetch(`${AGENT_RUNTIME_URL}/agents/${agentIdOrIndex}/stop`, {
Expand All @@ -146,7 +146,7 @@ agent
.action(async (agentIdOrIndex) => {
try {
if (!isNaN(Number(agentIdOrIndex))) {
agentIdOrIndex = await getAgentIdFromIndex(parseInt(agentIdOrIndex))
agentIdOrIndex = await getAgentIdFromIndex(Number.parseInt(agentIdOrIndex))
}

const response = await fetch(`${AGENT_RUNTIME_URL}/agents/${agentIdOrIndex}`, {
Expand All @@ -171,7 +171,7 @@ agent
.action(async (agentIdOrIndex, configPath) => {
try {
if (!isNaN(Number(agentIdOrIndex))) {
agentIdOrIndex = await getAgentIdFromIndex(parseInt(agentIdOrIndex))
agentIdOrIndex = await getAgentIdFromIndex(Number.parseInt(agentIdOrIndex))
}

const config = JSON.parse(fs.readFileSync(configPath, 'utf8'))
Expand Down
2 changes: 1 addition & 1 deletion packages/core/__tests__/knowledge.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import knowledge from "../src/knowledge";
import type { AgentRuntime } from "../src/runtime";
import { type Memory } from "../src/types";
import type { Memory } from "../src/types";

vi.mock("../generation", () => ({
splitChunks: vi.fn().mockImplementation(async (text) => [text]),
Expand Down
2 changes: 1 addition & 1 deletion packages/core/__tests__/mockCharacter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Character } from "@elizaos/core";
import type { Character } from "@elizaos/core";

export const mockCharacter: Character = {
name: "Eliza",
Expand Down
12 changes: 6 additions & 6 deletions packages/core/__tests__/runtime.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { beforeEach, describe, expect, it, test, vi } from "vitest";
import { AgentRuntime } from "../src/runtime";
import {
type Action,
type IDatabaseAdapter,
type IMemoryManager,
type Memory,
type UUID
import type {
Action,
IDatabaseAdapter,
IMemoryManager,
Memory,
UUID
} from "../src/types";

// Mock dependencies with minimal implementations
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/knowledge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ async function get(
runtime: AgentRuntime,
message: Memory
): Promise<KnowledgeItem[]> {
console.log("get", message);
// Add validation for message
if (!message?.content?.text) {
logger.warn("Invalid message for knowledge query:", {
Expand Down Expand Up @@ -69,6 +70,7 @@ async function set(
chunkSize = 512,
bleed = 20
) {
console.log("set", item);
const embedding = await runtime.useModel(ModelClass.TEXT_EMBEDDING, null);
await runtime.documentsManager.createMemory({
id: item.id,
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class MemoryManager implements IMemoryManager {
* @throws Error if the memory content is empty
*/
async addEmbeddingToMemory(memory: Memory): Promise<Memory> {
console.log("addEmbeddingToMemory", memory);
// Return early if embedding already exists
if (memory.embedding) {
return memory;
Expand Down Expand Up @@ -173,6 +174,7 @@ export class MemoryManager implements IMemoryManager {
*/
async createMemory(memory: Memory, unique = false): Promise<void> {
// TODO: check memory.agentId == this.runtime.agentId
console.log("createMemory", memory);

const existingMessage =
await this.runtime.databaseAdapter.getMemoryById(memory.id);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ import {
type Provider,
type State,
type UUID,
ServiceType,
Service
type ServiceType,
type Service
} from "./types.ts";
import { stringToUuid } from "./uuid.ts";

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/test_resources/createRuntime.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SqliteDatabaseAdapter, loadVecExtensions } from "@elizaos-plugins/sqlite";
import type { DatabaseAdapter } from "../database.ts";
import { AgentRuntime } from "../runtime.ts";
import { type Action, type Evaluator, type Provider } from "../types.ts";
import type { Action, Evaluator, Provider } from "../types.ts";
import {
zeroUuid
} from "./constants.ts";
Expand Down
25 changes: 25 additions & 0 deletions packages/plugin-anthropic/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"extends": ["../../biome.json"],
"organizeImports": {
"enabled": false
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4,
"lineWidth": 100
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
},
"files": {
"ignore": [
"dist/**/*",
"extra/**/*",
"node_modules/**/*"
]
}
}
2 changes: 1 addition & 1 deletion packages/plugin-anthropic/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { anthropic } from "@ai-sdk/anthropic";
import type { Plugin } from "@elizaos/core";
import {
GenerateTextParams,
type GenerateTextParams,
ModelClass
} from "@elizaos/core";
import { generateText } from "ai";
Expand Down
25 changes: 25 additions & 0 deletions packages/plugin-bootstrap/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"extends": ["../../biome.json"],
"organizeImports": {
"enabled": false
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4,
"lineWidth": 100
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
},
"files": {
"ignore": [
"dist/**/*",
"extra/**/*",
"node_modules/**/*"
]
}
}
4 changes: 3 additions & 1 deletion packages/plugin-bootstrap/src/providers/facts.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Memory, Provider, State } from "@elizaos/core";
import {
formatMessages,
IAgentRuntime,
type IAgentRuntime,
MemoryManager,
ModelClass
} from "@elizaos/core";
Expand All @@ -10,6 +10,8 @@ import { formatFacts } from "../evaluators/fact.ts";
const factsProvider: Provider = {
get: async (runtime: IAgentRuntime, message: Memory, state?: State) => {
const recentMessagesData = state?.recentMessagesData?.slice(-10);
console.log("get", message);


const recentMessages = formatMessages({
messages: recentMessagesData,
Expand Down
25 changes: 25 additions & 0 deletions packages/plugin-discord/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"extends": ["../../biome.json"],
"organizeImports": {
"enabled": false
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4,
"lineWidth": 100
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
},
"files": {
"ignore": [
"dist/**/*",
"extra/**/*",
"node_modules/**/*"
]
}
}
12 changes: 6 additions & 6 deletions packages/plugin-discord/src/actions/reply.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
type Action,
type HandlerCallback,
type IAgentRuntime,
type Memory,
type State
import type {
Action,
HandlerCallback,
IAgentRuntime,
Memory,
State
} from "@elizaos/core";

const replyAction = {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-discord/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
logger,
stringToUuid,
TestSuite,
type TestSuite,
type Character,
type Client as ElizaClient,
type IAgentRuntime,
Expand All @@ -28,7 +28,7 @@ import { MessageManager } from "./messages.ts";
import channelStateProvider from "./providers/channelState.ts";
import voiceStateProvider from "./providers/voiceState.ts";
import reply from "./actions/reply.ts";
import { IDiscordClient } from "./types.ts";
import type { IDiscordClient } from "./types.ts";
import { VoiceManager } from "./voice.ts";

export class DiscordClient extends EventEmitter implements IDiscordClient {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-discord/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ChannelType,
type Client,
type Message as DiscordMessage,
TextChannel,
type TextChannel,
} from "discord.js";
import { AttachmentManager } from "./attachments.ts";
import {
Expand Down
Loading

0 comments on commit c801a9a

Please sign in to comment.