@fickydev/pigent 0.1.8 → 0.1.10

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
@@ -4,6 +4,16 @@
4
4
 
5
5
  ### Added
6
6
 
7
+ - Added `task_runs` table and `TaskRepository` for scheduled task persistence.
8
+ - Added `Scheduler` module with global tick, per-task due check, lock, NOOP handling, and channel output.
9
+ - Added `scheduler` block to root config (`pigent.yaml`) with `tickIntervalMs` and `tasks[]`.
10
+ - Added `agent` field to task config to reference which agent executes the task.
11
+ - Replaced per-agent `heartbeat` config with daemon-level scheduler.
12
+ - Wired scheduler into daemon start/stop lifecycle.
13
+ - Added `task_configs` table and `TaskConfigRepository` for runtime task CRUD.
14
+ - Added `/task list`, `/task create <intervalMs> <prompt>`, `/task remove <id>` Telegram commands.
15
+ - Scheduler loads tasks from both config file and database, supports hot-add and hot-remove.
16
+
7
17
  - Added `bunx @fickydev/pigent <dir>` scaffold/setup/run CLI path.
8
18
  - Added one-command setup-and-run CLI at `src/cli/run.ts` and `bun run run`.
9
19
  - Added interactive setup CLI at `src/cli/setup.ts` and `bun run setup`.
@@ -45,6 +55,7 @@
45
55
  - Added session-scoped model and thinking level overrides with `/model` and `/thinking` Telegram commands.
46
56
  - Planned Telegram inline-button model and thinking level pickers backed by configured model choices.
47
57
  - Added Telegram inline-button pickers for `/model` and `/thinking`, callback handling, and bot command menu registration.
58
+ - Changed `/model` picker to use Pi's currently available models automatically when explicit `modelChoices` are not configured.
48
59
  - Kept daemon process alive after startup so CLI runs do not exit after `pigent ready`.
49
60
 
50
61
  ### Changed
package/PLAN.md CHANGED
@@ -214,7 +214,7 @@ Telegram should also provide inline-button pickers so non-technical users can ch
214
214
  - after selection, bot should answer the callback and update or send a confirmation message
215
215
  - daemon startup should register Telegram bot commands through `setMyCommands` so users see Pigent commands in the Telegram command menu
216
216
 
217
- Model choices should be explicitly configured instead of exposing every Pi model blindly:
217
+ Model choices default to Pi's currently available models from `ModelRegistry.getAvailable()`. Operators may optionally configure explicit choices to curate or rename the button list:
218
218
 
219
219
  ```yaml
220
220
  modelChoices:
@@ -226,7 +226,7 @@ modelChoices:
226
226
  label: GPT-4.1
227
227
  ```
228
228
 
229
- The command and callback handlers should validate agent access and model availability through a Pi model resolver. They must not reveal API keys, auth values, raw environment variables, or provider secrets.
229
+ The command and callback handlers should validate agent access and model availability through a Pi model resolver. They must not reveal API keys, auth values, raw environment variables, or provider secrets. The available-model fallback should use Pi auth presence checks only and never print secret values.
230
230
 
231
231
  ## Prompt Composition
232
232
 
package/TODO.md CHANGED
@@ -145,17 +145,23 @@
145
145
  - [x] Prototype one prompt through Pi SDK
146
146
  - [x] Decide CLI fallback strategy if SDK gaps appear
147
147
 
