opencode-windows-scheduler 1.2.3 → 1.4.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +61 -2
  2. package/README.md +21 -4
  3. package/ROADMAP-STRATEGY.md +61 -159
  4. package/ROADMAP.md +60 -98
  5. package/dist/core/audit.d.ts +68 -0
  6. package/dist/core/audit.d.ts.map +1 -0
  7. package/dist/core/audit.js +206 -0
  8. package/dist/core/native-notify.d.ts +36 -0
  9. package/dist/core/native-notify.d.ts.map +1 -0
  10. package/dist/core/native-notify.js +110 -0
  11. package/dist/core/record-history.js +4 -4
  12. package/dist/core/secrets.d.ts +57 -0
  13. package/dist/core/secrets.d.ts.map +1 -0
  14. package/dist/core/secrets.js +331 -0
  15. package/dist/core/structured-log.d.ts.map +1 -1
  16. package/dist/core/structured-log.js +9 -0
  17. package/dist/core/telegram.d.ts +45 -0
  18. package/dist/core/telegram.d.ts.map +1 -0
  19. package/dist/core/telegram.js +160 -0
  20. package/dist/db/schema.d.ts +1 -1
  21. package/dist/db/schema.d.ts.map +1 -1
  22. package/dist/db/schema.js +15 -0
  23. package/dist/index.d.ts +30 -4
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +349 -22
  26. package/dist/notifications.d.ts +26 -6
  27. package/dist/notifications.d.ts.map +1 -1
  28. package/dist/notifications.js +191 -34
  29. package/dist/rpc.d.ts +400 -0
  30. package/dist/rpc.d.ts.map +1 -1
  31. package/dist/rpc.js +146 -0
  32. package/dist/server.d.ts.map +1 -1
  33. package/dist/server.js +67 -0
  34. package/dist/settings.d.ts +63 -2
  35. package/dist/settings.d.ts.map +1 -1
  36. package/dist/settings.js +126 -2
  37. package/dist/workspaces.d.ts +8 -2
  38. package/dist/workspaces.d.ts.map +1 -1
  39. package/dist/workspaces.js +21 -4
  40. package/docs/ARCHITECTURE.md +16 -6
  41. package/docs/FEATURES.md +57 -12
  42. package/docs/README.ru.md +23 -4
  43. package/gui-experimental.cjs +4 -4
  44. package/package.json +5 -2
  45. package/src/core/audit.ts +291 -0
  46. package/src/core/native-notify.ts +154 -0
  47. package/src/core/record-history.ts +6 -4
  48. package/src/core/secrets.ts +385 -0
  49. package/src/core/structured-log.ts +9 -0
  50. package/src/core/telegram.ts +219 -0
  51. package/src/db/schema.ts +15 -0
  52. package/src/gui.tsx +543 -6
  53. package/src/index.ts +459 -22
  54. package/src/notifications.ts +232 -40
  55. package/src/rpc.ts +157 -0
  56. package/src/server.ts +67 -0
  57. package/src/settings.ts +213 -4
  58. package/src/workspaces.ts +22 -4
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,8 +361,41 @@ 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
 
380
+ // Секреты (Спринт 26): зашифрованное хранилище.
381
+ const [secretsList, setSecretsList] = createSignal<{ name: string; preview: string; updatedAt: string }[]>([])
382
+ const [secretsBusy, setSecretsBusy] = createSignal(false)
383
+ const [secretName, setSecretName] = createSignal("")
384
+ const [secretValue, setSecretValue] = createSignal("")
385
+
386
+ // Аудит (Спринт 26): журнал мутаций.
387
+ const [auditRecords, setAuditRecords] = createSignal<{ id: number; ts: string; action: string; targetType: string | null; target: string | null; actor: string; source: string | null; details: unknown; remote: string | null }[]>([])
388
+ const [auditBusy, setAuditBusy] = createSignal(false)
389
+ const [auditCollapsed, setAuditCollapsed] = createSignal(true)
390
+ const [auditFilterAction, setAuditFilterAction] = createSignal("")
391
+ const [auditFilterActor, setAuditFilterActor] = createSignal("")
392
+ const [auditFilterTarget, setAuditFilterTarget] = createSignal("")
393
+
394
+ // Настройки аудита (ретеншн).
395
+ const [auditRetentionEnabled, setAuditRetentionEnabled] = createSignal(true)
396
+ const [auditRetentionDays, setAuditRetentionDays] = createSignal(90)
397
+ const [auditMaxRecords, setAuditMaxRecords] = createSignal(10000)
398
+
353
399
  // Настройки ретеншна истории (Спринт 18): очистка старых записей.
354
400
  const [historyRetentionDays, setHistoryRetentionDays] = createSignal(30)
