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
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { PIPELINE_VERSION, pipelineStepTaskName, } from "./pipeline-spec.js";
|
|
2
|
+
/**
|
|
3
|
+
* Преобразует провалидированный pipeline в определения задач.
|
|
4
|
+
*
|
|
5
|
+
* Правила:
|
|
6
|
+
* - `trigger: dag` → задача без собственного триггера (`triggerType: "file"`),
|
|
7
|
+
* как матричные родители: её запускает только DAG-движок по `dependsOn`;
|
|
8
|
+
* - `needs` → `dependsOn` с именами задач (`<pipeline> <step>`);
|
|
9
|
+
* - `defaults` наследуются шагом;
|
|
10
|
+
* - матрица `workspaces` переносится в `matrix.workspaceIds`.
|
|
11
|
+
*/
|
|
12
|
+
export function pipelineSpecToTasks(spec, options = {}) {
|
|
13
|
+
const defaults = spec.defaults ?? {};
|
|
14
|
+
const warnings = [];
|
|
15
|
+
const nameByStep = new Map();
|
|
16
|
+
for (const step of spec.steps) {
|
|
17
|
+
const explicit = step.name?.trim();
|
|
18
|
+
nameByStep.set(step.id.toLowerCase(), explicit || pipelineStepTaskName(spec.name, step.id));
|
|
19
|
+
}
|
|
20
|
+
const tasks = spec.steps.map((step) => {
|
|
21
|
+
const trigger = step.trigger ?? defaults.trigger ?? "cron";
|
|
22
|
+
const scheduleValue = step.schedule ?? defaults.schedule ?? "";
|
|
23
|
+
const schedule = trigger === "cron" ? scheduleValue : "";
|
|
24
|
+
const dependsOn = step.needs?.length
|
|
25
|
+
? step.needs.map((need) => nameByStep.get(need.toLowerCase()))
|
|
26
|
+
: undefined;
|
|
27
|
+
const task = {
|
|
28
|
+
name: nameByStep.get(step.id.toLowerCase()),
|
|
29
|
+
schedule,
|
|
30
|
+
prompt: step.prompt,
|
|
31
|
+
// TaskDefinition не знает "dag": ручной триггер "file" не регистрирует
|
|
32
|
+
// cron, задачу запускает DAG-движок после успеха зависимостей.
|
|
33
|
+
triggerType: trigger === "dag" ? "file" : trigger,
|
|
34
|
+
...(dependsOn ? { dependsOn } : {}),
|
|
35
|
+
...(step.qualityGate !== undefined ? { qualityGate: step.qualityGate } : {}),
|
|
36
|
+
...(step.beforeScript !== undefined ? { beforeScript: step.beforeScript } : {}),
|
|
37
|
+
...(step.afterScript !== undefined ? { afterScript: step.afterScript } : {}),
|
|
38
|
+
...(step.guards !== undefined ? { guards: step.guards } : {}),
|
|
39
|
+
...(step.model !== undefined || defaults.model !== undefined
|
|
40
|
+
? { model: step.model ?? defaults.model }
|
|
41
|
+
: {}),
|
|
42
|
+
...(step.priority !== undefined || defaults.priority !== undefined
|
|
43
|
+
? { priority: step.priority ?? defaults.priority }
|
|
44
|
+
: {}),
|
|
45
|
+
...(step.timeoutSeconds !== undefined || defaults.timeoutSeconds !== undefined
|
|
46
|
+
? { timeoutSeconds: step.timeoutSeconds ?? defaults.timeoutSeconds }
|
|
47
|
+
: {}),
|
|
48
|
+
...(step.workingDirectory !== undefined || defaults.workingDirectory !== undefined
|
|
49
|
+
? { workingDirectory: step.workingDirectory ?? defaults.workingDirectory }
|
|
50
|
+
: {}),
|
|
51
|
+
...(step.workspaceId !== undefined ? { workspaceId: step.workspaceId } : {}),
|
|
52
|
+
...(step.retryCount !== undefined || defaults.retryCount !== undefined
|
|
53
|
+
? { retryCount: step.retryCount ?? defaults.retryCount }
|
|
54
|
+
: {}),
|
|
55
|
+
...(step.retryDelay !== undefined || defaults.retryDelay !== undefined
|
|
56
|
+
? { retryDelay: step.retryDelay ?? defaults.retryDelay }
|
|
57
|
+
: {}),
|
|
58
|
+
...(step.allowedTools !== undefined || defaults.allowedTools !== undefined
|
|
59
|
+
? { allowedTools: step.allowedTools ?? defaults.allowedTools }
|
|
60
|
+
: {}),
|
|
61
|
+
...(step.deniedTools !== undefined || defaults.deniedTools !== undefined
|
|
62
|
+
? { deniedTools: step.deniedTools ?? defaults.deniedTools }
|
|
63
|
+
: {}),
|
|
64
|
+
...(step.timezone !== undefined || defaults.timezone !== undefined
|
|
65
|
+
? { timezone: step.timezone ?? defaults.timezone }
|
|
66
|
+
: {}),
|
|
67
|
+
...(step.notBefore !== undefined ? { notBefore: step.notBefore } : {}),
|
|
68
|
+
...(step.notAfter !== undefined ? { notAfter: step.notAfter } : {}),
|
|
69
|
+
...(step.activeDays !== undefined ? { activeDays: step.activeDays } : {}),
|
|
70
|
+
...(step.windowPolicy !== undefined ? { windowPolicy: step.windowPolicy } : {}),
|
|
71
|
+
...(trigger === "once" && step.runAt !== undefined ? { runAt: step.runAt } : {}),
|
|
72
|
+
...(step.matrix ? { matrix: mapMatrix(step.matrix, options, warnings) } : {}),
|
|
73
|
+
pipelineName: spec.name,
|
|
74
|
+
pipelineStepId: step.id,
|
|
75
|
+
};
|
|
76
|
+
return task;
|
|
77
|
+
});
|
|
78
|
+
return { tasks, warnings };
|
|
79
|
+
}
|
|
80
|
+
function mapMatrix(matrix, options, warnings) {
|
|
81
|
+
const workspaceIds = matrix.workspaces.map((raw) => {
|
|
82
|
+
const value = raw.trim();
|
|
83
|
+
const resolved = options.resolveWorkspaceId?.(value);
|
|
84
|
+
if (options.resolveWorkspaceId && !resolved) {
|
|
85
|
+
warnings.push(`workspace «${value}» не найден — шаг будет отклонён при apply.`);
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
return resolved ?? value;
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
workspaceIds,
|
|
92
|
+
...(matrix.strategy ? { strategy: matrix.strategy } : {}),
|
|
93
|
+
...(matrix.failureMode ? { failureMode: matrix.failureMode } : {}),
|
|
94
|
+
...(matrix.aggregation ? { aggregation: matrix.aggregation } : {}),
|
|
95
|
+
...(matrix.concurrency !== undefined ? { concurrency: matrix.concurrency } : {}),
|
|
96
|
+
...(matrix.createAggregator !== undefined
|
|
97
|
+
? { createAggregator: matrix.createAggregator }
|
|
98
|
+
: {}),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Обратный маппинг: задачи одного pipeline из БД → `PipelineSpec` для export.
|
|
103
|
+
*
|
|
104
|
+
* Восстанавливает `needs` по `dependsOn`, `matrix.workspaces` по
|
|
105
|
+
* `matrix.workspaceIds`, trigger по `triggerType`. Шаг `dag` неотличим от
|
|
106
|
+
* ручного `file`-шага с зависимостями, поэтому восстанавливается эвристикой:
|
|
107
|
+
* `file`, без cron и watchPath, но с `dependsOn` → `dag`.
|
|
108
|
+
*/
|
|
109
|
+
export function tasksToPipelineSpec(tasks, pipelineName) {
|
|
110
|
+
const warnings = [];
|
|
111
|
+
const own = tasks.filter((task) => task.pipelineName?.toLowerCase() === pipelineName.toLowerCase() &&
|
|
112
|
+
Boolean(task.pipelineStepId));
|
|
113
|
+
const stepIdByTaskName = new Map();
|
|
114
|
+
for (const task of own) {
|
|
115
|
+
const key = task.name.trim().toLowerCase();
|
|
116
|
+
if (key && !stepIdByTaskName.has(key)) {
|
|
117
|
+
stepIdByTaskName.set(key, task.pipelineStepId);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const steps = own.map((task) => {
|
|
121
|
+
const stepId = task.pipelineStepId;
|
|
122
|
+
const trigger = inferTrigger(task);
|
|
123
|
+
const needs = task.dependsOn
|
|
124
|
+
?.map((dep) => {
|
|
125
|
+
const id = stepIdByTaskName.get(dep.trim().toLowerCase());
|
|
126
|
+
if (!id) {
|
|
127
|
+
warnings.push(`Шаг «${stepId}»: зависимость «${dep}» не входит в pipeline и опущена.`);
|
|
128
|
+
}
|
|
129
|
+
return id;
|
|
130
|
+
})
|
|
131
|
+
.filter((value) => Boolean(value));
|
|
132
|
+
const defaultName = pipelineStepTaskName(pipelineName, stepId);
|
|
133
|
+
const step = {
|
|
134
|
+
id: stepId,
|
|
135
|
+
...(task.name.trim() !== defaultName ? { name: task.name } : {}),
|
|
136
|
+
prompt: task.prompt,
|
|
137
|
+
...(needs?.length ? { needs } : {}),
|
|
138
|
+
...(trigger === "cron" && task.schedule ? { schedule: task.schedule } : {}),
|
|
139
|
+
...(trigger !== "cron" ? { trigger } : {}),
|
|
140
|
+
...(trigger === "once" && task.runAt !== undefined ? { runAt: task.runAt } : {}),
|
|
141
|
+
...(task.model !== undefined ? { model: task.model } : {}),
|
|
142
|
+
...(task.priority !== undefined ? { priority: task.priority } : {}),
|
|
143
|
+
...(task.timeoutSeconds !== undefined ? { timeoutSeconds: task.timeoutSeconds } : {}),
|
|
144
|
+
...(task.workingDirectory !== undefined
|
|
145
|
+
? { workingDirectory: task.workingDirectory }
|
|
146
|
+
: {}),
|
|
147
|
+
...(task.workspaceId !== undefined ? { workspaceId: task.workspaceId } : {}),
|
|
148
|
+
...(task.retryCount !== undefined ? { retryCount: task.retryCount } : {}),
|
|
149
|
+
...(task.retryDelay !== undefined ? { retryDelay: task.retryDelay } : {}),
|
|
150
|
+
...(task.qualityGate !== undefined ? { qualityGate: task.qualityGate } : {}),
|
|
151
|
+
...(task.beforeScript !== undefined ? { beforeScript: task.beforeScript } : {}),
|
|
152
|
+
...(task.afterScript !== undefined ? { afterScript: task.afterScript } : {}),
|
|
153
|
+
...(task.guards !== undefined ? { guards: task.guards } : {}),
|
|
154
|
+
...(task.allowedTools !== undefined ? { allowedTools: task.allowedTools } : {}),
|
|
155
|
+
...(task.deniedTools !== undefined ? { deniedTools: task.deniedTools } : {}),
|
|
156
|
+
...(task.matrix
|
|
157
|
+
? {
|
|
158
|
+
matrix: {
|
|
159
|
+
workspaces: task.matrix.workspaceIds,
|
|
160
|
+
...(task.matrix.strategy ? { strategy: task.matrix.strategy } : {}),
|
|
161
|
+
...(task.matrix.failureMode ? { failureMode: task.matrix.failureMode } : {}),
|
|
162
|
+
...(task.matrix.aggregation ? { aggregation: task.matrix.aggregation } : {}),
|
|
163
|
+
...(task.matrix.concurrency !== undefined
|
|
164
|
+
? { concurrency: task.matrix.concurrency }
|
|
165
|
+
: {}),
|
|
166
|
+
...(task.matrix.createAggregator !== undefined
|
|
167
|
+
? { createAggregator: task.matrix.createAggregator }
|
|
168
|
+
: {}),
|
|
169
|
+
},
|
|
170
|
+
}
|
|
171
|
+
: {}),
|
|
172
|
+
...(task.timezone !== undefined ? { timezone: task.timezone } : {}),
|
|
173
|
+
...(task.notBefore !== undefined ? { notBefore: task.notBefore } : {}),
|
|
174
|
+
...(task.notAfter !== undefined ? { notAfter: task.notAfter } : {}),
|
|
175
|
+
...(task.activeDays !== undefined ? { activeDays: task.activeDays } : {}),
|
|
176
|
+
...(task.windowPolicy !== undefined
|
|
177
|
+
? { windowPolicy: task.windowPolicy }
|
|
178
|
+
: {}),
|
|
179
|
+
};
|
|
180
|
+
return step;
|
|
181
|
+
});
|
|
182
|
+
return {
|
|
183
|
+
spec: { version: PIPELINE_VERSION, name: pipelineName, steps },
|
|
184
|
+
warnings,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function inferTrigger(task) {
|
|
188
|
+
const trigger = task.triggerType ?? "cron";
|
|
189
|
+
if (trigger === "file" &&
|
|
190
|
+
!task.schedule &&
|
|
191
|
+
!task.watchPath &&
|
|
192
|
+
Boolean(task.dependsOn?.length)) {
|
|
193
|
+
return "dag";
|
|
194
|
+
}
|
|
195
|
+
return trigger;
|
|
196
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type TaskGuards } from "./guard.js";
|
|
2
|
+
/** Версия формата, которую понимает этот модуль. */
|
|
3
|
+
export declare const PIPELINE_VERSION = 1;
|
|
4
|
+
/** Защита от случайно огромного файла: шагов в одном pipeline. */
|
|
5
|
+
export declare const MAX_PIPELINE_STEPS = 200;
|
|
6
|
+
/** Максимальная длина id шага (id попадает в имена задач и логи). */
|
|
7
|
+
export declare const MAX_STEP_ID_LENGTH = 64;
|
|
8
|
+
/**
|
|
9
|
+
* Чем запускается шаг.
|
|
10
|
+
*
|
|
11
|
+
* `dag` — шаг без собственного триггера: он запускается только как
|
|
12
|
+
* зависимость другого шага (`needs` непустой). Это позволяет описывать
|
|
13
|
+
* pipeline целиком, не придумывая каждому шагу cron.
|
|
14
|
+
*/
|
|
15
|
+
export type PipelineTrigger = "cron" | "file" | "git" | "mcp-event" | "once" | "dag";
|
|
16
|
+
export type PipelineMatrixStrategy = "parallel" | "sequential";
|
|
17
|
+
export type PipelineMatrixFailureMode = "continue" | "stop";
|
|
18
|
+
export type PipelineMatrixAggregation = "summary" | "per-task";
|
|
19
|
+
export type PipelineWindowPolicy = "skip" | "postpone" | "run";
|
|
20
|
+
/** Fan-out матрицы в терминах pipeline-файла. */
|
|
21
|
+
export interface PipelineMatrix {
|
|
22
|
+
/** Имена или id workspace, по одному клону на каждый. */
|
|
23
|
+
workspaces: string[];
|
|
24
|
+
strategy?: PipelineMatrixStrategy;
|
|
25
|
+
failureMode?: PipelineMatrixFailureMode;
|
|
26
|
+
aggregation?: PipelineMatrixAggregation;
|
|
27
|
+
/** Максимум одновременно выполняющихся клонов. */
|
|
28
|
+
concurrency?: number;
|
|
29
|
+
createAggregator?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Значения по умолчанию для всех шагов pipeline. */
|
|
32
|
+
export interface PipelineDefaults {
|
|
33
|
+
schedule?: string;
|
|
34
|
+
trigger?: PipelineTrigger;
|
|
35
|
+
model?: string;
|
|
36
|
+
priority?: number;
|
|
37
|
+
timeoutSeconds?: number;
|
|
38
|
+
workingDirectory?: string;
|
|
39
|
+
retryCount?: number;
|
|
40
|
+
retryDelay?: number;
|
|
41
|
+
allowedTools?: string[];
|
|
42
|
+
deniedTools?: string[];
|
|
43
|
+
timezone?: string;
|
|
44
|
+
}
|
|
45
|
+
/** Один шаг pipeline. */
|
|
46
|
+
export interface PipelineStep {
|
|
47
|
+
/** Уникальный стабильный идентификатор шага (латиница/кириллица, цифры, `. _ -`). */
|
|
48
|
+
id: string;
|
|
49
|
+
/** Имя задачи в планировщике; по умолчанию `<pipeline> <id>`. */
|
|
50
|
+
name?: string;
|
|
51
|
+
prompt: string;
|
|
52
|
+
/** id шагов, которые должны успешно завершиться раньше. */
|
|
53
|
+
needs?: string[];
|
|
54
|
+
/** Cron-выражение (для trigger: cron). */
|
|
55
|
+
schedule?: string;
|
|
56
|
+
trigger?: PipelineTrigger;
|
|
57
|
+
/** ISO-8601 для trigger: once. */
|
|
58
|
+
runAt?: string;
|
|
59
|
+
model?: string;
|
|
60
|
+
priority?: number;
|
|
61
|
+
timeoutSeconds?: number;
|
|
62
|
+
workingDirectory?: string;
|
|
63
|
+
workspaceId?: string;
|
|
64
|
+
retryCount?: number;
|
|
65
|
+
retryDelay?: number;
|
|
66
|
+
qualityGate?: string;
|
|
67
|
+
beforeScript?: string;
|
|
68
|
+
afterScript?: string;
|
|
69
|
+
/** W-3: guard-условия шага; при невыполнении запуск пропускается. */
|
|
70
|
+
guards?: TaskGuards;
|
|
71
|
+
allowedTools?: string[];
|
|
72
|
+
deniedTools?: string[];
|
|
73
|
+
matrix?: PipelineMatrix;
|
|
74
|
+
timezone?: string;
|
|
75
|
+
notBefore?: string;
|
|
76
|
+
notAfter?: string;
|
|
77
|
+
activeDays?: number[];
|
|
78
|
+
windowPolicy?: PipelineWindowPolicy;
|
|
79
|
+
}
|
|
80
|
+
/** Корневой документ `opencode.pipeline.yaml`. */
|
|
81
|
+
export interface PipelineSpec {
|
|
82
|
+
version: typeof PIPELINE_VERSION;
|
|
83
|
+
name: string;
|
|
84
|
+
description?: string;
|
|
85
|
+
defaults?: PipelineDefaults;
|
|
86
|
+
steps: PipelineStep[];
|
|
87
|
+
}
|
|
88
|
+
/** Одна находка валидатора. */
|
|
89
|
+
export interface PipelineIssue {
|
|
90
|
+
/** Путь до поля: `steps[2].schedule`, `defaults.model` и т.п. */
|
|
91
|
+
path: string;
|
|
92
|
+
message: string;
|
|
93
|
+
}
|
|
94
|
+
/** Результат валидации: ошибки блокируют apply, предупреждения — нет. */
|
|
95
|
+
export interface PipelineValidationResult {
|
|
96
|
+
ok: boolean;
|
|
97
|
+
errors: PipelineIssue[];
|
|
98
|
+
warnings: PipelineIssue[];
|
|
99
|
+
}
|
|
100
|
+
/** Имя задачи по умолчанию для шага pipeline. */
|
|
101
|
+
export declare function pipelineStepTaskName(pipelineName: string, stepId: string): string;
|
|
102
|
+
/**
|
|
103
|
+
* Валидирует произвольный разобранный YAML.
|
|
104
|
+
*
|
|
105
|
+
* Не бросает исключений: все проблемы складываются в `errors`/`warnings`,
|
|
106
|
+
* чтобы CLI мог напечатать их списком и вернуть exit code.
|
|
107
|
+
*/
|
|
108
|
+
export declare function validatePipelineSpec(input: unknown): PipelineValidationResult;
|
|
109
|
+
//# sourceMappingURL=pipeline-spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-spec.d.ts","sourceRoot":"","sources":["../../src/core/pipeline-spec.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAElE,oDAAoD;AACpD,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,kEAAkE;AAClE,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,qEAAqE;AACrE,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,MAAM,GACN,KAAK,GACL,WAAW,GACX,MAAM,GACN,KAAK,CAAC;AAEV,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,YAAY,CAAC;AAC/D,MAAM,MAAM,yBAAyB,GAAG,UAAU,GAAG,MAAM,CAAC;AAC5D,MAAM,MAAM,yBAAyB,GAAG,SAAS,GAAG,UAAU,CAAC;AAC/D,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;AAE/D,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC7B,yDAAyD;IACzD,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,sBAAsB,CAAC;IAClC,WAAW,CAAC,EAAE,yBAAyB,CAAC;IACxC,WAAW,CAAC,EAAE,yBAAyB,CAAC;IACxC,kDAAkD;IAClD,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