@fickydev/pigent 0.1.5 → 0.1.7

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
@@ -34,6 +34,15 @@
34
34
  - Added short `pigent` command shim for `status`, `logs`, `start`, `stop`, `restart`, `update`, and `setup`.
35
35
  - Simplified published CLI flow so `bunx @fickydev/pigent` runs setup and starts Pigent without install/start/typecheck prompts.
36
36
  - Added automatic database migrations at daemon startup.
37
+ - Added `HeartbeatRepository` for creating, updating, and querying heartbeat runs.
38
+ - Added `AgentRegistry` to centralize loaded agent/profile lookup and agent DB sync.
39
+ - Added safe Pi runner failure replies with internal error persistence.
40
+ - Added per-session locking to serialize Pi runs for the same agent/channel/chat/thread.
41
+ - Added Telegram chat instructions to Pi prompt composition.
42
+ - Added Telegram API retry/backoff for transient network, rate limit, and server errors.
43
+ - Planned model selection support across profile, agent, and Telegram chat override levels.
44
+ - Added profile and agent config-based Pi model and thinking level selection.
45
+ - Added session-scoped model and thinking level overrides with `/model` and `/thinking` Telegram commands.
37
46
  - Kept daemon process alive after startup so CLI runs do not exit after `pigent ready`.
38
47
 
39
48
  ### Changed
package/PLAN.md CHANGED
@@ -61,7 +61,8 @@ Profile defines reusable behavior shared by agents.
61
61
 
62
62
  Profile may include:
63
63
 
64
- - model preference
64
+ - model preference using `provider/modelId`
65
+ - thinking level preference (`off`, `low`, `medium`, `high`)
65
66
  - base system prompt
66
67
  - response style
67
68
  - default skills
@@ -152,6 +153,8 @@ Each Telegram group/private chat can define:
152
153
  - default agent
153
154
  - allowed agents
154
155
  - custom instructions
156
+ - per-agent model override via Telegram command
157
+ - per-agent thinking level override via Telegram command
155
158
  - heartbeat settings
156
159
  - enabled/disabled status
157
160
 
@@ -170,6 +173,41 @@ telegramChats:
170
173
  This is engineering group. Be concise. Prefer TypeScript.
