brass-runtime 1.16.0 → 1.17.0

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 (219) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +287 -23
  3. package/dist/agent/cli/main.cjs +38 -38
  4. package/dist/agent/cli/main.js +6 -6
  5. package/dist/agent/cli/main.mjs +6 -6
  6. package/dist/agent/index.cjs +7 -7
  7. package/dist/agent/index.d.ts +1 -1
  8. package/dist/agent/index.js +6 -6
  9. package/dist/agent/index.mjs +6 -6
  10. package/dist/chunk-2HQTDLHF.mjs +683 -0
  11. package/dist/chunk-36I3M4UC.mjs +370 -0
  12. package/dist/{chunk-QY5FKYEQ.js → chunk-3AYM6WPJ.js} +570 -51
  13. package/dist/chunk-3LOYJFRR.cjs +300 -0
  14. package/dist/chunk-3Y2RIUMM.js +300 -0
  15. package/dist/{chunk-7XOPAB5Q.js → chunk-4P2HHGAX.mjs} +83 -5
  16. package/dist/{chunk-N6VHMOWB.cjs → chunk-4ROBZFL6.cjs} +128 -128
  17. package/dist/{chunk-NC5SDRYE.js → chunk-52OB2ROS.js} +4 -4
  18. package/dist/{chunk-JX3LZQJH.cjs → chunk-52PPNNI4.cjs} +82 -20
  19. package/dist/{chunk-5YOQOXEQ.cjs → chunk-5EC274J5.cjs} +676 -293
  20. package/dist/chunk-5QC7LRZ3.js +229 -0
  21. package/dist/{chunk-7TL2LHQJ.js → chunk-5VRJNBLZ.mjs} +524 -141
  22. package/dist/chunk-62AZW6UT.cjs +313 -0
  23. package/dist/chunk-6IXXWIUM.js +683 -0
  24. package/dist/chunk-6RY2FFN4.mjs +2024 -0
  25. package/dist/chunk-74ZTY6CP.js +2871 -0
  26. package/dist/chunk-7CMJS3QE.mjs +2871 -0
  27. package/dist/{chunk-2WC63LJK.mjs → chunk-7JIJOVCT.js} +20 -10
  28. package/dist/chunk-7X3K5RMS.js +2024 -0
  29. package/dist/chunk-7ZPEZ57L.cjs +2024 -0
  30. package/dist/{chunk-FM4W4QPL.js → chunk-A2OM6NEH.mjs} +5 -4
  31. package/dist/chunk-AGR5B2BC.cjs +683 -0
  32. package/dist/chunk-B33ICAKP.js +313 -0
  33. package/dist/{chunk-J3H54ZRV.mjs → chunk-B5JD23U7.mjs} +1 -1
  34. package/dist/{chunk-F5EUMJL7.mjs → chunk-BKK77SBA.js} +83 -5
  35. package/dist/{chunk-U5KWK3PX.mjs → chunk-C3MDXTRZ.js} +11 -0
  36. package/dist/{chunk-SPUEME2B.cjs → chunk-CZIVE6NT.cjs} +12 -1
  37. package/dist/{chunk-TDVMADDN.js → chunk-DNFJLJMW.mjs} +11 -0
  38. package/dist/{chunk-XDZOO4L5.js → chunk-EJ6BPYVR.mjs} +79 -17
  39. package/dist/chunk-EOC4UHBS.mjs +229 -0
  40. package/dist/chunk-F6XWZQY4.cjs +777 -0
  41. package/dist/{chunk-7LVI2GIN.js → chunk-FH2X7BVP.js} +507 -72
  42. package/dist/{chunk-OOGJ73B6.js → chunk-FHQGHPMO.mjs} +20 -10
  43. package/dist/{chunk-WQ5QNU5R.cjs → chunk-GLE2WY7Z.cjs} +652 -217
  44. package/dist/{chunk-G6IQOE4P.mjs → chunk-GYM3LLGS.mjs} +507 -72
  45. package/dist/{chunk-TVN5I4U6.cjs → chunk-JF5WGYJJ.cjs} +25 -24
  46. package/dist/{chunk-CY33PGEX.mjs → chunk-KH4SYAOS.mjs} +570 -51
  47. package/dist/chunk-KN32XNTH.mjs +313 -0
  48. package/dist/chunk-KQLYONSE.cjs +2871 -0
  49. package/dist/{chunk-7HUOJA4W.cjs → chunk-KZJQ723N.cjs} +90 -80
  50. package/dist/{chunk-CCKHV5BT.mjs → chunk-L2SYFEBS.js} +5 -4
  51. package/dist/{chunk-IJT6RRQ5.cjs → chunk-L6VB5N7Q.cjs} +20 -9
  52. package/dist/{chunk-ZGLD4TVZ.mjs → chunk-MBEJI5HF.mjs} +4 -4
  53. package/dist/{chunk-PRWCB3QL.mjs → chunk-MIIYDLGM.js} +524 -141
  54. package/dist/{chunk-H55LI6WY.js → chunk-MOO4L7F4.mjs} +15 -4
  55. package/dist/chunk-MVGUEJ5Z.cjs +370 -0
  56. package/dist/chunk-PD4EJTQC.cjs +229 -0
  57. package/dist/chunk-PWC3RBQE.mjs +300 -0
  58. package/dist/{chunk-MWXMNYJS.cjs → chunk-Q2I37RP3.cjs} +643 -124
  59. package/dist/{chunk-VFIUZG7J.mjs → chunk-RKGKFN2A.js} +79 -17
  60. package/dist/{chunk-NYL4D7SK.cjs → chunk-SA6HUJVI.cjs} +5 -5
  61. package/dist/chunk-SK7UZRNI.mjs +777 -0
  62. package/dist/{chunk-K2T3DV26.mjs → chunk-TRM4JUZQ.js} +15 -4
  63. package/dist/chunk-UB4B6OFY.js +370 -0
  64. package/dist/{chunk-G3XGCZDQ.js → chunk-UCUBNWM2.js} +1 -1
  65. package/dist/chunk-VWIPB6I5.js +777 -0
  66. package/dist/{chunk-JNFRRJYH.cjs → chunk-WBGRHGBP.cjs} +270 -192
  67. package/dist/{client-CtFmoDvM.d.ts → client-CZHU674n.d.ts} +211 -36
  68. package/dist/core/index.cjs +135 -9
  69. package/dist/core/index.d.ts +238 -33
  70. package/dist/core/index.js +155 -29
  71. package/dist/core/index.mjs +155 -29
  72. package/dist/{effect-CGNl5Rqp.d.ts → effect-DIUHZ9IN.d.ts} +89 -1
  73. package/dist/effectRunner-CFLC32IK.cjs +8 -0
  74. package/dist/{effectRunner-A4CHJXJI.js → effectRunner-L4S7IPT3.js} +2 -2
  75. package/dist/{effectRunner-OPUF6QRN.mjs → effectRunner-NNGG75QA.mjs} +2 -2
  76. package/dist/http/index.cjs +324 -2986
  77. package/dist/http/index.d.ts +54 -68
  78. package/dist/http/index.js +238 -2900
  79. package/dist/http/index.mjs +238 -2900
  80. package/dist/http/testing.cjs +14 -12
  81. package/dist/http/testing.d.ts +5 -4
  82. package/dist/http/testing.js +10 -8
  83. package/dist/http/testing.mjs +10 -8
  84. package/dist/index.cjs +423 -255
  85. package/dist/index.d.ts +87 -69
  86. package/dist/index.js +301 -133
  87. package/dist/index.mjs +301 -133
  88. package/dist/observability/index.cjs +18 -531
  89. package/dist/observability/index.d.ts +81 -8
  90. package/dist/observability/index.js +25 -538
  91. package/dist/observability/index.mjs +25 -538
  92. package/dist/perf/cli.cjs +401 -0
  93. package/dist/perf/cli.d.ts +1 -0
  94. package/dist/perf/cli.js +401 -0
  95. package/dist/perf/cli.mjs +401 -0
  96. package/dist/perf/index.cjs +141 -0
  97. package/dist/perf/index.d.ts +483 -0
  98. package/dist/perf/index.js +141 -0
  99. package/dist/perf/index.mjs +141 -0
  100. package/dist/schedule-CK3Ml_7p.d.ts +259 -0
  101. package/dist/schema/index.cjs +6 -2
  102. package/dist/schema/index.d.ts +3 -1
  103. package/dist/schema/index.js +5 -1
  104. package/dist/schema/index.mjs +5 -1
  105. package/dist/{server-C8hDXA74.d.ts → server-D6JZ15_e.d.ts} +16 -4
  106. package/dist/{stream-dvSs0QS5.d.ts → stream-B4oK9JFP.d.ts} +1 -1
  107. package/dist/{tracer-B5tRH9H7.d.ts → tracer-Hwt1cl7h.d.ts} +13 -54
  108. package/dist/{tracing-Dt9S_6V8.d.ts → tracing-DqbTKGcf.d.ts} +1 -1
  109. package/docs/ARCHITECTURE.md +292 -0
  110. package/docs/README.md +65 -0
  111. package/docs/adr/0001-ai-context-pack.md +32 -0
  112. package/docs/agent-apply-mode.md +104 -0
  113. package/docs/agent-approvals.md +110 -0
  114. package/docs/agent-batch.md +185 -0
  115. package/docs/agent-boundaries.md +112 -0
  116. package/docs/agent-chat-sessions.md +160 -0
  117. package/docs/agent-ci.md +17 -0
  118. package/docs/agent-cli.md +405 -0
  119. package/docs/agent-config.md +480 -0
  120. package/docs/agent-context-discovery.md +159 -0
  121. package/docs/agent-copilot-like-dx.md +126 -0
  122. package/docs/agent-declarative-optimized-planning.md +138 -0
  123. package/docs/agent-dx.md +224 -0
  124. package/docs/agent-env-files.md +126 -0
  125. package/docs/agent-follow-up-context.md +43 -0
  126. package/docs/agent-global-usage.md +180 -0
  127. package/docs/agent-init.md +109 -0
  128. package/docs/agent-install-and-configure.md +516 -0
  129. package/docs/agent-language-workspace-ux.md +99 -0
  130. package/docs/agent-llm-adapters.md +123 -0
  131. package/docs/agent-local-install.md +190 -0
  132. package/docs/agent-local-tests.md +51 -0
  133. package/docs/agent-observability.md +155 -0
  134. package/docs/agent-patch-quality-loop.md +162 -0
  135. package/docs/agent-presets.md +22 -0
  136. package/docs/agent-project-commands.md +237 -0
  137. package/docs/agent-project-intelligence.md +156 -0
  138. package/docs/agent-redaction.md +18 -0
  139. package/docs/agent-release-readiness.md +76 -0
  140. package/docs/agent-rollback-safety.md +162 -0
  141. package/docs/agent-rollback.md +23 -0
  142. package/docs/agent-run-artifacts.md +16 -0
  143. package/docs/agent-vscode-auto-discovery.md +137 -0
  144. package/docs/agent-vscode-batch-runner.md +100 -0
  145. package/docs/agent-vscode-chat-layout.md +90 -0
  146. package/docs/agent-vscode-clean-install.md +147 -0
  147. package/docs/agent-vscode-code-actions.md +70 -0
  148. package/docs/agent-vscode-diff-preview.md +45 -0
  149. package/docs/agent-vscode-inline-assist.md +56 -0
  150. package/docs/agent-vscode-install.md +186 -0
  151. package/docs/agent-vscode-model-setup.md +97 -0
  152. package/docs/agent-vscode-patch-preview.md +92 -0
  153. package/docs/agent-vscode-problems.md +79 -0
  154. package/docs/agent-vscode-project-dashboard.md +106 -0
  155. package/docs/agent-vscode-run-history.md +92 -0
  156. package/docs/agent-vscode-ux.md +73 -0
  157. package/docs/ai/INVARIANTS.md +84 -0
  158. package/docs/ai/PROJECT_MAP.md +338 -0
  159. package/docs/ai/PUBLIC_API.md +339 -0
  160. package/docs/ai/VALIDATION_MATRIX.md +67 -0
  161. package/docs/api-polish.md +37 -0
  162. package/docs/cancellation.md +162 -0
  163. package/docs/coverage.md +46 -0
  164. package/docs/framework-integrations.md +38 -0
  165. package/docs/frameworks/angular.md +153 -0
  166. package/docs/frameworks/express.md +125 -0
  167. package/docs/frameworks/fastify.md +124 -0
  168. package/docs/frameworks/nestjs.md +282 -0
  169. package/docs/frameworks/nextjs.md +147 -0
  170. package/docs/frameworks/react.md +139 -0
  171. package/docs/frameworks/vanilla.md +224 -0
  172. package/docs/getting-started.md +159 -0
  173. package/docs/guides/README.md +40 -0
  174. package/docs/guides/circuit-breaker.md +89 -0
  175. package/docs/guides/error-handling.md +91 -0
  176. package/docs/guides/getting-started.md +107 -0
  177. package/docs/guides/layers.md +189 -0
  178. package/docs/guides/metrics.md +101 -0
  179. package/docs/guides/resource-management.md +141 -0
  180. package/docs/guides/retry.md +215 -0
  181. package/docs/guides/semaphore.md +66 -0
  182. package/docs/guides/streams.md +117 -0
  183. package/docs/guides/supervisors.md +98 -0
  184. package/docs/guides/testing.md +162 -0
  185. package/docs/guides/tracing.md +71 -0
  186. package/docs/http-recipes.md +399 -0
  187. package/docs/http.md +749 -0
  188. package/docs/modules.md +285 -0
  189. package/docs/nestjs.md +6 -0
  190. package/docs/observability-collector-smoke.md +31 -0
  191. package/docs/observability-framework-examples.md +110 -0
  192. package/docs/observability.md +649 -0
  193. package/docs/otel-collector-smoke.yaml +27 -0
  194. package/docs/performance-profiler.md +199 -0
  195. package/docs/production-readiness.md +73 -0
  196. package/docs/recipes/README.md +12 -0
  197. package/docs/recipes/http-server.md +45 -0
  198. package/docs/recipes/layers.md +44 -0
  199. package/docs/recipes/performance.md +47 -0
  200. package/docs/recipes/runtime.md +41 -0
  201. package/docs/recipes/testing.md +41 -0
  202. package/docs/release.md +53 -0
  203. package/docs/wasm-bounded-queues.md +44 -0
  204. package/docs/wasm-engine-observability-benchmarks.md +85 -0
  205. package/docs/wasm-fiber-engine.md +117 -0
  206. package/docs/wasm-scheduler-state-machine.md +122 -0
  207. package/docs/wasm-stream-chunks.md +54 -0
  208. package/package.json +22 -2
  209. package/dist/chunk-45F7OKGT.cjs +0 -104
  210. package/dist/chunk-7V4KY4RL.mjs +0 -104
  211. package/dist/chunk-DJQ7OMMB.cjs +0 -144
  212. package/dist/chunk-GOV47PPB.mjs +0 -552
  213. package/dist/chunk-JF4XXPZ5.cjs +0 -552
  214. package/dist/chunk-KCPT2D6G.js +0 -552
  215. package/dist/chunk-NOYZIMUJ.mjs +0 -144
  216. package/dist/chunk-PNVFW245.js +0 -144
  217. package/dist/chunk-ROJC3NBJ.js +0 -104
  218. package/dist/effectRunner-3ZHAD3LE.cjs +0 -8
  219. package/dist/schedule-Fque9Abz.d.ts +0 -70
