opencode-windows-scheduler 1.1.0 → 1.2.1
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 +60 -1
- package/README.md +18 -8
- package/README.ru.md +13 -3
- package/ROADMAP-STRATEGY.md +2 -2
- package/ROADMAP.md +51 -18
- package/dist/core/analytics.d.ts +10 -0
- package/dist/core/analytics.d.ts.map +1 -1
- package/dist/core/analytics.js +21 -0
- package/dist/core/dry-run.d.ts +18 -1
- package/dist/core/dry-run.d.ts.map +1 -1
- package/dist/core/dry-run.js +49 -3
- package/dist/core/matrix.d.ts.map +1 -1
- package/dist/core/matrix.js +10 -0
- package/dist/core/one-shot.d.ts +62 -0
- package/dist/core/one-shot.d.ts.map +1 -0
- package/dist/core/one-shot.js +126 -0
- package/dist/core/otel.d.ts +4 -0
- package/dist/core/otel.d.ts.map +1 -0
- package/dist/core/otel.js +98 -0
- package/dist/core/prometheus.d.ts +23 -0
- package/dist/core/prometheus.d.ts.map +1 -0
- package/dist/core/prometheus.js +146 -0
- package/dist/core/ps-wrapper.d.ts +36 -2
- package/dist/core/ps-wrapper.d.ts.map +1 -1
- package/dist/core/ps-wrapper.js +124 -4
- package/dist/core/record-history.d.ts.map +1 -1
- package/dist/core/record-history.js +9 -0
- package/dist/core/schedule-gate.d.ts +2 -0
- package/dist/core/schedule-gate.d.ts.map +1 -0
- package/dist/core/schedule-gate.js +182 -0
- package/dist/core/schedule-v2.d.ts +88 -0
- package/dist/core/schedule-v2.d.ts.map +1 -0
- package/dist/core/schedule-v2.js +496 -0
- package/dist/core/scheduler/linux.d.ts +12 -3
- package/dist/core/scheduler/linux.d.ts.map +1 -1
- package/dist/core/scheduler/linux.js +80 -3
- package/dist/core/scheduler/mac.d.ts.map +1 -1
- package/dist/core/scheduler/mac.js +17 -3
- package/dist/core/scheduler/posix.d.ts.map +1 -1
- package/dist/core/scheduler/posix.js +3 -0
- package/dist/core/scheduler/registry.d.ts +4 -0
- package/dist/core/scheduler/registry.d.ts.map +1 -1
- package/dist/core/scheduler/types.d.ts +20 -3
- package/dist/core/scheduler/types.d.ts.map +1 -1
- package/dist/core/scheduler/windows.d.ts.map +1 -1
- package/dist/core/scheduler/windows.js +23 -2
- package/dist/core/session.d.ts +34 -0
- package/dist/core/session.d.ts.map +1 -0
- package/dist/core/session.js +105 -0
- package/dist/core/structured-log.d.ts +84 -0
- package/dist/core/structured-log.d.ts.map +1 -0
- package/dist/core/structured-log.js +137 -0
- package/dist/core/wrappers/bash.d.ts +24 -0
- package/dist/core/wrappers/bash.d.ts.map +1 -1
- package/dist/core/wrappers/bash.js +70 -3
- package/dist/db/history-repo.d.ts +8 -0
- package/dist/db/history-repo.d.ts.map +1 -1
- package/dist/db/history-repo.js +76 -6
- package/dist/db/metrics-repo.d.ts +3 -0
- package/dist/db/metrics-repo.d.ts.map +1 -1
- package/dist/db/metrics-repo.js +16 -8
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +8 -1
- package/dist/db/schema.d.ts +1 -1
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +19 -0
- package/dist/gui-experimental.cjs +1 -0
- package/dist/history.d.ts +7 -0
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +13 -0
- package/dist/index.d.ts +137 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1323 -78
- package/dist/integrations.d.ts +64 -0
- package/dist/integrations.d.ts.map +1 -0
- package/dist/integrations.js +205 -0
- package/dist/notifications.d.ts +112 -6
- package/dist/notifications.d.ts.map +1 -1
- package/dist/notifications.js +396 -34
- package/dist/profiles.d.ts +60 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +209 -0
- package/dist/rpc.d.ts +592 -4
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +233 -6
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +473 -58
- package/dist/settings.d.ts +95 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +186 -8
- package/dist/shared/jobs-view.d.ts +43 -5
- package/dist/shared/jobs-view.d.ts.map +1 -1
- package/dist/shared/jobs-view.js +125 -7
- package/dist/task-transfer.d.ts +32 -3
- package/dist/task-transfer.d.ts.map +1 -1
- package/dist/task-transfer.js +101 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -11
- package/dist/workspaces.d.ts +43 -0
- package/dist/workspaces.d.ts.map +1 -1
- package/dist/workspaces.js +174 -8
- package/docs/ARCHITECTURE.md +32 -12
- package/docs/FEATURES.md +186 -10
- package/gui-experimental.cjs +4 -2
- package/package.json +15 -2
- package/scripts/demo-dashboard.mjs +12 -2
- package/src/core/analytics.ts +36 -0
- package/src/core/dry-run.ts +65 -4
- package/src/core/matrix.ts +10 -0
- package/src/core/one-shot.ts +173 -0
- package/src/core/otel.ts +128 -0
- package/src/core/prometheus.ts +215 -0
- package/src/core/ps-wrapper.ts +144 -4
- package/src/core/record-history.ts +13 -0
- package/src/core/schedule-gate.ts +213 -0
- package/src/core/schedule-v2.ts +533 -0
- package/src/core/scheduler/linux.ts +90 -3
- package/src/core/scheduler/mac.ts +35 -4
- package/src/core/scheduler/posix.ts +3 -0
- package/src/core/scheduler/registry.ts +4 -0
- package/src/core/scheduler/types.ts +20 -3
- package/src/core/scheduler/windows.ts +24 -2
- package/src/core/session.ts +115 -0
- package/src/core/structured-log.ts +205 -0
- package/src/core/wrappers/bash.ts +98 -2
- package/src/db/history-repo.ts +90 -7
- package/src/db/metrics-repo.ts +19 -7
- package/src/db/migrate.ts +7 -1
- package/src/db/schema.ts +25 -0
- package/src/gui.tsx +3832 -2868
- package/src/history.ts +17 -0
- package/src/index.ts +1670 -117
- package/src/integrations.ts +253 -0
- package/src/notifications.ts +516 -40
- package/src/profiles.ts +236 -0
- package/src/rpc.ts +244 -6
- package/src/server.ts +506 -58
- package/src/settings.ts +336 -9
- package/src/shared/jobs-view.ts +158 -8
- package/src/task-transfer.ts +151 -5
- package/src/tui.tsx +290 -14
- package/src/types.ts +3 -13
- package/src/workspaces.ts +214 -8
package/src/profiles.ts
ADDED
|
@@ -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
|
@@ -81,12 +81,28 @@ const TaskItem = {
|
|
|
81
81
|
beforeScript: { type: ["string", "null"] },
|
|
82
82
|
/** Post-flight команда (null — не задана). */
|
|
83
83
|
afterScript: { type: ["string", "null"] },
|
|
84
|
-
/** Тип триггера: "cron" (по умолчанию), "file"
|
|
84
|
+
/** Тип триггера: "cron" (по умолчанию), "file", "mcp-event" или "once". */
|
|
85
85
|
triggerType: { type: ["string", "null"] },
|
|
86
|
+
/** Время разового запуска (triggerType === "once"), ISO-8601; null для остальных. */
|
|
87
|
+
runAt: { type: ["string", "null"] },
|
|
88
|
+
/** Режим сессии OpenCode (Спринт 24): "new" (по умолчанию), "reuse" (--session), "last" (--continue). */
|
|
89
|
+
session: { type: ["string", "null"] },
|
|
90
|
+
/** Идентификатор переиспользуемой сессии (только для session === "reuse"); null для остальных. */
|
|
91
|
+
sessionId: { type: ["string", "null"] },
|
|
92
|
+
/** Сколько запусков переживает reuse-сессия до ротации; null — без ограничения. */
|
|
93
|
+
sessionMaxRuns: { type: ["number", "null"] },
|
|
86
94
|
/** Параметры MCP-события (null — не MCP-триггер). */
|
|
87
95
|
mcpEvent: McpEventSchema,
|
|
88
96
|
/** Путь к файлу/папке для файлового триггера. */
|
|
89
97
|
watchPath: { type: ["string", "null"] },
|
|
98
|
+
/** IANA-часовой пояс задачи (Спринт 19; null — системный). */
|
|
99
|
+
timezone: { type: ["string", "null"] },
|
|
100
|
+
/** Начало окна запуска "HH:MM" (null — без окна). */
|
|
101
|
+
notBefore: { type: ["string", "null"] },
|
|
102
|
+
/** Конец окна запуска "HH:MM" (null — без окна). */
|
|
103
|
+
notAfter: { type: ["string", "null"] },
|
|
104
|
+
/** Пауза до даты в ISO (null — автопродолжение не запланировано). */
|
|
105
|
+
pausedUntil: { type: ["string", "null"] },
|
|
90
106
|
/** Рабочая директория задачи (null — папка проекта по умолчанию). */
|
|
91
107
|
workingDirectory: { type: ["string", "null"] },
|
|
92
108
|
/** Привязка к multi-repo workspace (null — без workspace). */
|
|
@@ -105,6 +121,18 @@ const TaskItem = {
|
|
|
105
121
|
matrixParentId: { type: ["string", "null"] },
|
|
106
122
|
/** true — задача является родителем матрицы. */
|
|
107
123
|
isMatrixParent: { type: "boolean" },
|
|
124
|
+
/** true — задача поставлена на паузу (disabled в планировщике ОС). */
|
|
125
|
+
paused: { type: "boolean" },
|
|
126
|
+
/** true — определение есть в БД, но задачи нет в планировщике ОС. */
|
|
127
|
+
orphaned: { type: "boolean" },
|
|
128
|
+
/** Всего запусков именно этой задачи. */
|
|
129
|
+
runsTotal: { type: "number" },
|
|
130
|
+
/** Успешных запусков этой задачи. */
|
|
131
|
+
runsSuccess: { type: "number" },
|
|
132
|
+
/** Ошибок и таймаутов этой задачи. */
|
|
133
|
+
runsError: { type: "number" },
|
|
134
|
+
/** Частичных выполнений этой задачи (partial). */
|
|
135
|
+
runsPartial: { type: "number" },
|
|
108
136
|
/** Агрегат по клонам для родителя (null — не матрица). */
|
|
109
137
|
matrixSummary: {
|
|
110
138
|
type: ["object", "null"],
|
|
@@ -164,8 +192,16 @@ const CreateTaskInput = {
|
|
|
164
192
|
beforeScript: { type: "string" },
|
|
165
193
|
/** Команда после запуска (post-flight). */
|
|
166
194
|
afterScript: { type: "string" },
|
|
167
|
-
/** Тип триггера: "cron" (по
|
|
195
|
+
/** Тип триггера: "cron" (по умолчанию; нужен schedule), "file", "mcp-event" или "once" (нужен runAt либо delaySeconds). */
|
|
168
196
|
triggerType: { type: "string" },
|
|
197
|
+
/** Время разового запуска (triggerType === "once"), ISO-8601. Взаимоисключает schedule/newSchedule. */
|
|
198
|
+
runAt: { type: "string" },
|
|
199
|
+
/** Отложенный разовый запуск через N секунд (triggerType === "once"). Взаимоисключает runAt. */
|
|
200
|
+
delaySeconds: { type: "number" },
|
|
201
|
+
/** Режим сессии OpenCode (Спринт 24): "new" (по умолчанию), "reuse" (--session <id>), "last" (--continue). sessionId генерируется плагином. */
|
|
202
|
+
session: { type: "string" },
|
|
203
|
+
/** Сколько запусков переживает reuse-сессия до ротации (удаление и чистый старт). 0/не задано — без ограничения. */
|
|
204
|
+
sessionMaxRuns: { type: "number" },
|
|
169
205
|
/** Параметры MCP-события. */
|
|
170
206
|
mcpEvent: McpEventSchema,
|
|
171
207
|
/** Путь к файлу/папке для файлового триггера. */
|
|
@@ -180,8 +216,14 @@ const CreateTaskInput = {
|
|
|
180
216
|
deniedTools: { type: "array", items: { type: "string" } },
|
|
181
217
|
/** Matrix (fan-out): раскладывает задачу-шаблон на клоны по workspace. */
|
|
182
218
|
matrix: MatrixSchema,
|
|
219
|
+
/** IANA-часовой пояс задачи (например, Europe/Moscow). Пусто — системный. */
|
|
220
|
+
timezone: { type: "string" },
|
|
221
|
+
/** Начало окна запуска "HH:MM"; вне окна запуск переносится. */
|
|
222
|
+
notBefore: { type: "string" },
|
|
223
|
+
/** Конец окна запуска "HH:MM"; может быть меньше notBefore (через полночь). */
|
|
224
|
+
notAfter: { type: "string" },
|
|
183
225
|
},
|
|
184
|
-
required: ["name", "
|
|
226
|
+
required: ["name", "prompt"],
|
|
185
227
|
} as const;
|
|
186
228
|
|
|
187
229
|
const CreateTaskOutput = {
|
|
@@ -253,7 +295,12 @@ const HistoryRecord = {
|
|
|
253
295
|
const GetHistoryInput = {
|
|
254
296
|
type: "object" as const,
|
|
255
297
|
properties: {
|
|
298
|
+
/** Сколько последних записей вернуть (по умолчанию 20, максимум 200). */
|
|
256
299
|
limit: { type: "number" },
|
|
300
|
+
/** Фильтр по имени задачи (регистр не важен). */
|
|
301
|
+
taskName: { type: "string" },
|
|
302
|
+
/** Фильтр по статусу: success | error | partial | running | timeout. */
|
|
303
|
+
status: { type: "string" },
|
|
257
304
|
},
|
|
258
305
|
additionalProperties: false,
|
|
259
306
|
} as const;
|
|
@@ -361,7 +408,7 @@ const GetSettingsInput = {
|
|
|
361
408
|
additionalProperties: false,
|
|
362
409
|
} as const;
|
|
363
410
|
|
|
364
|
-
/** Настройки уведомлений: webhook (
|
|
411
|
+
/** Настройки уведомлений: webhook, шаблоны, фильтры, матрицы и дайджест (Спринт 20). */
|
|
365
412
|
const NotificationSettingsSchema = {
|
|
366
413
|
type: "object" as const,
|
|
367
414
|
properties: {
|
|
@@ -372,9 +419,48 @@ const NotificationSettingsSchema = {
|
|
|
372
419
|
properties: {
|
|
373
420
|
enabled: { type: "boolean" },
|
|
374
421
|
url: { type: "string" },
|
|
422
|
+
timeoutMs: { type: "number" },
|
|
423
|
+
retryCount: { type: "number" },
|
|
424
|
+
retryDelayMs: { type: "number" },
|
|
375
425
|
},
|
|
376
426
|
required: ["enabled", "url"],
|
|
377
427
|
},
|
|
428
|
+
templates: {
|
|
429
|
+
type: "object" as const,
|
|
430
|
+
properties: {
|
|
431
|
+
success: { type: "string" },
|
|
432
|
+
error: { type: "string" },
|
|
433
|
+
},
|
|
434
|
+
required: ["success", "error"],
|
|
435
|
+
},
|
|
436
|
+
filters: {
|
|
437
|
+
type: "object" as const,
|
|
438
|
+
properties: {
|
|
439
|
+
include: { type: "array", items: { type: "string" } },
|
|
440
|
+
exclude: { type: "array", items: { type: "string" } },
|
|
441
|
+
},
|
|
442
|
+
required: ["include", "exclude"],
|
|
443
|
+
},
|
|
444
|
+
matrix: {
|
|
445
|
+
type: "object" as const,
|
|
446
|
+
properties: {
|
|
447
|
+
enabled: { type: "boolean" },
|
|
448
|
+
onPartial: { type: "boolean" },
|
|
449
|
+
onAllFailed: { type: "boolean" },
|
|
450
|
+
stuckAfterMinutes: { type: "number" },
|
|
451
|
+
},
|
|
452
|
+
required: ["enabled", "onPartial", "onAllFailed", "stuckAfterMinutes"],
|
|
453
|
+
},
|
|
454
|
+
digest: {
|
|
455
|
+
type: "object" as const,
|
|
456
|
+
properties: {
|
|
457
|
+
enabled: { type: "boolean" },
|
|
458
|
+
frequency: { type: "string", enum: ["daily", "weekly"] },
|
|
459
|
+
time: { type: "string" },
|
|
460
|
+
lastSentAt: { type: ["string", "null"] },
|
|
461
|
+
},
|
|
462
|
+
required: ["enabled", "frequency", "time"],
|
|
463
|
+
},
|
|
378
464
|
},
|
|
379
465
|
required: ["enabled", "onlyOnError"],
|
|
380
466
|
} as const;
|
|
@@ -489,6 +575,22 @@ const TestNotificationOutput = {
|
|
|
489
575
|
required: ["success", "message"],
|
|
490
576
|
} as const;
|
|
491
577
|
|
|
578
|
+
/** Ручная отправка дайджеста (Спринт 20); не сдвигает плановое расписание. */
|
|
579
|
+
const SendDigestInput = {
|
|
580
|
+
type: "object" as const,
|
|
581
|
+
properties: {},
|
|
582
|
+
additionalProperties: false,
|
|
583
|
+
} as const;
|
|
584
|
+
|
|
585
|
+
const SendDigestOutput = {
|
|
586
|
+
type: "object" as const,
|
|
587
|
+
properties: {
|
|
588
|
+
success: { type: "boolean" },
|
|
589
|
+
message: { type: "string" },
|
|
590
|
+
},
|
|
591
|
+
required: ["success", "message"],
|
|
592
|
+
} as const;
|
|
593
|
+
|
|
492
594
|
const TemplateItem = {
|
|
493
595
|
type: "object" as const,
|
|
494
596
|
properties: {
|
|
@@ -602,7 +704,18 @@ const DeleteTemplateOutput = {
|
|
|
602
704
|
required: ["success"],
|
|
603
705
|
} as const;
|
|
604
706
|
|
|
605
|
-
const PauseResumeInput =
|
|
707
|
+
const PauseResumeInput = {
|
|
708
|
+
type: "object" as const,
|
|
709
|
+
properties: {
|
|
710
|
+
name: { type: "string" },
|
|
711
|
+
/**
|
|
712
|
+
* Только для pause: пауза до указанного момента (ISO). Плагин включит
|
|
713
|
+
* задачу автоматически; пусто — бессрочная пауза.
|
|
714
|
+
*/
|
|
715
|
+
until: { type: "string" },
|
|
716
|
+
},
|
|
717
|
+
required: ["name"],
|
|
718
|
+
} as const;
|
|
606
719
|
|
|
607
720
|
const UpdateTaskInput = {
|
|
608
721
|
type: "object" as const,
|
|
@@ -625,8 +738,16 @@ const UpdateTaskInput = {
|
|
|
625
738
|
beforeScript: { type: "string" },
|
|
626
739
|
/** Команда после запуска (post-flight). */
|
|
627
740
|
afterScript: { type: "string" },
|
|
628
|
-
/** Тип триггера: "cron" (по
|
|
741
|
+
/** Тип триггера: "cron" (по умолчанию; нужен schedule), "file", "mcp-event" или "once" (нужен runAt либо delaySeconds). */
|
|
629
742
|
triggerType: { type: "string" },
|
|
743
|
+
/** Время разового запуска (triggerType === "once"), ISO-8601. Взаимоисключает schedule/newSchedule. */
|
|
744
|
+
runAt: { type: "string" },
|
|
745
|
+
/** Отложенный разовый запуск через N секунд (triggerType === "once"). Взаимоисключает runAt. */
|
|
746
|
+
delaySeconds: { type: "number" },
|
|
747
|
+
/** Режим сессии OpenCode (Спринт 24): "new" (по умолчанию), "reuse" (--session <id>), "last" (--continue). sessionId генерируется плагином. */
|
|
748
|
+
session: { type: "string" },
|
|
749
|
+
/** Сколько запусков переживает reuse-сессия до ротации (удаление и чистый старт). 0/не задано — без ограничения. */
|
|
750
|
+
sessionMaxRuns: { type: "number" },
|
|
630
751
|
/** Параметры MCP-события. */
|
|
631
752
|
mcpEvent: McpEventSchema,
|
|
632
753
|
/** Путь к файлу/папке для файлового триггера. */
|
|
@@ -641,6 +762,12 @@ const UpdateTaskInput = {
|
|
|
641
762
|
deniedTools: { type: "array", items: { type: "string" } },
|
|
642
763
|
/** Matrix (fan-out): раскладывает задачу-шаблон на клоны по workspace. */
|
|
643
764
|
matrix: MatrixSchema,
|
|
765
|
+
/** IANA-часовой пояс задачи. Пустая строка — сбросить на системный. */
|
|
766
|
+
timezone: { type: "string" },
|
|
767
|
+
/** Начало окна запуска "HH:MM". Пустая строка — сбросить окно. */
|
|
768
|
+
notBefore: { type: "string" },
|
|
769
|
+
/** Конец окна запуска "HH:MM". Пустая строка — сбросить окно. */
|
|
770
|
+
notAfter: { type: "string" },
|
|
644
771
|
},
|
|
645
772
|
required: ["name"],
|
|
646
773
|
} as const;
|
|
@@ -656,6 +783,10 @@ const WorkspaceItem = {
|
|
|
656
783
|
gitRemote: { type: ["string", "null"] },
|
|
657
784
|
gitBranch: { type: ["string", "null"] },
|
|
658
785
|
color: { type: ["string", "null"] },
|
|
786
|
+
/** Env-переменные workspace; значения секретов замаскированы (***). */
|
|
787
|
+
env: { type: ["object", "null"], additionalProperties: { type: "string" } },
|
|
788
|
+
/** Путь к .env-файлу workspace (null — не задан). */
|
|
789
|
+
envFile: { type: ["string", "null"] },
|
|
659
790
|
createdAt: { type: "string" },
|
|
660
791
|
},
|
|
661
792
|
required: ["id", "name", "path", "createdAt"],
|
|
@@ -681,6 +812,10 @@ const AddWorkspaceInput = {
|
|
|
681
812
|
name: { type: "string" },
|
|
682
813
|
path: { type: "string" },
|
|
683
814
|
color: { type: "string" },
|
|
815
|
+
/** Env-переменные workspace (ключ → значение). */
|
|
816
|
+
env: { type: ["object", "null"], additionalProperties: { type: "string" } },
|
|
817
|
+
/** Путь к .env-файлу workspace. */
|
|
818
|
+
envFile: { type: ["string", "null"] },
|
|
684
819
|
},
|
|
685
820
|
required: ["path"],
|
|
686
821
|
additionalProperties: false,
|
|
@@ -703,6 +838,10 @@ const UpdateWorkspaceInput = {
|
|
|
703
838
|
name: { type: "string" },
|
|
704
839
|
path: { type: "string" },
|
|
705
840
|
color: { type: "string" },
|
|
841
|
+
/** Env-переменные workspace; null — очистить, отсутствие — не менять. */
|
|
842
|
+
env: { type: ["object", "null"], additionalProperties: { type: "string" } },
|
|
843
|
+
/** Путь к .env-файлу; null — очистить. */
|
|
844
|
+
envFile: { type: ["string", "null"] },
|
|
706
845
|
},
|
|
707
846
|
required: ["id"],
|
|
708
847
|
additionalProperties: false,
|
|
@@ -944,6 +1083,97 @@ const CleanupMatrixOrphansOutput = {
|
|
|
944
1083
|
required: ["success", "message", "removed"],
|
|
945
1084
|
} as const;
|
|
946
1085
|
|
|
1086
|
+
/** Профиль (Спринт 21): отдельная БД, настройки, логи и порт дашборда. */
|
|
1087
|
+
const ProfileItem = {
|
|
1088
|
+
type: "object" as const,
|
|
1089
|
+
properties: {
|
|
1090
|
+
name: { type: "string" },
|
|
1091
|
+
dir: { type: "string" },
|
|
1092
|
+
port: { type: ["number", "null"] },
|
|
1093
|
+
isDefault: { type: "boolean" },
|
|
1094
|
+
active: { type: "boolean" },
|
|
1095
|
+
},
|
|
1096
|
+
required: ["name", "dir", "isDefault", "active"],
|
|
1097
|
+
} as const;
|
|
1098
|
+
|
|
1099
|
+
const GetProfilesInput = {
|
|
1100
|
+
type: "object" as const,
|
|
1101
|
+
properties: {},
|
|
1102
|
+
additionalProperties: false,
|
|
1103
|
+
} as const;
|
|
1104
|
+
|
|
1105
|
+
const GetProfilesOutput = {
|
|
1106
|
+
type: "object" as const,
|
|
1107
|
+
properties: {
|
|
1108
|
+
current: { type: "string" },
|
|
1109
|
+
/** true — профиль задан переменной OPENCODE_SCHEDULER_PROFILE. */
|
|
1110
|
+
pinnedByEnv: { type: "boolean" },
|
|
1111
|
+
profiles: { type: "array", items: ProfileItem },
|
|
1112
|
+
},
|
|
1113
|
+
required: ["current", "pinnedByEnv", "profiles"],
|
|
1114
|
+
} as const;
|
|
1115
|
+
|
|
1116
|
+
const SetProfileInput = {
|
|
1117
|
+
type: "object" as const,
|
|
1118
|
+
properties: {
|
|
1119
|
+
name: { type: "string" },
|
|
1120
|
+
},
|
|
1121
|
+
required: ["name"],
|
|
1122
|
+
additionalProperties: false,
|
|
1123
|
+
} as const;
|
|
1124
|
+
|
|
1125
|
+
const SetProfileOutput = {
|
|
1126
|
+
type: "object" as const,
|
|
1127
|
+
properties: {
|
|
1128
|
+
success: { type: "boolean" },
|
|
1129
|
+
message: { type: "string" },
|
|
1130
|
+
current: { type: "string" },
|
|
1131
|
+
/** true — изменения вступят в силу после перезапуска OpenCode. */
|
|
1132
|
+
restartRequired: { type: "boolean" },
|
|
1133
|
+
},
|
|
1134
|
+
required: ["success", "message", "current", "restartRequired"],
|
|
1135
|
+
} as const;
|
|
1136
|
+
|
|
1137
|
+
const CreateProfileInput = {
|
|
1138
|
+
type: "object" as const,
|
|
1139
|
+
properties: {
|
|
1140
|
+
name: { type: "string" },
|
|
1141
|
+
/** Порт дашборда профиля (по умолчанию — свободный 3782+). */
|
|
1142
|
+
port: { type: "number" },
|
|
1143
|
+
},
|
|
1144
|
+
required: ["name"],
|
|
1145
|
+
additionalProperties: false,
|
|
1146
|
+
} as const;
|
|
1147
|
+
|
|
1148
|
+
const CreateProfileOutput = {
|
|
1149
|
+
type: "object" as const,
|
|
1150
|
+
properties: {
|
|
1151
|
+
success: { type: "boolean" },
|
|
1152
|
+
message: { type: "string" },
|
|
1153
|
+
profile: ProfileItem,
|
|
1154
|
+
error: { type: "string" },
|
|
1155
|
+
},
|
|
1156
|
+
required: ["success"],
|
|
1157
|
+
} as const;
|
|
1158
|
+
|
|
1159
|
+
const DeleteProfileInput = {
|
|
1160
|
+
type: "object" as const,
|
|
1161
|
+
properties: {
|
|
1162
|
+
name: { type: "string" },
|
|
1163
|
+
},
|
|
1164
|
+
required: ["name"],
|
|
1165
|
+
additionalProperties: false,
|
|
1166
|
+
} as const;
|
|
1167
|
+
|
|
1168
|
+
const DeleteProfileOutput = {
|
|
1169
|
+
type: "object" as const,
|
|
1170
|
+
properties: {
|
|
1171
|
+
success: { type: "boolean" },
|
|
1172
|
+
message: { type: "string" },
|
|
1173
|
+
},
|
|
1174
|
+
required: ["success", "message"],
|
|
1175
|
+
} as const;
|
|
1176
|
+
|
|
947
1177
|
export const SchedulerRpc = Rpc.define({
|
|
948
1178
|
id: "opencode-windows-scheduler",
|
|
949
1179
|
methods: {
|
|
@@ -980,6 +1210,10 @@ export const SchedulerRpc = Rpc.define({
|
|
|
980
1210
|
add_workspace: { input: AddWorkspaceInput, output: AddWorkspaceOutput },
|
|
981
1211
|
update_workspace: { input: UpdateWorkspaceInput, output: AddWorkspaceOutput },
|
|
982
1212
|
delete_workspace: { input: DeleteWorkspaceInput, output: DeleteWorkspaceOutput },
|
|
1213
|
+
get_profiles: { input: GetProfilesInput, output: GetProfilesOutput },
|
|
1214
|
+
set_profile: { input: SetProfileInput, output: SetProfileOutput },
|
|
1215
|
+
create_profile: { input: CreateProfileInput, output: CreateProfileOutput },
|
|
1216
|
+
delete_profile: { input: DeleteProfileInput, output: DeleteProfileOutput },
|
|
983
1217
|
export_tasks: { input: ExportTasksInput, output: ExportTasksOutput },
|
|
984
1218
|
import_tasks: { input: ImportTasksInput, output: ImportTasksOutput },
|
|
985
1219
|
get_settings: { input: GetSettingsInput, output: GetSettingsOutput },
|
|
@@ -992,6 +1226,10 @@ export const SchedulerRpc = Rpc.define({
|
|
|
992
1226
|
input: TestNotificationInput,
|
|
993
1227
|
output: TestNotificationOutput,
|
|
994
1228
|
},
|
|
1229
|
+
send_digest: {
|
|
1230
|
+
input: SendDigestInput,
|
|
1231
|
+
output: SendDigestOutput,
|
|
1232
|
+
},
|
|
995
1233
|
},
|
|
996
1234
|
events: {},
|
|
997
1235
|
});
|