effect 4.1.5 → 4.1.6

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 (309) hide show
  1. package/ai-docs/package.json +2 -2
  2. package/dist/Channel.d.ts +104 -7
  3. package/dist/Channel.d.ts.map +1 -1
  4. package/dist/Channel.js +73 -4
  5. package/dist/Channel.js.map +1 -1
  6. package/dist/Codegen.d.ts +7 -2
  7. package/dist/Codegen.d.ts.map +1 -1
  8. package/dist/Codegen.js +7 -2
  9. package/dist/Codegen.js.map +1 -1
  10. package/dist/Effect.d.ts +139 -18
  11. package/dist/Effect.d.ts.map +1 -1
  12. package/dist/Effect.js +10 -2
  13. package/dist/Effect.js.map +1 -1
  14. package/dist/Equal.d.ts +4 -4
  15. package/dist/Equal.d.ts.map +1 -1
  16. package/dist/Equal.js +78 -65
  17. package/dist/Equal.js.map +1 -1
  18. package/dist/Hash.d.ts.map +1 -1
  19. package/dist/Hash.js +24 -17
  20. package/dist/Hash.js.map +1 -1
  21. package/dist/LayerRef.d.ts +1 -1
  22. package/dist/LayerRef.d.ts.map +1 -1
  23. package/dist/LayerRef.js +3 -3
  24. package/dist/LayerRef.js.map +1 -1
  25. package/dist/Logger.d.ts +37 -13
  26. package/dist/Logger.d.ts.map +1 -1
  27. package/dist/Logger.js +39 -10
  28. package/dist/Logger.js.map +1 -1
  29. package/dist/Match.d.ts +23 -23
  30. package/dist/Match.d.ts.map +1 -1
  31. package/dist/Match.js.map +1 -1
  32. package/dist/Order.js +1 -1
  33. package/dist/Order.js.map +1 -1
  34. package/dist/Schema.d.ts +41 -0
  35. package/dist/Schema.d.ts.map +1 -1
  36. package/dist/Schema.js +51 -390
  37. package/dist/Schema.js.map +1 -1
  38. package/dist/SchemaAST.d.ts.map +1 -1
  39. package/dist/SchemaAST.js +0 -3
  40. package/dist/SchemaAST.js.map +1 -1
  41. package/dist/ScopedCache.d.ts.map +1 -1
  42. package/dist/ScopedCache.js +6 -4
  43. package/dist/ScopedCache.js.map +1 -1
  44. package/dist/Stream.d.ts +128 -5
  45. package/dist/Stream.d.ts.map +1 -1
  46. package/dist/Stream.js +124 -29
  47. package/dist/Stream.js.map +1 -1
  48. package/dist/String.js +1 -1
  49. package/dist/String.js.map +1 -1
  50. package/dist/Tracer.d.ts +10 -0
  51. package/dist/Tracer.d.ts.map +1 -1
  52. package/dist/Tracer.js +2 -0
  53. package/dist/Tracer.js.map +1 -1
  54. package/dist/ai/McpSchema.d.ts +88 -88
  55. package/dist/ai/McpSchema.d.ts.map +1 -1
  56. package/dist/ai/McpServer.d.ts +152 -2
  57. package/dist/ai/McpServer.d.ts.map +1 -1
  58. package/dist/ai/McpServer.js +8 -2
  59. package/dist/ai/McpServer.js.map +1 -1
  60. package/dist/ai/Prompt.d.ts +3 -1
  61. package/dist/ai/Prompt.d.ts.map +1 -1
  62. package/dist/ai/Prompt.js +17 -3
  63. package/dist/ai/Prompt.js.map +1 -1
  64. package/dist/ai/Skill.d.ts +172 -0
  65. package/dist/ai/Skill.d.ts.map +1 -0
  66. package/dist/ai/Skill.js +209 -0
  67. package/dist/ai/Skill.js.map +1 -0
  68. package/dist/ai/index.d.ts +5 -0
  69. package/dist/ai/index.d.ts.map +1 -1
  70. package/dist/ai/index.js +5 -0
  71. package/dist/ai/index.js.map +1 -1
  72. package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  73. package/dist/cluster/ClusterWorkflowEngine.js +155 -83
  74. package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
  75. package/dist/cluster/MessageStorage.d.ts +56 -0
  76. package/dist/cluster/MessageStorage.d.ts.map +1 -1
  77. package/dist/cluster/MessageStorage.js +18 -2
  78. package/dist/cluster/MessageStorage.js.map +1 -1
  79. package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
  80. package/dist/cluster/SqlMessageStorage.js +45 -22
  81. package/dist/cluster/SqlMessageStorage.js.map +1 -1
  82. package/dist/cluster/internal/entityActivation.js +2 -0
  83. package/dist/cluster/internal/entityActivation.js.map +1 -1
  84. package/dist/cluster/internal/entityManager.js +8 -5
  85. package/dist/cluster/internal/entityManager.js.map +1 -1
  86. package/dist/encoding/Base64.js +5 -1
  87. package/dist/encoding/Base64.js.map +1 -1
  88. package/dist/encoding/Base64Url.d.ts.map +1 -1
  89. package/dist/encoding/Base64Url.js +6 -1
  90. package/dist/encoding/Base64Url.js.map +1 -1
  91. package/dist/encoding/Xml.d.ts +38 -9
  92. package/dist/encoding/Xml.d.ts.map +1 -1
  93. package/dist/encoding/Xml.js +63 -31
  94. package/dist/encoding/Xml.js.map +1 -1
  95. package/dist/http/FetchHttpClient.d.ts +2 -1
  96. package/dist/http/FetchHttpClient.d.ts.map +1 -1
  97. package/dist/http/FetchHttpClient.js +14 -10
  98. package/dist/http/FetchHttpClient.js.map +1 -1
  99. package/dist/http/Headers.d.ts +201 -3
  100. package/dist/http/Headers.d.ts.map +1 -1
  101. package/dist/http/Headers.js +205 -3
  102. package/dist/http/Headers.js.map +1 -1
  103. package/dist/http/HttpClient.d.ts.map +1 -1
  104. package/dist/http/HttpClient.js +11 -7
  105. package/dist/http/HttpClient.js.map +1 -1
  106. package/dist/http/HttpClientError.d.ts +1 -0
  107. package/dist/http/HttpClientError.d.ts.map +1 -1
  108. package/dist/http/HttpClientError.js +32 -9
  109. package/dist/http/HttpClientError.js.map +1 -1
  110. package/dist/http/HttpClientRequest.d.ts +46 -0
  111. package/dist/http/HttpClientRequest.d.ts.map +1 -1
  112. package/dist/http/HttpClientRequest.js +15 -0
  113. package/dist/http/HttpClientRequest.js.map +1 -1
  114. package/dist/http/HttpClientResponse.d.ts +132 -0
  115. package/dist/http/HttpClientResponse.d.ts.map +1 -1
  116. package/dist/http/HttpClientResponse.js +83 -0
  117. package/dist/http/HttpClientResponse.js.map +1 -1
  118. package/dist/http/HttpMiddleware.js +1 -1
  119. package/dist/http/HttpMiddleware.js.map +1 -1
  120. package/dist/http/HttpServerResponse.d.ts +118 -0
  121. package/dist/http/HttpServerResponse.d.ts.map +1 -1
  122. package/dist/http/HttpServerResponse.js +43 -0
  123. package/dist/http/HttpServerResponse.js.map +1 -1
  124. package/dist/http/Multipart.d.ts.map +1 -1
  125. package/dist/http/Multipart.js +0 -5
  126. package/dist/http/Multipart.js.map +1 -1
  127. package/dist/http/MultipartParser/internal/contentType.d.ts +6 -0
  128. package/dist/http/MultipartParser/internal/contentType.d.ts.map +1 -1
  129. package/dist/http/MultipartParser/internal/contentType.js +1 -1
  130. package/dist/http/MultipartParser/internal/contentType.js.map +1 -1
  131. package/dist/http/internal/clientPath.d.ts +2 -0
  132. package/dist/http/internal/clientPath.d.ts.map +1 -0
  133. package/dist/http/internal/clientPath.js +24 -0
  134. package/dist/http/internal/clientPath.js.map +1 -0
  135. package/dist/http/internal/redactedPath.js +2 -0
  136. package/dist/http/internal/redactedPath.js.map +1 -1
  137. package/dist/http/internal/tracing.js +5 -3
  138. package/dist/http/internal/tracing.js.map +1 -1
  139. package/dist/http-api/HttpApi.d.ts +2 -2
  140. package/dist/http-api/HttpApi.d.ts.map +1 -1
  141. package/dist/http-api/HttpApi.js +30 -7
  142. package/dist/http-api/HttpApi.js.map +1 -1
  143. package/dist/http-api/HttpApiBuilder.d.ts.map +1 -1
  144. package/dist/http-api/HttpApiBuilder.js +5 -2
  145. package/dist/http-api/HttpApiBuilder.js.map +1 -1
  146. package/dist/http-api/HttpApiClient.d.ts.map +1 -1
  147. package/dist/http-api/HttpApiClient.js +23 -6
  148. package/dist/http-api/HttpApiClient.js.map +1 -1
  149. package/dist/http-api/internal/redactedKeys.d.ts +2 -0
  150. package/dist/http-api/internal/redactedKeys.d.ts.map +1 -0
  151. package/dist/http-api/internal/redactedKeys.js +37 -0
  152. package/dist/http-api/internal/redactedKeys.js.map +1 -0
  153. package/dist/internal/base64.js +34 -2
  154. package/dist/internal/base64.js.map +1 -1
  155. package/dist/internal/dateTime.js +35 -17
  156. package/dist/internal/dateTime.js.map +1 -1
  157. package/dist/internal/effect.js +9 -1
  158. package/dist/internal/effect.js.map +1 -1
  159. package/dist/internal/equal.js +14 -13
  160. package/dist/internal/equal.js.map +1 -1
  161. package/dist/internal/hash.js +4 -1
  162. package/dist/internal/hash.js.map +1 -1
  163. package/dist/internal/matcher.js +17 -17
  164. package/dist/internal/matcher.js.map +1 -1
  165. package/dist/internal/schema/schemaCodegen.js +3 -2
  166. package/dist/internal/schema/schemaCodegen.js.map +1 -1
  167. package/dist/internal/schema/schemaCodegenBuiltIns.d.ts +2 -0
  168. package/dist/internal/schema/schemaCodegenBuiltIns.d.ts.map +1 -0
  169. package/dist/internal/schema/schemaCodegenBuiltIns.js +425 -0
  170. package/dist/internal/schema/schemaCodegenBuiltIns.js.map +1 -0
  171. package/dist/internal/schema/toEquivalence.js +3 -4
  172. package/dist/internal/schema/toEquivalence.js.map +1 -1
  173. package/dist/internal/version.js +1 -1
  174. package/dist/jose/JoseError.d.ts +51 -1
  175. package/dist/jose/JoseError.d.ts.map +1 -1
  176. package/dist/jose/JoseError.js +25 -18
  177. package/dist/jose/JoseError.js.map +1 -1
  178. package/dist/jose/internal/compact.js +10 -5
  179. package/dist/jose/internal/compact.js.map +1 -1
  180. package/dist/observability/Otlp.d.ts +19 -0
  181. package/dist/observability/Otlp.d.ts.map +1 -1
  182. package/dist/observability/Otlp.js +10 -0
  183. package/dist/observability/Otlp.js.map +1 -1
  184. package/dist/observability/OtlpExporter.d.ts +49 -13
  185. package/dist/observability/OtlpExporter.d.ts.map +1 -1
  186. package/dist/observability/OtlpExporter.js +135 -54
  187. package/dist/observability/OtlpExporter.js.map +1 -1
  188. package/dist/observability/OtlpLogger.d.ts +14 -0
  189. package/dist/observability/OtlpLogger.d.ts.map +1 -1
  190. package/dist/observability/OtlpLogger.js +10 -2
  191. package/dist/observability/OtlpLogger.js.map +1 -1
  192. package/dist/observability/OtlpMetrics.d.ts.map +1 -1
  193. package/dist/observability/OtlpMetrics.js +2 -0
  194. package/dist/observability/OtlpMetrics.js.map +1 -1
  195. package/dist/observability/OtlpTracer.d.ts +14 -0
  196. package/dist/observability/OtlpTracer.d.ts.map +1 -1
  197. package/dist/observability/OtlpTracer.js +10 -2
  198. package/dist/observability/OtlpTracer.js.map +1 -1
  199. package/dist/persistence/KeyValueStore.d.ts.map +1 -1
  200. package/dist/persistence/KeyValueStore.js +6 -4
  201. package/dist/persistence/KeyValueStore.js.map +1 -1
  202. package/dist/reactivity/Atom.d.ts.map +1 -1
  203. package/dist/reactivity/Atom.js +10 -9
  204. package/dist/reactivity/Atom.js.map +1 -1
  205. package/dist/rpc/RpcClient.d.ts.map +1 -1
  206. package/dist/rpc/RpcClient.js +32 -1
  207. package/dist/rpc/RpcClient.js.map +1 -1
  208. package/dist/rpc/RpcGroup.d.ts +1 -1
  209. package/dist/rpc/RpcGroup.d.ts.map +1 -1
  210. package/dist/rpc/RpcGroup.js +4 -0
  211. package/dist/rpc/RpcGroup.js.map +1 -1
  212. package/dist/sql/Migrator.d.ts.map +1 -1
  213. package/dist/sql/Migrator.js +2 -5
  214. package/dist/sql/Migrator.js.map +1 -1
  215. package/dist/sql/SqlClient.d.ts.map +1 -1
  216. package/dist/sql/SqlClient.js +5 -1
  217. package/dist/sql/SqlClient.js.map +1 -1
  218. package/dist/workflow/Activity.d.ts +18 -0
  219. package/dist/workflow/Activity.d.ts.map +1 -1
  220. package/dist/workflow/Activity.js +13 -4
  221. package/dist/workflow/Activity.js.map +1 -1
  222. package/dist/workflow/Workflow.d.ts +10 -9
  223. package/dist/workflow/Workflow.d.ts.map +1 -1
  224. package/dist/workflow/Workflow.js +33 -22
  225. package/dist/workflow/Workflow.js.map +1 -1
  226. package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
  227. package/dist/workflow/WorkflowEngine.js +26 -12
  228. package/dist/workflow/WorkflowEngine.js.map +1 -1
  229. package/dist/workflow/internal/retry.d.ts +2 -0
  230. package/dist/workflow/internal/retry.d.ts.map +1 -0
  231. package/dist/workflow/internal/retry.js +11 -0
  232. package/dist/workflow/internal/retry.js.map +1 -0
  233. package/dist/workflow/internal/scope.d.ts +2 -0
  234. package/dist/workflow/internal/scope.d.ts.map +1 -0
  235. package/dist/workflow/internal/scope.js +26 -0
  236. package/dist/workflow/internal/scope.js.map +1 -0
  237. package/package.json +3 -3
  238. package/src/Channel.ts +105 -8
  239. package/src/Codegen.ts +7 -2
  240. package/src/Effect.ts +224 -48
  241. package/src/Equal.ts +85 -79
  242. package/src/Hash.ts +30 -22
  243. package/src/LayerRef.ts +6 -4
  244. package/src/Logger.ts +68 -25
  245. package/src/Match.ts +78 -50
  246. package/src/Order.ts +1 -1
  247. package/src/Schema.ts +79 -296
  248. package/src/SchemaAST.ts +0 -1
  249. package/src/ScopedCache.ts +6 -4
  250. package/src/Stream.ts +167 -33
  251. package/src/String.ts +1 -1
  252. package/src/Tracer.ts +10 -0
  253. package/src/ai/McpServer.ts +161 -4
  254. package/src/ai/Prompt.ts +20 -3
  255. package/src/ai/Skill.ts +236 -0
  256. package/src/ai/index.ts +6 -0
  257. package/src/cluster/ClusterWorkflowEngine.ts +172 -96
  258. package/src/cluster/MessageStorage.ts +51 -2
  259. package/src/cluster/SqlMessageStorage.ts +81 -34
  260. package/src/cluster/internal/entityActivation.ts +6 -0
  261. package/src/cluster/internal/entityManager.ts +8 -4
  262. package/src/encoding/Base64.ts +5 -1
  263. package/src/encoding/Base64Url.ts +6 -1
  264. package/src/encoding/Xml.ts +96 -26
  265. package/src/http/FetchHttpClient.ts +8 -5
  266. package/src/http/Headers.ts +309 -3
  267. package/src/http/HttpClient.ts +19 -7
  268. package/src/http/HttpClientError.ts +42 -9
  269. package/src/http/HttpClientRequest.ts +51 -0
  270. package/src/http/HttpClientResponse.ts +156 -0
  271. package/src/http/HttpMiddleware.ts +1 -1
  272. package/src/http/HttpServerResponse.ts +126 -0
  273. package/src/http/Multipart.ts +0 -5
  274. package/src/http/MultipartParser/internal/contentType.ts +1 -1
  275. package/src/http/internal/clientPath.ts +39 -0
  276. package/src/http/internal/redactedPath.ts +4 -0
  277. package/src/http/internal/tracing.ts +6 -3
  278. package/src/http-api/HttpApi.ts +29 -8
  279. package/src/http-api/HttpApiBuilder.ts +7 -2
  280. package/src/http-api/HttpApiClient.ts +30 -7
  281. package/src/http-api/internal/redactedKeys.ts +40 -0
  282. package/src/internal/base64.ts +57 -2
  283. package/src/internal/dateTime.ts +43 -24
  284. package/src/internal/effect.ts +31 -102
  285. package/src/internal/equal.ts +37 -17
  286. package/src/internal/hash.ts +5 -1
  287. package/src/internal/matcher.ts +34 -113
  288. package/src/internal/schema/schemaCodegen.ts +5 -4
  289. package/src/internal/schema/schemaCodegenBuiltIns.ts +343 -0
  290. package/src/internal/schema/toEquivalence.ts +3 -5
  291. package/src/internal/version.ts +1 -1
  292. package/src/jose/JoseError.ts +34 -0
  293. package/src/jose/internal/compact.ts +14 -5
  294. package/src/observability/Otlp.ts +29 -0
  295. package/src/observability/OtlpExporter.ts +206 -75
  296. package/src/observability/OtlpLogger.ts +24 -2
  297. package/src/observability/OtlpMetrics.ts +2 -0
  298. package/src/observability/OtlpTracer.ts +24 -3
  299. package/src/persistence/KeyValueStore.ts +17 -14
  300. package/src/reactivity/Atom.ts +12 -18
  301. package/src/rpc/RpcClient.ts +26 -1
  302. package/src/rpc/RpcGroup.ts +4 -1
  303. package/src/sql/Migrator.ts +2 -11
  304. package/src/sql/SqlClient.ts +14 -8
  305. package/src/workflow/Activity.ts +28 -4
  306. package/src/workflow/Workflow.ts +68 -44
  307. package/src/workflow/WorkflowEngine.ts +38 -15
  308. package/src/workflow/internal/retry.ts +12 -0
  309. package/src/workflow/internal/scope.ts +36 -0