@@ -0,0 +1,141 @@
1
+ import {
2
+ HTTP_PROFILE_VARIANTS,
3
+ captureMemorySnapshot,
4
+ comparePerfToBaseline,
5
+ compareRuntimeProfiles,
6
+ createPerfHistoryEntry,
7
+ defaultPerfHistoryDirectory,
8
+ diagnoseRuntimeProfile,
9
+ diffMemorySnapshots,
10
+ extractPerfMetrics,
11
+ forceGc,
12
+ formatHttpMemoryLabReport,
13
+ formatPerfBaselineComparison,
14
+ formatPerformanceReport,
15
+ formatRuntimeAbReport,
16
+ formatRuntimeSoakReport,
17
+ hasGc,
18
+ loadPerfBaseline,
19
+ makePerfRecorder,
20
+ profileHttpLayers,
21
+ profileHttpMemoryLab,
22
+ profileMemoryRetention,
23
+ profileRuntimeAb,
24
+ profileRuntimePrimitives,
25
+ profileRuntimeSoak,
26
+ readPerfHistory,
27
+ recommendPerformance,
28
+ recordPerfHistoryRun,
29
+ runBrassPerformanceProfile,
30
+ savePerfBaseline,
31
+ summarizePerfEvents,
32
+ writePerfHistoryEntry
33
+ } from "../chunk-6RY2FFN4.mjs";
34
+ import "../chunk-EOC4UHBS.mjs";
35
+ import "../chunk-7CMJS3QE.mjs";
36
+ import "../chunk-5VRJNBLZ.mjs";
37
+ import "../chunk-MOO4L7F4.mjs";
38
+ import "../chunk-FHQGHPMO.mjs";
39
+ import "../chunk-B5JD23U7.mjs";
40
+ import "../chunk-2HQTDLHF.mjs";
41
+ import "../chunk-A2OM6NEH.mjs";
42
+ import "../chunk-SK7UZRNI.mjs";
43
+ import "../chunk-4P2HHGAX.mjs";
44
+ import "../chunk-EJ6BPYVR.mjs";
45
+ import "../chunk-PWC3RBQE.mjs";
46
+ import "../chunk-GYM3LLGS.mjs";
47
+ import "../chunk-36I3M4UC.mjs";
48
+ import "../chunk-DNFJLJMW.mjs";
49
+ import "../chunk-Y6FXYEAI.mjs";
50
+
51
+ // src/perf/budget.ts
52
+ async function runRuntimePerfBudget(options = {}) {
53
+ const ab = await profileRuntimeAb({
54
+ ...options,
55
+ thresholds: {
56
+ maxRegressionPercent: options.thresholds?.maxRegressionPercent ?? 50,
57
+ minSignificantDeltaPercent: options.thresholds?.minSignificantDeltaPercent ?? 5
58
+ }
59
+ });
60
+ const minOpsPerSecond = positiveNumber(options.minOpsPerSecond, 1e4);
61
+ const maxHeapDeltaMb = positiveNumber(options.maxHeapDeltaMb, 32);
62
+ const violations = [];
63
+ for (const violation of ab.budgetViolations) {
64
+ violations.push({ area: "regression", message: violation });
65
+ }
66
+ for (const result of ab.candidate.results) {
67
+ if (result.units >= 1e3 && result.operationsPerSecond < minOpsPerSecond) {
68
+ violations.push({
69
+ area: "throughput",
70
+ message: `${result.name} throughput ${result.operationsPerSecond} ops/s is below ${minOpsPerSecond} ops/s`
71
+ });
72
+ }
73
+ }
74
+ if (ab.memory.delta.heapUsedMb > maxHeapDeltaMb) {
75
+ violations.push({
76
+ area: "memory",
77
+ message: `runtime A/B heap delta ${ab.memory.delta.heapUsedMb}MB exceeds ${maxHeapDeltaMb}MB`
78
+ });
79
+ }
80
+ return Object.freeze({
81
+ ab,
82
+ passed: violations.length === 0,
83
+ violations: Object.freeze(violations.map((item) => Object.freeze(item)))
84
+ });
85
+ }
86
+ function formatRuntimePerfBudgetReport(report) {
87
+ const lines = [];
88
+ lines.push(`Runtime performance budget: ${report.passed ? "pass" : "fail"}`);
89
+ lines.push(`baseline=${report.ab.baselineVariant} candidate=${report.ab.candidateVariant}`);
90
+ for (const comparison of report.ab.comparisons) {
91
+ const sign = comparison.deltaPercent >= 0 ? "+" : "";
92
+ lines.push(`- ${comparison.primitive}: ${sign}${comparison.deltaPercent}%`);
93
+ }
94
+ if (report.violations.length > 0) {
95
+ lines.push("");
96
+ lines.push("Violations");
97
+ for (const violation of report.violations) {
98
+ lines.push(`- [${violation.area}] ${violation.message}`);
99
+ }
100
+ }
101
+ return lines.join("\n");
102
+ }
103
+ function positiveNumber(value, fallback) {
104
+ if (value === void 0 || !Number.isFinite(value)) return fallback;
105
+ return Math.max(0, value);
106
+ }
107
+ export {
108
+ HTTP_PROFILE_VARIANTS,
109
+ captureMemorySnapshot,
110
+ comparePerfToBaseline,
111
+ compareRuntimeProfiles,
112
+ createPerfHistoryEntry,
113
+ defaultPerfHistoryDirectory,
114
+ diagnoseRuntimeProfile,
115
+ diffMemorySnapshots,
116
+ extractPerfMetrics,
117
+ forceGc,
118
+ formatHttpMemoryLabReport,
119
+ formatPerfBaselineComparison,
120
+ formatPerformanceReport,
121
+ formatRuntimeAbReport,
122
+ formatRuntimePerfBudgetReport,
123
+ formatRuntimeSoakReport,
124
+ hasGc,
125
+ loadPerfBaseline,
126
+ makePerfRecorder,
127
+ profileHttpLayers,
128
+ profileHttpMemoryLab,
129
+ profileMemoryRetention,
130
+ profileRuntimeAb,
131
+ profileRuntimePrimitives,
132
+ profileRuntimeSoak,
133
+ readPerfHistory,
134
+ recommendPerformance,
135
+ recordPerfHistoryRun,
136
+ runBrassPerformanceProfile,
137
+ runRuntimePerfBudget,
138
+ savePerfBaseline,
139
+ summarizePerfEvents,
140
+ writePerfHistoryEntry
141
+ };
@@ -0,0 +1,259 @@
1
+ import { A as Async, R as RuntimeHooks, a as RuntimeEmitContext } from './effect-DIUHZ9IN.js';
2
+
3
+ type CircuitBreakerState = "closed" | "open" | "half-open";
4
+ type CircuitBreakerError = {
5
+ readonly _tag: "CircuitBreakerOpen";
6
+ readonly openSince: number;
7
+ readonly failures: number;
8
+ };
9
+ type CircuitBreakerConfig = {
10
+ /** Number of consecutive failures before opening the circuit. Default: 5 */
11
+ readonly failureThreshold?: number;
12
+ /** Time in ms to wait before transitioning from OPEN to HALF_OPEN. Default: 30000 */
13
+ readonly resetTimeoutMs?: number;
14
+ /** Number of successes in HALF_OPEN needed to close the circuit. Default: 1 */
15
+ readonly successThreshold?: number;
16
+ /** Custom predicate: should this error count as a failure? Default: all errors count. */
17
+ readonly isFailure?: (error: unknown) => boolean;
18
+ /** Called on state transitions (for observability). */
19
+ readonly onStateChange?: (from: CircuitBreakerState, to: CircuitBreakerState) => void;
20
+ };
21
+ type CircuitBreakerStats = {
22
+ readonly state: CircuitBreakerState;
23
+ readonly failures: number;
24
+ readonly successes: number;
25
+ readonly totalRequests: number;
26
+ readonly totalFailures: number;
27
+ readonly totalSuccesses: number;
28
+ readonly totalRejected: number;
29
+ readonly lastFailureTime: number | null;
30
+ readonly lastSuccessTime: number | null;
31
+ };
32
+ type CircuitBreaker = {
33
+ /** Current state of the circuit breaker. */
34
+ readonly state: () => CircuitBreakerState;
35
+ /** Run an effect through the circuit breaker. */
36
+ readonly protect: <R, E, A>(effect: Async<R, E, A>) => Async<R, E | CircuitBreakerError, A>;
37
+ /** Get current stats. */
38
+ readonly stats: () => CircuitBreakerStats;
39
+ /** Manually reset to closed state. */
40
+ readonly reset: () => void;
41
+ };
42
+ /**
43
+ * Creates a circuit breaker.
44
+ *
45
+ * ```ts
46
+ * const breaker = makeCircuitBreaker({ failureThreshold: 3, resetTimeoutMs: 10000 });
47
+ *
48
+ * // Protect an effect:
49
+ * const result = await run(breaker.protect(callExternalService()));
50
+ * // Throws CircuitBreakerOpen if circuit is open
51
+ * ```
52
+ */
53
+ declare function makeCircuitBreaker(config?: CircuitBreakerConfig): CircuitBreaker;
54
+
55
+ type RuntimeTimerId = unknown;
56
+ type RuntimeClock = {
57
+ readonly now: () => number;
58
+ readonly setTimeout: (task: () => void, ms: number) => RuntimeTimerId;
59
+ readonly clearTimeout: (timer: RuntimeTimerId) => void;
60
+ };
61
+ type RuntimeClockEnv = {
62
+ readonly brass?: {
63
+ readonly clock?: RuntimeClock;
64
+ };
65
+ };
66
+ declare const liveClock: RuntimeClock;
67
+ declare function runtimeClockFromEnv(env: unknown): RuntimeClock;
68
+
69
+ type ScheduleDecision = {
70
+ readonly continue: boolean;
71
+ readonly delayMs: number;
72
+ readonly attempt?: number;
73
+ readonly elapsedMs?: number;
74
+ readonly reason?: string;
75
+ readonly name?: string;
76
+ };
77
+ type ScheduleJitterOptions = {
78
+ /** 1 means full jitter in [0, delay], 0.2 means +/-20% around delay. */
79
+ readonly factor?: number;
80
+ /** Deterministic hook for tests. Defaults to Math.random. */
81
+ readonly random?: () => number;
82
+ };
83
+ type ScheduleStepContext = {
84
+ readonly clock: RuntimeClock;
85
+ readonly startedAtMs: number;
86
+ readonly attempt: number;
87
+ readonly name?: string;
88
+ };
89
+ type ScheduleObserverEvent<I, O> = {
90
+ readonly name?: string;
91
+ readonly input: I;
92
+ readonly output: O;
93
+ readonly decision: ScheduleDecision;
94
+ readonly attempt: number;
95
+ readonly elapsedMs: number;
96
+ readonly state: unknown;
97
+ readonly nextState: unknown;
98
+ readonly timestamp: number;
99
+ };
100
+ type ScheduleObserver<I, O> = (event: ScheduleObserverEvent<I, O>) => void;
101
+ type ScheduleDriverDecision<O> = {
102
+ readonly continue: boolean;
103
+ readonly delayMs: number;
104
+ readonly output: O;
105
+ readonly decision: ScheduleDecision;
106
+ readonly attempt: number;
107
+ readonly elapsedMs: number;
108
+ readonly state: unknown;
109
+ };
110
+ type ScheduleDriverSnapshot<O = unknown> = {
111
+ readonly name?: string;
112
+ readonly attempt: number;
113
+ readonly elapsedMs: number;
114
+ readonly state: unknown;
115
+ readonly last?: ScheduleDriverDecision<O>;
116
+ };
117
+ type ScheduleDriverOptions<I = unknown, O = unknown> = {
118
+ readonly name?: string;
119
+ readonly clock?: RuntimeClock;
120
+ readonly startedAtMs?: number;
121
+ readonly onDecision?: ScheduleObserver<I, O>;
122
+ readonly hooks?: RuntimeHooks;
123
+ readonly emitContext?: RuntimeEmitContext;
124
+ readonly captureInput?: boolean;
125
+ readonly captureOutput?: boolean;
126
+ };
127
+ type ScheduleDriver<I, O> = {
128
+ readonly next: (input: I) => ScheduleDriverDecision<O>;
129
+ readonly reset: () => void;
130
+ readonly snapshot: () => ScheduleDriverSnapshot<O>;
131
+ readonly state: () => unknown;
132
+ readonly last: () => ScheduleDriverDecision<O> | undefined;
133
+ };
134
+ /** Retry/repeat up to N times with no delay. */
135
+ declare function recurs(n: number): Schedule<unknown, number>;
136
+ /** Continue forever with no delay. */
137
+ declare function forever(): Schedule<unknown, number>;
138
+ /** Never continue. */
139
+ declare function never(): Schedule<unknown, number>;
140
+ /** Continue exactly once. */
141
+ declare function once(): Schedule<unknown, number>;
142
+ /** Fixed delay between each retry/repeat. */
143
+ declare function fixed(delayMs: number): Schedule<unknown, number>;
144
+ /** Alias for fixed delay schedules. */
145
+ declare const spaced: typeof fixed;
146
+ /** Exponential backoff: delay doubles each time, capped at maxDelayMs. */
147
+ declare function exponential(baseMs: number, maxMs?: number): Schedule<unknown, number>;
148
+ /** Linear backoff: base, 2*base, 3*base... capped at maxDelayMs. */
149
+ declare function linear(baseMs: number, maxMs?: number): Schedule<unknown, number>;
150
+ /** Fibonacci backoff: base, base, 2*base, 3*base, 5*base, capped at maxDelayMs. */
151
+ declare function fibonacci(baseMs: number, maxMs?: number): Schedule<unknown, number>;
152
+ /** Exponential backoff with full jitter (random in [0, delay]). */
153
+ declare function jittered(baseMs: number, maxMs?: number): Schedule<unknown, number>;
154
+ /** Stop after a total elapsed time. */
155
+ declare function elapsed(maxMs: number): Schedule<unknown, number>;
156
+ /** Only continue while a predicate holds on the input. */
157
+ declare function whileInput<I>(pred: (input: I) => boolean): Schedule<I, I>;
158
+ /** Continue until the input predicate becomes true. */
159
+ declare function untilInput<I>(pred: (input: I) => boolean): Schedule<I, I>;
160
+ /** Limit a schedule to N repetitions. */
161
+ declare function take<I, O>(schedule: Schedule<I, O>, n: number): Schedule<I, O>;
162
+ /** Transform schedule output while preserving decisions and state. */
163
+ declare function map<I, O, O2>(schedule: Schedule<I, O>, f: (output: O) => O2): Schedule<I, O2>;
164
+ /** Transform schedule input before it reaches the wrapped schedule. */
165
+ declare function contramap<I0, I, O>(schedule: Schedule<I, O>, f: (input: I0) => I): Schedule<I0, O>;
166
+ /** Add jitter to any schedule's delay. */
167
+ declare function jitteredSchedule<I, O>(schedule: Schedule<I, O>, options?: number | ScheduleJitterOptions): Schedule<I, O>;
168
+ declare const jitter: typeof jitteredSchedule;
169
+ /**
170
+ * Reset a schedule's internal state after a rolling time window.
171
+ * Useful for retry/polling policies that should forgive old bursts.
172
+ */
173
+ declare function windowed<I, O>(schedule: Schedule<I, O>, windowMs: number, clock?: () => number): Schedule<I, O>;
174
+ /** Cap a schedule's delay without changing its state or output. */
175
+ declare function maxDelay<I, O>(schedule: Schedule<I, O>, maxMs: number): Schedule<I, O>;
176
+ /** Stop a schedule after a total elapsed runtime-clock budget. */
177
+ declare function maxElapsed<I, O>(schedule: Schedule<I, O>, maxMs: number): Schedule<I, O>;
178
+ declare const upTo: typeof maxElapsed;
179
+ /** Continue while a predicate holds on the wrapped schedule output. */
180
+ declare function whileOutput<I, O>(schedule: Schedule<I, O>, pred: (output: O) => boolean): Schedule<I, O>;
181
+ /** Continue until a predicate holds on the wrapped schedule output. */
182
+ declare function untilOutput<I, O>(schedule: Schedule<I, O>, pred: (output: O) => boolean): Schedule<I, O>;
183
+ /** Attach an observability name to a schedule. */
184
+ declare function named<I, O>(name: string, schedule: Schedule<I, O>): Schedule<I, O>;
185
+ /** Observe each schedule decision without changing semantics. */
186
+ declare function tapDecision<I, O>(schedule: Schedule<I, O>, tap: ScheduleObserver<I, O>): Schedule<I, O>;
187
+ /** Compose two schedules: use the first, then switch to the second. */
188
+ declare function andThen<I, O1, O2>(first: Schedule<I, O1>, second: Schedule<I, O2>): Schedule<I, O1 | O2>;
189
+ /** Run both schedules and continue while BOTH say continue. Use max delay. */
190
+ declare function intersect<I, O1, O2>(left: Schedule<I, O1>, right: Schedule<I, O2>): Schedule<I, [O1, O2]>;
191
+ /** Run both schedules and continue while EITHER says continue. Use min delay. */
192
+ declare function union<I, O1, O2>(left: Schedule<I, O1>, right: Schedule<I, O2>): Schedule<I, [O1, O2]>;
193
+ declare function makeScheduleDriver<I, O>(schedule: Schedule<I, O>, options?: ScheduleDriverOptions<I, O>): ScheduleDriver<I, O>;
194
+ declare const scheduleDriver: typeof makeScheduleDriver;
195
+ declare function runSchedule<I, O>(schedule: Schedule<I, O>, inputs: Iterable<I>, options?: ScheduleDriverOptions<I, O>): ScheduleDriverDecision<O>[];
196
+ /**
197
+ * Retry an effect according to a schedule.
198
+ * The schedule receives the error as input on each failure.
199
+ */
200
+ declare function retryWithSchedule<R, E, A, O>(effect: Async<R, E, A>, schedule: Schedule<E, O>, options?: ScheduleDriverOptions<E, O>): Async<R, E, A>;
201
+ declare const retry: typeof retryWithSchedule;
202
+ /**
203
+ * Repeat an effect according to a schedule.
204
+ * The schedule receives the success value as input on each iteration.
205
+ * Returns the last successful value.
206
+ */
207
+ declare function repeatWithSchedule<R, E, A, O>(effect: Async<R, E, A>, schedule: Schedule<A, O>, options?: ScheduleDriverOptions<A, O>): Async<R, E, A>;
208
+ declare const repeat: typeof repeatWithSchedule;
209
+ declare const poll: typeof repeatWithSchedule;
210
+ /**
211
+ * A Schedule<I, O> takes an input I (typically the error or output of an effect)
212
+ * and decides whether to continue and with what delay.
213
+ */
214
+ type Schedule<I, O> = {
215
+ readonly _tag: "Schedule";
216
+ readonly name?: string;
217
+ /** Initial state */
218
+ readonly initial: (context?: ScheduleStepContext) => any;
219
+ /** Given current state and input, produce a decision and next state */
220
+ readonly step: (state: any, input: I, context?: ScheduleStepContext) => [ScheduleDecision, any, O];
221
+ };
222
+ declare const Schedule: Readonly<{
223
+ driver: typeof makeScheduleDriver;
224
+ run: typeof runSchedule;
225
+ recurs: typeof recurs;
226
+ forever: typeof forever;
227
+ never: typeof never;
228
+ once: typeof once;
229
+ fixed: typeof fixed;
230
+ spaced: typeof fixed;
231
+ linear: typeof linear;
232
+ exponential: typeof exponential;
233
+ fibonacci: typeof fibonacci;
234
+ jittered: typeof jittered;
235
+ jitteredSchedule: typeof jitteredSchedule;
236
+ jitter: typeof jitteredSchedule;
237
+ elapsed: typeof elapsed;
238
+ whileInput: typeof whileInput;
239
+ untilInput: typeof untilInput;
240
+ whileOutput: typeof whileOutput;
241
+ untilOutput: typeof untilOutput;
242
+ take: typeof take;
243
+ map: typeof map;
244
+ contramap: typeof contramap;
245
+ maxDelay: typeof maxDelay;
246
+ maxElapsed: typeof maxElapsed;
247
+ upTo: typeof maxElapsed;
248
+ windowed: typeof windowed;
249
+ named: typeof named;
250
+ tapDecision: typeof tapDecision;
251
+ andThen: typeof andThen;
252
+ intersect: typeof intersect;
253
+ union: typeof union;
254
+ retry: typeof retryWithSchedule;
255
+ repeat: typeof repeatWithSchedule;
256
+ poll: typeof repeatWithSchedule;
257
+ }>;
258
+
259
+ export { upTo as $, liveClock as A, makeCircuitBreaker as B, type CircuitBreakerError as C, makeScheduleDriver as D, map as E, maxDelay as F, maxElapsed as G, named as H, never as I, once as J, poll as K, recurs as L, repeatWithSchedule as M, repeat as N, retryWithSchedule as O, retry as P, runSchedule as Q, type RuntimeClock as R, Schedule as S, runtimeClockFromEnv as T, scheduleDriver as U, spaced as V, take as W, tapDecision as X, union as Y, untilInput as Z, untilOutput as _, type ScheduleObserver as a, whileInput as a0, whileOutput as a1, windowed as a2, type CircuitBreakerStats as b, type CircuitBreaker as c, type CircuitBreakerConfig as d, type CircuitBreakerState as e, type RuntimeClockEnv as f, type RuntimeTimerId as g, type ScheduleDecision as h, type ScheduleDriver as i, type ScheduleDriverDecision as j, type ScheduleDriverOptions as k, type ScheduleDriverSnapshot as l, type ScheduleObserverEvent as m, type ScheduleStepContext as n, andThen as o, contramap as p, elapsed as q, exponential as r, fibonacci as s, fixed as t, forever as u, intersect as v, jitter as w, jittered as x, jitteredSchedule as y, linear as z };
@@ -9,7 +9,9 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkSPUEME2Bcjs = require('../chunk-SPUEME2B.cjs');
12
+
13
+
14
+ var _chunkCZIVE6NTcjs = require('../chunk-CZIVE6NT.cjs');
13
15
  require('../chunk-OBGZSXTJ.cjs');