148
- ## Heartbeat
149
-
150
- - [ ] Define heartbeat config
151
- - [ ] Implement scheduler
152
- - [ ] Add per-agent heartbeat lock
153
- - [ ] Add heartbeat prompt composition
154
- - [ ] Add `NOOP` handling
155
- - [x] Persist heartbeat start/result/failure
156
- - [ ] Add notification cooldown
157
- - [ ] Add max heartbeat messages per hour
158
- - [ ] Send heartbeat output to configured channel only when useful
148
+ ## Scheduler
149
+
150
+ - [x] Define task config schema
151
+ - [x] Move task config from per-agent to daemon-level (`pigent.yaml`)
152
+ - [x] Add `task_runs` database table
153
+ - [x] Implement `TaskRepository`
154
+ - [x] Create `Scheduler` module (global tick, per-task due check, lock, NOOP, channel output)
155
+ - [x] Wire scheduler into daemon start/stop
156
+ - [x] Update example root config with scheduler block
157
+ - [x] Add `task_configs` DB table for runtime task definitions
158
+ - [x] Add `TaskConfigRepository`
159
+ - [x] Add `/task list` command
160
+ - [x] Add `/task create <intervalMs> <prompt>` command
161
+ - [x] Add `/task remove <id>` command
162
+ - [x] Scheduler loads tasks from both config file + DB
163
+ - [ ] Add max task runs per hour rate limit
164
+ - [ ] Add `/task status` or similar command
159
165
 
160
166
  ## Policy And Safety
161
167
 
@@ -184,9 +190,10 @@
184
190
  - [x] `/thinking` show thinking level for default chat agent session
185
191
  - [x] `/thinking <level>` set thinking level for default chat agent session
186
192
  - [x] `/thinking default` clear thinking level for default chat agent session
187
- - [x] `/model` inline button picker for configured model choices
193
+ - [x] `/model` inline button picker for currently available Pi models
188
194
  - [x] `/thinking` inline button picker
189
195
  - [x] Handle model picker callback and persist selected session model
196
+ - [x] Fallback to Pi `ModelRegistry.getAvailable()` when `modelChoices` is empty
190
197
  - [x] Handle thinking picker callback and persist selected session thinking level
191
198
  - [x] Add `Use default` model/thinking buttons
192
199
  - [ ] `/model <agentId> <provider/modelId>` set model for an explicit agent session
@@ -195,11 +202,11 @@
195
202
 
196
203
  ## Tests
197
204
 
205
+ - [x] Unit test `isTaskDue` logic
198
206
  - [ ] Unit test config validation
199
207
  - [ ] Unit test Telegram update normalization
200
208
  - [ ] Unit test routing rules
201
209
  - [ ] Unit test session key generation
202
- - [ ] Unit test heartbeat `NOOP` behavior
203
210
  - [ ] Unit test model selection priority
204
211
  - [ ] Unit test Telegram `/model` command parsing
205
212
  - [ ] Unit test Telegram model picker callback parsing
@@ -10,11 +10,6 @@ extensions: []
10
10
  channels:
11
11
  telegram:
12
12
  enabled: false
13
- heartbeat:
14
- enabled: false
15
- intervalMs: 600000
16
- prompt: |
17
- Check assigned tasks. If no useful action is needed, reply exactly: NOOP.
18
13
  permissions:
19
14
  canRunShell: false
20
15
  canEditFiles: false
@@ -0,0 +1,13 @@
1
+ CREATE TABLE `task_runs` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `agent_id` text NOT NULL,
4
+ `task_id` text NOT NULL,
5
+ `prompt` text NOT NULL,
6
+ `session_id` text,
7
+ `status` text NOT NULL,
8
+ `result` text,
9
+ `error` text,
10
+ `started_at` integer,
11
+ `finished_at` integer,
12
+ `created_at` integer NOT NULL
13
+ );
@@ -0,0 +1,11 @@
1
+ CREATE TABLE `task_configs` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `agent` text NOT NULL,
4
+ `interval_ms` integer NOT NULL,
5
+ `prompt` text NOT NULL,
6
+ `channel` text DEFAULT 'telegram' NOT NULL,
7
+ `chat_id` text NOT NULL,
8
+ `enabled` integer DEFAULT true NOT NULL,
9
+ `created_at` integer NOT NULL,
10
+ `updated_at` integer NOT NULL
11
+ );