@fickydev/pigent 0.1.15 → 0.1.16

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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.1.16 - 2026-05-18
6
+
7
+ ### Changed
8
+
9
+ - Reworked `README.md` to be more end-user facing with clearer setup, Telegram, sessions, agents, and operations guidance.
10
+
5
11
  ## 0.1.15 - 2026-05-18
6
12
 
7
13
  ### Fixed
package/README.md CHANGED
@@ -1,290 +1,217 @@
1
1
  # Pigent
2
2
 
3
- Pigent is an autonomous multi-agent daemon that uses Pi as its core execution engine. It routes messages from external channels, starting with Telegram, to Pi-backed agents with separate profiles, skills, extensions, permissions, heartbeat behavior, and per-chat sessions.
3
+ Pigent lets you run a Pi-powered assistant from Telegram.
4
4
 
5
- ## Status
5
+ Install it on a machine that stays online, connect a Telegram bot, then chat with your own coding/automation agent from Telegram private chats or groups. Pigent keeps per-chat sessions, supports multiple agents, and can run scheduled tasks.
6
6
 
7
- Early MVP.
7
+ ## What Pigent Does
8
8
 
9
- Current working slice:
9
+ - Runs as a background user service.
10
+ - Connects Telegram messages to Pi-backed agents.
11
+ - Keeps a separate session per agent + chat + thread.
12
+ - Lets you start a fresh session with `/new`.
13
+ - Shows current session/model/context info with `/status`.
14
+ - Supports model and thinking-level overrides from Telegram.
15
+ - Supports scheduled `/task` runs.
16
+ - Stores app state locally in SQLite.
17
+ - Persists Pi session files under `~/.pigent/pi-sessions` by default.
10
18
 
11
- ```text
12
- Telegram polling -> MessageRouter -> fake AgentRunner -> SQLite persistence -> Telegram reply
13
- ```
14
-
15
- Pi SDK execution is now wired through `PiAgentRunner`. Fake responses can still be forced for transport/routing tests with `PIGENT_FAKE_AGENT=1`.
16
-
17
- ## Stack
18
-
19
- - Bun
20
- - TypeScript
21
- - Drizzle ORM
22
- - SQLite now, PostgreSQL later
23
- - Telegram polling first
24
- - Pi SDK planned as execution core
25
- - Hono deferred until webhooks/API are needed
26
-
27
- ## Architecture
28
-
29
- ```text
30
- Channel Adapter -> Message Router -> Agent Orchestrator -> Pi Runner
31
- -> State Store
32
- -> Policy Engine
33
- ```
34
-
35
- Current modules:
36
-
37
- ```text
38
- src/
39
- main.ts
40
-
41
- daemon/
42
- AgentDaemon.ts
43
-
44
- pi/
45
- PiAgentRunner.ts
46
-
47
- channels/
48
- types.ts
49
- telegram/
50
- TelegramApi.ts
51
- TelegramPollingAdapter.ts
52
- types.ts
53
-
54
- agents/
55
- AgentRunner.ts
56
- BotCommandHandler.ts
57
- MessageRouter.ts
58
-
59
- config/
60
- loadConfig.ts
61
- schemas.ts
19
+ Pigent is still an early MVP. Telegram polling is the first supported channel.
62
20
 
63
- db/
64
- client.ts
65
- schema.ts
66
- repositories/
21
+ ## Quick Start
67
22
 
68
- logging/
69
- logger.ts
70
- ```
71
-
72
- ## Setup And Run
73
-
74
- Install and start Pigent as a user service:
23
+ Install and start Pigent:
75
24
 
76
25
  ```bash
77
26
  bunx @fickydev/pigent
78
27
  ```
79
28
 
29
+ The setup wizard will ask for:
30
+
31
+ - quick or custom setup
32
+ - Telegram bot token
33
+ - default agent routing
34
+ - optional automatic Telegram chat setup
35
+
80
36
  Default app directory:
81
37
 