14
16
 
15
17
 
@@ -22,4 +24,6 @@ require('../chunk-OBGZSXTJ.cjs');
22
24
 
23
25
 
24
26
 
25
- exports.ConfigValidationError = _chunkSPUEME2Bcjs.ConfigValidationError; exports.Schema = _chunkSPUEME2Bcjs.Schema; exports.SchemaValidationException = _chunkSPUEME2Bcjs.SchemaValidationException; exports.formatIssues = _chunkSPUEME2Bcjs.formatIssues; exports.isSchema = _chunkSPUEME2Bcjs.isSchema; exports.makeSchemaIssue = _chunkSPUEME2Bcjs.makeSchemaIssue; exports.parseConfig = _chunkSPUEME2Bcjs.parseConfig; exports.s = _chunkSPUEME2Bcjs.s; exports.schema = _chunkSPUEME2Bcjs.schema; exports.validateValue = _chunkSPUEME2Bcjs.validateValue;
27
+
28
+
29
+ exports.ConfigValidationError = _chunkCZIVE6NTcjs.ConfigValidationError; exports.Schema = _chunkCZIVE6NTcjs.Schema; exports.SchemaValidationException = _chunkCZIVE6NTcjs.SchemaValidationException; exports.formatConfigError = _chunkCZIVE6NTcjs.formatConfigError; exports.formatIssues = _chunkCZIVE6NTcjs.formatIssues; exports.isConfigValidationError = _chunkCZIVE6NTcjs.isConfigValidationError; exports.isSchema = _chunkCZIVE6NTcjs.isSchema; exports.makeSchemaIssue = _chunkCZIVE6NTcjs.makeSchemaIssue; exports.parseConfig = _chunkCZIVE6NTcjs.parseConfig; exports.s = _chunkCZIVE6NTcjs.s; exports.schema = _chunkCZIVE6NTcjs.schema; exports.validateValue = _chunkCZIVE6NTcjs.validateValue;
@@ -66,6 +66,8 @@ declare class ConfigValidationError extends Error {
66
66
  readonly issues: readonly SchemaIssue[];
67
67
  constructor(configName: string, issues: readonly SchemaIssue[]);
68
68
  }
