agent-steward 0.0.2 → 0.0.3
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 +25 -2
- package/CROSS_PLATFORM.md +11 -9
- package/README.md +9 -8
- package/ROADMAP-STRATEGY.md +93 -44
- package/ROADMAP.md +114 -999
- package/dist/core/cron-to-schtasks.d.ts +0 -8
- package/dist/core/cron-to-schtasks.d.ts.map +1 -1
- package/dist/core/cron-to-schtasks.js +11 -86
- package/dist/core/dry-run.js +1 -1
- package/dist/core/file-watcher.js +9 -9
- package/dist/core/git-trigger.js +4 -4
- package/dist/core/lock.js +2 -4
- package/dist/core/one-shot.d.ts +27 -5
- package/dist/core/one-shot.d.ts.map +1 -1
- package/dist/core/one-shot.js +53 -10
- package/dist/core/otel.js +2 -2
- package/dist/core/ps-wrapper.d.ts +1 -1
- package/dist/core/ps-wrapper.d.ts.map +1 -1
- package/dist/core/ps-wrapper.js +55 -35
- package/dist/core/record-history.js +22 -22
- package/dist/core/schedule-v2.d.ts +2 -2
- package/dist/core/schedule-v2.d.ts.map +1 -1
- package/dist/core/schedule-v2.js +7 -7
- package/dist/core/scheduler/at-fallback.d.ts +42 -0
- package/dist/core/scheduler/at-fallback.d.ts.map +1 -0
- package/dist/core/scheduler/at-fallback.js +70 -0
- package/dist/core/scheduler/linux.d.ts +3 -1
- package/dist/core/scheduler/linux.d.ts.map +1 -1
- package/dist/core/scheduler/linux.js +43 -7
- package/dist/core/scheduler/mac.d.ts +14 -8
- package/dist/core/scheduler/mac.d.ts.map +1 -1
- package/dist/core/scheduler/mac.js +71 -22
- package/dist/core/scheduler/posix.d.ts.map +1 -1
- package/dist/core/scheduler/posix.js +12 -1
- package/dist/core/scheduler/registry.d.ts +2 -0
- package/dist/core/scheduler/registry.d.ts.map +1 -1
- package/dist/core/scheduler/windows.d.ts +16 -3
- package/dist/core/scheduler/windows.d.ts.map +1 -1
- package/dist/core/scheduler/windows.js +249 -96
- package/dist/core/secrets.js +2 -2
- package/dist/core/self-analysis.js +55 -55
- package/dist/core/summary.js +1 -1
- package/dist/core/triage-chain.js +1 -1
- package/dist/core/triage-worker.js +2 -2
- package/dist/core/triage.js +1 -1
- package/dist/core/wrappers/bash.js +33 -33
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +9 -1
- package/dist/db/run-journal.d.ts +60 -0
- package/dist/db/run-journal.d.ts.map +1 -0
- package/dist/db/run-journal.js +143 -0
- package/dist/db/run-resume.d.ts +48 -0
- package/dist/db/run-resume.d.ts.map +1 -0
- package/dist/db/run-resume.js +137 -0
- package/dist/db/runs-repo.d.ts +120 -0
- package/dist/db/runs-repo.d.ts.map +1 -0
- package/dist/db/runs-repo.js +319 -0
- package/dist/db/schema.d.ts +16 -2
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +190 -35
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +66 -36
- package/dist/notifications.js +18 -18
- package/dist/profiles.d.ts +7 -3
- package/dist/profiles.d.ts.map +1 -1
- package/dist/profiles.js +85 -7
- package/dist/rpc.d.ts +109 -0
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +89 -0
- package/dist/server.d.ts +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +20 -19
- package/dist/shared/jobs-view.d.ts.map +1 -1
- package/dist/skill.js +1 -1
- package/dist/task-transfer.d.ts +1 -1
- package/dist/task-transfer.d.ts.map +1 -1
- package/dist/task-transfer.js +14 -10
- package/dist/types.d.ts +20 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +37 -9
- package/dist/workspaces.js +1 -1
- package/docs/ARCHITECTURE.md +110 -8
- package/docs/COMPATIBILITY.md +10 -6
- package/docs/CONCEPT.md +15 -3
- package/docs/CROSS_PLATFORM.ru.md +11 -9
- package/docs/CROSS_PLATFORM.zh.md +11 -9
- package/docs/FAQ.md +2 -2
- package/docs/FAQ.ru.md +2 -2
- package/docs/FAQ.zh.md +2 -2
- package/docs/FEATURES.md +5 -4
- package/docs/FEATURES.zh.md +5 -4
- package/docs/MIGRATION.md +34 -26
- package/docs/README.ru.md +26 -7
- package/docs/README.zh.md +9 -8
- package/docs/V1-V2-COMPATIBILITY-PLAN.md +6 -6
- package/gui-experimental.cjs +8 -8
- package/index.js +1 -0
- package/locales/en.json +1 -0
- package/locales/ru.json +1 -0
- package/locales/zh.json +1 -0
- package/package.json +31 -10
- package/src/core/analytics.ts +2 -2
- package/src/core/audit.ts +17 -17
- package/src/core/cron-to-schtasks.ts +14 -93
- package/src/core/dry-run.ts +26 -26
- package/src/core/file-watcher.ts +17 -17
- package/src/core/git-trigger.ts +9 -9
- package/src/core/glob.ts +1 -1
- package/src/core/local-ai.ts +2 -2
- package/src/core/lock.ts +9 -9
- package/src/core/matrix.ts +31 -31
- package/src/core/native-notify.ts +2 -2
- package/src/core/one-shot.ts +63 -13
- package/src/core/otel.ts +4 -4
- package/src/core/permissions.ts +5 -5
- package/src/core/prometheus.ts +17 -17
- package/src/core/ps-wrapper.ts +57 -37
- package/src/core/record-history.ts +40 -40
- package/src/core/retention.ts +3 -3
- package/src/core/savings.ts +1 -1
- package/src/core/schedule-gate.ts +12 -12
- package/src/core/schedule-v2.ts +24 -24
- package/src/core/scheduler/at-fallback.ts +113 -0
- package/src/core/scheduler/index.ts +3 -3
- package/src/core/scheduler/linux.ts +64 -13
- package/src/core/scheduler/logs.ts +1 -1
- package/src/core/scheduler/mac.ts +112 -60
- package/src/core/scheduler/posix.ts +15 -1
- package/src/core/scheduler/registry.ts +6 -4
- package/src/core/scheduler/windows.ts +295 -125
- package/src/core/secrets.ts +13 -13
- package/src/core/self-analysis.ts +61 -61
- package/src/core/session.ts +3 -3
- package/src/core/structured-log.ts +3 -3
- package/src/core/summary.ts +25 -25
- package/src/core/telegram.ts +16 -16
- package/src/core/triage-chain.ts +4 -4
- package/src/core/triage-compare.ts +8 -8
- package/src/core/triage-rules.ts +4 -4
- package/src/core/triage-shadow.ts +7 -7
- package/src/core/triage-worker.ts +6 -6
- package/src/core/triage.ts +23 -23
- package/src/core/watch-paths.ts +1 -1
- package/src/core/wrappers/bash.ts +41 -41
- package/src/db/git-state-repo.ts +1 -1
- package/src/db/history-repo.ts +22 -22
- package/src/db/index.ts +16 -6
- package/src/db/metrics-repo.ts +10 -10
- package/src/db/migrate.ts +10 -10
- package/src/db/recovery.ts +3 -3
- package/src/db/run-journal.ts +212 -0
- package/src/db/run-resume.ts +220 -0
- package/src/db/runs-repo.ts +481 -0
- package/src/db/schema.ts +205 -44
- package/src/db/settings-repo.ts +2 -2
- package/src/db/tasks-repo.ts +10 -10
- package/src/db/templates-repo.ts +7 -7
- package/src/gui.tsx +1 -1
- package/src/history.ts +4 -4
- package/src/i18n.ts +7 -7
- package/src/index.ts +341 -304
- package/src/integrations.ts +6 -6
- package/src/notifications.ts +76 -76
- package/src/profiles.ts +98 -7
- package/src/rpc.ts +96 -1
- package/src/schtasks.ts +2 -2
- package/src/server.ts +43 -42
- package/src/settings.ts +44 -44
- package/src/shared/jobs-view.ts +60 -60
- package/src/skill.ts +1 -1
- package/src/task-transfer.ts +58 -56
- package/src/templates.ts +1 -1
- package/src/types.ts +45 -10
- package/src/workspaces.ts +16 -16
- package/dist/core/self-analysis.test.d.ts +0 -2
- package/dist/core/self-analysis.test.d.ts.map +0 -1
- package/dist/core/self-analysis.test.js +0 -219
- package/dist/gui-experimental.cjs +0 -1
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
type PluginModule as V1PluginModule,
|
|
7
7
|
} from "@opencode-ai/plugin";
|
|
8
8
|
import { z } from "zod";
|
|
9
|
-
import { Tool } from "@opencode/schema/tool";
|
|
9
|
+
import type { Tool } from "@opencode/schema/tool";
|
|
10
10
|
import { createRequire } from "node:module";
|
|
11
11
|
import { existsSync } from "node:fs";
|
|
12
12
|
import fs from "node:fs/promises";
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
STALE_LOCK_MAX_AGE_MS,
|
|
20
20
|
WRAPPER_DIR,
|
|
21
21
|
sanitizeName,
|
|
22
|
+
validateModelId,
|
|
22
23
|
validateTaskName,
|
|
23
24
|
} from "./types.js";
|
|
24
25
|
import { parseCron, buildScheduleGate, isValidIanaTimeZone, validateLaunchWindow, prevRun, nextRun as cronNextRun, normalizeActiveDays, activeWindowState, nextWindowOpenDelayMs } from "./core/schedule-v2.js";
|
|
@@ -172,8 +173,8 @@ const recorderPath = (() => {
|
|
|
172
173
|
.replace(/\.ts$/, ".js");
|
|
173
174
|
if (existsSync(distPath)) return distPath;
|
|
174
175
|
console.warn(
|
|
175
|
-
"[
|
|
176
|
-
`${distPath}. История/метрики не будут записываться. Выполните npm run build
|
|
176
|
+
"[agent-steward] Не найден собранный record-history.js: " +
|
|
177
|
+
`${distPath}. История/метрики не будут записываться. Выполните npm run build.`,
|
|
177
178
|
);
|
|
178
179
|
return distPath;
|
|
179
180
|
})();
|
|
@@ -190,8 +191,8 @@ const gatePath = (() => {
|
|
|
190
191
|
.replace(/\.ts$/, ".js");
|
|
191
192
|
if (existsSync(distPath)) return distPath;
|
|
192
193
|
console.warn(
|
|
193
|
-
"[
|
|
194
|
-
`${distPath}. Гейт расписания не будет проверяться. Выполните npm run build
|
|
194
|
+
"[agent-steward] Не найден собранный schedule-gate.js: " +
|
|
195
|
+
`${distPath}. Гейт расписания не будет проверяться. Выполните npm run build.`,
|
|
195
196
|
);
|
|
196
197
|
return distPath;
|
|
197
198
|
})();
|
|
@@ -217,37 +218,37 @@ export const matrixSchema = z.object({
|
|
|
217
218
|
.enum(["parallel", "sequential"])
|
|
218
219
|
.optional()
|
|
219
220
|
.describe(
|
|
220
|
-
"parallel (default) starts all clones at once; sequential starts the next clone only after the previous one finishes."
|
|
221
|
+
"parallel (default) starts all clones at once; sequential starts the next clone only after the previous one finishes.",
|
|
221
222
|
),
|
|
222
223
|
failureMode: z
|
|
223
224
|
.enum(["continue", "stop"])
|
|
224
225
|
.optional()
|
|
225
226
|
.describe(
|
|
226
|
-
"continue (default) keeps running the remaining clones after a failure; stop aborts the rest."
|
|
227
|
+
"continue (default) keeps running the remaining clones after a failure; stop aborts the rest.",
|
|
227
228
|
),
|
|
228
229
|
aggregation: z
|
|
229
230
|
.enum(["summary", "per-task"])
|
|
230
231
|
.optional()
|
|
231
232
|
.describe(
|
|
232
|
-
"summary (default) writes one aggregate record for the parent; per-task keeps per-clone records."
|
|
233
|
+
"summary (default) writes one aggregate record for the parent; per-task keeps per-clone records.",
|
|
233
234
|
),
|
|
234
235
|
createAggregator: z
|
|
235
236
|
.boolean()
|
|
236
237
|
.optional()
|
|
237
238
|
.describe(
|
|
238
|
-
"Also create the <parent>-matrix-complete task depending on every clone."
|
|
239
|
+
"Also create the <parent>-matrix-complete task depending on every clone.",
|
|
239
240
|
),
|
|
240
241
|
concurrency: z
|
|
241
242
|
.number()
|
|
242
243
|
.optional()
|
|
243
244
|
.describe(
|
|
244
|
-
"Maximum number of clones running at the same time (>= 1). Ignored for sequential (always 1) and capped by the global maxConcurrent setting."
|
|
245
|
+
"Maximum number of clones running at the same time (>= 1). Ignored for sequential (always 1) and capped by the global maxConcurrent setting.",
|
|
245
246
|
),
|
|
246
247
|
overrides: z
|
|
247
248
|
.record(z.string(), matrixOverrideSchema)
|
|
248
249
|
.optional()
|
|
249
250
|
.describe(
|
|
250
|
-
"Per-workspace overrides keyed by workspace id. Keys must be present in workspaceIds."
|
|
251
|
+
"Per-workspace overrides keyed by workspace id. Keys must be present in workspaceIds.",
|
|
251
252
|
),
|
|
252
253
|
});
|
|
253
254
|
|
|
@@ -256,19 +257,19 @@ export const scheduleTaskSchema = z.object({
|
|
|
256
257
|
name: z
|
|
257
258
|
.string()
|
|
258
259
|
.describe(
|
|
259
|
-
"Unique task name (the plugin prefix is applied automatically). Allowed: letters (including Cyrillic), digits, space, dot, underscore and hyphen."
|
|
260
|
+
"Unique task name (the plugin prefix is applied automatically). Allowed: letters (including Cyrillic), digits, space, dot, underscore and hyphen.",
|
|
260
261
|
),
|
|
261
262
|
schedule: z
|
|
262
263
|
.string()
|
|
263
264
|
.optional()
|
|
264
265
|
.describe(
|
|
265
|
-
"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."
|
|
266
|
+
"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.",
|
|
266
267
|
),
|
|
267
268
|
runAt: z
|
|
268
269
|
.string()
|
|
269
270
|
.optional()
|
|
270
271
|
.describe(
|
|
271
|
-
"Absolute one-shot start time in ISO-8601 (e.g. 2026-12-01T09:00:00Z). Requires triggerType=once; mutually exclusive with delaySeconds (runAt wins)."
|
|
272
|
+
"Absolute one-shot start time in ISO-8601 (e.g. 2026-12-01T09:00:00Z). Requires triggerType=once; mutually exclusive with delaySeconds (runAt wins).",
|
|
272
273
|
),
|
|
273
274
|
delaySeconds: z
|
|
274
275
|
.number()
|
|
@@ -276,13 +277,13 @@ export const scheduleTaskSchema = z.object({
|
|
|
276
277
|
.positive()
|
|
277
278
|
.optional()
|
|
278
279
|
.describe(
|
|
279
|
-
"One-shot delay in seconds from now. Requires triggerType=once. Convenient alternative to runAt."
|
|
280
|
+
"One-shot delay in seconds from now. Requires triggerType=once. Convenient alternative to runAt.",
|
|
280
281
|
),
|
|
281
282
|
session: z
|
|
282
283
|
.enum(["new", "reuse", "last"])
|
|
283
284
|
.optional()
|
|
284
285
|
.describe(
|
|
285
|
-
"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)."
|
|
286
|
+
"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).",
|
|
286
287
|
),
|
|
287
288
|
sessionMaxRuns: z
|
|
288
289
|
.number()
|
|
@@ -291,19 +292,19 @@ export const scheduleTaskSchema = z.object({
|
|
|
291
292
|
.max(10000)
|
|
292
293
|
.optional()
|
|
293
294
|
.describe(
|
|
294
|
-
"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."
|
|
295
|
+
"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.",
|
|
295
296
|
),
|
|
296
297
|
timezone: z
|
|
297
298
|
.string()
|
|
298
299
|
.optional()
|
|
299
300
|
.describe(
|
|
300
|
-
"IANA timezone of the schedule, e.g. Europe/Moscow. Defaults to the system timezone. A zone different from the system one is evaluated by the wrapper (poll mode)."
|
|
301
|
+
"IANA timezone of the schedule, e.g. Europe/Moscow. Defaults to the system timezone. A zone different from the system one is evaluated by the wrapper (poll mode).",
|
|
301
302
|
),
|
|
302
303
|
notBefore: z
|
|
303
304
|
.string()
|
|
304
305
|
.optional()
|
|
305
306
|
.describe(
|
|
306
|
-
"Launch window start in HH:MM (24h). Together with notAfter: a run outside the window is postponed to the next window opening, not skipped."
|
|
307
|
+
"Launch window start in HH:MM (24h). Together with notAfter: a run outside the window is postponed to the next window opening, not skipped.",
|
|
307
308
|
),
|
|
308
309
|
notAfter: z
|
|
309
310
|
.string()
|
|
@@ -320,7 +321,7 @@ export const scheduleTaskSchema = z.object({
|
|
|
320
321
|
.string()
|
|
321
322
|
.optional()
|
|
322
323
|
.describe(
|
|
323
|
-
"LLM model in OpenCode format, e.g. anthropic/claude-3-5-sonnet. Defaults to the OpenCode default model."
|
|
324
|
+
"LLM model in OpenCode format, e.g. anthropic/claude-3-5-sonnet. Defaults to the OpenCode default model.",
|
|
324
325
|
),
|
|
325
326
|
priority: z
|
|
326
327
|
.number()
|
|
@@ -330,25 +331,25 @@ export const scheduleTaskSchema = z.object({
|
|
|
330
331
|
.string()
|
|
331
332
|
.optional()
|
|
332
333
|
.describe(
|
|
333
|
-
"Pre-flight shell command executed before the run (e.g. git pull). A non-zero exit code cancels the run."
|
|
334
|
+
"Pre-flight shell command executed before the run (e.g. git pull). A non-zero exit code cancels the run.",
|
|
334
335
|
),
|
|
335
336
|
afterScript: z
|
|
336
337
|
.string()
|
|
337
338
|
.optional()
|
|
338
339
|
.describe(
|
|
339
|
-
"Post-flight shell command executed after the run (e.g. git push). Runs even when the task fails."
|
|
340
|
+
"Post-flight shell command executed after the run (e.g. git push). Runs even when the task fails.",
|
|
340
341
|
),
|
|
341
342
|
qualityGate: z
|
|
342
343
|
.string()
|
|
343
344
|
.optional()
|
|
344
345
|
.describe(
|
|
345
|
-
"Shell command executed after a successful AI response (e.g. npm test). A non-zero exit code marks the run as a Quality Gate failure."
|
|
346
|
+
"Shell command executed after a successful AI response (e.g. npm test). A non-zero exit code marks the run as a Quality Gate failure.",
|
|
346
347
|
),
|
|
347
348
|
dependsOn: z
|
|
348
349
|
.array(z.string())
|
|
349
350
|
.optional()
|
|
350
351
|
.describe(
|
|
351
|
-
"DAG dependencies: tasks that must finish successfully before this task starts."
|
|
352
|
+
"DAG dependencies: tasks that must finish successfully before this task starts.",
|
|
352
353
|
),
|
|
353
354
|
retryCount: z
|
|
354
355
|
.number()
|
|
@@ -370,7 +371,7 @@ export const scheduleTaskSchema = z.object({
|
|
|
370
371
|
.enum(["cron", "file", "git", "mcp-event", "once"])
|
|
371
372
|
.optional()
|
|
372
373
|
.describe(
|
|
373
|
-
"Trigger type: cron (default), file, git (new commits in the task working directory), mcp-event or once (single run at runAt/delaySeconds)."
|
|
374
|
+
"Trigger type: cron (default), file, git (new commits in the task working directory), mcp-event or once (single run at runAt/delaySeconds).",
|
|
374
375
|
),
|
|
375
376
|
mcpEvent: z
|
|
376
377
|
.object({
|
|
@@ -380,37 +381,37 @@ export const scheduleTaskSchema = z.object({
|
|
|
380
381
|
})
|
|
381
382
|
.optional()
|
|
382
383
|
.describe(
|
|
383
|
-
"MCP event trigger: server, event name and an optional filter (key=value or regex)."
|
|
384
|
+
"MCP event trigger: server, event name and an optional filter (key=value or regex).",
|
|
384
385
|
),
|
|
385
386
|
watchPath: z
|
|
386
387
|
.string()
|
|
387
388
|
.optional()
|
|
388
389
|
.describe(
|
|
389
|
-
"File or directory to watch when triggerType is \"file\". Can be set here or later via update_task."
|
|
390
|
+
"File or directory to watch when triggerType is \"file\". Can be set here or later via update_task.",
|
|
390
391
|
),
|
|
391
392
|
watchGlobs: z
|
|
392
393
|
.array(z.string())
|
|
393
394
|
.optional()
|
|
394
395
|
.describe(
|
|
395
|
-
"Glob masks that limit a file trigger, e.g. [\"**/*.md\", \"src/**\"]. Empty means any change under watchPath."
|
|
396
|
+
"Glob masks that limit a file trigger, e.g. [\"**/*.md\", \"src/**\"]. Empty means any change under watchPath.",
|
|
396
397
|
),
|
|
397
398
|
watchIgnore: z
|
|
398
399
|
.array(z.string())
|
|
399
400
|
.optional()
|
|
400
401
|
.describe(
|
|
401
|
-
"Glob masks excluded from a file trigger, e.g. [\"node_modules/**\", \"*.log\"]. Supports leading ! to re-include."
|
|
402
|
+
"Glob masks excluded from a file trigger, e.g. [\"node_modules/**\", \"*.log\"]. Supports leading ! to re-include.",
|
|
402
403
|
),
|
|
403
404
|
gitBranch: z
|
|
404
405
|
.string()
|
|
405
406
|
.optional()
|
|
406
407
|
.describe(
|
|
407
|
-
"Only for triggerType=git: branch name or glob (main, release/*, comma-separated). Empty means any branch."
|
|
408
|
+
"Only for triggerType=git: branch name or glob (main, release/*, comma-separated). Empty means any branch.",
|
|
408
409
|
),
|
|
409
410
|
gitPaths: z
|
|
410
411
|
.array(z.string())
|
|
411
412
|
.optional()
|
|
412
413
|
.describe(
|
|
413
|
-
"Only for triggerType=git: glob masks of changed files that must match to start the task (git diff --name-only)."
|
|
414
|
+
"Only for triggerType=git: glob masks of changed files that must match to start the task (git diff --name-only).",
|
|
414
415
|
),
|
|
415
416
|
gitIgnore: z
|
|
416
417
|
.array(z.string())
|
|
@@ -426,54 +427,54 @@ export const scheduleTaskSchema = z.object({
|
|
|
426
427
|
.array(z.number().int().min(0).max(6))
|
|
427
428
|
.optional()
|
|
428
429
|
.describe(
|
|
429
|
-
"Allowed weekdays 0=Sunday..6=Saturday for cron and event triggers. Empty or all seven means every day."
|
|
430
|
+
"Allowed weekdays 0=Sunday..6=Saturday for cron and event triggers. Empty or all seven means every day.",
|
|
430
431
|
),
|
|
431
432
|
windowPolicy: z
|
|
432
433
|
.enum(["skip", "postpone", "run"])
|
|
433
434
|
.optional()
|
|
434
435
|
.describe(
|
|
435
|
-
"Behaviour outside the launch window / active days: postpone (default, wait for the next opening), skip or run anyway."
|
|
436
|
+
"Behaviour outside the launch window / active days: postpone (default, wait for the next opening), skip or run anyway.",
|
|
436
437
|
),
|
|
437
438
|
workingDirectory: z
|
|
438
439
|
.string()
|
|
439
440
|
.optional()
|
|
440
441
|
.describe(
|
|
441
|
-
"Working directory of the task. Defaults to the current project folder so opencode run picks up the project's opencode.json with MCP servers."
|
|
442
|
+
"Working directory of the task. Defaults to the current project folder so opencode run picks up the project's opencode.json with MCP servers.",
|
|
442
443
|
),
|
|
443
444
|
workspaceId: z
|
|
444
445
|
.string()
|
|
445
446
|
.optional()
|
|
446
447
|
.describe(
|
|
447
|
-
"Multi-repo workspace binding. When set, cwd = workspace path and workingDirectory is ignored."
|
|
448
|
+
"Multi-repo workspace binding. When set, cwd = workspace path and workingDirectory is ignored.",
|
|
448
449
|
),
|
|
449
450
|
allowedTools: z
|
|
450
451
|
.array(z.string())
|
|
451
452
|
.optional()
|
|
452
453
|
.describe(
|
|
453
|
-
"Role-scoped tool allow-list, enforced through OPENCODE_CONFIG_CONTENT. A non-empty list also allows actions that the default policy denies (for example shell). An empty array is rejected."
|
|
454
|
+
"Role-scoped tool allow-list, enforced through OPENCODE_CONFIG_CONTENT. A non-empty list also allows actions that the default policy denies (for example shell). An empty array is rejected.",
|
|
454
455
|
),
|
|
455
456
|
deniedTools: z
|
|
456
457
|
.array(z.string())
|
|
457
458
|
.optional()
|
|
458
459
|
.describe(
|
|
459
|
-
"Role-scoped tool deny-list (takes precedence over allowedTools and over the default policy). Enforced through OPENCODE_CONFIG_CONTENT."
|
|
460
|
+
"Role-scoped tool deny-list (takes precedence over allowedTools and over the default policy). Enforced through OPENCODE_CONFIG_CONTENT.",
|
|
460
461
|
),
|
|
461
462
|
legacyShell: z
|
|
462
463
|
.boolean()
|
|
463
464
|
.optional()
|
|
464
465
|
.describe(
|
|
465
|
-
"Transitional flag (release 1.6): under the hybrid policy, re-enable shell for this task. Prefer listing shell in allowedTools. Ignored by secure/legacy policy."
|
|
466
|
+
"Transitional flag (release 1.6): under the hybrid policy, re-enable shell for this task. Prefer listing shell in allowedTools. Ignored by secure/legacy policy.",
|
|
466
467
|
),
|
|
467
468
|
runWhenLoggedOff: z
|
|
468
469
|
.boolean()
|
|
469
470
|
.optional()
|
|
470
471
|
.describe(
|
|
471
|
-
"Windows only: run the task even when no user is logged on (/ru SYSTEM). The task runs in session 0 without the user's profile, mapped drives or saved credentials, so tasks that need the user's environment may fail. Creating such a task usually requires an elevated shell. Default false: interactive only — the task runs only while the user is logged on."
|
|
472
|
+
"Windows only: run the task even when no user is logged on (/ru SYSTEM). The task runs in session 0 without the user's profile, mapped drives or saved credentials, so tasks that need the user's environment may fail. Creating such a task usually requires an elevated shell. Default false: interactive only — the task runs only while the user is logged on.",
|
|
472
473
|
),
|
|
473
474
|
matrix: matrixSchema
|
|
474
475
|
.optional()
|
|
475
476
|
.describe(
|
|
476
|
-
"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."
|
|
477
|
+
"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.",
|
|
477
478
|
),
|
|
478
479
|
}).superRefine((value, ctx) => {
|
|
479
480
|
const trigger = value.triggerType ?? "cron";
|
|
@@ -531,7 +532,7 @@ export const updateTaskSchema = z.object({
|
|
|
531
532
|
.string()
|
|
532
533
|
.optional()
|
|
533
534
|
.describe(
|
|
534
|
-
"New one-shot time in ISO-8601. Requires triggerType=once. Empty string clears it."
|
|
535
|
+
"New one-shot time in ISO-8601. Requires triggerType=once. Empty string clears it.",
|
|
535
536
|
),
|
|
536
537
|
delaySeconds: z
|
|
537
538
|
.number()
|
|
@@ -539,13 +540,13 @@ export const updateTaskSchema = z.object({
|
|
|
539
540
|
.positive()
|
|
540
541
|
.optional()
|
|
541
542
|
.describe(
|
|
542
|
-
"New one-shot delay in seconds from now. Requires triggerType=once."
|
|
543
|
+
"New one-shot delay in seconds from now. Requires triggerType=once.",
|
|
543
544
|
),
|
|
544
545
|
session: z
|
|
545
546
|
.enum(["new", "reuse", "last"])
|
|
546
547
|
.optional()
|
|
547
548
|
.describe(
|
|
548
|
-
"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)."
|
|
549
|
+
"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).",
|
|
549
550
|
),
|
|
550
551
|
sessionMaxRuns: z
|
|
551
552
|
.number()
|
|
@@ -554,7 +555,7 @@ export const updateTaskSchema = z.object({
|
|
|
554
555
|
.max(10000)
|
|
555
556
|
.optional()
|
|
556
557
|
.describe(
|
|
557
|
-
"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."
|
|
558
|
+
"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.",
|
|
558
559
|
),
|
|
559
560
|
timezone: z
|
|
560
561
|
.string()
|
|
@@ -572,7 +573,7 @@ export const updateTaskSchema = z.object({
|
|
|
572
573
|
.array(z.number().int().min(0).max(6))
|
|
573
574
|
.optional()
|
|
574
575
|
.describe(
|
|
575
|
-
"New allowed weekdays 0=Sunday..6=Saturday. Empty array clears the restriction."
|
|
576
|
+
"New allowed weekdays 0=Sunday..6=Saturday. Empty array clears the restriction.",
|
|
576
577
|
),
|
|
577
578
|
windowPolicy: z
|
|
578
579
|
.enum(["skip", "postpone", "run"])
|
|
@@ -582,7 +583,7 @@ export const updateTaskSchema = z.object({
|
|
|
582
583
|
.boolean()
|
|
583
584
|
.optional()
|
|
584
585
|
.describe(
|
|
585
|
-
"Windows only: true runs the task without a logged-on user (/ru SYSTEM, session 0 without the user profile, mapped drives or saved credentials; usually requires an elevated shell). false/omitted keeps the task interactive-only."
|
|
586
|
+
"Windows only: true runs the task without a logged-on user (/ru SYSTEM, session 0 without the user profile, mapped drives or saved credentials; usually requires an elevated shell). false/omitted keeps the task interactive-only.",
|
|
586
587
|
),
|
|
587
588
|
watchGlobs: z
|
|
588
589
|
.array(z.string())
|
|
@@ -682,13 +683,13 @@ export const updateTaskSchema = z.object({
|
|
|
682
683
|
.boolean()
|
|
683
684
|
.optional()
|
|
684
685
|
.describe(
|
|
685
|
-
"Transitional flag (release 1.6): re-enable shell under the hybrid policy for this task."
|
|
686
|
+
"Transitional flag (release 1.6): re-enable shell under the hybrid policy for this task.",
|
|
686
687
|
),
|
|
687
688
|
matrix: matrixSchema
|
|
688
689
|
.nullable()
|
|
689
690
|
.optional()
|
|
690
691
|
.describe(
|
|
691
|
-
"New matrix configuration. Pass null to turn the matrix off (clones and aggregator are removed)."
|
|
692
|
+
"New matrix configuration. Pass null to turn the matrix off (clones and aggregator are removed).",
|
|
692
693
|
),
|
|
693
694
|
}).superRefine((value, ctx) => {
|
|
694
695
|
if (
|
|
@@ -717,7 +718,7 @@ const pauseTaskSchema = z.object({
|
|
|
717
718
|
.string()
|
|
718
719
|
.optional()
|
|
719
720
|
.describe(
|
|
720
|
-
"Optional ISO date/time to resume automatically (e.g. 2026-12-01T09:00:00Z). The plugin re-enables the task at that moment."
|
|
721
|
+
"Optional ISO date/time to resume automatically (e.g. 2026-12-01T09:00:00Z). The plugin re-enables the task at that moment.",
|
|
721
722
|
),
|
|
722
723
|
});
|
|
723
724
|
|
|
@@ -753,7 +754,7 @@ const dryRunSchema = z.object({
|
|
|
753
754
|
.string()
|
|
754
755
|
.optional()
|
|
755
756
|
.describe(
|
|
756
|
-
"Task name to simulate. When omitted, every task is simulated (pipeline dry run, nothing is executed)."
|
|
757
|
+
"Task name to simulate. When omitted, every task is simulated (pipeline dry run, nothing is executed).",
|
|
757
758
|
),
|
|
758
759
|
});
|
|
759
760
|
|
|
@@ -770,7 +771,7 @@ const manageWorkspacesSchema = z.object({
|
|
|
770
771
|
.nullable()
|
|
771
772
|
.optional()
|
|
772
773
|
.describe(
|
|
773
|
-
"Workspace environment variables (key → value). Override envFile values; secrets are masked in logs (add/update)."
|
|
774
|
+
"Workspace environment variables (key → value). Override envFile values; secrets are masked in logs (add/update).",
|
|
774
775
|
),
|
|
775
776
|
envFile: z
|
|
776
777
|
.string()
|
|
@@ -783,7 +784,7 @@ export const matrixControlSchema = z.object({
|
|
|
783
784
|
action: z
|
|
784
785
|
.enum(["results", "cancel", "cleanup", "preview"])
|
|
785
786
|
.describe(
|
|
786
|
-
"results — aggregate status of a matrix; cancel — cancel pending clones; cleanup — delete orphaned clones and aggregators; preview — dry-expand a matrix config into clone names without creating anything."
|
|
787
|
+
"results — aggregate status of a matrix; cancel — cancel pending clones; cleanup — delete orphaned clones and aggregators; preview — dry-expand a matrix config into clone names without creating anything.",
|
|
787
788
|
),
|
|
788
789
|
name: z
|
|
789
790
|
.string()
|
|
@@ -874,7 +875,7 @@ export const manageSettingsSchema = z.object({
|
|
|
874
875
|
.enum(["auto", "ru", "en", "zh"])
|
|
875
876
|
.optional()
|
|
876
877
|
.describe(
|
|
877
|
-
"Interface language: auto (follow OpenCode), ru (default), en or zh. Applies without restart."
|
|
878
|
+
"Interface language: auto (follow OpenCode), ru (default), en or zh. Applies without restart.",
|
|
878
879
|
),
|
|
879
880
|
winterMode: z
|
|
880
881
|
.boolean()
|
|
@@ -895,7 +896,7 @@ export const manageSettingsSchema = z.object({
|
|
|
895
896
|
.any()
|
|
896
897
|
.optional()
|
|
897
898
|
.describe(
|
|
898
|
-
"Integration settings patch (hooks: enabled, token, secret, requireSignature, maxBodyBytes, timestampToleranceSeconds)."
|
|
899
|
+
"Integration settings patch (hooks: enabled, token, secret, requireSignature, maxBodyBytes, timestampToleranceSeconds).",
|
|
899
900
|
),
|
|
900
901
|
audit: z
|
|
901
902
|
.any()
|
|
@@ -907,7 +908,7 @@ export const manageSettingsSchema = z.object({
|
|
|
907
908
|
})
|
|
908
909
|
.optional()
|
|
909
910
|
.describe(
|
|
910
|
-
"Tool permission policy for background tasks: hybrid (default; shell/question denied), secure (read-only), legacy (allow everything, 1.5.x behaviour)."
|
|
911
|
+
"Tool permission policy for background tasks: hybrid (default; shell/question denied), secure (read-only), legacy (allow everything, 1.5.x behaviour).",
|
|
911
912
|
),
|
|
912
913
|
});
|
|
913
914
|
|
|
@@ -916,20 +917,20 @@ export const manageLocalAiSchema = z.object({
|
|
|
916
917
|
action: z
|
|
917
918
|
.enum(["get", "update", "test"])
|
|
918
919
|
.describe(
|
|
919
|
-
"get — current triage settings and shadow state; update — merge fields and save; test — one classification request against the configured model."
|
|
920
|
+
"get — current triage settings and shadow state; update — merge fields and save; test — one classification request against the configured model.",
|
|
920
921
|
),
|
|
921
922
|
mode: z
|
|
922
923
|
.enum(["off", "rules", "llm", "auto"])
|
|
923
924
|
.optional()
|
|
924
925
|
.describe(
|
|
925
|
-
"off — no triage; rules — built-in rules only; llm — model only; auto — model, then rules (default)."
|
|
926
|
+
"off — no triage; rules — built-in rules only; llm — model only; auto — model, then rules (default).",
|
|
926
927
|
),
|
|
927
928
|
baseUrl: z
|
|
928
929
|
.string()
|
|
929
930
|
.max(500)
|
|
930
931
|
.optional()
|
|
931
932
|
.describe(
|
|
932
|
-
"Ollama or OpenAI-compatible base URL, for example http://127.0.0.1:11434. A URL ending with /v1 switches to the OpenAI protocol."
|
|
933
|
+
"Ollama or OpenAI-compatible base URL, for example http://127.0.0.1:11434. A URL ending with /v1 switches to the OpenAI protocol.",
|
|
933
934
|
),
|
|
934
935
|
model: z
|
|
935
936
|
.string()
|
|
@@ -947,7 +948,7 @@ export const manageLocalAiSchema = z.object({
|
|
|
947
948
|
.enum(["rules", "notify", "skip"])
|
|
948
949
|
.optional()
|
|
949
950
|
.describe(
|
|
950
|
-
"When the model fails or is unsure: rules - apply rules (fail-open, default); notify - skip the rules step and deliver the notification; skip - legacy alias for notify."
|
|
951
|
+
"When the model fails or is unsure: rules - apply rules (fail-open, default); notify - skip the rules step and deliver the notification; skip - legacy alias for notify.",
|
|
951
952
|
),
|
|
952
953
|
confidenceThreshold: z
|
|
953
954
|
.number()
|
|
@@ -1110,7 +1111,7 @@ let projectDirectory: string | undefined;
|
|
|
1110
1111
|
* Использует Tool.Context из @opencode/schema/tool.
|
|
1111
1112
|
*/
|
|
1112
1113
|
function wrapExecute<Args>(
|
|
1113
|
-
fn: (args: Args, ctx: Tool.Context) => Promise<Tool.Result
|
|
1114
|
+
fn: (args: Args, ctx: Tool.Context) => Promise<Tool.Result>,
|
|
1114
1115
|
): (input: Args, context: Tool.Context) => Promise<Tool.Result> {
|
|
1115
1116
|
return async (input, context) => {
|
|
1116
1117
|
try {
|
|
@@ -1152,7 +1153,7 @@ function computeTaskNextRun(
|
|
|
1152
1153
|
| "pausedUntil"
|
|
1153
1154
|
>
|
|
1154
1155
|
| undefined,
|
|
1155
|
-
options: { paused?: boolean; now?: Date } = {}
|
|
1156
|
+
options: { paused?: boolean; now?: Date } = {},
|
|
1156
1157
|
): string | null {
|
|
1157
1158
|
if (!def) return null;
|
|
1158
1159
|
if (options.paused) return null;
|
|
@@ -1319,7 +1320,7 @@ const scheduleTaskExecute = wrapExecute<ScheduleArgs>(async (args) => {
|
|
|
1319
1320
|
// Спринт 27.5.4: Windows — работать без входа (/ru SYSTEM).
|
|
1320
1321
|
runWhenLoggedOff === true,
|
|
1321
1322
|
undefined,
|
|
1322
|
-
legacyShell === true
|
|
1323
|
+
legacyShell === true,
|
|
1323
1324
|
);
|
|
1324
1325
|
} catch (err: any) {
|
|
1325
1326
|
return {
|
|
@@ -1429,10 +1430,10 @@ const listTasksExecute = wrapExecute<ListArgs>(async () => {
|
|
|
1429
1430
|
* чтобы матрицу можно было запустить повторно.
|
|
1430
1431
|
*/
|
|
1431
1432
|
async function cancelMatrixRun(
|
|
1432
|
-
name: string
|
|
1433
|
+
name: string,
|
|
1433
1434
|
): Promise<{ cancelled: string[]; running: string[]; message: string; warnings: string[] }> {
|
|
1434
1435
|
const definition = (await loadTaskDefinitions()).find(
|
|
1435
|
-
(def) => def.name.toLowerCase() === name.trim().toLowerCase()
|
|
1436
|
+
(def) => def.name.toLowerCase() === name.trim().toLowerCase(),
|
|
1436
1437
|
);
|
|
1437
1438
|
if (!definition?.matrix) {
|
|
1438
1439
|
throw new Error(t("tool.error.matrixNotMatrix", { name }));
|
|
@@ -1443,7 +1444,7 @@ async function cancelMatrixRun(
|
|
|
1443
1444
|
|
|
1444
1445
|
for (const cloneName of result.running) {
|
|
1445
1446
|
const clone = (await loadTaskDefinitions()).find(
|
|
1446
|
-
(def) => def.name.toLowerCase() === cloneName.toLowerCase()
|
|
1447
|
+
(def) => def.name.toLowerCase() === cloneName.toLowerCase(),
|
|
1447
1448
|
);
|
|
1448
1449
|
if (!clone) continue;
|
|
1449
1450
|
|
|
@@ -1455,7 +1456,7 @@ async function cancelMatrixRun(
|
|
|
1455
1456
|
t("tool.matrix.stopFailed", {
|
|
1456
1457
|
clone: clone.name,
|
|
1457
1458
|
error: err instanceof Error ? err.message : String(err),
|
|
1458
|
-
})
|
|
1459
|
+
}),
|
|
1459
1460
|
);
|
|
1460
1461
|
continue;
|
|
1461
1462
|
}
|
|
@@ -1498,14 +1499,14 @@ async function cancelMatrixRun(
|
|
|
1498
1499
|
undefined,
|
|
1499
1500
|
clone.runWhenLoggedOff,
|
|
1500
1501
|
clone.paused,
|
|
1501
|
-
clone.legacyShell
|
|
1502
|
+
clone.legacyShell,
|
|
1502
1503
|
);
|
|
1503
1504
|
} catch (err: any) {
|
|
1504
1505
|
warnings.push(
|
|
1505
1506
|
t("tool.matrix.recreateFailed", {
|
|
1506
1507
|
clone: clone.name,
|
|
1507
1508
|
error: err instanceof Error ? err.message : String(err),
|
|
1508
|
-
})
|
|
1509
|
+
}),
|
|
1509
1510
|
);
|
|
1510
1511
|
}
|
|
1511
1512
|
}
|
|
@@ -1556,7 +1557,7 @@ async function cleanupOrphanedMatrixTasks(): Promise<string[]> {
|
|
|
1556
1557
|
|
|
1557
1558
|
if (removed.length > 0) {
|
|
1558
1559
|
console.log(
|
|
1559
|
-
`[matrix] Очищены осиротевшие задачи матриц: ${removed.join(", ")}
|
|
1560
|
+
`[matrix] Очищены осиротевшие задачи матриц: ${removed.join(", ")}`,
|
|
1560
1561
|
);
|
|
1561
1562
|
}
|
|
1562
1563
|
return removed;
|
|
@@ -1647,7 +1648,7 @@ async function garbageCollectTaskArtifacts(): Promise<void> {
|
|
|
1647
1648
|
}
|
|
1648
1649
|
|
|
1649
1650
|
async function deleteTaskWithFamily(
|
|
1650
|
-
name: string
|
|
1651
|
+
name: string,
|
|
1651
1652
|
): Promise<{ removed: string[]; existed: boolean }> {
|
|
1652
1653
|
const trimmed = name.trim();
|
|
1653
1654
|
const guard = getMatrixDeletionGuard(trimmed);
|
|
@@ -1663,7 +1664,7 @@ async function deleteTaskWithFamily(
|
|
|
1663
1664
|
try {
|
|
1664
1665
|
const osTasks = await scheduler.listTasks();
|
|
1665
1666
|
existed = osTasks.some(
|
|
1666
|
-
(task) => task.taskName.toLowerCase() === trimmed.toLowerCase()
|
|
1667
|
+
(task) => task.taskName.toLowerCase() === trimmed.toLowerCase(),
|
|
1667
1668
|
);
|
|
1668
1669
|
} catch {
|
|
1669
1670
|
// ОС-планировщик недоступен — довольствуемся данными БД.
|
|
@@ -1768,7 +1769,7 @@ const runTaskNowExecute = wrapExecute<RunNowArgs>(async (args) => {
|
|
|
1768
1769
|
*/
|
|
1769
1770
|
function clearableString(
|
|
1770
1771
|
next: string | undefined,
|
|
1771
|
-
current: string | undefined
|
|
1772
|
+
current: string | undefined,
|
|
1772
1773
|
): string | undefined {
|
|
1773
1774
|
if (next === undefined) return current;
|
|
1774
1775
|
const trimmed = next.trim();
|
|
@@ -1777,7 +1778,7 @@ function clearableString(
|
|
|
1777
1778
|
|
|
1778
1779
|
function clearableList(
|
|
1779
1780
|
next: string[] | undefined,
|
|
1780
|
-
current: string[] | undefined
|
|
1781
|
+
current: string[] | undefined,
|
|
1781
1782
|
): string[] | undefined {
|
|
1782
1783
|
if (next === undefined) return current;
|
|
1783
1784
|
const cleaned = next.map((value) => value.trim()).filter(Boolean);
|
|
@@ -1808,7 +1809,7 @@ async function removeMatrixChildrenFromScheduler(name: string): Promise<string[]
|
|
|
1808
1809
|
* Используется инструментом update_task и RPC-методом update_task.
|
|
1809
1810
|
*/
|
|
1810
1811
|
async function updateTaskFromInput(
|
|
1811
|
-
input: UpdateArgs & { newSchedule?: string; newPrompt?: string }
|
|
1812
|
+
input: UpdateArgs & { newSchedule?: string; newPrompt?: string },
|
|
1812
1813
|
): Promise<{
|
|
1813
1814
|
success: boolean;
|
|
1814
1815
|
message: string;
|
|
@@ -1859,8 +1860,8 @@ async function updateTaskFromInput(
|
|
|
1859
1860
|
input.runAt !== undefined
|
|
1860
1861
|
? input.runAt
|
|
1861
1862
|
: input.delaySeconds !== undefined
|
|
1862
|
-
|
|
1863
|
-
|
|
1863
|
+
? undefined
|
|
1864
|
+
: previous.runAt;
|
|
1864
1865
|
const normalized = normalizeOneShotRunAt({
|
|
1865
1866
|
runAt: candidateRunAt,
|
|
1866
1867
|
delaySeconds: input.delaySeconds,
|
|
@@ -1921,7 +1922,7 @@ async function updateTaskFromInput(
|
|
|
1921
1922
|
// Спринт 27: параметры триггеров сохраняются, если поле не передано.
|
|
1922
1923
|
const mergeStringList = (
|
|
1923
1924
|
next: string[] | undefined,
|
|
1924
|
-
prev: string[] | undefined
|
|
1925
|
+
prev: string[] | undefined,
|
|
1925
1926
|
): string[] | undefined => {
|
|
1926
1927
|
if (next === undefined) return prev;
|
|
1927
1928
|
const cleaned = next
|
|
@@ -1950,9 +1951,23 @@ async function updateTaskFromInput(
|
|
|
1950
1951
|
// после create — иначе задача молча начинает выполняться по расписанию.
|
|
1951
1952
|
const wasPaused = Boolean(
|
|
1952
1953
|
previous.paused === true ||
|
|
1953
|
-
(previous.pausedUntil && Date.parse(previous.pausedUntil) > Date.now())
|
|
1954
|
+
(previous.pausedUntil && Date.parse(previous.pausedUntil) > Date.now()),
|
|
1954
1955
|
);
|
|
1955
1956
|
|
|
1957
|
+
const nextModel = clearableString(input.model, previous.model);
|
|
1958
|
+
if (nextModel) {
|
|
1959
|
+
const modelError = validateModelId(nextModel);
|
|
1960
|
+
if (modelError) {
|
|
1961
|
+
return {
|
|
1962
|
+
success: false,
|
|
1963
|
+
message: t("tool.error.modelInvalid", {
|
|
1964
|
+
model: nextModel,
|
|
1965
|
+
error: modelError,
|
|
1966
|
+
}),
|
|
1967
|
+
};
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1956
1971
|
let previousDeleted = false;
|
|
1957
1972
|
try {
|
|
1958
1973
|
// Обновление = пересоздание в планировщике с сохранением старых значений.
|
|
@@ -1972,7 +1987,7 @@ async function updateTaskFromInput(
|
|
|
1972
1987
|
triggerType,
|
|
1973
1988
|
clearableString(input.watchPath, previous.watchPath),
|
|
1974
1989
|
clearableList(input.dependsOn, previous.dependsOn),
|
|
1975
|
-
|
|
1990
|
+
nextModel,
|
|
1976
1991
|
input.priority ?? previous.priority,
|
|
1977
1992
|
clearableString(input.beforeScript, previous.beforeScript),
|
|
1978
1993
|
clearableString(input.afterScript, previous.afterScript),
|
|
@@ -1996,7 +2011,7 @@ async function updateTaskFromInput(
|
|
|
1996
2011
|
triggerExtras,
|
|
1997
2012
|
input.runWhenLoggedOff ?? previous.runWhenLoggedOff,
|
|
1998
2013
|
wasPaused,
|
|
1999
|
-
input.legacyShell ?? previous.legacyShell
|
|
2014
|
+
input.legacyShell ?? previous.legacyShell,
|
|
2000
2015
|
);
|
|
2001
2016
|
|
|
2002
2017
|
// Матрица отключена при обновлении — убираем клонов и агрегатор.
|
|
@@ -2109,7 +2124,7 @@ const updateTaskExecute = wrapExecute<UpdateArgs>(async (args) => {
|
|
|
2109
2124
|
async function pauseOrResumeTask(
|
|
2110
2125
|
name: string,
|
|
2111
2126
|
paused: boolean,
|
|
2112
|
-
until?: string
|
|
2127
|
+
until?: string,
|
|
2113
2128
|
): Promise<{
|
|
2114
2129
|
success: boolean;
|
|
2115
2130
|
message: string;
|
|
@@ -2190,7 +2205,7 @@ async function pauseOrResumeTask(
|
|
|
2190
2205
|
affected.push(target);
|
|
2191
2206
|
} catch (err: any) {
|
|
2192
2207
|
warnings.push(
|
|
2193
|
-
`${target}: ${err instanceof Error ? err.message : String(err)}
|
|
2208
|
+
`${target}: ${err instanceof Error ? err.message : String(err)}`,
|
|
2194
2209
|
);
|
|
2195
2210
|
}
|
|
2196
2211
|
}
|
|
@@ -2211,7 +2226,7 @@ async function pauseOrResumeTask(
|
|
|
2211
2226
|
warnings.push(
|
|
2212
2227
|
t("tool.task.autosave", {
|
|
2213
2228
|
error: err instanceof Error ? err.message : String(err),
|
|
2214
|
-
})
|
|
2229
|
+
}),
|
|
2215
2230
|
);
|
|
2216
2231
|
}
|
|
2217
2232
|
}
|
|
@@ -2222,20 +2237,20 @@ async function pauseOrResumeTask(
|
|
|
2222
2237
|
const verb = paused ? t("tool.task.paused") : t("tool.task.resumed");
|
|
2223
2238
|
const message = definition.matrix
|
|
2224
2239
|
? t("tool.task.matrixPaused", {
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2240
|
+
name: trimmed,
|
|
2241
|
+
verb,
|
|
2242
|
+
until: untilText,
|
|
2243
|
+
affected: affected.length,
|
|
2244
|
+
total: targets.length,
|
|
2245
|
+
}) +
|
|
2231
2246
|
(warnings.length > 0
|
|
2232
2247
|
? t("tool.task.matrixPauseErrors", { warnings: warnings.join("; ") })
|
|
2233
2248
|
: "")
|
|
2234
2249
|
: t("tool.task.pausedText", {
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2250
|
+
name: trimmed,
|
|
2251
|
+
verb,
|
|
2252
|
+
until: untilText,
|
|
2253
|
+
}) +
|
|
2239
2254
|
(warnings.length > 0
|
|
2240
2255
|
? t("tool.task.pauseError", { warnings: warnings.join("; ") })
|
|
2241
2256
|
: "");
|
|
@@ -2304,13 +2319,13 @@ async function resumeExpiredPauses(): Promise<void> {
|
|
|
2304
2319
|
paused: false,
|
|
2305
2320
|
});
|
|
2306
2321
|
console.log(
|
|
2307
|
-
`[
|
|
2322
|
+
`[agent-steward] Автопродолжение: задача "${definition.name}" включена (пауза истекла).`,
|
|
2308
2323
|
);
|
|
2309
2324
|
} catch (err: any) {
|
|
2310
2325
|
console.error(
|
|
2311
|
-
`[
|
|
2326
|
+
`[agent-steward] Не удалось автопродолжить задачу "${definition.name}": ${
|
|
2312
2327
|
err instanceof Error ? err.message : String(err)
|
|
2313
|
-
}
|
|
2328
|
+
}`,
|
|
2314
2329
|
);
|
|
2315
2330
|
}
|
|
2316
2331
|
}
|
|
@@ -2566,7 +2581,7 @@ const matrixControlExecute = wrapExecute<MatrixControlArgs>(async (args) => {
|
|
|
2566
2581
|
failureMode: args.failureMode,
|
|
2567
2582
|
aggregation: args.aggregation,
|
|
2568
2583
|
},
|
|
2569
|
-
}
|
|
2584
|
+
});
|
|
2570
2585
|
return {
|
|
2571
2586
|
content: JSON.stringify({
|
|
2572
2587
|
success: true,
|
|
@@ -2945,7 +2960,7 @@ const transferTasksExecute = wrapExecute<TransferArgs>(async (args) => {
|
|
|
2945
2960
|
if (args.action === "export") {
|
|
2946
2961
|
const tasks = await scheduler.listTasks();
|
|
2947
2962
|
const { data, count } = await buildExportJson(
|
|
2948
|
-
tasks.map((task) => ({ ...task, name: task.taskName || "" }))
|
|
2963
|
+
tasks.map((task) => ({ ...task, name: task.taskName || "" })),
|
|
2949
2964
|
);
|
|
2950
2965
|
return { content: JSON.stringify({ success: true, data, count }) };
|
|
2951
2966
|
}
|
|
@@ -2997,7 +3012,7 @@ const transferTasksExecute = wrapExecute<TransferArgs>(async (args) => {
|
|
|
2997
3012
|
def.notBefore,
|
|
2998
3013
|
def.notAfter,
|
|
2999
3014
|
def.pausedUntil,
|
|
3000
|
-
def.runAt
|
|
3015
|
+
def.runAt,
|
|
3001
3016
|
);
|
|
3002
3017
|
await saveTaskDefinition(def);
|
|
3003
3018
|
imported.push(def.name);
|
|
@@ -3047,11 +3062,11 @@ const cleanupHistoryExecute = wrapExecute<CleanupHistoryArgs>(async (args) => {
|
|
|
3047
3062
|
message: report.skipped
|
|
3048
3063
|
? report.skipped
|
|
3049
3064
|
: t("tool.history.cleaned", {
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3065
|
+
deleted: report.deleted,
|
|
3066
|
+
byAge: report.deletedByAge,
|
|
3067
|
+
byCount: report.deletedByCount,
|
|
3068
|
+
kept: report.kept,
|
|
3069
|
+
}),
|
|
3055
3070
|
report,
|
|
3056
3071
|
}),
|
|
3057
3072
|
};
|
|
@@ -3070,11 +3085,11 @@ const emitEventExecute = wrapExecute<EmitEventArgs>(async (args) => {
|
|
|
3070
3085
|
(def) =>
|
|
3071
3086
|
def.triggerType === "mcp-event" &&
|
|
3072
3087
|
def.mcpEvent?.event?.toLowerCase() === eventName.toLowerCase() &&
|
|
3073
|
-
matchesEventFilter(def.mcpEvent?.filter, payload)
|
|
3088
|
+
matchesEventFilter(def.mcpEvent?.filter, payload),
|
|
3074
3089
|
)
|
|
3075
3090
|
.sort(
|
|
3076
3091
|
(a, b) =>
|
|
3077
|
-
(normalizePriority(b.priority) ?? 0) - (normalizePriority(a.priority) ?? 0)
|
|
3092
|
+
(normalizePriority(b.priority) ?? 0) - (normalizePriority(a.priority) ?? 0),
|
|
3078
3093
|
);
|
|
3079
3094
|
|
|
3080
3095
|
const triggered: string[] = [];
|
|
@@ -3083,7 +3098,7 @@ const emitEventExecute = wrapExecute<EmitEventArgs>(async (args) => {
|
|
|
3083
3098
|
await runTaskEntry(def.name);
|
|
3084
3099
|
triggered.push(def.name);
|
|
3085
3100
|
} catch (err: any) {
|
|
3086
|
-
console.error(`[
|
|
3101
|
+
console.error(`[agent-steward] emit_event: не удалось запустить ${def.name}:`, err);
|
|
3087
3102
|
}
|
|
3088
3103
|
}
|
|
3089
3104
|
return {
|
|
@@ -3167,7 +3182,7 @@ const getAuditLogExecute = wrapExecute<AuditLogArgs>(async (args) => {
|
|
|
3167
3182
|
function withAudit<A>(
|
|
3168
3183
|
toolName: string,
|
|
3169
3184
|
describe: (args: A) => Omit<AuditEntryInput, "actor"> | null,
|
|
3170
|
-
execute: (args: A, context: Tool.Context) => Promise<Tool.Result
|
|
3185
|
+
execute: (args: A, context: Tool.Context) => Promise<Tool.Result>,
|
|
3171
3186
|
): (args: A, context: Tool.Context) => Promise<Tool.Result> {
|
|
3172
3187
|
return async (args: A, context: Tool.Context) => {
|
|
3173
3188
|
const result = await execute(args, context);
|
|
@@ -3271,7 +3286,7 @@ function withRpcAudit<T extends Record<string, (...args: any[]) => any>>(handler
|
|
|
3271
3286
|
const input = args[0] ?? {};
|
|
3272
3287
|
const result = await handler(...args);
|
|
3273
3288
|
try {
|
|
3274
|
-
if ((result
|
|
3289
|
+
if ((result)?.success !== false) {
|
|
3275
3290
|
recordAudit({
|
|
3276
3291
|
action: rule.action,
|
|
3277
3292
|
targetType: rule.targetType,
|
|
@@ -3313,9 +3328,9 @@ async function refreshTriggers(): Promise<void> {
|
|
|
3313
3328
|
await fileWatcherManager.refresh();
|
|
3314
3329
|
} catch (err: any) {
|
|
3315
3330
|
console.error(
|
|
3316
|
-
`[
|
|
3331
|
+
`[agent-steward] Не удалось обновить файловые триггеры: ${
|
|
3317
3332
|
err instanceof Error ? err.message : String(err)
|
|
3318
|
-
}
|
|
3333
|
+
}`,
|
|
3319
3334
|
);
|
|
3320
3335
|
}
|
|
3321
3336
|
}
|
|
@@ -3324,9 +3339,9 @@ async function refreshTriggers(): Promise<void> {
|
|
|
3324
3339
|
await gitTriggerManager.refresh();
|
|
3325
3340
|
} catch (err: any) {
|
|
3326
3341
|
console.error(
|
|
3327
|
-
`[
|
|
3342
|
+
`[agent-steward] Не удалось обновить git-триггеры: ${
|
|
3328
3343
|
err instanceof Error ? err.message : String(err)
|
|
3329
|
-
}
|
|
3344
|
+
}`,
|
|
3330
3345
|
);
|
|
3331
3346
|
}
|
|
3332
3347
|
}
|
|
@@ -3357,16 +3372,16 @@ async function scheduleEventRun(taskName: string, reason: string): Promise<void>
|
|
|
3357
3372
|
if (state.active || policy === "run") {
|
|
3358
3373
|
await runTaskEntry(taskName);
|
|
3359
3374
|
console.log(
|
|
3360
|
-
`[
|
|
3375
|
+
`[agent-steward] Запуск задачи "${taskName}" (${reason}).`,
|
|
3361
3376
|
);
|
|
3362
3377
|
return;
|
|
3363
3378
|
}
|
|
3364
3379
|
|
|
3365
3380
|
if (policy === "skip") {
|
|
3366
3381
|
console.log(
|
|
3367
|
-
`[
|
|
3382
|
+
`[agent-steward] Задача "${taskName}" не запущена (${reason}): ${
|
|
3368
3383
|
state.reason ?? "вне окна"
|
|
3369
|
-
} — политика skip
|
|
3384
|
+
} — политика skip.`,
|
|
3370
3385
|
);
|
|
3371
3386
|
return;
|
|
3372
3387
|
}
|
|
@@ -3374,24 +3389,24 @@ async function scheduleEventRun(taskName: string, reason: string): Promise<void>
|
|
|
3374
3389
|
const delay = nextWindowOpenDelayMs(now, options);
|
|
3375
3390
|
if (delay <= 0 || delay > EVENT_POSTPONE_MAX_MS) {
|
|
3376
3391
|
console.log(
|
|
3377
|
-
`[
|
|
3392
|
+
`[agent-steward] Задача "${taskName}" не запущена (${reason}): ${
|
|
3378
3393
|
state.reason ?? "вне окна"
|
|
3379
|
-
} — до открытия окна больше 12
|
|
3394
|
+
} — до открытия окна больше 12 ч.`,
|
|
3380
3395
|
);
|
|
3381
3396
|
return;
|
|
3382
3397
|
}
|
|
3383
3398
|
|
|
3384
3399
|
console.log(
|
|
3385
|
-
`[
|
|
3386
|
-
delay / 60000
|
|
3387
|
-
)} мин: ${state.reason ?? "вне окна"}
|
|
3400
|
+
`[agent-steward] Задача "${taskName}" (${reason}) отложена на ~${Math.round(
|
|
3401
|
+
delay / 60000,
|
|
3402
|
+
)} мин: ${state.reason ?? "вне окна"}.`,
|
|
3388
3403
|
);
|
|
3389
3404
|
const timer = setTimeout(() => {
|
|
3390
3405
|
void scheduleEventRun(taskName, reason).catch((err: any) => {
|
|
3391
3406
|
console.error(
|
|
3392
|
-
`[
|
|
3407
|
+
`[agent-steward] Не удалось запустить отложенную задачу "${taskName}": ${
|
|
3393
3408
|
err instanceof Error ? err.message : String(err)
|
|
3394
|
-
}
|
|
3409
|
+
}`,
|
|
3395
3410
|
);
|
|
3396
3411
|
});
|
|
3397
3412
|
}, delay);
|
|
@@ -3443,7 +3458,7 @@ export async function createRuntime(ctxLike: RuntimeContextLike): Promise<Schedu
|
|
|
3443
3458
|
console.error(
|
|
3444
3459
|
`[migrate] Не удалось мигрировать JSON → SQLite: ${
|
|
3445
3460
|
err instanceof Error ? err.message : String(err)
|
|
3446
|
-
}
|
|
3461
|
+
}`,
|
|
3447
3462
|
);
|
|
3448
3463
|
}
|
|
3449
3464
|
try {
|
|
@@ -3452,7 +3467,7 @@ export async function createRuntime(ctxLike: RuntimeContextLike): Promise<Schedu
|
|
|
3452
3467
|
console.error(
|
|
3453
3468
|
`[recovery] Не удалось восстановить незавершённые запуски: ${
|
|
3454
3469
|
err instanceof Error ? err.message : String(err)
|
|
3455
|
-
}
|
|
3470
|
+
}`,
|
|
3456
3471
|
);
|
|
3457
3472
|
}
|
|
3458
3473
|
checkJsonBackups();
|
|
@@ -3468,7 +3483,7 @@ export async function createRuntime(ctxLike: RuntimeContextLike): Promise<Schedu
|
|
|
3468
3483
|
console.log(
|
|
3469
3484
|
`[retention] Удалено ${report.deleted} записей истории ` +
|
|
3470
3485
|
`(по возрасту: ${report.deletedByAge}, по лимиту: ${report.deletedByCount}); ` +
|
|
3471
|
-
`осталось ${report.kept}
|
|
3486
|
+
`осталось ${report.kept}.`,
|
|
3472
3487
|
);
|
|
3473
3488
|
}
|
|
3474
3489
|
})
|
|
@@ -3476,7 +3491,7 @@ export async function createRuntime(ctxLike: RuntimeContextLike): Promise<Schedu
|
|
|
3476
3491
|
console.error(
|
|
3477
3492
|
`[retention] Не удалось очистить историю: ${
|
|
3478
3493
|
err instanceof Error ? err.message : String(err)
|
|
3479
|
-
}
|
|
3494
|
+
}`,
|
|
3480
3495
|
);
|
|
3481
3496
|
});
|
|
3482
3497
|
|
|
@@ -3484,17 +3499,17 @@ export async function createRuntime(ctxLike: RuntimeContextLike): Promise<Schedu
|
|
|
3484
3499
|
// Проверяем сразу при старте и далее раз в 5 минут, пока плагин жив.
|
|
3485
3500
|
void resumeExpiredPauses().catch((err: any) => {
|
|
3486
3501
|
console.error(
|
|
3487
|
-
`[
|
|
3502
|
+
`[agent-steward] Не удалось проверить автопродолжение: ${
|
|
3488
3503
|
err instanceof Error ? err.message : String(err)
|
|
3489
|
-
}
|
|
3504
|
+
}`,
|
|
3490
3505
|
);
|
|
3491
3506
|
});
|
|
3492
3507
|
const pausedUntilTimer = setInterval(() => {
|
|
3493
3508
|
void resumeExpiredPauses().catch((err: any) => {
|
|
3494
3509
|
console.error(
|
|
3495
|
-
`[
|
|
3510
|
+
`[agent-steward] Не удалось проверить автопродолжение: ${
|
|
3496
3511
|
err instanceof Error ? err.message : String(err)
|
|
3497
|
-
}
|
|
3512
|
+
}`,
|
|
3498
3513
|
);
|
|
3499
3514
|
});
|
|
3500
3515
|
}, PAUSED_UNTIL_CHECK_MS);
|
|
@@ -3506,9 +3521,9 @@ export async function createRuntime(ctxLike: RuntimeContextLike): Promise<Schedu
|
|
|
3506
3521
|
void maybeSendDigest().catch(() => undefined);
|
|
3507
3522
|
void checkStuckMatrices().catch((err: any) => {
|
|
3508
3523
|
console.error(
|
|
3509
|
-
`[
|
|
3524
|
+
`[agent-steward] Детектор зависших матриц: ${
|
|
3510
3525
|
err instanceof Error ? err.message : String(err)
|
|
3511
|
-
}
|
|
3526
|
+
}`,
|
|
3512
3527
|
);
|
|
3513
3528
|
});
|
|
3514
3529
|
}, NOTIFICATION_CHECK_MS);
|
|
@@ -3532,7 +3547,7 @@ export async function createRuntime(ctxLike: RuntimeContextLike): Promise<Schedu
|
|
|
3532
3547
|
|
|
3533
3548
|
// Сначала запускаем задачи с более высоким приоритетом (10 — максимум).
|
|
3534
3549
|
const prioritized = [...definitions].sort(
|
|
3535
|
-
(a, b) => (normalizePriority(b.priority) ?? 5) - (normalizePriority(a.priority) ?? 5)
|
|
3550
|
+
(a, b) => (normalizePriority(b.priority) ?? 5) - (normalizePriority(a.priority) ?? 5),
|
|
3536
3551
|
);
|
|
3537
3552
|
|
|
3538
3553
|
for (const def of prioritized) {
|
|
@@ -3550,7 +3565,7 @@ export async function createRuntime(ctxLike: RuntimeContextLike): Promise<Schedu
|
|
|
3550
3565
|
const ranAfter = history.some(
|
|
3551
3566
|
(r) =>
|
|
3552
3567
|
r.taskName.toLowerCase() === def.name.toLowerCase() &&
|
|
3553
|
-
new Date(r.startedAt).getTime() >= prev.getTime()
|
|
3568
|
+
new Date(r.startedAt).getTime() >= prev.getTime(),
|
|
3554
3569
|
);
|
|
3555
3570
|
if (ranAfter) continue;
|
|
3556
3571
|
|
|
@@ -3558,19 +3573,19 @@ export async function createRuntime(ctxLike: RuntimeContextLike): Promise<Schedu
|
|
|
3558
3573
|
try {
|
|
3559
3574
|
await runTaskEntry(def.name);
|
|
3560
3575
|
console.log(
|
|
3561
|
-
`[
|
|
3576
|
+
`[agent-steward] Запущено восстановление пропущенной задачи "${def.name}" (последний срабатывал ~${Math.round(ageMs / 1000)} с назад).`,
|
|
3562
3577
|
);
|
|
3563
3578
|
} catch (err: any) {
|
|
3564
3579
|
console.error(
|
|
3565
|
-
`[
|
|
3580
|
+
`[agent-steward] Не удалось восстановить задачу "${def.name}": ${
|
|
3566
3581
|
err instanceof Error ? err.message : String(err)
|
|
3567
|
-
}
|
|
3582
|
+
}`,
|
|
3568
3583
|
);
|
|
3569
3584
|
}
|
|
3570
3585
|
}
|
|
3571
3586
|
} catch (err: any) {
|
|
3572
3587
|
console.error(
|
|
3573
|
-
`[
|
|
3588
|
+
`[agent-steward] Catch-up ошибка: ${err instanceof Error ? err.message : String(err)}`,
|
|
3574
3589
|
);
|
|
3575
3590
|
}
|
|
3576
3591
|
})();
|
|
@@ -3582,9 +3597,9 @@ export async function createRuntime(ctxLike: RuntimeContextLike): Promise<Schedu
|
|
|
3582
3597
|
await scheduleEventRun(taskName, "изменение отслеживаемого файла");
|
|
3583
3598
|
} catch (err: any) {
|
|
3584
3599
|
console.error(
|
|
3585
|
-
`[
|
|
3600
|
+
`[agent-steward] Не удалось запустить задачу "${taskName}" по файловому триггеру: ${
|
|
3586
3601
|
err instanceof Error ? err.message : String(err)
|
|
3587
|
-
}
|
|
3602
|
+
}`,
|
|
3588
3603
|
);
|
|
3589
3604
|
}
|
|
3590
3605
|
});
|
|
@@ -3596,9 +3611,9 @@ export async function createRuntime(ctxLike: RuntimeContextLike): Promise<Schedu
|
|
|
3596
3611
|
await scheduleEventRun(taskName, `новый коммит ${info.head?.slice(0, 7) ?? ""}`);
|
|
3597
3612
|
} catch (err: any) {
|
|
3598
3613
|
console.error(
|
|
3599
|
-
`[
|
|
3614
|
+
`[agent-steward] Не удалось запустить задачу "${taskName}" по git-триггеру: ${
|
|
3600
3615
|
err instanceof Error ? err.message : String(err)
|
|
3601
|
-
}
|
|
3616
|
+
}`,
|
|
3602
3617
|
);
|
|
3603
3618
|
}
|
|
3604
3619
|
});
|
|
@@ -3710,7 +3725,7 @@ export interface ShutdownResource {
|
|
|
3710
3725
|
export function createShutdownHandler(
|
|
3711
3726
|
runtime: SchedulerRuntime,
|
|
3712
3727
|
registrations: ShutdownResource[] = [],
|
|
3713
|
-
options: { waitMs?: number } = {}
|
|
3728
|
+
options: { waitMs?: number } = {},
|
|
3714
3729
|
): () => Promise<void> {
|
|
3715
3730
|
const waitMs = options.waitMs ?? SHUTDOWN_WAIT_MS;
|
|
3716
3731
|
|
|
@@ -3722,9 +3737,9 @@ export function createShutdownHandler(
|
|
|
3722
3737
|
await registration.dispose();
|
|
3723
3738
|
} catch (err) {
|
|
3724
3739
|
console.warn(
|
|
3725
|
-
`[
|
|
3740
|
+
`[agent-steward] Выгрузка: ошибка освобождения регистрации — ${
|
|
3726
3741
|
err instanceof Error ? err.message : String(err)
|
|
3727
|
-
}
|
|
3742
|
+
}`,
|
|
3728
3743
|
);
|
|
3729
3744
|
}
|
|
3730
3745
|
}
|
|
@@ -3737,7 +3752,7 @@ export function createShutdownHandler(
|
|
|
3737
3752
|
const wait = await shutdownGate.waitForIdle(waitMs);
|
|
3738
3753
|
if (wait.timedOut) {
|
|
3739
3754
|
console.warn(
|
|
3740
|
-
`[
|
|
3755
|
+
`[agent-steward] Выгрузка: ${wait.remaining} запуск(ов) не завершились за ${waitMs} мс — закрываем БД.`,
|
|
3741
3756
|
);
|
|
3742
3757
|
}
|
|
3743
3758
|
// Чекпойнт WAL выполняется в closeDb.
|
|
@@ -3860,10 +3875,10 @@ export function createToolSpecs(runtime: SchedulerRuntime): ToolSpec[] {
|
|
|
3860
3875
|
args.action === "list"
|
|
3861
3876
|
? null
|
|
3862
3877
|
: {
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3878
|
+
action: `workspace.${args.action}`,
|
|
3879
|
+
targetType: "workspace",
|
|
3880
|
+
target: args.id || args.name || "",
|
|
3881
|
+
},
|
|
3867
3882
|
execute: handlers.manage_workspaces as any,
|
|
3868
3883
|
},
|
|
3869
3884
|
{
|
|
@@ -3874,10 +3889,10 @@ export function createToolSpecs(runtime: SchedulerRuntime): ToolSpec[] {
|
|
|
3874
3889
|
audit: (args: MatrixControlArgs) =>
|
|
3875
3890
|
args.action === "cancel" || args.action === "cleanup"
|
|
3876
3891
|
? {
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3892
|
+
action: `matrix.${args.action}`,
|
|
3893
|
+
targetType: "matrix",
|
|
3894
|
+
target: args.name || "",
|
|
3895
|
+
}
|
|
3881
3896
|
: null,
|
|
3882
3897
|
execute: handlers.matrix_control as any,
|
|
3883
3898
|
},
|
|
@@ -3936,10 +3951,10 @@ export function createToolSpecs(runtime: SchedulerRuntime): ToolSpec[] {
|
|
|
3936
3951
|
args.action === "list"
|
|
3937
3952
|
? null
|
|
3938
3953
|
: {
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3954
|
+
action: `template.${args.action}`,
|
|
3955
|
+
targetType: "template",
|
|
3956
|
+
target: args.id || args.name || "",
|
|
3957
|
+
},
|
|
3943
3958
|
execute: handlers.manage_templates as any,
|
|
3944
3959
|
},
|
|
3945
3960
|
{
|
|
@@ -3951,10 +3966,10 @@ export function createToolSpecs(runtime: SchedulerRuntime): ToolSpec[] {
|
|
|
3951
3966
|
args.action === "list"
|
|
3952
3967
|
? null
|
|
3953
3968
|
: {
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3969
|
+
action: `profile.${args.action}`,
|
|
3970
|
+
targetType: "profile",
|
|
3971
|
+
target: args.name || "",
|
|
3972
|
+
},
|
|
3958
3973
|
execute: handlers.manage_profiles as any,
|
|
3959
3974
|
},
|
|
3960
3975
|
{
|
|
@@ -4001,10 +4016,10 @@ export function createToolSpecs(runtime: SchedulerRuntime): ToolSpec[] {
|
|
|
4001
4016
|
args.action === "list"
|
|
4002
4017
|
? null
|
|
4003
4018
|
: {
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4019
|
+
action: `secret.${args.action}`,
|
|
4020
|
+
targetType: "secret",
|
|
4021
|
+
target: (args.name ?? "").trim(),
|
|
4022
|
+
},
|
|
4008
4023
|
execute: handlers.manage_secrets as any,
|
|
4009
4024
|
},
|
|
4010
4025
|
{
|
|
@@ -4041,7 +4056,7 @@ async function startSchedulerDashboard(): Promise<void> {
|
|
|
4041
4056
|
});
|
|
4042
4057
|
if (dashboard) {
|
|
4043
4058
|
console.log(
|
|
4044
|
-
`[
|
|
4059
|
+
`[agent-steward] Открыть дашборд в браузере: http://localhost:${dashboard.port}`,
|
|
4045
4060
|
);
|
|
4046
4061
|
}
|
|
4047
4062
|
}
|
|
@@ -4089,9 +4104,9 @@ const v2Plugin = Plugin.define({
|
|
|
4089
4104
|
}
|
|
4090
4105
|
} catch (err: any) {
|
|
4091
4106
|
console.error(
|
|
4092
|
-
`[
|
|
4107
|
+
`[agent-steward] Не удалось зарегистрировать скилл "${SCHEDULER_SKILL_ID}": ${
|
|
4093
4108
|
err instanceof Error ? err.message : String(err)
|
|
4094
|
-
}
|
|
4109
|
+
}`,
|
|
4095
4110
|
);
|
|
4096
4111
|
}
|
|
4097
4112
|
|
|
@@ -4108,7 +4123,7 @@ const v2Plugin = Plugin.define({
|
|
|
4108
4123
|
};
|
|
4109
4124
|
},
|
|
4110
4125
|
create_task: async (input: unknown) => {
|
|
4111
|
-
console.log("[
|
|
4126
|
+
console.log("[agent-steward] create_task input:", input);
|
|
4112
4127
|
const {
|
|
4113
4128
|
name,
|
|
4114
4129
|
schedule,
|
|
@@ -4233,7 +4248,7 @@ const v2Plugin = Plugin.define({
|
|
|
4233
4248
|
undefined,
|
|
4234
4249
|
runWhenLoggedOff === true,
|
|
4235
4250
|
undefined,
|
|
4236
|
-
legacyShell === true
|
|
4251
|
+
legacyShell === true,
|
|
4237
4252
|
);
|
|
4238
4253
|
const nextRun = computeTaskNextRun({
|
|
4239
4254
|
schedule: schedule ?? "",
|
|
@@ -4263,9 +4278,9 @@ const v2Plugin = Plugin.define({
|
|
|
4263
4278
|
message:
|
|
4264
4279
|
removed.length > 0
|
|
4265
4280
|
? t("tool.task.matrixDeletedCount", {
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4281
|
+
name,
|
|
4282
|
+
count: removed.length,
|
|
4283
|
+
})
|
|
4269
4284
|
: t("tool.task.deleted", { name }),
|
|
4270
4285
|
};
|
|
4271
4286
|
} catch (err: any) {
|
|
@@ -4313,7 +4328,7 @@ const v2Plugin = Plugin.define({
|
|
|
4313
4328
|
try {
|
|
4314
4329
|
// Matrix-родитель не выполняется сам: запускаем его клоны (fan-out).
|
|
4315
4330
|
const definition = (await loadTaskDefinitions()).find(
|
|
4316
|
-
(def) => def.name.toLowerCase() === name.trim().toLowerCase()
|
|
4331
|
+
(def) => def.name.toLowerCase() === name.trim().toLowerCase(),
|
|
4317
4332
|
);
|
|
4318
4333
|
if (definition?.matrix) {
|
|
4319
4334
|
const matrixResult = await runMatrix(definition);
|
|
@@ -4326,13 +4341,13 @@ const v2Plugin = Plugin.define({
|
|
|
4326
4341
|
}) +
|
|
4327
4342
|
(matrixResult.skipped.length
|
|
4328
4343
|
? t("tool.matrix.startedSkipped", {
|
|
4329
|
-
|
|
4330
|
-
|
|
4344
|
+
count: matrixResult.skipped.length,
|
|
4345
|
+
})
|
|
4331
4346
|
: "") +
|
|
4332
4347
|
(matrixResult.errors.length
|
|
4333
4348
|
? t("tool.matrix.startedErrors", {
|
|
4334
|
-
|
|
4335
|
-
|
|
4349
|
+
errors: matrixResult.errors.join("; "),
|
|
4350
|
+
})
|
|
4336
4351
|
: ".");
|
|
4337
4352
|
return { success: matrixResult.success, message };
|
|
4338
4353
|
}
|
|
@@ -4342,7 +4357,7 @@ const v2Plugin = Plugin.define({
|
|
|
4342
4357
|
if (settings.maxConcurrent > 0) {
|
|
4343
4358
|
const allTasks = await scheduler.listTasks();
|
|
4344
4359
|
const runningCount = allTasks.filter((t) =>
|
|
4345
|
-
/running|выполняется/i.test(t.status ?? "")
|
|
4360
|
+
/running|выполняется/i.test(t.status ?? ""),
|
|
4346
4361
|
).length;
|
|
4347
4362
|
if (runningCount >= settings.maxConcurrent) {
|
|
4348
4363
|
return {
|
|
@@ -4381,12 +4396,12 @@ const v2Plugin = Plugin.define({
|
|
|
4381
4396
|
.filter((def) => (def.triggerType ?? "cron") === "mcp-event")
|
|
4382
4397
|
.filter(
|
|
4383
4398
|
(def) =>
|
|
4384
|
-
def.mcpEvent?.event?.trim().toLowerCase() === normalized.toLowerCase()
|
|
4399
|
+
def.mcpEvent?.event?.trim().toLowerCase() === normalized.toLowerCase(),
|
|
4385
4400
|
)
|
|
4386
4401
|
.filter((def) => matchesEventFilter(def.mcpEvent?.filter, payload))
|
|
4387
4402
|
.sort(
|
|
4388
4403
|
(a, b) =>
|
|
4389
|
-
(normalizePriority(b.priority) ?? 5) - (normalizePriority(a.priority) ?? 5)
|
|
4404
|
+
(normalizePriority(b.priority) ?? 5) - (normalizePriority(a.priority) ?? 5),
|
|
4390
4405
|
);
|
|
4391
4406
|
|
|
4392
4407
|
const triggered: string[] = [];
|
|
@@ -4395,13 +4410,13 @@ const v2Plugin = Plugin.define({
|
|
|
4395
4410
|
await runTaskEntry(def.name);
|
|
4396
4411
|
triggered.push(def.name);
|
|
4397
4412
|
console.log(
|
|
4398
|
-
`[
|
|
4413
|
+
`[agent-steward] Запуск задачи "${def.name}" по MCP-событию "${normalized}".`,
|
|
4399
4414
|
);
|
|
4400
4415
|
} catch (err: any) {
|
|
4401
4416
|
console.error(
|
|
4402
|
-
`[
|
|
4417
|
+
`[agent-steward] Не удалось запустить "${def.name}" по событию "${normalized}": ${
|
|
4403
4418
|
err instanceof Error ? err.message : String(err)
|
|
4404
|
-
}
|
|
4419
|
+
}`,
|
|
4405
4420
|
);
|
|
4406
4421
|
}
|
|
4407
4422
|
}
|
|
@@ -4460,11 +4475,11 @@ const v2Plugin = Plugin.define({
|
|
|
4460
4475
|
const message = report.skipped
|
|
4461
4476
|
? report.skipped
|
|
4462
4477
|
: t("tool.history.cleaned", {
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4478
|
+
deleted: report.deleted,
|
|
4479
|
+
byAge: report.deletedByAge,
|
|
4480
|
+
byCount: report.deletedByCount,
|
|
4481
|
+
kept: report.kept,
|
|
4482
|
+
});
|
|
4468
4483
|
return {
|
|
4469
4484
|
success: true,
|
|
4470
4485
|
message,
|
|
@@ -4497,7 +4512,7 @@ const v2Plugin = Plugin.define({
|
|
|
4497
4512
|
try {
|
|
4498
4513
|
const windowDays = Math.min(
|
|
4499
4514
|
365,
|
|
4500
|
-
Math.max(1, Math.floor(Number(days) || 14))
|
|
4515
|
+
Math.max(1, Math.floor(Number(days) || 14)),
|
|
4501
4516
|
);
|
|
4502
4517
|
const records = getHistory(null, 20000);
|
|
4503
4518
|
const definitions = await loadTaskDefinitions();
|
|
@@ -4529,7 +4544,7 @@ const v2Plugin = Plugin.define({
|
|
|
4529
4544
|
try {
|
|
4530
4545
|
const windowDays = Math.min(
|
|
4531
4546
|
365,
|
|
4532
|
-
Math.max(1, Math.floor(Number(days) || 14))
|
|
4547
|
+
Math.max(1, Math.floor(Number(days) || 14)),
|
|
4533
4548
|
);
|
|
4534
4549
|
const records = getHistory(null, 20000);
|
|
4535
4550
|
const definitions = await loadTaskDefinitions();
|
|
@@ -5014,7 +5029,7 @@ const v2Plugin = Plugin.define({
|
|
|
5014
5029
|
try {
|
|
5015
5030
|
return { templates: await loadTemplates() };
|
|
5016
5031
|
} catch (err: any) {
|
|
5017
|
-
console.error("[
|
|
5032
|
+
console.error("[agent-steward] get_templates error:", err);
|
|
5018
5033
|
return { templates: [] };
|
|
5019
5034
|
}
|
|
5020
5035
|
},
|
|
@@ -5038,10 +5053,10 @@ const v2Plugin = Plugin.define({
|
|
|
5038
5053
|
source.triggerType === "file"
|
|
5039
5054
|
? "file"
|
|
5040
5055
|
: source.triggerType === "mcp-event"
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5056
|
+
? "mcp-event"
|
|
5057
|
+
: source.triggerType
|
|
5058
|
+
? "cron"
|
|
5059
|
+
: undefined,
|
|
5045
5060
|
});
|
|
5046
5061
|
return { success: true, template };
|
|
5047
5062
|
} catch (err: any) {
|
|
@@ -5144,7 +5159,7 @@ const v2Plugin = Plugin.define({
|
|
|
5144
5159
|
},
|
|
5145
5160
|
def.runWhenLoggedOff === true,
|
|
5146
5161
|
def.paused === true,
|
|
5147
|
-
def.legacyShell === true
|
|
5162
|
+
def.legacyShell === true,
|
|
5148
5163
|
);
|
|
5149
5164
|
await saveTaskDefinition(def);
|
|
5150
5165
|
imported.push(def.name);
|
|
@@ -5166,7 +5181,7 @@ const v2Plugin = Plugin.define({
|
|
|
5166
5181
|
|
|
5167
5182
|
const rpcRegistration = await ctx.rpc.register(
|
|
5168
5183
|
SchedulerRpc,
|
|
5169
|
-
withRpcAudit(rpcHandlers)
|
|
5184
|
+
withRpcAudit(rpcHandlers),
|
|
5170
5185
|
);
|
|
5171
5186
|
|
|
5172
5187
|
// Lifecycle матриц (Спринт 16): при старте вычищаем клоны/агрегаторы,
|
|
@@ -5175,7 +5190,7 @@ const v2Plugin = Plugin.define({
|
|
|
5175
5190
|
console.log(
|
|
5176
5191
|
`[matrix] Не удалось очистить осиротевшие задачи: ${
|
|
5177
5192
|
err instanceof Error ? err.message : String(err)
|
|
5178
|
-
}
|
|
5193
|
+
}`,
|
|
5179
5194
|
);
|
|
5180
5195
|
});
|
|
5181
5196
|
|
|
@@ -5219,7 +5234,7 @@ export function toV1ToolArgs(spec: ToolSpec): Record<string, any> {
|
|
|
5219
5234
|
const shape = (spec.input as { shape?: unknown } | undefined)?.shape;
|
|
5220
5235
|
if (!shape || typeof shape !== "object") {
|
|
5221
5236
|
throw new Error(
|
|
5222
|
-
`V1-адаптер: схема инструмента "${spec.name}" должна быть z.object(...)
|
|
5237
|
+
`V1-адаптер: схема инструмента "${spec.name}" должна быть z.object(...)`,
|
|
5223
5238
|
);
|
|
5224
5239
|
}
|
|
5225
5240
|
return shape as Record<string, any>;
|
|
@@ -5255,7 +5270,7 @@ export function createV1Tools(runtime: SchedulerRuntime): Record<string, any> {
|
|
|
5255
5270
|
*/
|
|
5256
5271
|
export async function createV1Hooks(
|
|
5257
5272
|
input: Pick<V1PluginInput, "directory"> = { directory: process.cwd() },
|
|
5258
|
-
options: { startDashboard?: boolean } = {}
|
|
5273
|
+
options: { startDashboard?: boolean } = {},
|
|
5259
5274
|
): Promise<V1Hooks> {
|
|
5260
5275
|
const runtime = await createRuntime({ location: { directory: input.directory } });
|
|
5261
5276
|
const tools = createV1Tools(runtime);
|
|
@@ -5286,7 +5301,7 @@ export default { ...v2Plugin, ...v1Plugin };
|
|
|
5286
5301
|
function resolveMatrixExtraConfig(
|
|
5287
5302
|
name: string,
|
|
5288
5303
|
matrix: MatrixConfig,
|
|
5289
|
-
ids: string[]
|
|
5304
|
+
ids: string[],
|
|
5290
5305
|
): { concurrency?: number; overrides?: Record<string, MatrixWorkspaceOverride> } {
|
|
5291
5306
|
const extra: {
|
|
5292
5307
|
concurrency?: number;
|
|
@@ -5300,7 +5315,7 @@ function resolveMatrixExtraConfig(
|
|
|
5300
5315
|
matrix.concurrency < 1
|
|
5301
5316
|
) {
|
|
5302
5317
|
throw new Error(
|
|
5303
|
-
t("tool.error.matrixConcurrency", { task: name })
|
|
5318
|
+
t("tool.error.matrixConcurrency", { task: name }),
|
|
5304
5319
|
);
|
|
5305
5320
|
}
|
|
5306
5321
|
extra.concurrency = Math.floor(matrix.concurrency);
|
|
@@ -5316,7 +5331,7 @@ function resolveMatrixExtraConfig(
|
|
|
5316
5331
|
t("tool.error.matrixOverride", {
|
|
5317
5332
|
task: name,
|
|
5318
5333
|
workspace: workspaceKey,
|
|
5319
|
-
})
|
|
5334
|
+
}),
|
|
5320
5335
|
);
|
|
5321
5336
|
}
|
|
5322
5337
|
if (!value || typeof value !== "object") continue;
|
|
@@ -5329,7 +5344,21 @@ function resolveMatrixExtraConfig(
|
|
|
5329
5344
|
"afterScript",
|
|
5330
5345
|
] as const) {
|
|
5331
5346
|
const raw = (value as Record<string, unknown>)[field];
|
|
5332
|
-
if (typeof raw === "string" && raw.trim())
|
|
5347
|
+
if (typeof raw === "string" && raw.trim()) {
|
|
5348
|
+
const trimmed = raw.trim();
|
|
5349
|
+
if (field === "model") {
|
|
5350
|
+
const modelError = validateModelId(trimmed);
|
|
5351
|
+
if (modelError) {
|
|
5352
|
+
throw new Error(
|
|
5353
|
+
t("tool.error.modelInvalid", {
|
|
5354
|
+
model: trimmed,
|
|
5355
|
+
error: modelError,
|
|
5356
|
+
}),
|
|
5357
|
+
);
|
|
5358
|
+
}
|
|
5359
|
+
}
|
|
5360
|
+
override[field] = trimmed;
|
|
5361
|
+
}
|
|
5333
5362
|
}
|
|
5334
5363
|
if (Object.keys(override).length > 0) overrides[workspaceKey] = override;
|
|
5335
5364
|
}
|
|
@@ -5413,7 +5442,7 @@ async function schedulerCreateTask(
|
|
|
5413
5442
|
* Спринт 32 / релиз 1.6: переходный флаг для гибридной политики.
|
|
5414
5443
|
* true возвращает shell задаче, созданной до обновления поведения.
|
|
5415
5444
|
*/
|
|
5416
|
-
legacyShell?: boolean
|
|
5445
|
+
legacyShell?: boolean,
|
|
5417
5446
|
): Promise<void> {
|
|
5418
5447
|
// Спринт 27.5 (hotfix 1.5.1): проверяем имя до создания wrapper/prompt и записи
|
|
5419
5448
|
// в БД. Недопустимые символы отклоняются с понятным сообщением, а не ошибкой
|
|
@@ -5432,14 +5461,14 @@ async function schedulerCreateTask(
|
|
|
5432
5461
|
if (process.platform === "win32") {
|
|
5433
5462
|
if (prompt.length > 30000) {
|
|
5434
5463
|
throw new Error(
|
|
5435
|
-
`Промпт задачи "${normalizedName}" слишком длинный для командной строки Windows: ${prompt.length} символов (максимум 30000). Сократите промпт или вынесите инструкции в
|
|
5464
|
+
`Промпт задачи "${normalizedName}" слишком длинный для командной строки Windows: ${prompt.length} символов (максимум 30000). Сократите промпт или вынесите инструкции в файл.`,
|
|
5436
5465
|
);
|
|
5437
5466
|
}
|
|
5438
5467
|
} else {
|
|
5439
5468
|
const promptBytes = Buffer.byteLength(prompt, "utf8");
|
|
5440
5469
|
if (promptBytes > POSIX_MAX_PROMPT_BYTES) {
|
|
5441
5470
|
throw new Error(
|
|
5442
|
-
`Промпт задачи "${normalizedName}" слишком длинный для командной строки POSIX: ${promptBytes} байт (максимум ${POSIX_MAX_PROMPT_BYTES}). Сократите промпт или вынесите инструкции в
|
|
5471
|
+
`Промпт задачи "${normalizedName}" слишком длинный для командной строки POSIX: ${promptBytes} байт (максимум ${POSIX_MAX_PROMPT_BYTES}). Сократите промпт или вынесите инструкции в файл.`,
|
|
5443
5472
|
);
|
|
5444
5473
|
}
|
|
5445
5474
|
}
|
|
@@ -5448,6 +5477,14 @@ async function schedulerCreateTask(
|
|
|
5448
5477
|
const definitionExisted = Boolean(getTask(normalizedName));
|
|
5449
5478
|
|
|
5450
5479
|
const normalizedModel = model?.trim() || undefined;
|
|
5480
|
+
if (normalizedModel) {
|
|
5481
|
+
const modelError = validateModelId(normalizedModel);
|
|
5482
|
+
if (modelError) {
|
|
5483
|
+
throw new Error(
|
|
5484
|
+
t("tool.error.modelInvalid", { model: normalizedModel, error: modelError }),
|
|
5485
|
+
);
|
|
5486
|
+
}
|
|
5487
|
+
}
|
|
5451
5488
|
const normalizedPriority = normalizePriority(priority);
|
|
5452
5489
|
const normalizedBefore = beforeScript?.trim() || undefined;
|
|
5453
5490
|
const normalizedAfter = afterScript?.trim() || undefined;
|
|
@@ -5467,8 +5504,8 @@ async function schedulerCreateTask(
|
|
|
5467
5504
|
raw
|
|
5468
5505
|
.filter((item): item is string => typeof item === "string")
|
|
5469
5506
|
.map((item) => item.trim())
|
|
5470
|
-
.filter(Boolean)
|
|
5471
|
-
)
|
|
5507
|
+
.filter(Boolean),
|
|
5508
|
+
),
|
|
5472
5509
|
);
|
|
5473
5510
|
return cleaned.length > 0 ? cleaned : undefined;
|
|
5474
5511
|
};
|
|
@@ -5489,12 +5526,12 @@ async function schedulerCreateTask(
|
|
|
5489
5526
|
? Math.floor(triggerExtras.gitPollSeconds)
|
|
5490
5527
|
: undefined;
|
|
5491
5528
|
const normalizedMcpEvent =
|
|
5492
|
-
mcpEvent
|
|
5529
|
+
mcpEvent?.event?.trim()
|
|
5493
5530
|
? {
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5531
|
+
server: mcpEvent.server?.trim() || "",
|
|
5532
|
+
event: mcpEvent.event.trim(),
|
|
5533
|
+
...(mcpEvent.filter?.trim() ? { filter: mcpEvent.filter.trim() } : {}),
|
|
5534
|
+
}
|
|
5498
5535
|
: undefined;
|
|
5499
5536
|
let effectiveTriggerType = triggerType ?? "cron";
|
|
5500
5537
|
// One-shot: нормализуем время до создания файлов и задачи в ОС.
|
|
@@ -5515,11 +5552,11 @@ async function schedulerCreateTask(
|
|
|
5515
5552
|
const normalizedSession = normalizeSessionMode(session);
|
|
5516
5553
|
if (!normalizedSession) {
|
|
5517
5554
|
throw new Error(
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5555
|
+
t("tool.error.sessionUnknown", {
|
|
5556
|
+
name,
|
|
5557
|
+
session: String(session),
|
|
5558
|
+
}),
|
|
5559
|
+
);
|
|
5523
5560
|
}
|
|
5524
5561
|
effectiveSession = normalizedSession;
|
|
5525
5562
|
}
|
|
@@ -5537,14 +5574,14 @@ async function schedulerCreateTask(
|
|
|
5537
5574
|
.filter((t): t is string => typeof t === "string")
|
|
5538
5575
|
.map((t) => t.trim())
|
|
5539
5576
|
.filter(Boolean)
|
|
5540
|
-
.map((t) => [t.toLowerCase(), t] as const)
|
|
5541
|
-
).values()
|
|
5577
|
+
.map((t) => [t.toLowerCase(), t] as const),
|
|
5578
|
+
).values(),
|
|
5542
5579
|
);
|
|
5543
5580
|
return cleaned.length > 0 ? cleaned : undefined;
|
|
5544
5581
|
};
|
|
5545
5582
|
if (Array.isArray(allowedTools) && allowedTools.filter((t) => typeof t === "string" && t.trim()).length === 0) {
|
|
5546
5583
|
throw new Error(
|
|
5547
|
-
t("tool.error.allowedToolsEmpty", { task: name })
|
|
5584
|
+
t("tool.error.allowedToolsEmpty", { task: name }),
|
|
5548
5585
|
);
|
|
5549
5586
|
}
|
|
5550
5587
|
const normalizedAllowedTools = normalizeToolList(allowedTools);
|
|
@@ -5577,7 +5614,7 @@ async function schedulerCreateTask(
|
|
|
5577
5614
|
if (matrix) {
|
|
5578
5615
|
if (workspaceId?.trim()) {
|
|
5579
5616
|
throw new Error(
|
|
5580
|
-
t("tool.error.workspaceIdConflict", { task: name })
|
|
5617
|
+
t("tool.error.workspaceIdConflict", { task: name }),
|
|
5581
5618
|
);
|
|
5582
5619
|
}
|
|
5583
5620
|
const ids = Array.from(
|
|
@@ -5585,19 +5622,19 @@ async function schedulerCreateTask(
|
|
|
5585
5622
|
(Array.isArray(matrix.workspaceIds) ? matrix.workspaceIds : [])
|
|
5586
5623
|
.filter((id): id is string => typeof id === "string")
|
|
5587
5624
|
.map((id) => id.trim())
|
|
5588
|
-
.filter(Boolean)
|
|
5589
|
-
)
|
|
5625
|
+
.filter(Boolean),
|
|
5626
|
+
),
|
|
5590
5627
|
);
|
|
5591
5628
|
if (ids.length === 0) {
|
|
5592
5629
|
throw new Error(
|
|
5593
|
-
t("tool.error.workspaceIdsEmpty", { task: name })
|
|
5630
|
+
t("tool.error.workspaceIdsEmpty", { task: name }),
|
|
5594
5631
|
);
|
|
5595
5632
|
}
|
|
5596
5633
|
for (const id of ids) {
|
|
5597
5634
|
const ws = getWorkspace(id);
|
|
5598
5635
|
if (!ws) {
|
|
5599
5636
|
throw new Error(
|
|
5600
|
-
t("tool.error.workspaceMissing", { task: name, id })
|
|
5637
|
+
t("tool.error.workspaceMissing", { task: name, id }),
|
|
5601
5638
|
);
|
|
5602
5639
|
}
|
|
5603
5640
|
try {
|
|
@@ -5608,7 +5645,7 @@ async function schedulerCreateTask(
|
|
|
5608
5645
|
task: name,
|
|
5609
5646
|
workspace: ws.name,
|
|
5610
5647
|
path: ws.path,
|
|
5611
|
-
})
|
|
5648
|
+
}),
|
|
5612
5649
|
);
|
|
5613
5650
|
}
|
|
5614
5651
|
}
|
|
@@ -5639,12 +5676,12 @@ async function schedulerCreateTask(
|
|
|
5639
5676
|
: workingDirectory?.trim() || projectDirectory || process.cwd();
|
|
5640
5677
|
if (!gitCwd) {
|
|
5641
5678
|
throw new Error(
|
|
5642
|
-
t("tool.error.gitCwdRequired", { task: name })
|
|
5679
|
+
t("tool.error.gitCwdRequired", { task: name }),
|
|
5643
5680
|
);
|
|
5644
5681
|
}
|
|
5645
5682
|
if (!readGitBranch(gitCwd)) {
|
|
5646
5683
|
throw new Error(
|
|
5647
|
-
t("tool.error.gitNoRepo", { task: name, path: gitCwd })
|
|
5684
|
+
t("tool.error.gitNoRepo", { task: name, path: gitCwd }),
|
|
5648
5685
|
);
|
|
5649
5686
|
}
|
|
5650
5687
|
}
|
|
@@ -5663,12 +5700,12 @@ async function schedulerCreateTask(
|
|
|
5663
5700
|
t("tool.error.timezone", {
|
|
5664
5701
|
task: name,
|
|
5665
5702
|
timezone: normalizedTz,
|
|
5666
|
-
})
|
|
5703
|
+
}),
|
|
5667
5704
|
);
|
|
5668
5705
|
}
|
|
5669
5706
|
const windowError = validateLaunchWindow(
|
|
5670
5707
|
normalizedNotBefore,
|
|
5671
|
-
normalizedNotAfter
|
|
5708
|
+
normalizedNotAfter,
|
|
5672
5709
|
);
|
|
5673
5710
|
if (windowError) {
|
|
5674
5711
|
throw new Error(t("tool.error.window", { task: name, error: windowError }));
|
|
@@ -5691,21 +5728,21 @@ async function schedulerCreateTask(
|
|
|
5691
5728
|
const gate =
|
|
5692
5729
|
effectiveTriggerType === "cron"
|
|
5693
5730
|
? buildScheduleGate(
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
5731
|
+
schedule,
|
|
5732
|
+
normalizedTz,
|
|
5733
|
+
normalizedNotBefore,
|
|
5734
|
+
normalizedNotAfter,
|
|
5735
|
+
normalizedActiveDays,
|
|
5736
|
+
normalizedWindowPolicy,
|
|
5737
|
+
)
|
|
5701
5738
|
: undefined;
|
|
5702
5739
|
const wrapperGate = gate
|
|
5703
5740
|
? {
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5741
|
+
...gate,
|
|
5742
|
+
gateFile: gatePath,
|
|
5743
|
+
deferFile: `${lockFile}.defer`,
|
|
5744
|
+
forceFile: `${lockFile}.force`,
|
|
5745
|
+
}
|
|
5709
5746
|
: undefined;
|
|
5710
5747
|
// Workspace имеет приоритет над workingDirectory: одна задача = один repo
|
|
5711
5748
|
// = один cwd. Мы не угадываем, куда мержить, и не смешиваем контексты.
|
|
@@ -5715,7 +5752,7 @@ async function schedulerCreateTask(
|
|
|
5715
5752
|
throw new Error(
|
|
5716
5753
|
t("tool.error.workspaceIdMissing", {
|
|
5717
5754
|
id: normalizedWorkspaceId,
|
|
5718
|
-
})
|
|
5755
|
+
}),
|
|
5719
5756
|
);
|
|
5720
5757
|
}
|
|
5721
5758
|
if (workspace) {
|
|
@@ -5726,13 +5763,13 @@ async function schedulerCreateTask(
|
|
|
5726
5763
|
t("tool.error.workspacePathMissing", {
|
|
5727
5764
|
name: workspace.name,
|
|
5728
5765
|
path: workspace.path,
|
|
5729
|
-
})
|
|
5766
|
+
}),
|
|
5730
5767
|
);
|
|
5731
5768
|
}
|
|
5732
5769
|
if (workingDirectory?.trim() && workingDirectory.trim() !== workspace.path) {
|
|
5733
5770
|
console.warn(
|
|
5734
5771
|
`[workspace] Задача "${name}": workingDirectory "${workingDirectory.trim()}" ` +
|
|
5735
|
-
`игнорируется, cwd = workspace "${workspace.name}" (${workspace.path})
|
|
5772
|
+
`игнорируется, cwd = workspace "${workspace.name}" (${workspace.path}).`,
|
|
5736
5773
|
);
|
|
5737
5774
|
}
|
|
5738
5775
|
}
|
|
@@ -5747,7 +5784,7 @@ async function schedulerCreateTask(
|
|
|
5747
5784
|
effectiveWatchPath = normalizeWatchPath(effectiveWatchPath, effectiveWorkingDirectory);
|
|
5748
5785
|
} catch (err: any) {
|
|
5749
5786
|
throw new Error(
|
|
5750
|
-
t("tool.error.taskReason", { name, error: err.message || String(err) })
|
|
5787
|
+
t("tool.error.taskReason", { name, error: err.message || String(err) }),
|
|
5751
5788
|
);
|
|
5752
5789
|
}
|
|
5753
5790
|
}
|
|
@@ -5756,7 +5793,7 @@ async function schedulerCreateTask(
|
|
|
5756
5793
|
validateWatchGlobs(normalizedWatchIgnore);
|
|
5757
5794
|
} catch (err: any) {
|
|
5758
5795
|
throw new Error(
|
|
5759
|
-
t("tool.error.taskReason", { name, error: err.message || String(err) })
|
|
5796
|
+
t("tool.error.taskReason", { name, error: err.message || String(err) }),
|
|
5760
5797
|
);
|
|
5761
5798
|
}
|
|
5762
5799
|
|
|
@@ -5766,13 +5803,13 @@ async function schedulerCreateTask(
|
|
|
5766
5803
|
prompt,
|
|
5767
5804
|
beforeScript,
|
|
5768
5805
|
afterScript,
|
|
5769
|
-
qualityGate
|
|
5806
|
+
qualityGate,
|
|
5770
5807
|
);
|
|
5771
5808
|
const taskEnvFile = writeWorkspaceEnvFile(
|
|
5772
5809
|
workspace,
|
|
5773
5810
|
PLUGIN_DIR,
|
|
5774
5811
|
sanitized,
|
|
5775
|
-
usedSecretNames
|
|
5812
|
+
usedSecretNames,
|
|
5776
5813
|
);
|
|
5777
5814
|
if (taskEnvFile) {
|
|
5778
5815
|
console.log(`[workspace] Задача "${name}": env-переменные workspace подключены.`);
|
|
@@ -5787,7 +5824,7 @@ async function schedulerCreateTask(
|
|
|
5787
5824
|
throw new Error(
|
|
5788
5825
|
t("tool.error.prepareFiles", {
|
|
5789
5826
|
error: err.message || String(err),
|
|
5790
|
-
})
|
|
5827
|
+
}),
|
|
5791
5828
|
);
|
|
5792
5829
|
}
|
|
5793
5830
|
|
|
@@ -5827,7 +5864,7 @@ async function schedulerCreateTask(
|
|
|
5827
5864
|
undefined,
|
|
5828
5865
|
permissionsConfig,
|
|
5829
5866
|
policyMeta,
|
|
5830
|
-
sessionFile
|
|
5867
|
+
sessionFile,
|
|
5831
5868
|
);
|
|
5832
5869
|
} else {
|
|
5833
5870
|
wrapperPath = await writeBashWrapper({
|
|
@@ -5862,7 +5899,7 @@ async function schedulerCreateTask(
|
|
|
5862
5899
|
throw new Error(
|
|
5863
5900
|
t("tool.error.wrapper", {
|
|
5864
5901
|
error: err.message || String(err),
|
|
5865
|
-
})
|
|
5902
|
+
}),
|
|
5866
5903
|
);
|
|
5867
5904
|
}
|
|
5868
5905
|
|
|
@@ -5872,8 +5909,8 @@ async function schedulerCreateTask(
|
|
|
5872
5909
|
if (definitionExisted) return;
|
|
5873
5910
|
await Promise.all(
|
|
5874
5911
|
[wrapperPath, promptFile, logFile, taskEnvFile].map((file) =>
|
|
5875
|
-
file ? fs.unlink(file).catch(() => undefined) : Promise.resolve()
|
|
5876
|
-
)
|
|
5912
|
+
file ? fs.unlink(file).catch(() => undefined) : Promise.resolve(),
|
|
5913
|
+
),
|
|
5877
5914
|
);
|
|
5878
5915
|
};
|
|
5879
5916
|
|
|
@@ -5904,7 +5941,7 @@ async function schedulerCreateTask(
|
|
|
5904
5941
|
// 200 мс. Это ловит случай, когда ОС/обёртка вернула код 0, но задачи нет.
|
|
5905
5942
|
const isListed = (tasks: Awaited<ReturnType<typeof scheduler.listTasks>>): boolean =>
|
|
5906
5943
|
tasks.some(
|
|
5907
|
-
(task) => (task.taskName || "").trim().toLowerCase() === name.toLowerCase()
|
|
5944
|
+
(task) => (task.taskName || "").trim().toLowerCase() === name.toLowerCase(),
|
|
5908
5945
|
);
|
|
5909
5946
|
let listedTasks: Awaited<ReturnType<typeof scheduler.listTasks>> | undefined;
|
|
5910
5947
|
let verifyQueryError: unknown;
|
|
@@ -5929,16 +5966,16 @@ async function schedulerCreateTask(
|
|
|
5929
5966
|
" " +
|
|
5930
5967
|
(definitionExisted
|
|
5931
5968
|
? t("tool.error.schedulerKeptFiles")
|
|
5932
|
-
: t("tool.error.schedulerRemovedFiles"))
|
|
5969
|
+
: t("tool.error.schedulerRemovedFiles")),
|
|
5933
5970
|
);
|
|
5934
5971
|
}
|
|
5935
5972
|
if (!listedTasks && verifyQueryError) {
|
|
5936
5973
|
// Список получить не удалось — не удаляем возможно созданную задачу,
|
|
5937
5974
|
// но явно предупреждаем: проверка наличия не выполнена.
|
|
5938
5975
|
console.warn(
|
|
5939
|
-
`[
|
|
5976
|
+
`[agent-steward] Задача "${name}" создана, но проверить её в планировщике не удалось: ${
|
|
5940
5977
|
verifyQueryError instanceof Error ? verifyQueryError.message : String(verifyQueryError)
|
|
5941
|
-
}
|
|
5978
|
+
}`,
|
|
5942
5979
|
);
|
|
5943
5980
|
}
|
|
5944
5981
|
|
|
@@ -5976,7 +6013,7 @@ async function schedulerCreateTask(
|
|
|
5976
6013
|
sessionRunCount: preservedSessionRunCount(
|
|
5977
6014
|
previousDefinition,
|
|
5978
6015
|
effectiveSession,
|
|
5979
|
-
effectiveSessionId
|
|
6016
|
+
effectiveSessionId,
|
|
5980
6017
|
),
|
|
5981
6018
|
watchPath: normalizedMatrix ? undefined : effectiveWatchPath,
|
|
5982
6019
|
timezone: normalizedTz,
|
|
@@ -6009,13 +6046,13 @@ async function schedulerCreateTask(
|
|
|
6009
6046
|
dependsOn:
|
|
6010
6047
|
Array.isArray(dependsOn) && dependsOn.length > 0
|
|
6011
6048
|
? Array.from(
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6049
|
+
new Set(
|
|
6050
|
+
dependsOn
|
|
6051
|
+
.filter((dep): dep is string => typeof dep === "string")
|
|
6052
|
+
.map((dep) => dep.trim())
|
|
6053
|
+
.filter(Boolean),
|
|
6054
|
+
),
|
|
6055
|
+
)
|
|
6019
6056
|
: undefined,
|
|
6020
6057
|
};
|
|
6021
6058
|
try {
|
|
@@ -6028,7 +6065,7 @@ async function schedulerCreateTask(
|
|
|
6028
6065
|
"system",
|
|
6029
6066
|
"policy",
|
|
6030
6067
|
globalPolicy,
|
|
6031
|
-
legacyShell === true
|
|
6068
|
+
legacyShell === true,
|
|
6032
6069
|
);
|
|
6033
6070
|
} catch {
|
|
6034
6071
|
// Не критично — основная задача уже создана.
|
|
@@ -6080,7 +6117,7 @@ async function schedulerCreateTask(
|
|
|
6080
6117
|
undefined,
|
|
6081
6118
|
clone.runWhenLoggedOff,
|
|
6082
6119
|
clone.paused,
|
|
6083
|
-
clone.legacyShell
|
|
6120
|
+
clone.legacyShell,
|
|
6084
6121
|
);
|
|
6085
6122
|
};
|
|
6086
6123
|
|
|
@@ -6126,7 +6163,7 @@ async function schedulerCreateTask(
|
|
|
6126
6163
|
undefined,
|
|
6127
6164
|
cloneNames,
|
|
6128
6165
|
normalizedModel,
|
|
6129
|
-
normalizedPriority
|
|
6166
|
+
normalizedPriority,
|
|
6130
6167
|
);
|
|
6131
6168
|
return aggregatorName;
|
|
6132
6169
|
};
|
|
@@ -6149,7 +6186,7 @@ async function schedulerCreateTask(
|
|
|
6149
6186
|
console.log(
|
|
6150
6187
|
`[matrix] ${name}: синхронизация — создано ${syncResult.created.length}, ` +
|
|
6151
6188
|
`обновлено ${syncResult.updated.length}, удалено ${syncResult.removed.length}, ` +
|
|
6152
|
-
`занято ${syncResult.running.length}
|
|
6189
|
+
`занято ${syncResult.running.length}`,
|
|
6153
6190
|
);
|
|
6154
6191
|
}
|
|
6155
6192
|
} else {
|
|
@@ -6176,7 +6213,7 @@ async function schedulerCreateTask(
|
|
|
6176
6213
|
clone: clone.name,
|
|
6177
6214
|
workspace: workspaceLabel,
|
|
6178
6215
|
error: err instanceof Error ? err.message : String(err),
|
|
6179
|
-
})
|
|
6216
|
+
}),
|
|
6180
6217
|
);
|
|
6181
6218
|
}
|
|
6182
6219
|
}
|
|
@@ -6208,7 +6245,7 @@ async function schedulerCreateTask(
|
|
|
6208
6245
|
t("tool.error.matrixExpandRuntime", {
|
|
6209
6246
|
name,
|
|
6210
6247
|
error: err instanceof Error ? err.message : String(err),
|
|
6211
|
-
})
|
|
6248
|
+
}),
|
|
6212
6249
|
);
|
|
6213
6250
|
}
|
|
6214
6251
|
}
|
|
@@ -6225,9 +6262,9 @@ async function schedulerCreateTask(
|
|
|
6225
6262
|
await scheduler.pauseTask(target);
|
|
6226
6263
|
} catch (err: any) {
|
|
6227
6264
|
console.warn(
|
|
6228
|
-
`[
|
|
6265
|
+
`[agent-steward] Задача "${target}": пауза не восстановлена после пересоздания: ${
|
|
6229
6266
|
err instanceof Error ? err.message : String(err)
|
|
6230
|
-
}
|
|
6267
|
+
}`,
|
|
6231
6268
|
);
|
|
6232
6269
|
}
|
|
6233
6270
|
}
|
|
@@ -6246,7 +6283,7 @@ async function schedulerCreateTask(
|
|
|
6246
6283
|
async function recreateTaskFromDefinition(definition: TaskDefinition): Promise<void> {
|
|
6247
6284
|
const paused = Boolean(
|
|
6248
6285
|
definition.paused === true ||
|
|
6249
|
-
(definition.pausedUntil && Date.parse(definition.pausedUntil) > Date.now())
|
|
6286
|
+
(definition.pausedUntil && Date.parse(definition.pausedUntil) > Date.now()),
|
|
6250
6287
|
);
|
|
6251
6288
|
await schedulerCreateTask(
|
|
6252
6289
|
definition.name,
|
|
@@ -6293,7 +6330,7 @@ async function recreateTaskFromDefinition(definition: TaskDefinition): Promise<v
|
|
|
6293
6330
|
},
|
|
6294
6331
|
definition.runWhenLoggedOff,
|
|
6295
6332
|
paused,
|
|
6296
|
-
definition.legacyShell
|
|
6333
|
+
definition.legacyShell,
|
|
6297
6334
|
);
|
|
6298
6335
|
}
|
|
6299
6336
|
|
|
@@ -6304,13 +6341,13 @@ async function recreateTaskFromDefinition(definition: TaskDefinition): Promise<v
|
|
|
6304
6341
|
async function runTaskEntry(name: string): Promise<{ alreadyRunning: boolean }> {
|
|
6305
6342
|
if (shutdownGate.isShuttingDown()) {
|
|
6306
6343
|
throw new Error(
|
|
6307
|
-
"Плагин выгружается: новые запуски не принимаются. Повторите после перезапуска."
|
|
6344
|
+
"Плагин выгружается: новые запуски не принимаются. Повторите после перезапуска.",
|
|
6308
6345
|
);
|
|
6309
6346
|
}
|
|
6310
6347
|
|
|
6311
6348
|
const run = (async () => {
|
|
6312
6349
|
const definition = (await loadTaskDefinitions()).find(
|
|
6313
|
-
(def) => def.name.toLowerCase() === name.trim().toLowerCase()
|
|
6350
|
+
(def) => def.name.toLowerCase() === name.trim().toLowerCase(),
|
|
6314
6351
|
);
|
|
6315
6352
|
if (definition?.matrix) {
|
|
6316
6353
|
await runMatrix(definition);
|
|
@@ -6347,7 +6384,7 @@ async function runTaskEntry(name: string): Promise<{ alreadyRunning: boolean }>
|
|
|
6347
6384
|
*/
|
|
6348
6385
|
async function readOsTasksWithRetry(
|
|
6349
6386
|
expectNonEmpty: boolean,
|
|
6350
|
-
delayMs = 300
|
|
6387
|
+
delayMs = 300,
|
|
6351
6388
|
): Promise<{
|
|
6352
6389
|
tasks: Awaited<ReturnType<typeof scheduler.listTasks>>;
|
|
6353
6390
|
osAvailable: boolean;
|
|
@@ -6398,7 +6435,7 @@ async function collectTasksView() {
|
|
|
6398
6435
|
// (накопительные итоги, не зависят от retention истории). Для задач, у
|
|
6399
6436
|
// которых метрик ещё нет, считаем по загруженной истории.
|
|
6400
6437
|
const metricsByName = new Map(
|
|
6401
|
-
getAllMetrics(true).map((row) => [row.taskName.toLowerCase(), row])
|
|
6438
|
+
getAllMetrics(true).map((row) => [row.taskName.toLowerCase(), row]),
|
|
6402
6439
|
);
|
|
6403
6440
|
const historyCounts = new Map<
|
|
6404
6441
|
string,
|
|
@@ -6427,10 +6464,10 @@ async function collectTasksView() {
|
|
|
6427
6464
|
const orphanNames = defs
|
|
6428
6465
|
.filter((def) => !osNames.has(def.name.toLowerCase()))
|
|
6429
6466
|
.map((def) => def.name);
|
|
6430
|
-
const sources:
|
|
6467
|
+
const sources: { task: (typeof tasks)[number]; orphaned: boolean }[] = [
|
|
6431
6468
|
...tasks.map((task) => ({ task, orphaned: false })),
|
|
6432
6469
|
...orphanNames.map((name) => ({
|
|
6433
|
-
task: { taskName: name }
|
|
6470
|
+
task: { taskName: name },
|
|
6434
6471
|
orphaned: true,
|
|
6435
6472
|
})),
|
|
6436
6473
|
];
|
|
@@ -6466,17 +6503,17 @@ async function collectTasksView() {
|
|
|
6466
6503
|
const metricsRow = metricsByName.get(name.toLowerCase());
|
|
6467
6504
|
const counts = metricsRow
|
|
6468
6505
|
? {
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6506
|
+
total: metricsRow.total,
|
|
6507
|
+
success: metricsRow.success,
|
|
6508
|
+
error: metricsRow.error,
|
|
6509
|
+
partial: metricsRow.partial,
|
|
6510
|
+
}
|
|
6474
6511
|
: historyCounts.get(name.toLowerCase()) ?? {
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6512
|
+
total: 0,
|
|
6513
|
+
success: 0,
|
|
6514
|
+
error: 0,
|
|
6515
|
+
partial: 0,
|
|
6516
|
+
};
|
|
6480
6517
|
|
|
6481
6518
|
// Спринт 27.5.2: пауза учитывает и флаг ОС, и активный pausedUntil.
|
|
6482
6519
|
// nextRun считаем из определения — schtasks после мутации отдаёт
|
|
@@ -6543,13 +6580,13 @@ async function collectTasksView() {
|
|
|
6543
6580
|
isMatrixParent: Boolean(def?.matrix),
|
|
6544
6581
|
matrixSummary: matrixAggregate
|
|
6545
6582
|
? {
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6583
|
+
totalCount: matrixAggregate.totalCount,
|
|
6584
|
+
successCount: matrixAggregate.successCount,
|
|
6585
|
+
errorCount: matrixAggregate.errorCount,
|
|
6586
|
+
pendingCount: matrixAggregate.pendingCount,
|
|
6587
|
+
status: matrixAggregate.status,
|
|
6588
|
+
message: matrixAggregate.message,
|
|
6589
|
+
}
|
|
6553
6590
|
: null,
|
|
6554
6591
|
prompt: def?.prompt ?? "",
|
|
6555
6592
|
};
|