opencode-windows-scheduler 1.1.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 (84) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/README.md +13 -3
  3. package/README.ru.md +13 -3
  4. package/ROADMAP.md +20 -13
  5. package/dist/core/analytics.d.ts +10 -0
  6. package/dist/core/analytics.d.ts.map +1 -1
  7. package/dist/core/analytics.js +21 -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/schedule-gate.d.ts +2 -0
  17. package/dist/core/schedule-gate.d.ts.map +1 -0
  18. package/dist/core/schedule-gate.js +182 -0
  19. package/dist/core/schedule-v2.d.ts +88 -0
  20. package/dist/core/schedule-v2.d.ts.map +1 -0
  21. package/dist/core/schedule-v2.js +496 -0
  22. package/dist/core/scheduler/types.d.ts +15 -0
  23. package/dist/core/scheduler/types.d.ts.map +1 -1
  24. package/dist/core/scheduler/windows.d.ts.map +1 -1
  25. package/dist/core/scheduler/windows.js +13 -1
  26. package/dist/core/wrappers/bash.d.ts +15 -0
  27. package/dist/core/wrappers/bash.d.ts.map +1 -1
  28. package/dist/core/wrappers/bash.js +44 -1
  29. package/dist/db/history-repo.d.ts +8 -0
  30. package/dist/db/history-repo.d.ts.map +1 -1
  31. package/dist/db/history-repo.js +13 -0
  32. package/dist/db/schema.d.ts +1 -1
  33. package/dist/db/schema.d.ts.map +1 -1
  34. package/dist/db/schema.js +11 -0
  35. package/dist/index.d.ts +117 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +1010 -54
  38. package/dist/notifications.d.ts +112 -6
  39. package/dist/notifications.d.ts.map +1 -1
  40. package/dist/notifications.js +396 -34
  41. package/dist/profiles.d.ts +60 -0
  42. package/dist/profiles.d.ts.map +1 -0
  43. package/dist/profiles.js +209 -0
  44. package/dist/rpc.d.ts +511 -0
  45. package/dist/rpc.d.ts.map +1 -1
  46. package/dist/rpc.js +190 -2
  47. package/dist/server.d.ts.map +1 -1
  48. package/dist/server.js +5 -2
  49. package/dist/settings.d.ts +57 -0
  50. package/dist/settings.d.ts.map +1 -1
  51. package/dist/settings.js +118 -8
  52. package/dist/task-transfer.d.ts +13 -0
  53. package/dist/task-transfer.d.ts.map +1 -1
  54. package/dist/task-transfer.js +26 -0
  55. package/dist/types.d.ts.map +1 -1
  56. package/dist/types.js +3 -11
  57. package/dist/workspaces.d.ts +43 -0
  58. package/dist/workspaces.d.ts.map +1 -1
  59. package/dist/workspaces.js +174 -8
  60. package/docs/ARCHITECTURE.md +32 -12
  61. package/docs/FEATURES.md +86 -7
  62. package/gui-experimental.cjs +4 -2
  63. package/package.json +6 -2
  64. package/src/core/analytics.ts +36 -0
  65. package/src/core/dry-run.ts +42 -0
  66. package/src/core/matrix.ts +10 -0
  67. package/src/core/ps-wrapper.ts +117 -3
  68. package/src/core/schedule-gate.ts +213 -0
  69. package/src/core/schedule-v2.ts +533 -0
  70. package/src/core/scheduler/types.ts +15 -0
  71. package/src/core/scheduler/windows.ts +13 -1
  72. package/src/core/wrappers/bash.ts +60 -0
  73. package/src/db/history-repo.ts +23 -0
  74. package/src/db/schema.ts +14 -0
  75. package/src/gui.tsx +767 -22
  76. package/src/index.ts +1226 -52
  77. package/src/notifications.ts +516 -40
  78. package/src/profiles.ts +236 -0
  79. package/src/rpc.ts +201 -2
  80. package/src/server.ts +5 -2
  81. package/src/settings.ts +214 -9
  82. package/src/task-transfer.ts +44 -0
  83. package/src/types.ts +3 -13
  84. package/src/workspaces.ts +214 -8
@@ -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,9 +388,48 @@ 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;
@@ -489,6 +544,22 @@ const TestNotificationOutput = {
489
544
  required: ["success", "message"],
490
545
  } as const;