69
+ declare function isConfigValidationError(error: unknown): error is ConfigValidationError;
70
+ declare function formatConfigError(error: unknown): string;
69
71
  declare const makeSchemaIssue: (path: readonly SchemaPathPart[], expected: string, received: unknown, message?: string) => SchemaIssue;
70
72
  declare function formatIssues(issues: readonly SchemaIssue[]): string;
71
73
  declare function stringSchema(options?: StringSchemaOptions): Schema<string>;
@@ -174,4 +176,4 @@ declare function isSchema(value: unknown): value is AnySchema;
174
176
  declare function validateValue<A>(data: unknown, validator: JsonSchemaLike<A>): SchemaResult<A>;
175
177
  declare function parseConfig<A>(configName: string, validator: JsonSchemaLike<A>, value: unknown): A;
176
178
 
177
- export { type AnyJsonSchemaLike, type AnySchema, ConfigValidationError, type InferJsonSchema, type InferObject, type InferSchema, type JsonSchemaLike, type JsonValidator, type JsonValidatorResult, type NumberSchemaOptions, type ObjectSchemaOptions, Schema, type SchemaIssue, type SchemaPathPart, type SchemaResult, type SchemaShape, SchemaValidationException, type StringSchemaOptions, formatIssues, isSchema, makeSchemaIssue, parseConfig, s, schema, validateValue };
179
+ export { type AnyJsonSchemaLike, type AnySchema, ConfigValidationError, type InferJsonSchema, type InferObject, type InferSchema, type JsonSchemaLike, type JsonValidator, type JsonValidatorResult, type NumberSchemaOptions, type ObjectSchemaOptions, Schema, type SchemaIssue, type SchemaPathPart, type SchemaResult, type SchemaShape, SchemaValidationException, type StringSchemaOptions, formatConfigError, formatIssues, isConfigValidationError, isSchema, makeSchemaIssue, parseConfig, s, schema, validateValue };
@@ -2,20 +2,24 @@ import {
2
2
  ConfigValidationError,
3
3
  Schema,
4
4
  SchemaValidationException,
5
+ formatConfigError,
5
6
  formatIssues,
7
+ isConfigValidationError,
6
8
  isSchema,
7
9
  makeSchemaIssue,
8
10
  parseConfig,
9
11
  s,
10
12
  schema,
11
13
  validateValue
12
- } from "../chunk-TDVMADDN.js";
14
+ } from "../chunk-C3MDXTRZ.js";
13
15
  import "../chunk-3RG5ZIWI.js";
