@hexabot-ai/agentic 3.2.3 → 3.2.4
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/cjs/bindings/base-binding.js +98 -25
- package/dist/cjs/dsl.types.js +141 -34
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/validation-issue.js +10 -0
- package/dist/cjs/workflow-compiler.js +3 -2
- package/dist/cjs/workflow.js +3 -2
- package/dist/esm/bindings/base-binding.js +98 -25
- package/dist/esm/dsl.types.js +141 -34
- package/dist/esm/index.js +1 -0
- package/dist/esm/validation-issue.js +6 -0
- package/dist/esm/workflow-compiler.js +3 -2
- package/dist/esm/workflow.js +3 -2
- package/dist/types/bindings/base-binding.d.ts +2 -1
- package/dist/types/bindings/base-binding.d.ts.map +1 -1
- package/dist/types/dsl.types.d.ts +4 -1
- package/dist/types/dsl.types.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/validation-issue.d.ts +16 -0
- package/dist/types/validation-issue.d.ts.map +1 -0
- package/dist/types/workflow-compiler.d.ts.map +1 -1
- package/dist/types/workflow.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/validation.test.ts +235 -17
- package/src/bindings/base-binding.ts +116 -62
- package/src/dsl.types.ts +225 -40
- package/src/index.ts +6 -0
- package/src/validation-issue.ts +38 -0
- package/src/workflow-compiler.ts +3 -2
- package/src/workflow.ts +3 -2
|
@@ -22,9 +22,18 @@ const hasBindingsConfigured = (workflow) => {
|
|
|
22
22
|
const hasNestedBindings = Object.values(defs).some((definition) => definition.bindings && Object.keys(definition.bindings).length > 0);
|
|
23
23
|
return hasNonTaskDefs || hasNestedBindings;
|
|
24
24
|
};
|
|
25
|
-
const
|
|
25
|
+
const toBindingSettingsIssues = (zodIssues, defName) => zodIssues.map((issue) => {
|
|
26
26
|
const path = issue.path.join('.') || '<root>';
|
|
27
|
-
return
|
|
27
|
+
return {
|
|
28
|
+
code: 'binding_settings',
|
|
29
|
+
message: `defs.${defName}.settings.${path}: ${issue.message}`,
|
|
30
|
+
path: [
|
|
31
|
+
'defs',
|
|
32
|
+
defName,
|
|
33
|
+
'settings',
|
|
34
|
+
...issue.path.filter((segment) => typeof segment === 'string' || typeof segment === 'number'),
|
|
35
|
+
],
|
|
36
|
+
};
|
|
28
37
|
});
|
|
29
38
|
const collectDuplicateReferences = (refs) => {
|
|
30
39
|
const seen = new Set();
|
|
@@ -52,7 +61,7 @@ const collectBindingRefs = (bindings) => {
|
|
|
52
61
|
return refs;
|
|
53
62
|
};
|
|
54
63
|
const detectBindingCycles = (defs) => {
|
|
55
|
-
const
|
|
64
|
+
const issues = [];
|
|
56
65
|
const reportedCycles = new Set();
|
|
57
66
|
const states = new Map();
|
|
58
67
|
const stack = [];
|
|
@@ -71,7 +80,11 @@ const detectBindingCycles = (defs) => {
|
|
|
71
80
|
const cycleKey = cyclePath.join('->');
|
|
72
81
|
if (!reportedCycles.has(cycleKey)) {
|
|
73
82
|
reportedCycles.add(cycleKey);
|
|
74
|
-
|
|
83
|
+
issues.push({
|
|
84
|
+
code: 'binding_cycle',
|
|
85
|
+
message: `defs.${defName}.bindings: Circular binding reference detected (${cyclePath.join(' -> ')}).`,
|
|
86
|
+
path: ['defs', defName, 'bindings'],
|
|
87
|
+
});
|
|
75
88
|
}
|
|
76
89
|
return;
|
|
77
90
|
}
|
|
@@ -90,16 +103,22 @@ const detectBindingCycles = (defs) => {
|
|
|
90
103
|
for (const defName of defNames) {
|
|
91
104
|
visit(defName);
|
|
92
105
|
}
|
|
93
|
-
return
|
|
106
|
+
return issues;
|
|
94
107
|
};
|
|
95
|
-
const
|
|
108
|
+
const missingActionIssue = (defName, actionName) => ({
|
|
109
|
+
code: 'missing_action',
|
|
110
|
+
message: `defs.${defName}.action: No action implementation provided for "${actionName}".`,
|
|
111
|
+
path: ['defs', defName, 'action'],
|
|
112
|
+
actionName,
|
|
113
|
+
});
|
|
114
|
+
const resolveSupportedBindingKinds = (definition, defName, kinds, actions, issues) => {
|
|
96
115
|
if (definition.action) {
|
|
97
116
|
if (!actions) {
|
|
98
117
|
return null;
|
|
99
118
|
}
|
|
100
119
|
const action = actions[definition.action];
|
|
101
120
|
if (!action) {
|
|
102
|
-
|
|
121
|
+
issues.push(missingActionIssue(defName, definition.action));
|
|
103
122
|
return [];
|
|
104
123
|
}
|
|
105
124
|
return action.supportedBindings ?? [];
|
|
@@ -110,7 +129,7 @@ const resolveSupportedBindingKinds = (definition, defName, kinds, actions, error
|
|
|
110
129
|
return kinds[definition.kind]?.supportedBindings ?? [];
|
|
111
130
|
};
|
|
112
131
|
const validateAndResolveBindings = (workflow, options) => {
|
|
113
|
-
const
|
|
132
|
+
const issues = [];
|
|
114
133
|
const resolvedDefs = {};
|
|
115
134
|
const defs = workflow.defs ?? {};
|
|
116
135
|
const resolvedOptions = resolveValidationOptions(options);
|
|
@@ -120,34 +139,52 @@ const validateAndResolveBindings = (workflow, options) => {
|
|
|
120
139
|
const hasBindingUsage = hasBindingsConfigured(workflow);
|
|
121
140
|
const parsedSettingsByDefName = new Map();
|
|
122
141
|
if (hasBindingUsage && kindNames.length === 0) {
|
|
123
|
-
|
|
142
|
+
issues.push({
|
|
143
|
+
code: 'binding_registry_required',
|
|
144
|
+
message: 'Workflows that declare non-task defs or nested bindings require a non-empty "bindingKinds" registry.',
|
|
145
|
+
});
|
|
124
146
|
}
|
|
125
147
|
for (const [defName, defDefinition] of Object.entries(defs)) {
|
|
126
148
|
if (defDefinition.kind === TASK_KIND) {
|
|
127
149
|
if (defDefinition.action && actions && !actions[defDefinition.action]) {
|
|
128
|
-
|
|
150
|
+
issues.push(missingActionIssue(defName, defDefinition.action));
|
|
129
151
|
}
|
|
130
152
|
continue;
|
|
131
153
|
}
|
|
132
154
|
const kindDefinition = kinds[defDefinition.kind];
|
|
133
155
|
if (!kindDefinition) {
|
|
134
|
-
|
|
156
|
+
issues.push({
|
|
157
|
+
code: 'unknown_binding_kind',
|
|
158
|
+
message: `defs.${defName}.kind: Unknown binding kind "${defDefinition.kind}".`,
|
|
159
|
+
path: ['defs', defName, 'kind'],
|
|
160
|
+
bindingKind: defDefinition.kind,
|
|
161
|
+
});
|
|
135
162
|
continue;
|
|
136
163
|
}
|
|
137
164
|
const actionPolicy = kindDefinition.actionPolicy ?? 'optional';
|
|
138
165
|
if (actionPolicy === 'required' && !defDefinition.action) {
|
|
139
|
-
|
|
166
|
+
issues.push({
|
|
167
|
+
code: 'action_required',
|
|
168
|
+
message: `defs.${defName}.action: Binding kind "${defDefinition.kind}" requires an action.`,
|
|
169
|
+
path: ['defs', defName, 'action'],
|
|
170
|
+
bindingKind: defDefinition.kind,
|
|
171
|
+
});
|
|
140
172
|
}
|
|
141
173
|
if (actionPolicy === 'forbidden' && defDefinition.action) {
|
|
142
|
-
|
|
174
|
+
issues.push({
|
|
175
|
+
code: 'action_forbidden',
|
|
176
|
+
message: `defs.${defName}.action: Binding kind "${defDefinition.kind}" does not allow action declarations.`,
|
|
177
|
+
path: ['defs', defName, 'action'],
|
|
178
|
+
bindingKind: defDefinition.kind,
|
|
179
|
+
});
|
|
143
180
|
}
|
|
144
181
|
if (defDefinition.action && actions && !actions[defDefinition.action]) {
|
|
145
|
-
|
|
182
|
+
issues.push(missingActionIssue(defName, defDefinition.action));
|
|
146
183
|
}
|
|
147
184
|
const { schema } = kindDefinition;
|
|
148
185
|
const parsedPayload = schema.safeParse(defDefinition.settings);
|
|
149
186
|
if (!parsedPayload.success) {
|
|
150
|
-
|
|
187
|
+
issues.push(...toBindingSettingsIssues(parsedPayload.error.issues, defName));
|
|
151
188
|
continue;
|
|
152
189
|
}
|
|
153
190
|
parsedSettingsByDefName.set(defName, parsedPayload.data);
|
|
@@ -157,47 +194,83 @@ const validateAndResolveBindings = (workflow, options) => {
|
|
|
157
194
|
if (!defBindings) {
|
|
158
195
|
continue;
|
|
159
196
|
}
|
|
160
|
-
const supportedKinds = resolveSupportedBindingKinds(defDefinition, defName, kinds, actions,
|
|
197
|
+
const supportedKinds = resolveSupportedBindingKinds(defDefinition, defName, kinds, actions, issues);
|
|
161
198
|
const shouldValidateSupportedKinds = Array.isArray(supportedKinds);
|
|
162
199
|
for (const [bindingKind, bindingRefs] of Object.entries(defBindings)) {
|
|
200
|
+
const bindingPath = ['defs', defName, 'bindings', bindingKind];
|
|
163
201
|
const kindDefinition = kinds[bindingKind];
|
|
164
202
|
if (!kindDefinition) {
|
|
165
|
-
|
|
203
|
+
issues.push({
|
|
204
|
+
code: 'unknown_binding_kind',
|
|
205
|
+
message: `defs.${defName}.bindings.${bindingKind}: Unknown binding kind "${bindingKind}".`,
|
|
206
|
+
path: bindingPath,
|
|
207
|
+
bindingKind,
|
|
208
|
+
});
|
|
166
209
|
continue;
|
|
167
210
|
}
|
|
168
211
|
const { multiple } = kindDefinition;
|
|
169
212
|
if (multiple && !Array.isArray(bindingRefs)) {
|
|
170
|
-
|
|
213
|
+
issues.push({
|
|
214
|
+
code: 'binding_ref',
|
|
215
|
+
message: `defs.${defName}.bindings.${bindingKind}: Expected an array of def references for binding kind "${bindingKind}".`,
|
|
216
|
+
path: bindingPath,
|
|
217
|
+
bindingKind,
|
|
218
|
+
});
|
|
171
219
|
continue;
|
|
172
220
|
}
|
|
173
221
|
if (!multiple && typeof bindingRefs !== 'string') {
|
|
174
|
-
|
|
222
|
+
issues.push({
|
|
223
|
+
code: 'binding_ref',
|
|
224
|
+
message: `defs.${defName}.bindings.${bindingKind}: Expected a single def reference string for binding kind "${bindingKind}".`,
|
|
225
|
+
path: bindingPath,
|
|
226
|
+
bindingKind,
|
|
227
|
+
});
|
|
175
228
|
continue;
|
|
176
229
|
}
|
|
177
230
|
if (shouldValidateSupportedKinds &&
|
|
178
231
|
supportedKinds &&
|
|
179
232
|
!supportedKinds.includes(bindingKind)) {
|
|
180
233
|
const supportedKindsLabel = supportedKinds.length > 0 ? supportedKinds.join(', ') : '<none>';
|
|
181
|
-
|
|
234
|
+
issues.push({
|
|
235
|
+
code: 'binding_unsupported',
|
|
236
|
+
message: `defs.${defName}.bindings.${bindingKind}: "${defDefinition.action ?? defDefinition.kind}" does not support binding kind "${bindingKind}". Supported binding kinds: ${supportedKindsLabel}.`,
|
|
237
|
+
path: bindingPath,
|
|
238
|
+
bindingKind,
|
|
239
|
+
});
|
|
182
240
|
}
|
|
183
241
|
const refs = toBindingRefs(bindingRefs);
|
|
184
242
|
const duplicateRefs = collectDuplicateReferences(refs);
|
|
185
243
|
if (duplicateRefs.length > 0) {
|
|
186
|
-
|
|
244
|
+
issues.push({
|
|
245
|
+
code: 'binding_ref',
|
|
246
|
+
message: `defs.${defName}.bindings.${bindingKind}: Duplicate def reference(s): ${duplicateRefs.join(', ')}`,
|
|
247
|
+
path: bindingPath,
|
|
248
|
+
bindingKind,
|
|
249
|
+
});
|
|
187
250
|
}
|
|
188
251
|
for (const ref of refs) {
|
|
189
252
|
const definition = defs[ref];
|
|
190
253
|
if (!definition) {
|
|
191
|
-
|
|
254
|
+
issues.push({
|
|
255
|
+
code: 'binding_ref',
|
|
256
|
+
message: `defs.${defName}.bindings.${bindingKind}: Unknown def reference "${ref}".`,
|
|
257
|
+
path: bindingPath,
|
|
258
|
+
bindingKind,
|
|
259
|
+
});
|
|
192
260
|
continue;
|
|
193
261
|
}
|
|
194
262
|
if (definition.kind !== bindingKind) {
|
|
195
|
-
|
|
263
|
+
issues.push({
|
|
264
|
+
code: 'binding_ref',
|
|
265
|
+
message: `defs.${defName}.bindings.${bindingKind}: Def "${ref}" has kind "${definition.kind}" and cannot be mounted as "${bindingKind}".`,
|
|
266
|
+
path: bindingPath,
|
|
267
|
+
bindingKind,
|
|
268
|
+
});
|
|
196
269
|
}
|
|
197
270
|
}
|
|
198
271
|
}
|
|
199
272
|
}
|
|
200
|
-
|
|
273
|
+
issues.push(...detectBindingCycles(defs));
|
|
201
274
|
const inProgress = new Set();
|
|
202
275
|
const mountResolvedDef = (defName) => {
|
|
203
276
|
const existing = resolvedDefs[defName];
|
|
@@ -237,7 +310,7 @@ const validateAndResolveBindings = (workflow, options) => {
|
|
|
237
310
|
}
|
|
238
311
|
mountResolvedDef(defName);
|
|
239
312
|
}
|
|
240
|
-
return {
|
|
313
|
+
return { issues, resolvedDefs };
|
|
241
314
|
};
|
|
242
315
|
exports.validateAndResolveBindings = validateAndResolveBindings;
|
|
243
316
|
const mountTaskBindings = (taskBindings, resolvedDefs, bindingKinds, resolveDef) => {
|
package/dist/cjs/dsl.types.js
CHANGED
|
@@ -15,6 +15,7 @@ const yaml_1 = require("yaml");
|
|
|
15
15
|
const zod_1 = require("zod");
|
|
16
16
|
const base_binding_1 = require("./bindings/base-binding");
|
|
17
17
|
const naming_1 = require("./utils/naming");
|
|
18
|
+
const workflow_values_1 = require("./workflow-values");
|
|
18
19
|
exports.ExpressionStringSchema = zod_1.z
|
|
19
20
|
.string()
|
|
20
21
|
.regex(/^=/, 'Expression strings must start with "="')
|
|
@@ -239,32 +240,42 @@ exports.WorkflowDefinitionSchema = zod_1.z.strictObject({
|
|
|
239
240
|
flow: zod_1.z.array(exports.FlowStepSchema),
|
|
240
241
|
outputs: zod_1.z.record(zod_1.z.string(), exports.ExpressionStringSchema),
|
|
241
242
|
});
|
|
242
|
-
const collectTaskReferences = (steps) => {
|
|
243
|
+
const collectTaskReferences = (steps, basePath = ['flow']) => {
|
|
243
244
|
const refs = [];
|
|
244
|
-
|
|
245
|
+
steps.forEach((step, index) => {
|
|
246
|
+
const stepPath = [...basePath, index];
|
|
245
247
|
if ('do' in step) {
|
|
246
|
-
refs.push(step.do);
|
|
247
|
-
|
|
248
|
+
refs.push({ taskId: step.do, path: [...stepPath, 'do'] });
|
|
249
|
+
return;
|
|
248
250
|
}
|
|
249
251
|
if ('parallel' in step) {
|
|
250
|
-
refs.push(...collectTaskReferences(step.parallel.steps
|
|
251
|
-
|
|
252
|
+
refs.push(...collectTaskReferences(step.parallel.steps, [
|
|
253
|
+
...stepPath,
|
|
254
|
+
'parallel',
|
|
255
|
+
'steps',
|
|
256
|
+
]));
|
|
257
|
+
return;
|
|
252
258
|
}
|
|
253
259
|
if ('conditional' in step) {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
260
|
+
step.conditional.when.forEach((branch, branchIndex) => {
|
|
261
|
+
refs.push(...collectTaskReferences(branch.steps, [
|
|
262
|
+
...stepPath,
|
|
263
|
+
'conditional',
|
|
264
|
+
'when',
|
|
265
|
+
branchIndex,
|
|
266
|
+
'steps',
|
|
267
|
+
]));
|
|
268
|
+
});
|
|
269
|
+
return;
|
|
263
270
|
}
|
|
264
271
|
if ('loop' in step) {
|
|
265
|
-
refs.push(...collectTaskReferences(step.loop.steps
|
|
272
|
+
refs.push(...collectTaskReferences(step.loop.steps, [
|
|
273
|
+
...stepPath,
|
|
274
|
+
'loop',
|
|
275
|
+
'steps',
|
|
276
|
+
]));
|
|
266
277
|
}
|
|
267
|
-
}
|
|
278
|
+
});
|
|
268
279
|
return refs;
|
|
269
280
|
};
|
|
270
281
|
const isTaskDefinition = (definition) => definition.kind === exports.TASK_KIND;
|
|
@@ -276,9 +287,97 @@ const extractTaskDefinitions = (defs) => Object.entries(defs).reduce((tasks, [de
|
|
|
276
287
|
return tasks;
|
|
277
288
|
}, {});
|
|
278
289
|
exports.extractTaskDefinitions = extractTaskDefinitions;
|
|
279
|
-
const
|
|
290
|
+
const EXECUTION_SETTING_KEYS = new Set(Object.keys(exports.BaseSettingsSchema.shape));
|
|
291
|
+
const isExpressionString = (value) => typeof value === 'string' && value.startsWith('=');
|
|
292
|
+
const toIssuePath = (path) => path.filter((segment) => typeof segment === 'string' || typeof segment === 'number');
|
|
293
|
+
const getValueAtPath = (value, path) => {
|
|
294
|
+
let current = value;
|
|
295
|
+
for (const segment of path) {
|
|
296
|
+
if (current === null || typeof current !== 'object') {
|
|
297
|
+
return undefined;
|
|
298
|
+
}
|
|
299
|
+
current = current[segment];
|
|
300
|
+
}
|
|
301
|
+
return current;
|
|
302
|
+
};
|
|
303
|
+
const extractActionSettings = (settings) => {
|
|
304
|
+
if (!settings || typeof settings !== 'object' || Array.isArray(settings)) {
|
|
305
|
+
return {};
|
|
306
|
+
}
|
|
307
|
+
return Object.fromEntries(Object.entries(settings).filter(([key]) => !EXECUTION_SETTING_KEYS.has(key)));
|
|
308
|
+
};
|
|
309
|
+
const toActionSchemaIssues = ({ actionName, code, payload, schema, section, taskId, }) => {
|
|
310
|
+
const result = schema.safeParse(payload);
|
|
311
|
+
if (result.success) {
|
|
312
|
+
return [];
|
|
313
|
+
}
|
|
314
|
+
return result.error.issues.flatMap((issue) => {
|
|
315
|
+
const issuePath = toIssuePath(issue.path);
|
|
316
|
+
// Expressions are resolved immediately before action execution, so their
|
|
317
|
+
// eventual runtime type cannot be checked while validating the definition.
|
|
318
|
+
if (isExpressionString(getValueAtPath(payload, issuePath))) {
|
|
319
|
+
return [];
|
|
320
|
+
}
|
|
321
|
+
const path = ['defs', taskId, section, ...issuePath];
|
|
322
|
+
return [
|
|
323
|
+
{
|
|
324
|
+
actionName,
|
|
325
|
+
code,
|
|
326
|
+
message: `${path.join('.')}: ${issue.message}`,
|
|
327
|
+
path,
|
|
328
|
+
taskId,
|
|
329
|
+
},
|
|
330
|
+
];
|
|
331
|
+
});
|
|
332
|
+
};
|
|
333
|
+
const validateTaskActionSchemas = (definition, actions) => {
|
|
334
|
+
if (!actions) {
|
|
335
|
+
return [];
|
|
336
|
+
}
|
|
337
|
+
const issues = [];
|
|
338
|
+
const taskDefinitions = (0, exports.extractTaskDefinitions)(definition.defs);
|
|
339
|
+
for (const [taskId, task] of Object.entries(taskDefinitions)) {
|
|
340
|
+
const action = actions[task.action];
|
|
341
|
+
// Missing actions are reported by binding validation and have no schemas
|
|
342
|
+
// available for payload validation.
|
|
343
|
+
if (!action) {
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
if (action.inputSchema) {
|
|
347
|
+
issues.push(...toActionSchemaIssues({
|
|
348
|
+
actionName: task.action,
|
|
349
|
+
code: 'action_inputs',
|
|
350
|
+
payload: task.inputs ?? {},
|
|
351
|
+
schema: action.inputSchema,
|
|
352
|
+
section: 'inputs',
|
|
353
|
+
taskId,
|
|
354
|
+
}));
|
|
355
|
+
}
|
|
356
|
+
if (action.settingSchema) {
|
|
357
|
+
const effectiveSettings = (0, workflow_values_1.mergeSettings)(definition.defaults?.settings, task.settings);
|
|
358
|
+
issues.push(...toActionSchemaIssues({
|
|
359
|
+
actionName: task.action,
|
|
360
|
+
code: 'action_settings',
|
|
361
|
+
payload: extractActionSettings(effectiveSettings),
|
|
362
|
+
schema: action.settingSchema,
|
|
363
|
+
section: 'settings',
|
|
364
|
+
taskId,
|
|
365
|
+
}));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return issues;
|
|
369
|
+
};
|
|
370
|
+
const toSchemaIssues = (zodIssues) => zodIssues.map((issue) => {
|
|
280
371
|
const path = issue.path.join('.') || '<root>';
|
|
281
|
-
return
|
|
372
|
+
return {
|
|
373
|
+
code: 'schema',
|
|
374
|
+
message: `${path}: ${issue.message}`,
|
|
375
|
+
path: issue.path.filter((segment) => typeof segment === 'string' || typeof segment === 'number'),
|
|
376
|
+
};
|
|
377
|
+
});
|
|
378
|
+
const invalidWorkflow = (issues) => ({
|
|
379
|
+
success: false,
|
|
380
|
+
issues,
|
|
282
381
|
});
|
|
283
382
|
function validateWorkflow(input, options) {
|
|
284
383
|
let candidate = input;
|
|
@@ -288,32 +387,40 @@ function validateWorkflow(input, options) {
|
|
|
288
387
|
}
|
|
289
388
|
catch (error) {
|
|
290
389
|
const message = error instanceof Error ? error.message : 'Unknown YAML parse error';
|
|
291
|
-
return
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
390
|
+
return invalidWorkflow([
|
|
391
|
+
{ code: 'yaml_parse', message: 'Unable to parse workflow YAML' },
|
|
392
|
+
{ code: 'yaml_parse', message },
|
|
393
|
+
]);
|
|
295
394
|
}
|
|
296
395
|
}
|
|
297
396
|
const parsed = exports.WorkflowDefinitionSchema.safeParse(candidate);
|
|
298
397
|
if (!parsed.success) {
|
|
299
|
-
return
|
|
398
|
+
return invalidWorkflow(toSchemaIssues(parsed.error.issues));
|
|
300
399
|
}
|
|
301
|
-
const
|
|
400
|
+
const issues = [];
|
|
302
401
|
const taskDefinitions = (0, exports.extractTaskDefinitions)(parsed.data.defs);
|
|
303
|
-
const
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
402
|
+
const reportedMissingTasks = new Set();
|
|
403
|
+
for (const { taskId, path } of collectTaskReferences(parsed.data.flow)) {
|
|
404
|
+
if (Object.prototype.hasOwnProperty.call(taskDefinitions, taskId) ||
|
|
405
|
+
reportedMissingTasks.has(taskId)) {
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
reportedMissingTasks.add(taskId);
|
|
409
|
+
issues.push({
|
|
410
|
+
code: 'unknown_task',
|
|
411
|
+
message: `Unknown task(s) referenced in flow: ${taskId}`,
|
|
412
|
+
path,
|
|
413
|
+
taskId,
|
|
414
|
+
});
|
|
307
415
|
}
|
|
308
416
|
const bindingValidation = (0, base_binding_1.validateAndResolveBindings)(parsed.data, {
|
|
309
417
|
bindingKinds: options?.bindingKinds,
|
|
310
418
|
actions: options?.actions,
|
|
311
419
|
});
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
return { success: false, errors };
|
|
420
|
+
issues.push(...bindingValidation.issues);
|
|
421
|
+
issues.push(...validateTaskActionSchemas(parsed.data, options?.actions));
|
|
422
|
+
if (issues.length > 0) {
|
|
423
|
+
return invalidWorkflow(issues);
|
|
317
424
|
}
|
|
318
425
|
return { success: true, data: parsed.data };
|
|
319
426
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -19,7 +19,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
19
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.remapWorkflowDefinitionResourceRefs = exports.collectWorkflowDefinitionResourceRefs = exports.withTimeout = exports.sleep = exports.toSnakeCase = exports.isSnakeCaseName = exports.assertSnakeCaseName = exports.createDeferred = exports.mergeSettings = exports.evaluateValue = exports.evaluateMapping = exports.compileValue = exports.WorkflowCancellationError = exports.ParallelSuspensionError = exports.NonDeterministicWorkflowError = exports.StepType = exports.WorkflowRunner = exports.WorkflowEventEmitter = exports.Workflow = exports.compileWorkflow = exports.WORKFLOW_RUN_STATUSES = exports.EWorkflowRunStatus = exports.BaseWorkflowContext = exports.defineAction = exports.AbstractAction = void 0;
|
|
22
|
+
exports.remapWorkflowDefinitionResourceRefs = exports.collectWorkflowDefinitionResourceRefs = exports.withTimeout = exports.sleep = exports.toSnakeCase = exports.isSnakeCaseName = exports.assertSnakeCaseName = exports.createDeferred = exports.mergeSettings = exports.evaluateValue = exports.evaluateMapping = exports.compileValue = exports.WorkflowCancellationError = exports.ParallelSuspensionError = exports.NonDeterministicWorkflowError = exports.StepType = exports.WorkflowRunner = exports.WorkflowEventEmitter = exports.Workflow = exports.compileWorkflow = exports.issueMessages = exports.WORKFLOW_RUN_STATUSES = exports.EWorkflowRunStatus = exports.BaseWorkflowContext = exports.defineAction = exports.AbstractAction = void 0;
|
|
23
23
|
var abstract_action_1 = require("./action/abstract-action");
|
|
24
24
|
Object.defineProperty(exports, "AbstractAction", { enumerable: true, get: function () { return abstract_action_1.AbstractAction; } });
|
|
25
25
|
var action_1 = require("./action/action");
|
|
@@ -29,6 +29,8 @@ Object.defineProperty(exports, "BaseWorkflowContext", { enumerable: true, get: f
|
|
|
29
29
|
Object.defineProperty(exports, "EWorkflowRunStatus", { enumerable: true, get: function () { return context_1.EWorkflowRunStatus; } });
|
|
30
30
|
Object.defineProperty(exports, "WORKFLOW_RUN_STATUSES", { enumerable: true, get: function () { return context_1.WORKFLOW_RUN_STATUSES; } });
|
|
31
31
|
__exportStar(require("./dsl.types"), exports);
|
|
32
|
+
var validation_issue_1 = require("./validation-issue");
|
|
33
|
+
Object.defineProperty(exports, "issueMessages", { enumerable: true, get: function () { return validation_issue_1.issueMessages; } });
|
|
32
34
|
var workflow_1 = require("./workflow");
|
|
33
35
|
Object.defineProperty(exports, "compileWorkflow", { enumerable: true, get: function () { return workflow_1.compileWorkflow; } });
|
|
34
36
|
Object.defineProperty(exports, "Workflow", { enumerable: true, get: function () { return workflow_1.Workflow; } });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Hexabot — Fair Core License (FCL-1.0-ALv2)
|
|
4
|
+
* Copyright (c) 2026 Hexastack.
|
|
5
|
+
* Full terms: see LICENSE.md.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.issueMessages = void 0;
|
|
9
|
+
const issueMessages = (issues) => issues.map((issue) => issue.message);
|
|
10
|
+
exports.issueMessages = issueMessages;
|
|
@@ -9,6 +9,7 @@ exports.compileWorkflow = void 0;
|
|
|
9
9
|
const zod_1 = require("zod");
|
|
10
10
|
const base_binding_1 = require("./bindings/base-binding");
|
|
11
11
|
const dsl_types_1 = require("./dsl.types");
|
|
12
|
+
const validation_issue_1 = require("./validation-issue");
|
|
12
13
|
const workflow_event_emitter_1 = require("./workflow-event-emitter");
|
|
13
14
|
const workflow_values_1 = require("./workflow-values");
|
|
14
15
|
/** Build a stable identifier for a step using its path and label. */
|
|
@@ -97,8 +98,8 @@ const compileTasks = (definition, options) => {
|
|
|
97
98
|
bindingKinds: options.bindingKinds,
|
|
98
99
|
actions: options.actions,
|
|
99
100
|
});
|
|
100
|
-
if (bindingValidation.
|
|
101
|
-
throw new Error(`Workflow bindings validation failed: ${bindingValidation.
|
|
101
|
+
if (bindingValidation.issues.length > 0) {
|
|
102
|
+
throw new Error(`Workflow bindings validation failed: ${(0, validation_issue_1.issueMessages)(bindingValidation.issues).join('; ')}`);
|
|
102
103
|
}
|
|
103
104
|
assertActionsBound(taskDefinitions, options.actions);
|
|
104
105
|
for (const [taskName, task] of Object.entries(taskDefinitions)) {
|
package/dist/cjs/workflow.js
CHANGED
|
@@ -10,6 +10,7 @@ const yaml_1 = require("yaml");
|
|
|
10
10
|
const context_1 = require("./context");
|
|
11
11
|
const dsl_types_1 = require("./dsl.types");
|
|
12
12
|
const workflow_definition_1 = require("./utils/workflow-definition");
|
|
13
|
+
const validation_issue_1 = require("./validation-issue");
|
|
13
14
|
const workflow_compiler_1 = require("./workflow-compiler");
|
|
14
15
|
const workflow_runner_1 = require("./workflow-runner");
|
|
15
16
|
var workflow_compiler_2 = require("./workflow-compiler");
|
|
@@ -69,7 +70,7 @@ class Workflow {
|
|
|
69
70
|
actions: options.actions,
|
|
70
71
|
});
|
|
71
72
|
if (!validation.success) {
|
|
72
|
-
throw new Error(`Workflow validation failed: ${validation.
|
|
73
|
+
throw new Error(`Workflow validation failed: ${(0, validation_issue_1.issueMessages)(validation.issues).join('; ')}`);
|
|
73
74
|
}
|
|
74
75
|
const compiled = (0, workflow_compiler_1.compileWorkflow)(validation.data, options);
|
|
75
76
|
return new Workflow(compiled);
|
|
@@ -84,7 +85,7 @@ class Workflow {
|
|
|
84
85
|
actions: options.actions,
|
|
85
86
|
});
|
|
86
87
|
if (!validation.success) {
|
|
87
|
-
throw new Error(`Workflow validation failed: ${validation.
|
|
88
|
+
throw new Error(`Workflow validation failed: ${(0, validation_issue_1.issueMessages)(validation.issues).join('; ')}`);
|
|
88
89
|
}
|
|
89
90
|
const compiled = (0, workflow_compiler_1.compileWorkflow)(validation.data, options);
|
|
90
91
|
return new Workflow(compiled);
|