1.0.8 • Published 5 months ago

@elizaos/core v1.0.8

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

@elizaos/core

Overview

The @elizaos/core package provides a robust foundation for building AI agents with dynamic interaction capabilities. It enables agents to manage entities, memories, and context, and to interact with external systems, going beyond simple message responses to handle complex scenarios and execute tasks effectively.

Key Features

  • AgentRuntime: Central orchestrator for managing agent lifecycle, plugins, and interactions.
  • Actions: Define tasks the agent can perform, with validation and execution logic.
  • Providers: Supply real-time data and context to the agent, enabling interaction with dynamic environments and external APIs.
  • Evaluators: Process conversation data to extract insights, build long-term memory, and maintain contextual awareness.
  • Plugin System: Extensible architecture allowing for modular addition of functionalities.
  • Entity and Memory Management: Core support for tracking entities and their associated information.

Installation

  1. Add @elizaos/core to your agent/package.json dependencies:

    {
      "dependencies": {
        "@elizaos/core": "workspace:*"
      }
    }
  2. Navigate to your agent/ directory.

  3. Install dependencies:
    bun install
  4. Build your project:
    bun run build

Configuration

The following environment variables are used by @elizaos/core. Configure them in a .env file at your project root.

  • LOG_LEVEL: Logging verbosity (e.g., 'debug', 'info', 'error').
  • LOG_DIAGNOSTIC: Enable/disable diagnostic logging (true/false).
  • LOG_JSON_FORMAT: Output logs in JSON format (true/false).
  • DEFAULT_LOG_LEVEL: Default log level if not in debug mode.
  • SECRET_SALT: Secret salt for encryption purposes.
  • SENTRY_DSN: Sentry DSN for error reporting.
  • SENTRY_ENVIRONMENT: Sentry deployment environment (e.g., 'production', 'staging').
  • SENTRY_TRACES_SAMPLE_RATE: Sentry performance tracing sample rate (0.0 - 1.0).
  • SENTRY_SEND_DEFAULT_PII: Send Personally Identifiable Information to Sentry (true/false).

Example .env:

LOG_LEVEL=debug
LOG_DIAGNOSTIC=true
LOG_JSON_FORMAT=false
DEFAULT_LOG_LEVEL=info
SECRET_SALT=yourSecretSaltHere
SENTRY_DSN=yourSentryDsnHere
SENTRY_ENVIRONMENT=development
SENTRY_TRACES_SAMPLE_RATE=1.0
SENTRY_SEND_DEFAULT_PII=true

Note: Add your .env file to .gitignore to protect sensitive information.

Core Architecture

@elizaos/core is built around a few key concepts that work together within the AgentRuntime.

AgentRuntime

The AgentRuntime is the heart of the system. It manages the agent's lifecycle, loads plugins, orchestrates interactions, and provides a central point for actions, providers, and evaluators to operate. It's typically initialized with a set of plugins, including the corePlugin which provides foundational capabilities.

Actions

Actions define specific tasks or capabilities the agent can perform. Each action typically includes:

  • A unique name.
  • A description explaining its purpose and when it should be triggered.
  • A validate function to determine if the action is applicable in a given context.
  • A handler function that executes the action's logic.

Actions enable the agent to respond intelligently and perform operations based on user input or internal triggers.

Providers

Providers are responsible for supplying data and context to the AgentRuntime and its components. They can:

  • Fetch data from external APIs or databases.
  • Provide real-time information about the environment.
  • Offer access to external services or tools.

This allows the agent to operate with up-to-date and relevant information.

Evaluators

Evaluators analyze conversation data and other inputs to extract meaningful information, build the agent's memory, and maintain contextual awareness. They help the agent:

  • Understand user intent.
  • Extract facts and relationships.
  • Reflect on past interactions to improve future responses.
  • Update the agent's knowledge base.

Getting Started

Initializing with corePlugin

The corePlugin bundles essential actions, providers, and evaluators from @elizaos/core. To use it, add it to the AgentRuntime during initialization:

import { AgentRuntime, corePlugin } from '@elizaos/core';

const agentRuntime = new AgentRuntime({
  plugins: [
    corePlugin,
    // You can add other custom or third-party plugins here
  ],
  // Other AgentRuntime configurations can be specified here
});

// After initialization, agentRuntime is ready to be used.
// You should see console messages like "✓ Registering action: <plugin actions>"
// indicating successful plugin registration.

Example: Defining a Custom Action (Conceptual)

While corePlugin provides many actions, you might need to define custom actions for specific agent behaviors. Here's a conceptual outline:

// myCustomAction.ts
// (This is a simplified conceptual example)

export const myCustomAction = {
  name: 'customGreet',
  description: 'Greets a user in a special way.',
  validate: async ({ context }) => {
    // Logic to determine if this action should run
    // e.g., return context.message.text.includes('special hello');
    return true; // Placeholder
  },
  handler: async ({ runtime, context }) => {
    // Logic to execute the action
    // e.g., runtime.sendMessage(context.roomId, "A very special hello to you!");
    console.log('Custom Greet action executed!');
    return { success: true, message: 'Custom greeting sent.' };
  },
};

// Then, this action would be registered with the AgentRuntime, typically via a custom plugin.

For detailed instructions on creating and registering plugins and actions, refer to the specific documentation or examples within the codebase.

Development & Testing

Running Tests

The @elizaos/core package uses Vitest for testing.

  1. Prerequisites:

    • Ensure bun is installed (npm install -g bun).
    • Environment variables in .env (as described in Configuration) are generally not required for most core tests but might be for specific integration tests if any.
  2. Setup:

    • Navigate to the packages/core directory: cd packages/core
    • Install dependencies: bun install
  3. Execute Tests:

    bun test

    Test results will be displayed in the terminal.

TODO Items

The following improvements and features are planned for @elizaos/core:

  • Feature: Add ability for plugins to register their sources (Context: Exporting a default sendMessageAction).
  • Enhancement: Improve formatting of posts (Context: Returning formatted posts joined by a newline).
  • Bug: Resolve server ID creation/retrieval issues (Context: Creating a room with specific world, name, and server IDs).
  • Enhancement: Refactor message sending logic to an ensureConnection approach (Context: Sending messages to room participants).

Troubleshooting & FAQ

Common Issues

  • AgentRuntime not responding to triggers:

    • Cause: Improperly defined action validate functions or handlers. Trigger conditions might not be met.
    • Solution: Verify validate functions correctly identify trigger conditions. Ensure handler functions execute as intended. Check console logs for errors during validation/handling.
  • Provider data is outdated/incorrect:

    • Cause: Issues with external data source integration or API failures.
    • Solution: Check API connections and ensure the provider's data fetching logic is accurate. Review network configurations if needed.
  • Evaluator fails to maintain context:

    • Cause: Evaluator not capturing necessary facts/relationships correctly.
    • Solution: Review evaluator configuration. Ensure it uses correct data from AgentRuntime and is updated with the latest configuration for accurate context.

Frequently Asked Questions

  • Q: How do I define and use a new Action?

    • A: Define an action object with name, description, validate, and handler functions. Integrate it into AgentRuntime usually by creating a plugin that registers the action. Ensure the action's name and description clearly align with its task for proper triggering.
  • Q: My action is registered, but the agent is not calling it.

    • A: Double-check the action's name and description for clarity and relevance to the triggering conditions. Verify that the validate function correctly returns true (or a truthy value indicating applicability) under the desired conditions. Inspect logs for any errors or warnings related to your action.
  • Q: Can Providers access external API data?

    • A: Yes, Providers are designed to interact with external systems, including fetching data from external APIs. This enables the agent to use real-time, dynamic context.
  • Q: How do I extend the agent's evaluation capabilities?

    • A: Implement custom evaluators and integrate them with AgentRuntime (typically via a plugin). These can be tailored to extract specific information, enhancing the agent's memory and contextual understanding.
  • Q: How can I create a mock environment for testing?

    • A: The package may include mock adapters (e.g., MockDatabaseAdapter if it's part of core utilities) that simulate interactions (like database connections) without actual external dependencies, facilitating controlled testing.

Debugging Tips

  • Utilize console logs (LOG_LEVEL=debug) for detailed error messages and execution flow during action validation and handler execution.
  • Use mock classes/adapters where available to simulate environments and isolate functions for testing specific behaviors.
  • Ensure AgentRuntime is loaded with the correct configurations and plugins.

intern-client-twitter@toddli/plugin-trustgo@tribesxyz/ayaos@vdecentralised/plugin-discourse@vdecentralised/plugin-snapshot@gritlab/client-directplugin-chomp-marvinplugin-flowentsplugin-memeooorrplugin-internplugin-payaiplugin-pool-checkersolana_auto_refund_for_eliza@glacier-network/elizaos-adapter@elizaos/core-plugin-v2@elizaos/plugin-0g@elizaos/plugin-0x@elizaos/plugin-3d-generation@elizaos/plugin-abstract@elizaos/plugin-agentkit@elizaos/plugin-akash@elizaos/plugin-allora@elizaos/plugin-ankr@elizaos/plugin-anthropic@elizaos/plugin-anyone@elizaos/plugin-apro@elizaos/plugin-aptos@elizaos/plugin-arbitrage@elizaos/plugin-arthera@elizaos/plugin-asterai@elizaos/plugin-autonome@elizaos/plugin-avail@elizaos/plugin-avalanche@elizaos/plugin-b2@elizaos/plugin-binance@elizaos/plugin-birdeye@elizaos/plugin-bittensor@elizaos/plugin-bnb@elizaos/plugin-bootstrap@elizaos/plugin-browser@elizaos/plugin-chainbase@elizaos/plugin-coinbase@elizaos/plugin-coingecko@elizaos/plugin-coinmarketcap@elizaos/plugin-conflux@elizaos/plugin-cosmos@elizaos/plugin-cronos@elizaos/plugin-cronoszkevm@elizaos/plugin-dcap@elizaos/plugin-depin@elizaos/plugin-desk-exchange@elizaos/plugin-devin@elizaos/plugin-dexscreener@elizaos/plugin-di@elizaos/plugin-discord@elizaos/plugin-dkg@elizaos/plugin-dummy-services@elizaos/plugin-echochambers@elizaos/plugin-edwin@elizaos/plugin-elevenlabs@elizaos/plugin-email@elizaos/plugin-email-automation@elizaos/plugin-ethstorage@elizaos/plugin-evm@elizaos/plugin-farcaster@elizaos/plugin-flow@elizaos/plugin-football@elizaos/plugin-form@elizaos/plugin-fuel@elizaos/plugin-gelato@elizaos/plugin-genlayer@elizaos/plugin-giphy@elizaos/plugin-gitbook@elizaos/plugin-gitcoin-passport@elizaos/plugin-goat@elizaos/plugin-goplus@elizaos/plugin-groq@elizaos/plugin-holdstation@elizaos/plugin-hyperbolic@elizaos/project-starter@elizaos/plugin-router-nitro@everimbaq/plugin-tee@everimbaq/client-direct@everimbaq/client-twitter@evmagikit/plugin-holoworld@fleek-platform/eliza-plugin-mcp@elizacn/plugin-mcp@elizacn/plugin-polkadot@elizacn/plugin-vara@elizaos/adapter-mongodb@elizaos/adapter-pglite@elizaos/adapter-postgres@elizaos/adapter-qdrant@elizaos/adapter-redis@elizaos/adapter-sqlite@elizaos/adapter-sqljs@elizaos/adapter-supabase@elizaos/agent@elizaos/cli@elizaos/client-alexa
1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago

1.0.0-beta.76

5 months ago

1.0.0-beta.75

5 months ago

1.0.0-beta.74

5 months ago

1.0.0-beta.73

5 months ago

1.0.0-beta.72

5 months ago

1.0.0-beta.71

5 months ago

1.0.0-beta.70

5 months ago

1.0.0-beta.69

5 months ago

1.0.0-beta.68

5 months ago

1.0.0-beta.67

5 months ago

1.0.0-beta.61

5 months ago

1.0.0-beta.60

5 months ago

1.0.0-beta.59

5 months ago

1.0.0-beta.58

5 months ago

1.0.0-beta.57

6 months ago

1.0.0-beta.56

6 months ago

1.0.0-beta.55

6 months ago

1.0.0-beta.53

6 months ago

1.0.0-beta.52

6 months ago

1.0.0-beta.51

6 months ago

1.0.0-beta.50

6 months ago

1.0.0-beta.49

6 months ago

1.0.0-beta.48

6 months ago

1.0.0-beta.47

6 months ago

1.0.0-beta.46

6 months ago

1.0.0-beta.45

6 months ago

1.0.0-beta.44

6 months ago

1.0.0-beta.43

6 months ago

1.0.0-beta.42

6 months ago

1.0.0-beta.41

6 months ago

1.0.0-beta.40

6 months ago

1.0.0-beta.38

6 months ago

1.0.0-beta.37

6 months ago

1.0.0-beta.36

6 months ago

1.0.0-beta.35

6 months ago

1.0.0-beta.34

7 months ago

1.0.0-beta.33

7 months ago

1.0.0-beta.32

7 months ago

1.0.0-beta.29

7 months ago

1.0.0-beta.28

7 months ago

1.0.0-beta.27

7 months ago

1.0.0-beta.26

7 months ago

1.0.0-beta.25

7 months ago

1.0.0-beta.24

7 months ago

1.0.0-beta.23

7 months ago

1.0.0-beta.22

7 months ago

1.0.0-beta.21

7 months ago

1.0.0-beta.20

7 months ago

1.0.0-beta.19

7 months ago

1.0.0-beta.18

7 months ago

1.0.0-beta.17

7 months ago

1.0.0-beta.16

7 months ago

1.0.0-beta.14

7 months ago

1.0.0-beta.13

7 months ago

1.0.0-beta.12

7 months ago

1.0.0-beta.8

7 months ago

1.0.0-beta.7

8 months ago

1.0.0-beta.6

8 months ago

1.0.0-beta.5

8 months ago

1.0.0-beta.4

8 months ago

1.0.0-beta.3

8 months ago

1.0.0-beta.1

8 months ago

1.0.0-beta.0

8 months ago

1.0.0-alpha.67

8 months ago

1.0.0-alpha.66

8 months ago

1.0.0-alpha.65

8 months ago

1.0.0-alpha.64

8 months ago

1.0.0-alpha.63

8 months ago

1.0.0-alpha.62

8 months ago

1.0.0-alpha.61

8 months ago

1.0.0-alpha.60

8 months ago

1.0.0-alpha.59

8 months ago

1.0.0-alpha.58

8 months ago

1.0.0-alpha.57

8 months ago

1.0.0-alpha.56

8 months ago

1.0.0-alpha.55

8 months ago

1.0.0-alpha.54

8 months ago

1.0.0-alpha.53

8 months ago

1.0.0-alpha.52

8 months ago

1.0.0-alpha.51

8 months ago

1.0.0-alpha.50

8 months ago

1.0.0-alpha.49

8 months ago

1.0.0-alpha.48

8 months ago

1.0.0-alpha.47

8 months ago

1.0.0-alpha.46

8 months ago

1.0.0-alpha.45

8 months ago

1.0.0-alpha.44

8 months ago

1.0.0-alpha.43

8 months ago

1.0.0-alpha.42

8 months ago

1.0.0-alpha.41

8 months ago

1.0.0-alpha.40

8 months ago

1.0.0-alpha.39

8 months ago

1.0.0-alpha.38

8 months ago

1.0.0-alpha.37

8 months ago

1.0.0-alpha.36

8 months ago

1.0.0-alpha.35

8 months ago

1.0.0-alpha.34

8 months ago

1.0.0-alpha.33

8 months ago

1.0.0-alpha.32

8 months ago

1.0.0-alpha.31

8 months ago

1.0.0-alpha.30

8 months ago

1.0.0-alpha.29

8 months ago

1.0.0-alpha.28

8 months ago

1.0.0-alpha.27

8 months ago

1.0.0-alpha.26

8 months ago

1.0.0-alpha.25

8 months ago

1.0.0-alpha.24

8 months ago

1.0.0-alpha.23

8 months ago

1.0.0-alpha.22

8 months ago

1.0.0-alpha.21

8 months ago

1.0.0-alpha.20

8 months ago

1.0.0-alpha.19

8 months ago

1.0.0-alpha.18

8 months ago

1.0.0-alpha.17

8 months ago

1.0.0-alpha.16

8 months ago

1.0.0-alpha.11

8 months ago

1.0.0-alpha.7

8 months ago

1.0.0-alpha.6

8 months ago

1.0.0-alpha.5

8 months ago

1.0.0-alpha.4

8 months ago

1.0.0-alpha.3

8 months ago

1.0.0-alpha.2

8 months ago

1.0.0-alpha.1

8 months ago

1.0.0-alpha.0

8 months ago

0.25.9

8 months ago

0.25.8

8 months ago

0.25.6-alpha.1

9 months ago

0.1.9

9 months ago

0.1.8-alpha.1

9 months ago

0.1.8

10 months ago

0.1.7

10 months ago

0.1.7-alpha.2

10 months ago

0.1.7-alpha.1

11 months ago