agent-steward 0.0.3 → 0.0.5
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 +154 -2
- package/CROSS_PLATFORM.md +19 -0
- package/README.md +54 -9
- package/ROADMAP-STRATEGY.md +23 -20
- package/ROADMAP.md +140 -143
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +351 -0
- package/dist/core/dlq-api.d.ts +44 -0
- package/dist/core/dlq-api.d.ts.map +1 -0
- package/dist/core/dlq-api.js +68 -0
- package/dist/core/dry-run.d.ts.map +1 -1
- package/dist/core/dry-run.js +18 -1
- package/dist/core/execution.d.ts +203 -0
- package/dist/core/execution.d.ts.map +1 -0
- package/dist/core/execution.js +309 -0
- package/dist/core/gate-integrity.d.ts +35 -0
- package/dist/core/gate-integrity.d.ts.map +1 -0
- package/dist/core/gate-integrity.js +132 -0
- package/dist/core/git-trigger.d.ts.map +1 -1
- package/dist/core/git-trigger.js +14 -2
- package/dist/core/guard-run.d.ts +4 -0
- package/dist/core/guard-run.d.ts.map +1 -0
- package/dist/core/guard-run.js +101 -0
- package/dist/core/guard.d.ts +52 -0
- package/dist/core/guard.d.ts.map +1 -0
- package/dist/core/guard.js +362 -0
- package/dist/core/lock.d.ts +61 -4
- package/dist/core/lock.d.ts.map +1 -1
- package/dist/core/lock.js +213 -26
- package/dist/core/matrix.d.ts.map +1 -1
- package/dist/core/matrix.js +75 -15
- package/dist/core/mission.d.ts +83 -0
- package/dist/core/mission.d.ts.map +1 -0
- package/dist/core/mission.js +334 -0
- package/dist/core/one-shot.d.ts +5 -1
- package/dist/core/one-shot.d.ts.map +1 -1
- package/dist/core/one-shot.js +33 -8
- package/dist/core/opencode-cli.d.ts +28 -0
- package/dist/core/opencode-cli.d.ts.map +1 -0
- package/dist/core/opencode-cli.js +74 -0
- package/dist/core/opencode-models.d.ts +62 -0
- package/dist/core/opencode-models.d.ts.map +1 -0
- package/dist/core/opencode-models.js +277 -0
- package/dist/core/pipeline-apply.d.ts +38 -0
- package/dist/core/pipeline-apply.d.ts.map +1 -0
- package/dist/core/pipeline-apply.js +117 -0
- package/dist/core/pipeline-io.d.ts +13 -0
- package/dist/core/pipeline-io.d.ts.map +1 -0
- package/dist/core/pipeline-io.js +64 -0
- package/dist/core/pipeline-map.d.ts +46 -0
- package/dist/core/pipeline-map.d.ts.map +1 -0
- package/dist/core/pipeline-map.js +196 -0
- package/dist/core/pipeline-spec.d.ts +109 -0
- package/dist/core/pipeline-spec.d.ts.map +1 -0
- package/dist/core/pipeline-spec.js +554 -0
- package/dist/core/ps-wrapper.d.ts +19 -2
- package/dist/core/ps-wrapper.d.ts.map +1 -1
- package/dist/core/ps-wrapper.js +261 -63
- package/dist/core/record-history.d.ts +15 -0
- package/dist/core/record-history.d.ts.map +1 -1
- package/dist/core/record-history.js +183 -58
- package/dist/core/router/dispatch.d.ts +36 -0
- package/dist/core/router/dispatch.d.ts.map +1 -0
- package/dist/core/router/dispatch.js +59 -0
- package/dist/core/router/escalation.d.ts +47 -0
- package/dist/core/router/escalation.d.ts.map +1 -0
- package/dist/core/router/escalation.js +87 -0
- package/dist/core/router/planner.d.ts +53 -0
- package/dist/core/router/planner.d.ts.map +1 -0
- package/dist/core/router/planner.js +113 -0
- package/dist/core/router/rules.d.ts +46 -0
- package/dist/core/router/rules.d.ts.map +1 -0
- package/dist/core/router/rules.js +91 -0
- package/dist/core/run-panel-api.d.ts +94 -0
- package/dist/core/run-panel-api.d.ts.map +1 -0
- package/dist/core/run-panel-api.js +169 -0
- package/dist/core/schedule-gate.js +5 -1
- package/dist/core/schedule-v2.d.ts +34 -0
- package/dist/core/schedule-v2.d.ts.map +1 -1
- package/dist/core/schedule-v2.js +91 -5
- package/dist/core/scheduler/at-fallback.d.ts +55 -2
- package/dist/core/scheduler/at-fallback.d.ts.map +1 -1
- package/dist/core/scheduler/at-fallback.js +135 -5
- package/dist/core/scheduler/linux.d.ts +18 -2
- package/dist/core/scheduler/linux.d.ts.map +1 -1
- package/dist/core/scheduler/linux.js +63 -20
- package/dist/core/scheduler/mac.d.ts +44 -2
- package/dist/core/scheduler/mac.d.ts.map +1 -1
- package/dist/core/scheduler/mac.js +126 -15
- package/dist/core/scheduler/posix.d.ts.map +1 -1
- package/dist/core/scheduler/posix.js +25 -1
- package/dist/core/scheduler/registry.d.ts +11 -0
- package/dist/core/scheduler/registry.d.ts.map +1 -1
- package/dist/core/scheduler/registry.js +83 -21
- package/dist/core/scheduler/run-now.d.ts +16 -0
- package/dist/core/scheduler/run-now.d.ts.map +1 -0
- package/dist/core/scheduler/run-now.js +28 -0
- package/dist/core/scheduler/windows.d.ts.map +1 -1
- package/dist/core/scheduler/windows.js +15 -12
- package/dist/core/secrets.d.ts.map +1 -1
- package/dist/core/secrets.js +125 -28
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +18 -11
- package/dist/core/structured-log.d.ts +7 -1
- package/dist/core/structured-log.d.ts.map +1 -1
- package/dist/core/task-name.d.ts +24 -0
- package/dist/core/task-name.d.ts.map +1 -0
- package/dist/core/task-name.js +40 -0
- package/dist/core/worktree-run.d.ts +4 -0
- package/dist/core/worktree-run.d.ts.map +1 -0
- package/dist/core/worktree-run.js +164 -0
- package/dist/core/worktree.d.ts +115 -0
- package/dist/core/worktree.d.ts.map +1 -0
- package/dist/core/worktree.js +462 -0
- package/dist/core/wrappers/bash.d.ts +17 -0
- package/dist/core/wrappers/bash.d.ts.map +1 -1
- package/dist/core/wrappers/bash.js +224 -28
- package/dist/db/capability-repo.d.ts +124 -0
- package/dist/db/capability-repo.d.ts.map +1 -0
- package/dist/db/capability-repo.js +267 -0
- package/dist/db/history-repo.d.ts +46 -5
- package/dist/db/history-repo.d.ts.map +1 -1
- package/dist/db/history-repo.js +107 -25
- package/dist/db/index.d.ts +4 -0
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +39 -1
- package/dist/db/metrics-repo.js +2 -2
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +3 -1
- package/dist/db/recovery.d.ts.map +1 -1
- package/dist/db/recovery.js +5 -4
- package/dist/db/run-context.d.ts +103 -0
- package/dist/db/run-context.d.ts.map +1 -0
- package/dist/db/run-context.js +224 -0
- package/dist/db/run-dlq.d.ts +100 -0
- package/dist/db/run-dlq.d.ts.map +1 -0
- package/dist/db/run-dlq.js +191 -0
- package/dist/db/run-journal.d.ts +33 -5
- package/dist/db/run-journal.d.ts.map +1 -1
- package/dist/db/run-journal.js +78 -14
- package/dist/db/run-resume.d.ts +10 -2
- package/dist/db/run-resume.d.ts.map +1 -1
- package/dist/db/run-resume.js +39 -13
- package/dist/db/runs-repo.d.ts +32 -7
- package/dist/db/runs-repo.d.ts.map +1 -1
- package/dist/db/runs-repo.js +50 -11
- package/dist/db/schema.d.ts +2 -2
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +216 -3
- package/dist/db/settings-repo.d.ts +11 -0
- package/dist/db/settings-repo.d.ts.map +1 -1
- package/dist/db/settings-repo.js +25 -0
- package/dist/db/step-idempotency.d.ts +51 -0
- package/dist/db/step-idempotency.d.ts.map +1 -0
- package/dist/db/step-idempotency.js +136 -0
- package/dist/history.d.ts +1 -1
- package/dist/history.d.ts.map +1 -1
- package/dist/i18n.d.ts +5 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +11 -4
- package/dist/index.d.ts +140 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +480 -18
- package/dist/notifications.d.ts +22 -0
- package/dist/notifications.d.ts.map +1 -1
- package/dist/notifications.js +36 -8
- package/dist/profiles.d.ts.map +1 -1
- package/dist/profiles.js +25 -4
- package/dist/rpc.d.ts +924 -0
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +352 -0
- package/dist/server.d.ts +46 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +172 -53
- package/dist/settings.d.ts +2 -2
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +3 -3
- package/dist/shared/jobs-view.d.ts +1 -1
- package/dist/shared/jobs-view.d.ts.map +1 -1
- package/dist/shared/jobs-view.js +2 -0
- package/dist/task-transfer.d.ts +16 -0
- package/dist/task-transfer.d.ts.map +1 -1
- package/dist/task-transfer.js +16 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +7 -0
- package/dist/workspaces.d.ts +25 -3
- package/dist/workspaces.d.ts.map +1 -1
- package/dist/workspaces.js +43 -8
- package/docs/ARCHITECTURE.md +498 -58
- package/docs/COMPATIBILITY.md +2 -2
- package/docs/CONCEPT.md +185 -91
- package/docs/CROSS_PLATFORM.ru.md +20 -0
- package/docs/CROSS_PLATFORM.zh.md +18 -0
- package/docs/EXECUTION-LOOP.md +211 -0
- package/docs/FEATURES.md +65 -4
- package/docs/FEATURES.zh.md +52 -4
- package/docs/MIGRATION.md +2 -2
- package/docs/PIPELINE.md +293 -0
- package/docs/README.ru.md +44 -5
- package/docs/README.zh.md +46 -6
- package/docs/SAFETY.md +142 -0
- package/docs/SAVINGS.md +29 -0
- package/docs/SAVINGS.ru.md +29 -0
- package/docs/SAVINGS.zh.md +18 -0
- package/gui-experimental.cjs +9 -8
- package/locales/en.json +84 -1
- package/locales/ru.json +84 -1
- package/locales/zh.json +84 -1
- package/opencode.pipeline.yaml +35 -0
- package/package.json +46 -2
- package/scripts/audit-bundle.mjs +215 -0
- package/scripts/test-home.mjs +83 -0
- package/src/cli.ts +412 -0
- package/src/core/dlq-api.ts +98 -0
- package/src/core/dry-run.ts +27 -3
- package/src/core/execution.ts +538 -0
- package/src/core/file-watcher.ts +2 -2
- package/src/core/gate-integrity.ts +160 -0
- package/src/core/git-trigger.ts +18 -5
- package/src/core/guard-run.ts +119 -0
- package/src/core/guard.ts +431 -0
- package/src/core/lock.ts +244 -30
- package/src/core/matrix.ts +95 -50
- package/src/core/mission.ts +485 -0
- package/src/core/native-notify.ts +1 -1
- package/src/core/one-shot.ts +36 -8
- package/src/core/opencode-cli.ts +103 -0
- package/src/core/opencode-models.ts +315 -0
- package/src/core/pipeline-apply.ts +158 -0
- package/src/core/pipeline-io.ts +79 -0
- package/src/core/pipeline-map.ts +264 -0
- package/src/core/pipeline-spec.ts +775 -0
- package/src/core/ps-wrapper.ts +274 -64
- package/src/core/record-history.ts +229 -104
- package/src/core/router/dispatch.ts +94 -0
- package/src/core/router/escalation.ts +129 -0
- package/src/core/router/planner.ts +166 -0
- package/src/core/router/rules.ts +115 -0
- package/src/core/run-panel-api.ts +262 -0
- package/src/core/schedule-gate.ts +7 -3
- package/src/core/schedule-v2.ts +114 -5
- package/src/core/scheduler/at-fallback.ts +190 -5
- package/src/core/scheduler/linux.ts +72 -21
- package/src/core/scheduler/logs.ts +2 -2
- package/src/core/scheduler/mac.ts +174 -14
- package/src/core/scheduler/posix.ts +20 -1
- package/src/core/scheduler/registry.ts +107 -26
- package/src/core/scheduler/run-now.ts +32 -0
- package/src/core/scheduler/windows.ts +19 -15
- package/src/core/secrets.ts +131 -31
- package/src/core/session.ts +23 -10
- package/src/core/structured-log.ts +22 -5
- package/src/core/task-name.ts +67 -0
- package/src/core/telegram.ts +2 -2
- package/src/core/triage-worker.ts +7 -7
- package/src/core/triage.ts +2 -2
- package/src/core/worktree-run.ts +199 -0
- package/src/core/worktree.ts +600 -0
- package/src/core/wrappers/bash.ts +239 -27
- package/src/db/capability-repo.ts +402 -0
- package/src/db/history-repo.ts +151 -22
- package/src/db/index.ts +37 -1
- package/src/db/metrics-repo.ts +2 -2
- package/src/db/migrate.ts +3 -1
- package/src/db/recovery.ts +5 -4
- package/src/db/run-context.ts +370 -0
- package/src/db/run-dlq.ts +310 -0
- package/src/db/run-journal.ts +100 -13
- package/src/db/run-resume.ts +65 -13
- package/src/db/runs-repo.ts +66 -13
- package/src/db/schema.ts +218 -3
- package/src/db/settings-repo.ts +31 -0
- package/src/db/step-idempotency.ts +185 -0
- package/src/gui.tsx +692 -13
- package/src/history.ts +1 -1
- package/src/i18n.ts +12 -4
- package/src/index.ts +648 -8
- package/src/notifications.ts +38 -8
- package/src/profiles.ts +26 -4
- package/src/rpc.ts +379 -0
- package/src/server.ts +206 -54
- package/src/settings.ts +5 -5
- package/src/shared/jobs-view.ts +3 -1
- package/src/task-transfer.ts +31 -0
- package/src/types.ts +9 -0
- package/src/workspaces.ts +58 -9
package/dist/index.js
CHANGED
|
@@ -7,28 +7,37 @@ import fs from "node:fs/promises";
|
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { LockManager } from "./core/lock.js";
|
|
9
9
|
import { LOCK_DIR, LOG_DIR, PLUGIN_DIR, STALE_LOCK_MAX_AGE_MS, WRAPPER_DIR, sanitizeName, validateModelId, validateTaskName, } from "./types.js";
|
|
10
|
-
import { parseCron, buildScheduleGate, isValidIanaTimeZone, validateLaunchWindow, prevRun, nextRun as cronNextRun, normalizeActiveDays, activeWindowState, nextWindowOpenDelayMs } from "./core/schedule-v2.js";
|
|
10
|
+
import { parseCron, buildScheduleGate, isValidIanaTimeZone, validateLaunchWindow, prevRun, nextRun as cronNextRun, normalizeActiveDays, activeWindowState, nextWindowOpenDelayMs, assessCronWindowFeasibility, windowFeasibilityReasonText } from "./core/schedule-v2.js";
|
|
11
11
|
import { buildLaunchdOneShotCleanup, normalizeOneShotRunAt, } from "./core/one-shot.js";
|
|
12
12
|
import { generateSessionId, normalizeSessionMode, preservedSessionRunCount, sessionStatePath, writeSessionStateFile, } from "./core/session.js";
|
|
13
13
|
import { ensureWrapper, writePromptFile, writeWrapperCmd, lockFilePath, requestImmediateRun } from "./core/ps-wrapper.js";
|
|
14
|
-
import { getSchedulerBackend } from "./core/scheduler/index.js";
|
|
14
|
+
import { getSchedulerBackend, LinuxScheduler } from "./core/scheduler/index.js";
|
|
15
15
|
import { SCHEDULER_SKILL_ID, loadSchedulerSkill } from "./skill.js";
|
|
16
16
|
import { getTaskLogs } from "./core/scheduler/logs.js";
|
|
17
|
+
import { findSanitizedNameConflict, sanitizedConflictMessage } from "./core/task-name.js";
|
|
17
18
|
import { writeBashWrapper } from "./core/wrappers/bash.js";
|
|
19
|
+
import { normalizeTaskGuards } from "./core/guard.js";
|
|
18
20
|
import { simulatePipeline } from "./core/dry-run.js";
|
|
19
21
|
import { aggregateMatrixResults, cancelPendingMatrixClones, expandMatrixTask, findOrphanedMatrixTasks, getMatrixDeletionGuard, matrixCompleteName, planMatrixFamilyDelete, removeMatrixChildren, runMatrix, syncMatrixFamily, } from "./core/matrix.js";
|
|
20
22
|
import { normalizeWatchPath, validateWatchGlobs } from "./core/watch-paths.js";
|
|
21
23
|
import { createShutdownGate } from "./core/shutdown.js";
|
|
22
24
|
import { SchedulerRpc } from "./rpc.js";
|
|
25
|
+
import { loadPipelineFile, parsePipelineYaml, } from "./core/pipeline-io.js";
|
|
26
|
+
import { planPipelineApply, } from "./core/pipeline-apply.js";
|
|
27
|
+
import { tasksToPipelineSpec } from "./core/pipeline-map.js";
|
|
28
|
+
import { stringify as yamlStringify } from "yaml";
|
|
23
29
|
import { latestHistoryByTask, loadHistory, loadMetrics } from "./history.js";
|
|
24
30
|
import { defaultNotifications, loadSettings, saveSettings } from "./settings.js";
|
|
25
31
|
import { resolveLocale, setLocale, t } from "./i18n.js";
|
|
32
|
+
import { runMission } from "./core/mission.js";
|
|
26
33
|
import { DEFAULT_PERMISSION_POLICY, buildOpencodeConfig, resolvePermissions, } from "./core/permissions.js";
|
|
27
34
|
import { runHistoryRetention, maybeRunHistoryRetention } from "./core/retention.js";
|
|
28
35
|
import { buildAnalytics } from "./core/analytics.js";
|
|
29
36
|
import { generateSelfAnalysisReport } from "./core/self-analysis.js";
|
|
30
37
|
import { getHistory, listRunningRecords } from "./db/history-repo.js";
|
|
31
38
|
import { getAllMetrics } from "./db/metrics-repo.js";
|
|
39
|
+
import { discardDlq, listDlq, retryDlq } from "./core/dlq-api.js";
|
|
40
|
+
import { listRunPanel, pauseRunPanel, resumeRunPanel, } from "./core/run-panel-api.js";
|
|
32
41
|
import { findStuckMatrixClones, maybeSendDigest, notifyStuckMatrix, sendDigestNow, sendTestNotification, } from "./notifications.js";
|
|
33
42
|
import { shadowReport, resetShadowDecisions, } from "./core/triage-shadow.js";
|
|
34
43
|
import { compareTriage } from "./core/triage-compare.js";
|
|
@@ -88,6 +97,39 @@ const gatePath = (() => {
|
|
|
88
97
|
`${distPath}. Гейт расписания не будет проверяться. Выполните npm run build.`);
|
|
89
98
|
return distPath;
|
|
90
99
|
})();
|
|
100
|
+
/**
|
|
101
|
+
* W-1: путь к помощнику создания одноразового git worktree
|
|
102
|
+
* (dist/core/worktree-run.js). Обёртка вызывает его перед opencode.
|
|
103
|
+
*/
|
|
104
|
+
const worktreeHelperPath = (() => {
|
|
105
|
+
const resolved = require.resolve("./core/worktree-run.js");
|
|
106
|
+
if (!resolved.endsWith(".ts"))
|
|
107
|
+
return resolved;
|
|
108
|
+
const distPath = resolved
|
|
109
|
+
.replace(/([\\/])src([\\/])/, "$1dist$2")
|
|
110
|
+
.replace(/\.ts$/, ".js");
|
|
111
|
+
if (existsSync(distPath))
|
|
112
|
+
return distPath;
|
|
113
|
+
console.warn("[agent-steward] Не найден собранный worktree-run.js: " +
|
|
114
|
+
`${distPath}. Изоляция в git worktree не будет работать. Выполните npm run build.`);
|
|
115
|
+
return distPath;
|
|
116
|
+
})();
|
|
117
|
+
/**
|
|
118
|
+
* W-3: путь к CLI-помощнику guard-условий (dist/core/guard-run.js).
|
|
119
|
+
*/
|
|
120
|
+
const guardHelperPath = (() => {
|
|
121
|
+
const resolved = require.resolve("./core/guard-run.js");
|
|
122
|
+
if (!resolved.endsWith(".ts"))
|
|
123
|
+
return resolved;
|
|
124
|
+
const distPath = resolved
|
|
125
|
+
.replace(/([\\/])src([\\/])/, "$1dist$2")
|
|
126
|
+
.replace(/\.ts$/, ".js");
|
|
127
|
+
if (existsSync(distPath))
|
|
128
|
+
return distPath;
|
|
129
|
+
console.warn("[agent-steward] Не найден собранный guard-run.js: " +
|
|
130
|
+
`${distPath}. Guard-условия не будут проверяться. Выполните npm run build.`);
|
|
131
|
+
return distPath;
|
|
132
|
+
})();
|
|
91
133
|
/** Бэкенд планировщика текущей ОС (schtasks / crontab / launchd). */
|
|
92
134
|
const scheduler = getSchedulerBackend();
|
|
93
135
|
/** Per-workspace overrides for matrix clones (Sprint 17). */
|
|
@@ -128,6 +170,39 @@ export const matrixSchema = z.object({
|
|
|
128
170
|
.optional()
|
|
129
171
|
.describe("Per-workspace overrides keyed by workspace id. Keys must be present in workspaceIds."),
|
|
130
172
|
});
|
|
173
|
+
/** W-3: guard-условия задачи. */
|
|
174
|
+
export const guardsSchema = z.object({
|
|
175
|
+
command: z
|
|
176
|
+
.string()
|
|
177
|
+
.max(4000)
|
|
178
|
+
.optional()
|
|
179
|
+
.describe("Shell command evaluated before the run. Exit 0 runs the task; any other code skips it."),
|
|
180
|
+
timeoutSeconds: z
|
|
181
|
+
.number()
|
|
182
|
+
.int()
|
|
183
|
+
.min(1)
|
|
184
|
+
.max(3600)
|
|
185
|
+
.optional()
|
|
186
|
+
.describe("Shell guard timeout in seconds (default 60)."),
|
|
187
|
+
semantic: z
|
|
188
|
+
.object({
|
|
189
|
+
filesExist: z.array(z.string()).max(200).optional().describe("Paths that must exist."),
|
|
190
|
+
filesMissing: z.array(z.string()).max(200).optional().describe("Paths that must not exist."),
|
|
191
|
+
branch: z.string().max(200).optional().describe("Glob for the current git branch, e.g. feature/*."),
|
|
192
|
+
changedPaths: z
|
|
193
|
+
.array(z.string())
|
|
194
|
+
.max(200)
|
|
195
|
+
.optional()
|
|
196
|
+
.describe("Globs of changed paths; at least one must match."),
|
|
197
|
+
changedSince: z
|
|
198
|
+
.string()
|
|
199
|
+
.max(100)
|
|
200
|
+
.optional()
|
|
201
|
+
.describe("Git ref to diff against (default HEAD~1)."),
|
|
202
|
+
})
|
|
203
|
+
.optional()
|
|
204
|
+
.describe("Semantic pre-run checks inside the working directory."),
|
|
205
|
+
}).describe("W-3: guard conditions. If a check fails, the run is skipped before opencode starts.");
|
|
131
206
|
/** Zod-схема аргументов schedule_task */
|
|
132
207
|
export const scheduleTaskSchema = z.object({
|
|
133
208
|
name: z
|
|
@@ -291,6 +366,13 @@ export const scheduleTaskSchema = z.object({
|
|
|
291
366
|
.boolean()
|
|
292
367
|
.optional()
|
|
293
368
|
.describe("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."),
|
|
369
|
+
worktree: z
|
|
370
|
+
.boolean()
|
|
371
|
+
.optional()
|
|
372
|
+
.describe("W-1: run each tick in a one-off git worktree created from HEAD of workingDirectory. Keeps fan-out runs isolated from each other and from the main checkout. Requires a git repository; creation failure fails the run closed. Default false."),
|
|
373
|
+
guards: guardsSchema
|
|
374
|
+
.optional()
|
|
375
|
+
.describe("W-3: pre-run guard conditions. If a semantic check or shell command fails, the run is skipped (no opencode, no side effects). Combined with worktree: checks run inside the fresh worktree."),
|
|
294
376
|
matrix: matrixSchema
|
|
295
377
|
.optional()
|
|
296
378
|
.describe("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."),
|
|
@@ -483,6 +565,13 @@ export const updateTaskSchema = z.object({
|
|
|
483
565
|
.boolean()
|
|
484
566
|
.optional()
|
|
485
567
|
.describe("Transitional flag (release 1.6): re-enable shell under the hybrid policy for this task."),
|
|
568
|
+
worktree: z
|
|
569
|
+
.boolean()
|
|
570
|
+
.optional()
|
|
571
|
+
.describe("W-1: run each tick in a one-off git worktree created from HEAD of workingDirectory. Default false."),
|
|
572
|
+
guards: guardsSchema
|
|
573
|
+
.optional()
|
|
574
|
+
.describe("W-3: pre-run guard conditions; a failed check skips the run."),
|
|
486
575
|
matrix: matrixSchema
|
|
487
576
|
.nullable()
|
|
488
577
|
.optional()
|
|
@@ -542,6 +631,30 @@ const dryRunSchema = z.object({
|
|
|
542
631
|
.optional()
|
|
543
632
|
.describe("Task name to simulate. When omitted, every task is simulated (pipeline dry run, nothing is executed)."),
|
|
544
633
|
});
|
|
634
|
+
/** pipeline_validate — проверить опencode.pipeline.yaml (путь или исходник). */
|
|
635
|
+
export const pipelineValidateSchema = z.object({
|
|
636
|
+
path: z.string().optional().describe("Путь к файлу opencode.pipeline.yaml."),
|
|
637
|
+
source: z.string().optional().describe("Исходное содержимое YAML."),
|
|
638
|
+
dryRun: z
|
|
639
|
+
.boolean()
|
|
640
|
+
.optional()
|
|
641
|
+
.default(true)
|
|
642
|
+
.describe("Если true — только валидация без применения (по умолчанию true)."),
|
|
643
|
+
});
|
|
644
|
+
/** pipeline_apply — применить opencode.pipeline.yaml к текущему набору задач. */
|
|
645
|
+
export const pipelineApplySchema = z.object({
|
|
646
|
+
path: z.string().optional().describe("Путь к файлу opencode.pipeline.yaml."),
|
|
647
|
+
source: z.string().optional().describe("Исходное содержимое YAML."),
|
|
648
|
+
dryRun: z
|
|
649
|
+
.boolean()
|
|
650
|
+
.optional()
|
|
651
|
+
.default(false)
|
|
652
|
+
.describe("Если true — прогон diff'а без применения изменений (по умолчанию false)."),
|
|
653
|
+
});
|
|
654
|
+
/** pipeline_export — выгрузить задачи конвейера как opencode.pipeline.yaml. */
|
|
655
|
+
export const pipelineExportSchema = z.object({
|
|
656
|
+
pipeline: z.string().describe("Имя конвейера (pipelineName)."),
|
|
657
|
+
});
|
|
545
658
|
const manageWorkspacesSchema = z.object({
|
|
546
659
|
action: z
|
|
547
660
|
.enum(["list", "add", "update", "delete"])
|
|
@@ -649,7 +762,7 @@ export const manageSettingsSchema = z.object({
|
|
|
649
762
|
locale: z
|
|
650
763
|
.enum(["auto", "ru", "en", "zh"])
|
|
651
764
|
.optional()
|
|
652
|
-
.describe("Interface language: auto (
|
|
765
|
+
.describe("Interface language: auto (default, follows OpenCode), ru, en or zh. Applies without restart."),
|
|
653
766
|
winterMode: z
|
|
654
767
|
.boolean()
|
|
655
768
|
.optional()
|
|
@@ -916,7 +1029,7 @@ function computeTaskNextRun(def, options = {}) {
|
|
|
916
1029
|
}
|
|
917
1030
|
/** schedule_task — создаёт задачу в schtasks через общий schedulerCreateTask. */
|
|
918
1031
|
const scheduleTaskExecute = wrapExecute(async (args) => {
|
|
919
|
-
const { name, schedule, runAt, delaySeconds, prompt, timeoutSeconds, model, priority, beforeScript, afterScript, qualityGate, dependsOn, retryCount, retryDelay, nextTaskOnSuccess, nextTaskOnError, triggerType, mcpEvent, watchPath, workingDirectory, workspaceId, allowedTools, deniedTools, matrix, timezone, notBefore, notAfter, session, sessionMaxRuns, activeDays, windowPolicy, watchGlobs, watchIgnore, gitBranch, gitPaths, gitIgnore, gitPollSeconds, runWhenLoggedOff, legacyShell, } = args;
|
|
1032
|
+
const { name, schedule, runAt, delaySeconds, prompt, timeoutSeconds, model, priority, beforeScript, afterScript, qualityGate, dependsOn, retryCount, retryDelay, nextTaskOnSuccess, nextTaskOnError, triggerType, mcpEvent, watchPath, workingDirectory, workspaceId, allowedTools, deniedTools, matrix, timezone, notBefore, notAfter, session, sessionMaxRuns, activeDays, windowPolicy, watchGlobs, watchIgnore, gitBranch, gitPaths, gitIgnore, gitPollSeconds, runWhenLoggedOff, legacyShell, worktree, guards, } = args;
|
|
920
1033
|
let effectiveRunAt;
|
|
921
1034
|
if ((triggerType ?? "cron") === "once") {
|
|
922
1035
|
const normalized = normalizeOneShotRunAt({ runAt, delaySeconds });
|
|
@@ -943,7 +1056,7 @@ const scheduleTaskExecute = wrapExecute(async (args) => {
|
|
|
943
1056
|
gitPollSeconds,
|
|
944
1057
|
},
|
|
945
1058
|
// Спринт 27.5.4: Windows — работать без входа (/ru SYSTEM).
|
|
946
|
-
runWhenLoggedOff === true, undefined, legacyShell === true);
|
|
1059
|
+
runWhenLoggedOff === true, undefined, legacyShell === true, worktree === true, guards);
|
|
947
1060
|
}
|
|
948
1061
|
catch (err) {
|
|
949
1062
|
return {
|
|
@@ -1007,6 +1120,8 @@ const scheduleTaskExecute = wrapExecute(async (args) => {
|
|
|
1007
1120
|
workspaceId: workspace?.id ?? null,
|
|
1008
1121
|
workspaceName: workspace?.name ?? null,
|
|
1009
1122
|
matrix: matrix ?? null,
|
|
1123
|
+
worktree: worktree === true,
|
|
1124
|
+
guards: guards ?? null,
|
|
1010
1125
|
},
|
|
1011
1126
|
}),
|
|
1012
1127
|
};
|
|
@@ -1069,7 +1184,7 @@ async function cancelMatrixRun(name) {
|
|
|
1069
1184
|
}
|
|
1070
1185
|
// Возвращаем placeholder-задачу, чтобы следующая fan-out-волна работала.
|
|
1071
1186
|
try {
|
|
1072
|
-
await schedulerCreateTask(clone.name, clone.schedule, clone.prompt, clone.timeoutSeconds, undefined, clone.retryCount, clone.retryDelay, clone.qualityGate, undefined, undefined, "file", undefined, undefined, clone.model, clone.priority, clone.beforeScript, clone.afterScript, undefined, clone.workspaceId, clone.allowedTools, clone.deniedTools, undefined, definition.name, "create", clone.timezone, clone.notBefore, clone.notAfter, clone.pausedUntil, clone.runAt, clone.session, clone.sessionId, clone.sessionMaxRuns, undefined, clone.runWhenLoggedOff, clone.paused, clone.legacyShell);
|
|
1187
|
+
await schedulerCreateTask(clone.name, clone.schedule, clone.prompt, clone.timeoutSeconds, undefined, clone.retryCount, clone.retryDelay, clone.qualityGate, undefined, undefined, "file", undefined, undefined, clone.model, clone.priority, clone.beforeScript, clone.afterScript, undefined, clone.workspaceId, clone.allowedTools, clone.deniedTools, undefined, definition.name, "create", clone.timezone, clone.notBefore, clone.notAfter, clone.pausedUntil, clone.runAt, clone.session, clone.sessionId, clone.sessionMaxRuns, undefined, clone.runWhenLoggedOff, clone.paused, clone.legacyShell, clone.worktree, clone.guards);
|
|
1073
1188
|
}
|
|
1074
1189
|
catch (err) {
|
|
1075
1190
|
warnings.push(t("tool.matrix.recreateFailed", {
|
|
@@ -1496,7 +1611,7 @@ async function updateTaskFromInput(input) {
|
|
|
1496
1611
|
await schedulerCreateTask(name, schedule ?? "", prompt, input.timeoutSeconds ?? previous.timeoutSeconds, clearableString(input.workingDirectory, previous.workingDirectory), input.retryCount ?? previous.retryCount, input.retryDelay ?? previous.retryDelay, clearableString(input.qualityGate, previous.qualityGate), clearableString(input.nextTaskOnSuccess, previous.nextTaskOnSuccess), clearableString(input.nextTaskOnError, previous.nextTaskOnError), triggerType, clearableString(input.watchPath, previous.watchPath), clearableList(input.dependsOn, previous.dependsOn), nextModel, input.priority ?? previous.priority, clearableString(input.beforeScript, previous.beforeScript), clearableString(input.afterScript, previous.afterScript), input.mcpEvent ?? previous.mcpEvent, clearableString(input.workspaceId, previous.workspaceId), clearableList(input.allowedTools, previous.allowedTools), clearableList(input.deniedTools, previous.deniedTools), matrixNext, undefined,
|
|
1497
1612
|
// Если задача была матрицей — синхронизируем клонов, а не
|
|
1498
1613
|
// пересоздаём их с нуля (Спринт 17).
|
|
1499
|
-
matrixWas && matrixNext ? "sync" : "create", timezone, notBefore, notAfter, previous.pausedUntil, runAt, session, sessionId, sessionMaxRuns, triggerExtras, input.runWhenLoggedOff ?? previous.runWhenLoggedOff, wasPaused, input.legacyShell ?? previous.legacyShell);
|
|
1614
|
+
matrixWas && matrixNext ? "sync" : "create", timezone, notBefore, notAfter, previous.pausedUntil, runAt, session, sessionId, sessionMaxRuns, triggerExtras, input.runWhenLoggedOff ?? previous.runWhenLoggedOff, wasPaused, input.legacyShell ?? previous.legacyShell, input.worktree ?? previous.worktree, input.guards ?? previous.guards);
|
|
1500
1615
|
// Матрица отключена при обновлении — убираем клонов и агрегатор.
|
|
1501
1616
|
if (matrixWas && !matrixNext) {
|
|
1502
1617
|
await removeMatrixChildrenFromScheduler(name);
|
|
@@ -1883,6 +1998,153 @@ const dryRunExecute = wrapExecute(async (args) => {
|
|
|
1883
1998
|
}),
|
|
1884
1999
|
};
|
|
1885
2000
|
});
|
|
2001
|
+
/** pipeline_validate — проверить opencode.pipeline.yaml (путь или исходник). */
|
|
2002
|
+
const pipelineValidateExecute = wrapExecute(async (args) => {
|
|
2003
|
+
const path = args.path ?? args.source ? undefined : undefined;
|
|
2004
|
+
if (args.path === undefined && args.source === undefined) {
|
|
2005
|
+
return {
|
|
2006
|
+
content: JSON.stringify({
|
|
2007
|
+
success: false,
|
|
2008
|
+
pipeline: null,
|
|
2009
|
+
errors: ["Укажите path к файлу или source с содержимым YAML"],
|
|
2010
|
+
warnings: [],
|
|
2011
|
+
}),
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
2014
|
+
const parsed = args.source !== undefined
|
|
2015
|
+
? validatePipelineSpecFromSource(args.source)
|
|
2016
|
+
: await loadPipelineFile(args.path);
|
|
2017
|
+
if (!parsed.ok) {
|
|
2018
|
+
return {
|
|
2019
|
+
content: JSON.stringify({
|
|
2020
|
+
success: false,
|
|
2021
|
+
pipeline: null,
|
|
2022
|
+
errors: parsed.errors,
|
|
2023
|
+
warnings: parsed.warnings,
|
|
2024
|
+
}),
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
const spec = parsed.spec;
|
|
2028
|
+
return {
|
|
2029
|
+
content: JSON.stringify({
|
|
2030
|
+
success: true,
|
|
2031
|
+
pipeline: spec.name,
|
|
2032
|
+
steps: spec.steps.length,
|
|
2033
|
+
errors: [],
|
|
2034
|
+
warnings: parsed.warnings,
|
|
2035
|
+
}),
|
|
2036
|
+
};
|
|
2037
|
+
});
|
|
2038
|
+
function validatePipelineSpecFromSource(source) {
|
|
2039
|
+
const parsed = parsePipelineYaml(source);
|
|
2040
|
+
return parsed;
|
|
2041
|
+
}
|
|
2042
|
+
/** pipeline_apply — применить opencode.pipeline.yaml к текущему набору задач. */
|
|
2043
|
+
const pipelineApplyExecute = wrapExecute(async (args) => {
|
|
2044
|
+
const dryRun = args.dryRun !== false;
|
|
2045
|
+
const parsed = args.source !== undefined
|
|
2046
|
+
? validatePipelineSpecFromSource(args.source)
|
|
2047
|
+
: await loadPipelineFile(args.path);
|
|
2048
|
+
if (!parsed.ok) {
|
|
2049
|
+
return {
|
|
2050
|
+
content: JSON.stringify({
|
|
2051
|
+
success: false,
|
|
2052
|
+
pipeline: null,
|
|
2053
|
+
errors: parsed.errors,
|
|
2054
|
+
warnings: parsed.warnings,
|
|
2055
|
+
}),
|
|
2056
|
+
};
|
|
2057
|
+
}
|
|
2058
|
+
const spec = parsed.spec;
|
|
2059
|
+
const existing = await listTaskDefinitions();
|
|
2060
|
+
const plan = planPipelineApply(spec, existing, {
|
|
2061
|
+
resolveWorkspaceId: (nameOrId) => {
|
|
2062
|
+
const ws = getWorkspace(nameOrId);
|
|
2063
|
+
return ws ? ws.id : undefined;
|
|
2064
|
+
},
|
|
2065
|
+
});
|
|
2066
|
+
let created = 0;
|
|
2067
|
+
let updated = 0;
|
|
2068
|
+
const errors = [];
|
|
2069
|
+
if (!dryRun) {
|
|
2070
|
+
for (const task of plan.creates) {
|
|
2071
|
+
try {
|
|
2072
|
+
await schedulerCreateTask(task.name, task.schedule, task.prompt, task.timeoutSeconds, task.workingDirectory ?? task.workdir ?? undefined, task.retryCount, task.retryDelay, task.qualityGate, task.nextTaskOnSuccess, task.nextTaskOnError, task.triggerType ?? "cron", task.watchPath, task.dependsOn, task.model, task.priority, task.beforeScript, task.afterScript, task.mcpEvent, task.workspaceId, task.allowedTools, task.deniedTools, task.matrix, task.matrixParentId, "create", task.timezone, task.notBefore, task.notAfter, task.pausedUntil, task.runAt, task.session, task.sessionId, task.sessionMaxRuns, {
|
|
2073
|
+
activeDays: task.activeDays,
|
|
2074
|
+
windowPolicy: task.windowPolicy,
|
|
2075
|
+
watchGlobs: task.watchGlobs ?? [],
|
|
2076
|
+
watchIgnore: task.watchIgnore ?? [],
|
|
2077
|
+
gitBranch: task.gitBranch,
|
|
2078
|
+
gitPaths: task.gitPaths,
|
|
2079
|
+
gitIgnore: task.gitIgnore,
|
|
2080
|
+
gitPollSeconds: task.gitPollSeconds,
|
|
2081
|
+
}, task.runWhenLoggedOff ?? false, task.paused ?? false, task.legacyShell ?? false, task.worktree ?? false, task.guards);
|
|
2082
|
+
await saveTaskDefinition(task);
|
|
2083
|
+
created++;
|
|
2084
|
+
}
|
|
2085
|
+
catch (err) {
|
|
2086
|
+
errors.push(`create ${task.name}: ${err instanceof Error ? err.message : String(err)}`);
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
for (const item of plan.updates) {
|
|
2090
|
+
try {
|
|
2091
|
+
await schedulerCreateTask(item.task.name, item.task.schedule, item.task.prompt, item.task.timeoutSeconds, item.task.workingDirectory ?? item.task.workdir ?? undefined, item.task.retryCount, item.task.retryDelay, item.task.qualityGate, item.task.nextTaskOnSuccess, item.task.nextTaskOnError, item.task.triggerType ?? "cron", item.task.watchPath, item.task.dependsOn, item.task.model, item.task.priority, item.task.beforeScript, item.task.afterScript, item.task.mcpEvent, item.task.workspaceId, item.task.allowedTools, item.task.deniedTools, item.task.matrix, item.task.matrixParentId, "sync", item.task.timezone, item.task.notBefore, item.task.notAfter, item.task.pausedUntil, item.task.runAt, item.task.session, item.task.sessionId, item.task.sessionMaxRuns, {
|
|
2092
|
+
activeDays: item.task.activeDays,
|
|
2093
|
+
windowPolicy: item.task.windowPolicy,
|
|
2094
|
+
watchGlobs: item.task.watchGlobs ?? [],
|
|
2095
|
+
watchIgnore: item.task.watchIgnore ?? [],
|
|
2096
|
+
gitBranch: item.task.gitBranch,
|
|
2097
|
+
gitPaths: item.task.gitPaths,
|
|
2098
|
+
gitIgnore: item.task.gitIgnore,
|
|
2099
|
+
gitPollSeconds: item.task.gitPollSeconds,
|
|
2100
|
+
}, item.task.runWhenLoggedOff ?? false, item.task.paused ?? false, item.task.legacyShell ?? false, item.task.worktree ?? false, item.task.guards);
|
|
2101
|
+
await saveTaskDefinition(item.task);
|
|
2102
|
+
updated++;
|
|
2103
|
+
}
|
|
2104
|
+
catch (err) {
|
|
2105
|
+
errors.push(`update ${item.task.name}: ${err instanceof Error ? err.message : String(err)}`);
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
refreshTriggers();
|
|
2109
|
+
}
|
|
2110
|
+
return {
|
|
2111
|
+
content: JSON.stringify({
|
|
2112
|
+
success: errors.length === 0,
|
|
2113
|
+
pipeline: spec.name,
|
|
2114
|
+
dryRun,
|
|
2115
|
+
created,
|
|
2116
|
+
updated,
|
|
2117
|
+
unchanged: plan.unchanged.length,
|
|
2118
|
+
stale: plan.stale.length,
|
|
2119
|
+
warnings: [...plan.warnings, ...errors],
|
|
2120
|
+
errors,
|
|
2121
|
+
}),
|
|
2122
|
+
};
|
|
2123
|
+
});
|
|
2124
|
+
/** pipeline_export — выгрузить задачи конвейера как opencode.pipeline.yaml. */
|
|
2125
|
+
const pipelineExportExecute = wrapExecute(async (args) => {
|
|
2126
|
+
const allTasks = await listTaskDefinitions();
|
|
2127
|
+
const result = tasksToPipelineSpec(allTasks, args.pipeline);
|
|
2128
|
+
if (!result.spec) {
|
|
2129
|
+
return {
|
|
2130
|
+
content: JSON.stringify({
|
|
2131
|
+
success: false,
|
|
2132
|
+
error: `Конвейер "${args.pipeline}" не найден (не найдены задачи с pipelineName=${args.pipeline} и pipelineStepId).`,
|
|
2133
|
+
warnings: result.warnings,
|
|
2134
|
+
}),
|
|
2135
|
+
};
|
|
2136
|
+
}
|
|
2137
|
+
const yamlText = yamlStringify(result.spec, { lineWidth: 0 });
|
|
2138
|
+
return {
|
|
2139
|
+
content: JSON.stringify({
|
|
2140
|
+
success: true,
|
|
2141
|
+
pipeline: args.pipeline,
|
|
2142
|
+
steps: result.spec.steps.length,
|
|
2143
|
+
yaml: yamlText,
|
|
2144
|
+
warnings: result.warnings,
|
|
2145
|
+
}),
|
|
2146
|
+
};
|
|
2147
|
+
});
|
|
1886
2148
|
/**
|
|
1887
2149
|
* Перегенерирует env-файлы всех задач, привязанных к workspace (Спринт 21).
|
|
1888
2150
|
* Обёртки читают env-файл при запуске, поэтому перезапуск задач не нужен.
|
|
@@ -1895,8 +2157,14 @@ async function refreshWorkspaceEnvFiles(workspaceId) {
|
|
|
1895
2157
|
for (const task of await loadTaskDefinitions()) {
|
|
1896
2158
|
if (task.workspaceId !== workspaceId)
|
|
1897
2159
|
continue;
|
|
1898
|
-
|
|
1899
|
-
|
|
2160
|
+
try {
|
|
2161
|
+
writeWorkspaceEnvFile(workspace, PLUGIN_DIR, sanitizeName(task.name));
|
|
2162
|
+
refreshed += 1;
|
|
2163
|
+
}
|
|
2164
|
+
catch (err) {
|
|
2165
|
+
// P2-21: не разрешаем задаче работать с литералом ${secret:...}.
|
|
2166
|
+
console.error(`[workspace] Задача "${task.name}": env-файл не обновлён — ${err instanceof Error ? err.message : String(err)}`);
|
|
2167
|
+
}
|
|
1900
2168
|
}
|
|
1901
2169
|
return refreshed;
|
|
1902
2170
|
}
|
|
@@ -2390,7 +2658,16 @@ const transferTasksExecute = wrapExecute(async (args) => {
|
|
|
2390
2658
|
const errors = [...parsed.errors];
|
|
2391
2659
|
for (const def of parsed.tasks) {
|
|
2392
2660
|
try {
|
|
2393
|
-
await schedulerCreateTask(def.name, def.schedule, def.prompt, def.timeoutSeconds, def.workingDirectory ?? def.workdir, def.retryCount, def.retryDelay, def.qualityGate, def.nextTaskOnSuccess, def.nextTaskOnError, def.triggerType, def.watchPath, def.dependsOn, def.model, def.priority, def.beforeScript, def.afterScript, def.mcpEvent, def.workspaceId, def.allowedTools, def.deniedTools, def.matrix, def.matrixParentId, "create", def.timezone, def.notBefore, def.notAfter, def.pausedUntil, def.runAt
|
|
2661
|
+
await schedulerCreateTask(def.name, def.schedule, def.prompt, def.timeoutSeconds, def.workingDirectory ?? def.workdir, def.retryCount, def.retryDelay, def.qualityGate, def.nextTaskOnSuccess, def.nextTaskOnError, def.triggerType, def.watchPath, def.dependsOn, def.model, def.priority, def.beforeScript, def.afterScript, def.mcpEvent, def.workspaceId, def.allowedTools, def.deniedTools, def.matrix, def.matrixParentId, "create", def.timezone, def.notBefore, def.notAfter, def.pausedUntil, def.runAt, def.session, def.sessionId, def.sessionMaxRuns, {
|
|
2662
|
+
activeDays: def.activeDays,
|
|
2663
|
+
windowPolicy: def.windowPolicy,
|
|
2664
|
+
watchGlobs: def.watchGlobs,
|
|
2665
|
+
watchIgnore: def.watchIgnore,
|
|
2666
|
+
gitBranch: def.gitBranch,
|
|
2667
|
+
gitPaths: def.gitPaths,
|
|
2668
|
+
gitIgnore: def.gitIgnore,
|
|
2669
|
+
gitPollSeconds: def.gitPollSeconds,
|
|
2670
|
+
}, def.runWhenLoggedOff, def.paused, def.legacyShell, def.worktree, def.guards);
|
|
2394
2671
|
await saveTaskDefinition(def);
|
|
2395
2672
|
imported.push(def.name);
|
|
2396
2673
|
}
|
|
@@ -2563,6 +2840,11 @@ const RPC_AUDIT_RULES = {
|
|
|
2563
2840
|
update_task: { action: "task.update", targetType: "task", target: (i) => i.name ?? "" },
|
|
2564
2841
|
delete_task: { action: "task.delete", targetType: "task", target: (i) => i.name ?? "" },
|
|
2565
2842
|
run_task: { action: "task.run", targetType: "task", target: (i) => i.name ?? "" },
|
|
2843
|
+
run_mission: {
|
|
2844
|
+
action: "mission.run",
|
|
2845
|
+
targetType: "mission",
|
|
2846
|
+
target: (i) => i.taskName ?? "ad-hoc",
|
|
2847
|
+
},
|
|
2566
2848
|
pause_task: { action: "task.pause", targetType: "task", target: (i) => i.name ?? "" },
|
|
2567
2849
|
resume_task: { action: "task.resume", targetType: "task", target: (i) => i.name ?? "" },
|
|
2568
2850
|
cancel_matrix: { action: "matrix.cancel", targetType: "matrix", target: (i) => i.name ?? "" },
|
|
@@ -2576,6 +2858,18 @@ const RPC_AUDIT_RULES = {
|
|
|
2576
2858
|
targetType: "history",
|
|
2577
2859
|
target: () => "runs",
|
|
2578
2860
|
},
|
|
2861
|
+
retry_dlq: { action: "dlq.retry", targetType: "dlq", target: (i) => i.id ?? "" },
|
|
2862
|
+
discard_dlq: { action: "dlq.discard", targetType: "dlq", target: (i) => i.id ?? "" },
|
|
2863
|
+
pause_durable_run: {
|
|
2864
|
+
action: "run.pause",
|
|
2865
|
+
targetType: "run",
|
|
2866
|
+
target: (i) => i.runId ?? "",
|
|
2867
|
+
},
|
|
2868
|
+
resume_durable_run: {
|
|
2869
|
+
action: "run.resume",
|
|
2870
|
+
targetType: "run",
|
|
2871
|
+
target: (i) => i.runId ?? "",
|
|
2872
|
+
},
|
|
2579
2873
|
emit_event: { action: "event.emit", targetType: "event", target: (i) => i.eventName ?? "" },
|
|
2580
2874
|
add_workspace: {
|
|
2581
2875
|
action: "workspace.add",
|
|
@@ -2757,6 +3051,21 @@ export async function createRuntime(ctxLike) {
|
|
|
2757
3051
|
catch (err) {
|
|
2758
3052
|
console.error(`[recovery] Не удалось восстановить незавершённые запуски: ${err instanceof Error ? err.message : String(err)}`);
|
|
2759
3053
|
}
|
|
3054
|
+
// P1-14: pid:-записи fallback'а не переживают перезагрузку. Чистим их и
|
|
3055
|
+
// пересоздаём будущие one-shot, иначе после reboot можно убить чужой pid.
|
|
3056
|
+
if (scheduler instanceof LinuxScheduler) {
|
|
3057
|
+
try {
|
|
3058
|
+
const report = await scheduler.pruneStaleFallbacks();
|
|
3059
|
+
if (report.removed || report.rescheduled || report.missed) {
|
|
3060
|
+
console.log(`[scheduler] Fallback one-shot: удалено ${report.removed}, ` +
|
|
3061
|
+
`пересоздано ${report.rescheduled}, пропущено ${report.missed}, ` +
|
|
3062
|
+
`живо ${report.kept}.`);
|
|
3063
|
+
}
|
|
3064
|
+
}
|
|
3065
|
+
catch (err) {
|
|
3066
|
+
console.error(`[scheduler] Не удалось очистить fallback-записи: ${err instanceof Error ? err.message : String(err)}`);
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
2760
3069
|
checkJsonBackups();
|
|
2761
3070
|
void garbageCollectTaskArtifacts().catch((err) => {
|
|
2762
3071
|
console.log(`[gc] Не удалось вычистить мусорные файлы: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -2900,6 +3209,9 @@ export function createToolHandlers(_runtime) {
|
|
|
2900
3209
|
get_history: getHistoryExecute,
|
|
2901
3210
|
get_task_logs: getTaskLogsExecute,
|
|
2902
3211
|
dry_run: dryRunExecute,
|
|
3212
|
+
pipeline_validate: pipelineValidateExecute,
|
|
3213
|
+
pipeline_apply: pipelineApplyExecute,
|
|
3214
|
+
pipeline_export: pipelineExportExecute,
|
|
2903
3215
|
manage_workspaces: manageWorkspacesExecute,
|
|
2904
3216
|
matrix_control: matrixControlExecute,
|
|
2905
3217
|
get_metrics: getMetricsExecute,
|
|
@@ -3166,6 +3478,29 @@ export function createToolSpecs(runtime) {
|
|
|
3166
3478
|
"Filter by action, target, actor, time range and limit. Secret values are redacted.",
|
|
3167
3479
|
execute: handlers.get_audit_log,
|
|
3168
3480
|
},
|
|
3481
|
+
{
|
|
3482
|
+
name: "pipeline_validate",
|
|
3483
|
+
input: pipelineValidateSchema,
|
|
3484
|
+
description: "Проверяет opencode.pipeline.yaml (путь к файлу или исходник): валидирует version, шаги, зависимости, циклы, cron-расписание, matrix, модель, окна запуска и другие инварианты конвейера. Не применяет изменения.",
|
|
3485
|
+
execute: handlers.pipeline_validate,
|
|
3486
|
+
},
|
|
3487
|
+
{
|
|
3488
|
+
name: "pipeline_apply",
|
|
3489
|
+
input: pipelineApplySchema,
|
|
3490
|
+
description: "Применяет opencode.pipeline.yaml к текущему набору задач: создаёт новые, обновляет изменённые, пропускает без изменений (идемпотентно). Задачи без маркера pipelineName не трогаются. В режиме dryRun только отчитывает diff.",
|
|
3491
|
+
audit: (args) => ({
|
|
3492
|
+
action: "pipeline.apply",
|
|
3493
|
+
targetType: "pipeline",
|
|
3494
|
+
target: args.source ?? args.path ?? "",
|
|
3495
|
+
}),
|
|
3496
|
+
execute: handlers.pipeline_apply,
|
|
3497
|
+
},
|
|
3498
|
+
{
|
|
3499
|
+
name: "pipeline_export",
|
|
3500
|
+
input: pipelineExportSchema,
|
|
3501
|
+
description: "Выгружает задачи указанного конвейера (pipelineName) как opencode.pipeline.yaml: шаги, зависимости, matrix, кастомные настройки шага.",
|
|
3502
|
+
execute: handlers.pipeline_export,
|
|
3503
|
+
},
|
|
3169
3504
|
{
|
|
3170
3505
|
name: "emit_event",
|
|
3171
3506
|
input: emitEventSchema,
|
|
@@ -3250,7 +3585,7 @@ const v2Plugin = Plugin.define({
|
|
|
3250
3585
|
},
|
|
3251
3586
|
create_task: async (input) => {
|
|
3252
3587
|
console.log("[agent-steward] create_task input:", input);
|
|
3253
|
-
const { name, schedule, prompt, retryCount, retryDelay, qualityGate, nextTaskOnSuccess, nextTaskOnError, dependsOn, triggerType, watchPath, workingDirectory, model, priority, beforeScript, afterScript, mcpEvent, workspaceId, allowedTools, deniedTools, matrix, timezone, notBefore, notAfter, runAt, delaySeconds, session, sessionMaxRuns, runWhenLoggedOff, legacyShell, } = input;
|
|
3588
|
+
const { name, schedule, prompt, retryCount, retryDelay, qualityGate, nextTaskOnSuccess, nextTaskOnError, dependsOn, triggerType, watchPath, workingDirectory, model, priority, beforeScript, afterScript, mcpEvent, workspaceId, allowedTools, deniedTools, matrix, timezone, notBefore, notAfter, runAt, delaySeconds, session, sessionMaxRuns, runWhenLoggedOff, legacyShell, worktree, guards, } = input;
|
|
3254
3589
|
let effectiveRunAt;
|
|
3255
3590
|
if (triggerType === "once") {
|
|
3256
3591
|
const normalized = normalizeOneShotRunAt({ runAt, delaySeconds });
|
|
@@ -3273,7 +3608,7 @@ const v2Plugin = Plugin.define({
|
|
|
3273
3608
|
}
|
|
3274
3609
|
const effectiveSessionId = effectiveSession === "reuse" ? generateSessionId() : undefined;
|
|
3275
3610
|
try {
|
|
3276
|
-
await schedulerCreateTask(name, schedule ?? "", prompt, undefined, workingDirectory, retryCount, retryDelay, qualityGate, nextTaskOnSuccess, nextTaskOnError, triggerType, watchPath, dependsOn, model, priority, beforeScript, afterScript, mcpEvent, workspaceId, allowedTools, deniedTools, matrix, undefined, "create", timezone, notBefore, notAfter, undefined, effectiveRunAt, effectiveSession, effectiveSessionId, sessionMaxRuns, undefined, runWhenLoggedOff === true, undefined, legacyShell === true);
|
|
3611
|
+
await schedulerCreateTask(name, schedule ?? "", prompt, undefined, workingDirectory, retryCount, retryDelay, qualityGate, nextTaskOnSuccess, nextTaskOnError, triggerType, watchPath, dependsOn, model, priority, beforeScript, afterScript, mcpEvent, workspaceId, allowedTools, deniedTools, matrix, undefined, "create", timezone, notBefore, notAfter, undefined, effectiveRunAt, effectiveSession, effectiveSessionId, sessionMaxRuns, undefined, runWhenLoggedOff === true, undefined, legacyShell === true, worktree === true, guards);
|
|
3277
3612
|
const nextRun = computeTaskNextRun({
|
|
3278
3613
|
schedule: schedule ?? "",
|
|
3279
3614
|
triggerType: triggerType ?? "cron",
|
|
@@ -3400,6 +3735,38 @@ const v2Plugin = Plugin.define({
|
|
|
3400
3735
|
return { success: false, message: `schtasks error: ${err instanceof Error ? err.message : String(err)}` };
|
|
3401
3736
|
}
|
|
3402
3737
|
},
|
|
3738
|
+
run_mission: async (input) => {
|
|
3739
|
+
try {
|
|
3740
|
+
const mission = await runMission(input);
|
|
3741
|
+
return {
|
|
3742
|
+
success: mission.success,
|
|
3743
|
+
dryRun: mission.dryRun,
|
|
3744
|
+
runId: mission.runId ?? "",
|
|
3745
|
+
status: mission.status,
|
|
3746
|
+
description: mission.description,
|
|
3747
|
+
...(mission.error ? { error: mission.error } : {}),
|
|
3748
|
+
steps: mission.steps.map((step) => ({
|
|
3749
|
+
stepName: step.stepName,
|
|
3750
|
+
taskType: step.taskType,
|
|
3751
|
+
target: step.target,
|
|
3752
|
+
status: step.status,
|
|
3753
|
+
attempt: step.attempt,
|
|
3754
|
+
...(step.error ? { error: step.error } : {}),
|
|
3755
|
+
})),
|
|
3756
|
+
};
|
|
3757
|
+
}
|
|
3758
|
+
catch (err) {
|
|
3759
|
+
return {
|
|
3760
|
+
success: false,
|
|
3761
|
+
dryRun: false,
|
|
3762
|
+
runId: "",
|
|
3763
|
+
status: "failed",
|
|
3764
|
+
description: "",
|
|
3765
|
+
error: err instanceof Error ? err.message : String(err),
|
|
3766
|
+
steps: [],
|
|
3767
|
+
};
|
|
3768
|
+
}
|
|
3769
|
+
},
|
|
3403
3770
|
emit_event: async (input) => {
|
|
3404
3771
|
const { eventName, payload } = input;
|
|
3405
3772
|
const normalized = eventName?.trim();
|
|
@@ -3614,6 +3981,21 @@ const v2Plugin = Plugin.define({
|
|
|
3614
3981
|
}
|
|
3615
3982
|
return { success: allSuccess, reports };
|
|
3616
3983
|
},
|
|
3984
|
+
pipeline_validate: async (input) => {
|
|
3985
|
+
const { path, source, dryRun } = input;
|
|
3986
|
+
const result = await pipelineValidateExecute({ path, source, dryRun }, {});
|
|
3987
|
+
return JSON.parse(result.content);
|
|
3988
|
+
},
|
|
3989
|
+
pipeline_apply: async (input) => {
|
|
3990
|
+
const { path, source, dryRun } = input;
|
|
3991
|
+
const result = await pipelineApplyExecute({ path, source, dryRun }, {});
|
|
3992
|
+
return JSON.parse(result.content);
|
|
3993
|
+
},
|
|
3994
|
+
pipeline_export: async (input) => {
|
|
3995
|
+
const { pipeline } = input;
|
|
3996
|
+
const result = await pipelineExportExecute({ pipeline }, {});
|
|
3997
|
+
return JSON.parse(result.content);
|
|
3998
|
+
},
|
|
3617
3999
|
get_matrix_results: async (input) => {
|
|
3618
4000
|
const { parentId } = input;
|
|
3619
4001
|
const target = (parentId ?? "").trim();
|
|
@@ -3970,6 +4352,42 @@ const v2Plugin = Plugin.define({
|
|
|
3970
4352
|
});
|
|
3971
4353
|
return { success: true, ...result };
|
|
3972
4354
|
},
|
|
4355
|
+
list_dlq: async (input) => {
|
|
4356
|
+
const source = (input ?? {});
|
|
4357
|
+
return listDlq({ status: source.status, limit: source.limit });
|
|
4358
|
+
},
|
|
4359
|
+
retry_dlq: async (input) => {
|
|
4360
|
+
const source = (input ?? {});
|
|
4361
|
+
if (!source.id)
|
|
4362
|
+
return { success: false, error: "id is required" };
|
|
4363
|
+
return retryDlq(source.id);
|
|
4364
|
+
},
|
|
4365
|
+
discard_dlq: async (input) => {
|
|
4366
|
+
const source = (input ?? {});
|
|
4367
|
+
if (!source.id)
|
|
4368
|
+
return { success: false, error: "id is required" };
|
|
4369
|
+
return discardDlq(source.id, source.resolution);
|
|
4370
|
+
},
|
|
4371
|
+
list_durable_runs: async (input) => {
|
|
4372
|
+
const source = (input ?? {});
|
|
4373
|
+
return listRunPanel({ filter: source.filter, limit: source.limit });
|
|
4374
|
+
},
|
|
4375
|
+
pause_durable_run: async (input) => {
|
|
4376
|
+
const source = (input ?? {});
|
|
4377
|
+
if (!source.runId)
|
|
4378
|
+
return { success: false, error: "runId is required" };
|
|
4379
|
+
return pauseRunPanel(source.runId, {
|
|
4380
|
+
stepName: source.stepName,
|
|
4381
|
+
comment: source.comment,
|
|
4382
|
+
author: source.author,
|
|
4383
|
+
});
|
|
4384
|
+
},
|
|
4385
|
+
resume_durable_run: async (input) => {
|
|
4386
|
+
const source = (input ?? {});
|
|
4387
|
+
if (!source.runId)
|
|
4388
|
+
return { success: false, error: "runId is required" };
|
|
4389
|
+
return resumeRunPanel(source.runId);
|
|
4390
|
+
},
|
|
3973
4391
|
get_templates: async () => {
|
|
3974
4392
|
try {
|
|
3975
4393
|
return { templates: await loadTemplates() };
|
|
@@ -4066,7 +4484,7 @@ const v2Plugin = Plugin.define({
|
|
|
4066
4484
|
gitPaths: def.gitPaths,
|
|
4067
4485
|
gitIgnore: def.gitIgnore,
|
|
4068
4486
|
gitPollSeconds: def.gitPollSeconds,
|
|
4069
|
-
}, def.runWhenLoggedOff === true, def.paused === true, def.legacyShell === true);
|
|
4487
|
+
}, def.runWhenLoggedOff === true, def.paused === true, def.legacyShell === true, def.worktree === true, def.guards);
|
|
4070
4488
|
await saveTaskDefinition(def);
|
|
4071
4489
|
imported.push(def.name);
|
|
4072
4490
|
}
|
|
@@ -4236,7 +4654,7 @@ function resolveMatrixExtraConfig(name, matrix, ids) {
|
|
|
4236
4654
|
}
|
|
4237
4655
|
return extra;
|
|
4238
4656
|
}
|
|
4239
|
-
async function schedulerCreateTask(name, schedule, prompt, timeoutSeconds, workingDirectory, retryCount, retryDelay, qualityGate, nextTaskOnSuccess, nextTaskOnError, triggerType, watchPath, dependsOn, model, priority, beforeScript, afterScript, mcpEvent, workspaceId, allowedTools, deniedTools, matrix, matrixParentId,
|
|
4657
|
+
export async function schedulerCreateTask(name, schedule, prompt, timeoutSeconds, workingDirectory, retryCount, retryDelay, qualityGate, nextTaskOnSuccess, nextTaskOnError, triggerType, watchPath, dependsOn, model, priority, beforeScript, afterScript, mcpEvent, workspaceId, allowedTools, deniedTools, matrix, matrixParentId,
|
|
4240
4658
|
/** create — пересоздать клонов с нуля; sync — только diff (Спринт 17). */
|
|
4241
4659
|
matrixMode = "create",
|
|
4242
4660
|
/** IANA-зона задачи (Спринт 19). Не системная зона → poll-режим шлюза. */
|
|
@@ -4268,7 +4686,11 @@ paused,
|
|
|
4268
4686
|
* Спринт 32 / релиз 1.6: переходный флаг для гибридной политики.
|
|
4269
4687
|
* true возвращает shell задаче, созданной до обновления поведения.
|
|
4270
4688
|
*/
|
|
4271
|
-
legacyShell
|
|
4689
|
+
legacyShell,
|
|
4690
|
+
/** W-1: одноразовый git worktree на каждый запуск. */
|
|
4691
|
+
worktree,
|
|
4692
|
+
/** W-3: guard-условия перед запуском opencode. */
|
|
4693
|
+
guards) {
|
|
4272
4694
|
// Спринт 27.5 (hotfix 1.5.1): проверяем имя до создания wrapper/prompt и записи
|
|
4273
4695
|
// в БД. Недопустимые символы отклоняются с понятным сообщением, а не ошибкой
|
|
4274
4696
|
// schtasks; имя нормализуется (trim) для всех путей: MCP, RPC и импорт.
|
|
@@ -4297,6 +4719,15 @@ legacyShell) {
|
|
|
4297
4719
|
// Для отката файлов: при обновлении существующей задачи файлы переиспользуются,
|
|
4298
4720
|
// удалять их при сбое нельзя — в БД остаётся прежнее определение.
|
|
4299
4721
|
const definitionExisted = Boolean(getTask(normalizedName));
|
|
4722
|
+
// P1-10: при создании проверяем, что sanitized-имя не занято другой задачей
|
|
4723
|
+
// или её оставшимися файлами. Иначе «my task» и «my-task» делят
|
|
4724
|
+
// wrapper/prompt/lock/log, а вторая задача перезаписывает первую.
|
|
4725
|
+
if (!definitionExisted) {
|
|
4726
|
+
const conflict = findSanitizedNameConflict(normalizedName, listTaskDefinitions().map((def) => def.name));
|
|
4727
|
+
if (conflict) {
|
|
4728
|
+
throw new Error(sanitizedConflictMessage(normalizedName, conflict));
|
|
4729
|
+
}
|
|
4730
|
+
}
|
|
4300
4731
|
const normalizedModel = model?.trim() || undefined;
|
|
4301
4732
|
if (normalizedModel) {
|
|
4302
4733
|
const modelError = validateModelId(normalizedModel);
|
|
@@ -4315,6 +4746,14 @@ legacyShell) {
|
|
|
4315
4746
|
const normalizedRunWhenLoggedOff = runWhenLoggedOff === true ? true : undefined;
|
|
4316
4747
|
// Спринт 27.5.8: пауза сохраняется при пересоздании задачи.
|
|
4317
4748
|
const normalizedPaused = paused === true ? true : undefined;
|
|
4749
|
+
// W-1: изоляция запуска в одноразовом git worktree.
|
|
4750
|
+
const normalizedWorktree = worktree === true ? true : undefined;
|
|
4751
|
+
// W-3: guard-условия. Ошибка нормализации — явная ошибка создания задачи,
|
|
4752
|
+
// чтобы опечатка в конфигурации не превратилась в молчаливый пропуск.
|
|
4753
|
+
const guardsResult = normalizeTaskGuards(guards);
|
|
4754
|
+
if (!guardsResult.ok)
|
|
4755
|
+
throw new Error(guardsResult.error);
|
|
4756
|
+
const normalizedGuards = guardsResult.guards;
|
|
4318
4757
|
// Спринт 27: дни недели, политика окна и glob/git-фильтры.
|
|
4319
4758
|
const normalizeGlobList = (raw) => {
|
|
4320
4759
|
if (!Array.isArray(raw))
|
|
@@ -4493,6 +4932,23 @@ legacyShell) {
|
|
|
4493
4932
|
if (windowError) {
|
|
4494
4933
|
throw new Error(t("tool.error.window", { task: name, error: windowError }));
|
|
4495
4934
|
}
|
|
4935
|
+
// P2-24: cron может быть валидным, но никогда не попадать в окно запуска
|
|
4936
|
+
// (например, daily 09:00 при окне 22:00–06:00). Предупреждаем сразу при
|
|
4937
|
+
// создании: иначе задача молча не выполняется из-за лимита переноса 12 ч.
|
|
4938
|
+
if (normalizedNotBefore || normalizedNotAfter || normalizedActiveDays) {
|
|
4939
|
+
const feasibility = assessCronWindowFeasibility(schedule, {
|
|
4940
|
+
notBefore: normalizedNotBefore,
|
|
4941
|
+
notAfter: normalizedNotAfter,
|
|
4942
|
+
days: normalizedActiveDays,
|
|
4943
|
+
timeZone: normalizedTz || undefined,
|
|
4944
|
+
}, normalizedWindowPolicy);
|
|
4945
|
+
if (!feasibility.feasible) {
|
|
4946
|
+
console.warn(`[scheduler] Задача "${name}": ${t("dryRun.window.unreachable", {
|
|
4947
|
+
cron: schedule,
|
|
4948
|
+
reason: windowFeasibilityReasonText(feasibility.reason),
|
|
4949
|
+
})}`);
|
|
4950
|
+
}
|
|
4951
|
+
}
|
|
4496
4952
|
}
|
|
4497
4953
|
// Спринт 27: окно и дни недели применимы и к событийным триггерам
|
|
4498
4954
|
// (file/git/mcp-event/once) — проверяем корректность до создания задачи.
|
|
@@ -4589,7 +5045,7 @@ legacyShell) {
|
|
|
4589
5045
|
try {
|
|
4590
5046
|
if (scheduler.platform === "win32") {
|
|
4591
5047
|
await ensureWrapper();
|
|
4592
|
-
wrapperPath = await writeWrapperCmd(sanitized, name, promptFile, timeoutSeconds ?? 3600, lockFile, effectiveWorkingDirectory, logFile, recorderPath, qualityGate, normalizedModel, normalizedBefore, normalizedAfter, workspace?.name, normalizedAllowedTools, normalizedDeniedTools, wrapperGate, taskEnvFile, effectiveSession, effectiveSessionId,
|
|
5048
|
+
wrapperPath = await writeWrapperCmd(sanitized, name, promptFile, timeoutSeconds ?? 3600, lockFile, effectiveWorkingDirectory, logFile, recorderPath, qualityGate, normalizedModel, normalizedBefore, normalizedAfter, workspace?.name, normalizedAllowedTools, normalizedDeniedTools, wrapperGate, taskEnvFile, effectiveSession, effectiveSessionId, undefined, permissionsConfig, policyMeta, sessionFile, normalizedWorktree, worktreeHelperPath, normalizedGuards, guardHelperPath);
|
|
4593
5049
|
}
|
|
4594
5050
|
else {
|
|
4595
5051
|
wrapperPath = await writeBashWrapper({
|
|
@@ -4615,6 +5071,10 @@ legacyShell) {
|
|
|
4615
5071
|
sessionMode: effectiveSession,
|
|
4616
5072
|
sessionId: effectiveSessionId,
|
|
4617
5073
|
sessionFile,
|
|
5074
|
+
worktree: normalizedWorktree,
|
|
5075
|
+
worktreeHelper: worktreeHelperPath,
|
|
5076
|
+
guards: normalizedGuards,
|
|
5077
|
+
guardHelper: guardHelperPath,
|
|
4618
5078
|
...(effectiveTriggerType === "once" && scheduler.platform === "darwin"
|
|
4619
5079
|
? { oneShotCleanupCommand: buildLaunchdOneShotCleanup(sanitized, getProfileName()) }
|
|
4620
5080
|
: {}),
|
|
@@ -4742,6 +5202,8 @@ legacyShell) {
|
|
|
4742
5202
|
allowedTools: normalizedAllowedTools,
|
|
4743
5203
|
deniedTools: normalizedDeniedTools,
|
|
4744
5204
|
legacyShell: legacyShell === true ? true : undefined,
|
|
5205
|
+
worktree: normalizedWorktree,
|
|
5206
|
+
guards: normalizedGuards,
|
|
4745
5207
|
matrix: normalizedMatrix,
|
|
4746
5208
|
isMatrixParent: normalizedMatrix ? true : undefined,
|
|
4747
5209
|
matrixParentId,
|
|
@@ -4773,7 +5235,7 @@ legacyShell) {
|
|
|
4773
5235
|
// с нуля, а синхронизируются с новым определением; выполняющиеся — не трогаем.
|
|
4774
5236
|
if (normalizedMatrix) {
|
|
4775
5237
|
const createClone = async (clone) => {
|
|
4776
|
-
await schedulerCreateTask(clone.name, clone.schedule, clone.prompt, clone.timeoutSeconds, undefined, clone.retryCount, clone.retryDelay, clone.qualityGate, undefined, undefined, "file", undefined, undefined, clone.model, clone.priority, clone.beforeScript, clone.afterScript, undefined, clone.workspaceId, clone.allowedTools, clone.deniedTools, undefined, name, "create", clone.timezone, clone.notBefore, clone.notAfter, clone.pausedUntil, clone.runAt, clone.session, clone.sessionId, clone.sessionMaxRuns, undefined, clone.runWhenLoggedOff, clone.paused, clone.legacyShell);
|
|
5238
|
+
await schedulerCreateTask(clone.name, clone.schedule, clone.prompt, clone.timeoutSeconds, undefined, clone.retryCount, clone.retryDelay, clone.qualityGate, undefined, undefined, "file", undefined, undefined, clone.model, clone.priority, clone.beforeScript, clone.afterScript, undefined, clone.workspaceId, clone.allowedTools, clone.deniedTools, undefined, name, "create", clone.timezone, clone.notBefore, clone.notAfter, clone.pausedUntil, clone.runAt, clone.session, clone.sessionId, clone.sessionMaxRuns, undefined, clone.runWhenLoggedOff, clone.paused, clone.legacyShell, clone.worktree, clone.guards);
|
|
4777
5239
|
};
|
|
4778
5240
|
const removeChild = async (child) => {
|
|
4779
5241
|
try {
|
|
@@ -4924,7 +5386,7 @@ async function recreateTaskFromDefinition(definition) {
|
|
|
4924
5386
|
gitPaths: definition.gitPaths,
|
|
4925
5387
|
gitIgnore: definition.gitIgnore,
|
|
4926
5388
|
gitPollSeconds: definition.gitPollSeconds,
|
|
4927
|
-
}, definition.runWhenLoggedOff, paused, definition.legacyShell);
|
|
5389
|
+
}, definition.runWhenLoggedOff, paused, definition.legacyShell, definition.worktree, definition.guards);
|
|
4928
5390
|
}
|
|
4929
5391
|
/**
|
|
4930
5392
|
* Запуск задачи «как есть», но с учётом матрицы: родитель раскладывается
|