openagent-framework 0.1.1__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.
- openagent_framework-0.1.1/PKG-INFO +571 -0
- openagent_framework-0.1.1/docs/README.md +545 -0
- openagent_framework-0.1.1/openagent/__init__.py +5 -0
- openagent_framework-0.1.1/openagent/agent.py +262 -0
- openagent_framework-0.1.1/openagent/channels/__init__.py +3 -0
- openagent_framework-0.1.1/openagent/channels/base.py +91 -0
- openagent_framework-0.1.1/openagent/channels/discord.py +136 -0
- openagent_framework-0.1.1/openagent/channels/telegram.py +161 -0
- openagent_framework-0.1.1/openagent/channels/whatsapp.py +196 -0
- openagent_framework-0.1.1/openagent/cli.py +430 -0
- openagent_framework-0.1.1/openagent/config.py +74 -0
- openagent_framework-0.1.1/openagent/mcp/__init__.py +3 -0
- openagent_framework-0.1.1/openagent/mcp/client.py +419 -0
- openagent_framework-0.1.1/openagent/mcps/computer-use/.gitignore +2 -0
- openagent_framework-0.1.1/openagent/mcps/computer-use/package.json +27 -0
- openagent_framework-0.1.1/openagent/mcps/computer-use/src/index.ts +14 -0
- openagent_framework-0.1.1/openagent/mcps/computer-use/src/main.ts +73 -0
- openagent_framework-0.1.1/openagent/mcps/computer-use/src/tools/computer.ts +444 -0
- openagent_framework-0.1.1/openagent/mcps/computer-use/src/tools/index.ts +6 -0
- openagent_framework-0.1.1/openagent/mcps/computer-use/src/utils/response.ts +8 -0
- openagent_framework-0.1.1/openagent/mcps/computer-use/src/xdotoolStringToKeys.ts +230 -0
- openagent_framework-0.1.1/openagent/mcps/computer-use/tsconfig.json +16 -0
- openagent_framework-0.1.1/openagent/mcps/editor/.gitignore +2 -0
- openagent_framework-0.1.1/openagent/mcps/editor/package.json +23 -0
- openagent_framework-0.1.1/openagent/mcps/editor/src/index.ts +267 -0
- openagent_framework-0.1.1/openagent/mcps/editor/tsconfig.json +14 -0
- openagent_framework-0.1.1/openagent/mcps/messaging/requirements.txt +4 -0
- openagent_framework-0.1.1/openagent/mcps/messaging/server.py +277 -0
- openagent_framework-0.1.1/openagent/mcps/shell/.gitignore +2 -0
- openagent_framework-0.1.1/openagent/mcps/shell/package.json +22 -0
- openagent_framework-0.1.1/openagent/mcps/shell/src/index.ts +149 -0
- openagent_framework-0.1.1/openagent/mcps/shell/tsconfig.json +14 -0
- openagent_framework-0.1.1/openagent/mcps/web-search/.gitignore +2 -0
- openagent_framework-0.1.1/openagent/mcps/web-search/package.json +28 -0
- openagent_framework-0.1.1/openagent/mcps/web-search/src/browser-pool.ts +131 -0
- openagent_framework-0.1.1/openagent/mcps/web-search/src/content-extractor.ts +260 -0
- openagent_framework-0.1.1/openagent/mcps/web-search/src/enhanced-content-extractor.ts +590 -0
- openagent_framework-0.1.1/openagent/mcps/web-search/src/index.ts +538 -0
- openagent_framework-0.1.1/openagent/mcps/web-search/src/rate-limiter.ts +45 -0
- openagent_framework-0.1.1/openagent/mcps/web-search/src/search-engine.ts +1158 -0
- openagent_framework-0.1.1/openagent/mcps/web-search/src/types.ts +80 -0
- openagent_framework-0.1.1/openagent/mcps/web-search/src/utils.ts +61 -0
- openagent_framework-0.1.1/openagent/mcps/web-search/tsconfig.json +16 -0
- openagent_framework-0.1.1/openagent/memory/__init__.py +5 -0
- openagent_framework-0.1.1/openagent/memory/db.py +341 -0
- openagent_framework-0.1.1/openagent/memory/knowledge.py +435 -0
- openagent_framework-0.1.1/openagent/memory/manager.py +233 -0
- openagent_framework-0.1.1/openagent/models/__init__.py +6 -0
- openagent_framework-0.1.1/openagent/models/base.py +60 -0
- openagent_framework-0.1.1/openagent/models/claude_api.py +127 -0
- openagent_framework-0.1.1/openagent/models/claude_cli.py +169 -0
- openagent_framework-0.1.1/openagent/models/zhipu.py +143 -0
- openagent_framework-0.1.1/openagent/scheduler.py +133 -0
- openagent_framework-0.1.1/openagent/scripts/restart.sh +10 -0
- openagent_framework-0.1.1/openagent/scripts/setup.sh +65 -0
- openagent_framework-0.1.1/openagent/scripts/start.sh +71 -0
- openagent_framework-0.1.1/openagent/scripts/status.sh +35 -0
- openagent_framework-0.1.1/openagent/scripts/stop.sh +25 -0
- openagent_framework-0.1.1/openagent/service.py +224 -0
- openagent_framework-0.1.1/openagent_framework.egg-info/PKG-INFO +571 -0
- openagent_framework-0.1.1/openagent_framework.egg-info/SOURCES.txt +65 -0
- openagent_framework-0.1.1/openagent_framework.egg-info/dependency_links.txt +1 -0
- openagent_framework-0.1.1/openagent_framework.egg-info/entry_points.txt +2 -0
- openagent_framework-0.1.1/openagent_framework.egg-info/requires.txt +22 -0
- openagent_framework-0.1.1/openagent_framework.egg-info/top_level.txt +1 -0
- openagent_framework-0.1.1/pyproject.toml +48 -0
- openagent_framework-0.1.1/setup.cfg +4 -0
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openagent-framework
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Simplified LLM agent framework with MCP, memory, and multi-channel support
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: anthropic>=0.40.0
|
|
9
|
+
Requires-Dist: openai>=1.50.0
|
|
10
|
+
Requires-Dist: mcp>=1.0.0
|
|
11
|
+
Requires-Dist: click>=8.1.0
|
|
12
|
+
Requires-Dist: rich>=13.0.0
|
|
13
|
+
Requires-Dist: pyyaml>=6.0
|
|
14
|
+
Requires-Dist: aiosqlite>=0.20.0
|
|
15
|
+
Requires-Dist: croniter>=2.0.0
|
|
16
|
+
Provides-Extra: telegram
|
|
17
|
+
Requires-Dist: python-telegram-bot>=21.0; extra == "telegram"
|
|
18
|
+
Provides-Extra: discord
|
|
19
|
+
Requires-Dist: discord.py>=2.3.0; extra == "discord"
|
|
20
|
+
Provides-Extra: whatsapp
|
|
21
|
+
Requires-Dist: whatsapp-api-client-python>=0.0.46; extra == "whatsapp"
|
|
22
|
+
Provides-Extra: all
|
|
23
|
+
Requires-Dist: python-telegram-bot>=21.0; extra == "all"
|
|
24
|
+
Requires-Dist: discord.py>=2.3.0; extra == "all"
|
|
25
|
+
Requires-Dist: whatsapp-api-client-python>=0.0.46; extra == "all"
|
|
26
|
+
|
|
27
|
+
# OpenAgent
|
|
28
|
+
|
|
29
|
+
Simplified LLM agent framework with MCP tools, persistent memory, and multi-channel support.
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install -e . # core + CLI
|
|
35
|
+
pip install -e ".[all]" # includes Telegram, Discord, WhatsApp
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Set your API key:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Start chatting:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
openagent chat
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Models
|
|
53
|
+
|
|
54
|
+
OpenAgent supports multiple LLM providers. Set the provider in `openagent.yaml` or via code.
|
|
55
|
+
|
|
56
|
+
### Claude API (Anthropic SDK)
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
model:
|
|
60
|
+
provider: claude-api
|
|
61
|
+
model_id: claude-sonnet-4-6 # or claude-opus-4-6, claude-haiku-4-5-20251001
|
|
62
|
+
api_key: ${ANTHROPIC_API_KEY}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from openagent.models import ClaudeAPI
|
|
67
|
+
model = ClaudeAPI(model="claude-sonnet-4-6", api_key="sk-ant-...")
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Claude CLI (Claude Code SDK)
|
|
71
|
+
|
|
72
|
+
Uses the `claude` CLI tool installed on your machine. Must be authenticated first (`claude login`).
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
model:
|
|
76
|
+
provider: claude-cli
|
|
77
|
+
model_id: claude-sonnet-4-6 # optional, uses CLI default if omitted
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from openagent.models import ClaudeCLI
|
|
82
|
+
model = ClaudeCLI(model="claude-sonnet-4-6")
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Z.ai GLM (OpenAI-compatible)
|
|
86
|
+
|
|
87
|
+
```yaml
|
|
88
|
+
model:
|
|
89
|
+
provider: zhipu
|
|
90
|
+
model_id: glm-4 # or glm-4-flash, glm-3-turbo
|
|
91
|
+
api_key: ${ZHIPU_API_KEY}
|
|
92
|
+
base_url: https://open.bigmodel.cn/api/paas/v4 # default
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from openagent.models import ZhipuGLM
|
|
97
|
+
model = ZhipuGLM(model="glm-4", api_key="your-key")
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Adding Custom / Local Models
|
|
101
|
+
|
|
102
|
+
Any OpenAI-compatible endpoint works with `ZhipuGLM` by changing `base_url`:
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
# Ollama
|
|
106
|
+
model = ZhipuGLM(model="llama3", base_url="http://localhost:11434/v1", api_key="ollama")
|
|
107
|
+
|
|
108
|
+
# vLLM
|
|
109
|
+
model = ZhipuGLM(model="mistral", base_url="http://localhost:8000/v1", api_key="unused")
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Or subclass `BaseModel` for full control:
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from openagent.models.base import BaseModel, ModelResponse
|
|
116
|
+
|
|
117
|
+
class MyModel(BaseModel):
|
|
118
|
+
async def generate(self, messages, system=None, tools=None):
|
|
119
|
+
# Your implementation
|
|
120
|
+
return ModelResponse(content="Hello!")
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## MCP (Model Context Protocol)
|
|
126
|
+
|
|
127
|
+
MCP servers are automatically available to all models and channels. OpenAgent includes **6 default MCPs** that are always loaded — your custom MCPs are merged on top.
|
|
128
|
+
|
|
129
|
+
### Default MCPs (always loaded)
|
|
130
|
+
|
|
131
|
+
These are injected automatically. No configuration needed.
|
|
132
|
+
|
|
133
|
+
| Name | Source | Tools | Requires |
|
|
134
|
+
|---|---|---|---|
|
|
135
|
+
| `filesystem` | [@modelcontextprotocol/server-filesystem](https://www.npmjs.com/package/@modelcontextprotocol/server-filesystem) (official) | Read, write, list, search files | Node.js |
|
|
136
|
+
| `editor` | Custom (bundled) | `edit` (surgical find-replace), `grep` (regex search with context), `glob` (pattern file matching) | Node.js |
|
|
137
|
+
| `web-search` | [web-search-mcp](https://github.com/mrkrsl/web-search-mcp) (bundled) | `full-web-search`, `get-web-search-summaries`, `get-single-web-page-content` — no API key needed | Node.js + Playwright |
|
|
138
|
+
| `shell` | Custom (bundled) | `shell_exec`, `shell_which` — cross-platform shell execution | Node.js |
|
|
139
|
+
| `computer-use` | Custom (bundled) | `computer` — screenshot, mouse & keyboard control | Node.js |
|
|
140
|
+
| `chrome-devtools` | [chrome-devtools-mcp](https://www.npmjs.com/package/chrome-devtools-mcp) (official) | Browser automation, performance analysis, DOM inspection (29 tools) | Node.js + Chrome |
|
|
141
|
+
|
|
142
|
+
### Optional Built-in MCPs
|
|
143
|
+
|
|
144
|
+
These ship with OpenAgent but are **not loaded by default** (they require credentials):
|
|
145
|
+
|
|
146
|
+
| Name | Tools | Requires |
|
|
147
|
+
|---|---|---|
|
|
148
|
+
| `messaging` | `telegram_send_message`, `telegram_send_file`, `discord_send_message`, `discord_send_file`, `whatsapp_send_message`, `whatsapp_send_file` | Channel tokens (env vars) |
|
|
149
|
+
|
|
150
|
+
Enable messaging MCP:
|
|
151
|
+
```yaml
|
|
152
|
+
mcp:
|
|
153
|
+
- builtin: messaging
|
|
154
|
+
env:
|
|
155
|
+
TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
All defaults are cross-platform (macOS, Linux, Windows). If a prerequisite is missing, that MCP is skipped with a warning.
|
|
159
|
+
|
|
160
|
+
### Disabling Defaults
|
|
161
|
+
|
|
162
|
+
```yaml
|
|
163
|
+
# Disable all defaults
|
|
164
|
+
mcp_defaults: false
|
|
165
|
+
|
|
166
|
+
# Disable specific ones
|
|
167
|
+
mcp_disable: ["computer-use", "web-search"]
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
# Programmatic
|
|
172
|
+
registry = MCPRegistry.from_config(mcp_config=[], include_defaults=False)
|
|
173
|
+
registry = MCPRegistry.from_config(mcp_config=[], disable=["computer-use"])
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Adding Your Own MCPs
|
|
177
|
+
|
|
178
|
+
User MCPs are merged on top of defaults. If you define one with the same name as a default, yours replaces it.
|
|
179
|
+
|
|
180
|
+
```yaml
|
|
181
|
+
mcp:
|
|
182
|
+
# Add a custom MCP
|
|
183
|
+
- name: database
|
|
184
|
+
command: ["python", "-m", "mcp_server_sqlite"]
|
|
185
|
+
args: ["--db", "mydata.db"]
|
|
186
|
+
|
|
187
|
+
# Remote MCP server
|
|
188
|
+
- name: web-search
|
|
189
|
+
url: "http://localhost:8080/sse"
|
|
190
|
+
|
|
191
|
+
# Override the default filesystem root
|
|
192
|
+
- name: filesystem
|
|
193
|
+
command: ["npx", "-y", "@modelcontextprotocol/server-filesystem"]
|
|
194
|
+
args: ["/Users/me/projects"]
|
|
195
|
+
|
|
196
|
+
# With environment variables
|
|
197
|
+
- name: github
|
|
198
|
+
command: ["npx", "-y", "@anthropic/mcp-github"]
|
|
199
|
+
env:
|
|
200
|
+
GITHUB_TOKEN: ${GITHUB_TOKEN}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Programmatic Usage
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
from openagent.mcp import MCPTools, MCPRegistry
|
|
207
|
+
|
|
208
|
+
# With defaults (filesystem, fetch, shell, computer-use) + custom
|
|
209
|
+
registry = MCPRegistry.from_config(mcp_config=[
|
|
210
|
+
{"name": "search", "url": "http://localhost:8080/sse"},
|
|
211
|
+
])
|
|
212
|
+
|
|
213
|
+
# Without defaults
|
|
214
|
+
registry = MCPRegistry.from_config(mcp_config=[...], include_defaults=False)
|
|
215
|
+
|
|
216
|
+
# Manual
|
|
217
|
+
registry = MCPRegistry()
|
|
218
|
+
registry.add(MCPTools(name="fs", command=["npx", "-y", "@modelcontextprotocol/server-filesystem"], args=["/data"]))
|
|
219
|
+
|
|
220
|
+
# Pass to agent
|
|
221
|
+
agent = Agent(model=model, mcp_registry=registry)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### List Available Tools
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
openagent mcp list
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Memory
|
|
233
|
+
|
|
234
|
+
OpenAgent has a **dual memory system**:
|
|
235
|
+
|
|
236
|
+
1. **SQL memories** (quick facts) — user preferences, short facts stored in SQLite rows
|
|
237
|
+
2. **Knowledge base** (detailed docs) — Obsidian-compatible `.md` files indexed by FTS5
|
|
238
|
+
|
|
239
|
+
### Configuration
|
|
240
|
+
|
|
241
|
+
```yaml
|
|
242
|
+
memory:
|
|
243
|
+
db_path: "./openagent.db" # SQLite database for sessions, messages, facts
|
|
244
|
+
knowledge_dir: "./memories" # Directory for .md knowledge files
|
|
245
|
+
auto_extract: true # auto-extract facts + knowledge from conversations
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### How It Works
|
|
249
|
+
|
|
250
|
+
- **Session history**: every message stored immediately in SQLite
|
|
251
|
+
- **Quick-access facts**: short user preferences extracted automatically → SQLite `memories` table
|
|
252
|
+
- **Knowledge base**: detailed procedures, architecture notes, references → `.md` files in `memories/` directory
|
|
253
|
+
- **Hybrid search**: FTS5 full-text search across all knowledge files + SQL queries for facts
|
|
254
|
+
- **Deduplication**: checks for overlap before storing new memories
|
|
255
|
+
- **Obsidian-compatible**: `.md` files with YAML frontmatter, `[[wikilinks]]`, and tags — open the `memories/` folder in Obsidian for graph view and visual browsing
|
|
256
|
+
|
|
257
|
+
### Memory File Format
|
|
258
|
+
|
|
259
|
+
```markdown
|
|
260
|
+
---
|
|
261
|
+
topic: deploy
|
|
262
|
+
tags: [k8s, wardrobe, ovh]
|
|
263
|
+
links: [mixout-server-architecture, ovh-vps-setup]
|
|
264
|
+
created: 2026-04-07T12:00:00
|
|
265
|
+
updated: 2026-04-07T12:00:00
|
|
266
|
+
---
|
|
267
|
+
# Deploy Wardrobe Service
|
|
268
|
+
To deploy the wardrobe service to OVH k3s...
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Programmatic Usage
|
|
272
|
+
|
|
273
|
+
```python
|
|
274
|
+
from openagent.memory import MemoryDB, KnowledgeBase
|
|
275
|
+
|
|
276
|
+
agent = Agent(model=model, memory="my_app.db", knowledge_dir="./memories")
|
|
277
|
+
|
|
278
|
+
# Search knowledge base
|
|
279
|
+
results = await agent._memory.search_knowledge("how to deploy wardrobe")
|
|
280
|
+
|
|
281
|
+
# Add knowledge manually
|
|
282
|
+
await agent._memory.remember_knowledge(
|
|
283
|
+
title="Deploy Procedure",
|
|
284
|
+
content="rsync + docker build + k3s import...",
|
|
285
|
+
topic="deploy",
|
|
286
|
+
tags=["k8s", "ovh"],
|
|
287
|
+
)
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Disable Memory
|
|
291
|
+
|
|
292
|
+
```python
|
|
293
|
+
agent = Agent(model=model) # no memory parameter = no persistence
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Channels
|
|
299
|
+
|
|
300
|
+
### Telegram
|
|
301
|
+
|
|
302
|
+
1. Create a bot via [@BotFather](https://t.me/BotFather) on Telegram
|
|
303
|
+
2. Get the bot token
|
|
304
|
+
|
|
305
|
+
```yaml
|
|
306
|
+
channels:
|
|
307
|
+
telegram:
|
|
308
|
+
token: ${TELEGRAM_BOT_TOKEN}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
export TELEGRAM_BOT_TOKEN=123456:ABC-DEF...
|
|
313
|
+
openagent serve --channel telegram
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
```python
|
|
317
|
+
from openagent.channels.telegram import TelegramChannel
|
|
318
|
+
|
|
319
|
+
channel = TelegramChannel(agent=agent, token="YOUR_BOT_TOKEN")
|
|
320
|
+
await channel.start()
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Discord
|
|
324
|
+
|
|
325
|
+
1. Go to [Discord Developer Portal](https://discord.com/developers/applications)
|
|
326
|
+
2. Create an application, add a bot, copy the token
|
|
327
|
+
3. Enable "Message Content Intent" in Bot settings
|
|
328
|
+
4. Invite the bot to your server with `bot` + `applications.commands` scopes
|
|
329
|
+
|
|
330
|
+
```yaml
|
|
331
|
+
channels:
|
|
332
|
+
discord:
|
|
333
|
+
token: ${DISCORD_BOT_TOKEN}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
export DISCORD_BOT_TOKEN=MTI...
|
|
338
|
+
openagent serve --channel discord
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
```python
|
|
342
|
+
from openagent.channels.discord import DiscordChannel
|
|
343
|
+
|
|
344
|
+
channel = DiscordChannel(agent=agent, token="YOUR_BOT_TOKEN")
|
|
345
|
+
await channel.start()
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
The bot responds to DMs and mentions.
|
|
349
|
+
|
|
350
|
+
### WhatsApp (Green API)
|
|
351
|
+
|
|
352
|
+
No WhatsApp Business account needed. Uses [Green API](https://green-api.com) free tier.
|
|
353
|
+
|
|
354
|
+
1. Sign up at https://green-api.com
|
|
355
|
+
2. Create an instance and scan the QR code with your phone
|
|
356
|
+
3. Copy the Instance ID and API Token
|
|
357
|
+
|
|
358
|
+
```yaml
|
|
359
|
+
channels:
|
|
360
|
+
whatsapp:
|
|
361
|
+
green_api_id: ${GREEN_API_ID}
|
|
362
|
+
green_api_token: ${GREEN_API_TOKEN}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
export GREEN_API_ID=1101...
|
|
367
|
+
export GREEN_API_TOKEN=abc123...
|
|
368
|
+
openagent serve --channel whatsapp
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
```python
|
|
372
|
+
from openagent.channels.whatsapp import WhatsAppChannel
|
|
373
|
+
|
|
374
|
+
channel = WhatsAppChannel(agent=agent, instance_id="ID", api_token="TOKEN")
|
|
375
|
+
await channel.start()
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Running Multiple Channels
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
# All configured channels
|
|
382
|
+
openagent serve
|
|
383
|
+
|
|
384
|
+
# Specific channels
|
|
385
|
+
openagent serve --channel telegram --channel discord
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## YAML Config Reference
|
|
391
|
+
|
|
392
|
+
Full `openagent.yaml` example:
|
|
393
|
+
|
|
394
|
+
```yaml
|
|
395
|
+
name: my-assistant
|
|
396
|
+
|
|
397
|
+
system_prompt: |
|
|
398
|
+
You are a helpful assistant specialized in coding.
|
|
399
|
+
|
|
400
|
+
model:
|
|
401
|
+
provider: claude-api # claude-api | claude-cli | zhipu
|
|
402
|
+
model_id: claude-sonnet-4-6
|
|
403
|
+
api_key: ${ANTHROPIC_API_KEY}
|
|
404
|
+
# base_url: https://... # only for zhipu/OpenAI-compatible
|
|
405
|
+
|
|
406
|
+
# mcp_defaults: true # set false to disable all default MCPs
|
|
407
|
+
# mcp_disable: ["computer-use"] # disable specific default MCPs
|
|
408
|
+
|
|
409
|
+
mcp: # user MCPs (merged on top of defaults)
|
|
410
|
+
- name: web-search
|
|
411
|
+
url: "http://localhost:8080/sse"
|
|
412
|
+
|
|
413
|
+
memory:
|
|
414
|
+
db_path: "./openagent.db"
|
|
415
|
+
auto_extract: true
|
|
416
|
+
|
|
417
|
+
channels:
|
|
418
|
+
telegram:
|
|
419
|
+
token: ${TELEGRAM_BOT_TOKEN}
|
|
420
|
+
discord:
|
|
421
|
+
token: ${DISCORD_BOT_TOKEN}
|
|
422
|
+
whatsapp:
|
|
423
|
+
green_api_id: ${GREEN_API_ID}
|
|
424
|
+
green_api_token: ${GREEN_API_TOKEN}
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
Environment variables are substituted using `${VAR_NAME}` syntax.
|
|
428
|
+
|
|
429
|
+
---
|
|
430
|
+
|
|
431
|
+
## Programmatic Usage
|
|
432
|
+
|
|
433
|
+
Use OpenAgent as a library in your own Python project:
|
|
434
|
+
|
|
435
|
+
```python
|
|
436
|
+
import asyncio
|
|
437
|
+
from openagent import Agent
|
|
438
|
+
from openagent.models import ClaudeAPI
|
|
439
|
+
from openagent.mcp import MCPTools
|
|
440
|
+
from openagent.memory import MemoryDB
|
|
441
|
+
|
|
442
|
+
async def main():
|
|
443
|
+
agent = Agent(
|
|
444
|
+
name="my-bot",
|
|
445
|
+
model=ClaudeAPI(api_key="sk-ant-...", model="claude-sonnet-4-6"),
|
|
446
|
+
system_prompt="You are a helpful coding assistant.",
|
|
447
|
+
mcp_tools=[
|
|
448
|
+
MCPTools(command=["npx", "-y", "@anthropic/mcp-filesystem"], args=["/data"]),
|
|
449
|
+
],
|
|
450
|
+
memory=MemoryDB("my_app.db"),
|
|
451
|
+
)
|
|
452
|
+
|
|
453
|
+
async with agent:
|
|
454
|
+
response = await agent.run("What files are in /data?", user_id="user-1")
|
|
455
|
+
print(response)
|
|
456
|
+
|
|
457
|
+
asyncio.run(main())
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
### Streaming
|
|
461
|
+
|
|
462
|
+
```python
|
|
463
|
+
async with agent:
|
|
464
|
+
async for chunk in agent.stream_run("Tell me a story"):
|
|
465
|
+
print(chunk, end="", flush=True)
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
---
|
|
469
|
+
|
|
470
|
+
## Environment Variables
|
|
471
|
+
|
|
472
|
+
| Variable | Description |
|
|
473
|
+
|---|---|
|
|
474
|
+
| `ANTHROPIC_API_KEY` | API key for Claude API |
|
|
475
|
+
| `ZHIPU_API_KEY` | API key for Z.ai GLM |
|
|
476
|
+
| `TELEGRAM_BOT_TOKEN` | Telegram bot token |
|
|
477
|
+
| `DISCORD_BOT_TOKEN` | Discord bot token |
|
|
478
|
+
| `GREEN_API_ID` | Green API instance ID (WhatsApp) |
|
|
479
|
+
| `GREEN_API_TOKEN` | Green API token (WhatsApp) |
|
|
480
|
+
|
|
481
|
+
---
|
|
482
|
+
|
|
483
|
+
## Scheduler
|
|
484
|
+
|
|
485
|
+
Cron-based task scheduler. Tasks are stored in SQLite and survive process restarts and reboots.
|
|
486
|
+
|
|
487
|
+
### Configuration
|
|
488
|
+
|
|
489
|
+
```yaml
|
|
490
|
+
scheduler:
|
|
491
|
+
enabled: true
|
|
492
|
+
tasks:
|
|
493
|
+
- name: daily-report
|
|
494
|
+
cron: "0 9 * * *"
|
|
495
|
+
prompt: "Generate and send the daily status report"
|
|
496
|
+
- name: health-check
|
|
497
|
+
cron: "*/30 * * * *"
|
|
498
|
+
prompt: "Check all services and report any issues"
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
### CLI Management
|
|
502
|
+
|
|
503
|
+
```bash
|
|
504
|
+
openagent task add --name "daily-report" --cron "0 9 * * *" --prompt "Generate report"
|
|
505
|
+
openagent task list
|
|
506
|
+
openagent task remove <id>
|
|
507
|
+
openagent task enable <id>
|
|
508
|
+
openagent task disable <id>
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
The scheduler runs automatically as part of `openagent serve`.
|
|
512
|
+
|
|
513
|
+
---
|
|
514
|
+
|
|
515
|
+
## Media Support
|
|
516
|
+
|
|
517
|
+
All channels (Telegram, Discord, WhatsApp) support sending and receiving:
|
|
518
|
+
- Images (jpg, png, gif, webp)
|
|
519
|
+
- Files/documents (any type)
|
|
520
|
+
- Voice messages (ogg, mp3, wav)
|
|
521
|
+
- Videos (mp4, mov)
|
|
522
|
+
|
|
523
|
+
The agent can send files by including markers in its response:
|
|
524
|
+
```
|
|
525
|
+
Here's the chart you requested:
|
|
526
|
+
[IMAGE:/path/to/chart.png]
|
|
527
|
+
|
|
528
|
+
And the full report:
|
|
529
|
+
[FILE:/path/to/report.pdf]
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
---
|
|
533
|
+
|
|
534
|
+
## Auto-Start (System Service)
|
|
535
|
+
|
|
536
|
+
Install OpenAgent as a system service that starts on boot:
|
|
537
|
+
|
|
538
|
+
```bash
|
|
539
|
+
openagent install # Register as system service
|
|
540
|
+
openagent uninstall # Remove system service
|
|
541
|
+
openagent status # Check if service is running
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
Cross-platform:
|
|
545
|
+
- **macOS**: launchd (~/Library/LaunchAgents/)
|
|
546
|
+
- **Linux**: systemd user unit (~/.config/systemd/user/)
|
|
547
|
+
- **Windows**: Task Scheduler
|
|
548
|
+
|
|
549
|
+
The service runs `openagent serve` with all configured channels and the scheduler.
|
|
550
|
+
|
|
551
|
+
---
|
|
552
|
+
|
|
553
|
+
## CLI Reference
|
|
554
|
+
|
|
555
|
+
```bash
|
|
556
|
+
openagent chat # Interactive chat
|
|
557
|
+
openagent chat -m zhipu # Chat with Z.ai GLM
|
|
558
|
+
openagent chat --model-id glm-4-flash # Override model ID
|
|
559
|
+
openagent chat -s session-123 # Resume session
|
|
560
|
+
openagent serve # Start all channels + scheduler
|
|
561
|
+
openagent serve -ch telegram # Start specific channel
|
|
562
|
+
openagent task add -n "name" -c "cron" -p "prompt" # Add scheduled task
|
|
563
|
+
openagent task list # List tasks
|
|
564
|
+
openagent task remove <id> # Remove task
|
|
565
|
+
openagent mcp list # List MCP tools
|
|
566
|
+
openagent install # Install as system service
|
|
567
|
+
openagent uninstall # Remove system service
|
|
568
|
+
openagent status # Check service status
|
|
569
|
+
openagent --config my.yaml chat # Use custom config file
|
|
570
|
+
openagent -v chat # Verbose/debug mode
|
|
571
|
+
```
|