package/dist/Effect.d.ts CHANGED
@@ -58,7 +58,7 @@ import type { Scheduler } from "./Scheduler.ts";
58
58
  import type { Scope } from "./Scope.ts";
59
59
  import type { AnySpan, ParentSpan, Span, SpanLink, SpanOptions, SpanOptionsNoTrace, TraceOptions, Tracer } from "./Tracer.ts";
60
60
  import type { TxRef } from "./TxRef.ts";
61
- import type { Concurrency, Covariant, EqualsWith, ExcludeReason, ExcludeTag, ExtractReason, ExtractTag, NarrowReason, NoInfer, OmitReason, ReasonOf, ReasonTags, Simplify, Tags, unassigned } from "./Types.ts";
61
+ import type { Concurrency, Covariant, EqualsWith, ExcludeReason, ExcludeTag, ExtractReason, ExtractTag, IsUnion, NarrowReason, NoInfer, OmitReason, ReasonOf, ReasonTags, Simplify, Tags, unassigned } from "./Types.ts";
62
62
  import type * as Unify from "./Unify.ts";
63
63
  /**
64
64
  * Type-level identifier for `Effect` values.
@@ -4570,7 +4570,7 @@ export declare const catchTag: {
4570
4570
  * @category error handling
4571
4571
  * @since 2.0.0
4572
4572
  */