82
38
  ```text
83
39
  ~/.pigent/app
84
40
  ```
85
41
 
86
- After install, use short commands:
42
+ After setup, use:
87
43
 
88
44
  ```bash
89
45
  pigent status
90
46
  pigent logs
91
- pigent stop
92
- pigent start
93
47
  pigent restart
94
48
  pigent update
95
49
  pigent setup
96
50
  ```
97
51
 
98
- Update to latest package:
52
+ Update Pigent later:
99
53
 
100
54
  ```bash
101
55
  pigent update
102
56
  ```
103
57
 
104
- `pigent update` backs up the app, preserves `.env`, SQLite DB, `pigent.yaml`, `agents/`, and `profiles/`, refreshes shipped files, and restarts the service.
58
+ `pigent update` backs up the app, keeps your `.env`, SQLite database, `pigent.yaml`, `agents/`, and `profiles/`, refreshes package files, then restarts the service.
105
59
 
106
- Run in foreground instead of installing a service:
60
+ ## Create A Telegram Bot
107
61
 
108
- ```bash
109
- bunx @fickydev/pigent run
62
+ 1. Open Telegram and message `@BotFather`.
63
+ 2. Send:
64
+
65
+ ```text
66
+ /newbot
110
67
  ```
111
68
 
112
- From a checked-out repo:
69
+ 3. Follow BotFather prompts.
70
+ 4. Copy the bot token.
71
+ 5. Run setup again if needed:
113
72
 
114
73
  ```bash
115
- bun run run
74
+ pigent setup
116
75
  ```
117
76
 
118
- The setup flow will:
119
-
120
- - ask for quick or custom mode
121
- - create `.env` from `.env.example` if missing
122
- - configure `DATABASE_URL`
123
- - optionally write or replace `TELEGRAM_BOT_TOKEN`
124
- - optionally enable automatic Telegram chat setup
125
- - optionally configure Telegram chat routing in `pigent.yaml`
126
- - optionally configure log level and Telegram polling values in custom mode
127
- Database migrations run automatically at daemon startup. The published CLI does not ask users to run `bun install`, `bun start`, or `bun typecheck`.
77
+ Paste the token when prompted.
128
78
 
129
- Manual setup:
79
+ You can also put it in `~/.pigent/app/.env`:
130
80
 
131
- ```bash
132
- bun install
133
- cp .env.example .env
134
- bun run db:migrate
135
- bun run typecheck
81
+ ```env
82
+ TELEGRAM_BOT_TOKEN=123456:abc...
136
83
  ```
137
84
 
138
- Configure `.env`:
85
+ ## First Chat
139
86
 
140
- ```env
141
- DATABASE_URL=file:./pigent.db
142
- TELEGRAM_BOT_TOKEN=
143
- PIGENT_WORKSPACE_ROOT=~/.pigent
144
- PIGENT_FAKE_AGENT=0
145
- PIGENT_FALLBACK_FAKE_AGENT=1
146
- PIGENT_AUTO_SETUP_CHATS=1
147
- PIGENT_AUTO_SETUP_DEFAULT_AGENT=assistant
87
+ Send your bot a message in Telegram:
88
+
89
+ ```text
90
+ /help
148
91
  ```
149
92
 
150
- Start daemon directly after setup:
93
+ If automatic chat setup is enabled, Pigent will route the chat to the default `assistant` agent.
151
94
 
152
- ```bash
153
- bun run start
95
+ If automatic setup is disabled, configure the chat in `pigent.yaml`:
96
+
97
+ ```yaml
98
+ telegramChats:
99
+ - chatId: "123456"
100
+ title: My Private Chat
101
+ defaultAgent: assistant
102
+ allowedAgents:
103
+ - assistant
104
+ instructions: |
105
+ Be concise.
154
106
  ```
155
107
 
156
- Development watch mode:
108
+ Then restart:
157
109
 
158
110
  ```bash
159
- bun run dev
111
+ pigent restart
160
112
  ```
