opencode-windows-scheduler 1.5.1 → 1.5.4

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 (80) hide show
  1. package/CHANGELOG.md +56 -1
  2. package/LICENSE +21 -21
  3. package/README.md +3 -2
  4. package/ROADMAP-STRATEGY.md +5 -4
  5. package/ROADMAP.md +502 -103
  6. package/dist/core/audit.d.ts +27 -0
  7. package/dist/core/audit.d.ts.map +1 -1
  8. package/dist/core/audit.js +60 -0
  9. package/dist/core/local-ai.d.ts +52 -0
  10. package/dist/core/local-ai.d.ts.map +1 -0
  11. package/dist/core/local-ai.js +119 -0
  12. package/dist/core/ps-wrapper.d.ts +2 -30
  13. package/dist/core/ps-wrapper.d.ts.map +1 -1
  14. package/dist/core/ps-wrapper.js +258 -49
  15. package/dist/core/secrets.d.ts +10 -3
  16. package/dist/core/secrets.d.ts.map +1 -1
  17. package/dist/core/secrets.js +28 -4
  18. package/dist/core/triage-chain.d.ts +34 -0
  19. package/dist/core/triage-chain.d.ts.map +1 -0
  20. package/dist/core/triage-chain.js +70 -0
  21. package/dist/core/triage-rules.d.ts +23 -0
  22. package/dist/core/triage-rules.d.ts.map +1 -0
  23. package/dist/core/triage-rules.js +174 -0
  24. package/dist/core/triage-shadow.d.ts +47 -0
  25. package/dist/core/triage-shadow.d.ts.map +1 -0
  26. package/dist/core/triage-shadow.js +48 -0
  27. package/dist/core/triage.d.ts +76 -0
  28. package/dist/core/triage.d.ts.map +1 -0
  29. package/dist/core/triage.js +271 -0
  30. package/dist/core/wrappers/bash.d.ts +1 -0
  31. package/dist/core/wrappers/bash.d.ts.map +1 -1
  32. package/dist/core/wrappers/bash.js +91 -5
  33. package/dist/gui-experimental.cjs +1 -0
  34. package/dist/i18n.d.ts.map +1 -1
  35. package/dist/i18n.js +34 -7
  36. package/dist/index.d.ts +27 -0
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +194 -6
  39. package/dist/notifications.d.ts.map +1 -1
  40. package/dist/notifications.js +9 -1
  41. package/dist/rpc.d.ts +259 -0
  42. package/dist/rpc.d.ts.map +1 -1
  43. package/dist/rpc.js +58 -0
  44. package/dist/settings.d.ts +80 -0
  45. package/dist/settings.d.ts.map +1 -1
  46. package/dist/settings.js +199 -0
  47. package/dist/workspaces.d.ts +2 -2
  48. package/dist/workspaces.d.ts.map +1 -1
  49. package/dist/workspaces.js +6 -4
  50. package/docs/ARCHITECTURE.md +69 -10
  51. package/docs/FEATURES.md +37 -7
  52. package/docs/LOCAL-AI.md +202 -0
  53. package/docs/MIGRATION.md +17 -0
  54. package/docs/README.ru.md +5 -4
  55. package/docs/spikes/local-model-structured-output.md +81 -0
  56. package/docs/spikes/ollama-qwen3-4b-smoke.json +28 -0
  57. package/docs/spikes/ollama-qwen3-4b.json +163 -0
  58. package/gui-experimental.cjs +8 -8
  59. package/locales/en.json +32 -0
  60. package/locales/ru.json +32 -0
  61. package/package.json +9 -2
  62. package/scripts/bench-local.mjs +321 -0
  63. package/scripts/spike-local-structured.mjs +182 -0
  64. package/skills/scheduled-job-best-practices/references/recipes.md +40 -0
  65. package/src/core/audit.ts +89 -0
  66. package/src/core/local-ai.ts +173 -0
  67. package/src/core/ps-wrapper.ts +265 -48
  68. package/src/core/secrets.ts +34 -10
  69. package/src/core/triage-chain.ts +116 -0
  70. package/src/core/triage-rules.ts +215 -0
  71. package/src/core/triage-shadow.ts +96 -0
  72. package/src/core/triage.ts +366 -0
  73. package/src/core/wrappers/bash.ts +112 -5
  74. package/src/gui.tsx +4761 -4533
  75. package/src/i18n.ts +32 -9
  76. package/src/index.ts +239 -4
  77. package/src/notifications.ts +16 -0
  78. package/src/rpc.ts +58 -0
  79. package/src/settings.ts +318 -0
  80. package/src/workspaces.ts +9 -4