4573
- <A, E, R, const K extends Tags<E> | Arr.NonEmptyReadonlyArray<Tags<E>>, R1, E1, A1, A2 = unassigned, E2 = never, R2 = never>(self: Effect<A, E, R>, k: K, f: (e: ExtractTag<E, K extends Arr.NonEmptyReadonlyArray<string> ? K[number] : K>) => Effect<A1, E1, R1>, orElse?: ((e: ExcludeTag<E, K extends Arr.NonEmptyReadonlyArray<string> ? K[number] : K>) => Effect<A2, E2, R2>) | undefined): Effect<A | A1 | Exclude<A2, unassigned>, E1 | E2 | (A2 extends unassigned ? ExcludeTag<E, K extends Arr.NonEmptyReadonlyArray<string> ? K[number] : K> : never), R | R1 | R2>;
4573
+ <A, E = any, R = unknown, const K extends Tags<E> | Arr.NonEmptyReadonlyArray<Tags<E>> = never, R1 = unknown, E1 = unknown, A1 = unknown, A2 = unassigned, E2 = never, R2 = never>(self: Effect<A, E, R>, k: K, f: (e: ExtractTag<E, K extends Arr.NonEmptyReadonlyArray<string> ? K[number] : K>) => Effect<A1, E1, R1>, orElse?: ((e: ExcludeTag<E, K extends Arr.NonEmptyReadonlyArray<string> ? K[number] : K>) => Effect<A2, E2, R2>) | undefined): Effect<A | A1 | Exclude<A2, unassigned>, E1 | E2 | (A2 extends unassigned ? ExcludeTag<E, K extends Arr.NonEmptyReadonlyArray<string> ? K[number] : K> : never), R | R1 | R2>;
4574
4574
  };