161
113
 
162
- Typecheck:
114
+ To find a chat id, send any message to the bot and check logs:
163
115
 
164
116
  ```bash
165
- bun run typecheck
117
+ pigent logs
166
118
  ```
167
119
 
168
- ## Telegram Testing
169
-
170
- ### 1. Create bot
171
-
172
- Use Telegram `@BotFather`:
120
+ Look for:
173
121
 
174
- ```text
175
- /newbot
122
+ ```json
123
+ {"message":"inbound message received","chatId":"123456"}
176
124
  ```
177
125
 
178
- Copy token into `.env`:
179
-
180
- ```env
181
- TELEGRAM_BOT_TOKEN=123456:abc...
182
- ```
126
+ Group chat ids often start with `-100`.
183
127
 
184
- ### 2. Discover chat id
128
+ ## Telegram Commands
185
129
 
186
- Run daemon:
130
+ Common commands:
187
131
 
188
- ```bash
189
- bun run start
132
+ ```text
133
+ /help Show help
134
+ /start Start bot help
135
+ /agents List agents
136
+ /new Start a fresh chat session
137
+ /status Show session/model/context status
138
+ /model Pick model
139
+ /thinking Pick thinking level
140
+ /agent <agentId> <message> Send message to a specific agent
141
+ @agentId <message> Send message to a specific agent
190
142
  ```
191
143
 
192
- Message bot in private chat or add bot to a group and send `/help`.
193
-
194
- Logs will include:
144
+ Task commands:
195
145
 
196
- ```json
197
- {"message":"inbound message received","chatId":"123456"}
146
+ ```text
147
+ /task list
148
+ /task create <intervalMs> <prompt>
149
+ /task remove <id>
198
150
  ```
199
151
 
200
- Group chat ids usually look like:
152
+ Example:
201
153
 
202
154
  ```text
203
- -1001234567890
155
+ /task create 3600000 Check repo status and summarize anything important.
204
156
  ```
205
157
 
206
- ### 3. Configure chat
158
+ ## Sessions And Memory
207
159
 
208
- Edit `pigent.yaml`:
160
+ Pigent keeps sessions by this key:
209
161
 
210
- ```yaml
211
- telegramChats:
212
- - chatId: "123456"
213
- title: Ficky Private Chat
214
- defaultAgent: assistant
215
- allowedAgents:
216
- - assistant
217
- instructions: |
218
- Be concise.
162
+ ```text
163
+ agentId + channel + chatId + threadId
219
164
  ```
220
165
 
221
- Restart daemon after editing config.
166
+ That means:
222
167
 
223
- ### 4. Test commands
168
+ - private chats get their own session
169
+ - groups share a session by default
170
+ - Telegram forum topics can have separate sessions
171
+ - different agents do not share the same session
224
172
 
225
- In Telegram:
173
+ Use `/new` to end the current active session and start fresh. The next normal message creates a new Pi session file.
226
174
 
227
- ```text
228
- /help
229
- ```
175
+ Use `/status` to inspect current state. When a Pi session exists, status shows Pi context usage; otherwise it falls back to a database estimate.
230
176
 
231
- ```text
232
- /agents
233
- ```
177
+ Pi session files live here by default:
234
178
 
235
179
  ```text
236
- hello
180
+ ~/.pigent/pi-sessions
237
181
  ```
238
182
 
239
- ```text
240
- @assistant review this
241
- ```
183
+ Override with:
242
184
 
243
- ```text
244
- /agent assistant write a test
185
+ ```env
186
+ PIGENT_PI_SESSION_DIR=/path/to/pi-sessions
245
187
  ```
246
188
 
247
- With `PIGENT_FAKE_AGENT=1`, expected fake runner response:
189
+ ## Agents
190
+
191
+ The default assistant lives at:
248
192
 
249
193
  ```text
