@vaudience/aigentflow-flow-validator 0.15.3

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.
@@ -0,0 +1,291 @@
1
+ /** Severity of a validation issue. `info` is reserved for future lints. */
2
+ type Severity = 'error' | 'warning' | 'info';
3
+ /**
4
+ * A single validation finding. The same shape is used for errors and
5
+ * warnings; warnings simply carry `severity: 'warning'` and never set
6
+ * {@link ValidationResult.valid} to false.
7
+ */
8
+ interface ValidationIssue {
9
+ /** Dotted field path, e.g. `steps.fetch.query.url`. */
10
+ field: string;
11
+ /** Human-readable description of the problem. */
12
+ message: string;
13
+ /** Stable, machine-readable code (parity contract). */
14
+ code: string;
15
+ /** Severity. */
16
+ severity: Severity;
17
+ /** Step ID when the issue is step-specific. */
18
+ stepId?: string;
19
+ /** 1-based line in the source YAML, when known. */
20
+ line?: number;
21
+ /** 1-based column in the source YAML, when known. */
22
+ column?: number;
23
+ /** Extra context (e.g. the available step names). */
24
+ context?: string;
25
+ /** Suggested fix. */
26
+ suggestion?: string;
27
+ }
28
+ /** Roll-up statistics for a validation run. */
29
+ interface ValidationSummary {
30
+ totalSteps: number;
31
+ validSteps: number;
32
+ errorCount: number;
33
+ warningCount: number;
34
+ templatesFound: number;
35
+ templatesValid: number;
36
+ }
37
+ /** The complete result of validating one flow. */
38
+ interface ValidationResult {
39
+ /** True when there are zero `error`-severity issues. */
40
+ valid: boolean;
41
+ /** Error-severity issues. A non-empty list means `valid` is false. */
42
+ errors: ValidationIssue[];
43
+ /** Warning-severity issues. Never affect `valid`. */
44
+ warnings: ValidationIssue[];
45
+ /** Roll-up statistics. */
46
+ summary: ValidationSummary;
47
+ }
48
+ /** Options accepted by {@link validateFlow} and {@link validateFlowObject}. */
49
+ interface ValidateOptions {
50
+ /**
51
+ * When true, an unrecognised orchestrator tool name and an unknown template
52
+ * function are reported as `error` instead of `warning`. Off by default
53
+ * because the vendored allow-lists can lag the live AIgentFlow registries,
54
+ * and a false-positive error is worse than a missed lint. See PARITY.md.
55
+ */
56
+ strictRegistries?: boolean;
57
+ }
58
+ interface PropertyDefinition {
59
+ type?: string;
60
+ description?: string;
61
+ required?: boolean;
62
+ enum?: string[];
63
+ default?: unknown;
64
+ format?: string;
65
+ properties?: Record<string, PropertyDefinition>;
66
+ validation?: string;
67
+ items?: PropertyDefinition;
68
+ min_items?: number;
69
+ max_items?: number;
70
+ }
71
+ type QueryDefinition = PropertyDefinition;
72
+ interface ErrorStrategyDefinition {
73
+ action?: string;
74
+ max_retries?: number;
75
+ retry_delay?: string;
76
+ goto_step?: string;
77
+ exponential_backoff?: boolean;
78
+ max_delay?: string;
79
+ backoff_multiplier?: number;
80
+ jitter?: boolean;
81
+ retry_on?: string[];
82
+ }
83
+ interface NextCondition {
84
+ if?: string;
85
+ /**
86
+ * The branch target. The YAML key is `goto`, NOT `goto_step` — this is the
87
+ * ONE place in the whole grammar spelled that way (`ConditionDefinition.GotoStep`
88
+ * carries `yaml:"goto"`, aigentflow.domain.step.go:134), while the flow-level
89
+ * and step-level `error_strategy` and `quality_gate` all use `goto_step`.
90
+ * Reading the wrong key here silently disabled every conditional-branch check.
91
+ */
92
+ goto?: string;
93
+ /** Present only so the misspelling can be REPORTED; AIgentFlow's strict parser rejects it. */
94
+ goto_step?: string;
95
+ }
96
+ interface ParallelDefinition {
97
+ rendezvous?: string;
98
+ steps?: string[];
99
+ resolution?: string;
100
+ }
101
+ interface NextLogicDefinition {
102
+ default?: string;
103
+ conditions?: NextCondition[];
104
+ parallel?: ParallelDefinition;
105
+ }
106
+ interface ThrottleDefinition {
107
+ delay?: string;
108
+ batch_size?: number;
109
+ batch_delay?: string;
110
+ }
111
+ interface ForEachDefinition {
112
+ items?: string;
113
+ as?: string;
114
+ max_parallel?: number;
115
+ resolution?: string;
116
+ throttle?: ThrottleDefinition;
117
+ }
118
+ interface LoopSubStep {
119
+ id?: string;
120
+ executor?: string;
121
+ credential?: string;
122
+ credentials?: Record<string, CredentialBinding | null>;
123
+ output_schema?: InputSchema;
124
+ [key: string]: unknown;
125
+ }
126
+ /**
127
+ * `quality_gate:` step block (DC-CP-8). An LLM-as-judge scores the step's own
128
+ * output against `rubric`; `passed = score >= threshold`. On failure the step
129
+ * is routed by `on_fail`.
130
+ */
131
+ interface QualityGateDefinition {
132
+ rubric?: string;
133
+ threshold?: number;
134
+ model?: string;
135
+ provider?: string;
136
+ on_fail?: string;
137
+ goto_step?: string;
138
+ max_retries?: number;
139
+ }
140
+ interface LoopDefinition {
141
+ while?: string;
142
+ max_iterations?: number;
143
+ steps?: LoopSubStep[];
144
+ }
145
+ interface CredentialBinding {
146
+ source?: string;
147
+ inject_as?: string;
148
+ }
149
+ interface ResponseExpectationField {
150
+ type?: string;
151
+ required?: boolean | string;
152
+ items?: PropertyDefinition;
153
+ }
154
+ interface StepDefinition {
155
+ executor?: string;
156
+ query?: Record<string, unknown>;
157
+ pre_processing?: unknown[];
158
+ post_processing?: unknown[];
159
+ response_expectation?: Record<string, ResponseExpectationField>;
160
+ /** Evaluation mode (e.g. `raw-text`). `response_expectation` is read only when this is set. */
161
+ response_evaluation?: string;
162
+ next?: NextLogicDefinition;
163
+ error_strategy?: ErrorStrategyDefinition;
164
+ for_each?: ForEachDefinition;
165
+ loop?: LoopDefinition;
166
+ /**
167
+ * Bounds each executor invocation of the step (a Go duration, or
168
+ * "none"/"never"/"infinite"). Unparseable, or on a `loop:` step, it bounds
169
+ * nothing — see `step_max_duration_ignored`.
170
+ */
171
+ max_duration?: string;
172
+ credential?: string;
173
+ credentials?: Record<string, CredentialBinding | null>;
174
+ output_schema?: InputSchema;
175
+ quality_gate?: QualityGateDefinition;
176
+ [key: string]: unknown;
177
+ }
178
+ interface ExpressionFunctionDefinition {
179
+ package?: string;
180
+ function?: string;
181
+ }
182
+ interface VisibleWhenPredicate {
183
+ field?: string;
184
+ equals?: unknown;
185
+ in?: unknown[];
186
+ }
187
+ interface InputSchemaField {
188
+ name?: string;
189
+ type?: string;
190
+ label?: string;
191
+ description?: string;
192
+ required?: boolean;
193
+ default?: unknown;
194
+ enum?: string[];
195
+ min?: number;
196
+ max?: number;
197
+ min_length?: number;
198
+ max_length?: number;
199
+ min_items?: number;
200
+ max_items?: number;
201
+ pattern?: string;
202
+ accept?: string[];
203
+ max_size?: number;
204
+ visible_when?: VisibleWhenPredicate;
205
+ }
206
+ interface InputSchema {
207
+ version?: number;
208
+ fields?: InputSchemaField[];
209
+ }
210
+ interface OrchestratorTrigger {
211
+ type?: string;
212
+ interval?: string;
213
+ }
214
+ interface OrchestratorDefinition {
215
+ exons?: string;
216
+ agentic?: boolean;
217
+ mode?: string;
218
+ triggers?: OrchestratorTrigger[];
219
+ tools?: string[];
220
+ max_turns?: number;
221
+ human_question_timeout?: string;
222
+ human_question_timeout_response?: string;
223
+ }
224
+ interface Flow {
225
+ aigentflow_version?: string;
226
+ name?: string;
227
+ version?: string;
228
+ description?: string;
229
+ handle?: string;
230
+ visibility?: string;
231
+ start?: string;
232
+ steps?: Record<string, StepDefinition>;
233
+ query?: Record<string, QueryDefinition>;
234
+ output?: string[];
235
+ error_strategy?: ErrorStrategyDefinition;
236
+ expression_functions?: ExpressionFunctionDefinition[];
237
+ constraints?: Record<string, unknown>;
238
+ currency?: string;
239
+ max_duration?: string;
240
+ orchestrator?: OrchestratorDefinition;
241
+ campaign?: Record<string, unknown>;
242
+ checkpoint?: Record<string, unknown>;
243
+ input_schema?: InputSchema;
244
+ classification?: Record<string, unknown>;
245
+ is_template?: boolean;
246
+ template?: Record<string, unknown> | null;
247
+ [key: string]: unknown;
248
+ }
249
+
250
+ /** The AIgentFlow version whose flow schema this validator tracks. */
251
+ declare const SPEC_VERSION: string;
252
+ /** Current supported `input_schema.version`. */
253
+ declare const INPUT_SCHEMA_VERSION: number;
254
+
255
+ /** Result of parsing flow YAML. */
256
+ interface ParseOutput {
257
+ /** The parsed flow object, present only when there are no parse errors. */
258
+ flow?: Flow;
259
+ /** Fatal YAML syntax / structure errors. Non-empty means `flow` is absent. */
260
+ parseErrors: ValidationIssue[];
261
+ /** Non-fatal YAML warnings (e.g. deprecated tags). */
262
+ parseWarnings: ValidationIssue[];
263
+ /**
264
+ * The SOURCE spelling of every number and boolean scalar, keyed by field path
265
+ * (`mock_scenarios.s.fetch.delay`). The reference decodes a scalar into a Go
266
+ * `string` field as its source text, so `delay: 0.0` arrives there as "0.0"
267
+ * (not a Go duration) while the parsed value here is the number 0. Present
268
+ * whenever `flow` is.
269
+ */
270
+ scalarSources?: ReadonlyMap<string, string>;
271
+ }
272
+ /**
273
+ * Parse flow YAML into a {@link Flow} object plus structured parse diagnostics.
274
+ * Never throws — malformed input is reported via `parseErrors`.
275
+ */
276
+ declare function parseFlow(yamlText: string): ParseOutput;
277
+
278
+ /**
279
+ * Validate an already-parsed flow object. Use this when you have a plain
280
+ * object (e.g. from your own YAML/JSON loader); use {@link validateFlow} to
281
+ * parse YAML text and validate in one step.
282
+ */
283
+ declare function validateFlowObject(flow: unknown, opts?: ValidateOptions): ValidationResult;
284
+ /**
285
+ * Parse flow YAML text and validate it. Parse errors (syntax, duplicate keys)
286
+ * are returned as `error`-severity issues; on a parse failure the structural
287
+ * validators are skipped because there is no usable document.
288
+ */
289
+ declare function validateFlow(yamlText: string, opts?: ValidateOptions): ValidationResult;
290
+
291
+ export { type Flow, INPUT_SCHEMA_VERSION, type ParseOutput, SPEC_VERSION, type Severity, type ValidateOptions, type ValidationIssue, type ValidationResult, type ValidationSummary, parseFlow, validateFlow, validateFlowObject };
@@ -0,0 +1,291 @@
1
+ /** Severity of a validation issue. `info` is reserved for future lints. */
2
+ type Severity = 'error' | 'warning' | 'info';
3
+ /**
4
+ * A single validation finding. The same shape is used for errors and
5
+ * warnings; warnings simply carry `severity: 'warning'` and never set
6
+ * {@link ValidationResult.valid} to false.
7
+ */
8
+ interface ValidationIssue {
9
+ /** Dotted field path, e.g. `steps.fetch.query.url`. */
10
+ field: string;
11
+ /** Human-readable description of the problem. */
12
+ message: string;
13
+ /** Stable, machine-readable code (parity contract). */
14
+ code: string;
15
+ /** Severity. */
16
+ severity: Severity;
17
+ /** Step ID when the issue is step-specific. */
18
+ stepId?: string;
19
+ /** 1-based line in the source YAML, when known. */
20
+ line?: number;
21
+ /** 1-based column in the source YAML, when known. */
22
+ column?: number;
23
+ /** Extra context (e.g. the available step names). */
24
+ context?: string;
25
+ /** Suggested fix. */
26
+ suggestion?: string;
27
+ }
28
+ /** Roll-up statistics for a validation run. */
29
+ interface ValidationSummary {
30
+ totalSteps: number;
31
+ validSteps: number;
32
+ errorCount: number;
33
+ warningCount: number;
34
+ templatesFound: number;
35
+ templatesValid: number;
36
+ }
37
+ /** The complete result of validating one flow. */
38
+ interface ValidationResult {
39
+ /** True when there are zero `error`-severity issues. */
40
+ valid: boolean;
41
+ /** Error-severity issues. A non-empty list means `valid` is false. */
42
+ errors: ValidationIssue[];
43
+ /** Warning-severity issues. Never affect `valid`. */
44
+ warnings: ValidationIssue[];
45
+ /** Roll-up statistics. */
46
+ summary: ValidationSummary;
47
+ }
48
+ /** Options accepted by {@link validateFlow} and {@link validateFlowObject}. */
49
+ interface ValidateOptions {
50
+ /**
51
+ * When true, an unrecognised orchestrator tool name and an unknown template
52
+ * function are reported as `error` instead of `warning`. Off by default
53
+ * because the vendored allow-lists can lag the live AIgentFlow registries,
54
+ * and a false-positive error is worse than a missed lint. See PARITY.md.
55
+ */
56
+ strictRegistries?: boolean;
57
+ }
58
+ interface PropertyDefinition {
59
+ type?: string;
60
+ description?: string;
61
+ required?: boolean;
62
+ enum?: string[];
63
+ default?: unknown;
64
+ format?: string;
65
+ properties?: Record<string, PropertyDefinition>;
66
+ validation?: string;
67
+ items?: PropertyDefinition;
68
+ min_items?: number;
69
+ max_items?: number;
70
+ }
71
+ type QueryDefinition = PropertyDefinition;
72
+ interface ErrorStrategyDefinition {
73
+ action?: string;
74
+ max_retries?: number;
75
+ retry_delay?: string;
76
+ goto_step?: string;
77
+ exponential_backoff?: boolean;
78
+ max_delay?: string;
79
+ backoff_multiplier?: number;
80
+ jitter?: boolean;
81
+ retry_on?: string[];
82
+ }
83
+ interface NextCondition {
84
+ if?: string;
85
+ /**
86
+ * The branch target. The YAML key is `goto`, NOT `goto_step` — this is the
87
+ * ONE place in the whole grammar spelled that way (`ConditionDefinition.GotoStep`
88
+ * carries `yaml:"goto"`, aigentflow.domain.step.go:134), while the flow-level
89
+ * and step-level `error_strategy` and `quality_gate` all use `goto_step`.
90
+ * Reading the wrong key here silently disabled every conditional-branch check.
91
+ */
92
+ goto?: string;
93
+ /** Present only so the misspelling can be REPORTED; AIgentFlow's strict parser rejects it. */
94
+ goto_step?: string;
95
+ }
96
+ interface ParallelDefinition {
97
+ rendezvous?: string;
98
+ steps?: string[];
99
+ resolution?: string;
100
+ }
101
+ interface NextLogicDefinition {
102
+ default?: string;
103
+ conditions?: NextCondition[];
104
+ parallel?: ParallelDefinition;
105
+ }
106
+ interface ThrottleDefinition {
107
+ delay?: string;
108
+ batch_size?: number;
109
+ batch_delay?: string;
110
+ }
111
+ interface ForEachDefinition {
112
+ items?: string;
113
+ as?: string;
114
+ max_parallel?: number;
115
+ resolution?: string;
116
+ throttle?: ThrottleDefinition;
117
+ }
118
+ interface LoopSubStep {
119
+ id?: string;
120
+ executor?: string;
121
+ credential?: string;
122
+ credentials?: Record<string, CredentialBinding | null>;
123
+ output_schema?: InputSchema;
124
+ [key: string]: unknown;
125
+ }
126
+ /**
127
+ * `quality_gate:` step block (DC-CP-8). An LLM-as-judge scores the step's own
128
+ * output against `rubric`; `passed = score >= threshold`. On failure the step
129
+ * is routed by `on_fail`.
130
+ */
131
+ interface QualityGateDefinition {
132
+ rubric?: string;
133
+ threshold?: number;
134
+ model?: string;
135
+ provider?: string;
136
+ on_fail?: string;
137
+ goto_step?: string;
138
+ max_retries?: number;
139
+ }
140
+ interface LoopDefinition {
141
+ while?: string;
142
+ max_iterations?: number;
143
+ steps?: LoopSubStep[];
144
+ }
145
+ interface CredentialBinding {
146
+ source?: string;
147
+ inject_as?: string;
148
+ }
149
+ interface ResponseExpectationField {
150
+ type?: string;
151
+ required?: boolean | string;
152
+ items?: PropertyDefinition;
153
+ }
154
+ interface StepDefinition {
155
+ executor?: string;
156
+ query?: Record<string, unknown>;
157
+ pre_processing?: unknown[];
158
+ post_processing?: unknown[];
159
+ response_expectation?: Record<string, ResponseExpectationField>;
160
+ /** Evaluation mode (e.g. `raw-text`). `response_expectation` is read only when this is set. */
161
+ response_evaluation?: string;
162
+ next?: NextLogicDefinition;
163
+ error_strategy?: ErrorStrategyDefinition;
164
+ for_each?: ForEachDefinition;
165
+ loop?: LoopDefinition;
166
+ /**
167
+ * Bounds each executor invocation of the step (a Go duration, or
168
+ * "none"/"never"/"infinite"). Unparseable, or on a `loop:` step, it bounds
169
+ * nothing — see `step_max_duration_ignored`.
170
+ */
171
+ max_duration?: string;
172
+ credential?: string;
173
+ credentials?: Record<string, CredentialBinding | null>;
174
+ output_schema?: InputSchema;
175
+ quality_gate?: QualityGateDefinition;
176
+ [key: string]: unknown;
177
+ }
178
+ interface ExpressionFunctionDefinition {
179
+ package?: string;
180
+ function?: string;
181
+ }
182
+ interface VisibleWhenPredicate {
183
+ field?: string;
184
+ equals?: unknown;
185
+ in?: unknown[];
186
+ }
187
+ interface InputSchemaField {
188
+ name?: string;
189
+ type?: string;
190
+ label?: string;
191
+ description?: string;
192
+ required?: boolean;
193
+ default?: unknown;
194
+ enum?: string[];
195
+ min?: number;
196
+ max?: number;
197
+ min_length?: number;
198
+ max_length?: number;
199
+ min_items?: number;
200
+ max_items?: number;
201
+ pattern?: string;
202
+ accept?: string[];
203
+ max_size?: number;
204
+ visible_when?: VisibleWhenPredicate;
205
+ }
206
+ interface InputSchema {
207
+ version?: number;
208
+ fields?: InputSchemaField[];
209
+ }
210
+ interface OrchestratorTrigger {
211
+ type?: string;
212
+ interval?: string;
213
+ }
214
+ interface OrchestratorDefinition {
215
+ exons?: string;
216
+ agentic?: boolean;
217
+ mode?: string;
218
+ triggers?: OrchestratorTrigger[];
219
+ tools?: string[];
220
+ max_turns?: number;
221
+ human_question_timeout?: string;
222
+ human_question_timeout_response?: string;
223
+ }
224
+ interface Flow {
225
+ aigentflow_version?: string;
226
+ name?: string;
227
+ version?: string;
228
+ description?: string;
229
+ handle?: string;
230
+ visibility?: string;
231
+ start?: string;
232
+ steps?: Record<string, StepDefinition>;
233
+ query?: Record<string, QueryDefinition>;
234
+ output?: string[];
235
+ error_strategy?: ErrorStrategyDefinition;
236
+ expression_functions?: ExpressionFunctionDefinition[];
237
+ constraints?: Record<string, unknown>;
238
+ currency?: string;
239
+ max_duration?: string;
240
+ orchestrator?: OrchestratorDefinition;
241
+ campaign?: Record<string, unknown>;
242
+ checkpoint?: Record<string, unknown>;
243
+ input_schema?: InputSchema;
244
+ classification?: Record<string, unknown>;
245
+ is_template?: boolean;
246
+ template?: Record<string, unknown> | null;
247
+ [key: string]: unknown;
248
+ }
249
+
250
+ /** The AIgentFlow version whose flow schema this validator tracks. */
251
+ declare const SPEC_VERSION: string;
252
+ /** Current supported `input_schema.version`. */
253
+ declare const INPUT_SCHEMA_VERSION: number;
254
+
255
+ /** Result of parsing flow YAML. */
256
+ interface ParseOutput {
257
+ /** The parsed flow object, present only when there are no parse errors. */
258
+ flow?: Flow;
259
+ /** Fatal YAML syntax / structure errors. Non-empty means `flow` is absent. */
260
+ parseErrors: ValidationIssue[];
261
+ /** Non-fatal YAML warnings (e.g. deprecated tags). */
262
+ parseWarnings: ValidationIssue[];
263
+ /**
264
+ * The SOURCE spelling of every number and boolean scalar, keyed by field path
265
+ * (`mock_scenarios.s.fetch.delay`). The reference decodes a scalar into a Go
266
+ * `string` field as its source text, so `delay: 0.0` arrives there as "0.0"
267
+ * (not a Go duration) while the parsed value here is the number 0. Present
268
+ * whenever `flow` is.
269
+ */
270
+ scalarSources?: ReadonlyMap<string, string>;
271
+ }
272
+ /**
273
+ * Parse flow YAML into a {@link Flow} object plus structured parse diagnostics.
274
+ * Never throws — malformed input is reported via `parseErrors`.
275
+ */
276
+ declare function parseFlow(yamlText: string): ParseOutput;
277
+
278
+ /**
279
+ * Validate an already-parsed flow object. Use this when you have a plain
280
+ * object (e.g. from your own YAML/JSON loader); use {@link validateFlow} to
281
+ * parse YAML text and validate in one step.
282
+ */
283
+ declare function validateFlowObject(flow: unknown, opts?: ValidateOptions): ValidationResult;
284
+ /**
285
+ * Parse flow YAML text and validate it. Parse errors (syntax, duplicate keys)
286
+ * are returned as `error`-severity issues; on a parse failure the structural
287
+ * validators are skipped because there is no usable document.
288
+ */
289
+ declare function validateFlow(yamlText: string, opts?: ValidateOptions): ValidationResult;
290
+
291
+ export { type Flow, INPUT_SCHEMA_VERSION, type ParseOutput, SPEC_VERSION, type Severity, type ValidateOptions, type ValidationIssue, type ValidationResult, type ValidationSummary, parseFlow, validateFlow, validateFlowObject };