openclaw-scheduler 0.2.0
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/AGENTS.md +302 -0
- package/BEST-PRACTICES.md +506 -0
- package/CHANGELOG.md +82 -0
- package/CODE_OF_CONDUCT.md +22 -0
- package/CONTEXT.md +26 -0
- package/CONTRIBUTING.md +73 -0
- package/IMPLEMENTATION_SPEC.md +170 -0
- package/INSTALL-ADDITIONAL-HOST.md +333 -0
- package/INSTALL-LINUX.md +419 -0
- package/INSTALL-WINDOWS.md +305 -0
- package/INSTALL.md +364 -0
- package/JOB-QUICK-REF.md +222 -0
- package/LICENSE +21 -0
- package/QUICK-START.md +256 -0
- package/README.md +2170 -0
- package/SECURITY.md +34 -0
- package/UNINSTALL.md +129 -0
- package/UPGRADING.md +436 -0
- package/agents.js +67 -0
- package/approval.js +107 -0
- package/backup.js +390 -0
- package/bin/openclaw-scheduler.js +138 -0
- package/cli.js +1083 -0
- package/db.js +122 -0
- package/dispatch/529-recovery.mjs +204 -0
- package/dispatch/README.md +372 -0
- package/dispatch/config.example.json +24 -0
- package/dispatch/deliver-watcher.sh +57 -0
- package/dispatch/hooks.mjs +171 -0
- package/dispatch/index.mjs +1836 -0
- package/dispatch/watcher.mjs +1396 -0
- package/dispatch-queue.js +112 -0
- package/dispatcher-approvals.js +96 -0
- package/dispatcher-delivery.js +43 -0
- package/dispatcher-maintenance.js +242 -0
- package/dispatcher-shell.js +29 -0
- package/dispatcher-strategies.js +1280 -0
- package/dispatcher-utils.js +81 -0
- package/dispatcher.js +855 -0
- package/docs/adr-schedule-ownership.md +73 -0
- package/docs/gateway-contract.md +904 -0
- package/docs/plans/2026-03-09-fix-typescript-types.md +91 -0
- package/docs/plans/2026-03-09-test-coverage-gaps.md +83 -0
- package/docs/plans/2026-03-10-dispatcher-refactor.md +801 -0
- package/docs/trust-architecture.md +266 -0
- package/gateway.js +473 -0
- package/idempotency.js +119 -0
- package/index.d.ts +864 -0
- package/index.js +17 -0
- package/jobs.js +1224 -0
- package/messages.js +357 -0
- package/migrate-consolidate.js +694 -0
- package/migrate.js +125 -0
- package/package.json +130 -0
- package/paths.js +79 -0
- package/prompt-context.js +94 -0
- package/retrieval.js +176 -0
- package/runs.js +270 -0
- package/scheduler-schema.js +101 -0
- package/schema.sql +480 -0
- package/scripts/dispatch-cli-utils.mjs +65 -0
- package/scripts/inbox-consumer.mjs +288 -0
- package/scripts/stuck-detector.sh +18 -0
- package/scripts/stuck-run-detector.mjs +333 -0
- package/scripts/telegram-webhook-check.mjs +238 -0
- package/setup.mjs +724 -0
- package/shell-result.js +214 -0
- package/task-tracker.js +300 -0
- package/team-adapter.js +335 -0
- package/v02-runtime.js +599 -0
package/QUICK-START.md
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# Quick Start -- OpenClaw Scheduler
|
|
2
|
+
|
|
3
|
+
This guide gets you from zero to a running scheduler with real jobs in under 10 minutes. It covers:
|
|
4
|
+
|
|
5
|
+
1. Installing and starting the scheduler
|
|
6
|
+
2. Converting your existing OpenClaw cron jobs
|
|
7
|
+
3. Building your first workflow chain
|
|
8
|
+
|
|
9
|
+
For the full reference manual, see [README.md](README.md).
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Why switch from built-in cron?
|
|
14
|
+
|
|
15
|
+
OpenClaw's built-in `cron/jobs.json` and heartbeat are fine for simple tasks. The scheduler replaces them when you need:
|
|
16
|
+
|
|
17
|
+
- **Run history** -- know what ran, when, and whether it succeeded
|
|
18
|
+
- **Shell jobs** -- scripts that run even when the gateway is down
|
|
19
|
+
- **Retries** -- automatic retry with exponential backoff on failure
|
|
20
|
+
- **Chains** -- parent/child jobs that trigger on success, failure, or output patterns
|
|
21
|
+
- **Approval gates** -- human-in-the-loop before risky steps execute
|
|
22
|
+
- **Delivery** -- send results to Telegram, Discord, WhatsApp, Signal, iMessage, or Slack, with alias routing and chunking
|
|
23
|
+
- **Audit trail** -- every dispatch, retry, and delivery is recorded in SQLite
|
|
24
|
+
|
|
25
|
+
| Before (built-in) | After (scheduler) |
|
|
26
|
+
|---|---|
|
|
27
|
+
| `~/.openclaw/cron/jobs.json` | SQLite `jobs` table with full run history |
|
|
28
|
+
| No run tracking | Status, duration, summary for every run |
|
|
29
|
+
| No retry | Configurable retries with exponential backoff |
|
|
30
|
+
| No chains | Parent/child jobs with trigger conditions |
|
|
31
|
+
| Shell scripts are manual | Shell jobs with cron, delivery, and audit |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 1. Install
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
mkdir -p ~/.openclaw/scheduler
|
|
39
|
+
npm install --prefix ~/.openclaw/scheduler openclaw-scheduler@latest
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Create a shell alias for convenience:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
alias ocs='npm exec --prefix ~/.openclaw/scheduler openclaw-scheduler --'
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Add this line to your `~/.zshrc` or `~/.bashrc` to make it permanent.
|
|
49
|
+
|
|
50
|
+
## 2. Run setup
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
ocs setup
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The wizard will:
|
|
57
|
+
- Create or migrate `scheduler.db`
|
|
58
|
+
- Install a system service (macOS launchd or Linux systemd)
|
|
59
|
+
- Create built-in helper jobs (Inbox Consumer, Stuck Run Detector)
|
|
60
|
+
|
|
61
|
+
## 3. Verify
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
ocs status
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
You should see the scheduler running with at least the built-in jobs.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Converting existing OpenClaw crons
|
|
72
|
+
|
|
73
|
+
### Automatic import
|
|
74
|
+
|
|
75
|
+
If you have jobs in `~/.openclaw/cron/jobs.json`:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
ocs migrate
|
|
79
|
+
ocs jobs list
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
This imports all existing cron jobs into the scheduler's SQLite database.
|
|
83
|
+
|
|
84
|
+
Then disable the old cron system:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
openclaw cron edit <job-id> --disable # for each job
|
|
88
|
+
openclaw config set cron.enabled false
|
|
89
|
+
openclaw config set agents.defaults.heartbeat.every "0m"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Manual conversion
|
|
93
|
+
|
|
94
|
+
Here is how each type of OpenClaw cron entry maps to a scheduler job:
|
|
95
|
+
|
|
96
|
+
#### Simple cron line (shell)
|
|
97
|
+
|
|
98
|
+
**Before:** `*/5 * * * * /usr/local/bin/check-api.sh`
|
|
99
|
+
|
|
100
|
+
**After:**
|
|
101
|
+
```bash
|
|
102
|
+
ocs jobs add '{
|
|
103
|
+
"name": "API Check",
|
|
104
|
+
"schedule_cron": "*/5 * * * *",
|
|
105
|
+
"session_target": "shell",
|
|
106
|
+
"payload_message": "/usr/local/bin/check-api.sh",
|
|
107
|
+
"run_timeout_ms": 60000,
|
|
108
|
+
"delivery_mode": "announce",
|
|
109
|
+
"delivery_channel": "telegram",
|
|
110
|
+
"delivery_to": "YOUR_CHAT_ID",
|
|
111
|
+
"origin": "system"
|
|
112
|
+
}'
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Key fields:
|
|
116
|
+
- `session_target: "shell"` -- runs a shell command directly, no AI needed
|
|
117
|
+
- `payload_message` -- the command to execute
|
|
118
|
+
- `delivery_mode: "announce"` -- sends output only on failure
|
|
119
|
+
|
|
120
|
+
#### Heartbeat / AI prompt
|
|
121
|
+
|
|
122
|
+
**Before:** `heartbeat.every: "30m"` with a prompt
|
|
123
|
+
|
|
124
|
+
**After:**
|
|
125
|
+
```bash
|
|
126
|
+
ocs jobs add '{
|
|
127
|
+
"name": "Daily Status Summary",
|
|
128
|
+
"schedule_cron": "0 8 * * *",
|
|
129
|
+
"schedule_tz": "America/New_York",
|
|
130
|
+
"session_target": "isolated",
|
|
131
|
+
"payload_message": "Summarize the most important errors and follow-ups from the last 24 hours.",
|
|
132
|
+
"run_timeout_ms": 300000,
|
|
133
|
+
"delivery_mode": "announce-always",
|
|
134
|
+
"delivery_channel": "telegram",
|
|
135
|
+
"delivery_to": "YOUR_CHAT_ID",
|
|
136
|
+
"origin": "system"
|
|
137
|
+
}'
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Key fields:
|
|
141
|
+
- `session_target: "isolated"` -- runs in its own agent session
|
|
142
|
+
- `delivery_mode: "announce-always"` -- always sends output, not just on failure
|
|
143
|
+
|
|
144
|
+
#### Two sequential tasks
|
|
145
|
+
|
|
146
|
+
**Before:** two cron entries with manual timing
|
|
147
|
+
|
|
148
|
+
**After:** a parent/child chain:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Step 1: parent job
|
|
152
|
+
ocs jobs add '{
|
|
153
|
+
"name": "Nightly Backup",
|
|
154
|
+
"schedule_cron": "0 2 * * *",
|
|
155
|
+
"session_target": "shell",
|
|
156
|
+
"payload_message": "/usr/local/bin/nightly-backup.sh",
|
|
157
|
+
"run_timeout_ms": 300000,
|
|
158
|
+
"delivery_mode": "announce",
|
|
159
|
+
"delivery_channel": "telegram",
|
|
160
|
+
"delivery_to": "YOUR_CHAT_ID",
|
|
161
|
+
"origin": "system"
|
|
162
|
+
}'
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Step 2: child job (runs after parent succeeds)
|
|
167
|
+
ocs jobs add '{
|
|
168
|
+
"name": "Verify Backup",
|
|
169
|
+
"parent_id": "BACKUP_JOB_ID",
|
|
170
|
+
"trigger_on": "success",
|
|
171
|
+
"trigger_delay_s": 60,
|
|
172
|
+
"session_target": "shell",
|
|
173
|
+
"payload_message": "/usr/local/bin/verify-backup.sh",
|
|
174
|
+
"run_timeout_ms": 60000,
|
|
175
|
+
"delivery_mode": "announce",
|
|
176
|
+
"delivery_channel": "telegram",
|
|
177
|
+
"delivery_to": "YOUR_CHAT_ID",
|
|
178
|
+
"origin": "system"
|
|
179
|
+
}'
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
The second job only runs when the first one succeeds. No more hoping the timing is right.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Common operations
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# List all jobs
|
|
190
|
+
ocs jobs list
|
|
191
|
+
|
|
192
|
+
# Run a job immediately
|
|
193
|
+
ocs jobs run <job-id>
|
|
194
|
+
|
|
195
|
+
# View recent runs for a job
|
|
196
|
+
ocs runs list <job-id> 10
|
|
197
|
+
|
|
198
|
+
# View a specific run's details
|
|
199
|
+
ocs runs get <run-id>
|
|
200
|
+
|
|
201
|
+
# Disable a job
|
|
202
|
+
ocs jobs update <job-id> '{"enabled": false}'
|
|
203
|
+
|
|
204
|
+
# Enable a job
|
|
205
|
+
ocs jobs update <job-id> '{"enabled": true}'
|
|
206
|
+
|
|
207
|
+
# Delete a job
|
|
208
|
+
ocs jobs delete <job-id>
|
|
209
|
+
|
|
210
|
+
# Check scheduler health
|
|
211
|
+
ocs status
|
|
212
|
+
|
|
213
|
+
# View logs
|
|
214
|
+
tail -f /tmp/openclaw-scheduler.log
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Session targets explained
|
|
220
|
+
|
|
221
|
+
| Target | When to use | Gateway needed? |
|
|
222
|
+
|---|---|---|
|
|
223
|
+
| `shell` | Deterministic commands, scripts, health checks | No |
|
|
224
|
+
| `isolated` | AI reasoning, summarization, writing, tool use | Yes |
|
|
225
|
+
| `main` | Inject into the main session (system events) | Yes |
|
|
226
|
+
|
|
227
|
+
**Rule of thumb:** if the task has a predictable answer, use `shell`. If it needs thinking, use `isolated`.
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Delivery modes explained
|
|
232
|
+
|
|
233
|
+
| Mode | Behavior |
|
|
234
|
+
|---|---|
|
|
235
|
+
| `announce` | Send output only on failure |
|
|
236
|
+
| `announce-always` | Send output on every run (success and failure) |
|
|
237
|
+
| `none` | Never send output |
|
|
238
|
+
|
|
239
|
+
For `announce` and `announce-always`, you must set `delivery_channel` and `delivery_to`.
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Next steps
|
|
244
|
+
|
|
245
|
+
- [INSTALL.md](INSTALL.md) -- detailed macOS launchd setup
|
|
246
|
+
- [INSTALL-LINUX.md](INSTALL-LINUX.md) -- Linux/WSL2 systemd setup
|
|
247
|
+
- [BEST-PRACTICES.md](BEST-PRACTICES.md) -- operational patterns and anti-patterns
|
|
248
|
+
- [README.md](README.md) -- full reference manual (chains, retries, approvals, messaging, etc.)
|
|
249
|
+
- [UNINSTALL.md](UNINSTALL.md) -- how to remove the scheduler and restore built-in cron
|
|
250
|
+
|
|
251
|
+
### Optional: agentcli
|
|
252
|
+
|
|
253
|
+
For declarative workflow manifests, stable job IDs, and v0.2 identity support,
|
|
254
|
+
install [agentcli](https://github.com/amittell/agentcli) and use `agentcli apply`
|
|
255
|
+
to manage jobs. See [Working with agentcli](README.md#working-with-agentcli) in
|
|
256
|
+
the README.
|