250
- [Assistant] fake runner received: hello
194
+ ~/.pigent/app/agents/assistant/
251
195
  ```
252
196
 
253
- With `PIGENT_FAKE_AGENT=0`, Pigent calls the Pi SDK and returns the Pi assistant response.
254
-
255
- ## Agent Config
256
-
257
- Example agent lives at:
197
+ Main files:
258
198
 
259
199
  ```text
260
200
  agents/assistant/agent.yaml
261
201
  agents/assistant/SYSTEM.md
262
- ```
263
-
264
- Example profile:
265
-
266
- ```text
267
202
  profiles/assistant.yaml
268
203
  ```
269
204
 
270
- Agent config shape:
205
+ Example `agent.yaml`:
271
206
 
272
207
  ```yaml
273
208
  id: assistant
274
209
  name: Assistant
275
- profile: generic-assistant
210
+ profile: assistant
276
211
  workspace: ~/.pigent/workspaces/assistant
277
212
  systemPromptFile: ./SYSTEM.md
278
213
  skills: []
279
214
  extensions: []
280
- channels:
281
- telegram:
282
- enabled: false
283
- heartbeat:
284
- enabled: false
285
- intervalMs: 600000
286
- prompt: |
287
- Check assigned tasks. If no useful action is needed, reply exactly: NOOP.
288
215
  permissions:
289
216
  canRunShell: false
290
217
  canEditFiles: false
@@ -292,100 +219,124 @@ permissions:
292
219
  blockedTools: []
293
220
  ```
294
221
 
295
- ## Automatic Chat Setup
222
+ Edit `SYSTEM.md` to change how the agent behaves.
223
+
224
+ Each agent can have its own:
225
+
226
+ - name
227
+ - profile
228
+ - workspace
229
+ - system prompt
230
+ - skills/extensions
231
+ - permissions
296
232
 
297
- For easier Telegram testing, Pigent can auto-create DB routing for new Telegram chats.
233
+ ## Configuration
298
234
 
299
- Enable in `.env`:
235
+ Important environment variables in `~/.pigent/app/.env`:
300
236
 
301
237
  ```env
238
+ DATABASE_URL=file:./pigent.db
239
+ TELEGRAM_BOT_TOKEN=
240
+ PIGENT_WORKSPACE_ROOT=~/.pigent
241
+ PIGENT_PI_SESSION_DIR=~/.pigent/pi-sessions
242
+ PIGENT_FAKE_AGENT=0
243
+ PIGENT_FALLBACK_FAKE_AGENT=1
302
244
  PIGENT_AUTO_SETUP_CHATS=1
303
245
  PIGENT_AUTO_SETUP_DEFAULT_AGENT=assistant
304
246
  ```
305
247
 
306
- When a new Telegram chat sends any message Pigent receives, the daemon inserts a chat config into SQLite with:
248
+ Use fake mode only for testing Telegram routing without calling Pi:
307
249
 
308
- - `defaultAgent: assistant`
309
- - `allowedAgents: [assistant]`
310
- - `enabled: true`
250
+ ```env
251
+ PIGENT_FAKE_AGENT=1
252
+ ```
311
253
 
312
- This does not write to `pigent.yaml`; it creates runtime DB config only. Keep it off for stricter production setups.
254
+ ## Running In Foreground
313
255
 
314
- ## Routing
256
+ Run without installing a service:
315
257
 
316
- One Telegram bot can serve many agents.
258
+ ```bash
259
+ bunx @fickydev/pigent run
260
+ ```
317
261
 
318
- Routing priority:
262
+ From a checked-out repo:
319
263
 
320
- 1. `@agentId <message>`
321
- 2. `/agent <agentId> <message>`
322
- 3. chat default agent
323
- 4. no-route error
264
+ ```bash
265
+ bun install
266
+ bun run run
267
+ ```
324
268
 
325
- Session key:
269
+ Development commands:
270
+
271
+ ```bash
272
+ bun run start
273
+ bun run dev
274
+ bun run typecheck
275
+ bun run check
276
+ ```
277
+
278
+ ## Data Storage
279
+
280
+ Pigent stores local runtime data in SQLite.
281
+
282
+ Default database:
326
283
 
327
284
  ```text
