@usearazzo/runner 1.0.1-alpha.33 → 1.0.1-alpha.35

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 (72) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +15 -1
  3. package/dist/arazzo-runner.browser.js +1516 -265
  4. package/dist/arazzo-runner.browser.min.js +1 -1
  5. package/package.json +64 -18
  6. package/src/ArazzoRunner.cjs +26 -3
  7. package/src/ArazzoRunner.mjs +26 -3
  8. package/src/client/OpenAPIOperationResponse.cjs +9 -0
  9. package/src/client/OpenAPIOperationResponse.mjs +9 -0
  10. package/src/document/APIDocument.cjs +53 -0
  11. package/src/document/APIDocument.mjs +53 -0
  12. package/src/errors/ExecutionError.cjs +2 -0
  13. package/src/errors/ExecutionError.mjs +2 -0
  14. package/src/executor/OpenAPIOperationExecutor.cjs +77 -6
  15. package/src/executor/OpenAPIOperationExecutor.mjs +77 -6
  16. package/src/executor/StepExecutor.cjs +16 -2
  17. package/src/executor/StepExecutor.mjs +16 -2
  18. package/src/executor/StepRetryRunner.cjs +5 -3
  19. package/src/executor/StepRetryRunner.mjs +5 -3
  20. package/src/executor/StepTransitionInterpreter.cjs +1 -1
  21. package/src/executor/StepTransitionInterpreter.mjs +1 -1
  22. package/src/executor/WorkflowCallStack.cjs +1 -1
  23. package/src/executor/WorkflowCallStack.mjs +1 -1
  24. package/src/executor/WorkflowExecutor.cjs +447 -89
  25. package/src/executor/WorkflowExecutor.mjs +447 -89
  26. package/src/index.cjs +21 -0
  27. package/src/index.mjs +4 -0
  28. package/src/observability/ArazzoRunnerEvent.cjs +5 -0
  29. package/src/observability/ArazzoRunnerEvent.mjs +1 -0
  30. package/src/observability/DocumentRegistryEvent.cjs +5 -0
  31. package/src/observability/DocumentRegistryEvent.mjs +1 -0
  32. package/src/observability/EventChannel.cjs +106 -0
  33. package/src/observability/EventChannel.mjs +98 -0
  34. package/src/observability/OpenAPIOperationEvent.cjs +5 -0
  35. package/src/observability/OpenAPIOperationEvent.mjs +1 -0
  36. package/src/observability/Redactor.cjs +215 -0
  37. package/src/observability/Redactor.mjs +210 -0
  38. package/src/observability/WorkflowExecutionEvent.cjs +5 -0
  39. package/src/observability/WorkflowExecutionEvent.mjs +1 -0
  40. package/src/observability/combineObservers.cjs +18 -0
  41. package/src/observability/combineObservers.mjs +12 -0
  42. package/src/observability/instrument.cjs +159 -0
  43. package/src/observability/instrument.mjs +144 -0
  44. package/src/observability/logging/LoggingObserver.cjs +177 -0
  45. package/src/observability/logging/LoggingObserver.mjs +172 -0
  46. package/src/observability/logging/index.cjs +13 -0
  47. package/src/observability/logging/index.mjs +1 -0
  48. package/src/observability/opentelemetry/ArazzoRunnerInstrumentation.cjs +321 -0
  49. package/src/observability/opentelemetry/ArazzoRunnerInstrumentation.mjs +313 -0
  50. package/src/observability/opentelemetry/index.cjs +13 -0
  51. package/src/observability/opentelemetry/index.mjs +1 -0
  52. package/src/observability/stream/EventStream.cjs +112 -0
  53. package/src/observability/stream/EventStream.mjs +107 -0
  54. package/src/observability/stream/index.cjs +13 -0
  55. package/src/observability/stream/index.mjs +1 -0
  56. package/src/registry/DocumentRegistry.cjs +27 -3
  57. package/src/registry/DocumentRegistry.mjs +27 -3
  58. package/src/registry/providers/ArazzoDocumentRegistryProvider.cjs +20 -0
  59. package/src/registry/providers/ArazzoDocumentRegistryProvider.mjs +21 -1
  60. package/src/registry/providers/DocumentRegistryProvider.cjs +14 -0
  61. package/src/registry/providers/DocumentRegistryProvider.mjs +14 -0
  62. package/src/registry/providers/OpenAPIDocumentRegistryProvider.cjs +27 -5
  63. package/src/registry/providers/OpenAPIDocumentRegistryProvider.mjs +27 -5
  64. package/src/version.cjs +9 -0
  65. package/src/version.mjs +3 -0
  66. package/types/observability/logging/LoggingObserver.d.ts +82 -0
  67. package/types/observability/logging/index.d.ts +2 -0
  68. package/types/observability/opentelemetry/ArazzoRunnerInstrumentation.d.ts +84 -0
  69. package/types/observability/opentelemetry/index.d.ts +2 -0
  70. package/types/observability/stream/EventStream.d.ts +68 -0
  71. package/types/observability/stream/index.d.ts +2 -0
  72. package/types/runner.d.ts +802 -5
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';
@@ -76,6 +77,37 @@ export declare class ActionResolver {
76
77
  resolveOnFailure(actions: StepOnFailureElement | undefined, isCriterionMet: CriterionPredicate, scope: StepScope): Promise<FailureActionElement[]>;
77
78
  }
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
+ };
109
+ }
110
+
79
111
  /**
80
112
  * Base document held by the document registry.
81
113
  * @public
@@ -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.
@@ -219,14 +258,40 @@ export declare class ArazzoRunner {
219
258
  export declare class ArazzoRunnerError extends ApiDOMStructuredError {
220
259
  }
221
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
+
222
286
  /**
223
287
  * Options for {@link ArazzoRunner.load}.
224
288
  *
225
289
  * Every option is a seam of a building block the runner wires: `registry` is
226
290
  * the {@link DocumentRegistry} the documents load into (a fresh one with the
227
291
  * default providers when omitted), `reference` goes to everything the runner
228
- * builds that retrieves documents, `httpClient` and `requestInterceptor` go to
229
- * 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
230
295
  * {@link WorkflowExecutor}.
231
296
  *
232
297
  * Retrieving documents and calling APIs are separate on purpose: `reference`
@@ -234,7 +299,7 @@ export declare class ArazzoRunnerError extends ApiDOMStructuredError {
234
299
  * apply to document retrieval, so credentials for one do not reach the other.
235
300
  * @public
236
301
  */
