Intermediate 25 min

Project Setup

Create the Project

First, create a new directory for your agent:

mkdir todo-agent && cd todo-agent

Initialize a new Node.js project:

npm init -y

Install Dependencies

We’ll need a few packages:

  • typescript and ts-node for TypeScript support
  • dotenv for environment variables
  • openai for the OpenAI API client

Install them:

npm install typescript ts-node dotenv openai
npm install -D @types/node

Set Up TypeScript

Create a TypeScript config:

npx tsc --init

This creates a tsconfig.json. We’ll use the defaults for now.

Create Project Structure

Create these directories and files:

todo-agent/
├── src/
│   ├── agent.ts      # Main agent loop
│   ├── tools.ts      # Tool functions
│   └── memory.ts     # In-memory store
├── public/
│   └── index.html    # Simple UI (later)
├── .env              # API keys (never commit!)
├── package.json
└── tsconfig.json

Set Up Environment Variables

Create a .env file:

OPENAI_API_KEY=your-api-key-here

Important: Never commit this file to git. Add .env to your .gitignore.

Test the Setup

Create a simple test file src/test.ts:

console.log("Agent project ready!");

Run it:

npx ts-node src/test.ts

You should see: “Agent project ready!”

If you see that, you’re all set. Let’s move on to designing the agent.