Eko Framework

repository·main·Indexed 26 days ago

https://github.com/fellouai/eko

A production-ready JavaScript framework (@eko-ai/eko) for building reliable agentic workflows using natural language. It supports Node.js and browser environments, enabling complex multi-agent tasks, human-in-the-loop intervention, and integration with LLM providers including Anthropic, Google, and OpenAI. Features include specialized agents like BrowserAgent and FileAgent, Model Context Protocol (MCP) support, and tools for task orchestration and memory management.

Tokens
6.2K
Snippets
12
Records
51
Agent score
90%

What's inside Eko

  1. Quickstart: Run an agentic workflow

    main

    To use Eko, define your LLM configurations (supporting Anthropic, Google, OpenAI, and OpenAI-compatible providers), initialize your agents (e.g., BrowserAgent, FileAgent), and instantiate the Eko class. You can then run natural language commands using eko.run().

    const llms: LLMs = {
      default: {
        provider: "anthropic",
        model: "claude-sonnet-4-5-20250929",
        apiKey: "your-api-key"
      },
      gemini: {
        provider: "google",
        model: "gemini-2.5-pro",
        apiKey: "your-api-key"
      },
      openai: {
        provider: "openai",
        model: "gpt-5",
        apiKey: "your-api-key"
      },
      // OpenAI-compatible models (Qwen, Doubao, etc.)
      qwen: {
        provider: "openai",
        model: "qwen-plus",
        apiKey: "your-qwen-api-key",
        config: {
          baseURL: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
        }
      },
      doubao: {
        provider: "openai",  // Use OpenAI provider for compatibility
        model: "doubao-seed-1-6-250615",  // or other Doubao model
        apiKey: "your-volcengine-api-key",
        config: {
          baseURL: "https://ark.cn-beijing.volces.com/api/v3"  // Volcengine endpoint
        }
      }
    
    };
    
    let agents: Agent[] = [new BrowserAgent(), new FileAgent()];
    let eko = new Eko({ llms, agents });
    let result = await eko.run("Search for the latest news about Musk, summarize and save to the desktop as Musk.md");
  2. Upgrade from Eko 3.x to 4.0

    main

    When upgrading to version 4.0, follow these steps:

    1. Update dependencies: pnpm up @eko-ai/eko @eko-ai/eko-nodejs @eko-ai/eko-web @eko-ai/eko-extension.
    2. Regenerate saved workflows or exported plans to ensure they use the v3 schema and dependency graph format.
    3. Perform a clean install: rm -rf node_modules && pnpm install.
    4. Rebuild browser or desktop bundles.
    5. Update your code to use the new pause/interrupt APIs and account for parallel agent behavior.
  3. Security Best Practices for Web Environments

    main
    DO NOT use API Keys directly in browser or frontend code, as this exposes your credentials. Instead, configure a backend API proxy request using baseURL and request headers.
  4. Run the Node.js Automation example

    main

    The Node.js example uses Playwright to drive browser automation. Ensure you provide the necessary API keys as environment variables.

    cd example/nodejs
    pnpm install
    pnpm playwright install   # first time only, installs browsers
    pnpm run build
    OPENAI_API_KEY=... ANTHROPIC_API_KEY=... pnpm run start
  5. Run the Browser Extension example

    main

    To run the browser extension demo:

    1. Build the project.
    2. Load the dist directory into Chrome via chrome://extensions using 'Load unpacked' in Developer Mode.
    3. Configure your API key in the extension options.
    cd example/extension
    pnpm install
    pnpm run build
  6. Configure OpenAI/OpenRouter environment variables for Node.js automation

    main

    When using the @eko-ai/eko-nodejs example or similar Node.js automation scripts, you must configure the following environment variables to connect to an LLM provider (such as OpenRouter or OpenAI).

    OPENAI_BASE_URL=https://openrouter.ai/api/v1
    OPENAI_MODEL=anthropic/claude-sonnet-4.5
    OPENAI_API_KEY=your_api_key_here
  7. Configure Eko system settings via the Config object

    main

    The Config object defines the operational parameters for the Eko system, including limits for tokens, retries, parallel execution, and memory management. You can customize these settings to tune performance and resource usage.

    const config: Config = {
      name: "Eko",
      mode: "normal",
      platform: "mac",
      maxReactNum: 500,
      maxOutputTokens: 16000,
      maxRetryNum: 3,
      agentParallel: false,
      workflowConfirm: false,
      compressThreshold: 80,
      compressTokensThreshold: 80000,
      largeTextLength: 8000,
      fileTextMaxLength: 20000,
      maxDialogueImgFileNum: 1,
      toolResultMultimodal: true,
      parallelToolCalls: true,
      markImageMode: "draw",
      expertModeTodoLoopNum: 10,
      memoryConfig: {
        maxMessageNum: 15,
        maxInputTokens: 64000,
        enableCompression: true,
        compressionThreshold: 10,
        compressionMaxLength: 6000,
      },
    };
  8. Configure EkoConfig

    main

    The EkoConfig type defines the primary configuration object for initializing an Eko instance. It requires llms and allows for optional agents, specialized LLM lists for planning or compression, and callback handlers for streaming and human interaction.

    export type EkoConfig = {
      llms: LLMs;
      agents?: Agent[];
      planLlms?: string[];
      compressLlms?: string[];
      callback?: AgentStreamCallback & HumanCallback;
      defaultMcpClient?: IMcpClient;
      a2aClient?: IA2aClient;
    };