@fabricorg/platform 1.9.0 → 1.10.1

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 (209) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +48 -2
  3. package/dist/actions/index.cjs +45 -26
  4. package/dist/actions/index.cjs.map +1 -1
  5. package/dist/actions/index.d.cts +225 -226
  6. package/dist/actions/index.d.ts +225 -226
  7. package/dist/actions/index.js +41 -2
  8. package/dist/actions/index.js.map +1 -1
  9. package/dist/adapters/index.cjs +696 -66
  10. package/dist/adapters/index.cjs.map +1 -1
  11. package/dist/adapters/index.d.cts +367 -365
  12. package/dist/adapters/index.d.ts +367 -365
  13. package/dist/adapters/index.js +682 -2
  14. package/dist/adapters/index.js.map +1 -1
  15. package/dist/agent-hitl/index.cjs +21 -10
  16. package/dist/agent-hitl/index.cjs.map +1 -1
  17. package/dist/agent-hitl/index.d.cts +30 -30
  18. package/dist/agent-hitl/index.d.ts +30 -30
  19. package/dist/agent-hitl/index.js +21 -2
  20. package/dist/agent-hitl/index.js.map +1 -1
  21. package/dist/certification/index.cjs +109 -24
  22. package/dist/certification/index.cjs.map +1 -1
  23. package/dist/certification/index.d.cts +33 -39
  24. package/dist/certification/index.d.ts +33 -39
  25. package/dist/certification/index.js +107 -8
  26. package/dist/certification/index.js.map +1 -1
  27. package/dist/discovery/index.cjs +12 -10
  28. package/dist/discovery/index.cjs.map +1 -1
  29. package/dist/discovery/index.d.cts +2 -10
  30. package/dist/discovery/index.d.ts +2 -10
  31. package/dist/discovery/index.js +12 -2
  32. package/dist/discovery/index.js.map +1 -1
  33. package/dist/engine-B4csEOEc.js +223 -0
  34. package/dist/engine-B4csEOEc.js.map +1 -0
  35. package/dist/engine-BqScuhrT.cjs +246 -0
  36. package/dist/engine-BqScuhrT.cjs.map +1 -0
  37. package/dist/events/index.cjs +39 -10
  38. package/dist/events/index.cjs.map +1 -1
  39. package/dist/events/index.d.cts +43 -43
  40. package/dist/events/index.d.ts +43 -43
  41. package/dist/events/index.js +39 -2
  42. package/dist/events/index.js.map +1 -1
  43. package/dist/evidence/index.cjs +12 -50
  44. package/dist/evidence/index.d.cts +2 -229
  45. package/dist/evidence/index.d.ts +2 -229
  46. package/dist/evidence/index.js +1 -5
  47. package/dist/evidence-BuCICb0c.js +516 -0
  48. package/dist/evidence-BuCICb0c.js.map +1 -0
  49. package/dist/evidence-Cq48eDvA.cjs +575 -0
  50. package/dist/evidence-Cq48eDvA.cjs.map +1 -0
  51. package/dist/governance/index.cjs +24 -18
  52. package/dist/governance/index.cjs.map +1 -1
  53. package/dist/governance/index.d.cts +80 -83
  54. package/dist/governance/index.d.ts +80 -83
  55. package/dist/governance/index.js +22 -2
  56. package/dist/governance/index.js.map +1 -1
  57. package/dist/ids/index.cjs +52 -22
  58. package/dist/ids/index.cjs.map +1 -1
  59. package/dist/ids/index.d.cts +17 -17
  60. package/dist/ids/index.d.ts +17 -17
  61. package/dist/ids/index.js +49 -2
  62. package/dist/ids/index.js.map +1 -1
  63. package/dist/index-9jasmw76.d.cts +124 -0
  64. package/dist/index-BXpeFdk2.d.cts +190 -0
  65. package/dist/index-BXpeFdk2.d.ts +190 -0
  66. package/dist/index-BnbsKZsT.d.cts +231 -0
  67. package/dist/index-CIl1rYRv.d.cts +11 -0
  68. package/dist/index-CIl1rYRv.d.ts +11 -0
  69. package/dist/index-CVHA1ypT.d.cts +262 -0
  70. package/dist/index-DZ4mnNb7.d.cts +78 -0
  71. package/dist/index-DZ4mnNb7.d.ts +78 -0
  72. package/dist/index-IqcDvl69.d.ts +124 -0
  73. package/dist/index-fmUiRBXu.d.cts +57 -0
  74. package/dist/index-fmUiRBXu.d.ts +57 -0
  75. package/dist/index-sPUPs8pr.d.ts +262 -0
  76. package/dist/index-z9-CYOIo.d.ts +231 -0
  77. package/dist/index.cjs +111 -385
  78. package/dist/index.d.cts +18 -17
  79. package/dist/index.d.ts +18 -17
  80. package/dist/index.js +19 -20
  81. package/dist/manifest/index.cjs +224 -35
  82. package/dist/manifest/index.cjs.map +1 -1
  83. package/dist/manifest/index.d.cts +130 -131
  84. package/dist/manifest/index.d.ts +130 -131
  85. package/dist/manifest/index.js +219 -7
  86. package/dist/manifest/index.js.map +1 -1
  87. package/dist/modules/index.cjs +281 -42
  88. package/dist/modules/index.cjs.map +1 -1
  89. package/dist/modules/index.d.cts +157 -159
  90. package/dist/modules/index.d.ts +157 -159
  91. package/dist/modules/index.js +274 -6
  92. package/dist/modules/index.js.map +1 -1
  93. package/dist/objects/index.cjs +355 -22
  94. package/dist/objects/index.cjs.map +1 -1
  95. package/dist/objects/index.d.cts +2 -77
  96. package/dist/objects/index.d.ts +2 -77
  97. package/dist/objects/index.js +352 -2
  98. package/dist/objects/index.js.map +1 -1
  99. package/dist/policies/index.cjs +14 -48
  100. package/dist/policies/index.d.cts +2 -247
  101. package/dist/policies/index.d.ts +2 -247
  102. package/dist/policies/index.js +1 -3
  103. package/dist/policies-DH_GCXQ-.js +627 -0
  104. package/dist/policies-DH_GCXQ-.js.map +1 -0
  105. package/dist/policies-Nxbp1CH8.cjs +698 -0
  106. package/dist/policies-Nxbp1CH8.cjs.map +1 -0
  107. package/dist/privacy/index.cjs +26 -43
  108. package/dist/privacy/index.cjs.map +1 -1
  109. package/dist/privacy/index.d.cts +2 -189
  110. package/dist/privacy/index.d.ts +2 -189
  111. package/dist/privacy/index.js +18 -3
  112. package/dist/privacy/index.js.map +1 -1
  113. package/dist/projections/index.cjs +241 -23
  114. package/dist/projections/index.cjs.map +1 -1
  115. package/dist/projections/index.d.cts +2 -125
  116. package/dist/projections/index.d.ts +2 -125
  117. package/dist/projections/index.js +238 -3
  118. package/dist/projections/index.js.map +1 -1
  119. package/dist/state-machines/index.cjs +76 -18
  120. package/dist/state-machines/index.cjs.map +1 -1
  121. package/dist/state-machines/index.d.cts +2 -55
  122. package/dist/state-machines/index.d.ts +2 -55
  123. package/dist/state-machines/index.js +74 -2
  124. package/dist/state-machines/index.js.map +1 -1
  125. package/dist/testing/index.cjs +27 -19
  126. package/dist/testing/index.cjs.map +1 -1
  127. package/dist/testing/index.d.cts +17 -19
  128. package/dist/testing/index.d.ts +17 -19
  129. package/dist/testing/index.js +25 -3
  130. package/dist/testing/index.js.map +1 -1
  131. package/package.json +6 -5
  132. package/dist/chunk-2AE6TMAX.cjs +0 -44
  133. package/dist/chunk-2AE6TMAX.cjs.map +0 -1
  134. package/dist/chunk-6HY35TKB.cjs +0 -491
  135. package/dist/chunk-6HY35TKB.cjs.map +0 -1
  136. package/dist/chunk-6UGEIDLC.cjs +0 -26
  137. package/dist/chunk-6UGEIDLC.cjs.map +0 -1
  138. package/dist/chunk-7GAWSUOG.js +0 -64
  139. package/dist/chunk-7GAWSUOG.js.map +0 -1
  140. package/dist/chunk-AFXFAEWA.js +0 -673
  141. package/dist/chunk-AFXFAEWA.js.map +0 -1
  142. package/dist/chunk-AFXKSIVI.cjs +0 -540
  143. package/dist/chunk-AFXKSIVI.cjs.map +0 -1
  144. package/dist/chunk-B5DOGDPG.js +0 -42
  145. package/dist/chunk-B5DOGDPG.js.map +0 -1
  146. package/dist/chunk-BJGZE3GE.js +0 -20
  147. package/dist/chunk-BJGZE3GE.js.map +0 -1
  148. package/dist/chunk-CRZXTZ36.cjs +0 -258
  149. package/dist/chunk-CRZXTZ36.cjs.map +0 -1
  150. package/dist/chunk-D4SWRBUH.cjs +0 -22
  151. package/dist/chunk-D4SWRBUH.cjs.map +0 -1
  152. package/dist/chunk-DBTAUI6C.cjs +0 -395
  153. package/dist/chunk-DBTAUI6C.cjs.map +0 -1
  154. package/dist/chunk-EMSAFNPX.js +0 -98
  155. package/dist/chunk-EMSAFNPX.js.map +0 -1
  156. package/dist/chunk-F3E5SXPN.cjs +0 -28
  157. package/dist/chunk-F3E5SXPN.cjs.map +0 -1
  158. package/dist/chunk-HEYMMVDP.js +0 -480
  159. package/dist/chunk-HEYMMVDP.js.map +0 -1
  160. package/dist/chunk-IFW43ELT.cjs +0 -331
  161. package/dist/chunk-IFW43ELT.cjs.map +0 -1
  162. package/dist/chunk-LFE74IJX.js +0 -20
  163. package/dist/chunk-LFE74IJX.js.map +0 -1
  164. package/dist/chunk-LZSE6QGQ.cjs +0 -60
  165. package/dist/chunk-LZSE6QGQ.cjs.map +0 -1
  166. package/dist/chunk-MCWSUGB3.cjs +0 -102
  167. package/dist/chunk-MCWSUGB3.cjs.map +0 -1
  168. package/dist/chunk-MLBALEUR.js +0 -290
  169. package/dist/chunk-MLBALEUR.js.map +0 -1
  170. package/dist/chunk-NNXQZPB3.cjs +0 -31
  171. package/dist/chunk-NNXQZPB3.cjs.map +0 -1
  172. package/dist/chunk-OFCCZ27Z.js +0 -26
  173. package/dist/chunk-OFCCZ27Z.js.map +0 -1
  174. package/dist/chunk-PDN5DOLQ.js +0 -242
  175. package/dist/chunk-PDN5DOLQ.js.map +0 -1
  176. package/dist/chunk-PIDZQAEL.js +0 -50
  177. package/dist/chunk-PIDZQAEL.js.map +0 -1
  178. package/dist/chunk-Q4Q4JPR3.js +0 -524
  179. package/dist/chunk-Q4Q4JPR3.js.map +0 -1
  180. package/dist/chunk-RALMUSOX.js +0 -55
  181. package/dist/chunk-RALMUSOX.js.map +0 -1
  182. package/dist/chunk-SNTV45LH.cjs +0 -295
  183. package/dist/chunk-SNTV45LH.cjs.map +0 -1
  184. package/dist/chunk-TBS2S5AX.cjs +0 -40
  185. package/dist/chunk-TBS2S5AX.cjs.map +0 -1
  186. package/dist/chunk-TYNIFC7J.js +0 -253
  187. package/dist/chunk-TYNIFC7J.js.map +0 -1
  188. package/dist/chunk-UGWGHTNC.cjs +0 -56
  189. package/dist/chunk-UGWGHTNC.cjs.map +0 -1
  190. package/dist/chunk-WI7CWNYI.cjs +0 -68
  191. package/dist/chunk-WI7CWNYI.cjs.map +0 -1
  192. package/dist/chunk-WNZP53GI.js +0 -386
  193. package/dist/chunk-WNZP53GI.js.map +0 -1
  194. package/dist/chunk-WQ3BYI7T.cjs +0 -249
  195. package/dist/chunk-WQ3BYI7T.cjs.map +0 -1
  196. package/dist/chunk-Y2PJLRIY.js +0 -36
  197. package/dist/chunk-Y2PJLRIY.js.map +0 -1
  198. package/dist/chunk-YGIPN3TU.cjs +0 -684
  199. package/dist/chunk-YGIPN3TU.cjs.map +0 -1
  200. package/dist/chunk-ZAEVQSB5.js +0 -326
  201. package/dist/chunk-ZAEVQSB5.js.map +0 -1
  202. package/dist/chunk-ZMQTV5OJ.js +0 -27
  203. package/dist/chunk-ZMQTV5OJ.js.map +0 -1
  204. package/dist/evidence/index.cjs.map +0 -1
  205. package/dist/evidence/index.js.map +0 -1
  206. package/dist/index.cjs.map +0 -1
  207. package/dist/index.js.map +0 -1
  208. package/dist/policies/index.cjs.map +0 -1
  209. package/dist/policies/index.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ //#region adapters/circuit-breaker.d.ts
