agent-mini 0.1.0__tar.gz → 0.2.0__tar.gz

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.
Files changed (47) hide show
  1. {agent_mini-0.1.0 → agent_mini-0.2.0}/.github/workflows/publish.yml +2 -0
  2. {agent_mini-0.1.0 → agent_mini-0.2.0}/.gitignore +2 -0
  3. {agent_mini-0.1.0 → agent_mini-0.2.0}/CONTRIBUTING.md +1 -2
  4. agent_mini-0.2.0/PKG-INFO +331 -0
  5. agent_mini-0.2.0/README.md +296 -0
  6. agent_mini-0.2.0/SECURITY.md +26 -0
  7. {agent_mini-0.1.0 → agent_mini-0.2.0}/config.example.json +1 -5
  8. {agent_mini-0.1.0 → agent_mini-0.2.0}/pyproject.toml +2 -2
  9. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/__init__.py +1 -1
  10. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/cli.py +132 -79
  11. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/config.py +3 -13
  12. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/providers/__init__.py +5 -12
  13. agent_mini-0.2.0/src/agent_mini/providers/openai.py +28 -0
  14. {agent_mini-0.1.0 → agent_mini-0.2.0}/tests/test_phases.py +5 -5
  15. agent_mini-0.1.0/PKG-INFO +0 -530
  16. agent_mini-0.1.0/README.md +0 -495
  17. agent_mini-0.1.0/docs/01-openclaw-inspired-improvements.md +0 -1282
  18. agent_mini-0.1.0/docs/02-small-llm-optimization-guide.md +0 -1299
  19. agent_mini-0.1.0/src/agent_mini/providers/gemini.py +0 -257
  20. agent_mini-0.1.0/src/agent_mini/providers/github_copilot.py +0 -253
  21. {agent_mini-0.1.0 → agent_mini-0.2.0}/.github/workflows/ci.yml +0 -0
  22. {agent_mini-0.1.0 → agent_mini-0.2.0}/LICENSE +0 -0
  23. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/__main__.py +0 -0
  24. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/agent/__init__.py +0 -0
  25. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/agent/context.py +0 -0
  26. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/agent/loop.py +0 -0
  27. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/agent/memory.py +0 -0
  28. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/agent/token_estimator.py +0 -0
  29. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/agent/tools.py +0 -0
  30. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/agent/vision.py +0 -0
  31. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/bus.py +0 -0
  32. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/channels/__init__.py +0 -0
  33. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/channels/base.py +0 -0
  34. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/channels/telegram.py +0 -0
  35. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/providers/base.py +0 -0
  36. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/providers/local.py +0 -0
  37. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/providers/ollama.py +0 -0
  38. {agent_mini-0.1.0 → agent_mini-0.2.0}/src/agent_mini/sessions.py +0 -0
  39. {agent_mini-0.1.0 → agent_mini-0.2.0}/tests/__init__.py +0 -0
  40. {agent_mini-0.1.0 → agent_mini-0.2.0}/tests/test_config.py +0 -0
  41. {agent_mini-0.1.0 → agent_mini-0.2.0}/tests/test_context.py +0 -0
  42. {agent_mini-0.1.0 → agent_mini-0.2.0}/tests/test_json_repair.py +0 -0
  43. {agent_mini-0.1.0 → agent_mini-0.2.0}/tests/test_loop.py +0 -0
  44. {agent_mini-0.1.0 → agent_mini-0.2.0}/tests/test_memory.py +0 -0
  45. {agent_mini-0.1.0 → agent_mini-0.2.0}/tests/test_token_estimator.py +0 -0
  46. {agent_mini-0.1.0 → agent_mini-0.2.0}/tests/test_tools.py +0 -0
  47. {agent_mini-0.1.0 → agent_mini-0.2.0}/uv.lock +0 -0
@@ -26,3 +26,5 @@ jobs:
26
26
 
27
27
  - name: Publish to PyPI
28
28
  uses: pypa/gh-action-pypi-publish@release/v1
29
+ with:
30
+ skip-existing: true
@@ -34,3 +34,5 @@ node_modules/
34
34
  config.json
35
35
  .pytest_cache/