4575
4575
  /**
4576
4576
  * Handles multiple errors in a single block of code using their `_tag` field.
@@ -4950,6 +4950,15 @@ export declare const catchReason: {
4950
4950
  */
4951
4951
  <A, E, R, K extends Tags<E>, RK extends ReasonTags<ExtractTag<E, K>>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(self: Effect<A, E, R>, errorTag: K, reasonTag: RK, f: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Effect<A2, E2, R2>, orElse?: ((reasons: ExcludeReason<ExtractTag<E, K>, RK>, error: OmitReason<ExtractTag<E, K>, RK>) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | Exclude<A3, unassigned>, ExcludeTag<E, K> | E2 | E3 | (A3 extends unassigned ? ExtractTag<E, K> : never), R | R2 | R3>;
4952
4952
  };
4953
+ type RequiredCaseKeys<Cases> = {
4954
+ [RK in keyof Cases & string]: {} extends Record<RK, 1> ? never : [Cases] extends [Record<RK, (...args: Array<any>) => any>] ? RK : never;
4955
+ }[keyof Cases & string];
4956
+ type CaseReturn<Cases> = Cases extends unknown ? ReturnType<Extract<Cases[keyof Cases], (...args: Array<any>) => any>> : never;
4957
+ type UnhandledParent<E, K extends string, Handled extends string> = {} extends Record<K, 1> ? ExtractTag<E, K> : IsUnion<K> extends true ? ExtractTag<E, K> : ExtractTag<E, K> extends infer P ? P extends {
4958
+ readonly reason: {
4959
+ readonly _tag: string;
4960
+ };
4961
+ } ? [ExcludeReason<P, Handled>] extends [never] ? never : P : P : never;
4953
4962
  /**
4954
4963
  * Catches multiple reasons within a tagged error using an object of handlers.
4955
4964
  *
@@ -4959,6 +4968,8 @@ export declare const catchReason: {
4959
4968
  * is converted to a defect, preserving reason order and interrupts. An
4960
4969
  * interruption alongside a typed error does not prevent recovery.
4961
4970
  *
4971
+ * Only own enumerable properties of `cases` are matched; inherited properties are ignored.
4972
+ *
4962
4973
  * **Example** (Handling multiple error reasons)
4963
4974
  *
4964
4975
  * ```ts import.meta.vitest
@@ -5006,6 +5017,8 @@ export declare const catchReasons: {
5006
5017
  * is converted to a defect, preserving reason order and interrupts. An
5007
5018
  * interruption alongside a typed error does not prevent recovery.
5008
5019
  *
5020
+ * Only own enumerable properties of `cases` are matched; inherited properties are ignored.
5021
+ *
5009
5022
  * **Example** (Handling multiple error reasons)
5010
5023
  *
5011
5024
  * ```ts import.meta.vitest
@@ -5045,13 +5058,58 @@ export declare const catchReasons: {
5045
5058
  */
5046
5059
  <K extends Tags<E>, E, Cases extends {
5047
5060
  [RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>, error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<any, any, any>;
5048
- }, A2 = unassigned, E2 = never, R2 = never>(errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>, error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Effect<A2, E2, R2>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | Exclude<A2, unassigned> | {
5049
- [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
5050
- }[keyof Cases], ExcludeTag<E, K> | E2 | (A2 extends unassigned ? ExtractTag<E, K> : never) | {
5051
- [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never;
5052
- }[keyof Cases], R | R2 | {
5053
- [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<any, any, infer R> ? R : never;
5054
- }[keyof Cases]>;
5061
+ }, A2 = never, E2 = never, R2 = never, Ret extends Effect<any, any, any> = Effect<A2, E2, R2>>(errorTag: K, cases: Cases, orElse: (reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, RequiredCaseKeys<Cases>>, error: OmitReason<ExtractTag<NoInfer<E>, K>, RequiredCaseKeys<Cases>>) => Ret): <A, R>(self: Effect<A, E, R>) => Effect<A | Success<Ret | CaseReturn<Cases>>, ExcludeTag<E, K> | UnhandledParent<E, K, string> | Error<Ret | CaseReturn<Cases>>, R | Services<Ret | CaseReturn<Cases>>>;
5062
+ /**
5063
+ * Catches multiple reasons within a tagged error using an object of handlers.
5064
+ *
5065
+ * **Gotchas**
5066
+ *
5067
+ * If the cause contains a defect, the handler is skipped and every typed error
5068
+ * is converted to a defect, preserving reason order and interrupts. An
5069
+ * interruption alongside a typed error does not prevent recovery.
5070
+ *
5071
+ * Only own enumerable properties of `cases` are matched; inherited properties are ignored.
5072
+ *
5073
+ * **Example** (Handling multiple error reasons)
5074
+ *
5075
+ * ```ts import.meta.vitest
5076
+ * import { Data, Effect } from "effect"
5077
+ *
5078
+ * class RateLimitError extends Data.TaggedError("RateLimitError")<{
5079
+ * retryAfter: number
5080
+ * }> {}
5081
+ *
5082
+ * class QuotaExceededError extends Data.TaggedError("QuotaExceededError")<{
5083
+ * limit: number
5084
+ * }> {}
5085
+ *
5086
+ * class AiError extends Data.TaggedError("AiError")<{
5087
+ * reason: RateLimitError | QuotaExceededError
5088
+ * }> {}
5089
+ *
5090
+ * const program: Effect.Effect<string, AiError> = Effect.fail(
5091
+ * new AiError({ reason: new QuotaExceededError({ limit: 100 }) })
5092
+ * )
5093
+ *
5094
+ * const handled = program.pipe(
5095
+ * Effect.catchReasons("AiError", {
5096
+ * RateLimitError: (reason) =>
5097
+ * Effect.succeed(`Retry after ${reason.retryAfter}s`),
5098
+ * QuotaExceededError: (reason) =>
5099
+ * Effect.succeed(`Quota exceeded: ${reason.limit}`)
5100
+ * })
5101
+ * )
5102
+ *
5103
+ * Effect.runSync(handled) // => "Quota exceeded: 100"
5104
+ * ```
5105
+ *
5106
+ * @stability stable
5107
+ * @category error handling
5108
+ * @since 4.0.0
5109
+ */
5110
+ <K extends Tags<E>, E, Cases extends {
5111
+ [RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>, error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<any, any, any>;
5112
+ }, A2 = never, E2 = never, R2 = never, Ret extends Effect<any, any, any> = Effect<A2, E2, R2>>(errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, RequiredCaseKeys<Cases>>, error: OmitReason<ExtractTag<NoInfer<E>, K>, RequiredCaseKeys<Cases>>) => Ret) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | Success<Ret | CaseReturn<Cases>>, ExcludeTag<E, K> | UnhandledParent<E, K, RequiredCaseKeys<Cases>> | Error<Ret | CaseReturn<Cases>>, R | Services<Ret | CaseReturn<Cases>>>;
5055
5113
  /**
5056
5114
  * Catches multiple reasons within a tagged error using an object of handlers.
5057
5115
  *
@@ -5061,6 +5119,8 @@ export declare const catchReasons: {
5061
5119
  * is converted to a defect, preserving reason order and interrupts. An
5062
5120
  * interruption alongside a typed error does not prevent recovery.
5063
5121
  *
5122
+ * Only own enumerable properties of `cases` are matched; inherited properties are ignored.
5123
+ *
5064
5124
  * **Example** (Handling multiple error reasons)
5065
5125
  *
5066
5126
  * ```ts import.meta.vitest
@@ -5100,13 +5160,58 @@ export declare const catchReasons: {
5100
5160
  */
5101
5161
  <A, E, R, K extends Tags<E>, Cases extends {
5102
5162
  [RK in ReasonTags<ExtractTag<E, K>>]+?: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Effect<any, any, any>;
5103
- }, A2 = unassigned, E2 = never, R2 = never>(self: Effect<A, E, R>, errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>, error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Effect<A2, E2, R2>) | undefined): Effect<A | Exclude<A2, unassigned> | {
5104
- [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
5105
- }[keyof Cases], ExcludeTag<E, K> | E2 | (A2 extends unassigned ? ExtractTag<E, K> : never) | {
5106
- [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never;
5107
- }[keyof Cases], R | R2 | {
5108
- [RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<any, any, infer R> ? R : never;
5109
- }[keyof Cases]>;
5163
+ }, A2 = never, E2 = never, R2 = never, Ret extends Effect<any, any, any> = Effect<A2, E2, R2>>(self: Effect<A, E, R>, errorTag: K, cases: Cases, orElse: (reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, RequiredCaseKeys<Cases>>, error: OmitReason<ExtractTag<NoInfer<E>, K>, RequiredCaseKeys<Cases>>) => Ret): Effect<A | Success<Ret | CaseReturn<Cases>>, ExcludeTag<E, K> | UnhandledParent<E, K, string> | Error<Ret | CaseReturn<Cases>>, R | Services<Ret | CaseReturn<Cases>>>;
5164
+ /**
5165
+ * Catches multiple reasons within a tagged error using an object of handlers.
5166
+ *
5167
+ * **Gotchas**
5168
+ *
5169
+ * If the cause contains a defect, the handler is skipped and every typed error
5170
+ * is converted to a defect, preserving reason order and interrupts. An
5171
+ * interruption alongside a typed error does not prevent recovery.
5172
+ *
5173
+ * Only own enumerable properties of `cases` are matched; inherited properties are ignored.
5174
+ *
5175
+ * **Example** (Handling multiple error reasons)
5176
+ *
5177
+ * ```ts import.meta.vitest
5178
+ * import { Data, Effect } from "effect"
5179
+ *
5180
+ * class RateLimitError extends Data.TaggedError("RateLimitError")<{
5181
+ * retryAfter: number
5182
+ * }> {}
5183
+ *
5184
+ * class QuotaExceededError extends Data.TaggedError("QuotaExceededError")<{
5185
+ * limit: number
5186
+ * }> {}
5187
+ *
5188
+ * class AiError extends Data.TaggedError("AiError")<{
5189
+ * reason: RateLimitError | QuotaExceededError
5190
+ * }> {}
5191
+ *
5192
+ * const program: Effect.Effect<string, AiError> = Effect.fail(
5193
+ * new AiError({ reason: new QuotaExceededError({ limit: 100 }) })
5194
+ * )
5195
+ *
5196
+ * const handled = program.pipe(
5197
+ * Effect.catchReasons("AiError", {
5198
+ * RateLimitError: (reason) =>
5199
+ * Effect.succeed(`Retry after ${reason.retryAfter}s`),
5200
+ * QuotaExceededError: (reason) =>
5201
+ * Effect.succeed(`Quota exceeded: ${reason.limit}`)
5202
+ * })
5203
+ * )
5204
+ *
5205
+ * Effect.runSync(handled) // => "Quota exceeded: 100"
5206
+ * ```
5207
+ *
5208
+ * @stability stable
5209
+ * @category error handling
5210
+ * @since 4.0.0
5211
+ */
5212
+ <A, E, R, K extends Tags<E>, Cases extends {
5213
+ [RK in ReasonTags<ExtractTag<E, K>>]+?: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Effect<any, any, any>;
5214
+ }, A2 = never, E2 = never, R2 = never, Ret extends Effect<any, any, any> = Effect<A2, E2, R2>>(self: Effect<A, E, R>, errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, RequiredCaseKeys<Cases>>, error: OmitReason<ExtractTag<NoInfer<E>, K>, RequiredCaseKeys<Cases>>) => Ret) | undefined): Effect<A | Success<Ret | CaseReturn<Cases>>, ExcludeTag<E, K> | UnhandledParent<E, K, RequiredCaseKeys<Cases>> | Error<Ret | CaseReturn<Cases>>, R | Services<Ret | CaseReturn<Cases>>>;
5110
5215
  };
5111
5216
  /**
5112
5217
  * Type helper that keeps only error tags whose tagged error contains a tagged `reason` field.
@@ -16824,6 +16929,11 @@ export declare const annotateSpans: {
16824
16929
  /**
16825
16930
  * Adds an annotation to the current span if available.
16826
16931
  *
16932
+ * **Details**
16933
+ *
16934
+ * Does nothing when there is no current span or when the nearest parent span is
16935
+ * an `ExternalSpan`.
16936
+ *
16827
16937
  * **Example** (Annotating the current span)
16828
16938
  *
16829
16939
  * ```ts import.meta.vitest
@@ -16849,6 +16959,11 @@ export declare const annotateCurrentSpan: {
16849
16959
  /**
16850
16960
  * Adds an annotation to the current span if available.
16851
16961
  *
16962
+ * **Details**
16963
+ *
16964
+ * Does nothing when there is no current span or when the nearest parent span is
16965
+ * an `ExternalSpan`.
16966
+ *
16852
16967
  * **Example** (Annotating the current span)
16853
16968
  *
16854
16969
  * ```ts import.meta.vitest
@@ -16874,6 +16989,11 @@ export declare const annotateCurrentSpan: {
16874
16989
  /**
16875
16990
  * Adds an annotation to the current span if available.
16876
16991
  *
16992
+ * **Details**
16993
+ *
16994
+ * Does nothing when there is no current span or when the nearest parent span is
16995
+ * an `ExternalSpan`.
16996
+ *
16877
16997
  * **Example** (Annotating the current span)
16878
16998
  *
16879
16999
  * ```ts import.meta.vitest
@@ -16902,8 +17022,9 @@ export declare const annotateCurrentSpan: {
16902
17022
  *
16903
17023
  * **Details**
16904
17024
  *
16905
- * The effect fails with `NoSuchElementError` when there is no active local
16906
- * `Span`.
17025
+ * The effect fails with `NoSuchElementError` when there is no parent span or
17026
+ * when the nearest parent span is an `ExternalSpan`. Use `currentParentSpan` to
17027
+ * read either kind.
16907
17028
  *
16908
17029
  * **Example** (Reading the current span)
16909
17030
  *