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.
- package/CHANGELOG.md +61 -2
- package/README.md +21 -4
- package/ROADMAP-STRATEGY.md +61 -159
- package/ROADMAP.md +60 -98
- package/dist/core/audit.d.ts +68 -0
- package/dist/core/audit.d.ts.map +1 -0
- package/dist/core/audit.js +206 -0
- package/dist/core/native-notify.d.ts +36 -0
- package/dist/core/native-notify.d.ts.map +1 -0
- package/dist/core/native-notify.js +110 -0
- package/dist/core/record-history.js +4 -4
- package/dist/core/secrets.d.ts +57 -0
- package/dist/core/secrets.d.ts.map +1 -0
- package/dist/core/secrets.js +331 -0
- package/dist/core/structured-log.d.ts.map +1 -1
- package/dist/core/structured-log.js +9 -0
- package/dist/core/telegram.d.ts +45 -0
- package/dist/core/telegram.d.ts.map +1 -0
- package/dist/core/telegram.js +160 -0
- package/dist/db/schema.d.ts +1 -1
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +15 -0
- package/dist/index.d.ts +30 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +349 -22
- package/dist/notifications.d.ts +26 -6
- package/dist/notifications.d.ts.map +1 -1
- package/dist/notifications.js +191 -34
- package/dist/rpc.d.ts +400 -0
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +146 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +67 -0
- package/dist/settings.d.ts +63 -2
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +126 -2
- package/dist/workspaces.d.ts +8 -2
- package/dist/workspaces.d.ts.map +1 -1
- package/dist/workspaces.js +21 -4
- package/docs/ARCHITECTURE.md +16 -6
- package/docs/FEATURES.md +57 -12
- package/docs/README.ru.md +23 -4
- package/gui-experimental.cjs +4 -4
- package/package.json +5 -2
- package/src/core/audit.ts +291 -0
- package/src/core/native-notify.ts +154 -0
- package/src/core/record-history.ts +6 -4
- package/src/core/secrets.ts +385 -0
- package/src/core/structured-log.ts +9 -0
- package/src/core/telegram.ts +219 -0
- package/src/db/schema.ts +15 -0
- package/src/gui.tsx +543 -6
- package/src/index.ts +459 -22
- package/src/notifications.ts +232 -40
- package/src/rpc.ts +157 -0
- package/src/server.ts +67 -0
- package/src/settings.ts +213 -4
- package/src/workspaces.ts +22 -4
package/src/notifications.ts
CHANGED
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
type ErrorAnalyticsRow,
|
|
14
14
|
} from "./core/analytics.js";
|
|
15
15
|
import { getHistory } from "./db/history-repo.js";
|
|
16
|
+
import { sendTelegramMessage } from "./core/telegram.js";
|
|
17
|
+
import { sendNativeNotification } from "./core/native-notify.js";
|
|
16
18
|
|
|
17
19
|
/** Статус завершения задачи, который приходит из record-history. */
|
|
18
20
|
export type NotificationStatus = "success" | "error" | "timeout" | string;
|
|
@@ -23,6 +25,10 @@ export interface NotificationPayload {
|
|
|
23
25
|
status: NotificationStatus;
|
|
24
26
|
durationMs: number;
|
|
25
27
|
error?: string | null;
|
|
28
|
+
/** Потраченные токены, если известны. */
|
|
29
|
+
tokens?: number | null;
|
|
30
|
+
/** Стоимость запуска в USD, если известна. */
|
|
31
|
+
costUsd?: number | null;
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
/** Таймаут HTTP-запроса по умолчанию: уведомление не должно подвешивать задачу. */
|
|
@@ -95,6 +101,18 @@ export function formatNotificationMessage(
|
|
|
95
101
|
const isSuccess = status === "success";
|
|
96
102
|
const reason =
|
|
97
103
|
typeof error === "string" && error.trim() ? `: ${error.trim()}` : "";
|
|
104
|
+
const tokens =
|
|
105
|
+
typeof payload.tokens === "number" && payload.tokens > 0
|
|
106
|
+
? String(Math.round(payload.tokens))
|
|
107
|
+
: "";
|
|
108
|
+
const cost =
|
|
109
|
+
typeof payload.costUsd === "number" && payload.costUsd > 0
|
|
110
|
+
? `$${payload.costUsd.toFixed(4)}`
|
|
111
|
+
: "";
|
|
112
|
+
const usage = [tokens ? `${tokens} tok` : "", cost].filter(Boolean).join(" · ");
|
|
113
|
+
const usageSuffix = usage ? ` · ${usage}` : "";
|
|
114
|
+
const costVar = usageSuffix;
|
|
115
|
+
const tokensVar = tokens;
|
|
98
116
|
|
|
99
117
|
if (templates && isSuccess && templates.success.trim()) {
|
|
100
118
|
return renderTemplate(templates.success, {
|
|
@@ -103,6 +121,8 @@ export function formatNotificationMessage(
|
|
|
103
121
|
duration,
|
|
104
122
|
error: "",
|
|
105
123
|
emoji: "✅",
|
|
124
|
+
cost: costVar,
|
|
125
|
+
tokens: tokensVar,
|
|
106
126
|
});
|
|
107
127
|
}
|
|
108
128
|
if (templates && !isSuccess && templates.error.trim()) {
|
|
@@ -112,13 +132,15 @@ export function formatNotificationMessage(
|
|
|
112
132
|
duration,
|
|
113
133
|
error: reason,
|
|
114
134
|
emoji: "❌",
|
|
135
|
+
cost: costVar,
|
|
136
|
+
tokens: tokensVar,
|
|
115
137
|
});
|
|
116
138
|
}
|
|
117
139
|
|
|
118
140
|
if (isSuccess) {
|
|
119
|
-
return `✅ Задача "${taskName}" выполнена (${duration})`;
|
|
141
|
+
return `✅ Задача "${taskName}" выполнена (${duration})${usageSuffix}`;
|
|
120
142
|
}
|
|
121
|
-
return `❌ Задача "${taskName}" упала (${duration})${reason}`;
|
|
143
|
+
return `❌ Задача "${taskName}" упала (${duration})${reason}${usageSuffix}`;
|
|
122
144
|
}
|
|
123
145
|
|
|
124
146
|
/** Информация о завершении матрицы для уведомления. */
|
|
@@ -270,22 +292,149 @@ function webhookOptionsFrom(config: NotificationSettings): WebhookOptions {
|
|
|
270
292
|
};
|
|
271
293
|
}
|
|
272
294
|
|
|
273
|
-
/**
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
295
|
+
/** Канал доставки уведомлений. */
|
|
296
|
+
export type NotificationChannel = "webhook" | "telegram" | "native";
|
|
297
|
+
|
|
298
|
+
/** Результат отправки в один канал. */
|
|
299
|
+
export interface ChannelDeliveryResult {
|
|
300
|
+
channel: NotificationChannel;
|
|
301
|
+
ok: boolean;
|
|
302
|
+
error?: string;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Тихие часы: true, если сейчас действует окно `quiet`. Диапазон может
|
|
307
|
+
* переходить через полночь (22:00 → 08:00). Некорректное время — false.
|
|
308
|
+
*/
|
|
309
|
+
export function isQuietHours(
|
|
310
|
+
now: Date,
|
|
311
|
+
quiet?: { enabled?: boolean; from?: string; to?: string } | null
|
|
312
|
+
): boolean {
|
|
313
|
+
if (!quiet?.enabled) return false;
|
|
314
|
+
const parse = (value: unknown): number | null => {
|
|
315
|
+
const match = /^([01]\d|2[0-3]):([0-5]\d)$/.exec(
|
|
316
|
+
typeof value === "string" ? value.trim() : ""
|
|
317
|
+
);
|
|
318
|
+
return match ? Number(match[1]) * 60 + Number(match[2]) : null;
|
|
319
|
+
};
|
|
320
|
+
const from = parse(quiet.from);
|
|
321
|
+
const to = parse(quiet.to);
|
|
322
|
+
if (from === null || to === null) return false;
|
|
323
|
+
const minutes = now.getHours() * 60 + now.getMinutes();
|
|
324
|
+
if (from === to) return true;
|
|
325
|
+
if (from < to) return minutes >= from && minutes < to;
|
|
326
|
+
return minutes >= from || minutes < to;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** URL дашборда: настройка, иначе фактический порт сервера, иначе null. */
|
|
330
|
+
async function resolveDashboardUrl(
|
|
331
|
+
config: NotificationSettings
|
|
332
|
+
): Promise<string | null> {
|
|
333
|
+
const custom = (config.dashboardUrl ?? "").trim();
|
|
334
|
+
if (custom) return custom;
|
|
277
335
|
try {
|
|
278
|
-
await
|
|
279
|
-
|
|
280
|
-
return
|
|
281
|
-
} catch
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
336
|
+
const { getDashboardPort } = await import("./server.js");
|
|
337
|
+
const port = getDashboardPort();
|
|
338
|
+
return port ? `http://localhost:${port}` : null;
|
|
339
|
+
} catch {
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** Токен и chat_id Telegram: настройки важнее переменных окружения. */
|
|
345
|
+
function telegramCredentials(config: NotificationSettings): {
|
|
346
|
+
token: string;
|
|
347
|
+
chatId: string;
|
|
348
|
+
} {
|
|
349
|
+
const token =
|
|
350
|
+
(config.telegram?.botToken ?? "").trim() ||
|
|
351
|
+
(process.env.OPENCODE_SCHEDULER_TELEGRAM_BOT_TOKEN ?? "").trim();
|
|
352
|
+
const chatId =
|
|
353
|
+
(config.telegram?.chatId ?? "").trim() ||
|
|
354
|
+
(process.env.OPENCODE_SCHEDULER_TELEGRAM_CHAT_ID ?? "").trim();
|
|
355
|
+
return { token, chatId };
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Отправляет сообщение во все включённые каналы и возвращает результат
|
|
360
|
+
* по каждому. Ошибки каналов не прерывают остальные и не содержат секретов.
|
|
361
|
+
*/
|
|
362
|
+
async function deliverDetailed(
|
|
363
|
+
config: NotificationSettings,
|
|
364
|
+
message: string,
|
|
365
|
+
only?: NotificationChannel
|
|
366
|
+
): Promise<ChannelDeliveryResult[]> {
|
|
367
|
+
const results: ChannelDeliveryResult[] = [];
|
|
368
|
+
const dashboardUrl = await resolveDashboardUrl(config);
|
|
369
|
+
|
|
370
|
+
const webhook = config.webhook;
|
|
371
|
+
if (
|
|
372
|
+
(!only || only === "webhook") &&
|
|
373
|
+
config.enabled &&
|
|
374
|
+
webhook?.enabled &&
|
|
375
|
+
webhook.url.trim()
|
|
376
|
+
) {
|
|
377
|
+
try {
|
|
378
|
+
await sendWebhook(webhook.url, message, webhookOptionsFrom(config));
|
|
379
|
+
console.log("[windows-scheduler] Уведомление отправлено в webhook.");
|
|
380
|
+
results.push({ channel: "webhook", ok: true });
|
|
381
|
+
} catch (err: any) {
|
|
382
|
+
const text = err instanceof Error ? err.message : String(err);
|
|
383
|
+
console.error(`[windows-scheduler] Webhook: ${text}`);
|
|
384
|
+
results.push({ channel: "webhook", ok: false, error: text });
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const telegram = config.telegram;
|
|
389
|
+
if ((!only || only === "telegram") && config.enabled && telegram?.enabled) {
|
|
390
|
+
const { token, chatId } = telegramCredentials(config);
|
|
391
|
+
if (!token || !chatId) {
|
|
392
|
+
const text = "Telegram включён, но не заданы botToken/chatId.";
|
|
393
|
+
console.error(`[windows-scheduler] ${text}`);
|
|
394
|
+
results.push({ channel: "telegram", ok: false, error: text });
|
|
395
|
+
} else {
|
|
396
|
+
try {
|
|
397
|
+
await sendTelegramMessage(token, chatId, message, {
|
|
398
|
+
apiBase: telegram.apiBase,
|
|
399
|
+
parseMode: telegram.parseMode,
|
|
400
|
+
disableNotification: telegram.disableNotification,
|
|
401
|
+
messageThreadId: telegram.messageThreadId,
|
|
402
|
+
includeDashboardLink: telegram.includeDashboardLink,
|
|
403
|
+
dashboardUrl,
|
|
404
|
+
});
|
|
405
|
+
console.log("[windows-scheduler] Уведомление отправлено в Telegram.");
|
|
406
|
+
results.push({ channel: "telegram", ok: true });
|
|
407
|
+
} catch (err: any) {
|
|
408
|
+
const text = err instanceof Error ? err.message : String(err);
|
|
409
|
+
console.error(`[windows-scheduler] Telegram: ${text}`);
|
|
410
|
+
results.push({ channel: "telegram", ok: false, error: text });
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const native = config.native;
|
|
416
|
+
if ((!only || only === "native") && config.enabled && native?.enabled) {
|
|
417
|
+
const result = await sendNativeNotification(
|
|
418
|
+
{ title: "OpenCode Scheduler", body: message, sound: native.sound },
|
|
419
|
+
{}
|
|
286
420
|
);
|
|
287
|
-
|
|
421
|
+
if (result.success) {
|
|
422
|
+
console.log("[windows-scheduler] Нативное уведомление показано.");
|
|
423
|
+
results.push({ channel: "native", ok: true });
|
|
424
|
+
} else {
|
|
425
|
+
const text = result.error ?? "не удалось показать уведомление";
|
|
426
|
+
console.error(`[windows-scheduler] Нативное уведомление: ${text}`);
|
|
427
|
+
results.push({ channel: "native", ok: false, error: text });
|
|
428
|
+
}
|
|
288
429
|
}
|
|
430
|
+
|
|
431
|
+
return results;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/** Отправляет текст во все включённые каналы; true — хотя бы один успешен. */
|
|
435
|
+
async function deliver(config: NotificationSettings, message: string): Promise<boolean> {
|
|
436
|
+
const results = await deliverDetailed(config, message);
|
|
437
|
+
return results.some((item) => item.ok);
|
|
289
438
|
}
|
|
290
439
|
|
|
291
440
|
/**
|
|
@@ -301,7 +450,9 @@ export async function notifyTaskCompletion(
|
|
|
301
450
|
taskName: string,
|
|
302
451
|
status: NotificationStatus,
|
|
303
452
|
durationMs: number,
|
|
304
|
-
error?: string | null
|
|
453
|
+
error?: string | null,
|
|
454
|
+
tokens?: number | null,
|
|
455
|
+
costUsd?: number | null
|
|
305
456
|
): Promise<void> {
|
|
306
457
|
try {
|
|
307
458
|
const settings = await loadSettings();
|
|
@@ -309,9 +460,17 @@ export async function notifyTaskCompletion(
|
|
|
309
460
|
if (!config?.enabled) return;
|
|
310
461
|
if (config.onlyOnError && status === "success") return;
|
|
311
462
|
if (!isTaskAllowed(taskName, config.filters)) return;
|
|
463
|
+
// Тихие часы подавляют успешные запуски, но не ошибки и таймауты.
|
|
464
|
+
if (
|
|
465
|
+
isQuietHours(new Date(), config.quietHours) &&
|
|
466
|
+
status !== "error" &&
|
|
467
|
+
status !== "timeout"
|
|
468
|
+
) {
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
312
471
|
|
|
313
472
|
const message = formatNotificationMessage(
|
|
314
|
-
{ taskName, status, durationMs, error },
|
|
473
|
+
{ taskName, status, durationMs, error, tokens, costUsd },
|
|
315
474
|
config.templates
|
|
316
475
|
);
|
|
317
476
|
await deliver(config, message);
|
|
@@ -345,6 +504,9 @@ export async function notifyMatrixCompletion(
|
|
|
345
504
|
if (info.status === "partial" && !matrix.onPartial) return;
|
|
346
505
|
if (info.status === "error" && !matrix.onAllFailed) return;
|
|
347
506
|
if (info.status === "success" && config.onlyOnError) return;
|
|
507
|
+
if (isQuietHours(new Date(), config.quietHours) && info.status !== "error") {
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
348
510
|
|
|
349
511
|
await deliver(config, formatMatrixMessage(info));
|
|
350
512
|
} catch (err: any) {
|
|
@@ -547,9 +709,15 @@ export async function sendDigestNow(
|
|
|
547
709
|
if (!config?.enabled) {
|
|
548
710
|
return { success: false, message: "Уведомления выключены." };
|
|
549
711
|
}
|
|
550
|
-
const
|
|
551
|
-
if (
|
|
552
|
-
|
|
712
|
+
const channels: NotificationChannel[] = [];
|
|
713
|
+
if (config.webhook?.enabled && config.webhook.url.trim()) channels.push("webhook");
|
|
714
|
+
if (config.telegram?.enabled) channels.push("telegram");
|
|
715
|
+
if (config.native?.enabled) channels.push("native");
|
|
716
|
+
if (channels.length === 0) {
|
|
717
|
+
return {
|
|
718
|
+
success: false,
|
|
719
|
+
message: "Все каналы выключены. Включите webhook, Telegram или нативные уведомления.",
|
|
720
|
+
};
|
|
553
721
|
}
|
|
554
722
|
const digest = config.digest;
|
|
555
723
|
if (!digest) {
|
|
@@ -562,7 +730,9 @@ export async function sendDigestNow(
|
|
|
562
730
|
now,
|
|
563
731
|
});
|
|
564
732
|
const text = formatDigestMessage(summary, now);
|
|
565
|
-
await
|
|
733
|
+
if (!(await deliver(config, text))) {
|
|
734
|
+
return { success: false, message: "Не удалось отправить дайджест ни в один канал." };
|
|
735
|
+
}
|
|
566
736
|
|
|
567
737
|
if (options.updateLastSentAt) {
|
|
568
738
|
await saveSettings({
|
|
@@ -608,39 +778,61 @@ export async function maybeSendDigest(now: Date = new Date()): Promise<boolean>
|
|
|
608
778
|
}
|
|
609
779
|
|
|
610
780
|
/**
|
|
611
|
-
* Отправляет тестовое сообщение в
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
* при тесте важно увидеть причину ошибки.
|
|
781
|
+
* Отправляет тестовое сообщение в выбранный канал или во все включённые
|
|
782
|
+
* (кнопка «🧪 Тестовое уведомление»). В отличие от notifyTaskCompletion,
|
|
783
|
+
* результат возвращается пользователю: при тесте важна причина ошибки.
|
|
615
784
|
*/
|
|
616
|
-
export async function sendTestNotification(
|
|
785
|
+
export async function sendTestNotification(
|
|
786
|
+
channel: "all" | NotificationChannel = "all"
|
|
787
|
+
): Promise<{
|
|
617
788
|
success: boolean;
|
|
618
789
|
message: string;
|
|
619
790
|
}> {
|
|
620
791
|
try {
|
|
621
792
|
const settings = await loadSettings();
|
|
622
|
-
const
|
|
793
|
+
const config = settings.notifications;
|
|
794
|
+
if (!config?.enabled) {
|
|
795
|
+
return {
|
|
796
|
+
success: false,
|
|
797
|
+
message: "Уведомления выключены. Включите главный переключатель.",
|
|
798
|
+
};
|
|
799
|
+
}
|
|
623
800
|
|
|
624
|
-
|
|
801
|
+
const enabled: NotificationChannel[] = [];
|
|
802
|
+
if (config.webhook?.enabled && config.webhook.url.trim()) enabled.push("webhook");
|
|
803
|
+
if (config.telegram?.enabled) enabled.push("telegram");
|
|
804
|
+
if (config.native?.enabled) enabled.push("native");
|
|
805
|
+
if (enabled.length === 0) {
|
|
625
806
|
return {
|
|
626
807
|
success: false,
|
|
627
|
-
message:
|
|
808
|
+
message:
|
|
809
|
+
"Все каналы выключены. Включите webhook, Telegram или нативные уведомления.",
|
|
628
810
|
};
|
|
629
811
|
}
|
|
630
|
-
if (!
|
|
631
|
-
return { success: false, message:
|
|
812
|
+
if (channel !== "all" && !enabled.includes(channel)) {
|
|
813
|
+
return { success: false, message: `Канал ${channel} выключен.` };
|
|
632
814
|
}
|
|
633
815
|
|
|
634
|
-
await
|
|
635
|
-
|
|
636
|
-
"🧪 Тестовое уведомление от OpenCode Scheduler —
|
|
637
|
-
|
|
638
|
-
timeoutMs: webhook.timeoutMs,
|
|
639
|
-
retryCount: webhook.retryCount,
|
|
640
|
-
retryDelayMs: webhook.retryDelayMs,
|
|
641
|
-
}
|
|
816
|
+
const results = await deliverDetailed(
|
|
817
|
+
config,
|
|
818
|
+
"🧪 Тестовое уведомление от OpenCode Scheduler — канал настроен корректно.",
|
|
819
|
+
channel === "all" ? undefined : channel
|
|
642
820
|
);
|
|
643
|
-
|
|
821
|
+
const sent = results.filter((item) => item.ok).map((item) => item.channel);
|
|
822
|
+
const failed = results.filter((item) => !item.ok);
|
|
823
|
+
const parts: string[] = [];
|
|
824
|
+
if (sent.length > 0) parts.push(`Отправлено: ${sent.join(", ")}.`);
|
|
825
|
+
if (failed.length > 0) {
|
|
826
|
+
parts.push(
|
|
827
|
+
`Ошибки: ${failed
|
|
828
|
+
.map((item) => `${item.channel} — ${item.error ?? "неизвестная ошибка"}`)
|
|
829
|
+
.join("; ")}.`
|
|
830
|
+
);
|
|
831
|
+
}
|
|
832
|
+
return {
|
|
833
|
+
success: failed.length === 0 && sent.length > 0,
|
|
834
|
+
message: parts.join(" ") || "Тестовое уведомление не отправлено.",
|
|
835
|
+
};
|
|
644
836
|
} catch (err: any) {
|
|
645
837
|
return {
|
|
646
838
|
success: false,
|
package/src/rpc.ts
CHANGED
|
@@ -441,6 +441,41 @@ const NotificationSettingsSchema = {
|
|
|
441
441
|
},
|
|
442
442
|
required: ["include", "exclude"],
|
|
443
443
|
},
|
|
444
|
+
telegram: {
|
|
445
|
+
type: "object" as const,
|
|
446
|
+
properties: {
|
|
447
|
+
enabled: { type: "boolean" },
|
|
448
|
+
botToken: { type: "string" },
|
|
449
|
+
chatId: { type: "string" },
|
|
450
|
+
parseMode: {
|
|
451
|
+
type: "string",
|
|
452
|
+
enum: ["", "HTML", "Markdown", "MarkdownV2"],
|
|
453
|
+
},
|
|
454
|
+
disableNotification: { type: "boolean" },
|
|
455
|
+
messageThreadId: { type: ["number", "null"] },
|
|
456
|
+
includeDashboardLink: { type: "boolean" },
|
|
457
|
+
apiBase: { type: "string" },
|
|
458
|
+
},
|
|
459
|
+
required: ["enabled"],
|
|
460
|
+
},
|
|
461
|
+
native: {
|
|
462
|
+
type: "object" as const,
|
|
463
|
+
properties: {
|
|
464
|
+
enabled: { type: "boolean" },
|
|
465
|
+
sound: { type: "boolean" },
|
|
466
|
+
},
|
|
467
|
+
required: ["enabled"],
|
|
468
|
+
},
|
|
469
|
+
quietHours: {
|
|
470
|
+
type: "object" as const,
|
|
471
|
+
properties: {
|
|
472
|
+
enabled: { type: "boolean" },
|
|
473
|
+
from: { type: "string" },
|
|
474
|
+
to: { type: "string" },
|
|
475
|
+
},
|
|
476
|
+
required: ["enabled", "from", "to"],
|
|
477
|
+
},
|
|
478
|
+
dashboardUrl: { type: "string" },
|
|
444
479
|
matrix: {
|
|
445
480
|
type: "object" as const,
|
|
446
481
|
properties: {
|
|
@@ -477,6 +512,17 @@ const HistorySettingsSchema = {
|
|
|
477
512
|
required: ["retentionDays", "maxRecords"],
|
|
478
513
|
} as const;
|
|
479
514
|
|
|
515
|
+
/** Журнал аудита (Спринт 26). */
|
|
516
|
+
const AuditSettingsSchema = {
|
|
517
|
+
type: "object" as const,
|
|
518
|
+
properties: {
|
|
519
|
+
enabled: { type: "boolean" },
|
|
520
|
+
retentionDays: { type: "number" },
|
|
521
|
+
maxRecords: { type: "number" },
|
|
522
|
+
},
|
|
523
|
+
required: ["enabled", "retentionDays", "maxRecords"],
|
|
524
|
+
} as const;
|
|
525
|
+
|
|
480
526
|
const GetSettingsOutput = {
|
|
481
527
|
type: "object" as const,
|
|
482
528
|
properties: {
|
|
@@ -484,6 +530,7 @@ const GetSettingsOutput = {
|
|
|
484
530
|
winterMode: { type: "boolean" },
|
|
485
531
|
notifications: NotificationSettingsSchema,
|
|
486
532
|
history: HistorySettingsSchema,
|
|
533
|
+
audit: AuditSettingsSchema,
|
|
487
534
|
},
|
|
488
535
|
required: ["maxConcurrent", "winterMode", "notifications"],
|
|
489
536
|
} as const;
|
|
@@ -495,6 +542,7 @@ const SaveSettingsInput = {
|
|
|
495
542
|
winterMode: { type: "boolean" },
|
|
496
543
|
notifications: NotificationSettingsSchema,
|
|
497
544
|
history: HistorySettingsSchema,
|
|
545
|
+
audit: AuditSettingsSchema,
|
|
498
546
|
},
|
|
499
547
|
additionalProperties: false,
|
|
500
548
|
} as const;
|
|
@@ -507,6 +555,7 @@ const SaveSettingsOutput = {
|
|
|
507
555
|
winterMode: { type: "boolean" },
|
|
508
556
|
notifications: NotificationSettingsSchema,
|
|
509
557
|
history: HistorySettingsSchema,
|
|
558
|
+
audit: AuditSettingsSchema,
|
|
510
559
|
},
|
|
511
560
|
required: ["success", "maxConcurrent", "winterMode", "notifications"],
|
|
512
561
|
} as const;
|
|
@@ -591,6 +640,110 @@ const SendDigestOutput = {
|
|
|
591
640
|
required: ["success", "message"],
|
|
592
641
|
} as const;
|
|
593
642
|
|
|
643
|
+
/** Секрет: имя и маскированный превью, значение никогда не возвращается. */
|
|
644
|
+
const SecretItem = {
|
|
645
|
+
type: "object" as const,
|
|
646
|
+
properties: {
|
|
647
|
+
name: { type: "string" },
|
|
648
|
+
preview: { type: "string" },
|
|
649
|
+
updatedAt: { type: "string" },
|
|
650
|
+
},
|
|
651
|
+
required: ["name", "preview"],
|
|
652
|
+
} as const;
|
|
653
|
+
|
|
654
|
+
const ListSecretsInput = {
|
|
655
|
+
type: "object" as const,
|
|
656
|
+
properties: {},
|
|
657
|
+
additionalProperties: false,
|
|
658
|
+
} as const;
|
|
659
|
+
|
|
660
|
+
const ListSecretsOutput = {
|
|
661
|
+
type: "object" as const,
|
|
662
|
+
properties: {
|
|
663
|
+
success: { type: "boolean" },
|
|
664
|
+
secrets: { type: "array", items: SecretItem },
|
|
665
|
+
},
|
|
666
|
+
required: ["success", "secrets"],
|
|
667
|
+
} as const;
|
|
668
|
+
|
|
669
|
+
const SaveSecretInput = {
|
|
670
|
+
type: "object" as const,
|
|
671
|
+
properties: {
|
|
672
|
+
name: { type: "string" },
|
|
673
|
+
value: { type: "string" },
|
|
674
|
+
},
|
|
675
|
+
required: ["name", "value"],
|
|
676
|
+
additionalProperties: false,
|
|
677
|
+
} as const;
|
|
678
|
+
|
|
679
|
+
const SaveSecretOutput = {
|
|
680
|
+
type: "object" as const,
|
|
681
|
+
properties: {
|
|
682
|
+
success: { type: "boolean" },
|
|
683
|
+
message: { type: "string" },
|
|
684
|
+
secret: SecretItem,
|
|
685
|
+
},
|
|
686
|
+
required: ["success"],
|
|
687
|
+
} as const;
|
|
688
|
+
|
|
689
|
+
const DeleteSecretInput = {
|
|
690
|
+
type: "object" as const,
|
|
691
|
+
properties: {
|
|
692
|
+
name: { type: "string" },
|
|
693
|
+
},
|
|
694
|
+
required: ["name"],
|
|
695
|
+
additionalProperties: false,
|
|
696
|
+
} as const;
|
|
697
|
+
|
|
698
|
+
const DeleteSecretOutput = {
|
|
699
|
+
type: "object" as const,
|
|
700
|
+
properties: {
|
|
701
|
+
success: { type: "boolean" },
|
|
702
|
+
message: { type: "string" },
|
|
703
|
+
},
|
|
704
|
+
required: ["success", "message"],
|
|
705
|
+
} as const;
|
|
706
|
+
|
|
707
|
+
/** Запись журнала аудита (Спринт 26). */
|
|
708
|
+
const AuditRecordSchema = {
|
|
709
|
+
type: "object" as const,
|
|
710
|
+
properties: {
|
|
711
|
+
id: { type: "number" },
|
|
712
|
+
ts: { type: "string" },
|
|
713
|
+
action: { type: "string" },
|
|
714
|
+
targetType: { type: ["string", "null"] },
|
|
715
|
+
target: { type: ["string", "null"] },
|
|
716
|
+
actor: { type: "string" },
|
|
717
|
+
source: { type: ["string", "null"] },
|
|
718
|
+
details: {},
|
|
719
|
+
remote: { type: ["string", "null"] },
|
|
720
|
+
},
|
|
721
|
+
required: ["id", "ts", "action", "actor"],
|
|
722
|
+
} as const;
|
|
723
|
+
|
|
724
|
+
const GetAuditInput = {
|
|
725
|
+
type: "object" as const,
|
|
726
|
+
properties: {
|
|
727
|
+
action: { type: "string" },
|
|
728
|
+
target: { type: "string" },
|
|
729
|
+
actor: { type: "string" },
|
|
730
|
+
since: { type: "string" },
|
|
731
|
+
until: { type: "string" },
|
|
732
|
+
limit: { type: "number" },
|
|
733
|
+
},
|
|
734
|
+
additionalProperties: false,
|
|
735
|
+
} as const;
|
|
736
|
+
|
|
737
|
+
const GetAuditOutput = {
|
|
738
|
+
type: "object" as const,
|
|
739
|
+
properties: {
|
|
740
|
+
success: { type: "boolean" },
|
|
741
|
+
records: { type: "array", items: AuditRecordSchema },
|
|
742
|
+
total: { type: "number" },
|
|
743
|
+
},
|
|
744
|
+
required: ["success", "records", "total"],
|
|
745
|
+
} as const;
|
|
746
|
+
|
|
594
747
|
const TemplateItem = {
|
|
595
748
|
type: "object" as const,
|
|
596
749
|
properties: {
|
|
@@ -1230,6 +1383,10 @@ export const SchedulerRpc = Rpc.define({
|
|
|
1230
1383
|
input: SendDigestInput,
|
|
1231
1384
|
output: SendDigestOutput,
|
|
1232
1385
|
},
|
|
1386
|
+
list_secrets: { input: ListSecretsInput, output: ListSecretsOutput },
|
|
1387
|
+
save_secret: { input: SaveSecretInput, output: SaveSecretOutput },
|
|
1388
|
+
delete_secret: { input: DeleteSecretInput, output: DeleteSecretOutput },
|
|
1389
|
+
get_audit: { input: GetAuditInput, output: GetAuditOutput },
|
|
1233
1390
|
},
|
|
1234
1391
|
events: {},
|
|
1235
1392
|
});
|