opencode-windows-scheduler 1.0.0 → 1.2.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 (93) hide show
  1. package/CHANGELOG.md +58 -7
  2. package/README.md +14 -4
  3. package/README.ru.md +14 -4
  4. package/ROADMAP.md +30 -20
  5. package/dist/core/analytics.d.ts +129 -0
  6. package/dist/core/analytics.d.ts.map +1 -0
  7. package/dist/core/analytics.js +286 -0
  8. package/dist/core/dry-run.d.ts +13 -0
  9. package/dist/core/dry-run.d.ts.map +1 -1
  10. package/dist/core/dry-run.js +30 -0
  11. package/dist/core/matrix.d.ts.map +1 -1
  12. package/dist/core/matrix.js +10 -0
  13. package/dist/core/ps-wrapper.d.ts +32 -2
  14. package/dist/core/ps-wrapper.d.ts.map +1 -1
  15. package/dist/core/ps-wrapper.js +101 -3
  16. package/dist/core/retention.d.ts +29 -0
  17. package/dist/core/retention.d.ts.map +1 -0
  18. package/dist/core/retention.js +98 -0
  19. package/dist/core/schedule-gate.d.ts +2 -0
  20. package/dist/core/schedule-gate.d.ts.map +1 -0
  21. package/dist/core/schedule-gate.js +182 -0
  22. package/dist/core/schedule-v2.d.ts +88 -0
  23. package/dist/core/schedule-v2.d.ts.map +1 -0
  24. package/dist/core/schedule-v2.js +496 -0
  25. package/dist/core/scheduler/types.d.ts +15 -0
  26. package/dist/core/scheduler/types.d.ts.map +1 -1
  27. package/dist/core/scheduler/windows.d.ts.map +1 -1
  28. package/dist/core/scheduler/windows.js +13 -1
  29. package/dist/core/wrappers/bash.d.ts +15 -0
  30. package/dist/core/wrappers/bash.d.ts.map +1 -1
  31. package/dist/core/wrappers/bash.js +44 -1
  32. package/dist/db/history-repo.d.ts +41 -0
  33. package/dist/db/history-repo.d.ts.map +1 -1
  34. package/dist/db/history-repo.js +78 -0
  35. package/dist/db/schema.d.ts +1 -1
  36. package/dist/db/schema.d.ts.map +1 -1
  37. package/dist/db/schema.js +11 -0
  38. package/dist/index.d.ts +117 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +1094 -56
  41. package/dist/notifications.d.ts +112 -6
  42. package/dist/notifications.d.ts.map +1 -1
  43. package/dist/notifications.js +396 -34
  44. package/dist/profiles.d.ts +60 -0
  45. package/dist/profiles.d.ts.map +1 -0
  46. package/dist/profiles.js +209 -0
  47. package/dist/rpc.d.ts +645 -0
  48. package/dist/rpc.d.ts.map +1 -1
  49. package/dist/rpc.js +251 -2
  50. package/dist/server.d.ts.map +1 -1
  51. package/dist/server.js +200 -7
  52. package/dist/settings.d.ts +80 -0
  53. package/dist/settings.d.ts.map +1 -1
  54. package/dist/settings.js +159 -8
  55. package/dist/task-transfer.d.ts +13 -0
  56. package/dist/task-transfer.d.ts.map +1 -1
  57. package/dist/task-transfer.js +26 -0
  58. package/dist/types.d.ts.map +1 -1
  59. package/dist/types.js +3 -11
  60. package/dist/version.d.ts +8 -0
  61. package/dist/version.d.ts.map +1 -0
  62. package/dist/version.js +27 -0
  63. package/dist/workspaces.d.ts +43 -0
  64. package/dist/workspaces.d.ts.map +1 -1
  65. package/dist/workspaces.js +174 -8
  66. package/docs/ARCHITECTURE.md +45 -13
  67. package/docs/FEATURES.md +103 -12
  68. package/gui-experimental.cjs +4 -2
  69. package/package.json +8 -2
  70. package/src/core/analytics.ts +414 -0
  71. package/src/core/dry-run.ts +42 -0
  72. package/src/core/matrix.ts +10 -0
  73. package/src/core/ps-wrapper.ts +117 -3
  74. package/src/core/retention.ts +141 -0
  75. package/src/core/schedule-gate.ts +213 -0
  76. package/src/core/schedule-v2.ts +533 -0
  77. package/src/core/scheduler/types.ts +15 -0
  78. package/src/core/scheduler/windows.ts +13 -1
  79. package/src/core/wrappers/bash.ts +60 -0
  80. package/src/db/history-repo.ts +116 -0
  81. package/src/db/schema.ts +14 -0
  82. package/src/gui.tsx +3613 -2725
  83. package/src/index.ts +1325 -55
  84. package/src/notifications.ts +516 -40
  85. package/src/profiles.ts +236 -0
  86. package/src/rpc.ts +267 -2
  87. package/src/server.ts +226 -7
  88. package/src/settings.ts +285 -9
  89. package/src/task-transfer.ts +44 -0
  90. package/src/types.ts +3 -13
  91. package/src/version.ts +27 -0
  92. package/src/workspaces.ts +214 -8
  93. package/dist/gui-experimental.cjs +0 -1