36
36
  .ruff_cache/
37
+
38
+ archived
@@ -86,8 +86,7 @@ src/agent_mini/
86
86
  ├── providers/
87
87
  │ ├── base.py # Provider interface + tool call parsing
88
88
  │ ├── ollama.py # Ollama provider
89
- │ ├── gemini.py # Google Gemini provider
90
- │ ├── github_copilot.py # GitHub Copilot (OAuth device flow)
89
+ │ ├── openai.py # OpenAI provider
91
90
  │ └── local.py # Any OpenAI-compatible endpoint
92
91
  └── channels/
93
92
  ├── base.py # Channel interface
@@ -0,0 +1,331 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-mini
3
+ Version: 0.2.0
4
+ Summary: Ultra-lightweight personal AI agent — shell, files, web, memory — powered by local or cloud LLMs
5
+ Project-URL: Homepage, https://github.com/mohsinkaleem/agent-mini
6
+ Project-URL: Repository, https://github.com/mohsinkaleem/agent-mini
7
+ Project-URL: Issues, https://github.com/mohsinkaleem/agent-mini/issues
8
+ Author-email: Mohsin Kaleem <mohsin.kaleem512@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: agent,ai,cli,llm,local,ollama,telegram
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: click>=8.0
24
+ Requires-Dist: httpx>=0.27
25
+ Requires-Dist: rich>=13.0
26
+ Provides-Extra: all
27
+ Requires-Dist: python-telegram-bot>=21.0; extra == 'all'
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
30
+ Requires-Dist: pytest>=8.0; extra == 'dev'
31
+ Requires-Dist: ruff>=0.4; extra == 'dev'
32
+ Provides-Extra: telegram
33
+ Requires-Dist: python-telegram-bot>=21.0; extra == 'telegram'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # Agent Mini
37
+
38
+ [![PyPI version](https://img.shields.io/pypi/v/agent-mini)](https://pypi.org/project/agent-mini/)
39
+ [![CI](https://github.com/mohsinkaleem/agent-mini/actions/workflows/ci.yml/badge.svg)](https://github.com/mohsinkaleem/agent-mini/actions/workflows/ci.yml)
40
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue)](https://www.python.org/)
41
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
42
+
43
+ A minimal, local-first AI agent you can actually understand and extend.
44
+
45
+ - **~3,000 lines of Python** — read the whole thing in an afternoon
46
+ - **Local-first** — Ollama as default, OpenAI if you want cloud, or any OpenAI-compatible server
47
+ - **Zero frameworks** — pure `httpx` + `asyncio`, no LangChain, no LiteLLM
48
+ - **Built-in tools** — shell, files, web search, persistent memory
49
+ - **Extensible** — drop a Python file in `~/.agent-mini/plugins/` and it's a tool
50
+ - **Small-model optimized** — token-aware context pruning, tool call repair, model-tier tuning
51
+
52
+ ## Quick Start
53
+
54
+ ```bash
55
+ pip install agent-mini
56
+ agent-mini init
57
+ agent-mini chat
58
+ ```
59
+
60
+ The `init` wizard walks you through picking a provider, model, and basic settings. It creates `~/.agent-mini/config.json` — you're ready to chat.
61
+
62
+ ## Providers
63
+
64
+ Agent Mini ships with three providers. Set `"provider"` in your config:
65
+
66
+ ### Ollama (default) — Local Models
67
+
68
+ ```bash
69
+ ollama pull llama3.1
70
+ ```
71
+
72
+ ```json
73
+ {
74
+ "provider": "ollama",
75
+ "providers": {
76
+ "ollama": {
77
+ "baseUrl": "http://localhost:11434",
78
+ "model": "llama3.1",
79
+ "think": false
80
+ }
81
+ }
82
+ }
83
+ ```
84
+
85
+ `think` controls thinking mode — `false`, `true`, or `"low"` / `"medium"` / `"high"`.
86
+
87
+ ### OpenAI
88
+
89
+ ```json
90
+ {
91
+ "provider": "openai",
92
+ "providers": {
93
+ "openai": {
94
+ "apiKey": "sk-...",
95
+ "model": "gpt-4o"
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ ### Local — Any OpenAI-Compatible Server
102
+
103
+ Works with LM Studio, vLLM, llama.cpp, text-generation-webui, etc.
104
+
105
+ ```json
106
+ {
107
+ "provider": "local",
108
+ "providers": {
109
+ "local": {
110
+ "baseUrl": "http://localhost:8080/v1",
111
+ "apiKey": "no-key",
112
+ "model": "my-model"
113
+ }
114
+ }
115
+ }
116
+ ```
117
+
118
+ All providers support **streaming** and **tool calling**.
119
+
120
+ ---
121
+
122
+ ## Tools
123
+
124
+ Available out of the box — no API keys needed:
125
+
126
+ | Tool | Description |
127
+ |------|-------------|
128
+ | `shell_exec` | Run shell commands |
129
+ | `read_file` | Read file contents |
130
+ | `write_file` | Create / overwrite files |
131
+ | `append_file` | Append to files |
132
+ | `code_edit` | Find-and-replace in files |
133
+ | `list_directory` | Browse filesystem |
134
+ | `search_files` | Grep / ripgrep across files |
135
+ | `web_search` | DuckDuckGo search (free, no key) |
136
+ | `web_fetch` | Fetch any URL as plain text |
137
+ | `memory_store` | Save to persistent memory |
138
+ | `memory_recall` | Fuzzy search memory (TF-IDF) |
139
+
140
+ ### Plugins
141
+
142
+ Extend with custom tools — drop a `.py` file in `~/.agent-mini/plugins/`:
143
+
144
+ ```python
145
+ # ~/.agent-mini/plugins/timestamp.py
146
+ from datetime import datetime, timezone
147
+
148
+ TOOL_DEF = {
149
+ "type": "function",
150
+ "function": {
151
+ "name": "get_timestamp",
152
+ "description": "Get the current UTC timestamp.",
153
+ "parameters": {"type": "object", "properties": {}, "required": []},
154
+ },
155
+ }
156
+
157
+ async def handler(arguments: dict) -> str:
158
+ return datetime.now(timezone.utc).isoformat()
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Chat Commands
164
+
165
+ ```
166
+ /clear Reset conversation
167
+ /model <name> Switch provider/model (e.g. ollama/llama3.1)
168
+ /tools List available tools
169
+ /memory [query] Browse or search memories
170
+ /status Show config and token usage
171
+ /save [file] Export conversation as Markdown
172
+ /sessions List saved sessions
173
+ /load <id> Resume a session
174
+ /help Show commands
175
+ ```
176
+
177
+ Multi-line input: wrap with `"""` or `'''`. Line continuation: end with `\`.
178
+
179
+ ---
180
+
181
+ ## Telegram Gateway
182
+
183
+ 1. Create a bot via [@BotFather](https://t.me/BotFather)
184
+ 2. Run `agent-mini init` and enable Telegram during setup, or edit config:
185
+
186
+ ```json
187
+ {
188
+ "channels": {
189
+ "telegram": {
190
+ "enabled": true,
191
+ "token": "YOUR_BOT_TOKEN",
192
+ "allowFrom": ["YOUR_USER_ID"],
193
+ "streamResponses": true
194
+ }
195
+ }
196
+ }
197
+ ```
198
+
199
+ 3. `agent-mini gateway`
200
+
201
+ ---
202
+
203
+ ## Sandbox & Security
204
+
205
+ Control tool access:
206
+
207
+ | Level | Description |
208
+ |-------|-------------|
209
+ | `unrestricted` | All tools, all paths |
210
+ | `workspace` | All tools, paths restricted to workspace (default) |
211
+ | `readonly` | Read-only — no shell, write, edit |
212
+
213
+ ```json
214
+ { "tools": { "sandboxLevel": "readonly" } }
215
+ ```
216
+
217
+ Dangerous shell commands (`rm -rf`, `sudo`, `mkfs`, etc.) are blocked by default.
218
+
219
+ ---
220
+
221
+ ## Sessions
222
+
223
+ Conversations auto-save after each turn. Resume:
224
+
225
+ ```bash
226
+ agent-mini chat -s 20260307_143022
227
+ ```
228
+
229
+ Or inside the REPL: `/sessions` to list, `/load <id>` to resume.
230
+
231
+ ---
232
+
233
+ ## How It Works
234
+
235
+ Agent Mini is a **ReAct loop** — the LLM reasons, picks a tool, observes the result, and repeats until it has an answer.
236
+
237
+ Key design choices for small/local models:
238
+
239
+ - **Token-aware context** — estimates token usage and prunes old tool results when approaching the model's effective context window
240
+ - **Model tier classification** — auto-detects tiny/small/medium/cloud models and adjusts context budgets, iteration limits, and output caps
241
+ - **Tool call repair** — fixes malformed JSON from small models (trailing commas, single quotes, unquoted keys)
242
+ - **Loop detection** — catches repeated identical tool calls and nudges the LLM to try a different approach
243
+ - **History summarization** — compresses long conversations to stay within context
244
+
245
+ ---
246
+
247
+ ## Configuration Reference
248
+
249
+ ```json
250
+ {
251
+ "provider": "ollama",
252
+ "providers": {
253
+ "ollama": { "baseUrl": "http://localhost:11434", "model": "llama3.1", "think": false },
254
+ "openai": { "apiKey": "", "model": "gpt-4o" },
255
+ "local": { "baseUrl": "http://localhost:8080/v1", "apiKey": "no-key", "model": "local-model" }
256
+ },
257
+ "agent": {
258
+ "maxIterations": 20,
259
+ "temperature": 0.7,
260
+ "systemPrompt": ""
261
+ },
262
+ "channels": {
263
+ "telegram": { "enabled": false, "token": "", "allowFrom": [], "streamResponses": true }
264
+ },
265
+ "tools": { "restrictToWorkspace": false, "sandboxLevel": "workspace", "blockedCommands": [] },
266
+ "memory": { "enabled": true, "maxEntries": 1000 },
267
+ "workspace": "~/.agent-mini/workspace"
268
+ }
269
+ ```
270
+
271
+ Key paths:
272
+ - Config: `~/.agent-mini/config.json`
273
+ - Workspace: `~/.agent-mini/workspace/`
274
+ - Memory: `~/.agent-mini/memory.json`
275
+ - Plugins: `~/.agent-mini/plugins/`
276
+ - Sessions: `~/.agent-mini/sessions/`
277
+
278
+ ---
279
+
280
+ ## CLI
281
+
282
+ | Command | Description |
283
+ |---------|-------------|
284
+ | `agent-mini init` | Interactive setup wizard |
285
+ | `agent-mini chat` | Interactive chat |
286
+ | `agent-mini chat -m "..."` | Single message |
287
+ | `agent-mini gateway` | Start Telegram bot |
288
+ | `agent-mini status` | Show config status |
289
+
290
+ ---
291
+
292
+ ## Project Structure
293
+
294
+ ```
295
+ src/agent_mini/
296
+ ├── cli.py # CLI commands (Click)
297
+ ├── config.py # Typed config
298
+ ├── bus.py # Message routing
299
+ ├── sessions.py # Session persistence
300
+ ├── agent/
301
+ │ ├── loop.py # ReAct agent loop
302
+ │ ├── context.py # System prompt builder
303
+ │ ├── memory.py # JSON memory + TF-IDF search
304
+ │ ├── tools.py # Built-in tools + plugin loader
305
+ │ ├── token_estimator.py # Token counting + model tiers
306
+ │ └── vision.py # Image detection + encoding
307
+ ├── providers/
308
+ │ ├── base.py # Provider interface
309
+ │ ├── ollama.py # Ollama
310
+ │ ├── openai.py # OpenAI
311
+ │ └── local.py # OpenAI-compatible
312
+ └── channels/
313
+ ├── base.py # Channel interface
314
+ └── telegram.py # Telegram bot
315
+ ```
316
+
317
+ ## Development
318
+
319
+ ```bash
320
+ git clone https://github.com/mohsinkaleem/agent-mini.git
321
+ cd agent-mini
322
+ uv sync --extra dev
323
+ uv run pytest tests/ -v
324
+ uv run ruff check src/ tests/
325
+ ```
326
+
327
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
328
+
329
+ ## License
330
+
331
+ MIT
@@ -0,0 +1,296 @@
1
+ # Agent Mini
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/agent-mini)](https://pypi.org/project/agent-mini/)
4
+ [![CI](https://github.com/mohsinkaleem/agent-mini/actions/workflows/ci.yml/badge.svg)](https://github.com/mohsinkaleem/agent-mini/actions/workflows/ci.yml)
5
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue)](https://www.python.org/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
7
+
8
+ A minimal, local-first AI agent you can actually understand and extend.
9
+
10
+ - **~3,000 lines of Python** — read the whole thing in an afternoon
11
+ - **Local-first** — Ollama as default, OpenAI if you want cloud, or any OpenAI-compatible server
12
+ - **Zero frameworks** — pure `httpx` + `asyncio`, no LangChain, no LiteLLM
13
+ - **Built-in tools** — shell, files, web search, persistent memory
14
+ - **Extensible** — drop a Python file in `~/.agent-mini/plugins/` and it's a tool
15
+ - **Small-model optimized** — token-aware context pruning, tool call repair, model-tier tuning
16
+
17
+ ## Quick Start
18
+
19
+ ```bash
20
+ pip install agent-mini
21
+ agent-mini init
22
+ agent-mini chat
23
+ ```
24
+
25
+ The `init` wizard walks you through picking a provider, model, and basic settings. It creates `~/.agent-mini/config.json` — you're ready to chat.
26
+
27
+ ## Providers
28
+
29
+ Agent Mini ships with three providers. Set `"provider"` in your config:
30
+
31
+ ### Ollama (default) — Local Models
32
+
33
+ ```bash
34
+ ollama pull llama3.1
35
+ ```
36
+
37
+ ```json
38
+ {
39
+ "provider": "ollama",
40
+ "providers": {
41
+ "ollama": {
42
+ "baseUrl": "http://localhost:11434",
43
+ "model": "llama3.1",
44
+ "think": false
45
+ }
46
+ }
47
+ }
48
+ ```
49
+
50
+ `think` controls thinking mode — `false`, `true`, or `"low"` / `"medium"` / `"high"`.
51
+
52
+ ### OpenAI
53
+
54
+ ```json
55
+ {
56
+ "provider": "openai",
57
+ "providers": {
58
+ "openai": {
59
+ "apiKey": "sk-...",
60
+ "model": "gpt-4o"
61
+ }
62
+ }
63
+ }
64
+ ```
65
+
66
+ ### Local — Any OpenAI-Compatible Server
67
+
68
+ Works with LM Studio, vLLM, llama.cpp, text-generation-webui, etc.
69
+
70
+ ```json
71
+ {
72
+ "provider": "local",
73
+ "providers": {
74
+ "local": {
75
+ "baseUrl": "http://localhost:8080/v1",
76
+ "apiKey": "no-key",
77
+ "model": "my-model"
78
+ }
79
+ }
80
+ }
81
+ ```
82
+
83
+ All providers support **streaming** and **tool calling**.
84
+
85
+ ---
86
+
87
+ ## Tools
88
+
89
+ Available out of the box — no API keys needed:
90
+
91
+ | Tool | Description |
92
+ |------|-------------|
93
+ | `shell_exec` | Run shell commands |
94
+ | `read_file` | Read file contents |
95
+ | `write_file` | Create / overwrite files |
96
+ | `append_file` | Append to files |
97
+ | `code_edit` | Find-and-replace in files |
98
+ | `list_directory` | Browse filesystem |
99
+ | `search_files` | Grep / ripgrep across files |
100
+ | `web_search` | DuckDuckGo search (free, no key) |
101
+ | `web_fetch` | Fetch any URL as plain text |
102
+ | `memory_store` | Save to persistent memory |
103
+ | `memory_recall` | Fuzzy search memory (TF-IDF) |
104
+
105
+ ### Plugins
106
+
107
+ Extend with custom tools — drop a `.py` file in `~/.agent-mini/plugins/`:
108
+
109
+ ```python
110
+ # ~/.agent-mini/plugins/timestamp.py
111
+ from datetime import datetime, timezone
112
+
113
+ TOOL_DEF = {
114
+ "type": "function",
115
+ "function": {
116
+ "name": "get_timestamp",
117
+ "description": "Get the current UTC timestamp.",
118
+ "parameters": {"type": "object", "properties": {}, "required": []},
119
+ },
120
+ }
121
+
122
+ async def handler(arguments: dict) -> str:
123
+ return datetime.now(timezone.utc).isoformat()
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Chat Commands
129
+
130
+ ```
131
+ /clear Reset conversation
132
+ /model <name> Switch provider/model (e.g. ollama/llama3.1)
133
+ /tools List available tools
134
+ /memory [query] Browse or search memories
135
+ /status Show config and token usage
136
+ /save [file] Export conversation as Markdown
137
+ /sessions List saved sessions
138
+ /load <id> Resume a session
139
+ /help Show commands
140
+ ```
141
+
142
+ Multi-line input: wrap with `"""` or `'''`. Line continuation: end with `\`.
143
+
144
+ ---
145
+
146
+ ## Telegram Gateway
147
+
148
+ 1. Create a bot via [@BotFather](https://t.me/BotFather)
149
+ 2. Run `agent-mini init` and enable Telegram during setup, or edit config:
150
+
151
+ ```json
152
+ {
153
+ "channels": {
154
+ "telegram": {
155
+ "enabled": true,
156
+ "token": "YOUR_BOT_TOKEN",
157
+ "allowFrom": ["YOUR_USER_ID"],
158
+ "streamResponses": true
159
+ }
160
+ }
161
+ }
162
+ ```
163
+
164
+ 3. `agent-mini gateway`
165
+
166
+ ---
167
+
168
+ ## Sandbox & Security
169
+
170
+ Control tool access:
171
+
172
+ | Level | Description |
173
+ |-------|-------------|
174
+ | `unrestricted` | All tools, all paths |
175
+ | `workspace` | All tools, paths restricted to workspace (default) |
176
+ | `readonly` | Read-only — no shell, write, edit |
177
+
178
+ ```json
179
+ { "tools": { "sandboxLevel": "readonly" } }
180
+ ```
181
+
182
+ Dangerous shell commands (`rm -rf`, `sudo`, `mkfs`, etc.) are blocked by default.
183
+
184
+ ---
185
+
186
+ ## Sessions
187
+
188
+ Conversations auto-save after each turn. Resume:
189
+
190
+ ```bash
191
+ agent-mini chat -s 20260307_143022
192
+ ```
193
+
194
+ Or inside the REPL: `/sessions` to list, `/load <id>` to resume.
195
+
196
+ ---
197
+
198
+ ## How It Works
199
+
200
+ Agent Mini is a **ReAct loop** — the LLM reasons, picks a tool, observes the result, and repeats until it has an answer.
201
+
202
+ Key design choices for small/local models:
203
+
204
+ - **Token-aware context** — estimates token usage and prunes old tool results when approaching the model's effective context window
205
+ - **Model tier classification** — auto-detects tiny/small/medium/cloud models and adjusts context budgets, iteration limits, and output caps
206
+ - **Tool call repair** — fixes malformed JSON from small models (trailing commas, single quotes, unquoted keys)
207
+ - **Loop detection** — catches repeated identical tool calls and nudges the LLM to try a different approach
208
+ - **History summarization** — compresses long conversations to stay within context
209
+
210
+ ---
211
+
212
+ ## Configuration Reference
213
+
214
+ ```json
215
+ {
216
+ "provider": "ollama",
217
+ "providers": {
218
+ "ollama": { "baseUrl": "http://localhost:11434", "model": "llama3.1", "think": false },
219
+ "openai": { "apiKey": "", "model": "gpt-4o" },
220
+ "local": { "baseUrl": "http://localhost:8080/v1", "apiKey": "no-key", "model": "local-model" }
221
+ },
222
+ "agent": {
223
+ "maxIterations": 20,
224
+ "temperature": 0.7,
225
+ "systemPrompt": ""
226
+ },
227
+ "channels": {
228
+ "telegram": { "enabled": false, "token": "", "allowFrom": [], "streamResponses": true }
229
+ },
230
+ "tools": { "restrictToWorkspace": false, "sandboxLevel": "workspace", "blockedCommands": [] },
231
+ "memory": { "enabled": true, "maxEntries": 1000 },
232
+ "workspace": "~/.agent-mini/workspace"
233
+ }
234
+ ```
235
+
236
+ Key paths:
237
+ - Config: `~/.agent-mini/config.json`
238
+ - Workspace: `~/.agent-mini/workspace/`
239
+ - Memory: `~/.agent-mini/memory.json`
240
+ - Plugins: `~/.agent-mini/plugins/`
241
+ - Sessions: `~/.agent-mini/sessions/`
242
+
243
+ ---
244
+
245
+ ## CLI
246
+
247
+ | Command | Description |
248
+ |---------|-------------|
249
+ | `agent-mini init` | Interactive setup wizard |
250
+ | `agent-mini chat` | Interactive chat |
251
+ | `agent-mini chat -m "..."` | Single message |
252
+ | `agent-mini gateway` | Start Telegram bot |
253
+ | `agent-mini status` | Show config status |
254
+
255
+ ---
256
+
257
+ ## Project Structure
258
+
259
+ ```
260
+ src/agent_mini/
261
+ ├── cli.py # CLI commands (Click)
262
+ ├── config.py # Typed config
263
+ ├── bus.py # Message routing
264
+ ├── sessions.py # Session persistence
265
+ ├── agent/
266
+ │ ├── loop.py # ReAct agent loop
267
+ │ ├── context.py # System prompt builder
268
+ │ ├── memory.py # JSON memory + TF-IDF search
269
+ │ ├── tools.py # Built-in tools + plugin loader
270
+ │ ├── token_estimator.py # Token counting + model tiers
271
+ │ └── vision.py # Image detection + encoding
272
+ ├── providers/
273
+ │ ├── base.py # Provider interface
274
+ │ ├── ollama.py # Ollama
275
+ │ ├── openai.py # OpenAI
276
+ │ └── local.py # OpenAI-compatible
277
+ └── channels/
278
+ ├── base.py # Channel interface
279
+ └── telegram.py # Telegram bot
280
+ ```
281
+
282
+ ## Development
283
+
284
+ ```bash
285
+ git clone https://github.com/mohsinkaleem/agent-mini.git
286
+ cd agent-mini
287
+ uv sync --extra dev
288
+ uv run pytest tests/ -v
289
+ uv run ruff check src/ tests/
290
+ ```
291
+
292
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
293
+
294
+ ## License
295
+
296
+ MIT
@@ -0,0 +1,26 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ | Version | Supported |
6
+ | ------- | ------------------ |
7
+ | 0.1.x | :white_check_mark: |
8
+
9
+ ## Reporting a Vulnerability
10
+
11
+ If you discover a security vulnerability, please report it responsibly:
12
+
13
+ 1. **Do not** open a public issue.
14
+ 2. Email **mohsin.kaleem512@gmail.com** with details of the vulnerability.
15
+ 3. Include steps to reproduce if possible.
16
+
17
+ You should receive a response within 48 hours. We'll work with you to understand the issue and coordinate a fix before any public disclosure.
18
+
19
+ ## Security Considerations
20
+
21
+ Agent Mini executes shell commands and file operations on behalf of the user. The built-in sandbox levels (`unrestricted`, `workspace`, `readonly`) control access:
22
+
23
+ - **Always use `workspace` or `readonly` mode** in shared or untrusted environments.
24
+ - **Never expose the agent to untrusted input** without enabling `restrictToWorkspace`.
25
+ - Dangerous commands (`rm -rf /`, `sudo`, `mkfs`, etc.) are blocked by default.
26
+ - API keys are stored in `~/.agent-mini/config.json` — ensure this file has appropriate permissions (`chmod 600`).
@@ -6,12 +6,8 @@
6
6
  "model": "llama3.1",
7
7
  "think": false
8
8
  },
9
- "gemini": {
9
+ "openai": {
10
10
  "apiKey": "",
11
- "model": "gemini-2.0-flash"
12
- },
13
- "github_copilot": {
14
- "token": "",
15
11
  "model": "gpt-4o"
16
12
  },
17
13
  "local": {