opencode-windows-scheduler 1.2.3 → 1.3.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 +39 -2
- package/README.md +14 -3
- package/ROADMAP-STRATEGY.md +61 -159
- package/ROADMAP.md +63 -96
- package/dist/core/native-notify.d.ts +36 -0
- package/dist/core/native-notify.d.ts.map +1 -0
- package/dist/core/native-notify.js +110 -0
- package/dist/core/record-history.js +4 -4
- package/dist/core/telegram.d.ts +45 -0
- package/dist/core/telegram.d.ts.map +1 -0
- package/dist/core/telegram.js +160 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/notifications.d.ts +26 -6
- package/dist/notifications.d.ts.map +1 -1
- package/dist/notifications.js +191 -34
- package/dist/settings.d.ts +47 -2
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +97 -2
- package/docs/ARCHITECTURE.md +4 -2
- package/docs/FEATURES.md +28 -11
- package/docs/README.ru.md +11 -2
- package/gui-experimental.cjs +4 -4
- package/package.json +3 -2
- package/src/core/native-notify.ts +154 -0
- package/src/core/record-history.ts +6 -4
- package/src/core/telegram.ts +219 -0
- package/src/gui.tsx +220 -6
- package/src/index.ts +7 -3
- package/src/notifications.ts +232 -40
- package/src/settings.ts +162 -4
package/dist/settings.js
CHANGED
|
@@ -83,10 +83,30 @@ export function defaultNotifications() {
|
|
|
83
83
|
retryDelayMs: DEFAULT_WEBHOOK_RETRY_DELAY_MS,
|
|
84
84
|
},
|
|
85
85
|
templates: {
|
|
86
|
-
success: '✅ Задача "{task}" выполнена ({duration})',
|
|
87
|
-
error: '❌ Задача "{task}" упала ({duration}){error}',
|
|
86
|
+
success: '✅ Задача "{task}" выполнена ({duration}){cost}',
|
|
87
|
+
error: '❌ Задача "{task}" упала ({duration}){error}{cost}',
|
|
88
88
|
},
|
|
89
89
|
filters: { include: [], exclude: [] },
|
|
90
|
+
telegram: {
|
|
91
|
+
enabled: false,
|
|
92
|
+
botToken: "",
|
|
93
|
+
chatId: "",
|
|
94
|
+
parseMode: "HTML",
|
|
95
|
+
disableNotification: false,
|
|
96
|
+
messageThreadId: null,
|
|
97
|
+
includeDashboardLink: true,
|
|
98
|
+
apiBase: "https://api.telegram.org",
|
|
99
|
+
},
|
|
100
|
+
native: {
|
|
101
|
+
enabled: false,
|
|
102
|
+
sound: true,
|
|
103
|
+
},
|
|
104
|
+
quietHours: {
|
|
105
|
+
enabled: false,
|
|
106
|
+
from: "22:00",
|
|
107
|
+
to: "08:00",
|
|
108
|
+
},
|
|
109
|
+
dashboardUrl: "",
|
|
90
110
|
matrix: {
|
|
91
111
|
enabled: true,
|
|
92
112
|
onPartial: true,
|
|
@@ -147,6 +167,29 @@ function asRecord(value) {
|
|
|
147
167
|
? value
|
|
148
168
|
: undefined;
|
|
149
169
|
}
|
|
170
|
+
/** Приводит parse_mode Telegram к допустимому значению. */
|
|
171
|
+
function normalizeTelegramParseMode(value, fallback) {
|
|
172
|
+
return value === "" || value === "HTML" || value === "Markdown" || value === "MarkdownV2"
|
|
173
|
+
? value
|
|
174
|
+
: fallback;
|
|
175
|
+
}
|
|
176
|
+
/** Проверяет http(s)-базу API; иначе возвращает fallback. */
|
|
177
|
+
function normalizeHttpBase(value, fallback) {
|
|
178
|
+
if (typeof value !== "string")
|
|
179
|
+
return fallback;
|
|
180
|
+
const trimmed = value.trim().replace(/\/+$/, "");
|
|
181
|
+
if (!trimmed)
|
|
182
|
+
return fallback;
|
|
183
|
+
try {
|
|
184
|
+
const parsed = new URL(trimmed);
|
|
185
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
|
|
186
|
+
return fallback;
|
|
187
|
+
return trimmed;
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
return fallback;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
150
193
|
/** Приводит настройки уведомлений к безопасному виду. */
|
|
151
194
|
function normalizeNotifications(value, fallback) {
|
|
152
195
|
const fallbackWebhook = fallback.webhook ?? defaultNotifications().webhook;
|
|
@@ -154,6 +197,9 @@ function normalizeNotifications(value, fallback) {
|
|
|
154
197
|
const fallbackFilters = fallback.filters ?? { include: [], exclude: [] };
|
|
155
198
|
const fallbackMatrix = fallback.matrix ?? defaultNotifications().matrix;
|
|
156
199
|
const fallbackDigest = fallback.digest ?? defaultNotifications().digest;
|
|
200
|
+
const fallbackTelegram = fallback.telegram ?? defaultNotifications().telegram;
|
|
201
|
+
const fallbackNative = fallback.native ?? defaultNotifications().native;
|
|
202
|
+
const fallbackQuiet = fallback.quietHours ?? defaultNotifications().quietHours;
|
|
157
203
|
const raw = asRecord(value);
|
|
158
204
|
if (!raw) {
|
|
159
205
|
return {
|
|
@@ -166,6 +212,10 @@ function normalizeNotifications(value, fallback) {
|
|
|
166
212
|
},
|
|
167
213
|
matrix: { ...fallbackMatrix },
|
|
168
214
|
digest: { ...fallbackDigest },
|
|
215
|
+
telegram: { ...fallbackTelegram },
|
|
216
|
+
native: { ...fallbackNative },
|
|
217
|
+
quietHours: { ...fallbackQuiet },
|
|
218
|
+
dashboardUrl: fallback.dashboardUrl ?? "",
|
|
169
219
|
};
|
|
170
220
|
}
|
|
171
221
|
const rawWebhook = asRecord(raw.webhook);
|
|
@@ -173,6 +223,9 @@ function normalizeNotifications(value, fallback) {
|
|
|
173
223
|
const rawFilters = asRecord(raw.filters);
|
|
174
224
|
const rawMatrix = asRecord(raw.matrix);
|
|
175
225
|
const rawDigest = asRecord(raw.digest);
|
|
226
|
+
const rawTelegram = asRecord(raw.telegram);
|
|
227
|
+
const rawNative = asRecord(raw.native);
|
|
228
|
+
const rawQuiet = asRecord(raw.quietHours);
|
|
176
229
|
const frequency = rawDigest?.frequency === "weekly" || rawDigest?.frequency === "daily"
|
|
177
230
|
? rawDigest.frequency
|
|
178
231
|
: fallbackDigest.frequency;
|
|
@@ -205,6 +258,48 @@ function normalizeNotifications(value, fallback) {
|
|
|
205
258
|
include: normalizeNameList(rawFilters?.include, fallbackFilters.include),
|
|
206
259
|
exclude: normalizeNameList(rawFilters?.exclude, fallbackFilters.exclude),
|
|
207
260
|
},
|
|
261
|
+
telegram: {
|
|
262
|
+
enabled: typeof rawTelegram?.enabled === "boolean"
|
|
263
|
+
? rawTelegram.enabled
|
|
264
|
+
: fallbackTelegram.enabled,
|
|
265
|
+
botToken: typeof rawTelegram?.botToken === "string"
|
|
266
|
+
? rawTelegram.botToken.trim().slice(0, 512)
|
|
267
|
+
: fallbackTelegram.botToken,
|
|
268
|
+
chatId: typeof rawTelegram?.chatId === "string"
|
|
269
|
+
? rawTelegram.chatId.trim().slice(0, 128)
|
|
270
|
+
: fallbackTelegram.chatId,
|
|
271
|
+
parseMode: normalizeTelegramParseMode(rawTelegram?.parseMode, fallbackTelegram.parseMode),
|
|
272
|
+
disableNotification: typeof rawTelegram?.disableNotification === "boolean"
|
|
273
|
+
? rawTelegram.disableNotification
|
|
274
|
+
: fallbackTelegram.disableNotification,
|
|
275
|
+
messageThreadId: rawTelegram?.messageThreadId === null
|
|
276
|
+
? null
|
|
277
|
+
: Number.isFinite(Number(rawTelegram?.messageThreadId))
|
|
278
|
+
? Math.max(0, Math.floor(Number(rawTelegram?.messageThreadId)))
|
|
279
|
+
: fallbackTelegram.messageThreadId,
|
|
280
|
+
includeDashboardLink: typeof rawTelegram?.includeDashboardLink === "boolean"
|
|
281
|
+
? rawTelegram.includeDashboardLink
|
|
282
|
+
: fallbackTelegram.includeDashboardLink,
|
|
283
|
+
apiBase: normalizeHttpBase(rawTelegram?.apiBase, fallbackTelegram.apiBase),
|
|
284
|
+
},
|
|
285
|
+
native: {
|
|
286
|
+
enabled: typeof rawNative?.enabled === "boolean"
|
|
287
|
+
? rawNative.enabled
|
|
288
|
+
: fallbackNative.enabled,
|
|
289
|
+
sound: typeof rawNative?.sound === "boolean"
|
|
290
|
+
? rawNative.sound
|
|
291
|
+
: fallbackNative.sound,
|
|
292
|
+
},
|
|
293
|
+
quietHours: {
|
|
294
|
+
enabled: typeof rawQuiet?.enabled === "boolean"
|
|
295
|
+
? rawQuiet.enabled
|
|
296
|
+
: fallbackQuiet.enabled,
|
|
297
|
+
from: normalizeDailyTime(rawQuiet?.from, fallbackQuiet.from),
|
|
298
|
+
to: normalizeDailyTime(rawQuiet?.to, fallbackQuiet.to),
|
|
299
|
+
},
|
|
300
|
+
dashboardUrl: typeof raw.dashboardUrl === "string"
|
|
301
|
+
? raw.dashboardUrl.trim().slice(0, 500)
|
|
302
|
+
: (fallback.dashboardUrl ?? ""),
|
|
208
303
|
matrix: {
|
|
209
304
|
enabled: typeof rawMatrix?.enabled === "boolean"
|
|
210
305
|
? rawMatrix.enabled
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -130,7 +130,9 @@ from their clones instead of their own last run.
|
|
|
130
130
|
| `src/workspaces.ts` | Workspace registry and path validation; env pairs and `.env` file resolution with secret masking |
|
|
131
131
|
| `src/templates.ts` | Reusable task templates |
|
|
132
132
|
| `src/settings.ts` | Plugin settings: notifications and history retention |
|
|
133
|
-
| `src/notifications.ts` |
|
|
133
|
+
| `src/notifications.ts` | Multi-channel delivery (webhook, Telegram, native OS) with retries/backoff, templates, task filters, quiet hours, matrix and stuck-clone notifications, daily/weekly digest |
|
|
134
|
+
| `src/core/telegram.ts` | Telegram Bot API `sendMessage`: parse-mode escaping, dashboard link, token validation and masking |
|
|
135
|
+
| `src/core/native-notify.ts` | Native OS notifications: Windows Toast (PowerShell/WinRT), macOS `osascript`, Linux `notify-send`; no external dependency |
|
|
134
136
|
| `src/history.ts` | History model and status types |
|
|
135
137
|
| `src/version.ts` | Runtime plugin version (reads package.json) |
|
|
136
138
|
| `src/core/retention.ts` | Daily history prune and incremental vacuum |
|
|
@@ -304,7 +306,7 @@ never requires a manual migration.
|
|
|
304
306
|
|
|
305
307
|
| Interface | Audience | Entry point |
|
|
306
308
|
| --- | --- | --- |
|
|
307
|
-
| Agent tools | AI agent |
|
|
309
|
+
| Agent tools | AI agent | 22 tools registered via `ctx.tool.transform` |
|
|
308
310
|
| Agent skill | AI agent | `skills/scheduled-job-best-practices` |
|
|
309
311
|
| RPC | Sidebar GUI | `src/rpc.ts` contracts, ~30 methods |
|
|
310
312
|
| Sidebar GUI | Human | `gui-experimental.cjs` |
|
package/docs/FEATURES.md
CHANGED
|
@@ -397,27 +397,44 @@ matrix combinations are rejected explicitly.
|
|
|
397
397
|
|
|
398
398
|
### Notifications
|
|
399
399
|
|
|
400
|
-
|
|
400
|
+
Notifications on run completion through three independent channels — webhook, Telegram
|
|
401
|
+
and native OS notifications — configurable in settings and testable with
|
|
401
402
|
`test_notification`.
|
|
402
403
|
|
|
403
|
-
- **
|
|
404
|
-
compatible webhook (`{ content, text }`). `webhook.timeoutMs`
|
|
405
|
-
`webhook.retryCount` (default 2) and `webhook.retryDelayMs`
|
|
406
|
-
the request; network errors, timeouts, HTTP 5xx and 429 are
|
|
407
|
-
backoff (capped at 30 s), other 4xx are not.
|
|
404
|
+
- **Webhook delivery:** per-task completion (success/error/timeout) through a
|
|
405
|
+
Discord/Slack compatible webhook (`{ content, text }`). `webhook.timeoutMs`
|
|
406
|
+
(default 10 000), `webhook.retryCount` (default 2) and `webhook.retryDelayMs`
|
|
407
|
+
(default 1000) control the request; network errors, timeouts, HTTP 5xx and 429 are
|
|
408
|
+
retried with exponential backoff (capped at 30 s), other 4xx are not.
|
|
409
|
+
- **Telegram:** Bot API `sendMessage` with `chat_id`, `parse_mode` (`HTML`,
|
|
410
|
+
`MarkdownV2`, `Markdown` or plain text), optional silent mode, forum topic
|
|
411
|
+
(`messageThreadId`) and a dashboard link (`includeDashboardLink`). Configured in the
|
|
412
|
+
GUI or with `manage_settings` → `notifications.telegram`. `botToken` and `chatId`
|
|
413
|
+
may instead come from `OPENCODE_SCHEDULER_TELEGRAM_BOT_TOKEN` and
|
|
414
|
+
`OPENCODE_SCHEDULER_TELEGRAM_CHAT_ID` so no secret is stored in `settings.json`;
|
|
415
|
+
the token is masked in every error message and log line.
|
|
416
|
+
- **Native OS notifications:** Windows Toast (PowerShell/WinRT), macOS Notification
|
|
417
|
+
Center (`osascript`) and Linux `notify-send`. No extra dependency: `node-notifier`
|
|
418
|
+
is not required. `notifications.native.sound` toggles the sound where supported.
|
|
408
419
|
- **Templates:** `templates.success` and `templates.error` accept placeholders
|
|
409
|
-
`{task}`, `{status}`, `{duration}`, `{error}`, `{emoji}`.
|
|
420
|
+
`{task}`, `{status}`, `{duration}`, `{error}`, `{emoji}`, `{cost}` and `{tokens}`.
|
|
421
|
+
When token/cost data is present the message gains a ` · 1500 tok · $0.0060` suffix.
|
|
410
422
|
- **Filters:** `filters.include` / `filters.exclude` are task-name patterns with `*`
|
|
411
423
|
wildcards; an empty include list means all tasks, exclude wins.
|
|
424
|
+
- **Quiet hours:** `quietHours.enabled` with `from`/`to` in `HH:MM` (an overnight
|
|
425
|
+
range such as 22:00 → 08:00 is supported). During the window `success` and
|
|
426
|
+
`partial` are suppressed while `error` and `timeout` are still delivered.
|
|
412
427
|
- **Matrix notifications:** on family completion — success, `partial` (`onPartial`)
|
|
413
428
|
and all clones failed (`onAllFailed`). A stuck detector reports clones running
|
|
414
429
|
longer than `matrix.stuckAfterMinutes` (default 60, `0` disables) once per run.
|
|
415
430
|
- **Digest:** `digest.enabled` sends a daily (`frequency: "daily"`, at `digest.time`)
|
|
416
431
|
or weekly (Mondays, catch-up afterwards) summary: runs, success rate, cost, tokens
|
|
417
|
-
and top errors. Also available as the
|
|
418
|
-
«📊 Отправить дайджест сейчас» button (manual sends
|
|
419
|
-
|
|
420
|
-
|
|
432
|
+
and top errors through every enabled channel. Also available as the
|
|
433
|
+
`send_digest` RPC and the GUI's «📊 Отправить дайджест сейчас» button (manual sends
|
|
434
|
+
do not move the schedule).
|
|
435
|
+
- **Test button:** sends a test message to `all`, `webhook`, `telegram` or `native`
|
|
436
|
+
and reports per-channel success/failure. Failures in one channel never block the
|
|
437
|
+
others and never throw into the task run.
|
|
421
438
|
|
|
422
439
|
### Crash recovery
|
|
423
440
|
|
package/docs/README.ru.md
CHANGED
|
@@ -38,7 +38,7 @@ English version: [README.md](../README.md).
|
|
|
38
38
|
| Триггеры | cron, одноразовый запуск (`triggerType: "once"`), изменение файла (chokidar), MCP-события, входящие webhooks (`POST /api/hooks/:task` с HMAC) |
|
|
39
39
|
| Мультирепо | workspaces с валидацией путей, запуски по workspace, матрица поверх родительской задачи |
|
|
40
40
|
| Наблюдаемость | история SQLite (success / error / timeout / partial / running), метрики (длительность, токены, стоимость), JSONL-логи с `/api/logs`, Prometheus `/metrics`, экспорт OTLP, логи по задачам, веб-дашборд с аналитикой за 14 дней, ретеншн истории и экспорт CSV/JSON |
|
|
41
|
-
| Эксплуатация | dry-run, экспорт/импорт JSON, шаблоны, webhook
|
|
41
|
+
| Эксплуатация | dry-run, экспорт/импорт JSON, шаблоны, уведомления по нескольким каналам (webhook, Telegram, нативные toast), тихие часы, дайджест, настройки |
|
|
42
42
|
| Интерфейсы | панель OpenCode GUI, веб-дашборд, 22 инструмента для агента, встроенный скилл |
|
|
43
43
|
|
|
44
44
|
## Установка
|
|
@@ -102,7 +102,7 @@ npm run build && npm run build:gui
|
|
|
102
102
|
| `manage_templates` | `action`, поля шаблона | Список, сохранение и удаление шаблонов задач |
|
|
103
103
|
| `manage_profiles` | `action`, `name?`, `port?` | Список, создание, переключение и удаление изолированных профилей |
|
|
104
104
|
| `transfer_tasks` | `action`, `data?` | Экспорт всех задач в JSON и импорт обратно |
|
|
105
|
-
| `send_notification` | `action` (`test`/`digest`) | Проверка
|
|
105
|
+
| `send_notification` | `action` (`test`/`digest`), `channel?` (`all`/`webhook`/`telegram`/`native`) | Проверка каналов уведомлений или отправка дайджеста |
|
|
106
106
|
| `get_dashboard_info` | — | Порт/URL дашборда, платформа, заголовок, активный профиль |
|
|
107
107
|
| `cleanup_history` | `retentionDays?`, `maxRecords?` | Удаление старой истории по возрасту и/или лимиту записей |
|
|
108
108
|
| `emit_event` | `eventName`, `payload?` | Запуск задач, подписанных на MCP-событие |
|
|
@@ -192,6 +192,15 @@ Windows (Планировщик Windows), macOS (launchd) и Linux (crontab). Р
|
|
|
192
192
|
**Куда отправляются данные?**
|
|
193
193
|
Никуда. История, логи, метрики и настройки хранятся локально в SQLite; телеметрии и аккаунтов нет.
|
|
194
194
|
|
|
195
|
+
**Как включить уведомления в Telegram?**
|
|
196
|
+
Создайте бота у [@BotFather](https://t.me/BotFather), скопируйте токен, напишите боту сообщение и возьмите `chat_id` из `getUpdates` (или используйте ID группы/канала). Укажите оба значения в панели или через `manage_settings` → `notifications.telegram` (`enabled`, `botToken`, `chatId`, при необходимости `parseMode`). Чтобы не хранить секреты в `settings.json`, задайте `OPENCODE_SCHEDULER_TELEGRAM_BOT_TOKEN` и `OPENCODE_SCHEDULER_TELEGRAM_CHAT_ID` — переменные используются, если поля пусты. Проверка: `send_notification` с `channel: "telegram"`.
|
|
197
|
+
|
|
198
|
+
**Нужен ли отдельный пакет для системных уведомлений?**
|
|
199
|
+
Нет. Windows Toast (PowerShell/WinRT), macOS Notification Center (`osascript`) и Linux `notify-send` вызываются напрямую, `node-notifier` не требуется. Включается через `notifications.native.enabled`.
|
|
200
|
+
|
|
201
|
+
**Можно ли отключить уведомления на ночь?**
|
|
202
|
+
Да. Задайте `notifications.quietHours` (`enabled`, `from`, `to` в `HH:MM`). В этом окне успешные и `partial` запуски не отправляются, а ошибки и таймауты приходят всегда.
|
|
203
|
+
|
|
195
204
|
**Чем это отличается от `experimental.schedules` в OpenCode?**
|
|
196
205
|
Встроенный планировщик выполняет задачи, пока OpenCode запущен. Этот плагин использует нативный планировщик ОС и добавляет DAG-пайплайны, матричные сборки, Quality Gates, webhooks и наблюдаемость.
|
|
197
206
|
|