@@ -0,0 +1,236 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+
5
+ /**
6
+ * Профили (Спринт 21): каждый профиль — отдельная директория со своей БД,
7
+ * настройками, логами, обёртками и портом дашборда. Профиль `default`
8
+ * использует базовую директорию плагина (как раньше — без миграции), остальные
9
+ * живут в `<base>/profiles/<name>`.
10
+ */
11
+
12
+ export const DEFAULT_PROFILE = "default";
13
+
14
+ /** Файл-маркер активного профиля (когда переменная окружения не задана). */
15
+ const ACTIVE_PROFILE_FILE = "active-profile";
16
+
17
+ /** Метаданные профиля: имя и порт дашборда. */
18
+ export interface ProfileMeta {
19
+ name: string;
20
+ port: number;
21
+ }
22
+
23
+ /** Описание профиля для RPC/GUI. */
24
+ export interface ProfileInfo {
25
+ name: string;
26
+ dir: string;
27
+ port: number | null;
28
+ isDefault: boolean;
29
+ active: boolean;
30
+ }
31
+
32
+ /**
33
+ * Базовая директория плагина (до профилей).
34
+ *
35
+ * Windows: %APPDATA%\opencode\windows-scheduler.
36
+ * macOS/Linux: $XDG_CONFIG_HOME/opencode/windows-scheduler или
37
+ * ~/.config/opencode/windows-scheduler.
38
+ * OPENCODE_SCHEDULER_HOME переопределяет всё (тесты, кастомные установки).
39
+ */
40
+ export function getBasePluginDir(): string {
41
+ const custom = process.env.OPENCODE_SCHEDULER_HOME?.trim();
42
+ if (custom) return path.resolve(custom);
43
+
44
+ if (process.platform === "win32") {
45
+ const base = process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming");
46
+ return path.join(base, "opencode", "windows-scheduler");
47
+ }
48
+
49
+ const configHome = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config");
50
+ return path.join(configHome, "opencode", "windows-scheduler");
51
+ }
52
+
53
+ /** Нормализует имя профиля: нижний регистр, только [a-z0-9_-]. */
54
+ export function sanitizeProfileName(value: string | null | undefined): string {
55
+ const normalized = (value ?? "")
56
+ .trim()
57
+ .toLowerCase()
58
+ .replace(/[^a-z0-9_-]+/g, "-")
59
+ .replace(/^-+|-+$/g, "")
60
+ .slice(0, 40);
61
+ return normalized || DEFAULT_PROFILE;
62
+ }
63
+
64
+ /** Валидация имени профиля (без «исправления»): пусто/кривые символы — ошибка. */
65
+ export function validateProfileName(value: string): string | null {
66
+ const trimmed = (value ?? "").trim().toLowerCase();
67
+ if (!trimmed) return "Имя профиля не может быть пустым.";
68
+ if (!/^[a-z][a-z0-9_-]{0,39}$/.test(trimmed)) {
69
+ return "Имя профиля: только латиница, цифры, «-» и «_», до 40 символов, не с цифры.";
70
+ }
71
+ return null;
72
+ }
73
+
74
+ /** Читает имя активного профиля из файла-маркера (если есть). */
75
+ function readActiveProfileMarker(base: string): string | null {
76
+ try {
77
+ const raw = fs.readFileSync(path.join(base, ACTIVE_PROFILE_FILE), "utf8").trim();
78
+ return raw ? sanitizeProfileName(raw) : null;
79
+ } catch {
80
+ return null;
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Имя текущего профиля: OPENCODE_SCHEDULER_PROFILE > файл-маркер > default.
86
+ */
87
+ export function getProfileName(): string {
88
+ const fromEnv = process.env.OPENCODE_SCHEDULER_PROFILE?.trim();
89
+ if (fromEnv) return sanitizeProfileName(fromEnv);
90
+ return readActiveProfileMarker(getBasePluginDir()) ?? DEFAULT_PROFILE;
91
+ }
92
+
93
+ /** Директория профиля: default — базовая, остальные — <base>/profiles/<name>. */
94
+ export function getProfileDir(name: string = getProfileName()): string {
95
+ const base = getBasePluginDir();
96
+ const normalized = sanitizeProfileName(name);
97
+ if (normalized === DEFAULT_PROFILE) return base;
98
+ return path.join(base, "profiles", normalized);
99
+ }
100
+
101
+ /** Путь к метаданным профиля. */
102
+ function profileMetaFile(name: string): string {
103
+ return path.join(getProfileDir(name), "profile.json");
104
+ }
105
+
106
+ /** Читает profile.json профиля (или null, если файла нет/он битый). */
107
+ export function readProfileMeta(name: string): ProfileMeta | null {
108
+ try {
109
+ const raw = fs.readFileSync(profileMetaFile(name), "utf8");
110
+ const parsed = JSON.parse(raw) as Partial<ProfileMeta>;
111
+ const profileName = sanitizeProfileName(parsed?.name ?? name);
112
+ const port = Number(parsed?.port);
113
+ return {
114
+ name: profileName,
115
+ port: Number.isFinite(port) && port >= 1 && port <= 65535 ? Math.floor(port) : 0,
116
+ };
117
+ } catch {
118
+ return null;
119
+ }
120
+ }
121
+
122
+ /** Порт дашборда профиля: env > profile.json > null (дефолтная логика сервера). */
123
+ export function getProfilePort(name: string = getProfileName()): number | null {
124
+ const fromEnv = Number(process.env.OPENCODE_SCHEDULER_PORT);
125
+ if (Number.isFinite(fromEnv) && fromEnv >= 1 && fromEnv <= 65535) {
126
+ return Math.floor(fromEnv);
127
+ }
128
+ const meta = readProfileMeta(name);
129
+ if (meta && meta.port > 0) return meta.port;
130
+ return null;
131
+ }
132
+
133
+ /** Список существующих профилей (default всегда первый). */
134
+ export function listProfiles(): ProfileInfo[] {
135
+ const base = getBasePluginDir();
136
+ const active = getProfileName();
137
+ const names = new Set<string>([DEFAULT_PROFILE]);
138
+
139
+ const profilesRoot = path.join(base, "profiles");
140
+ try {
141
+ for (const entry of fs.readdirSync(profilesRoot, { withFileTypes: true })) {
142
+ if (!entry.isDirectory()) continue;
143
+ const candidate = sanitizeProfileName(entry.name);
144
+ if (candidate === DEFAULT_PROFILE) continue;
145
+ names.add(candidate);
146
+ }
147
+ } catch {
148
+ // profiles/ ещё нет — только default.
149
+ }
150
+
151
+ return Array.from(names)
152
+ .sort((a, b) => (a === DEFAULT_PROFILE ? -1 : b === DEFAULT_PROFILE ? 1 : a.localeCompare(b)))
153
+ .map((name) => {
154
+ const meta = readProfileMeta(name);
155
+ return {
156
+ name,
157
+ dir: getProfileDir(name),
158
+ port: meta && meta.port > 0 ? meta.port : null,
159
+ isDefault: name === DEFAULT_PROFILE,
160
+ active: name === active,
161
+ };
162
+ });
163
+ }
164
+
165
+ /** Свободный порт для нового профиля: 3782+N, занятые profile.json пропускаются. */
166
+ function allocateProfilePort(): number {
167
+ const used = new Set<number>();
168
+ for (const profile of listProfiles()) {
169
+ if (profile.port) used.add(profile.port);
170
+ }
171
+ for (let port = 3782; port < 3882; port += 1) {
172
+ if (!used.has(port)) return port;
173
+ }
174
+ return 3782 + used.size;
175
+ }
176
+
177
+ /**
178
+ * Создаёт профиль: директорию + profile.json. Для default просто гарантирует
179
+ * базовую директорию. Возвращает метаданные профиля.
180
+ */
181
+ export function createProfile(name: string, port?: number): ProfileMeta {
182
+ const error = validateProfileName(name);
183
+ if (error) throw new Error(error);
184
+ const normalized = sanitizeProfileName(name);
185
+ const dir = getProfileDir(normalized);
186
+ fs.mkdirSync(dir, { recursive: true });
187
+
188
+ const existing = readProfileMeta(normalized);
189
+ const assigned =
190
+ Number.isFinite(Number(port)) && Number(port) > 0
191
+ ? Math.floor(Number(port))
192
+ : existing && existing.port > 0
193
+ ? existing.port
194
+ : allocateProfilePort();
195
+
196
+ const meta: ProfileMeta = { name: normalized, port: assigned };
197
+ fs.writeFileSync(profileMetaFile(normalized), `${JSON.stringify(meta, null, 2)}\n`, "utf8");
198
+ return meta;
199
+ }
200
+
201
+ /** Удаляет профиль (кроме default). Возвращает true, если директория удалена. */
202
+ export function deleteProfile(name: string): boolean {
203
+ const normalized = sanitizeProfileName(name);
204
+ if (normalized === DEFAULT_PROFILE) {
205
+ throw new Error("Профиль default удалить нельзя.");
206
+ }
207
+ const dir = getProfileDir(normalized);
208
+ if (!fs.existsSync(dir)) return false;
209
+ fs.rmSync(dir, { recursive: true, force: true });
210
+
211
+ // Если удалили активный профиль — возвращаем маркер на default.
212
+ const base = getBasePluginDir();
213
+ if (readActiveProfileMarker(base) === normalized) {
214
+ setActiveProfile(DEFAULT_PROFILE);
215
+ }
216
+ return true;
217
+ }
218
+
219
+ /**
220
+ * Переключает активный профиль через файл-маркер. Изменение подхватится при
221
+ * следующем запуске OpenCode (директории вычисляются при загрузке модуля).
222
+ */
223
+ export function setActiveProfile(name: string): void {
224
+ const normalized = sanitizeProfileName(name);
225
+ if (normalized !== DEFAULT_PROFILE && !fs.existsSync(getProfileDir(normalized))) {
226
+ throw new Error(`Профиль "${normalized}" не существует. Сначала создайте его.`);
227
+ }
228
+ const base = getBasePluginDir();
229
+ fs.mkdirSync(base, { recursive: true });
230
+ fs.writeFileSync(path.join(base, ACTIVE_PROFILE_FILE), `${normalized}\n`, "utf8");
231
+ }
232
+
233
+ /** true, если профиль переключается переменной окружения (маркер не поможет). */
234
+ export function isProfilePinnedByEnv(): boolean {
235
+ return Boolean(process.env.OPENCODE_SCHEDULER_PROFILE?.trim());
236
+ }
package/src/rpc.ts CHANGED
@@ -87,6 +87,14 @@ const TaskItem = {
87
87
  mcpEvent: McpEventSchema,
88
88
  /** Путь к файлу/папке для файлового триггера. */
89
89
  watchPath: { type: ["string", "null"] },
90
+ /** IANA-часовой пояс задачи (Спринт 19; null — системный). */
91
+ timezone: { type: ["string", "null"] },
92
+ /** Начало окна запуска "HH:MM" (null — без окна). */
93
+ notBefore: { type: ["string", "null"] },
94
+ /** Конец окна запуска "HH:MM" (null — без окна). */
95
+ notAfter: { type: ["string", "null"] },
96
+ /** Пауза до даты в ISO (null — автопродолжение не запланировано). */
97
+ pausedUntil: { type: ["string", "null"] },
90
98
  /** Рабочая директория задачи (null — папка проекта по умолчанию). */
91
99
  workingDirectory: { type: ["string", "null"] },
92
100
  /** Привязка к multi-repo workspace (null — без workspace). */
@@ -180,6 +188,12 @@ const CreateTaskInput = {
180
188
  deniedTools: { type: "array", items: { type: "string" } },
181
189
  /** Matrix (fan-out): раскладывает задачу-шаблон на клоны по workspace. */
182
190
  matrix: MatrixSchema,
191
+ /** IANA-часовой пояс задачи (например, Europe/Moscow). Пусто — системный. */
192
+ timezone: { type: "string" },
193
+ /** Начало окна запуска "HH:MM"; вне окна запуск переносится. */
194
+ notBefore: { type: "string" },
195
+ /** Конец окна запуска "HH:MM"; может быть меньше notBefore (через полночь). */
196
+ notAfter: { type: "string" },
183
197
  },
184
198
  required: ["name", "schedule", "prompt"],
185
199
  } as const;
@@ -254,6 +268,8 @@ const GetHistoryInput = {
254
268
  type: "object" as const,
255
269
  properties: {
256
270
  limit: { type: "number" },
271
+ /** Фильтр по имени задачи (регистр не важен). */
272
+ taskName: { type: "string" },
257
273
  },
258
274
  additionalProperties: false,
259
275
  } as const;
@@ -361,7 +377,7 @@ const GetSettingsInput = {
361
377
  additionalProperties: false,
362
378
  } as const;
363
379
 
364
- /** Настройки уведомлений: webhook (Discord/Slack/generic). */
380
+ /** Настройки уведомлений: webhook, шаблоны, фильтры, матрицы и дайджест (Спринт 20). */
365
381
  const NotificationSettingsSchema = {
366
382
  type: "object" as const,
367
383
  properties: {
@@ -372,19 +388,71 @@ const NotificationSettingsSchema = {
372
388
  properties: {
373
389
  enabled: { type: "boolean" },
374
390
  url: { type: "string" },
391
+ timeoutMs: { type: "number" },
392
+ retryCount: { type: "number" },
393
+ retryDelayMs: { type: "number" },
375
394
  },
376
395
  required: ["enabled", "url"],
377
396
  },
397
+ templates: {
398
+ type: "object" as const,
399
+ properties: {
400
+ success: { type: "string" },
401
+ error: { type: "string" },
402
+ },
403
+ required: ["success", "error"],
404
+ },
405
+ filters: {
406
+ type: "object" as const,
407
+ properties: {
408
+ include: { type: "array", items: { type: "string" } },
409
+ exclude: { type: "array", items: { type: "string" } },
410
+ },
411
+ required: ["include", "exclude"],
412
+ },
413
+ matrix: {
414
+ type: "object" as const,
415
+ properties: {
416
+ enabled: { type: "boolean" },
417
+ onPartial: { type: "boolean" },
418
+ onAllFailed: { type: "boolean" },
419
+ stuckAfterMinutes: { type: "number" },
420
+ },
421
+ required: ["enabled", "onPartial", "onAllFailed", "stuckAfterMinutes"],
422
+ },
423
+ digest: {
424
+ type: "object" as const,
425
+ properties: {
426
+ enabled: { type: "boolean" },
427
+ frequency: { type: "string", enum: ["daily", "weekly"] },
428
+ time: { type: "string" },
429
+ lastSentAt: { type: ["string", "null"] },
430
+ },
431
+ required: ["enabled", "frequency", "time"],
432
+ },
378
433
  },
379
434
  required: ["enabled", "onlyOnError"],
380
435
  } as const;
381
436
 
437
+ /** Ретеншн истории (Спринт 18). */
438
+ const HistorySettingsSchema = {
439
+ type: "object" as const,
440
+ properties: {
441
+ retentionDays: { type: "number" },
442
+ maxRecords: { type: "number" },
443
+ lastCleanupAt: { type: ["string", "null"] },
444
+ lastCleanupDeleted: { type: "number" },
445
+ },
446
+ required: ["retentionDays", "maxRecords"],
447
+ } as const;
448
+
382
449
  const GetSettingsOutput = {
383
450
  type: "object" as const,
384
451
  properties: {
385
452
  maxConcurrent: { type: "number" },
386
453
  winterMode: { type: "boolean" },
387
454
  notifications: NotificationSettingsSchema,
455
+ history: HistorySettingsSchema,
388
456
  },
389
457
  required: ["maxConcurrent", "winterMode", "notifications"],
390
458
  } as const;
@@ -395,6 +463,7 @@ const SaveSettingsInput = {
395
463
  maxConcurrent: { type: "number" },
396
464
  winterMode: { type: "boolean" },
397
465
  notifications: NotificationSettingsSchema,
466
+ history: HistorySettingsSchema,
398
467
  },
399
468
  additionalProperties: false,
400
469
  } as const;
@@ -406,10 +475,60 @@ const SaveSettingsOutput = {
406
475
  maxConcurrent: { type: "number" },
407
476
  winterMode: { type: "boolean" },
408
477
  notifications: NotificationSettingsSchema,
478
+ history: HistorySettingsSchema,
409
479
  },
410
480
  required: ["success", "maxConcurrent", "winterMode", "notifications"],
411
481
  } as const;
