teleton 0.5.1 → 0.6.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 +239 -101
- package/dist/chunk-2QUJLHCZ.js +362 -0
- package/dist/chunk-4IPJ25HE.js +2839 -0
- package/dist/{chunk-RRB6BWU7.js → chunk-6L6KGATM.js} +1042 -3039
- package/dist/{chunk-BYTHCDZA.js → chunk-ADCMUNYU.js} +65 -496
- package/dist/chunk-D5I7GBV7.js +322 -0
- package/dist/chunk-ECSCVEQQ.js +139 -0
- package/dist/chunk-GDCODBNO.js +72 -0
- package/dist/{chunk-O4R7V5Y2.js → chunk-RO62LO6Z.js} +11 -1
- package/dist/cli/index.js +346 -22
- package/dist/index.js +7 -4
- package/dist/{memory-657W5AS6.js → memory-TVDOGQXS.js} +14 -10
- package/dist/{migrate-PMB2JVXH.js → migrate-QIEMPOMT.js} +5 -2
- package/dist/{server-BQY7CM2N.js → server-RSWVCVY3.js} +805 -26
- package/dist/{task-dependency-resolver-TRPILAHM.js → task-dependency-resolver-72DLY2HV.js} +1 -1
- package/dist/{task-executor-N7XNVK5N.js → task-executor-VXB6DAV2.js} +1 -1
- package/dist/tool-index-DKI2ZNOU.js +245 -0
- package/dist/web/assets/index-BNhrx9S1.js +67 -0
- package/dist/web/assets/index-CqrrRLOh.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +16 -16
- package/dist/chunk-5WWR4CU3.js +0 -124
- package/dist/web/assets/index-CDMbujHf.css +0 -1
- package/dist/web/assets/index-DDX8oQ2z.js +0 -67
package/README.md
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
<h1 align="center">Teleton Agent</h1>
|
|
2
2
|
|
|
3
|
-
<p align="center"><b>Autonomous AI agent for Telegram with native TON blockchain integration</b></p>
|
|
3
|
+
<p align="center"><b>Autonomous AI agent platform for Telegram with native TON blockchain integration</b></p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
|
|
7
7
|
<a href="https://nodejs.org/"><img src="https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen" alt="Node.js"></a>
|
|
8
8
|
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-5.7-blue" alt="TypeScript"></a>
|
|
9
9
|
<a href="https://teletonagent.dev"><img src="https://img.shields.io/badge/Website-teletonagent.dev-ff6600" alt="Website"></a>
|
|
10
|
+
<a href="https://deepwiki.com/TONresistor/teleton-agent"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
|
|
10
11
|
</p>
|
|
11
12
|
|
|
12
13
|
---
|
|
13
14
|
|
|
14
|
-
<p align="center">Teleton is
|
|
15
|
+
<p align="center">Teleton is an autonomous AI agent platform that operates as a real Telegram user account (not a bot). It thinks through an agentic loop with tool calling, remembers conversations across sessions with hybrid RAG, and can operate a TON wallet: send crypto, swap on DEXs, bid on domains, verify payments. All from a chat message. It ships with 114 built-in tools, supports 6 LLM providers, and exposes a Plugin SDK so you can build your own tools on top of the platform.</p>
|
|
15
16
|
|
|
16
|
-
### Key Highlights
|
|
17
|
+
### Key Highlights
|
|
17
18
|
|
|
18
|
-
- **Full Telegram access**: Operates as a real user
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
22
|
-
- **
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
19
|
+
- **Full Telegram access**: Operates as a real user via MTProto (GramJS), not a limited bot
|
|
20
|
+
- **Agentic loop**: Up to 5 iterations of tool calling per message — the agent thinks, acts, observes, and repeats
|
|
21
|
+
- **Multi-Provider LLM**: Anthropic, OpenAI, Google Gemini, xAI Grok, Groq, OpenRouter
|
|
22
|
+
- **TON Blockchain**: Built-in W5R1 wallet, send/receive TON & jettons, swap on STON.fi and DeDust, NFTs, DNS domains
|
|
23
|
+
- **Persistent memory**: Hybrid RAG (sqlite-vec + FTS5), auto-compaction with AI summarization, daily logs
|
|
24
|
+
- **114 built-in tools**: Messaging, media, blockchain, DEX trading, deals, DNS, journaling, and more
|
|
25
|
+
- **Plugin SDK**: Extend the agent with custom tools — frozen SDK with isolated databases, secrets management, lifecycle hooks
|
|
26
|
+
- **MCP Client**: Connect external tool servers (stdio/SSE) with 2 lines of YAML — no code, no rebuild
|
|
27
|
+
- **Secure by design**: Prompt injection defense, sandboxed workspace, plugin isolation, wallet encryption
|
|
25
28
|
|
|
26
29
|
---
|
|
27
30
|
|
|
@@ -29,33 +32,36 @@
|
|
|
29
32
|
|
|
30
33
|
### Tool Categories
|
|
31
34
|
|
|
32
|
-
| Category
|
|
33
|
-
|
|
34
|
-
| Telegram
|
|
35
|
-
| TON & Jettons | 15
|
|
36
|
-
| STON.fi DEX
|
|
37
|
-
| DeDust DEX
|
|
38
|
-
| TON DNS
|
|
39
|
-
| Deals
|
|
40
|
-
| Journal
|
|
41
|
-
|
|
|
35
|
+
| Category | Tools | Description |
|
|
36
|
+
| ------------- | ----- | ------------------------------------------------------------------------------------------------------------------ |
|
|
37
|
+
| Telegram | 66 | Messaging, media, chats, groups, polls, stickers, gifts, stars, stories, contacts, folders, profile, memory, tasks |
|
|
38
|
+
| TON & Jettons | 15 | W5R1 wallet, send/receive TON & jettons, balances, prices, holders, history, charts, NFTs, smart DEX router |
|
|
39
|
+
| STON.fi DEX | 5 | Swap, quote, search, trending tokens, liquidity pools |
|
|
40
|
+
| DeDust DEX | 5 | Swap, quote, pools, prices, token analytics (holders, top traders, buy/sell tax) |
|
|
41
|
+
| TON DNS | 7 | Domain auctions, bidding, linking/unlinking, resolution, availability checks |
|
|
42
|
+
| Deals | 5 | P2P escrow with inline buttons, on-chain payment verification, anti double-spend |
|
|
43
|
+
| Journal | 3 | Trade/operation logging with P&L tracking and natural language queries |
|
|
44
|
+
| Web | 2 | Web search and page extraction via Tavily (search, fetch/extract) |
|
|
45
|
+
| Workspace | 6 | Sandboxed file operations with path traversal protection |
|
|
42
46
|
|
|
43
47
|
### Advanced Capabilities
|
|
44
48
|
|
|
45
|
-
| Capability
|
|
46
|
-
|
|
47
|
-
| **Multi-Provider LLM**
|
|
48
|
-
| **RAG + Hybrid Search** | Local embeddings with FTS5 keyword + sqlite-vec
|
|
49
|
-
| **Auto-Compaction**
|
|
50
|
-
| **Observation Masking** | Compresses old tool results to
|
|
51
|
-
| **Plugin SDK**
|
|
52
|
-
| **
|
|
53
|
-
| **
|
|
54
|
-
| **Scheduled Tasks**
|
|
55
|
-
| **Message Debouncing**
|
|
56
|
-
| **Daily Logs**
|
|
57
|
-
| **Multi-Policy Access** | Configurable DM/group policies (open, allowlist, pairing, disabled) |
|
|
58
|
-
| **
|
|
49
|
+
| Capability | Description |
|
|
50
|
+
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
51
|
+
| **Multi-Provider LLM** | Switch between Anthropic, OpenAI, Google, xAI, Groq, OpenRouter with one config change |
|
|
52
|
+
| **RAG + Hybrid Search** | Local ONNX embeddings (384d) or Voyage AI (512d/1024d) with FTS5 keyword + sqlite-vec cosine similarity, fused via RRF |
|
|
53
|
+
| **Auto-Compaction** | AI-summarized context management prevents overflow, preserves key information in `memory/*.md` files |
|
|
54
|
+
| **Observation Masking** | Compresses old tool results to one-line summaries, saving ~90% context window |
|
|
55
|
+
| **Plugin SDK** | Frozen namespaced SDK (`sdk.ton`, `sdk.telegram`, `sdk.secrets`, `sdk.storage`) with isolated databases and lifecycle hooks |
|
|
56
|
+
| **Smart DEX Router** | `dex_quote` compares STON.fi vs DeDust in parallel, recommends the best rate |
|
|
57
|
+
| **Vision Analysis** | Image understanding via multimodal LLM (utility model) |
|
|
58
|
+
| **Scheduled Tasks** | Time-based task execution with DAG dependency resolution |
|
|
59
|
+
| **Message Debouncing** | Intelligent batching of rapid group messages (DMs are always instant) |
|
|
60
|
+
| **Daily Logs** | Automatic session summaries preserved across resets |
|
|
61
|
+
| **Multi-Policy Access** | Configurable DM/group policies (open, allowlist, pairing, disabled) with per-group module permissions |
|
|
62
|
+
| **Tool RAG** | Semantic tool selection — sends only the top-K most relevant tools per message (hybrid vector + FTS5, configurable `top_k`, `always_include` patterns) |
|
|
63
|
+
| **MCP Client** | Connect external MCP tool servers (stdio or SSE) — auto-discovery, namespaced tools, managed via CLI or WebUI |
|
|
64
|
+
| **Sandboxed Workspace** | Secure file system with recursive URL decoding, symlink detection, and immutable config files |
|
|
59
65
|
|
|
60
66
|
---
|
|
61
67
|
|
|
@@ -66,7 +72,7 @@
|
|
|
66
72
|
- **Telegram Account** - Dedicated account recommended for security
|
|
67
73
|
- **Telegram API Credentials** - From [my.telegram.org/apps](https://my.telegram.org/apps)
|
|
68
74
|
- **Your Telegram User ID** - Message [@userinfobot](https://t.me/userinfobot)
|
|
69
|
-
- **Bot Token** *(optional)* - From [@BotFather](https://t.me/BotFather) for inline bot features
|
|
75
|
+
- **Bot Token** *(optional)* - From [@BotFather](https://t.me/BotFather) for inline bot features (deals)
|
|
70
76
|
|
|
71
77
|
> **Security Warning**: The agent will have full control over the Telegram account. Use a dedicated account, not your main one.
|
|
72
78
|
|
|
@@ -76,14 +82,9 @@
|
|
|
76
82
|
|
|
77
83
|
### 1. Installation
|
|
78
84
|
|
|
79
|
-
**
|
|
85
|
+
**npm (recommended):**
|
|
80
86
|
```bash
|
|
81
|
-
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
**npm:**
|
|
85
|
-
```bash
|
|
86
|
-
npm install -g teleton
|
|
87
|
+
npm install -g teleton@latest
|
|
87
88
|
```
|
|
88
89
|
|
|
89
90
|
**Docker:**
|
|
@@ -110,12 +111,12 @@ The wizard will configure:
|
|
|
110
111
|
- Access policies (DM/group response rules)
|
|
111
112
|
- Admin user ID
|
|
112
113
|
- TON wallet generation (W5R1 with 24-word mnemonic)
|
|
113
|
-
- Workspace initialization (SOUL.md,
|
|
114
|
+
- Workspace initialization (SOUL.md, STRATEGY.md, SECURITY.md, MEMORY.md)
|
|
114
115
|
|
|
115
116
|
Configuration files created:
|
|
116
117
|
- `~/.teleton/config.yaml` - Main configuration
|
|
117
118
|
- `~/.teleton/wallet.json` - TON wallet (backup mnemonic securely)
|
|
118
|
-
- `~/.teleton/memory.db` - SQLite database
|
|
119
|
+
- `~/.teleton/memory.db` - SQLite database (WAL mode, sqlite-vec, FTS5)
|
|
119
120
|
- `~/.teleton/workspace/` - Sandboxed file storage
|
|
120
121
|
|
|
121
122
|
### 3. Start
|
|
@@ -151,7 +152,7 @@ agent:
|
|
|
151
152
|
provider: "anthropic" # anthropic | openai | google | xai | groq | openrouter
|
|
152
153
|
api_key: "sk-ant-api03-..."
|
|
153
154
|
model: "claude-opus-4-5-20251101"
|
|
154
|
-
utility_model: "claude-3-5-haiku-20241022" #
|
|
155
|
+
utility_model: "claude-3-5-haiku-20241022" # for summarization, compaction, vision
|
|
155
156
|
max_agentic_iterations: 5
|
|
156
157
|
|
|
157
158
|
telegram:
|
|
@@ -161,14 +162,16 @@ telegram:
|
|
|
161
162
|
admin_ids: [123456789]
|
|
162
163
|
owner_name: "Your Name"
|
|
163
164
|
owner_username: "your_username"
|
|
165
|
+
debounce_ms: 1500 # group message batching delay
|
|
164
166
|
|
|
165
|
-
# Optional: inline bot for interactive features
|
|
167
|
+
# Optional: inline bot for interactive features (deals)
|
|
166
168
|
bot_token: "123456:ABC-DEF..."
|
|
167
169
|
bot_username: "your_bot"
|
|
168
170
|
|
|
169
171
|
session_reset_policy:
|
|
170
172
|
daily_reset_enabled: true
|
|
171
173
|
daily_reset_hour: 4
|
|
174
|
+
idle_expiry_minutes: 1440 # 24h idle → new session
|
|
172
175
|
|
|
173
176
|
webui: # Optional: Web dashboard
|
|
174
177
|
enabled: false # Enable WebUI server
|
|
@@ -177,8 +180,86 @@ webui: # Optional: Web dashboard
|
|
|
177
180
|
# auth_token: "..." # Auto-generated if omitted
|
|
178
181
|
```
|
|
179
182
|
|
|
183
|
+
### MCP Servers
|
|
184
|
+
|
|
185
|
+
Connect external tool servers via the [Model Context Protocol](https://modelcontextprotocol.io/). No code needed — tools are auto-discovered and registered at startup.
|
|
186
|
+
|
|
187
|
+
**Via CLI (recommended):**
|
|
188
|
+
```bash
|
|
189
|
+
teleton mcp add @modelcontextprotocol/server-filesystem /tmp
|
|
190
|
+
teleton mcp add @openbnb/mcp-server-airbnb
|
|
191
|
+
teleton mcp list
|
|
192
|
+
teleton mcp remove filesystem
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Via config.yaml:**
|
|
196
|
+
```yaml
|
|
197
|
+
mcp:
|
|
198
|
+
servers:
|
|
199
|
+
filesystem:
|
|
200
|
+
command: npx -y @modelcontextprotocol/server-filesystem /tmp
|
|
201
|
+
brave:
|
|
202
|
+
command: npx -y @modelcontextprotocol/server-brave-search
|
|
203
|
+
env:
|
|
204
|
+
BRAVE_API_KEY: "sk-xxx"
|
|
205
|
+
remote:
|
|
206
|
+
url: http://localhost:3001/mcp
|
|
207
|
+
scope: admin-only
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Via WebUI:**
|
|
211
|
+
|
|
212
|
+
When the WebUI is enabled, the **MCP Servers** page lets you add/remove servers, configure environment variables (API keys), and view connection status and tool lists — all from the browser.
|
|
213
|
+
|
|
214
|
+
Tools are namespaced as `mcp_<server>_<tool>` (e.g. `mcp_filesystem_read_file`). Each server supports `scope` (always, dm-only, group-only, admin-only) and `enabled` toggle.
|
|
215
|
+
|
|
216
|
+
### Web Search & Fetch
|
|
217
|
+
|
|
218
|
+
The agent has two built-in web tools powered by [Tavily](https://tavily.com/) (free tier available):
|
|
219
|
+
|
|
220
|
+
| Tool | Description |
|
|
221
|
+
|------|-------------|
|
|
222
|
+
| `web_search` | Search the web — returns titles, URLs, content snippets, relevance scores. Supports `topic`: general, news, finance |
|
|
223
|
+
| `web_fetch` | Extract readable text from a URL — articles, docs, links shared by users |
|
|
224
|
+
|
|
225
|
+
Both tools require a Tavily API key. Set it via CLI or config:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
teleton config set tavily_api_key
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Or in `config.yaml`:
|
|
232
|
+
```yaml
|
|
233
|
+
tavily_api_key: "tvly-..."
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Once configured, the agent can autonomously search the web and read pages when needed to answer questions or verify information.
|
|
237
|
+
|
|
238
|
+
### Managing Config Keys
|
|
239
|
+
|
|
240
|
+
Use `teleton config` to manage optional keys without editing YAML manually:
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
# List all configurable keys and their status
|
|
244
|
+
teleton config list
|
|
245
|
+
|
|
246
|
+
# Set a key (prompts interactively if value omitted)
|
|
247
|
+
teleton config set tavily_api_key
|
|
248
|
+
teleton config set tonapi_key AFTWPHSLN3...
|
|
249
|
+
|
|
250
|
+
# View a key (sensitive values are masked)
|
|
251
|
+
teleton config get tavily_api_key
|
|
252
|
+
|
|
253
|
+
# Remove a key
|
|
254
|
+
teleton config unset tavily_api_key
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Configurable keys: `tavily_api_key`, `tonapi_key`, `telegram.bot_token`, `telegram.bot_username`.
|
|
258
|
+
|
|
180
259
|
### Environment Variables
|
|
181
260
|
|
|
261
|
+
All environment variables override the corresponding `config.yaml` value at startup — useful for Docker and CI:
|
|
262
|
+
|
|
182
263
|
| Variable | Description | Default |
|
|
183
264
|
|----------|-------------|---------|
|
|
184
265
|
| `TELETON_HOME` | Data directory (config, DB, session) | `~/.teleton` |
|
|
@@ -186,6 +267,8 @@ webui: # Optional: Web dashboard
|
|
|
186
267
|
| `TELETON_TG_API_ID` | Telegram API ID (overrides config) | - |
|
|
187
268
|
| `TELETON_TG_API_HASH` | Telegram API Hash (overrides config) | - |
|
|
188
269
|
| `TELETON_TG_PHONE` | Phone number (overrides config) | - |
|
|
270
|
+
| `TELETON_TAVILY_API_KEY` | Tavily API key for web search | - |
|
|
271
|
+
| `TELETON_TONAPI_KEY` | TonAPI key for higher rate limits | - |
|
|
189
272
|
| `TELETON_WEBUI_ENABLED` | Enable WebUI (overrides config) | `false` |
|
|
190
273
|
| `TELETON_WEBUI_PORT` | WebUI port (overrides config) | `7777` |
|
|
191
274
|
|
|
@@ -197,12 +280,15 @@ Teleton includes an **optional web dashboard** for monitoring and configuration.
|
|
|
197
280
|
|
|
198
281
|
### Features
|
|
199
282
|
|
|
200
|
-
- **Dashboard**: System status, uptime, model info, session count
|
|
201
|
-
- **Tools Management**: View all
|
|
202
|
-
- **
|
|
203
|
-
- **Soul Editor**: Edit SOUL.md, SECURITY.md, STRATEGY.md, MEMORY.md
|
|
283
|
+
- **Dashboard**: System status, uptime, model info, session count, memory stats
|
|
284
|
+
- **Tools Management**: View all tools grouped by module, toggle enable/disable, change scope per tool
|
|
285
|
+
- **Plugin Marketplace**: Install, update, and manage plugins from registry with secrets management
|
|
286
|
+
- **Soul Editor**: Edit SOUL.md, SECURITY.md, STRATEGY.md, MEMORY.md with unsaved changes warning
|
|
204
287
|
- **Memory Search**: Search knowledge base with hybrid vector+keyword search
|
|
205
288
|
- **Live Logs**: Real-time log streaming via Server-Sent Events
|
|
289
|
+
- **Workspace**: File browser with inline text editor
|
|
290
|
+
- **MCP Servers**: Add/remove external tool servers, manage API keys (env vars), view connection status
|
|
291
|
+
- **Tasks**: Scheduled task management with status, dependencies, and bulk actions
|
|
206
292
|
|
|
207
293
|
### Usage
|
|
208
294
|
|
|
@@ -235,12 +321,13 @@ When WebUI is enabled, the agent will display:
|
|
|
235
321
|
|
|
236
322
|
1. Click the URL (token is auto-filled) or visit `http://localhost:7777`
|
|
237
323
|
2. Paste the token from the console (displayed once at startup)
|
|
238
|
-
3. Token is stored
|
|
324
|
+
3. Token is stored as HttpOnly cookie (7 days) for subsequent visits
|
|
239
325
|
|
|
240
326
|
### Security
|
|
241
327
|
|
|
242
328
|
- **Localhost only**: Server binds to `127.0.0.1` by default (not accessible from network)
|
|
243
|
-
- **Bearer token auth**: All API routes require authentication
|
|
329
|
+
- **Bearer token auth**: All API routes require authentication (timing-safe comparison)
|
|
330
|
+
- **HttpOnly cookies**: SameSite=Strict, prevents XSS token theft
|
|
244
331
|
- **No persistence**: Runtime changes (like model switches via WebUI) are not saved to config.yaml
|
|
245
332
|
- **For remote access**: Use SSH tunneling or reverse proxy (nginx/caddy) with HTTPS
|
|
246
333
|
|
|
@@ -257,22 +344,34 @@ The agent's personality and rules are configured via markdown files in `~/.telet
|
|
|
257
344
|
| File | Purpose | Mutable by Agent |
|
|
258
345
|
|------|---------|-----------------|
|
|
259
346
|
| `SOUL.md` | Personality, tone, behavior guidelines | No |
|
|
260
|
-
| `IDENTITY.md` | Agent name, bio, public-facing identity | No |
|
|
261
347
|
| `STRATEGY.md` | Trading rules, buy/sell thresholds | No |
|
|
262
348
|
| `SECURITY.md` | Security principles, threat recognition | No |
|
|
263
|
-
| `USER.md` | Owner information and preferences | No |
|
|
264
|
-
| `BOOTSTRAP.md` | First-run instructions (read once at startup) | No |
|
|
265
349
|
| `MEMORY.md` | Persistent memory (facts, contacts, decisions) | Yes |
|
|
350
|
+
| `memory/*.md` | Session summaries, daily logs (auto-generated) | Yes |
|
|
266
351
|
|
|
267
352
|
> **Tip**: Templates are located in `src/templates/` if installing from source. Edit the workspace copies in `~/.teleton/workspace/` — not the source templates.
|
|
268
353
|
|
|
269
354
|
### Admin Commands
|
|
270
355
|
|
|
356
|
+
All admin commands support `/`, `!`, or `.` prefix:
|
|
357
|
+
|
|
271
358
|
| Command | Description |
|
|
272
359
|
|---------|-------------|
|
|
360
|
+
| `/status` | Uptime, model, sessions, wallet, policies |
|
|
361
|
+
| `/model <name>` | Hot-swap LLM model at runtime |
|
|
362
|
+
| `/policy <dm\|group> <value>` | Change access policies live |
|
|
363
|
+
| `/loop <1-50>` | Set max agentic iterations |
|
|
364
|
+
| `/strategy [buy\|sell <pct>]` | View/change trading thresholds |
|
|
365
|
+
| `/wallet` | Show wallet address + balance |
|
|
366
|
+
| `/modules set\|info\|reset` | Per-group tool permissions |
|
|
367
|
+
| `/plugin set\|unset\|keys` | Manage plugin secrets |
|
|
273
368
|
| `/task <description>` | Assign a task to the agent |
|
|
274
|
-
| `/
|
|
369
|
+
| `/boot` | Run bootstrap template |
|
|
370
|
+
| `/pause` / `/resume` | Pause/resume agent |
|
|
275
371
|
| `/clear [chat_id]` | Clear conversation history |
|
|
372
|
+
| `/verbose` | Toggle debug logging |
|
|
373
|
+
| `/rag [status\|topk <n>]` | Toggle Tool RAG or view status |
|
|
374
|
+
| `/stop` | Emergency shutdown |
|
|
276
375
|
| `/ping` | Check responsiveness |
|
|
277
376
|
| `/help` | Show all commands |
|
|
278
377
|
|
|
@@ -286,29 +385,34 @@ The agent's personality and rules are configured via markdown files in `~/.telet
|
|
|
286
385
|
|-------|------------|
|
|
287
386
|
| LLM | Multi-provider via [pi-ai](https://github.com/mariozechner/pi-ai) (Anthropic, OpenAI, Google, xAI, Groq, OpenRouter) |
|
|
288
387
|
| Telegram Userbot | [GramJS](https://gram.js.org/) (MTProto) |
|
|
289
|
-
| Inline Bot | [Grammy](https://grammy.dev/) (Bot API) |
|
|
388
|
+
| Inline Bot | [Grammy](https://grammy.dev/) (Bot API, for deals) |
|
|
290
389
|
| Blockchain | [TON SDK](https://github.com/ton-org/ton) (W5R1 wallet) |
|
|
291
390
|
| DeFi | STON.fi SDK, DeDust SDK |
|
|
292
391
|
| Database | [better-sqlite3](https://github.com/WiseLibs/better-sqlite3) with WAL mode |
|
|
293
|
-
| Vector Search | [sqlite-vec](https://github.com/asg017/sqlite-vec) (
|
|
392
|
+
| Vector Search | [sqlite-vec](https://github.com/asg017/sqlite-vec) (cosine similarity) |
|
|
393
|
+
| Full-Text Search | SQLite FTS5 (BM25 ranking) |
|
|
394
|
+
| Embeddings | [@huggingface/transformers](https://www.npmjs.com/package/@huggingface/transformers) (local ONNX) or Voyage AI |
|
|
294
395
|
| Token Counting | [js-tiktoken](https://github.com/dqbd/tiktoken) |
|
|
396
|
+
| MCP Client | [@modelcontextprotocol/sdk](https://modelcontextprotocol.io/) (stdio + SSE transports) |
|
|
397
|
+
| WebUI | [Hono](https://hono.dev/) (API) + React + Vite (frontend) |
|
|
295
398
|
| Language | TypeScript 5.7, Node.js 20+ |
|
|
296
399
|
|
|
297
400
|
### Project Structure
|
|
298
401
|
|
|
299
402
|
```
|
|
300
403
|
src/
|
|
301
|
-
├── index.ts # Entry point, lifecycle,
|
|
404
|
+
├── index.ts # Entry point, TonnetApp lifecycle, graceful shutdown
|
|
302
405
|
├── agent/ # Core agent runtime
|
|
303
|
-
│ ├── runtime.ts # Agentic loop
|
|
406
|
+
│ ├── runtime.ts # Agentic loop (5 iterations, tool calling, masking, compaction)
|
|
304
407
|
│ ├── client.ts # Multi-provider LLM client
|
|
305
|
-
│ └── tools/ #
|
|
306
|
-
│ ├── register-all.ts # Central tool registration
|
|
307
|
-
│ ├── registry.ts # Tool registry
|
|
308
|
-
│ ├── module-loader.ts # Built-in module loading (deals)
|
|
309
|
-
│ ├── plugin-loader.ts # External plugin discovery
|
|
408
|
+
│ └── tools/ # 114 built-in tools
|
|
409
|
+
│ ├── register-all.ts # Central tool registration (8 categories, 109 tools)
|
|
410
|
+
│ ├── registry.ts # Tool registry, scope filtering, provider limits
|
|
411
|
+
│ ├── module-loader.ts # Built-in module loading (deals → +5 tools)
|
|
412
|
+
│ ├── plugin-loader.ts # External plugin discovery, validation, hot-reload
|
|
413
|
+
│ ├── mcp-loader.ts # MCP client (stdio/SSE), tool discovery, lifecycle
|
|
310
414
|
│ ├── telegram/ # Telegram operations (66 tools)
|
|
311
|
-
│ ├── ton/ # TON blockchain + jettons + DEX
|
|
415
|
+
│ ├── ton/ # TON blockchain + jettons + DEX router (15 tools)
|
|
312
416
|
│ ├── stonfi/ # STON.fi DEX (5 tools)
|
|
313
417
|
│ ├── dedust/ # DeDust DEX (5 tools)
|
|
314
418
|
│ ├── dns/ # TON DNS (7 tools)
|
|
@@ -323,43 +427,51 @@ src/
|
|
|
323
427
|
│ ├── gramjs-bot.ts # GramJS MTProto for styled buttons
|
|
324
428
|
│ └── services/ # Message builder, styled keyboard, verification
|
|
325
429
|
├── telegram/ # Telegram integration layer
|
|
326
|
-
│ ├── bridge.ts # GramJS wrapper (
|
|
327
|
-
│ ├── handlers.ts # Message routing
|
|
328
|
-
│ ├── admin.ts #
|
|
430
|
+
│ ├── bridge.ts # GramJS wrapper (peer cache, message parsing, keyboards)
|
|
431
|
+
│ ├── handlers.ts # Message routing, rate limiting, ChatQueue, feed storage
|
|
432
|
+
│ ├── admin.ts # 17 admin commands
|
|
329
433
|
│ ├── debounce.ts # Message batching for groups
|
|
330
434
|
│ ├── formatting.ts # Markdown → Telegram HTML
|
|
435
|
+
│ ├── task-executor.ts # Scheduled task runner
|
|
436
|
+
│ ├── task-dependency-resolver.ts # DAG-based task chains
|
|
331
437
|
│ └── callbacks/ # Inline button routing
|
|
332
438
|
├── memory/ # Storage and knowledge
|
|
333
|
-
│ ├── schema.ts #
|
|
334
|
-
│ ├── database.ts # SQLite + WAL +
|
|
335
|
-
│ ├── search/ # RAG system (
|
|
336
|
-
│ ├── embeddings/ # Local +
|
|
337
|
-
│ ├── compaction.ts # Context auto-compaction
|
|
439
|
+
│ ├── schema.ts # 10 tables, 25 indexes, FTS5, vec0, semver migrations
|
|
440
|
+
│ ├── database.ts # SQLite + WAL + sqlite-vec
|
|
441
|
+
│ ├── search/ # RAG system (hybrid vector + BM25 fusion via RRF)
|
|
442
|
+
│ ├── embeddings/ # Local ONNX + Voyage AI + caching provider
|
|
443
|
+
│ ├── compaction.ts # Context auto-compaction with AI summarization
|
|
338
444
|
│ ├── observation-masking.ts # Tool result compression (~90% savings)
|
|
339
445
|
│ └── daily-logs.ts # Automatic session summaries
|
|
340
446
|
├── ton/ # TON blockchain
|
|
341
|
-
│ ├── wallet-service.ts # W5R1 wallet
|
|
447
|
+
│ ├── wallet-service.ts # W5R1 wallet, PBKDF2 key caching, encrypted storage
|
|
342
448
|
│ ├── transfer.ts # TON send operations
|
|
343
|
-
│ └── payment-verifier.ts # On-chain payment verification
|
|
449
|
+
│ └── payment-verifier.ts # On-chain payment verification with replay protection
|
|
344
450
|
├── sdk/ # Plugin SDK (v1.0.0)
|
|
345
|
-
│ ├── index.ts # SDK factory (createPluginSDK)
|
|
451
|
+
│ ├── index.ts # SDK factory (createPluginSDK, all objects frozen)
|
|
346
452
|
│ ├── ton.ts # TON service for plugins
|
|
347
453
|
│ ├── telegram.ts # Telegram service for plugins
|
|
348
|
-
│
|
|
454
|
+
│ ├── secrets.ts # 3-tier secret resolution (env → file → config)
|
|
455
|
+
│ └── storage.ts # KV store with TTL
|
|
349
456
|
├── session/ # Session management
|
|
350
|
-
│ ├── store.ts # Session persistence (SQLite)
|
|
351
|
-
│ └── transcript.ts #
|
|
457
|
+
│ ├── store.ts # Session persistence (SQLite, daily reset, idle expiry)
|
|
458
|
+
│ └── transcript.ts # JSONL conversation transcripts
|
|
352
459
|
├── soul/ # System prompt assembly
|
|
353
|
-
│ └── loader.ts #
|
|
460
|
+
│ └── loader.ts # 10 sections: soul + security + strategy + memory + context + ...
|
|
354
461
|
├── config/ # Configuration
|
|
355
462
|
│ ├── schema.ts # Zod schemas + validation
|
|
356
|
-
│ └── providers.ts # Multi-provider LLM registry
|
|
463
|
+
│ └── providers.ts # Multi-provider LLM registry (6 providers)
|
|
464
|
+
├── webui/ # Optional web dashboard
|
|
465
|
+
│ ├── server.ts # Hono server, auth middleware, static serving
|
|
466
|
+
│ └── routes/ # 11 API route groups (status, tools, logs, memory, soul, plugins, mcp, tasks, workspace, config, marketplace)
|
|
357
467
|
├── constants/ # Centralized limits, timeouts, API endpoints
|
|
358
|
-
├── services/ # Shared services (TTS)
|
|
359
468
|
├── utils/ # Logger, sanitize, retry, fetch
|
|
360
|
-
├── workspace/ #
|
|
469
|
+
├── workspace/ # Path validator (anti-traversal, anti-symlink)
|
|
361
470
|
├── templates/ # Workspace template files (SOUL.md, etc.)
|
|
362
|
-
└── cli/ # CLI commands (setup, doctor)
|
|
471
|
+
└── cli/ # CLI commands (setup, config, doctor, mcp)
|
|
472
|
+
|
|
473
|
+
web/ # React + Vite frontend (10 pages)
|
|
474
|
+
packages/sdk/ # Published @teleton-agent/sdk
|
|
363
475
|
```
|
|
364
476
|
|
|
365
477
|
---
|
|
@@ -370,12 +482,14 @@ src/
|
|
|
370
482
|
|
|
371
483
|
| Layer | Protection |
|
|
372
484
|
|-------|-----------|
|
|
373
|
-
| **
|
|
485
|
+
| **Prompt injection** | `sanitizeForPrompt()` strips control chars, invisible unicode, markdown injection. `sanitizeForContext()` for RAG results |
|
|
374
486
|
| **Immutable config** | SOUL.md, STRATEGY.md, SECURITY.md cannot be modified by the agent |
|
|
375
|
-
| **
|
|
487
|
+
| **Workspace sandbox** | Agent confined to `~/.teleton/workspace/`, recursive URL decoding blocks double-encoding attacks, symlinks detected and blocked |
|
|
488
|
+
| **Plugin isolation** | Frozen SDK objects, sanitized config (no API keys), isolated per-plugin databases, `npm ci --ignore-scripts` |
|
|
489
|
+
| **Wallet protection** | File permissions `0o600`, KeyPair cached (single PBKDF2), mnemonic never exposed to plugins |
|
|
376
490
|
| **Memory protection** | Memory writes blocked in group chats to prevent poisoning |
|
|
377
|
-
| **
|
|
378
|
-
| **
|
|
491
|
+
| **Payment security** | `INSERT OR IGNORE` on tx hashes prevents double-spend, atomic status transitions prevent race conditions |
|
|
492
|
+
| **Tool scoping** | Financial tools DM-only, moderation group-only, per-chat permissions configurable at runtime |
|
|
379
493
|
|
|
380
494
|
### Reporting Vulnerabilities
|
|
381
495
|
|
|
@@ -407,25 +521,29 @@ npm run dev # Watch mode with auto-restart
|
|
|
407
521
|
### Commands
|
|
408
522
|
|
|
409
523
|
```bash
|
|
410
|
-
npm run build #
|
|
524
|
+
npm run build # SDK → backend (tsup) → frontend (vite)
|
|
411
525
|
npm run start # Start agent (compiled)
|
|
412
526
|
npm run dev # Development mode (watch, tsx)
|
|
527
|
+
npm run dev:web # Frontend dev server (port 5173, proxied to 7777)
|
|
413
528
|
npm run setup # Run setup wizard
|
|
414
529
|
npm run doctor # Health checks
|
|
415
530
|
npm run typecheck # Type checking
|
|
416
531
|
npm run lint # ESLint
|
|
532
|
+
npm run test # Vitest
|
|
417
533
|
npm run format # Prettier
|
|
418
534
|
```
|
|
419
535
|
|
|
420
536
|
### Plugins
|
|
421
537
|
|
|
422
|
-
Plugins extend the agent with custom tools. Drop a `.js` file or folder in `~/.teleton/plugins/` — loaded at startup, no rebuild needed.
|
|
538
|
+
Plugins extend the agent with custom tools. Drop a `.js` file or folder in `~/.teleton/plugins/` — loaded at startup, hot-reloaded in dev mode, no rebuild needed. See [official example plugins](https://github.com/TONresistor/teleton-plugins) for complete working examples.
|
|
423
539
|
|
|
424
540
|
```
|
|
425
541
|
~/.teleton/plugins/
|
|
426
542
|
├── weather.js # Single-file plugin
|
|
427
543
|
└── my-plugin/
|
|
428
|
-
|
|
544
|
+
├── index.js # Folder plugin
|
|
545
|
+
├── package.json # npm deps (auto-installed via npm ci)
|
|
546
|
+
└── package-lock.json
|
|
429
547
|
```
|
|
430
548
|
|
|
431
549
|
Plugins export a `tools` function (recommended) or array, plus optional lifecycle hooks:
|
|
@@ -436,7 +554,7 @@ Plugins export a `tools` function (recommended) or array, plus optional lifecycl
|
|
|
436
554
|
export const manifest = {
|
|
437
555
|
name: "weather",
|
|
438
556
|
version: "1.0.0",
|
|
439
|
-
sdkVersion: "1.0.0",
|
|
557
|
+
sdkVersion: "^1.0.0",
|
|
440
558
|
};
|
|
441
559
|
|
|
442
560
|
// Optional: creates an isolated database at ~/.teleton/plugins/data/weather.db
|
|
@@ -484,13 +602,17 @@ When `tools` is a function, the SDK provides namespaced access to core services:
|
|
|
484
602
|
| | **Moderation**: `banUser()`, `unbanUser()`, `muteUser()` |
|
|
485
603
|
| | **Stars & Gifts**: `getStarsBalance()`, `sendGift()`, `getAvailableGifts()`, `getMyGifts()`, `getResaleGifts()`, `buyResaleGift()` |
|
|
486
604
|
| | **Advanced**: `getMe()`, `isAvailable()`, `getRawClient()`, `setTyping()`, `sendStory()` |
|
|
487
|
-
| `sdk.secrets` | `get()`, `require()`, `has()` —
|
|
605
|
+
| `sdk.secrets` | `get()`, `require()`, `has()` — 3-tier resolution (env var → secrets file → plugin config) |
|
|
488
606
|
| `sdk.storage` | `get()`, `set()`, `delete()`, `has()`, `clear()` — KV store with TTL support |
|
|
489
|
-
| `sdk.db` | Raw `better-sqlite3` database
|
|
607
|
+
| `sdk.db` | Raw `better-sqlite3` database — isolated per plugin at `~/.teleton/plugins/data/<name>.db` |
|
|
490
608
|
| `sdk.config` | Sanitized app config (no API keys exposed) |
|
|
491
609
|
| `sdk.pluginConfig` | Plugin-specific config from `config.yaml` `plugins:` section |
|
|
492
610
|
| `sdk.log` | `info()`, `warn()`, `error()`, `debug()` — Prefixed logger |
|
|
493
611
|
|
|
612
|
+
**Lifecycle hooks**: `migrate(db)`, `start(ctx)`, `stop()`, `onMessage(event)`, `onCallbackQuery(event)`
|
|
613
|
+
|
|
614
|
+
**Security**: all SDK objects are `Object.freeze()`-ed. Plugins never see API keys or other plugins' data.
|
|
615
|
+
|
|
494
616
|
Plugin config in `config.yaml`:
|
|
495
617
|
```yaml
|
|
496
618
|
plugins:
|
|
@@ -503,21 +625,34 @@ Backward compatible: plugins can export `tools` as a static array without the SD
|
|
|
503
625
|
At startup:
|
|
504
626
|
```
|
|
505
627
|
🔌 Plugin "weather": 1 tool registered
|
|
506
|
-
✅
|
|
628
|
+
✅ 115 tools loaded (1 from plugins)
|
|
507
629
|
```
|
|
508
630
|
|
|
509
631
|
---
|
|
510
632
|
|
|
633
|
+
## Documentation
|
|
634
|
+
|
|
635
|
+
Full documentation is available in the [`docs/`](docs/) directory:
|
|
636
|
+
|
|
637
|
+
| Section | Description |
|
|
638
|
+
|---------|-------------|
|
|
639
|
+
| [Configuration Guide](docs/configuration.md) | Complete reference for every config option |
|
|
640
|
+
| [Deployment Guide](docs/deployment.md) | Docker, systemd, docker-compose, VPS |
|
|
641
|
+
| [Plugin Development](docs/plugins.md) | Step-by-step plugin tutorial |
|
|
642
|
+
| [Telegram Setup](docs/telegram-setup.md) | API credentials, policies, 2FA, admin commands |
|
|
643
|
+
| [TON Wallet](docs/ton-wallet.md) | Wallet setup, DEX trading, security |
|
|
644
|
+
|
|
645
|
+
---
|
|
646
|
+
|
|
511
647
|
## Contributing
|
|
512
648
|
|
|
513
|
-
|
|
649
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the full guide.
|
|
514
650
|
|
|
515
651
|
1. Fork the repository
|
|
516
|
-
2. Create a feature branch
|
|
652
|
+
2. Create a feature branch from `dev`
|
|
517
653
|
3. Make your changes
|
|
518
|
-
4.
|
|
519
|
-
5.
|
|
520
|
-
6. Open a Pull Request
|
|
654
|
+
4. Verify: `npm run typecheck && npm run lint && npm test`
|
|
655
|
+
5. Open a Pull Request against `dev`
|
|
521
656
|
|
|
522
657
|
---
|
|
523
658
|
|
|
@@ -545,6 +680,9 @@ MIT License - See [LICENSE](LICENSE) for details.
|
|
|
545
680
|
- [TON SDK](https://github.com/ton-org/ton) - TON blockchain client
|
|
546
681
|
- [STON.fi SDK](https://www.npmjs.com/package/@ston-fi/sdk) - DEX integration
|
|
547
682
|
- [DeDust SDK](https://www.npmjs.com/package/@dedust/sdk) - DEX integration
|
|
683
|
+
- [MCP SDK](https://github.com/modelcontextprotocol/typescript-sdk) - Model Context Protocol client
|
|
684
|
+
- [sqlite-vec](https://github.com/asg017/sqlite-vec) - Vector search for SQLite
|
|
685
|
+
- [Hono](https://hono.dev/) - Lightweight web framework
|
|
548
686
|
|
|
549
687
|
---
|
|
550
688
|
|