astraagent 2.25.6

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 (63) hide show
  1. package/.env.template +22 -0
  2. package/LICENSE +21 -0
  3. package/README.md +333 -0
  4. package/astra/__init__.py +15 -0
  5. package/astra/__pycache__/__init__.cpython-314.pyc +0 -0
  6. package/astra/__pycache__/chat.cpython-314.pyc +0 -0
  7. package/astra/__pycache__/cli.cpython-314.pyc +0 -0
  8. package/astra/__pycache__/prompts.cpython-314.pyc +0 -0
  9. package/astra/__pycache__/updater.cpython-314.pyc +0 -0
  10. package/astra/chat.py +763 -0
  11. package/astra/cli.py +913 -0
  12. package/astra/core/__init__.py +8 -0
  13. package/astra/core/__pycache__/__init__.cpython-314.pyc +0 -0
  14. package/astra/core/__pycache__/agent.cpython-314.pyc +0 -0
  15. package/astra/core/__pycache__/config.cpython-314.pyc +0 -0
  16. package/astra/core/__pycache__/memory.cpython-314.pyc +0 -0
  17. package/astra/core/__pycache__/reasoning.cpython-314.pyc +0 -0
  18. package/astra/core/__pycache__/state.cpython-314.pyc +0 -0
  19. package/astra/core/agent.py +515 -0
  20. package/astra/core/config.py +247 -0
  21. package/astra/core/memory.py +782 -0
  22. package/astra/core/reasoning.py +423 -0
  23. package/astra/core/state.py +366 -0
  24. package/astra/core/voice.py +144 -0
  25. package/astra/llm/__init__.py +32 -0
  26. package/astra/llm/__pycache__/__init__.cpython-314.pyc +0 -0
  27. package/astra/llm/__pycache__/providers.cpython-314.pyc +0 -0
  28. package/astra/llm/providers.py +530 -0
  29. package/astra/planning/__init__.py +117 -0
  30. package/astra/prompts.py +289 -0
  31. package/astra/reflection/__init__.py +181 -0
  32. package/astra/search.py +469 -0
  33. package/astra/tasks.py +466 -0
  34. package/astra/tools/__init__.py +17 -0
  35. package/astra/tools/__pycache__/__init__.cpython-314.pyc +0 -0
  36. package/astra/tools/__pycache__/advanced.cpython-314.pyc +0 -0
  37. package/astra/tools/__pycache__/base.cpython-314.pyc +0 -0
  38. package/astra/tools/__pycache__/browser.cpython-314.pyc +0 -0
  39. package/astra/tools/__pycache__/file.cpython-314.pyc +0 -0
  40. package/astra/tools/__pycache__/git.cpython-314.pyc +0 -0
  41. package/astra/tools/__pycache__/memory_tool.cpython-314.pyc +0 -0
  42. package/astra/tools/__pycache__/python.cpython-314.pyc +0 -0
  43. package/astra/tools/__pycache__/shell.cpython-314.pyc +0 -0
  44. package/astra/tools/__pycache__/web.cpython-314.pyc +0 -0
  45. package/astra/tools/__pycache__/windows.cpython-314.pyc +0 -0
  46. package/astra/tools/advanced.py +251 -0
  47. package/astra/tools/base.py +344 -0
  48. package/astra/tools/browser.py +93 -0
  49. package/astra/tools/file.py +476 -0
  50. package/astra/tools/git.py +74 -0
  51. package/astra/tools/memory_tool.py +89 -0
  52. package/astra/tools/python.py +238 -0
  53. package/astra/tools/shell.py +183 -0
  54. package/astra/tools/web.py +804 -0
  55. package/astra/tools/windows.py +542 -0
  56. package/astra/updater.py +450 -0
  57. package/astra/utils/__init__.py +230 -0
  58. package/bin/astraagent.js +73 -0
  59. package/bin/postinstall.js +25 -0
  60. package/config.json.template +52 -0
  61. package/main.py +16 -0
  62. package/package.json +51 -0
  63. package/pyproject.toml +72 -0
