@probelabs/visor 0.1.124 → 0.1.126
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/dist/config.d.ts.map +1 -1
- package/dist/docs/DEPLOYMENT.md +117 -11
- package/dist/docs/GITHUB_CHECKS.md +18 -4
- package/dist/docs/NPM_USAGE.md +112 -39
- package/dist/docs/action-reference.md +63 -9
- package/dist/docs/advanced-ai.md +58 -51
- package/dist/docs/ai-configuration.md +99 -11
- package/dist/docs/ai-custom-tools-usage.md +70 -33
- package/dist/docs/ai-custom-tools.md +50 -27
- package/dist/docs/architecture.md +1232 -0
- package/dist/docs/bot-transports-rfc.md +13 -3
- package/dist/docs/ci-cli-mode.md +116 -8
- package/dist/docs/claude-code.md +111 -41
- package/dist/docs/command-provider.md +37 -15
- package/dist/docs/commands.md +252 -6
- package/dist/docs/configuration.md +138 -4
- package/dist/docs/contributing.md +737 -0
- package/dist/docs/custom-tools.md +39 -8
- package/dist/docs/dashboards/README.md +33 -19
- package/dist/docs/debug-visualizer-progress.md +14 -13
- package/dist/docs/debug-visualizer-rfc.md +14 -13
- package/dist/docs/debug-visualizer.md +30 -5
- package/dist/docs/debugging.md +73 -8
- package/dist/docs/default-output-schema.md +24 -20
- package/dist/docs/dependencies.md +75 -21
- package/dist/docs/dev-playbook.md +85 -9
- package/dist/docs/engine-pause-resume-rfc.md +11 -11
- package/dist/docs/engine-state-machine-plan.md +10 -3
- package/dist/docs/event-driven-github-integration-rfc.md +20 -11
- package/dist/docs/event-triggers.md +95 -6
- package/dist/docs/execution-statistics-rfc.md +16 -4
- package/dist/docs/fact-validator-gap-analysis.md +12 -1
- package/dist/docs/fact-validator-implementation-plan.md +19 -11
- package/dist/docs/fail-if.md +116 -11
- package/dist/docs/failure-conditions-implementation.md +40 -6
- package/dist/docs/failure-conditions-schema.md +243 -87
- package/dist/docs/failure-routing-rfc.md +43 -18
- package/dist/docs/failure-routing.md +80 -23
- package/dist/docs/faq.md +836 -0
- package/dist/docs/foreach-dependency-propagation.md +32 -15
- package/dist/docs/github-ops.md +6 -5
- package/dist/docs/glossary.md +322 -0
- package/dist/docs/goto-forward-run-plan.md +23 -10
- package/dist/docs/guides/criticality-modes.md +15 -13
- package/dist/docs/guides/fault-management-and-contracts.md +8 -5
- package/dist/docs/guides/workflow-style-guide.md +17 -8
- package/dist/docs/http.md +102 -3
- package/dist/docs/human-input-provider.md +20 -36
- package/dist/docs/index.md +206 -0
- package/dist/docs/lifecycle-hooks.md +322 -2
- package/dist/docs/limits.md +20 -5
- package/dist/docs/liquid-templates.md +86 -14
- package/dist/docs/loop-routing-refactor.md +4 -2
- package/dist/docs/mcp-provider.md +53 -19
- package/dist/docs/mcp.md +27 -1
- package/dist/docs/memory.md +7 -2
- package/dist/docs/migration.md +596 -0
- package/dist/docs/observability.md +227 -6
- package/dist/docs/output-formats.md +388 -9
- package/dist/docs/output-history.md +36 -6
- package/dist/docs/performance.md +510 -4
- package/dist/docs/pluggable.md +95 -4
- package/dist/docs/proposals/snapshot-scope-execution.md +6 -5
- package/dist/docs/providers/git-checkout.md +16 -14
- package/dist/docs/providers/noop.md +696 -0
- package/dist/docs/recipes.md +8 -9
- package/dist/docs/rfc/git-checkout-step.md +3 -1
- package/dist/docs/rfc/on_init-hook.md +18 -5
- package/dist/docs/rfc/workspace-isolation.md +16 -0
- package/dist/docs/roadmap/criticality-implementation-tasks.md +27 -27
- package/dist/docs/router-patterns.md +155 -43
- package/dist/docs/schema-templates.md +51 -15
- package/dist/docs/script.md +162 -13
- package/dist/docs/sdk.md +46 -12
- package/dist/docs/security.md +464 -5
- package/dist/docs/slack-integration.md +481 -0
- package/dist/docs/tag-filtering.md +60 -20
- package/dist/docs/telemetry-setup.md +157 -46
- package/dist/docs/test-framework-rfc.md +37 -36
- package/dist/docs/testing/assertions.md +92 -4
- package/dist/docs/testing/ci.md +56 -7
- package/dist/docs/testing/cli.md +57 -15
- package/dist/docs/testing/cookbook.md +53 -20
- package/dist/docs/testing/dsl-reference.md +110 -9
- package/dist/docs/testing/fixtures-and-mocks.md +28 -3
- package/dist/docs/testing/flows.md +59 -4
- package/dist/docs/testing/getting-started.md +14 -13
- package/dist/docs/testing/troubleshooting.md +39 -2
- package/dist/docs/timeouts.md +174 -18
- package/dist/docs/troubleshooting.md +176 -6
- package/dist/docs/workflow-creation-guide.md +101 -3
- package/dist/docs/workflows.md +138 -41
- package/dist/examples/README.md +169 -4
- package/dist/examples/ai-custom-tools-simple.yaml +2 -3
- package/dist/examples/cron-webhook-config.yaml +15 -0
- package/dist/examples/forEach-example.yaml +6 -0
- package/dist/examples/git-checkout-basic.yaml +4 -0
- package/dist/examples/git-checkout-compare.yaml +6 -0
- package/dist/examples/git-checkout-cross-repo.yaml +7 -0
- package/dist/examples/http-integration-config.yaml +30 -0
- package/dist/examples/https-server-config.yaml +15 -0
- package/dist/examples/mcp-provider-example.yaml +10 -10
- package/dist/examples/transform-example.yaml +3 -0
- package/dist/examples/webhook-pipeline-config.yaml +18 -0
- package/dist/examples/workflows/workflow-composition-example.yaml +4 -0
- package/dist/frontends/slack-frontend.d.ts +2 -0
- package/dist/frontends/slack-frontend.d.ts.map +1 -1
- package/dist/generated/config-schema.d.ts +11 -7
- package/dist/generated/config-schema.d.ts.map +1 -1
- package/dist/generated/config-schema.json +11 -7
- package/dist/index.js +3127 -974
- package/dist/output/traces/{run-2026-01-28T16-15-24-569Z.ndjson → run-2026-01-31T16-37-22-321Z.ndjson} +84 -84
- package/dist/output/traces/{run-2026-01-28T16-16-09-757Z.ndjson → run-2026-01-31T16-38-06-031Z.ndjson} +1013 -1013
- package/dist/providers/ai-check-provider.d.ts +9 -2
- package/dist/providers/ai-check-provider.d.ts.map +1 -1
- package/dist/providers/command-check-provider.d.ts.map +1 -1
- package/dist/providers/mcp-custom-sse-server.d.ts +17 -1
- package/dist/providers/mcp-custom-sse-server.d.ts.map +1 -1
- package/dist/providers/workflow-check-provider.d.ts.map +1 -1
- package/dist/providers/workflow-tool-executor.d.ts +68 -0
- package/dist/providers/workflow-tool-executor.d.ts.map +1 -0
- package/dist/sdk/{check-provider-registry-AQ3JETBG.mjs → check-provider-registry-3KI5RKXT.mjs} +6 -5
- package/dist/sdk/check-provider-registry-IYILYY35.mjs +28 -0
- package/dist/sdk/chunk-2CPMMNIX.mjs +1459 -0
- package/dist/sdk/chunk-2CPMMNIX.mjs.map +1 -0
- package/dist/sdk/chunk-5LI6T4O3.mjs +3600 -0
- package/dist/sdk/chunk-5LI6T4O3.mjs.map +1 -0
- package/dist/sdk/{chunk-YLQ4UN62.mjs → chunk-A4PGHURG.mjs} +6838 -6257
- package/dist/sdk/chunk-A4PGHURG.mjs.map +1 -0
- package/dist/sdk/chunk-EXFGO4FX.mjs +147 -0
- package/dist/sdk/chunk-EXFGO4FX.mjs.map +1 -0
- package/dist/sdk/chunk-PJ7K5UFC.mjs +17732 -0
- package/dist/sdk/chunk-PJ7K5UFC.mjs.map +1 -0
- package/dist/sdk/{chunk-BHZ4CKUS.mjs → chunk-PXFIALUH.mjs} +77 -8
- package/dist/sdk/chunk-PXFIALUH.mjs.map +1 -0
- package/dist/sdk/{chunk-PVITVJ6J.mjs → chunk-RTKJXNZS.mjs} +32 -9
- package/dist/sdk/chunk-RTKJXNZS.mjs.map +1 -0
- package/dist/sdk/chunk-VW2GBXQT.mjs +606 -0
- package/dist/sdk/chunk-VW2GBXQT.mjs.map +1 -0
- package/dist/sdk/{config-RQQPMLRD.mjs → config-5AUYQFHE.mjs} +2 -2
- package/dist/sdk/config-6CUVEH7H.mjs +16 -0
- package/dist/sdk/config-6CUVEH7H.mjs.map +1 -0
- package/dist/sdk/{github-frontend-6Q4BISZX.mjs → github-frontend-BZ4N3BFZ.mjs} +7 -3
- package/dist/sdk/github-frontend-BZ4N3BFZ.mjs.map +1 -0
- package/dist/sdk/host-4MT3EW2I.mjs +52 -0
- package/dist/sdk/{host-P5NQICP7.mjs → host-NYWXLIFC.mjs} +2 -2
- package/dist/sdk/host-NYWXLIFC.mjs.map +1 -0
- package/dist/sdk/{routing-DEY2AIXM.mjs → routing-6R42GXUO.mjs} +2 -2
- package/dist/sdk/routing-6R42GXUO.mjs.map +1 -0
- package/dist/sdk/routing-7FXPULTO.mjs +24 -0
- package/dist/sdk/routing-7FXPULTO.mjs.map +1 -0
- package/dist/sdk/sdk.d.mts +3 -1
- package/dist/sdk/sdk.d.ts +3 -1
- package/dist/sdk/sdk.js +12163 -11204
- package/dist/sdk/sdk.js.map +1 -1
- package/dist/sdk/sdk.mjs +14 -10
- package/dist/sdk/sdk.mjs.map +1 -1
- package/dist/sdk/slack-frontend-JUT3TYVC.mjs +821 -0
- package/dist/sdk/slack-frontend-JUT3TYVC.mjs.map +1 -0
- package/dist/sdk/workflow-check-provider-H3CUOLUD.mjs +28 -0
- package/dist/sdk/workflow-check-provider-H3CUOLUD.mjs.map +1 -0
- package/dist/sdk/workflow-check-provider-YUNNF4KC.mjs +28 -0
- package/dist/sdk/workflow-check-provider-YUNNF4KC.mjs.map +1 -0
- package/dist/sdk/workflow-registry-KFWSDSLM.mjs +12 -0
- package/dist/sdk/workflow-registry-KFWSDSLM.mjs.map +1 -0
- package/dist/slack/socket-runner.d.ts +2 -0
- package/dist/slack/socket-runner.d.ts.map +1 -1
- package/dist/state-machine/context/workflow-inputs.d.ts +20 -0
- package/dist/state-machine/context/workflow-inputs.d.ts.map +1 -0
- package/dist/state-machine/dispatch/execution-invoker.d.ts.map +1 -1
- package/dist/state-machine/dispatch/foreach-processor.d.ts.map +1 -1
- package/dist/state-machine/dispatch/stats-manager.d.ts.map +1 -1
- package/dist/state-machine/states/level-dispatch.d.ts.map +1 -1
- package/dist/state-machine/states/routing.d.ts +2 -1
- package/dist/state-machine/states/routing.d.ts.map +1 -1
- package/dist/traces/{run-2026-01-28T16-15-24-569Z.ndjson → run-2026-01-31T16-37-22-321Z.ndjson} +84 -84
- package/dist/traces/{run-2026-01-28T16-16-09-757Z.ndjson → run-2026-01-31T16-38-06-031Z.ndjson} +1013 -1013
- package/dist/types/config.d.ts +3 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/human-id.d.ts +12 -0
- package/dist/utils/human-id.d.ts.map +1 -0
- package/dist/utils/worktree-manager.d.ts +3 -0
- package/dist/utils/worktree-manager.d.ts.map +1 -1
- package/dist/workflow-executor.d.ts.map +1 -1
- package/dist/workflow-registry.d.ts +1 -0
- package/dist/workflow-registry.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/sdk/chunk-BHZ4CKUS.mjs.map +0 -1
- package/dist/sdk/chunk-PVITVJ6J.mjs.map +0 -1
- package/dist/sdk/chunk-YLQ4UN62.mjs.map +0 -1
- package/dist/sdk/github-frontend-6Q4BISZX.mjs.map +0 -1
- /package/dist/sdk/{check-provider-registry-AQ3JETBG.mjs.map → check-provider-registry-3KI5RKXT.mjs.map} +0 -0
- /package/dist/sdk/{config-RQQPMLRD.mjs.map → check-provider-registry-IYILYY35.mjs.map} +0 -0
- /package/dist/sdk/{routing-DEY2AIXM.mjs.map → config-5AUYQFHE.mjs.map} +0 -0
- /package/dist/sdk/{host-P5NQICP7.mjs.map → host-4MT3EW2I.mjs.map} +0 -0
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_logger,
|
|
3
|
+
logger
|
|
4
|
+
} from "./chunk-3NMLT3YS.mjs";
|
|
5
|
+
import {
|
|
6
|
+
__esm
|
|
7
|
+
} from "./chunk-WMJKH4XE.mjs";
|
|
8
|
+
|
|
9
|
+
// src/dependency-resolver.ts
|
|
10
|
+
var DependencyResolver;
|
|
11
|
+
var init_dependency_resolver = __esm({
|
|
12
|
+
"src/dependency-resolver.ts"() {
|
|
13
|
+
"use strict";
|
|
14
|
+
DependencyResolver = class {
|
|
15
|
+
/**
|
|
16
|
+
* Build dependency graph from check dependencies
|
|
17
|
+
*/
|
|
18
|
+
static buildDependencyGraph(checkDependencies) {
|
|
19
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
20
|
+
for (const checkId of Object.keys(checkDependencies)) {
|
|
21
|
+
nodes.set(checkId, {
|
|
22
|
+
id: checkId,
|
|
23
|
+
dependencies: checkDependencies[checkId] || [],
|
|
24
|
+
dependents: [],
|
|
25
|
+
depth: 0
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
for (const [checkId, dependencies] of Object.entries(checkDependencies)) {
|
|
29
|
+
for (const depId of dependencies || []) {
|
|
30
|
+
if (!nodes.has(depId)) {
|
|
31
|
+
throw new Error(`Check "${checkId}" depends on "${depId}" but "${depId}" is not defined`);
|
|
32
|
+
}
|
|
33
|
+
const depNode = nodes.get(depId);
|
|
34
|
+
depNode.dependents.push(checkId);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const cycleDetection = this.detectCycles(nodes);
|
|
38
|
+
if (cycleDetection.hasCycles) {
|
|
39
|
+
return {
|
|
40
|
+
nodes,
|
|
41
|
+
executionOrder: [],
|
|
42
|
+
hasCycles: true,
|
|
43
|
+
cycleNodes: cycleDetection.cycleNodes
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const executionOrder = this.topologicalSort(nodes);
|
|
47
|
+
return {
|
|
48
|
+
nodes,
|
|
49
|
+
executionOrder,
|
|
50
|
+
hasCycles: false
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Detect cycles in the dependency graph using DFS
|
|
55
|
+
*/
|
|
56
|
+
static detectCycles(nodes) {
|
|
57
|
+
const visited = /* @__PURE__ */ new Set();
|
|
58
|
+
const recursionStack = /* @__PURE__ */ new Set();
|
|
59
|
+
const cycleNodes = [];
|
|
60
|
+
const dfs = (nodeId) => {
|
|
61
|
+
if (recursionStack.has(nodeId)) {
|
|
62
|
+
cycleNodes.push(nodeId);
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
if (visited.has(nodeId)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
visited.add(nodeId);
|
|
69
|
+
recursionStack.add(nodeId);
|
|
70
|
+
const node = nodes.get(nodeId);
|
|
71
|
+
if (node) {
|
|
72
|
+
for (const depId of node.dependencies) {
|
|
73
|
+
if (dfs(depId)) {
|
|
74
|
+
cycleNodes.push(nodeId);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
recursionStack.delete(nodeId);
|
|
80
|
+
return false;
|
|
81
|
+
};
|
|
82
|
+
for (const nodeId of nodes.keys()) {
|
|
83
|
+
if (!visited.has(nodeId)) {
|
|
84
|
+
if (dfs(nodeId)) {
|
|
85
|
+
return { hasCycles: true, cycleNodes: [...new Set(cycleNodes)] };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return { hasCycles: false };
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Perform topological sort to determine execution order
|
|
93
|
+
* Groups checks that can run in parallel at each level
|
|
94
|
+
*/
|
|
95
|
+
static topologicalSort(nodes) {
|
|
96
|
+
const remainingNodes = new Map(nodes);
|
|
97
|
+
const executionGroups = [];
|
|
98
|
+
let level = 0;
|
|
99
|
+
while (remainingNodes.size > 0) {
|
|
100
|
+
const readyNodes = [];
|
|
101
|
+
for (const [nodeId, node] of remainingNodes.entries()) {
|
|
102
|
+
const unmetDependencies = node.dependencies.filter((depId) => remainingNodes.has(depId));
|
|
103
|
+
if (unmetDependencies.length === 0) {
|
|
104
|
+
readyNodes.push(nodeId);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (readyNodes.length === 0) {
|
|
108
|
+
throw new Error("Unable to resolve dependencies - possible circular dependency detected");
|
|
109
|
+
}
|
|
110
|
+
executionGroups.push({
|
|
111
|
+
parallel: readyNodes,
|
|
112
|
+
level
|
|
113
|
+
});
|
|
114
|
+
for (const nodeId of readyNodes) {
|
|
115
|
+
remainingNodes.delete(nodeId);
|
|
116
|
+
}
|
|
117
|
+
level++;
|
|
118
|
+
}
|
|
119
|
+
return executionGroups;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Validate that all dependencies exist
|
|
123
|
+
*/
|
|
124
|
+
static validateDependencies(checkIds, dependencies) {
|
|
125
|
+
const errors = [];
|
|
126
|
+
const checkIdSet = new Set(checkIds);
|
|
127
|
+
for (const [checkId, deps] of Object.entries(dependencies)) {
|
|
128
|
+
if (!checkIdSet.has(checkId)) {
|
|
129
|
+
errors.push(`Check "${checkId}" is not in the list of available checks`);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
for (const depId of deps || []) {
|
|
133
|
+
if (!checkIdSet.has(depId)) {
|
|
134
|
+
errors.push(`Check "${checkId}" depends on "${depId}" which is not available`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
valid: errors.length === 0,
|
|
140
|
+
errors
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get all transitive dependencies (ancestors) for a given check
|
|
145
|
+
* This returns all checks that must complete before the given check can run,
|
|
146
|
+
* not just the direct dependencies.
|
|
147
|
+
*
|
|
148
|
+
* For example, if A -> B -> C, then:
|
|
149
|
+
* - getAllDependencies(C) returns [A, B]
|
|
150
|
+
* - getAllDependencies(B) returns [A]
|
|
151
|
+
* - getAllDependencies(A) returns []
|
|
152
|
+
*
|
|
153
|
+
* @param checkId The check to find dependencies for
|
|
154
|
+
* @param nodes The dependency graph nodes
|
|
155
|
+
* @returns Array of all transitive dependency IDs
|
|
156
|
+
*/
|
|
157
|
+
static getAllDependencies(checkId, nodes) {
|
|
158
|
+
const allDeps = /* @__PURE__ */ new Set();
|
|
159
|
+
const visited = /* @__PURE__ */ new Set();
|
|
160
|
+
const collectDependencies = (currentId) => {
|
|
161
|
+
if (visited.has(currentId)) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
visited.add(currentId);
|
|
165
|
+
const node = nodes.get(currentId);
|
|
166
|
+
if (!node) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
for (const depId of node.dependencies) {
|
|
170
|
+
allDeps.add(depId);
|
|
171
|
+
collectDependencies(depId);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
collectDependencies(checkId);
|
|
175
|
+
return Array.from(allDeps);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Get execution statistics for debugging
|
|
179
|
+
*/
|
|
180
|
+
static getExecutionStats(graph) {
|
|
181
|
+
const totalChecks = graph.nodes.size;
|
|
182
|
+
const parallelLevels = graph.executionOrder.length;
|
|
183
|
+
const maxParallelism = Math.max(...graph.executionOrder.map((group) => group.parallel.length));
|
|
184
|
+
const averageParallelism = totalChecks / parallelLevels;
|
|
185
|
+
const checksWithDependencies = Array.from(graph.nodes.values()).filter(
|
|
186
|
+
(node) => node.dependencies.length > 0
|
|
187
|
+
).length;
|
|
188
|
+
return {
|
|
189
|
+
totalChecks,
|
|
190
|
+
parallelLevels,
|
|
191
|
+
maxParallelism,
|
|
192
|
+
averageParallelism,
|
|
193
|
+
checksWithDependencies
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// src/workflow-registry.ts
|
|
201
|
+
import { promises as fs } from "fs";
|
|
202
|
+
import * as path from "path";
|
|
203
|
+
import * as yaml from "js-yaml";
|
|
204
|
+
import Ajv from "ajv";
|
|
205
|
+
import addFormats from "ajv-formats";
|
|
206
|
+
var WorkflowRegistry;
|
|
207
|
+
var init_workflow_registry = __esm({
|
|
208
|
+
"src/workflow-registry.ts"() {
|
|
209
|
+
init_logger();
|
|
210
|
+
init_dependency_resolver();
|
|
211
|
+
WorkflowRegistry = class _WorkflowRegistry {
|
|
212
|
+
static instance;
|
|
213
|
+
workflows = /* @__PURE__ */ new Map();
|
|
214
|
+
ajv;
|
|
215
|
+
constructor() {
|
|
216
|
+
this.ajv = new Ajv({ allErrors: true, strict: false });
|
|
217
|
+
addFormats(this.ajv);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Get the singleton instance of the workflow registry
|
|
221
|
+
*/
|
|
222
|
+
static getInstance() {
|
|
223
|
+
if (!_WorkflowRegistry.instance) {
|
|
224
|
+
_WorkflowRegistry.instance = new _WorkflowRegistry();
|
|
225
|
+
}
|
|
226
|
+
return _WorkflowRegistry.instance;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Register a workflow definition
|
|
230
|
+
*/
|
|
231
|
+
register(workflow, source = "inline", options) {
|
|
232
|
+
const validation = this.validateWorkflow(workflow);
|
|
233
|
+
if (!validation.valid) {
|
|
234
|
+
return validation;
|
|
235
|
+
}
|
|
236
|
+
if (this.workflows.has(workflow.id) && !options?.override) {
|
|
237
|
+
return {
|
|
238
|
+
valid: false,
|
|
239
|
+
errors: [
|
|
240
|
+
{
|
|
241
|
+
path: "id",
|
|
242
|
+
message: `Workflow with ID '${workflow.id}' already exists`,
|
|
243
|
+
value: workflow.id
|
|
244
|
+
}
|
|
245
|
+
]
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
this.workflows.set(workflow.id, {
|
|
249
|
+
definition: workflow,
|
|
250
|
+
source,
|
|
251
|
+
registeredAt: /* @__PURE__ */ new Date(),
|
|
252
|
+
usage: {
|
|
253
|
+
count: 0
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
logger.debug(`Registered workflow '${workflow.id}' from ${source}`);
|
|
257
|
+
return { valid: true };
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Get a workflow by ID
|
|
261
|
+
*/
|
|
262
|
+
get(id) {
|
|
263
|
+
const entry = this.workflows.get(id);
|
|
264
|
+
if (entry) {
|
|
265
|
+
entry.usage = entry.usage || { count: 0 };
|
|
266
|
+
entry.usage.count++;
|
|
267
|
+
entry.usage.lastUsed = /* @__PURE__ */ new Date();
|
|
268
|
+
}
|
|
269
|
+
return entry?.definition;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Check if a workflow exists
|
|
273
|
+
*/
|
|
274
|
+
has(id) {
|
|
275
|
+
return this.workflows.has(id);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* List all registered workflows
|
|
279
|
+
*/
|
|
280
|
+
list() {
|
|
281
|
+
return Array.from(this.workflows.values()).map((entry) => entry.definition);
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Get workflow metadata
|
|
285
|
+
*/
|
|
286
|
+
getMetadata(id) {
|
|
287
|
+
return this.workflows.get(id);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Remove a workflow from the registry
|
|
291
|
+
*/
|
|
292
|
+
unregister(id) {
|
|
293
|
+
return this.workflows.delete(id);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Clear all workflows
|
|
297
|
+
*/
|
|
298
|
+
clear() {
|
|
299
|
+
this.workflows.clear();
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Import workflows from a file or URL
|
|
303
|
+
*/
|
|
304
|
+
async import(source, options) {
|
|
305
|
+
return this.importInternal(source, options, /* @__PURE__ */ new Set());
|
|
306
|
+
}
|
|
307
|
+
async importInternal(source, options, visited) {
|
|
308
|
+
const results = [];
|
|
309
|
+
try {
|
|
310
|
+
const { content, resolvedSource, importBasePath } = await this.loadWorkflowContent(
|
|
311
|
+
source,
|
|
312
|
+
options?.basePath
|
|
313
|
+
);
|
|
314
|
+
const visitKey = resolvedSource || source;
|
|
315
|
+
if (visited.has(visitKey)) {
|
|
316
|
+
return results;
|
|
317
|
+
}
|
|
318
|
+
visited.add(visitKey);
|
|
319
|
+
const data = this.parseWorkflowContent(content, resolvedSource || source);
|
|
320
|
+
const topImports = !Array.isArray(data) ? data?.imports : void 0;
|
|
321
|
+
if (Array.isArray(topImports)) {
|
|
322
|
+
for (const childSource of topImports) {
|
|
323
|
+
const childResults = await this.importInternal(
|
|
324
|
+
childSource,
|
|
325
|
+
{ ...options, basePath: importBasePath },
|
|
326
|
+
visited
|
|
327
|
+
);
|
|
328
|
+
results.push(...childResults);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const workflows = Array.isArray(data) ? data : [data];
|
|
332
|
+
for (const workflow of workflows) {
|
|
333
|
+
const workflowImports = workflow?.imports;
|
|
334
|
+
if (Array.isArray(workflowImports)) {
|
|
335
|
+
for (const childSource of workflowImports) {
|
|
336
|
+
const childResults = await this.importInternal(
|
|
337
|
+
childSource,
|
|
338
|
+
{ ...options, basePath: importBasePath },
|
|
339
|
+
visited
|
|
340
|
+
);
|
|
341
|
+
results.push(...childResults);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (options?.validate !== false) {
|
|
345
|
+
const validation = this.validateWorkflow(workflow);
|
|
346
|
+
if (!validation.valid) {
|
|
347
|
+
results.push(validation);
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
if (options?.validators) {
|
|
351
|
+
for (const validator of options.validators) {
|
|
352
|
+
const customValidation = validator(workflow);
|
|
353
|
+
if (!customValidation.valid) {
|
|
354
|
+
results.push(customValidation);
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
const workflowWithoutExtras = { ...workflow };
|
|
361
|
+
delete workflowWithoutExtras.tests;
|
|
362
|
+
delete workflowWithoutExtras.imports;
|
|
363
|
+
const result = this.register(workflowWithoutExtras, source, {
|
|
364
|
+
override: options?.override
|
|
365
|
+
});
|
|
366
|
+
results.push(result);
|
|
367
|
+
}
|
|
368
|
+
} catch (error) {
|
|
369
|
+
results.push({
|
|
370
|
+
valid: false,
|
|
371
|
+
errors: [
|
|
372
|
+
{
|
|
373
|
+
path: "source",
|
|
374
|
+
message: `Failed to import workflows from '${source}': ${error instanceof Error ? error.message : String(error)}`,
|
|
375
|
+
value: source
|
|
376
|
+
}
|
|
377
|
+
]
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
return results;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Import multiple workflow sources
|
|
384
|
+
*/
|
|
385
|
+
async importMany(sources, options) {
|
|
386
|
+
const results = /* @__PURE__ */ new Map();
|
|
387
|
+
for (const source of sources) {
|
|
388
|
+
const importResults = await this.import(source, options);
|
|
389
|
+
results.set(source, importResults);
|
|
390
|
+
}
|
|
391
|
+
return results;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Validate a workflow definition
|
|
395
|
+
*/
|
|
396
|
+
validateWorkflow(workflow) {
|
|
397
|
+
const errors = [];
|
|
398
|
+
const warnings = [];
|
|
399
|
+
if (!workflow.id) {
|
|
400
|
+
errors.push({ path: "id", message: "Workflow ID is required" });
|
|
401
|
+
}
|
|
402
|
+
if (!workflow.name) {
|
|
403
|
+
errors.push({ path: "name", message: "Workflow name is required" });
|
|
404
|
+
}
|
|
405
|
+
if (!workflow.steps || Object.keys(workflow.steps).length === 0) {
|
|
406
|
+
errors.push({ path: "steps", message: "Workflow must have at least one step" });
|
|
407
|
+
}
|
|
408
|
+
if (workflow.inputs) {
|
|
409
|
+
for (let i = 0; i < workflow.inputs.length; i++) {
|
|
410
|
+
const input = workflow.inputs[i];
|
|
411
|
+
if (!input.name) {
|
|
412
|
+
errors.push({ path: `inputs[${i}].name`, message: "Input parameter name is required" });
|
|
413
|
+
}
|
|
414
|
+
if (!input.schema) {
|
|
415
|
+
warnings.push({
|
|
416
|
+
path: `inputs[${i}].schema`,
|
|
417
|
+
message: "Input parameter schema is recommended"
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
if (workflow.outputs) {
|
|
423
|
+
for (let i = 0; i < workflow.outputs.length; i++) {
|
|
424
|
+
const output = workflow.outputs[i];
|
|
425
|
+
if (!output.name) {
|
|
426
|
+
errors.push({ path: `outputs[${i}].name`, message: "Output parameter name is required" });
|
|
427
|
+
}
|
|
428
|
+
if (!output.value && !output.value_js) {
|
|
429
|
+
errors.push({
|
|
430
|
+
path: `outputs[${i}]`,
|
|
431
|
+
message: "Output parameter must have either value or value_js"
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
for (const [stepId, step] of Object.entries(workflow.steps || {})) {
|
|
437
|
+
if (step.depends_on) {
|
|
438
|
+
for (const dep of step.depends_on) {
|
|
439
|
+
if (!workflow.steps[dep]) {
|
|
440
|
+
errors.push({
|
|
441
|
+
path: `steps.${stepId}.depends_on`,
|
|
442
|
+
message: `Step '${stepId}' depends on non-existent step '${dep}'`,
|
|
443
|
+
value: dep
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
if (step.inputs) {
|
|
449
|
+
for (const [inputName, mapping] of Object.entries(step.inputs)) {
|
|
450
|
+
if (typeof mapping === "object" && mapping !== null && "source" in mapping) {
|
|
451
|
+
const typedMapping = mapping;
|
|
452
|
+
if (typedMapping.source === "step" && !typedMapping.stepId) {
|
|
453
|
+
errors.push({
|
|
454
|
+
path: `steps.${stepId}.inputs.${inputName}`,
|
|
455
|
+
message: 'Step input mapping with source "step" must have stepId'
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
if (typedMapping.source === "param") {
|
|
459
|
+
const paramExists = workflow.inputs?.some((p) => p.name === typedMapping.value);
|
|
460
|
+
if (!paramExists) {
|
|
461
|
+
errors.push({
|
|
462
|
+
path: `steps.${stepId}.inputs.${inputName}`,
|
|
463
|
+
message: `Step input references non-existent parameter '${typedMapping.value}'`,
|
|
464
|
+
value: typedMapping.value
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
const circularDeps = this.detectCircularDependencies(workflow);
|
|
473
|
+
if (circularDeps.length > 0) {
|
|
474
|
+
errors.push({
|
|
475
|
+
path: "steps",
|
|
476
|
+
message: `Circular dependencies detected: ${circularDeps.join(" -> ")}`
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
return {
|
|
480
|
+
valid: errors.length === 0,
|
|
481
|
+
errors: errors.length > 0 ? errors : void 0,
|
|
482
|
+
warnings: warnings.length > 0 ? warnings : void 0
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* Validate input values against workflow input schema
|
|
487
|
+
*/
|
|
488
|
+
validateInputs(workflow, inputs) {
|
|
489
|
+
const errors = [];
|
|
490
|
+
if (!workflow.inputs) {
|
|
491
|
+
return { valid: true };
|
|
492
|
+
}
|
|
493
|
+
for (const param of workflow.inputs) {
|
|
494
|
+
if (param.required !== false && !(param.name in inputs) && param.default === void 0) {
|
|
495
|
+
errors.push({
|
|
496
|
+
path: `inputs.${param.name}`,
|
|
497
|
+
message: `Required input '${param.name}' is missing`
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
for (const param of workflow.inputs) {
|
|
502
|
+
if (param.name in inputs && param.schema) {
|
|
503
|
+
const value = inputs[param.name];
|
|
504
|
+
const valid = this.validateAgainstSchema(value, param.schema);
|
|
505
|
+
if (!valid.valid) {
|
|
506
|
+
errors.push({
|
|
507
|
+
path: `inputs.${param.name}`,
|
|
508
|
+
message: valid.error || "Invalid input value",
|
|
509
|
+
value
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return {
|
|
515
|
+
valid: errors.length === 0,
|
|
516
|
+
errors: errors.length > 0 ? errors : void 0
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Load workflow content from file or URL
|
|
521
|
+
*/
|
|
522
|
+
async loadWorkflowContent(source, basePath) {
|
|
523
|
+
const baseIsUrl = basePath?.startsWith("http://") || basePath?.startsWith("https://");
|
|
524
|
+
if (source.startsWith("http://") || source.startsWith("https://")) {
|
|
525
|
+
const response = await fetch(source);
|
|
526
|
+
if (!response.ok) {
|
|
527
|
+
throw new Error(`Failed to fetch workflow from ${source}: ${response.statusText}`);
|
|
528
|
+
}
|
|
529
|
+
const importBasePath = new URL(".", source).toString();
|
|
530
|
+
return { content: await response.text(), resolvedSource: source, importBasePath };
|
|
531
|
+
}
|
|
532
|
+
if (baseIsUrl) {
|
|
533
|
+
const resolvedUrl = new URL(source, basePath).toString();
|
|
534
|
+
const response = await fetch(resolvedUrl);
|
|
535
|
+
if (!response.ok) {
|
|
536
|
+
throw new Error(`Failed to fetch workflow from ${resolvedUrl}: ${response.statusText}`);
|
|
537
|
+
}
|
|
538
|
+
const importBasePath = new URL(".", resolvedUrl).toString();
|
|
539
|
+
return { content: await response.text(), resolvedSource: resolvedUrl, importBasePath };
|
|
540
|
+
}
|
|
541
|
+
const filePath = path.isAbsolute(source) ? source : path.resolve(basePath || process.cwd(), source);
|
|
542
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
543
|
+
return { content, resolvedSource: filePath, importBasePath: path.dirname(filePath) };
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Parse workflow content (YAML or JSON)
|
|
547
|
+
*/
|
|
548
|
+
parseWorkflowContent(content, source) {
|
|
549
|
+
try {
|
|
550
|
+
return JSON.parse(content);
|
|
551
|
+
} catch {
|
|
552
|
+
try {
|
|
553
|
+
return yaml.load(content);
|
|
554
|
+
} catch (error) {
|
|
555
|
+
throw new Error(
|
|
556
|
+
`Failed to parse workflow file ${source}: ${error instanceof Error ? error.message : String(error)}`
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Detect circular dependencies in workflow steps using DependencyResolver
|
|
563
|
+
*/
|
|
564
|
+
detectCircularDependencies(workflow) {
|
|
565
|
+
const dependencies = {};
|
|
566
|
+
for (const [stepId, step] of Object.entries(workflow.steps || {})) {
|
|
567
|
+
const rawDeps = step.depends_on;
|
|
568
|
+
dependencies[stepId] = Array.isArray(rawDeps) ? rawDeps : rawDeps ? [rawDeps] : [];
|
|
569
|
+
}
|
|
570
|
+
try {
|
|
571
|
+
const graph = DependencyResolver.buildDependencyGraph(dependencies);
|
|
572
|
+
if (graph.hasCycles && graph.cycleNodes) {
|
|
573
|
+
return graph.cycleNodes;
|
|
574
|
+
}
|
|
575
|
+
return [];
|
|
576
|
+
} catch {
|
|
577
|
+
return [];
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Validate a value against a JSON schema
|
|
582
|
+
*/
|
|
583
|
+
validateAgainstSchema(value, schema) {
|
|
584
|
+
try {
|
|
585
|
+
const validate = this.ajv.compile(schema);
|
|
586
|
+
const valid = validate(value);
|
|
587
|
+
if (!valid) {
|
|
588
|
+
const errors = validate.errors?.map((e) => `${e.instancePath || "/"}: ${e.message}`).join(", ");
|
|
589
|
+
return { valid: false, error: errors };
|
|
590
|
+
}
|
|
591
|
+
return { valid: true };
|
|
592
|
+
} catch (error) {
|
|
593
|
+
return { valid: false, error: error instanceof Error ? error.message : String(error) };
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
export {
|
|
601
|
+
DependencyResolver,
|
|
602
|
+
init_dependency_resolver,
|
|
603
|
+
WorkflowRegistry,
|
|
604
|
+
init_workflow_registry
|
|
605
|
+
};
|
|
606
|
+
//# sourceMappingURL=chunk-VW2GBXQT.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/dependency-resolver.ts","../../src/workflow-registry.ts"],"sourcesContent":["/**\n * Dependency resolution and execution ordering for checks\n */\n\nexport interface CheckNode {\n id: string;\n dependencies: string[];\n dependents: string[];\n depth: number;\n}\n\nexport interface ExecutionGroup {\n /** Checks that can run in parallel */\n parallel: string[];\n /** Execution level/wave (0 = no dependencies, 1 = depends on level 0, etc.) */\n level: number;\n}\n\nexport interface DependencyGraph {\n nodes: Map<string, CheckNode>;\n executionOrder: ExecutionGroup[];\n hasCycles: boolean;\n cycleNodes?: string[];\n}\n\nexport class DependencyResolver {\n /**\n * Build dependency graph from check dependencies\n */\n static buildDependencyGraph(checkDependencies: Record<string, string[]>): DependencyGraph {\n const nodes = new Map<string, CheckNode>();\n\n // Initialize all nodes\n for (const checkId of Object.keys(checkDependencies)) {\n nodes.set(checkId, {\n id: checkId,\n dependencies: checkDependencies[checkId] || [],\n dependents: [],\n depth: 0,\n });\n }\n\n // Build bidirectional relationships\n for (const [checkId, dependencies] of Object.entries(checkDependencies)) {\n for (const depId of dependencies || []) {\n if (!nodes.has(depId)) {\n throw new Error(`Check \"${checkId}\" depends on \"${depId}\" but \"${depId}\" is not defined`);\n }\n\n const depNode = nodes.get(depId)!;\n depNode.dependents.push(checkId);\n }\n }\n\n // Detect cycles using DFS\n const cycleDetection = this.detectCycles(nodes);\n if (cycleDetection.hasCycles) {\n return {\n nodes,\n executionOrder: [],\n hasCycles: true,\n cycleNodes: cycleDetection.cycleNodes,\n };\n }\n\n // Calculate execution order using topological sort\n const executionOrder = this.topologicalSort(nodes);\n\n return {\n nodes,\n executionOrder,\n hasCycles: false,\n };\n }\n\n /**\n * Detect cycles in the dependency graph using DFS\n */\n private static detectCycles(nodes: Map<string, CheckNode>): {\n hasCycles: boolean;\n cycleNodes?: string[];\n } {\n const visited = new Set<string>();\n const recursionStack = new Set<string>();\n const cycleNodes: string[] = [];\n\n const dfs = (nodeId: string): boolean => {\n if (recursionStack.has(nodeId)) {\n cycleNodes.push(nodeId);\n return true;\n }\n if (visited.has(nodeId)) {\n return false;\n }\n\n visited.add(nodeId);\n recursionStack.add(nodeId);\n\n const node = nodes.get(nodeId);\n if (node) {\n for (const depId of node.dependencies) {\n if (dfs(depId)) {\n cycleNodes.push(nodeId);\n return true;\n }\n }\n }\n\n recursionStack.delete(nodeId);\n return false;\n };\n\n for (const nodeId of nodes.keys()) {\n if (!visited.has(nodeId)) {\n if (dfs(nodeId)) {\n return { hasCycles: true, cycleNodes: [...new Set(cycleNodes)] };\n }\n }\n }\n\n return { hasCycles: false };\n }\n\n /**\n * Perform topological sort to determine execution order\n * Groups checks that can run in parallel at each level\n */\n private static topologicalSort(nodes: Map<string, CheckNode>): ExecutionGroup[] {\n const remainingNodes = new Map(nodes);\n const executionGroups: ExecutionGroup[] = [];\n let level = 0;\n\n while (remainingNodes.size > 0) {\n // Find nodes with no remaining dependencies\n const readyNodes: string[] = [];\n\n for (const [nodeId, node] of remainingNodes.entries()) {\n const unmetDependencies = node.dependencies.filter(depId => remainingNodes.has(depId));\n if (unmetDependencies.length === 0) {\n readyNodes.push(nodeId);\n }\n }\n\n if (readyNodes.length === 0) {\n // This shouldn't happen if cycle detection worked correctly\n throw new Error('Unable to resolve dependencies - possible circular dependency detected');\n }\n\n // Add this group to execution order\n executionGroups.push({\n parallel: readyNodes,\n level,\n });\n\n // Remove processed nodes\n for (const nodeId of readyNodes) {\n remainingNodes.delete(nodeId);\n }\n\n level++;\n }\n\n return executionGroups;\n }\n\n /**\n * Validate that all dependencies exist\n */\n static validateDependencies(\n checkIds: string[],\n dependencies: Record<string, string[]>\n ): { valid: boolean; errors: string[] } {\n const errors: string[] = [];\n const checkIdSet = new Set(checkIds);\n\n for (const [checkId, deps] of Object.entries(dependencies)) {\n if (!checkIdSet.has(checkId)) {\n errors.push(`Check \"${checkId}\" is not in the list of available checks`);\n continue;\n }\n\n for (const depId of deps || []) {\n if (!checkIdSet.has(depId)) {\n errors.push(`Check \"${checkId}\" depends on \"${depId}\" which is not available`);\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n };\n }\n\n /**\n * Get all transitive dependencies (ancestors) for a given check\n * This returns all checks that must complete before the given check can run,\n * not just the direct dependencies.\n *\n * For example, if A -> B -> C, then:\n * - getAllDependencies(C) returns [A, B]\n * - getAllDependencies(B) returns [A]\n * - getAllDependencies(A) returns []\n *\n * @param checkId The check to find dependencies for\n * @param nodes The dependency graph nodes\n * @returns Array of all transitive dependency IDs\n */\n static getAllDependencies(checkId: string, nodes: Map<string, CheckNode>): string[] {\n const allDeps = new Set<string>();\n const visited = new Set<string>();\n\n const collectDependencies = (currentId: string) => {\n if (visited.has(currentId)) {\n return;\n }\n visited.add(currentId);\n\n const node = nodes.get(currentId);\n if (!node) {\n return;\n }\n\n // Add direct dependencies and recurse\n for (const depId of node.dependencies) {\n allDeps.add(depId);\n collectDependencies(depId);\n }\n };\n\n collectDependencies(checkId);\n return Array.from(allDeps);\n }\n\n /**\n * Get execution statistics for debugging\n */\n static getExecutionStats(graph: DependencyGraph): {\n totalChecks: number;\n parallelLevels: number;\n maxParallelism: number;\n averageParallelism: number;\n checksWithDependencies: number;\n } {\n const totalChecks = graph.nodes.size;\n const parallelLevels = graph.executionOrder.length;\n const maxParallelism = Math.max(...graph.executionOrder.map(group => group.parallel.length));\n const averageParallelism = totalChecks / parallelLevels;\n const checksWithDependencies = Array.from(graph.nodes.values()).filter(\n node => node.dependencies.length > 0\n ).length;\n\n return {\n totalChecks,\n parallelLevels,\n maxParallelism,\n averageParallelism,\n checksWithDependencies,\n };\n }\n}\n","/**\n * Workflow registry for managing reusable workflow definitions\n */\n\nimport {\n WorkflowDefinition,\n WorkflowRegistryEntry,\n WorkflowValidationResult,\n WorkflowImportOptions,\n JsonSchema,\n} from './types/workflow';\nimport { promises as fs } from 'fs';\nimport * as path from 'path';\nimport * as yaml from 'js-yaml';\nimport { logger } from './logger';\nimport { DependencyResolver } from './dependency-resolver';\nimport Ajv from 'ajv';\nimport addFormats from 'ajv-formats';\n\n/**\n * Registry for managing workflow definitions\n */\nexport class WorkflowRegistry {\n private static instance: WorkflowRegistry;\n private workflows: Map<string, WorkflowRegistryEntry> = new Map();\n private ajv: Ajv;\n\n private constructor() {\n this.ajv = new Ajv({ allErrors: true, strict: false });\n addFormats(this.ajv);\n }\n\n /**\n * Get the singleton instance of the workflow registry\n */\n public static getInstance(): WorkflowRegistry {\n if (!WorkflowRegistry.instance) {\n WorkflowRegistry.instance = new WorkflowRegistry();\n }\n return WorkflowRegistry.instance;\n }\n\n /**\n * Register a workflow definition\n */\n public register(\n workflow: WorkflowDefinition,\n source: string = 'inline',\n options?: { override?: boolean }\n ): WorkflowValidationResult {\n // Validate the workflow\n const validation = this.validateWorkflow(workflow);\n if (!validation.valid) {\n return validation;\n }\n\n // Check if workflow already exists\n if (this.workflows.has(workflow.id) && !options?.override) {\n return {\n valid: false,\n errors: [\n {\n path: 'id',\n message: `Workflow with ID '${workflow.id}' already exists`,\n value: workflow.id,\n },\n ],\n };\n }\n\n // Register the workflow\n this.workflows.set(workflow.id, {\n definition: workflow,\n source,\n registeredAt: new Date(),\n usage: {\n count: 0,\n },\n });\n\n logger.debug(`Registered workflow '${workflow.id}' from ${source}`);\n return { valid: true };\n }\n\n /**\n * Get a workflow by ID\n */\n public get(id: string): WorkflowDefinition | undefined {\n const entry = this.workflows.get(id);\n if (entry) {\n // Update usage statistics\n entry.usage = entry.usage || { count: 0 };\n entry.usage.count++;\n entry.usage.lastUsed = new Date();\n }\n return entry?.definition;\n }\n\n /**\n * Check if a workflow exists\n */\n public has(id: string): boolean {\n return this.workflows.has(id);\n }\n\n /**\n * List all registered workflows\n */\n public list(): WorkflowDefinition[] {\n return Array.from(this.workflows.values()).map(entry => entry.definition);\n }\n\n /**\n * Get workflow metadata\n */\n public getMetadata(id: string): WorkflowRegistryEntry | undefined {\n return this.workflows.get(id);\n }\n\n /**\n * Remove a workflow from the registry\n */\n public unregister(id: string): boolean {\n return this.workflows.delete(id);\n }\n\n /**\n * Clear all workflows\n */\n public clear(): void {\n this.workflows.clear();\n }\n\n /**\n * Import workflows from a file or URL\n */\n public async import(\n source: string,\n options?: WorkflowImportOptions\n ): Promise<WorkflowValidationResult[]> {\n return this.importInternal(source, options, new Set<string>());\n }\n\n private async importInternal(\n source: string,\n options: WorkflowImportOptions | undefined,\n visited: Set<string>\n ): Promise<WorkflowValidationResult[]> {\n const results: WorkflowValidationResult[] = [];\n\n try {\n // Load the workflow file\n const { content, resolvedSource, importBasePath } = await this.loadWorkflowContent(\n source,\n options?.basePath\n );\n const visitKey = resolvedSource || source;\n if (visited.has(visitKey)) {\n return results;\n }\n visited.add(visitKey);\n\n const data = this.parseWorkflowContent(content, resolvedSource || source);\n\n // Process top-level imports if present\n const topImports = !Array.isArray(data) ? (data as any)?.imports : undefined;\n if (Array.isArray(topImports)) {\n for (const childSource of topImports) {\n const childResults = await this.importInternal(\n childSource,\n { ...options, basePath: importBasePath },\n visited\n );\n results.push(...childResults);\n }\n }\n\n // Handle both single workflow and multiple workflows\n const workflows: WorkflowDefinition[] = Array.isArray(data) ? data : [data];\n\n for (const workflow of workflows) {\n const workflowImports = (workflow as any)?.imports;\n if (Array.isArray(workflowImports)) {\n for (const childSource of workflowImports) {\n const childResults = await this.importInternal(\n childSource,\n { ...options, basePath: importBasePath },\n visited\n );\n results.push(...childResults);\n }\n }\n\n // Validate if requested\n if (options?.validate !== false) {\n const validation = this.validateWorkflow(workflow);\n if (!validation.valid) {\n results.push(validation);\n continue;\n }\n\n // Run custom validators if provided\n if (options?.validators) {\n for (const validator of options.validators) {\n const customValidation = validator(workflow);\n if (!customValidation.valid) {\n results.push(customValidation);\n continue;\n }\n }\n }\n }\n\n // Strip out fields before registering\n const workflowWithoutExtras = { ...workflow };\n delete (workflowWithoutExtras as any).tests;\n delete (workflowWithoutExtras as any).imports;\n\n // Register the workflow (without tests/imports)\n const result = this.register(workflowWithoutExtras, source, {\n override: options?.override,\n });\n results.push(result);\n }\n } catch (error) {\n results.push({\n valid: false,\n errors: [\n {\n path: 'source',\n message: `Failed to import workflows from '${source}': ${error instanceof Error ? error.message : String(error)}`,\n value: source,\n },\n ],\n });\n }\n\n return results;\n }\n\n /**\n * Import multiple workflow sources\n */\n public async importMany(\n sources: string[],\n options?: WorkflowImportOptions\n ): Promise<Map<string, WorkflowValidationResult[]>> {\n const results = new Map<string, WorkflowValidationResult[]>();\n\n for (const source of sources) {\n const importResults = await this.import(source, options);\n results.set(source, importResults);\n }\n\n return results;\n }\n\n /**\n * Validate a workflow definition\n */\n public validateWorkflow(workflow: WorkflowDefinition): WorkflowValidationResult {\n const errors: Array<{ path: string; message: string; value?: unknown }> = [];\n const warnings: Array<{ path: string; message: string }> = [];\n\n // Validate required fields\n if (!workflow.id) {\n errors.push({ path: 'id', message: 'Workflow ID is required' });\n }\n\n if (!workflow.name) {\n errors.push({ path: 'name', message: 'Workflow name is required' });\n }\n\n if (!workflow.steps || Object.keys(workflow.steps).length === 0) {\n errors.push({ path: 'steps', message: 'Workflow must have at least one step' });\n }\n\n // Validate input parameters\n if (workflow.inputs) {\n for (let i = 0; i < workflow.inputs.length; i++) {\n const input = workflow.inputs[i];\n if (!input.name) {\n errors.push({ path: `inputs[${i}].name`, message: 'Input parameter name is required' });\n }\n if (!input.schema) {\n warnings.push({\n path: `inputs[${i}].schema`,\n message: 'Input parameter schema is recommended',\n });\n }\n }\n }\n\n // Validate output parameters\n if (workflow.outputs) {\n for (let i = 0; i < workflow.outputs.length; i++) {\n const output = workflow.outputs[i];\n if (!output.name) {\n errors.push({ path: `outputs[${i}].name`, message: 'Output parameter name is required' });\n }\n if (!output.value && !output.value_js) {\n errors.push({\n path: `outputs[${i}]`,\n message: 'Output parameter must have either value or value_js',\n });\n }\n }\n }\n\n // Validate steps\n for (const [stepId, step] of Object.entries(workflow.steps || {})) {\n // Validate step dependencies\n if (step.depends_on) {\n for (const dep of step.depends_on) {\n if (!workflow.steps[dep]) {\n errors.push({\n path: `steps.${stepId}.depends_on`,\n message: `Step '${stepId}' depends on non-existent step '${dep}'`,\n value: dep,\n });\n }\n }\n }\n\n // Validate input mappings\n if (step.inputs) {\n for (const [inputName, mapping] of Object.entries(step.inputs)) {\n if (typeof mapping === 'object' && mapping !== null && 'source' in mapping) {\n const typedMapping = mapping as any;\n if (typedMapping.source === 'step' && !typedMapping.stepId) {\n errors.push({\n path: `steps.${stepId}.inputs.${inputName}`,\n message: 'Step input mapping with source \"step\" must have stepId',\n });\n }\n if (typedMapping.source === 'param') {\n // Validate that the parameter exists\n const paramExists = workflow.inputs?.some(p => p.name === typedMapping.value);\n if (!paramExists) {\n errors.push({\n path: `steps.${stepId}.inputs.${inputName}`,\n message: `Step input references non-existent parameter '${typedMapping.value}'`,\n value: typedMapping.value,\n });\n }\n }\n }\n }\n }\n }\n\n // Check for circular dependencies\n const circularDeps = this.detectCircularDependencies(workflow);\n if (circularDeps.length > 0) {\n errors.push({\n path: 'steps',\n message: `Circular dependencies detected: ${circularDeps.join(' -> ')}`,\n });\n }\n\n return {\n valid: errors.length === 0,\n errors: errors.length > 0 ? errors : undefined,\n warnings: warnings.length > 0 ? warnings : undefined,\n };\n }\n\n /**\n * Validate input values against workflow input schema\n */\n public validateInputs(\n workflow: WorkflowDefinition,\n inputs: Record<string, unknown>\n ): WorkflowValidationResult {\n const errors: Array<{ path: string; message: string; value?: unknown }> = [];\n\n if (!workflow.inputs) {\n return { valid: true };\n }\n\n // Check required inputs\n for (const param of workflow.inputs) {\n if (param.required !== false && !(param.name in inputs) && param.default === undefined) {\n errors.push({\n path: `inputs.${param.name}`,\n message: `Required input '${param.name}' is missing`,\n });\n }\n }\n\n // Validate input schemas\n for (const param of workflow.inputs) {\n if (param.name in inputs && param.schema) {\n const value = inputs[param.name];\n const valid = this.validateAgainstSchema(value, param.schema);\n if (!valid.valid) {\n errors.push({\n path: `inputs.${param.name}`,\n message: valid.error || 'Invalid input value',\n value,\n });\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors: errors.length > 0 ? errors : undefined,\n };\n }\n\n /**\n * Load workflow content from file or URL\n */\n private async loadWorkflowContent(\n source: string,\n basePath?: string\n ): Promise<{ content: string; resolvedSource: string; importBasePath?: string }> {\n const baseIsUrl = basePath?.startsWith('http://') || basePath?.startsWith('https://');\n\n // Handle URLs\n if (source.startsWith('http://') || source.startsWith('https://')) {\n const response = await fetch(source);\n if (!response.ok) {\n throw new Error(`Failed to fetch workflow from ${source}: ${response.statusText}`);\n }\n const importBasePath = new URL('.', source).toString();\n return { content: await response.text(), resolvedSource: source, importBasePath };\n }\n\n // Handle relative URLs when basePath is a URL\n if (baseIsUrl) {\n const resolvedUrl = new URL(source, basePath).toString();\n const response = await fetch(resolvedUrl);\n if (!response.ok) {\n throw new Error(`Failed to fetch workflow from ${resolvedUrl}: ${response.statusText}`);\n }\n const importBasePath = new URL('.', resolvedUrl).toString();\n return { content: await response.text(), resolvedSource: resolvedUrl, importBasePath };\n }\n\n // Handle file paths\n const filePath = path.isAbsolute(source)\n ? source\n : path.resolve(basePath || process.cwd(), source);\n const content = await fs.readFile(filePath, 'utf-8');\n return { content, resolvedSource: filePath, importBasePath: path.dirname(filePath) };\n }\n\n /**\n * Parse workflow content (YAML or JSON)\n */\n private parseWorkflowContent(content: string, source: string): any {\n // Try JSON first\n try {\n return JSON.parse(content);\n } catch {\n // Try YAML\n try {\n return yaml.load(content);\n } catch (error) {\n throw new Error(\n `Failed to parse workflow file ${source}: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n }\n\n /**\n * Detect circular dependencies in workflow steps using DependencyResolver\n */\n private detectCircularDependencies(workflow: WorkflowDefinition): string[] {\n // Build dependency map\n const dependencies: Record<string, string[]> = {};\n for (const [stepId, step] of Object.entries(workflow.steps || {})) {\n // Normalize depends_on to array (supports string | string[])\n const rawDeps = step.depends_on;\n dependencies[stepId] = Array.isArray(rawDeps) ? rawDeps : rawDeps ? [rawDeps] : [];\n }\n\n try {\n // Use DependencyResolver to check for cycles\n const graph = DependencyResolver.buildDependencyGraph(dependencies);\n\n if (graph.hasCycles && graph.cycleNodes) {\n return graph.cycleNodes;\n }\n\n return [];\n } catch {\n // DependencyResolver throws error for non-existent dependencies\n // This should be caught by the dependency validation in validateWorkflow\n // Return empty array here and let the validation handle it\n return [];\n }\n }\n\n /**\n * Validate a value against a JSON schema\n */\n private validateAgainstSchema(\n value: unknown,\n schema: JsonSchema\n ): { valid: boolean; error?: string } {\n try {\n const validate = this.ajv.compile(schema as any);\n const valid = validate(value);\n if (!valid) {\n const errors = validate.errors\n ?.map(e => `${e.instancePath || '/'}: ${e.message}`)\n .join(', ');\n return { valid: false, error: errors };\n }\n return { valid: true };\n } catch (error) {\n return { valid: false, error: error instanceof Error ? error.message : String(error) };\n }\n }\n}\n"],"mappings":";;;;;;;;;AAAA,IAyBa;AAzBb;AAAA;AAAA;AAyBO,IAAM,qBAAN,MAAyB;AAAA;AAAA;AAAA;AAAA,MAI9B,OAAO,qBAAqB,mBAA8D;AACxF,cAAM,QAAQ,oBAAI,IAAuB;AAGzC,mBAAW,WAAW,OAAO,KAAK,iBAAiB,GAAG;AACpD,gBAAM,IAAI,SAAS;AAAA,YACjB,IAAI;AAAA,YACJ,cAAc,kBAAkB,OAAO,KAAK,CAAC;AAAA,YAC7C,YAAY,CAAC;AAAA,YACb,OAAO;AAAA,UACT,CAAC;AAAA,QACH;AAGA,mBAAW,CAAC,SAAS,YAAY,KAAK,OAAO,QAAQ,iBAAiB,GAAG;AACvE,qBAAW,SAAS,gBAAgB,CAAC,GAAG;AACtC,gBAAI,CAAC,MAAM,IAAI,KAAK,GAAG;AACrB,oBAAM,IAAI,MAAM,UAAU,OAAO,iBAAiB,KAAK,UAAU,KAAK,kBAAkB;AAAA,YAC1F;AAEA,kBAAM,UAAU,MAAM,IAAI,KAAK;AAC/B,oBAAQ,WAAW,KAAK,OAAO;AAAA,UACjC;AAAA,QACF;AAGA,cAAM,iBAAiB,KAAK,aAAa,KAAK;AAC9C,YAAI,eAAe,WAAW;AAC5B,iBAAO;AAAA,YACL;AAAA,YACA,gBAAgB,CAAC;AAAA,YACjB,WAAW;AAAA,YACX,YAAY,eAAe;AAAA,UAC7B;AAAA,QACF;AAGA,cAAM,iBAAiB,KAAK,gBAAgB,KAAK;AAEjD,eAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA,WAAW;AAAA,QACb;AAAA,MACF;AAAA;AAAA;AAAA;AAAA,MAKA,OAAe,aAAa,OAG1B;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