328
- agentId + channel + chatId + threadId
285
+ ~/.pigent/app/pigent.db
329
286
  ```
330
287
 
331
- ## Database
288
+ Configured by:
332
289
 
333
- Drizzle schema currently includes:
290
+ ```env
291
+ DATABASE_URL=file:./pigent.db
292
+ ```
293
+
294
+ Important tables include:
334
295
 
335
296
  - `agents`
336
297
  - `agent_sessions`
337
298
  - `telegram_chats`
338
299
  - `telegram_chat_agents`
339
300
  - `messages`
340
- - `heartbeats`
301
+ - `task_configs`
302
+ - `task_runs`
341
303
  - `runtime_kv`
342
304
 
343
- SQLite database path is controlled by:
344
-
345
- ```env
346
- DATABASE_URL=file:./pigent.db
347
- ```
305
+ Database migrations run automatically when the daemon starts.
348
306
 
349
- ## Commands
307
+ ## Architecture
350
308
 
351
- Available Telegram commands:
309
+ High-level flow:
352
310
 
353
311
  ```text
354
- /help
355
- /start
356
- /agents
357
- /new
358
- /status
359
- /model
360
- /thinking
361
- /task list
362
- /task create <intervalMs> <prompt>
363
- /task remove <id>
364
- /agent <agentId> <message>
312
+ Telegram -> Message Router -> Agent Runner -> Pi Runner
313
+ \-> SQLite state
365
314
  ```
366
315
 
367
- Planned commands:
316
+ Code layout:
368
317
 
369
318
  ```text
370
- /default-agent <agentId>
371
- /instructions <text>
372
- /sessions
373
- /reset-session <agentId>
374
- /heartbeat status
319
+ src/
320
+ main.ts
321
+ daemon/
322
+ channels/telegram/
323
+ agents/
324
+ pi/
325
+ db/
326
+ config/
327
+ logging/
375
328
  ```
376
329
 
377
- ## Development Notes
330
+ ## Safety Notes
378
331
 
379
- - Do not add Hono until webhook/API needs exist.
380
- - Keep Telegram-specific logic inside `src/channels/telegram` or routing config.
381
- - Channel adapters must not call Pi directly.
382
- - Pi runner must not know channel secrets.
383
- - Pi sessions are persisted under `~/.pigent/pi-sessions` by default (`PIGENT_PI_SESSION_DIR` overrides this).
384
- - Use repositories for database access.
385
- - Keep SQLite/PostgreSQL portability in mind.
386
- - Never inject secrets or raw `.env` values into model prompts.
332
+ - Do not put bot tokens or API keys in prompts.
333
+ - Keep Telegram-specific logic inside the Telegram channel adapter or routing config.
334
+ - Channel adapters should not call Pi directly.
335
+ - Pi runner should not know Telegram secrets.
336
+ - Default permissions are conservative.
337
+ - File and shell capabilities should be enabled only for trusted agents/workspaces.
387
338
 
388
- See also:
339
+ ## More Docs
389
340
 
390
341
  - `PLAN.md` — architecture and milestones
391
342
  - `TODO.md` — task checklist
package/TODO.md CHANGED
@@ -143,6 +143,7 @@
143
143
  - [x] Persist Pi session file path per active Pigent session
144
144
  - [x] Reuse Pi session files across messages
145
145
  - [x] Self-heal missing runtime `agent_sessions` columns after partial/mismatched migration state
146
+ - [x] Make README more end-user facing
146
147
  - [ ] Confirm per-agent system prompt injection
147
148
  - [ ] Confirm per-agent skills loading
148
149
  - [ ] Confirm per-agent extensions loading
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fickydev/pigent",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Autonomous multi-agent daemon using Pi as core execution engine.",