Skip to main content

Run the CLI Agent example

Overview

To start building your own Agent, follow Quick start. If you'd like to explore the capabilities of Warden Agent Kit first, check out this guide: it demonstrates how to run our Typescript example built with the kit.

This example implements a CLI Agent that is able to do the following:

  • Process user prompts in natural language using the LangChain extension.
  • Interact with the Warden Protocol using the supported Agent Actions.
Code

The example code is available on GitHub: cli-agent

Prerequisites

Before you start, meet the following prerequisites:

1. Install packages

Clone the agent-kit repository:

git clone https://github.com/warden-protocol/agent-kit.git

Navigate to the directory with the CLI Agent example and install npm packages:

cd agent-kit/examples/typescript/cli-agent
npm install

2. Set environment variables

Set the following environment variables:

export OPENAI_API_KEY=your-openai-api-key
export PRIVATE_KEY=your-wallet-private-key

To use the request_funds tool in Step 4.1, you'll need to get a Warden faucet API token: just reach out to us in Discord. After obtaining the token, set it as an environment variable:

export FAUCET_TOKEN=your-faucet-token

This is optional: you can alternatively connect your wallet to SpaceWard and request tokens from our online faucet.

3. Run the Agent

Finally, you can run the Agent in the command line:

npm start

You'll see the following output:

Starting Agent...
Starting chat mode... Type 'exit' to end.

Prompt:

4. Prompt the Agent

4.1. Get WARD

If you have a faucet token, you can prompt the Agent to fund your wallet with WARD. Otherwise, skip this step. You can connect your wallet to SpaceWard and request tokens from our online faucet.

Type your prompt in the command line:

Prompt: get some ward

The Agent will automatically send you some WARD from the faucet, using the request_funds tool. You'll see an output like this:

-------------------
Faucet request completed: 5F0332879A6426FF6396C5BCA411FFD14426CF4E7757B757A3BAF5BEF1ACD0EC
-------------------
Your request for funds has been successfully completed. You have received the tokens. If you need anything else, feel free to ask!
-------------------

4.2. Create a Space

To access most of the Warden features, you need to create a Space first.

Type your prompt in the command line:

Prompt: create a space

The Agent will create a Space, using the create_space tool:

-------------------
Successfully created space
-------------------
A new space has been successfully created! If you need any further assistance, just let me know.
-------------------

4.3. Use other tools

After running the CLI Agent example and creating a Space, you can ask the Agent to return your Space ID, create a key, and so on.

A comprehensive list of all the available tools can be found in Agent Actions. Alternatively, you can just ask the Agent about it: what capabilities do you have?

To stop the Agent, just type exit.

tip

You can add more Agent capabilities and even incorporate a custom tool, as shown in Add Agent capabilities.

Next steps

After running the CLI Agent example, you can take the following steps: