File: README.md
Dexter ๐ค
Dexter is an autonomous financial research agent that thinks, plans, and learns as it works. It performs analysis using task planning, self-reflection, and real-time market data. Think Claude Code, but built specifically for financial research.
Table of Contents
- ๐ Overview
- โ Prerequisites
- ๐ป How to Install
- ๐ How to Run
- ๐ How to Evaluate
- ๐ How to Debug
- ๐ฑ How to Use with WhatsApp
- ๐ค How to Contribute
- ๐ License
โ ๏ธ Disclaimer
This project is for educational, entertainment, and informational purposes only. It is not intended for real trading or investment.
- Not financial, investment, tax, or legal advice
- No guarantees of accuracy, completeness, or fitness for any purpose
- Outputs may be incorrect, incomplete, or out of date
- Creator and contributors assume no liability for any financial losses or damages
- Consult a licensed financial advisor before making investment decisions
- Past performance does not indicate future results
By using this software, you agree to use it solely for learning and informational purposes and accept all risks associated with its use.
๐ Overview
Dexter takes complex financial questions and turns them into clear, step-by-step research plans. It runs those tasks using live market data, checks its own work, and refines the results until it has a confident, data-backed answer.
Key Capabilities:
- Intelligent Task Planning: Automatically decomposes complex queries into structured research steps
- Autonomous Execution: Selects and executes the right tools to gather financial data
- Self-Validation: Checks its own work and iterates until tasks are complete
- Real-Time Financial Data: Access to income statements, balance sheets, and cash flow statements
- Safety Features: Built-in loop detection and step limits to prevent runaway execution
โ Prerequisites
- Bun runtime (v1.0 or higher)
- OpenAI API key (get here)
- Financial Datasets API key (get here)
- Exa API key (get here) - optional, for web search
Installing Bun
If you don't have Bun installed, you can install it using curl:
macOS/Linux:
curl -fsSL https://bun.com/install | bashWindows:
powershell -c "irm bun.sh/install.ps1|iex"After installation, restart your terminal and verify Bun is installed:
bun --version๐ป How to Install
- Clone the repository:
git clone https://github.com/virattt/dexter.git
cd dexter- Install dependencies with Bun:
bun install- Set up your environment variables:
# Copy the example environment file
cp env.example .env
# Edit .env and add your API keys (if using cloud providers)
# OPENAI_API_KEY=your-openai-api-key
# ANTHROPIC_API_KEY=your-anthropic-api-key (optional)
# GOOGLE_API_KEY=your-google-api-key (optional)
# XAI_API_KEY=your-xai-api-key (optional)
# OPENROUTER_API_KEY=your-openrouter-api-key (optional)
# Institutional-grade market data for agents
# FINANCIAL_DATASETS_API_KEY=your-financial-datasets-api-key
# (Optional) If using Ollama locally
# OLLAMA_BASE_URL=http://127.0.0.1:11434
# Web Search (Exa preferred, Tavily fallback)
# EXASEARCH_API_KEY=your-exa-api-key
# TAVILY_API_KEY=your-tavily-api-key๐ How to Run
Run Dexter in interactive mode:
bun startOr with watch mode for development:
bun dev๐ How to Evaluate
Dexter includes an evaluation suite that tests the agent against a dataset of financial questions. Evals use LangSmith for tracking and an LLM-as-judge approach for scoring correctness.
Run on all questions:
bun run src/evals/run.tsRun on a random sample of data:
bun run src/evals/run.ts --sample 10The eval runner displays a real-time UI showing progress, current question, and running accuracy statistics. Results are logged to LangSmith for analysis.
๐ How to Debug
Dexter logs all tool calls to a scratchpad file for debugging and history tracking. Each query creates a new JSONL file in .dexter/scratchpad/.
Scratchpad location:
.dexter/scratchpad/
โโโ 2026-01-30-111400_9a8f10723f79.jsonl
โโโ 2026-01-30-143022_a1b2c3d4e5f6.jsonl
โโโ ...Each file contains newline-delimited JSON entries tracking:
- init: The original query
- tool_result: Each tool call with arguments, raw result, and LLM summary
- thinking: Agent reasoning steps
Example scratchpad entry:
{"type":"tool_result","timestamp":"2026-01-30T11:14:05.123Z","toolName":"get_income_statements","args":{"ticker":"AAPL","period":"annual","limit":5},"result":{...},"llmSummary":"Retrieved 5 years of Apple annual income statements showing revenue growth from $274B to $394B"}This makes it easy to inspect exactly what data the agent gathered and how it interpreted results.
๐ฑ How to Use with WhatsApp
Chat with Dexter through WhatsApp by linking your phone to the gateway. Messages you send to yourself are processed by Dexter and responses are sent back to the same chat.
Quick start:
# Link your WhatsApp account (scan QR code)
bun run gateway:login
# Start the gateway
bun run gatewayThen open WhatsApp, go to your own chat (message yourself), and ask Dexter a question.
For detailed setup instructions, configuration options, and troubleshooting, see the WhatsApp Gateway README.
๐ค How to Contribute
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
Important: Please keep your pull requests small and focused. This will make it easier to review and merge.
๐ License
This project is licensed under the MIT License.
File: src/gateway/channels/whatsapp/README.md
WhatsApp Gateway
Chat with Dexter through WhatsApp by linking your phone to the gateway. Messages you send to yourself (self-chat) are processed by Dexter and responses are sent back to the same chat.
Table of Contents
- โ Prerequisites
- ๐ How to Link WhatsApp
- ๐ How to Run
- ๐ฌ How to Chat
- โ๏ธ Configuration
- ๐ฅ Group Chat
- ๐ How to Relink
- ๐ Troubleshooting
- ๐ง Full Reset
โ Prerequisites
- Dexter installed and working (see main README)
- WhatsApp installed on your phone
- Your phone connected to the internet
๐ How to Link WhatsApp
Link your WhatsApp account to Dexter by scanning a QR code:
bun run gateway:loginThis will:
- Display a QR code in your terminal
- Open WhatsApp on your phone
- Go to Settings > Linked Devices > Link a Device
- Scan the QR code
After linking, you'll be asked how you want to use Dexter:
Option 1: Self-chat (personal phone)
Use your own WhatsApp to talk to Dexter by messaging yourself. The linked phone number is added to allowFrom and self-chat mode is activated automatically.
Option 2: Dedicated bot phone
If Dexter has its own phone number (e.g. a separate SIM), choose this option and enter the phone number(s) allowed to message it. The gateway will be configured with dmPolicy: "allowlist" so other people can DM the bot.
Credentials are saved to .dexter/credentials/whatsapp/default/.
๐ How to Run
Start the gateway to begin receiving messages:
bun run gatewayYou should see:
[whatsapp] Connected
Dexter gateway running. Press Ctrl+C to stop.The gateway will now listen for incoming WhatsApp messages and respond using Dexter.
๐ฌ How to Chat
Once the gateway is running:
- Open WhatsApp on your phone
- Go to your own chat (message yourself)
- Send a message like "What is Apple's revenue?"
- You'll see a typing indicator while Dexter processes
- Dexter's response will appear in the chat
Example conversation:
You: What was NVIDIA's revenue in 2024?
Dexter: NVIDIA's revenue for fiscal year 2024 was $60.9 billion...โ๏ธ Configuration
The gateway configuration is stored at .dexter/gateway.json. It's auto-created when you run gateway:login.
Self-chat configuration (personal phone, message yourself):
{
"gateway": {
"accountId": "default",
"logLevel": "info"
},
"channels": {
"whatsapp": {
"enabled": true,
"allowFrom": ["+1234567890"]
}
},
"bindings": []
}Bot phone configuration (dedicated Dexter phone, others message it):
{
"gateway": {
"accountId": "default",
"logLevel": "info"
},
"channels": {
"whatsapp": {
"enabled": true,
"accounts": {
"default": {
"dmPolicy": "allowlist",
"allowFrom": ["+1555YOURNUM"],
"groupPolicy": "disabled",
"groupAllowFrom": []
}
},
"allowFrom": ["+1555YOURNUM"]
}
},
"bindings": []
}Key settings:
| Setting | Description |
|---|---|
channels.whatsapp.allowFrom |
Phone numbers allowed to message Dexter (E.164 format) |
channels.whatsapp.enabled |
Enable/disable the WhatsApp channel |
accounts..dmPolicy |
DM access policy: pairing (default), allowlist, open, or disabled |
accounts..allowFrom |
Per-account allowed senders (overrides top-level allowFrom) |
gateway.logLevel |
Log verbosity: silent, error, info, debug |
๐ฅ Group Chat
Dexter can participate in WhatsApp group chats, responding only when @-mentioned.
Setup
Add group policy to your account in .dexter/gateway.json:
{
"channels": {
"whatsapp": {
"enabled": true,
"accounts": {
"default": {
"groupPolicy": "open", // "open", "allowlist", or "disabled"
"groupAllowFrom": ["*"] // no need to list individual group members
}
},
"allowFrom": ["+1234567890"] // existing DM allowlist (unrelated to groups)
}
}
}| Setting | Description |
|---|---|
groupPolicy |
"open" (any group), "allowlist" (restricted), or "disabled" (default) |
groupAllowFrom |
Which groups Dexter can participate in (["*"] for any) |
You don't need to list individual group members โ when groupPolicy is "open", Dexter will respond to @-mentions from anyone in any group it's added to.
Usage
- Add Dexter's WhatsApp number to a group
- Send messages normally โ Dexter stays silent
- @-mention Dexter (tap
@and select from the picker) to get a response - Dexter sees recent group messages for context, so it can follow the conversation
Note: You must use WhatsApp's @-mention picker (tap @ then select the contact) โ typing a phone number manually won't trigger a response.
๐ How to Relink
If you need to relink your WhatsApp (e.g., after logging out or switching phones):
- Stop the gateway (Ctrl+C)
- Delete the credentials:bash
rm -rf .dexter/credentials/whatsapp/default - Run login again:bash
bun run gateway:login - Scan the new QR code
๐ Troubleshooting
Gateway shows "Disconnected":
- Check your internet connection
- Try relinking (see above)
Messages not being received:
- Verify your phone number is in
allowFromin.dexter/gateway.json - Make sure you're messaging yourself (self-chat mode)
Debug logs:
- Check
.dexter/gateway-debug.logfor detailed logs
๐ง Full Reset
If you're experiencing persistent issues (connection problems, encryption errors, messages not sending), perform a full reset:
Stop the gateway (Ctrl+C if running)
Unlink from WhatsApp:
- Open WhatsApp on your phone
- Go to Settings > Linked Devices
- Tap on the Dexter device and select Log Out
Clear all local data:
bashrm -rf .dexter/credentials/whatsapp/default rm -rf .dexter/gateway.json rm -rf .dexter/gateway-debug.logRelink and start fresh:
bashbun run gateway:loginScan the QR code and start the gateway:
bashbun run gateway
This clears all cached credentials and encryption sessions, which resolves most connection issues.