14
16
  export {
15
17
  ConfigValidationError,
16
18
  Schema,
17
19
  SchemaValidationException,
20
+ formatConfigError,
18
21
  formatIssues,
22
+ isConfigValidationError,
19
23
  isSchema,
20
24
  makeSchemaIssue,
21
25
  parseConfig,
@@ -2,20 +2,24 @@ import {
2
2
  ConfigValidationError,
3
3
  Schema,
4
4
  SchemaValidationException,
5
+ formatConfigError,
5
6
  formatIssues,
7
+ isConfigValidationError,
6
8
  isSchema,
7
9
  makeSchemaIssue,
8
10
  parseConfig,
9
11
  s,
10
12
  schema,
11
13
  validateValue
12
- } from "../chunk-U5KWK3PX.mjs";
14
+ } from "../chunk-DNFJLJMW.mjs";
13
15
  import "../chunk-Y6FXYEAI.mjs";
14
16
  export {
15
17
  ConfigValidationError,
16
18
  Schema,
17
19
  SchemaValidationException,
20
+ formatConfigError,
18
21
  formatIssues,
22
+ isConfigValidationError,
19
23
  isSchema,
20
24
  makeSchemaIssue,
21
25
  parseConfig,
@@ -1,6 +1,7 @@
1
- import { a as MetricExemplar, b as MetricSnapshot, M as MetricsRegistry, T as TraceSampler, c as TraceSamplingInput, C as CircuitBreakerStats, E as EventBus, B as BrassEnv, I as InMemoryTracer, d as Tracer, R as RuntimeSpan, e as InMemoryTracerOptions } from './tracer-B5tRH9H7.js';
2
- import { T as TraceContext, R as RuntimeHooks, A as Async, J as JSONValue, B as Baggage, f as Runtime, g as RuntimeRegistry, h as RuntimeOptions } from './effect-CGNl5Rqp.js';
3
- import { A as AdaptiveLimiterStats } from './client-CtFmoDvM.js';
1
+ import { a as MetricExemplar, b as MetricSnapshot, M as MetricsRegistry, T as TraceSampler, c as TraceSamplingInput, E as EventBus, B as BrassEnv, I as InMemoryTracer, d as Tracer, R as RuntimeSpan, e as InMemoryTracerOptions } from './tracer-Hwt1cl7h.js';
2
+ import { T as TraceContext, R as RuntimeHooks, A as Async, J as JSONValue, B as Baggage, f as Runtime, g as RuntimeRegistry, h as RuntimeOptions } from './effect-DIUHZ9IN.js';
3
+ import { b as CircuitBreakerStats } from './schedule-CK3Ml_7p.js';
4
+ import { A as AdaptiveLimiterStats } from './client-CZHU674n.js';
4
5
 
5
6
  declare const PROMETHEUS_CONTENT_TYPE = "text/plain; version=0.0.4; charset=utf-8";
6
7
  declare const OTLP_JSON_CONTENT_TYPE = "application/json";
@@ -411,6 +412,17 @@ type ObservabilityOtlpOptions = {
411
412
  readonly retry?: ExportRetryOptions;
412
413
  readonly pipeline?: ExportPipelineTuning;
413
414
  };
415
+ type ObservabilityOtlpSignal = "metrics" | "traces" | "logs";
416
+ type MakeOtlpOptionsInput = {
417
+ readonly endpoint: string;
418
+ readonly headers?: ObservabilityOtlpOptions["headers"];
419
+ readonly fetch?: ObservabilityOtlpOptions["fetch"];
420
+ readonly timeoutMs?: ObservabilityOtlpOptions["timeoutMs"];
421
+ readonly retry?: ObservabilityOtlpOptions["retry"];
422
+ readonly pipeline?: ObservabilityOtlpOptions["pipeline"];
423
+ readonly signals?: readonly ObservabilityOtlpSignal[];
424
+ };
425
+ declare function makeOtlpOptions(input: MakeOtlpOptionsInput): ObservabilityOtlpOptions;
414
426
  type ObservabilityOptions = {
415
427
  readonly serviceName?: string;
416
428
  readonly serviceVersion?: string;
@@ -671,4 +683,4 @@ type ObservedHttpServerResult<A> = {
671
683
  declare function runObservedHttpServerEffect<R extends object = {}, E = never, A = never>(observability: Observability, input: RequestObservabilityContextInput, effect: Async<R, E, A>, options?: HttpServerObservabilityOptions<A>, env?: R, runtimeOptions?: RequestObservabilityRuntimeOptions<R>): Promise<ObservedHttpServerResult<A>>;
672
684
  declare function observeHttpServerRequest<A>(observability: Observability, input: RequestObservabilityContextInput, handler: (ctx: RequestObservabilityContext) => Promise<A>, options?: HttpServerObservabilityOptions<A>): Promise<ObservedHttpServerResult<A>>;
673
685
 
674
- export { type RuntimeMetricsSinkOptions as $, type ObservabilityRuntimeEnv as A, type ObservabilityTraceExportResult as B, type CardinalityConfig as C, type ObservedHttpServerResult as D, type ExportBatchResult as E, type OtlpAttributeValue as F, type OtlpExportOptions as G, type HealthCheck as H, type InjectTraceContextOptions as I, type OtlpFetch as J, type OtlpHttpExportResult as K, type LogLevel as L, type OtlpHttpExporterOptions as M, type OtlpHttpResponse as N, type Observability as O, PROMETHEUS_CONTENT_TYPE as P, type PrometheusMetricsExporter as Q, type RequestObservabilityContextInput as R, type SpanAttributes as S, type TraceContextCarrier as T, type PrometheusMetricsOptions as U, type RedactionConfig as V, type RedactionOptions as W, type RequestObservabilityRuntimeOptions as X, type ResolvedTraceSampling as Y, type RuntimeHealthOptions as Z, type RuntimeHealthReport as _, type RequestObservabilityContext as a, toOtlpAttributes as a$, type SpanLink as a0, type SpanOptions as a1, type SpanSource as a2, type StructuredLogRecord as a3, type StructuredLogSinkOptions as a4, type StructuredLogSource as a5, type TraceContextHeaderValue as a6, type TraceSamplingConfig as a7, type TraceSamplingOptions as a8, type TraceSamplingRule as a9, makeRuntimeHealth as aA, makeRuntimeMetricsSink as aB, makeStructuredLogSink as aC, makeTraceSampler as aD, metricsSnapshotToOtlp as aE, normalizeHttpRoute as aF, normalizeSpanId as aG, normalizeTraceId as aH, observeHttpServerRequest as aI, otlpAnyValue as aJ, parseBaggage as aK, parseTraceparent as aL, postOtlpJson as aM, ratioSampler as aN, readiness as aO, resolveRequestBaggage as aP, resolveRequestTraceSeed as aQ, resolveTraceSampling as aR, runObservedHttpServerEffect as aS, runtimeHealth as aT, sanitizeHttpTarget as aU, shouldSampleWith as aV, snapshotRuntimeHealth as aW, spanEvent as aX, spanLink as aY, spansToOtlp as aZ, structuredLogsToOtlp as a_, alwaysOffSampler as aa, alwaysOnSampler as ab, currentBaggage as ac, currentSpanLink as ad, defaultStructuredLogWriter as ae, exemplarFromTraceContext as af, exportWithRetry as ag, extractBaggage as ah, extractTraceContext as ai, formatBaggage as aj, formatPrometheusMetrics as ak, formatStructuredLog as al, formatTraceparent as am, healthToHttpResponse as an, injectBaggage as ao, injectTraceContext as ap, logEffect as aq, makeCardinalityLimitedMetrics as ar, makeExportPipeline as as, makeObservability as at, makeObservabilityRedactor as au, makeOtlpHttpLogExporter as av, makeOtlpHttpMetricsExporter as aw, makeOtlpHttpSpanExporter as ax, makePrometheusMetricsExporter as ay, makeRequestObservabilityContext as az, type ObservabilityOptions as b, unixNanoFromMs as b0, withBaggage as b1, withLogContext as b2, withSpan as b3, withTimeout as b4, type CardinalityLimiterOptions as c, type ExportPipeline as d, type ExportPipelineFlushOptions as e, type ExportPipelineFlushResult as f, type ExportPipelineOptions as g, type ExportPipelineStats as h, type ExportPipelineTuning as i, type ExportRetryOptions as j, type ExportSignal as k, type HealthCheckResult as l, type HealthHttpResponse as m, type HealthStatus as n, type HttpServerObservabilityLogOptions as o, type HttpServerObservabilityOptions as p, type HttpServerObservabilitySpanOptions as q, type HttpServerOutcome as r, OTLP_JSON_CONTENT_TYPE as s, type ObservabilityExporters as t, type ObservabilityFlushError as u, type ObservabilityFlushResult as v, type ObservabilityLogExportResult as w, type ObservabilityOtlpOptions as x, type ObservabilityRedactor as y, type ObservabilityRequestEnvInput as z };
686
+ export { type RuntimeHealthOptions as $, type ObservabilityRequestEnvInput as A, type ObservabilityRuntimeEnv as B, type CardinalityConfig as C, type ObservabilityTraceExportResult as D, type ExportBatchResult as E, type ObservedHttpServerResult as F, type OtlpAttributeValue as G, type HealthCheck as H, type InjectTraceContextOptions as I, type OtlpExportOptions as J, type OtlpFetch as K, type LogLevel as L, type MakeOtlpOptionsInput as M, type OtlpHttpExportResult as N, type Observability as O, type OtlpHttpExporterOptions as P, type OtlpHttpResponse as Q, type RequestObservabilityContextInput as R, type SpanAttributes as S, type TraceContextCarrier as T, PROMETHEUS_CONTENT_TYPE as U, type PrometheusMetricsExporter as V, type PrometheusMetricsOptions as W, type RedactionConfig as X, type RedactionOptions as Y, type RequestObservabilityRuntimeOptions as Z, type ResolvedTraceSampling as _, type RequestObservabilityContext as a, spanLink as a$, type RuntimeHealthReport as a0, type RuntimeMetricsSinkOptions as a1, type SpanLink as a2, type SpanOptions as a3, type SpanSource as a4, type StructuredLogRecord as a5, type StructuredLogSinkOptions as a6, type StructuredLogSource as a7, type TraceContextHeaderValue as a8, type TraceSamplingConfig as a9, makeOtlpOptions as aA, makePrometheusMetricsExporter as aB, makeRequestObservabilityContext as aC, makeRuntimeHealth as aD, makeRuntimeMetricsSink as aE, makeStructuredLogSink as aF, makeTraceSampler as aG, metricsSnapshotToOtlp as aH, normalizeHttpRoute as aI, normalizeSpanId as aJ, normalizeTraceId as aK, observeHttpServerRequest as aL, otlpAnyValue as aM, parseBaggage as aN, parseTraceparent as aO, postOtlpJson as aP, ratioSampler as aQ, readiness as aR, resolveRequestBaggage as aS, resolveRequestTraceSeed as aT, resolveTraceSampling as aU, runObservedHttpServerEffect as aV, runtimeHealth as aW, sanitizeHttpTarget as aX, shouldSampleWith as aY, snapshotRuntimeHealth as aZ, spanEvent as a_, type TraceSamplingOptions as aa, type TraceSamplingRule as ab, alwaysOffSampler as ac, alwaysOnSampler as ad, currentBaggage as ae, currentSpanLink as af, defaultStructuredLogWriter as ag, exemplarFromTraceContext as ah, exportWithRetry as ai, extractBaggage as aj, extractTraceContext as ak, formatBaggage as al, formatPrometheusMetrics as am, formatStructuredLog as an, formatTraceparent as ao, healthToHttpResponse as ap, injectBaggage as aq, injectTraceContext as ar, logEffect as as, makeCardinalityLimitedMetrics as at, makeExportPipeline as au, makeObservability as av, makeObservabilityRedactor as aw, makeOtlpHttpLogExporter as ax, makeOtlpHttpMetricsExporter as ay, makeOtlpHttpSpanExporter as az, type ObservabilityOptions as b, spansToOtlp as b0, structuredLogsToOtlp as b1, toOtlpAttributes as b2, unixNanoFromMs as b3, withBaggage as b4, withLogContext as b5, withSpan as b6, withTimeout as b7, type CardinalityLimiterOptions as c, type ExportPipeline as d, type ExportPipelineFlushOptions as e, type ExportPipelineFlushResult as f, type ExportPipelineOptions as g, type ExportPipelineStats as h, type ExportPipelineTuning as i, type ExportRetryOptions as j, type ExportSignal as k, type HealthCheckResult as l, type HealthHttpResponse as m, type HealthStatus as n, type HttpServerObservabilityLogOptions as o, type HttpServerObservabilityOptions as p, type HttpServerObservabilitySpanOptions as q, type HttpServerOutcome as r, OTLP_JSON_CONTENT_TYPE as s, type ObservabilityExporters as t, type ObservabilityFlushError as u, type ObservabilityFlushResult as v, type ObservabilityLogExportResult as w, type ObservabilityOtlpOptions as x, type ObservabilityOtlpSignal as y, type ObservabilityRedactor as z };
@@ -1,4 +1,4 @@
1
- import { Z as ZIO, O as Option, E as Exit, A as Async } from './effect-CGNl5Rqp.js';
1
+ import { Z as ZIO, O as Option, E as Exit, A as Async } from './effect-DIUHZ9IN.js';
2
2
 
3
3
  type Empty<R, E, A> = {
4
4
  readonly _tag: "Empty";
@@ -1,56 +1,5 @@
1
- import { A as Async, R as RuntimeHooks, a as RingBufferOptions, b as RuntimeEvent, c as RuntimeEmitContext, d as RuntimeEventRecord, e as RuntimeSpanLink, T as TraceContext, B as Baggage } from './effect-CGNl5Rqp.js';
2
-
3
- type CircuitBreakerState = "closed" | "open" | "half-open";
4
- type CircuitBreakerError = {
5
- readonly _tag: "CircuitBreakerOpen";
6
- readonly openSince: number;
7
- readonly failures: number;
8
- };
9
- type CircuitBreakerConfig = {
10
- /** Number of consecutive failures before opening the circuit. Default: 5 */
11
- readonly failureThreshold?: number;
12
- /** Time in ms to wait before transitioning from OPEN to HALF_OPEN. Default: 30000 */
13
- readonly resetTimeoutMs?: number;
14
- /** Number of successes in HALF_OPEN needed to close the circuit. Default: 1 */
15
- readonly successThreshold?: number;
16
- /** Custom predicate: should this error count as a failure? Default: all errors count. */
17
- readonly isFailure?: (error: unknown) => boolean;
18
- /** Called on state transitions (for observability). */
19
- readonly onStateChange?: (from: CircuitBreakerState, to: CircuitBreakerState) => void;
20
- };
21
- type CircuitBreakerStats = {
22
- readonly state: CircuitBreakerState;
23
- readonly failures: number;
24
- readonly successes: number;
25
- readonly totalRequests: number;
26
- readonly totalFailures: number;
27
- readonly totalSuccesses: number;
28
- readonly totalRejected: number;
29
- readonly lastFailureTime: number | null;
30
- readonly lastSuccessTime: number | null;
31
- };
32
- type CircuitBreaker = {
33
- /** Current state of the circuit breaker. */
34
- readonly state: () => CircuitBreakerState;
35
- /** Run an effect through the circuit breaker. */
36
- readonly protect: <R, E, A>(effect: Async<R, E, A>) => Async<R, E | CircuitBreakerError, A>;
37
- /** Get current stats. */
38
- readonly stats: () => CircuitBreakerStats;
39
- /** Manually reset to closed state. */
40
- readonly reset: () => void;
41
- };
42
- /**
43
- * Creates a circuit breaker.
44
- *
45
- * ```ts
46
- * const breaker = makeCircuitBreaker({ failureThreshold: 3, resetTimeoutMs: 10000 });
47
- *
48
- * // Protect an effect:
49
- * const result = await run(breaker.protect(callExternalService()));
50
- * // Throws CircuitBreakerOpen if circuit is open
51
- * ```
52
- */
53
- declare function makeCircuitBreaker(config?: CircuitBreakerConfig): CircuitBreaker;
1
+ import { R as RuntimeHooks, b as RingBufferOptions, c as RuntimeEvent, a as RuntimeEmitContext, d as RuntimeEventRecord, e as RuntimeSpanLink, T as TraceContext, B as Baggage } from './effect-DIUHZ9IN.js';
2
+ import { R as RuntimeClock } from './schedule-CK3Ml_7p.js';
54
3
 
55
4
  type MetricType = "counter" | "gauge" | "histogram";
56
5
  type MetricValue = {
@@ -188,6 +137,10 @@ type InMemoryTracerStats = {
188
137
  declare class InMemoryTracer implements RuntimeHooks {
189
138
  private readonly options;
190
139
  spans: Map<string, RuntimeSpan>;
140
+ private readonly finishedSpanIds;
141
+ private readonly finishedSpanSet;
142
+ private finishedSpanOffset;
143
+ private finishedSpanCount;
191
144
  private prunedFinishedSpans;
192
145
  constructor(options?: InMemoryTracerOptions);
193
146
  emit(ev: RuntimeEvent, ctx: RuntimeEmitContext): void;
@@ -199,6 +152,11 @@ declare class InMemoryTracer implements RuntimeHooks {
199
152
  private now;
200
153
  private pruneExpiredFinished;
201
154
  private pruneFinishedOverLimit;
155
+ private markFinished;
156
+ private deleteFinished;
157
+ private peekOldestFinished;
158
+ private deleteOldestFinished;
159
+ private compactFinishedIds;
202
160
  }
203
161
 
204
162
  type TraceSamplingInput = {
@@ -224,7 +182,8 @@ type BrassEnv = {
224
182
  respectRemoteSampled?: boolean;
225
183
  forceSampleOnError?: boolean;
226
184
  childName?: (parentName?: string) => string | undefined;
185
+ clock?: RuntimeClock;
227
186
  };
228
187
  };
229
188
 
230
- export { type BrassEnv as B, type CircuitBreakerStats as C, EventBus as E, type Gauge as G, type Histogram as H, InMemoryTracer as I, type MetricsRegistry as M, type RuntimeSpan as R, type TraceSampler as T, type MetricExemplar as a, type MetricSnapshot as b, type TraceSamplingInput as c, type Tracer as d, type InMemoryTracerOptions as e, type CircuitBreaker as f, type CircuitBreakerConfig as g, type CircuitBreakerError as h, type CircuitBreakerState as i, type Counter as j, type EventBusOptions as k, type EventHandler as l, type HistogramBuckets as m, type InMemoryTracerStats as n, type MetricType as o, type MetricValue as p, type RuntimeSpanEvent as q, defaultTracer as r, makeCircuitBreaker as s, makeMetrics as t, runtimeHooksToEventHandler as u };
189
+ export { type BrassEnv as B, type Counter as C, EventBus as E, type Gauge as G, type Histogram as H, InMemoryTracer as I, type MetricsRegistry as M, type RuntimeSpan as R, type TraceSampler as T, type MetricExemplar as a, type MetricSnapshot as b, type TraceSamplingInput as c, type Tracer as d, type InMemoryTracerOptions as e, type EventBusOptions as f, type EventHandler as g, type HistogramBuckets as h, type InMemoryTracerStats as i, type MetricType as j, type MetricValue as k, type RuntimeSpanEvent as l, defaultTracer as m, makeMetrics as n, runtimeHooksToEventHandler as r };
@@ -1,4 +1,4 @@
1
- import { A as Async, E as Exit } from './effect-CGNl5Rqp.js';
1
+ import { A as Async, E as Exit } from './effect-DIUHZ9IN.js';
2
2
 
3
3
  /**
4
4
  * Acquires a resource, uses it, and guarantees release regardless of outcome.