effect 4.0.0-beta.31 → 4.0.0-beta.32

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 (464) 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.map +1 -1
  37. package/dist/Effect.js +3 -4
  38. package/dist/Effect.js.map +1 -1
  39. package/dist/Fiber.d.ts +2 -1
  40. package/dist/Fiber.d.ts.map +1 -1
  41. package/dist/Fiber.js.map +1 -1
  42. package/dist/FiberHandle.d.ts +9 -8
  43. package/dist/FiberHandle.d.ts.map +1 -1
  44. package/dist/FiberHandle.js +8 -7
  45. package/dist/FiberHandle.js.map +1 -1
  46. package/dist/FiberMap.d.ts +20 -19
  47. package/dist/FiberMap.d.ts.map +1 -1
  48. package/dist/FiberMap.js +6 -6
  49. package/dist/FiberMap.js.map +1 -1
  50. package/dist/FileSystem.d.ts +17 -16
  51. package/dist/FileSystem.d.ts.map +1 -1
  52. package/dist/FileSystem.js +10 -7
  53. package/dist/FileSystem.js.map +1 -1
  54. package/dist/Graph.d.ts +64 -64
  55. package/dist/Graph.d.ts.map +1 -1
  56. package/dist/Graph.js +53 -53
  57. package/dist/Graph.js.map +1 -1
  58. package/dist/HashMap.d.ts +11 -5
  59. package/dist/HashMap.d.ts.map +1 -1
  60. package/dist/HashMap.js +3 -1
  61. package/dist/HashMap.js.map +1 -1
  62. package/dist/Iterable.d.ts +11 -11
  63. package/dist/Iterable.d.ts.map +1 -1
  64. package/dist/Iterable.js +12 -12
  65. package/dist/Iterable.js.map +1 -1
  66. package/dist/Latch.d.ts +69 -3
  67. package/dist/Latch.d.ts.map +1 -1
  68. package/dist/Latch.js +58 -0
  69. package/dist/Latch.js.map +1 -1
  70. package/dist/Layer.d.ts +84 -0
  71. package/dist/Layer.d.ts.map +1 -1
  72. package/dist/Layer.js +27 -0
  73. package/dist/Layer.js.map +1 -1
  74. package/dist/Number.d.ts +74 -18
  75. package/dist/Number.d.ts.map +1 -1
  76. package/dist/Number.js +34 -15
  77. package/dist/Number.js.map +1 -1
  78. package/dist/Option.d.ts +2 -0
  79. package/dist/Option.d.ts.map +1 -1
  80. package/dist/Option.js.map +1 -1
  81. package/dist/PartitionedSemaphore.d.ts +183 -0
  82. package/dist/PartitionedSemaphore.d.ts.map +1 -0
  83. package/dist/PartitionedSemaphore.js +231 -0
  84. package/dist/PartitionedSemaphore.js.map +1 -0
  85. package/dist/PubSub.d.ts +5 -4
  86. package/dist/PubSub.d.ts.map +1 -1
  87. package/dist/PubSub.js +6 -5
  88. package/dist/PubSub.js.map +1 -1
  89. package/dist/Queue.d.ts +3 -3
  90. package/dist/Queue.d.ts.map +1 -1
  91. package/dist/Queue.js +2 -2
  92. package/dist/Queue.js.map +1 -1
  93. package/dist/Record.d.ts +40 -40
  94. package/dist/Record.d.ts.map +1 -1
  95. package/dist/Record.js +16 -15
  96. package/dist/Record.js.map +1 -1
  97. package/dist/Scheduler.d.ts +25 -123
  98. package/dist/Scheduler.d.ts.map +1 -1
  99. package/dist/Scheduler.js +20 -123
  100. package/dist/Scheduler.js.map +1 -1
  101. package/dist/Schema.d.ts +30 -0
  102. package/dist/Schema.d.ts.map +1 -1
  103. package/dist/Schema.js +28 -1
  104. package/dist/Schema.js.map +1 -1
  105. package/dist/SchemaGetter.js +6 -4
  106. package/dist/SchemaGetter.js.map +1 -1
  107. package/dist/SchemaTransformation.d.ts.map +1 -1
  108. package/dist/SchemaTransformation.js +32 -27
  109. package/dist/SchemaTransformation.js.map +1 -1
  110. package/dist/Semaphore.d.ts +149 -53
  111. package/dist/Semaphore.d.ts.map +1 -1
  112. package/dist/Semaphore.js +137 -117
  113. package/dist/Semaphore.js.map +1 -1
  114. package/dist/ServiceMap.d.ts +26 -0
  115. package/dist/ServiceMap.d.ts.map +1 -1
  116. package/dist/ServiceMap.js +36 -21
  117. package/dist/ServiceMap.js.map +1 -1
  118. package/dist/Stream.js +1 -1
  119. package/dist/Stream.js.map +1 -1
  120. package/dist/String.d.ts +114 -47
  121. package/dist/String.d.ts.map +1 -1
  122. package/dist/String.js +29 -47
  123. package/dist/String.js.map +1 -1
  124. package/dist/SubscriptionRef.d.ts +1 -2
  125. package/dist/SubscriptionRef.d.ts.map +1 -1
  126. package/dist/SubscriptionRef.js +81 -115
  127. package/dist/SubscriptionRef.js.map +1 -1
  128. package/dist/Terminal.d.ts +2 -1
  129. package/dist/Terminal.d.ts.map +1 -1
  130. package/dist/Terminal.js.map +1 -1
  131. package/dist/Tracer.d.ts +5 -4
  132. package/dist/Tracer.d.ts.map +1 -1
  133. package/dist/Tracer.js +2 -1
  134. package/dist/Tracer.js.map +1 -1
  135. package/dist/Trie.d.ts +26 -14
  136. package/dist/Trie.d.ts.map +1 -1
  137. package/dist/Trie.js +8 -4
  138. package/dist/Trie.js.map +1 -1
  139. package/dist/TxHashMap.d.ts +77 -59
  140. package/dist/TxHashMap.d.ts.map +1 -1
  141. package/dist/TxHashMap.js +25 -19
  142. package/dist/TxHashMap.js.map +1 -1
  143. package/dist/TxSemaphore.d.ts +162 -2
  144. package/dist/TxSemaphore.d.ts.map +1 -1
  145. package/dist/TxSemaphore.js +16 -2
  146. package/dist/TxSemaphore.js.map +1 -1
  147. package/dist/index.d.ts +88 -32
  148. package/dist/index.d.ts.map +1 -1
  149. package/dist/index.js +88 -32
  150. package/dist/index.js.map +1 -1
  151. package/dist/internal/dateTime.js +9 -9
  152. package/dist/internal/dateTime.js.map +1 -1
  153. package/dist/internal/effect.js +20 -89
  154. package/dist/internal/effect.js.map +1 -1
  155. package/dist/internal/hashMap.js +2 -1
  156. package/dist/internal/hashMap.js.map +1 -1
  157. package/dist/internal/option.js +6 -0
  158. package/dist/internal/option.js.map +1 -1
  159. package/dist/internal/trie.js +3 -3
  160. package/dist/internal/trie.js.map +1 -1
  161. package/dist/unstable/ai/AiError.js +1 -1
  162. package/dist/unstable/ai/AiError.js.map +1 -1
  163. package/dist/unstable/ai/AnthropicStructuredOutput.d.ts.map +1 -1
  164. package/dist/unstable/ai/AnthropicStructuredOutput.js +4 -0
  165. package/dist/unstable/ai/AnthropicStructuredOutput.js.map +1 -1
  166. package/dist/unstable/ai/Chat.d.ts.map +1 -1
  167. package/dist/unstable/ai/Chat.js +2 -2
  168. package/dist/unstable/ai/Chat.js.map +1 -1
  169. package/dist/unstable/ai/OpenAiStructuredOutput.d.ts.map +1 -1
  170. package/dist/unstable/ai/OpenAiStructuredOutput.js +4 -0
  171. package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
  172. package/dist/unstable/ai/Tool.d.ts +14 -0
  173. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  174. package/dist/unstable/ai/Tool.js +13 -0
  175. package/dist/unstable/ai/Tool.js.map +1 -1
  176. package/dist/unstable/cli/Argument.d.ts +2 -4
  177. package/dist/unstable/cli/Argument.d.ts.map +1 -1
  178. package/dist/unstable/cli/Argument.js +1 -3
  179. package/dist/unstable/cli/Argument.js.map +1 -1
  180. package/dist/unstable/cli/CliOutput.d.ts +3 -2
  181. package/dist/unstable/cli/CliOutput.d.ts.map +1 -1
  182. package/dist/unstable/cli/CliOutput.js +4 -3
  183. package/dist/unstable/cli/CliOutput.js.map +1 -1
  184. package/dist/unstable/cli/Command.d.ts +3 -2
  185. package/dist/unstable/cli/Command.d.ts.map +1 -1
  186. package/dist/unstable/cli/Command.js +3 -3
  187. package/dist/unstable/cli/Command.js.map +1 -1
  188. package/dist/unstable/cli/Flag.d.ts +2 -2
  189. package/dist/unstable/cli/Flag.d.ts.map +1 -1
  190. package/dist/unstable/cli/Flag.js +1 -1
  191. package/dist/unstable/cli/Flag.js.map +1 -1
  192. package/dist/unstable/cli/HelpDoc.d.ts +14 -12
  193. package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
  194. package/dist/unstable/cli/Param.d.ts +4 -4
  195. package/dist/unstable/cli/Param.d.ts.map +1 -1
  196. package/dist/unstable/cli/Param.js +7 -7
  197. package/dist/unstable/cli/Param.js.map +1 -1
  198. package/dist/unstable/cli/Primitive.d.ts +1 -1
  199. package/dist/unstable/cli/Primitive.d.ts.map +1 -1
  200. package/dist/unstable/cli/Primitive.js.map +1 -1
  201. package/dist/unstable/cli/Prompt.js +71 -67
  202. package/dist/unstable/cli/Prompt.js.map +1 -1
  203. package/dist/unstable/cli/internal/completions/CommandDescriptor.js +9 -2
  204. package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
  205. package/dist/unstable/cli/internal/parser.js +8 -3
  206. package/dist/unstable/cli/internal/parser.js.map +1 -1
  207. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts +3 -2
  208. package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  209. package/dist/unstable/cluster/ClusterWorkflowEngine.js +25 -23
  210. package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
  211. package/dist/unstable/cluster/Entity.d.ts +3 -2
  212. package/dist/unstable/cluster/Entity.d.ts.map +1 -1
  213. package/dist/unstable/cluster/Entity.js +7 -7
  214. package/dist/unstable/cluster/Entity.js.map +1 -1
  215. package/dist/unstable/cluster/Message.d.ts +4 -3
  216. package/dist/unstable/cluster/Message.d.ts.map +1 -1
  217. package/dist/unstable/cluster/Message.js +3 -2
  218. package/dist/unstable/cluster/Message.js.map +1 -1
  219. package/dist/unstable/cluster/MessageStorage.d.ts +10 -10
  220. package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
  221. package/dist/unstable/cluster/MessageStorage.js +12 -12
  222. package/dist/unstable/cluster/MessageStorage.js.map +1 -1
  223. package/dist/unstable/cluster/Reply.d.ts +2 -1
  224. package/dist/unstable/cluster/Reply.d.ts.map +1 -1
  225. package/dist/unstable/cluster/Reply.js +4 -3
  226. package/dist/unstable/cluster/Reply.js.map +1 -1
  227. package/dist/unstable/cluster/RunnerServer.d.ts.map +1 -1
  228. package/dist/unstable/cluster/RunnerServer.js +9 -8
  229. package/dist/unstable/cluster/RunnerServer.js.map +1 -1
  230. package/dist/unstable/cluster/Runners.d.ts +2 -1
  231. package/dist/unstable/cluster/Runners.d.ts.map +1 -1
  232. package/dist/unstable/cluster/Runners.js +7 -6
  233. package/dist/unstable/cluster/Runners.js.map +1 -1
  234. package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
  235. package/dist/unstable/cluster/Sharding.js +19 -13
  236. package/dist/unstable/cluster/Sharding.js.map +1 -1
  237. package/dist/unstable/cluster/ShardingConfig.d.ts +5 -4
  238. package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
  239. package/dist/unstable/cluster/ShardingConfig.js +4 -4
  240. package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
  241. package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
  242. package/dist/unstable/cluster/SqlMessageStorage.js +19 -18
  243. package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
  244. package/dist/unstable/cluster/internal/entityManager.js +9 -10
  245. package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
  246. package/dist/unstable/devtools/DevToolsSchema.d.ts +2 -1
  247. package/dist/unstable/devtools/DevToolsSchema.d.ts.map +1 -1
  248. package/dist/unstable/devtools/DevToolsSchema.js +1 -4
  249. package/dist/unstable/devtools/DevToolsSchema.js.map +1 -1
  250. package/dist/unstable/http/Cookies.d.ts +5 -4
  251. package/dist/unstable/http/Cookies.d.ts.map +1 -1
  252. package/dist/unstable/http/Cookies.js +3 -4
  253. package/dist/unstable/http/Cookies.js.map +1 -1
  254. package/dist/unstable/http/Etag.d.ts.map +1 -1
  255. package/dist/unstable/http/Etag.js +5 -1
  256. package/dist/unstable/http/Etag.js.map +1 -1
  257. package/dist/unstable/http/Headers.d.ts +3 -2
  258. package/dist/unstable/http/Headers.d.ts.map +1 -1
  259. package/dist/unstable/http/Headers.js +2 -1
  260. package/dist/unstable/http/Headers.js.map +1 -1
  261. package/dist/unstable/http/HttpClient.d.ts.map +1 -1
  262. package/dist/unstable/http/HttpClient.js +2 -1
  263. package/dist/unstable/http/HttpClient.js.map +1 -1
  264. package/dist/unstable/http/HttpClientRequest.d.ts +4 -3
  265. package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
  266. package/dist/unstable/http/HttpClientRequest.js +8 -6
  267. package/dist/unstable/http/HttpClientRequest.js.map +1 -1
  268. package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
  269. package/dist/unstable/http/HttpClientResponse.js +2 -1
  270. package/dist/unstable/http/HttpClientResponse.js.map +1 -1
  271. package/dist/unstable/http/HttpIncomingMessage.d.ts +2 -1
  272. package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
  273. package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
  274. package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
  275. package/dist/unstable/http/HttpMiddleware.js +16 -15
  276. package/dist/unstable/http/HttpMiddleware.js.map +1 -1
  277. package/dist/unstable/http/HttpPlatform.d.ts.map +1 -1
  278. package/dist/unstable/http/HttpPlatform.js +3 -2
  279. package/dist/unstable/http/HttpPlatform.js.map +1 -1
  280. package/dist/unstable/http/HttpRouter.d.ts +2 -1
  281. package/dist/unstable/http/HttpRouter.d.ts.map +1 -1
  282. package/dist/unstable/http/HttpRouter.js +7 -7
  283. package/dist/unstable/http/HttpRouter.js.map +1 -1
  284. package/dist/unstable/http/HttpServer.d.ts.map +1 -1
  285. package/dist/unstable/http/HttpServer.js +2 -2
  286. package/dist/unstable/http/HttpServer.js.map +1 -1
  287. package/dist/unstable/http/HttpServerError.d.ts +2 -1
  288. package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
  289. package/dist/unstable/http/HttpServerError.js +2 -1
  290. package/dist/unstable/http/HttpServerError.js.map +1 -1
  291. package/dist/unstable/http/HttpServerRequest.d.ts +3 -2
  292. package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
  293. package/dist/unstable/http/HttpServerRequest.js +14 -10
  294. package/dist/unstable/http/HttpServerRequest.js.map +1 -1
  295. package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
  296. package/dist/unstable/http/HttpServerResponse.js +4 -3
  297. package/dist/unstable/http/HttpServerResponse.js.map +1 -1
  298. package/dist/unstable/http/HttpTraceContext.d.ts +3 -2
  299. package/dist/unstable/http/HttpTraceContext.d.ts.map +1 -1
  300. package/dist/unstable/http/HttpTraceContext.js +27 -15
  301. package/dist/unstable/http/HttpTraceContext.js.map +1 -1
  302. package/dist/unstable/http/UrlParams.d.ts +5 -4
  303. package/dist/unstable/http/UrlParams.d.ts.map +1 -1
  304. package/dist/unstable/http/UrlParams.js +5 -6
  305. package/dist/unstable/http/UrlParams.js.map +1 -1
  306. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  307. package/dist/unstable/httpapi/HttpApiBuilder.js +4 -2
  308. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  309. package/dist/unstable/httpapi/HttpApiError.d.ts +15 -0
  310. package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
  311. package/dist/unstable/httpapi/HttpApiError.js +81 -3
  312. package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
  313. package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
  314. package/dist/unstable/observability/OtlpExporter.js +2 -2
  315. package/dist/unstable/observability/OtlpExporter.js.map +1 -1
  316. package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
  317. package/dist/unstable/observability/OtlpTracer.js +7 -3
  318. package/dist/unstable/observability/OtlpTracer.js.map +1 -1
  319. package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
  320. package/dist/unstable/reactivity/Atom.js +1 -5
  321. package/dist/unstable/reactivity/Atom.js.map +1 -1
  322. package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
  323. package/dist/unstable/reactivity/AtomRegistry.js +4 -2
  324. package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
  325. package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
  326. package/dist/unstable/rpc/Rpc.js +4 -3
  327. package/dist/unstable/rpc/Rpc.js.map +1 -1
  328. package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
  329. package/dist/unstable/rpc/RpcClient.js +4 -4
  330. package/dist/unstable/rpc/RpcClient.js.map +1 -1
  331. package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
  332. package/dist/unstable/rpc/RpcSchema.js +3 -2
  333. package/dist/unstable/rpc/RpcSchema.js.map +1 -1
  334. package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
  335. package/dist/unstable/rpc/RpcSerialization.js +4 -1
  336. package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
  337. package/dist/unstable/rpc/RpcServer.d.ts +1 -1
  338. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  339. package/dist/unstable/rpc/RpcServer.js +3 -2
  340. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  341. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  342. package/dist/unstable/socket/Socket.js +2 -1
  343. package/dist/unstable/socket/Socket.js.map +1 -1
  344. package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
  345. package/dist/unstable/sql/SqlClient.js +1 -1
  346. package/dist/unstable/sql/SqlClient.js.map +1 -1
  347. package/dist/unstable/workflow/DurableDeferred.js +6 -6
  348. package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
  349. package/dist/unstable/workflow/Workflow.d.ts +2 -1
  350. package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
  351. package/dist/unstable/workflow/WorkflowEngine.d.ts +5 -4
  352. package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
  353. package/dist/unstable/workflow/WorkflowEngine.js +19 -14
  354. package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
  355. package/package.json +1 -1
  356. package/src/Array.ts +112 -105
  357. package/src/BigDecimal.ts +63 -66
  358. package/src/BigInt.ts +49 -41
  359. package/src/Chunk.ts +68 -63
  360. package/src/Config.ts +4 -1
  361. package/src/Cron.ts +10 -15
  362. package/src/DateTime.ts +16 -15
  363. package/src/Deferred.ts +8 -6
  364. package/src/Duration.ts +34 -33
  365. package/src/Effect.ts +3 -4
  366. package/src/Fiber.ts +2 -1
  367. package/src/FiberHandle.ts +10 -9
  368. package/src/FiberMap.ts +22 -22
  369. package/src/FileSystem.ts +25 -22
  370. package/src/Graph.ts +105 -105
  371. package/src/HashMap.ts +11 -5
  372. package/src/Iterable.ts +13 -13
  373. package/src/Latch.ts +85 -3
  374. package/src/Layer.ts +121 -0
  375. package/src/Number.ts +85 -26
  376. package/src/Option.ts +2 -0
  377. package/src/PartitionedSemaphore.ts +414 -0
  378. package/src/PubSub.ts +7 -6
  379. package/src/Queue.ts +5 -5
  380. package/src/Record.ts +52 -47
  381. package/src/Scheduler.ts +37 -126
  382. package/src/Schema.ts +49 -1
  383. package/src/SchemaGetter.ts +4 -4
  384. package/src/SchemaTransformation.ts +27 -27
  385. package/src/Semaphore.ts +271 -183
  386. package/src/ServiceMap.ts +83 -31
  387. package/src/Stream.ts +1 -1
  388. package/src/String.ts +122 -69
  389. package/src/SubscriptionRef.ts +96 -117
  390. package/src/Terminal.ts +2 -1
  391. package/src/Tracer.ts +6 -5
  392. package/src/Trie.ts +26 -14
  393. package/src/TxHashMap.ts +78 -60
  394. package/src/TxSemaphore.ts +186 -11
  395. package/src/index.ts +89 -33
  396. package/src/internal/dateTime.ts +14 -14
  397. package/src/internal/effect.ts +29 -121
  398. package/src/internal/hashMap.ts +4 -3
  399. package/src/internal/option.ts +7 -0
  400. package/src/internal/trie.ts +6 -6
  401. package/src/unstable/ai/AiError.ts +1 -1
  402. package/src/unstable/ai/AnthropicStructuredOutput.ts +4 -0
  403. package/src/unstable/ai/Chat.ts +6 -2
  404. package/src/unstable/ai/OpenAiStructuredOutput.ts +4 -0
  405. package/src/unstable/ai/Tool.ts +20 -0
  406. package/src/unstable/cli/Argument.ts +2 -4
  407. package/src/unstable/cli/CliOutput.ts +7 -5
  408. package/src/unstable/cli/Command.ts +5 -5
  409. package/src/unstable/cli/Flag.ts +2 -2
  410. package/src/unstable/cli/HelpDoc.ts +14 -12
  411. package/src/unstable/cli/Param.ts +15 -11
  412. package/src/unstable/cli/Primitive.ts +1 -1
  413. package/src/unstable/cli/Prompt.ts +81 -83
  414. package/src/unstable/cli/internal/completions/CommandDescriptor.ts +3 -2
  415. package/src/unstable/cli/internal/parser.ts +7 -4
  416. package/src/unstable/cluster/ClusterWorkflowEngine.ts +35 -30
  417. package/src/unstable/cluster/Entity.ts +13 -12
  418. package/src/unstable/cluster/Message.ts +6 -5
  419. package/src/unstable/cluster/MessageStorage.ts +26 -25
  420. package/src/unstable/cluster/Reply.ts +7 -4
  421. package/src/unstable/cluster/RunnerServer.ts +10 -13
  422. package/src/unstable/cluster/Runners.ts +8 -7
  423. package/src/unstable/cluster/Sharding.ts +24 -17
  424. package/src/unstable/cluster/ShardingConfig.ts +6 -6
  425. package/src/unstable/cluster/SqlMessageStorage.ts +21 -18
  426. package/src/unstable/cluster/internal/entityManager.ts +27 -21
  427. package/src/unstable/devtools/DevToolsSchema.ts +3 -2
  428. package/src/unstable/http/Cookies.ts +7 -8
  429. package/src/unstable/http/Etag.ts +5 -3
  430. package/src/unstable/http/Headers.ts +6 -5
  431. package/src/unstable/http/HttpClient.ts +2 -1
  432. package/src/unstable/http/HttpClientRequest.ts +11 -9
  433. package/src/unstable/http/HttpClientResponse.ts +3 -2
  434. package/src/unstable/http/HttpIncomingMessage.ts +2 -1
  435. package/src/unstable/http/HttpMiddleware.ts +16 -15
  436. package/src/unstable/http/HttpPlatform.ts +3 -2
  437. package/src/unstable/http/HttpRouter.ts +9 -9
  438. package/src/unstable/http/HttpServer.ts +3 -9
  439. package/src/unstable/http/HttpServerError.ts +3 -2
  440. package/src/unstable/http/HttpServerRequest.ts +25 -21
  441. package/src/unstable/http/HttpServerResponse.ts +5 -4
  442. package/src/unstable/http/HttpTraceContext.ts +31 -17
  443. package/src/unstable/http/UrlParams.ts +11 -14
  444. package/src/unstable/httpapi/HttpApiBuilder.ts +9 -3
  445. package/src/unstable/httpapi/HttpApiError.ts +67 -12
  446. package/src/unstable/observability/OtlpExporter.ts +5 -2
  447. package/src/unstable/observability/OtlpTracer.ts +8 -4
  448. package/src/unstable/reactivity/Atom.ts +1 -4
  449. package/src/unstable/reactivity/AtomRegistry.ts +5 -3
  450. package/src/unstable/rpc/Rpc.ts +4 -3
  451. package/src/unstable/rpc/RpcClient.ts +10 -9
  452. package/src/unstable/rpc/RpcSchema.ts +6 -5
  453. package/src/unstable/rpc/RpcSerialization.ts +4 -1
  454. package/src/unstable/rpc/RpcServer.ts +3 -3
  455. package/src/unstable/socket/Socket.ts +2 -1
  456. package/src/unstable/sql/SqlClient.ts +5 -3
  457. package/src/unstable/workflow/DurableDeferred.ts +6 -6
  458. package/src/unstable/workflow/Workflow.ts +1 -1
  459. package/src/unstable/workflow/WorkflowEngine.ts +29 -20
  460. package/dist/NullOr.d.ts +0 -149
  461. package/dist/NullOr.d.ts.map +0 -1
  462. package/dist/NullOr.js +0 -152
  463. package/dist/NullOr.js.map +0 -1
  464. package/src/NullOr.ts +0 -204