237
- 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'> {
238
303
  /**
239
304
  * The registry to load the documents into. A registry backs one entry
240
305
  * document: loading a different one into it throws.
@@ -254,13 +319,56 @@ export declare interface ArazzoRunnerLoadOptions extends Pick<OpenAPIOperationEx
254
319
  * same options.
255
320
  */
256
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;
257
341
  }
258
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
+
259
367
  /**
260
368
  * Options for the ArazzoRunner constructor.
261
369
  * @public
262
370
  */
263
- export declare interface ArazzoRunnerOptions extends Omit<ArazzoRunnerLoadOptions, 'registry'> {
371
+ export declare interface ArazzoRunnerOptions extends Omit<ArazzoRunnerLoadOptions, 'registry' | 'sourceMap'> {
264
372
  /**
265
373
  * The entry Arazzo document holding the workflows to run.
266
374
  */
@@ -485,6 +593,16 @@ export declare class ClientError extends ArazzoRunnerError {
485
593
  readonly uri?: string;
486
594
  }
487
595
 
596
+ /**
597
+ * One observer that hands each event to every observer given, in order, so
598
+ * several consumers (a log, a trace, a stream) can watch the same run.
599
+ *
600
+ * Delivery stays synchronous. An observer that throws aborts the run with its
601
+ * error, as any observer does, and the observers after it miss that event.
602
+ * @public
603
+ */
604
+ export declare const combineObservers: <E extends ArazzoRunnerEvent = ArazzoRunnerEvent>(...observers: readonly ArazzoRunnerObserver<E>[]) => ArazzoRunnerObserver<E>;
605
+
488
606
  /**
489
607
  * A read-only source of the runtime expression context for a step.
490
608
  *
@@ -573,6 +691,26 @@ export declare class CriterionError extends ArazzoRunnerError {
573
691
  */
574
692
  export declare type CriterionErrorReason = (typeof CriterionError)[Exclude<keyof typeof CriterionError, keyof typeof ArazzoRunnerError | 'prototype'>];
575
693
 
694
+ /**
695
+ * One criterion was evaluated during an attempt. Fired after the attempt's
696
+ * request (or sub-workflow run), in list order, success criteria first.
697
+ * @public
698
+ */
699
+ export declare interface CriterionEvaluatedEvent extends WorkflowExecutionStepEventBase {
700
+ readonly type: 'criterion:evaluated';
701
+ /**
702
+ * Where the criterion is written.
703
+ */
704
+ readonly location: DocumentLocation;
705
+ readonly attempt: number;
706
+ /**
707
+ * `success` for one of the step's `successCriteria`, `action` for a
708
+ * criterion of an `onSuccess` / `onFailure` action the attempt considered.
709
+ */
710
+ readonly kind: 'success' | 'action';
711
+ readonly criterion: CriterionEvaluationRecord;
712
+ }
713
+
576
714
  /**
577
715
  * A criterion condition that cannot be evaluated: a syntax error in the
578
716
  * condition, a context the condition cannot apply to, or an error raised while
@@ -603,6 +741,21 @@ export declare interface CriterionEvaluationRecord {
603
741
  * action criterion.
604
742
  */
605
743
  readonly actionName?: string;
744
+ /**
745
+ * Every runtime expression the evaluation resolved, keyed by the expression
746
+ * as written, with the value it resolved to: the expressions embedded in a
747
+ * `simple` condition, or the `context` of a `regex`, `jsonpath` or `xpath`
748
+ * one. What the criterion actually saw, e.g. `{ "$statusCode": 404 }`.
749
+ *
750
+ * A whole body (`$response.body`, `$request.body`) is recorded as the
751
+ * placeholder `[body]`, so the trace never holds a body; the body and its
752
+ * size are in the attempt's `openapi:operation:request:settled` event.
753
+ */
754
+ readonly values: Readonly<Record<string, unknown>>;
755
+ /**
756
+ * Where the criterion is written.
757
+ */
758
+ readonly location: DocumentLocation;
606
759
  /**
607
760
  * Why the condition could not be evaluated — present only then, with `met`
608
761
  * `false`.
@@ -730,11 +883,113 @@ export declare interface CriterionOutcome {
730
883
  */
731
884
  export declare type CriterionPredicate = (criterion: CriterionElement, action: SelectedAction) => boolean | Promise<boolean>;
732
885
 
886
+ /**
887
+ * A `dependsOn` prerequisite was satisfied, or failed.
888
+ * @public
889
+ */
890
+ export declare interface DependencySettledEvent extends WorkflowExecutionEventBase {
891
+ readonly type: 'dependency:settled';
892
+ readonly dependency: WorkflowExecutionDependency;
893
+ /**
894
+ * Whether the prerequisite had already completed earlier in this run and was
895
+ * not run again. When it is `true`, no workflow events of its own precede
896
+ * this event.
897
+ */
898
+ readonly memoized: boolean;
899
+ readonly settledStatus: WorkflowExecutionResult['settledStatus'];
900
+ }
901
+
902
+ /**
903
+ * A `dependsOn` prerequisite is about to be satisfied: either run, or found
904
+ * already completed earlier in the same run.
905
+ * @public
906
+ */
907
+ export declare interface DependencyStartEvent extends WorkflowExecutionEventBase {
908
+ readonly type: 'dependency:start';
909
+ /**
910
+ * Where the `dependsOn` entry is written.
911
+ */
912
+ readonly location: DocumentLocation;
913
+ readonly dependency: WorkflowExecutionDependency;
914
+ }
915
+
733
916
  /** @public */
734
917
  export declare class DocumentLoadError extends ArazzoRunnerError {
735
918
  readonly uri?: string;
736
919
  }
737
920
 
921
+ /**
922
+ * The registry loaded a document, which it caches right after. A load that
923
+ * fails throws and emits no settled event; an observer that throws here
924
+ * leaves the document uncached.
925
+ * @public
926
+ */
927
+ export declare interface DocumentLoadSettledEvent extends ArazzoRunnerEventBase {
928
+ readonly type: 'document:load:settled';
929
+ readonly uri: string;
930
+ }
931
+
932
+ /**
933
+ * The registry started loading a document it had neither cached nor already
934
+ * loading. Cache hits emit nothing.
935
+ *
936
+ * Registry events carry no `runId`: the registry is shared, and one load can
937
+ * serve several runs at once.
938
+ * @public
939
+ */
940
+ export declare interface DocumentLoadStartEvent extends ArazzoRunnerEventBase {
941
+ readonly type: 'document:load:start';
942
+ /**
943
+ * The canonical URI of the document.
944
+ */
945
+ readonly uri: string;
946
+ }
947
+
948
+ /**
949
+ * Where an element is written.
950
+ * @public
951
+ */
952
+ export declare interface DocumentLocation {
953
+ /**
954
+ * The document that defines the element: the one it came from when it was
955
+ * reached through a reference (a workflow of another Arazzo document, an
956
+ * operation of a Path Item Object written as a `$ref`), not necessarily the
957
+ * entry document.
958
+ */
959
+ readonly uri: string;
960
+ /**
961
+ * The element's JSON Pointer in that document. Absent only for an element
962
+ * whose pointer no one recorded: the runner records one for every element
963
+ * an event locates.
964
+ */
965
+ readonly jsonPointer?: string;
966
+ /**
967
+ * The element's range in that document, present only when the document was
968
+ * parsed with source maps (`sourceMap` on `ArazzoRunner.load`).
969
+ */
970
+ readonly range?: DocumentRange;
971
+ }
972
+
973
+ /**
974
+ * A position in a document, as in the Language Server Protocol: a 0-based
975
+ * line, and a 0-based character offset within it in UTF-16 code units.
976
+ * @public
977
+ */
978
+ export declare interface DocumentPosition {
979
+ readonly line: number;
980
+ readonly character: number;
981
+ }
982
+
983
+ /**
984
+ * A range in a document, as in the Language Server Protocol: from `start` to
985
+ * `end`, the shape the validator's diagnostics use.
986
+ * @public
987
+ */
988
+ export declare interface DocumentRange {
989
+ readonly start: DocumentPosition;
990
+ readonly end: DocumentPosition;
991
+ }
992
+
738
993
  /**
739
994
  * Registry for API documents keyed by canonical URI.
740
995
  *
@@ -789,12 +1044,28 @@ export declare class DocumentRegistry {
789
1044
  clear(): void;
790
1045
  }
791
1046
 
1047
+ /**
1048
+ * An event the {@link DocumentRegistry} emits.
1049
+ * @public
1050
+ */
1051
+ export declare type DocumentRegistryEvent = DocumentLoadStartEvent | DocumentLoadSettledEvent;
1052
+
792
1053
  /**
793
1054
  * Options for the DocumentRegistry.
794
1055
  * @public
795
1056
  */
796
1057
  export declare interface DocumentRegistryOptions {
797
1058
  readonly providers?: DocumentRegistryProvider[];
1059
+ /**
1060
+ * Receives the registry's events: the start and end of every document
1061
+ * load. Cache hits emit nothing. See {@link DocumentRegistryEvent}.
1062
+ */
1063
+ readonly observer?: ArazzoRunnerObserver<DocumentRegistryEvent>;
1064
+ /**
1065
+ * Reads the current time in milliseconds, stamped on each event. Defaults to
1066
+ * `performance.now`.
1067
+ */
1068
+ readonly now?: () => number;
798
1069
  }
799
1070
 
800
1071
  /**
@@ -821,6 +1092,13 @@ export declare abstract class DocumentRegistryProvider {
821
1092
  * Loads and produces a document from a URI.
822
1093
  */
823
1094
  abstract provide(uri: string): Promise<APIDocument>;
1095
+ /**
1096
+ * Rejects a document the parser could only partly read. The strict parsers
1097
+ * throw on a syntax error; the lenient ones that source maps need record it
1098
+ * and parse what they can instead, so a document must load with source maps
1099
+ * exactly when it loads without.
1100
+ */
1101
+ protected assertParsed(uri: string, parseResult: ParseResultElement): void;
824
1102
  }
825
1103
 
826
1104
  /**
@@ -850,6 +1128,8 @@ export declare class ExecutionError extends ArazzoRunnerError {
850
1128
  static readonly GotoTargetMissing: "goto-target-missing";
851
1129
  /** A `goto` action's `stepId` names no step in the workflow. */
852
1130
  static readonly GotoTargetNotFound: "goto-target-not-found";
1131
+ /** A process-wide instrumentation wrap (see `instrument`) settled without running its workflow or step. */
1132
+ static readonly InstrumentationWrap: "instrumentation-wrap";
853
1133
  /** An `operationId` or `operationPath` is not a valid operation reference. */
854
1134
  static readonly InvalidOperationReference: "invalid-operation-reference";
855
1135
  /** A `workflowId` is not a valid `$sourceDescriptions.{name}.{workflowId}` expression. */
@@ -951,6 +1231,79 @@ export declare type HTTPClient = (request: OpenAPIOperationRequest) => Promise<R
951
1231
  */
952
1232
  export declare const httpClientFetch: HTTPClient;
953
1233
 
1234
+ /**
1235
+ * Applies `hooks` to every runner in the process, until the returned
1236
+ * function removes them: the seam process-wide tooling, such as the
1237
+ * OpenTelemetry instrumentation, is built on. A run already in progress
1238
+ * picks hooks up at its next event or operation, and drops removed ones the
1239
+ * same way: a removed hook misses the settled events of what it saw start.
1240
+ * Hooks apply in the order they were added, the first wrap outermost.
1241
+ * @public
1242
+ */
1243
+ export declare const instrument: (hooks: InstrumentationHooks) => (() => void);
1244
+
1245
+ /**
1246
+ * Hooks that apply to every runner in the process, on top of the observer
1247
+ * each was given.
1248
+ * @public
1249
+ */
1250
+ export declare interface InstrumentationHooks {
1251
+ /**
1252
+ * Receives every event of every building block, after the block's own
1253
+ * observer, under the same rules: synchronously, never awaited, and a throw
1254
+ * aborts what emitted it. Events carry what the run saw, credentials
1255
+ * included.
1256
+ */
1257
+ readonly observer?: ArazzoRunnerObserver;
1258
+ /** Runs around each workflow invocation and each step. */
1259
+ readonly wrap?: InstrumentationWrap;
1260
+ }
1261
+
1262
+ /**
1263
+ * Runs around each workflow invocation and each step, so what `run` does
1264
+ * happens inside it: in the active context of a span it opened, for one. It
1265
+ * must call `run`, and should settle once `run` settles; a second call runs
1266
+ * nothing again. What it resolves or rejects with does not change the run:
1267
+ * the run's own outcome stands, once the run settled, and the operation's
1268
+ * settled event says what it was.
1269
+ * @public
1270
+ */
1271
+ export declare type InstrumentationWrap = (operation: InstrumentedOperation, run: () => Promise<void>) => Promise<void>;
1272
+
1273
+ /**
1274
+ * What an {@link InstrumentationWrap} runs around.
1275
+ * @public
1276
+ */
1277
+ export declare type InstrumentedOperation = InstrumentedWorkflow | InstrumentedStep;
1278
+
1279
+ /**
1280
+ * A step an {@link InstrumentationWrap} runs around: its `step:start`, its
1281
+ * attempts and requests, and its `step:settled`.
1282
+ * @public
1283
+ */
1284
+ export declare interface InstrumentedStep {
1285
+ readonly kind: 'step';
1286
+ readonly runId: string;
1287
+ readonly workflowId: string;
1288
+ readonly path: readonly string[];
1289
+ readonly stepId: string;
1290
+ readonly location: DocumentLocation;
1291
+ }
1292
+
1293
+ /**
1294
+ * A workflow invocation an {@link InstrumentationWrap} runs around: its
1295
+ * `workflow:start`, its steps and its `workflow:settled`.
1296
+ * @public
1297
+ */
1298
+ export declare interface InstrumentedWorkflow {
1299
+ readonly kind: 'workflow';
1300
+ readonly runId: string;
1301
+ readonly workflowId: string;
1302
+ readonly path: readonly string[];
1303
+ readonly via: WorkflowCallVia;
1304
+ readonly location: DocumentLocation;
1305
+ }
1306
+
954
1307
  /** @public */
955
1308
  export declare class InvalidEntryDocumentError extends ArazzoRunnerError {
956
1309
  readonly uri?: string;
@@ -1166,12 +1519,48 @@ export declare class OpenAPIDocumentRegistryProvider extends DocumentRegistryPro
1166
1519
  */
1167
1520
  export declare type OpenAPIDocumentRegistryProviderOptions = DocumentRegistryProviderOptions;
1168
1521
 
1522
+ /**
1523
+ * The normalized operation was assembled into the OpenAPI document the
1524
+ * request is built from.
1525
+ * @public
1526
+ */
1527
+ export declare interface OpenAPIOperationAssembledEvent extends OpenAPIOperationEventBase {
1528
+ readonly type: 'openapi:operation:assembled';
1529
+ }
1530
+
1169
1531
  /**
1170
1532
  * Union of OperationElement across all supported OpenAPI versions.
1171
1533
  * @public
1172
1534
  */
1173
1535
  export declare type OpenAPIOperationElement = OperationElement | OperationElement_2 | OperationElement_3;
1174
1536
 
1537
+ /**
1538
+ * An event the {@link OpenAPIOperationExecutor} emits.
1539
+ * @public
1540
+ */
1541
+ export declare type OpenAPIOperationEvent = OpenAPIOperationNormalizeStartEvent | OpenAPIOperationNormalizeSettledEvent | OpenAPIOperationAssembledEvent | OpenAPIOperationRequestStartEvent | OpenAPIOperationRequestSettledEvent;
1542
+
1543
+ /**
1544
+ * The fields every {@link OpenAPIOperationEvent} carries: the operation, and
1545
+ * the step it runs for, in the same shape a {@link RequestInterceptor}
1546
+ * receives them.
1547
+ * @public
1548
+ */
1549
+ export declare interface OpenAPIOperationEventBase extends ArazzoRunnerEventBase, RequestContext {
1550
+ /**
1551
+ * Where the operation is written. It differs from `operation` (where the
1552
+ * operation was looked up) for an operation of a Path Item Object written
1553
+ * as a `$ref`, which is written in the document the reference names.
1554
+ */
1555
+ readonly location: DocumentLocation;
1556
+ /**
1557
+ * The `runId` of the {@link WorkflowExecutor.execute} call the operation
1558
+ * runs for, from the execute options. Absent when the executor is used
1559
+ * without one.
1560
+ */
1561
+ readonly runId?: string;
1562
+ }
1563
+
1175
1564
  /**
1176
1565
  * Options for executing an OpenAPI operation.
1177
1566
  *
@@ -1241,6 +1630,12 @@ export declare interface OpenAPIOperationExecuteOptions {
1241
1630
  */
1242
1631
  readonly securities?: OpenAPIOperationSecurities;
1243
1632
  readonly signal?: AbortSignal;
1633
+ /**
1634
+ * Identifies the run this call belongs to, stamped on the executor's events
1635
+ * (see {@link OpenAPIOperationEventBase.runId}). Consumed by the executor,
1636
+ * never sent. The workflow executor sets it for every step.
1637
+ */
1638
+ readonly runId?: string;
1244
1639
  /**
1245
1640
  * Runs after the executor-level interceptor, for this call only.
1246
1641
  */
@@ -1349,6 +1744,22 @@ export declare interface OpenAPIOperationExecutorOptions {
1349
1744
  * fresh {@link OpenAPIDocumentAssembler}.
1350
1745
  */
1351
1746
  readonly documentAssembler?: OpenAPIDocumentAssembler;
1747
+ /**
1748
+ * Receives the executor's events: the start and end of each operation's
1749
+ * normalization, its assembly, and the request sent and its response. See
1750
+ * {@link OpenAPIOperationEvent}.
1751
+ */
1752
+ readonly observer?: ArazzoRunnerObserver<OpenAPIOperationEvent>;
1753
+ /**
1754
+ * Reads the current time in milliseconds, stamped on each event. Defaults to
1755
+ * `performance.now`.
1756
+ */
1757
+ readonly now?: () => number;
1758
+ /**
1759
+ * Whether the `openapi:operation:request:*` events carry the request and
1760
+ * response bodies. Off by default.
1761
+ */
1762
+ readonly captureBodies?: boolean;
1352
1763
  }
1353
1764
 
1354
1765
  /**
@@ -1493,6 +1904,23 @@ export declare interface OpenAPIOperationNormalizerOptions {
1493
1904
  readonly openapi31?: OpenAPI31OperationNormalizer;
1494
1905
  }
1495
1906
 
1907
+ /**
1908
+ * The operation was normalized.
1909
+ * @public
1910
+ */
1911
+ export declare interface OpenAPIOperationNormalizeSettledEvent extends OpenAPIOperationEventBase {
1912
+ readonly type: 'openapi:operation:normalize:settled';
1913
+ }
1914
+
1915
+ /**
1916
+ * Normalization of the operation began: dereferencing it (which may fetch
1917
+ * externally referenced documents) and inheriting its path-level fields.
1918
+ * @public
1919
+ */
1920
+ export declare interface OpenAPIOperationNormalizeStartEvent extends OpenAPIOperationEventBase {
1921
+ readonly type: 'openapi:operation:normalize:start';
1922
+ }
1923
+
1496
1924
  /**
1497
1925
  * Resolves the `parameters` of a step targeting an OpenAPI operation into the
1498
1926
  * map the operation is executed with.
@@ -1587,6 +2015,51 @@ export declare interface OpenAPIOperationRequestInfo {
1587
2015
  readonly body?: unknown;
1588
2016
  }
1589
2017
 
2018
+ /**
2019
+ * The response was received and its body read, as it came: mask it with
2020
+ * {@link Redactor} before it leaves the process. A request that fails in the
2021
+ * transport throws and emits no settled event.
2022
+ * @public
2023
+ */
2024
+ export declare interface OpenAPIOperationRequestSettledEvent extends OpenAPIOperationEventBase {
2025
+ readonly type: 'openapi:operation:request:settled';
2026
+ readonly response: {
2027
+ readonly status: number;
2028
+ readonly headers: Readonly<Record<string, string>>;
2029
+ /**
2030
+ * The body's size in bytes: {@link OpenAPIOperationResponse.size}.
2031
+ */
2032
+ readonly size: number;
2033
+ /**
2034
+ * The body parsed by its content type, as `$response.body` reads it. Only
2035
+ * with {@link OpenAPIOperationExecutorOptions.captureBodies}.
2036
+ */
2037
+ readonly body?: unknown;
2038
+ };
2039
+ }
2040
+
2041
+ /**
2042
+ * The request about to be handed to the {@link HTTPClient}, after every
2043
+ * request interceptor ran, as it is sent: credentials included, like the
2044
+ * request an interceptor receives. Mask it with {@link Redactor} before it
2045
+ * leaves the process.
2046
+ * @public
2047
+ */
2048
+ export declare interface OpenAPIOperationRequestStartEvent extends OpenAPIOperationEventBase {
2049
+ readonly type: 'openapi:operation:request:start';
2050
+ readonly request: {
2051
+ readonly method: string;
2052
+ readonly url: string;
2053
+ readonly headers: Readonly<Record<string, string>>;
2054
+ /**
2055
+ * The body as handed to the {@link HTTPClient}: JSON or form text, or a
2056
+ * `FormData`, `Blob` or stream. Only with
2057
+ * {@link OpenAPIOperationExecutorOptions.captureBodies}.
2058
+ */
2059
+ readonly body?: unknown;
2060
+ };
2061
+ }
2062
+
1590
2063
  /**
1591
2064
  * Response from an OpenAPI operation execution.
1592
2065
  *
@@ -1618,6 +2091,11 @@ export declare class OpenAPIOperationResponse {
1618
2091
  content: string | Uint8Array;
1619
2092
  request?: OpenAPIOperationRequestInfo;
1620
2093
  });
2094
+ /**
2095
+ * The body's size in bytes, as read: after the transport decoded any
2096
+ * `Content-Encoding`, so a compressed body counts at its decoded size.
2097
+ */
2098
+ get size(): number;
1621
2099
  /**
1622
2100
  * The body as text, like `Response.text()`; `''` when there is none.
1623
2101
  */
@@ -1738,6 +2216,60 @@ export declare class OutputResolver extends ArazzoValueResolver {
1738
2216
  resolve(outputs: StepOutputsElement | WorkflowOutputsElement | undefined, resolve: RuntimeExpressionResolver, scope: ResolverScope): Promise<Record<string, unknown>>;
1739
2217
  }
1740
2218
 
2219
+ /**
2220
+ * Masks credentials in events before they leave the process.
2221
+ *
2222
+ * Events carry what the run saw, credentials included, like the request a
2223
+ * request interceptor receives. Pass every event through
2224
+ * {@link Redactor.event} before logging, exporting or writing it.
2225
+ *
2226
+ * It masks by name, whatever the event:
2227
+ *
2228
+ * - the value of any field whose name matches a pattern: headers, query
2229
+ * parameters, body and output fields, at any depth;
2230
+ * - a criterion value whose runtime expression reads a matching name, in its
2231
+ * base or in any token of its JSON Pointer (`$inputs.password`,
2232
+ * `$steps.login.outputs.token#/value`);
2233
+ * - in every absolute URL, as `URL` parses it, the userinfo and the matching
2234
+ * query and fragment parameters;
2235
+ * - a request or response body that is JSON or a URL-encoded form, field by
2236
+ * field, and any other body, or any object that is not plain data, whole.
2237
+ *
2238
+ * A settled event's `error` is carried as it is, the error `execute` rejects
2239
+ * with. A credential under a name no pattern matches is carried as it is. The
2240
+ * masked value is `REDACTED`.
2241
+ * @public
2242
+ */
2243
+ export declare class Redactor {
2244
+ #private;
2245
+ static readonly CENSOR = "REDACTED";
2246
+ /**
2247
+ * Elastic APM's `sanitizeFieldNames` defaults, with `*secret*` for its exact
2248
+ * `secret` (which misses OAuth's `client_secret`), plus the signed-URL query
2249
+ * parameters OpenTelemetry's HTTP conventions mask.
2250
+ */
2251
+ static readonly defaultFields: readonly string[];
2252
+ constructor(options?: RedactorOptions);
2253
+ /**
2254
+ * A masked copy of the event.
2255
+ */
2256
+ event<E extends ArazzoRunnerEvent>(event: E): E;
2257
+ }
2258
+
2259
+ /**
2260
+ * Options for the Redactor.
2261
+ * @public
2262
+ */
2263
+ export declare interface RedactorOptions {
2264
+ /**
2265
+ * Wildcard patterns of the names whose values are masked. `*` matches any
2266
+ * run of characters; matching is case-insensitive and against the whole
2267
+ * name, so `*token*` matches `access_token` and `X-Auth-Token`. The list
2268
+ * replaces {@link Redactor.defaultFields}; spread it to extend it.
2269
+ */
2270
+ readonly fields?: readonly string[];
2271
+ }
2272
+
1741
2273
  /**
1742
2274
  * Evaluates a `regex` Arazzo criterion condition against a resolved context value.
1743
2275
  *
@@ -1984,6 +2516,44 @@ export declare interface RetryReferenceRecord {
1984
2516
  readonly subWorkflow?: WorkflowExecutionResult;
1985
2517
  }
1986
2518
 
2519
+ /**
2520
+ * A `retry` action's reference completed.
2521
+ * @public
2522
+ */
2523
+ export declare interface RetryReferenceSettledEvent extends WorkflowExecutionStepEventBase {
2524
+ readonly type: 'retry:reference:settled';
2525
+ readonly attempt: number;
2526
+ readonly kind: RetryReferenceRecord['kind'];
2527
+ readonly id: RetryReferenceRecord['id'];
2528
+ readonly successful: RetryReferenceRecord['successful'];
2529
+ }
2530
+
2531
+ /**
2532
+ * A `retry` action's `stepId` / `workflowId` reference is about to run.
2533
+ * @public
2534
+ */
2535
+ export declare interface RetryReferenceStartEvent extends WorkflowExecutionStepEventBase {
2536
+ readonly type: 'retry:reference:start';
2537
+ /**
2538
+ * Where the `retry` action that names the reference is written.
2539
+ */
2540
+ readonly location: DocumentLocation;
2541
+ readonly attempt: number;
2542
+ readonly kind: RetryReferenceRecord['kind'];
2543
+ readonly id: RetryReferenceRecord['id'];
2544
+ }
2545
+
2546
+ /**
2547
+ * The run is about to wait out a `retry` action's `retryAfter` before the
2548
+ * step's next attempt. Fired only for a positive delay.
2549
+ * @public
2550
+ */
2551
+ export declare interface RetryWaitEvent extends WorkflowExecutionStepEventBase {
2552
+ readonly type: 'retry:wait';
2553
+ readonly attempt: number;
2554
+ readonly delayMs: number;
2555
+ }
2556
+
1987
2557
  /**
1988
2558
  * Identifies a step that calls a workflow, for the context its criteria,
1989
2559
  * outputs and actions are evaluated against.
@@ -2327,6 +2897,20 @@ export declare abstract class SourceDescriptionsLocatorNormalizer {
2327
2897
  } | undefined;
2328
2898
  }
2329
2899
 
2900
+ /**
2901
+ * One attempt at a step began, after it was charged to the step budget.
2902
+ * @public
2903
+ */
2904
+ export declare interface StepAttemptEvent extends WorkflowExecutionStepEventBase {
2905
+ readonly type: 'step:attempt';
2906
+ /**
2907
+ * The attempt number, starting at 1. Each `retry` increments it. The
2908
+ * attempt a `retry` reference makes at another step is that reference's
2909
+ * own, so it is always 1, under the referenced step's `stepId`.
2910
+ */
2911
+ readonly attempt: number;
2912
+ }
2913
+
2330
2914
  /**
2331
2915
  * The execute options of a step: the opaque bag forwarded to the operation
2332
2916
  * executor, or a function returning it for the operation the step was located
@@ -2568,6 +3152,10 @@ export declare abstract class StepParameterResolver extends ArazzoValueResolver
2568
3152
  */
2569
3153
  export declare interface StepRunRecord {
2570
3154
  readonly stepId: string;
3155
+ /**
3156
+ * Where the step is written.
3157
+ */
3158
+ readonly location: DocumentLocation;
2571
3159
  readonly successful: boolean;
2572
3160
  readonly action: SelectedAction | undefined;
2573
3161
  /**
@@ -2630,11 +3218,75 @@ export declare interface StepScope {
2630
3218
  readonly stepId: string;
2631
3219
  }
2632
3220
 
3221
+ /**
3222
+ * A step settled: its retries are done and its terminal action is selected,
3223
+ * or it threw. A step that threw is not `successful` and carries the `error`.
3224
+ * @public
3225
+ */
3226
+ export declare interface StepSettledEvent extends WorkflowExecutionStepEventBase {
3227
+ readonly type: 'step:settled';
3228
+ readonly successful: boolean;
3229
+ /** The attempts made, the one that threw included. */
3230
+ readonly attempts: number;
3231
+ /** What the step threw, as for {@link WorkflowSettledEvent.error}. */
3232
+ readonly error?: unknown;
3233
+ }
3234
+
3235
+ /**
3236
+ * A step began. Its attempts follow it, and its `step:settled` always does.
3237
+ * @public
3238
+ */
3239
+ export declare interface StepStartEvent extends WorkflowExecutionStepEventBase {
3240
+ readonly type: 'step:start';
3241
+ /**
3242
+ * Where the step is written.
3243
+ */
3244
+ readonly location: DocumentLocation;
3245
+ }
3246
+
3247
+ /**
3248
+ * What a workflow does after a step, once the step's action has been
3249
+ * interpreted.
3250
+ *
3251
+ * `next` runs the following step (the success default, or a matched `goto` that
3252
+ * targets the next step); `goto` jumps to a step by id within the current
3253
+ * workflow; `transfer` hands control one-way to another workflow, which the
3254
+ * caller's run then ends on; `end` stops the run with `status: ended`; `break`
3255
+ * stops with `status: failed` (the failure default).
3256
+ * @public
3257
+ */
3258
+ export declare type StepTransition = {
3259
+ readonly kind: 'next';
3260
+ } | {
3261
+ readonly kind: 'goto';
3262
+ readonly stepId: string;
3263
+ } | {
3264
+ readonly kind: 'transfer';
3265
+ readonly workflowId: string;
3266
+ } | {
3267
+ readonly kind: 'end';
3268
+ } | {
3269
+ readonly kind: 'break';
3270
+ };
3271
+
2633
3272
  /** @public */
2634
3273
  export declare class UnmatchedProviderError extends ArazzoRunnerError {
2635
3274
  readonly uri?: string;
2636
3275
  }
2637
3276
 
3277
+ /**
3278
+ * How a workflow invocation was entered.
3279
+ *
3280
+ * Recorded per call so a detected loop can be named for the mechanism that formed
3281
+ * it: a repeat reached purely through `dependsOn` edges is a dependency cycle,
3282
+ * one involving a sub-workflow step call — a `retry` action's `workflowId`
3283
+ * reference — or a `goto`'s one-way transfer to a `workflowId` — is a call
3284
+ * cycle. `retry` and `goto` are grouped with `step` for that classification, not
3285
+ * `dependsOn`: each is a call the current step makes, not a stated precondition.
3286
+ * @public
3287
+ */
3288
+ export declare type WorkflowCallVia = 'root' | 'step' | 'dependsOn' | 'retry' | 'goto';
3289
+
2638
3290
  /**
2639
3291
  * A workflow of an Arazzo document, as listed by
2640
3292
  * {@link ArazzoDocument.listWorkflows}.
@@ -2740,6 +3392,69 @@ export declare interface WorkflowExecuteOptions {
2740
3392
  readonly signal?: AbortSignal;
2741
3393
  }
2742
3394
 
3395
+ /**
3396
+ * The workflow a `dependency:*` event is about.
3397
+ * @public
3398
+ */
3399
+ export declare interface WorkflowExecutionDependency {
3400
+ /**
3401
+ * The `dependsOn` entry as written: a bare workflowId, or a
3402
+ * `$sourceDescriptions.{name}.{workflowId}` expression.
3403
+ */
3404
+ readonly reference: string;
3405
+ /**
3406
+ * The bare id of the workflow the entry resolved to.
3407
+ */
3408
+ readonly workflowId: string;
3409
+ /**
3410
+ * The canonical URI of the Arazzo document that defines it.
3411
+ */
3412
+ readonly documentURI: string;
3413
+ }
3414
+
3415
+ /**
3416
+ * An event the {@link WorkflowExecutor} emits, discriminated by `type`.
3417
+ *
3418
+ * The events other than `workflow:normalize:*` mark the boundaries the
3419
+ * {@link WorkflowExecutionResult} trace records, plus the criterion and
3420
+ * action decisions behind each step, so folding a run's events rebuilds its
3421
+ * trace. A workflow's or step's start and settled events are stamped with the
3422
+ * readings its `durationMs` comes from, so their timestamps differ by exactly
3423
+ * that.
3424
+ *
3425
+ * A run that throws (an authoring error, a cancellation, a throwing observer)
3426
+ * leaves the workflows and steps it unwinds through unsettled; the rejection
3427
+ * of `execute` is the signal.
3428
+ * @public
3429
+ */
3430
+ export declare type WorkflowExecutionEvent = WorkflowStartEvent | WorkflowSettledEvent | WorkflowNormalizeStartEvent | WorkflowNormalizeSettledEvent | DependencyStartEvent | DependencySettledEvent | StepStartEvent | StepAttemptEvent | CriterionEvaluatedEvent | ActionSelectedEvent | RetryWaitEvent | RetryReferenceStartEvent | RetryReferenceSettledEvent | StepSettledEvent;
3431
+
3432
+ /**
3433
+ * The fields every {@link WorkflowExecutionEvent} carries.
3434
+ * @public
3435
+ */
3436
+ export declare interface WorkflowExecutionEventBase extends ArazzoRunnerEventBase {
3437
+ /**
3438
+ * A random id of the {@link WorkflowExecutor.execute} call the event
3439
+ * belongs to. Every workflow, dependency and step of one call shares it, so
3440
+ * the events of concurrent calls, or of runs in different processes, can be
3441
+ * told apart. The operation events of the call carry it too.
3442
+ */
3443
+ readonly runId: string;
3444
+ /**
3445
+ * The bare id of the workflow in progress when the event fired. For a
3446
+ * `dependency:*` event, this is the dependent workflow, not the dependency.
3447
+ */
3448
+ readonly workflowId: string;
3449
+ /**
3450
+ * The chain of workflows in progress, outermost first, this one included.
3451
+ * Uses the same form as `ExecutionError.path`: bare ids for workflows of
3452
+ * the entry document, `{documentURI}#{workflowId}` for workflows of other
3453
+ * documents.
3454
+ */
3455
+ readonly path: readonly string[];
3456
+ }
3457
+
2743
3458
  /**
2744
3459
  * The outcome of executing a workflow.
2745
3460
  *
@@ -2881,6 +3596,14 @@ export declare interface WorkflowExecutionStateOptions {
2881
3596
  readonly inputs?: Record<string, unknown>;
2882
3597
  }
2883
3598
 
3599
+ /**
3600
+ * The fields every step-scoped {@link WorkflowExecutionEvent} carries.
3601
+ * @public
3602
+ */
3603
+ export declare interface WorkflowExecutionStepEventBase extends WorkflowExecutionEventBase {
3604
+ readonly stepId: string;
3605
+ }
3606
+
2884
3607
  /**
2885
3608
  * Executes an Arazzo workflow: the stateful loop that turns "run one step" into
2886
3609
  * "run a workflow".
@@ -3009,6 +3732,15 @@ export declare interface WorkflowExecutorOptions {
3009
3732
  * negative duration if the system clock were adjusted mid-run.
3010
3733
  */
3011
3734
  readonly now?: () => number;
3735
+ /**
3736
+ * Receives the run's events, stamped with
3737
+ * {@link WorkflowExecutorOptions.now}: workflows, dependencies, steps,
3738
+ * attempts, criterion outcomes, selected actions, retry waits and retry
3739
+ * references, plus each workflow's normalization. See
3740
+ * {@link WorkflowExecutionEvent}, and {@link ArazzoRunnerObserver} for how
3741
+ * events are delivered.
3742
+ */
3743
+ readonly observer?: ArazzoRunnerObserver<WorkflowExecutionEvent>;
3012
3744
  }
3013
3745
 
3014
3746
  /**
@@ -3017,6 +3749,33 @@ export declare interface WorkflowExecutorOptions {
3017
3749
  */
3018
3750
  export declare type WorkflowId = string;
3019
3751
 
3752
+ /**
3753
+ * The workflow was normalized.
3754
+ * @public
3755
+ */
3756
+ export declare interface WorkflowNormalizeSettledEvent extends WorkflowExecutionEventBase {
3757
+ readonly type: 'workflow:normalize:settled';
3758
+ /**
3759
+ * Where the workflow is written.
3760
+ */
3761
+ readonly location: DocumentLocation;
3762
+ }
3763
+
3764
+ /**
3765
+ * The workflow is being normalized before its first run in this `execute`
3766
+ * call: dereferenced (which may fetch externally referenced documents), with
3767
+ * its parameters and actions inherited into its steps. A workflow already
3768
+ * normalized earlier in the same call emits nothing.
3769
+ * @public
3770
+ */
3771
+ export declare interface WorkflowNormalizeStartEvent extends WorkflowExecutionEventBase {
3772
+ readonly type: 'workflow:normalize:start';
3773
+ /**
3774
+ * Where the workflow is written.
3775
+ */
3776
+ readonly location: DocumentLocation;
3777
+ }
3778
+
3020
3779
  /**
3021
3780
  * Resolves the `parameters` of a step targeting a `workflowId` into the
3022
3781
  * sub-workflow's inputs — or those of a `goto` / `retry` action naming a
@@ -3064,6 +3823,44 @@ export declare interface WorkflowReferenceContext {
3064
3823
  readonly stepId?: string;
3065
3824
  }
3066
3825
 
3826
+ /**
3827
+ * A workflow invocation produced its result, or threw. The fields repeat
3828
+ * the {@link WorkflowExecutionResult} fields of the same name; an invocation
3829
+ * that threw settles as `failed`, with no outputs, and carries the `error`.
3830
+ * @public
3831
+ */
3832
+ export declare interface WorkflowSettledEvent extends WorkflowExecutionEventBase {
3833
+ readonly type: 'workflow:settled';
3834
+ readonly status: WorkflowExecutionResult['status'];
3835
+ readonly settledStatus: WorkflowExecutionResult['settledStatus'];
3836
+ readonly outputs: WorkflowExecutionResult['outputs'];
3837
+ /**
3838
+ * What the invocation threw, as `execute` rejects with it: an
3839
+ * {@link ArazzoRunnerError} for an error in the document, an abort, or the
3840
+ * transport's own error. Only when it threw.
3841
+ */
3842
+ readonly error?: unknown;
3843
+ }
3844
+
3845
+ /**
3846
+ * A workflow invocation began: it entered the call stack, before it is
3847
+ * normalized and its definition checked. Its `workflow:settled` always
3848
+ * follows, carrying the `error` when the invocation throws.
3849
+ * @public
3850
+ */
3851
+ export declare interface WorkflowStartEvent extends WorkflowExecutionEventBase {
3852
+ readonly type: 'workflow:start';
3853
+ /** Where the workflow is written. */
3854
+ readonly location: DocumentLocation;
3855
+ /**
3856
+ * How the workflow was reached. `root` is the workflow named in `execute`,
3857
+ * `step` is a sub-workflow step, `dependsOn` is a prerequisite, `retry` is
3858
+ * a `retry` action's `workflowId` reference, and `goto` is a one-way
3859
+ * transfer.
3860
+ */
3861
+ readonly via: WorkflowCallVia;
3862
+ }
3863
+
3067
3864
  /**
3068
3865
  * Evaluates an `xpath` Arazzo criterion condition against a resolved context value.
3069
3866
  *