@usearazzo/runner 1.0.1-alpha.32 → 1.0.1-alpha.34

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.
Files changed (66) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +10 -1
  3. package/dist/arazzo-runner.browser.js +1789 -403
  4. package/dist/arazzo-runner.browser.min.js +1 -1
  5. package/package.json +18 -17
  6. package/src/ArazzoRunner.cjs +26 -3
  7. package/src/ArazzoRunner.mjs +26 -3
  8. package/src/action/ActionResolver.cjs +13 -12
  9. package/src/action/ActionResolver.mjs +13 -12
  10. package/src/client/OpenAPIOperationResponse.cjs +9 -0
  11. package/src/client/OpenAPIOperationResponse.mjs +9 -0
  12. package/src/criterion/CriterionEvaluator.cjs +13 -8
  13. package/src/criterion/CriterionEvaluator.mjs +13 -8
  14. package/src/criterion/SimpleCriterionEvaluator.cjs +5 -3
  15. package/src/criterion/SimpleCriterionEvaluator.mjs +6 -4
  16. package/src/document/APIDocument.cjs +53 -0
  17. package/src/document/APIDocument.mjs +53 -0
  18. package/src/executor/OpenAPIOperationExecutor.cjs +66 -6
  19. package/src/executor/OpenAPIOperationExecutor.mjs +66 -6
  20. package/src/executor/OpenAPIOperationLocatorNormalizer.cjs +1 -1
  21. package/src/executor/OpenAPIOperationLocatorNormalizer.mjs +1 -1
  22. package/src/executor/StepExecutor.cjs +34 -15
  23. package/src/executor/StepExecutor.mjs +34 -15
  24. package/src/executor/StepRetryRunner.cjs +5 -3
  25. package/src/executor/StepRetryRunner.mjs +5 -3
  26. package/src/executor/StepTransitionInterpreter.cjs +1 -1
  27. package/src/executor/StepTransitionInterpreter.mjs +1 -1
  28. package/src/executor/WorkflowCallStack.cjs +1 -1
  29. package/src/executor/WorkflowCallStack.mjs +1 -1
  30. package/src/executor/WorkflowExecutor.cjs +277 -61
  31. package/src/executor/WorkflowExecutor.mjs +277 -61
  32. package/src/expression/RuntimeExpressionEvaluator.cjs +52 -9
  33. package/src/expression/RuntimeExpressionEvaluator.mjs +52 -9
  34. package/src/index.cjs +7 -0
  35. package/src/index.mjs +2 -0
  36. package/src/observability/ArazzoRunnerEvent.cjs +5 -0
  37. package/src/observability/ArazzoRunnerEvent.mjs +1 -0
  38. package/src/observability/DocumentRegistryEvent.cjs +5 -0
  39. package/src/observability/DocumentRegistryEvent.mjs +1 -0
  40. package/src/observability/EventChannel.cjs +96 -0
  41. package/src/observability/EventChannel.mjs +91 -0
  42. package/src/observability/OpenAPIOperationEvent.cjs +5 -0
  43. package/src/observability/OpenAPIOperationEvent.mjs +1 -0
  44. package/src/observability/Redactor.cjs +213 -0
  45. package/src/observability/Redactor.mjs +208 -0
  46. package/src/observability/WorkflowExecutionEvent.cjs +5 -0
  47. package/src/observability/WorkflowExecutionEvent.mjs +1 -0
  48. package/src/registry/DocumentRegistry.cjs +57 -11
  49. package/src/registry/DocumentRegistry.mjs +57 -11
  50. package/src/registry/providers/ArazzoDocumentRegistryProvider.cjs +21 -0
  51. package/src/registry/providers/ArazzoDocumentRegistryProvider.mjs +22 -1
  52. package/src/registry/providers/DocumentRegistryProvider.cjs +33 -1
  53. package/src/registry/providers/DocumentRegistryProvider.mjs +33 -1
  54. package/src/registry/providers/OpenAPIDocumentRegistryProvider.cjs +28 -5
  55. package/src/registry/providers/OpenAPIDocumentRegistryProvider.mjs +28 -5
  56. package/src/resolver/ArazzoValueResolver.cjs +6 -3
  57. package/src/resolver/ArazzoValueResolver.mjs +6 -3
  58. package/src/resolver/OpenAPIOperationParameterResolver.cjs +2 -2
  59. package/src/resolver/OpenAPIOperationParameterResolver.mjs +2 -2
  60. package/src/resolver/OutputResolver.cjs +10 -3
  61. package/src/resolver/OutputResolver.mjs +10 -3
  62. package/src/resolver/RequestBodyResolver.cjs +37 -17
  63. package/src/resolver/RequestBodyResolver.mjs +37 -17
  64. package/src/resolver/WorkflowParameterResolver.cjs +2 -2
  65. package/src/resolver/WorkflowParameterResolver.mjs +2 -2
  66. package/types/runner.d.ts +788 -41
package/types/runner.d.ts CHANGED
@@ -2,13 +2,14 @@ import type { ApiDOMErrorOptions } from '@speclynx/apidom-error';
2
2
  import { ApiDOMReferenceOptions } from '@speclynx/apidom-reference/configuration/empty';
3
3
  import { ApiDOMStructuredError } from '@speclynx/apidom-error';
4
4
  import { CriterionElement } from '@speclynx/apidom-ns-arazzo-1';
5
+ import type { Element as Element_2 } from '@speclynx/apidom-datamodel';
5
6
  import { FailureActionElement } from '@speclynx/apidom-ns-arazzo-1';
6
7
  import { FailureActionParametersElement } from '@speclynx/apidom-ns-arazzo-1';
7
8
  import { JSONPointer } from '@speclynx/apidom-json-pointer';
8
9
  import { OperationElement } from '@speclynx/apidom-ns-openapi-2';
9
10
  import { OperationElement as OperationElement_2 } from '@speclynx/apidom-ns-openapi-3-0';
10
11
  import { OperationElement as OperationElement_3 } from '@speclynx/apidom-ns-openapi-3-1';
11
- import type { ParseResultElement } from '@usearazzo/parser';
12
+ import { ParseResultElement } from '@usearazzo/parser';
12
13
  import type { PartialDeep } from 'type-fest';
13
14
  import { PathItemElement } from '@speclynx/apidom-ns-openapi-2';
14
15
  import { PathItemElement as PathItemElement_2 } from '@speclynx/apidom-ns-openapi-3-0';
@@ -66,14 +67,45 @@ export declare class ActionResolver {
66
67
  * `end` its author was reaching for would otherwise never happen without a
67
68
  * word said about why.
68
69
  */
69
- resolveOnSuccess(actions: StepOnSuccessElement | undefined, isCriterionMet: CriterionPredicate, scope: StepScope): SuccessActionElement[];
70
+ resolveOnSuccess(actions: StepOnSuccessElement | undefined, isCriterionMet: CriterionPredicate, scope: StepScope): Promise<SuccessActionElement[]>;
70
71
  /**
71
72
  * Returns every `onFailure` action whose criteria are all met, in list order.
72
73
  *
73
74
  * Same matching and error behavior as {@link ActionResolver.resolveOnSuccess} —
74
75
  * see there for the full rationale — mirrored for the step's other list.
75
76
  */
76
- resolveOnFailure(actions: StepOnFailureElement | undefined, isCriterionMet: CriterionPredicate, scope: StepScope): FailureActionElement[];
77
+ resolveOnFailure(actions: StepOnFailureElement | undefined, isCriterionMet: CriterionPredicate, scope: StepScope): Promise<FailureActionElement[]>;
78
+ }
79
+
80
+ /**
81
+ * The action an attempt resolved to: the `retry` that re-runs the step, or,
82
+ * for its last attempt, the step's terminal action. The attempt a `retry`
83
+ * reference makes at another step selects none.
84
+ * @public
85
+ */
86
+ export declare interface ActionSelectedEvent extends WorkflowExecutionStepEventBase {
87
+ readonly type: 'action-selected';
88
+ /**
89
+ * Where the selected action is written; absent when no action was
90
+ * selected.
91
+ */
92
+ readonly location?: DocumentLocation;
93
+ readonly attempt: number;
94
+ /**
95
+ * The selected action. Absent when none matched, so the step takes the
96
+ * default path: the next step on success, a break on failure. It is the
97
+ * document's own element, shared with the trace: read it, never change it.
98
+ */
99
+ readonly action?: SelectedAction;
100
+ /**
101
+ * What the run does next because of it, as plain data: `retry` re-runs the
102
+ * step, and the rest are the step's terminal transition — `next`, `goto` a
103
+ * step, `transfer` to a workflow, `end`, or `break`. With no `action`, it is
104
+ * the default path: `next` on success, `break` on failure.
105
+ */
106
+ readonly transition: StepTransition | {
107
+ readonly kind: 'retry';
108
+ };
77
109
  }
