opencode-windows-scheduler 1.5.2 → 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.
- package/CHANGELOG.md +46 -1
- package/LICENSE +21 -21
- package/README.md +3 -2
- package/ROADMAP-STRATEGY.md +5 -4
- package/ROADMAP.md +251 -72
- package/dist/core/local-ai.d.ts +52 -0
- package/dist/core/local-ai.d.ts.map +1 -0
- package/dist/core/local-ai.js +119 -0
- package/dist/core/ps-wrapper.d.ts +2 -30
- package/dist/core/ps-wrapper.d.ts.map +1 -1
- package/dist/core/ps-wrapper.js +211 -39
- package/dist/core/triage-chain.d.ts +34 -0
- package/dist/core/triage-chain.d.ts.map +1 -0
- package/dist/core/triage-chain.js +70 -0
- package/dist/core/triage-rules.d.ts +23 -0
- package/dist/core/triage-rules.d.ts.map +1 -0
- package/dist/core/triage-rules.js +174 -0
- package/dist/core/triage-shadow.d.ts +47 -0
- package/dist/core/triage-shadow.d.ts.map +1 -0
- package/dist/core/triage-shadow.js +48 -0
- package/dist/core/triage.d.ts +76 -0
- package/dist/core/triage.d.ts.map +1 -0
- package/dist/core/triage.js +271 -0
- package/dist/gui-experimental.cjs +1 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +34 -7
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +187 -2
- package/dist/notifications.d.ts.map +1 -1
- package/dist/notifications.js +9 -1
- package/dist/rpc.d.ts +259 -0
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +58 -0
- package/dist/settings.d.ts +80 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +199 -0
- package/docs/ARCHITECTURE.md +9 -7
- package/docs/FEATURES.md +22 -2
- package/docs/LOCAL-AI.md +202 -0
- package/docs/MIGRATION.md +17 -0
- package/docs/README.ru.md +5 -4
- package/docs/spikes/local-model-structured-output.md +81 -0
- package/docs/spikes/ollama-qwen3-4b-smoke.json +28 -0
- package/docs/spikes/ollama-qwen3-4b.json +163 -0
- package/gui-experimental.cjs +8 -8
- package/locales/en.json +32 -0
- package/locales/ru.json +32 -0
- package/package.json +9 -2
- package/scripts/bench-local.mjs +321 -0
- package/scripts/spike-local-structured.mjs +182 -0
- package/skills/scheduled-job-best-practices/references/recipes.md +40 -0
- package/src/core/local-ai.ts +173 -0
- package/src/core/ps-wrapper.ts +218 -38
- package/src/core/triage-chain.ts +116 -0
- package/src/core/triage-rules.ts +215 -0
- package/src/core/triage-shadow.ts +96 -0
- package/src/core/triage.ts +366 -0
- package/src/gui.tsx +4761 -4533
- package/src/i18n.ts +32 -9
- package/src/index.ts +222 -2
- package/src/notifications.ts +16 -0
- package/src/rpc.ts +58 -0
- package/src/settings.ts +318 -0
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
|
-
/**
|
|
32
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
50
|
-
|
|
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,
|
|
@@ -830,6 +837,64 @@ export const manageSettingsSchema = z.object({
|
|
|
830
837
|
.describe("Audit log settings patch (enabled, retentionDays, maxRecords)."),
|
|
831
838
|
});
|
|
832
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
|
+
|
|
833
898
|
/** manage_templates — пользовательские шаблоны задач. */
|
|
834
899
|
export const manageTemplatesSchema = z.object({
|
|
835
900
|
action: z
|
|
@@ -945,6 +1010,7 @@ type MatrixControlArgs = z.infer<typeof matrixControlSchema>;
|
|
|
945
1010
|
type MetricsArgs = z.infer<typeof getMetricsSchema>;
|
|
946
1011
|
type AnalyticsArgs = z.infer<typeof getAnalyticsSchema>;
|
|
947
1012
|
type SettingsArgs = z.infer<typeof manageSettingsSchema>;
|
|
1013
|
+
type LocalAiArgs = z.infer<typeof manageLocalAiSchema>;
|
|
948
1014
|
type TemplatesArgs = z.infer<typeof manageTemplatesSchema>;
|
|
949
1015
|
type ProfilesArgs = z.infer<typeof manageProfilesSchema>;
|
|
950
1016
|
type TransferArgs = z.infer<typeof transferTasksSchema>;
|
|
@@ -2523,6 +2589,106 @@ const manageSettingsExecute = wrapExecute<SettingsArgs>(async (args) => {
|
|
|
2523
2589
|
return { content: JSON.stringify({ success: true, settings }) };
|
|
2524
2590
|
});
|
|
2525
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
|
+
|
|
2526
2692
|
/** manage_templates — список, сохранение и удаление шаблонов задач. */
|
|
2527
2693
|
const manageTemplatesExecute = wrapExecute<TemplatesArgs>(async (args) => {
|
|
2528
2694
|
if (args.action === "list") {
|
|
@@ -3470,6 +3636,24 @@ export default Plugin.define({
|
|
|
3470
3636
|
) as any,
|
|
3471
3637
|
});
|
|
3472
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
|
+
|
|
3473
3657
|
editor.add({
|
|
3474
3658
|
name: "manage_templates",
|
|
3475
3659
|
input: manageTemplatesSchema,
|
|
@@ -4348,6 +4532,38 @@ export default Plugin.define({
|
|
|
4348
4532
|
return await sendDigestNow({ updateLastSentAt: false });
|
|
4349
4533
|
},
|
|
4350
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
|
+
|
|
4351
4567
|
// --- Спринт 26: секреты и аудит -------------------------------------
|
|
4352
4568
|
list_secrets: async () => {
|
|
4353
4569
|
return { success: true, secrets: listSecrets() };
|
|
@@ -5087,7 +5303,9 @@ async function schedulerCreateTask(
|
|
|
5087
5303
|
wrapperGate,
|
|
5088
5304
|
taskEnvFile,
|
|
5089
5305
|
effectiveSession,
|
|
5090
|
-
effectiveSessionId
|
|
5306
|
+
effectiveSessionId,
|
|
5307
|
+
retryCount,
|
|
5308
|
+
retryDelay
|
|
5091
5309
|
);
|
|
5092
5310
|
} else {
|
|
5093
5311
|
wrapperPath = await writeBashWrapper({
|
|
@@ -5722,6 +5940,8 @@ async function collectTasksView() {
|
|
|
5722
5940
|
return {
|
|
5723
5941
|
name,
|
|
5724
5942
|
schedule: def?.schedule ?? "",
|
|
5943
|
+
/** Hotfix 1.5.3.1: лимит времени задачи (раньше не был виден агенту). */
|
|
5944
|
+
timeoutSeconds: def?.timeoutSeconds ?? null,
|
|
5725
5945
|
status,
|
|
5726
5946
|
orphaned,
|
|
5727
5947
|
// Спринт 24 (фикс): явный признак паузы. Раньше GUI пытался вывести его
|
package/src/notifications.ts
CHANGED
|
@@ -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;
|