package/.env.template ADDED
@@ -0,0 +1,22 @@
1
+ # AstraAgent Environment Variables
2
+ # Copy this file to .env and fill in your values
3
+
4
+ # Local LLM Server Configuration
5
+ LOCAL_API_KEY=your-api-key-here
6
+ LOCAL_API_BASE=http://localhost:8000/api/v1
7
+ LOCAL_MODEL=default
8
+
9
+ # Alternative: OpenAI Configuration
10
+ # OPENAI_API_KEY=sk-...
11
+ # OPENAI_MODEL=gpt-4
12
+
13
+ # Alternative: Anthropic Configuration
14
+ # ANTHROPIC_API_KEY=sk-ant-...
15
+
16
+ # Logging
17
+ LOG_LEVEL=info
18
+
19
+ # Workspace Paths
20
+ WORKSPACE_PATH=./workspace
21
+ ARTIFACTS_PATH=./artifacts
22
+ TEMP_PATH=./temp
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 AstraAgent Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,333 @@
1
+ # ๐Ÿš€ AstraAgent - Autonomous AI Agent Framework
2
+
3
+ <p align="center">
4
+ <img src="https://img.shields.io/badge/Python-3.9+-blue.svg" alt="Python">
5
+ <img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License">
6
+ <img src="https://img.shields.io/badge/Status-Production_Ready-brightgreen.svg" alt="Status">
7
+ </p>
8
+
9
+ **AstraAgent** is a state-of-the-art autonomous AI agent framework designed to accomplish complex tasks with minimal human intervention. It rivals industry-leading agents from Google and OpenAI, featuring a modular architecture, comprehensive tool system, and advanced memory management.
10
+
11
+ ---
12
+
13
+ ## โœจ Key Features
14
+
15
+ ### ๐Ÿง  **Autonomous Problem Solving**
16
+ - **OBSERVE โ†’ THINK โ†’ PLAN โ†’ ACT โ†’ REFLECT โ†’ ITERATE** workflow
17
+ - Self-correcting behavior with error recovery
18
+ - Dynamic plan adjustment based on results
19
+
20
+ ### ๐Ÿ”ง **Comprehensive Tool System**
21
+ - **Shell**: Execute system commands safely
22
+ - **File System**: Read, write, copy, delete files
23
+ - **Python**: Execute code in sandboxed environment
24
+ - **Web Search**: DuckDuckGo integration
25
+ - **Web Fetch**: Extract content from URLs
26
+ - **Browser**: Playwright-based automation
27
+ - **Git**: Repository management
28
+ - **Memory**: Persistent knowledge storage
29
+
30
+ ### ๐Ÿงฌ **Advanced Memory System**
31
+ - Short-term, long-term, episodic, and semantic memory
32
+ - Automatic memory consolidation
33
+ - Similarity-based recall
34
+ - Persistent storage with auto-save
35
+
36
+ ### ๐Ÿ›ก๏ธ **Safety Guardrails**
37
+ - Dangerous command blocking
38
+ - File extension restrictions
39
+ - Execution timeout limits
40
+ - Approval system for high-risk actions
41
+
42
+ ### ๐Ÿ”Œ **Multi-Provider LLM Support**
43
+ - **Grok/xAI** (grok-3, grok-3-fast, grok-3-mini) โญ NEW
44
+ - OpenAI (GPT-4, GPT-4o, GPT-3.5)
45
+ - Anthropic (Claude 3.5, Claude 3)
46
+ - Local models (Ollama, LM Studio)
47
+
48
+ ---
49
+
50
+ ## ๐Ÿ“ฆ Installation
51
+
52
+ ### Quick Install
53
+ ```bash
54
+ pip install -e .
55
+ ```
56
+
57
+ ### Install via npm (global launcher)
58
+ ```bash
59
+ npm install -g astraagent
60
+ astraagent setup
61
+ astraagent start -i
62
+ ```
63
+
64
+ ### With All Features
65
+ ```bash
66
+ pip install -e ".[all]"
67
+ ```
68
+
69
+ ### Development Install
70
+ ```bash
71
+ pip install -e ".[dev]"
72
+ ```
73
+
74
+ ### Browser Automation (optional)
75
+ ```bash
76
+ pip install playwright
77
+ playwright install chromium
78
+ ```
79
+
80
+ ---
81
+
82
+ ## ๐Ÿš€ Quick Start
83
+
84
+ ### Set Your API Key
85
+ ```bash
86
+ # Grok/xAI (recommended)
87
+ set XAI_API_KEY=your-key-here # Windows
88
+ export XAI_API_KEY=your-key-here # Linux/Mac
89
+
90
+ # Or OpenAI
91
+ set OPENAI_API_KEY=your-key-here # Windows
92
+ export OPENAI_API_KEY=your-key-here # Linux/Mac
93
+ ```
94
+
95
+ ### Run the Agent
96
+ ```bash
97
+ # Quick start alias (interactive)
98
+ python main.py start -i
99
+
100
+ # Run agent with a goal
101
+ python main.py run "Create a Python script that generates prime numbers"
102
+
103
+ # Run in interactive mode
104
+ python main.py run -i
105
+
106
+ # List available tools
107
+ python main.py tools
108
+
109
+ # Interactive multi-provider chat
110
+ python main.py chat # Interactive selection
111
+ python main.py chat --list-providers # Show available providers
112
+
113
+ # Update checker/auto updater
114
+ python main.py update --check
115
+ python main.py update --auto
116
+ ```
117
+
118
+ ###๐Ÿ’ฌ Interactive Chat with Multiple LLM Providers
119
+
120
+ **NEW:** Chat with GPT-4, Claude, Gemini, Ollama, and more!
121
+
122
+ ```bash
123
+ # Start interactive chat mode
124
+ python main.py chat
125
+
126
+ # List available providers
127
+ python main.py chat --list-providers
128
+ ```
129
+
130
+ Supported providers:
131
+ - ๐Ÿ†“ **Local** - Ollama, LM Studio (free, self-hosted)
132
+ - **OpenAI** - GPT-4, GPT-4 Turbo, GPT-3.5
133
+ - **Google Gemini** - Gemini 2.0 Flash, 1.5 Pro/Flash
134
+ - **Anthropic Claude** - Claude 3.5 Sonnet, Claude 3 Opus
135
+ - **OpenRouter** - Access 100+ models in one place
136
+ - **Groq** - Fast inference (Mixtral, Llama, Gemma)
137
+
138
+ See [CHAT_GUIDE.md](CHAT_GUIDE.md) for complete chat documentation.
139
+
140
+ ### Programmatic Usage
141
+ ```python
142
+ import asyncio
143
+ from astra import AstraAgent, AgentConfig
144
+
145
+ async def main():
146
+ config = AgentConfig()
147
+ config.llm.provider = "openai"
148
+ config.llm.model = "gpt-4"
149
+
150
+ agent = AstraAgent(config)
151
+ result = await agent.run("Write a web scraper for news headlines")
152
+ print(result)
153
+ agent.shutdown()
154
+
155
+ asyncio.run(main())
156
+ ```
157
+
158
+ ---
159
+
160
+ ## ๐Ÿ› ๏ธ Available Tools
161
+
162
+ | Tool | Description | Risk Level |
163
+ |------|-------------|------------|
164
+ | `shell` | Execute shell commands | High |
165
+ | `read_file` | Read file contents | Low |
166
+ | `write_file` | Write/create files | Medium |
167
+ | `list_dir` | List directory contents | Low |
168
+ | `python` | Execute Python code | Medium |
169
+ | `web_search` | Search the web | Low |
170
+ | `google_search` | Search via Google | Low |
171
+ | `exa_search` | Search via Exa API | Low |
172
+ | `web_search_multi` | Multi-engine web search | Low |
173
+ | `web_fetch` | Fetch URL content | Low |
174
+ | `browser` | Browser automation | Medium |
175
+ | `git` | Git operations | Medium |
176
+ | `memory` | Store/recall information | Low |
177
+
178
+ ---
179
+
180
+ ## โš™๏ธ Configuration
181
+
182
+ ### Environment Variables
183
+ ```bash
184
+ # API Keys (set one)
185
+ XAI_API_KEY=xai-... # Grok/xAI API key (recommended)
186
+ OPENAI_API_KEY=sk-... # OpenAI API key
187
+ ANTHROPIC_API_KEY=sk-ant-... # Anthropic API key
188
+ EXA_API_KEY=exa-... # Exa search API key (optional)
189
+ GOOGLE_CSE_API_KEY=... # Google Custom Search API key (optional)
190
+ GOOGLE_CSE_ID=... # Google Custom Search engine ID (optional)
191
+
192
+ # Configuration
193
+ ASTRA_MODE=autonomous # Execution mode
194
+ ASTRA_MODEL=grok-3 # LLM model
195
+ ASTRA_PROVIDER=grok # LLM provider: grok, openai, anthropic, ollama
196
+ ASTRA_MAX_ITERATIONS=50 # Max agent iterations
197
+ ```
198
+
199
+ ### Configuration File
200
+ ```python
201
+ from astra import AgentConfig
202
+
203
+ config = AgentConfig()
204
+ config.llm.provider = "grok" # or "openai", "anthropic", "ollama"
205
+ config.llm.model = "grok-3" # or "gpt-4", "claude-3-sonnet"
206
+ config.llm.temperature = 0.7
207
+ config.max_iterations = 100
208
+ config.workspace_path = "./workspace"
209
+ config.save("config.json")
210
+ ```
211
+
212
+ ---
213
+
214
+ ## ๐Ÿ“ Project Structure
215
+
216
+ ```
217
+ AstraAgent/
218
+ โ”œโ”€โ”€ astra/
219
+ โ”‚ โ”œโ”€โ”€ __init__.py
220
+ โ”‚ โ”œโ”€โ”€ cli.py # Command-line interface
221
+ โ”‚ โ”œโ”€โ”€ core/
222
+ โ”‚ โ”‚ โ”œโ”€โ”€ agent.py # Main agent class
223
+ โ”‚ โ”‚ โ”œโ”€โ”€ config.py # Configuration system
224
+ โ”‚ โ”‚ โ”œโ”€โ”€ state.py # State management
225
+ โ”‚ โ”‚ โ””โ”€โ”€ memory.py # Memory system
226
+ โ”‚ โ”œโ”€โ”€ tools/
227
+ โ”‚ โ”‚ โ”œโ”€โ”€ base.py # Tool framework
228
+ โ”‚ โ”‚ โ”œโ”€โ”€ shell.py # Shell commands
229
+ โ”‚ โ”‚ โ”œโ”€โ”€ file.py # File operations
230
+ โ”‚ โ”‚ โ”œโ”€โ”€ python.py # Python execution
231
+ โ”‚ โ”‚ โ”œโ”€โ”€ web.py # Web search/fetch
232
+ โ”‚ โ”‚ โ”œโ”€โ”€ browser.py # Browser automation
233
+ โ”‚ โ”‚ โ”œโ”€โ”€ git.py # Git operations
234
+ โ”‚ โ”‚ โ””โ”€โ”€ memory_tool.py # Memory management
235
+ โ”‚ โ””โ”€โ”€ llm/
236
+ โ”‚ โ””โ”€โ”€ __init__.py # LLM providers
237
+ โ”œโ”€โ”€ main.py # Entry point
238
+ โ”œโ”€โ”€ pyproject.toml # Project config
239
+ โ””โ”€โ”€ README.md
240
+ ```
241
+
242
+ ---
243
+
244
+ ## ๐ŸŽฏ Example Use Cases
245
+
246
+ ### 1. Code Generation
247
+ ```bash
248
+ python main.py run "Create a FastAPI REST API with user authentication"
249
+ ```
250
+
251
+ ### 2. Data Analysis
252
+ ```bash
253
+ python main.py run "Analyze the CSV files in ./data and create a report"
254
+ ```
255
+
256
+ ### 3. Web Research
257
+ ```bash
258
+ python main.py run "Research the latest AI developments and summarize in a report"
259
+ ```
260
+
261
+ ### 4. Automation
262
+ ```bash
263
+ python main.py run "Set up a new Python project with pytest and CI/CD"
264
+ ```
265
+
266
+ ### 5. Documentation
267
+ ```bash
268
+ python main.py run "Generate API documentation for the src/ folder"
269
+ ```
270
+
271
+ ---
272
+
273
+ ## ๐Ÿ”’ Safety Features
274
+
275
+ - **Command Blocking**: Prevents `rm -rf`, `format`, and other dangerous commands
276
+ - **Sandboxed Execution**: Python code runs in restricted environment
277
+ - **File Restrictions**: Blocks writes to system directories
278
+ - **Timeout Limits**: Prevents infinite loops
279
+ - **Approval Mode**: Optional user confirmation for risky actions
280
+
281
+ ---
282
+
283
+ ## ๐Ÿงช Development
284
+
285
+ ### Run Tests
286
+ ```bash
287
+ pytest tests/
288
+ ```
289
+
290
+ ### Auto Update
291
+ ```bash
292
+ python main.py update --check
293
+ python main.py update --auto
294
+ ```
295
+
296
+ ### Format Code
297
+ ```bash
298
+ black astra/
299
+ ruff check astra/ --fix
300
+ ```
301
+
302
+ ---
303
+
304
+ ## ๐Ÿ“Š Comparison
305
+
306
+ | Feature | AstraAgent | ChatGPT | Google Agent |
307
+ |---------|------------|---------|--------------|
308
+ | Autonomous Execution | โœ… | โŒ | โœ… |
309
+ | Local File Access | โœ… | โŒ | โŒ |
310
+ | Shell Commands | โœ… | โŒ | โŒ |
311
+ | Browser Automation | โœ… | โŒ | โœ… |
312
+ | Persistent Memory | โœ… | Limited | โŒ |
313
+ | Self-Hosted | โœ… | โŒ | โŒ |
314
+ | Multi-Provider LLM | โœ… | โŒ | โŒ |
315
+ | Extensible Tools | โœ… | Via Plugins | โŒ |
316
+
317
+ ---
318
+
319
+ ## ๐Ÿ“œ License
320
+
321
+ MIT License - see [LICENSE](LICENSE) for details.
322
+
323
+ ---
324
+
325
+ ## ๐Ÿ™ Acknowledgments
326
+
327
+ Built with the power of modern LLMs and inspired by the vision of truly autonomous AI assistants.
328
+
329
+ ---
330
+
331
+ <p align="center">
332
+ <b>AstraAgent</b> - The Future of Autonomous AI
333
+ </p>
@@ -0,0 +1,15 @@
1
+ """
2
+ AstraAgent - Autonomous AI Agent Framework
3
+ A comprehensive, state-of-the-art autonomous agent system.
4
+
5
+ Author: AstraAgent Team
6
+ Version: 2.25.6
7
+ """
8
+
9
+ __version__ = "2.25.6"
10
+ __author__ = "AstraAgent Team"
11
+
12
+ from astra.core.agent import AstraAgent
13
+ from astra.core.config import AgentConfig
14
+
15
+ __all__ = ["AstraAgent", "AgentConfig", "__version__"]