opencode-windows-scheduler 1.0.0 → 1.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/CHANGELOG.md +58 -7
- package/README.md +14 -4
- package/README.ru.md +14 -4
- package/ROADMAP.md +30 -20
- package/dist/core/analytics.d.ts +129 -0
- package/dist/core/analytics.d.ts.map +1 -0
- package/dist/core/analytics.js +286 -0
- package/dist/core/dry-run.d.ts +13 -0
- package/dist/core/dry-run.d.ts.map +1 -1
- package/dist/core/dry-run.js +30 -0
- package/dist/core/matrix.d.ts.map +1 -1
- package/dist/core/matrix.js +10 -0
- package/dist/core/ps-wrapper.d.ts +32 -2
- package/dist/core/ps-wrapper.d.ts.map +1 -1
- package/dist/core/ps-wrapper.js +101 -3
- package/dist/core/retention.d.ts +29 -0
- package/dist/core/retention.d.ts.map +1 -0
- package/dist/core/retention.js +98 -0
- package/dist/core/schedule-gate.d.ts +2 -0
- package/dist/core/schedule-gate.d.ts.map +1 -0
- package/dist/core/schedule-gate.js +182 -0
- package/dist/core/schedule-v2.d.ts +88 -0
- package/dist/core/schedule-v2.d.ts.map +1 -0
- package/dist/core/schedule-v2.js +496 -0
- package/dist/core/scheduler/types.d.ts +15 -0
- package/dist/core/scheduler/types.d.ts.map +1 -1
- package/dist/core/scheduler/windows.d.ts.map +1 -1
- package/dist/core/scheduler/windows.js +13 -1
- package/dist/core/wrappers/bash.d.ts +15 -0
- package/dist/core/wrappers/bash.d.ts.map +1 -1
- package/dist/core/wrappers/bash.js +44 -1
- package/dist/db/history-repo.d.ts +41 -0
- package/dist/db/history-repo.d.ts.map +1 -1
- package/dist/db/history-repo.js +78 -0
- package/dist/db/schema.d.ts +1 -1
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +11 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1094 -56
- package/dist/notifications.d.ts +112 -6
- package/dist/notifications.d.ts.map +1 -1
- package/dist/notifications.js +396 -34
- package/dist/profiles.d.ts +60 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +209 -0
- package/dist/rpc.d.ts +645 -0
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +251 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +200 -7
- package/dist/settings.d.ts +80 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +159 -8
- package/dist/task-transfer.d.ts +13 -0
- package/dist/task-transfer.d.ts.map +1 -1
- package/dist/task-transfer.js +26 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -11
- package/dist/version.d.ts +8 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +27 -0
- package/dist/workspaces.d.ts +43 -0
- package/dist/workspaces.d.ts.map +1 -1
- package/dist/workspaces.js +174 -8
- package/docs/ARCHITECTURE.md +45 -13
- package/docs/FEATURES.md +103 -12
- package/gui-experimental.cjs +4 -2
- package/package.json +8 -2
- package/src/core/analytics.ts +414 -0
- package/src/core/dry-run.ts +42 -0
- package/src/core/matrix.ts +10 -0
- package/src/core/ps-wrapper.ts +117 -3
- package/src/core/retention.ts +141 -0
- package/src/core/schedule-gate.ts +213 -0
- package/src/core/schedule-v2.ts +533 -0
- package/src/core/scheduler/types.ts +15 -0
- package/src/core/scheduler/windows.ts +13 -1
- package/src/core/wrappers/bash.ts +60 -0
- package/src/db/history-repo.ts +116 -0
- package/src/db/schema.ts +14 -0
- package/src/gui.tsx +3613 -2725
- package/src/index.ts +1325 -55
- package/src/notifications.ts +516 -40
- package/src/profiles.ts +236 -0
- package/src/rpc.ts +267 -2
- package/src/server.ts +226 -7
- package/src/settings.ts +285 -9
- package/src/task-transfer.ts +44 -0
- package/src/types.ts +3 -13
- package/src/version.ts +27 -0
- package/src/workspaces.ts +214 -8
- package/dist/gui-experimental.cjs +0 -1
package/docs/FEATURES.md
CHANGED
|
@@ -7,6 +7,8 @@ matter in practice.
|
|
|
7
7
|
- [Execution policy](#execution-policy)
|
|
8
8
|
- [Orchestration](#orchestration)
|
|
9
9
|
- [Multi-repository workspaces](#multi-repository-workspaces)
|
|
10
|
+
- [Profiles (multi-project)](#profiles-multi-project)
|
|
11
|
+
- [Workspace environment variables](#workspace-environment-variables)
|
|
10
12
|
- [Observability](#observability)
|
|
11
13
|
- [Management](#management)
|
|
12
14
|
- [Agent interface](#agent-interface)
|
|
@@ -17,7 +19,10 @@ matter in practice.
|
|
|
17
19
|
|
|
18
20
|
### Cron schedules
|
|
19
21
|
|
|
20
|
-
Five-field cron: `minute hour day-of-month month day-of-week`.
|
|
22
|
+
Five-field cron: `minute hour day-of-month month day-of-week`. Supports lists,
|
|
23
|
+
ranges and steps in every field (`0 8-10,18 * * 1-5/2`), month and weekday names
|
|
24
|
+
(`0 9 * * MON-FRI`), `@every` sugar (`@every 15m`, `@every 2h`, `@every 1d`),
|
|
25
|
+
`L` as the last day of the month and the `d#n` n-th weekday form (`0 9 * * FRI#3`).
|
|
21
26
|
|
|
22
27
|
| Pattern | Example | Meaning |
|
|
23
28
|
| --- | --- | --- |
|
|
@@ -25,10 +30,26 @@ Five-field cron: `minute hour day-of-month month day-of-week`.
|
|
|
25
30
|
| Fixed time | `0 9 * * *` | Daily at 09:00 |
|
|
26
31
|
| Weekdays | `30 8 * * 1-5` | 08:30 Monday to Friday |
|
|
27
32
|
| Monthly | `0 3 1 * *` | 03:00 on the 1st |
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
| Last day | `0 3 L * *` | 03:00 on the last day of the month |
|
|
34
|
+
| N-th weekday | `0 9 * * FRI#3` | 09:00 on the third Friday |
|
|
35
|
+
| Sugar | `@every 15m` | Every 15 minutes |
|
|
36
|
+
|
|
37
|
+
The Windows backend translates simple cron expressions to native Task Scheduler
|
|
38
|
+
triggers. Expressions `schtasks` cannot express (`L`, `#`, complex lists) or tasks
|
|
39
|
+
with a timezone other than the system one are registered in poll mode: the OS task
|
|
40
|
+
wakes the wrapper every minute and `schedule-gate` decides whether the agent runs.
|
|
41
|
+
|
|
42
|
+
### Timezones and launch windows
|
|
43
|
+
|
|
44
|
+
- `timezone` — IANA zone per task (e.g. `Europe/Moscow`). `nextRun`/`prevRun`,
|
|
45
|
+
dry-run next-run estimates and the gate evaluate cron in this zone; DST
|
|
46
|
+
transitions are handled (nonexistent spring-forward times are skipped).
|
|
47
|
+
- `notBefore` / `notAfter` — daily launch window in `HH:MM` (may cross midnight,
|
|
48
|
+
e.g. `22:00`–`06:00`). A run that fires outside the window is **postponed**
|
|
49
|
+
until the window opens (once, via a defer-file), not skipped.
|
|
50
|
+
- `pausedUntil` — pause a task until an ISO moment. `pause_task` accepts
|
|
51
|
+
`until`; the plugin re-enables the task automatically at startup and on a
|
|
52
|
+
5-minute timer, and `resume_task` resumes early.
|
|
32
53
|
|
|
33
54
|
### File triggers
|
|
34
55
|
|
|
@@ -186,6 +207,42 @@ Use `workspaceId` instead of `workingDirectory` to run a task in a workspace. Pa
|
|
|
186
207
|
validated on add/update/import, and the dashboard groups tasks and runs by workspace.
|
|
187
208
|
Workspaces are the unit that matrix builds fan out to.
|
|
188
209
|
|
|
210
|
+
## Profiles (multi-project, Спринт 21)
|
|
211
|
+
|
|
212
|
+
Profiles let you run several independent scheduler installations inside one plugin,
|
|
213
|
+
each with its own SQLite database, settings, logs, wrappers and dashboard port.
|
|
214
|
+
This is useful for separating projects, clients or environments (e.g. `default` and
|
|
215
|
+
`work`) without them seeing each other's data.
|
|
216
|
+
|
|
217
|
+
- Profile `default` uses the plugin's base directory (no migration, behaves exactly
|
|
218
|
+
as before Sprint 21). Named profiles live in `<base>/profiles/<name>`.
|
|
219
|
+
- Profile selection order: `OPENCODE_SCHEDULER_PROFILE` env var → file `active-profile`
|
|
220
|
+
in the base directory → `default`. Switching profiles writes the marker and requires
|
|
221
|
+
an OpenCode restart because plugin directories are resolved at module load time.
|
|
222
|
+
- Dashboard port per profile: `OPENCODE_SCHEDULER_PORT` env var → port from
|
|
223
|
+
`profile.json` → server default (3782, then 4782/5782 fallback).
|
|
224
|
+
- RPC: `get_profiles` lists profiles with dirs, ports and the active flag;
|
|
225
|
+
`set_profile` switches the active profile (restart hint); `create_profile` /
|
|
226
|
+
`delete_profile` manage named profiles (`default` cannot be deleted).
|
|
227
|
+
|
|
228
|
+
### Workspace environment variables (Спринт 21)
|
|
229
|
+
|
|
230
|
+
Each workspace can carry env variables that are injected into every task run in that
|
|
231
|
+
workspace:
|
|
232
|
+
|
|
233
|
+
- `env` — explicit `KEY=VALUE` pairs stored in SQLite as JSON;
|
|
234
|
+
- `envFile` — optional path to a `.env` file whose variables are loaded first, then
|
|
235
|
+
explicit pairs override them;
|
|
236
|
+
- File format: `KEY=value` lines, `#` comments, blank lines, leading `export `,
|
|
237
|
+
values in matching quotes are unquoted;
|
|
238
|
+
- Key validation: `^[A-Za-z_][A-Za-z0-9_]*$`, max 100 pairs per workspace;
|
|
239
|
+
- Delivery: at task create/update the plugin writes `<PLUGIN_DIR>/env/<sanitized>.env`
|
|
240
|
+
with real values (mode `0600` on POSIX) and passes it to the wrapper
|
|
241
|
+
(Windows: `-EnvFile "<path>"`; POSIX: `set -a; . "$ENV_FILE"; set +a` before the
|
|
242
|
+
`opencode run` invocation);
|
|
243
|
+
- Secret masking: keys matching `/(TOKEN|SECRET|PASS|PASSWORD|KEY|CREDENTIAL|AUTH)/i`
|
|
244
|
+
are shown as `***` in logs and masked API responses — values never leak into logs.
|
|
245
|
+
|
|
189
246
|
## Observability
|
|
190
247
|
|
|
191
248
|
### History
|
|
@@ -204,7 +261,12 @@ pre/post-flight results, next chained task, workspace and tool restrictions. Sta
|
|
|
204
261
|
### Metrics
|
|
205
262
|
|
|
206
263
|
Per-task counters and totals: runs, successes, errors, tokens, cost. Available through
|
|
207
|
-
`get_history`, the RPC layer and the dashboard header.
|
|
264
|
+
`get_history`, the RPC layer and the dashboard header. A 14-day analytics slice —
|
|
265
|
+
per-day buckets (UTC), success rate, token-based cost estimate, top tasks by cost,
|
|
266
|
+
matrix and model breakdowns — is available through `get_analytics` /
|
|
267
|
+
`GET /api/analytics` and the dashboard's «📊 Аналитика за период» block. History is
|
|
268
|
+
pruned automatically (age and size limits, see Settings) and can be exported as
|
|
269
|
+
CSV/JSON (`GET /api/history/export`).
|
|
208
270
|
|
|
209
271
|
### Logs
|
|
210
272
|
|
|
@@ -219,8 +281,10 @@ fan-out and estimated time. Nothing is executed and nothing is created.
|
|
|
219
281
|
### Dashboard
|
|
220
282
|
|
|
221
283
|
A local web dashboard shows tasks, matrix tabs, per-workspace summaries, DAG markers,
|
|
222
|
-
metrics
|
|
223
|
-
|
|
284
|
+
metrics, a 14-day analytics block (KPIs, daily bar chart, top tasks by cost, matrices),
|
|
285
|
+
recent runs and CSV/JSON history export. It binds to localhost and has no authentication
|
|
286
|
+
— do not expose it. `GET /api/health` reports plugin version, scheduler backend, queue
|
|
287
|
+
depth and database status for external monitoring.
|
|
224
288
|
|
|
225
289
|
## Management
|
|
226
290
|
|
|
@@ -241,6 +305,25 @@ matrix combinations are rejected explicitly.
|
|
|
241
305
|
Webhook notifications on run completion, configurable in settings and testable with
|
|
242
306
|
`test_notification`.
|
|
243
307
|
|
|
308
|
+
- **Delivery:** per-task completion (success/error/timeout) through a Discord/Slack
|
|
309
|
+
compatible webhook (`{ content, text }`). `webhook.timeoutMs` (default 10 000),
|
|
310
|
+
`webhook.retryCount` (default 2) and `webhook.retryDelayMs` (default 1000) control
|
|
311
|
+
the request; network errors, timeouts, HTTP 5xx and 429 are retried with exponential
|
|
312
|
+
backoff (capped at 30 s), other 4xx are not.
|
|
313
|
+
- **Templates:** `templates.success` and `templates.error` accept placeholders
|
|
314
|
+
`{task}`, `{status}`, `{duration}`, `{error}`, `{emoji}`.
|
|
315
|
+
- **Filters:** `filters.include` / `filters.exclude` are task-name patterns with `*`
|
|
316
|
+
wildcards; an empty include list means all tasks, exclude wins.
|
|
317
|
+
- **Matrix notifications:** on family completion — success, `partial` (`onPartial`)
|
|
318
|
+
and all clones failed (`onAllFailed`). A stuck detector reports clones running
|
|
319
|
+
longer than `matrix.stuckAfterMinutes` (default 60, `0` disables) once per run.
|
|
320
|
+
- **Digest:** `digest.enabled` sends a daily (`frequency: "daily"`, at `digest.time`)
|
|
321
|
+
or weekly (Mondays, catch-up afterwards) summary: runs, success rate, cost, tokens
|
|
322
|
+
and top errors. Also available as the `send_digest` RPC and the GUI's
|
|
323
|
+
«📊 Отправить дайджест сейчас» button (manual sends do not move the schedule).
|
|
324
|
+
- **ntfy.sh is intentionally not implemented** (excluded by the assignment); the
|
|
325
|
+
network channel is the webhook, plus GUI toasts for manual runs.
|
|
326
|
+
|
|
244
327
|
### Crash recovery
|
|
245
328
|
|
|
246
329
|
Runs left in `running` after a crash are marked `error` on the next plugin start, so
|
|
@@ -248,14 +331,22 @@ the timeline never lies. Orphaned matrix clones are cleaned up at startup as wel
|
|
|
248
331
|
|
|
249
332
|
### Settings
|
|
250
333
|
|
|
251
|
-
Global defaults (timeout, concurrency, notifications) live in
|
|
252
|
-
are editable from the GUI/RPC layer.
|
|
334
|
+
Global defaults (timeout, concurrency, notifications, history retention) live in
|
|
335
|
+
`settings.json` and are editable from the GUI/RPC layer. History retention keeps the
|
|
336
|
+
raw run log bounded: `history.retentionDays` (default 30) and `history.maxRecords`
|
|
337
|
+
(default 5000); `0` disables the respective limit. Cleanup runs at most once a day on
|
|
338
|
+
plugin start, records `lastCleanupAt` / `lastCleanupDeleted`, and is also available as
|
|
339
|
+
the `cleanup_history` RPC and the GUI's «Очистить сейчас» button. Aggregates in
|
|
340
|
+
`metrics.json` are not affected by retention.
|
|
253
341
|
|
|
254
342
|
## Agent interface
|
|
255
343
|
|
|
256
|
-
|
|
344
|
+
Twenty-two tools: `schedule_task`, `list_tasks`, `update_task`, `delete_task`,
|
|
257
345
|
`run_task_now`, `pause_task`, `resume_task`, `get_history`, `get_task_logs`, `dry_run`,
|
|
258
|
-
`manage_workspaces`, `matrix_control
|
|
346
|
+
`manage_workspaces`, `matrix_control` (results/cancel/cleanup/preview), `get_metrics`,
|
|
347
|
+
`get_analytics`, `manage_settings`, `manage_templates`, `manage_profiles`,
|
|
348
|
+
`transfer_tasks`, `send_notification`, `get_dashboard_info`, `cleanup_history`,
|
|
349
|
+
`emit_event`.
|
|
259
350
|
|
|
260
351
|
A bundled skill, `scheduled-job-best-practices`, teaches the agent safe defaults:
|
|
261
352
|
least privilege, Quality Gates, timeout, matrix concurrency, DAG rules and a
|