package/src/i18n.ts CHANGED
@@ -28,15 +28,26 @@ export const SUPPORTED_LOCALES: readonly Locale[] = ["ru", "en"];
28
28
  /** Русский остаётся локалью по умолчанию (см. ROADMAP, спринт 28). */
29
29
  export const DEFAULT_LOCALE: Locale = "ru";
30
30
 
31
- /** Каталог модуля: `src/` при запуске из исходников, `dist/` из сборки. */
32
- const MODULE_DIR = path.dirname(fileURLToPath(import.meta.url));
31
+ /**
32
+ * Каталог модуля: `src/` при запуске из исходников, `dist/` из сборки.
33
+ *
34
+ * В GUI-бандле (renderer Electron/webview) нет ни `import.meta.url` с реальным
35
+ * путём к пакету, ни `process`; любой бросок на этапе загрузки модуля валит
36
+ * весь плагин, поэтому путь вычисляется лениво и молча.
37
+ */
38
+ function moduleDir(): string | null {
39
+ try {
40
+ return path.dirname(fileURLToPath(import.meta.url));
41
+ } catch {
42
+ return null;
43
+ }
44
+ }
33
45
 
34
46
  /** Каталоги, где может лежать `locales/` (оба варианта дают корень пакета). */
35
47
  function candidateCatalogDirs(): string[] {
36
- return [
37
- path.resolve(MODULE_DIR, "../locales"),
38
- path.resolve(MODULE_DIR, "locales"),
39
- ];
48
+ const dir = moduleDir();
49
+ if (!dir) return [];
50
+ return [path.resolve(dir, "../locales"), path.resolve(dir, "locales")];
40
51
  }
41
52
 
42
53
  const catalogs = new Map<Locale, Record<string, string>>();
@@ -45,10 +56,22 @@ const pluralRules = new Map<Locale, Intl.PluralRules>();
45
56
  /**
46
57
  * Локаль запуска: `OPENCODE_SCHEDULER_LOCALE=en` позволяет прогнать набор
47
58
  * тестов на английском без правки настроек. Не задана — русский.
59
+ *
60
+ * `process` отсутствует в GUI-бандле (renderer), поэтому обращение к нему
61
+ * защищено: иначе `ReferenceError: process is not defined` ломает загрузку
62
+ * всего плагина ещё до регистрации панели.
48
63
  */
49
- const INITIAL_LOCALE: Locale = normalizeLocale(
50
- process.env.OPENCODE_SCHEDULER_LOCALE
51
- );
64
+ function envLocale(): string | undefined {
65
+ try {
66
+ return typeof process !== "undefined" && process.env
67
+ ? process.env.OPENCODE_SCHEDULER_LOCALE
68
+ : undefined;
69
+ } catch {
70
+ return undefined;
71
+ }
72
+ }
73
+
74
+ const INITIAL_LOCALE: Locale = normalizeLocale(envLocale());
52
75
 
53
76
  let currentLocale: Locale = INITIAL_LOCALE;
54
77
 
package/src/index.ts CHANGED
@@ -46,13 +46,14 @@ import {
46
46
  } from "./core/matrix.js";
47
47
  import { SchedulerRpc } from "./rpc.js";
48
48
  import { latestHistoryByTask, loadHistory, loadMetrics } from "./history.js";
