effect 4.0.7 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (679) hide show
  1. package/README.md +1 -1
  2. package/dist/BigDecimal.d.ts.map +1 -1
  3. package/dist/BigDecimal.js +3 -0
  4. package/dist/BigDecimal.js.map +1 -1
  5. package/dist/Channel.d.ts +12 -6
  6. package/dist/Channel.d.ts.map +1 -1
  7. package/dist/Channel.js +9 -3
  8. package/dist/Channel.js.map +1 -1
  9. package/dist/Config.d.ts +7 -1
  10. package/dist/Config.d.ts.map +1 -1
  11. package/dist/Config.js.map +1 -1
  12. package/dist/Context.d.ts +18 -1
  13. package/dist/Context.d.ts.map +1 -1
  14. package/dist/Context.js +27 -8
  15. package/dist/Context.js.map +1 -1
  16. package/dist/Cron.d.ts +81 -11
  17. package/dist/Cron.d.ts.map +1 -1
  18. package/dist/Cron.js +101 -26
  19. package/dist/Cron.js.map +1 -1
  20. package/dist/Duration.d.ts +78 -0
  21. package/dist/Duration.d.ts.map +1 -1
  22. package/dist/Duration.js +123 -0
  23. package/dist/Duration.js.map +1 -1
  24. package/dist/Effect.d.ts +164 -7
  25. package/dist/Effect.d.ts.map +1 -1
  26. package/dist/Effect.js +11 -1
  27. package/dist/Effect.js.map +1 -1
  28. package/dist/FileSystem.d.ts +59 -4
  29. package/dist/FileSystem.d.ts.map +1 -1
  30. package/dist/FileSystem.js +9 -2
  31. package/dist/FileSystem.js.map +1 -1
  32. package/dist/Glob.d.ts +165 -0
  33. package/dist/Glob.d.ts.map +1 -0
  34. package/dist/Glob.js +127 -0
  35. package/dist/Glob.js.map +1 -0
  36. package/dist/Match.d.ts +86 -0
  37. package/dist/Match.d.ts.map +1 -1
  38. package/dist/Match.js +72 -0
  39. package/dist/Match.js.map +1 -1
  40. package/dist/Pool.d.ts +51 -0
  41. package/dist/Pool.d.ts.map +1 -1
  42. package/dist/Pool.js +59 -9
  43. package/dist/Pool.js.map +1 -1
  44. package/dist/Random.d.ts.map +1 -1
  45. package/dist/Random.js +3 -3
  46. package/dist/Random.js.map +1 -1
  47. package/dist/RcMap.d.ts.map +1 -1
  48. package/dist/RcMap.js +8 -2
  49. package/dist/RcMap.js.map +1 -1
  50. package/dist/Schedule.d.ts +18 -1
  51. package/dist/Schedule.d.ts.map +1 -1
  52. package/dist/Schedule.js +7 -2
  53. package/dist/Schedule.js.map +1 -1
  54. package/dist/Schema.d.ts +666 -41
  55. package/dist/Schema.d.ts.map +1 -1
  56. package/dist/Schema.js +650 -0
  57. package/dist/Schema.js.map +1 -1
  58. package/dist/SchemaGetter.d.ts +6 -1
  59. package/dist/SchemaGetter.d.ts.map +1 -1
  60. package/dist/SchemaGetter.js +22 -11
  61. package/dist/SchemaGetter.js.map +1 -1
  62. package/dist/SchemaRepresentation.d.ts +14 -0
  63. package/dist/SchemaRepresentation.d.ts.map +1 -1
  64. package/dist/SchemaRepresentation.js +16 -0
  65. package/dist/SchemaRepresentation.js.map +1 -1
  66. package/dist/SchemaTransformation.d.ts +8 -3
  67. package/dist/SchemaTransformation.d.ts.map +1 -1
  68. package/dist/SchemaTransformation.js +6 -3
  69. package/dist/SchemaTransformation.js.map +1 -1
  70. package/dist/ScopedCache.d.ts.map +1 -1
  71. package/dist/ScopedCache.js +5 -7
  72. package/dist/ScopedCache.js.map +1 -1
  73. package/dist/Semaphore.d.ts +130 -0
  74. package/dist/Semaphore.d.ts.map +1 -1
  75. package/dist/Semaphore.js +40 -0
  76. package/dist/Semaphore.js.map +1 -1
  77. package/dist/Stream.d.ts +13 -4
  78. package/dist/Stream.d.ts.map +1 -1
  79. package/dist/Stream.js +9 -0
  80. package/dist/Stream.js.map +1 -1
  81. package/dist/Terminal.d.ts +18 -1
  82. package/dist/Terminal.d.ts.map +1 -1
  83. package/dist/Terminal.js +1 -1
  84. package/dist/Terminal.js.map +1 -1
  85. package/dist/ai/AiError.d.ts +43 -116
  86. package/dist/ai/AiError.d.ts.map +1 -1
  87. package/dist/ai/AiError.js +53 -72
  88. package/dist/ai/AiError.js.map +1 -1
  89. package/dist/ai/Decision.d.ts +196 -15
  90. package/dist/ai/Decision.d.ts.map +1 -1
  91. package/dist/ai/Decision.js +130 -0
  92. package/dist/ai/Decision.js.map +1 -1
  93. package/dist/ai/DecisionModel.d.ts +54 -13
  94. package/dist/ai/DecisionModel.d.ts.map +1 -1
  95. package/dist/ai/DecisionModel.js +123 -12
  96. package/dist/ai/DecisionModel.js.map +1 -1
  97. package/dist/ai/McpServer.d.ts +630 -29
  98. package/dist/ai/McpServer.d.ts.map +1 -1
  99. package/dist/ai/McpServer.js +562 -116
  100. package/dist/ai/McpServer.js.map +1 -1
  101. package/dist/ai/McpTest.d.ts +130 -0
  102. package/dist/ai/McpTest.d.ts.map +1 -0
  103. package/dist/ai/McpTest.js +237 -0
  104. package/dist/ai/McpTest.js.map +1 -0
  105. package/dist/ai/Response.d.ts +1 -25
  106. package/dist/ai/Response.d.ts.map +1 -1
  107. package/dist/ai/Response.js +1 -10
  108. package/dist/ai/Response.js.map +1 -1
  109. package/dist/ai/Tool.d.ts +19 -1
  110. package/dist/ai/Tool.d.ts.map +1 -1
  111. package/dist/ai/Tool.js.map +1 -1
  112. package/dist/ai/index.d.ts +5 -0
  113. package/dist/ai/index.d.ts.map +1 -1
  114. package/dist/ai/index.js +5 -0
  115. package/dist/ai/index.js.map +1 -1
  116. package/dist/ai/internal/mcpCore.js +17 -12
  117. package/dist/ai/internal/mcpCore.js.map +1 -1
  118. package/dist/ai/internal/mcpProtocol/v2024_11_05.js +4 -5
  119. package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
  120. package/dist/ai/internal/mcpProtocol/v2025_03_26.js +4 -5
  121. package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
  122. package/dist/ai/internal/mcpProtocol/v2025_06_18.js +4 -5
  123. package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
  124. package/dist/ai/internal/mcpProtocol/v2025_11_25.js +4 -5
  125. package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
  126. package/dist/ai/internal/mcpProtocol/v2026_07_28.js +18 -10
  127. package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
  128. package/dist/ai/internal/mcpProtocol.js +13 -0
  129. package/dist/ai/internal/mcpProtocol.js.map +1 -1
  130. package/dist/ai/internal/mcpRuntime.js +5 -3
  131. package/dist/ai/internal/mcpRuntime.js.map +1 -1
  132. package/dist/ai/internal/mcpStatefulRuntime.js +6 -1
  133. package/dist/ai/internal/mcpStatefulRuntime.js.map +1 -1
  134. package/dist/cli/Argument.d.ts +6 -0
  135. package/dist/cli/Argument.d.ts.map +1 -1
  136. package/dist/cli/Argument.js +2 -0
  137. package/dist/cli/Argument.js.map +1 -1
  138. package/dist/cli/CliOutput.d.ts +65 -1
  139. package/dist/cli/CliOutput.d.ts.map +1 -1
  140. package/dist/cli/CliOutput.js +94 -37
  141. package/dist/cli/CliOutput.js.map +1 -1
  142. package/dist/cli/Command.d.ts +23 -0
  143. package/dist/cli/Command.d.ts.map +1 -1
  144. package/dist/cli/Command.js +8 -0
  145. package/dist/cli/Command.js.map +1 -1
  146. package/dist/cli/Flag.d.ts +107 -0
  147. package/dist/cli/Flag.d.ts.map +1 -1
  148. package/dist/cli/Flag.js +37 -0
  149. package/dist/cli/Flag.js.map +1 -1
  150. package/dist/cli/HelpDoc.d.ts +15 -1
  151. package/dist/cli/HelpDoc.d.ts.map +1 -1
  152. package/dist/cli/Param.d.ts +6 -0
  153. package/dist/cli/Param.d.ts.map +1 -1
  154. package/dist/cli/Param.js +2 -0
  155. package/dist/cli/Param.js.map +1 -1
  156. package/dist/cli/Primitive.d.ts +14 -0
  157. package/dist/cli/Primitive.d.ts.map +1 -1
  158. package/dist/cli/Primitive.js +15 -1
  159. package/dist/cli/Primitive.js.map +1 -1
  160. package/dist/cli/Prompt.d.ts +1 -0
  161. package/dist/cli/Prompt.d.ts.map +1 -1
  162. package/dist/cli/Prompt.js +1 -0
  163. package/dist/cli/Prompt.js.map +1 -1
  164. package/dist/cli/internal/help.d.ts.map +1 -1
  165. package/dist/cli/internal/help.js +17 -10
  166. package/dist/cli/internal/help.js.map +1 -1
  167. package/dist/cluster/Sharding.d.ts.map +1 -1
  168. package/dist/cluster/Sharding.js +90 -28
  169. package/dist/cluster/Sharding.js.map +1 -1
  170. package/dist/cluster/ShardingConfig.d.ts +72 -6
  171. package/dist/cluster/ShardingConfig.d.ts.map +1 -1
  172. package/dist/cluster/ShardingConfig.js +4 -0
  173. package/dist/cluster/ShardingConfig.js.map +1 -1
  174. package/dist/cluster/SingleRunner.d.ts +3 -3
  175. package/dist/cluster/SingleRunner.d.ts.map +1 -1
  176. package/dist/cluster/SingleRunner.js +1 -1
  177. package/dist/cluster/SqlMessageStorage.d.ts +37 -6
  178. package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
  179. package/dist/cluster/SqlMessageStorage.js +34 -7
  180. package/dist/cluster/SqlMessageStorage.js.map +1 -1
  181. package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
  182. package/dist/cluster/SqlRunnerStorage.js +23 -8
  183. package/dist/cluster/SqlRunnerStorage.js.map +1 -1
  184. package/dist/crypto/Aead.d.ts +322 -0
  185. package/dist/crypto/Aead.d.ts.map +1 -0
  186. package/dist/crypto/Aead.js +331 -0
  187. package/dist/crypto/Aead.js.map +1 -0
  188. package/dist/crypto/Cipher.d.ts +235 -0
  189. package/dist/crypto/Cipher.d.ts.map +1 -0
  190. package/dist/crypto/Cipher.js +233 -0
  191. package/dist/crypto/Cipher.js.map +1 -0
  192. package/dist/crypto/CryptoError.d.ts +212 -0
  193. package/dist/crypto/CryptoError.d.ts.map +1 -0
  194. package/dist/crypto/CryptoError.js +202 -0
  195. package/dist/crypto/CryptoError.js.map +1 -0
  196. package/dist/crypto/Digest.d.ts +143 -0
  197. package/dist/crypto/Digest.d.ts.map +1 -0
  198. package/dist/crypto/Digest.js +146 -0
  199. package/dist/crypto/Digest.js.map +1 -0
  200. package/dist/crypto/Kdf.d.ts +220 -0
  201. package/dist/crypto/Kdf.d.ts.map +1 -0
  202. package/dist/crypto/Kdf.js +212 -0
  203. package/dist/crypto/Kdf.js.map +1 -0
  204. package/dist/crypto/KeyAgreement.d.ts +323 -0
  205. package/dist/crypto/KeyAgreement.d.ts.map +1 -0
  206. package/dist/crypto/KeyAgreement.js +303 -0
  207. package/dist/crypto/KeyAgreement.js.map +1 -0
  208. package/dist/crypto/KeyFormat.d.ts +309 -0
  209. package/dist/crypto/KeyFormat.d.ts.map +1 -0
  210. package/dist/crypto/KeyFormat.js +556 -0
  211. package/dist/crypto/KeyFormat.js.map +1 -0
  212. package/dist/crypto/KeyWrap.d.ts +389 -0
  213. package/dist/crypto/KeyWrap.d.ts.map +1 -0
  214. package/dist/crypto/KeyWrap.js +381 -0
  215. package/dist/crypto/KeyWrap.js.map +1 -0
  216. package/dist/crypto/Mac.d.ts +277 -0
  217. package/dist/crypto/Mac.d.ts.map +1 -0
  218. package/dist/crypto/Mac.js +288 -0
  219. package/dist/crypto/Mac.js.map +1 -0
  220. package/dist/crypto/SecureRandom.d.ts +340 -0
  221. package/dist/crypto/SecureRandom.d.ts.map +1 -0
  222. package/dist/crypto/SecureRandom.js +257 -0
  223. package/dist/crypto/SecureRandom.js.map +1 -0
  224. package/dist/crypto/Signature.d.ts +448 -0
  225. package/dist/crypto/Signature.d.ts.map +1 -0
  226. package/dist/crypto/Signature.js +484 -0
  227. package/dist/crypto/Signature.js.map +1 -0
  228. package/dist/crypto/WebCrypto.d.ts +61 -0
  229. package/dist/crypto/WebCrypto.d.ts.map +1 -0
  230. package/dist/crypto/WebCrypto.js +63 -0
  231. package/dist/crypto/WebCrypto.js.map +1 -0
  232. package/dist/crypto/index.d.ts +65 -0
  233. package/dist/crypto/index.d.ts.map +1 -0
  234. package/dist/crypto/index.js +66 -0
  235. package/dist/crypto/index.js.map +1 -0
  236. package/dist/crypto/internal/asymmetric.d.ts +2 -0
  237. package/dist/crypto/internal/asymmetric.d.ts.map +1 -0
  238. package/dist/crypto/internal/asymmetric.js +210 -0
  239. package/dist/crypto/internal/asymmetric.js.map +1 -0
  240. package/dist/crypto/internal/chacha.d.ts +46 -0
  241. package/dist/crypto/internal/chacha.d.ts.map +1 -0
  242. package/dist/crypto/internal/chacha.js +885 -0
  243. package/dist/crypto/internal/chacha.js.map +1 -0
  244. package/dist/crypto/internal/der.d.ts +6 -0
  245. package/dist/crypto/internal/der.d.ts.map +1 -0
  246. package/dist/crypto/internal/der.js +86 -0
  247. package/dist/crypto/internal/der.js.map +1 -0
  248. package/dist/crypto/internal/digest.d.ts +2 -0
  249. package/dist/crypto/internal/digest.d.ts.map +1 -0
  250. package/dist/crypto/internal/digest.js +15 -0
  251. package/dist/crypto/internal/digest.js.map +1 -0
  252. package/dist/crypto/internal/key.d.ts +2 -0
  253. package/dist/crypto/internal/key.d.ts.map +1 -0
  254. package/dist/crypto/internal/key.js +170 -0
  255. package/dist/crypto/internal/key.js.map +1 -0
  256. package/dist/crypto/internal/md5.d.ts +39 -0
  257. package/dist/crypto/internal/md5.d.ts.map +1 -0
  258. package/dist/crypto/internal/md5.js +179 -0
  259. package/dist/crypto/internal/md5.js.map +1 -0
  260. package/dist/crypto/internal/webCrypto.d.ts +2 -0
  261. package/dist/crypto/internal/webCrypto.d.ts.map +1 -0
  262. package/dist/crypto/internal/webCrypto.js +111 -0
  263. package/dist/crypto/internal/webCrypto.js.map +1 -0
  264. package/dist/encoding/Base64Url.d.ts.map +1 -1
  265. package/dist/encoding/Base64Url.js +3 -2
  266. package/dist/encoding/Base64Url.js.map +1 -1
  267. package/dist/encoding/Csv.d.ts +608 -0
  268. package/dist/encoding/Csv.d.ts.map +1 -0
  269. package/dist/encoding/Csv.js +718 -0
  270. package/dist/encoding/Csv.js.map +1 -0
  271. package/dist/encoding/Hex.d.ts +3 -2
  272. package/dist/encoding/Hex.d.ts.map +1 -1
  273. package/dist/encoding/Hex.js +3 -2
  274. package/dist/encoding/Hex.js.map +1 -1
  275. package/dist/encoding/SchemaBinary.d.ts.map +1 -1
  276. package/dist/encoding/SchemaBinary.js +42 -4
  277. package/dist/encoding/SchemaBinary.js.map +1 -1
  278. package/dist/encoding/Toml.d.ts +17 -3
  279. package/dist/encoding/Toml.d.ts.map +1 -1
  280. package/dist/encoding/Toml.js +104 -16
  281. package/dist/encoding/Toml.js.map +1 -1
  282. package/dist/encoding/Yaml.d.ts +8 -1
  283. package/dist/encoding/Yaml.d.ts.map +1 -1
  284. package/dist/encoding/Yaml.js +54 -18
  285. package/dist/encoding/Yaml.js.map +1 -1
  286. package/dist/encoding/index.d.ts +5 -0
  287. package/dist/encoding/index.d.ts.map +1 -1
  288. package/dist/encoding/index.js +5 -0
  289. package/dist/encoding/index.js.map +1 -1
  290. package/dist/eventlog/EventJournal.d.ts.map +1 -1
  291. package/dist/eventlog/EventJournal.js +6 -3
  292. package/dist/eventlog/EventJournal.js.map +1 -1
  293. package/dist/eventlog/EventLog.d.ts +119 -4
  294. package/dist/eventlog/EventLog.d.ts.map +1 -1
  295. package/dist/eventlog/EventLog.js +200 -12
  296. package/dist/eventlog/EventLog.js.map +1 -1
  297. package/dist/eventlog/EventLogEncryption.d.ts +41 -4
  298. package/dist/eventlog/EventLogEncryption.d.ts.map +1 -1
  299. package/dist/eventlog/EventLogEncryption.js +83 -64
  300. package/dist/eventlog/EventLogEncryption.js.map +1 -1
  301. package/dist/eventlog/EventLogMessage.d.ts +279 -0
  302. package/dist/eventlog/EventLogMessage.d.ts.map +1 -1
  303. package/dist/eventlog/EventLogMessage.js +217 -1
  304. package/dist/eventlog/EventLogMessage.js.map +1 -1
  305. package/dist/eventlog/EventLogRemote.d.ts +200 -28
  306. package/dist/eventlog/EventLogRemote.d.ts.map +1 -1
  307. package/dist/eventlog/EventLogRemote.js +186 -16
  308. package/dist/eventlog/EventLogRemote.js.map +1 -1
  309. package/dist/eventlog/EventLogServer.d.ts +3 -0
  310. package/dist/eventlog/EventLogServer.d.ts.map +1 -1
  311. package/dist/eventlog/EventLogServer.js +18 -10
  312. package/dist/eventlog/EventLogServer.js.map +1 -1
  313. package/dist/eventlog/EventLogServerEncrypted.d.ts +326 -5
  314. package/dist/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
  315. package/dist/eventlog/EventLogServerEncrypted.js +769 -14
  316. package/dist/eventlog/EventLogServerEncrypted.js.map +1 -1
  317. package/dist/eventlog/EventLogSessionAuth.d.ts +5 -3
  318. package/dist/eventlog/EventLogSessionAuth.d.ts.map +1 -1
  319. package/dist/eventlog/EventLogSessionAuth.js +41 -64
  320. package/dist/eventlog/EventLogSessionAuth.js.map +1 -1
  321. package/dist/eventlog/EventRow.d.ts +4 -0
  322. package/dist/eventlog/EventRow.d.ts.map +1 -1
  323. package/dist/eventlog/EventRow.js +12 -2
  324. package/dist/eventlog/EventRow.js.map +1 -1
  325. package/dist/eventlog/SqlEventJournal.js +2 -2
  326. package/dist/eventlog/SqlEventJournal.js.map +1 -1
  327. package/dist/eventlog/SqlEventLogServerEncrypted.d.ts +21 -5
  328. package/dist/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -1
  329. package/dist/eventlog/SqlEventLogServerEncrypted.js +1048 -113
  330. package/dist/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
  331. package/dist/eventlog/SqlEventLogServerUnencrypted.js +2 -2
  332. package/dist/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
  333. package/dist/eventlog/internal/batches.d.ts +12 -0
  334. package/dist/eventlog/internal/batches.d.ts.map +1 -0
  335. package/dist/eventlog/internal/batches.js +26 -0
  336. package/dist/eventlog/internal/batches.js.map +1 -0
  337. package/dist/eventlog/internal/compaction.d.ts +38 -0
  338. package/dist/eventlog/internal/compaction.d.ts.map +1 -0
  339. package/dist/eventlog/internal/compaction.js +33 -0
  340. package/dist/eventlog/internal/compaction.js.map +1 -0
  341. package/dist/eventlog/internal/identityRootSecretDerivation.js +66 -67
  342. package/dist/eventlog/internal/identityRootSecretDerivation.js.map +1 -1
  343. package/dist/eventlog/internal/remoteCompaction.d.ts +31 -0
  344. package/dist/eventlog/internal/remoteCompaction.d.ts.map +1 -0
  345. package/dist/eventlog/internal/remoteCompaction.js +76 -0
  346. package/dist/eventlog/internal/remoteCompaction.js.map +1 -0
  347. package/dist/http/Cookies.d.ts +172 -0
  348. package/dist/http/Cookies.d.ts.map +1 -1
  349. package/dist/http/Cookies.js +143 -1
  350. package/dist/http/Cookies.js.map +1 -1
  351. package/dist/http/FetchHttpClient.d.ts +26 -2
  352. package/dist/http/FetchHttpClient.d.ts.map +1 -1
  353. package/dist/http/FetchHttpClient.js +78 -15
  354. package/dist/http/FetchHttpClient.js.map +1 -1
  355. package/dist/http/HttpClient.d.ts +79 -8
  356. package/dist/http/HttpClient.d.ts.map +1 -1
  357. package/dist/http/HttpClient.js +65 -5
  358. package/dist/http/HttpClient.js.map +1 -1
  359. package/dist/http/HttpClientRequest.d.ts +9 -5
  360. package/dist/http/HttpClientRequest.d.ts.map +1 -1
  361. package/dist/http/HttpClientRequest.js +2 -3
  362. package/dist/http/HttpClientRequest.js.map +1 -1
  363. package/dist/http/HttpClientResponse.d.ts.map +1 -1
  364. package/dist/http/HttpClientResponse.js +3 -2
  365. package/dist/http/HttpClientResponse.js.map +1 -1
  366. package/dist/http/HttpMethod.d.ts +7 -1
  367. package/dist/http/HttpMethod.d.ts.map +1 -1
  368. package/dist/http/HttpMethod.js +3 -8
  369. package/dist/http/HttpMethod.js.map +1 -1
  370. package/dist/http/HttpServerRequest.d.ts +5 -2
  371. package/dist/http/HttpServerRequest.d.ts.map +1 -1
  372. package/dist/http/HttpServerRequest.js +6 -17
  373. package/dist/http/HttpServerRequest.js.map +1 -1
  374. package/dist/http/HttpServerResponse.d.ts.map +1 -1
  375. package/dist/http/HttpServerResponse.js +3 -2
  376. package/dist/http/HttpServerResponse.js.map +1 -1
  377. package/dist/http/HttpTraceContext.d.ts +2 -1
  378. package/dist/http/HttpTraceContext.d.ts.map +1 -1
  379. package/dist/http/HttpTraceContext.js +7 -5
  380. package/dist/http/HttpTraceContext.js.map +1 -1
  381. package/dist/http/ProblemDetails.d.ts +96 -0
  382. package/dist/http/ProblemDetails.d.ts.map +1 -0
  383. package/dist/http/ProblemDetails.js +98 -0
  384. package/dist/http/ProblemDetails.js.map +1 -0
  385. package/dist/http/index.d.ts +5 -0
  386. package/dist/http/index.d.ts.map +1 -1
  387. package/dist/http/index.js +5 -0
  388. package/dist/http/index.js.map +1 -1
  389. package/dist/http/internal/decompression.js +3 -2
  390. package/dist/http/internal/decompression.js.map +1 -1
  391. package/dist/http/internal/urlParams.js +8 -0
  392. package/dist/http/internal/urlParams.js.map +1 -1
  393. package/dist/http-api/HttpApiBuilder.js +19 -5
  394. package/dist/http-api/HttpApiBuilder.js.map +1 -1
  395. package/dist/http-api/HttpApiClient.d.ts +63 -0
  396. package/dist/http-api/HttpApiClient.d.ts.map +1 -1
  397. package/dist/http-api/HttpApiClient.js +51 -0
  398. package/dist/http-api/HttpApiClient.js.map +1 -1
  399. package/dist/http-api/HttpApiEndpoint.d.ts.map +1 -1
  400. package/dist/http-api/HttpApiEndpoint.js +14 -5
  401. package/dist/http-api/HttpApiEndpoint.js.map +1 -1
  402. package/dist/http-api/HttpApiError.d.ts +185 -13
  403. package/dist/http-api/HttpApiError.d.ts.map +1 -1
  404. package/dist/http-api/HttpApiError.js +128 -0
  405. package/dist/http-api/HttpApiError.js.map +1 -1
  406. package/dist/http-api/HttpApiMiddleware.d.ts +64 -17
  407. package/dist/http-api/HttpApiMiddleware.d.ts.map +1 -1
  408. package/dist/http-api/HttpApiMiddleware.js +85 -1
  409. package/dist/http-api/HttpApiMiddleware.js.map +1 -1
  410. package/dist/http-api/HttpApiSchema.d.ts +76 -14
  411. package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
  412. package/dist/http-api/HttpApiSchema.js +53 -0
  413. package/dist/http-api/HttpApiSchema.js.map +1 -1
  414. package/dist/index.d.ts +5 -5
  415. package/dist/index.d.ts.map +1 -1
  416. package/dist/index.js +5 -5
  417. package/dist/index.js.map +1 -1
  418. package/dist/internal/effect.js +25 -14
  419. package/dist/internal/effect.js.map +1 -1
  420. package/dist/internal/glob.d.ts +2 -0
  421. package/dist/internal/glob.d.ts.map +1 -0
  422. package/dist/internal/glob.js +630 -0
  423. package/dist/internal/glob.js.map +1 -0
  424. package/dist/internal/matcher.js +10 -0
  425. package/dist/internal/matcher.js.map +1 -1
  426. package/dist/internal/persistence.js +9 -0
  427. package/dist/internal/persistence.js.map +1 -1
  428. package/dist/internal/rcRef.js +4 -1
  429. package/dist/internal/rcRef.js.map +1 -1
  430. package/dist/internal/schema/toCodeDocument.js +6 -3
  431. package/dist/internal/schema/toCodeDocument.js.map +1 -1
  432. package/dist/internal/trie.js +42 -13
  433. package/dist/internal/trie.js.map +1 -1
  434. package/dist/internal/ulid.js +41 -0
  435. package/dist/internal/ulid.js.map +1 -1
  436. package/dist/internal/uuid.js +52 -8
  437. package/dist/internal/uuid.js.map +1 -1
  438. package/dist/internal/version.js +1 -1
  439. package/dist/observability/Otlp.d.ts +15 -4
  440. package/dist/observability/Otlp.d.ts.map +1 -1
  441. package/dist/observability/Otlp.js +10 -0
  442. package/dist/observability/Otlp.js.map +1 -1
  443. package/dist/observability/OtlpResource.d.ts +7 -0
  444. package/dist/observability/OtlpResource.d.ts.map +1 -1
  445. package/dist/observability/OtlpResource.js +11 -1
  446. package/dist/observability/OtlpResource.js.map +1 -1
  447. package/dist/persistence/KeyValueStore.d.ts +47 -2
  448. package/dist/persistence/KeyValueStore.d.ts.map +1 -1
  449. package/dist/persistence/KeyValueStore.js +129 -18
  450. package/dist/persistence/KeyValueStore.js.map +1 -1
  451. package/dist/persistence/PersistedQueue.d.ts +9 -0
  452. package/dist/persistence/PersistedQueue.d.ts.map +1 -1
  453. package/dist/persistence/PersistedQueue.js +94 -52
  454. package/dist/persistence/PersistedQueue.js.map +1 -1
  455. package/dist/persistence/Persistence.d.ts +10 -4
  456. package/dist/persistence/Persistence.d.ts.map +1 -1
  457. package/dist/persistence/Persistence.js +18 -11
  458. package/dist/persistence/Persistence.js.map +1 -1
  459. package/dist/process/ChildProcess.d.ts +207 -67
  460. package/dist/process/ChildProcess.d.ts.map +1 -1
  461. package/dist/process/ChildProcess.js +56 -158
  462. package/dist/process/ChildProcess.js.map +1 -1
  463. package/dist/process/ChildProcessSpawner.d.ts +5 -0
  464. package/dist/process/ChildProcessSpawner.d.ts.map +1 -1
  465. package/dist/process/ChildProcessSpawner.js.map +1 -1
  466. package/dist/process/CommandLine.d.ts +294 -0
  467. package/dist/process/CommandLine.d.ts.map +1 -0
  468. package/dist/process/CommandLine.js +481 -0
  469. package/dist/process/CommandLine.js.map +1 -0
  470. package/dist/process/index.d.ts +5 -0
  471. package/dist/process/index.d.ts.map +1 -1
  472. package/dist/process/index.js +5 -0
  473. package/dist/process/index.js.map +1 -1
  474. package/dist/reactivity/Atom.d.ts +2 -1
  475. package/dist/reactivity/Atom.d.ts.map +1 -1
  476. package/dist/reactivity/Atom.js +3 -4
  477. package/dist/reactivity/Atom.js.map +1 -1
  478. package/dist/reactivity/AtomRegistry.js.map +1 -1
  479. package/dist/rpc/RpcClient.d.ts +16 -1
  480. package/dist/rpc/RpcClient.d.ts.map +1 -1
  481. package/dist/rpc/RpcClient.js +50 -16
  482. package/dist/rpc/RpcClient.js.map +1 -1
  483. package/dist/rpc/RpcMessage.d.ts +10 -1
  484. package/dist/rpc/RpcMessage.d.ts.map +1 -1
  485. package/dist/rpc/RpcMessage.js +1 -0
  486. package/dist/rpc/RpcMessage.js.map +1 -1
  487. package/dist/rpc/RpcSerialization.d.ts.map +1 -1
  488. package/dist/rpc/RpcSerialization.js +6 -0
  489. package/dist/rpc/RpcSerialization.js.map +1 -1
  490. package/dist/rpc/RpcServer.d.ts +31 -0
  491. package/dist/rpc/RpcServer.d.ts.map +1 -1
  492. package/dist/rpc/RpcServer.js +139 -66
  493. package/dist/rpc/RpcServer.js.map +1 -1
  494. package/dist/schema/Model.d.ts +14 -0
  495. package/dist/schema/Model.d.ts.map +1 -1
  496. package/dist/schema/Model.js +18 -3
  497. package/dist/schema/Model.js.map +1 -1
  498. package/dist/sql/Migrator.d.ts +0 -19
  499. package/dist/sql/Migrator.d.ts.map +1 -1
  500. package/dist/sql/Migrator.js +3 -48
  501. package/dist/sql/Migrator.js.map +1 -1
  502. package/dist/sql/MigratorFileSystem.d.ts +21 -0
  503. package/dist/sql/MigratorFileSystem.d.ts.map +1 -0
  504. package/dist/sql/MigratorFileSystem.js +57 -0
  505. package/dist/sql/MigratorFileSystem.js.map +1 -0
  506. package/dist/sql/SqlClient.d.ts.map +1 -1
  507. package/dist/sql/SqlClient.js +5 -9
  508. package/dist/sql/SqlClient.js.map +1 -1
  509. package/dist/sql/Statement.d.ts +20 -6
  510. package/dist/sql/Statement.d.ts.map +1 -1
  511. package/dist/sql/Statement.js +0 -13
  512. package/dist/sql/Statement.js.map +1 -1
  513. package/dist/sql/index.js +1 -1
  514. package/dist/testing/index.d.ts +0 -5
  515. package/dist/testing/index.d.ts.map +1 -1
  516. package/dist/testing/index.js +0 -5
  517. package/dist/testing/index.js.map +1 -1
  518. package/dist/workflow/internal/crypto.js +9 -8
  519. package/dist/workflow/internal/crypto.js.map +1 -1
  520. package/package.json +3 -1
  521. package/src/BigDecimal.ts +3 -0
  522. package/src/Channel.ts +17 -11
  523. package/src/Config.ts +7 -1
  524. package/src/Context.ts +34 -10
  525. package/src/Cron.ts +178 -29
  526. package/src/Duration.ts +140 -0
  527. package/src/Effect.ts +914 -85
  528. package/src/FileSystem.ts +65 -4
  529. package/src/Glob.ts +205 -0
  530. package/src/Match.ts +127 -0
  531. package/src/Pool.ts +73 -15
  532. package/src/Random.ts +3 -3
  533. package/src/RcMap.ts +5 -1
  534. package/src/Schedule.ts +26 -3
  535. package/src/Schema.ts +1189 -62
  536. package/src/SchemaGetter.ts +27 -11
  537. package/src/SchemaRepresentation.ts +19 -0
  538. package/src/SchemaTransformation.ts +8 -3
  539. package/src/ScopedCache.ts +5 -9
  540. package/src/Semaphore.ts +141 -0
  541. package/src/Stream.ts +15 -6
  542. package/src/Terminal.ts +19 -1
  543. package/src/ai/AiError.ts +56 -80
  544. package/src/ai/Decision.ts +257 -6
  545. package/src/ai/DecisionModel.ts +171 -28
  546. package/src/ai/McpServer.ts +1269 -286
  547. package/src/ai/McpTest.ts +380 -0
  548. package/src/ai/Response.ts +2 -22
  549. package/src/ai/Tool.ts +27 -8
  550. package/src/ai/index.ts +6 -0
  551. package/src/ai/internal/mcpCore.ts +78 -44
  552. package/src/ai/internal/mcpProtocol/v2024_11_05.ts +4 -7
  553. package/src/ai/internal/mcpProtocol/v2025_03_26.ts +4 -7
  554. package/src/ai/internal/mcpProtocol/v2025_06_18.ts +4 -7
  555. package/src/ai/internal/mcpProtocol/v2025_11_25.ts +4 -7
  556. package/src/ai/internal/mcpProtocol/v2026_07_28.ts +15 -10
  557. package/src/ai/internal/mcpProtocol.ts +29 -0
  558. package/src/ai/internal/mcpRuntime.ts +9 -5
  559. package/src/ai/internal/mcpStatefulRuntime.ts +14 -2
  560. package/src/cli/Argument.ts +6 -0
  561. package/src/cli/CliOutput.ts +117 -49
  562. package/src/cli/Command.ts +23 -0
  563. package/src/cli/Flag.ts +107 -0
  564. package/src/cli/HelpDoc.ts +18 -1
  565. package/src/cli/Param.ts +6 -0
  566. package/src/cli/Primitive.ts +16 -1
  567. package/src/cli/Prompt.ts +1 -0
  568. package/src/cli/internal/help.ts +21 -9
  569. package/src/cluster/Sharding.ts +93 -26
  570. package/src/cluster/ShardingConfig.ts +41 -3
  571. package/src/cluster/SingleRunner.ts +3 -3
  572. package/src/cluster/SqlMessageStorage.ts +49 -17
  573. package/src/cluster/SqlRunnerStorage.ts +37 -27
  574. package/src/crypto/Aead.ts +517 -0
  575. package/src/crypto/Cipher.ts +326 -0
  576. package/src/crypto/CryptoError.ts +242 -0
  577. package/src/crypto/Digest.ts +167 -0
  578. package/src/crypto/Kdf.ts +315 -0
  579. package/src/crypto/KeyAgreement.ts +489 -0
  580. package/src/crypto/KeyFormat.ts +712 -0
  581. package/src/crypto/KeyWrap.ts +639 -0
  582. package/src/crypto/Mac.ts +386 -0
  583. package/src/crypto/SecureRandom.ts +459 -0
  584. package/src/crypto/Signature.ts +673 -0
  585. package/src/crypto/WebCrypto.ts +64 -0
  586. package/src/crypto/index.ts +78 -0
  587. package/src/crypto/internal/asymmetric.ts +329 -0
  588. package/src/crypto/internal/chacha.ts +1088 -0
  589. package/src/crypto/internal/der.ts +110 -0
  590. package/src/crypto/internal/digest.ts +16 -0
  591. package/src/crypto/internal/key.ts +235 -0
  592. package/src/crypto/internal/md5.ts +170 -0
  593. package/src/crypto/internal/webCrypto.ts +150 -0
  594. package/src/encoding/Base64Url.ts +5 -2
  595. package/src/encoding/Csv.ts +1298 -0
  596. package/src/encoding/Hex.ts +3 -2
  597. package/src/encoding/SchemaBinary.ts +40 -4
  598. package/src/encoding/Toml.ts +85 -20
  599. package/src/encoding/Yaml.ts +61 -18
  600. package/src/encoding/index.ts +6 -0
  601. package/src/eventlog/EventJournal.ts +4 -3
  602. package/src/eventlog/EventLog.ts +340 -15
  603. package/src/eventlog/EventLogEncryption.ts +118 -110
  604. package/src/eventlog/EventLogMessage.ts +273 -1
  605. package/src/eventlog/EventLogRemote.ts +367 -23
  606. package/src/eventlog/EventLogServer.ts +23 -8
  607. package/src/eventlog/EventLogServerEncrypted.ts +1130 -67
  608. package/src/eventlog/EventLogSessionAuth.ts +56 -70
  609. package/src/eventlog/EventRow.ts +12 -3
  610. package/src/eventlog/SqlEventJournal.ts +2 -2
  611. package/src/eventlog/SqlEventLogServerEncrypted.ts +1244 -136
  612. package/src/eventlog/SqlEventLogServerUnencrypted.ts +2 -2
  613. package/src/eventlog/internal/batches.ts +30 -0
  614. package/src/eventlog/internal/compaction.ts +64 -0
  615. package/src/eventlog/internal/identityRootSecretDerivation.ts +93 -123
  616. package/src/eventlog/internal/remoteCompaction.ts +92 -0
  617. package/src/http/Cookies.ts +281 -1
  618. package/src/http/FetchHttpClient.ts +88 -16
  619. package/src/http/HttpClient.ts +89 -22
  620. package/src/http/HttpClientRequest.ts +12 -9
  621. package/src/http/HttpClientResponse.ts +3 -2
  622. package/src/http/HttpMethod.ts +10 -2
  623. package/src/http/HttpServerRequest.ts +15 -30
  624. package/src/http/HttpServerResponse.ts +3 -2
  625. package/src/http/HttpTraceContext.ts +7 -4
  626. package/src/http/ProblemDetails.ts +149 -0
  627. package/src/http/index.ts +6 -0
  628. package/src/http/internal/decompression.ts +4 -4
  629. package/src/http/internal/urlParams.ts +8 -0
  630. package/src/http-api/HttpApiBuilder.ts +24 -12
  631. package/src/http-api/HttpApiClient.ts +67 -1
  632. package/src/http-api/HttpApiEndpoint.ts +14 -5
  633. package/src/http-api/HttpApiError.ts +250 -0
  634. package/src/http-api/HttpApiMiddleware.ts +95 -1
  635. package/src/http-api/HttpApiSchema.ts +105 -14
  636. package/src/index.ts +6 -6
  637. package/src/internal/effect.ts +34 -18
  638. package/src/internal/glob.ts +736 -0
  639. package/src/internal/matcher.ts +17 -0
  640. package/src/internal/persistence.ts +11 -0
  641. package/src/internal/rcRef.ts +4 -1
  642. package/src/internal/schema/toCodeDocument.ts +7 -3
  643. package/src/internal/trie.ts +43 -14
  644. package/src/internal/ulid.ts +44 -0
  645. package/src/internal/uuid.ts +57 -16
  646. package/src/internal/version.ts +1 -1
  647. package/src/observability/Otlp.ts +21 -4
  648. package/src/observability/OtlpResource.ts +9 -1
  649. package/src/persistence/KeyValueStore.ts +219 -22
  650. package/src/persistence/PersistedQueue.ts +128 -59
  651. package/src/persistence/Persistence.ts +20 -13
  652. package/src/process/ChildProcess.ts +255 -260
  653. package/src/process/ChildProcessSpawner.ts +5 -0
  654. package/src/process/CommandLine.ts +630 -0
  655. package/src/process/index.ts +6 -0
  656. package/src/reactivity/Atom.ts +5 -5
  657. package/src/reactivity/AtomRegistry.ts +1 -1
  658. package/src/rpc/RpcClient.ts +62 -26
  659. package/src/rpc/RpcMessage.ts +10 -1
  660. package/src/rpc/RpcSerialization.ts +3 -0
  661. package/src/rpc/RpcServer.ts +176 -78
  662. package/src/schema/Model.ts +26 -3
  663. package/src/sql/Migrator.ts +4 -63
  664. package/src/sql/MigratorFileSystem.ts +71 -0
  665. package/src/sql/SqlClient.ts +2 -16
  666. package/src/sql/Statement.ts +8 -7
  667. package/src/sql/index.ts +1 -1
  668. package/src/testing/index.ts +0 -6
  669. package/src/workflow/internal/crypto.ts +15 -11
  670. package/dist/Crypto.d.ts +0 -244
  671. package/dist/Crypto.d.ts.map +0 -1
  672. package/dist/Crypto.js +0 -139
  673. package/dist/Crypto.js.map +0 -1
  674. package/dist/testing/TestCrypto.d.ts +0 -73
  675. package/dist/testing/TestCrypto.d.ts.map +0 -1
  676. package/dist/testing/TestCrypto.js +0 -87
  677. package/dist/testing/TestCrypto.js.map +0 -1
  678. package/src/Crypto.ts +0 -347
  679. package/src/testing/TestCrypto.ts +0 -94