355
401
  const [historyMaxRecords, setHistoryMaxRecords] = createSignal(5000)
@@ -399,6 +445,23 @@ export default Plugin.define({
399
445
  setDigestFrequency(n?.digest?.frequency === "weekly" ? "weekly" : "daily")
400
446
  setDigestTime(n?.digest?.time ?? "09:00")
401
447
  setDigestLastSentAt(n?.digest?.lastSentAt ?? null)
448
+ setTelegramEnabled(Boolean(n?.telegram?.enabled))
449
+ setTelegramBotToken(n?.telegram?.botToken ?? "")
450
+ setTelegramChatId(n?.telegram?.chatId ?? "")
451
+ setTelegramParseMode((n?.telegram?.parseMode ?? "HTML") as "" | "HTML" | "Markdown" | "MarkdownV2")
452
+ setTelegramSilent(Boolean(n?.telegram?.disableNotification))
453
+ setTelegramLink(n?.telegram?.includeDashboardLink !== false)
454
+ setTelegramApiBase(n?.telegram?.apiBase ?? "https://api.telegram.org")
455
+ setTelegramThreadId(typeof n?.telegram?.messageThreadId === "number" ? n.telegram.messageThreadId : null)
456
+ setNativeEnabled(Boolean(n?.native?.enabled))
457
+ setNativeSound(n?.native?.sound !== false)
458
+ setQuietEnabled(Boolean(n?.quietHours?.enabled))
459
+ setQuietFrom(n?.quietHours?.from ?? "22:00")
460
+ setQuietTo(n?.quietHours?.to ?? "08:00")
461
+ const a = n?.audit
462
+ setAuditRetentionEnabled(Boolean(a?.enabled !== false))
463
+ setAuditRetentionDays(Number(a?.retentionDays ?? 90))
464
+ setAuditMaxRecords(Number(a?.maxRecords ?? 10000))
402
465
  }
403
466
 
404
467
  async function loadSettingsGui() {
@@ -412,9 +475,16 @@ export default Plugin.define({
412
475
  setHistoryMaxRecords(Number(h?.maxRecords ?? 5000))
413
476
  setHistoryLastCleanupAt(h?.lastCleanupAt ?? null)
414
477
  setHistoryLastCleanupDeleted(Number(h?.lastCleanupDeleted ?? 0))
478
+ const au = s.audit
479
+ setAuditRetentionEnabled(Boolean(au?.enabled !== false))
480
+ setAuditRetentionDays(Number(au?.retentionDays ?? 90))
481
+ setAuditMaxRecords(Number(au?.maxRecords ?? 10000))
415
482
  } catch (err: any) {
416
483
  console.error("RPC Error (get_settings):", err)
417
484
  }
485
+
486
+ void loadSecretsGui()
487
+ void loadAuditGui()
418
488
  }
419
489
 
420
490
  /** Текущие настройки уведомлений из сигналов формы. */
@@ -442,6 +512,25 @@ export default Plugin.define({
442
512
  include: splitList(filterInclude()),
443
513
  exclude: splitList(filterExclude()),
444
514
  },
515
+ telegram: {
516
+ enabled: telegramEnabled(),
517
+ botToken: (telegramBotToken() || "").trim(),
518
+ chatId: (telegramChatId() || "").trim(),
519
+ parseMode: telegramParseMode(),
520
+ disableNotification: telegramSilent(),
521
+ messageThreadId: telegramThreadId(),
522
+ includeDashboardLink: telegramLink(),
523
+ apiBase: telegramApiBase(),
524
+ },
525
+ native: {
526
+ enabled: nativeEnabled(),
527
+ sound: nativeSound(),
528
+ },
529
+ quietHours: {
530
+ enabled: quietEnabled(),
531
+ from: (quietFrom() || "22:00").trim(),
532
+ to: (quietTo() || "08:00").trim(),
533
+ },
445
534
  matrix: {
446
535
  enabled: matrixNotifyEnabled(),
447
536
  onPartial: matrixNotifyPartial(),
@@ -457,6 +546,11 @@ export default Plugin.define({
457
546
  time: (digestTime() || "09:00").trim(),
458
547
  lastSentAt: digestLastSentAt(),
459
548
  },
549
+ audit: {
550
+ enabled: auditRetentionEnabled(),
551
+ retentionDays: auditRetentionDays(),
552
+ maxRecords: auditMaxRecords(),
553
+ },
460
554
  }
461
555
  }
462
556
 
@@ -490,6 +584,12 @@ export default Plugin.define({
490
584
  setHistoryLastCleanupAt(h?.lastCleanupAt ?? null)
491
585
  setHistoryLastCleanupDeleted(Number(h?.lastCleanupDeleted ?? 0))
492
586
  }
587
+ if (patch.audit !== undefined) {
588
+ const au = s.audit
589
+ setAuditRetentionEnabled(Boolean(au?.enabled !== false))
590
+ setAuditRetentionDays(Number(au?.retentionDays ?? 90))
591
+ setAuditMaxRecords(Number(au?.maxRecords ?? 10000))
592
+ }
493
593
  } catch (err: any) {
494
594
  console.error("RPC Error (save_settings):", err)
495
595
  ctx.toast.show({ title: "Не удалось сохранить настройки", variant: "error", description: errorMessage(err) })
@@ -537,6 +637,87 @@ export default Plugin.define({
537
637
  }
538
638
  }
539
639
 
640
+ /** Загрузка списка секретов (имена + превью, без значений). */
641
+ async function loadSecretsGui() {
642
+ setSecretsBusy(true)
643
+ try {
644
+ const result = await rpc.list_secrets({})
645
+ setSecretsList(result?.secrets ?? [])
646
+ } catch (err: any) {
647
+ console.error("RPC Error (list_secrets):", err)
648
+ } finally {
649
+ setSecretsBusy(false)
650
+ }
651
+ }
652
+
653
+ /** Сохранить/создать секрет. */
654
+ async function handleSaveSecret() {
655
+ const name = secretName().trim()
656
+ const value = secretValue()
657
+ if (!name || !value) return
658
+ setSecretsBusy(true)
659
+ try {
660
+ const result = await rpc.save_secret({ name, value })
661
+ if (result?.success) {
662
+ setSecretName("")
663
+ setSecretValue("")
664
+ ctx.toast.show({ title: "Секрет сохранён", variant: "success", description: result.message })
665
+ void loadSecretsGui()
666
+ } else {
667
+ ctx.toast.show({ title: "Секрет не сохранён", variant: "error", description: result?.message ?? "" })
668
+ }
669
+ } catch (err: any) {
670
+ console.error("RPC Error (save_secret):", err)
671
+ ctx.toast.show({ title: "Секрет не сохранён", variant: "error", description: errorMessage(err) })
672
+ } finally {
673
+ setSecretsBusy(false)
674
+ }
675
+ }
676
+
677
+ /** Удалить секрет по имени. */
678
+ async function handleDeleteSecret(name: string) {
679
+ setSecretsBusy(true)
680
+ try {
681
+ const result = await rpc.delete_secret({ name })
682
+ if (result?.success) {
683
+ ctx.toast.show({ title: "Секрет удалён", variant: "success", description: result?.message ?? "" })
684
+ void loadSecretsGui()
685
+ } else {
686
+ ctx.toast.show({ title: "Секрет не удалён", variant: "error", description: result?.message ?? "" })
687
+ }
688
+ } catch (err: any) {
689
+ console.error("RPC Error (delete_secret):", err)
690
+ ctx.toast.show({ title: "Секрет не удалён", variant: "error", description: errorMessage(err) })
691
+ } finally {
692
+ setSecretsBusy(false)
693
+ }
694
+ }
695
+
696
+ /** Загрузка журнала аудита с фильтрами. */
697
+ async function loadAuditGui() {
698
+ setAuditBusy(true)
699
+ try {
700
+ const result = await rpc.get_audit({
701
+ action: auditFilterAction() || undefined,
702
+ actor: auditFilterActor() || undefined,
703
+ target: auditFilterTarget() || undefined,
704
+ limit: 200,
705
+ })
706
+ if (result?.success) {
707
+ setAuditRecords(result?.records ?? [])
708
+ }
709
+ } catch (err: any) {
710
+ console.error("RPC Error (get_audit):", err)
711
+ } finally {
712
+ setAuditBusy(false)
713
+ }
714
+ }
715
+
716
+ /** Сохраняет настройки аудита. */
717
+ async function saveAuditSettings() {
718
+ await persistSettings({ audit: { enabled: auditRetentionEnabled(), retentionDays: auditRetentionDays(), maxRecords: auditMaxRecords() } })
719
+ }
720
+
540
721
  /** Кнопка «🧪 Тестовое уведомление». */
541
722
  async function handleTestNotification() {
542
723
  setTestNotificationBusy(true)
@@ -2499,6 +2680,161 @@ export default Plugin.define({
2499
2680
  </div>
2500
2681
  </div>
2501
2682
 
2683
+ {/* Telegram (Спринт 25) */}
2684
+ <div style="border-top:1px solid #333;padding-top:10px;display:flex;flex-direction:column;gap:8px">
2685
+ <label style={`display:flex;align-items:center;gap:8px;font-size:12px;cursor:pointer;opacity:${notificationsEnabled() ? 1 : 0.5}`}>
2686
+ <input
2687
+ type="checkbox"
2688
+ checked={telegramEnabled()}
2689
+ disabled={!notificationsEnabled()}
2690
+ onChange={(e) => {
2691
+ setTelegramEnabled(e.currentTarget.checked)
2692
+ void saveNotificationSettings()
2693
+ }}
2694
+ style="accent-color:#5ac8fa;cursor:pointer;margin:0"
2695
+ />
2696
+ Telegram
2697
+ </label>
2698
+ <input
2699
+ type="password"
2700
+ autocomplete="off"
2701
+ value={telegramBotToken() || ""}
2702
+ disabled={!notificationsEnabled() || !telegramEnabled()}
2703
+ onInput={(e) => setTelegramBotToken(e.currentTarget.value)}
2704
+ onChange={() => void saveNotificationSettings()}
2705
+ placeholder="Токен бота из @BotFather"
2706
+ 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}`}
2707
+ />
2708
+ <input
2709
+ type="text"
2710
+ value={telegramChatId() || ""}
2711
+ disabled={!notificationsEnabled() || !telegramEnabled()}
2712
+ onInput={(e) => setTelegramChatId(e.currentTarget.value)}
2713
+ onChange={() => void saveNotificationSettings()}
2714
+ placeholder="chat_id (например, 123456789 или -100...)"
2715
+ 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}`}
2716
+ />
2717
+ <div style={`display:flex;align-items:center;gap:10px;flex-wrap:wrap;font-size:12px;color:#b0b0b0;opacity:${notificationsEnabled() && telegramEnabled() ? 1 : 0.5}`}>
2718
+ <span>разметка:</span>
2719
+ <select
2720
+ value={telegramParseMode()}
2721
+ disabled={!notificationsEnabled() || !telegramEnabled()}
2722
+ onChange={(e) => {
2723
+ setTelegramParseMode(e.currentTarget.value as "" | "HTML" | "Markdown" | "MarkdownV2")
2724
+ void saveNotificationSettings()
2725
+ }}
2726
+ style="padding:4px 6px;background:#1e1e1e;border:1px solid #333;border-radius:4px;color:#fff;font-size:12px;outline:none"
2727
+ >
2728
+ <option value="HTML">HTML</option>
2729
+ <option value="MarkdownV2">MarkdownV2</option>
2730
+ <option value="Markdown">Markdown</option>
2731
+ <option value="">plain text</option>
2732
+ </select>
2733
+ <label style="display:flex;align-items:center;gap:6px;cursor:pointer">
2734
+ <input
2735
+ type="checkbox"
2736
+ checked={telegramSilent()}
2737
+ disabled={!notificationsEnabled() || !telegramEnabled()}
2738
+ onChange={(e) => {
2739
+ setTelegramSilent(e.currentTarget.checked)
2740
+ void saveNotificationSettings()
2741
+ }}
2742
+ style="accent-color:#5ac8fa;cursor:pointer;margin:0"
2743
+ />
2744
+ без звука
2745
+ </label>
2746
+ <label style="display:flex;align-items:center;gap:6px;cursor:pointer">
2747
+ <input
2748
+ type="checkbox"
2749
+ checked={telegramLink()}
2750
+ disabled={!notificationsEnabled() || !telegramEnabled()}
2751
+ onChange={(e) => {
2752
+ setTelegramLink(e.currentTarget.checked)
2753
+ void saveNotificationSettings()
2754
+ }}
2755
+ style="accent-color:#5ac8fa;cursor:pointer;margin:0"
2756
+ />
2757
+ ссылка на дашборд
2758
+ </label>
2759
+ </div>
2760
+ <div style="font-size:11px;color:#8e8e93">
2761
+ Токен можно не хранить в settings.json: задайте OPENCODE_SCHEDULER_TELEGRAM_BOT_TOKEN и OPENCODE_SCHEDULER_TELEGRAM_CHAT_ID.
2762
+ </div>
2763
+ </div>
2764
+
2765
+ {/* Нативные уведомления ОС (Спринт 25) */}
2766
+ <div style="border-top:1px solid #333;padding-top:10px;display:flex;flex-direction:column;gap:8px">
2767
+ <label style={`display:flex;align-items:center;gap:8px;font-size:12px;cursor:pointer;opacity:${notificationsEnabled() ? 1 : 0.5}`}>
2768
+ <input
2769
+ type="checkbox"
2770
+ checked={nativeEnabled()}
2771
+ disabled={!notificationsEnabled()}
2772
+ onChange={(e) => {
2773
+ setNativeEnabled(e.currentTarget.checked)
2774
+ void saveNotificationSettings()
2775
+ }}
2776
+ style="accent-color:#5ac8fa;cursor:pointer;margin:0"
2777
+ />
2778
+ Нативные уведомления ОС
2779
+ </label>
2780
+ <label style={`display:flex;align-items:center;gap:8px;font-size:12px;cursor:pointer;opacity:${notificationsEnabled() && nativeEnabled() ? 1 : 0.5}`}>
2781
+ <input
2782
+ type="checkbox"
2783
+ checked={nativeSound()}
2784
+ disabled={!notificationsEnabled() || !nativeEnabled()}
2785
+ onChange={(e) => {
2786
+ setNativeSound(e.currentTarget.checked)
2787
+ void saveNotificationSettings()
2788
+ }}
2789
+ style="accent-color:#5ac8fa;cursor:pointer;margin:0"
2790
+ />
2791
+ со звуком
2792
+ </label>
2793
+ <div style="font-size:11px;color:#8e8e93">
2794
+ Windows Toast, macOS Notification Center, Linux notify-send. Без внешних зависимостей.
2795
+ </div>
2796
+ </div>
2797
+
2798
+ {/* Тихие часы (Спринт 25) */}
2799
+ <div style="border-top:1px solid #333;padding-top:10px;display:flex;flex-direction:column;gap:8px">
2800
+ <label style={`display:flex;align-items:center;gap:8px;font-size:12px;cursor:pointer;opacity:${notificationsEnabled() ? 1 : 0.5}`}>
2801
+ <input
2802
+ type="checkbox"
2803
+ checked={quietEnabled()}
2804
+ disabled={!notificationsEnabled()}
2805
+ onChange={(e) => {
2806
+ setQuietEnabled(e.currentTarget.checked)
2807
+ void saveNotificationSettings()
2808
+ }}
2809
+ style="accent-color:#5ac8fa;cursor:pointer;margin:0"
2810
+ />
2811
+ Тихие часы
2812
+ </label>
2813
+ <div style={`display:flex;align-items:center;gap:8px;flex-wrap:wrap;font-size:12px;color:#b0b0b0;opacity:${notificationsEnabled() && quietEnabled() ? 1 : 0.5}`}>
2814
+ <span>с</span>
2815
+ <input
2816
+ type="time"
2817
+ value={quietFrom()}
2818
+ disabled={!notificationsEnabled() || !quietEnabled()}
2819
+ onInput={(e) => setQuietFrom(e.currentTarget.value)}
2820
+ onChange={() => void saveNotificationSettings()}
2821
+ style="padding:4px 6px;background:#1e1e1e;border:1px solid #333;border-radius:4px;color:#fff;font-size:12px;outline:none"
2822
+ />
2823
+ <span>до</span>
2824
+ <input
2825
+ type="time"
2826
+ value={quietTo()}
2827
+ disabled={!notificationsEnabled() || !quietEnabled()}
2828
+ onInput={(e) => setQuietTo(e.currentTarget.value)}
2829
+ onChange={() => void saveNotificationSettings()}
2830
+ style="padding:4px 6px;background:#1e1e1e;border:1px solid #333;border-radius:4px;color:#fff;font-size:12px;outline:none"
2831
+ />
2832
+ </div>
2833
+ <div style="font-size:11px;color:#8e8e93">
2834
+ В тихие часы success и partial подавляются, ошибки и таймауты отправляются.
2835
+ </div>
2836
+ </div>
2837
+
2502
2838
  {/* Фильтры по задачам (Спринт 20) */}
2503
2839
  <div style="border-top:1px solid #333;padding-top:10px;display:flex;flex-direction:column;gap:8px">
2504
2840
  <div style="font-size:12px;color:#e0e0e0;font-weight:600">Фильтры по задачам</div>
@@ -2547,10 +2883,69 @@ export default Plugin.define({
2547
2883
  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
2884
  />
2549
2885
  <div style="font-size:11px;color:#8e8e93">
2550
- Плейсхолдеры: {"{task} {status} {duration} {error} {emoji}"}. Пусто = шаблон по умолчанию.
2886
+ Плейсхолдеры: {"{task} {status} {duration} {error} {emoji} {cost} {tokens}"}. Пусто = шаблон по умолчанию.
2551
2887
  </div>
2552
2888
  </div>
2553
2889
 
2890
+ {/* 🔐 Секреты (Спринт 26) */}
2891
+ <div style="width:100%;max-width:700px;box-sizing:border-box;margin-top:8px;background:#1e1e1e;border:1px solid #333;border-radius:10px;overflow:hidden">
2892
+ <div style="display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 14px">
2893
+ <span style="font-size:12px;font-weight:600;color:#e0e0e0">🔐 Секреты</span>
2894
+ <span style="font-size:11px;color:#8e8e93">{secretsList().length}</span>
2895
+ </div>
2896
+ <div style="padding:0 14px 14px;display:flex;flex-direction:column;gap:10px">
2897
+ <div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap">
2898
+ <input
2899
+ type="text"
2900
+ value={secretName()}
2901
+ placeholder="Имя секрета (A-Za-z0-9_.-)"
2902
+ onInput={(e) => setSecretName(e.currentTarget.value)}
2903
+ style="width:220px;padding:4px 6px;background:#1e1e1e;border:1px solid #333;border-radius:4px;color:#fff;font-size:12px;outline:none"
2904
+ />
2905
+ <input
2906
+ type="password"
2907
+ autocomplete="new-password"
2908
+ value={secretValue()}
2909
+ placeholder="Значение (не возвращается при чтении)"
2910
+ onInput={(e) => setSecretValue(e.currentTarget.value)}
2911
+ style="width:320px;padding:4px 6px;background:#1e1e1e;border:1px solid #333;border-radius:4px;color:#fff;font-size:12px;outline:none"
2912
+ />
2913
+ <button
2914
+ onClick={() => void handleSaveSecret()}
2915
+ disabled={secretsBusy() || !secretName().trim() || !secretValue()}
2916
+ style={secretsBusy() || !secretName().trim() || !secretValue()
2917
+ ? "padding:6px 12px;background:#666;color:white;border:none;border-radius:6px;cursor:not-allowed;font-size:12px;font-weight:500;opacity:0.6"
2918
+ : "padding:6px 12px;background:#007acc;color:white;border:none;border-radius:6px;cursor:pointer;font-size:12px;font-weight:500;opacity:1"}
2919
+ >
2920
+ {secretsBusy() ? "Сохранение..." : "💾 Сохранить"}
2921
+ </button>
2922
+ </div>
2923
+ <div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap;overflow:auto">
2924
+ {secretsList().map((item) => (
2925
+ <span
2926
+ key={item.name}
2927
+ style="display:flex;align-items:center;gap:6px;padding:4px 8px;background:#252526;border:1px solid #333;border-radius:4px;font-size:11px;color:#e0e0e0"
2928
+ >
2929
+ <span style="font-weight:600;color:#569cd6">{item.name}</span>
2930
+ <span style="color:#ce9178">•••• {item.preview}</span>
2931
+ <button
2932
+ onClick={() => void handleDeleteSecret(item.name)}
2933
+ title="Удалить"
2934
+ style="padding:2px 6px;background:#c43b2b;color:white;border:none;border-radius:3px;cursor:pointer;font-size:10px;font-weight:600;line-height:1"
2935
+ >
2936
+ ×
2937
+ </button>
2938
+ </span>
2939
+ ))}
2940
+ {secretsList().length === 0 && (
2941
+ <span style="font-size:11px;color:#8e8e93">Секретов нет. Значения хранятся зашифрованно в secrets.json.</span>
2942
+ )}
2943
+ </div>
2944
+ <div style="font-size:11px;color:#8e8e93">
2945
+ В задачах используйте ссылку <code style="color:#dcdcaa">${"{secret:NAME}"}</code> — значение подставляется из хранилища при запуске и маскируется в логах.
2946
+ </div>
2947
+ </div>
2948
+ </div>
2554
2949
  {/* Уведомления о матрицах (Спринт 20) */}
2555
2950
  <div style="border-top:1px solid #333;padding-top:10px;display:flex;flex-direction:column;gap:8px">
2556
2951
  <div style="font-size:12px;color:#e0e0e0;font-weight:600">Матрицы</div>
@@ -2662,20 +3057,20 @@ export default Plugin.define({
2662
3057
  <div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap">
2663
3058
  <button
2664
3059
  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}`}
3060
+ disabled={testNotificationBusy() || !(webhookEnabled() || telegramEnabled() || nativeEnabled())}
3061
+ 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
3062
  >
2668
3063
  {testNotificationBusy() ? "Отправка..." : "🧪 Тестовое уведомление"}
2669
3064
  </button>
2670
3065
  <button
2671
3066
  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}`}
3067
+ disabled={digestBusy() || !(webhookEnabled() || telegramEnabled() || nativeEnabled())}
3068
+ 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
3069
  >
2675
3070
  {digestBusy() ? "Отправка..." : "📊 Отправить дайджест сейчас"}
2676
3071
  </button>
2677
3072
  <span style="font-size:11px;color:#8e8e93">
2678
- ntfy.sh не используется — только webhook.
3073
+ Каналы: webhook, Telegram, нативные уведомления ОС.
2679
3074
  </span>
2680
3075
  </div>
2681
3076
  </div>
@@ -2750,6 +3145,148 @@ export default Plugin.define({
2750
3145
  )}
2751
3146
  </div>
2752
3147
 
3148
+ {/* 📜 Журнал аудита (Спринт 26) */}
3149
+ <div style="width:100%;max-width:900px;box-sizing:border-box;margin-top:8px;background:#1e1e1e;border:1px solid #333;border-radius:10px;overflow:hidden">
3150
+ <div style="display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 14px">
3151
+ <button
3152
+ onClick={() => setAuditCollapsed(!auditCollapsed())}
3153
+ style="display:flex;align-items:center;gap:8px;background:transparent;border:none;color:#e0e0e0;font-size:12px;font-weight:600;cursor:pointer;text-align:left;padding:0"
3154
+ >
3155
+ <span>📜 Журнал аудита</span>
3156
+ <span style="font-size:11px;font-weight:400;color:#8e8e93">{auditRecords().length}</span>
3157
+ <span style="font-size:11px;color:#8e8e93">{auditCollapsed() ? "▾" : "▴"}</span>
3158
+ </button>
3159
+ </div>
3160
+
3161
+ {!auditCollapsed() && (
3162
+ <div style="padding:0 14px 14px;display:flex;flex-direction:column;gap:10px">
3163
+ <div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap">
3164
+ <label style="font-size:12px;color:#e0e0e0;white-space:nowrap">Действие</label>
3165
+ <input
3166
+ type="text"
3167
+ value={auditFilterAction()}
3168
+ placeholder="например task.create"
3169
+ onInput={(e) => setAuditFilterAction(e.currentTarget.value)}
3170
+ onChange={() => void loadAuditGui()}
3171
+ style="width:150px;padding:4px 6px;background:#1e1e1e;border:1px solid #333;border-radius:4px;color:#fff;font-size:12px;outline:none"
3172
+ />
3173
+ <label style="font-size:12px;color:#e0e0e0;white-space:nowrap">Источник</label>
3174
+ <input
3175
+ type="text"
3176
+ value={auditFilterActor()}
3177
+ placeholder="mcp/gui/http"
3178
+ onInput={(e) => setAuditFilterActor(e.currentTarget.value)}
3179
+ onChange={() => void loadAuditGui()}
3180
+ style="width:110px;padding:4px 6px;background:#1e1e1e;border:1px solid #333;border-radius:4px;color:#fff;font-size:12px;outline:none"
3181
+ />
3182
+ <label style="font-size:12px;color:#e0e0e0;white-space:nowrap">Цель</label>
3183
+ <input
3184
+ type="text"
3185
+ value={auditFilterTarget()}
3186
+ placeholder="имя задачи/секрета"
3187
+ onInput={(e) => setAuditFilterTarget(e.currentTarget.value)}
3188
+ onChange={() => void loadAuditGui()}
3189
+ style="width:180px;padding:4px 6px;background:#1e1e1e;border:1px solid #333;border-radius:4px;color:#fff;font-size:12px;outline:none"
3190
+ />
3191
+ <button
3192
+ onClick={() => void loadAuditGui()}
3193
+ disabled={auditBusy()}
3194
+ style={auditBusy()
3195
+ ? "padding:6px 12px;background:#666;color:white;border:none;border-radius:6px;cursor:not-allowed;font-size:12px;font-weight:500;opacity:0.6"
3196
+ : "padding:6px 12px;background:#007acc;color:white;border:none;border-radius:6px;cursor:pointer;font-size:12px;font-weight:500;opacity:1"}
3197
+ >
3198
+ {auditBusy() ? "Загрузка..." : "Обновить"}
3199
+ </button>
3200
+ </div>
3201
+ <div style="width:100%;overflow:auto;border:1px solid #333;border-radius:6px;background:#0f0f0f">
3202
+ <table style="width:100%;border-collapse:collapse;font-size:11px">
3203
+ <thead>
3204
+ <tr style="border-bottom:1px solid #333">
3205
+ <th style="text-align:left;padding:6px 8px;color:#8e8e93">Время</th>
3206
+ <th style="text-align:left;padding:6px 8px;color:#8e8e93">Действие</th>
3207
+ <th style="text-align:left;padding:6px 8px;color:#8e8e93">Цель</th>
3208
+ <th style="text-align:left;padding:6px 8px;color:#8e8e93">Источник</th>
3209
+ <th style="text-align:left;padding:6px 8px;color:#8e8e93">Автор</th>
3210
+ <th style="text-align:left;padding:6px 8px;color:#8e8e93">Удалён с</th>
3211
+ </tr>
3212
+ </thead>
3213
+ <tbody>
3214
+ {auditRecords().map((r) => (
3215
+ <tr key={r.id} style="border-bottom:1px solid #222">
3216
+ <td style="padding:5px 8px;color:#e0e0e0;white-space:nowrap">{new Date(r.ts).toLocaleString()}</td>
3217
+ <td style="padding:5px 8px;color:#569cd6">{r.action}</td>
3218
+ <td style="padding:5px 8px;color:#e0e0e0;white-space:nowrap">{r.targetType ?? ""}: {r.target ?? "—"}</td>
3219
+ <td style="padding:5px 8px;color:#ce9178">{r.source ?? "—"}</td>
3220
+ <td style="padding:5px 8px;color:#e0e0e0">{r.actor}</td>
3221
+ <td style="padding:5px 8px;color:#8e8e93;white-space:nowrap">{r.remote ?? "—"}</td>
3222
+ </tr>
3223
+ ))}
3224
+ {auditRecords().length === 0 && (
3225
+ <tr>
3226
+ <td colspan="6" style="padding:10px 8px;color:#8e8e93;text-align:center">Записей аудита нет.</td>
3227
+ </tr>
3228
+ )}
3229
+ </tbody>
3230
+ </table>
3231
+ </div>
3232
+ <div style="font-size:11px;color:#8e8e93">
3233
+ Записываются мутации задач, настроек, шаблонов, профилей, рабочих зон, секретов, импорта и очистки истории. Детали маскируются (секреты заменены на <code style="color:#dcdcaa">***</code>).
3234
+ </div>
3235
+ </div>
3236
+ )}
3237
+ </div>
3238
+
3239
+ {/* 🧹 Настройки аудита (ретеншн) */}
3240
+ <div style="width:100%;max-width:700px;box-sizing:border-box;margin-top:8px;background:#1e1e1e;border:1px solid #333;border-radius:10px;overflow:hidden">
3241
+ <div style="display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 14px">
3242
+ <span style="font-size:12px;font-weight:600;color:#e0e0e0">Журнал аудита — хранение</span>
3243
+ </div>
3244
+ <div style="padding:0 14px 14px;display:flex;flex-direction:column;gap:10px">
3245
+ <div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap">
3246
+ <label style="display:flex;align-items:center;gap:6px;font-size:12px;cursor:pointer">
3247
+ <input
3248
+ type="checkbox"
3249
+ checked={auditRetentionEnabled()}
3250
+ onChange={(e) => {
3251
+ setAuditRetentionEnabled(e.currentTarget.checked)
3252
+ void saveAuditSettings()
3253
+ }}
3254
+ style="accent-color:#5ac8fa;cursor:pointer;margin:0"
3255
+ />
3256
+ Включить аудит
3257
+ </label>
3258
+ </div>
3259
+ <div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap">
3260
+ <label style="font-size:12px;color:#e0e0e0;white-space:nowrap">Удалять записи старше, дней</label>
3261
+ <input
3262
+ type="number"
3263
+ min="0"
3264
+ value={auditRetentionDays()}
3265
+ onChange={(e) => {
3266
+ setAuditRetentionDays(Math.max(0, Math.floor(Number(e.currentTarget.value) || 0)))
3267
+ void saveAuditSettings()
3268
+ }}
3269
+ style="width:80px;padding:4px 6px;background:#1e1e1e;border:1px solid #333;border-radius:4px;color:#fff;font-size:12px;outline:none"
3270
+ />
3271
+ <span style="font-size:11px;color:#8e8e93">0 = не удалять по возрасту</span>
3272
+ </div>
3273
+ <div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap">
3274
+ <label style="font-size:12px;color:#e0e0e0;white-space:nowrap">Хранить не более записей</label>
3275
+ <input
3276
+ type="number"
3277
+ min="0"
3278
+ value={auditMaxRecords()}
3279
+ onChange={(e) => {
3280
+ setAuditMaxRecords(Math.max(0, Math.floor(Number(e.currentTarget.value) || 0)))
3281
+ void saveAuditSettings()
3282
+ }}
3283
+ style="width:80px;padding:4px 6px;background:#1e1e1e;border:1px solid #333;border-radius:4px;color:#fff;font-size:12px;outline:none"
3284
+ />
3285
+ <span style="font-size:11px;color:#8e8e93">0 = без ограничения</span>
3286
+ </div>
3287
+ </div>
3288
+ </div>
3289
+
2753
3290
  {/* 📦 Multi-repo workspaces */}
2754
3291
  <div style="width:100%;max-width:700px;box-sizing:border-box;background:#1e1e1e;border:1px solid #333;border-radius:10px;overflow:hidden">
2755
3292
  <div style="display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 14px">