@@ -9,11 +9,11 @@ import type { LazyArg } from "../Function.ts"
9
9
  import { dual } from "../Function.ts"
10
10
  import * as Hash from "../Hash.ts"
11
11
  import * as Inspectable from "../Inspectable.ts"
12
+ import * as Option from "../Option.ts"
12
13
  import * as order from "../Order.ts"
13
14
  import { pipeArguments } from "../Pipeable.ts"
14
15
  import * as Predicate from "../Predicate.ts"
15
16
  import type { Mutable } from "../Types.ts"
16
- import * as UndefinedOr from "../UndefinedOr.ts"
17
17
  import * as effect from "./effect.ts"
18
18
 
19
19
  /** @internal */
@@ -264,10 +264,10 @@ export const makeZonedUnsafe = (input: DateTime.DateTime.Input, options?: {
264
264
  zone = zoneMakeOffset(timeZoneOption)
265
265
  } else {
266
266
  const parsedZone = zoneFromString(timeZoneOption)
267
- if (parsedZone === undefined) {
267
+ if (Option.isNone(parsedZone)) {
268
268
  throw new IllegalArgumentError(`Invalid time zone: ${timeZoneOption}`)
269
269
  }
270
- zone = parsedZone
270
+ zone = parsedZone.value
271
271
  }
272
272
  if (options?.adjustForTimeZone !== true) {
273
273
  return makeZonedProto(self.epochMilliseconds, zone, self.partsUtc)
@@ -283,20 +283,20 @@ export const makeZoned: (
283
283
  readonly adjustForTimeZone?: boolean | undefined
284
284
  readonly disambiguation?: DateTime.Disambiguation | undefined
285
285
  }
286
- ) => DateTime.Zoned | undefined = UndefinedOr.liftThrowable(makeZonedUnsafe)
286
+ ) => Option.Option<DateTime.Zoned> = Option.liftThrowable(makeZonedUnsafe)
287
287
 
288
288
  /** @internal */
289
- export const make: <A extends DateTime.DateTime.Input>(input: A) => DateTime.DateTime.PreserveZone<A> | undefined =
290
- UndefinedOr.liftThrowable(makeUnsafe)
289
+ export const make: <A extends DateTime.DateTime.Input>(input: A) => Option.Option<DateTime.DateTime.PreserveZone<A>> =
290
+ Option.liftThrowable(makeUnsafe)
291
291
 
292
292
  const zonedStringRegExp = /^(.{17,35})\[(.+)\]$/
293
293
 
294
294
  /** @internal */
295
- export const makeZonedFromString = (input: string): DateTime.Zoned | undefined => {
295
+ export const makeZonedFromString = (input: string): Option.Option<DateTime.Zoned> => {
296
296
  const match = zonedStringRegExp.exec(input)
297
297
  if (match === null) {
298
298
  const offset = parseOffset(input)
299
- return offset !== null ? makeZoned(input, { timeZone: offset }) : undefined
299
+ return offset !== null ? makeZoned(input, { timeZone: offset }) : Option.none()
300
300
  }
301
301
  const [, isoString, timeZone] = match
302
302
  return makeZoned(isoString, { timeZone })
@@ -402,7 +402,7 @@ export const zoneMakeOffset = (offset: number): DateTime.TimeZone.Offset => {
402
402
  }
403
403
 
404
404
  /** @internal */
405
- export const zoneMakeNamed: (zoneId: string) => DateTime.TimeZone.Named | undefined = UndefinedOr.liftThrowable(
405
+ export const zoneMakeNamed: (zoneId: string) => Option.Option<DateTime.TimeZone.Named> = Option.liftThrowable(
406
406
  zoneMakeNamedUnsafe
407
407
  )
408
408
 
@@ -420,10 +420,10 @@ export const zoneMakeLocal = (): DateTime.TimeZone.Named =>
420
420
  const offsetZoneRegExp = /^(?:GMT|[+-])/
421
421
 
422
422
  /** @internal */
423
- export const zoneFromString = (zone: string): DateTime.TimeZone | undefined => {
423
+ export const zoneFromString = (zone: string): Option.Option<DateTime.TimeZone> => {
424
424
  if (offsetZoneRegExp.test(zone)) {
425
425
  const offset = parseOffset(zone)
426
- return offset === null ? undefined : zoneMakeOffset(offset)
426
+ return offset === null ? Option.none() : Option.some(zoneMakeOffset(offset))
427
427
  }
428
428
  return zoneMakeNamed(zone)
429
429
  }
@@ -441,17 +441,17 @@ export const setZoneNamed: {
441
441
  (zoneId: string, options?: {
442
442
  readonly adjustForTimeZone?: boolean | undefined
443
443
  readonly disambiguation?: DateTime.Disambiguation | undefined
444
- }): (self: DateTime.DateTime) => DateTime.Zoned | undefined
444
+ }): (self: DateTime.DateTime) => Option.Option<DateTime.Zoned>
445
445
  (self: DateTime.DateTime, zoneId: string, options?: {
446
446
  readonly adjustForTimeZone?: boolean | undefined
447
447
  readonly disambiguation?: DateTime.Disambiguation | undefined
448
- }): DateTime.Zoned | undefined
448
+ }): Option.Option<DateTime.Zoned>
449
449
  } = dual(
450
450
  isDateTimeArgs,
451
451
  (self: DateTime.DateTime, zoneId: string, options?: {
452
452
  readonly adjustForTimeZone?: boolean | undefined
453
453
  readonly disambiguation?: DateTime.Disambiguation | undefined
454
- }): DateTime.Zoned | undefined => UndefinedOr.map(zoneMakeNamed(zoneId), (zone) => setZone(self, zone, options))
454
+ }): Option.Option<DateTime.Zoned> => Option.map(zoneMakeNamed(zoneId), (zone) => setZone(self, zone, options))
455
455
  )