@@ -140,6 +140,9 @@ export interface ChildProcessHandle {
140
140
  *
141
141
  * **Details**
142
142
  *
143
+ * Available for `"input"` and `"duplex"` file descriptors. The write side is
144
+ * ended when the sink completes.
145
+ *
143
146
  * If a file descriptor is accessed that was not configured, returns a drain
144
147
  * `Sink`.
145
148
  */
@@ -150,6 +153,8 @@ export interface ChildProcessHandle {
150
153
  *
151
154
  * **Details**
152
155
  *
156
+ * Available for `"output"` and `"duplex"` file descriptors.
157
+ *
153
158
  * If a file descriptor is accessed that was not configured, returns an empty
154
159
  * `Stream`.
155
160
  */
@@ -0,0 +1,630 @@
1
+ /**
2
+ * Builds command lines, the single strings that a shell or a Windows program
3
+ * turns back into arguments, and argument lists from templates. It is
4
+ * unrelated to `effect/cli`, which parses the arguments of your own program.
5
+ *
6
+ * The rules depend on what parses the string, not on the platform that builds
7
+ * it, so `quote`, `join` and `display` take an explicit `format`:
8
+ *
9
+ * - `"posix"` (the default) for `sh`, `dash`, `bash` and `zsh`. Quoted output
10
+ * is also read the same way by `fish`.
11
+ * - `"powershell"` for PowerShell 7.3 or later.
12
+ * - `"windows"` for the Microsoft C runtime rules that most Windows programs
13
+ * use to split their command line.
14
+ *
15
+ * SSH sends one command line to the login shell of the remote account, so the
16
+ * format must match that shell. The remote shell must be a POSIX shell or
17
+ * PowerShell: Windows OpenSSH uses `cmd.exe` by default, which no format
18
+ * supports, so set its `DefaultShell` to PowerShell. Docker and Kubernetes exec
19
+ * take argument lists and need no command line at all.
20
+ *
21
+ * Arguments can be `Redacted` strings. `quote` and `join` include their values,
22
+ * because their output is meant to run, while `display` replaces them with
23
+ * `<redacted>`.
24
+ *
25
+ * @stability unstable
26
+ * @since 4.0.7
27
+ */
28
+ import * as Data from "../Data.ts"
29
+ import * as Redacted from "../Redacted.ts"
30
+ import * as Result from "../Result.ts"
31
+
32
+ /**
33
+ * Command line syntax understood by the functions in this module.
34
+ *
35
+ * **Details**
36
+ *
37
+ * - `"posix"`: POSIX shells (`sh`, `dash`, `bash`, `zsh`). Quoted words are
38
+ * also safe in `fish`.
39
+ * - `"powershell"`: PowerShell 7.3 or later, which passes arguments to native
40
+ * programs unchanged (`$PSNativeCommandArgumentPassing` set to `Standard` or
41
+ * `Windows`).
42
+ * - `"windows"`: the Microsoft C runtime convention, also implemented by
43
+ * `CommandLineToArgvW`, that most Windows programs use. It is not the syntax
44
+ * of `cmd.exe` or of batch files.
45
+ *
46
+ * @stability unstable
47
+ * @category models
48
+ * @since 4.0.7
49
+ */
50
+ export type Format = "posix" | "powershell" | "windows"
51
+
52
+ /**
53
+ * One argument: a plain string or a `Redacted` string that must not appear in
54
+ * logs.
55
+ *
56
+ * @stability unstable
57
+ * @category models
58
+ * @since 4.0.7
59
+ */
60
+ export type Word = string | Redacted.Redacted<string>
61
+
62
+ /**
63
+ * Single value accepted inside a `${}` interpolation of {@link template}.
64
+ *
65
+ * @stability unstable
66
+ * @category models
67
+ * @since 4.0.7
68
+ */
69
+ export type TemplateExpressionItem = string | number | boolean | Redacted.Redacted<string>
70
+
71
+ /**
72
+ * Value accepted inside a `${}` interpolation of {@link template}.
73
+ *
74
+ * **Details**
75
+ *
76
+ * An array adds one argument per element and must stand alone as a whole
77
+ * argument. An empty array adds no arguments.
78
+ *
79
+ * @stability unstable
80
+ * @category models
81
+ * @since 4.0.7
82
+ */
83
+ export type TemplateExpression = TemplateExpressionItem | ReadonlyArray<TemplateExpressionItem>
84
+
85
+ /**
86
+ * Error returned when a command line or a template cannot be built.
87
+ *
88
+ * **Details**
89
+ *
90
+ * - `NulCharacter`: an argument passed to {@link quote} or {@link join}
91
+ * contains a NUL character, which no command line can carry.
92
+ * - `InvalidArgument`: the format cannot carry an argument: a Windows program
93
+ * name with a double quote, or the argument `--%`, which PowerShell drops
94
+ * when it calls a native program.
95
+ * - `InvalidEscape`: template text ends with a backslash that escapes nothing,
96
+ * or contains an invalid JavaScript escape sequence.
97
+ * - `UnterminatedQuote`: a quoted section of a template is not closed.
98
+ * - `UnsupportedSyntax`: template text contains shell syntax that cannot work
99
+ * without a shell, such as operators, expansions, globs, comments or
100
+ * variable assignments, or an interpolated array is not a separate argument.
101
+ *
102
+ * Messages never include the input, which may contain secrets.
103
+ *
104
+ * @stability unstable
105
+ * @category errors
106
+ * @since 4.0.7
107
+ */
108
+ export class CommandLineError extends Data.TaggedError("CommandLineError")<{
109
+ readonly reason: "NulCharacter" | "InvalidArgument" | "InvalidEscape" | "UnterminatedQuote" | "UnsupportedSyntax"
110
+ readonly message: string
111
+ }> {}
112
+
113
+ /**
114
+ * Quotes one argument so that a program reading the given format sees it as
115
+ * exactly one argument, with one PowerShell exception listed under Gotchas.
116
+ *
117
+ * **When to use**
118
+ *
119
+ * Use when you insert an argument into a command line that is otherwise
120
+ * written by hand, for example a script passed to `sh -c`.
121
+ *
122
+ * **Details**
123
+ *
124
+ * - `"posix"` leaves words made of letters, digits and `_ @ + : , . / -`
125
+ * unchanged and wraps everything else in single quotes. Single quotes and
126
+ * backslashes are written outside the quotes, so `fish` reads the result
127
+ * the same way.
128
+ * - `"powershell"` always uses single quotes, doubling `'` and the
129
+ * typographic single quotes that PowerShell also accepts as quotes.
130
+ * - `"windows"` quotes words that contain a space, a tab, a line break or a
131
+ * double quote, using the C runtime backslash rules. Use {@link join} for a
132
+ * complete command line, because the program name follows different rules.
133
+ *
134
+ * **Gotchas**
135
+ *
136
+ * - The result contains the value of a `Redacted` argument. Use
137
+ * {@link display} for logs.
138
+ * - Control characters are kept as they are. That is safe for `sh -c` and SSH
139
+ * commands, but not for text typed into an interactive shell.
140
+ * - PowerShell never passes an argument equal to `--%` to a native program,
141
+ * however it is quoted. Use {@link join} for a whole native call, which
142
+ * fails with `InvalidArgument` instead.
143
+ *
144
+ * **Example** (Quoting arguments for different shells)
145
+ *
146
+ * ```ts import.meta.vitest
147
+ * import { Result } from "effect"
148
+ * import { CommandLine } from "effect/process"
149
+ *
150
+ * CommandLine.quote("it's") // => Result.succeed("'it'\\''s'")
151
+ * CommandLine.quote("it's", { format: "powershell" }) // => Result.succeed("'it''s'")
152
+ * CommandLine.quote("C:\\My Files\\", { format: "windows" }) // => Result.succeed("\"C:\\My Files\\\\\"")
153
+ * ```
154
+ *
155
+ * @see {@link join} for quoting a whole argument list
156
+ *
157
+ * @stability unstable
158
+ * @category encoding
159
+ * @since 4.0.7
160
+ */
161
+ export const quote = (
162
+ word: Word,
163
+ options?: { readonly format?: Format | undefined }
164
+ ): Result.Result<string, CommandLineError> => {
165
+ const value = unwrap(word)
166
+ if (value.includes("\0")) return failNul("The argument")
167
+ return Result.succeed(quoteWord(options?.format ?? "posix", value, false))
168
+ }
169
+
170
+ /**
171
+ * Builds a command line that runs the given program and arguments.
172
+ *
173
+ * **When to use**
174
+ *
175
+ * Use when a transport accepts only one string, such as an SSH exec request or
176
+ * a `shell` option, and the arguments must reach the program unchanged.
177
+ *
178
+ * **Details**
179
+ *
180
+ * The first word is the program. Each word is quoted as in {@link quote} and
181
+ * the words are separated by spaces.
182
+ *
183
+ * - `"posix"` also quotes a program name that `sh`, `bash`, `zsh` or `fish`
184
+ * reads as syntax, such as `if` or `time`.
185
+ * - `"powershell"` starts the line with the call operator `&`, because a
186
+ * quoted program name is otherwise read as a string value.
187
+ * - `"windows"` quotes the program name with the C runtime rules for program
188
+ * names, which do not support backslash escapes.
189
+ * - An empty list returns an empty string.
190
+ *
191
+ * **Gotchas**
192
+ *
193
+ * - The result contains the values of `Redacted` arguments. Use
194
+ * {@link display} for logs.
195
+ * - A Windows program name that contains `"` fails with `InvalidArgument`.
196
+ * - For `"powershell"`, an argument equal to `--%` fails with
197
+ * `InvalidArgument`: PowerShell drops it when it calls a native program,
198
+ * however it is quoted.
199
+ * - `"windows"` output is the command line of a program, not a `cmd.exe`
200
+ * script. `cmd.exe`, which `shell: true` uses on Windows, expands `%NAME%`
201
+ * and reads `^ & | < >` before the program sees its arguments, so a script
202
+ * that contains untrusted values has to be written by hand.
203
+ *
204
+ * **Example** (Joining arguments into command lines)
205
+ *
206
+ * ```ts import.meta.vitest
207
+ * import { Result } from "effect"
208
+ * import { CommandLine } from "effect/process"
209
+ *
210
+ * const args = ["git", "commit", "-m", "fix: don't fail"]
211
+ *
212
+ * CommandLine.join(args) // => Result.succeed("git commit -m 'fix: don'\\''t fail'")
213
+ * CommandLine.join(args, { format: "powershell" }) // => Result.succeed("& 'git' 'commit' '-m' 'fix: don''t fail'")
214
+ * CommandLine.join(args, { format: "windows" }) // => Result.succeed("git commit -m \"fix: don't fail\"")
215
+ * ```
216
+ *
217
+ * @see {@link display} for rendering a command for logs and error messages
218
+ *
219
+ * @stability unstable
220
+ * @category encoding
221
+ * @since 4.0.7
222
+ */
223
+ export const join = (
224
+ words: ReadonlyArray<Word>,
225
+ options?: { readonly format?: Format | undefined }
226
+ ): Result.Result<string, CommandLineError> => {
227
+ const values: Array<string> = []
228
+ for (let i = 0; i < words.length; i++) {
229
+ const value = unwrap(words[i])
230
+ if (value.includes("\0")) return failNul(`Argument ${i}`)
231
+ values.push(value)
232
+ }
233
+ if (values.length === 0) return Result.succeed("")
234
+ const format = options?.format ?? "posix"
235
+ if (format === "powershell") {
236
+ const stopParsing = values.indexOf("--%", 1)
237
+ if (stopParsing !== -1) {
238
+ return Result.fail(
239
+ new CommandLineError({
240
+ reason: "InvalidArgument",
241
+ message: `Argument ${stopParsing} is "--%", which PowerShell drops when it calls a program`
242
+ })
243
+ )
244
+ }
245
+ } else if (format === "windows" && values[0].includes("\"")) {
246
+ return Result.fail(
247
+ new CommandLineError({
248
+ reason: "InvalidArgument",
249
+ message: "A Windows program name cannot contain a double quote"
250
+ })
251
+ )
252
+ }
253
+ return Result.succeed(joinWords(format, values.map((value, i) => quoteWord(format, value, i === 0))))
254
+ }
255
+
256
+ /**
257
+ * Renders a command for logs and error messages.
258
+ *
259
+ * **When to use**
260
+ *
261
+ * Use when you show a command to a person, for example in an error message,
262
+ * and secrets and control characters must not reach the output.
263
+ *
264
+ * **Details**
265
+ *
266
+ * - Quotes like {@link join}, so commands without control characters or
267
+ * secrets can be copied into a terminal of the given format.
268
+ * - Replaces `Redacted` arguments with `<redacted>`.
269
+ * - Writes control characters and Unicode line separators as escapes such as
270
+ * `\n` or `\u001b`, so output cannot move the cursor or inject terminal
271
+ * sequences.
272
+ * - Never fails: input that {@link join} rejects is rendered anyway.
273
+ *
274
+ * **Gotchas**
275
+ *
276
+ * The output is for reading only. It is not a reliable command line: escapes
277
+ * and `<redacted>` change what a shell would run.
278
+ *
279
+ * **Example** (Showing a command with a secret)
280
+ *
281
+ * ```ts import.meta.vitest
282
+ * import { Redacted } from "effect"
283
+ * import { CommandLine } from "effect/process"
284
+ *
285
+ * const token = Redacted.make("hunter2")
286
+ *
287
+ * CommandLine.display(["curl", "-H", token, "https://x.dev/a b"]) // => "curl -H <redacted> 'https://x.dev/a b'"
288
+ * ```
289
+ *
290
+ * @see {@link join} for building a command line to run
291
+ *
292
+ * @stability unstable
293
+ * @category encoding
294
+ * @since 4.0.7
295
+ */
296
+ export const display = (words: ReadonlyArray<Word>, options?: { readonly format?: Format | undefined }): string => {
297
+ if (words.length === 0) return ""
298
+ const format = options?.format ?? "posix"
299
+ // Escaping after quoting keeps the escapes inside the quotes.
300
+ return joinWords(
301
+ format,
302
+ words.map((word, i) =>
303
+ Redacted.isRedacted(word) ? "<redacted>" : escapeControlCharacters(quoteWord(format, word, i === 0))
304
+ )
305
+ )
306
+ }
307
+
308
+ /**
309
+ * Builds an argument list from a template literal.
310
+ *
311
+ * **When to use**
312
+ *
313
+ * Use to write a command as it would look in a shell while keeping every
314
+ * interpolated value a literal argument.
315
+ *
316
+ * **Details**
317
+ *
318
+ * - The template text is split into words as a POSIX shell does: spaces,
319
+ * tabs and line breaks separate words, and quotes and backslash escapes are
320
+ * removed. A long command can span several lines.
321
+ * - Text that would need a shell fails with `UnsupportedSyntax`: operators
322
+ * (`| & ; < > ( )`), expansions (`$NAME`, `${...}`, `$(...)`, backticks, a
323
+ * leading `~`, braces such as `{a,b}`, and a leading `=` that `zsh`
324
+ * expands), globs (`* ? [`), comments (`#` at the start of a word), and a
325
+ * variable assignment in the program position. Quote such characters to
326
+ * pass them literally.
327
+ * - No shell runs, so a program such as `if` or `time` names an executable.
328
+ * - Each `${}` value is inserted literally, without splitting or quote
329
+ * processing. Next to other text or inside quotes, it becomes part of the
330
+ * surrounding argument.
331
+ * - An array adds one argument per element and must stand alone as a whole
332
+ * argument.
333
+ * - Numbers and booleans are converted with `String`.
334
+ * - An argument that contains a `Redacted` value becomes `Redacted` as a
335
+ * whole.
336
+ *
337
+ * **Gotchas**
338
+ *
339
+ * - An invalid JavaScript escape sequence in the text, such as `\u` without
340
+ * hex digits, fails with `InvalidEscape`. Use `String.raw` or a `${}` value
341
+ * for backslashes.
342
+ * - Neither the text nor the values are checked for NUL characters.
343
+ * {@link join} and the child process spawners reject them where they would
344
+ * truncate an argument.
345
+ *
346
+ * **Example** (Building arguments with interpolated values)
347
+ *
348
+ * ```ts import.meta.vitest
349
+ * import { Redacted, Result } from "effect"
350
+ * import { CommandLine } from "effect/process"
351
+ *
352
+ * const msg = "fix: handle $HOME"
353
+ * const files = ["a.ts", "b.ts"]
354
+ *
355
+ * CommandLine.template`git commit -m ${msg} ${files}` // => Result.succeed(["git", "commit", "-m", msg, ...files])
356
+ *
357
+ * const password = Redacted.make("hunter2")
358
+ * const words = Result.getOrThrow(CommandLine.template`psql "--password=${password}"`)
359
+ *
360
+ * CommandLine.display(words) // => "psql <redacted>"
361
+ * ```
362
+ *
363
+ * @stability unstable
364
+ * @category constructors
365
+ * @since 4.0.7
366
+ */
367
+ export const template = (
368
+ strings: TemplateStringsArray,
369
+ ...expressions: ReadonlyArray<TemplateExpression>
370
+ ): Result.Result<Array<Word>, CommandLineError> => {
371
+ const index = strings.findIndex((text) => text === undefined)
372
+ if (index !== -1) {
373
+ return Result.fail(
374
+ new CommandLineError({
375
+ reason: "InvalidEscape",
376
+ message: `Template part ${index} contains an invalid escape sequence`
377
+ })
378
+ )
379
+ }
380
+ return parseTemplate(strings, expressions)
381
+ }
382
+
383
+ // -----------------------------------------------------------------------------
384
+ // Quoting
385
+ // -----------------------------------------------------------------------------
386
+
387
+ const unwrap = (item: TemplateExpressionItem): string =>
388
+ Redacted.isRedacted(item) ? Redacted.value(item as Redacted.Redacted<string>) : String(item)
389
+
390
+ const toWord = (item: TemplateExpressionItem): Word =>
391
+ Redacted.isRedacted(item) ? item as Redacted.Redacted<string> : String(item)
392
+
393
+ const failNul = (subject: string): Result.Result<never, CommandLineError> =>
394
+ Result.fail(new CommandLineError({ reason: "NulCharacter", message: `${subject} contains a NUL character` }))
395
+
396
+ // Words that sh, bash, zsh or fish read as syntax in the program position. A
397
+ // quoted reserved word is an ordinary command name.
398
+ const reservedWords = new Set([
399
+ "!",
400
+ "{",
401
+ "}",
402
+ "and",
403
+ "begin",
404
+ "case",
405
+ "coproc",
406
+ "do",
407
+ "done",
408
+ "elif",
409
+ "else",
410
+ "end",
411
+ "esac",
412
+ "fi",
413
+ "for",
414
+ "foreach",
415
+ "function",
416
+ "if",
417
+ "in",
418
+ "nocorrect",
419
+ "not",
420
+ "or",
421
+ "repeat",
422
+ "select",
423
+ "switch",
424
+ "then",
425
+ "time",
426
+ "until",
427
+ "while"
428
+ ])
429
+
430
+ // Quotes one word for the format. The program, the first word, follows
431
+ // different rules from the arguments in POSIX shells and in Windows programs.
432
+ const quoteWord = (format: Format, value: string, program: boolean): string => {
433
+ switch (format) {
434
+ case "posix":
435
+ return program && reservedWords.has(value) ? `'${value}'` : quotePosix(value)
436
+ case "powershell":
437
+ return quotePowerShell(value)
438
+ case "windows":
439
+ return program && !value.includes("\"") ? quoteWindowsProgram(value) : quoteWindowsArgument(value)
440
+ }
441
+ }
442
+
443
+ const joinWords = (format: Format, quoted: ReadonlyArray<string>): string =>
444
+ format === "powershell" ? `& ${quoted.join(" ")}` : quoted.join(" ")
445
+
446
+ const posixSafe = /^[A-Za-z0-9_@+:,./-]+$/
447
+
448
+ // Single quotes keep every character literal in POSIX shells. `'` and `\` are
449
+ // written outside the quotes, because fish also treats `\'` and `\\` as
450
+ // escapes inside single quotes.
451
+ const quotePosix = (value: string): string =>
452
+ posixSafe.test(value) ? value : `'${value.replace(/['\\]/g, (char) => `'\\${char}'`)}'`
453
+
454
+ // PowerShell also reads the typographic single quotes U+2018 to U+201B as
455
+ // quotes, so each of them is doubled like `'`.
456
+ const quotePowerShell = (value: string): string => `'${value.replace(/['\u2018\u2019\u201A\u201B]/g, "$&$&")}'`
457
+
458
+ const windowsNeedsQuotes = /[ \t\n\v"]/
459
+
460
+ // Arguments: 2n backslashes before a quote mean n backslashes, 2n+1 mean n
461
+ // backslashes and a literal quote, and other backslashes are literal.
462
+ const quoteWindowsArgument = (value: string): string => {
463
+ if (value.length > 0 && !windowsNeedsQuotes.test(value)) return value
464
+ let out = "\""
465
+ let backslashes = 0
466
+ for (const char of value) {
467
+ if (char === "\\") {
468
+ backslashes++
469
+ } else if (char === "\"") {
470
+ out += "\\".repeat(backslashes * 2 + 1) + "\""
471
+ backslashes = 0
472
+ } else {
473
+ out += "\\".repeat(backslashes) + char
474
+ backslashes = 0
475
+ }
476
+ }
477
+ return out + "\\".repeat(backslashes * 2) + "\""
478
+ }
479
+
480
+ // Program names allow quotes for grouping but no backslash escapes.
481
+ const quoteWindowsProgram = (value: string): string => value.length > 0 && !/[ \t]/.test(value) ? value : `"${value}"`
482
+
483
+ // oxlint-disable-next-line no-control-regex
484
+ const controlCharacters = /[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g
485
+
486
+ const controlEscapes: Record<string, string> = { "\n": "\\n", "\r": "\\r", "\t": "\\t" }
487
+
488
+ const escapeControlCharacters = (value: string): string =>
489
+ value.replace(
490
+ controlCharacters,
491
+ (char) => controlEscapes[char] ?? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`
492
+ )
493
+
494
+ // -----------------------------------------------------------------------------
495
+ // Templates
496
+ // -----------------------------------------------------------------------------
497
+
498
+ const operators = "|&;<>()"
499
+ const globs = "*?["
500
+ const expansionStart = /[A-Za-z_0-9{(@*#?$!'"-]/
501
+ const quotedExpansionStart = /[A-Za-z_0-9{(@*#?$!-]/
502
+ const assignmentName = /^[A-Za-z_][A-Za-z0-9_]*\+?$/
503
+
504
+ const isBlank = (char: string | undefined): boolean => char === " " || char === "\t" || char === "\n"
505
+
506
+ // Why an unquoted character needs a shell, if it does.
507
+ const unsupportedSyntax = (char: string, next: string | undefined, wordStart: boolean): string | undefined => {
508
+ if (operators.includes(char)) return `The operator "${char}" needs a shell`
509
+ if (char === "`") return "Command substitution needs a shell"
510
+ if (char === "$" && next !== undefined && expansionStart.test(next)) return `The expansion "$${next}" needs a shell`
511
+ if (globs.includes(char)) return `The glob character "${char}" needs a shell`
512
+ if (!wordStart) return undefined
513
+ if (char === "#") return "A comment needs a shell"
514
+ if (char === "~") return "Tilde expansion needs a shell"
515
+ if (char === "=" && next !== undefined && !isBlank(next)) return "A leading \"=\" is expanded by zsh"
516
+ return undefined
517
+ }
518
+
519
+ // Splits the text parts with POSIX quote removal and inserts the values
520
+ // between them.
521
+ const parseTemplate = (
522
+ texts: ReadonlyArray<string>,
523
+ values: ReadonlyArray<TemplateExpression>
524
+ ): Result.Result<Array<Word>, CommandLineError> => {
525
+ const words: Array<Word> = []
526
+ // The current word, empty until it starts. An opened quote adds "".
527
+ let word: Array<Word> = []
528
+ // The current word is unquoted literal text, so it can be the name of a
529
+ // variable assignment.
530
+ let plain = true
531
+ let braceDepth = 0
532
+ let quote: "'" | "\"" | undefined = undefined
533
+ let quotePart = 0
534
+ let part = 0
535
+
536
+ const error = (
537
+ reason: CommandLineError["reason"],
538
+ message: string,
539
+ at = part
540
+ ): Result.Result<never, CommandLineError> =>
541
+ Result.fail(new CommandLineError({ reason, message: `${message} in template part ${at}` }))
542
+
543
+ const endWord = (): void => {
544
+ if (word.length === 0) return
545
+ const value = word.map(unwrap).join("")
546
+ words.push(
547
+ word.length === 1 && Redacted.isRedacted(word[0])
548
+ ? word[0]
549
+ : word.some(Redacted.isRedacted)
550
+ ? Redacted.make(value)
551
+ : value
552
+ )
553
+ word = []
554
+ plain = true
555
+ braceDepth = 0
556
+ }
557
+
558
+ const scan = (text: string): Result.Result<never, CommandLineError> | undefined => {
559
+ for (let i = 0; i < text.length; i++) {
560
+ const char = text[i]
561
+ const next = text[i + 1]
562
+ if (quote === "'") {
563
+ if (char === "'") quote = undefined
564
+ else word.push(char)
565
+ } else if (quote === "\"") {
566
+ if (char === "\"") {
567
+ quote = undefined
568
+ } else if (char === "\\" && next !== undefined && "$`\"\\\n".includes(next)) {
569
+ if (next !== "\n") word.push(next)
570
+ i++
571
+ } else if (char === "`") {
572
+ return error("UnsupportedSyntax", "Command substitution needs a shell")
573
+ } else if (char === "$" && next !== undefined && quotedExpansionStart.test(next)) {
574
+ return error("UnsupportedSyntax", `The expansion "$${next}" needs a shell`)
575
+ } else {
576
+ word.push(char)
577
+ }
578
+ } else if (isBlank(char)) {
579
+ endWord()
580
+ } else if (char === "\\") {
581
+ if (next === undefined) return error("InvalidEscape", "A trailing backslash escapes nothing")
582
+ if (next !== "\n") {
583
+ word.push(next)
584
+ plain = false
585
+ }
586
+ i++
587
+ } else if (char === "'" || char === "\"") {
588
+ quote = char
589
+ quotePart = part
590
+ word.push("")
591
+ plain = false
592
+ } else {
593
+ const unsupported = unsupportedSyntax(char, next, word.length === 0)
594
+ if (unsupported !== undefined) return error("UnsupportedSyntax", unsupported)
595
+ if (char === "{") {
596
+ braceDepth++
597
+ } else if (char === "}") {
598
+ if (braceDepth > 0) braceDepth--
599
+ } else if (braceDepth > 0 && (char === "," || (char === "." && next === "."))) {
600
+ return error("UnsupportedSyntax", "Brace expansion needs a shell")
601
+ } else if (char === "=" && words.length === 0 && plain && assignmentName.test(word.join(""))) {
602
+ return error("UnsupportedSyntax", "A variable assignment needs a shell")
603
+ }
604
+ word.push(char)
605
+ }
606
+ }
607
+ return undefined
608
+ }
609
+
610
+ for (; part < texts.length; part++) {
611
+ const failure = scan(texts[part])
612
+ if (failure !== undefined) return failure
613
+ if (part === values.length) break
614
+ const expression = values[part]
615
+ if (Array.isArray(expression)) {
616
+ // An array must stand alone: nothing may touch it on either side.
617
+ const after = texts[part + 1][0]
618
+ if (word.length > 0 || (after === undefined ? part + 1 < values.length : !isBlank(after))) {
619
+ return error("UnsupportedSyntax", "An interpolated array must be a separate argument")
620
+ }
621
+ for (const item of expression as ReadonlyArray<TemplateExpressionItem>) words.push(toWord(item))
622
+ } else {
623
+ word.push(toWord(expression as TemplateExpressionItem))
624
+ plain = false
625
+ }
626
+ }
627
+ if (quote !== undefined) return error("UnterminatedQuote", "The quote is not closed", quotePart)
628
+ endWord()
629
+ return Result.succeed(words)
630
+ }
@@ -16,3 +16,9 @@ export * as ChildProcess from "./ChildProcess.ts"
16
16
  * @since 4.0.0
17
17
  */
18
18
  export * as ChildProcessSpawner from "./ChildProcessSpawner.ts"
19
+
20
+ /**
21
+ * @stability unstable
22
+ * @since 4.0.7
23
+ */
24
+ export * as CommandLine from "./CommandLine.ts"
@@ -31,7 +31,6 @@ import * as KeyValueStore from "../persistence/KeyValueStore.ts"
31
31
  import type { Pipeable } from "../Pipeable.ts"
32
32
  import { hasProperty } from "../Predicate.ts"
33
33
  import * as Pull from "../Pull.ts"
34
- import { UnhandledLogLevel } from "../References.ts"
35
34
  import * as Scheduler from "../Scheduler.ts"
36
35
  import * as Schema from "../Schema.ts"
37
36
  import * as Scope from "../Scope.ts"
@@ -699,9 +698,9 @@ const closeScope = (scope: Scope.Closeable): Effect.Effect<void> =>
699
698
  Effect.catchCause(
700
699
  Scope.close(scope, Exit.void),
701
700
  (cause) =>
702
- Cause.hasInterruptsOnly(cause) ? Effect.void : Effect.withFiber((fiber) => {
703
- const level = fiber.getRef(UnhandledLogLevel)
704
- return level ? Effect.logWithLevel(level)("Unhandled error in atom finalizer", cause) : Effect.void
701
+ Cause.hasInterruptsOnly(cause) ? Effect.void : Effect.ignoreCause(Effect.failCause(cause), {
702
+ log: "Unhandled",
703
+ message: "Unhandled error in atom finalizer"
705
704
  })
706
705
  )
707
706
 
@@ -3173,7 +3172,8 @@ export type SerializableTypeId = "~effect-atom/atom/Atom/Serializable"
3173
3172
  * **Details**
3174
3173
  *
3175
3174
  * The key identifies the atom in dehydrated state, and the encode/decode
3176
- * functions convert between the atom value and its JSON encoding.
3175
+ * functions convert between the atom value and its JSON representation, as
3176
+ * produced by the schema's JSON codec (`Schema.toCodecJson`).
3177
3177
  *
3178
3178
  * @stability unstable
3179
3179
  * @category models