78
110
 
79
111
  /**
@@ -85,6 +117,13 @@ export declare abstract class APIDocument {
85
117
  readonly uri: string;
86
118
  readonly parseResult: ParseResultElement;
87
119
  protected constructor(uri: string, parseResult: ParseResultElement);
120
+ /**
121
+ * Where an element of this document, or one it references, is written, as
122
+ * the registry provider recorded it when it loaded the document: the
123
+ * document it came from (its `ref-origin`) when it came through a
124
+ * reference, and its JSON Pointer there.
125
+ */
126
+ locationOf(element: Element_2): DocumentLocation;
88
127
  /**
89
128
  * Returns a JSON-serializable representation of the document's API element.
90
129
  * Compatible with JSON.stringify() — JSON.stringify(doc) produces correct output.
@@ -163,6 +202,7 @@ export declare class ArazzoDocument extends APIDocument {
163
202
  */
164
203
  export declare class ArazzoDocumentRegistryProvider extends DocumentRegistryProvider {
165
204
  #private;
205
+ readonly sourceDescriptionType = "arazzo";
166
206
  constructor(options?: ArazzoDocumentRegistryProviderOptions);
167
207
  canProvide(uri: string): Promise<boolean>;
168
208
  /**
@@ -218,14 +258,40 @@ export declare class ArazzoRunner {
218
258
  export declare class ArazzoRunnerError extends ApiDOMStructuredError {
219
259
  }
220
260
 
261
+ /**
262
+ * Every event the runner's building blocks emit, discriminated by `type`.
263
+ *
264
+ * Events carry no level or severity, like Node's `diagnostics_channel`
265
+ * messages: how to log an event is the logging consumer's decision. The
266
+ * `document-*`, `workflow-normalize-*` and `openapi-operation-*` events describe the
267
+ * machinery under a run, the detail a debug log would show.
268
+ * @public
269
+ */
270
+ export declare type ArazzoRunnerEvent = WorkflowExecutionEvent | DocumentRegistryEvent | OpenAPIOperationEvent;
271
+
272
+ /**
273
+ * The fields every {@link ArazzoRunnerEvent} carries.
274
+ * @public
275
+ */
276
+ export declare interface ArazzoRunnerEventBase {
277
+ /**
278
+ * When the event happened, read from the emitting block's injected `now`
279
+ * clock (`performance.now` by default). Timestamps of different blocks
280
+ * compare only when the blocks share a clock, as the ones
281
+ * {@link ArazzoRunner} wires do.
282
+ */
283
+ readonly timestamp: number;
284
+ }
285
+
221
286
  /**
222
287
  * Options for {@link ArazzoRunner.load}.
223
288
  *
224
289
  * Every option is a seam of a building block the runner wires: `registry` is
225
290
  * the {@link DocumentRegistry} the documents load into (a fresh one with the
226
291
  * default providers when omitted), `reference` goes to everything the runner
227
- * builds that retrieves documents, `httpClient` and `requestInterceptor` go to
228
- * the {@link OpenAPIOperationExecutor}, and the rest go to the
292
+ * builds that retrieves documents, `httpClient`, `requestInterceptor` and
293
+ * `captureBodies` go to the {@link OpenAPIOperationExecutor}, and the rest go
294
+ * to the
229
295
  * {@link WorkflowExecutor}.
230
296
  *
231
297
  * Retrieving documents and calling APIs are separate on purpose: `reference`
@@ -233,7 +299,7 @@ export declare class ArazzoRunnerError extends ApiDOMStructuredError {
233
299
  * apply to document retrieval, so credentials for one do not reach the other.
234
300
  * @public
235
301
  */
236
- export declare interface ArazzoRunnerLoadOptions extends Pick<OpenAPIOperationExecutorOptions, 'httpClient' | 'requestInterceptor'>, Pick<WorkflowExecutorOptions, 'maxSteps' | 'maxWorkflowDepth' | 'sleep' | 'now'> {
302
+ export declare interface ArazzoRunnerLoadOptions extends Pick<OpenAPIOperationExecutorOptions, 'httpClient' | 'requestInterceptor' | 'captureBodies'>, Pick<WorkflowExecutorOptions, 'maxSteps' | 'maxWorkflowDepth' | 'sleep' | 'now'> {
237
303
  /**
238
304
  * The registry to load the documents into. A registry backs one entry
239
305
  * document: loading a different one into it throws.
@@ -253,13 +319,56 @@ export declare interface ArazzoRunnerLoadOptions extends Pick<OpenAPIOperationEx
253
319
  * same options.
254
320
  */
255
321
  readonly reference?: ArazzoRunnerReferenceOptions;
322
+ /**
323
+ * Parses the documents with source maps, so every `location` (on events,
324
+ * and on the result's steps and criteria) carries the element's range. Off by
325
+ * default: source-mapped parsing is slower and keeps more in memory. It
326
+ * changes no other behaviour: a document that fails to parse without it
327
+ * fails with it. A `registry` passed alongside parses as its own providers
328
+ * say.
329
+ */
330
+ readonly sourceMap?: boolean;
331
+ /**
332
+ * Receives the events of every building block the runner wires, stamped
333
+ * with `now`: the run's workflows, steps and the decisions behind them, and
334
+ * the machinery under them (document loads, workflow and operation
335
+ * normalization, request assembly). See {@link ArazzoRunnerEvent}.
336
+ *
337
+ * Loads into a `registry` passed alongside are reported only if that
338
+ * registry was given an observer of its own.
339
+ */
340
+ readonly observer?: ArazzoRunnerObserver;
256
341
  }
257
342
 
343
+ /**
344
+ * Receives events as they happen. Each building block takes one as its
345
+ * `observer` option, typed to the events it emits; an observer of every
346
+ * {@link ArazzoRunnerEvent} fits them all.
347
+ *
348
+ * It is called synchronously and never awaited, so it cannot slow down or
349
+ * reorder a run. A handler that throws aborts the run with that error. A
350
+ * returned promise is ignored, rejection included: an async observer handles
351
+ * its own errors.
352
+ *
353
+ * Each event is a frozen copy of its plain data, so changing it cannot reach
354
+ * the run. Anything else is shared and must be treated as read-only: the
355
+ * ApiDOM element in {@link ActionSelectedEvent.action}, or a `Map` or class
356
+ * instance a custom HTTP client put into a response body.
357
+ *
358
+ * Events carry what the run saw, credentials included, like the request a
359
+ * request interceptor receives. Pass them through {@link Redactor.event}
360
+ * before they leave the process.
361
+ *
362
+ * A building block without an observer builds no events.
363
+ * @public
364
+ */
365
+ export declare type ArazzoRunnerObserver<E extends ArazzoRunnerEvent = ArazzoRunnerEvent> = (event: E) => void;
366
+
258
367
  /**
259
368
  * Options for the ArazzoRunner constructor.
260
369
  * @public
261
370
  */
262
- export declare interface ArazzoRunnerOptions extends Omit<ArazzoRunnerLoadOptions, 'registry'> {
371
+ export declare interface ArazzoRunnerOptions extends Omit<ArazzoRunnerLoadOptions, 'registry' | 'sourceMap'> {
263
372
  /**
264
373
  * The entry Arazzo document holding the workflows to run.
265
374
  */
@@ -347,7 +456,7 @@ export declare abstract class ArazzoValueResolver {
347
456
  /**
348
457
  * Resolves one authored value element by the rule above.
349
458
  */
350
- protected resolveValue(element: unknown, resolve: RuntimeExpressionResolver): unknown;
459
+ protected resolveValue(element: unknown, resolve: RuntimeExpressionResolver): Promise<unknown>;
351
460
  }
352
461
 
353
462
  /**
@@ -498,14 +607,19 @@ export declare interface ContextSource {
498
607
  }
499
608
 
500
609
  /**
501
- * Resolves a runtime expression to a value during criterion evaluation.
610
+ * Resolves a runtime expression to a value, or to a Promise of it, during
611
+ * criterion evaluation. The result is awaited, so a synchronous resolver works
612
+ * too.
502
613
  *
503
614
  * Used both for a criterion's `context` (regex/jsonpath/xpath) and for the
504
615
  * expressions embedded in a `simple` condition. It should resolve leniently —
505
616
  * an unresolvable reference returning `undefined` fails the criterion rather
506
617
  * than throwing (a common way to drive it is
507
618
  * `(expression) => runtimeExpressionEvaluator.evaluate(expression)` with a
508
- * lenient evaluator).
619
+ * lenient evaluator). An error it throws or rejects with — such as the load
620
+ * error of a `$sourceDescriptions` document that cannot be loaded — is not a
621
+ * {@link CriterionEvaluationError}, so it propagates instead of failing the
622
+ * criterion.
509
623
  * @public
510
624
  */
511
625
  export declare type CriterionContextResolver = (expression: string) => unknown;
@@ -567,6 +681,26 @@ export declare class CriterionError extends ArazzoRunnerError {
567
681
  */
568
682
  export declare type CriterionErrorReason = (typeof CriterionError)[Exclude<keyof typeof CriterionError, keyof typeof ArazzoRunnerError | 'prototype'>];
569
683
 
684
+ /**
685
+ * One criterion was evaluated during an attempt. Fired after the attempt's
686
+ * request (or sub-workflow run), in list order, success criteria first.
687
+ * @public
688
+ */
689
+ export declare interface CriterionEvaluatedEvent extends WorkflowExecutionStepEventBase {
690
+ readonly type: 'criterion-evaluated';
691
+ /**
692
+ * Where the criterion is written.
693
+ */
694
+ readonly location: DocumentLocation;
695
+ readonly attempt: number;
696
+ /**
697
+ * `success` for one of the step's `successCriteria`, `action` for a
698
+ * criterion of an `onSuccess` / `onFailure` action the attempt considered.
699
+ */
700
+ readonly kind: 'success' | 'action';
701
+ readonly criterion: CriterionEvaluationRecord;
702
+ }
703
+
570
704
  /**
571
705
  * A criterion condition that cannot be evaluated: a syntax error in the
572
706
  * condition, a context the condition cannot apply to, or an error raised while
@@ -597,6 +731,21 @@ export declare interface CriterionEvaluationRecord {
597
731
  * action criterion.
598
732
  */
599
733
  readonly actionName?: string;
734
+ /**
735
+ * Every runtime expression the evaluation resolved, keyed by the expression
736
+ * as written, with the value it resolved to: the expressions embedded in a
737
+ * `simple` condition, or the `context` of a `regex`, `jsonpath` or `xpath`
738
+ * one. What the criterion actually saw, e.g. `{ "$statusCode": 404 }`.
739
+ *
740
+ * A whole body (`$response.body`, `$request.body`) is recorded as the
741
+ * placeholder `[body]`, so the trace never holds a body; the body and its
742
+ * size are in the attempt's `openapi-operation-request-settled` event.
743
+ */
744
+ readonly values: Readonly<Record<string, unknown>>;
745
+ /**
746
+ * Where the criterion is written.
747
+ */
748
+ readonly location: DocumentLocation;
600
749
  /**
601
750
  * Why the condition could not be evaluated — present only then, with `met`
602
751
  * `false`.
@@ -665,7 +814,7 @@ export declare class CriterionEvaluator {
665
814
  * the expressions embedded in the condition; for the other types it resolves
666
815
  * the criterion's `context` expression that the condition is applied to.
667
816
  */
668
- evaluate(criterion: CriterionElement, resolve: CriterionContextResolver): CriterionOutcome;
817
+ evaluate(criterion: CriterionElement, resolve: CriterionContextResolver): Promise<CriterionOutcome>;
669
818
  }
670
819
 
671
820
  /**
@@ -713,21 +862,124 @@ export declare interface CriterionOutcome {
713
862
  }
714
863
 
715
864
  /**
716
- * Determines whether a single criterion of an action is met. Receives the
717
- * action declaring the criterion, so a caller can attribute the outcome to it.
865
+ * Determines whether a single criterion of an action is met, or resolves to
866
+ * whether it is. Receives the action declaring the criterion, so a caller can
867
+ * attribute the outcome to it.
718
868
  *
719
869
  * Bridged to a criterion evaluator
720
- * (`(criterion) => criterionEvaluator.evaluate(criterion, resolve).met`); an
721
- * unresolvable/failing criterion is `false`, not an error.
870
+ * (`async (criterion) => (await criterionEvaluator.evaluate(criterion, resolve)).met`);
871
+ * an unresolvable/failing criterion is `false`, not an error.
872
+ * @public
873
+ */
874
+ export declare type CriterionPredicate = (criterion: CriterionElement, action: SelectedAction) => boolean | Promise<boolean>;
875
+
876
+ /**
877
+ * A `dependsOn` prerequisite was satisfied, or failed.
878
+ * @public
879
+ */
880
+ export declare interface DependencySettledEvent extends WorkflowExecutionEventBase {
881
+ readonly type: 'dependency-settled';
882
+ readonly dependency: WorkflowExecutionDependency;
883
+ /**
884
+ * Whether the prerequisite had already completed earlier in this run and was
885
+ * not run again. When it is `true`, no workflow events of its own precede
886
+ * this event.
887
+ */
888
+ readonly memoized: boolean;
889
+ readonly settledStatus: WorkflowExecutionResult['settledStatus'];
890
+ }
891
+
892
+ /**
893
+ * A `dependsOn` prerequisite is about to be satisfied: either run, or found
894
+ * already completed earlier in the same run.
722
895
  * @public
723
896
  */
724
- export declare type CriterionPredicate = (criterion: CriterionElement, action: SelectedAction) => boolean;
897
+ export declare interface DependencyStartEvent extends WorkflowExecutionEventBase {
898
+ readonly type: 'dependency-start';
899
+ /**
900
+ * Where the `dependsOn` entry is written.
901
+ */
902
+ readonly location: DocumentLocation;
903
+ readonly dependency: WorkflowExecutionDependency;
904
+ }
725
905
 
726
906
  /** @public */
727
907
  export declare class DocumentLoadError extends ArazzoRunnerError {
728
908
  readonly uri?: string;
729
909
  }
730
910
 
911
+ /**
912
+ * The registry loaded a document, which it caches right after. A load that
913
+ * fails throws and emits no settled event; an observer that throws here
914
+ * leaves the document uncached.
915
+ * @public
916
+ */
917
+ export declare interface DocumentLoadSettledEvent extends ArazzoRunnerEventBase {
918
+ readonly type: 'document-load-settled';
919
+ readonly uri: string;
920
+ }
921
+
922
+ /**
923
+ * The registry started loading a document it had neither cached nor already
924
+ * loading. Cache hits emit nothing.
925
+ *
926
+ * Registry events carry no `runId`: the registry is shared, and one load can
927
+ * serve several runs at once.
928
+ * @public
929
+ */
930
+ export declare interface DocumentLoadStartEvent extends ArazzoRunnerEventBase {
931
+ readonly type: 'document-load-start';
932
+ /**
933
+ * The canonical URI of the document.
934
+ */
935
+ readonly uri: string;
936
+ }
937
+
938
+ /**
939
+ * Where an element is written.
940
+ * @public
941
+ */
942
+ export declare interface DocumentLocation {
943
+ /**
944
+ * The document that defines the element: the one it came from when it was
945
+ * reached through a reference (a workflow of another Arazzo document, an
946
+ * operation of a Path Item Object written as a `$ref`), not necessarily the
947
+ * entry document.
948
+ */
949
+ readonly uri: string;
950
+ /**
951
+ * The element's JSON Pointer in that document. Absent only for an element
952
+ * whose pointer no one recorded: the runner records one for every element
953
+ * an event locates.
954
+ */
955
+ readonly jsonPointer?: string;
956
+ /**
957
+ * The element's range in that document, present only when the document was
958
+ * parsed with source maps (`sourceMap` on `ArazzoRunner.load`).
959
+ */
960
+ readonly range?: DocumentRange;
961
+ }
962
+
963
+ /**
964
+ * A position in a document, as in the Language Server Protocol: a 0-based
965
+ * line, and a 0-based character offset within it in UTF-16 code units.
966
+ * @public
967
+ */
968
+ export declare interface DocumentPosition {
969
+ readonly line: number;
970
+ readonly character: number;
971
+ }
972
+
973
+ /**
974
+ * A range in a document, as in the Language Server Protocol: from `start` to
975
+ * `end`, the shape the validator's diagnostics use.
976
+ * @public
977
+ */
978
+ export declare interface DocumentRange {
979
+ readonly start: DocumentPosition;
980
+ readonly end: DocumentPosition;
981
+ }
982
+
731
983
  /**
732
984
  * Registry for API documents keyed by canonical URI.
733
985
  *
@@ -748,20 +1000,24 @@ export declare class DocumentRegistry {
748
1000
  * otherwise detects the format, loads via the matching provider,
749
1001
  * caches, and returns it.
750
1002
  *
1003
+ * Concurrent calls for a document that is still loading share that one
1004
+ * load instead of each fetching and parsing it. A failed load is not
1005
+ * remembered: the next call tries again.
1006
+ *
751
1007
  * @throws DocumentLoadError - When the document cannot be read or loaded
752
1008
  * @throws UnmatchedProviderError - When no provider can load the document
753
1009
  */
754
1010
  acquire(uri: string): Promise<APIDocument>;
755
1011
  /**
756
- * Returns an already-loaded document by URI, or undefined if not cached.
1012
+ * Whether a source description of `type` can be loaded at all: some provider
1013
+ * loads that type, or does not say which type it loads. A source with no
1014
+ * `type` may be of any type, so it can.
757
1015
  *
758
- * Synchronous counterpart to `acquire`: it never loads a document, only
759
- * returns one the registry already holds, marking it most recently used like
760
- * any other access. Consumers that must resolve a reference without awaiting
761
- * (e.g. runtime expression evaluation) use this; the executor is responsible
762
- * for having acquired the document beforehand.
1016
+ * Answered from the providers alone, without fetching anything — so a
1017
+ * caller can skip a load that could only fail, such as an AsyncAPI source
1018
+ * while no provider loads AsyncAPI.
763
1019
  */
764
- get(uri: string): APIDocument | undefined;
1020
+ canLoad(type: string | undefined): boolean;
765
1021
  /**
766
1022
  * Acquires the entry Arazzo document and marks it with `isEntry: true`.
767
1023
  * Validates that the document is an Arazzo specification.
@@ -771,15 +1027,35 @@ export declare class DocumentRegistry {
771
1027
  * @throws InvalidEntryDocumentError - When the document is not an Arazzo document
772
1028
  */
773
1029
  acquireEntryDocument(uri: string): Promise<ArazzoDocument>;
1030
+ /**
1031
+ * Drops every cached document. A load still in progress is no longer shared:
1032
+ * the next `acquire` of that document starts a fresh load.
1033
+ */
774
1034
  clear(): void;
775
1035
  }
776
1036
 
1037
+ /**
1038
+ * An event the {@link DocumentRegistry} emits.
1039
+ * @public
1040
+ */
1041
+ export declare type DocumentRegistryEvent = DocumentLoadStartEvent | DocumentLoadSettledEvent;
1042
+
777
1043
  /**
778
1044
  * Options for the DocumentRegistry.
779
1045
  * @public
780
1046
  */
781
1047
  export declare interface DocumentRegistryOptions {
782
1048
  readonly providers?: DocumentRegistryProvider[];
1049
+ /**
1050
+ * Receives the registry's events: the start and end of every document
1051
+ * load. Cache hits emit nothing. See {@link DocumentRegistryEvent}.
1052
+ */
1053
+ readonly observer?: ArazzoRunnerObserver<DocumentRegistryEvent>;
1054
+ /**
1055
+ * Reads the current time in milliseconds, stamped on each event. Defaults to
1056
+ * `performance.now`.
1057
+ */
1058
+ readonly now?: () => number;
783
1059
  }
784
1060
 
785
1061
  /**
@@ -789,6 +1065,15 @@ export declare interface DocumentRegistryOptions {
789
1065
  * @public
790
1066
  */
791
1067
  export declare abstract class DocumentRegistryProvider {
1068
+ /**
1069
+ * The Source Description Object `type` this provider loads (`openapi`,
1070
+ * `arazzo`, …), or `undefined` when it does not say — then it may load a
1071
+ * source of any type.
1072
+ *
1073
+ * Lets the registry tell, without fetching anything, whether a source of a
1074
+ * given type can be loaded at all (`DocumentRegistry.canLoad`).
1075
+ */
1076
+ readonly sourceDescriptionType?: string;
792
1077
  /**
793
1078
  * Checks if the content at the URI can be handled by this provider.
794
1079
  */
@@ -797,6 +1082,13 @@ export declare abstract class DocumentRegistryProvider {
797
1082
  * Loads and produces a document from a URI.
798
1083
  */
799
1084
  abstract provide(uri: string): Promise<APIDocument>;
1085
+ /**
1086
+ * Rejects a document the parser could only partly read. The strict parsers
1087
+ * throw on a syntax error; the lenient ones that source maps need record it
1088
+ * and parse what they can instead, so a document must load with source maps
1089
+ * exactly when it loads without.
1090
+ */
1091
+ protected assertParsed(uri: string, parseResult: ParseResultElement): void;
800
1092
  }
801
1093
 
802
1094
  /**
@@ -1127,6 +1419,7 @@ export declare interface OpenAPIDocumentAssemblerOptions {
1127
1419
  */
1128
1420
  export declare class OpenAPIDocumentRegistryProvider extends DocumentRegistryProvider {
1129
1421
  #private;
1422
+ readonly sourceDescriptionType = "openapi";
1130
1423
  constructor(options?: OpenAPIDocumentRegistryProviderOptions);
1131
1424
  canProvide(uri: string): Promise<boolean>;
1132
1425
  /**
@@ -1141,12 +1434,48 @@ export declare class OpenAPIDocumentRegistryProvider extends DocumentRegistryPro
1141
1434
  */
1142
1435
  export declare type OpenAPIDocumentRegistryProviderOptions = DocumentRegistryProviderOptions;
1143
1436
 
1437
+ /**
1438
+ * The normalized operation was assembled into the OpenAPI document the
1439
+ * request is built from.
1440
+ * @public
1441
+ */
1442
+ export declare interface OpenAPIOperationAssembledEvent extends OpenAPIOperationEventBase {
1443
+ readonly type: 'openapi-operation-assembled';
1444
+ }
1445
+
1144
1446
  /**
1145
1447
  * Union of OperationElement across all supported OpenAPI versions.
1146
1448
  * @public
1147
1449
  */
1148
1450
  export declare type OpenAPIOperationElement = OperationElement | OperationElement_2 | OperationElement_3;
1149
1451
 
1452
+ /**
1453
+ * An event the {@link OpenAPIOperationExecutor} emits.
1454
+ * @public
1455
+ */
1456
+ export declare type OpenAPIOperationEvent = OpenAPIOperationNormalizeStartEvent | OpenAPIOperationNormalizeSettledEvent | OpenAPIOperationAssembledEvent | OpenAPIOperationRequestStartEvent | OpenAPIOperationRequestSettledEvent;
1457
+
1458
+ /**
1459
+ * The fields every {@link OpenAPIOperationEvent} carries: the operation, and
1460
+ * the step it runs for, in the same shape a {@link RequestInterceptor}
1461
+ * receives them.
1462
+ * @public
1463
+ */
1464
+ export declare interface OpenAPIOperationEventBase extends ArazzoRunnerEventBase, RequestContext {
1465
+ /**
1466
+ * Where the operation is written. It differs from `operation` (where the
1467
+ * operation was looked up) for an operation of a Path Item Object written
1468
+ * as a `$ref`, which is written in the document the reference names.
1469
+ */
1470
+ readonly location: DocumentLocation;
1471
+ /**
1472
+ * The `runId` of the {@link WorkflowExecutor.execute} call the operation
1473
+ * runs for, from the execute options. Absent when the executor is used
1474
+ * without one.
1475
+ */
1476
+ readonly runId?: string;
1477
+ }
1478
+
1150
1479
  /**
1151
1480
  * Options for executing an OpenAPI operation.
1152
1481
  *
@@ -1216,6 +1545,12 @@ export declare interface OpenAPIOperationExecuteOptions {
1216
1545
  */
1217
1546
  readonly securities?: OpenAPIOperationSecurities;
1218
1547
  readonly signal?: AbortSignal;
1548
+ /**
1549
+ * Identifies the run this call belongs to, stamped on the executor's events
1550
+ * (see {@link OpenAPIOperationEventBase.runId}). Consumed by the executor,
1551
+ * never sent. The workflow executor sets it for every step.
1552
+ */
1553
+ readonly runId?: string;
1219
1554
  /**
1220
1555
  * Runs after the executor-level interceptor, for this call only.
1221
1556
  */
@@ -1324,6 +1659,22 @@ export declare interface OpenAPIOperationExecutorOptions {
1324
1659
  * fresh {@link OpenAPIDocumentAssembler}.
1325
1660
  */
1326
1661
  readonly documentAssembler?: OpenAPIDocumentAssembler;
1662
+ /**
1663
+ * Receives the executor's events: the start and end of each operation's
1664
+ * normalization, its assembly, and the request sent and its response. See
1665
+ * {@link OpenAPIOperationEvent}.
1666
+ */
1667
+ readonly observer?: ArazzoRunnerObserver<OpenAPIOperationEvent>;
1668
+ /**
1669
+ * Reads the current time in milliseconds, stamped on each event. Defaults to
1670
+ * `performance.now`.
1671
+ */
1672
+ readonly now?: () => number;
1673
+ /**
1674
+ * Whether the `openapi-operation-request-*` events carry the request and
1675
+ * response bodies. Off by default.
1676
+ */
1677
+ readonly captureBodies?: boolean;
1327
1678
  }
1328
1679
 
1329
1680
  /**
@@ -1468,6 +1819,23 @@ export declare interface OpenAPIOperationNormalizerOptions {
1468
1819
  readonly openapi31?: OpenAPI31OperationNormalizer;
1469
1820
  }
1470
1821
 
1822
+ /**
1823
+ * The operation was normalized.
1824
+ * @public
1825
+ */
1826
+ export declare interface OpenAPIOperationNormalizeSettledEvent extends OpenAPIOperationEventBase {
1827
+ readonly type: 'openapi-operation-normalize-settled';
1828
+ }
1829
+
1830
+ /**
1831
+ * Normalization of the operation began: dereferencing it (which may fetch
1832
+ * externally referenced documents) and inheriting its path-level fields.
1833
+ * @public
1834
+ */
1835
+ export declare interface OpenAPIOperationNormalizeStartEvent extends OpenAPIOperationEventBase {
1836
+ readonly type: 'openapi-operation-normalize-start';
1837
+ }
1838
+
1471
1839
  /**
1472
1840
  * Resolves the `parameters` of a step targeting an OpenAPI operation into the
1473
1841
  * map the operation is executed with.
@@ -1517,7 +1885,7 @@ export declare class OpenAPIOperationParameterResolver extends StepParameterReso
1517
1885
  *
1518
1886
  * `scope` names the step in a thrown {@link ResolverError}.
1519
1887
  */
1520
- resolve(parameters: StepParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Record<string, unknown>;
1888
+ resolve(parameters: StepParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Promise<Record<string, unknown>>;
1521
1889
  }
1522
1890
 
1523
1891
  /**
@@ -1562,6 +1930,51 @@ export declare interface OpenAPIOperationRequestInfo {
1562
1930
  readonly body?: unknown;
1563
1931
  }
1564
1932
 
1933
+ /**
1934
+ * The response was received and its body read, as it came: mask it with
1935
+ * {@link Redactor} before it leaves the process. A request that fails in the
1936
+ * transport throws and emits no settled event.
1937
+ * @public
1938
+ */
1939
+ export declare interface OpenAPIOperationRequestSettledEvent extends OpenAPIOperationEventBase {
1940
+ readonly type: 'openapi-operation-request-settled';
1941
+ readonly response: {
1942
+ readonly status: number;
1943
+ readonly headers: Readonly<Record<string, string>>;
1944
+ /**
1945
+ * The body's size in bytes: {@link OpenAPIOperationResponse.size}.
1946
+ */
1947
+ readonly size: number;
1948
+ /**
1949
+ * The body parsed by its content type, as `$response.body` reads it. Only
1950
+ * with {@link OpenAPIOperationExecutorOptions.captureBodies}.
1951
+ */
1952
+ readonly body?: unknown;
1953
+ };
1954
+ }
1955
+
1956
+ /**
1957
+ * The request about to be handed to the {@link HTTPClient}, after every
1958
+ * request interceptor ran, as it is sent: credentials included, like the
1959
+ * request an interceptor receives. Mask it with {@link Redactor} before it
1960
+ * leaves the process.
1961
+ * @public
1962
+ */
1963
+ export declare interface OpenAPIOperationRequestStartEvent extends OpenAPIOperationEventBase {
1964
+ readonly type: 'openapi-operation-request-start';
1965
+ readonly request: {
1966
+ readonly method: string;
1967
+ readonly url: string;
1968
+ readonly headers: Readonly<Record<string, string>>;
1969
+ /**
1970
+ * The body as handed to the {@link HTTPClient}: JSON or form text, or a
1971
+ * `FormData`, `Blob` or stream. Only with
1972
+ * {@link OpenAPIOperationExecutorOptions.captureBodies}.
1973
+ */
1974
+ readonly body?: unknown;
1975
+ };
1976
+ }
1977
+
1565
1978
  /**
1566
1979
  * Response from an OpenAPI operation execution.
1567
1980
  *
@@ -1593,6 +2006,11 @@ export declare class OpenAPIOperationResponse {
1593
2006
  content: string | Uint8Array;
1594
2007
  request?: OpenAPIOperationRequestInfo;
1595
2008
  });
2009
+ /**
2010
+ * The body's size in bytes, as read: after the transport decoded any
2011
+ * `Content-Encoding`, so a compressed body counts at its decoded size.
2012
+ */
2013
+ get size(): number;
1596
2014
  /**
1597
2015
  * The body as text, like `Response.text()`; `''` when there is none.
1598
2016
  */
@@ -1710,7 +2128,60 @@ export declare class OutputResolver extends ArazzoValueResolver {
1710
2128
  * {@link ResolverError}. An output value that is not a valid runtime
1711
2129
  * expression throws with reason `ResolverError.InvalidExpression`.
1712
2130
  */
1713
- resolve(outputs: StepOutputsElement | WorkflowOutputsElement | undefined, resolve: RuntimeExpressionResolver, scope: ResolverScope): Record<string, unknown>;
2131
+ resolve(outputs: StepOutputsElement | WorkflowOutputsElement | undefined, resolve: RuntimeExpressionResolver, scope: ResolverScope): Promise<Record<string, unknown>>;
2132
+ }
2133
+
2134
+ /**
2135
+ * Masks credentials in events before they leave the process.
2136
+ *
2137
+ * Events carry what the run saw, credentials included, like the request a
2138
+ * request interceptor receives. Pass every event through
2139
+ * {@link Redactor.event} before logging, exporting or writing it.
2140
+ *
2141
+ * It masks by name, whatever the event:
2142
+ *
2143
+ * - the value of any field whose name matches a pattern: headers, query
2144
+ * parameters, body and output fields, at any depth;
2145
+ * - a criterion value whose runtime expression reads a matching name, in its
2146
+ * base or in any token of its JSON Pointer (`$inputs.password`,
2147
+ * `$steps.login.outputs.token#/value`);
2148
+ * - in every absolute URL, as `URL` parses it, the userinfo and the matching
2149
+ * query and fragment parameters;
2150
+ * - a request or response body that is JSON or a URL-encoded form, field by
2151
+ * field, and any other body, or any object that is not plain data, whole.
2152
+ *
2153
+ * A credential under a name no pattern matches is carried as it is. The
2154
+ * masked value is `REDACTED`.
2155
+ * @public
2156
+ */
2157
+ export declare class Redactor {
2158
+ #private;
2159
+ static readonly CENSOR = "REDACTED";
2160
+ /**
2161
+ * Elastic APM's `sanitizeFieldNames` defaults, with `*secret*` for its exact
2162
+ * `secret` (which misses OAuth's `client_secret`), plus the signed-URL query
2163
+ * parameters OpenTelemetry's HTTP conventions mask.
2164
+ */
2165
+ static readonly defaultFields: readonly string[];
2166
+ constructor(options?: RedactorOptions);
2167
+ /**
2168
+ * A masked copy of the event.
2169
+ */
2170
+ event<E extends ArazzoRunnerEvent>(event: E): E;
2171
+ }
2172
+
2173
+ /**
2174
+ * Options for the Redactor.
2175
+ * @public
2176
+ */
2177
+ export declare interface RedactorOptions {
2178
+ /**
2179
+ * Wildcard patterns of the names whose values are masked. `*` matches any
2180
+ * run of characters; matching is case-insensitive and against the whole
2181
+ * name, so `*token*` matches `access_token` and `X-Auth-Token`. The list
2182
+ * replaces {@link Redactor.defaultFields}; spread it to extend it.
2183
+ */
2184
+ readonly fields?: readonly string[];
1714
2185
  }
1715
2186
 
1716
2187
  /**
@@ -1781,7 +2252,7 @@ export declare class RequestBodyResolver extends ArazzoValueResolver {
1781
2252
  *
1782
2253
  * `scope` names the step in a thrown {@link ResolverError}.
1783
2254
  */
1784
- resolve(requestBody: RequestBodyElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): ResolvedRequestBody | undefined;
2255
+ resolve(requestBody: RequestBodyElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Promise<ResolvedRequestBody | undefined>;
1785
2256
  }
1786
2257
 
1787
2258
  /**
@@ -1959,6 +2430,44 @@ export declare interface RetryReferenceRecord {
1959
2430
  readonly subWorkflow?: WorkflowExecutionResult;
1960
2431
  }
1961
2432
 
2433
+ /**
2434
+ * A `retry` action's reference completed.
2435
+ * @public
2436
+ */
2437
+ export declare interface RetryReferenceSettledEvent extends WorkflowExecutionStepEventBase {
2438
+ readonly type: 'retry-reference-settled';
2439
+ readonly attempt: number;
2440
+ readonly kind: RetryReferenceRecord['kind'];
2441
+ readonly id: RetryReferenceRecord['id'];
2442
+ readonly successful: RetryReferenceRecord['successful'];
2443
+ }
2444
+
2445
+ /**
2446
+ * A `retry` action's `stepId` / `workflowId` reference is about to run.
2447
+ * @public
2448
+ */
2449
+ export declare interface RetryReferenceStartEvent extends WorkflowExecutionStepEventBase {
2450
+ readonly type: 'retry-reference-start';
2451
+ /**
2452
+ * Where the `retry` action that names the reference is written.
2453
+ */
2454
+ readonly location: DocumentLocation;
2455
+ readonly attempt: number;
2456
+ readonly kind: RetryReferenceRecord['kind'];
2457
+ readonly id: RetryReferenceRecord['id'];
2458
+ }
2459
+
2460
+ /**
2461
+ * The run is about to wait out a `retry` action's `retryAfter` before the
2462
+ * step's next attempt. Fired only for a positive delay.
2463
+ * @public
2464
+ */
2465
+ export declare interface RetryWaitEvent extends WorkflowExecutionStepEventBase {
2466
+ readonly type: 'retry-wait';
2467
+ readonly attempt: number;
2468
+ readonly delayMs: number;
2469
+ }
2470
+
1962
2471
  /**
1963
2472
  * Identifies a step that calls a workflow, for the context its criteria,
1964
2473
  * outputs and actions are evaluated against.
@@ -2062,6 +2571,9 @@ export declare type RuntimeExpressionErrorReason = (typeof RuntimeExpressionErro
2062
2571
  * (via the registry) the source name points at. A step reference resolves to
2063
2572
  * the Step Object as authored — a locator, not the step's execution result.
2064
2573
  *
2574
+ * Evaluation is asynchronous because a `$sourceDescriptions` reference may
2575
+ * have to load the document it points at.
2576
+ *
2065
2577
  * A reference resolves to `undefined` when it is absent. Runtime values
2066
2578
  * originate from JSON (or ApiDOM), which cannot represent `undefined` — an
2067
2579
  * absent value is a missing property and an explicit null is `null` — so
@@ -2086,8 +2598,16 @@ export declare class RuntimeExpressionEvaluator {
2086
2598
  * The expression must be the bare form without surrounding braces
2087
2599
  * (e.g. `$inputs.username`, `$response.body#/pets/0/id`). In strict mode an
2088
2600
  * unresolvable reference throws; otherwise it returns `undefined`.
2601
+ *
2602
+ * A `$sourceDescriptions` reference whose document cannot be loaded is not
2603
+ * merely unresolved: unless it names a field of the Source Description Object,
2604
+ * it rejects with the load error in either mode, since nothing else can
2605
+ * produce its value.
2606
+ *
2607
+ * @throws DocumentLoadError - When a referenced source document cannot be read or loaded
2608
+ * @throws UnmatchedProviderError - When no provider can load a referenced source document
2089
2609
  */
2090
- evaluate(expression: string): unknown;
2610
+ evaluate(expression: string): Promise<unknown>;
2091
2611
  /**
2092
2612
  * Renders a template string, replacing each embedded `{expression}` with the
2093
2613
  * string form of its evaluated value. Returns a string.
@@ -2096,7 +2616,7 @@ export declare class RuntimeExpressionEvaluator {
2096
2616
  * mode, unresolvable references render as an empty string. A `{…}` that is not
2097
2617
  * a valid embedded expression (e.g. a literal JSON payload) is left unchanged.
2098
2618
  */
2099
- interpolate(template: string): string;
2619
+ interpolate(template: string): Promise<string>;
2100
2620
  /**
2101
2621
  * Resolves an Arazzo "value" string.
2102
2622
  *
@@ -2108,7 +2628,7 @@ export declare class RuntimeExpressionEvaluator {
2108
2628
  * yields the string representation of its value, not the typed value. A
2109
2629
  * string containing no expressions is returned unchanged.
2110
2630
  */
2111
- resolve(value: string): unknown;
2631
+ resolve(value: string): Promise<unknown>;
2112
2632
  }
2113
2633
 
2114
2634
  /**
@@ -2132,8 +2652,10 @@ export declare interface RuntimeExpressionEvaluatorOptions {
2132
2652
  readonly document?: ArazzoDocument;
2133
2653
  /**
2134
2654
  * The document registry, used to reach the external document a
2135
- * `$sourceDescriptions` reference points at. The referenced document must
2136
- * already be loaded — resolution is synchronous and never triggers a fetch.
2655
+ * `$sourceDescriptions` reference points at. The document is acquired from
2656
+ * it — returned from its cache, or loaded — whenever the source's `type` is
2657
+ * one the registry can load. Without a registry, `$sourceDescriptions`
2658
+ * resolves against the Source Description Object's own fields only.
2137
2659
  */
2138
2660
  readonly registry?: DocumentRegistry;
2139
2661
  }
@@ -2156,11 +2678,14 @@ export declare interface RuntimeExpressionRequestContext {
2156
2678
  }
2157
2679
 
2158
2680
  /**
2159
- * Resolves a runtime expression to its value.
2681
+ * Resolves a runtime expression to its value, or to a Promise of it.
2160
2682
  *
2161
2683
  * Bridged to a lenient runtime expression evaluator
2162
2684
  * (`(expression) => runtimeExpressionEvaluator.evaluate(expression)`), so an
2163
- * unresolvable reference yields `undefined` rather than throwing.
2685
+ * unresolvable reference yields `undefined` rather than throwing; a
2686
+ * `$sourceDescriptions` document that cannot be loaded still rejects with the
2687
+ * load error (see `RuntimeExpressionEvaluator.evaluate`). The result
2688
+ * is awaited, so a synchronous resolver works too.
2164
2689
  * @public
2165
2690
  */
2166
2691
  export declare type RuntimeExpressionResolver = (expression: string) => unknown;
@@ -2226,7 +2751,9 @@ export declare function settledResult(result: WorkflowExecutionResult): Workflow
2226
2751
  * unlike `regex`/`jsonpath`/`xpath` — it has no separate `context`. Parsing,
2227
2752
  * loose/case-insensitive comparison, and member/index navigation are delegated
2228
2753
  * to `@swaggerexpert/arazzo-criterion`; each embedded runtime expression is
2229
- * resolved through the supplied resolver.
2754
+ * resolved through the supplied resolver and awaited in turn. `&&` and `||`
2755
+ * short-circuit, so an operand that cannot change the outcome is never
2756
+ * resolved.
2230
2757
  *
2231
2758
  * An operand that resolves to `undefined` (a lenient miss) does not throw; it is
2232
2759
  * compared per the library's rules (e.g. `undefined == x` and relational
@@ -2240,7 +2767,7 @@ export declare class SimpleCriterionEvaluator {
2240
2767
  * Evaluates the simple `condition`, resolving each embedded runtime
2241
2768
  * expression via `resolve`.
2242
2769
  */
2243
- evaluate(condition: string, resolve: CriterionContextResolver): boolean;
2770
+ evaluate(condition: string, resolve: CriterionContextResolver): Promise<boolean>;
2244
2771
  }
2245
2772
 
2246
2773
  /**
@@ -2284,6 +2811,20 @@ export declare abstract class SourceDescriptionsLocatorNormalizer {
2284
2811
  } | undefined;
2285
2812
  }
2286
2813
 
2814
+ /**
2815
+ * One attempt at a step began, after it was charged to the step budget.
2816
+ * @public
2817
+ */
2818
+ export declare interface StepAttemptEvent extends WorkflowExecutionStepEventBase {
2819
+ readonly type: 'step-attempt';
2820
+ /**
2821
+ * The attempt number, starting at 1. Each `retry` increments it. The
2822
+ * attempt a `retry` reference makes at another step is that reference's
2823
+ * own, so it is always 1, under the referenced step's `stepId`.
2824
+ */
2825
+ readonly attempt: number;
2826
+ }
2827
+
2287
2828
  /**
2288
2829
  * The execute options of a step: the opaque bag forwarded to the operation
2289
2830
  * executor, or a function returning it for the operation the step was located
@@ -2423,7 +2964,7 @@ export declare class StepExecutor {
2423
2964
  * names the step's workflow on a thrown error, as for
2424
2965
  * {@link StepExecutor.execute}.
2425
2966
  */
2426
- evaluateCriteria(step: StepElement, context: RuntimeExpressionContext, workflowId?: string): CriterionEvaluationRecord[];
2967
+ evaluateCriteria(step: StepElement, context: RuntimeExpressionContext, workflowId?: string): Promise<CriterionEvaluationRecord[]>;
2427
2968
  /**
2428
2969
  * Selects every matching `onSuccess` / `onFailure` action for the outcome, in
2429
2970
  * list order, gating each action's criteria against the context, and records
@@ -2447,7 +2988,7 @@ export declare class StepExecutor {
2447
2988
  * `workflowId` names the step's workflow on a thrown error, as for
2448
2989
  * {@link StepExecutor.execute}.
2449
2990
  */
2450
- selectActions(step: StepElement, successful: boolean, context: RuntimeExpressionContext, workflowId?: string): Pick<StepExecutionResult, 'matchedActions' | 'actionCriteria'>;
2991
+ selectActions(step: StepElement, successful: boolean, context: RuntimeExpressionContext, workflowId?: string): Promise<Pick<StepExecutionResult, 'matchedActions' | 'actionCriteria'>>;
2451
2992
  /**
2452
2993
  * The context a step's actions are taken in — see
2453
2994
  * {@link StepExecutionResult.actionContext}: `context` with
@@ -2475,7 +3016,9 @@ export declare interface StepExecutorOptions {
2475
3016
  */
2476
3017
  readonly document: ArazzoDocument;
2477
3018
  /**
2478
- * The document registry holding the already-loaded source documents.
3019
+ * The document registry the source documents are acquired from — returned
3020
+ * from its cache, or loaded when an operation, a workflow or a
3021
+ * `$sourceDescriptions` expression first needs them.
2479
3022
  */
2480
3023
  readonly registry: DocumentRegistry;
2481
3024
  /**
@@ -2514,7 +3057,7 @@ export declare abstract class StepParameterResolver extends ArazzoValueResolver
2514
3057
  * has it, the same way {@link ActionResolver.resolveOnSuccess} is handed
2515
3058
  * `scope`.
2516
3059
  */
2517
- abstract resolve(parameters: StepParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Record<string, unknown>;
3060
+ abstract resolve(parameters: StepParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Promise<Record<string, unknown>>;
2518
3061
  }
2519
3062
 
2520
3063
  /**
@@ -2523,6 +3066,10 @@ export declare abstract class StepParameterResolver extends ArazzoValueResolver
2523
3066
  */
2524
3067
  export declare interface StepRunRecord {
2525
3068
  readonly stepId: string;
3069
+ /**
3070
+ * Where the step is written.
3071
+ */
3072
+ readonly location: DocumentLocation;
2526
3073
  readonly successful: boolean;
2527
3074
  readonly action: SelectedAction | undefined;
2528
3075
  /**
@@ -2585,11 +3132,71 @@ export declare interface StepScope {
2585
3132
  readonly stepId: string;
2586
3133
  }
2587
3134
 
3135
+ /**
3136
+ * A step settled: its retries are done and its terminal action is selected.
3137
+ * @public
3138
+ */
3139
+ export declare interface StepSettledEvent extends WorkflowExecutionStepEventBase {
3140
+ readonly type: 'step-settled';
3141
+ readonly successful: boolean;
3142
+ readonly attempts: number;
3143
+ }
3144
+
3145
+ /**
3146
+ * A step began. Its attempts follow it.
3147
+ * @public
3148
+ */
3149
+ export declare interface StepStartEvent extends WorkflowExecutionStepEventBase {
3150
+ readonly type: 'step-start';
3151
+ /**
3152
+ * Where the step is written.
3153
+ */
3154
+ readonly location: DocumentLocation;
3155
+ }
3156
+
3157
+ /**
3158
+ * What a workflow does after a step, once the step's action has been
3159
+ * interpreted.
3160
+ *
3161
+ * `next` runs the following step (the success default, or a matched `goto` that
3162
+ * targets the next step); `goto` jumps to a step by id within the current
3163
+ * workflow; `transfer` hands control one-way to another workflow, which the
3164
+ * caller's run then ends on; `end` stops the run with `status: ended`; `break`
3165
+ * stops with `status: failed` (the failure default).
3166
+ * @public
3167
+ */
3168
+ export declare type StepTransition = {
3169
+ readonly kind: 'next';
3170
+ } | {
3171
+ readonly kind: 'goto';
3172
+ readonly stepId: string;
3173
+ } | {
3174
+ readonly kind: 'transfer';
3175
+ readonly workflowId: string;
3176
+ } | {
3177
+ readonly kind: 'end';
3178
+ } | {
3179
+ readonly kind: 'break';
3180
+ };
3181
+
2588
3182
  /** @public */
2589
3183
  export declare class UnmatchedProviderError extends ArazzoRunnerError {
2590
3184
  readonly uri?: string;
2591
3185
  }
2592
3186
 
3187
+ /**
3188
+ * How a workflow invocation was entered.
3189
+ *
3190
+ * Recorded per call so a detected loop can be named for the mechanism that formed
3191
+ * it: a repeat reached purely through `dependsOn` edges is a dependency cycle,
3192
+ * one involving a sub-workflow step call — a `retry` action's `workflowId`
3193
+ * reference — or a `goto`'s one-way transfer to a `workflowId` — is a call
3194
+ * cycle. `retry` and `goto` are grouped with `step` for that classification, not
3195
+ * `dependsOn`: each is a call the current step makes, not a stated precondition.
3196
+ * @public
3197
+ */
3198
+ export declare type WorkflowCallVia = 'root' | 'step' | 'dependsOn' | 'retry' | 'goto';
3199
+
2593
3200
  /**
2594
3201
  * A workflow of an Arazzo document, as listed by
2595
3202
  * {@link ArazzoDocument.listWorkflows}.
@@ -2695,6 +3302,69 @@ export declare interface WorkflowExecuteOptions {
2695
3302
  readonly signal?: AbortSignal;
2696
3303
  }
2697
3304
 
3305
+ /**
3306
+ * The workflow a `dependency-*` event is about.
3307
+ * @public
3308
+ */
3309
+ export declare interface WorkflowExecutionDependency {
3310
+ /**
3311
+ * The `dependsOn` entry as written: a bare workflowId, or a
3312
+ * `$sourceDescriptions.{name}.{workflowId}` expression.
3313
+ */
3314
+ readonly reference: string;
3315
+ /**
3316
+ * The bare id of the workflow the entry resolved to.
3317
+ */
3318
+ readonly workflowId: string;
3319
+ /**
3320
+ * The canonical URI of the Arazzo document that defines it.
3321
+ */
3322
+ readonly documentURI: string;
3323
+ }
3324
+
3325
+ /**
3326
+ * An event the {@link WorkflowExecutor} emits, discriminated by `type`.
3327
+ *
3328
+ * The events other than `workflow-normalize-*` mark the boundaries the
3329
+ * {@link WorkflowExecutionResult} trace records, plus the criterion and
3330
+ * action decisions behind each step, so folding a run's events rebuilds its
3331
+ * trace. A workflow's or step's start and settled events are stamped with the
3332
+ * readings its `durationMs` comes from, so their timestamps differ by exactly
3333
+ * that.
3334
+ *
3335
+ * A run that throws (an authoring error, a cancellation, a throwing observer)
3336
+ * leaves the workflows and steps it unwinds through unsettled; the rejection
3337
+ * of `execute` is the signal.
3338
+ * @public
3339
+ */
3340
+ export declare type WorkflowExecutionEvent = WorkflowStartEvent | WorkflowSettledEvent | WorkflowNormalizeStartEvent | WorkflowNormalizeSettledEvent | DependencyStartEvent | DependencySettledEvent | StepStartEvent | StepAttemptEvent | CriterionEvaluatedEvent | ActionSelectedEvent | RetryWaitEvent | RetryReferenceStartEvent | RetryReferenceSettledEvent | StepSettledEvent;
3341
+
3342
+ /**
3343
+ * The fields every {@link WorkflowExecutionEvent} carries.
3344
+ * @public
3345
+ */
3346
+ export declare interface WorkflowExecutionEventBase extends ArazzoRunnerEventBase {
3347
+ /**
3348
+ * A random id of the {@link WorkflowExecutor.execute} call the event
3349
+ * belongs to. Every workflow, dependency and step of one call shares it, so
3350
+ * the events of concurrent calls, or of runs in different processes, can be
3351
+ * told apart. The operation events of the call carry it too.
3352
+ */
3353
+ readonly runId: string;
3354
+ /**
3355
+ * The bare id of the workflow in progress when the event fired. For a
3356
+ * `dependency-*` event, this is the dependent workflow, not the dependency.
3357
+ */
3358
+ readonly workflowId: string;
3359
+ /**
3360
+ * The chain of workflows in progress, outermost first, this one included.
3361
+ * Uses the same form as `ExecutionError.path`: bare ids for workflows of
3362
+ * the entry document, `{documentURI}#{workflowId}` for workflows of other
3363
+ * documents.
3364
+ */
3365
+ readonly path: readonly string[];
3366
+ }
3367
+
2698
3368
  /**
2699
3369
  * The outcome of executing a workflow.
2700
3370
  *
@@ -2836,6 +3506,14 @@ export declare interface WorkflowExecutionStateOptions {
2836
3506
  readonly inputs?: Record<string, unknown>;
2837
3507
  }
2838
3508
 
3509
+ /**
3510
+ * The fields every step-scoped {@link WorkflowExecutionEvent} carries.
3511
+ * @public
3512
+ */
3513
+ export declare interface WorkflowExecutionStepEventBase extends WorkflowExecutionEventBase {
3514
+ readonly stepId: string;
3515
+ }
3516
+
2839
3517
  /**
2840
3518
  * Executes an Arazzo workflow: the stateful loop that turns "run one step" into
2841
3519
  * "run a workflow".
@@ -2908,7 +3586,9 @@ export declare interface WorkflowExecutorOptions {
2908
3586
  */
2909
3587
  readonly document: ArazzoDocument;
2910
3588
  /**
2911
- * The document registry holding the already-loaded source documents.
3589
+ * The document registry the source documents are acquired from — returned
3590
+ * from its cache, or loaded when an operation, a workflow or a
3591
+ * `$sourceDescriptions` expression first needs them.
2912
3592
  */
2913
3593
  readonly registry: DocumentRegistry;
2914
3594
  /**
@@ -2962,6 +3642,15 @@ export declare interface WorkflowExecutorOptions {
2962
3642
  * negative duration if the system clock were adjusted mid-run.
2963
3643
  */
2964
3644
  readonly now?: () => number;
3645
+ /**
3646
+ * Receives the run's events, stamped with
3647
+ * {@link WorkflowExecutorOptions.now}: workflows, dependencies, steps,
3648
+ * attempts, criterion outcomes, selected actions, retry waits and retry
3649
+ * references, plus each workflow's normalization. See
3650
+ * {@link WorkflowExecutionEvent}, and {@link ArazzoRunnerObserver} for how
3651
+ * events are delivered.
3652
+ */
3653
+ readonly observer?: ArazzoRunnerObserver<WorkflowExecutionEvent>;
2965
3654
  }
2966
3655
 
2967
3656
  /**
@@ -2970,6 +3659,33 @@ export declare interface WorkflowExecutorOptions {
2970
3659
  */
2971
3660
  export declare type WorkflowId = string;
2972
3661
 
3662
+ /**
3663
+ * The workflow was normalized.
3664
+ * @public
3665
+ */
3666
+ export declare interface WorkflowNormalizeSettledEvent extends WorkflowExecutionEventBase {
3667
+ readonly type: 'workflow-normalize-settled';
3668
+ /**
3669
+ * Where the workflow is written.
3670
+ */
3671
+ readonly location: DocumentLocation;
3672
+ }
3673
+
3674
+ /**
3675
+ * The workflow is being normalized before its first run in this `execute`
3676
+ * call: dereferenced (which may fetch externally referenced documents), with
3677
+ * its parameters and actions inherited into its steps. A workflow already
3678
+ * normalized earlier in the same call emits nothing.
3679
+ * @public
3680
+ */
3681
+ export declare interface WorkflowNormalizeStartEvent extends WorkflowExecutionEventBase {
3682
+ readonly type: 'workflow-normalize-start';
3683
+ /**
3684
+ * Where the workflow is written.
3685
+ */
3686
+ readonly location: DocumentLocation;
3687
+ }
3688
+
2973
3689
  /**
2974
3690
  * Resolves the `parameters` of a step targeting a `workflowId` into the
2975
3691
  * sub-workflow's inputs — or those of a `goto` / `retry` action naming a
@@ -2996,7 +3712,7 @@ export declare class WorkflowParameterResolver extends StepParameterResolver {
2996
3712
  *
2997
3713
  * `scope` names the step in a thrown {@link ResolverError}.
2998
3714
  */
2999
- resolve(parameters: StepParametersElement | SuccessActionParametersElement | FailureActionParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Record<string, unknown>;
3715
+ resolve(parameters: StepParametersElement | SuccessActionParametersElement | FailureActionParametersElement | undefined, resolve: RuntimeExpressionResolver, scope: StepScope): Promise<Record<string, unknown>>;
3000
3716
  }
3001
3717
 
3002
3718
  /**
@@ -3017,6 +3733,37 @@ export declare interface WorkflowReferenceContext {
3017
3733
  readonly stepId?: string;
3018
3734
  }
3019
3735
 
3736
+ /**
3737
+ * A workflow invocation produced its result. The fields repeat the
3738
+ * {@link WorkflowExecutionResult} fields of the same name.
3739
+ * @public
3740
+ */
3741
+ export declare interface WorkflowSettledEvent extends WorkflowExecutionEventBase {
3742
+ readonly type: 'workflow-settled';
3743
+ readonly status: WorkflowExecutionResult['status'];
3744
+ readonly settledStatus: WorkflowExecutionResult['settledStatus'];
3745
+ readonly outputs: WorkflowExecutionResult['outputs'];
3746
+ }
3747
+
3748
+ /**
3749
+ * A workflow invocation began: it entered the call stack, before it is
3750
+ * normalized and its definition checked. A definition that fails those checks
3751
+ * throws, leaving the event without its `workflow-settled`.
3752
+ * @public
3753
+ */
3754
+ export declare interface WorkflowStartEvent extends WorkflowExecutionEventBase {
3755
+ readonly type: 'workflow-start';
3756
+ /** Where the workflow is written. */
3757
+ readonly location: DocumentLocation;
3758
+ /**
3759
+ * How the workflow was reached. `root` is the workflow named in `execute`,
3760
+ * `step` is a sub-workflow step, `dependsOn` is a prerequisite, `retry` is
3761
+ * a `retry` action's `workflowId` reference, and `goto` is a one-way
3762
+ * transfer.
3763
+ */
3764
+ readonly via: WorkflowCallVia;
3765
+ }
3766
+
3020
3767
  /**
3021
3768
  * Evaluates an `xpath` Arazzo criterion condition against a resolved context value.
3022
3769
  *