456
456
 
457
457
  /** @internal */
@@ -540,6 +540,11 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
540
540
  maxOpsBeforeYield!: number
541
541
  currentPreventYield!: boolean
542
542
 
543
+ _dispatcher: Scheduler.SchedulerDispatcher | undefined = undefined
544
+ get currentDispatcher(): Scheduler.SchedulerDispatcher {
545
+ return this._dispatcher ??= this.currentScheduler.makeDispatcher()
546
+ }
547
+
543
548
  getRef<X>(ref: ServiceMap.Reference<X>): X {
544
549
  return ServiceMap.getReferenceUnsafe(this.services, ref)
545
550
  }
@@ -675,7 +680,11 @@ export class FiberImpl<A = any, E = any> implements Fiber.Fiber<A, E> {
675
680
  }
676
681
  setServices(services: ServiceMap.ServiceMap<never>): void {
677
682
  this.services = services
678
- this.currentScheduler = this.getRef(Scheduler.Scheduler)
683
+ const scheduler = this.getRef(Scheduler.Scheduler)
684
+ if (scheduler !== this.currentScheduler) {
685
+ this.currentScheduler = scheduler
686
+ this._dispatcher = undefined
687
+ }
679
688
  this.currentSpan = services.mapUnsafe.get(Tracer.ParentSpanKey)
680
689
  this.currentLogLevel = this.getRef(CurrentLogLevel)
681
690
  this.minimumLogLevel = this.getRef(MinimumLogLevel)
@@ -903,7 +912,7 @@ export const yieldNowWith: (priority?: number) => Effect.Effect<void> = makePrim
903
912
  op: "Yield",
904
913
  [evaluate](fiber) {
905
914
  let resumed = false
906
- fiber.currentScheduler.scheduleTask(() => {
915
+ fiber.currentDispatcher.scheduleTask(() => {
907
916
  if (resumed) return
908
917
  fiber.evaluate(exitVoid as any)
909
918
  }, this[args] ?? 0)
@@ -4849,7 +4858,7 @@ export const forkUnsafe = <FA, FE, A, E, R>(
4849
4858
  if (immediate) {
4850
4859
  child.evaluate(effect as any)
4851
4860
  } else {
4852
- parent.currentScheduler.scheduleTask(() => child.evaluate(effect as any), 0)
4861
+ parent.currentDispatcher.scheduleTask(() => child.evaluate(effect as any), 0)
4853
4862
  }
4854
4863
  if (!daemon && !child._exit) {
4855
4864
  parent.children().add(child)
@@ -4990,10 +4999,8 @@ export const runForkWith = <R>(services: ServiceMap.ServiceMap<R>) =>
4990
4999
  effect: Effect.Effect<A, E, R>,
4991
5000
  options?: Effect.RunOptions | undefined
4992
5001
  ): Fiber.Fiber<A, E> => {
4993
- const scheduler = options?.scheduler ||
4994
- (!services.mapUnsafe.has(Scheduler.Scheduler.key) && new Scheduler.MixedScheduler())
4995
5002
  const fiber = new FiberImpl<A, E>(
4996
- scheduler ? ServiceMap.add(services, Scheduler.Scheduler, scheduler) : services,
5003
+ options?.scheduler ? ServiceMap.add(services, Scheduler.Scheduler, options.scheduler) : services,
4997
5004
  options?.uninterruptible !== true
4998
5005
  )
4999
5006
  fiber.evaluate(effect as any)
@@ -5113,7 +5120,7 @@ export const runSyncExitWith = <R>(services: ServiceMap.ServiceMap<R>) => {
5113
5120
  if (effectIsExit(effect)) return effect
5114
5121
  const scheduler = new Scheduler.MixedScheduler("sync")
5115
5122
  const fiber = runFork(effect, { scheduler })
5116
- scheduler.flush()
5123
+ fiber.currentDispatcher?.flush()
5117
5124
  return (fiber as FiberImpl<A, E>)._exit ?? exitDie(fiber)
5118
5125
  }
5119
5126
  }
@@ -5136,108 +5143,6 @@ export const runSyncWith = <R>(services: ServiceMap.ServiceMap<R>) => {
5136
5143
  /** @internal */
5137
5144
  export const runSync: <A, E>(effect: Effect.Effect<A, E>) => A = runSyncWith(ServiceMap.empty())
5138
5145
 
5139
- // ----------------------------------------------------------------------------
5140
- // Semaphore
5141
- // ----------------------------------------------------------------------------
5142
-
5143
- /** @internal */
5144
- class Semaphore {
5145
- public waiters = new Set<() => void>()
5146
- public taken = 0
5147
- public permits: number
5148
-
5149
- constructor(permits: number) {
5150
- this.permits = permits
5151
- }
5152
-
5153
- get free() {
5154
- return this.permits - this.taken
5155
- }
5156
-
5157
- readonly take = (n: number): Effect.Effect<number> => {
5158
- const take: Effect.Effect<number> = suspend(() => {
5159
- if (this.free < n) {
5160
- return callback((resume) => {
5161
- if (this.free >= n) return resume(take)
5162
- const observer = () => {
5163
- if (this.free < n) return
5164
- this.waiters.delete(observer)
5165
- resume(take)
5166
- }
5167
- this.waiters.add(observer)
5168
- return sync(() => {
5169
- this.waiters.delete(observer)
5170
- })
5171
- })
5172
- }
5173
- this.taken += n
5174
- return succeed(n)
5175
- })
5176
- return take
5177
- }
5178
-
5179
- updateTakenUnsafe(fiber: Fiber.Fiber<any, any>, f: (n: number) => number): Effect.Effect<number> {
5180
- this.taken = f(this.taken)
5181
- if (this.waiters.size > 0) {
5182
- fiber.currentScheduler.scheduleTask(() => {
5183
- const iter = this.waiters.values()
5184
- let item = iter.next()
5185
- while (item.done === false && this.free > 0) {
5186
- item.value()
5187
- item = iter.next()
5188
- }
5189
- }, 0)
5190
- }
5191
- return succeed(this.free)
5192
- }
5193
-
5194
- updateTaken(f: (n: number) => number): Effect.Effect<number> {
5195
- return withFiber((fiber) => this.updateTakenUnsafe(fiber, f))
5196
- }
5197
-
5198
- readonly resize = (permits: number) =>
5199
- asVoid(
5200
- withFiber((fiber) => {
5201
- this.permits = permits
5202
- if (this.free < 0) {
5203
- return void_
5204
- }
5205
- return this.updateTakenUnsafe(fiber, (taken) => taken)
5206
- })
5207
- )
5208
-
5209
- readonly release = (n: number): Effect.Effect<number> => this.updateTaken((taken) => taken - n)
5210
-
5211
- readonly releaseAll: Effect.Effect<number> = this.updateTaken((_) => 0)
5212
-
5213
- readonly withPermits = (n: number) => <A, E, R>(self: Effect.Effect<A, E, R>) =>
5214
- uninterruptibleMask((restore) =>
5215
- flatMap(
5216
- restore(this.take(n)),
5217
- (permits) => onExitPrimitive(restore(self), () => this.release(permits), true)
5218
- )
5219
- )
5220
-
5221
- readonly withPermit = this.withPermits(1)
5222
-
5223
- readonly withPermitsIfAvailable = (n: number) => <A, E, R>(self: Effect.Effect<A, E, R>) =>
5224
- uninterruptibleMask((restore) =>
5225
- suspend(() => {
5226
- if (this.free < n) {
5227
- return succeedNone
5228
- }
5229
- this.taken += n
5230
- return ensuring(restore(asSome(self)), this.release(n))
5231
- })
5232
- )
5233
- }
5234
-
5235
- /** @internal */
5236
- export const makeSemaphoreUnsafe = (permits: number): Semaphore => new Semaphore(permits)
5237
-
5238
- /** @internal */
5239
- export const makeSemaphore = (permits: number) => sync(() => makeSemaphoreUnsafe(permits))
5240
-
5241
5146
  const succeedTrue = succeed(true)
5242
5147
  const succeedFalse = succeed(false)
5243
5148
 
@@ -5255,7 +5160,7 @@ class Latch implements _Latch.Latch {
5255
5160
  return succeedTrue
5256
5161
  }
5257
5162
  this.scheduled = true
5258
- fiber.currentScheduler.scheduleTask(this.flushWaiters, 0)
5163
+ fiber.currentDispatcher.scheduleTask(this.flushWaiters, 0)
5259
5164
  return succeedTrue
5260
5165
  }
5261
5166
  private flushWaiters = () => {
@@ -5297,7 +5202,7 @@ class Latch implements _Latch.Latch {
5297
5202
  return true
5298
5203
  }
5299
5204
  close = sync(() => this.closeUnsafe())
5300
- whenOpen = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> => andThen(this.await, self)
5205
+ whenOpen = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> => flatMap(this.await, () => self)
5301
5206
  }
5302
5207
 
5303
5208
  /** @internal */
@@ -5360,16 +5265,15 @@ const NoopSpanProto: Omit<Tracer.Span, "parent" | "name" | "annotations" | "leve
5360
5265
  /** @internal */
5361
5266
  export const noopSpan = (options: {
5362
5267
  readonly name: string
5363
- readonly parent: Tracer.AnySpan | undefined
5268
+ readonly parent: Option.Option<Tracer.AnySpan>
5364
5269
  readonly annotations: ServiceMap.ServiceMap<never>
5365
5270
  }): Tracer.Span => Object.assign(Object.create(NoopSpanProto), options)
5366
5271
 
5367
- const filterDisablePropagation = (span: Tracer.AnySpan | undefined): Tracer.AnySpan | undefined => {
5368
- if (span) {
5369
- return ServiceMap.get(span.annotations, Tracer.DisablePropagation)
5370
- ? span._tag === "Span" ? filterDisablePropagation(span.parent) : undefined
5371
- : span
5372
- }
5272
+ const filterDisablePropagation = (span: Tracer.AnySpan | undefined): Option.Option<Tracer.AnySpan> => {
5273
+ if (!span) return Option.none()
5274
+ return ServiceMap.get(span.annotations, Tracer.DisablePropagation)
5275
+ ? span._tag === "Span" ? filterDisablePropagation(Option.getOrUndefined(span.parent)) : Option.none()
5276
+ : Option.some(span)
5373
5277
  }
5374
5278
 
5375
5279
  /** @internal */
@@ -5380,7 +5284,11 @@ export const makeSpanUnsafe = <XA, XE>(
5380
5284
  ) => {
5381
5285
  const disablePropagation = !fiber.getRef(TracerEnabled) ||
5382
5286
  (options?.annotations && ServiceMap.get(options.annotations, Tracer.DisablePropagation))
5383
- const parent = options?.parent ?? (options?.root ? undefined : filterDisablePropagation(fiber.currentSpan))
5287
+ const parent = options?.parent !== undefined
5288
+ ? Option.some(options.parent)
5289
+ : options?.root
5290
+ ? Option.none<Tracer.AnySpan>()
5291
+ : filterDisablePropagation(fiber.currentSpan)
5384
5292
 
5385
5293
  let span: Tracer.Span
5386
5294
 
@@ -5413,9 +5321,9 @@ export const makeSpanUnsafe = <XA, XE>(
5413
5321
  links,
5414
5322
  startTime: timingEnabled ? clock.currentTimeNanosUnsafe() : 0n,
5415
5323
  kind: options?.kind ?? "internal",
5416
- root: options?.root ?? options?.parent === undefined,
5324
+ root: options?.root ?? Option.isNone(parent),
5417
5325
  sampled: options?.sampled ??
5418
- (parent?.sampled === false
5326
+ (Option.isSome(parent) && parent.value.sampled === false
5419
5327
  ? false
5420
5328
  : !isLogLevelGreaterThan(fiber.getRef(Tracer.MinimumTraceLevel), level))
5421
5329
  })
@@ -1271,14 +1271,15 @@ export const filterMap = dual<
1271
1271
 
1272
1272
  /** @internal */
1273
1273
  export const findFirst = dual<
1274
- <K, A>(predicate: (a: NoInfer<A>, k: K) => boolean) => (self: HashMap<K, A>) => [K, A] | undefined,
1275
- <K, A>(self: HashMap<K, A>, predicate: (a: A, k: K) => boolean) => [K, A] | undefined
1274
+ <K, A>(predicate: (a: NoInfer<A>, k: K) => boolean) => (self: HashMap<K, A>) => Option.Option<[K, A]>,
1275
+ <K, A>(self: HashMap<K, A>, predicate: (a: A, k: K) => boolean) => Option.Option<[K, A]>
1276
1276
  >(2, <K, A>(self: HashMap<K, A>, predicate: (a: A, k: K) => boolean) => {
1277
1277
  for (const [key, value] of self) {
1278
1278
  if (predicate(value, key)) {
1279
- return [key, value]
1279
+ return Option.some([key, value])
1280
1280
  }
1281
1281
  }
1282
+ return Option.none()
1282
1283
  })
1283
1284
 
1284
1285
  /** @internal */
@@ -45,10 +45,17 @@ const SomeProto = Object.assign(Object.create(CommonProto), {
45
45
  }
46
46
  })
47
47
 
48
+ Object.defineProperty(SomeProto, "valueOrUndefined", {
49
+ get() {
50
+ return this.value
51
+ }
52
+ })
53
+
48
54
  const NoneHash = Hash.hash("None")
49
55
  const NoneProto = Object.assign(Object.create(CommonProto), {
50
56
  _tag: "None",
51
57
  _op: "None",
58
+ valueOrUndefined: undefined,
52
59
  [Equal.symbol]<A>(this: Option.None<A>, that: unknown): boolean {
53
60
  return isOption(that) && isNone(that)
54
61
  },
@@ -682,19 +682,19 @@ export const modify = dual<
682
682
 
683
683
  /** @internal */
684
684
  export const longestPrefixOf = dual<
685
- (key: string) => <V>(self: TR.Trie<V>) => [string, V] | undefined,
686
- <V>(self: TR.Trie<V>, key: string) => [string, V] | undefined
685
+ (key: string) => <V>(self: TR.Trie<V>) => Option.Option<[string, V]>,
686
+ <V>(self: TR.Trie<V>, key: string) => Option.Option<[string, V]>
687
687
  >(
688
688
  2,
689
- <V>(self: TR.Trie<V>, key: string): [string, V] | undefined => {
689
+ <V>(self: TR.Trie<V>, key: string): Option.Option<[string, V]> => {
690
690
  let n: Node<V> | undefined = (self as TrieImpl<V>)._root
691
- if (n === undefined || key.length === 0) return undefined
692
- let longestPrefixNode: [string, V] | undefined = undefined
691
+ if (n === undefined || key.length === 0) return Option.none()
692
+ let longestPrefixNode: Option.Option<[string, V]> = Option.none()
693
693
  let cIndex = 0
694
694
  while (cIndex < key.length) {
695
695
  const c = key[cIndex]
696
696
  if (n.value !== undefined) {
697
- longestPrefixNode = [key.slice(0, cIndex + 1), n.value]
697
+ longestPrefixNode = Option.some([key.slice(0, cIndex + 1), n.value])
698
698
  }
699
699
 
700
700
  if (c > n.key) {
@@ -183,7 +183,7 @@ export class NetworkError extends Schema.ErrorClass<NetworkError>(
183
183
  description: error.description,
184
184
  reason: error._tag,
185
185
  request: {
186
- hash: error.request.hash,
186
+ hash: Option.getOrUndefined(error.request.hash),
187
187
  headers: redactHeaders(error.request.headers),
188
188
  method: error.request.method,
189
189
  url: error.request.url,
@@ -22,6 +22,7 @@ import * as Predicate from "../../Predicate.ts"
22
22
  import * as Schema from "../../Schema.ts"
23
23
  import * as AST from "../../SchemaAST.ts"
24
24
  import * as Transformation from "../../SchemaTransformation.ts"
25
+ import * as Tool from "./Tool.ts"
25
26
 
26
27
  /**
27
28
  * Transforms a `Schema.Codec` into a form compatible with Anthropic's
@@ -225,6 +226,9 @@ function recur(ast: AST.AST): AST.AST {
225
226
  }
226
227
  } else if (ast.indexSignatures.length === 1 && ast.propertySignatures.length === 0) {
227
228
  const is = ast.indexSignatures[0]
229
+ if (Tool.isEmptyParamsRecord(is)) {
230
+ return ast
231
+ }
228
232
  // records are not supported by Anthropic, so we translate them to arrays of key-value pairs
229
233
  if (annotations !== undefined && typeof annotations.description === "string") {
230
234
  annotations.description = `${RECORD_DESCRIPTION}; ${annotations.description}`
@@ -696,7 +696,9 @@ export const makePersisted = Effect.fnUntraced(function*(options: {
696
696
  yield* Ref.set(chat.history, history)
697
697
  // Export the chat history
698
698
  const exported = yield* Effect.orDie(chat.export)
699
- const timeToLive = Predicate.isNotUndefined(ttl) ? Duration.fromInput(ttl) : undefined
699
+ const timeToLive = Predicate.isNotUndefined(ttl)
700
+ ? Option.getOrUndefined(Duration.fromInput(ttl))
701
+ : undefined
700
702
  // Save the chat to the backing store
701
703
  yield* store.set(chatId, exported as object, timeToLive)
702
704
  }
@@ -738,7 +740,9 @@ export const makePersisted = Effect.fnUntraced(function*(options: {
738
740
  // Export the chat history
739
741
  const history = yield* Effect.orDie(chat.export)
740
742
  // Save the history for the newly created chat
741
- const timeToLive = Predicate.isNotUndefined(ttl) ? Duration.fromInput(ttl) : undefined
743
+ const timeToLive = Predicate.isNotUndefined(ttl)
744
+ ? Option.getOrUndefined(Duration.fromInput(ttl))
745
+ : undefined
742
746
  yield* store.set(chatId, history as object, timeToLive)
743
747
  // Convert the chat to a persisted chat
744
748
  return yield* toPersisted(chatId, chat, ttl)
@@ -11,6 +11,7 @@ import * as Rec from "../../Record.ts"
11
11
  import * as Schema from "../../Schema.ts"
12
12
  import * as AST from "../../SchemaAST.ts"
13
13
  import * as Transformation from "../../SchemaTransformation.ts"
14
+ import * as Tool from "./Tool.ts"
14
15
 
15
16
  /**
16
17
  * Transforms a `Schema.Codec` into a form compatible with OpenAI's
@@ -243,6 +244,9 @@ function recurOpenAI(ast: AST.AST): AST.AST {
243
244
  }
244
245
  } else if (ast.indexSignatures.length === 1 && ast.propertySignatures.length === 0) {
245
246
  const is = ast.indexSignatures[0]
247
+ if (Tool.isEmptyParamsRecord(is)) {
248
+ return ast
249
+ }
246
250
  // records are not supported by OpenAI, so we translate them to arrays of key-value pairs
247
251
  if (annotations !== undefined && typeof annotations.description === "string") {
248
252
  annotations.description = `${RECORD_DESCRIPTION}; ${annotations.description}`
@@ -1129,6 +1129,9 @@ const dynamicProto = <
1129
1129
  * can call. The tool definition includes parameter validation, success/failure
1130
1130
  * schemas, and optional service dependencies.
1131
1131
  *
1132
+ * If a tool accepts no parameters but still needs an explicit empty object
1133
+ * schema, use {@link EmptyParams}.
1134
+ *
1132
1135
  * @example
1133
1136
  * ```ts
1134
1137
  * import { Schema } from "effect"
@@ -1866,3 +1869,20 @@ export const unsafeSecureJsonParse = (text: string): unknown => {
1866
1869
  Error.stackTraceLimit = stackTraceLimit
1867
1870
  }
1868
1871
  }
1872
+
1873
+ /**
1874
+ * @since 4.0.0
1875
+ */
1876
+ export interface EmptyParams extends Schema.$Record<Schema.String, Schema.Never> {}
1877
+
1878
+ /**
1879
+ * A schema for tools that accept no parameters.
1880
+ *
1881
+ * @since 4.0.0
1882
+ */
1883
+ export const EmptyParams: EmptyParams = Schema.Record(Schema.String, Schema.Never)
1884
+
1885
+ /** @internal */
1886
+ export function isEmptyParamsRecord(indexSignature: AST.IndexSignature): boolean {
1887
+ return indexSignature.parameter === AST.string && AST.isNever(indexSignature.type)
1888
+ }
@@ -226,9 +226,7 @@ export const fileParse = (
226
226
  * host: Schema.String
227
227
  * })
228
228
  *
229
- * const JsonConfigSchema = Schema.fromJsonString(ConfigSchema)
230
- *
231
- * const config = Argument.fileSchema("config", JsonConfigSchema)
229
+ * const config = Argument.fileSchema("config", ConfigSchema)
232
230
  * ```
233
231
  *
234
232
  * @since 4.0.0
@@ -236,7 +234,7 @@ export const fileParse = (
236
234
  */
237
235
  export const fileSchema = <A>(
238
236
  name: string,
239
- schema: Schema.Codec<A, string>,
237
+ schema: Schema.Decoder<A>,
240
238
  options?: Primitive.FileSchemaOptions | undefined
241
239
  ): Argument<A> => Param.fileSchema(Param.argumentKind, name, schema, options)
242
240
 
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import * as Layer from "../../Layer.ts"
6
+ import * as Option from "../../Option.ts"
6
7
  import * as ServiceMap from "../../ServiceMap.ts"
7
8
  import type * as CliError from "./CliError.ts"
8
9
  import type { HelpDoc } from "./HelpDoc.ts"
@@ -44,6 +45,7 @@ export interface Formatter {
44
45
  *
45
46
  * @example
46
47
  * ```ts
48
+ * import { Option as O } from "effect"
47
49
  * import type { HelpDoc } from "effect/unstable/cli"
48
50
  * import { CliOutput } from "effect/unstable/cli"
49
51
  *
@@ -55,7 +57,7 @@ export interface Formatter {
55
57
  * name: "verbose",
56
58
  * aliases: ["-v"],
57
59
  * type: "boolean",
58
- * description: "Enable verbose output",
60
+ * description: O.some("Enable verbose output"),
59
61
  * required: false
60
62
  * }
61
63
  * ],
@@ -63,7 +65,7 @@ export interface Formatter {
63
65
  * {
64
66
  * name: "file",
65
67
  * type: "string",
66
- * description: "Input file to process",
68
+ * description: O.some("Input file to process"),
67
69
  * required: true,
68
70
  * variadic: false
69
71
  * }
@@ -459,7 +461,7 @@ const formatHelpDocImpl = (doc: HelpDoc, colors: ColorFunctions): string => {
459
461
  const nameType = `${coloredName} ${coloredType}`
460
462
 
461
463
  const optionalSuffix = arg.required ? "" : colors.dim(" (optional)")
462
- const description = (arg.description ?? "") + optionalSuffix
464
+ const description = Option.getOrElse(arg.description, () => "") + optionalSuffix
463
465
 
464
466
  return {
465
467
  left: nameType,
@@ -491,7 +493,7 @@ const formatHelpDocImpl = (doc: HelpDoc, colors: ColorFunctions): string => {
491
493
 
492
494
  return {
493
495
  left: namesPart + typePart,
494
- right: flag.description ?? ""
496
+ right: Option.getOrElse(flag.description, () => "")
495
497
  }
496
498
  })
497
499
 
@@ -519,7 +521,7 @@ const formatHelpDocImpl = (doc: HelpDoc, colors: ColorFunctions): string => {
519
521
 
520
522
  return {
521
523
  left: namesPart + typePart,
522
- right: flag.description ?? ""
524
+ right: Option.getOrElse(flag.description, () => "")
523
525
  }
524
526
  })
525
527
 
@@ -360,10 +360,10 @@ export interface ParsedTokens {
360
360
  readonly flags: Record<string, ReadonlyArray<string>>
361
361
  readonly arguments: ReadonlyArray<string>
362
362
  readonly errors?: ReadonlyArray<CliError.CliError>
363
- readonly subcommand?: {
363
+ readonly subcommand: Option.Option<{
364
364
  readonly name: string
365
365
  readonly parsedInput: ParsedTokens
366
- }
366
+ }>
367
367
  }
368
368
 
369
369
  /**
@@ -939,17 +939,17 @@ export const withSubcommands: {
939
939
  type InternalInput = NextInput & { readonly [SubcommandStateSymbol]?: SubcommandState }
940
940
 
941
941
  const parse = Effect.fnUntraced(function*(raw: ParsedTokens) {
942
- if (!raw.subcommand) {
942
+ if (Option.isNone(raw.subcommand)) {
943
943
  return (yield* impl.parse(raw)) as NextInput
944
944
  }
945
945
 
946
- const sub = byName.get(raw.subcommand.name)
946
+ const sub = byName.get(raw.subcommand.value.name)
947
947
  if (!sub) {
948
948
  return (yield* impl.parse(raw)) as NextInput
949
949
  }
950
950
 
951
951
  const context = yield* impl.parseContext(raw)
952
- const result = yield* sub.parse(raw.subcommand.parsedInput)
952
+ const result = yield* sub.parse(raw.subcommand.value.parsedInput)
953
953
  return Object.assign({}, context, { [SubcommandStateSymbol]: { name: sub.name, result } }) as NextInput
954
954
  })
955
955
 
@@ -304,7 +304,7 @@ export const fileParse = (
304
304
  * const ConfigSchema = Schema.Struct({
305
305
  * port: Schema.Number,
306
306
  * host: Schema.String
307
- * }).pipe(Schema.fromJsonString)
307
+ * })
308
308
  *
309
309
  * const config = Flag.fileSchema("config", ConfigSchema, { format: "json" })
310
310
  * ```
@@ -314,7 +314,7 @@ export const fileParse = (
314
314
  */
315
315
  export const fileSchema = <A>(
316
316
  name: string,
317
- schema: Schema.Codec<A, string>,
317
+ schema: Schema.Decoder<A>,
318
318
  options?: Primitive.FileSchemaOptions | undefined
319
319
  ): Flag<A> => Param.fileSchema(Param.flagKind, name, schema, options)
320
320