effect 4.0.0-beta.31 → 4.0.0-beta.33

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 (481) hide show
  1. package/dist/Array.d.ts +87 -86
  2. package/dist/Array.d.ts.map +1 -1
  3. package/dist/Array.js +47 -40
  4. package/dist/Array.js.map +1 -1
  5. package/dist/BigDecimal.d.ts +46 -45
  6. package/dist/BigDecimal.d.ts.map +1 -1
  7. package/dist/BigDecimal.js +35 -38
  8. package/dist/BigDecimal.js.map +1 -1
  9. package/dist/BigInt.d.ts +39 -32
  10. package/dist/BigInt.d.ts.map +1 -1
  11. package/dist/BigInt.js +32 -29
  12. package/dist/BigInt.js.map +1 -1
  13. package/dist/Chunk.d.ts +58 -57
  14. package/dist/Chunk.d.ts.map +1 -1
  15. package/dist/Chunk.js +20 -21
  16. package/dist/Chunk.js.map +1 -1
  17. package/dist/Config.d.ts.map +1 -1
  18. package/dist/Config.js +4 -1
  19. package/dist/Config.js.map +1 -1
  20. package/dist/Cron.d.ts +3 -6
  21. package/dist/Cron.d.ts.map +1 -1
  22. package/dist/Cron.js +8 -15
  23. package/dist/Cron.js.map +1 -1
  24. package/dist/DateTime.d.ts +16 -15
  25. package/dist/DateTime.d.ts.map +1 -1
  26. package/dist/DateTime.js +8 -8
  27. package/dist/DateTime.js.map +1 -1
  28. package/dist/Deferred.d.ts +7 -5
  29. package/dist/Deferred.d.ts.map +1 -1
  30. package/dist/Deferred.js +7 -5
  31. package/dist/Deferred.js.map +1 -1
  32. package/dist/Duration.d.ts +26 -24
  33. package/dist/Duration.d.ts.map +1 -1
  34. package/dist/Duration.js +23 -22
  35. package/dist/Duration.js.map +1 -1
  36. package/dist/Effect.d.ts +7 -3
  37. package/dist/Effect.d.ts.map +1 -1
  38. package/dist/Effect.js +3 -4
  39. package/dist/Effect.js.map +1 -1
  40. package/dist/Fiber.d.ts +2 -1
  41. package/dist/Fiber.d.ts.map +1 -1
  42. package/dist/Fiber.js.map +1 -1
  43. package/dist/FiberHandle.d.ts +9 -8
  44. package/dist/FiberHandle.d.ts.map +1 -1
  45. package/dist/FiberHandle.js +8 -7
  46. package/dist/FiberHandle.js.map +1 -1
  47. package/dist/FiberMap.d.ts +20 -19
  48. package/dist/FiberMap.d.ts.map +1 -1
  49. package/dist/FiberMap.js +6 -6
  50. package/dist/FiberMap.js.map +1 -1
  51. package/dist/FileSystem.d.ts +17 -16
  52. package/dist/FileSystem.d.ts.map +1 -1
  53. package/dist/FileSystem.js +10 -7
  54. package/dist/FileSystem.js.map +1 -1
  55. package/dist/Graph.d.ts +64 -64
  56. package/dist/Graph.d.ts.map +1 -1
  57. package/dist/Graph.js +53 -53
  58. package/dist/Graph.js.map +1 -1
  59. package/dist/HashMap.d.ts +11 -5
  60. package/dist/HashMap.d.ts.map +1 -1
  61. package/dist/HashMap.js +3 -1
  62. package/dist/HashMap.js.map +1 -1
  63. package/dist/Iterable.d.ts +11 -11
  64. package/dist/Iterable.d.ts.map +1 -1
  65. package/dist/Iterable.js +12 -12
  66. package/dist/Iterable.js.map +1 -1
  67. package/dist/Latch.d.ts +69 -3
  68. package/dist/Latch.d.ts.map +1 -1
  69. package/dist/Latch.js +58 -0
  70. package/dist/Latch.js.map +1 -1
  71. package/dist/Layer.d.ts +84 -0
  72. package/dist/Layer.d.ts.map +1 -1
  73. package/dist/Layer.js +27 -0
  74. package/dist/Layer.js.map +1 -1
  75. package/dist/Number.d.ts +74 -18
  76. package/dist/Number.d.ts.map +1 -1
  77. package/dist/Number.js +34 -15
  78. package/dist/Number.js.map +1 -1
  79. package/dist/Option.d.ts +2 -0
  80. package/dist/Option.d.ts.map +1 -1
  81. package/dist/Option.js.map +1 -1
  82. package/dist/PartitionedSemaphore.d.ts +183 -0
  83. package/dist/PartitionedSemaphore.d.ts.map +1 -0
  84. package/dist/PartitionedSemaphore.js +231 -0
  85. package/dist/PartitionedSemaphore.js.map +1 -0
  86. package/dist/PubSub.d.ts +5 -4
  87. package/dist/PubSub.d.ts.map +1 -1
  88. package/dist/PubSub.js +6 -5
  89. package/dist/PubSub.js.map +1 -1
  90. package/dist/Queue.d.ts +4 -4
  91. package/dist/Queue.d.ts.map +1 -1
  92. package/dist/Queue.js +2 -2
  93. package/dist/Queue.js.map +1 -1
  94. package/dist/Record.d.ts +40 -40
  95. package/dist/Record.d.ts.map +1 -1
  96. package/dist/Record.js +16 -15
  97. package/dist/Record.js.map +1 -1
  98. package/dist/Scheduler.d.ts +25 -123
  99. package/dist/Scheduler.d.ts.map +1 -1
  100. package/dist/Scheduler.js +20 -123
  101. package/dist/Scheduler.js.map +1 -1
  102. package/dist/Schema.d.ts +30 -0
  103. package/dist/Schema.d.ts.map +1 -1
  104. package/dist/Schema.js +28 -1
  105. package/dist/Schema.js.map +1 -1
  106. package/dist/SchemaGetter.js +6 -4
  107. package/dist/SchemaGetter.js.map +1 -1
  108. package/dist/SchemaTransformation.d.ts.map +1 -1
  109. package/dist/SchemaTransformation.js +32 -27
  110. package/dist/SchemaTransformation.js.map +1 -1
  111. package/dist/Semaphore.d.ts +149 -53
  112. package/dist/Semaphore.d.ts.map +1 -1
  113. package/dist/Semaphore.js +137 -117
  114. package/dist/Semaphore.js.map +1 -1
  115. package/dist/ServiceMap.d.ts +26 -0
  116. package/dist/ServiceMap.d.ts.map +1 -1
  117. package/dist/ServiceMap.js +36 -21
  118. package/dist/ServiceMap.js.map +1 -1
  119. package/dist/Stream.js +1 -1
  120. package/dist/Stream.js.map +1 -1
  121. package/dist/String.d.ts +114 -47
  122. package/dist/String.d.ts.map +1 -1
  123. package/dist/String.js +29 -47
  124. package/dist/String.js.map +1 -1
  125. package/dist/SubscriptionRef.d.ts +1 -2
  126. package/dist/SubscriptionRef.d.ts.map +1 -1
  127. package/dist/SubscriptionRef.js +81 -115
  128. package/dist/SubscriptionRef.js.map +1 -1
  129. package/dist/Terminal.d.ts +2 -1
  130. package/dist/Terminal.d.ts.map +1 -1
  131. package/dist/Terminal.js.map +1 -1
  132. package/dist/Tracer.d.ts +5 -4
  133. package/dist/Tracer.d.ts.map +1 -1
  134. package/dist/Tracer.js +2 -1
  135. package/dist/Tracer.js.map +1 -1
  136. package/dist/Trie.d.ts +26 -14
  137. package/dist/Trie.d.ts.map +1 -1
  138. package/dist/Trie.js +8 -4
  139. package/dist/Trie.js.map +1 -1
  140. package/dist/TxHashMap.d.ts +77 -59
  141. package/dist/TxHashMap.d.ts.map +1 -1
  142. package/dist/TxHashMap.js +25 -19
  143. package/dist/TxHashMap.js.map +1 -1
  144. package/dist/TxSemaphore.d.ts +162 -2
  145. package/dist/TxSemaphore.d.ts.map +1 -1
  146. package/dist/TxSemaphore.js +16 -2
  147. package/dist/TxSemaphore.js.map +1 -1
  148. package/dist/index.d.ts +88 -32
  149. package/dist/index.d.ts.map +1 -1
  150. package/dist/index.js +88 -32
  151. package/dist/index.js.map +1 -1
  152. package/dist/internal/dateTime.js +9 -9
  153. package/dist/internal/dateTime.js.map +1 -1
  154. package/dist/internal/effect.js +20 -89
  155. package/dist/internal/effect.js.map +1 -1
  156. package/dist/internal/hashMap.js +2 -1
  157. package/dist/internal/hashMap.js.map +1 -1
  158. package/dist/internal/option.js +6 -0
  159. package/dist/internal/option.js.map +1 -1
  160. package/dist/internal/trie.js +3 -3
  161. package/dist/internal/trie.js.map +1 -1
  162. package/dist/unstable/ai/AiError.js +1 -1
  163. package/dist/unstable/ai/AiError.js.map +1 -1
  164. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
  165. package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
  166. package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
  167. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  168. package/dist/unstable/ai/Chat.js +2 -2
  169. package/dist/unstable/ai/Chat.js.map +1 -1
  170. package/dist/unstable/ai/LanguageModel.d.ts +8 -0
  171. package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
  172. package/dist/unstable/ai/LanguageModel.js +112 -11
  173. package/dist/unstable/ai/LanguageModel.js.map +1 -1
  174. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
  175. package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
  176. package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
  177. package/dist/unstable/ai/ResponseIdTracker.d.ts +38 -0
  178. package/dist/unstable/ai/ResponseIdTracker.d.ts.map +1 -0
  179. package/dist/unstable/ai/ResponseIdTracker.js +68 -0
  180. package/dist/unstable/ai/ResponseIdTracker.js.map +1 -0
  181. package/dist/unstable/ai/Tool.d.ts +14 -0
  182. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  183. package/dist/unstable/ai/Tool.js +13 -0
  184. package/dist/unstable/ai/Tool.js.map +1 -1
  185. package/dist/unstable/ai/index.d.ts +4 -0
  186. package/dist/unstable/ai/index.d.ts.map +1 -1
  187. package/dist/unstable/ai/index.js +4 -0
  188. package/dist/unstable/ai/index.js.map +1 -1
  189. package/dist/unstable/cli/Argument.d.ts +2 -4
  190. package/dist/unstable/cli/Argument.d.ts.map +1 -1
  191. package/dist/unstable/cli/Argument.js +1 -3
  192. package/dist/unstable/cli/Argument.js.map +1 -1
  193. package/dist/unstable/cli/CliOutput.d.ts +3 -2
  194. package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
  195. package/dist/unstable/cli/CliOutput.js +4 -3
  196. package/dist/unstable/cli/CliOutput.js.map +1 -1
  197. package/dist/unstable/cli/Command.d.ts +3 -2
  198. package/dist/unstable/cli/Command.d.ts.map +1 -1
  199. package/dist/unstable/cli/Command.js +3 -3
  200. package/dist/unstable/cli/Command.js.map +1 -1
  201. package/dist/unstable/cli/Flag.d.ts +2 -2
  202. package/dist/unstable/cli/Flag.d.ts.map +1 -1
  203. package/dist/unstable/cli/Flag.js +1 -1
  204. package/dist/unstable/cli/Flag.js.map +1 -1
  205. package/dist/unstable/cli/HelpDoc.d.ts +14 -12
  206. package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
  207. package/dist/unstable/cli/Param.d.ts +4 -4
  208. package/dist/unstable/cli/Param.d.ts.map +1 -1
  209. package/dist/unstable/cli/Param.js +7 -7
  210. package/dist/unstable/cli/Param.js.map +1 -1
  211. package/dist/unstable/cli/Primitive.d.ts +1 -1
  212. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  213. package/dist/unstable/cli/Primitive.js.map +1 -1
  214. package/dist/unstable/cli/Prompt.js +71 -67
  215. package/dist/unstable/cli/Prompt.js.map +1 -1
  216. package/dist/unstable/cli/internal/completions/CommandDescriptor.js +9 -2
  217. package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
  218. package/dist/unstable/cli/internal/parser.js +8 -3
  219. package/dist/unstable/cli/internal/parser.js.map +1 -1
  220. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
  221. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  222. package/dist/unstable/cluster/ClusterWorkflowEngine.js +25 -23
  223. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  224. package/dist/unstable/cluster/Entity.d.ts +3 -2
  225. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  226. package/dist/unstable/cluster/Entity.js +7 -7
  227. package/dist/unstable/cluster/Entity.js.map +1 -1
  228. package/dist/unstable/cluster/Message.d.ts +4 -3
  229. package/dist/unstable/cluster/Message.d.ts.map +1 -1
  230. package/dist/unstable/cluster/Message.js +3 -2
  231. package/dist/unstable/cluster/Message.js.map +1 -1
  232. package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
  233. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  234. package/dist/unstable/cluster/MessageStorage.js +12 -12
  235. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  236. package/dist/unstable/cluster/Reply.d.ts +2 -1
  237. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  238. package/dist/unstable/cluster/Reply.js +4 -3
  239. package/dist/unstable/cluster/Reply.js.map +1 -1
  240. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  241. package/dist/unstable/cluster/RunnerServer.js +9 -8
  242. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  243. package/dist/unstable/cluster/Runners.d.ts +2 -1
  244. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  245. package/dist/unstable/cluster/Runners.js +7 -6
  246. package/dist/unstable/cluster/Runners.js.map +1 -1
  247. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  248. package/dist/unstable/cluster/Sharding.js +19 -13
  249. package/dist/unstable/cluster/Sharding.js.map +1 -1
  250. package/dist/unstable/cluster/ShardingConfig.d.ts +5 -4
  251. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  252. package/dist/unstable/cluster/ShardingConfig.js +4 -4
  253. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  254. package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
  255. package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
  256. package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
  257. package/dist/unstable/cluster/internal/entityManager.js +9 -10
  258. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  259. package/dist/unstable/devtools/DevToolsSchema.d.ts +2 -1
  260. package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
  261. package/dist/unstable/devtools/DevToolsSchema.js +1 -4
  262. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  263. package/dist/unstable/http/Cookies.d.ts +5 -4
  264. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  265. package/dist/unstable/http/Cookies.js +3 -4
  266. package/dist/unstable/http/Cookies.js.map +1 -1
  267. package/dist/unstable/http/Etag.d.ts.map +1 -1
  268. package/dist/unstable/http/Etag.js +5 -1
  269. package/dist/unstable/http/Etag.js.map +1 -1
  270. package/dist/unstable/http/Headers.d.ts +3 -2
  271. package/dist/unstable/http/Headers.d.ts.map +1 -1
  272. package/dist/unstable/http/Headers.js +2 -1
  273. package/dist/unstable/http/Headers.js.map +1 -1
  274. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  275. package/dist/unstable/http/HttpClient.js +2 -1
  276. package/dist/unstable/http/HttpClient.js.map +1 -1
  277. package/dist/unstable/http/HttpClientRequest.d.ts +4 -3
  278. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  279. package/dist/unstable/http/HttpClientRequest.js +8 -6
  280. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  281. package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
  282. package/dist/unstable/http/HttpClientResponse.js +2 -1
  283. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  284. package/dist/unstable/http/HttpIncomingMessage.d.ts +2 -1
  285. package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
  286. package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
  287. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  288. package/dist/unstable/http/HttpMiddleware.js +16 -15
  289. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  290. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  291. package/dist/unstable/http/HttpPlatform.js +3 -2
  292. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  293. package/dist/unstable/http/HttpRouter.d.ts +2 -1
  294. package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
  295. package/dist/unstable/http/HttpRouter.js +7 -7
  296. package/dist/unstable/http/HttpRouter.js.map +1 -1
  297. package/dist/unstable/http/HttpServer.d.ts.map +1 -1
  298. package/dist/unstable/http/HttpServer.js +2 -2
  299. package/dist/unstable/http/HttpServer.js.map +1 -1
  300. package/dist/unstable/http/HttpServerError.d.ts +2 -1
  301. package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
  302. package/dist/unstable/http/HttpServerError.js +2 -1
  303. package/dist/unstable/http/HttpServerError.js.map +1 -1
  304. package/dist/unstable/http/HttpServerRequest.d.ts +3 -2
  305. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  306. package/dist/unstable/http/HttpServerRequest.js +14 -10
  307. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  308. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  309. package/dist/unstable/http/HttpServerResponse.js +4 -3
  310. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  311. package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
  312. package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
  313. package/dist/unstable/http/HttpTraceContext.js +27 -15
  314. package/dist/unstable/http/HttpTraceContext.js.map +1 -1
  315. package/dist/unstable/http/UrlParams.d.ts +5 -4
  316. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  317. package/dist/unstable/http/UrlParams.js +5 -6
  318. package/dist/unstable/http/UrlParams.js.map +1 -1
  319. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  320. package/dist/unstable/httpapi/HttpApiBuilder.js +4 -2
  321. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  322. package/dist/unstable/httpapi/HttpApiError.d.ts +15 -0
  323. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  324. package/dist/unstable/httpapi/HttpApiError.js +81 -3
  325. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  326. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  327. package/dist/unstable/observability/OtlpExporter.js +2 -2
  328. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  329. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  330. package/dist/unstable/observability/OtlpTracer.js +7 -3
  331. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  332. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  333. package/dist/unstable/reactivity/Atom.js +1 -5
  334. package/dist/unstable/reactivity/Atom.js.map +1 -1
  335. package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
  336. package/dist/unstable/reactivity/AtomRegistry.js +4 -2
  337. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  338. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  339. package/dist/unstable/rpc/Rpc.js +4 -3
  340. package/dist/unstable/rpc/Rpc.js.map +1 -1
  341. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  342. package/dist/unstable/rpc/RpcClient.js +4 -4
  343. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  344. package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
  345. package/dist/unstable/rpc/RpcSchema.js +3 -2
  346. package/dist/unstable/rpc/RpcSchema.js.map +1 -1
  347. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  348. package/dist/unstable/rpc/RpcSerialization.js +4 -1
  349. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  350. package/dist/unstable/rpc/RpcServer.d.ts +1 -1
  351. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  352. package/dist/unstable/rpc/RpcServer.js +3 -2
  353. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  354. package/dist/unstable/socket/Socket.d.ts +2 -1
  355. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  356. package/dist/unstable/socket/Socket.js +5 -3
  357. package/dist/unstable/socket/Socket.js.map +1 -1
  358. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  359. package/dist/unstable/sql/SqlClient.js +1 -1
  360. package/dist/unstable/sql/SqlClient.js.map +1 -1
  361. package/dist/unstable/workflow/DurableDeferred.js +6 -6
  362. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  363. package/dist/unstable/workflow/Workflow.d.ts +2 -1
  364. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  365. package/dist/unstable/workflow/WorkflowEngine.d.ts +5 -4
  366. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  367. package/dist/unstable/workflow/WorkflowEngine.js +19 -14
  368. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  369. package/package.json +1 -1
  370. package/src/Array.ts +112 -105
  371. package/src/BigDecimal.ts +63 -66
  372. package/src/BigInt.ts +49 -41
  373. package/src/Chunk.ts +68 -63
  374. package/src/Config.ts +4 -1
  375. package/src/Cron.ts +10 -15
  376. package/src/DateTime.ts +16 -15
  377. package/src/Deferred.ts +8 -6
  378. package/src/Duration.ts +34 -33
  379. package/src/Effect.ts +12 -23
  380. package/src/Fiber.ts +2 -1
  381. package/src/FiberHandle.ts +10 -9
  382. package/src/FiberMap.ts +22 -22
  383. package/src/FileSystem.ts +25 -22
  384. package/src/Graph.ts +105 -105
  385. package/src/HashMap.ts +11 -5
  386. package/src/Iterable.ts +13 -13
  387. package/src/Latch.ts +85 -3
  388. package/src/Layer.ts +121 -0
  389. package/src/Number.ts +85 -26
  390. package/src/Option.ts +2 -0
  391. package/src/PartitionedSemaphore.ts +414 -0
  392. package/src/PubSub.ts +7 -6
  393. package/src/Queue.ts +6 -6
  394. package/src/Record.ts +52 -47
  395. package/src/Scheduler.ts +37 -126
  396. package/src/Schema.ts +49 -1
  397. package/src/SchemaGetter.ts +4 -4
  398. package/src/SchemaTransformation.ts +27 -27
  399. package/src/Semaphore.ts +271 -183
  400. package/src/ServiceMap.ts +83 -31
  401. package/src/Stream.ts +1 -1
  402. package/src/String.ts +122 -69
  403. package/src/SubscriptionRef.ts +96 -117
  404. package/src/Terminal.ts +2 -1
  405. package/src/Tracer.ts +6 -5
  406. package/src/Trie.ts +26 -14
  407. package/src/TxHashMap.ts +78 -60
  408. package/src/TxSemaphore.ts +186 -11
  409. package/src/index.ts +89 -33
  410. package/src/internal/dateTime.ts +14 -14
  411. package/src/internal/effect.ts +29 -121
  412. package/src/internal/hashMap.ts +4 -3
  413. package/src/internal/option.ts +7 -0
  414. package/src/internal/trie.ts +6 -6
  415. package/src/unstable/ai/AiError.ts +1 -1
  416. package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
  417. package/src/unstable/ai/Chat.ts +6 -2
  418. package/src/unstable/ai/LanguageModel.ts +192 -65
  419. package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
  420. package/src/unstable/ai/ResponseIdTracker.ts +97 -0
  421. package/src/unstable/ai/Tool.ts +20 -0
  422. package/src/unstable/ai/index.ts +5 -0
  423. package/src/unstable/cli/Argument.ts +2 -4
  424. package/src/unstable/cli/CliOutput.ts +7 -5
  425. package/src/unstable/cli/Command.ts +5 -5
  426. package/src/unstable/cli/Flag.ts +2 -2
  427. package/src/unstable/cli/HelpDoc.ts +14 -12
  428. package/src/unstable/cli/Param.ts +15 -11
  429. package/src/unstable/cli/Primitive.ts +1 -1
  430. package/src/unstable/cli/Prompt.ts +81 -83
  431. package/src/unstable/cli/internal/completions/CommandDescriptor.ts +3 -2
  432. package/src/unstable/cli/internal/parser.ts +7 -4
  433. package/src/unstable/cluster/ClusterWorkflowEngine.ts +35 -30
  434. package/src/unstable/cluster/Entity.ts +13 -12
  435. package/src/unstable/cluster/Message.ts +6 -5
  436. package/src/unstable/cluster/MessageStorage.ts +26 -25
  437. package/src/unstable/cluster/Reply.ts +7 -4
  438. package/src/unstable/cluster/RunnerServer.ts +10 -13
  439. package/src/unstable/cluster/Runners.ts +8 -7
  440. package/src/unstable/cluster/Sharding.ts +24 -17
  441. package/src/unstable/cluster/ShardingConfig.ts +6 -6
  442. package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
  443. package/src/unstable/cluster/internal/entityManager.ts +27 -21
  444. package/src/unstable/devtools/DevToolsSchema.ts +3 -2
  445. package/src/unstable/http/Cookies.ts +7 -8
  446. package/src/unstable/http/Etag.ts +5 -3
  447. package/src/unstable/http/Headers.ts +6 -5
  448. package/src/unstable/http/HttpClient.ts +2 -1
  449. package/src/unstable/http/HttpClientRequest.ts +11 -9
  450. package/src/unstable/http/HttpClientResponse.ts +3 -2
  451. package/src/unstable/http/HttpIncomingMessage.ts +2 -1
  452. package/src/unstable/http/HttpMiddleware.ts +16 -15
  453. package/src/unstable/http/HttpPlatform.ts +3 -2
  454. package/src/unstable/http/HttpRouter.ts +9 -9
  455. package/src/unstable/http/HttpServer.ts +3 -9
  456. package/src/unstable/http/HttpServerError.ts +3 -2
  457. package/src/unstable/http/HttpServerRequest.ts +25 -21
  458. package/src/unstable/http/HttpServerResponse.ts +5 -4
  459. package/src/unstable/http/HttpTraceContext.ts +31 -17
  460. package/src/unstable/http/UrlParams.ts +11 -14
  461. package/src/unstable/httpapi/HttpApiBuilder.ts +9 -3
  462. package/src/unstable/httpapi/HttpApiError.ts +67 -12
  463. package/src/unstable/observability/OtlpExporter.ts +5 -2
  464. package/src/unstable/observability/OtlpTracer.ts +8 -4
  465. package/src/unstable/reactivity/Atom.ts +1 -4
  466. package/src/unstable/reactivity/AtomRegistry.ts +5 -3
  467. package/src/unstable/rpc/Rpc.ts +4 -3
  468. package/src/unstable/rpc/RpcClient.ts +10 -9
  469. package/src/unstable/rpc/RpcSchema.ts +6 -5
  470. package/src/unstable/rpc/RpcSerialization.ts +4 -1
  471. package/src/unstable/rpc/RpcServer.ts +3 -3
  472. package/src/unstable/socket/Socket.ts +14 -9
  473. package/src/unstable/sql/SqlClient.ts +5 -3
  474. package/src/unstable/workflow/DurableDeferred.ts +6 -6
  475. package/src/unstable/workflow/Workflow.ts +1 -1
  476. package/src/unstable/workflow/WorkflowEngine.ts +29 -20
  477. package/dist/NullOr.d.ts +0 -149
  478. package/dist/NullOr.d.ts.map +0 -1
  479. package/dist/NullOr.js +0 -152
  480. package/dist/NullOr.js.map +0 -1
  481. package/src/NullOr.ts +0 -204