171
174
  ```
172
175
 
176
+ ## Model Selection
177
+
178
+ Pigent should support model selection at multiple levels without exposing provider secrets to channel prompts.
179
+
180
+ Model identifiers use Pi SDK `provider/modelId` format, for example:
181
+
182
+ ```text
183
+ anthropic/claude-opus-4-5
184
+ openai/gpt-4.1
185
+ ollama/qwen2.5-coder:7b
186
+ ```
187
+
188
+ Selection priority:
189
+
190
+ ```text
191
+ session override > agent config > profile config > Pi default
192
+ ```
193
+
194
+ A session is keyed by `agentId + channel + chatId + threadId`, so the same agent can use different models in private chats, group chats, and Telegram forum topics.
195
+
196
+ Config support should come first:
197
+
198
+ - `profiles/*.yaml` may define `model` and `thinkingLevel`
199
+ - `agents/*/agent.yaml` may override `model` and `thinkingLevel`
200
+
201
+ Telegram command support should persist session-scoped overrides after config support exists:
202
+
203
+ - `/model` shows current model for the default agent in the chat
204
+ - `/model <provider/modelId>` sets model for the default agent session in the current chat/thread
205
+ - `/model default` clears model override for the default agent session in the current chat/thread
206
+ - `/thinking <level>` sets thinking level for the default agent session in the current chat/thread
207
+ - `/thinking default` clears thinking override for the default agent session in the current chat/thread
208
+
209
+ The command handler should validate agent access and model availability through a Pi model resolver. It must not reveal API keys, auth values, raw environment variables, or provider secrets.
210
+
173
211
  ## Prompt Composition
174
212
 
175
213
  For each request, compose context from:
@@ -195,6 +233,7 @@ Initial entities:
195
233
  - telegram chat agents
196
234
  - messages
197
235
  - heartbeats
236
+ - session model/thinking overrides
198
237
  - tasks/events later
199
238
 
200
239
  SQLite first. Keep schema types portable so PostgreSQL migration is straightforward.
@@ -319,6 +358,8 @@ drizzle/
319
358
  ### Milestone 6: Pi Runner
320
359
 
321
360
  - create Pi SDK sessions
361
+ - resolve profile/agent model preferences
362
+ - resolve chat model overrides
322
363
  - send prompts
323
364
  - return responses
324
365
  - persist inbound/outbound messages
@@ -362,6 +403,8 @@ Add Hono only after daemon works. Use it for:
362
403
 
363
404
  ## Open Questions
364
405
 
406
+ - Should `/model <agentId> ...` support non-default agent sessions in the command itself?
407
+ - Should model availability errors block `/model` saves or save with a warning?
365
408
  - Which Pi SDK session manager should be used for persistent sessions?
366
409
  - How exactly should per-agent skills/extensions be loaded into Pi runtime?
367
410
  - Should group instructions live in YAML, DB, or both?
package/TODO.md CHANGED
@@ -39,6 +39,9 @@
39
39
 
40
40
  ## Config
41
41
 
42
+ - [x] Add profile-level `thinkingLevel` config
43
+ - [x] Add agent-level `model` override config
44
+ - [x] Add agent-level `thinkingLevel` override config
42
45
  - [x] Define root config format
43
46
  - [x] Define `AgentConfig`
44
47
  - [x] Define `ProfileConfig`
@@ -66,12 +69,14 @@
66
69
  - [x] Define `messages` table
67
70
  - [x] Define `heartbeats` table
68
71
  - [x] Define `runtime_kv` table for offsets and daemon state
69
- - [ ] Implement repositories
72
+ - [x] Add `agent_sessions.model` for session model override
73
+ - [x] Add `agent_sessions.thinking_level` for session thinking override
74
+ - [x] Implement repositories
70
75
  - [x] `AgentRepository`
71
76
  - [x] `SessionRepository`
72
77
  - [x] `MessageRepository`
73
78
  - [x] `TelegramRepository`
74
- - [ ] `HeartbeatRepository`
79
+ - [x] `HeartbeatRepository`
75
80
 
76
81
  ## Channel Layer
77
82
 
@@ -83,7 +88,7 @@
83
88
  - [x] `getUpdates`
84
89
  - [x] `sendMessage`
85
90
  - [x] error handling
86
- - [ ] retry/backoff
91
+ - [x] retry/backoff
87
92
  - [x] Implement `TelegramPollingAdapter`
88
93
  - [x] polling loop
89
94
  - [x] offset tracking
@@ -106,21 +111,27 @@
106
111
 
107
112
  ## Agent Runtime
108
113
 
109
- - [ ] Implement `AgentRegistry`
114
+ - [x] Implement `AgentRegistry`
110
115
  - [x] Implement `AgentDaemon`
111
116
  - [x] Implement `AgentRunner`
112
117
  - [ ] Implement `PiSessionFactory`
113
118
  - [x] Implement `PiAgentRunner`
114
119
  - [x] Create/get session by `agentId + channel + chatId + threadId`
115
- - [ ] Compose prompt with chat instructions
120
+ - [x] Compose prompt with chat instructions
116
121
  - [x] Compose basic channel/chat/user prompt for Pi runner
117
122
  - [x] Persist inbound message before Pi run
118
123
  - [x] Persist outbound response after Pi run
119
- - [ ] Handle Pi errors and send safe error reply
120
- - [ ] Add per-session lock to prevent concurrent Pi runs
124
+ - [x] Handle Pi errors and send safe error reply
125
+ - [x] Add per-session lock to prevent concurrent Pi runs
121
126
 
122
127
  ## Pi Integration
123
128
 
129
+ - [x] Confirm SDK model selection supports `createAgentSession({ model, thinkingLevel })`
130
+ - [x] Implement Pi model resolver for `provider/modelId`
131
+ - [x] Apply profile-level model selection
132
+ - [x] Apply agent-level model override
133
+ - [x] Apply session model override
134
+ - [x] Apply thinking level selection
124
135
  - [x] Confirm SDK APIs needed for session creation
125
136
  - [ ] Confirm persistent session manager approach
126
137
  - [ ] Confirm per-agent system prompt injection
@@ -136,7 +147,7 @@
136
147
  - [ ] Add per-agent heartbeat lock
137
148
  - [ ] Add heartbeat prompt composition
138
149
  - [ ] Add `NOOP` handling
139
- - [ ] Persist heartbeat start/result/failure
150
+ - [x] Persist heartbeat start/result/failure
140
151
  - [ ] Add notification cooldown
141
152
  - [ ] Add max heartbeat messages per hour
142
153
  - [ ] Send heartbeat output to configured channel only when useful
@@ -156,12 +167,20 @@
156
167
  ## Commands UX
157
168
 
158
169
  - [x] `/agents` list agents available in chat
159
- - [ ] `/agent <id> <message>` route message
170
+ - [x] `/agent <id> <message>` route message
160
171
  - [ ] `/default-agent <id>` set chat default
161
172
  - [ ] `/instructions <text>` set chat instructions
162
173
  - [ ] `/sessions` list active sessions for chat
163
174
  - [ ] `/reset-session <agentId>` clear chat session
164
175
  - [ ] `/heartbeat status` show heartbeat state
176
+ - [x] `/model` show current model for default chat agent session
177
+ - [x] `/model <provider/modelId>` set model for default chat agent session
178
+ - [x] `/model default` clear model for default chat agent session
179
+ - [x] `/thinking` show thinking level for default chat agent session
180
+ - [x] `/thinking <level>` set thinking level for default chat agent session
181
+ - [x] `/thinking default` clear thinking level for default chat agent session
182
+ - [ ] `/model <agentId> <provider/modelId>` set model for an explicit agent session
183
+ - [ ] `/thinking <agentId> <level>` set thinking level for an explicit agent session
165
184
  - [x] `/help` show bot commands
166
185
 
167
186
  ## Tests
@@ -171,6 +190,8 @@
171
190
  - [ ] Unit test routing rules
172
191
  - [ ] Unit test session key generation
173
192
  - [ ] Unit test heartbeat `NOOP` behavior
193
+ - [ ] Unit test model selection priority
194
+ - [ ] Unit test Telegram `/model` command parsing
174
195
  - [ ] Repository tests against temp SQLite DB
175
196
  - [ ] Integration test fake Telegram update to fake Pi runner
176
197
 
@@ -1,6 +1,8 @@
1
1
  id: assistant
2
2
  name: Assistant
3
3
  profile: generic-assistant
4
+ model: null
5
+ thinkingLevel: null
4
6
  workspace: ~/.pigent/workspaces/assistant
5
7
  systemPromptFile: ./SYSTEM.md
6
8
  skills: []
@@ -0,0 +1,2 @@
1
+ ALTER TABLE `agent_sessions` ADD `model` text;--> statement-breakpoint
2
+ ALTER TABLE `agent_sessions` ADD `thinking_level` text;