Installation
Eko is a JavaScript library that can be used in Browser Extension, Node.js Enviroment, and Web Enviroment. This guide covers installation and setup for different environments.
Browser Extension
In the quickstart, we have seen how to use the browser extension. Now let’s build one.
Install
There are two ways to build a browser extension using Eko.
-
Install eko dependency in the existing plugin project
Terminal window pnpm install @eko-ai/ekopnpm install @eko-ai/eko-extension -
By initializing the plugin project template installation
Terminal window # install cli (used to initialize browser extension projects)pnpm install @eko-ai/eko-cli -g# initialize projecteko-cli init my-extension-democd my-extension-demo# install dependenciespnpm install# buildpnpm run build
Usage Example
import { Eko, LLMs } from "@eko-ai/eko";import { BrowserAgent } from "@eko-ai/eko-extension";
export async function main(prompt: string) { const llms: LLMs = { default: { provider: "anthropic", model: "claude-3-7-sonnet", apiKey: "your_api_key" } }; let agents = [new BrowserAgent()]; let eko = new Eko({ llms, agents }); await eko.run(prompt);}
Initialize extension template
# install cli (used to initialize browser extension projects)pnpm install @eko-ai/eko-cli -g# initialize projecteko-cli init my-extension-democd my-extension-demo
# install dependenciespnpm install# buildpnpm run build
Node.js Environment
Eko can also be run in a Node.js environment, where it can use agents such as browsers, computers, and files. The following is an example of a browser usage:
Install
-
Install eko dependencies
Terminal window pnpm install @eko-ai/ekopnpm install @eko-ai/eko-nodejs -
Install playwright dependencies (browser automation)
Terminal window pnpm install playwrightnpx playwright install
Usage Example
import { Eko, Agent, LLMs } from "@eko-ai/eko";import { BrowserAgent, FileAgent } from "@eko-ai/eko-nodejs";
const llms: LLMs = { default: { provider: "anthropic", model: "claude-3-7-sonnet", apiKey: "your_api_key" }};
async function run() { 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 news.md"); console.log("result: ", result.result);}
run().catch(e => { console.log(e)});
Web Environment
Eko can also be directly embedded into a web page environment. In this example, Eko will automate a web page test.
Install
pnpm install @eko-ai/ekopnpm install @eko-ai/eko-web
Usage Example
import { Eko, LLMs } from "@eko-ai/eko";import { BrowserAgent } from "@eko-ai/eko-web";
export async function auto_test_case() { const llms: LLMs = { default: { provider: "anthropic", model: "claude-3-7-sonnet", apiKey: "your_api_key" } };
let agents = [new BrowserAgent()]; let eko = new Eko({ llms, agents }); const result = await eko.run("Browser automation testing with steps: 1. ..."); alert(result.result);}
Build from eko source code
Clone & Build
# clone eko projectgit clone https://github.com/FellouAI/eko.gitcd eko
# install dependenciespnpm installpnpm run build
Run examples in different environments
-
Browser extension example
Terminal window cd example/extension# Install dependenciespnpm installpnpm run build# load unpacked extensions in developer mode# 1. Open the Chrome browser's extension page.# 2. Load the built `dist` directory. -
Node.js environment example
Terminal window cd example/nodejs# Install dependenciespnpm installpnpm run build# Runpnpm run dev -
Web environment example
Terminal window cd example/web# Install dependenciespnpm installpnpm run build# Runpnpm run dev