49
- import { loadSettings, saveSettings } from "./settings.js";
49
+ import { defaultNotifications, loadSettings, saveSettings } from "./settings.js";
50
50
  import { setLocale, t, type Locale } from "./i18n.js";
51
51
  import type {
52
52
  AuditSettings,
53
53
  HistorySettings,
54
54
  IntegrationSettings,
55
55
  NotificationSettings,
56
+ TriageSettings,
56
57
  } from "./settings.js";
57
58
  import { runHistoryRetention, maybeRunHistoryRetention } from "./core/retention.js";
58
59
  import { buildAnalytics } from "./core/analytics.js";
@@ -65,6 +66,12 @@ import {
65
66
  sendDigestNow,
66
67
  sendTestNotification,
67
68
  } from "./notifications.js";
69
+ import {
70
+ shadowReport,
71
+ resetShadowDecisions,
72
+ } from "./core/triage-shadow.js";
73
+ import { applyLocalAiPatch, summarizeLocalAi, type LocalAiPatch } from "./core/local-ai.js";
74
+ import { classifyNotification, type TriageInput } from "./core/triage.js";
68
75
  import {
69
76
  loadTaskDefinitions,
70
77
  saveTaskDefinition,
@@ -112,6 +119,7 @@ import {
112
119
  } from "./workspaces.js";
113
120
  import {
114
121
  deleteSecret,
122
+ collectSecretNames,
115
123
  hasSecret,
116
124
  listSecrets,
117
125
  setSecret,
@@ -120,6 +128,7 @@ import {
120
128
  cleanupAuditLog,
121
129
  readAuditLog,
122
130
  recordAudit,
131
+ recordTaskToolBlocks,
123
132
  } from "./core/audit.js";
124
133
  import type { AuditEntryInput } from "./core/audit.js";
125
134
 
@@ -828,6 +837,64 @@ export const manageSettingsSchema = z.object({
828
837
  .describe("Audit log settings patch (enabled, retentionDays, maxRecords)."),
829
838
  });
830
839
 
840
+ /** manage_local_ai — настройки локального ассистента и триажа (Спринт 30.7). */
841
+ export const manageLocalAiSchema = z.object({
842
+ action: z
843
+ .enum(["get", "update", "test"])
844
+ .describe(
845
+ "get — current triage settings and shadow state; update — merge fields and save; test — one classification request against the configured model."
846
+ ),
847
+ mode: z
848
+ .enum(["off", "rules", "llm", "auto"])
849
+ .optional()
850
+ .describe(
851
+ "off — no triage; rules — built-in rules only; llm — model only; auto — model, then rules (default)."
852
+ ),
853
+ baseUrl: z
854
+ .string()
855
+ .max(500)
856
+ .optional()
857
+ .describe(
858
+ "Ollama or OpenAI-compatible base URL, for example http://127.0.0.1:11434. A URL ending with /v1 switches to the OpenAI protocol."
859
+ ),
860
+ model: z
861
+ .string()
862
+ .max(200)
863
+ .optional()
864
+ .describe("Model id, for example qwen3:4b."),
865
+ timeoutMs: z
866
+ .number()
867
+ .int()
868
+ .min(1000)
869
+ .max(120000)
870
+ .optional()
871
+ .describe("Request timeout in milliseconds (1000..120000)."),
872
+ fallback: z
873
+ .enum(["rules", "skip"])
874
+ .optional()
875
+ .describe(
876
+ "When the model fails or is unsure: rules — apply rules (fail-open, default); skip — no rules, the notification is delivered."
877
+ ),
878
+ confidenceThreshold: z
879
+ .number()
880
+ .min(0)
881
+ .max(1)
882
+ .optional()
883
+ .describe("Minimum model confidence (0..1); below it the fallback applies."),
884
+ shadow: z
885
+ .object({
886
+ enabled: z.boolean().optional().describe("Log decisions without suppressing notifications."),
887
+ days: z.number().int().min(1).max(365).optional().describe("Shadow period length in days."),
888
+ startedAt: z
889
+ .string()
890
+ .nullable()
891
+ .optional()
892
+ .describe("ISO start of the shadow period; null restarts it on the next save."),
893
+ })
894
+ .optional()
895
+ .describe("Shadow mode patch."),
896
+ });
897
+
831
898
  /** manage_templates — пользовательские шаблоны задач. */
832
899
  export const manageTemplatesSchema = z.object({
833
900
  action: z
@@ -943,6 +1010,7 @@ type MatrixControlArgs = z.infer<typeof matrixControlSchema>;
943
1010
  type MetricsArgs = z.infer<typeof getMetricsSchema>;
944
1011
  type AnalyticsArgs = z.infer<typeof getAnalyticsSchema>;
945
1012
  type SettingsArgs = z.infer<typeof manageSettingsSchema>;
1013
+ type LocalAiArgs = z.infer<typeof manageLocalAiSchema>;
946
1014
  type TemplatesArgs = z.infer<typeof manageTemplatesSchema>;
947
1015
  type ProfilesArgs = z.infer<typeof manageProfilesSchema>;
948
1016
  type TransferArgs = z.infer<typeof transferTasksSchema>;
@@ -2521,6 +2589,106 @@ const manageSettingsExecute = wrapExecute<SettingsArgs>(async (args) => {
2521
2589
  return { content: JSON.stringify({ success: true, settings }) };
2522
2590
  });
2523
2591
 
2592
+ /** Настройки триажа: сохранённые или дефолт для незаполненного конфига. */
2593
+ function triageOrDefault(settings: Awaited<ReturnType<typeof loadSettings>>): TriageSettings {
2594
+ const saved = settings.notifications.triage;
2595
+ if (saved) return saved;
2596
+ const fallback = defaultNotifications().triage;
2597
+ return (
2598
+ fallback ?? {
2599
+ mode: "off",
2600
+ baseUrl: "http://127.0.0.1:11434",
2601
+ model: "",
2602
+ timeoutMs: 45_000,
2603
+ fallback: "rules",
2604
+ confidenceThreshold: 0.6,
2605
+ }
2606
+ );
2607
+ }
2608
+
2609
+ /** Синтетическое уведомление для проверки связи с моделью. */
2610
+ const LOCAL_AI_SELF_TEST: TriageInput = {
2611
+ taskName: "scheduler-self-test",
2612
+ status: "error",
2613
+ error: "Quality Gate failed: 2 tests broke the build",
2614
+ durationMs: 12_000,
2615
+ };
2616
+
2617
+ /** Один классификационный запрос — общий путь для инструмента и GUI. */
2618
+ async function runLocalAiTest(patch: LocalAiPatch = {}) {
2619
+ const settings = await loadSettings();
2620
+ const { settings: candidate } = applyLocalAiPatch(triageOrDefault(settings), patch);
2621
+ const result = await classifyNotification(LOCAL_AI_SELF_TEST, candidate, { retries: 0 });
2622
+ return {
2623
+ success: result.ok,
2624
+ localAi: summarizeLocalAi(candidate),
2625
+ result: {
2626
+ ok: result.ok,
2627
+ failure: result.failure ?? null,
2628
+ error: result.error ?? null,
2629
+ latencyMs: result.latencyMs,
2630
+ attempts: result.attempts,
2631
+ model: result.model,
2632
+ protocol: result.protocol,
2633
+ verdict: result.verdict ?? null,
2634
+ },
2635
+ };
2636
+ }
2637
+
2638
+ /** manage_local_ai — настройки триажа и проверка связи с моделью. */
2639
+ const manageLocalAiExecute = wrapExecute<LocalAiArgs>(async (args) => {
2640
+ const settings = await loadSettings();
2641
+ const current = triageOrDefault(settings);
2642
+
2643
+ if (args.action === "get") {
2644
+ return {
2645
+ content: JSON.stringify({ success: true, localAi: summarizeLocalAi(current) }),
2646
+ };
2647
+ }
2648
+
2649
+ const patch: LocalAiPatch = {
2650
+ mode: args.mode,
2651
+ baseUrl: args.baseUrl,
2652
+ model: args.model,
2653
+ timeoutMs: args.timeoutMs,
2654
+ fallback: args.fallback,
2655
+ confidenceThreshold: args.confidenceThreshold,
2656
+ shadow: args.shadow,
2657
+ };
2658
+
2659
+ if (args.action === "test") {
2660
+ // Проверка не меняет конфиг: патч применяется только в памяти.
2661
+ return { content: JSON.stringify(await runLocalAiTest(patch)) };
2662
+ }
2663
+
2664
+ if (!Object.values(patch).some((value) => value !== undefined)) {
2665
+ return {
2666
+ content: JSON.stringify({
2667
+ success: false,
2668
+ error: t("tool.localAi.updateFields"),
2669
+ localAi: summarizeLocalAi(current),
2670
+ }),
2671
+ };
2672
+ }
2673
+
2674
+ const { settings: merged, changed } = applyLocalAiPatch(current, patch);
2675
+ const saved = await saveSettings({
2676
+ notifications: { ...settings.notifications, triage: merged },
2677
+ });
2678
+ const localAi = summarizeLocalAi(triageOrDefault(saved));
2679
+ return {
2680
+ content: JSON.stringify({
2681
+ success: true,
2682
+ changed,
2683
+ message:
2684
+ changed.length > 0
2685
+ ? t("tool.localAi.updated", { fields: changed.join(", ") })
2686
+ : t("tool.localAi.unchanged"),
2687
+ localAi,
2688
+ }),
2689
+ };
2690
+ });
2691
+
2524
2692
  /** manage_templates — список, сохранение и удаление шаблонов задач. */
2525
2693
  const manageTemplatesExecute = wrapExecute<TemplatesArgs>(async (args) => {
2526
2694
  if (args.action === "list") {
@@ -3468,6 +3636,24 @@ export default Plugin.define({
3468
3636
  ) as any,
3469
3637
  });
3470
3638
 
3639
+ editor.add({
3640
+ name: "manage_local_ai",
3641
+ input: manageLocalAiSchema,
3642
+ description:
3643
+ "Reads, updates or tests the local assistant for notification triage: mode (off, rules, llm, auto), Ollama/OpenAI baseUrl, model, timeout, fallback, confidence threshold and shadow mode. " +
3644
+ "action=test sends one synthetic notification to the model and reports latency, protocol and verdict without saving anything. " +
3645
+ "Without a model the scheduler keeps working through rules: notifications are never blocked by a missing model.",
3646
+ options: { codemode: true },
3647
+ execute: withAudit<LocalAiArgs>(
3648
+ "manage_local_ai",
3649
+ (args) =>
3650
+ args.action === "update"
3651
+ ? { action: "localAi.update", targetType: "settings", target: "triage" }
3652
+ : null,
3653
+ manageLocalAiExecute as any
3654
+ ) as any,
3655
+ });
3656
+
3471
3657
  editor.add({
3472
3658
  name: "manage_templates",
3473
3659
  input: manageTemplatesSchema,
@@ -4346,6 +4532,38 @@ export default Plugin.define({
4346
4532
  return await sendDigestNow({ updateLastSentAt: false });
4347
4533
  },
4348
4534
 
4535
+ // --- Спринт 30.6: shadow-режим триажа ---------------------------------
4536
+ get_shadow_report: async () => {
4537
+ const settings = await loadSettings();
4538
+ const shadow = shadowReport(settings.notifications.triage?.shadow);
4539
+ return {
4540
+ success: true,
4541
+ active: shadow.active,
4542
+ startedAt: shadow.startedAt,
4543
+ days: shadow.days,
4544
+ total: shadow.total,
4545
+ skips: shadow.skips,
4546
+ wouldSuppress: shadow.wouldSuppress,
4547
+ bySource: shadow.bySource,
4548
+ };
4549
+ },
4550
+ reset_shadow_report: async () => {
4551
+ resetShadowDecisions();
4552
+ return { success: true };
4553
+ },
4554
+ test_local_ai: async (input: unknown) => {
4555
+ // Проверка связи: патч применяется только в памяти, конфиг не меняется.
4556
+ const patch = (input ?? {}) as LocalAiPatch;
4557
+ return await runLocalAiTest({
4558
+ mode: patch.mode,
4559
+ baseUrl: patch.baseUrl,
4560
+ model: patch.model,
4561
+ timeoutMs: patch.timeoutMs,
4562
+ fallback: patch.fallback,
4563
+ confidenceThreshold: patch.confidenceThreshold,
4564
+ });
4565
+ },
4566
+
4349
4567
  // --- Спринт 26: секреты и аудит -------------------------------------
4350
4568
  list_secrets: async () => {
4351
4569
  return { success: true, secrets: listSecrets() };
@@ -5029,8 +5247,19 @@ async function schedulerCreateTask(
5029
5247
  workspace?.path || workingDirectory?.trim() || projectDirectory || process.cwd();
5030
5248
 
5031
5249
  // Спринт 21: env-переменные workspace → отдельный файл, который читает обёртка.
5032
- // Значения не логируются; в лог попадает только факт загрузки.
5033
- const taskEnvFile = writeWorkspaceEnvFile(workspace, PLUGIN_DIR, sanitized);
5250
+ // Спринт 29.3: инжектит в env только реально используемые секреты (scoped-инъекция).
5251
+ const usedSecretNames = collectSecretNames(
5252
+ prompt,
5253
+ beforeScript,
5254
+ afterScript,
5255
+ qualityGate
5256
+ );
5257
+ const taskEnvFile = writeWorkspaceEnvFile(
5258
+ workspace,
5259
+ PLUGIN_DIR,
5260
+ sanitized,
5261
+ usedSecretNames
5262
+ );
5034
5263
  if (taskEnvFile) {
5035
5264
  console.log(`[workspace] Задача "${name}": env-переменные workspace подключены.`);
5036
5265
  }
@@ -5074,7 +5303,9 @@ async function schedulerCreateTask(
5074
5303
  wrapperGate,
5075
5304
  taskEnvFile,
5076
5305
  effectiveSession,
5077
- effectiveSessionId
5306
+ effectiveSessionId,
5307
+ retryCount,
5308
+ retryDelay
5078
5309
  );
5079
5310
  } else {
5080
5311
  wrapperPath = await writeBashWrapper({
@@ -5263,6 +5494,8 @@ async function schedulerCreateTask(
5263
5494
  };
5264
5495
  try {
5265
5496
  await saveTaskDefinition(taskDefinition);
5497
+ // Аудит политики прав: фиксируем, какие инструменты задача блокирует.
5498
+ recordTaskToolBlocks(name, normalizedAllowedTools, normalizedDeniedTools);
5266
5499
  } catch {
5267
5500
  // Не критично — основная задача уже создана.
5268
5501
  }
@@ -5707,6 +5940,8 @@ async function collectTasksView() {
5707
5940
  return {
5708
5941
  name,
5709
5942
  schedule: def?.schedule ?? "",
5943
+ /** Hotfix 1.5.3.1: лимит времени задачи (раньше не был виден агенту). */
5944
+ timeoutSeconds: def?.timeoutSeconds ?? null,
5710
5945
  status,
5711
5946
  orphaned,
5712
5947
  // Спринт 24 (фикс): явный признак паузы. Раньше GUI пытался вывести его
@@ -6,6 +6,7 @@ import {
6
6
  type NotificationFilters,
7
7
  type NotificationSettings,
8
8
  type NotificationTemplates,
9
+ isShadowActive,
9
10
  } from "./settings.js";
10
11
  import {
11
12
  buildAnalytics,
@@ -15,6 +16,7 @@ import {
15
16
  import { getHistory } from "./db/history-repo.js";
16
17
  import { sendTelegramMessage } from "./core/telegram.js";
17
18
  import { sendNativeNotification } from "./core/native-notify.js";
19
+ import { decideTriage, recordShadow } from "./core/triage-chain.js";
18
20
  import { t } from "./i18n.js";
19
21
 
20
22
  /** Статус завершения задачи, который приходит из record-history. */
@@ -485,6 +487,20 @@ export async function notifyTaskCompletion(
485
487
  return;
486
488
  }
487
489
 
490
+ // Триаж может подавить уведомление (LLM → правила → fail-open).
491
+ // В shadow-режиме решение фиксируется, но уведомление не подавляется.
492
+ const shadow = config.triage?.shadow;
493
+ const triage = await decideTriage(
494
+ { taskName, status, error, durationMs, tokens, costUsd },
495
+ config.triage
496
+ );
497
+ recordShadow(
498
+ { taskName, status, error, durationMs, tokens, costUsd },
499
+ triage,
500
+ shadow
501
+ );
502
+ if (!isShadowActive(shadow) && triage.action === "skip") return;
503
+
488
504
  const message = formatNotificationMessage(
489
505
  { taskName, status, durationMs, error, tokens, costUsd },
490
506
  config.templates
package/src/rpc.ts CHANGED
@@ -57,6 +57,8 @@ const TaskItem = {
57
57
  properties: {
58
58
  name: { type: "string" },
59
59
  schedule: { type: "string" },
60
+ /** Hotfix 1.5.3.1: лимит времени задачи в секундах (null - по умолчанию). */
61
+ timeoutSeconds: { type: ["number", "null"] },
60
62
  status: { type: "string" },
61
63
  nextRun: { type: ["string", "null"] },
62
64
  /** LLM-модель задачи (null — модель OpenCode по умолчанию). */
@@ -543,6 +545,62 @@ const NotificationSettingsSchema = {
543
545
  },
544
546
  required: ["enabled", "frequency", "time"],
545
547
  },
548
+ triage: {
549
+ type: "object" as const,
550
+ properties: {
551
+ mode: { type: "string", enum: ["off", "rules", "llm", "auto"] },
552
+ baseUrl: { type: "string" },
553
+ model: { type: "string" },
554
+ timeoutMs: { type: "number" },
555
+ fallback: { type: "string", enum: ["rules", "skip"] },
556
+ confidenceThreshold: { type: "number" },
557
+ rules: {
558
+ type: "array",
559
+ items: {
560
+ type: "object" as const,
561
+ properties: {
562
+ id: { type: "string" },
563
+ field: {
564
+ type: "string",
565
+ enum: ["status", "task", "error", "cost"],
566
+ },
567
+ operator: {
568
+ type: "string",
569
+ enum: ["equals", "contains", "regex", "gt", "lt", "gte", "lte"],
570
+ },
571
+ value: { type: ["string", "number"] },
572
+ category: {
573
+ type: "string",
574
+ enum: ["quality", "timeout", "permission", "network", "unknown"],
575
+ },
576
+ severity: { type: "string", enum: ["low", "medium", "high"] },
577
+ confidence: { type: "number" },
578
+ action: { type: "string", enum: ["notify", "skip"] },
579
+ reason: { type: "string" },
580
+ priority: { type: "number" },
581
+ },
582
+ required: ["field", "operator", "value"],
583
+ },
584
+ },
585
+ shadow: {
586
+ type: "object" as const,
587
+ properties: {
588
+ enabled: { type: "boolean" },
589
+ days: { type: "number" },
590
+ startedAt: { type: ["string", "null"] },
591
+ },
592
+ required: ["enabled", "days", "startedAt"],
593
+ },
594
+ },
595
+ required: [
596
+ "mode",
597
+ "baseUrl",
598
+ "model",
599
+ "timeoutMs",
600
+ "fallback",
601
+ "confidenceThreshold",
602
+ ],
603
+ },
546
604
  },
547
605
  required: ["enabled", "onlyOnError"],
548
606
  } as const;