@@ -8,6 +8,7 @@ import * as Exit from "../../Exit.ts"
8
8
  import * as Fiber from "../../Fiber.ts"
9
9
  import * as Latch from "../../Latch.ts"
10
10
  import * as Layer from "../../Layer.ts"
11
+ import * as Option from "../../Option.ts"
11
12
  import * as PrimaryKey from "../../PrimaryKey.ts"
12
13
  import * as RcMap from "../../RcMap.ts"
13
14
  import type * as Record from "../../Record.ts"
@@ -150,8 +151,9 @@ export const make = Effect.gen(function*() {
150
151
  const replies = yield* storage.repliesForUnfiltered([requestId])
151
152
  const last = replies[replies.length - 1]
152
153
  if (last && last._tag === "WithExit") {
153
- return last as WithExitEncoded<Workflow.ResultEncoded<any, any>>
154
+ return Option.some(last as WithExitEncoded<Workflow.ResultEncoded<any, any>>)
154
155
  }
156
+ return Option.none<WithExitEncoded<Workflow.ResultEncoded<any, any>>>()
155
157
  })
156
158
 
157
159
  const requestReply = Effect.fnUntraced(function*(options: {
@@ -162,10 +164,10 @@ export const make = Effect.gen(function*() {
162
164
  readonly id: string
163
165
  }) {
164
166
  const requestId = yield* requestIdFor(options)
165
- if (requestId === undefined) {
166
- return undefined
167
+ if (Option.isNone(requestId)) {
168
+ return Option.none<WithExitEncoded<Workflow.ResultEncoded<any, any>>>()
167
169
  }
168
- return yield* replyForRequestId(requestId)
170
+ return yield* replyForRequestId(requestId.value)
169
171
  })
170
172
 
171
173
  const resetActivityAttempt = Effect.fnUntraced(
@@ -182,8 +184,8 @@ export const make = Effect.gen(function*() {
182
184
  tag: "activity",
183
185
  id: activityPrimaryKey(options.activity.name, options.attempt)
184
186
  })
185
- if (requestId === undefined) return
186
- yield* sharding.reset(requestId)
187
+ if (Option.isNone(requestId)) return
188
+ yield* sharding.reset(requestId.value)
187
189
  },
188
190
  Effect.retry({
189
191
  times: 3,
@@ -218,13 +220,13 @@ export const make = Effect.gen(function*() {
218
220
  id: ""
219
221
  })
220
222
 
221
- const maybeSuspended =
222
- maybeReply && maybeReply.exit._tag === "Success" && maybeReply.exit.value._tag === "Suspended"
223
- ? maybeReply
224
- : undefined
223
+ const maybeSuspended = Option.filter(
224
+ maybeReply,
225
+ (reply) => reply.exit._tag === "Success" && reply.exit.value._tag === "Suspended"
226
+ )
225
227
 
226
- if (maybeSuspended === undefined) return
227
- yield* sharding.reset(Snowflake.Snowflake(maybeSuspended.requestId))
228
+ if (Option.isNone(maybeSuspended)) return
229
+ yield* sharding.reset(Snowflake.Snowflake(maybeSuspended.value.requestId))
228
230
  yield* sharding.pollStorage
229
231
  })
230
232
 
@@ -239,13 +241,13 @@ export const make = Effect.gen(function*() {
239
241
  tag: "resume",
240
242
  id: ""
241
243
  })
242
- if (requestId === undefined) {
244
+ if (Option.isNone(requestId)) {
243
245
  const client = (yield* RcMap.get(clientsPartial, options.workflowName))(options.executionId)
244
246
  return yield* client.resume({} as any, { discard: true })
245
247
  }
246
- const reply = yield* replyForRequestId(requestId)
247
- if (reply === undefined) return
248
- yield* sharding.reset(requestId)
248
+ const reply = yield* replyForRequestId(requestId.value)
249
+ if (Option.isNone(reply)) return
250
+ yield* sharding.reset(requestId.value)
249
251
  }, Effect.scoped)
250
252
 
251
253
  const engine = WorkflowEngine.makeUnsafe({
@@ -272,7 +274,7 @@ export const make = Effect.gen(function*() {
272
274
  }
273
275
  return engine.deferredResult(InterruptSignal).pipe(
274
276
  Effect.flatMap((maybeExit) => {
275
- if (maybeExit === undefined) {
277
+ if (Option.isNone(maybeExit)) {
276
278
  return Effect.void
277
279
  }
278
280
  instance.suspended = false
@@ -373,12 +375,12 @@ export const make = Effect.gen(function*() {
373
375
  tag: "run",
374
376
  id: ""
375
377
  })
376
- if (!reply) return undefined
377
- const exit = yield* (Schema.decodeUnknownEffect(exitSchema)(reply.exit) as Effect.Effect<
378
+ if (Option.isNone(reply)) return Option.none()
379
+ const exit = yield* (Schema.decodeUnknownEffect(exitSchema)(reply.value.exit) as Effect.Effect<
378
380
  Exit.Exit<any, any>,
379
381
  Schema.SchemaError
380
382
  >)
381
- return yield* exit
383
+ return Option.some(yield* exit)
382
384
  }, Effect.orDie),
383
385
 
384
386
  interrupt: Effect.fnUntraced(
@@ -392,10 +394,11 @@ export const make = Effect.gen(function*() {
392
394
  id: ""
393
395
  })
394
396
 
395
- const nonSuspendedReply = reply && (reply.exit._tag !== "Success" || reply.exit.value._tag !== "Suspended")
396
- ? reply
397
- : undefined
398
- if (nonSuspendedReply !== undefined) {
397
+ const nonSuspendedReply = Option.filter(
398
+ reply,
399
+ (reply) => reply.exit._tag !== "Success" || reply.exit.value._tag !== "Suspended"
400
+ )
401
+ if (Option.isSome(nonSuspendedReply)) {
399
402
  return
400
403
  }
401
404
 
@@ -463,13 +466,15 @@ export const make = Effect.gen(function*() {
463
466
  })
464
467
  ),
465
468
  Effect.map((reply) => {
466
- if (reply === undefined) {
467
- return undefined
469
+ if (Option.isNone(reply)) {
470
+ return Option.none<Exit.Exit<unknown, unknown>>()
468
471
  }
469
- const decoded = decodeDeferredWithExit(reply as any)
470
- return decoded.exit._tag === "Success"
471
- ? decoded.exit.value
472
- : decoded.exit
472
+ const decoded = decodeDeferredWithExit(reply.value as any)
473
+ return Option.some(
474
+ decoded.exit._tag === "Success"
475
+ ? decoded.exit.value
476
+ : decoded.exit
477
+ )
473
478
  }),
474
479
  Effect.retry({
475
480
  while: (e) => e._tag === "PersistenceError",
@@ -12,13 +12,13 @@ import { identity } from "../../Function.ts"
12
12
  import * as Hash from "../../Hash.ts"
13
13
  import type * as Latch from "../../Latch.ts"
14
14
  import * as Layer from "../../Layer.ts"
15
+ import * as Option from "../../Option.ts"
15
16
  import * as Predicate from "../../Predicate.ts"
16
17
  import * as Queue from "../../Queue.ts"
17
18
  import type * as Schedule from "../../Schedule.ts"
18
19
  import { Scope } from "../../Scope.ts"
19
20
  import * as ServiceMap from "../../ServiceMap.ts"
20
21
  import type * as Stream from "../../Stream.ts"
21
- import * as UndefinedOr from "../../UndefinedOr.ts"
22
22
  import * as Headers from "../http/Headers.ts"
23
23
  import * as Rpc from "../rpc/Rpc.ts"
24
24
  import * as RpcClient from "../rpc/RpcClient.ts"
@@ -459,24 +459,24 @@ export declare namespace Replier {
459
459
  */
460
460
  export class Request<Rpc extends Rpc.Any> extends Data.Class<
461
461
  Envelope.Request<Rpc> & {
462
- readonly lastSentChunk: Reply.Chunk<Rpc> | undefined
462
+ readonly lastSentChunk: Option.Option<Reply.Chunk<Rpc>>
463
463
  }
464
464
  > {
465
465
  /**
466
466
  * @since 4.0.0
467
467
  */
468
- get lastSentChunkValue(): Rpc.SuccessChunk<Rpc> | undefined {
469
- return UndefinedOr.map(this.lastSentChunk, (chunk) => Arr.lastNonEmpty(chunk.values))
468
+ get lastSentChunkValue(): Option.Option<Rpc.SuccessChunk<Rpc>> {
469
+ return Option.map(this.lastSentChunk, (chunk) => Arr.lastNonEmpty(chunk.values))
470
470
  }
471
471
 
472
472
  /**
473
473
  * @since 4.0.0
474
474
  */
475
475
  get nextSequence(): number {
476
- if (this.lastSentChunk === undefined) {
476
+ if (Option.isNone(this.lastSentChunk)) {
477
477
  return 0
478
478
  }
479
- return this.lastSentChunk.sequence + 1
479
+ return this.lastSentChunk.value.sequence + 1
480
480
  }
481
481
  }
482
482
 
@@ -524,10 +524,11 @@ export const makeTestClient: <Type extends string, Rpcs extends Rpc.Any, LA, LE,
524
524
  services: services as any,
525
525
  concurrency: options?.concurrency ?? 1,
526
526
  build: entity.protocol.toHandlers(handlers as any).pipe(
527
- Effect.provideServices(services.pipe(
528
- ServiceMap.add(CurrentRunnerAddress, runnerAddress),
529
- ServiceMap.omit(Scope)
530
- ))
527
+ Effect.provideServices(ServiceMap.mutate(services, (services) =>
528
+ services.pipe(
529
+ ServiceMap.add(CurrentRunnerAddress, runnerAddress),
530
+ ServiceMap.omit(Scope)
531
+ )))
531
532
  ) as any
532
533
  })
533
534
  return Effect.void
@@ -570,7 +571,7 @@ export const makeTestClient: <Type extends string, Rpcs extends Rpc.Any, LA, LE,
570
571
  [Envelope.TypeId]: Envelope.TypeId,
571
572
  address,
572
573
  requestId: Snowflake.Snowflake(message.id),
573
- lastSentChunk: undefined
574
+ lastSentChunk: Option.none()
574
575
  }) as any
575
576
  })
576
577
  }
@@ -619,7 +620,7 @@ export const keepAlive: (
619
620
  spanId: span.spanId,
620
621
  sampled: span.sampled
621
622
  }),
622
- lastReceivedReply: undefined,
623
+ lastReceivedReply: Option.none(),
623
624
  respond: () => Effect.void
624
625
  }),
625
626
  true
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as Data from "../../Data.ts"
5
5
  import * as Effect from "../../Effect.ts"
6
+ import * as Option from "../../Option.ts"
6
7
  import * as Schema from "../../Schema.ts"
7
8
  import type { ServiceMap } from "../../ServiceMap.ts"
8
9
  import * as Rpc from "../rpc/Rpc.ts"
@@ -36,7 +37,7 @@ export const incomingLocalFromOutgoing = <R extends Rpc.Any>(self: Outgoing<R>):
36
37
  return new IncomingRequestLocal({
37
38
  envelope: self.envelope,
38
39
  respond: self.respond,
39
- lastSentReply: undefined
40
+ lastSentReply: Option.none()
40
41
  })
41
42
  }
42
43
 
@@ -46,7 +47,7 @@ export const incomingLocalFromOutgoing = <R extends Rpc.Any>(self: Outgoing<R>):
46
47
  */
47
48
  export class IncomingRequest<R extends Rpc.Any> extends Data.TaggedClass("IncomingRequest")<{
48
49
  readonly envelope: Envelope.PartialRequest
49
- readonly lastSentReply: Reply.Encoded | undefined
50
+ readonly lastSentReply: Option.Option<Reply.Encoded>
50
51
  readonly respond: (reply: Reply.ReplyWithContext<R>) => Effect.Effect<void, MalformedMessage | PersistenceError>
51
52
  }> {}
52
53
 
@@ -56,7 +57,7 @@ export class IncomingRequest<R extends Rpc.Any> extends Data.TaggedClass("Incomi
56
57
  */
57
58
  export class IncomingRequestLocal<R extends Rpc.Any> extends Data.TaggedClass("IncomingRequestLocal")<{
58
59
  readonly envelope: Envelope.Request<R>
59
- readonly lastSentReply: Reply.Reply<R> | undefined
60
+ readonly lastSentReply: Option.Option<Reply.Reply<R>>
60
61
  readonly respond: (reply: Reply.Reply<R>) => Effect.Effect<void, MalformedMessage | PersistenceError>
61
62
  }> {}
62
63
 
@@ -82,7 +83,7 @@ export type Outgoing<R extends Rpc.Any> = OutgoingRequest<R> | OutgoingEnvelope
82
83
  export class OutgoingRequest<R extends Rpc.Any> extends Data.TaggedClass("OutgoingRequest")<{
83
84
  readonly envelope: Envelope.Request<R>
84
85
  readonly services: ServiceMap<Rpc.Services<R>>
85
- readonly lastReceivedReply: Reply.Reply<R> | undefined
86
+ readonly lastReceivedReply: Option.Option<Reply.Reply<R>>
86
87
  readonly rpc: R
87
88
  readonly respond: (reply: Reply.Reply<R>) => Effect.Effect<void>
88
89
  }> {
@@ -196,7 +197,7 @@ export const deserializeLocal = <Rpc extends Rpc.Any>(
196
197
  ...encoded,
197
198
  payload
198
199
  } as any),
199
- lastSentReply: undefined,
200
+ lastSentReply: Option.none(),
200
201
  respond: self.respond
201
202
  })
202
203
  )
@@ -8,11 +8,10 @@ import * as Effect from "../../Effect.ts"
8
8
  import * as Exit from "../../Exit.ts"
9
9
  import * as Latch from "../../Latch.ts"
10
10
  import * as Layer from "../../Layer.ts"
11
- import type * as Option from "../../Option.ts"
11
+ import * as Option from "../../Option.ts"
12
12
  import type { Predicate } from "../../Predicate.ts"
13
13
  import * as Schema from "../../Schema.ts"
14
14
  import * as ServiceMap from "../../ServiceMap.ts"
15
- import * as UndefinedOr from "../../UndefinedOr.ts"
16
15
  import type * as Rpc from "../rpc/Rpc.ts"
17
16
  import { EntityNotAssignedToRunner, MalformedMessage, type PersistenceError } from "./ClusterError.ts"
18
17
  import * as DeliverAt from "./DeliverAt.ts"
@@ -81,7 +80,7 @@ export class MessageStorage extends ServiceMap.Service<MessageStorage, {
81
80
  readonly tag: string
82
81
  readonly id: string
83
82
  }
84
- ) => Effect.Effect<Snowflake.Snowflake | undefined, PersistenceError>
83
+ ) => Effect.Effect<Option.Option<Snowflake.Snowflake>, PersistenceError>
85
84
 
