agentic-cli 0.1.2__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.
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/CHANGELOG.md +23 -0
- agentic_cli-0.2.0/PKG-INFO +505 -0
- agentic_cli-0.2.0/README.md +466 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/examples/hello_agent.py +8 -4
- agentic_cli-0.2.0/examples/hello_langgraph.py +132 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/pyproject.toml +9 -1
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/__init__.py +18 -6
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/cli/app.py +131 -24
- agentic_cli-0.2.0/src/agentic_cli/cli/builtin_commands.py +115 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/cli/settings_command.py +7 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/config.py +36 -6
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/tools/standard.py +1 -1
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/workflow/__init__.py +3 -12
- agentic_cli-0.1.2/src/agentic_cli/workflow/manager.py → agentic_cli-0.2.0/src/agentic_cli/workflow/adk_manager.py +233 -149
- agentic_cli-0.2.0/src/agentic_cli/workflow/base_manager.py +249 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/workflow/config.py +2 -2
- agentic_cli-0.2.0/src/agentic_cli/workflow/langgraph_manager.py +939 -0
- agentic_cli-0.2.0/src/agentic_cli/workflow/langgraph_state.py +181 -0
- agentic_cli-0.2.0/tests/test_langgraph.py +451 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/tests/test_workflow.py +29 -29
- agentic_cli-0.1.2/PKG-INFO +0 -72
- agentic_cli-0.1.2/README.md +0 -40
- agentic_cli-0.1.2/src/agentic_cli/cli/builtin_commands.py +0 -262
- agentic_cli-0.1.2/src/agentic_cli/workflow/event_processor.py +0 -175
- agentic_cli-0.1.2/src/agentic_cli/workflow/memory.py +0 -164
- agentic_cli-0.1.2/src/agentic_cli/workflow/retry.py +0 -168
- agentic_cli-0.1.2/src/agentic_cli/workflow/session_handler.py +0 -93
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/.gitignore +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/LICENSE +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/environment.yml +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/requirements-dev.txt +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/requirements.txt +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/cli/__init__.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/cli/commands.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/config_mixins.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/knowledge_base/__init__.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/knowledge_base/embeddings.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/knowledge_base/manager.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/knowledge_base/models.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/knowledge_base/sources.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/knowledge_base/vector_store.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/logging.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/persistence/__init__.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/persistence/artifacts.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/persistence/session.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/resolvers.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/tools/__init__.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/tools/executor.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/tools/registry.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/workflow/events.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/src/agentic_cli/workflow/thinking.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/tests/__init__.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/tests/conftest.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/tests/test_commands.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/tests/test_config.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/tests/test_knowledge_base.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/tests/test_persistence.py +0 -0
- {agentic_cli-0.1.2 → agentic_cli-0.2.0}/tests/test_tools.py +0 -0
|
@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.2.0] - 2025-01-25
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- LangGraph as pluggable orchestration backend (`LangGraphWorkflowManager`)
|
|
13
|
+
- `create_workflow_manager_from_settings()` factory function for auto-selecting orchestrator
|
|
14
|
+
- Thinking level support for LangGraphWorkflowManager (Anthropic and Google models)
|
|
15
|
+
- `log_activity` setting for optional conversation activity logging
|
|
16
|
+
- `hello_langgraph.py` example demonstrating LangGraph orchestration
|
|
17
|
+
- Comprehensive README documentation with architecture, examples, and API reference
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Renamed `WorkflowManager` to `GoogleADKWorkflowManager` for clarity
|
|
22
|
+
- Replaced custom retry logic with framework built-in mechanisms (ADK HttpRetryOptions, LangGraph RetryPolicy)
|
|
23
|
+
- Removed `ConversationMemory` in favor of native framework session/state management
|
|
24
|
+
- Gemini 3 Pro thinking level now falls back to HIGH when MEDIUM is requested (Pro only supports LOW/HIGH)
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- LangGraph compatibility issues with content block extraction
|
|
29
|
+
- Thinking level configuration for Gemini 3 Pro models
|
|
30
|
+
|
|
8
31
|
## [0.1.2] - 2026-01-24
|
|
9
32
|
|
|
10
33
|
### Added
|
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentic-cli
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A framework for building domain-specific agentic CLI applications
|
|
5
|
+
Project-URL: Homepage, https://github.com/shoom1/agentic-cli
|
|
6
|
+
Project-URL: Repository, https://github.com/shoom1/agentic-cli
|
|
7
|
+
Author: Andrey Shiryaev
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Requires-Python: >=3.12
|
|
17
|
+
Requires-Dist: feedparser>=6.0.0
|
|
18
|
+
Requires-Dist: google-adk[genai]>=0.4.0
|
|
19
|
+
Requires-Dist: httpx>=0.27.0
|
|
20
|
+
Requires-Dist: numpy>=1.26.0
|
|
21
|
+
Requires-Dist: prompt-toolkit>=3.0.0
|
|
22
|
+
Requires-Dist: pydantic-settings>=2.0.0
|
|
23
|
+
Requires-Dist: pydantic>=2.0.0
|
|
24
|
+
Requires-Dist: rich>=13.0.0
|
|
25
|
+
Requires-Dist: structlog>=24.0.0
|
|
26
|
+
Requires-Dist: thinking-prompt>=0.2.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-cov>=6.0.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
31
|
+
Provides-Extra: langgraph
|
|
32
|
+
Requires-Dist: langchain-anthropic>=0.2.0; extra == 'langgraph'
|
|
33
|
+
Requires-Dist: langchain-core>=0.3.0; extra == 'langgraph'
|
|
34
|
+
Requires-Dist: langchain-google-genai>=2.0.0; extra == 'langgraph'
|
|
35
|
+
Requires-Dist: langchain-openai>=0.2.0; extra == 'langgraph'
|
|
36
|
+
Requires-Dist: langchain>=0.3.0; extra == 'langgraph'
|
|
37
|
+
Requires-Dist: langgraph>=0.2.0; extra == 'langgraph'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# Agentic CLI
|
|
41
|
+
|
|
42
|
+
A framework for building domain-specific agentic CLI applications powered by LLM agents.
|
|
43
|
+
|
|
44
|
+
## Overview
|
|
45
|
+
|
|
46
|
+
Agentic CLI provides the core infrastructure for building interactive CLI applications that leverage LLM agents for complex tasks. It offers:
|
|
47
|
+
|
|
48
|
+
- **Pluggable Orchestration**: Choose between Google ADK or LangGraph for agent workflows
|
|
49
|
+
- **Rich Terminal UI**: Thinking boxes, markdown rendering, and streaming responses via `thinking-prompt`
|
|
50
|
+
- **Declarative Agents**: Define agents with simple configuration objects
|
|
51
|
+
- **Built-in Tools**: Python execution, knowledge base search, web search
|
|
52
|
+
- **Session Persistence**: Save and restore conversation sessions
|
|
53
|
+
- **Type-safe Configuration**: Settings management with pydantic-settings
|
|
54
|
+
|
|
55
|
+
## Architecture
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
┌─────────────────────────────────────────────────────────────────────┐
|
|
59
|
+
│ BaseCLIApp │
|
|
60
|
+
│ - Terminal UI (thinking-prompt) │
|
|
61
|
+
│ - Command registry (/help, /status, /clear, etc.) │
|
|
62
|
+
│ - Message history │
|
|
63
|
+
└─────────────────────────────────────────────────────────────────────┘
|
|
64
|
+
│
|
|
65
|
+
▼
|
|
66
|
+
┌─────────────────────────────────────────────────────────────────────┐
|
|
67
|
+
│ BaseWorkflowManager │
|
|
68
|
+
│ - Agent orchestration │
|
|
69
|
+
│ - Event streaming │
|
|
70
|
+
│ - Session management │
|
|
71
|
+
├─────────────────────────────┬───────────────────────────────────────┤
|
|
72
|
+
│ GoogleADKWorkflowManager │ LangGraphWorkflowManager │
|
|
73
|
+
│ (Default) │ (Optional: langgraph extra) │
|
|
74
|
+
└─────────────────────────────┴───────────────────────────────────────┘
|
|
75
|
+
│
|
|
76
|
+
▼
|
|
77
|
+
┌─────────────────────────────────────────────────────────────────────┐
|
|
78
|
+
│ AgentConfig[] │
|
|
79
|
+
│ - name, prompt, tools, sub_agents, description │
|
|
80
|
+
└─────────────────────────────────────────────────────────────────────┘
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Requirements
|
|
84
|
+
|
|
85
|
+
- Python 3.12+
|
|
86
|
+
- Google API key (for Gemini models) or Anthropic API key (for Claude models)
|
|
87
|
+
|
|
88
|
+
## Installation
|
|
89
|
+
|
|
90
|
+
### Basic Installation (Google ADK)
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pip install agentic-cli
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### With LangGraph Support
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pip install agentic-cli[langgraph]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Development Installation
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
git clone https://github.com/shoom1/agentic-cli.git
|
|
106
|
+
cd agentic-cli
|
|
107
|
+
pip install -e ".[dev]"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Using Conda
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
conda env create -f environment.yml
|
|
114
|
+
conda run -n agenticcli pip install -e .
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Quick Start
|
|
118
|
+
|
|
119
|
+
Create a minimal CLI application in just a few lines:
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
import asyncio
|
|
123
|
+
from agentic_cli import BaseCLIApp, BaseSettings, AgentConfig, GoogleADKWorkflowManager
|
|
124
|
+
from agentic_cli.cli import AppInfo
|
|
125
|
+
|
|
126
|
+
# Define your tools
|
|
127
|
+
def greet(name: str) -> dict:
|
|
128
|
+
"""Greet a person by name."""
|
|
129
|
+
return {"greeting": f"Hello, {name}!"}
|
|
130
|
+
|
|
131
|
+
# Configure your agent
|
|
132
|
+
AGENTS = [
|
|
133
|
+
AgentConfig(
|
|
134
|
+
name="assistant",
|
|
135
|
+
prompt="You are a helpful assistant. Use the greet tool when asked to greet someone.",
|
|
136
|
+
tools=[greet],
|
|
137
|
+
),
|
|
138
|
+
]
|
|
139
|
+
|
|
140
|
+
# Create your app
|
|
141
|
+
class MyApp(BaseCLIApp):
|
|
142
|
+
def get_app_info(self) -> AppInfo:
|
|
143
|
+
return AppInfo(name="My App", version="0.1.0")
|
|
144
|
+
|
|
145
|
+
def get_settings(self) -> BaseSettings:
|
|
146
|
+
return BaseSettings()
|
|
147
|
+
|
|
148
|
+
def create_workflow_manager(self) -> GoogleADKWorkflowManager:
|
|
149
|
+
return GoogleADKWorkflowManager(agent_configs=AGENTS, settings=self._settings)
|
|
150
|
+
|
|
151
|
+
if __name__ == "__main__":
|
|
152
|
+
asyncio.run(MyApp().run())
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Run with your API key:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
export GOOGLE_API_KEY="your-api-key"
|
|
159
|
+
python my_app.py
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Workflow Managers
|
|
163
|
+
|
|
164
|
+
### GoogleADKWorkflowManager (Default)
|
|
165
|
+
|
|
166
|
+
Uses Google's Agent Development Kit for orchestration. Best for:
|
|
167
|
+
- Simple agent hierarchies
|
|
168
|
+
- Google Gemini models with native thinking support
|
|
169
|
+
- Quick prototyping
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
from agentic_cli import GoogleADKWorkflowManager
|
|
173
|
+
|
|
174
|
+
manager = GoogleADKWorkflowManager(
|
|
175
|
+
agent_configs=AGENTS,
|
|
176
|
+
settings=settings,
|
|
177
|
+
model="gemini-2.0-flash", # Optional: auto-detected from API keys
|
|
178
|
+
)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### LangGraphWorkflowManager
|
|
182
|
+
|
|
183
|
+
Uses LangGraph for orchestration. Best for:
|
|
184
|
+
- Cyclical workflows (self-validation, iterative refinement)
|
|
185
|
+
- Model-agnostic operation (OpenAI, Anthropic, Google)
|
|
186
|
+
- State checkpointing and time-travel debugging
|
|
187
|
+
- Complex multi-agent coordination
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
from agentic_cli import LangGraphWorkflowManager
|
|
191
|
+
|
|
192
|
+
manager = LangGraphWorkflowManager(
|
|
193
|
+
agent_configs=AGENTS,
|
|
194
|
+
settings=settings,
|
|
195
|
+
checkpointer="memory", # or "postgres" for persistence
|
|
196
|
+
)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Requires: `pip install agentic-cli[langgraph]`
|
|
200
|
+
|
|
201
|
+
### Comparison
|
|
202
|
+
|
|
203
|
+
| Feature | Google ADK | LangGraph |
|
|
204
|
+
|---------|------------|-----------|
|
|
205
|
+
| Setup complexity | Simple | Moderate |
|
|
206
|
+
| Cyclical workflows | Limited | Native |
|
|
207
|
+
| Multi-provider | Google only | OpenAI, Anthropic, Google |
|
|
208
|
+
| State persistence | In-memory | Memory or PostgreSQL |
|
|
209
|
+
| Thinking support | Native (Gemini) | Via model config |
|
|
210
|
+
|
|
211
|
+
### Auto-selection via Settings
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
from agentic_cli import create_workflow_manager_from_settings
|
|
215
|
+
|
|
216
|
+
settings = BaseSettings(orchestrator="langgraph") # or "adk"
|
|
217
|
+
manager = create_workflow_manager_from_settings(agent_configs=AGENTS, settings=settings)
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Configuration
|
|
221
|
+
|
|
222
|
+
### BaseSettings
|
|
223
|
+
|
|
224
|
+
All settings can be configured via environment variables with the `AGENTIC_` prefix or in a `.env` file:
|
|
225
|
+
|
|
226
|
+
```python
|
|
227
|
+
from agentic_cli import BaseSettings
|
|
228
|
+
|
|
229
|
+
class MySettings(BaseSettings):
|
|
230
|
+
model_config = SettingsConfigDict(
|
|
231
|
+
env_file=".env",
|
|
232
|
+
env_prefix="MYAPP_", # Custom prefix
|
|
233
|
+
)
|
|
234
|
+
app_name: str = "my_app"
|
|
235
|
+
workspace_dir: Path = Path.home() / ".my_app"
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Key Settings
|
|
239
|
+
|
|
240
|
+
| Setting | Env Variable | Default | Description |
|
|
241
|
+
|---------|--------------|---------|-------------|
|
|
242
|
+
| `google_api_key` | `GOOGLE_API_KEY` | None | Google API key for Gemini |
|
|
243
|
+
| `anthropic_api_key` | `ANTHROPIC_API_KEY` | None | Anthropic API key for Claude |
|
|
244
|
+
| `default_model` | `AGENTIC_DEFAULT_MODEL` | Auto | Model to use |
|
|
245
|
+
| `thinking_effort` | `AGENTIC_THINKING_EFFORT` | "medium" | Thinking level: none, low, medium, high |
|
|
246
|
+
| `orchestrator` | `AGENTIC_ORCHESTRATOR` | "adk" | Orchestrator: adk or langgraph |
|
|
247
|
+
| `workspace_dir` | `AGENTIC_WORKSPACE_DIR` | ~/.agentic | Storage directory |
|
|
248
|
+
| `log_level` | `AGENTIC_LOG_LEVEL` | "warning" | Logging level |
|
|
249
|
+
|
|
250
|
+
### Settings Context
|
|
251
|
+
|
|
252
|
+
For multi-tenant or isolated contexts:
|
|
253
|
+
|
|
254
|
+
```python
|
|
255
|
+
from agentic_cli import SettingsContext
|
|
256
|
+
|
|
257
|
+
with SettingsContext(custom_settings):
|
|
258
|
+
# All code here uses custom_settings
|
|
259
|
+
result = my_tool()
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Agent Configuration
|
|
263
|
+
|
|
264
|
+
Agents are defined declaratively using `AgentConfig`:
|
|
265
|
+
|
|
266
|
+
```python
|
|
267
|
+
from agentic_cli import AgentConfig
|
|
268
|
+
|
|
269
|
+
# Simple agent
|
|
270
|
+
assistant = AgentConfig(
|
|
271
|
+
name="assistant",
|
|
272
|
+
prompt="You are a helpful assistant.",
|
|
273
|
+
tools=[my_tool],
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
# Agent with dynamic prompt
|
|
277
|
+
def get_prompt():
|
|
278
|
+
return f"Today is {datetime.now().strftime('%Y-%m-%d')}. Help the user."
|
|
279
|
+
|
|
280
|
+
dynamic_agent = AgentConfig(
|
|
281
|
+
name="dynamic",
|
|
282
|
+
prompt=get_prompt, # Callable for dynamic prompts
|
|
283
|
+
tools=[tool_a, tool_b],
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
# Coordinator with sub-agents
|
|
287
|
+
coordinator = AgentConfig(
|
|
288
|
+
name="coordinator",
|
|
289
|
+
prompt="Route requests to the appropriate specialist.",
|
|
290
|
+
tools=[],
|
|
291
|
+
sub_agents=["researcher", "analyst"], # Names of other agents
|
|
292
|
+
description="Routes work to specialists",
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
researcher = AgentConfig(
|
|
296
|
+
name="researcher",
|
|
297
|
+
prompt="Research topics thoroughly.",
|
|
298
|
+
tools=[web_search],
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
analyst = AgentConfig(
|
|
302
|
+
name="analyst",
|
|
303
|
+
prompt="Analyze data and provide insights.",
|
|
304
|
+
tools=[calculate],
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
# Pass all configs to workflow manager
|
|
308
|
+
configs = [coordinator, researcher, analyst]
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### AgentConfig Fields
|
|
312
|
+
|
|
313
|
+
| Field | Type | Description |
|
|
314
|
+
|-------|------|-------------|
|
|
315
|
+
| `name` | str | Unique identifier |
|
|
316
|
+
| `prompt` | str \| Callable | System instruction |
|
|
317
|
+
| `tools` | list[Callable] | Available tool functions |
|
|
318
|
+
| `sub_agents` | list[str] | Names of agents this one can delegate to |
|
|
319
|
+
| `description` | str | Short description for routing |
|
|
320
|
+
| `model` | str \| None | Model override (defaults to manager's model) |
|
|
321
|
+
|
|
322
|
+
## Tools
|
|
323
|
+
|
|
324
|
+
### Creating Tools
|
|
325
|
+
|
|
326
|
+
Tools are regular Python functions with type hints and docstrings:
|
|
327
|
+
|
|
328
|
+
```python
|
|
329
|
+
def search_database(query: str, limit: int = 10) -> dict:
|
|
330
|
+
"""Search the database for matching records.
|
|
331
|
+
|
|
332
|
+
Args:
|
|
333
|
+
query: Search query string
|
|
334
|
+
limit: Maximum number of results (default: 10)
|
|
335
|
+
|
|
336
|
+
Returns:
|
|
337
|
+
Dict with results and count
|
|
338
|
+
"""
|
|
339
|
+
results = db.search(query, limit=limit)
|
|
340
|
+
return {"results": results, "count": len(results)}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Built-in Tools
|
|
344
|
+
|
|
345
|
+
#### SafePythonExecutor
|
|
346
|
+
|
|
347
|
+
Execute Python code in a sandboxed environment:
|
|
348
|
+
|
|
349
|
+
```python
|
|
350
|
+
from agentic_cli.tools import SafePythonExecutor
|
|
351
|
+
|
|
352
|
+
executor = SafePythonExecutor(default_timeout=30)
|
|
353
|
+
result = executor.execute("""
|
|
354
|
+
import numpy as np
|
|
355
|
+
data = np.array([1, 2, 3, 4, 5])
|
|
356
|
+
np.mean(data)
|
|
357
|
+
""")
|
|
358
|
+
# result = {"success": True, "result": "3.0", "output": "", "error": ""}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Allowed modules: numpy, pandas, scipy, math, json, datetime, collections, itertools, re, random
|
|
362
|
+
|
|
363
|
+
#### KnowledgeBaseManager
|
|
364
|
+
|
|
365
|
+
Semantic search over documents:
|
|
366
|
+
|
|
367
|
+
```python
|
|
368
|
+
from agentic_cli.knowledge_base import KnowledgeBaseManager, SourceType
|
|
369
|
+
|
|
370
|
+
kb = KnowledgeBaseManager(settings=settings)
|
|
371
|
+
|
|
372
|
+
# Ingest a document
|
|
373
|
+
doc = kb.ingest_document(
|
|
374
|
+
content="Machine learning is...",
|
|
375
|
+
title="ML Introduction",
|
|
376
|
+
source_type=SourceType.WEB,
|
|
377
|
+
source_url="https://example.com/ml",
|
|
378
|
+
)
|
|
379
|
+
|
|
380
|
+
# Search
|
|
381
|
+
results = kb.search("neural networks", top_k=5)
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## CLI Commands
|
|
385
|
+
|
|
386
|
+
Built-in slash commands available in all apps:
|
|
387
|
+
|
|
388
|
+
| Command | Aliases | Description |
|
|
389
|
+
|---------|---------|-------------|
|
|
390
|
+
| `/help` | | Show available commands |
|
|
391
|
+
| `/status` | | Show session and workflow status |
|
|
392
|
+
| `/clear` | | Clear the screen |
|
|
393
|
+
| `/exit` | `/quit` | Exit the application |
|
|
394
|
+
|
|
395
|
+
### Adding Custom Commands
|
|
396
|
+
|
|
397
|
+
```python
|
|
398
|
+
from agentic_cli.cli.commands import Command, CommandCategory
|
|
399
|
+
|
|
400
|
+
class MyCommand(Command):
|
|
401
|
+
def __init__(self):
|
|
402
|
+
super().__init__(
|
|
403
|
+
name="mycommand",
|
|
404
|
+
description="Do something custom",
|
|
405
|
+
category=CommandCategory.GENERAL,
|
|
406
|
+
)
|
|
407
|
+
|
|
408
|
+
async def execute(self, args: str, app: Any) -> None:
|
|
409
|
+
app.session.add_response(f"Executed with args: {args}")
|
|
410
|
+
|
|
411
|
+
# In your app
|
|
412
|
+
class MyApp(BaseCLIApp):
|
|
413
|
+
def get_custom_commands(self) -> list[Command]:
|
|
414
|
+
return [MyCommand()]
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
## Events
|
|
418
|
+
|
|
419
|
+
WorkflowEvent types for UI integration:
|
|
420
|
+
|
|
421
|
+
| EventType | Description | Metadata |
|
|
422
|
+
|-----------|-------------|----------|
|
|
423
|
+
| `TEXT` | Final text response | session_id |
|
|
424
|
+
| `THINKING` | Model reasoning | session_id |
|
|
425
|
+
| `TOOL_CALL` | Tool invocation | tool_name, tool_args |
|
|
426
|
+
| `TOOL_RESULT` | Tool result | tool_name, result, success |
|
|
427
|
+
| `CODE_EXECUTION` | Code execution result | outcome |
|
|
428
|
+
| `ERROR` | Error message | recoverable, error_code |
|
|
429
|
+
| `USER_INPUT_REQUIRED` | Tool needs user input | request_id, prompt |
|
|
430
|
+
|
|
431
|
+
### Processing Events
|
|
432
|
+
|
|
433
|
+
```python
|
|
434
|
+
async for event in manager.process(message, user_id="user1"):
|
|
435
|
+
if event.type == EventType.TEXT:
|
|
436
|
+
print(event.content)
|
|
437
|
+
elif event.type == EventType.THINKING:
|
|
438
|
+
print(f"[Thinking] {event.content}")
|
|
439
|
+
elif event.type == EventType.TOOL_CALL:
|
|
440
|
+
print(f"Calling: {event.metadata['tool_name']}")
|
|
441
|
+
elif event.type == EventType.TOOL_RESULT:
|
|
442
|
+
print(f"Result: {event.metadata['result']}")
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
## Examples
|
|
446
|
+
|
|
447
|
+
See the `examples/` directory for complete working examples:
|
|
448
|
+
|
|
449
|
+
- **hello_agent.py** - Simple assistant using Google ADK
|
|
450
|
+
- **hello_langgraph.py** - Same assistant using LangGraph
|
|
451
|
+
|
|
452
|
+
Run examples:
|
|
453
|
+
|
|
454
|
+
```bash
|
|
455
|
+
export GOOGLE_API_KEY="your-key"
|
|
456
|
+
python examples/hello_agent.py
|
|
457
|
+
|
|
458
|
+
# Or with LangGraph (requires langgraph extra)
|
|
459
|
+
pip install agentic-cli[langgraph]
|
|
460
|
+
python examples/hello_langgraph.py
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
## Development
|
|
464
|
+
|
|
465
|
+
### Running Tests
|
|
466
|
+
|
|
467
|
+
```bash
|
|
468
|
+
# With conda
|
|
469
|
+
conda run -n agenticcli python -m pytest tests/ -v
|
|
470
|
+
|
|
471
|
+
# With pip
|
|
472
|
+
pytest tests/ -v
|
|
473
|
+
|
|
474
|
+
# With coverage
|
|
475
|
+
pytest tests/ -v --cov=agentic_cli
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
### Project Structure
|
|
479
|
+
|
|
480
|
+
```
|
|
481
|
+
agentic-cli/
|
|
482
|
+
├── src/agentic_cli/
|
|
483
|
+
│ ├── __init__.py # Package exports
|
|
484
|
+
│ ├── config.py # BaseSettings, SettingsContext
|
|
485
|
+
│ ├── cli/
|
|
486
|
+
│ │ ├── app.py # BaseCLIApp
|
|
487
|
+
│ │ └── commands.py # Command, CommandRegistry
|
|
488
|
+
│ ├── workflow/
|
|
489
|
+
│ │ ├── events.py # WorkflowEvent, EventType
|
|
490
|
+
│ │ ├── config.py # AgentConfig
|
|
491
|
+
│ │ ├── adk_manager.py # GoogleADKWorkflowManager
|
|
492
|
+
│ │ └── langgraph_manager.py # LangGraphWorkflowManager
|
|
493
|
+
│ ├── tools/
|
|
494
|
+
│ │ └── executor.py # SafePythonExecutor
|
|
495
|
+
│ └── knowledge_base/
|
|
496
|
+
│ └── manager.py # KnowledgeBaseManager
|
|
497
|
+
├── examples/
|
|
498
|
+
│ ├── hello_agent.py
|
|
499
|
+
│ └── hello_langgraph.py
|
|
500
|
+
└── tests/
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
## License
|
|
504
|
+
|
|
505
|
+
MIT
|