agentix-cli 0.8.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +387 -116
- package/dist/agent-5KIMJI3F.js +2 -0
- package/dist/chunk-34UAFPK4.js +10 -0
- package/dist/chunk-34UAFPK4.js.map +1 -0
- package/dist/{chunk-X7UN6JAA.js → chunk-6MKAXEE5.js} +2 -2
- package/dist/chunk-CJ45Y2IR.js +12 -0
- package/dist/chunk-CJ45Y2IR.js.map +1 -0
- package/dist/chunk-D6EDMQRV.js +108 -0
- package/dist/chunk-D6EDMQRV.js.map +1 -0
- package/dist/chunk-DSYKYZMT.js +2 -0
- package/dist/chunk-DSYKYZMT.js.map +1 -0
- package/dist/chunk-HI24KAEY.js +54 -0
- package/dist/chunk-HI24KAEY.js.map +1 -0
- package/dist/{chunk-MGMZNJCE.js → chunk-KXZMYLHQ.js} +27 -27
- package/dist/chunk-KXZMYLHQ.js.map +1 -0
- package/dist/chunk-MCJUAE6V.js +6 -0
- package/dist/chunk-MCJUAE6V.js.map +1 -0
- package/dist/chunk-QOYAX2FT.js +2 -0
- package/dist/chunk-QOYAX2FT.js.map +1 -0
- package/dist/chunk-QZP65I2H.js +45 -0
- package/dist/chunk-QZP65I2H.js.map +1 -0
- package/dist/chunk-T25UEXVK.js +126 -0
- package/dist/chunk-T25UEXVK.js.map +1 -0
- package/dist/chunk-VH23CDHL.js +157 -0
- package/dist/chunk-VH23CDHL.js.map +1 -0
- package/dist/chunk-WJ6ZF6EZ.js +6 -0
- package/dist/chunk-WJ6ZF6EZ.js.map +1 -0
- package/dist/chunk-ZRYBSI5G.js +23 -0
- package/dist/chunk-ZRYBSI5G.js.map +1 -0
- package/dist/cli.js +277 -36
- package/dist/cli.js.map +1 -1
- package/dist/compaction-7I3E5QUO.js +28 -0
- package/dist/compaction-7I3E5QUO.js.map +1 -0
- package/dist/config-HAD5E4YX.js +2 -0
- package/dist/debug-N3B5NVJU.js +2 -0
- package/dist/heal-OTGT5HHJ.js +2 -0
- package/dist/index.d.ts +1849 -368
- package/dist/index.js +39 -35
- package/dist/index.js.map +1 -1
- package/dist/loader-YQE6XJBT.js +2 -0
- package/dist/loader-YQE6XJBT.js.map +1 -0
- package/dist/memory-extract-RGPUPMKU.js +2 -0
- package/dist/memory-extract-RGPUPMKU.js.map +1 -0
- package/dist/{providers-AVYG63KK.js → providers-G3WZ4RVJ.js} +2 -2
- package/dist/providers-G3WZ4RVJ.js.map +1 -0
- package/dist/registry-CDWY7CLL.js +2 -0
- package/dist/registry-CDWY7CLL.js.map +1 -0
- package/dist/subagent-WV7QKQ3L.js +3 -0
- package/dist/subagent-WV7QKQ3L.js.map +1 -0
- package/dist/usage-dashboard-2TJQBFSH.js +404 -0
- package/dist/usage-dashboard-2TJQBFSH.js.map +1 -0
- package/dist/workspace-setup-QQTCJY4B.js +2 -0
- package/dist/workspace-setup-QQTCJY4B.js.map +1 -0
- package/package.json +4 -1
- package/dist/agent-K2YOEOJ5.js +0 -2
- package/dist/chunk-F73GPYCO.js +0 -106
- package/dist/chunk-F73GPYCO.js.map +0 -1
- package/dist/chunk-FRFR27IN.js +0 -3
- package/dist/chunk-FRFR27IN.js.map +0 -1
- package/dist/chunk-MGMZNJCE.js.map +0 -1
- package/dist/chunk-NGKOM4ZZ.js +0 -137
- package/dist/chunk-NGKOM4ZZ.js.map +0 -1
- package/dist/chunk-Z4GC5D6D.js +0 -12
- package/dist/chunk-Z4GC5D6D.js.map +0 -1
- package/dist/heal-UV5A6B5T.js +0 -2
- package/dist/loader-6VSM6FSY.js +0 -2
- /package/dist/{agent-K2YOEOJ5.js.map → agent-5KIMJI3F.js.map} +0 -0
- /package/dist/{chunk-X7UN6JAA.js.map → chunk-6MKAXEE5.js.map} +0 -0
- /package/dist/{heal-UV5A6B5T.js.map → config-HAD5E4YX.js.map} +0 -0
- /package/dist/{loader-6VSM6FSY.js.map → debug-N3B5NVJU.js.map} +0 -0
- /package/dist/{providers-AVYG63KK.js.map → heal-OTGT5HHJ.js.map} +0 -0
package/README.md
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
# AgentX
|
|
2
2
|
|
|
3
|
-
**Self-hosted multi-agent orchestrator.** Routes messages from Telegram, WhatsApp, Discord, GitLab, crons, webhooks, and cross-machine
|
|
3
|
+
**Self-hosted multi-agent orchestrator.** Routes messages from Telegram, WhatsApp, Discord, GitLab, crons, webhooks, and cross-machine mesh to AI agents running on Claude Code, OpenAI, Ollama, or any LLM provider.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Why AgentX?
|
|
6
|
+
|
|
7
|
+
Existing multi-agent frameworks (CrewAI, AutoGen, LangGraph) are SDK-first, Python-heavy, and cloud-dependent. AgentX is **infrastructure-first** — closer to systemd for AI agents than to another framework.
|
|
8
|
+
|
|
9
|
+
- **BYOAI** — Bring your own AI. Claude, OpenAI, Ollama, whatever
|
|
10
|
+
- **Agents = directories** — Each agent is a workspace with config files. No code required
|
|
11
|
+
- **Mesh federation** — Agents on different machines collaborate over Tailscale/VPN
|
|
12
|
+
- **Channel routing** — Telegram, GitLab, WhatsApp, Discord, webhooks — built in
|
|
13
|
+
- **Cross-channel messaging** — Agents receive on one channel, send to another via `/send` API
|
|
14
|
+
- **Wiki memory** — Agents build compounding knowledge from conversations
|
|
15
|
+
- **Live monitoring** — Real-time SSE event stream + debug mode with categories
|
|
6
16
|
|
|
7
17
|
## Install
|
|
8
18
|
|
|
@@ -10,16 +20,17 @@
|
|
|
10
20
|
npm install -g agentix-cli
|
|
11
21
|
```
|
|
12
22
|
|
|
13
|
-
## Quick
|
|
23
|
+
## Quick Start
|
|
14
24
|
|
|
15
25
|
```bash
|
|
16
|
-
agentx init
|
|
17
|
-
agentx agent add
|
|
18
|
-
agentx channel add
|
|
19
|
-
agentx daemon start
|
|
26
|
+
agentx init # Create config + workspace
|
|
27
|
+
agentx agent add # Add an agent (interactive)
|
|
28
|
+
agentx channel add # Add a channel (Telegram/WhatsApp/Discord/GitLab)
|
|
29
|
+
agentx daemon start # Start the daemon
|
|
30
|
+
agentx daemon watch # Live activity feed (color-coded)
|
|
20
31
|
```
|
|
21
32
|
|
|
22
|
-
##
|
|
33
|
+
## Architecture
|
|
23
34
|
|
|
24
35
|
```
|
|
25
36
|
Telegram ──┐
|
|
@@ -31,63 +42,306 @@ agentx daemon start # Start
|
|
|
31
42
|
A2A mesh ──┘
|
|
32
43
|
│
|
|
33
44
|
Context Engine
|
|
34
|
-
|
|
45
|
+
(10 layers, token-budgeted)
|
|
46
|
+
│
|
|
47
|
+
┌─────────┼─────────┐
|
|
48
|
+
Wiki Memory Bootstrap
|
|
49
|
+
(per-agent) (Haiku) (SOUL.md)
|
|
35
50
|
```
|
|
36
51
|
|
|
37
52
|
Each agent = a workspace directory with Claude Code configuration (`.claude/`, `CLAUDE.md`, skills, hooks, MCP servers). AgentX orchestrates when and where agents run.
|
|
38
53
|
|
|
54
|
+
## Communication Matrix
|
|
55
|
+
|
|
56
|
+
AgentX supports every communication path: human-to-agent, agent-to-human, agent-to-agent, and cross-channel — across all channels.
|
|
57
|
+
|
|
58
|
+
| Path | Telegram | WhatsApp | Discord | GitLab | API |
|
|
59
|
+
|------|:--------:|:--------:|:-------:|:------:|:---:|
|
|
60
|
+
| **H2A** (human to agent) | mention/DM | route | mention/DM | @username | POST /task |
|
|
61
|
+
| **A2H reply** | streaming | text | text | per-agent token | JSON |
|
|
62
|
+
| **A2H initiate** | /send | /send | /send | /send | - |
|
|
63
|
+
| **A2A delegation** | per-account bot chain | shared number + name prefix | shared + name prefix | @mention webhook | - |
|
|
64
|
+
| **Cross-channel** | /send | /send | /send | /send | - |
|
|
65
|
+
| **Cross-mesh** | mesh task | mesh task | mesh task | mesh task | mesh task |
|
|
66
|
+
|
|
67
|
+
### Cross-Channel Messaging
|
|
68
|
+
|
|
69
|
+
Agents can send messages to ANY channel proactively — not just reply:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Agent on GitLab sends a notification to Telegram
|
|
73
|
+
curl -X POST http://localhost:19900/send \
|
|
74
|
+
-H "Content-Type: application/json" \
|
|
75
|
+
-d '{"channel":"telegram","chatId":"-1001234567890","text":"Deploy complete!","agentId":"devops"}'
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This enables **H2A2H chains**: a human asks an agent on GitLab to notify someone on WhatsApp. The agent calls `/send` to deliver the message cross-channel.
|
|
79
|
+
|
|
80
|
+
### Automated Client Services
|
|
81
|
+
|
|
82
|
+
Define predictable request-response services that intercept messages BEFORE agent routing — no LLM needed for known patterns:
|
|
83
|
+
|
|
84
|
+
```jsonc
|
|
85
|
+
"services": {
|
|
86
|
+
"monthly-report": {
|
|
87
|
+
"name": "Monthly Client Report",
|
|
88
|
+
"triggers": [
|
|
89
|
+
{ "pattern": "monthly report|client records|تقرير الشهر", "channel": "whatsapp" }
|
|
90
|
+
],
|
|
91
|
+
"allowedContacts": ["+966"],
|
|
92
|
+
"agent": "atlas",
|
|
93
|
+
"prompt": "Run the monthly report SQL query and export as CSV...",
|
|
94
|
+
"schedule": "0 9 1 * *",
|
|
95
|
+
"notify": { "channel": "whatsapp", "chatId": "+966...@s.whatsapp.net" }
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
- **Regex triggers** with optional channel filter (Arabic + English patterns)
|
|
101
|
+
- **Contact allowlist** — only authorized contacts can trigger
|
|
102
|
+
- **Predefined prompt** — service sends a known prompt, not the user's raw message
|
|
103
|
+
- **Optional cron schedule** — also runs automatically on a schedule
|
|
104
|
+
- **Cross-channel notify** — results delivered to any channel
|
|
105
|
+
|
|
39
106
|
## Features
|
|
40
107
|
|
|
41
108
|
### Channels
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
- **
|
|
55
|
-
- **
|
|
56
|
-
- **
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
- **
|
|
60
|
-
- **
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
109
|
+
|
|
110
|
+
| Channel | Highlights |
|
|
111
|
+
|---------|-----------|
|
|
112
|
+
| **Telegram** | Multi-account bots, streaming edits, bot-to-bot delegation, media handling |
|
|
113
|
+
| **WhatsApp** | Baileys integration, QR pairing, per-contact/group routing, agent delegation (shared number, name-prefixed) |
|
|
114
|
+
| **Discord** | Mention-based routing, DM support, agent delegation |
|
|
115
|
+
| **GitLab** | Per-agent identity via PAT tokens, @mention routing, bot-to-bot handoff, image attachments, cascade prevention |
|
|
116
|
+
| **Webhooks** | Generic `POST /webhook/:agentId` for Stripe, Sentry, GitHub, etc. |
|
|
117
|
+
|
|
118
|
+
### GitLab Integration
|
|
119
|
+
|
|
120
|
+
Agents participate in GitLab as first-class team members:
|
|
121
|
+
- **Per-agent identity** — Each agent has its own GitLab user and PAT. Agent usernames resolved from tokens at startup via API (not manual config)
|
|
122
|
+
- **Deterministic @mention routing** — `@coding-agent` routes to that agent. Username-to-agent map built from token resolution
|
|
123
|
+
- **Bot-to-bot handoff** — QA agent can `@mention` devops in its review, devops picks it up automatically
|
|
124
|
+
- **Eye reaction** — Agents react with 👀 using their own token (never the global token)
|
|
125
|
+
- **Cascade prevention** — Hidden signature `<!-- agentx:agentId -->`, sent-note dedup, bot-user detection
|
|
126
|
+
- **Human mention filtering** — If @mentioned user isn't a known agent, the note is ignored
|
|
127
|
+
- **Image attachments** — Screenshots and diagrams in comments are downloaded and passed to agents for analysis
|
|
128
|
+
|
|
129
|
+
### Context Compaction
|
|
130
|
+
|
|
131
|
+
Long conversations don't lose context. When session history exceeds threshold:
|
|
132
|
+
1. **Memory flush** — Haiku extracts memorable facts before compaction
|
|
133
|
+
2. **Summarize** — Older messages compressed into a structured summary
|
|
134
|
+
3. **Preserve** — Last 6 messages kept verbatim, tool call pairs kept intact
|
|
135
|
+
|
|
136
|
+
### Message Queue
|
|
137
|
+
|
|
138
|
+
When an agent is busy, incoming messages are queued instead of dropped:
|
|
139
|
+
|
|
140
|
+
| Mode | Behavior |
|
|
141
|
+
|------|----------|
|
|
142
|
+
| `collect` (default) | Batch all messages, deliver as one when agent finishes |
|
|
143
|
+
| `followup` | Process each queued message as a separate follow-up turn |
|
|
144
|
+
| `drop` | Silently discard (for non-critical channels) |
|
|
145
|
+
|
|
146
|
+
Configure per agent: `agents.<id>.queueMode`
|
|
147
|
+
|
|
148
|
+
### Sub-Agent Spawning
|
|
149
|
+
|
|
150
|
+
Agents can spawn background sub-agents for parallel work:
|
|
151
|
+
- `spawn_agent` tool available in orchestrator tier
|
|
152
|
+
- Depth-limited (max 3 levels) to prevent infinite chains
|
|
153
|
+
- Timeout enforcement per spawn
|
|
154
|
+
- Results returned to parent agent
|
|
155
|
+
|
|
156
|
+
### Bootstrap Identity Files
|
|
157
|
+
|
|
158
|
+
Structured workspace files loaded into agent context automatically:
|
|
159
|
+
|
|
160
|
+
| File | Purpose | Lifecycle |
|
|
161
|
+
|------|---------|-----------|
|
|
162
|
+
| `SOUL.md` | Personality, tone, boundaries | Persistent |
|
|
163
|
+
| `IDENTITY.md` | Name, role, tagline | Persistent |
|
|
164
|
+
| `USER.md` | User profile, preferences | Persistent |
|
|
165
|
+
| `AGENTS.md` | Operating rules, standing orders | Persistent |
|
|
166
|
+
| `BOOTSTRAP.md` | First-run ritual | Auto-deleted after first load |
|
|
167
|
+
|
|
168
|
+
### Heartbeat
|
|
169
|
+
|
|
170
|
+
Periodic in-session check-ins (unlike cron which creates isolated sessions):
|
|
171
|
+
|
|
172
|
+
```jsonc
|
|
173
|
+
"agents": {
|
|
174
|
+
"assistant": {
|
|
175
|
+
"heartbeat": {
|
|
176
|
+
"enabled": true,
|
|
177
|
+
"intervalMinutes": 30,
|
|
178
|
+
"prompt": "Check inbox, pending tasks, and system health."
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Heartbeat runs in the agent's existing session context, preserving conversation history and memory.
|
|
185
|
+
|
|
186
|
+
### Cron with Retry & Missed Run Detection
|
|
187
|
+
|
|
188
|
+
Scheduled jobs with production-grade reliability:
|
|
189
|
+
- **Exponential backoff** on failure: 30s, 1m, 5m, 15m, 60m (up to 5 retries)
|
|
190
|
+
- **Missed run detection** — On startup, compares saved last-run times against schedule and catches up
|
|
191
|
+
- **Failure notifications** — Configure per-job `notify` destination (any channel)
|
|
192
|
+
- **Auto-disable** after 3 consecutive failures (`onError: "disable"`)
|
|
193
|
+
- **Health endpoint** — `GET /crons/health` returns healthy/failing/disabled/missed counts
|
|
194
|
+
|
|
195
|
+
```jsonc
|
|
196
|
+
"crons": {
|
|
197
|
+
"daily-report": {
|
|
198
|
+
"schedule": "0 9 * * *",
|
|
199
|
+
"agent": "assistant",
|
|
200
|
+
"prompt": "Generate today's status report.",
|
|
201
|
+
"notify": {
|
|
202
|
+
"channel": "telegram",
|
|
203
|
+
"chatId": "-1001234567890"
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Smart Block Streaming
|
|
210
|
+
|
|
211
|
+
Intelligent chunking for message delivery across channels:
|
|
212
|
+
- **minChars** threshold — no fragment spam
|
|
213
|
+
- **Paragraph-aware breaks** — never splits inside code fences
|
|
214
|
+
- **Per-channel defaults** — Telegram (60 chars), WhatsApp (40 chars + human pacing), Discord (80 chars)
|
|
215
|
+
- **Coalescing** — idle debounce merges consecutive small blocks
|
|
216
|
+
|
|
217
|
+
### Observability & Debug Mode
|
|
218
|
+
|
|
219
|
+
Toggle verbose debug logging at runtime:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Enable debug for specific categories
|
|
223
|
+
curl -X POST http://localhost:19900/debug/on?categories=webhook,agent
|
|
224
|
+
|
|
225
|
+
# Check debug state + recent log entries
|
|
226
|
+
curl http://localhost:19900/debug
|
|
227
|
+
|
|
228
|
+
# Disable
|
|
229
|
+
curl -X POST http://localhost:19900/debug/off
|
|
230
|
+
|
|
231
|
+
# Or via environment variable
|
|
232
|
+
AGENTX_DEBUG=webhook,agent agentx daemon start
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**Categories:** `webhook`, `agent`, `channel`, `cron`, `mesh`, `context`, `memory`, `config`, `all`
|
|
236
|
+
|
|
237
|
+
### Live Monitoring
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
agentx daemon watch # Color-coded live feed
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Or connect via SSE:
|
|
244
|
+
```bash
|
|
245
|
+
curl -N http://localhost:19900/events
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Wiki Knowledge Base
|
|
249
|
+
|
|
250
|
+
Each agent has a personal wiki — a compounding knowledge artifact built from conversations.
|
|
251
|
+
|
|
252
|
+
1. **Ingest** — Every conversation saved as raw entry
|
|
253
|
+
2. **Absorb** — LLM compiles entries into wiki articles
|
|
254
|
+
3. **Query** — Agents get relevant context filtered by tags
|
|
255
|
+
4. **Sync** — Federated wiki view across mesh peers
|
|
256
|
+
|
|
257
|
+
Three compilation modes: `unified` (default), `flat`, `graph`. Wikipedia-style UI at `agentx wiki serve`.
|
|
258
|
+
|
|
259
|
+
### Persistent Agent Memory
|
|
260
|
+
|
|
261
|
+
Haiku-powered cross-session memory:
|
|
262
|
+
- Facts, preferences, commitments extracted after each conversation
|
|
263
|
+
- BM25 full-text search across memories
|
|
264
|
+
- Injected into context for future conversations
|
|
265
|
+
- Auto-pruning with configurable expiry
|
|
266
|
+
|
|
267
|
+
### Skills
|
|
268
|
+
|
|
269
|
+
Reusable capabilities installed per-agent or globally:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
agentx skill add skills/my-skill --all
|
|
273
|
+
agentx skill list
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Mesh Federation
|
|
277
|
+
|
|
278
|
+
Agents on different machines collaborate:
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
agentx mesh add server-2 http://100.x.x.x:19900
|
|
282
|
+
agentx daemon send devops "check disk space" --peer server-2
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
- Static or mDNS peer discovery
|
|
286
|
+
- Health checks every 60s
|
|
287
|
+
- Wiki sync across peers
|
|
288
|
+
- Cross-machine agent delegation via A2A protocol
|
|
289
|
+
|
|
290
|
+
### MCP Server
|
|
291
|
+
|
|
292
|
+
AgentX exposes its full capabilities as MCP tools, usable from Claude Code, Cursor, or Windsurf:
|
|
293
|
+
|
|
294
|
+
| Tool | Description |
|
|
295
|
+
|------|-------------|
|
|
296
|
+
| `agentx_generate` | Generate code/components/APIs with tech stack awareness |
|
|
297
|
+
| `agentx_inspect` | Analyze project tech stack and schemas |
|
|
298
|
+
| `agentx_send` | Send messages to any channel (cross-channel routing) |
|
|
299
|
+
| `agentx_task` | Delegate work to a specific agent |
|
|
300
|
+
| `agentx_agents` | List agents and their status |
|
|
301
|
+
| `agentx_health` | Daemon health check |
|
|
302
|
+
| `agentx_crons` | Cron job health with error details |
|
|
303
|
+
| `agentx_debug` | Toggle debug mode with categories |
|
|
304
|
+
|
|
69
305
|
```bash
|
|
70
|
-
|
|
71
|
-
agentx
|
|
72
|
-
agentx daemon status # Agents, crons, mesh health
|
|
73
|
-
agentx daemon logs [-f] # Tail logs
|
|
74
|
-
agentx daemon send <agent> <msg> # Send task to agent
|
|
75
|
-
agentx daemon send <agent> <msg> --peer server-2 # Remote agent
|
|
76
|
-
agentx daemon deploy <host> -i key [--restart] # Deploy (runs tests first)
|
|
306
|
+
# Start the MCP server (stdio transport)
|
|
307
|
+
agentx mcp
|
|
77
308
|
```
|
|
78
309
|
|
|
79
|
-
|
|
310
|
+
Configure in Claude Code's `.claude/settings.json` or Cursor's MCP settings.
|
|
311
|
+
|
|
312
|
+
## CLI Reference
|
|
313
|
+
|
|
80
314
|
```bash
|
|
81
|
-
|
|
82
|
-
agentx
|
|
83
|
-
agentx
|
|
84
|
-
agentx
|
|
85
|
-
agentx
|
|
315
|
+
# Daemon
|
|
316
|
+
agentx daemon start [--detach]
|
|
317
|
+
agentx daemon stop
|
|
318
|
+
agentx daemon status
|
|
319
|
+
agentx daemon watch
|
|
320
|
+
agentx daemon logs [-f]
|
|
321
|
+
agentx daemon send <agent> <msg> [--peer <name>]
|
|
322
|
+
agentx daemon deploy <host> -i key [--restart]
|
|
323
|
+
|
|
324
|
+
# Wiki
|
|
325
|
+
agentx wiki status [--mode M]
|
|
326
|
+
agentx wiki absorb [--agent X] [--mode M] [--dry-run]
|
|
327
|
+
agentx wiki serve [--mode M] [--peer URL]
|
|
328
|
+
agentx wiki sync [--peer URL]
|
|
329
|
+
agentx wiki compare --agent X
|
|
330
|
+
agentx wiki lint [--agent X]
|
|
331
|
+
agentx wiki search <query>
|
|
332
|
+
|
|
333
|
+
# Management
|
|
334
|
+
agentx agent add | list | remove <id>
|
|
335
|
+
agentx channel add | list
|
|
336
|
+
agentx cron add | list | enable | disable <id>
|
|
337
|
+
agentx mesh add | list | remove <name>
|
|
338
|
+
agentx skill add <path> [--agent X] [--all] | list
|
|
86
339
|
agentx hook add <agent>
|
|
87
|
-
agentx config check
|
|
88
|
-
agentx config show # Print resolved config
|
|
89
|
-
agentx migrate openclaw [path] [--dry-run]
|
|
340
|
+
agentx config check | show
|
|
90
341
|
agentx init [--force]
|
|
342
|
+
|
|
343
|
+
# Usage
|
|
344
|
+
agentx usage [report] [--days N]
|
|
91
345
|
```
|
|
92
346
|
|
|
93
347
|
## Configuration
|
|
@@ -96,7 +350,7 @@ Single `agentx.json`. Environment variables expanded (`${VAR_NAME}`). Auto-loads
|
|
|
96
350
|
|
|
97
351
|
```jsonc
|
|
98
352
|
{
|
|
99
|
-
"node": { "id": "my-machine", "name": "My Machine", "bind": "
|
|
353
|
+
"node": { "id": "my-machine", "name": "My Machine", "bind": "0.0.0.0:19900" },
|
|
100
354
|
|
|
101
355
|
"agents": {
|
|
102
356
|
"assistant": {
|
|
@@ -104,9 +358,15 @@ Single `agentx.json`. Environment variables expanded (`${VAR_NAME}`). Auto-loads
|
|
|
104
358
|
"workspace": "/path/to/workspace",
|
|
105
359
|
"tier": "claude-code", // "sdk" or "orchestrator"
|
|
106
360
|
"model": "claude-sonnet-4-6",
|
|
107
|
-
"mentions": ["@my_bot"],
|
|
361
|
+
"mentions": ["@my_bot", "my-gitlab-user"],
|
|
108
362
|
"maxConcurrent": 2,
|
|
109
|
-
"
|
|
363
|
+
"queueMode": "collect", // "followup" or "drop"
|
|
364
|
+
"systemPrompt": "You are a helpful assistant.",
|
|
365
|
+
"heartbeat": {
|
|
366
|
+
"enabled": false,
|
|
367
|
+
"intervalMinutes": 30,
|
|
368
|
+
"prompt": "Check inbox and pending tasks."
|
|
369
|
+
}
|
|
110
370
|
}
|
|
111
371
|
},
|
|
112
372
|
|
|
@@ -118,19 +378,6 @@ Single `agentx.json`. Environment variables expanded (`${VAR_NAME}`). Auto-loads
|
|
|
118
378
|
},
|
|
119
379
|
"policy": { "dm": "pair", "group": "mention-required" }
|
|
120
380
|
},
|
|
121
|
-
"whatsapp": {
|
|
122
|
-
"enabled": true,
|
|
123
|
-
"defaultAgent": "assistant",
|
|
124
|
-
"routes": [
|
|
125
|
-
{ "contact": "+1234567890", "agent": "assistant" },
|
|
126
|
-
{ "group": "Team Chat", "agent": "devops" }
|
|
127
|
-
]
|
|
128
|
-
},
|
|
129
|
-
"discord": {
|
|
130
|
-
"enabled": true,
|
|
131
|
-
"token": "${DISCORD_BOT_TOKEN}",
|
|
132
|
-
"agentBinding": "assistant"
|
|
133
|
-
},
|
|
134
381
|
"gitlab": {
|
|
135
382
|
"enabled": true,
|
|
136
383
|
"host": "https://gitlab.example.com",
|
|
@@ -138,11 +385,14 @@ Single `agentx.json`. Environment variables expanded (`${VAR_NAME}`). Auto-loads
|
|
|
138
385
|
"webhookPort": 18810,
|
|
139
386
|
"routes": [
|
|
140
387
|
{ "project": "team/project-a", "agent": "pm-a" },
|
|
141
|
-
{ "project": "*", "agent": "
|
|
388
|
+
{ "project": "*", "agent": "default-agent" }
|
|
142
389
|
],
|
|
143
390
|
"agentMappings": [
|
|
144
|
-
{
|
|
145
|
-
|
|
391
|
+
{
|
|
392
|
+
"agentId": "coder",
|
|
393
|
+
"gitlabUsernames": ["coder-bot"],
|
|
394
|
+
"token": "${CODER_GITLAB_TOKEN}"
|
|
395
|
+
}
|
|
146
396
|
]
|
|
147
397
|
}
|
|
148
398
|
},
|
|
@@ -153,65 +403,66 @@ Single `agentx.json`. Environment variables expanded (`${VAR_NAME}`). Auto-loads
|
|
|
153
403
|
"schedule": "0 9 * * *",
|
|
154
404
|
"timezone": "UTC",
|
|
155
405
|
"agent": "assistant",
|
|
156
|
-
"prompt": "Generate today's status report."
|
|
406
|
+
"prompt": "Generate today's status report.",
|
|
407
|
+
"onError": "notify",
|
|
408
|
+
"notify": {
|
|
409
|
+
"channel": "telegram",
|
|
410
|
+
"chatId": "-1001234567890"
|
|
411
|
+
}
|
|
157
412
|
}
|
|
158
413
|
},
|
|
159
414
|
|
|
160
415
|
"mesh": {
|
|
161
416
|
"enabled": true,
|
|
162
417
|
"peers": [
|
|
163
|
-
{ "url": "http://100.
|
|
418
|
+
{ "url": "http://100.x.x.x:19900", "name": "server-2" }
|
|
164
419
|
]
|
|
165
420
|
}
|
|
166
421
|
}
|
|
167
422
|
```
|
|
168
423
|
|
|
169
|
-
## Context Engine
|
|
170
|
-
|
|
171
|
-
Every agent prompt is built from 8 structured layers, each with a token budget:
|
|
172
|
-
|
|
173
|
-
| Layer | Priority | Budget | Content |
|
|
174
|
-
|-------|----------|--------|---------|
|
|
175
|
-
| Channel | 1 | 200 | Channel type + rules (GitLab: no @handles, use GFM) |
|
|
176
|
-
| Scope | 2 | 200 | Group name, project path, or DM |
|
|
177
|
-
| Identity | 3 | 300 | Agent system prompt (first line) |
|
|
178
|
-
| Peers | 4 | 400 | Team roster with handles (Telegram only) |
|
|
179
|
-
| Intent | 5 | 200 | Extracted from message: deploy, review, bugfix... |
|
|
180
|
-
| Artifacts | 6 | 500 | Media, reply-to text, issue/MR references |
|
|
181
|
-
| History | 7 | 1200 | Group conversation or session history |
|
|
182
|
-
| Wiki | 8 | 1000 | Relevant knowledge articles |
|
|
183
|
-
|
|
184
|
-
Total budget: 4000 tokens. Lower layers truncated if over budget.
|
|
185
|
-
|
|
186
424
|
## HTTP API
|
|
187
425
|
|
|
188
426
|
| Endpoint | Method | Description |
|
|
189
427
|
|----------|--------|-------------|
|
|
190
|
-
| `/health` | GET | Status, agents, crons, mesh,
|
|
428
|
+
| `/health` | GET | Status, agents, crons, mesh, usage |
|
|
429
|
+
| `/events` | GET | SSE live event stream |
|
|
191
430
|
| `/agents` | GET | List agents |
|
|
431
|
+
| `/channels` | GET | List registered channels |
|
|
192
432
|
| `/crons` | GET | List cron jobs |
|
|
193
|
-
| `/
|
|
194
|
-
| `/
|
|
433
|
+
| `/crons/health` | GET | Cron health: healthy/failing/disabled/missed |
|
|
434
|
+
| `/services` | GET | List registered automated services |
|
|
195
435
|
| `/task` | POST | `{ "agent": "id", "message": "..." }` |
|
|
436
|
+
| `/send` | POST | `{ "channel": "telegram", "chatId": "...", "text": "...", "agentId": "..." }` |
|
|
196
437
|
| `/mesh/task` | POST | `{ "peer": "name", "message": "..." }` |
|
|
197
|
-
| `/webhook/:agentId[/:source]` | POST | Webhook callback
|
|
198
|
-
| `/v1/chat/completions` | POST | OpenAI-compatible endpoint
|
|
199
|
-
| `/
|
|
438
|
+
| `/webhook/:agentId[/:source]` | POST | Webhook callback |
|
|
439
|
+
| `/v1/chat/completions` | POST | OpenAI-compatible endpoint |
|
|
440
|
+
| `/debug` | GET | Debug state + recent log entries |
|
|
441
|
+
| `/debug/on` | POST | Enable debug (`?categories=webhook,agent`) |
|
|
442
|
+
| `/debug/off` | POST | Disable debug |
|
|
200
443
|
| `/.well-known/agent-card.json` | GET | A2A agent discovery |
|
|
201
444
|
|
|
202
|
-
##
|
|
445
|
+
## Context Engine
|
|
203
446
|
|
|
204
|
-
|
|
447
|
+
Every agent prompt is built from structured layers, each with a token budget:
|
|
205
448
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
449
|
+
| Layer | Priority | Budget | Content |
|
|
450
|
+
|-------|----------|--------|---------|
|
|
451
|
+
| Channel | 1 | 200 | Channel type + formatting rules |
|
|
452
|
+
| Scope | 2 | 200 | Group name, project path, or DM |
|
|
453
|
+
| Landscape | 3 | 800 | Team roster, mesh peers, rules, /send API docs |
|
|
454
|
+
| Identity | 4 | 200 | Agent system prompt |
|
|
455
|
+
| Bootstrap | 4.5 | 500 | SOUL.md, IDENTITY.md, AGENTS.md |
|
|
456
|
+
| Intent | 5 | 200 | Extracted: deploy, review, bugfix... |
|
|
457
|
+
| Artifacts | 6 | 500 | Media, reply-to text, issue refs |
|
|
458
|
+
| Memory | 6.5 | 600 | Cross-session facts (Haiku-extracted) |
|
|
459
|
+
| History | 7 | 1200 | Conversation or session history |
|
|
460
|
+
| Cross-chat | 7 | 800 | Context from other active chats |
|
|
461
|
+
| Wiki | 8 | 1000 | Tag-matched knowledge articles |
|
|
211
462
|
|
|
212
|
-
|
|
463
|
+
Total budget: 6000 tokens. Context always injected, even on resumed sessions.
|
|
213
464
|
|
|
214
|
-
## Three
|
|
465
|
+
## Three Execution Tiers
|
|
215
466
|
|
|
216
467
|
| Tier | How | Auth | Best for |
|
|
217
468
|
|------|-----|------|----------|
|
|
@@ -219,25 +470,45 @@ Supports streaming (`"stream": true`) with SSE. The `model` field maps to the ag
|
|
|
219
470
|
| `sdk` | Claude Agent SDK | API key | Programmatic control, headless servers |
|
|
220
471
|
| `orchestrator` | AgentX's own loop | Any provider key | Non-Claude providers (OpenAI, Ollama) |
|
|
221
472
|
|
|
222
|
-
##
|
|
473
|
+
## Daemon Management
|
|
474
|
+
|
|
475
|
+
Single-instance guard via PID file — prevents orphan processes on restart:
|
|
223
476
|
|
|
224
477
|
```bash
|
|
225
|
-
agentx
|
|
478
|
+
agentx daemon start # Checks .agentx/daemon.pid, exits if another is running
|
|
479
|
+
agentx daemon stop # Graceful shutdown, saves cron last-run times
|
|
480
|
+
systemctl --user restart agentx-daemon.service # Safe — PID guard prevents duplicates
|
|
226
481
|
```
|
|
227
482
|
|
|
228
|
-
## Use
|
|
483
|
+
## Use Cases
|
|
229
484
|
|
|
230
485
|
- **Team of Telegram bots** — each project gets its own bot + agent
|
|
231
|
-
- **GitLab
|
|
232
|
-
- **
|
|
233
|
-
- **
|
|
234
|
-
- **
|
|
235
|
-
- **
|
|
236
|
-
- **
|
|
486
|
+
- **GitLab CI/CD team** — coder, QA, devops, PM agents collaborate on issues via @mentions
|
|
487
|
+
- **Cross-channel notifications** — GitLab agent notifies humans on Telegram/WhatsApp
|
|
488
|
+
- **WhatsApp delegation** — shared phone number, agents identified by name prefix
|
|
489
|
+
- **Scheduled automation** — cron jobs with retry, missed-run catch-up, failure alerts
|
|
490
|
+
- **Multi-machine swarm** — agents on laptop + server collaborate via mesh
|
|
491
|
+
- **Webhook automation** — Sentry error -> DevOps investigates, Stripe payment -> billing processes
|
|
492
|
+
- **Personal wiki** — Every conversation compounds into searchable knowledge
|
|
237
493
|
|
|
238
|
-
##
|
|
494
|
+
## Contributing
|
|
495
|
+
|
|
496
|
+
```bash
|
|
497
|
+
git clone https://github.com/anis-marrouchi/agentx.git
|
|
498
|
+
cd agentx
|
|
499
|
+
npm install
|
|
500
|
+
npm run build # ESM build via tsup
|
|
501
|
+
npm test # Run tests
|
|
502
|
+
agentx init --force # Create local config
|
|
503
|
+
agentx daemon start # Start dev daemon
|
|
504
|
+
agentx daemon watch # See what's happening
|
|
505
|
+
```
|
|
239
506
|
|
|
240
|
-
|
|
507
|
+
Areas we're looking for help:
|
|
508
|
+
- **Testing** — Unit and integration tests
|
|
509
|
+
- **Channels** — Slack, Microsoft Teams adapters
|
|
510
|
+
- **Dashboard** — Web UI for agent management
|
|
511
|
+
- **Security** — Audit of token handling and permission boundaries
|
|
241
512
|
|
|
242
513
|
## License
|
|
243
514
|
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{s as a,t as b,u as c}from"./chunk-D6EDMQRV.js";import"./chunk-SFQUP3BP.js";import"./chunk-CJ45Y2IR.js";import"./chunk-KXZMYLHQ.js";import"./chunk-M7HKBG3V.js";import"./chunk-MCJUAE6V.js";import"./chunk-DSYKYZMT.js";import"./chunk-QOYAX2FT.js";import"./chunk-4YCH6IZV.js";export{a as createAgentContext,b as generate,c as generateStream};
|
|
2
|
+
//# sourceMappingURL=agent-5KIMJI3F.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{readFileSync as R,writeFileSync as D,appendFileSync as S,existsSync as C,mkdirSync as _}from"fs";import{resolve as T}from"path";var y={"claude-opus":{input:15,output:75,cacheRead:1.5,cacheCreate:18.75},"claude-sonnet":{input:3,output:15,cacheRead:.3,cacheCreate:3.75},"claude-haiku":{input:.25,output:1.25,cacheRead:.025,cacheCreate:.3125}};function v(O){let t=O.toLowerCase();return t.includes("opus")?"claude-opus":t.includes("haiku")?"claude-haiku":"claude-sonnet"}var b=class{dir;cache=null;constructor(t=T(process.cwd(),".agentx/usage")){this.dir=t,_(this.dir,{recursive:!0})}static calculateCost(t){let o=v(t.model||"claude-sonnet"),n=y[o]||y["claude-sonnet"];return(t.inputTokens||0)/1e6*n.input+(t.outputTokens||0)/1e6*n.output+(t.cacheReadTokens||0)/1e6*n.cacheRead+(t.cacheCreateTokens||0)/1e6*n.cacheCreate}record(t,o,n,c,s,i,l){let e=this.today(),a=e.agents[t]||{tasks:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,totalDuration:0,errors:0};a.tasks++,a.totalDuration+=o,l&&(a.model=l),n?(a.inputTokens+=n.inputTokens,a.outputTokens+=n.outputTokens,a.cacheReadTokens+=n.cacheReadTokens,a.cacheCreateTokens+=n.cacheCreateTokens):c!==void 0&&s!==void 0&&(a.inputTokens+=Math.ceil(c/4),a.outputTokens+=Math.ceil(s/4)),i&&a.errors++,e.agents[t]=a,this.save(e)}today(){let t=new Date().toISOString().slice(0,10);if(this.cache?.date===t)return this.cache;let o=this.filePath(t);if(C(o))try{return this.cache=JSON.parse(R(o,"utf-8")),this.cache}catch{}return this.cache={date:t,agents:{}},this.cache}getDate(t){let o=this.filePath(t);if(!C(o))return null;try{return JSON.parse(R(o,"utf-8"))}catch{return null}}generateDailyReport(t){let o=t||new Date().toISOString().slice(0,10),n=this.getDate(o);if(!n)return null;let c=0,s=0,i=0,l=0,e=0,a=0,g="",m=0,p={};for(let[k,h]of Object.entries(n.agents)){let d=b.calculateCost(h);p[k]=d,c+=h.tasks,s+=h.inputTokens||0,i+=h.outputTokens||0,l+=h.cacheReadTokens||0,e+=h.cacheCreateTokens||0,a+=d,d>m&&(m=d,g=k)}return{date:o,totalTasks:c,totalInput:s,totalOutput:i,totalCacheRead:l,totalCacheCreate:e,totalCost:a,topAgent:g,topCost:m,agentCosts:p}}appendToTokenCosts(t,o){let n=o||T(process.cwd(),".agentx/TOKEN_COSTS.md"),c=e=>e<.01?e.toFixed(4):e.toFixed(2),s=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e),i=Object.entries(t.agentCosts).sort(([,e],[,a])=>a-e).map(([e,a])=>`${e}: $${c(a)}`).join(", "),l=`| ${t.date} | ${t.totalTasks} | ${s(t.totalInput)} | ${s(t.totalOutput)} | ${s(t.totalCacheRead)} | ${s(t.totalCacheCreate)} | $${c(t.totalCost)} | ${i} |`;C(n)?S(n,l+`
|
|
2
|
+
`):D(n,`# Token Costs
|
|
3
|
+
|
|
4
|
+
Daily token cost tracking. Auto-appended at midnight (Africa/Tunis).
|
|
5
|
+
|
|
6
|
+
| Date | Tasks | Input | Output | Cache R | Cache W | Cost | Per Agent |
|
|
7
|
+
|------|-------|-------|--------|---------|---------|------|-----------|
|
|
8
|
+
`+l+`
|
|
9
|
+
`)}summary(t=7){let o=0,n=0,c=0,s=0,i=0,l=0,e=0,a={};for(let p=0;p<t;p++){let k=new Date(Date.now()-p*864e5).toISOString().slice(0,10),h=this.getDate(k);if(h)for(let[d,u]of Object.entries(h.agents)){let f=b.calculateCost(u);o+=u.tasks,n+=u.inputTokens||0,c+=u.outputTokens||0,s+=u.cacheReadTokens||0,i+=u.cacheCreateTokens||0,l+=u.errors,e+=f;let r=a[d]||{tasks:0,input:0,output:0,cacheRead:0,cacheCreate:0,total:0,avgDuration:0,totalDuration:0,cost:0};r.tasks+=u.tasks,r.input+=u.inputTokens||0,r.output+=u.outputTokens||0,r.cacheRead+=u.cacheReadTokens||0,r.cacheCreate+=u.cacheCreateTokens||0,r.total=r.input+r.output+r.cacheRead+r.cacheCreate,r.totalDuration+=u.totalDuration,r.avgDuration=r.totalDuration/r.tasks,r.cost+=f,u.model&&(r.model=u.model),a[d]=r}}let g=n+c+s+i,m=s+i>0?s/(s+i):0;return{totalTasks:o,totalTokens:g,totalInput:n,totalOutput:c,totalCacheRead:s,totalCacheCreate:i,cacheHitRatio:m,totalErrors:l,totalCost:e,byAgent:a}}filePath(t){return T(this.dir,`${t}.json`)}save(t){try{D(this.filePath(t.date),JSON.stringify(t,null,2))}catch{}}};export{b as a};
|
|
10
|
+
//# sourceMappingURL=chunk-34UAFPK4.js.map
|