86
85
  /**
87
86
  * For locally sent messages, register a handler to process the replies.
@@ -187,7 +186,7 @@ export declare namespace SaveResult {
187
186
  export interface Duplicate<R extends Rpc.Any> {
188
187
  readonly _tag: "Duplicate"
189
188
  readonly originalId: Snowflake.Snowflake
190
- readonly lastReceivedReply: Reply.Reply<R> | undefined
189
+ readonly lastReceivedReply: Option.Option<Reply.Reply<R>>
191
190
  }
192
191
 
193
192
  /**
@@ -197,7 +196,7 @@ export declare namespace SaveResult {
197
196
  export interface DuplicateEncoded {
198
197
  readonly _tag: "Duplicate"
199
198
  readonly originalId: Snowflake.Snowflake
200
- readonly lastReceivedReply: Reply.Encoded | undefined
199
+ readonly lastReceivedReply: Option.Option<Reply.Encoded>
201
200
  }
202
201
 
203
202
  /**
@@ -240,7 +239,7 @@ export type Encoded = {
240
239
  */
241
240
  readonly requestIdForPrimaryKey: (
242
241
  primaryKey: string
243
- ) => Effect.Effect<Snowflake.Snowflake | undefined, PersistenceError>
242
+ ) => Effect.Effect<Option.Option<Snowflake.Snowflake>, PersistenceError>
244
243
 
