opencode-windows-scheduler 1.2.2 → 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/src/gui.tsx CHANGED
@@ -39,6 +39,19 @@ interface NotificationSettings {
39
39
  }
40
40
  templates?: { success: string; error: string }
41
41
  filters?: { include: string[]; exclude: string[] }
42
+ telegram?: {
43
+ enabled: boolean
44
+ botToken: string
45
+ chatId: string
46
+ parseMode: "" | "HTML" | "Markdown" | "MarkdownV2"
47
+ disableNotification: boolean
48
+ messageThreadId: number | null
49
+ includeDashboardLink: boolean
50
+ apiBase: string
51
+ }
52
+ native?: { enabled: boolean; sound: boolean }
53
+ quietHours?: { enabled: boolean; from: string; to: string }
54
+ dashboardUrl?: string
42
55
  matrix?: {
43
56
  enabled: boolean
44
57
  onPartial: boolean
@@ -348,6 +361,20 @@ export default Plugin.define({
348
361
  const [digestFrequency, setDigestFrequency] = createSignal<"daily" | "weekly">("daily")
349
362
  const [digestTime, setDigestTime] = createSignal("09:00")
350
363
  const [digestLastSentAt, setDigestLastSentAt] = createSignal<string | null>(null)
364
+ // Спринт 25: Telegram, нативные уведомления и тихие часы.
365
+ const [telegramEnabled, setTelegramEnabled] = createSignal(false)
366
+ const [telegramBotToken, setTelegramBotToken] = createSignal("")
367
+ const [telegramChatId, setTelegramChatId] = createSignal("")
368
+ const [telegramParseMode, setTelegramParseMode] = createSignal<"" | "HTML" | "Markdown" | "MarkdownV2">("HTML")
369
+ const [telegramSilent, setTelegramSilent] = createSignal(false)
370
+ const [telegramLink, setTelegramLink] = createSignal(true)
371
+ const [telegramApiBase, setTelegramApiBase] = createSignal("https://api.telegram.org")
372
+ const [telegramThreadId, setTelegramThreadId] = createSignal<number | null>(null)
373
+ const [nativeEnabled, setNativeEnabled] = createSignal(false)
374
+ const [nativeSound, setNativeSound] = createSignal(true)
375
+ const [quietEnabled, setQuietEnabled] = createSignal(false)
376
+ const [quietFrom, setQuietFrom] = createSignal("22:00")
377
+ const [quietTo, setQuietTo] = createSignal("08:00")
351
378
  const [digestBusy, setDigestBusy] = createSignal(false)
352
379
 
353
380
  // Настройки ретеншна истории (Спринт 18): очистка старых записей.
@@ -399,6 +426,19 @@ export default Plugin.define({
399
426
  setDigestFrequency(n?.digest?.frequency === "weekly" ? "weekly" : "daily")
400
427
  setDigestTime(n?.digest?.time ?? "09:00")
401
428
  setDigestLastSentAt(n?.digest?.lastSentAt ?? null)
429
+ setTelegramEnabled(Boolean(n?.telegram?.enabled))
430
+ setTelegramBotToken(n?.telegram?.botToken ?? "")
431
+ setTelegramChatId(n?.telegram?.chatId ?? "")
432
+ setTelegramParseMode((n?.telegram?.parseMode ?? "HTML") as "" | "HTML" | "Markdown" | "MarkdownV2")
433
+ setTelegramSilent(Boolean(n?.telegram?.disableNotification))
434
+ setTelegramLink(n?.telegram?.includeDashboardLink !== false)
435
+ setTelegramApiBase(n?.telegram?.apiBase ?? "https://api.telegram.org")
436
+ setTelegramThreadId(typeof n?.telegram?.messageThreadId === "number" ? n.telegram.messageThreadId : null)
437
+ setNativeEnabled(Boolean(n?.native?.enabled))
438
+ setNativeSound(n?.native?.sound !== false)
439
+ setQuietEnabled(Boolean(n?.quietHours?.enabled))
440
+ setQuietFrom(n?.quietHours?.from ?? "22:00")
441
+ setQuietTo(n?.quietHours?.to ?? "08:00")
402
442
  }
403
443
 
404
444
  async function loadSettingsGui() {
@@ -442,6 +482,25 @@ export default Plugin.define({
442
482
  include: splitList(filterInclude()),
443
483
  exclude: splitList(filterExclude()),
444
484
  },
485
+ telegram: {
486
+ enabled: telegramEnabled(),
487
+ botToken: (telegramBotToken() || "").trim(),
488
+ chatId: (telegramChatId() || "").trim(),
489
+ parseMode: telegramParseMode(),
490
+ disableNotification: telegramSilent(),
491
+ messageThreadId: telegramThreadId(),
492
+ includeDashboardLink: telegramLink(),
493
+ apiBase: telegramApiBase(),
494
+ },
495
+ native: {
496
+ enabled: nativeEnabled(),
497
+ sound: nativeSound(),
498
+ },
499
+ quietHours: {
500
+ enabled: quietEnabled(),
501
+ from: (quietFrom() || "22:00").trim(),
502
+ to: (quietTo() || "08:00").trim(),
503
+ },
445
504
  matrix: {
446
505
  enabled: matrixNotifyEnabled(),
447
506
  onPartial: matrixNotifyPartial(),
@@ -2499,6 +2558,161 @@ export default Plugin.define({
2499
2558
  </div>
2500
2559
  </div>
2501
2560
 
2561
+ {/* Telegram (Спринт 25) */}
2562
+ <div style="border-top:1px solid #333;padding-top:10px;display:flex;flex-direction:column;gap:8px">
2563
+ <label style={`display:flex;align-items:center;gap:8px;font-size:12px;cursor:pointer;opacity:${notificationsEnabled() ? 1 : 0.5}`}>
2564
+ <input
2565
+ type="checkbox"
2566
+ checked={telegramEnabled()}
2567
+ disabled={!notificationsEnabled()}
2568
+ onChange={(e) => {
2569
+ setTelegramEnabled(e.currentTarget.checked)
2570
+ void saveNotificationSettings()
2571
+ }}
2572
+ style="accent-color:#5ac8fa;cursor:pointer;margin:0"
2573
+ />
2574
+ Telegram
2575
+ </label>
2576
+ <input
2577
+ type="password"
2578
+ autocomplete="off"
2579
+ value={telegramBotToken() || ""}
2580
+ disabled={!notificationsEnabled() || !telegramEnabled()}
2581
+ onInput={(e) => setTelegramBotToken(e.currentTarget.value)}
2582
+ onChange={() => void saveNotificationSettings()}
2583
+ placeholder="Токен бота из @BotFather"
2584
+ style={`display:block;width:100%;box-sizing:border-box;padding:8px;background:#1e1e1e;border:1px solid #333;border-radius:6px;color:#fff;font-size:13px;outline:none;opacity:${notificationsEnabled() && telegramEnabled() ? 1 : 0.5}`}
2585
+ />
2586
+ <input
2587
+ type="text"
2588
+ value={telegramChatId() || ""}
2589
+ disabled={!notificationsEnabled() || !telegramEnabled()}
2590
+ onInput={(e) => setTelegramChatId(e.currentTarget.value)}
2591
+ onChange={() => void saveNotificationSettings()}
2592
+ placeholder="chat_id (например, 123456789 или -100...)"
2593
+ style={`display:block;width:100%;box-sizing:border-box;padding:8px;background:#1e1e1e;border:1px solid #333;border-radius:6px;color:#fff;font-size:13px;outline:none;opacity:${notificationsEnabled() && telegramEnabled() ? 1 : 0.5}`}
2594
+ />
2595
+ <div style={`display:flex;align-items:center;gap:10px;flex-wrap:wrap;font-size:12px;color:#b0b0b0;opacity:${notificationsEnabled() && telegramEnabled() ? 1 : 0.5}`}>
2596
+ <span>разметка:</span>
2597
+ <select
2598
+ value={telegramParseMode()}
2599
+ disabled={!notificationsEnabled() || !telegramEnabled()}
2600
+ onChange={(e) => {
2601
+ setTelegramParseMode(e.currentTarget.value as "" | "HTML" | "Markdown" | "MarkdownV2")
2602
+ void saveNotificationSettings()
2603
+ }}
2604
+ style="padding:4px 6px;background:#1e1e1e;border:1px solid #333;border-radius:4px;color:#fff;font-size:12px;outline:none"
2605
+ >
2606
+ <option value="HTML">HTML</option>
2607
+ <option value="MarkdownV2">MarkdownV2</option>
2608
+ <option value="Markdown">Markdown</option>
2609
+ <option value="">plain text</option>
2610
+ </select>
2611
+ <label style="display:flex;align-items:center;gap:6px;cursor:pointer">
2612
+ <input
2613
+ type="checkbox"
2614
+ checked={telegramSilent()}
2615
+ disabled={!notificationsEnabled() || !telegramEnabled()}
2616
+ onChange={(e) => {
2617
+ setTelegramSilent(e.currentTarget.checked)
2618
+ void saveNotificationSettings()
2619
+ }}
2620
+ style="accent-color:#5ac8fa;cursor:pointer;margin:0"
2621
+ />
2622
+ без звука
2623
+ </label>
2624
+ <label style="display:flex;align-items:center;gap:6px;cursor:pointer">
2625
+ <input
2626
+ type="checkbox"
2627
+ checked={telegramLink()}
2628
+ disabled={!notificationsEnabled() || !telegramEnabled()}
2629
+ onChange={(e) => {
2630
+ setTelegramLink(e.currentTarget.checked)
2631
+ void saveNotificationSettings()
2632
+ }}
2633
+ style="accent-color:#5ac8fa;cursor:pointer;margin:0"
2634
+ />
2635
+ ссылка на дашборд
2636
+ </label>
2637
+ </div>
2638
+ <div style="font-size:11px;color:#8e8e93">
2639
+ Токен можно не хранить в settings.json: задайте OPENCODE_SCHEDULER_TELEGRAM_BOT_TOKEN и OPENCODE_SCHEDULER_TELEGRAM_CHAT_ID.
2640
+ </div>
2641
+ </div>
2642
+
2643
+ {/* Нативные уведомления ОС (Спринт 25) */}
2644
+ <div style="border-top:1px solid #333;padding-top:10px;display:flex;flex-direction:column;gap:8px">
2645
+ <label style={`display:flex;align-items:center;gap:8px;font-size:12px;cursor:pointer;opacity:${notificationsEnabled() ? 1 : 0.5}`}>
2646
+ <input
2647
+ type="checkbox"
2648
+ checked={nativeEnabled()}
2649
+ disabled={!notificationsEnabled()}
2650
+ onChange={(e) => {
2651
+ setNativeEnabled(e.currentTarget.checked)
2652
+ void saveNotificationSettings()
2653
+ }}
2654
+ style="accent-color:#5ac8fa;cursor:pointer;margin:0"
2655
+ />
2656
+ Нативные уведомления ОС
2657
+ </label>
2658
+ <label style={`display:flex;align-items:center;gap:8px;font-size:12px;cursor:pointer;opacity:${notificationsEnabled() && nativeEnabled() ? 1 : 0.5}`}>
2659
+ <input
2660
+ type="checkbox"
2661
+ checked={nativeSound()}
2662
+ disabled={!notificationsEnabled() || !nativeEnabled()}
2663
+ onChange={(e) => {
2664
+ setNativeSound(e.currentTarget.checked)
2665
+ void saveNotificationSettings()
2666
+ }}
2667
+ style="accent-color:#5ac8fa;cursor:pointer;margin:0"
2668
+ />
2669
+ со звуком
2670
+ </label>
2671
+ <div style="font-size:11px;color:#8e8e93">
2672
+ Windows Toast, macOS Notification Center, Linux notify-send. Без внешних зависимостей.
2673
+ </div>
2674
+ </div>
2675
+
2676
+ {/* Тихие часы (Спринт 25) */}
2677
+ <div style="border-top:1px solid #333;padding-top:10px;display:flex;flex-direction:column;gap:8px">
2678
+ <label style={`display:flex;align-items:center;gap:8px;font-size:12px;cursor:pointer;opacity:${notificationsEnabled() ? 1 : 0.5}`}>
2679
+ <input
2680
+ type="checkbox"
2681
+ checked={quietEnabled()}
2682
+ disabled={!notificationsEnabled()}
2683
+ onChange={(e) => {
2684
+ setQuietEnabled(e.currentTarget.checked)
2685
+ void saveNotificationSettings()
2686
+ }}
2687
+ style="accent-color:#5ac8fa;cursor:pointer;margin:0"
2688
+ />
2689
+ Тихие часы
2690
+ </label>
2691
+ <div style={`display:flex;align-items:center;gap:8px;flex-wrap:wrap;font-size:12px;color:#b0b0b0;opacity:${notificationsEnabled() && quietEnabled() ? 1 : 0.5}`}>
2692
+ <span>с</span>
2693
+ <input
2694
+ type="time"
2695
+ value={quietFrom()}
2696
+ disabled={!notificationsEnabled() || !quietEnabled()}
2697
+ onInput={(e) => setQuietFrom(e.currentTarget.value)}
2698
+ onChange={() => void saveNotificationSettings()}
2699
+ style="padding:4px 6px;background:#1e1e1e;border:1px solid #333;border-radius:4px;color:#fff;font-size:12px;outline:none"
2700
+ />
2701
+ <span>до</span>
2702
+ <input
2703
+ type="time"
2704
+ value={quietTo()}
2705
+ disabled={!notificationsEnabled() || !quietEnabled()}
2706
+ onInput={(e) => setQuietTo(e.currentTarget.value)}
2707
+ onChange={() => void saveNotificationSettings()}
2708
+ style="padding:4px 6px;background:#1e1e1e;border:1px solid #333;border-radius:4px;color:#fff;font-size:12px;outline:none"
2709
+ />
2710
+ </div>
2711
+ <div style="font-size:11px;color:#8e8e93">
2712
+ В тихие часы success и partial подавляются, ошибки и таймауты отправляются.
2713
+ </div>
2714
+ </div>
2715
+
2502
2716
  {/* Фильтры по задачам (Спринт 20) */}
2503
2717
  <div style="border-top:1px solid #333;padding-top:10px;display:flex;flex-direction:column;gap:8px">
2504
2718
  <div style="font-size:12px;color:#e0e0e0;font-weight:600">Фильтры по задачам</div>
@@ -2547,7 +2761,7 @@ export default Plugin.define({
2547
2761
  style={`display:block;width:100%;box-sizing:border-box;padding:8px;background:#1e1e1e;border:1px solid #333;border-radius:6px;color:#fff;font-size:12px;outline:none;opacity:${notificationsEnabled() ? 1 : 0.5}`}
2548
2762
  />
2549
2763
  <div style="font-size:11px;color:#8e8e93">
2550
- Плейсхолдеры: {"{task} {status} {duration} {error} {emoji}"}. Пусто = шаблон по умолчанию.
2764
+ Плейсхолдеры: {"{task} {status} {duration} {error} {emoji} {cost} {tokens}"}. Пусто = шаблон по умолчанию.
2551
2765
  </div>
2552
2766
  </div>
2553
2767
 
@@ -2662,20 +2876,20 @@ export default Plugin.define({
2662
2876
  <div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap">
2663
2877
  <button
2664
2878
  onClick={() => void handleTestNotification()}
2665
- disabled={testNotificationBusy() || !webhookEnabled()}
2666
- style={`padding:6px 12px;background:#007acc;color:white;border:none;border-radius:6px;cursor:${testNotificationBusy() || !webhookEnabled() ? "not-allowed" : "pointer"};font-size:12px;font-weight:500;opacity:${testNotificationBusy() || !webhookEnabled() ? 0.6 : 1}`}
2879
+ disabled={testNotificationBusy() || !(webhookEnabled() || telegramEnabled() || nativeEnabled())}
2880
+ style={`padding:6px 12px;background:#007acc;color:white;border:none;border-radius:6px;cursor:${testNotificationBusy() || !(webhookEnabled() || telegramEnabled() || nativeEnabled()) ? "not-allowed" : "pointer"};font-size:12px;font-weight:500;opacity:${testNotificationBusy() || !(webhookEnabled() || telegramEnabled() || nativeEnabled()) ? 0.6 : 1}`}
2667
2881
  >
2668
2882
  {testNotificationBusy() ? "Отправка..." : "🧪 Тестовое уведомление"}
2669
2883
  </button>
2670
2884
  <button
2671
2885
  onClick={() => void handleSendDigest()}
2672
- disabled={digestBusy() || !webhookEnabled()}
2673
- style={`padding:6px 12px;background:#2d7d46;color:white;border:none;border-radius:6px;cursor:${digestBusy() || !webhookEnabled() ? "not-allowed" : "pointer"};font-size:12px;font-weight:500;opacity:${digestBusy() || !webhookEnabled() ? 0.6 : 1}`}
2886
+ disabled={digestBusy() || !(webhookEnabled() || telegramEnabled() || nativeEnabled())}
2887
+ style={`padding:6px 12px;background:#2d7d46;color:white;border:none;border-radius:6px;cursor:${digestBusy() || !(webhookEnabled() || telegramEnabled() || nativeEnabled()) ? "not-allowed" : "pointer"};font-size:12px;font-weight:500;opacity:${digestBusy() || !(webhookEnabled() || telegramEnabled() || nativeEnabled()) ? 0.6 : 1}`}
2674
2888
  >
2675
2889
  {digestBusy() ? "Отправка..." : "📊 Отправить дайджест сейчас"}
2676
2890
  </button>
2677
2891
  <span style="font-size:11px;color:#8e8e93">
2678
- ntfy.sh не используется — только webhook.
2892
+ Каналы: webhook, Telegram, нативные уведомления ОС.
2679
2893
  </span>
2680
2894
  </div>
2681
2895
  </div>
package/src/index.ts CHANGED
@@ -681,7 +681,7 @@ export const manageSettingsSchema = z.object({
681
681
  notifications: z
682
682
  .any()
683
683
  .optional()
684
- .describe("Notification settings patch (enabled, onlyOnError, webhook, templates, filters, matrix, digest)."),
684
+ .describe("Notification settings patch (enabled, onlyOnError, webhook, telegram, native, quietHours, templates, filters, matrix, digest)."),
685
685
  history: z
686
686
  .object({
687
687
  retentionDays: z.number().int().min(1).max(3650).optional(),
@@ -751,6 +751,10 @@ export const sendNotificationSchema = z.object({
751
751
  action: z
752
752
  .enum(["test", "digest"])
753
753
  .describe("test — send a test message through the configured channel; digest — send the digest now."),
754
+ channel: z
755
+ .enum(["all", "webhook", "telegram", "native"])
756
+ .optional()
757
+ .describe("For action=test: which channel to check (default all enabled)."),
754
758
  });
755
759
 
756
760
  /** get_dashboard_info — сведения о панели управления. */
@@ -2161,7 +2165,7 @@ const transferTasksExecute = wrapExecute<TransferArgs>(async (args) => {
2161
2165
  const sendNotificationExecute = wrapExecute<NotificationArgs>(async (args) => {
2162
2166
  const result =
2163
2167
  args.action === "test"
2164
- ? await sendTestNotification()
2168
+ ? await sendTestNotification(args.channel ?? "all")
2165
2169
  : await sendDigestNow({ updateLastSentAt: false });
2166
2170
  return { content: JSON.stringify(result) };
2167
2171
  });
@@ -2565,7 +2569,7 @@ export default Plugin.define({
2565
2569
  name: "manage_settings",
2566
2570
  input: manageSettingsSchema,
2567
2571
  description:
2568
- "Reads or updates global scheduler settings: maxConcurrent, winterMode, notifications (webhook, filters, matrix alerts, digest) and history retention. Updates are merged into the current settings.",
2572
+ "Reads or updates global scheduler settings: maxConcurrent, winterMode, notifications (webhook, Telegram, native OS notifications, quiet hours, filters, matrix alerts, digest) and history retention. Updates are merged into the current settings.",
2569
2573
  options: { codemode: true },
2570
2574
  execute: manageSettingsExecute as any,
2571
2575
  });