@amaster.ai/pi-task-scheduler 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/README.md +11 -29
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,21 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
Scheduled task domain types, execution scheduler, and pi agent extension.
|
|
6
6
|
|
|
7
|
-
The package owns schedule parsing, task lifecycle state, process-local timers,
|
|
8
|
-
runner callbacks, scheduler hooks, and LLM-callable tools for autonomous task
|
|
9
|
-
management.
|
|
7
|
+
The package owns schedule parsing, task lifecycle state, process-local timers, runner callbacks, scheduler hooks, and LLM-callable tools for autonomous task management.
|
|
10
8
|
|
|
11
9
|
## Storage
|
|
12
10
|
|
|
13
|
-
The package ships with a built-in file-based storage (default, zero external
|
|
14
|
-
dependencies):
|
|
11
|
+
The package ships with a built-in file-based storage (default, zero external dependencies):
|
|
15
12
|
|
|
16
13
|
- `JsonScheduledTaskStore` — persists tasks to a JSON file with atomic writes
|
|
17
14
|
- `FileSchedulerLock` — PID-based file lock for single-owner execution
|
|
18
15
|
|
|
19
|
-
For database-backed storage (multi-tenant, Prisma), use
|
|
20
|
-
`@amaster.ai/pi-storage/scheduler` which implements the same interfaces with
|
|
21
|
-
`DbScheduledTaskStore` and `RedisSchedulerLock`.
|
|
16
|
+
For database-backed storage (multi-tenant, Prisma), use `@amaster.ai/pi-storage/scheduler` which implements the same interfaces with `DbScheduledTaskStore` and `RedisSchedulerLock`.
|
|
22
17
|
|
|
23
18
|
### Default (file storage)
|
|
24
19
|
|
|
@@ -42,8 +37,7 @@ await scheduler.start();
|
|
|
42
37
|
|
|
43
38
|
### Custom storage
|
|
44
39
|
|
|
45
|
-
Implement `ScheduledTaskStore` and `SchedulerLock` interfaces for any backend
|
|
46
|
-
(database, Redis, etc.):
|
|
40
|
+
Implement `ScheduledTaskStore` and `SchedulerLock` interfaces for any backend (database, Redis, etc.):
|
|
47
41
|
|
|
48
42
|
```ts
|
|
49
43
|
import { PersistentTaskScheduler } from "@amaster.ai/pi-task-scheduler";
|
|
@@ -61,16 +55,11 @@ await scheduler.start();
|
|
|
61
55
|
|
|
62
56
|
## Integration Modes
|
|
63
57
|
|
|
64
|
-
The package provides two integration paths depending on who controls the
|
|
65
|
-
scheduler lifecycle.
|
|
58
|
+
The package provides two integration paths depending on who controls the scheduler lifecycle.
|
|
66
59
|
|
|
67
60
|
### Mode 1: Extension auto-discovery (standalone / CLI)
|
|
68
61
|
|
|
69
|
-
When installed as an npm dependency with the `pi.extensions` field in
|
|
70
|
-
`package.json`, the runtime auto-discovers and loads the extension. The
|
|
71
|
-
extension creates its own `PersistentTaskScheduler` with file-based storage
|
|
72
|
-
(`JsonScheduledTaskStore` + `FileSchedulerLock`) — fully self-contained, no
|
|
73
|
-
external infrastructure needed.
|
|
62
|
+
When installed as an npm dependency with the `pi.extensions` field in `package.json`, the runtime auto-discovers and loads the extension. The extension creates its own `PersistentTaskScheduler` with file-based storage (`JsonScheduledTaskStore` + `FileSchedulerLock`) — fully self-contained, no external infrastructure needed.
|
|
74
63
|
|
|
75
64
|
```
|
|
76
65
|
pi.extensions → session_start → creates file-based scheduler → registers tools + commands
|
|
@@ -86,9 +75,7 @@ pi.extensions → session_start → creates file-based scheduler → registers t
|
|
|
86
75
|
|
|
87
76
|
Configuration via settings key `pi-scheduler`:
|
|
88
77
|
|
|
89
|
-
Project `.pi/settings.json` values are loaded only after project trust is
|
|
90
|
-
accepted and are not environment-interpolated. User and agent settings retain
|
|
91
|
-
environment interpolation.
|
|
78
|
+
Project `.pi/settings.json` values are loaded only after project trust is accepted and are not environment-interpolated. User and agent settings retain environment interpolation.
|
|
92
79
|
|
|
93
80
|
```json
|
|
94
81
|
{
|
|
@@ -100,9 +87,7 @@ environment interpolation.
|
|
|
100
87
|
|
|
101
88
|
### Mode 2: Dependency import (host-controlled)
|
|
102
89
|
|
|
103
|
-
When the host process owns the scheduler instance (e.g. backed by a database),
|
|
104
|
-
it bypasses the extension and registers tools directly using
|
|
105
|
-
`createSchedulerTools`:
|
|
90
|
+
When the host process owns the scheduler instance (e.g. backed by a database), it bypasses the extension and registers tools directly using `createSchedulerTools`:
|
|
106
91
|
|
|
107
92
|
```ts
|
|
108
93
|
import { createSchedulerTools } from "@amaster.ai/pi-task-scheduler/tools";
|
|
@@ -119,8 +104,7 @@ await scheduler.start();
|
|
|
119
104
|
const tools = createSchedulerTools(scheduler);
|
|
120
105
|
```
|
|
121
106
|
|
|
122
|
-
In this mode the auto-discovered extension should be filtered out to prevent
|
|
123
|
-
double tool registration. The host manages scheduler start/stop independently.
|
|
107
|
+
In this mode the auto-discovered extension should be filtered out to prevent double tool registration. The host manages scheduler start/stop independently.
|
|
124
108
|
|
|
125
109
|
```
|
|
126
110
|
host creates scheduler → createSchedulerTools(scheduler) → tools injected into runtime
|
|
@@ -145,10 +129,8 @@ Tasks support three schedule types:
|
|
|
145
129
|
- `once`: ISO timestamps or relative values such as `+5m`
|
|
146
130
|
- `cron`: 5/6-field cron expressions and a small RRULE subset
|
|
147
131
|
|
|
148
|
-
The scheduler does not catch up missed runs after process downtime. When it
|
|
149
|
-
starts, it registers future timers for enabled tasks.
|
|
132
|
+
The scheduler does not catch up missed runs after process downtime. When it starts, it registers future timers for enabled tasks.
|
|
150
133
|
|
|
151
134
|
## Hooks
|
|
152
135
|
|
|
153
|
-
Hooks are best-effort observability callbacks. If a hook throws, the scheduler
|
|
154
|
-
swallows the error and keeps task state authoritative.
|
|
136
|
+
Hooks are best-effort observability callbacks. If a hook throws, the scheduler swallows the error and keeps task state authoritative.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amaster.ai/pi-task-scheduler",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Pi extension for cron-based scheduled task management with LLM-callable tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"croner": "^10.0.1",
|
|
60
|
-
"@amaster.ai/pi-shared": "0.1.
|
|
60
|
+
"@amaster.ai/pi-shared": "0.1.10"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@earendil-works/pi-coding-agent": ">=0.79.1",
|