491
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
+
492
563
  const TemplateItem = {
493
564
  type: "object" as const,
494
565
  properties: {
@@ -602,7 +673,18 @@ const DeleteTemplateOutput = {
602
673
  required: ["success"],
603
674
  } as const;
604
675
 
605
- 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;
606
688
 
607
689
  const UpdateTaskInput = {
608
690
  type: "object" as const,
@@ -641,6 +723,12 @@ const UpdateTaskInput = {
641
723
  deniedTools: { type: "array", items: { type: "string" } },
642
724
  /** Matrix (fan-out): раскладывает задачу-шаблон на клоны по workspace. */
643
725
  matrix: MatrixSchema,
726
+ /** IANA-часовой пояс задачи. Пустая строка — сбросить на системный. */
727
+ timezone: { type: "string" },
728
+ /** Начало окна запуска "HH:MM". Пустая строка — сбросить окно. */
729
+ notBefore: { type: "string" },
730
+ /** Конец окна запуска "HH:MM". Пустая строка — сбросить окно. */
731
+ notAfter: { type: "string" },
644
732
  },
645
733
  required: ["name"],
646
734
  } as const;
@@ -656,6 +744,10 @@ const WorkspaceItem = {
656
744
  gitRemote: { type: ["string", "null"] },
657
745
  gitBranch: { type: ["string", "null"] },
658
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"] },
659
751
  createdAt: { type: "string" },
660
752
  },
661
753
  required: ["id", "name", "path", "createdAt"],
@@ -681,6 +773,10 @@ const AddWorkspaceInput = {
681
773
  name: { type: "string" },
682
774
  path: { type: "string" },
683
775
  color: { type: "string" },
776
+ /** Env-переменные workspace (ключ → значение). */
777
+ env: { type: ["object", "null"], additionalProperties: { type: "string" } },
778
+ /** Путь к .env-файлу workspace. */
779
+ envFile: { type: ["string", "null"] },
684
780
  },
685
781
  required: ["path"],
686
782
  additionalProperties: false,
@@ -703,6 +799,10 @@ const UpdateWorkspaceInput = {
703
799
  name: { type: "string" },
704
800
  path: { type: "string" },
705
801
  color: { type: "string" },
802
+ /** Env-переменные workspace; null — очистить, отсутствие — не менять. */
803
+ env: { type: ["object", "null"], additionalProperties: { type: "string" } },
804
+ /** Путь к .env-файлу; null — очистить. */
805
+ envFile: { type: ["string", "null"] },
706
806
  },
707
807
  required: ["id"],
708
808
  additionalProperties: false,
@@ -944,6 +1044,97 @@ const CleanupMatrixOrphansOutput = {
944
1044
  required: ["success", "message", "removed"],
945
1045
  } as const;
946
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
+
947
1138
  export const SchedulerRpc = Rpc.define({
948
1139
  id: "opencode-windows-scheduler",
949
1140
  methods: {
@@ -980,6 +1171,10 @@ export const SchedulerRpc = Rpc.define({
980
1171
  add_workspace: { input: AddWorkspaceInput, output: AddWorkspaceOutput },
981
1172
  update_workspace: { input: UpdateWorkspaceInput, output: AddWorkspaceOutput },
982
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 },
983
1178
  export_tasks: { input: ExportTasksInput, output: ExportTasksOutput },
984
1179
  import_tasks: { input: ImportTasksInput, output: ImportTasksOutput },
985
1180
  get_settings: { input: GetSettingsInput, output: GetSettingsOutput },
@@ -992,6 +1187,10 @@ export const SchedulerRpc = Rpc.define({
992
1187
  input: TestNotificationInput,
993
1188
  output: TestNotificationOutput,
994
1189
  },
1190
+ send_digest: {
1191
+ input: SendDigestInput,
1192
+ output: SendDigestOutput,
1193
+ },
995
1194
  },
996
1195
  events: {},
997
1196
  });
package/src/server.ts CHANGED
@@ -9,6 +9,7 @@ import { getSchedulerTitle } from "./core/scheduler/index.js";
9
9
  import { getPluginVersion } from "./version.js";
10
10
  import { checkpointDb, getDbFile, getDbStatus } from "./db/index.js";
11
11
  import { listWorkspaces } from "./workspaces.js";
12
+ import { getProfileName, getProfilePort } from "./profiles.js";
12
13
  import { simulatePipeline } from "./core/dry-run.js";
13
14
 
14
15
  /**
@@ -255,7 +256,8 @@ export async function startDashboardServer(
255
256
  if (running) return { port: running.port };
256
257
  if (starting) return starting;
257
258
 
258
- const preferred = ports?.preferred ?? PREFERRED_PORT;
259
+ // Спринт 21: у профиля может быть свой порт (profile.json / OPENCODE_SCHEDULER_PORT).
260
+ const preferred = ports?.preferred ?? getProfilePort(getProfileName()) ?? PREFERRED_PORT;
259
261
  const fallback = ports?.fallback ?? FALLBACK_PORT;
260
262
  // Последний кандидат — порт 0: ОС сама выдаст гарантированно свободный порт.
261
263
  const candidates = ports
@@ -525,6 +527,7 @@ async function handleRequest(
525
527
  port: getDashboardPort(),
526
528
  version: getPluginVersion(),
527
529
  scheduler: getSchedulerTitle(),
530
+ profile: getProfileName(),
528
531
  queueDepth: countRunningRecords(),
529
532
  db: getDbStatus(),
530
533
  });
@@ -1075,7 +1078,7 @@ function renderPage(): string {
1075
1078
  <header>
1076
1079
  <div>
1077
1080
  <h1>❄️ ${getSchedulerTitle()} ❄️</h1>
1078
- <div class="sub">Локальный веб-дашборд · Local AI CI/CD Orchestrator</div>
1081
+ <div class="sub">Локальный веб-дашборд · Local AI CI/CD Orchestrator · профиль <b>${getProfileName()}</b></div>
1079
1082
  </div>
1080
1083
  <div style="text-align:right">
1081
1084
  <a class="btn btn-db" href="/api/export-db" download>💾 Скачать БД</a>