agent-steward 0.0.4 → 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 +134 -2
- package/CROSS_PLATFORM.md +19 -0
- package/README.md +52 -7
- package/ROADMAP-STRATEGY.md +21 -18
- package/ROADMAP.md +140 -159
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +351 -0
- 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 +41 -0
- package/dist/core/lock.d.ts.map +1 -1
- package/dist/core/lock.js +141 -29
- 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/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 +250 -62
- package/dist/core/record-history.d.ts.map +1 -1
- package/dist/core/record-history.js +130 -29
- package/dist/core/router/rules.d.ts.map +1 -1
- package/dist/core/router/rules.js +6 -0
- package/dist/core/scheduler/linux.d.ts +8 -1
- package/dist/core/scheduler/linux.d.ts.map +1 -1
- package/dist/core/scheduler/linux.js +34 -9
- 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/windows.d.ts.map +1 -1
- package/dist/core/scheduler/windows.js +15 -12
- package/dist/core/structured-log.d.ts +7 -1
- package/dist/core/structured-log.d.ts.map +1 -1
- 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 +175 -24
- package/dist/db/capability-repo.d.ts +43 -2
- package/dist/db/capability-repo.d.ts.map +1 -1
- package/dist/db/capability-repo.js +96 -11
- package/dist/db/history-repo.d.ts +38 -5
- package/dist/db/history-repo.d.ts.map +1 -1
- package/dist/db/history-repo.js +88 -25
- package/dist/db/metrics-repo.js +2 -2
- package/dist/db/recovery.d.ts.map +1 -1
- package/dist/db/recovery.js +5 -4
- 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 +5 -0
- package/dist/db/run-resume.d.ts.map +1 -1
- package/dist/db/run-resume.js +9 -2
- package/dist/db/runs-repo.d.ts +19 -2
- package/dist/db/runs-repo.d.ts.map +1 -1
- package/dist/db/runs-repo.js +22 -6
- package/dist/db/schema.d.ts +2 -2
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +63 -2
- 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 +136 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +378 -14
- 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 +246 -0
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +117 -0
- package/dist/server.d.ts +15 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +77 -18
- 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/docs/ARCHITECTURE.md +281 -65
- package/docs/COMPATIBILITY.md +2 -2
- package/docs/CONCEPT.md +18 -4
- package/docs/CROSS_PLATFORM.ru.md +20 -0
- package/docs/CROSS_PLATFORM.zh.md +18 -0
- package/docs/EXECUTION-LOOP.md +22 -7
- 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 +42 -3
- package/docs/README.zh.md +43 -3
- package/docs/SAFETY.md +23 -3
- package/gui-experimental.cjs +9 -8
- package/locales/en.json +17 -1
- package/locales/ru.json +17 -1
- package/locales/zh.json +17 -1
- package/opencode.pipeline.yaml +35 -0
- package/package.json +23 -4
- package/scripts/test-home.mjs +83 -0
- package/src/cli.ts +412 -0
- package/src/core/dry-run.ts +2 -2
- 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 +178 -37
- 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/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 +263 -63
- package/src/core/record-history.ts +164 -77
- package/src/core/router/rules.ts +6 -0
- package/src/core/schedule-gate.ts +1 -1
- package/src/core/scheduler/at-fallback.ts +1 -1
- package/src/core/scheduler/linux.ts +40 -11
- package/src/core/scheduler/logs.ts +2 -2
- package/src/core/scheduler/mac.ts +174 -14
- package/src/core/scheduler/registry.ts +2 -2
- package/src/core/scheduler/windows.ts +19 -15
- package/src/core/secrets.ts +8 -8
- package/src/core/structured-log.ts +22 -5
- 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 +190 -23
- package/src/db/capability-repo.ts +127 -10
- package/src/db/history-repo.ts +129 -22
- package/src/db/metrics-repo.ts +2 -2
- package/src/db/recovery.ts +5 -4
- package/src/db/run-journal.ts +100 -13
- package/src/db/run-resume.ts +17 -1
- package/src/db/runs-repo.ts +36 -6
- package/src/db/schema.ts +65 -2
- package/src/gui.tsx +177 -13
- package/src/history.ts +1 -1
- package/src/i18n.ts +12 -4
- package/src/index.ts +524 -4
- package/src/notifications.ts +38 -8
- package/src/profiles.ts +26 -4
- package/src/rpc.ts +128 -0
- package/src/server.ts +94 -18
- package/src/settings.ts +5 -5
- package/src/shared/jobs-view.ts +3 -1
- package/src/task-transfer.ts +31 -0
package/src/index.ts
CHANGED
|
@@ -41,6 +41,7 @@ import { SCHEDULER_SKILL_ID, loadSchedulerSkill } from "./skill.js";
|
|
|
41
41
|
import { getTaskLogs } from "./core/scheduler/logs.js";
|
|
42
42
|
import { findSanitizedNameConflict, sanitizedConflictMessage } from "./core/task-name.js";
|
|
43
43
|
import { writeBashWrapper } from "./core/wrappers/bash.js";
|
|
44
|
+
import { normalizeTaskGuards, type TaskGuards } from "./core/guard.js";
|
|
44
45
|
import { simulatePipeline } from "./core/dry-run.js";
|
|
45
46
|
import {
|
|
46
47
|
aggregateMatrixResults,
|
|
@@ -57,6 +58,22 @@ import {
|
|
|
57
58
|
import { normalizeWatchPath, validateWatchGlobs } from "./core/watch-paths.js";
|
|
58
59
|
import { createShutdownGate } from "./core/shutdown.js";
|
|
59
60
|
import { SchedulerRpc } from "./rpc.js";
|
|
61
|
+
import {
|
|
62
|
+
validatePipelineSpec,
|
|
63
|
+
type PipelineValidationResult,
|
|
64
|
+
} from "./core/pipeline-spec.js";
|
|
65
|
+
import {
|
|
66
|
+
loadPipelineFile,
|
|
67
|
+
parsePipelineYaml,
|
|
68
|
+
type PipelineParseResult,
|
|
69
|
+
} from "./core/pipeline-io.js";
|
|
70
|
+
import {
|
|
71
|
+
planPipelineApply,
|
|
72
|
+
executePipelineApply,
|
|
73
|
+
type PipelineApplyPlan,
|
|
74
|
+
} from "./core/pipeline-apply.js";
|
|
75
|
+
import { pipelineSpecToTasks, tasksToPipelineSpec } from "./core/pipeline-map.js";
|
|
76
|
+
import { stringify as yamlStringify } from "yaml";
|
|
60
77
|
import { latestHistoryByTask, loadHistory, loadMetrics } from "./history.js";
|
|
61
78
|
import { defaultNotifications, loadSettings, saveSettings } from "./settings.js";
|
|
62
79
|
import { resolveLocale, setLocale, t, type Locale, type LocaleMode } from "./i18n.js";
|
|
@@ -68,6 +85,7 @@ import type {
|
|
|
68
85
|
PermissionSettings,
|
|
69
86
|
TriageSettings,
|
|
70
87
|
} from "./settings.js";
|
|
88
|
+
import { runMission, type MissionSpec } from "./core/mission.js";
|
|
71
89
|
import {
|
|
72
90
|
DEFAULT_PERMISSION_POLICY,
|
|
73
91
|
buildOpencodeConfig,
|
|
@@ -204,6 +222,41 @@ const gatePath = (() => {
|
|
|
204
222
|
return distPath;
|
|
205
223
|
})();
|
|
206
224
|
|
|
225
|
+
/**
|
|
226
|
+
* W-1: путь к помощнику создания одноразового git worktree
|
|
227
|
+
* (dist/core/worktree-run.js). Обёртка вызывает его перед opencode.
|
|
228
|
+
*/
|
|
229
|
+
const worktreeHelperPath = (() => {
|
|
230
|
+
const resolved = require.resolve("./core/worktree-run.js");
|
|
231
|
+
if (!resolved.endsWith(".ts")) return resolved;
|
|
232
|
+
const distPath = resolved
|
|
233
|
+
.replace(/([\\/])src([\\/])/, "$1dist$2")
|
|
234
|
+
.replace(/\.ts$/, ".js");
|
|
235
|
+
if (existsSync(distPath)) return distPath;
|
|
236
|
+
console.warn(
|
|
237
|
+
"[agent-steward] Не найден собранный worktree-run.js: " +
|
|
238
|
+
`${distPath}. Изоляция в git worktree не будет работать. Выполните npm run build.`,
|
|
239
|
+
);
|
|
240
|
+
return distPath;
|
|
241
|
+
})();
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* W-3: путь к CLI-помощнику guard-условий (dist/core/guard-run.js).
|
|
245
|
+
*/
|
|
246
|
+
const guardHelperPath = (() => {
|
|
247
|
+
const resolved = require.resolve("./core/guard-run.js");
|
|
248
|
+
if (!resolved.endsWith(".ts")) return resolved;
|
|
249
|
+
const distPath = resolved
|
|
250
|
+
.replace(/([\\/])src([\\/])/, "$1dist$2")
|
|
251
|
+
.replace(/\.ts$/, ".js");
|
|
252
|
+
if (existsSync(distPath)) return distPath;
|
|
253
|
+
console.warn(
|
|
254
|
+
"[agent-steward] Не найден собранный guard-run.js: " +
|
|
255
|
+
`${distPath}. Guard-условия не будут проверяться. Выполните npm run build.`,
|
|
256
|
+
);
|
|
257
|
+
return distPath;
|
|
258
|
+
})();
|
|
259
|
+
|
|
207
260
|
/** Бэкенд планировщика текущей ОС (schtasks / crontab / launchd). */
|
|
208
261
|
const scheduler = getSchedulerBackend();
|
|
209
262
|
|
|
@@ -259,6 +312,40 @@ export const matrixSchema = z.object({
|
|
|
259
312
|
),
|
|
260
313
|
});
|
|
261
314
|
|
|
315
|
+
/** W-3: guard-условия задачи. */
|
|
316
|
+
export const guardsSchema = z.object({
|
|
317
|
+
command: z
|
|
318
|
+
.string()
|
|
319
|
+
.max(4000)
|
|
320
|
+
.optional()
|
|
321
|
+
.describe("Shell command evaluated before the run. Exit 0 runs the task; any other code skips it."),
|
|
322
|
+
timeoutSeconds: z
|
|
323
|
+
.number()
|
|
324
|
+
.int()
|
|
325
|
+
.min(1)
|
|
326
|
+
.max(3600)
|
|
327
|
+
.optional()
|
|
328
|
+
.describe("Shell guard timeout in seconds (default 60)."),
|
|
329
|
+
semantic: z
|
|
330
|
+
.object({
|
|
331
|
+
filesExist: z.array(z.string()).max(200).optional().describe("Paths that must exist."),
|
|
332
|
+
filesMissing: z.array(z.string()).max(200).optional().describe("Paths that must not exist."),
|
|
333
|
+
branch: z.string().max(200).optional().describe("Glob for the current git branch, e.g. feature/*."),
|
|
334
|
+
changedPaths: z
|
|
335
|
+
.array(z.string())
|
|
336
|
+
.max(200)
|
|
337
|
+
.optional()
|
|
338
|
+
.describe("Globs of changed paths; at least one must match."),
|
|
339
|
+
changedSince: z
|
|
340
|
+
.string()
|
|
341
|
+
.max(100)
|
|
342
|
+
.optional()
|
|
343
|
+
.describe("Git ref to diff against (default HEAD~1)."),
|
|
344
|
+
})
|
|
345
|
+
.optional()
|
|
346
|
+
.describe("Semantic pre-run checks inside the working directory."),
|
|
347
|
+
}).describe("W-3: guard conditions. If a check fails, the run is skipped before opencode starts.");
|
|
348
|
+
|
|
262
349
|
/** Zod-схема аргументов schedule_task */
|
|
263
350
|
export const scheduleTaskSchema = z.object({
|
|
264
351
|
name: z
|
|
@@ -478,6 +565,17 @@ export const scheduleTaskSchema = z.object({
|
|
|
478
565
|
.describe(
|
|
479
566
|
"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.",
|
|
480
567
|
),
|
|
568
|
+
worktree: z
|
|
569
|
+
.boolean()
|
|
570
|
+
.optional()
|
|
571
|
+
.describe(
|
|
572
|
+
"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.",
|
|
573
|
+
),
|
|
574
|
+
guards: guardsSchema
|
|
575
|
+
.optional()
|
|
576
|
+
.describe(
|
|
577
|
+
"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.",
|
|
578
|
+
),
|
|
481
579
|
matrix: matrixSchema
|
|
482
580
|
.optional()
|
|
483
581
|
.describe(
|
|
@@ -692,6 +790,15 @@ export const updateTaskSchema = z.object({
|
|
|
692
790
|
.describe(
|
|
693
791
|
"Transitional flag (release 1.6): re-enable shell under the hybrid policy for this task.",
|
|
694
792
|
),
|
|
793
|
+
worktree: z
|
|
794
|
+
.boolean()
|
|
795
|
+
.optional()
|
|
796
|
+
.describe(
|
|
797
|
+
"W-1: run each tick in a one-off git worktree created from HEAD of workingDirectory. Default false.",
|
|
798
|
+
),
|
|
799
|
+
guards: guardsSchema
|
|
800
|
+
.optional()
|
|
801
|
+
.describe("W-3: pre-run guard conditions; a failed check skips the run."),
|
|
695
802
|
matrix: matrixSchema
|
|
696
803
|
.nullable()
|
|
697
804
|
.optional()
|
|
@@ -765,6 +872,33 @@ const dryRunSchema = z.object({
|
|
|
765
872
|
),
|
|
766
873
|
});
|
|
767
874
|
|
|
875
|
+
/** pipeline_validate — проверить опencode.pipeline.yaml (путь или исходник). */
|
|
876
|
+
export const pipelineValidateSchema = z.object({
|
|
877
|
+
path: z.string().optional().describe("Путь к файлу opencode.pipeline.yaml."),
|
|
878
|
+
source: z.string().optional().describe("Исходное содержимое YAML."),
|
|
879
|
+
dryRun: z
|
|
880
|
+
.boolean()
|
|
881
|
+
.optional()
|
|
882
|
+
.default(true)
|
|
883
|
+
.describe("Если true — только валидация без применения (по умолчанию true)."),
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
/** pipeline_apply — применить opencode.pipeline.yaml к текущему набору задач. */
|
|
887
|
+
export const pipelineApplySchema = z.object({
|
|
888
|
+
path: z.string().optional().describe("Путь к файлу opencode.pipeline.yaml."),
|
|
889
|
+
source: z.string().optional().describe("Исходное содержимое YAML."),
|
|
890
|
+
dryRun: z
|
|
891
|
+
.boolean()
|
|
892
|
+
.optional()
|
|
893
|
+
.default(false)
|
|
894
|
+
.describe("Если true — прогон diff'а без применения изменений (по умолчанию false)."),
|
|
895
|
+
});
|
|
896
|
+
|
|
897
|
+
/** pipeline_export — выгрузить задачи конвейера как opencode.pipeline.yaml. */
|
|
898
|
+
export const pipelineExportSchema = z.object({
|
|
899
|
+
pipeline: z.string().describe("Имя конвейера (pipelineName)."),
|
|
900
|
+
});
|
|
901
|
+
|
|
768
902
|
const manageWorkspacesSchema = z.object({
|
|
769
903
|
action: z
|
|
770
904
|
.enum(["list", "add", "update", "delete"])
|
|
@@ -882,7 +1016,7 @@ export const manageSettingsSchema = z.object({
|
|
|
882
1016
|
.enum(["auto", "ru", "en", "zh"])
|
|
883
1017
|
.optional()
|
|
884
1018
|
.describe(
|
|
885
|
-
"Interface language: auto (
|
|
1019
|
+
"Interface language: auto (default, follows OpenCode), ru, en or zh. Applies without restart.",
|
|
886
1020
|
),
|
|
887
1021
|
winterMode: z
|
|
888
1022
|
.boolean()
|
|
@@ -1105,6 +1239,9 @@ type CleanupHistoryArgs = z.infer<typeof cleanupHistorySchema>;
|
|
|
1105
1239
|
type EmitEventArgs = z.infer<typeof emitEventSchema>;
|
|
1106
1240
|
type SecretsArgs = z.infer<typeof manageSecretsSchema>;
|
|
1107
1241
|
type AuditLogArgs = z.infer<typeof getAuditLogSchema>;
|
|
1242
|
+
type PipelineValidateArgs = z.infer<typeof pipelineValidateSchema>;
|
|
1243
|
+
type PipelineApplyArgs = z.infer<typeof pipelineApplySchema>;
|
|
1244
|
+
type PipelineExportArgs = z.infer<typeof pipelineExportSchema>;
|
|
1108
1245
|
|
|
1109
1246
|
/**
|
|
1110
1247
|
* Директория проекта, в которой запущен OpenCode. Используется как рабочая
|
|
@@ -1260,6 +1397,8 @@ const scheduleTaskExecute = wrapExecute<ScheduleArgs>(async (args) => {
|
|
|
1260
1397
|
gitPollSeconds,
|
|
1261
1398
|
runWhenLoggedOff,
|
|
1262
1399
|
legacyShell,
|
|
1400
|
+
worktree,
|
|
1401
|
+
guards,
|
|
1263
1402
|
} = args;
|
|
1264
1403
|
|
|
1265
1404
|
let effectiveRunAt: string | undefined;
|
|
@@ -1328,6 +1467,8 @@ const scheduleTaskExecute = wrapExecute<ScheduleArgs>(async (args) => {
|
|
|
1328
1467
|
runWhenLoggedOff === true,
|
|
1329
1468
|
undefined,
|
|
1330
1469
|
legacyShell === true,
|
|
1470
|
+
worktree === true,
|
|
1471
|
+
guards,
|
|
1331
1472
|
);
|
|
1332
1473
|
} catch (err: any) {
|
|
1333
1474
|
return {
|
|
@@ -1394,6 +1535,8 @@ const scheduleTaskExecute = wrapExecute<ScheduleArgs>(async (args) => {
|
|
|
1394
1535
|
workspaceId: workspace?.id ?? null,
|
|
1395
1536
|
workspaceName: workspace?.name ?? null,
|
|
1396
1537
|
matrix: matrix ?? null,
|
|
1538
|
+
worktree: worktree === true,
|
|
1539
|
+
guards: guards ?? null,
|
|
1397
1540
|
},
|
|
1398
1541
|
}),
|
|
1399
1542
|
};
|
|
@@ -1507,6 +1650,8 @@ async function cancelMatrixRun(
|
|
|
1507
1650
|
clone.runWhenLoggedOff,
|
|
1508
1651
|
clone.paused,
|
|
1509
1652
|
clone.legacyShell,
|
|
1653
|
+
clone.worktree,
|
|
1654
|
+
clone.guards,
|
|
1510
1655
|
);
|
|
1511
1656
|
} catch (err: any) {
|
|
1512
1657
|
warnings.push(
|
|
@@ -2019,6 +2164,8 @@ async function updateTaskFromInput(
|
|
|
2019
2164
|
input.runWhenLoggedOff ?? previous.runWhenLoggedOff,
|
|
2020
2165
|
wasPaused,
|
|
2021
2166
|
input.legacyShell ?? previous.legacyShell,
|
|
2167
|
+
input.worktree ?? previous.worktree,
|
|
2168
|
+
input.guards ?? previous.guards,
|
|
2022
2169
|
);
|
|
2023
2170
|
|
|
2024
2171
|
// Матрица отключена при обновлении — убираем клонов и агрегатор.
|
|
@@ -2445,6 +2592,239 @@ const dryRunExecute = wrapExecute<DryRunArgs>(async (args) => {
|
|
|
2445
2592
|
};
|
|
2446
2593
|
});
|
|
2447
2594
|
|
|
2595
|
+
/** pipeline_validate — проверить opencode.pipeline.yaml (путь или исходник). */
|
|
2596
|
+
const pipelineValidateExecute = wrapExecute<PipelineValidateArgs>(async (args) => {
|
|
2597
|
+
const path = args.path ?? args.source ? undefined : undefined;
|
|
2598
|
+
if (args.path === undefined && args.source === undefined) {
|
|
2599
|
+
return {
|
|
2600
|
+
content: JSON.stringify({
|
|
2601
|
+
success: false,
|
|
2602
|
+
pipeline: null,
|
|
2603
|
+
errors: ["Укажите path к файлу или source с содержимым YAML"],
|
|
2604
|
+
warnings: [],
|
|
2605
|
+
}),
|
|
2606
|
+
};
|
|
2607
|
+
}
|
|
2608
|
+
const parsed =
|
|
2609
|
+
args.source !== undefined
|
|
2610
|
+
? validatePipelineSpecFromSource(args.source)
|
|
2611
|
+
: await loadPipelineFile(args.path!);
|
|
2612
|
+
if (!parsed.ok) {
|
|
2613
|
+
return {
|
|
2614
|
+
content: JSON.stringify({
|
|
2615
|
+
success: false,
|
|
2616
|
+
pipeline: null,
|
|
2617
|
+
errors: parsed.errors,
|
|
2618
|
+
warnings: parsed.warnings,
|
|
2619
|
+
}),
|
|
2620
|
+
};
|
|
2621
|
+
}
|
|
2622
|
+
const spec = parsed.spec!;
|
|
2623
|
+
return {
|
|
2624
|
+
content: JSON.stringify({
|
|
2625
|
+
success: true,
|
|
2626
|
+
pipeline: spec.name,
|
|
2627
|
+
steps: spec.steps.length,
|
|
2628
|
+
errors: [],
|
|
2629
|
+
warnings: parsed.warnings,
|
|
2630
|
+
}),
|
|
2631
|
+
};
|
|
2632
|
+
});
|
|
2633
|
+
|
|
2634
|
+
function validatePipelineSpecFromSource(source: string): PipelineParseResult {
|
|
2635
|
+
const parsed = parsePipelineYaml(source);
|
|
2636
|
+
return parsed;
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
/** pipeline_apply — применить opencode.pipeline.yaml к текущему набору задач. */
|
|
2640
|
+
const pipelineApplyExecute = wrapExecute<PipelineApplyArgs>(async (args) => {
|
|
2641
|
+
const dryRun = args.dryRun !== false;
|
|
2642
|
+
const parsed =
|
|
2643
|
+
args.source !== undefined
|
|
2644
|
+
? validatePipelineSpecFromSource(args.source)
|
|
2645
|
+
: await loadPipelineFile(args.path!);
|
|
2646
|
+
if (!parsed.ok) {
|
|
2647
|
+
return {
|
|
2648
|
+
content: JSON.stringify({
|
|
2649
|
+
success: false,
|
|
2650
|
+
pipeline: null,
|
|
2651
|
+
errors: parsed.errors,
|
|
2652
|
+
warnings: parsed.warnings,
|
|
2653
|
+
}),
|
|
2654
|
+
};
|
|
2655
|
+
}
|
|
2656
|
+
|
|
2657
|
+
const spec = parsed.spec!;
|
|
2658
|
+
const existing = await listTaskDefinitions();
|
|
2659
|
+
const plan = planPipelineApply(spec, existing, {
|
|
2660
|
+
resolveWorkspaceId: (nameOrId: string) => {
|
|
2661
|
+
const ws = getWorkspace(nameOrId);
|
|
2662
|
+
return ws ? ws.id : undefined;
|
|
2663
|
+
},
|
|
2664
|
+
});
|
|
2665
|
+
|
|
2666
|
+
let created = 0;
|
|
2667
|
+
let updated = 0;
|
|
2668
|
+
const errors: string[] = [];
|
|
2669
|
+
|
|
2670
|
+
if (!dryRun) {
|
|
2671
|
+
for (const task of plan.creates) {
|
|
2672
|
+
try {
|
|
2673
|
+
await schedulerCreateTask(
|
|
2674
|
+
task.name,
|
|
2675
|
+
task.schedule,
|
|
2676
|
+
task.prompt,
|
|
2677
|
+
task.timeoutSeconds,
|
|
2678
|
+
task.workingDirectory ?? task.workdir ?? undefined,
|
|
2679
|
+
task.retryCount,
|
|
2680
|
+
task.retryDelay,
|
|
2681
|
+
task.qualityGate,
|
|
2682
|
+
task.nextTaskOnSuccess,
|
|
2683
|
+
task.nextTaskOnError,
|
|
2684
|
+
task.triggerType ?? "cron",
|
|
2685
|
+
task.watchPath,
|
|
2686
|
+
task.dependsOn,
|
|
2687
|
+
task.model,
|
|
2688
|
+
task.priority,
|
|
2689
|
+
task.beforeScript,
|
|
2690
|
+
task.afterScript,
|
|
2691
|
+
task.mcpEvent,
|
|
2692
|
+
task.workspaceId,
|
|
2693
|
+
task.allowedTools,
|
|
2694
|
+
task.deniedTools,
|
|
2695
|
+
task.matrix,
|
|
2696
|
+
task.matrixParentId,
|
|
2697
|
+
"create",
|
|
2698
|
+
task.timezone,
|
|
2699
|
+
task.notBefore,
|
|
2700
|
+
task.notAfter,
|
|
2701
|
+
task.pausedUntil,
|
|
2702
|
+
task.runAt,
|
|
2703
|
+
task.session,
|
|
2704
|
+
task.sessionId,
|
|
2705
|
+
task.sessionMaxRuns,
|
|
2706
|
+
{
|
|
2707
|
+
activeDays: task.activeDays,
|
|
2708
|
+
windowPolicy: task.windowPolicy,
|
|
2709
|
+
watchGlobs: task.watchGlobs ?? [],
|
|
2710
|
+
watchIgnore: task.watchIgnore ?? [],
|
|
2711
|
+
gitBranch: task.gitBranch,
|
|
2712
|
+
gitPaths: task.gitPaths,
|
|
2713
|
+
gitIgnore: task.gitIgnore,
|
|
2714
|
+
gitPollSeconds: task.gitPollSeconds,
|
|
2715
|
+
},
|
|
2716
|
+
task.runWhenLoggedOff ?? false,
|
|
2717
|
+
task.paused ?? false,
|
|
2718
|
+
task.legacyShell ?? false,
|
|
2719
|
+
task.worktree ?? false,
|
|
2720
|
+
task.guards,
|
|
2721
|
+
);
|
|
2722
|
+
await saveTaskDefinition(task);
|
|
2723
|
+
created++;
|
|
2724
|
+
} catch (err: any) {
|
|
2725
|
+
errors.push(`create ${task.name}: ${err instanceof Error ? err.message : String(err)}`);
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
for (const item of plan.updates) {
|
|
2729
|
+
try {
|
|
2730
|
+
await schedulerCreateTask(
|
|
2731
|
+
item.task.name,
|
|
2732
|
+
item.task.schedule,
|
|
2733
|
+
item.task.prompt,
|
|
2734
|
+
item.task.timeoutSeconds,
|
|
2735
|
+
item.task.workingDirectory ?? item.task.workdir ?? undefined,
|
|
2736
|
+
item.task.retryCount,
|
|
2737
|
+
item.task.retryDelay,
|
|
2738
|
+
item.task.qualityGate,
|
|
2739
|
+
item.task.nextTaskOnSuccess,
|
|
2740
|
+
item.task.nextTaskOnError,
|
|
2741
|
+
item.task.triggerType ?? "cron",
|
|
2742
|
+
item.task.watchPath,
|
|
2743
|
+
item.task.dependsOn,
|
|
2744
|
+
item.task.model,
|
|
2745
|
+
item.task.priority,
|
|
2746
|
+
item.task.beforeScript,
|
|
2747
|
+
item.task.afterScript,
|
|
2748
|
+
item.task.mcpEvent,
|
|
2749
|
+
item.task.workspaceId,
|
|
2750
|
+
item.task.allowedTools,
|
|
2751
|
+
item.task.deniedTools,
|
|
2752
|
+
item.task.matrix,
|
|
2753
|
+
item.task.matrixParentId,
|
|
2754
|
+
"sync",
|
|
2755
|
+
item.task.timezone,
|
|
2756
|
+
item.task.notBefore,
|
|
2757
|
+
item.task.notAfter,
|
|
2758
|
+
item.task.pausedUntil,
|
|
2759
|
+
item.task.runAt,
|
|
2760
|
+
item.task.session,
|
|
2761
|
+
item.task.sessionId,
|
|
2762
|
+
item.task.sessionMaxRuns,
|
|
2763
|
+
{
|
|
2764
|
+
activeDays: item.task.activeDays,
|
|
2765
|
+
windowPolicy: item.task.windowPolicy,
|
|
2766
|
+
watchGlobs: item.task.watchGlobs ?? [],
|
|
2767
|
+
watchIgnore: item.task.watchIgnore ?? [],
|
|
2768
|
+
gitBranch: item.task.gitBranch,
|
|
2769
|
+
gitPaths: item.task.gitPaths,
|
|
2770
|
+
gitIgnore: item.task.gitIgnore,
|
|
2771
|
+
gitPollSeconds: item.task.gitPollSeconds,
|
|
2772
|
+
},
|
|
2773
|
+
item.task.runWhenLoggedOff ?? false,
|
|
2774
|
+
item.task.paused ?? false,
|
|
2775
|
+
item.task.legacyShell ?? false,
|
|
2776
|
+
item.task.worktree ?? false,
|
|
2777
|
+
item.task.guards,
|
|
2778
|
+
);
|
|
2779
|
+
await saveTaskDefinition(item.task);
|
|
2780
|
+
updated++;
|
|
2781
|
+
} catch (err: any) {
|
|
2782
|
+
errors.push(`update ${item.task.name}: ${err instanceof Error ? err.message : String(err)}`);
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
refreshTriggers();
|
|
2786
|
+
}
|
|
2787
|
+
|
|
2788
|
+
return {
|
|
2789
|
+
content: JSON.stringify({
|
|
2790
|
+
success: errors.length === 0,
|
|
2791
|
+
pipeline: spec.name,
|
|
2792
|
+
dryRun,
|
|
2793
|
+
created,
|
|
2794
|
+
updated,
|
|
2795
|
+
unchanged: plan.unchanged.length,
|
|
2796
|
+
stale: plan.stale.length,
|
|
2797
|
+
warnings: [...plan.warnings, ...errors],
|
|
2798
|
+
errors,
|
|
2799
|
+
}),
|
|
2800
|
+
};
|
|
2801
|
+
});
|
|
2802
|
+
|
|
2803
|
+
/** pipeline_export — выгрузить задачи конвейера как opencode.pipeline.yaml. */
|
|
2804
|
+
const pipelineExportExecute = wrapExecute<PipelineExportArgs>(async (args) => {
|
|
2805
|
+
const allTasks = await listTaskDefinitions();
|
|
2806
|
+
const result = tasksToPipelineSpec(allTasks, args.pipeline);
|
|
2807
|
+
if (!result.spec) {
|
|
2808
|
+
return {
|
|
2809
|
+
content: JSON.stringify({
|
|
2810
|
+
success: false,
|
|
2811
|
+
error: `Конвейер "${args.pipeline}" не найден (не найдены задачи с pipelineName=${args.pipeline} и pipelineStepId).`,
|
|
2812
|
+
warnings: result.warnings,
|
|
2813
|
+
}),
|
|
2814
|
+
};
|
|
2815
|
+
}
|
|
2816
|
+
const yamlText = yamlStringify(result.spec, { lineWidth: 0 });
|
|
2817
|
+
return {
|
|
2818
|
+
content: JSON.stringify({
|
|
2819
|
+
success: true,
|
|
2820
|
+
pipeline: args.pipeline,
|
|
2821
|
+
steps: result.spec.steps.length,
|
|
2822
|
+
yaml: yamlText,
|
|
2823
|
+
warnings: result.warnings,
|
|
2824
|
+
}),
|
|
2825
|
+
};
|
|
2826
|
+
});
|
|
2827
|
+
|
|
2448
2828
|
/**
|
|
2449
2829
|
* Перегенерирует env-файлы всех задач, привязанных к workspace (Спринт 21).
|
|
2450
2830
|
* Обёртки читают env-файл при запуске, поэтому перезапуск задач не нужен.
|
|
@@ -3029,6 +3409,24 @@ const transferTasksExecute = wrapExecute<TransferArgs>(async (args) => {
|
|
|
3029
3409
|
def.notAfter,
|
|
3030
3410
|
def.pausedUntil,
|
|
3031
3411
|
def.runAt,
|
|
3412
|
+
def.session,
|
|
3413
|
+
def.sessionId,
|
|
3414
|
+
def.sessionMaxRuns,
|
|
3415
|
+
{
|
|
3416
|
+
activeDays: def.activeDays,
|
|
3417
|
+
windowPolicy: def.windowPolicy,
|
|
3418
|
+
watchGlobs: def.watchGlobs,
|
|
3419
|
+
watchIgnore: def.watchIgnore,
|
|
3420
|
+
gitBranch: def.gitBranch,
|
|
3421
|
+
gitPaths: def.gitPaths,
|
|
3422
|
+
gitIgnore: def.gitIgnore,
|
|
3423
|
+
gitPollSeconds: def.gitPollSeconds,
|
|
3424
|
+
},
|
|
3425
|
+
def.runWhenLoggedOff,
|
|
3426
|
+
def.paused,
|
|
3427
|
+
def.legacyShell,
|
|
3428
|
+
def.worktree,
|
|
3429
|
+
def.guards,
|
|
3032
3430
|
);
|
|
3033
3431
|
await saveTaskDefinition(def);
|
|
3034
3432
|
imported.push(def.name);
|
|
@@ -3230,6 +3628,11 @@ const RPC_AUDIT_RULES: Record<
|
|
|
3230
3628
|
update_task: { action: "task.update", targetType: "task", target: (i) => i.name ?? "" },
|
|
3231
3629
|
delete_task: { action: "task.delete", targetType: "task", target: (i) => i.name ?? "" },
|
|
3232
3630
|
run_task: { action: "task.run", targetType: "task", target: (i) => i.name ?? "" },
|
|
3631
|
+
run_mission: {
|
|
3632
|
+
action: "mission.run",
|
|
3633
|
+
targetType: "mission",
|
|
3634
|
+
target: (i) => i.taskName ?? "ad-hoc",
|
|
3635
|
+
},
|
|
3233
3636
|
pause_task: { action: "task.pause", targetType: "task", target: (i) => i.name ?? "" },
|
|
3234
3637
|
resume_task: { action: "task.resume", targetType: "task", target: (i) => i.name ?? "" },
|
|
3235
3638
|
cancel_matrix: { action: "matrix.cancel", targetType: "matrix", target: (i) => i.name ?? "" },
|
|
@@ -3702,6 +4105,9 @@ export interface ToolHandlers {
|
|
|
3702
4105
|
get_history: typeof getHistoryExecute;
|
|
3703
4106
|
get_task_logs: typeof getTaskLogsExecute;
|
|
3704
4107
|
dry_run: typeof dryRunExecute;
|
|
4108
|
+
pipeline_validate: typeof pipelineValidateExecute;
|
|
4109
|
+
pipeline_apply: typeof pipelineApplyExecute;
|
|
4110
|
+
pipeline_export: typeof pipelineExportExecute;
|
|
3705
4111
|
manage_workspaces: typeof manageWorkspacesExecute;
|
|
3706
4112
|
matrix_control: typeof matrixControlExecute;
|
|
3707
4113
|
get_metrics: typeof getMetricsExecute;
|
|
@@ -3739,6 +4145,9 @@ export function createToolHandlers(_runtime: SchedulerRuntime): ToolHandlers {
|
|
|
3739
4145
|
get_history: getHistoryExecute,
|
|
3740
4146
|
get_task_logs: getTaskLogsExecute,
|
|
3741
4147
|
dry_run: dryRunExecute,
|
|
4148
|
+
pipeline_validate: pipelineValidateExecute,
|
|
4149
|
+
pipeline_apply: pipelineApplyExecute,
|
|
4150
|
+
pipeline_export: pipelineExportExecute,
|
|
3742
4151
|
manage_workspaces: manageWorkspacesExecute,
|
|
3743
4152
|
matrix_control: matrixControlExecute,
|
|
3744
4153
|
get_metrics: getMetricsExecute,
|
|
@@ -4078,6 +4487,32 @@ export function createToolSpecs(runtime: SchedulerRuntime): ToolSpec[] {
|
|
|
4078
4487
|
"Filter by action, target, actor, time range and limit. Secret values are redacted.",
|
|
4079
4488
|
execute: handlers.get_audit_log as any,
|
|
4080
4489
|
},
|
|
4490
|
+
{
|
|
4491
|
+
name: "pipeline_validate",
|
|
4492
|
+
input: pipelineValidateSchema,
|
|
4493
|
+
description:
|
|
4494
|
+
"Проверяет opencode.pipeline.yaml (путь к файлу или исходник): валидирует version, шаги, зависимости, циклы, cron-расписание, matrix, модель, окна запуска и другие инварианты конвейера. Не применяет изменения.",
|
|
4495
|
+
execute: handlers.pipeline_validate as any,
|
|
4496
|
+
},
|
|
4497
|
+
{
|
|
4498
|
+
name: "pipeline_apply",
|
|
4499
|
+
input: pipelineApplySchema,
|
|
4500
|
+
description:
|
|
4501
|
+
"Применяет opencode.pipeline.yaml к текущему набору задач: создаёт новые, обновляет изменённые, пропускает без изменений (идемпотентно). Задачи без маркера pipelineName не трогаются. В режиме dryRun только отчитывает diff.",
|
|
4502
|
+
audit: (args: PipelineApplyArgs) => ({
|
|
4503
|
+
action: "pipeline.apply",
|
|
4504
|
+
targetType: "pipeline",
|
|
4505
|
+
target: args.source ?? args.path ?? "",
|
|
4506
|
+
}),
|
|
4507
|
+
execute: handlers.pipeline_apply as any,
|
|
4508
|
+
},
|
|
4509
|
+
{
|
|
4510
|
+
name: "pipeline_export",
|
|
4511
|
+
input: pipelineExportSchema,
|
|
4512
|
+
description:
|
|
4513
|
+
"Выгружает задачи указанного конвейера (pipelineName) как opencode.pipeline.yaml: шаги, зависимости, matrix, кастомные настройки шага.",
|
|
4514
|
+
execute: handlers.pipeline_export as any,
|
|
4515
|
+
},
|
|
4081
4516
|
{
|
|
4082
4517
|
name: "emit_event",
|
|
4083
4518
|
input: emitEventSchema,
|
|
@@ -4203,6 +4638,8 @@ const v2Plugin = Plugin.define({
|
|
|
4203
4638
|
sessionMaxRuns,
|
|
4204
4639
|
runWhenLoggedOff,
|
|
4205
4640
|
legacyShell,
|
|
4641
|
+
worktree,
|
|
4642
|
+
guards,
|
|
4206
4643
|
} = input as {
|
|
4207
4644
|
name: string;
|
|
4208
4645
|
schedule?: string;
|
|
@@ -4234,6 +4671,8 @@ const v2Plugin = Plugin.define({
|
|
|
4234
4671
|
sessionMaxRuns?: number;
|
|
4235
4672
|
runWhenLoggedOff?: boolean;
|
|
4236
4673
|
legacyShell?: boolean;
|
|
4674
|
+
worktree?: boolean;
|
|
4675
|
+
guards?: TaskGuards;
|
|
4237
4676
|
};
|
|
4238
4677
|
let effectiveRunAt: string | undefined;
|
|
4239
4678
|
if (triggerType === "once") {
|
|
@@ -4297,6 +4736,8 @@ const v2Plugin = Plugin.define({
|
|
|
4297
4736
|
runWhenLoggedOff === true,
|
|
4298
4737
|
undefined,
|
|
4299
4738
|
legacyShell === true,
|
|
4739
|
+
worktree === true,
|
|
4740
|
+
guards,
|
|
4300
4741
|
);
|
|
4301
4742
|
const nextRun = computeTaskNextRun({
|
|
4302
4743
|
schedule: schedule ?? "",
|
|
@@ -4428,6 +4869,37 @@ const v2Plugin = Plugin.define({
|
|
|
4428
4869
|
return { success: false, message: `schtasks error: ${err instanceof Error ? err.message : String(err)}` };
|
|
4429
4870
|
}
|
|
4430
4871
|
},
|
|
4872
|
+
run_mission: async (input: unknown) => {
|
|
4873
|
+
try {
|
|
4874
|
+
const mission = await runMission(input as MissionSpec);
|
|
4875
|
+
return {
|
|
4876
|
+
success: mission.success,
|
|
4877
|
+
dryRun: mission.dryRun,
|
|
4878
|
+
runId: mission.runId ?? "",
|
|
4879
|
+
status: mission.status,
|
|
4880
|
+
description: mission.description,
|
|
4881
|
+
...(mission.error ? { error: mission.error } : {}),
|
|
4882
|
+
steps: mission.steps.map((step) => ({
|
|
4883
|
+
stepName: step.stepName,
|
|
4884
|
+
taskType: step.taskType,
|
|
4885
|
+
target: step.target,
|
|
4886
|
+
status: step.status,
|
|
4887
|
+
attempt: step.attempt,
|
|
4888
|
+
...(step.error ? { error: step.error } : {}),
|
|
4889
|
+
})),
|
|
4890
|
+
};
|
|
4891
|
+
} catch (err: any) {
|
|
4892
|
+
return {
|
|
4893
|
+
success: false,
|
|
4894
|
+
dryRun: false,
|
|
4895
|
+
runId: "",
|
|
4896
|
+
status: "failed",
|
|
4897
|
+
description: "",
|
|
4898
|
+
error: err instanceof Error ? err.message : String(err),
|
|
4899
|
+
steps: [],
|
|
4900
|
+
};
|
|
4901
|
+
}
|
|
4902
|
+
},
|
|
4431
4903
|
emit_event: async (input: unknown) => {
|
|
4432
4904
|
const { eventName, payload } = input as {
|
|
4433
4905
|
eventName?: string;
|
|
@@ -4676,6 +5148,29 @@ const v2Plugin = Plugin.define({
|
|
|
4676
5148
|
}
|
|
4677
5149
|
return { success: allSuccess, reports };
|
|
4678
5150
|
},
|
|
5151
|
+
pipeline_validate: async (input: unknown) => {
|
|
5152
|
+
const { path, source, dryRun } = input as {
|
|
5153
|
+
path?: string;
|
|
5154
|
+
source?: string;
|
|
5155
|
+
dryRun?: boolean;
|
|
5156
|
+
};
|
|
5157
|
+
const result = await pipelineValidateExecute({ path, source, dryRun } as PipelineValidateArgs, {} as Tool.Context);
|
|
5158
|
+
return JSON.parse(result.content as string);
|
|
5159
|
+
},
|
|
5160
|
+
pipeline_apply: async (input: unknown) => {
|
|
5161
|
+
const { path, source, dryRun } = input as {
|
|
5162
|
+
path?: string;
|
|
5163
|
+
source?: string;
|
|
5164
|
+
dryRun?: boolean;
|
|
5165
|
+
};
|
|
5166
|
+
const result = await pipelineApplyExecute({ path, source, dryRun } as PipelineApplyArgs, {} as Tool.Context);
|
|
5167
|
+
return JSON.parse(result.content as string);
|
|
5168
|
+
},
|
|
5169
|
+
pipeline_export: async (input: unknown) => {
|
|
5170
|
+
const { pipeline } = input as { pipeline?: string };
|
|
5171
|
+
const result = await pipelineExportExecute({ pipeline } as PipelineExportArgs, {} as Tool.Context);
|
|
5172
|
+
return JSON.parse(result.content as string);
|
|
5173
|
+
},
|
|
4679
5174
|
get_matrix_results: async (input: unknown) => {
|
|
4680
5175
|
const { parentId } = input as { parentId?: string; name?: string };
|
|
4681
5176
|
const target = (parentId ?? "").trim();
|
|
@@ -5245,6 +5740,8 @@ const v2Plugin = Plugin.define({
|
|
|
5245
5740
|
def.runWhenLoggedOff === true,
|
|
5246
5741
|
def.paused === true,
|
|
5247
5742
|
def.legacyShell === true,
|
|
5743
|
+
def.worktree === true,
|
|
5744
|
+
def.guards,
|
|
5248
5745
|
);
|
|
5249
5746
|
await saveTaskDefinition(def);
|
|
5250
5747
|
imported.push(def.name);
|
|
@@ -5472,7 +5969,7 @@ export interface TriggerExtras {
|
|
|
5472
5969
|
gitPollSeconds?: number;
|
|
5473
5970
|
}
|
|
5474
5971
|
|
|
5475
|
-
async function schedulerCreateTask(
|
|
5972
|
+
export async function schedulerCreateTask(
|
|
5476
5973
|
name: string,
|
|
5477
5974
|
schedule: string,
|
|
5478
5975
|
prompt: string,
|
|
@@ -5528,6 +6025,10 @@ async function schedulerCreateTask(
|
|
|
5528
6025
|
* true возвращает shell задаче, созданной до обновления поведения.
|
|
5529
6026
|
*/
|
|
5530
6027
|
legacyShell?: boolean,
|
|
6028
|
+
/** W-1: одноразовый git worktree на каждый запуск. */
|
|
6029
|
+
worktree?: boolean,
|
|
6030
|
+
/** W-3: guard-условия перед запуском opencode. */
|
|
6031
|
+
guards?: TaskGuards,
|
|
5531
6032
|
): Promise<void> {
|
|
5532
6033
|
// Спринт 27.5 (hotfix 1.5.1): проверяем имя до создания wrapper/prompt и записи
|
|
5533
6034
|
// в БД. Недопустимые символы отклоняются с понятным сообщением, а не ошибкой
|
|
@@ -5593,6 +6094,13 @@ async function schedulerCreateTask(
|
|
|
5593
6094
|
const normalizedRunWhenLoggedOff = runWhenLoggedOff === true ? true : undefined;
|
|
5594
6095
|
// Спринт 27.5.8: пауза сохраняется при пересоздании задачи.
|
|
5595
6096
|
const normalizedPaused = paused === true ? true : undefined;
|
|
6097
|
+
// W-1: изоляция запуска в одноразовом git worktree.
|
|
6098
|
+
const normalizedWorktree = worktree === true ? true : undefined;
|
|
6099
|
+
// W-3: guard-условия. Ошибка нормализации — явная ошибка создания задачи,
|
|
6100
|
+
// чтобы опечатка в конфигурации не превратилась в молчаливый пропуск.
|
|
6101
|
+
const guardsResult = normalizeTaskGuards(guards);
|
|
6102
|
+
if (!guardsResult.ok) throw new Error(guardsResult.error);
|
|
6103
|
+
const normalizedGuards = guardsResult.guards;
|
|
5596
6104
|
// Спринт 27: дни недели, политика окна и glob/git-фильтры.
|
|
5597
6105
|
const normalizeGlobList = (raw?: string[]): string[] | undefined => {
|
|
5598
6106
|
if (!Array.isArray(raw)) return undefined;
|
|
@@ -5979,12 +6487,14 @@ async function schedulerCreateTask(
|
|
|
5979
6487
|
taskEnvFile,
|
|
5980
6488
|
effectiveSession,
|
|
5981
6489
|
effectiveSessionId,
|
|
5982
|
-
retryCount,
|
|
5983
|
-
retryDelay,
|
|
5984
6490
|
undefined,
|
|
5985
6491
|
permissionsConfig,
|
|
5986
6492
|
policyMeta,
|
|
5987
6493
|
sessionFile,
|
|
6494
|
+
normalizedWorktree,
|
|
6495
|
+
worktreeHelperPath,
|
|
6496
|
+
normalizedGuards,
|
|
6497
|
+
guardHelperPath,
|
|
5988
6498
|
);
|
|
5989
6499
|
} else {
|
|
5990
6500
|
wrapperPath = await writeBashWrapper({
|
|
@@ -6010,6 +6520,10 @@ async function schedulerCreateTask(
|
|
|
6010
6520
|
sessionMode: effectiveSession,
|
|
6011
6521
|
sessionId: effectiveSessionId,
|
|
6012
6522
|
sessionFile,
|
|
6523
|
+
worktree: normalizedWorktree,
|
|
6524
|
+
worktreeHelper: worktreeHelperPath,
|
|
6525
|
+
guards: normalizedGuards,
|
|
6526
|
+
guardHelper: guardHelperPath,
|
|
6013
6527
|
...(effectiveTriggerType === "once" && scheduler.platform === "darwin"
|
|
6014
6528
|
? { oneShotCleanupCommand: buildLaunchdOneShotCleanup(sanitized, getProfileName()) }
|
|
6015
6529
|
: {}),
|
|
@@ -6156,6 +6670,8 @@ async function schedulerCreateTask(
|
|
|
6156
6670
|
allowedTools: normalizedAllowedTools,
|
|
6157
6671
|
deniedTools: normalizedDeniedTools,
|
|
6158
6672
|
legacyShell: legacyShell === true ? true : undefined,
|
|
6673
|
+
worktree: normalizedWorktree,
|
|
6674
|
+
guards: normalizedGuards,
|
|
6159
6675
|
matrix: normalizedMatrix,
|
|
6160
6676
|
isMatrixParent: normalizedMatrix ? true : undefined,
|
|
6161
6677
|
matrixParentId,
|
|
@@ -6238,6 +6754,8 @@ async function schedulerCreateTask(
|
|
|
6238
6754
|
clone.runWhenLoggedOff,
|
|
6239
6755
|
clone.paused,
|
|
6240
6756
|
clone.legacyShell,
|
|
6757
|
+
clone.worktree,
|
|
6758
|
+
clone.guards,
|
|
6241
6759
|
);
|
|
6242
6760
|
};
|
|
6243
6761
|
|
|
@@ -6451,6 +6969,8 @@ async function recreateTaskFromDefinition(definition: TaskDefinition): Promise<v
|
|
|
6451
6969
|
definition.runWhenLoggedOff,
|
|
6452
6970
|
paused,
|
|
6453
6971
|
definition.legacyShell,
|
|
6972
|
+
definition.worktree,
|
|
6973
|
+
definition.guards,
|
|
6454
6974
|
);
|
|
6455
6975
|
}
|
|
6456
6976
|
|