1
2
  /**
2
3
  * State of an adapter circuit breaker.
3
4
  *
@@ -7,7 +8,7 @@
7
8
  * - `half_open`: the cooldown elapsed. One probe call is admitted; its outcome
8
9
  * closes the breaker (success) or reopens it (failure).
9
10
  */
10
- type AdapterCircuitState = "closed" | "open" | "half_open";
11
+ export type AdapterCircuitState = "closed" | "open" | "half_open";
11
12
  /**
12
13
  * How a single adapter outcome counts toward the breaker.
13
14
  *
@@ -17,7 +18,7 @@ type AdapterCircuitState = "closed" | "open" | "half_open";
17
18
  * (a validation or business rejection). It is neither a success nor a
18
19
  * dependency failure and does not enter the rolling window.
19
20
  */
20
- type AdapterCircuitOutcome = "success" | "failure" | "ignored";
21
+ export type AdapterCircuitOutcome = "success" | "failure" | "ignored";
21
22
  /**
22
23
  * Map an {@link AdapterOutcomeKind} to how it counts toward a circuit breaker.
23
24
  *
@@ -37,90 +38,90 @@ type AdapterCircuitOutcome = "success" | "failure" | "ignored";
37
38
  * `classifyThrownError` (default `transient_failure`) and maps that kind here,
38
39
  * so an unclassified thrown error counts as a failure.
39
40
  */
40
- declare function classifyCircuitBreakerOutcome(kind: AdapterOutcomeKind): AdapterCircuitOutcome;
41
+ export declare function classifyCircuitBreakerOutcome(kind: AdapterOutcomeKind): AdapterCircuitOutcome;
41
42
  /** The answer a breaker gives before a call. */