412
482
 
483
+ const CleanupHistoryInput = {
484
+ type: "object" as const,
485
+ properties: {
486
+ /** Удалять записи старше N дней (0 — выключить ограничение по возрасту). */
487
+ retentionDays: { type: "number" },
488
+ /** Хранить не более N записей (0 — без ограничения). */
489
+ maxRecords: { type: "number" },
490
+ },
491
+ additionalProperties: false,
492
+ } as const;
493
+
494
+ const CleanupHistoryOutput = {
495
+ type: "object" as const,
496
+ properties: {
497
+ success: { type: "boolean" },
498
+ message: { type: "string" },
499
+ deleted: { type: "number" },
500
+ deletedByAge: { type: "number" },
501
+ deletedByCount: { type: "number" },
502
+ kept: { type: "number" },
503
+ retentionDays: { type: "number" },
504
+ maxRecords: { type: "number" },
505
+ vacuumed: { type: "boolean" },
506
+ },
507
+ required: ["success", "message", "deleted", "kept"],
508
+ } as const;
509
+
510
+ const GetAnalyticsInput = {
511
+ type: "object" as const,
512
+ properties: {
513
+ /** Окно анализа в днях (по умолчанию 14, максимум 365). */
514
+ days: { type: "number" },
515
+ /** Сколько строк в топах (по умолчанию 10). */
516
+ topLimit: { type: "number" },
517
+ },
518
+ additionalProperties: false,
519
+ } as const;
520
+
521
+ const GetAnalyticsOutput = {
522
+ type: "object" as const,
523
+ properties: {
524
+ success: { type: "boolean" },
525
+ // null при ошибке: report формируется только при success=true.
526
+ report: { type: ["object", "null"] as const },
527
+ error: { type: "string" },
528
+ },
529
+ required: ["success", "report"],
530
+ } as const;
531
+
413
532
  const TestNotificationInput = {
414
533
  type: "object" as const,
415
534
  properties: {},
@@ -425,6 +544,22 @@ const TestNotificationOutput = {
425
544
  required: ["success", "message"],
426
545
  } as const;
427
546
 
547
+ /** Ручная отправка дайджеста (Спринт 20); не сдвигает плановое расписание. */
548
+ const SendDigestInput = {
549
+ type: "object" as const,
550
+ properties: {},
551
+ additionalProperties: false,
552
+ } as const;
553
+
554
+ const SendDigestOutput = {
555
+ type: "object" as const,
556
+ properties: {
557
+ success: { type: "boolean" },
558
+ message: { type: "string" },
559
+ },
560
+ required: ["success", "message"],
561
+ } as const;
562
+
428
563
  const TemplateItem = {
429
564
  type: "object" as const,
430
565
  properties: {
@@ -538,7 +673,18 @@ const DeleteTemplateOutput = {
538
673
  required: ["success"],
539
674
  } as const;
540
675
 
541
- const PauseResumeInput = NameOnly;
676
+ const PauseResumeInput = {
677
+ type: "object" as const,
678
+ properties: {
679
+ name: { type: "string" },
680
+ /**
681
+ * Только для pause: пауза до указанного момента (ISO). Плагин включит
682
+ * задачу автоматически; пусто — бессрочная пауза.
683
+ */
684
+ until: { type: "string" },
685
+ },
686
+ required: ["name"],
687
+ } as const;
542
688
 
543
689
  const UpdateTaskInput = {
544
690
  type: "object" as const,
@@ -577,6 +723,12 @@ const UpdateTaskInput = {
577
723
  deniedTools: { type: "array", items: { type: "string" } },
578
724
  /** Matrix (fan-out): раскладывает задачу-шаблон на клоны по workspace. */
579
725
  matrix: MatrixSchema,
726
+ /** IANA-часовой пояс задачи. Пустая строка — сбросить на системный. */
727
+ timezone: { type: "string" },
728
+ /** Начало окна запуска "HH:MM". Пустая строка — сбросить окно. */
729
+ notBefore: { type: "string" },
730
+ /** Конец окна запуска "HH:MM". Пустая строка — сбросить окно. */
731
+ notAfter: { type: "string" },
580
732
  },
581
733
  required: ["name"],
582
734
  } as const;
@@ -592,6 +744,10 @@ const WorkspaceItem = {
592
744
  gitRemote: { type: ["string", "null"] },
593
745
  gitBranch: { type: ["string", "null"] },
594
746
  color: { type: ["string", "null"] },
747
+ /** Env-переменные workspace; значения секретов замаскированы (***). */
748
+ env: { type: ["object", "null"], additionalProperties: { type: "string" } },
749
+ /** Путь к .env-файлу workspace (null — не задан). */
750
+ envFile: { type: ["string", "null"] },
595
751
  createdAt: { type: "string" },
596
752
  },
597
753
  required: ["id", "name", "path", "createdAt"],
@@ -617,6 +773,10 @@ const AddWorkspaceInput = {
617
773
  name: { type: "string" },
618
774
  path: { type: "string" },
619
775
  color: { type: "string" },
776
+ /** Env-переменные workspace (ключ → значение). */
777
+ env: { type: ["object", "null"], additionalProperties: { type: "string" } },
778
+ /** Путь к .env-файлу workspace. */
779
+ envFile: { type: ["string", "null"] },
620
780
  },
621
781
  required: ["path"],
622
782
  additionalProperties: false,
@@ -639,6 +799,10 @@ const UpdateWorkspaceInput = {
639
799
  name: { type: "string" },
640
800
  path: { type: "string" },
641
801
  color: { type: "string" },
802
+ /** Env-переменные workspace; null — очистить, отсутствие — не менять. */
803
+ env: { type: ["object", "null"], additionalProperties: { type: "string" } },
804
+ /** Путь к .env-файлу; null — очистить. */
805
+ envFile: { type: ["string", "null"] },
642
806
  },
643
807
  required: ["id"],
644
808
  additionalProperties: false,
@@ -880,6 +1044,97 @@ const CleanupMatrixOrphansOutput = {
880
1044
  required: ["success", "message", "removed"],
881
1045
  } as const;
882
1046
 
1047
+ /** Профиль (Спринт 21): отдельная БД, настройки, логи и порт дашборда. */
1048
+ const ProfileItem = {
1049
+ type: "object" as const,
1050
+ properties: {
1051
+ name: { type: "string" },
1052
+ dir: { type: "string" },
1053
+ port: { type: ["number", "null"] },
1054
+ isDefault: { type: "boolean" },
1055
+ active: { type: "boolean" },
1056
+ },
1057
+ required: ["name", "dir", "isDefault", "active"],
1058
+ } as const;
1059
+
1060
+ const GetProfilesInput = {
1061
+ type: "object" as const,
1062
+ properties: {},
1063
+ additionalProperties: false,
1064
+ } as const;
1065
+
1066
+ const GetProfilesOutput = {
1067
+ type: "object" as const,
1068
+ properties: {
1069
+ current: { type: "string" },
1070
+ /** true — профиль задан переменной OPENCODE_SCHEDULER_PROFILE. */
1071
+ pinnedByEnv: { type: "boolean" },
1072
+ profiles: { type: "array", items: ProfileItem },
1073
+ },
1074
+ required: ["current", "pinnedByEnv", "profiles"],
1075
+ } as const;
1076
+
1077
+ const SetProfileInput = {
1078
+ type: "object" as const,
1079
+ properties: {
1080
+ name: { type: "string" },
1081
+ },
1082
+ required: ["name"],
1083
+ additionalProperties: false,
1084
+ } as const;
1085
+
1086
+ const SetProfileOutput = {
1087
+ type: "object" as const,
1088
+ properties: {
1089
+ success: { type: "boolean" },
1090
+ message: { type: "string" },
1091
+ current: { type: "string" },
1092
+ /** true — изменения вступят в силу после перезапуска OpenCode. */
1093
+ restartRequired: { type: "boolean" },
1094
+ },
1095
+ required: ["success", "message", "current", "restartRequired"],
1096
+ } as const;
1097
+
1098
+ const CreateProfileInput = {
1099
+ type: "object" as const,
1100
+ properties: {
1101
+ name: { type: "string" },
1102
+ /** Порт дашборда профиля (по умолчанию — свободный 3782+). */
1103
+ port: { type: "number" },
1104
+ },
1105
+ required: ["name"],
1106
+ additionalProperties: false,
1107
+ } as const;
1108
+
1109
+ const CreateProfileOutput = {
1110
+ type: "object" as const,
1111
+ properties: {
1112
+ success: { type: "boolean" },
1113
+ message: { type: "string" },
1114
+ profile: ProfileItem,
1115
+ error: { type: "string" },
1116
+ },
1117
+ required: ["success"],
1118
+ } as const;
1119
+
1120
+ const DeleteProfileInput = {
1121
+ type: "object" as const,
1122
+ properties: {
1123
+ name: { type: "string" },
1124
+ },
1125
+ required: ["name"],
1126
+ additionalProperties: false,
1127
+ } as const;
1128
+
1129
+ const DeleteProfileOutput = {
1130
+ type: "object" as const,
1131
+ properties: {
1132
+ success: { type: "boolean" },
1133
+ message: { type: "string" },
1134
+ },
1135
+ required: ["success", "message"],
1136
+ } as const;
1137
+
883
1138
  export const SchedulerRpc = Rpc.define({
884
1139
  id: "opencode-windows-scheduler",
885
1140
  methods: {
@@ -906,6 +1161,8 @@ export const SchedulerRpc = Rpc.define({
906
1161
  input: GetTasksInput,
907
1162
  output: CleanupMatrixOrphansOutput,
908
1163
  },
1164
+ cleanup_history: { input: CleanupHistoryInput, output: CleanupHistoryOutput },
1165
+ get_analytics: { input: GetAnalyticsInput, output: GetAnalyticsOutput },
909
1166
  expand_matrix_preview: {
910
1167
  input: ExpandMatrixPreviewInput,
911
1168
  output: ExpandMatrixPreviewOutput,
@@ -914,6 +1171,10 @@ export const SchedulerRpc = Rpc.define({
914
1171
  add_workspace: { input: AddWorkspaceInput, output: AddWorkspaceOutput },
915
1172
  update_workspace: { input: UpdateWorkspaceInput, output: AddWorkspaceOutput },
916
1173
  delete_workspace: { input: DeleteWorkspaceInput, output: DeleteWorkspaceOutput },
1174
+ get_profiles: { input: GetProfilesInput, output: GetProfilesOutput },
1175
+ set_profile: { input: SetProfileInput, output: SetProfileOutput },
1176
+ create_profile: { input: CreateProfileInput, output: CreateProfileOutput },
1177
+ delete_profile: { input: DeleteProfileInput, output: DeleteProfileOutput },
917
1178
  export_tasks: { input: ExportTasksInput, output: ExportTasksOutput },
918
1179
  import_tasks: { input: ImportTasksInput, output: ImportTasksOutput },
919
1180
  get_settings: { input: GetSettingsInput, output: GetSettingsOutput },
@@ -926,6 +1187,10 @@ export const SchedulerRpc = Rpc.define({
926
1187
  input: TestNotificationInput,
927
1188
  output: TestNotificationOutput,
928
1189
  },
1190
+ send_digest: {
1191
+ input: SendDigestInput,
1192
+ output: SendDigestOutput,
1193
+ },
929
1194
  },
930
1195
  events: {},
931
1196
  });