opencode-windows-scheduler 1.2.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 +16 -1
- package/README.md +5 -5
- package/ROADMAP-STRATEGY.md +2 -2
- package/ROADMAP.md +31 -5
- package/dist/core/dry-run.d.ts +5 -1
- package/dist/core/dry-run.d.ts.map +1 -1
- package/dist/core/dry-run.js +20 -4
- 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 +6 -2
- package/dist/core/ps-wrapper.d.ts.map +1 -1
- package/dist/core/ps-wrapper.js +25 -3
- package/dist/core/record-history.d.ts.map +1 -1
- package/dist/core/record-history.js +9 -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 +5 -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 +10 -1
- 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 +9 -0
- package/dist/core/wrappers/bash.d.ts.map +1 -1
- package/dist/core/wrappers/bash.js +27 -3
- package/dist/db/history-repo.d.ts.map +1 -1
- package/dist/db/history-repo.js +63 -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 +8 -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 +22 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +330 -41
- package/dist/integrations.d.ts +64 -0
- package/dist/integrations.d.ts.map +1 -0
- package/dist/integrations.js +205 -0
- package/dist/rpc.d.ts +81 -4
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +43 -4
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +468 -56
- package/dist/settings.d.ts +38 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +68 -0
- 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 +19 -3
- package/dist/task-transfer.d.ts.map +1 -1
- package/dist/task-transfer.js +75 -3
- package/docs/FEATURES.md +101 -4
- package/gui-experimental.cjs +4 -4
- package/package.json +11 -2
- package/scripts/demo-dashboard.mjs +12 -2
- package/src/core/dry-run.ts +24 -5
- 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 +29 -3
- package/src/core/record-history.ts +13 -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 +5 -3
- package/src/core/scheduler/windows.ts +11 -1
- package/src/core/session.ts +115 -0
- package/src/core/structured-log.ts +205 -0
- package/src/core/wrappers/bash.ts +38 -2
- package/src/db/history-repo.ts +67 -7
- package/src/db/metrics-repo.ts +19 -7
- package/src/db/migrate.ts +7 -1
- package/src/db/schema.ts +11 -0
- package/src/gui.tsx +3832 -3613
- package/src/history.ts +17 -0
- package/src/index.ts +426 -47
- package/src/integrations.ts +253 -0
- package/src/rpc.ts +43 -4
- package/src/server.ts +501 -56
- package/src/settings.ts +122 -0
- package/src/shared/jobs-view.ts +158 -8
- package/src/task-transfer.ts +107 -5
- package/src/tui.tsx +290 -14
package/src/index.ts
CHANGED
|
@@ -8,6 +8,16 @@ import path from "node:path";
|
|
|
8
8
|
import { LockManager } from "./core/lock.js";
|
|
9
9
|
import { LOCK_DIR, LOG_DIR, PLUGIN_DIR, sanitizeName } from "./types.js";
|
|
10
10
|
import { parseCron, buildScheduleGate, isValidIanaTimeZone, validateLaunchWindow, prevRun } from "./core/schedule-v2.js";
|
|
11
|
+
import {
|
|
12
|
+
buildLaunchdOneShotCleanup,
|
|
13
|
+
normalizeOneShotRunAt,
|
|
14
|
+
} from "./core/one-shot.js";
|
|
15
|
+
import {
|
|
16
|
+
generateSessionId,
|
|
17
|
+
normalizeSessionMode,
|
|
18
|
+
preservedSessionRunCount,
|
|
19
|
+
type SessionMode,
|
|
20
|
+
} from "./core/session.js";
|
|
11
21
|
import { ensureWrapper, writePromptFile, writeWrapperCmd, lockFilePath, requestImmediateRun } from "./core/ps-wrapper.js";
|
|
12
22
|
import { getSchedulerBackend } from "./core/scheduler/index.js";
|
|
13
23
|
import { SCHEDULER_SKILL_ID, loadSchedulerSkill } from "./skill.js";
|
|
@@ -27,9 +37,13 @@ import {
|
|
|
27
37
|
syncMatrixFamily,
|
|
28
38
|
} from "./core/matrix.js";
|
|
29
39
|
import { SchedulerRpc } from "./rpc.js";
|
|
30
|
-
import { loadHistory, loadMetrics } from "./history.js";
|
|
40
|
+
import { latestHistoryByTask, loadHistory, loadMetrics } from "./history.js";
|
|
31
41
|
import { loadSettings, saveSettings } from "./settings.js";
|
|
32
|
-
import type {
|
|
42
|
+
import type {
|
|
43
|
+
HistorySettings,
|
|
44
|
+
IntegrationSettings,
|
|
45
|
+
NotificationSettings,
|
|
46
|
+
} from "./settings.js";
|
|
33
47
|
import { runHistoryRetention, maybeRunHistoryRetention } from "./core/retention.js";
|
|
34
48
|
import { buildAnalytics } from "./core/analytics.js";
|
|
35
49
|
import { getHistory, listRunningRecords } from "./db/history-repo.js";
|
|
@@ -186,8 +200,38 @@ export const scheduleTaskSchema = z.object({
|
|
|
186
200
|
name: z.string().describe("Unique task name (the plugin prefix is applied automatically)."),
|
|
187
201
|
schedule: z
|
|
188
202
|
.string()
|
|
203
|
+
.optional()
|
|
204
|
+
.describe(
|
|
205
|
+
"Cron expression (5 fields: minute hour day-of-month month day-of-week). Required for triggerType=cron; ignored for file/mcp-event. Supports ranges, lists, */N steps, month/weekday names, @every 15m|2h|1d, L (last day of month) and FRI#3 (third Friday). Expressions schtasks cannot express are checked every minute inside the wrapper."
|
|
206
|
+
),
|
|
207
|
+
runAt: z
|
|
208
|
+
.string()
|
|
209
|
+
.optional()
|
|
210
|
+
.describe(
|
|
211
|
+
"Absolute one-shot start time in ISO-8601 (e.g. 2026-12-01T09:00:00Z). Requires triggerType=once; mutually exclusive with delaySeconds (runAt wins)."
|
|
212
|
+
),
|
|
213
|
+
delaySeconds: z
|
|
214
|
+
.number()
|
|
215
|
+
.int()
|
|
216
|
+
.positive()
|
|
217
|
+
.optional()
|
|
218
|
+
.describe(
|
|
219
|
+
"One-shot delay in seconds from now. Requires triggerType=once. Convenient alternative to runAt."
|
|
220
|
+
),
|
|
221
|
+
session: z
|
|
222
|
+
.enum(["new", "reuse", "last"])
|
|
223
|
+
.optional()
|
|
189
224
|
.describe(
|
|
190
|
-
"
|
|
225
|
+
"OpenCode session mode for the task: new (default, fresh session per run), reuse (keep a persistent session stored on the task — sessionId is auto-generated), last (continue the latest session via --continue)."
|
|
226
|
+
),
|
|
227
|
+
sessionMaxRuns: z
|
|
228
|
+
.number()
|
|
229
|
+
.int()
|
|
230
|
+
.min(1)
|
|
231
|
+
.max(10000)
|
|
232
|
+
.optional()
|
|
233
|
+
.describe(
|
|
234
|
+
"Only for session=reuse: how many runs the reused session survives before it is deleted and a fresh one is created. Unset/0 — no limit."
|
|
191
235
|
),
|
|
192
236
|
timezone: z
|
|
193
237
|
.string()
|
|
@@ -263,9 +307,11 @@ export const scheduleTaskSchema = z.object({
|
|
|
263
307
|
.optional()
|
|
264
308
|
.describe("Compensation/rollback task started after a failed run."),
|
|
265
309
|
triggerType: z
|
|
266
|
-
.enum(["cron", "file", "mcp-event"])
|
|
310
|
+
.enum(["cron", "file", "mcp-event", "once"])
|
|
267
311
|
.optional()
|
|
268
|
-
.describe(
|
|
312
|
+
.describe(
|
|
313
|
+
"Trigger type: cron (default), file, mcp-event or once (single run at runAt/delaySeconds)."
|
|
314
|
+
),
|
|
269
315
|
mcpEvent: z
|
|
270
316
|
.object({
|
|
271
317
|
server: z.string(),
|
|
@@ -311,6 +357,40 @@ export const scheduleTaskSchema = z.object({
|
|
|
311
357
|
.describe(
|
|
312
358
|
"Matrix fan-out: the task becomes a template that is expanded into clones, one per workspace. The parent never runs itself. Cannot be combined with workspaceId."
|
|
313
359
|
),
|
|
360
|
+
}).superRefine((value, ctx) => {
|
|
361
|
+
const trigger = value.triggerType ?? "cron";
|
|
362
|
+
if (trigger === "cron" && !value.schedule?.trim()) {
|
|
363
|
+
ctx.addIssue({
|
|
364
|
+
code: z.ZodIssueCode.custom,
|
|
365
|
+
path: ["schedule"],
|
|
366
|
+
message: "Для triggerType=cron нужно cron-выражение schedule.",
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
if (
|
|
370
|
+
trigger === "once" &&
|
|
371
|
+
!value.runAt &&
|
|
372
|
+
value.delaySeconds === undefined
|
|
373
|
+
) {
|
|
374
|
+
ctx.addIssue({
|
|
375
|
+
code: z.ZodIssueCode.custom,
|
|
376
|
+
path: ["runAt"],
|
|
377
|
+
message: "Для triggerType=once нужен runAt (ISO-8601) или delaySeconds.",
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
if (trigger === "once" && value.matrix) {
|
|
381
|
+
ctx.addIssue({
|
|
382
|
+
code: z.ZodIssueCode.custom,
|
|
383
|
+
path: ["matrix"],
|
|
384
|
+
message: "One-shot нельзя комбинировать с matrix: матрица запускается только вручную.",
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
if (trigger !== "once" && (value.runAt || value.delaySeconds !== undefined)) {
|
|
388
|
+
ctx.addIssue({
|
|
389
|
+
code: z.ZodIssueCode.custom,
|
|
390
|
+
path: ["runAt"],
|
|
391
|
+
message: "runAt/delaySeconds допустимы только при triggerType=once.",
|
|
392
|
+
});
|
|
393
|
+
}
|
|
314
394
|
});
|
|
315
395
|
|
|
316
396
|
const listTasksSchema = z.object({});
|
|
@@ -329,6 +409,35 @@ export const updateTaskSchema = z.object({
|
|
|
329
409
|
.string()
|
|
330
410
|
.optional()
|
|
331
411
|
.describe("New cron expression. Keeps the current value when omitted."),
|
|
412
|
+
runAt: z
|
|
413
|
+
.string()
|
|
414
|
+
.optional()
|
|
415
|
+
.describe(
|
|
416
|
+
"New one-shot time in ISO-8601. Requires triggerType=once. Empty string clears it."
|
|
417
|
+
),
|
|
418
|
+
delaySeconds: z
|
|
419
|
+
.number()
|
|
420
|
+
.int()
|
|
421
|
+
.positive()
|
|
422
|
+
.optional()
|
|
423
|
+
.describe(
|
|
424
|
+
"New one-shot delay in seconds from now. Requires triggerType=once."
|
|
425
|
+
),
|
|
426
|
+
session: z
|
|
427
|
+
.enum(["new", "reuse", "last"])
|
|
428
|
+
.optional()
|
|
429
|
+
.describe(
|
|
430
|
+
"OpenCode session mode for the task: new (fresh session per run), reuse (keep a persistent session stored on the task — sessionId is auto-generated), last (continue the latest session via --continue)."
|
|
431
|
+
),
|
|
432
|
+
sessionMaxRuns: z
|
|
433
|
+
.number()
|
|
434
|
+
.int()
|
|
435
|
+
.min(1)
|
|
436
|
+
.max(10000)
|
|
437
|
+
.optional()
|
|
438
|
+
.describe(
|
|
439
|
+
"Only for session=reuse: how many runs the reused session survives before it is deleted and a fresh one is created. Unset/0 — no limit."
|
|
440
|
+
),
|
|
332
441
|
timezone: z
|
|
333
442
|
.string()
|
|
334
443
|
.optional()
|
|
@@ -378,7 +487,7 @@ export const updateTaskSchema = z.object({
|
|
|
378
487
|
.optional()
|
|
379
488
|
.describe("New error-chain task. Empty string clears it."),
|
|
380
489
|
triggerType: z
|
|
381
|
-
.enum(["cron", "file", "mcp-event"])
|
|
490
|
+
.enum(["cron", "file", "mcp-event", "once"])
|
|
382
491
|
.optional()
|
|
383
492
|
.describe("New trigger type."),
|
|
384
493
|
mcpEvent: z
|
|
@@ -415,6 +524,25 @@ export const updateTaskSchema = z.object({
|
|
|
415
524
|
.describe(
|
|
416
525
|
"New matrix configuration. Pass null to turn the matrix off (clones and aggregator are removed)."
|
|
417
526
|
),
|
|
527
|
+
}).superRefine((value, ctx) => {
|
|
528
|
+
if (
|
|
529
|
+
value.triggerType !== undefined &&
|
|
530
|
+
value.triggerType !== "once" &&
|
|
531
|
+
(value.runAt || value.delaySeconds !== undefined)
|
|
532
|
+
) {
|
|
533
|
+
ctx.addIssue({
|
|
534
|
+
code: z.ZodIssueCode.custom,
|
|
535
|
+
path: ["runAt"],
|
|
536
|
+
message: "runAt/delaySeconds допустимы только при triggerType=once.",
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
if (value.triggerType === "once" && value.matrix) {
|
|
540
|
+
ctx.addIssue({
|
|
541
|
+
code: z.ZodIssueCode.custom,
|
|
542
|
+
path: ["matrix"],
|
|
543
|
+
message: "One-shot нельзя комбинировать с matrix.",
|
|
544
|
+
});
|
|
545
|
+
}
|
|
418
546
|
});
|
|
419
547
|
|
|
420
548
|
const pauseTaskSchema = z.object({
|
|
@@ -561,6 +689,12 @@ export const manageSettingsSchema = z.object({
|
|
|
561
689
|
})
|
|
562
690
|
.optional()
|
|
563
691
|
.describe("History retention policy."),
|
|
692
|
+
integrations: z
|
|
693
|
+
.any()
|
|
694
|
+
.optional()
|
|
695
|
+
.describe(
|
|
696
|
+
"Integration settings patch (hooks: enabled, token, secret, requireSignature, maxBodyBytes, timestampToleranceSeconds)."
|
|
697
|
+
),
|
|
564
698
|
});
|
|
565
699
|
|
|
566
700
|
/** manage_templates — пользовательские шаблоны задач. */
|
|
@@ -690,6 +824,8 @@ const scheduleTaskExecute = wrapExecute<ScheduleArgs>(async (args) => {
|
|
|
690
824
|
const {
|
|
691
825
|
name,
|
|
692
826
|
schedule,
|
|
827
|
+
runAt,
|
|
828
|
+
delaySeconds,
|
|
693
829
|
prompt,
|
|
694
830
|
timeoutSeconds,
|
|
695
831
|
model,
|
|
@@ -713,12 +849,32 @@ const scheduleTaskExecute = wrapExecute<ScheduleArgs>(async (args) => {
|
|
|
713
849
|
timezone,
|
|
714
850
|
notBefore,
|
|
715
851
|
notAfter,
|
|
852
|
+
session,
|
|
853
|
+
sessionMaxRuns,
|
|
716
854
|
} = args;
|
|
717
855
|
|
|
856
|
+
let effectiveRunAt: string | undefined;
|
|
857
|
+
if ((triggerType ?? "cron") === "once") {
|
|
858
|
+
const normalized = normalizeOneShotRunAt({ runAt, delaySeconds });
|
|
859
|
+
if (!normalized.ok) {
|
|
860
|
+
return {
|
|
861
|
+
content: JSON.stringify({ success: false, error: normalized.error }),
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
effectiveRunAt = normalized.runAt;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// Спринт 24: режим сессии. По умолчанию "new" (старое поведение).
|
|
868
|
+
// sessionId пользователя никогда не принимаем — он создаётся автоматически.
|
|
869
|
+
const effectiveSession: "new" | "reuse" | "last" =
|
|
870
|
+
normalizeSessionMode(session) ?? "new";
|
|
871
|
+
const effectiveSessionId =
|
|
872
|
+
effectiveSession === "reuse" ? generateSessionId() : undefined;
|
|
873
|
+
|
|
718
874
|
try {
|
|
719
875
|
await schedulerCreateTask(
|
|
720
876
|
name,
|
|
721
|
-
schedule,
|
|
877
|
+
schedule ?? "",
|
|
722
878
|
prompt,
|
|
723
879
|
timeoutSeconds,
|
|
724
880
|
workingDirectory,
|
|
@@ -743,7 +899,12 @@ const scheduleTaskExecute = wrapExecute<ScheduleArgs>(async (args) => {
|
|
|
743
899
|
"create",
|
|
744
900
|
timezone,
|
|
745
901
|
notBefore,
|
|
746
|
-
notAfter
|
|
902
|
+
notAfter,
|
|
903
|
+
undefined,
|
|
904
|
+
effectiveRunAt,
|
|
905
|
+
effectiveSession,
|
|
906
|
+
effectiveSessionId,
|
|
907
|
+
sessionMaxRuns
|
|
747
908
|
);
|
|
748
909
|
} catch (err: any) {
|
|
749
910
|
return {
|
|
@@ -780,6 +941,10 @@ const scheduleTaskExecute = wrapExecute<ScheduleArgs>(async (args) => {
|
|
|
780
941
|
nextTaskOnSuccess: nextTaskOnSuccess?.trim() || null,
|
|
781
942
|
nextTaskOnError: nextTaskOnError?.trim() || null,
|
|
782
943
|
triggerType: triggerType ?? "cron",
|
|
944
|
+
runAt: effectiveRunAt ?? null,
|
|
945
|
+
session: effectiveSession,
|
|
946
|
+
sessionId: effectiveSessionId ?? null,
|
|
947
|
+
sessionMaxRuns: sessionMaxRuns ?? null,
|
|
783
948
|
timezone: timezone?.trim() || null,
|
|
784
949
|
notBefore: notBefore?.trim() || null,
|
|
785
950
|
notAfter: notAfter?.trim() || null,
|
|
@@ -1142,16 +1307,81 @@ async function updateTaskFromInput(
|
|
|
1142
1307
|
};
|
|
1143
1308
|
}
|
|
1144
1309
|
|
|
1310
|
+
// One-shot: без нового runAt/delaySeconds сохраняем прежнее время.
|
|
1311
|
+
// При смене триггера на once время обязательно, иначе задача не запустится.
|
|
1312
|
+
let runAt: string | undefined;
|
|
1313
|
+
if (triggerType === "once") {
|
|
1314
|
+
const candidateRunAt =
|
|
1315
|
+
input.runAt !== undefined
|
|
1316
|
+
? input.runAt
|
|
1317
|
+
: input.delaySeconds !== undefined
|
|
1318
|
+
? undefined
|
|
1319
|
+
: previous.runAt;
|
|
1320
|
+
const normalized = normalizeOneShotRunAt({
|
|
1321
|
+
runAt: candidateRunAt,
|
|
1322
|
+
delaySeconds: input.delaySeconds,
|
|
1323
|
+
});
|
|
1324
|
+
if (!normalized.ok) {
|
|
1325
|
+
return {
|
|
1326
|
+
success: false,
|
|
1327
|
+
message: `Задача "${name}": ${normalized.error}`,
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
runAt = normalized.runAt;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
// Спринт 24: режим сессии. Без новых session/sessionMaxRuns сохраняем прежние.
|
|
1334
|
+
// sessionId пользователя не принимаем — генерируем сами при переходе на reuse.
|
|
1335
|
+
let session: "new" | "reuse" | "last" = "new";
|
|
1336
|
+
if (input.session !== undefined) {
|
|
1337
|
+
const normalizedSession = normalizeSessionMode(input.session);
|
|
1338
|
+
if (!normalizedSession) {
|
|
1339
|
+
return {
|
|
1340
|
+
success: false,
|
|
1341
|
+
message: `Задача "${name}": неизвестный режим сессии "${String(input.session)}".`,
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
session = normalizedSession;
|
|
1345
|
+
} else if (previous.session) {
|
|
1346
|
+
session = previous.session;
|
|
1347
|
+
}
|
|
1348
|
+
const sessionMaxRuns =
|
|
1349
|
+
input.sessionMaxRuns !== undefined ? input.sessionMaxRuns : previous.sessionMaxRuns;
|
|
1350
|
+
if (
|
|
1351
|
+
sessionMaxRuns !== undefined &&
|
|
1352
|
+
(!Number.isInteger(sessionMaxRuns) || sessionMaxRuns < 1)
|
|
1353
|
+
) {
|
|
1354
|
+
return {
|
|
1355
|
+
success: false,
|
|
1356
|
+
message: `Задача "${name}": sessionMaxRuns должен быть целым числом ≥ 1.`,
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1359
|
+
let sessionId = previous.sessionId;
|
|
1360
|
+
if (session === "reuse" && !sessionId) {
|
|
1361
|
+
sessionId = generateSessionId();
|
|
1362
|
+
}
|
|
1363
|
+
if (session !== "reuse") {
|
|
1364
|
+
sessionId = undefined;
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1145
1367
|
const matrixWas = previous.matrix;
|
|
1146
1368
|
const matrixNext =
|
|
1147
1369
|
input.matrix === undefined ? matrixWas : input.matrix ?? undefined;
|
|
1370
|
+
if (triggerType === "once" && matrixNext) {
|
|
1371
|
+
return {
|
|
1372
|
+
success: false,
|
|
1373
|
+
message:
|
|
1374
|
+
`Задача "${name}": one-shot нельзя комбинировать с matrix. ` +
|
|
1375
|
+
`Запустите матрицу вручную или используйте cron/file-триггер.`,
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1148
1378
|
|
|
1149
1379
|
try {
|
|
1150
1380
|
// Обновление = пересоздание в планировщике с сохранением старых значений.
|
|
1151
1381
|
await scheduler.deleteTask(name);
|
|
1152
1382
|
await schedulerCreateTask(
|
|
1153
1383
|
name,
|
|
1154
|
-
schedule ?? "
|
|
1384
|
+
schedule ?? "",
|
|
1155
1385
|
prompt,
|
|
1156
1386
|
input.timeoutSeconds ?? previous.timeoutSeconds,
|
|
1157
1387
|
clearableString(input.workingDirectory, previous.workingDirectory),
|
|
@@ -1179,7 +1409,11 @@ async function updateTaskFromInput(
|
|
|
1179
1409
|
timezone,
|
|
1180
1410
|
notBefore,
|
|
1181
1411
|
notAfter,
|
|
1182
|
-
previous.pausedUntil
|
|
1412
|
+
previous.pausedUntil,
|
|
1413
|
+
runAt,
|
|
1414
|
+
session,
|
|
1415
|
+
sessionId,
|
|
1416
|
+
sessionMaxRuns
|
|
1183
1417
|
);
|
|
1184
1418
|
|
|
1185
1419
|
// Матрица отключена при обновлении — убираем клонов и агрегатор.
|
|
@@ -1727,12 +1961,14 @@ const manageSettingsExecute = wrapExecute<SettingsArgs>(async (args) => {
|
|
|
1727
1961
|
args.maxConcurrent === undefined &&
|
|
1728
1962
|
args.winterMode === undefined &&
|
|
1729
1963
|
args.notifications === undefined &&
|
|
1730
|
-
args.history === undefined
|
|
1964
|
+
args.history === undefined &&
|
|
1965
|
+
args.integrations === undefined
|
|
1731
1966
|
) {
|
|
1732
1967
|
return {
|
|
1733
1968
|
content: JSON.stringify({
|
|
1734
1969
|
success: false,
|
|
1735
|
-
error:
|
|
1970
|
+
error:
|
|
1971
|
+
"Для action=update передайте хотя бы одно поле: maxConcurrent, winterMode, notifications, history или integrations.",
|
|
1736
1972
|
settings: current,
|
|
1737
1973
|
}),
|
|
1738
1974
|
};
|
|
@@ -1743,6 +1979,7 @@ const manageSettingsExecute = wrapExecute<SettingsArgs>(async (args) => {
|
|
|
1743
1979
|
winterMode: args.winterMode,
|
|
1744
1980
|
notifications: args.notifications as NotificationSettings | undefined,
|
|
1745
1981
|
history: args.history as HistorySettings | undefined,
|
|
1982
|
+
integrations: args.integrations as IntegrationSettings | undefined,
|
|
1746
1983
|
});
|
|
1747
1984
|
return { content: JSON.stringify({ success: true, settings }) };
|
|
1748
1985
|
});
|
|
@@ -1905,7 +2142,8 @@ const transferTasksExecute = wrapExecute<TransferArgs>(async (args) => {
|
|
|
1905
2142
|
def.timezone,
|
|
1906
2143
|
def.notBefore,
|
|
1907
2144
|
def.notAfter,
|
|
1908
|
-
def.pausedUntil
|
|
2145
|
+
def.pausedUntil,
|
|
2146
|
+
def.runAt
|
|
1909
2147
|
);
|
|
1910
2148
|
await saveTaskDefinition(def);
|
|
1911
2149
|
imported.push(def.name);
|
|
@@ -2456,9 +2694,13 @@ export default Plugin.define({
|
|
|
2456
2694
|
timezone,
|
|
2457
2695
|
notBefore,
|
|
2458
2696
|
notAfter,
|
|
2697
|
+
runAt,
|
|
2698
|
+
delaySeconds,
|
|
2699
|
+
session,
|
|
2700
|
+
sessionMaxRuns,
|
|
2459
2701
|
} = input as {
|
|
2460
2702
|
name: string;
|
|
2461
|
-
schedule
|
|
2703
|
+
schedule?: string;
|
|
2462
2704
|
prompt: string;
|
|
2463
2705
|
retryCount?: number;
|
|
2464
2706
|
retryDelay?: number;
|
|
@@ -2466,7 +2708,7 @@ export default Plugin.define({
|
|
|
2466
2708
|
nextTaskOnSuccess?: string;
|
|
2467
2709
|
nextTaskOnError?: string;
|
|
2468
2710
|
dependsOn?: string[];
|
|
2469
|
-
triggerType?: "cron" | "file" | "mcp-event";
|
|
2711
|
+
triggerType?: "cron" | "file" | "mcp-event" | "once";
|
|
2470
2712
|
watchPath?: string;
|
|
2471
2713
|
workingDirectory?: string;
|
|
2472
2714
|
model?: string;
|
|
@@ -2481,11 +2723,39 @@ export default Plugin.define({
|
|
|
2481
2723
|
timezone?: string;
|
|
2482
2724
|
notBefore?: string;
|
|
2483
2725
|
notAfter?: string;
|
|
2726
|
+
runAt?: string;
|
|
2727
|
+
delaySeconds?: number;
|
|
2728
|
+
session?: "new" | "reuse" | "last";
|
|
2729
|
+
sessionMaxRuns?: number;
|
|
2484
2730
|
};
|
|
2731
|
+
let effectiveRunAt: string | undefined;
|
|
2732
|
+
if (triggerType === "once") {
|
|
2733
|
+
const normalized = normalizeOneShotRunAt({ runAt, delaySeconds });
|
|
2734
|
+
if (!normalized.ok) {
|
|
2735
|
+
return { success: false, message: `Задача "${name}": ${normalized.error}` };
|
|
2736
|
+
}
|
|
2737
|
+
effectiveRunAt = normalized.runAt;
|
|
2738
|
+
}
|
|
2739
|
+
let effectiveSession: "new" | "reuse" | "last" = "new";
|
|
2740
|
+
if (session !== undefined) {
|
|
2741
|
+
const normalizedSession = normalizeSessionMode(session);
|
|
2742
|
+
if (!normalizedSession) {
|
|
2743
|
+
return { success: false, message: `Задача "${name}": неизвестный режим сессии "${String(session)}".` };
|
|
2744
|
+
}
|
|
2745
|
+
effectiveSession = normalizedSession;
|
|
2746
|
+
}
|
|
2747
|
+
if (
|
|
2748
|
+
sessionMaxRuns !== undefined &&
|
|
2749
|
+
(!Number.isInteger(sessionMaxRuns) || sessionMaxRuns < 1)
|
|
2750
|
+
) {
|
|
2751
|
+
return { success: false, message: `Задача "${name}": sessionMaxRuns должен быть целым числом ≥ 1.` };
|
|
2752
|
+
}
|
|
2753
|
+
const effectiveSessionId =
|
|
2754
|
+
effectiveSession === "reuse" ? generateSessionId() : undefined;
|
|
2485
2755
|
try {
|
|
2486
2756
|
await schedulerCreateTask(
|
|
2487
2757
|
name,
|
|
2488
|
-
schedule,
|
|
2758
|
+
schedule ?? "",
|
|
2489
2759
|
prompt,
|
|
2490
2760
|
undefined,
|
|
2491
2761
|
workingDirectory,
|
|
@@ -2510,7 +2780,12 @@ export default Plugin.define({
|
|
|
2510
2780
|
"create",
|
|
2511
2781
|
timezone,
|
|
2512
2782
|
notBefore,
|
|
2513
|
-
notAfter
|
|
2783
|
+
notAfter,
|
|
2784
|
+
undefined,
|
|
2785
|
+
effectiveRunAt,
|
|
2786
|
+
effectiveSession,
|
|
2787
|
+
effectiveSessionId,
|
|
2788
|
+
sessionMaxRuns
|
|
2514
2789
|
);
|
|
2515
2790
|
return { success: true, message: `Задача "${name}" успешно создана.` };
|
|
2516
2791
|
} catch (err: any) {
|
|
@@ -2683,12 +2958,22 @@ export default Plugin.define({
|
|
|
2683
2958
|
return { success: true, logs: result.logs };
|
|
2684
2959
|
},
|
|
2685
2960
|
get_history: async (input: unknown) => {
|
|
2686
|
-
|
|
2961
|
+
// Контракт совпадает с агентским инструментом get_history:
|
|
2962
|
+
// limit по умолчанию 20 (максимум 200), фильтры taskName и status.
|
|
2963
|
+
const { limit, taskName, status } = input as {
|
|
2964
|
+
limit?: number;
|
|
2965
|
+
taskName?: string;
|
|
2966
|
+
status?: string;
|
|
2967
|
+
};
|
|
2687
2968
|
const filter = taskName?.trim().toLowerCase();
|
|
2688
|
-
const
|
|
2689
|
-
|
|
2690
|
-
)
|
|
2691
|
-
|
|
2969
|
+
const statusFilter = status?.trim().toLowerCase();
|
|
2970
|
+
const max = Math.max(1, Math.min(Math.floor(limit ?? 20), 200));
|
|
2971
|
+
const records = (await loadHistory())
|
|
2972
|
+
.filter((record) => !filter || record.taskName.toLowerCase() === filter)
|
|
2973
|
+
.filter(
|
|
2974
|
+
(record) => !statusFilter || String(record.status).toLowerCase() === statusFilter
|
|
2975
|
+
);
|
|
2976
|
+
return { records: records.slice(0, max) };
|
|
2692
2977
|
},
|
|
2693
2978
|
get_metrics: async () => {
|
|
2694
2979
|
return await loadMetrics();
|
|
@@ -2997,18 +3282,20 @@ export default Plugin.define({
|
|
|
2997
3282
|
return await loadSettings();
|
|
2998
3283
|
},
|
|
2999
3284
|
save_settings: async (input: unknown) => {
|
|
3000
|
-
const { maxConcurrent, winterMode, notifications, history } = input as {
|
|
3285
|
+
const { maxConcurrent, winterMode, notifications, history, integrations } = input as {
|
|
3001
3286
|
maxConcurrent?: number;
|
|
3002
3287
|
winterMode?: boolean;
|
|
3003
3288
|
notifications?: NotificationSettings;
|
|
3004
3289
|
history?: HistorySettings;
|
|
3290
|
+
integrations?: IntegrationSettings;
|
|
3005
3291
|
};
|
|
3006
3292
|
const current = await loadSettings();
|
|
3007
3293
|
if (
|
|
3008
3294
|
maxConcurrent === undefined &&
|
|
3009
3295
|
winterMode === undefined &&
|
|
3010
3296
|
notifications === undefined &&
|
|
3011
|
-
history === undefined
|
|
3297
|
+
history === undefined &&
|
|
3298
|
+
integrations === undefined
|
|
3012
3299
|
) {
|
|
3013
3300
|
return {
|
|
3014
3301
|
success: false,
|
|
@@ -3016,6 +3303,7 @@ export default Plugin.define({
|
|
|
3016
3303
|
winterMode: current.winterMode,
|
|
3017
3304
|
notifications: current.notifications,
|
|
3018
3305
|
history: current.history,
|
|
3306
|
+
integrations: current.integrations,
|
|
3019
3307
|
};
|
|
3020
3308
|
}
|
|
3021
3309
|
const settings = await saveSettings({
|
|
@@ -3023,6 +3311,7 @@ export default Plugin.define({
|
|
|
3023
3311
|
winterMode,
|
|
3024
3312
|
notifications,
|
|
3025
3313
|
history,
|
|
3314
|
+
integrations,
|
|
3026
3315
|
});
|
|
3027
3316
|
return {
|
|
3028
3317
|
success: true,
|
|
@@ -3030,6 +3319,7 @@ export default Plugin.define({
|
|
|
3030
3319
|
winterMode: settings.winterMode,
|
|
3031
3320
|
notifications: settings.notifications,
|
|
3032
3321
|
history: settings.history,
|
|
3322
|
+
integrations: settings.integrations,
|
|
3033
3323
|
};
|
|
3034
3324
|
},
|
|
3035
3325
|
test_notification: async () => {
|
|
@@ -3156,7 +3446,8 @@ export default Plugin.define({
|
|
|
3156
3446
|
def.timezone,
|
|
3157
3447
|
def.notBefore,
|
|
3158
3448
|
def.notAfter,
|
|
3159
|
-
def.pausedUntil
|
|
3449
|
+
def.pausedUntil,
|
|
3450
|
+
def.runAt
|
|
3160
3451
|
);
|
|
3161
3452
|
await saveTaskDefinition(def);
|
|
3162
3453
|
imported.push(def.name);
|
|
@@ -3291,7 +3582,7 @@ async function schedulerCreateTask(
|
|
|
3291
3582
|
qualityGate?: string,
|
|
3292
3583
|
nextTaskOnSuccess?: string,
|
|
3293
3584
|
nextTaskOnError?: string,
|
|
3294
|
-
triggerType?: "cron" | "file" | "mcp-event",
|
|
3585
|
+
triggerType?: "cron" | "file" | "mcp-event" | "once",
|
|
3295
3586
|
watchPath?: string,
|
|
3296
3587
|
dependsOn?: string[],
|
|
3297
3588
|
model?: string,
|
|
@@ -3313,7 +3604,15 @@ async function schedulerCreateTask(
|
|
|
3313
3604
|
/** Окончание окна "HH:MM"; может быть меньше notBefore (через полночь). */
|
|
3314
3605
|
notAfter?: string,
|
|
3315
3606
|
/** Пауза до момента ISO; после него задача возобновляется автоматически. */
|
|
3316
|
-
pausedUntil?: string
|
|
3607
|
+
pausedUntil?: string,
|
|
3608
|
+
/** Абсолютное время однократного запуска (ISO, только triggerType=once). */
|
|
3609
|
+
runAt?: string,
|
|
3610
|
+
/** Режим сессии OpenCode (Спринт 24): new (по умолчанию), reuse, last. */
|
|
3611
|
+
session?: "new" | "reuse" | "last",
|
|
3612
|
+
/** ID сессии для reuse (генерируется автоматически; пользователь не задаёт). */
|
|
3613
|
+
sessionId?: string,
|
|
3614
|
+
/** Сколько запусков переживает reuse-сессия до ротации (0/undefined — без ограничения). */
|
|
3615
|
+
sessionMaxRuns?: number
|
|
3317
3616
|
): Promise<void> {
|
|
3318
3617
|
const normalizedModel = model?.trim() || undefined;
|
|
3319
3618
|
const normalizedPriority = normalizePriority(priority);
|
|
@@ -3332,6 +3631,30 @@ async function schedulerCreateTask(
|
|
|
3332
3631
|
}
|
|
3333
3632
|
: undefined;
|
|
3334
3633
|
let effectiveTriggerType = triggerType ?? "cron";
|
|
3634
|
+
// One-shot: нормализуем время до создания файлов и задачи в ОС.
|
|
3635
|
+
// Для остальных триггеров runAt не имеет смысла и отбрасывается.
|
|
3636
|
+
let effectiveRunAt: string | undefined;
|
|
3637
|
+
if (effectiveTriggerType === "once") {
|
|
3638
|
+
const normalized = normalizeOneShotRunAt({ runAt });
|
|
3639
|
+
if (!normalized.ok) {
|
|
3640
|
+
throw new Error(`Задача "${name}": ${normalized.error}`);
|
|
3641
|
+
}
|
|
3642
|
+
effectiveRunAt = normalized.runAt;
|
|
3643
|
+
}
|
|
3644
|
+
// Спринт 24: режим сессии. sessionId генерируется автоматически для reuse;
|
|
3645
|
+
// значение пользователя никогда не принимаем.
|
|
3646
|
+
let effectiveSession: "new" | "reuse" | "last" = "new";
|
|
3647
|
+
let effectiveSessionId: string | undefined;
|
|
3648
|
+
if (session !== undefined) {
|
|
3649
|
+
const normalizedSession = normalizeSessionMode(session);
|
|
3650
|
+
if (!normalizedSession) {
|
|
3651
|
+
throw new Error(`Задача "${name}": неизвестный режим сессии "${String(session)}".`);
|
|
3652
|
+
}
|
|
3653
|
+
effectiveSession = normalizedSession;
|
|
3654
|
+
}
|
|
3655
|
+
if (effectiveSession === "reuse") {
|
|
3656
|
+
effectiveSessionId = sessionId?.trim() || generateSessionId();
|
|
3657
|
+
}
|
|
3335
3658
|
// Role-scoped: нормализуем списки инструментов (trim, дедуп без регистра).
|
|
3336
3659
|
// Пустой allowedTools — осознанная блокировка: «белый список из нуля
|
|
3337
3660
|
// инструментов» это почти наверняка ошибка конфигурации.
|
|
@@ -3519,7 +3842,9 @@ async function schedulerCreateTask(
|
|
|
3519
3842
|
normalizedAllowedTools,
|
|
3520
3843
|
normalizedDeniedTools,
|
|
3521
3844
|
wrapperGate,
|
|
3522
|
-
taskEnvFile
|
|
3845
|
+
taskEnvFile,
|
|
3846
|
+
effectiveSession,
|
|
3847
|
+
effectiveSessionId
|
|
3523
3848
|
);
|
|
3524
3849
|
} else {
|
|
3525
3850
|
wrapperPath = await writeBashWrapper({
|
|
@@ -3540,6 +3865,11 @@ async function schedulerCreateTask(
|
|
|
3540
3865
|
deniedTools: normalizedDeniedTools,
|
|
3541
3866
|
scheduleGate: wrapperGate,
|
|
3542
3867
|
envFile: taskEnvFile,
|
|
3868
|
+
sessionMode: effectiveSession,
|
|
3869
|
+
sessionId: effectiveSessionId,
|
|
3870
|
+
...(effectiveTriggerType === "once" && scheduler.platform === "darwin"
|
|
3871
|
+
? { oneShotCleanupCommand: buildLaunchdOneShotCleanup(sanitized) }
|
|
3872
|
+
: {}),
|
|
3543
3873
|
});
|
|
3544
3874
|
}
|
|
3545
3875
|
} catch (err: any) {
|
|
@@ -3554,6 +3884,7 @@ async function schedulerCreateTask(
|
|
|
3554
3884
|
schedule,
|
|
3555
3885
|
timeoutSeconds: timeoutSeconds ?? 3600,
|
|
3556
3886
|
triggerType: effectiveTriggerType,
|
|
3887
|
+
...(effectiveRunAt ? { runAt: effectiveRunAt } : {}),
|
|
3557
3888
|
workingDirectory: effectiveWorkingDirectory,
|
|
3558
3889
|
logFile,
|
|
3559
3890
|
model: normalizedModel,
|
|
@@ -3567,7 +3898,10 @@ async function schedulerCreateTask(
|
|
|
3567
3898
|
}
|
|
3568
3899
|
|
|
3569
3900
|
// Сохраняем определение задачи для последующего экспорта/импорта.
|
|
3570
|
-
|
|
3901
|
+
// Определение до перезаписи: нужно и для очереди матрицы, и для счётчика сессии.
|
|
3902
|
+
const previousDefinition = getTask(name);
|
|
3903
|
+
const existingQueue =
|
|
3904
|
+
matrixMode === "sync" ? previousDefinition?.matrixQueue : undefined;
|
|
3571
3905
|
const taskDefinition: TaskDefinition = {
|
|
3572
3906
|
name,
|
|
3573
3907
|
schedule,
|
|
@@ -3586,6 +3920,19 @@ async function schedulerCreateTask(
|
|
|
3586
3920
|
nextTaskOnSuccess,
|
|
3587
3921
|
nextTaskOnError,
|
|
3588
3922
|
triggerType: effectiveTriggerType,
|
|
3923
|
+
runAt: effectiveRunAt,
|
|
3924
|
+
// Спринт 24: сессия. sessionRunCount не экспортируется (internal).
|
|
3925
|
+
session: effectiveSession,
|
|
3926
|
+
sessionId: effectiveSessionId,
|
|
3927
|
+
sessionMaxRuns,
|
|
3928
|
+
// Раньше редактирование всегда сбрасывало счётчик в 0, из-за чего лимит
|
|
3929
|
+
// sessionMaxRuns обходился правкой любого поля задачи. Сохраняем счётчик,
|
|
3930
|
+
// только если сессия и её id не изменились.
|
|
3931
|
+
sessionRunCount: preservedSessionRunCount(
|
|
3932
|
+
previousDefinition,
|
|
3933
|
+
effectiveSession,
|
|
3934
|
+
effectiveSessionId
|
|
3935
|
+
),
|
|
3589
3936
|
watchPath: normalizedMatrix ? undefined : watchPath,
|
|
3590
3937
|
timezone: normalizedTz,
|
|
3591
3938
|
notBefore: normalizedNotBefore,
|
|
@@ -3772,13 +4119,8 @@ async function collectTasksView() {
|
|
|
3772
4119
|
|
|
3773
4120
|
// Читаем историю один раз, чтобы определить финальный статус по последней записи.
|
|
3774
4121
|
const history = await loadHistory();
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
lastByTask.set(record.taskName, {
|
|
3778
|
-
status: record.status,
|
|
3779
|
-
error: record.error,
|
|
3780
|
-
});
|
|
3781
|
-
}
|
|
4122
|
+
// loadHistory() отдаёт записи от новых к старым; helper оставляет самую свежую.
|
|
4123
|
+
const lastByTask = latestHistoryByTask(history);
|
|
3782
4124
|
|
|
3783
4125
|
// Читаем определения задач один раз (расписание, повторы, цепочки, директория).
|
|
3784
4126
|
const defs = await loadTaskDefinitions();
|
|
@@ -3791,12 +4133,21 @@ async function collectTasksView() {
|
|
|
3791
4133
|
const metricsByName = new Map(
|
|
3792
4134
|
getAllMetrics(true).map((row) => [row.taskName.toLowerCase(), row])
|
|
3793
4135
|
);
|
|
3794
|
-
const historyCounts = new Map<
|
|
4136
|
+
const historyCounts = new Map<
|
|
4137
|
+
string,
|
|
4138
|
+
{ total: number; success: number; error: number; partial: number }
|
|
4139
|
+
>();
|
|
3795
4140
|
for (const record of history) {
|
|
3796
4141
|
const key = record.taskName.toLowerCase();
|
|
3797
|
-
const counts = historyCounts.get(key) ?? {
|
|
4142
|
+
const counts = historyCounts.get(key) ?? {
|
|
4143
|
+
total: 0,
|
|
4144
|
+
success: 0,
|
|
4145
|
+
error: 0,
|
|
4146
|
+
partial: 0,
|
|
4147
|
+
};
|
|
3798
4148
|
counts.total += 1;
|
|
3799
4149
|
if (record.status === "success") counts.success += 1;
|
|
4150
|
+
else if (record.status === "partial") counts.partial += 1;
|
|
3800
4151
|
else counts.error += 1;
|
|
3801
4152
|
historyCounts.set(key, counts);
|
|
3802
4153
|
}
|
|
@@ -3825,11 +4176,13 @@ async function collectTasksView() {
|
|
|
3825
4176
|
let status = mapStatus(t.status);
|
|
3826
4177
|
|
|
3827
4178
|
// Приоритет 2: если последняя запись в истории — error/timeout, перебиваем на error.
|
|
3828
|
-
const last = lastByTask.get(name);
|
|
3829
|
-
if (last
|
|
3830
|
-
status = "error";
|
|
3831
|
-
|
|
3832
|
-
|
|
4179
|
+
const last = lastByTask.get(name.toLowerCase());
|
|
4180
|
+
if (last) {
|
|
4181
|
+
if (last.status === "error" || last.status === "timeout") status = "error";
|
|
4182
|
+
else if (last.status === "success") status = "success";
|
|
4183
|
+
// partial раньше терялся: задача после частичного запуска выглядела
|
|
4184
|
+
// как «готова»/«не запускалась», хотя запуск был неуспешным.
|
|
4185
|
+
else if (last.status === "partial") status = "partial";
|
|
3833
4186
|
}
|
|
3834
4187
|
|
|
3835
4188
|
const def = defs.find((d) => d.name.toLowerCase() === name.toLowerCase());
|
|
@@ -3845,18 +4198,41 @@ async function collectTasksView() {
|
|
|
3845
4198
|
// общие итоги по всем задачам — отсюда одинаковые 201/130/71).
|
|
3846
4199
|
const metricsRow = metricsByName.get(name.toLowerCase());
|
|
3847
4200
|
const counts = metricsRow
|
|
3848
|
-
? {
|
|
3849
|
-
|
|
4201
|
+
? {
|
|
4202
|
+
total: metricsRow.total,
|
|
4203
|
+
success: metricsRow.success,
|
|
4204
|
+
error: metricsRow.error,
|
|
4205
|
+
partial: metricsRow.partial,
|
|
4206
|
+
}
|
|
4207
|
+
: historyCounts.get(name.toLowerCase()) ?? {
|
|
4208
|
+
total: 0,
|
|
4209
|
+
success: 0,
|
|
4210
|
+
error: 0,
|
|
4211
|
+
partial: 0,
|
|
4212
|
+
};
|
|
3850
4213
|
|
|
3851
4214
|
return {
|
|
3852
4215
|
name,
|
|
3853
4216
|
schedule: def?.schedule ?? "",
|
|
3854
4217
|
status,
|
|
3855
4218
|
orphaned,
|
|
4219
|
+
// Спринт 24 (фикс): явный признак паузы. Раньше GUI пытался вывести его
|
|
4220
|
+
// из текстового статуса, но mapStatus() превращает "disabled" в "unknown",
|
|
4221
|
+
// поэтому кнопка «возобновить» была недоступна.
|
|
4222
|
+
paused: Boolean(t.paused),
|
|
3856
4223
|
runsTotal: counts.total,
|
|
3857
4224
|
runsSuccess: counts.success,
|
|
3858
4225
|
runsError: counts.error,
|
|
3859
|
-
|
|
4226
|
+
runsPartial: counts.partial,
|
|
4227
|
+
// Для разовой задачи показываем запланированное время, а не пустое расписание.
|
|
4228
|
+
nextRun: def?.triggerType === "once"
|
|
4229
|
+
? def?.runAt ?? (t.nextRunTime ? String(t.nextRunTime) : null)
|
|
4230
|
+
: t.nextRunTime ? String(t.nextRunTime) : null,
|
|
4231
|
+
runAt: def?.runAt ?? null,
|
|
4232
|
+
session: def?.session ?? "new",
|
|
4233
|
+
sessionId: def?.sessionId ?? null,
|
|
4234
|
+
sessionMaxRuns: def?.sessionMaxRuns ?? null,
|
|
4235
|
+
sessionRunCount: def?.sessionRunCount ?? 0,
|
|
3860
4236
|
model: def?.model ?? null,
|
|
3861
4237
|
priority: def?.priority ?? 5,
|
|
3862
4238
|
beforeScript: def?.beforeScript ?? null,
|
|
@@ -3936,7 +4312,10 @@ function mapStatus(status?: string): string {
|
|
|
3936
4312
|
if (!status) return "unknown";
|
|
3937
4313
|
const s = status.toLowerCase();
|
|
3938
4314
|
if (s.includes("running") || s.includes("выполняется")) return "running";
|
|
3939
|
-
|
|
4315
|
+
// "Ready" в планировщике Windows означает лишь «готова к запуску», а не
|
|
4316
|
+
// успешное выполнение. Раньше такие задачи показывались зелёными, хотя
|
|
4317
|
+
// могли ни разу не запускаться.
|
|
4318
|
+
if (s.includes("ready") || s.includes("готов")) return "idle";
|
|
3940
4319
|
if (s.includes("disabled")) return "unknown";
|
|
3941
4320
|
return "unknown";
|
|
3942
4321
|
}
|