42
- interface AdapterCircuitAdmission {
43
- /**
44
- * Whether the call may proceed. Always `true` in `monitor` mode; `false`
45
- * only in `enforce` mode while the breaker is open, forced open, or
46
- * half-open with its probe already in flight.
47
- */
48
- allowed: boolean;
49
- /** State at the time of the decision. */
50
- state: AdapterCircuitState;
51
- /** True when this admission is the half-open probe. Pass it back to `record`. */
52
- probe: boolean;
53
- /** Monitor mode only: true when `enforce` mode would have rejected this call. */
54
- wouldReject?: boolean;
55
- /**
56
- * Milliseconds until the breaker will admit a probe, when known. Absent while
57
- * a manual `force_open` override is set or a half-open probe is in flight.
58
- */
59
- retryAfterMs?: number;
60
- /** Set when a manual override decided the admission. */
61
- manualOverride?: AdapterCircuitBreakerManualOverride;
62
- /**
63
- * The breaker epoch the admission was granted in; opaque to callers.
64
- * {@link InMemoryAdapterCircuitBreaker} lets an outcome change state only
65
- * when this still matches its current epoch. An admission without it is
66
- * treated as current.
67
- */
68
- generation?: number;
43
+ export interface AdapterCircuitAdmission {
44
+ /**
45
+ * Whether the call may proceed. Always `true` in `monitor` mode; `false`
46
+ * only in `enforce` mode while the breaker is open, forced open, or
47
+ * half-open with its probe already in flight.
48
+ */
49
+ allowed: boolean;
50
+ /** State at the time of the decision. */
51
+ state: AdapterCircuitState;
52
+ /** True when this admission is the half-open probe. Pass it back to `record`. */
53
+ probe: boolean;
54
+ /** Monitor mode only: true when `enforce` mode would have rejected this call. */
55
+ wouldReject?: boolean;
56
+ /**
57
+ * Milliseconds until the breaker will admit a probe, when known. Absent while
58
+ * a manual `force_open` override is set or a half-open probe is in flight.
59
+ */
60
+ retryAfterMs?: number;
61
+ /** Set when a manual override decided the admission. */
62
+ manualOverride?: AdapterCircuitBreakerManualOverride;
63
+ /**
64
+ * The breaker epoch the admission was granted in; opaque to callers.
65
+ * {@link InMemoryAdapterCircuitBreaker} lets an outcome change state only
66
+ * when this still matches its current epoch. An admission without it is
67
+ * treated as current.
68
+ */
69
+ generation?: number;
69
70
  }
70
71
  /**
71
72
  * Contract between a circuit breaker and `executeWithAdapterRetry`.
72
73
  * Implement it to plug in a shared or distributed breaker.
73
74
  */
74
- interface AdapterCircuitBreaker {
75
- /** Registry key this breaker guards; defaults to `adapterType:operation`. */
76
- readonly key: string;
77
- readonly mode: "monitor" | "enforce";
78
- /** Current state, applying any elapsed cooldown or manual override. */
79
- getState(): AdapterCircuitState;
80
- /**
81
- * Preview whether a call would be admitted now. Side-effect free: it does
82
- * not commit an elapsed cooldown, take the half-open probe or emit
83
- * telemetry.
84
- */
85
- check(): AdapterCircuitAdmission;
86
- /**
87
- * Decide whether a call may start now. Call it immediately before the
88
- * external effect and pass the returned admission to {@link record}.
89
- */
90
- acquire(): AdapterCircuitAdmission;
91
- /**
92
- * Record the outcome of a call that was admitted by {@link acquire}. Pass
93
- * that admission, not a {@link check} preview, so the breaker can tell a
94
- * stale outcome from a current one.
95
- */
96
- record(outcome: AdapterCircuitOutcome, admission?: AdapterCircuitAdmission): void;
75
+ export interface AdapterCircuitBreaker {
76
+ /** Registry key this breaker guards; defaults to `adapterType:operation`. */
77
+ readonly key: string;
78
+ readonly mode: "monitor" | "enforce";
79
+ /** Current state, applying any elapsed cooldown or manual override. */
80
+ getState(): AdapterCircuitState;
81
+ /**
82
+ * Preview whether a call would be admitted now. Side-effect free: it does
83
+ * not commit an elapsed cooldown, take the half-open probe or emit
84
+ * telemetry.
85
+ */
86
+ check(): AdapterCircuitAdmission;
87
+ /**
88
+ * Decide whether a call may start now. Call it immediately before the
89
+ * external effect and pass the returned admission to {@link record}.
90
+ */
91
+ acquire(): AdapterCircuitAdmission;
92
+ /**
93
+ * Record the outcome of a call that was admitted by {@link acquire}. Pass
94
+ * that admission, not a {@link check} preview, so the breaker can tell a
95
+ * stale outcome from a current one.
96
+ */
97
+ record(outcome: AdapterCircuitOutcome, admission?: AdapterCircuitAdmission): void;
97
98
  }
98
- type AdapterCircuitBreakerEventReason = "failure_threshold" | "cooldown_elapsed" | "probe_succeeded" | "probe_failed" | "manual_override" | "manual_override_cleared";
99
+ export type AdapterCircuitBreakerEventReason = "failure_threshold" | "cooldown_elapsed" | "probe_succeeded" | "probe_failed" | "manual_override" | "manual_override_cleared";
99
100
  interface AdapterCircuitBreakerEventBase {
100
- key: string;
101
- mode: "monitor" | "enforce";
102
- /** Epoch milliseconds from the breaker's clock. */
103
- at: number;
101
+ key: string;
102
+ mode: "monitor" | "enforce";
103
+ /** Epoch milliseconds from the breaker's clock. */
104
+ at: number;
104
105
  }
105
106
  /** Telemetry reported by {@link InMemoryAdapterCircuitBreaker}. */
106
- type AdapterCircuitBreakerEvent = (AdapterCircuitBreakerEventBase & {
107
- type: "state_change";
108
- from: AdapterCircuitState;
109
- to: AdapterCircuitState;
110
- reason: AdapterCircuitBreakerEventReason;
111
- manualOverride?: AdapterCircuitBreakerManualOverride;
107
+ export type AdapterCircuitBreakerEvent = (AdapterCircuitBreakerEventBase & {
108
+ type: "state_change";
109
+ from: AdapterCircuitState;
110
+ to: AdapterCircuitState;
111
+ reason: AdapterCircuitBreakerEventReason;
112
+ manualOverride?: AdapterCircuitBreakerManualOverride;
112
113
  }) | (AdapterCircuitBreakerEventBase & {
113
- /** Enforce mode refused a call; it was not attempted. */
114
- type: "rejected";
115
- state: AdapterCircuitState;
116
- retryAfterMs?: number;
117
- manualOverride?: AdapterCircuitBreakerManualOverride;
114
+ /** Enforce mode refused a call; it was not attempted. */
115
+ type: "rejected";
116
+ state: AdapterCircuitState;
117
+ retryAfterMs?: number;
118
+ manualOverride?: AdapterCircuitBreakerManualOverride;
118
119
  }) | (AdapterCircuitBreakerEventBase & {
119
- /** Monitor mode let a call through that enforce mode would have refused. */
120
- type: "would_reject";
121
- state: AdapterCircuitState;
122
- retryAfterMs?: number;
123
- manualOverride?: AdapterCircuitBreakerManualOverride;
120
+ /** Monitor mode let a call through that enforce mode would have refused. */
121
+ type: "would_reject";
122
+ state: AdapterCircuitState;
123
+ retryAfterMs?: number;
124
+ manualOverride?: AdapterCircuitBreakerManualOverride;
124
125
  });
125
126
  /**
126
127
  * Telemetry callback. Errors it throws and promises it rejects are caught
@@ -131,14 +132,14 @@ type AdapterCircuitBreakerEvent = (AdapterCircuitBreakerEventBase & {
131
132
  * record. A callback may call back into the breaker; it sees committed state,
132
133
  * and events its own calls produce are delivered after it returns, in order.
133
134
  */
134
- type AdapterCircuitBreakerEventListener = (event: AdapterCircuitBreakerEvent) => void | Promise<void>;
135
- interface InMemoryAdapterCircuitBreakerOptions {
136
- /** Usually `adapterType:operation`. */
137
- key: string;
138
- config: AdapterCircuitBreakerConfig;
139
- /** Epoch-millisecond clock. Defaults to `Date.now`. */
140
- now?: () => number;
141
- onEvent?: AdapterCircuitBreakerEventListener;
135
+ export type AdapterCircuitBreakerEventListener = (event: AdapterCircuitBreakerEvent) => void | Promise<void>;
136
+ export interface InMemoryAdapterCircuitBreakerOptions {
137
+ /** Usually `adapterType:operation`. */
138
+ key: string;
139
+ config: AdapterCircuitBreakerConfig;
140
+ /** Epoch-millisecond clock. Defaults to `Date.now`. */
141
+ now?: () => number;
142
+ onEvent?: AdapterCircuitBreakerEventListener;
142
143
  }
143
144
  /**
144
145
  * Validate a circuit-breaker config. Throws a `RangeError` naming the first
@@ -147,7 +148,7 @@ interface InMemoryAdapterCircuitBreakerOptions {
147
148
  * finite numbers; `cooldownMs` a non-negative finite number; `manualOverride`
148
149
  * `force_open` or `force_closed` when present.
149
150
  */
150
- declare function assertAdapterCircuitBreakerConfig(config: AdapterCircuitBreakerConfig): void;
151
+ export declare function assertAdapterCircuitBreakerConfig(config: AdapterCircuitBreakerConfig): void;
151
152
  /**
152
153
  * Dependency-free, in-process circuit breaker for one adapter operation.
153
154
  *
@@ -211,72 +212,72 @@ declare function assertAdapterCircuitBreakerConfig(config: AdapterCircuitBreaker
211
212
  * automatic open, `force_open` blocks only in `enforce` mode. Clearing the
212
213
  * override returns the breaker to `closed` with its window intact.
213
214
  */
214
- declare class InMemoryAdapterCircuitBreaker implements AdapterCircuitBreaker {
215
- readonly key: string;
216
- readonly mode: "monitor" | "enforce";
217
- private readonly config;
218
- private readonly now;
219
- private readonly onEvent;
220
- private readonly probeLeaseMs;
221
- private samples;
222
- private state;
223
- private openedAt;
224
- private probeIssuedAt;
225
- /** Advances on every state change, manual override change and probe grant. */
226
- private generation;
227
- private manualOverride;
228
- /** Telemetry waiting for the current operation to commit. */
229
- private readonly outbox;
230
- private operationDepth;
231
- private flushing;
232
- constructor(options: InMemoryAdapterCircuitBreakerOptions);
233
- getState(): AdapterCircuitState;
234
- getManualOverride(): AdapterCircuitBreakerManualOverride | undefined;
235
- /**
236
- * Set (`force_open` / `force_closed`) or clear (`undefined`) the manual
237
- * override. Clearing returns the breaker to `closed` with its window intact.
238
- */
239
- setManualOverride(override: AdapterCircuitBreakerManualOverride | undefined): void;
240
- check(): AdapterCircuitAdmission;
241
- acquire(): AdapterCircuitAdmission;
242
- record(outcome: AdapterCircuitOutcome, admission?: AdapterCircuitAdmission): void;
243
- private applyOutcome;
244
- /**
245
- * `take` is false for {@link check}: a pure preview that sees an elapsed
246
- * cooldown without committing it, takes no probe and emits nothing.
247
- */
248
- private decide;
249
- private refuse;
250
- private releaseProbe;
251
- /** Apply the time-based open → half_open transition. */
252
- private advance;
253
- private shouldTrip;
254
- private prune;
255
- private transition;
256
- private reportedState;
257
- /**
258
- * Commit an elapsed cooldown as an operation of its own, delivering its
259
- * event before the caller's operation reads state.
260
- */
261
- private settle;
262
- /**
263
- * Run `step` to completion, then deliver the telemetry it produced. The
264
- * return value is fixed before any listener runs.
265
- */
266
- private operation;
267
- private emit;
268
- /**
269
- * Deliver buffered events in order. A listener that calls back into the
270
- * breaker queues its own events; this loop delivers them after it returns
271
- * instead of recursing.
272
- */
273
- private flush;
274
- private deliver;
215
+ export declare class InMemoryAdapterCircuitBreaker implements AdapterCircuitBreaker {
216
+ readonly key: string;
217
+ readonly mode: "monitor" | "enforce";
218
+ private readonly config;
219
+ private readonly now;
220
+ private readonly onEvent;
221
+ private readonly probeLeaseMs;
222
+ private samples;
223
+ private state;
224
+ private openedAt;
225
+ private probeIssuedAt;
226
+ /** Advances on every state change, manual override change and probe grant. */
227
+ private generation;
228
+ private manualOverride;
229
+ /** Telemetry waiting for the current operation to commit. */
230
+ private readonly outbox;
231
+ private operationDepth;
232
+ private flushing;
233
+ constructor(options: InMemoryAdapterCircuitBreakerOptions);
234
+ getState(): AdapterCircuitState;
235
+ getManualOverride(): AdapterCircuitBreakerManualOverride | undefined;
236
+ /**
237
+ * Set (`force_open` / `force_closed`) or clear (`undefined`) the manual
238
+ * override. Clearing returns the breaker to `closed` with its window intact.
239
+ */
240
+ setManualOverride(override: AdapterCircuitBreakerManualOverride | undefined): void;
241
+ check(): AdapterCircuitAdmission;
242
+ acquire(): AdapterCircuitAdmission;
243
+ record(outcome: AdapterCircuitOutcome, admission?: AdapterCircuitAdmission): void;
244
+ private applyOutcome;
245
+ /**
246
+ * `take` is false for {@link check}: a pure preview that sees an elapsed
247
+ * cooldown without committing it, takes no probe and emits nothing.
248
+ */
249
+ private decide;
250
+ private refuse;
251
+ private releaseProbe;
252
+ /** Apply the time-based open → half_open transition. */
253
+ private advance;
254
+ private shouldTrip;
255
+ private prune;
256
+ private transition;
257
+ private reportedState;
258
+ /**
259
+ * Commit an elapsed cooldown as an operation of its own, delivering its
260
+ * event before the caller's operation reads state.
261
+ */
262
+ private settle;
263
+ /**
264
+ * Run `step` to completion, then deliver the telemetry it produced. The
265
+ * return value is fixed before any listener runs.
266
+ */
267
+ private operation;
268
+ private emit;
269
+ /**
270
+ * Deliver buffered events in order. A listener that calls back into the
271
+ * breaker queues its own events; this loop delivers them after it returns
272
+ * instead of recursing.
273
+ */
274
+ private flush;
275
+ private deliver;
275
276
  }
276
277
  /** Trusted invocation context available when selecting an adapter breaker. */
277
- interface AdapterCircuitBreakerScope {
278
- tenantId: string;
279
- spaceId?: string;
278
+ export interface AdapterCircuitBreakerScope {
279
+ tenantId: string;
280
+ spaceId?: string;
280
281
  }
281
282
  /**
282
283
  * Key by tenant, optional space, vendor, and adapter operation. Components are
@@ -290,24 +291,24 @@ interface AdapterCircuitBreakerScope {
290
291
  * adapter type, but its absence is tolerated for JavaScript callers.
291
292
  * Keys appear in errors and telemetry: use non-secret identifiers.
292
293
  */
293
- declare function scopedAdapterCircuitBreakerKey(adapter: AdapterImplementation, scope: AdapterCircuitBreakerScope | undefined): string;
294
+ export declare function scopedAdapterCircuitBreakerKey(adapter: AdapterImplementation, scope: AdapterCircuitBreakerScope | undefined): string;
294
295
  /** Supplies the breaker, if any, that guards an adapter in invocation scope. */
295
- interface AdapterCircuitBreakerProvider {
296
- forAdapter(adapter: AdapterImplementation, scope?: AdapterCircuitBreakerScope): AdapterCircuitBreaker | undefined;
296
+ export interface AdapterCircuitBreakerProvider {
297
+ forAdapter(adapter: AdapterImplementation, scope?: AdapterCircuitBreakerScope): AdapterCircuitBreaker | undefined;
297
298
  }
298
- interface AdapterCircuitBreakerRegistryOptions {
299
- /**
300
- * Defaults to `adapterType:operation`, shared across tenants and vendors in
301
- * this registry. Use {@link scopedAdapterCircuitBreakerKey} for tenant,
302
- * space, and vendor isolation. The first config seen for a key wins;
303
- * later conflicting configs reuse that breaker without throwing. Breakers
304
- * are never evicted, and scoped keys are high-cardinality: avoid them as
305
- * metric labels.
306
- */
307
- key?: (adapter: AdapterImplementation, scope: AdapterCircuitBreakerScope | undefined) => string;
308
- /** Epoch-millisecond clock handed to every breaker. Defaults to `Date.now`. */
309
- now?: () => number;
310
- onEvent?: AdapterCircuitBreakerEventListener;
299
+ export interface AdapterCircuitBreakerRegistryOptions {
300
+ /**
301
+ * Defaults to `adapterType:operation`, shared across tenants and vendors in
302
+ * this registry. Use {@link scopedAdapterCircuitBreakerKey} for tenant,
303
+ * space, and vendor isolation. The first config seen for a key wins;
304
+ * later conflicting configs reuse that breaker without throwing. Breakers
305
+ * are never evicted, and scoped keys are high-cardinality: avoid them as
306
+ * metric labels.
307
+ */
308
+ key?: (adapter: AdapterImplementation, scope: AdapterCircuitBreakerScope | undefined) => string;
309
+ /** Epoch-millisecond clock handed to every breaker. Defaults to `Date.now`. */
310
+ now?: () => number;
311
+ onEvent?: AdapterCircuitBreakerEventListener;
311
312
  }
312
313
  /**
313
314
  * Lazily creates one {@link InMemoryAdapterCircuitBreaker} per
@@ -318,70 +319,71 @@ interface AdapterCircuitBreakerRegistryOptions {
318
319
  * wins; later conflicting configs reuse the existing breaker without throwing.
319
320
  * Share a key only between adapters intended to use the same configuration.
320
321
  */
321
- declare class AdapterCircuitBreakerRegistry implements AdapterCircuitBreakerProvider {
322
- private readonly options;
323
- private readonly breakers;
324
- constructor(options?: AdapterCircuitBreakerRegistryOptions);
325
- forAdapter(adapter: AdapterImplementation, scope?: AdapterCircuitBreakerScope): InMemoryAdapterCircuitBreaker | undefined;
326
- /** Looks up the default `adapterType:operation` key without creating a breaker. */
327
- get(adapterType: string, operation: string): InMemoryAdapterCircuitBreaker | undefined;
328
- /** Looks up an exact key, including a custom key, without creating a breaker. */
329
- getByKey(key: string): InMemoryAdapterCircuitBreaker | undefined;
322
+ export declare class AdapterCircuitBreakerRegistry implements AdapterCircuitBreakerProvider {
323
+ private readonly options;
324
+ private readonly breakers;
325
+ constructor(options?: AdapterCircuitBreakerRegistryOptions);
326
+ forAdapter(adapter: AdapterImplementation, scope?: AdapterCircuitBreakerScope): InMemoryAdapterCircuitBreaker | undefined;
327
+ /** Looks up the default `adapterType:operation` key without creating a breaker. */
328
+ get(adapterType: string, operation: string): InMemoryAdapterCircuitBreaker | undefined;
329
+ /** Looks up an exact key, including a custom key, without creating a breaker. */
330
+ getByKey(key: string): InMemoryAdapterCircuitBreaker | undefined;
330
331
  }
331
332
  /**
332
333
  * Thrown by `executeWithAdapterRetry` when an `enforce`-mode breaker refuses
333
334
  * an attempt. The refused attempt never reached `execute`, so no external
334
335
  * effect happened for it.
335
336
  */
336
- declare class AdapterCircuitOpenError extends Error {
337
- readonly name = "AdapterCircuitOpenError";
338
- readonly code: "ADAPTER_CIRCUIT_OPEN";
339
- readonly reason: "circuit_open";
340
- readonly adapterKey: string;
341
- readonly state: AdapterCircuitState;
342
- /** The attempt number that was refused (1 = refused before any call). */
343
- readonly attempt: number;
344
- readonly retryAfterMs?: number;
345
- readonly manualOverride?: AdapterCircuitBreakerManualOverride;
346
- /** Error of the previous attempt, when the breaker opened mid-retry. */
347
- readonly lastError?: string;
348
- constructor(input: {
349
- adapterKey: string;
350
- state: AdapterCircuitState;
351
- attempt: number;
352
- retryAfterMs?: number;
353
- manualOverride?: AdapterCircuitBreakerManualOverride;
354
- lastError?: string;
355
- });
337
+ export declare class AdapterCircuitOpenError extends Error {
338
+ readonly name = "AdapterCircuitOpenError";
339
+ readonly code: "ADAPTER_CIRCUIT_OPEN";
340
+ readonly reason: "circuit_open";
341
+ readonly adapterKey: string;
342
+ readonly state: AdapterCircuitState;
343
+ /** The attempt number that was refused (1 = refused before any call). */
344
+ readonly attempt: number;
345
+ readonly retryAfterMs?: number;
346
+ readonly manualOverride?: AdapterCircuitBreakerManualOverride;
347
+ /** Error of the previous attempt, when the breaker opened mid-retry. */
348
+ readonly lastError?: string;
349
+ constructor(input: {
350
+ adapterKey: string;
351
+ state: AdapterCircuitState;
352
+ attempt: number;
353
+ retryAfterMs?: number;
354
+ manualOverride?: AdapterCircuitBreakerManualOverride;
355
+ lastError?: string;
356
+ });
356
357
  }
357
358
  /**
358
359
  * Recognise an {@link AdapterCircuitOpenError}, including one constructed by a
359
360
  * second copy of this package (for example an ESM and a CommonJS build loaded
360
361
  * side by side), where `instanceof` fails.
361
362
  */
362
- declare function isAdapterCircuitOpenError(error: unknown): error is AdapterCircuitOpenError;
363
-
364
- interface AdapterExecutionContext {
365
- tenantId: string;
366
- spaceId: string;
367
- actionInvocationId: string;
368
- adapterInvocationId: string;
369
- correlationId: string;
370
- causationId?: string;
371
- attempt: number;
372
- maxAttempts: number;
373
- /** Epoch-millis deadline after which the adapter should abandon the call. */
374
- deadlineMs?: number;
375
- /** Set by the host when the invocation has been cancelled; adapters should stop work. */
376
- cancelled?: boolean;
377
- /** Non-secret reason the invocation was cancelled. */
378
- cancellationReason?: string;
379
- /**
380
- * AbortSignal the host aborts when the deadline expires or the invocation is
381
- * cancelled. Adapters should propagate this to underlying HTTP/database
382
- * clients so in-flight work is abandoned rather than left dangling.
383
- */
384
- signal?: AbortSignal;
363
+ export declare function isAdapterCircuitOpenError(error: unknown): error is AdapterCircuitOpenError;
364
+ //#endregion
365
+ //#region adapters/index.d.ts
366
+ export interface AdapterExecutionContext {
367
+ tenantId: string;
368
+ spaceId: string;
369
+ actionInvocationId: string;
370
+ adapterInvocationId: string;
371
+ correlationId: string;
372
+ causationId?: string;
373
+ attempt: number;
374
+ maxAttempts: number;
375
+ /** Epoch-millis deadline after which the adapter should abandon the call. */
376
+ deadlineMs?: number;
377
+ /** Set by the host when the invocation has been cancelled; adapters should stop work. */
378
+ cancelled?: boolean;
379
+ /** Non-secret reason the invocation was cancelled. */
380
+ cancellationReason?: string;
381
+ /**
382
+ * AbortSignal the host aborts when the deadline expires or the invocation is
383
+ * cancelled. Adapters should propagate this to underlying HTTP/database
384
+ * clients so in-flight work is abandoned rather than left dangling.
385
+ */
386
+ signal?: AbortSignal;
385
387
  }
386
388
  /**
387
389
  * Additive classification of an adapter outcome so the retry layer can
@@ -392,20 +394,20 @@ interface AdapterExecutionContext {
392
394
  * layer treats a non-success result as `transient_failure` for backward
393
395
  * compatibility.
394
396
  */
395
- type AdapterOutcomeKind = "success" | "transient_failure" | "permanent_failure" | "timeout" | "ambiguous";
397
+ export type AdapterOutcomeKind = "success" | "transient_failure" | "permanent_failure" | "timeout" | "ambiguous";
396
398
  /**
397
399
  * Durable, non-secret evidence attached to a classified adapter outcome.
398
400
  * Used by the host to record reconciliation evidence when an adapter returns
399
401
  * an ambiguous result whose external effect may or may not have been applied.
400
402
  */
401
- interface AdapterOutcomeEvidence {
402
- kind: AdapterOutcomeKind;
403
- reason?: string;
404
- /** Opaque, non-secret reference to external operation state for reconciliation. */
405
- externalReference?: string;
406
- /** Whether the external effect may have been applied (true for ambiguous/timeout). */
407
- effectMayHaveApplied?: boolean;
408
- observedAt: Date | string;
403
+ export interface AdapterOutcomeEvidence {
404
+ kind: AdapterOutcomeKind;
405
+ reason?: string;
406
+ /** Opaque, non-secret reference to external operation state for reconciliation. */
407
+ externalReference?: string;
408
+ /** Whether the external effect may have been applied (true for ambiguous/timeout). */
409
+ effectMayHaveApplied?: boolean;
410
+ observedAt: Date | string;
409
411
  }
410
412
  /**
411
413
  * An adapter handed the work to an external system that will finish it later.
@@ -415,45 +417,45 @@ interface AdapterOutcomeEvidence {
415
417
  * in someone else's hands. The host keeps the invocation running and expects a
416
418
  * completion carrying this reference through its completion ingress.
417
419
  */
418
- interface AcceptedExternalOperation {
419
- /** Opaque, non-secret reference the external system will complete by. */
420
- externalReference: string;
421
- /** When the external system said it expects to finish, if it said. */
422
- expectedBy?: Date | string;
420
+ export interface AcceptedExternalOperation {
421
+ /** Opaque, non-secret reference the external system will complete by. */
422
+ externalReference: string;
423
+ /** When the external system said it expects to finish, if it said. */
424
+ expectedBy?: Date | string;
423
425
  }
424
- interface AdapterExecutionResult {
425
- success: boolean;
426
- correlationId?: string;
427
- error?: string;
428
- /** Additive outcome classification. Omitted = infer from `success`. */
429
- outcome?: AdapterOutcomeKind;
430
- /** Durable evidence for ambiguous or timeout outcomes requiring reconciliation. */
431
- outcomeEvidence?: AdapterOutcomeEvidence;
432
- /** Present when a successful call handed the work off to finish elsewhere. */
433
- acceptedExternalOperation?: AcceptedExternalOperation;
426
+ export interface AdapterExecutionResult {
427
+ success: boolean;
428
+ correlationId?: string;
429
+ error?: string;
430
+ /** Additive outcome classification. Omitted = infer from `success`. */
431
+ outcome?: AdapterOutcomeKind;
432
+ /** Durable evidence for ambiguous or timeout outcomes requiring reconciliation. */
433
+ outcomeEvidence?: AdapterOutcomeEvidence;
434
+ /** Present when a successful call handed the work off to finish elsewhere. */
435
+ acceptedExternalOperation?: AcceptedExternalOperation;
434
436
  }
435
- type AdapterExecutor = (input: Record<string, unknown>, context: AdapterExecutionContext) => Promise<AdapterExecutionResult>;
436
- interface AdapterRetryPolicy {
437
- /** External calls must explicitly opt into retry by being idempotent. */
438
- idempotent: boolean;
439
- /** Total attempts including the first call. Non-idempotent policies are forced to 1. */
440
- maxAttempts?: number;
441
- /** First backoff delay in milliseconds. */
442
- initialDelayMs?: number;
443
- /** Exponential multiplier applied after each failed attempt. */
444
- backoffMultiplier?: number;
445
- /** Upper bound for any single retry delay in milliseconds. */
446
- maxDelayMs?: number;
437
+ export type AdapterExecutor = (input: Record<string, unknown>, context: AdapterExecutionContext) => Promise<AdapterExecutionResult>;
438
+ export interface AdapterRetryPolicy {
439
+ /** External calls must explicitly opt into retry by being idempotent. */
440
+ idempotent: boolean;
441
+ /** Total attempts including the first call. Non-idempotent policies are forced to 1. */
442
+ maxAttempts?: number;
443
+ /** First backoff delay in milliseconds. */
444
+ initialDelayMs?: number;
445
+ /** Exponential multiplier applied after each failed attempt. */
446
+ backoffMultiplier?: number;
447
+ /** Upper bound for any single retry delay in milliseconds. */
448
+ maxDelayMs?: number;
447
449
  }
448
- interface ResolvedAdapterRetryPolicy {
449
- idempotent: boolean;
450
- maxAttempts: number;
451
- initialDelayMs: number;
452
- backoffMultiplier: number;
453
- maxDelayMs: number;
450
+ export interface ResolvedAdapterRetryPolicy {
451
+ idempotent: boolean;
452
+ maxAttempts: number;
453
+ initialDelayMs: number;
454
+ backoffMultiplier: number;
455
+ maxDelayMs: number;
454
456
  }
455
457
  /** Manual circuit-breaker override: pin the breaker open or closed. */
456
- type AdapterCircuitBreakerManualOverride = "force_open" | "force_closed";
458
+ export type AdapterCircuitBreakerManualOverride = "force_open" | "force_closed";
457
459
  /**
458
460
  * Per-adapter circuit-breaker configuration, read by
459
461
  * {@link AdapterCircuitBreakerRegistry} (and so by Platform Host) to create one
@@ -461,113 +463,113 @@ type AdapterCircuitBreakerManualOverride = "force_open" | "force_closed";
461
463
  * `adapterType:operation`; configurable through the registry `key` option).
462
464
  * Validated by {@link assertAdapterCircuitBreakerConfig}.
463
465
  */
464
- interface AdapterCircuitBreakerConfig {
465
- /**
466
- * `monitor` records outcomes, runs the state machine and reports what it
467
- * would have refused, but never blocks a call. `enforce` refuses calls
468
- * while the breaker is open, without attempting them.
469
- */
470
- mode: "monitor" | "enforce";
471
- /**
472
- * A failure count. Let `M = minimumSamples ?? failureThreshold`. Once at
473
- * least `M` outcomes fall within `windowMs`, the breaker opens when the most
474
- * recent `failureThreshold` of them are all failures, or when the failure
475
- * ratio in the window reaches `failureThreshold / M`. Without
476
- * `minimumSamples` this is "`failureThreshold` consecutive failures".
477
- * Matches the .NET port's `InMemoryAdapterCircuitBreaker`. Positive integer.
478
- */
479
- failureThreshold: number;
480
- /** Rolling window, in milliseconds, of outcomes the thresholds consider. */
481
- windowMs: number;
482
- /** Milliseconds an open breaker waits before admitting one half-open probe. */
483
- cooldownMs: number;
484
- /** Outcomes required in the window before the breaker can open. Defaults to `failureThreshold`. */
485
- minimumSamples?: number;
486
- /**
487
- * How long, in milliseconds, the single half-open probe holds its slot
488
- * before it is presumed lost and another call may probe. Defaults to
489
- * `max(cooldownMs, windowMs)`; it is independent of `cooldownMs`, so a zero
490
- * or short cooldown never admits concurrent probes. Positive.
491
- */
492
- probeLeaseMs?: number;
493
- /**
494
- * Optional initial manual override. `force_open` reports `open` (and blocks
495
- * only in `enforce` mode); `force_closed` reports `closed` and never blocks.
496
- * Change it at runtime with `InMemoryAdapterCircuitBreaker.setManualOverride`.
497
- */
498
- manualOverride?: AdapterCircuitBreakerManualOverride;
466
+ export interface AdapterCircuitBreakerConfig {
467
+ /**
468
+ * `monitor` records outcomes, runs the state machine and reports what it
469
+ * would have refused, but never blocks a call. `enforce` refuses calls
470
+ * while the breaker is open, without attempting them.
471
+ */
472
+ mode: "monitor" | "enforce";
473
+ /**
474
+ * A failure count. Let `M = minimumSamples ?? failureThreshold`. Once at
475
+ * least `M` outcomes fall within `windowMs`, the breaker opens when the most
476
+ * recent `failureThreshold` of them are all failures, or when the failure
477
+ * ratio in the window reaches `failureThreshold / M`. Without
478
+ * `minimumSamples` this is "`failureThreshold` consecutive failures".
479
+ * Matches the .NET port's `InMemoryAdapterCircuitBreaker`. Positive integer.
480
+ */
481
+ failureThreshold: number;
482
+ /** Rolling window, in milliseconds, of outcomes the thresholds consider. */
483
+ windowMs: number;
484
+ /** Milliseconds an open breaker waits before admitting one half-open probe. */
485
+ cooldownMs: number;
486
+ /** Outcomes required in the window before the breaker can open. Defaults to `failureThreshold`. */
487
+ minimumSamples?: number;
488
+ /**
489
+ * How long, in milliseconds, the single half-open probe holds its slot
490
+ * before it is presumed lost and another call may probe. Defaults to
491
+ * `max(cooldownMs, windowMs)`; it is independent of `cooldownMs`, so a zero
492
+ * or short cooldown never admits concurrent probes. Positive.
493
+ */
494
+ probeLeaseMs?: number;
495
+ /**
496
+ * Optional initial manual override. `force_open` reports `open` (and blocks
497
+ * only in `enforce` mode); `force_closed` reports `closed` and never blocks.
498
+ * Change it at runtime with `InMemoryAdapterCircuitBreaker.setManualOverride`.
499
+ */
500
+ manualOverride?: AdapterCircuitBreakerManualOverride;
499
501
  }
500
- interface AdapterImplementation {
501
- adapterType: string;
502
- operation: string;
503
- vendor: string;
504
- /** Whether this adapter operation can be safely retried by default. */
505
- idempotent: boolean;
506
- retryPolicy?: AdapterRetryPolicy;
507
- /** Defaults to monitor-only; enforce mode must be explicitly configured. */
508
- circuitBreaker?: AdapterCircuitBreakerConfig;
509
- execute: AdapterExecutor;
502
+ export interface AdapterImplementation {
503
+ adapterType: string;
504
+ operation: string;
505
+ vendor: string;
506
+ /** Whether this adapter operation can be safely retried by default. */
507
+ idempotent: boolean;
508
+ retryPolicy?: AdapterRetryPolicy;
509
+ /** Defaults to monitor-only; enforce mode must be explicitly configured. */
510
+ circuitBreaker?: AdapterCircuitBreakerConfig;
511
+ execute: AdapterExecutor;
510
512
  }
511
- interface AdapterAttempt<T> {
512
- attempt: number;
513
- result?: T;
514
- error?: string;
515
- willRetry: boolean;
516
- nextDelayMs?: number;
513
+ export interface AdapterAttempt<T> {
514
+ attempt: number;
515
+ result?: T;
516
+ error?: string;
517
+ willRetry: boolean;
518
+ nextDelayMs?: number;
517
519
  }
518
- interface ExecuteWithRetryOptions<T> {
519
- policy?: AdapterRetryPolicy;
520
- defaultIdempotent: boolean;
521
- execute: (attempt: number, maxAttempts: number) => Promise<T>;
522
- isSuccessful: (result: T) => boolean;
523
- getError: (result: T) => string | undefined;
524
- /**
525
- * Optional outcome classifier. When provided, the retry layer retries only
526
- * `transient_failure` outcomes (and only when the policy is idempotent).
527
- * `permanent_failure`, `timeout`, and `ambiguous` outcomes are never retried.
528
- * When omitted, all non-success results are treated as transient (backward compatible).
529
- */
530
- classifyOutcome?: (result: T) => AdapterOutcomeKind;
531
- /**
532
- * Optional classifier for errors thrown by the execute callback (not returned
533
- * as results). When provided, the retry layer retries only `transient_failure`
534
- * classifications. When omitted, thrown errors are never retried — the caller
535
- * must explicitly opt into retrying a thrown failure by classifying it.
536
- */
537
- classifyThrownError?: (error: unknown) => AdapterOutcomeKind;
538
- sleep?: (delayMs: number) => Promise<void>;
539
- onAttempt?: (attempt: AdapterAttempt<T>) => Promise<void> | void;
540
- /**
541
- * Optional per-attempt preparation, awaited before the circuit breaker is
542
- * consulted and before `execute` (for example, persisting the attempt
543
- * number). Put every await a caller needs before the call here, so that
544
- * nothing awaits between breaker admission and the external call. If it
545
- * throws, no admission is taken and no breaker outcome is recorded; the
546
- * error is classified with `classifyThrownError` and retried or rethrown
547
- * exactly like an error thrown by `execute`.
548
- */
549
- prepareAttempt?: (attempt: number, maxAttempts: number) => Promise<void> | void;
550
- /**
551
- * Optional circuit breaker. When present, `acquire()` is called
552
- * immediately before every `execute` call, with no await in between, and every attempt's outcome is
553
- * recorded through {@link classifyCircuitBreakerOutcome}. In `enforce` mode
554
- * a refused attempt is not executed and {@link AdapterCircuitOpenError} is
555
- * thrown; if the breaker opens between attempts, retrying stops and the
556
- * same error is thrown. When omitted, behaviour is unchanged.
557
- */
558
- circuitBreaker?: AdapterCircuitBreaker;
520
+ export interface ExecuteWithRetryOptions<T> {
521
+ policy?: AdapterRetryPolicy;
522
+ defaultIdempotent: boolean;
523
+ execute: (attempt: number, maxAttempts: number) => Promise<T>;
524
+ isSuccessful: (result: T) => boolean;
525
+ getError: (result: T) => string | undefined;
526
+ /**
527
+ * Optional outcome classifier. When provided, the retry layer retries only
528
+ * `transient_failure` outcomes (and only when the policy is idempotent).
529
+ * `permanent_failure`, `timeout`, and `ambiguous` outcomes are never retried.
530
+ * When omitted, all non-success results are treated as transient (backward compatible).
531
+ */
532
+ classifyOutcome?: (result: T) => AdapterOutcomeKind;
533
+ /**
534
+ * Optional classifier for errors thrown by the execute callback (not returned
535
+ * as results). When provided, the retry layer retries only `transient_failure`
536
+ * classifications. When omitted, thrown errors are never retried — the caller
537
+ * must explicitly opt into retrying a thrown failure by classifying it.
538
+ */
539
+ classifyThrownError?: (error: unknown) => AdapterOutcomeKind;
540
+ sleep?: (delayMs: number) => Promise<void>;
541
+ onAttempt?: (attempt: AdapterAttempt<T>) => Promise<void> | void;
542
+ /**
543
+ * Optional per-attempt preparation, awaited before the circuit breaker is
544
+ * consulted and before `execute` (for example, persisting the attempt
545
+ * number). Put every await a caller needs before the call here, so that
546
+ * nothing awaits between breaker admission and the external call. If it
547
+ * throws, no admission is taken and no breaker outcome is recorded; the
548
+ * error is classified with `classifyThrownError` and retried or rethrown
549
+ * exactly like an error thrown by `execute`.
550
+ */
551
+ prepareAttempt?: (attempt: number, maxAttempts: number) => Promise<void> | void;
552
+ /**
553
+ * Optional circuit breaker. When present, `acquire()` is called
554
+ * immediately before every `execute` call, with no await in between, and every attempt's outcome is
555
+ * recorded through {@link classifyCircuitBreakerOutcome}. In `enforce` mode
556
+ * a refused attempt is not executed and {@link AdapterCircuitOpenError} is
557
+ * thrown; if the breaker opens between attempts, retrying stops and the
558
+ * same error is thrown. When omitted, behaviour is unchanged.
559
+ */
560
+ circuitBreaker?: AdapterCircuitBreaker;
559
561
  }
560
- declare class MissingAdapterRegistrationError extends Error {
561
- constructor(adapterType: string, operation: string);
562
+ export declare class MissingAdapterRegistrationError extends Error {
563
+ constructor(adapterType: string, operation: string);
562
564
  }
563
- declare class AdapterRegistry {
564
- private readonly adapters;
565
- register(adapter: AdapterImplementation): void;
566
- resolve(adapterType: string, operation: string): AdapterImplementation | undefined;
567
- require(adapterType: string, operation: string): AdapterImplementation;
565
+ export declare class AdapterRegistry {
566
+ private readonly adapters;
567
+ register(adapter: AdapterImplementation): void;
568
+ resolve(adapterType: string, operation: string): AdapterImplementation | undefined;
569
+ require(adapterType: string, operation: string): AdapterImplementation;
568
570
  }
569
- declare function resolveAdapterRetryPolicy(policy: AdapterRetryPolicy | undefined, defaultIdempotent: boolean): ResolvedAdapterRetryPolicy;
570
- declare function getRetryDelayMs(attempt: number, policy: ResolvedAdapterRetryPolicy): number;
571
+ export declare function resolveAdapterRetryPolicy(policy: AdapterRetryPolicy | undefined, defaultIdempotent: boolean): ResolvedAdapterRetryPolicy;
572
+ export declare function getRetryDelayMs(attempt: number, policy: ResolvedAdapterRetryPolicy): number;
571
573
  /**
572
574
  * Classify an {@link AdapterExecutionResult} into an {@link AdapterOutcomeKind}.
573
575
  * When `outcome` is explicitly set, it is returned directly, after rejecting a
@@ -575,20 +577,20 @@ declare function getRetryDelayMs(attempt: number, policy: ResolvedAdapterRetryPo
575
577
  * Otherwise a successful result maps to `success` and a failed result maps to
576
578
  * `transient_failure` (the historical default).
577
579
  */
578
- declare function classifyAdapterOutcome(result: AdapterExecutionResult): AdapterOutcomeKind;
580
+ export declare function classifyAdapterOutcome(result: AdapterExecutionResult): AdapterOutcomeKind;
579
581
  /**
580
582
  * Determine whether an outcome kind is retryable. Only `transient_failure`
581
583
  * is retryable, and only when the adapter policy is idempotent. Permanent
582
584
  * failures, timeouts, and ambiguous outcomes are never retried.
583
585
  */
584
- declare function shouldRetryAdapterOutcome(kind: AdapterOutcomeKind, idempotent: boolean): boolean;
586
+ export declare function shouldRetryAdapterOutcome(kind: AdapterOutcomeKind, idempotent: boolean): boolean;
585
587
  /**
586
588
  * Reject a contradictory adapter result where `success` is true but the
587
589
  * explicit `outcome` is a non-success kind. A successful result claiming an
588
590
  * ambiguous, permanent, timeout, or transient outcome is a programming
589
591
  * error — the adapter cannot have both succeeded and require reconciliation.
590
592
  */
591
- declare function assertAdapterOutcomeConsistency(result: AdapterExecutionResult): void;
592
- declare function executeWithAdapterRetry<T>(options: ExecuteWithRetryOptions<T>): Promise<T>;
593
-
594
- export { type AcceptedExternalOperation, type AdapterAttempt, type AdapterCircuitAdmission, type AdapterCircuitBreaker, type AdapterCircuitBreakerConfig, type AdapterCircuitBreakerEvent, type AdapterCircuitBreakerEventListener, type AdapterCircuitBreakerEventReason, type AdapterCircuitBreakerManualOverride, type AdapterCircuitBreakerProvider, AdapterCircuitBreakerRegistry, type AdapterCircuitBreakerRegistryOptions, type AdapterCircuitBreakerScope, AdapterCircuitOpenError, type AdapterCircuitOutcome, type AdapterCircuitState, type AdapterExecutionContext, type AdapterExecutionResult, type AdapterExecutor, type AdapterImplementation, type AdapterOutcomeEvidence, type AdapterOutcomeKind, AdapterRegistry, type AdapterRetryPolicy, type ExecuteWithRetryOptions, InMemoryAdapterCircuitBreaker, type InMemoryAdapterCircuitBreakerOptions, MissingAdapterRegistrationError, type ResolvedAdapterRetryPolicy, assertAdapterCircuitBreakerConfig, assertAdapterOutcomeConsistency, classifyAdapterOutcome, classifyCircuitBreakerOutcome, executeWithAdapterRetry, getRetryDelayMs, isAdapterCircuitOpenError, resolveAdapterRetryPolicy, scopedAdapterCircuitBreakerKey, shouldRetryAdapterOutcome };
593
+ export declare function assertAdapterOutcomeConsistency(result: AdapterExecutionResult): void;
594
+ export declare function executeWithAdapterRetry<T>(options: ExecuteWithRetryOptions<T>): Promise<T>;
595
+ //#endregion
596
+ export {};