@fickydev/pigent 0.1.9 → 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`.
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
 
@@ -196,11 +202,11 @@
196
202
 
197
203
  ## Tests
198
204
 
205
+ - [x] Unit test `isTaskDue` logic
199
206
  - [ ] Unit test config validation
200
207
  - [ ] Unit test Telegram update normalization
201
208
  - [ ] Unit test routing rules
202
209
  - [ ] Unit test session key generation
203
- - [ ] Unit test heartbeat `NOOP` behavior
204
210
  - [ ] Unit test model selection priority
205
211
  - [ ] Unit test Telegram `/model` command parsing
206
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
+ );