open-agents-ai 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +307 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6792 -0
- package/package.json +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# Open Agents
|
|
2
|
+
|
|
3
|
+
**AI coding agent framework powered by open-weight models via Ollama.**
|
|
4
|
+
|
|
5
|
+
A multi-turn agentic tool-calling loop that iteratively reads code, makes changes, runs tests, and fixes failures until the task is complete — modeled after how Claude Code operates, but running entirely on local open-weight models.
|
|
6
|
+
|
|
7
|
+
## How It Works
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
You: oa "fix the null check in auth.ts"
|
|
11
|
+
|
|
12
|
+
Agent: [Turn 1] file_read(src/auth.ts)
|
|
13
|
+
[Turn 2] grep_search(pattern="null", path="src/auth.ts")
|
|
14
|
+
[Turn 3] file_edit(old_string="if (user)", new_string="if (user != null)")
|
|
15
|
+
[Turn 4] shell(command="npm test")
|
|
16
|
+
[Turn 5] task_complete(summary="Fixed null check — all tests pass")
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The agent has **11 tools** and uses them autonomously in a loop, reading errors, fixing code, and re-running validation until the task succeeds or the turn limit is reached.
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# 1. Install Ollama (https://ollama.com)
|
|
25
|
+
curl -fsSL https://ollama.com/install.sh | sh
|
|
26
|
+
|
|
27
|
+
# 2. Pull the model
|
|
28
|
+
ollama pull qwen3.5:122b
|
|
29
|
+
|
|
30
|
+
# 3. Clone and install
|
|
31
|
+
git clone https://github.com/robit-man/open-agents.git && cd open-agents
|
|
32
|
+
./scripts/install.sh
|
|
33
|
+
|
|
34
|
+
# 4. Use it
|
|
35
|
+
oa "add pagination to the users endpoint"
|
|
36
|
+
open-agents "refactor the auth module into separate files"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
### Prerequisites
|
|
42
|
+
|
|
43
|
+
- **Node.js** >= 20
|
|
44
|
+
- **pnpm** (`npm install -g pnpm`)
|
|
45
|
+
- **Ollama** ([ollama.com](https://ollama.com)) with a model that supports tool calling
|
|
46
|
+
|
|
47
|
+
### Install System-Wide
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Install to ~/.local/bin (no sudo needed)
|
|
51
|
+
./scripts/install.sh
|
|
52
|
+
|
|
53
|
+
# Install to /usr/local/bin
|
|
54
|
+
sudo ./scripts/install.sh --global
|
|
55
|
+
|
|
56
|
+
# Custom prefix
|
|
57
|
+
./scripts/install.sh --prefix ~/bin
|
|
58
|
+
|
|
59
|
+
# Uninstall
|
|
60
|
+
./scripts/install.sh --uninstall
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The installer will:
|
|
64
|
+
1. Check Node.js and pnpm versions
|
|
65
|
+
2. Install workspace dependencies
|
|
66
|
+
3. Build all packages
|
|
67
|
+
4. Create `open-agents` and `oa` symlinks
|
|
68
|
+
5. Configure an optimized Ollama model (auto-detects RAM for context window sizing)
|
|
69
|
+
|
|
70
|
+
### Manual Build
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pnpm install
|
|
74
|
+
pnpm -r build
|
|
75
|
+
pnpm -r test # 911 tests across 77 files
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Tools
|
|
79
|
+
|
|
80
|
+
The agent has access to 11 tools that it calls autonomously:
|
|
81
|
+
|
|
82
|
+
| Tool | Description |
|
|
83
|
+
|------|-------------|
|
|
84
|
+
| `file_read` | Read file contents with line numbers (supports offset/limit) |
|
|
85
|
+
| `file_write` | Create or overwrite files |
|
|
86
|
+
| `file_edit` | Precise string replacement in files (preferred over full rewrites) |
|
|
87
|
+
| `shell` | Execute any shell command (tests, builds, git, etc.) |
|
|
88
|
+
| `grep_search` | Search file contents with regex (uses ripgrep when available) |
|
|
89
|
+
| `find_files` | Find files by glob pattern |
|
|
90
|
+
| `list_directory` | List directory contents with types and sizes |
|
|
91
|
+
| `web_search` | Search the web via DuckDuckGo |
|
|
92
|
+
| `web_fetch` | Fetch and extract text from web pages (docs, MDN, w3schools) |
|
|
93
|
+
| `memory_read` | Read from persistent memory store |
|
|
94
|
+
| `memory_write` | Store patterns and solutions for future tasks |
|
|
95
|
+
|
|
96
|
+
### Self-Learning
|
|
97
|
+
|
|
98
|
+
When the agent encounters an unfamiliar API or language feature, it automatically:
|
|
99
|
+
1. Searches the web for documentation
|
|
100
|
+
2. Fetches the relevant page (w3schools.com, MDN, official docs)
|
|
101
|
+
3. Stores the learned pattern in persistent memory
|
|
102
|
+
4. Applies the knowledge to the current task
|
|
103
|
+
|
|
104
|
+
### Error Recovery
|
|
105
|
+
|
|
106
|
+
The agent follows an iterative fix loop:
|
|
107
|
+
1. Run validation (tests/build/lint)
|
|
108
|
+
2. Read the full error output
|
|
109
|
+
3. Identify the exact file, line, and failure
|
|
110
|
+
4. Fix with `file_edit`
|
|
111
|
+
5. Re-run validation
|
|
112
|
+
6. Repeat until passing
|
|
113
|
+
|
|
114
|
+
## Commands
|
|
115
|
+
|
|
116
|
+
| Command | Description |
|
|
117
|
+
|---------|-------------|
|
|
118
|
+
| `oa "task"` | Run a coding task (short alias) |
|
|
119
|
+
| `open-agents "task"` | Run a coding task |
|
|
120
|
+
| `open-agents run "task" --repo /path` | Run against a specific repo |
|
|
121
|
+
| `open-agents index /path` | Index a repository |
|
|
122
|
+
| `open-agents status` | Show system status |
|
|
123
|
+
| `open-agents config` | Show/set configuration |
|
|
124
|
+
| `open-agents serve` | Start/verify backend server |
|
|
125
|
+
| `open-agents eval` | Run evaluation suite |
|
|
126
|
+
|
|
127
|
+
### Flags
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
-m, --model <name> Model name (default: qwen3.5:122b)
|
|
131
|
+
-b, --backend-url <url> Backend URL (default: http://localhost:11434)
|
|
132
|
+
--backend <type> Backend type: ollama (default), vllm, fake
|
|
133
|
+
-r, --repo <path> Repository root (default: cwd)
|
|
134
|
+
--dry-run Show what would happen without writing files
|
|
135
|
+
--offline Skip backend health check
|
|
136
|
+
-v, --verbose Show model responses and debug info
|
|
137
|
+
--timeout-ms <ms> Per-request timeout (default: 300000)
|
|
138
|
+
-h, --help Show help
|
|
139
|
+
-V, --version Show version
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Configuration
|
|
143
|
+
|
|
144
|
+
Config priority: CLI flags > environment variables > `~/.open-agents/config.json` > defaults.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Set defaults
|
|
148
|
+
open-agents config set model qwen3.5:122b
|
|
149
|
+
open-agents config set backendUrl http://localhost:11434
|
|
150
|
+
open-agents config set backendType ollama
|
|
151
|
+
|
|
152
|
+
# Environment variables
|
|
153
|
+
export OPEN_AGENTS_MODEL=qwen3.5:122b
|
|
154
|
+
export OPEN_AGENTS_BACKEND_URL=http://localhost:11434
|
|
155
|
+
export OPEN_AGENTS_BACKEND_TYPE=ollama
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Model Support
|
|
159
|
+
|
|
160
|
+
**Primary target**: Qwen3.5-122B-A10B via Ollama (MoE, runs on 48GB+ VRAM)
|
|
161
|
+
|
|
162
|
+
The `setup-model.sh` script auto-configures the context window based on available RAM:
|
|
163
|
+
|
|
164
|
+
| RAM | Context Window |
|
|
165
|
+
|-----|---------------|
|
|
166
|
+
| 300GB+ | 128K tokens |
|
|
167
|
+
| 128GB+ | 64K tokens |
|
|
168
|
+
| 64GB+ | 32K tokens |
|
|
169
|
+
| < 64GB | 16K tokens |
|
|
170
|
+
|
|
171
|
+
### Other Models
|
|
172
|
+
|
|
173
|
+
Any model that supports tool calling via Ollama or an OpenAI-compatible API works:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Use a different Ollama model
|
|
177
|
+
oa --model qwen2.5-coder:32b "fix the bug"
|
|
178
|
+
|
|
179
|
+
# Use vLLM backend
|
|
180
|
+
oa --backend vllm --backend-url http://localhost:8000/v1 "add tests"
|
|
181
|
+
|
|
182
|
+
# Use any OpenAI-compatible API
|
|
183
|
+
oa --backend-url http://10.0.0.5:11434 "refactor auth"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Architecture
|
|
187
|
+
|
|
188
|
+
### Agentic Loop
|
|
189
|
+
|
|
190
|
+
The core is `AgenticRunner` — a multi-turn tool-calling loop:
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
User task
|
|
194
|
+
↓
|
|
195
|
+
System prompt + tools → LLM
|
|
196
|
+
↓
|
|
197
|
+
LLM returns tool_calls → Execute tools → Feed results back → LLM
|
|
198
|
+
↓ (repeat until task_complete or max turns)
|
|
199
|
+
Result: completed/incomplete, turns, tool calls, duration
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Key design decisions:
|
|
203
|
+
- **Tool-first**: The model explores via tools rather than pre-stuffed context
|
|
204
|
+
- **Iterative**: Tests, sees failures, fixes them — no need for perfect one-shot output
|
|
205
|
+
- **Context compaction**: Long conversations are compressed, preserving only recent context
|
|
206
|
+
- **Bounded**: Maximum turns, timeout, and output limits prevent runaway loops
|
|
207
|
+
- **Observable**: Every tool call and result is emitted as a real-time event
|
|
208
|
+
|
|
209
|
+
### Package Structure
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
packages/
|
|
213
|
+
orchestrator/ - AgenticRunner, OllamaAgenticBackend, RALPH loop
|
|
214
|
+
execution/ - 11 tools (file, shell, grep, web, memory), validation pipeline
|
|
215
|
+
schemas/ - Zod schemas and TypeScript types
|
|
216
|
+
backend-vllm/ - Ollama + vLLM backend clients (OpenAI-compatible)
|
|
217
|
+
memory/ - SQLite-backed persistent memory stores
|
|
218
|
+
indexer/ - Codebase scanning and symbol extraction
|
|
219
|
+
retrieval/ - Multi-stage retrieval (lexical + semantic + graph)
|
|
220
|
+
prompts/ - Prompt contracts for each agent role
|
|
221
|
+
cli/ - CLI entry point, commands, config, UI
|
|
222
|
+
|
|
223
|
+
apps/
|
|
224
|
+
api/ - Express API server
|
|
225
|
+
worker/ - Background task processor
|
|
226
|
+
|
|
227
|
+
eval/ - 8 evaluation tasks with agentic runner
|
|
228
|
+
scripts/ - install.sh, setup-model.sh, bootstrap.sh
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Evaluation
|
|
232
|
+
|
|
233
|
+
The framework includes 8 evaluation tasks that test the agent's ability to autonomously resolve coding problems:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# Run all 8 tasks with agentic tool-calling loop
|
|
237
|
+
node eval/run-agentic.mjs
|
|
238
|
+
|
|
239
|
+
# Single task
|
|
240
|
+
node eval/run-agentic.mjs 04-add-test
|
|
241
|
+
|
|
242
|
+
# Different model
|
|
243
|
+
node eval/run-agentic.mjs --model qwen2.5-coder:32b
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Results (Qwen3.5-122B)
|
|
247
|
+
|
|
248
|
+
```
|
|
249
|
+
TASK RESULT TIME TURNS TOOLS
|
|
250
|
+
01-fix-typo PASS 39.1s 4 7
|
|
251
|
+
02-add-function PASS 24.5s 4 5
|
|
252
|
+
03-fix-bug PASS 26.9s 4 5
|
|
253
|
+
04-add-test PASS 198.1s 6 8
|
|
254
|
+
05-refactor PASS 73.1s 4 5
|
|
255
|
+
06-type-error PASS 143.2s 5 7
|
|
256
|
+
07-add-endpoint PASS 40.0s 4 5
|
|
257
|
+
08-multi-file PASS 75.5s 8 13
|
|
258
|
+
|
|
259
|
+
Pass rate: 100% (8/8)
|
|
260
|
+
Total: 39 turns, 55 tool calls, ~10 minutes
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Task Descriptions
|
|
264
|
+
|
|
265
|
+
| ID | Task | Difficulty |
|
|
266
|
+
|----|------|-----------|
|
|
267
|
+
| 01 | Fix typo in function name | Easy |
|
|
268
|
+
| 02 | Add isPrime function | Easy |
|
|
269
|
+
| 03 | Fix off-by-one bug | Easy |
|
|
270
|
+
| 04 | Write comprehensive tests for untested functions | Medium |
|
|
271
|
+
| 05 | Extract functions from long method (refactor) | Medium |
|
|
272
|
+
| 06 | Fix TypeScript type errors | Medium |
|
|
273
|
+
| 07 | Add REST API endpoint | Medium |
|
|
274
|
+
| 08 | Add pagination across multiple files | Hard |
|
|
275
|
+
|
|
276
|
+
## Test Suite
|
|
277
|
+
|
|
278
|
+
```
|
|
279
|
+
Package Tests
|
|
280
|
+
─────────────────────────
|
|
281
|
+
schemas 216
|
|
282
|
+
backend-vllm 162
|
|
283
|
+
execution 136
|
|
284
|
+
indexer 94
|
|
285
|
+
cli 72
|
|
286
|
+
orchestrator 70
|
|
287
|
+
retrieval 66
|
|
288
|
+
memory 58
|
|
289
|
+
prompts 34
|
|
290
|
+
apps/api 1
|
|
291
|
+
apps/worker 2
|
|
292
|
+
─────────────────────────
|
|
293
|
+
Total 911 passing
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## Development
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
pnpm install # Install dependencies
|
|
300
|
+
pnpm -r build # Build all packages
|
|
301
|
+
pnpm -r test # Run all 911 tests
|
|
302
|
+
pnpm -r dev # Watch mode
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## License
|
|
306
|
+
|
|
307
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { parseCliArgs, routeCommand } from "./types.js";
|
|
2
|
+
export type { ParsedCliArgs, CommandName } from "./types.js";
|
|
3
|
+
export { loadConfig, mergeConfig, setConfigValue, DEFAULT_CONFIG } from "./types.js";
|
|
4
|
+
export type { AgentConfig, BackendType } from "./types.js";
|
|
5
|
+
export { Spinner } from "./types.js";
|
|
6
|
+
export { printHeader, printSuccess, printError, printWarning, printInfo, printSection, printKeyValue, printBlank, printReport, formatDuration } from "./types.js";
|