245
244
  /**
246
245
  * Retrieves the replies for the specified requests.
@@ -277,7 +276,7 @@ export type Encoded = {
277
276
  ) => Effect.Effect<
278
277
  Array<{
279
278
  readonly envelope: Envelope.Encoded
280
- readonly lastSentReply: Reply.Encoded | undefined
279
+ readonly lastSentReply: Option.Option<Reply.Encoded>
281
280
  }>,
282
281
  PersistenceError
283
282
  >
@@ -291,7 +290,7 @@ export type Encoded = {
291
290
  ) => Effect.Effect<
292
291
  Array<{
293
292
  readonly envelope: Envelope.Encoded
294
- readonly lastSentReply: Reply.Encoded | undefined
293
+ readonly lastSentReply: Option.Option<Reply.Encoded>
295
294
  }>,
296
295
  PersistenceError
297
296
  >
@@ -463,18 +462,18 @@ export const makeEncoded: (encoded: Encoded) => Effect.Effect<
463
462
  })
464
463
  ),
465
464
  Effect.flatMap((result) => {
466
- if (result._tag === "Success" || result.lastReceivedReply === undefined) {
465
+ if (result._tag === "Success" || Option.isNone(result.lastReceivedReply)) {
467
466
  return Effect.succeed(result as SaveResult<any>)
468
467
  }
469
468
  const duplicate = result
470
469
  const schema = Reply.Reply(message.rpc)
471
- return Schema.decodeEffect(schema)(result.lastReceivedReply).pipe(
470
+ return Schema.decodeEffect(schema)(result.lastReceivedReply.value).pipe(
472
471
  Effect.provideServices(message.services),
473
472
  MalformedMessage.refail,
474
473
  Effect.map((reply) =>
475
474
  SaveResult.Duplicate({
476
475
  originalId: duplicate.originalId,
477
- lastReceivedReply: reply
476
+ lastReceivedReply: Option.some(reply)
478
477
  })
479
478
  )
480
479
  )
@@ -546,7 +545,7 @@ export const makeEncoded: (encoded: Encoded) => Effect.Effect<
546
545
  const decodeMessages = (
547
546
  envelopes: Array<{
548
547
  readonly envelope: Envelope.Encoded
549
- readonly lastSentReply: Reply.Encoded | undefined
548
+ readonly lastSentReply: Option.Option<Reply.Encoded>
550
549
  }>
551
550
  ) => {
552
551
  const messages: Array<Message.Incoming<any>> = []
@@ -655,7 +654,7 @@ export const noop: MessageStorage["Service"] = Effect.runSync(make({
655
654
  clearReplies: () => Effect.void,
656
655
  repliesFor: () => Effect.succeed([]),
657
656
  repliesForUnfiltered: () => Effect.succeed([]),
658
- requestIdForPrimaryKey: () => Effect.undefined,
657
+ requestIdForPrimaryKey: () => Effect.succeedNone,
659
658
  unprocessedMessages: () => Effect.succeed([]),
660
659
  unprocessedMessagesById: () => Effect.succeed([]),
661
660
  resetAddress: () => Effect.void,
@@ -693,7 +692,7 @@ export class MemoryDriver extends ServiceMap.Service<MemoryDriver>()("effect/clu
693
692
  const unprocessedWith = (predicate: Predicate<Envelope.Encoded>) => {
694
693
  const messages: Array<{
695
694
  readonly envelope: Envelope.Encoded
696
- readonly lastSentReply: Reply.Encoded | undefined
695
+ readonly lastSentReply: Option.Option<Reply.Encoded>
697
696
  }> = []
698
697
  const now = clock.currentTimeMillisUnsafe()
699
698
  for (const envelope of unprocessed) {
@@ -707,12 +706,12 @@ export class MemoryDriver extends ServiceMap.Service<MemoryDriver>()("effect/clu
707
706
  }
708
707
  messages.push({
709
708
  envelope,
710
- lastSentReply: entry?.replies[entry.replies.length - 1]
709
+ lastSentReply: Option.fromNullishOr(entry?.replies[entry.replies.length - 1])
711
710
  })
712
711
  } else {
713
712
  messages.push({
714
713
  envelope,
715
- lastSentReply: undefined
714
+ lastSentReply: Option.none()
716
715
  })
717
716
  }
718
717
  }
@@ -751,9 +750,11 @@ export class MemoryDriver extends ServiceMap.Service<MemoryDriver>()("effect/clu
751
750
  if (existing) {
752
751
  return SaveResultEncoded.Duplicate({
753
752
  originalId: Snowflake.Snowflake(existing.envelope.requestId),
754
- lastReceivedReply: existing.replies.length === 1 && existing.replies[0]._tag === "WithExit"
755
- ? existing.replies[0]
756
- : existing.lastReceivedChunk
753
+ lastReceivedReply: Option.fromNullishOr(
754
+ existing.replies.length === 1 && existing.replies[0]._tag === "WithExit"
755
+ ? existing.replies[0]
756
+ : existing.lastReceivedChunk
757
+ )
757
758
  })
758
759
  }
759
760
  if (envelope._tag === "Request") {
@@ -797,7 +798,7 @@ export class MemoryDriver extends ServiceMap.Service<MemoryDriver>()("effect/clu
797
798
  requestIdForPrimaryKey: (primaryKey) =>
798
799
  Effect.sync(() => {
799
800
  const entry = requestsByPrimaryKey.get(primaryKey)
800
- return UndefinedOr.map(entry?.envelope.requestId, Snowflake.Snowflake)
801
+ return Option.map(Option.fromNullishOr(entry?.envelope.requestId), Snowflake.Snowflake)
801
802
  }),
802
803
  repliesFor: (requestIds) => Effect.sync(() => repliesFor(requestIds)),
803
804
  repliesForUnfiltered: (requestIds) =>
@@ -808,7 +809,7 @@ export class MemoryDriver extends ServiceMap.Service<MemoryDriver>()("effect/clu
808
809
  const now = clock.currentTimeMillisUnsafe()
809
810
  const messages = Arr.empty<{
810
811
  envelope: Envelope.Encoded
811
- lastSentReply: Reply.Encoded | undefined
812
+ lastSentReply: Option.Option<Reply.Encoded>
812
813
  }>()
813
814
  for (let index = 0; index < journal.length; index++) {
814
815
  const envelope = journal[index]
@@ -823,12 +824,12 @@ export class MemoryDriver extends ServiceMap.Service<MemoryDriver>()("effect/clu
823
824
  }
824
825
  messages.push({
825
826
  envelope,
826
- lastSentReply: entry.replies[entry.replies.length - 1]
827
+ lastSentReply: Option.fromNullishOr(entry.replies[entry.replies.length - 1])
827
828
  })
828
829
  } else {
829
830
  messages.push({
830
831
  envelope,
831
- lastSentReply: undefined
832
+ lastSentReply: Option.none()
832
833
  })
833
834
  unprocessed.delete(envelope)
834
835
  }
@@ -906,11 +907,11 @@ export const layerMemory: Layer.Layer<
906
907
  const EnvelopeWithReply: Schema.Struct<
907
908
  {
908
909
  readonly envelope: Schema.Decoder<Envelope.PartialRequest | Envelope.AckChunk | Envelope.Interrupt>
909
- readonly lastSentReply: Schema.UndefinedOr<Schema.Codec<Reply.Encoded>>
910
+ readonly lastSentReply: Schema.Option<Schema.Codec<Reply.Encoded>>
910
911
  }
911
912
  > = Schema.Struct({
912
913
  envelope: Schema.toCodecJson(Envelope.Partial),
913
- lastSentReply: Schema.UndefinedOr(Reply.Encoded)
914
+ lastSentReply: Schema.Option(Reply.Encoded)
914
915
  })
915
916
 
916
917
  const decodeEnvelopeWithReply = Schema.decodeEffect(EnvelopeWithReply)
@@ -352,12 +352,15 @@ export const serialize = <R extends Rpc.Any>(
352
352
  */
353
353
  export const serializeLastReceived = <R extends Rpc.Any>(
354
354
  self: OutgoingRequest<R>
355
- ): Effect.Effect<Encoded | undefined, MalformedMessage> => {
356
- if (self.lastReceivedReply === undefined) {
357
- return Effect.undefined
355
+ ): Effect.Effect<Option.Option<Encoded>, MalformedMessage> => {
356
+ const lastReceivedReply = self.lastReceivedReply
357
+ if (lastReceivedReply._tag === "None") {
358
+ return Effect.succeedNone
358
359
  }
359
360
  const schema = Reply(self.rpc)
360
361
  return MalformedMessage.refail(
361
- Effect.provideServices(Schema.encodeEffect(schema)(self.lastReceivedReply), self.services)
362
+ Effect.provideServices(Schema.encodeEffect(schema)(lastReceivedReply.value), self.services)
363
+ ).pipe(
364
+ Effect.map(Option.some)
362
365
  )
363
366
  }
@@ -6,6 +6,7 @@ import type * as Exit from "../../Exit.ts"
6
6
  import * as Fiber from "../../Fiber.ts"
7
7
  import { constant } from "../../Function.ts"
8
8
  import * as Layer from "../../Layer.ts"
9
+ import * as Option from "../../Option.ts"
9
10
  import * as Queue from "../../Queue.ts"
10
11
  import * as RpcServer from "../rpc/RpcServer.ts"
11
12
  import type * as ClusterError from "./ClusterError.ts"
@@ -36,23 +37,19 @@ export const layerHandlers = Runners.Rpcs.toLayer(Effect.gen(function*() {
36
37
  ? new Message.IncomingRequest({
37
38
  envelope,
38
39
  respond: constVoid,
39
- lastSentReply: undefined
40
+ lastSentReply: Option.none()
40
41
  })
41
42
  : new Message.IncomingEnvelope({ envelope })
42
43
  ),
43
44
  Effect: ({ persisted, request }) => {
44
- let replyEncoded:
45
- | Effect.Effect<
46
- Reply.Encoded,
47
- ClusterError.EntityNotAssignedToRunner
48
- >
49
- | undefined = undefined
45
+ let replyEncoded: Option.Option<Effect.Effect<Reply.Encoded, ClusterError.EntityNotAssignedToRunner>> = Option
46
+ .none()
50
47
  let resume = (reply: Effect.Effect<Reply.Encoded, ClusterError.EntityNotAssignedToRunner>) => {
51
- replyEncoded = reply
48
+ replyEncoded = Option.some(reply)
52
49
  }
53
50
  const message = new Message.IncomingRequest({
54
51
  envelope: request,
55
- lastSentReply: undefined,
52
+ lastSentReply: Option.none(),
56
53
  respond(reply) {
57
54
  resume(Effect.orDie(Reply.serialize(reply)))
58
55
  return Effect.void
@@ -89,8 +86,8 @@ export const layerHandlers = Runners.Rpcs.toLayer(Effect.gen(function*() {
89
86
  return Effect.andThen(
90
87
  sharding.send(message),
91
88
  Effect.callback<Reply.Encoded, ClusterError.EntityNotAssignedToRunner>((resume_) => {
92
- if (replyEncoded) {
93
- resume_(replyEncoded)
89
+ if (Option.isSome(replyEncoded)) {
90
+ resume_(replyEncoded.value)
94
91
  } else {
95
92
  resume = resume_
96
93
  }
@@ -103,7 +100,7 @@ export const layerHandlers = Runners.Rpcs.toLayer(Effect.gen(function*() {
103
100
  (queue) => {
104
101
  const message = new Message.IncomingRequest({
105
102
  envelope: request,
106
- lastSentReply: undefined,
103
+ lastSentReply: Option.none(),
107
104
  respond(reply) {
108
105
  return Effect.flatMap(Reply.serialize(reply), (reply) => {
109
106
  Queue.offerUnsafe(queue, reply)
@@ -191,6 +188,6 @@ export const layerClientOnly: Layer.Layer<
191
188
  Layer.provide(RunnerHealth.layerNoop),
192
189
  Layer.updateService(ShardingConfig, (config) => ({
193
190
  ...config,
194
- runnerAddress: undefined
191
+ runnerAddress: Option.none()
195
192
  }))
196
193
  )
@@ -5,6 +5,7 @@ import * as Effect from "../../Effect.ts"
5
5
  import * as Exit from "../../Exit.ts"
6
6
  import * as Latch from "../../Latch.ts"
7
7
  import * as Layer from "../../Layer.ts"
8
+ import * as Option from "../../Option.ts"
8
9
  import * as Queue from "../../Queue.ts"
9
10
  import * as RcMap from "../../RcMap.ts"
10
11
  import * as Schema from "../../Schema.ts"
@@ -80,7 +81,7 @@ export class Runners extends ServiceMap.Service<Runners, {
80
81
  */
81
82
  readonly notify: <R extends Rpc.Any>(
82
83
  options: {
83
- readonly address: RunnerAddress | undefined
84
+ readonly address: Option.Option<RunnerAddress>
84
85
  readonly message: Message.Outgoing<R>
85
86
  readonly discard: boolean
86
87
  }
@@ -166,8 +167,8 @@ export const make: (options: Omit<Runners["Service"], "sendLocal" | "notifyLocal
166
167
  Duplicate: ({ lastReceivedReply, originalId }) => {
167
168
  // If the last received reply is an exit, we can just return it
168
169
  // as the response.
169
- if (lastReceivedReply && lastReceivedReply._tag === "WithExit") {
170
- return message.respond(lastReceivedReply.withRequestId(message.envelope.requestId))
170
+ if (Option.isSome(lastReceivedReply) && lastReceivedReply.value._tag === "WithExit") {
171
+ return message.respond(lastReceivedReply.value.withRequestId(message.envelope.requestId))
171
172
  }
172
173
  requestIdRewrites.set(message.envelope.requestId, originalId)
173
174
  return afterPersist(
@@ -341,10 +342,10 @@ export const make: (options: Omit<Runners["Service"], "sendLocal" | "notifyLocal
341
342
  return notifyWith(message, (message, duplicate) => {
342
343
  if (discard || message._tag === "OutgoingEnvelope") {
343
344
  return options.notify(options_)
344
- } else if (!duplicate && options_.address) {
345
+ } else if (!duplicate && Option.isSome(options_.address)) {
345
346
  return Effect.catch(
346
347
  options.send({
347
- address: options_.address,
348
+ address: options_.address.value,
348
349
  message
349
350
  }),
350
351
  (_) => replyFromStorage(message)
@@ -584,11 +585,11 @@ export const makeRpc: Effect.Effect<
584
585
  })
585
586
  },
586
587
  notify({ address, message }) {
587
- if (!address) {
588
+ if (Option.isNone(address)) {
588
589
  return Effect.void
589
590
  }
590
591
  const envelope = message.envelope
591
- return RcMap.get(clients, address).pipe(
592
+ return RcMap.get(clients, address.value).pipe(
592
593
  Effect.flatMap((client) => client.Notify({ envelope })),
593
594
  Effect.scoped,
594
595
  Effect.ignore