effect 4.1.2 → 4.1.3

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 (465) hide show
  1. package/ai-docs/package.json +1 -1
  2. package/ai-docs/tsconfig.json +2 -1
  3. package/dist/DateTime.d.ts +33 -2
  4. package/dist/DateTime.d.ts.map +1 -1
  5. package/dist/DateTime.js +16 -0
  6. package/dist/DateTime.js.map +1 -1
  7. package/dist/Match.d.ts +6 -6
  8. package/dist/Match.d.ts.map +1 -1
  9. package/dist/Match.js.map +1 -1
  10. package/dist/Queue.d.ts +2 -1
  11. package/dist/Queue.d.ts.map +1 -1
  12. package/dist/Queue.js +16 -9
  13. package/dist/Queue.js.map +1 -1
  14. package/dist/Rational.d.ts +1214 -0
  15. package/dist/Rational.d.ts.map +1 -0
  16. package/dist/Rational.js +880 -0
  17. package/dist/Rational.js.map +1 -0
  18. package/dist/RcMap.d.ts +3 -0
  19. package/dist/RcMap.d.ts.map +1 -1
  20. package/dist/RcMap.js +13 -14
  21. package/dist/RcMap.js.map +1 -1
  22. package/dist/Runtime.d.ts +75 -3
  23. package/dist/Runtime.d.ts.map +1 -1
  24. package/dist/Runtime.js +81 -4
  25. package/dist/Runtime.js.map +1 -1
  26. package/dist/Schema.d.ts +131 -29
  27. package/dist/Schema.d.ts.map +1 -1
  28. package/dist/Schema.js +128 -22
  29. package/dist/Schema.js.map +1 -1
  30. package/dist/SchemaAST.d.ts.map +1 -1
  31. package/dist/SchemaAST.js +24 -12
  32. package/dist/SchemaAST.js.map +1 -1
  33. package/dist/SchemaParser.js +2 -2
  34. package/dist/SchemaParser.js.map +1 -1
  35. package/dist/SchemaRepresentation.d.ts +9 -0
  36. package/dist/SchemaRepresentation.d.ts.map +1 -1
  37. package/dist/SchemaRepresentation.js +9 -0
  38. package/dist/SchemaRepresentation.js.map +1 -1
  39. package/dist/ScopedCache.d.ts +7 -0
  40. package/dist/ScopedCache.d.ts.map +1 -1
  41. package/dist/ScopedCache.js +18 -1
  42. package/dist/ScopedCache.js.map +1 -1
  43. package/dist/ai/AgUi.d.ts +109 -0
  44. package/dist/ai/AgUi.d.ts.map +1 -0
  45. package/dist/ai/AgUi.js +543 -0
  46. package/dist/ai/AgUi.js.map +1 -0
  47. package/dist/ai/AgUiSchema.d.ts +6965 -0
  48. package/dist/ai/AgUiSchema.d.ts.map +1 -0
  49. package/dist/ai/AgUiSchema.js +974 -0
  50. package/dist/ai/AgUiSchema.js.map +1 -0
  51. package/dist/ai/AgUiServer.d.ts +6400 -0
  52. package/dist/ai/AgUiServer.d.ts.map +1 -0
  53. package/dist/ai/AgUiServer.js +309 -0
  54. package/dist/ai/AgUiServer.js.map +1 -0
  55. package/dist/ai/Chat.d.ts +30 -4
  56. package/dist/ai/Chat.d.ts.map +1 -1
  57. package/dist/ai/Chat.js +34 -4
  58. package/dist/ai/Chat.js.map +1 -1
  59. package/dist/ai/LanguageModel.d.ts +1 -1
  60. package/dist/ai/LanguageModel.d.ts.map +1 -1
  61. package/dist/ai/LanguageModel.js +18 -8
  62. package/dist/ai/LanguageModel.js.map +1 -1
  63. package/dist/ai/McpClient.d.ts +5 -0
  64. package/dist/ai/McpClient.d.ts.map +1 -1
  65. package/dist/ai/McpClient.js +11 -1
  66. package/dist/ai/McpClient.js.map +1 -1
  67. package/dist/ai/McpServer.d.ts +18 -1
  68. package/dist/ai/McpServer.d.ts.map +1 -1
  69. package/dist/ai/McpServer.js +214 -34
  70. package/dist/ai/McpServer.js.map +1 -1
  71. package/dist/ai/Prompt.d.ts +6 -2
  72. package/dist/ai/Prompt.d.ts.map +1 -1
  73. package/dist/ai/Prompt.js.map +1 -1
  74. package/dist/ai/Response.d.ts +5 -2
  75. package/dist/ai/Response.d.ts.map +1 -1
  76. package/dist/ai/Response.js +5 -1
  77. package/dist/ai/Response.js.map +1 -1
  78. package/dist/ai/Tool.d.ts +265 -69
  79. package/dist/ai/Tool.d.ts.map +1 -1
  80. package/dist/ai/Tool.js +19 -2
  81. package/dist/ai/Tool.js.map +1 -1
  82. package/dist/ai/Toolkit.d.ts +32 -2
  83. package/dist/ai/Toolkit.d.ts.map +1 -1
  84. package/dist/ai/Toolkit.js +61 -8
  85. package/dist/ai/Toolkit.js.map +1 -1
  86. package/dist/ai/index.d.ts +15 -0
  87. package/dist/ai/index.d.ts.map +1 -1
  88. package/dist/ai/index.js +15 -0
  89. package/dist/ai/index.js.map +1 -1
  90. package/dist/ai/internal/mcpCore.d.ts +0 -2
  91. package/dist/ai/internal/mcpCore.d.ts.map +1 -1
  92. package/dist/ai/internal/mcpCore.js +2 -8
  93. package/dist/ai/internal/mcpCore.js.map +1 -1
  94. package/dist/ai/internal/mcpProtocol/v2024_11_05.js +6 -11
  95. package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
  96. package/dist/ai/internal/mcpProtocol/v2025_03_26.js +6 -11
  97. package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
  98. package/dist/ai/internal/mcpProtocol/v2025_06_18.js +6 -8
  99. package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
  100. package/dist/ai/internal/mcpProtocol/v2025_11_25.js +6 -8
  101. package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
  102. package/dist/ai/internal/mcpProtocol/v2026_07_28.js +60 -51
  103. package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
  104. package/dist/ai/internal/mcpProtocol.js +11 -1
  105. package/dist/ai/internal/mcpProtocol.js.map +1 -1
  106. package/dist/ai/internal/mcpProtocolRegistry.js +4 -0
  107. package/dist/ai/internal/mcpProtocolRegistry.js.map +1 -1
  108. package/dist/ai/internal/mcpRuntime.js +6 -2
  109. package/dist/ai/internal/mcpRuntime.js.map +1 -1
  110. package/dist/ai/internal/mcpSchema/v2024_11_05.js +0 -2
  111. package/dist/ai/internal/mcpSchema/v2024_11_05.js.map +1 -1
  112. package/dist/ai/internal/mcpSchema/v2025_03_26.d.ts.map +1 -1
  113. package/dist/ai/internal/mcpSchema/v2025_03_26.js +0 -2
  114. package/dist/ai/internal/mcpSchema/v2025_03_26.js.map +1 -1
  115. package/dist/ai/internal/mcpSchema/v2025_06_18.d.ts.map +1 -1
  116. package/dist/ai/internal/mcpSchema/v2025_06_18.js +0 -2
  117. package/dist/ai/internal/mcpSchema/v2025_06_18.js.map +1 -1
  118. package/dist/ai/internal/mcpSchema/v2025_11_25.d.ts.map +1 -1
  119. package/dist/ai/internal/mcpSchema/v2025_11_25.js +0 -2
  120. package/dist/ai/internal/mcpSchema/v2025_11_25.js.map +1 -1
  121. package/dist/ai/internal/mcpSchema/v2026_07_28.d.ts.map +1 -1
  122. package/dist/ai/internal/mcpSchema/v2026_07_28.js +0 -2
  123. package/dist/ai/internal/mcpSchema/v2026_07_28.js.map +1 -1
  124. package/dist/ai/internal/mcpSkills.js +3 -93
  125. package/dist/ai/internal/mcpSkills.js.map +1 -1
  126. package/dist/ai/internal/mcpStatefulRuntime.js +0 -2
  127. package/dist/ai/internal/mcpStatefulRuntime.js.map +1 -1
  128. package/dist/ai/internal/structured-output.js +1 -1
  129. package/dist/ai/internal/structured-output.js.map +1 -1
  130. package/dist/cli/Argument.d.ts +81 -0
  131. package/dist/cli/Argument.d.ts.map +1 -1
  132. package/dist/cli/Argument.js +26 -0
  133. package/dist/cli/Argument.js.map +1 -1
  134. package/dist/cli/CliError.d.ts +7 -4
  135. package/dist/cli/CliError.d.ts.map +1 -1
  136. package/dist/cli/CliError.js +7 -4
  137. package/dist/cli/CliError.js.map +1 -1
  138. package/dist/cli/Command.d.ts +241 -22
  139. package/dist/cli/Command.d.ts.map +1 -1
  140. package/dist/cli/Command.js +85 -9
  141. package/dist/cli/Command.js.map +1 -1
  142. package/dist/cli/CommandSpec.d.ts +287 -0
  143. package/dist/cli/CommandSpec.d.ts.map +1 -0
  144. package/dist/cli/CommandSpec.js +277 -0
  145. package/dist/cli/CommandSpec.js.map +1 -0
  146. package/dist/cli/Completions.d.ts +5 -0
  147. package/dist/cli/Completions.d.ts.map +1 -1
  148. package/dist/cli/Completions.js.map +1 -1
  149. package/dist/cli/Flag.d.ts +102 -0
  150. package/dist/cli/Flag.d.ts.map +1 -1
  151. package/dist/cli/Flag.js +47 -0
  152. package/dist/cli/Flag.js.map +1 -1
  153. package/dist/cli/Param.d.ts +154 -1
  154. package/dist/cli/Param.d.ts.map +1 -1
  155. package/dist/cli/Param.js +87 -29
  156. package/dist/cli/Param.js.map +1 -1
  157. package/dist/cli/index.d.ts +5 -0
  158. package/dist/cli/index.d.ts.map +1 -1
  159. package/dist/cli/index.js +5 -0
  160. package/dist/cli/index.js.map +1 -1
  161. package/dist/cli/internal/command.d.ts +2 -2
  162. package/dist/cli/internal/command.d.ts.map +1 -1
  163. package/dist/cli/internal/command.js +1 -1
  164. package/dist/cli/internal/command.js.map +1 -1
  165. package/dist/cli/internal/completions/bash.js +6 -7
  166. package/dist/cli/internal/completions/bash.js.map +1 -1
  167. package/dist/cli/internal/completions/descriptor.js +21 -7
  168. package/dist/cli/internal/completions/descriptor.js.map +1 -1
  169. package/dist/cli/internal/completions/fish.js +3 -3
  170. package/dist/cli/internal/completions/fish.js.map +1 -1
  171. package/dist/cli/internal/completions/powershell.js +2 -2
  172. package/dist/cli/internal/completions/powershell.js.map +1 -1
  173. package/dist/cli/internal/completions/zsh.js +2 -2
  174. package/dist/cli/internal/completions/zsh.js.map +1 -1
  175. package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
  176. package/dist/cluster/ClusterWorkflowEngine.js +15 -13
  177. package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
  178. package/dist/cluster/Entity.d.ts +17 -0
  179. package/dist/cluster/Entity.d.ts.map +1 -1
  180. package/dist/cluster/Entity.js +20 -0
  181. package/dist/cluster/Entity.js.map +1 -1
  182. package/dist/cluster/MessageRetention.d.ts +71 -0
  183. package/dist/cluster/MessageRetention.d.ts.map +1 -0
  184. package/dist/cluster/MessageRetention.js +100 -0
  185. package/dist/cluster/MessageRetention.js.map +1 -0
  186. package/dist/cluster/MessageStorage.d.ts +81 -0
  187. package/dist/cluster/MessageStorage.d.ts.map +1 -1
  188. package/dist/cluster/MessageStorage.js +34 -2
  189. package/dist/cluster/MessageStorage.js.map +1 -1
  190. package/dist/cluster/ShardingConfig.d.ts +24 -2
  191. package/dist/cluster/ShardingConfig.d.ts.map +1 -1
  192. package/dist/cluster/ShardingConfig.js.map +1 -1
  193. package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
  194. package/dist/cluster/SqlMessageStorage.js +187 -29
  195. package/dist/cluster/SqlMessageStorage.js.map +1 -1
  196. package/dist/cluster/index.d.ts +5 -0
  197. package/dist/cluster/index.d.ts.map +1 -1
  198. package/dist/cluster/index.js +5 -0
  199. package/dist/cluster/index.js.map +1 -1
  200. package/dist/encoding/Base64.d.ts +0 -6
  201. package/dist/encoding/Base64.d.ts.map +1 -1
  202. package/dist/encoding/Base64.js +25 -5
  203. package/dist/encoding/Base64.js.map +1 -1
  204. package/dist/encoding/Base64Url.d.ts +0 -6
  205. package/dist/encoding/Base64Url.d.ts.map +1 -1
  206. package/dist/encoding/Base64Url.js +91 -8
  207. package/dist/encoding/Base64Url.js.map +1 -1
  208. package/dist/encoding/Csv.d.ts.map +1 -1
  209. package/dist/encoding/Csv.js +11 -5
  210. package/dist/encoding/Csv.js.map +1 -1
  211. package/dist/encoding/Hex.d.ts.map +1 -1
  212. package/dist/encoding/Hex.js +51 -34
  213. package/dist/encoding/Hex.js.map +1 -1
  214. package/dist/encoding/SchemaBinary.d.ts +14 -2
  215. package/dist/encoding/SchemaBinary.d.ts.map +1 -1
  216. package/dist/encoding/SchemaBinary.js +78 -5
  217. package/dist/encoding/SchemaBinary.js.map +1 -1
  218. package/dist/encoding/Xml.d.ts +25 -0
  219. package/dist/encoding/Xml.d.ts.map +1 -1
  220. package/dist/encoding/Xml.js +44 -19
  221. package/dist/encoding/Xml.js.map +1 -1
  222. package/dist/graphql/GraphQL.d.ts.map +1 -1
  223. package/dist/graphql/GraphQL.js +4 -1
  224. package/dist/graphql/GraphQL.js.map +1 -1
  225. package/dist/http/Headers.d.ts +5 -1
  226. package/dist/http/Headers.d.ts.map +1 -1
  227. package/dist/http/Headers.js +7 -2
  228. package/dist/http/Headers.js.map +1 -1
  229. package/dist/http/HttpClient.d.ts +57 -12
  230. package/dist/http/HttpClient.d.ts.map +1 -1
  231. package/dist/http/HttpClient.js +92 -54
  232. package/dist/http/HttpClient.js.map +1 -1
  233. package/dist/http/HttpClientError.d.ts +22 -8
  234. package/dist/http/HttpClientError.d.ts.map +1 -1
  235. package/dist/http/HttpClientError.js +68 -14
  236. package/dist/http/HttpClientError.js.map +1 -1
  237. package/dist/http/HttpEffect.d.ts +63 -4
  238. package/dist/http/HttpEffect.d.ts.map +1 -1
  239. package/dist/http/HttpEffect.js +89 -9
  240. package/dist/http/HttpEffect.js.map +1 -1
  241. package/dist/http/HttpMiddleware.js +1 -1
  242. package/dist/http/HttpMiddleware.js.map +1 -1
  243. package/dist/http/HttpServer.d.ts +80 -0
  244. package/dist/http/HttpServer.d.ts.map +1 -1
  245. package/dist/http/HttpServer.js +16 -0
  246. package/dist/http/HttpServer.js.map +1 -1
  247. package/dist/http/HttpServerRequest.d.ts.map +1 -1
  248. package/dist/http/HttpServerRequest.js +1 -14
  249. package/dist/http/HttpServerRequest.js.map +1 -1
  250. package/dist/http/HttpStaticServer.js +10 -16
  251. package/dist/http/HttpStaticServer.js.map +1 -1
  252. package/dist/http-api/HttpApiBuilder.js +9 -1
  253. package/dist/http-api/HttpApiBuilder.js.map +1 -1
  254. package/dist/http-api/HttpApiSchema.d.ts +19 -0
  255. package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
  256. package/dist/http-api/HttpApiSchema.js +8 -1
  257. package/dist/http-api/HttpApiSchema.js.map +1 -1
  258. package/dist/index.d.ts +5 -0
  259. package/dist/index.d.ts.map +1 -1
  260. package/dist/index.js +5 -0
  261. package/dist/index.js.map +1 -1
  262. package/dist/internal/base64.d.ts +2 -0
  263. package/dist/internal/base64.d.ts.map +1 -0
  264. package/dist/internal/base64.js +30 -0
  265. package/dist/internal/base64.js.map +1 -0
  266. package/dist/internal/core.js +3 -4
  267. package/dist/internal/core.js.map +1 -1
  268. package/dist/internal/dateTime.js +18 -10
  269. package/dist/internal/dateTime.js.map +1 -1
  270. package/dist/internal/effect.js +41 -17
  271. package/dist/internal/effect.js.map +1 -1
  272. package/dist/internal/equal.js +7 -0
  273. package/dist/internal/equal.js.map +1 -1
  274. package/dist/internal/matcher.js +1 -1
  275. package/dist/internal/matcher.js.map +1 -1
  276. package/dist/internal/schema/codegen.js +7 -7
  277. package/dist/internal/schema/codegen.js.map +1 -1
  278. package/dist/internal/schema/fromJsonSchemaDocument.js +20 -1
  279. package/dist/internal/schema/fromJsonSchemaDocument.js.map +1 -1
  280. package/dist/internal/schema/interpreter.js +10 -10
  281. package/dist/internal/schema/interpreter.js.map +1 -1
  282. package/dist/internal/schema/parser.js +9 -4
  283. package/dist/internal/schema/parser.js.map +1 -1
  284. package/dist/internal/schema/toEquivalence.js +6 -5
  285. package/dist/internal/schema/toEquivalence.js.map +1 -1
  286. package/dist/internal/schema/toFormatter.js +3 -2
  287. package/dist/internal/schema/toFormatter.js.map +1 -1
  288. package/dist/internal/version.js +1 -1
  289. package/dist/observability/OtlpMetrics.js +1 -1
  290. package/dist/observability/OtlpMetrics.js.map +1 -1
  291. package/dist/observability/OtlpTracer.js +2 -2
  292. package/dist/observability/OtlpTracer.js.map +1 -1
  293. package/dist/persistence/PersistedQueue.d.ts +72 -3
  294. package/dist/persistence/PersistedQueue.d.ts.map +1 -1
  295. package/dist/persistence/PersistedQueue.js +142 -29
  296. package/dist/persistence/PersistedQueue.js.map +1 -1
  297. package/dist/persistence/RateLimiter.d.ts +12 -2
  298. package/dist/persistence/RateLimiter.d.ts.map +1 -1
  299. package/dist/persistence/RateLimiter.js +11 -4
  300. package/dist/persistence/RateLimiter.js.map +1 -1
  301. package/dist/process/CommandLine.d.ts +9 -9
  302. package/dist/process/CommandLine.js +6 -6
  303. package/dist/process/index.d.ts +1 -1
  304. package/dist/process/index.js +1 -1
  305. package/dist/reactivity/Atom.d.ts.map +1 -1
  306. package/dist/reactivity/Atom.js +24 -3
  307. package/dist/reactivity/Atom.js.map +1 -1
  308. package/dist/reactivity/AtomRpc.d.ts +24 -6
  309. package/dist/reactivity/AtomRpc.d.ts.map +1 -1
  310. package/dist/reactivity/AtomRpc.js.map +1 -1
  311. package/dist/rpc/OpenRpc.d.ts +384 -0
  312. package/dist/rpc/OpenRpc.d.ts.map +1 -0
  313. package/dist/rpc/OpenRpc.js +490 -0
  314. package/dist/rpc/OpenRpc.js.map +1 -0
  315. package/dist/rpc/Rpc.d.ts +22 -3
  316. package/dist/rpc/Rpc.d.ts.map +1 -1
  317. package/dist/rpc/Rpc.js.map +1 -1
  318. package/dist/rpc/RpcClient.d.ts +20 -21
  319. package/dist/rpc/RpcClient.d.ts.map +1 -1
  320. package/dist/rpc/RpcClient.js.map +1 -1
  321. package/dist/rpc/RpcServer.d.ts +23 -2
  322. package/dist/rpc/RpcServer.d.ts.map +1 -1
  323. package/dist/rpc/RpcServer.js +67 -25
  324. package/dist/rpc/RpcServer.js.map +1 -1
  325. package/dist/rpc/index.d.ts +5 -0
  326. package/dist/rpc/index.d.ts.map +1 -1
  327. package/dist/rpc/index.js +5 -0
  328. package/dist/rpc/index.js.map +1 -1
  329. package/dist/schema/SchemaCompiler/runtime.js +3 -2
  330. package/dist/schema/SchemaCompiler/runtime.js.map +1 -1
  331. package/dist/sql/SqlClient.d.ts +59 -6
  332. package/dist/sql/SqlClient.d.ts.map +1 -1
  333. package/dist/sql/SqlClient.js +64 -17
  334. package/dist/sql/SqlClient.js.map +1 -1
  335. package/dist/sql/Statement.d.ts +1 -1
  336. package/dist/sql/Statement.d.ts.map +1 -1
  337. package/dist/sql/Statement.js +9 -16
  338. package/dist/sql/Statement.js.map +1 -1
  339. package/dist/testing/TestClock.d.ts +2 -12
  340. package/dist/testing/TestClock.d.ts.map +1 -1
  341. package/dist/testing/TestClock.js +177 -169
  342. package/dist/testing/TestClock.js.map +1 -1
  343. package/dist/workflow/DurableClock.d.ts +27 -0
  344. package/dist/workflow/DurableClock.d.ts.map +1 -1
  345. package/dist/workflow/DurableClock.js +18 -2
  346. package/dist/workflow/DurableClock.js.map +1 -1
  347. package/dist/workflow/Workflow.d.ts.map +1 -1
  348. package/dist/workflow/Workflow.js +5 -4
  349. package/dist/workflow/Workflow.js.map +1 -1
  350. package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
  351. package/dist/workflow/WorkflowEngine.js +14 -3
  352. package/dist/workflow/WorkflowEngine.js.map +1 -1
  353. package/package.json +3 -3
  354. package/src/DateTime.ts +35 -2
  355. package/src/Match.ts +10 -8
  356. package/src/Queue.ts +16 -11
  357. package/src/Rational.ts +1549 -0
  358. package/src/RcMap.ts +16 -14
  359. package/src/Runtime.ts +84 -4
  360. package/src/Schema.ts +188 -29
  361. package/src/SchemaAST.ts +29 -13
  362. package/src/SchemaParser.ts +2 -2
  363. package/src/SchemaRepresentation.ts +13 -0
  364. package/src/ScopedCache.ts +18 -1
  365. package/src/ai/AgUi.ts +485 -0
  366. package/src/ai/AgUiSchema.ts +1666 -0
  367. package/src/ai/AgUiServer.ts +451 -0
  368. package/src/ai/Chat.ts +78 -16
  369. package/src/ai/LanguageModel.ts +27 -9
  370. package/src/ai/McpClient.ts +11 -1
  371. package/src/ai/McpServer.ts +247 -50
  372. package/src/ai/Prompt.ts +6 -2
  373. package/src/ai/Response.ts +19 -3
  374. package/src/ai/Tool.ts +426 -110
  375. package/src/ai/Toolkit.ts +71 -10
  376. package/src/ai/index.ts +18 -0
  377. package/src/ai/internal/mcpCore.ts +11 -15
  378. package/src/ai/internal/mcpProtocol/v2024_11_05.ts +9 -14
  379. package/src/ai/internal/mcpProtocol/v2025_03_26.ts +9 -14
  380. package/src/ai/internal/mcpProtocol/v2025_06_18.ts +9 -11
  381. package/src/ai/internal/mcpProtocol/v2025_11_25.ts +9 -11
  382. package/src/ai/internal/mcpProtocol/v2026_07_28.ts +76 -55
  383. package/src/ai/internal/mcpProtocol.ts +22 -3
  384. package/src/ai/internal/mcpProtocolRegistry.ts +5 -0
  385. package/src/ai/internal/mcpRuntime.ts +10 -4
  386. package/src/ai/internal/mcpSchema/v2024_11_05.ts +0 -2
  387. package/src/ai/internal/mcpSchema/v2025_03_26.ts +0 -2
  388. package/src/ai/internal/mcpSchema/v2025_06_18.ts +0 -2
  389. package/src/ai/internal/mcpSchema/v2025_11_25.ts +0 -2
  390. package/src/ai/internal/mcpSchema/v2026_07_28.ts +0 -2
  391. package/src/ai/internal/mcpSkills.ts +3 -86
  392. package/src/ai/internal/mcpStatefulRuntime.ts +0 -2
  393. package/src/ai/internal/structured-output.ts +1 -1
  394. package/src/cli/Argument.ts +86 -0
  395. package/src/cli/CliError.ts +7 -4
  396. package/src/cli/Command.ts +261 -35
  397. package/src/cli/CommandSpec.ts +508 -0
  398. package/src/cli/Completions.ts +5 -0
  399. package/src/cli/Flag.ts +106 -0
  400. package/src/cli/Param.ts +225 -23
  401. package/src/cli/index.ts +6 -0
  402. package/src/cli/internal/command.ts +3 -4
  403. package/src/cli/internal/completions/bash.ts +9 -7
  404. package/src/cli/internal/completions/descriptor.ts +37 -5
  405. package/src/cli/internal/completions/fish.ts +9 -3
  406. package/src/cli/internal/completions/powershell.ts +2 -1
  407. package/src/cli/internal/completions/zsh.ts +2 -2
  408. package/src/cluster/ClusterWorkflowEngine.ts +14 -15
  409. package/src/cluster/Entity.ts +24 -0
  410. package/src/cluster/MessageRetention.ts +111 -0
  411. package/src/cluster/MessageStorage.ts +73 -2
  412. package/src/cluster/ShardingConfig.ts +12 -1
  413. package/src/cluster/SqlMessageStorage.ts +271 -41
  414. package/src/cluster/index.ts +6 -0
  415. package/src/encoding/Base64.ts +26 -5
  416. package/src/encoding/Base64Url.ts +93 -10
  417. package/src/encoding/Csv.ts +11 -5
  418. package/src/encoding/Hex.ts +56 -42
  419. package/src/encoding/SchemaBinary.ts +76 -5
  420. package/src/encoding/Xml.ts +65 -16
  421. package/src/graphql/GraphQL.ts +7 -4
  422. package/src/http/Headers.ts +7 -2
  423. package/src/http/HttpClient.ts +118 -68
  424. package/src/http/HttpClientError.ts +82 -15
  425. package/src/http/HttpEffect.ts +101 -10
  426. package/src/http/HttpMiddleware.ts +2 -2
  427. package/src/http/HttpServer.ts +80 -0
  428. package/src/http/HttpServerRequest.ts +1 -19
  429. package/src/http/HttpStaticServer.ts +10 -16
  430. package/src/http-api/HttpApiBuilder.ts +11 -1
  431. package/src/http-api/HttpApiSchema.ts +22 -1
  432. package/src/index.ts +6 -0
  433. package/src/internal/base64.ts +42 -0
  434. package/src/internal/core.ts +3 -4
  435. package/src/internal/dateTime.ts +27 -13
  436. package/src/internal/effect.ts +45 -18
  437. package/src/internal/equal.ts +8 -0
  438. package/src/internal/matcher.ts +7 -3
  439. package/src/internal/schema/codegen.ts +8 -7
  440. package/src/internal/schema/fromJsonSchemaDocument.ts +21 -1
  441. package/src/internal/schema/interpreter.ts +10 -10
  442. package/src/internal/schema/parser.ts +8 -4
  443. package/src/internal/schema/toEquivalence.ts +7 -5
  444. package/src/internal/schema/toFormatter.ts +3 -2
  445. package/src/internal/version.ts +1 -1
  446. package/src/observability/OtlpMetrics.ts +1 -1
  447. package/src/observability/OtlpTracer.ts +2 -2
  448. package/src/persistence/PersistedQueue.ts +199 -41
  449. package/src/persistence/RateLimiter.ts +17 -5
  450. package/src/process/CommandLine.ts +10 -10
  451. package/src/process/index.ts +1 -1
  452. package/src/reactivity/Atom.ts +25 -3
  453. package/src/reactivity/AtomRpc.ts +61 -45
  454. package/src/rpc/OpenRpc.ts +747 -0
  455. package/src/rpc/Rpc.ts +38 -6
  456. package/src/rpc/RpcClient.ts +45 -82
  457. package/src/rpc/RpcServer.ts +77 -28
  458. package/src/rpc/index.ts +6 -0
  459. package/src/schema/SchemaCompiler/runtime.ts +8 -3
  460. package/src/sql/SqlClient.ts +112 -26
  461. package/src/sql/Statement.ts +19 -23
  462. package/src/testing/TestClock.ts +204 -189
  463. package/src/workflow/DurableClock.ts +20 -3
  464. package/src/workflow/Workflow.ts +5 -3
  465. package/src/workflow/WorkflowEngine.ts +20 -5
package/src/cli/Param.ts CHANGED
@@ -12,6 +12,7 @@
12
12
  * @since 4.0.0
13
13
  */
14
14
  import * as Config from "../Config.ts"
15
+ import * as Context from "../Context.ts"
15
16
  import * as Effect from "../Effect.ts"
16
17
  import { dual, identity, type LazyArg } from "../Function.ts"
17
18
  import * as Option from "../Option.ts"
@@ -20,7 +21,7 @@ import * as Predicate from "../Predicate.ts"
20
21
  import type * as Redacted_ from "../Redacted.ts"
21
22
  import * as Result from "../Result.ts"
22
23
  import * as Schema from "../Schema.ts"
23
- import type { Covariant } from "../Types.ts"
24
+ import type { Covariant, NoInfer } from "../Types.ts"
24
25
  import * as CliError from "./CliError.ts"
25
26
  import type { Environment } from "./Command.ts"
26
27
  import * as Primitive from "./Primitive.ts"
@@ -223,6 +224,11 @@ export interface Single<Kind extends ParamKind, out A> extends Param<Kind, A> {
223
224
  * default `no-<name>`, `false` means no negated form. See `withNegation`.
224
225
  */
225
226
  readonly negation?: string | false | undefined
227
+ /**
228
+ * User-defined annotations attached with `annotate`. Never read by the
229
+ * parser or by help; surfaced by `CommandSpec` for documentation tooling.
230
+ */
231
+ readonly annotations: Context.Context<never>
226
232
  }
227
233
 
228
234
  /**
@@ -258,8 +264,35 @@ export interface Transform<Kind extends ParamKind, in out A, out B> extends Para
258
264
  parse: Parse<A>,
259
265
  alternatives: ReadonlyArray<LazyArg<Parse<unknown>>>
260
266
  ) => Parse<B>
267
+ /**
268
+ * Structural description of the fallback this node adds when the parameter
269
+ * is missing, if any. Set by `withDefault`, `withFallbackConfig` and
270
+ * `withFallbackPrompt`; it is never evaluated, only reported.
271
+ */
272
+ readonly fallback?: Fallback | undefined
261
273
  }
262
274
 
275
+ /**
276
+ * Describes, without evaluating it, how a parameter obtains a value when it is
277
+ * absent from the command line.
278
+ *
279
+ * **Details**
280
+ *
281
+ * `Default` carries the literal value given to `withDefault`. The other
282
+ * variants only record that a fallback exists: an effectful default, a
283
+ * `Config` lookup or an interactive prompt cannot be inspected without
284
+ * running them, so documentation tooling describes them by kind.
285
+ *
286
+ * @stability unstable
287
+ * @category models
288
+ * @since 4.1.3
289
+ */
290
+ export type Fallback =
291
+ | { readonly _tag: "Default"; readonly value: unknown }
292
+ | { readonly _tag: "DefaultEffect" }
293
+ | { readonly _tag: "Config" }
294
+ | { readonly _tag: "Prompt" }
295
+
263
296
  /**
264
297
  * Parameter node that turns a missing argument or flag into `Option.none()` and
265
298
  * a present parsed value into `Option.some(value)`.
@@ -374,6 +407,7 @@ export const makeSingle = <const Kind extends ParamKind, A>(params: {
374
407
  readonly hidden?: boolean | undefined
375
408
  readonly optionalValue?: string | undefined
376
409
  readonly negation?: string | false | undefined
410
+ readonly annotations?: Context.Context<never> | undefined
377
411
  }): Single<Kind, A> => {
378
412
  const parse: Parse<A> = (args) =>
379
413
  params.kind === argumentKind
@@ -385,6 +419,7 @@ export const makeSingle = <const Kind extends ParamKind, A>(params: {
385
419
  description: params.description ?? Option.none(),
386
420
  aliases: params.aliases ?? [],
387
421
  hidden: params.hidden ?? false,
422
+ annotations: params.annotations ?? Context.empty(),
388
423
  parse
389
424
  }, Proto)
390
425
  }
@@ -1192,6 +1227,131 @@ export const withHidden = <Kind extends ParamKind, A>(self: Param<Kind, A>): Par
1192
1227
  hidden: true
1193
1228
  }))
1194
1229
 
1230
+ /**
1231
+ * Attaches a user-defined annotation to a parameter.
1232
+ *
1233
+ * **When to use**
1234
+ *
1235
+ * Use when documentation tooling needs facts the parser cannot know, such as
1236
+ * the environment variable behind a `withFallbackConfig`, or a deprecation
1237
+ * note. Annotations are keyed by a `Context.Key`, exactly like
1238
+ * `Command.annotate`.
1239
+ *
1240
+ * **Details**
1241
+ *
1242
+ * Annotations never affect parsing, help or completions. They are reported
1243
+ * by `CommandSpec.resolve` on each flag and argument, and survive combinators
1244
+ * applied before or after them.
1245
+ *
1246
+ * **Example** (Recording the environment variable behind a config fallback)
1247
+ *
1248
+ * ```ts import.meta.vitest
1249
+ * import { Config, Context } from "effect"
1250
+ * import { Param } from "effect/cli"
1251
+ *
1252
+ * const EnvVar = Context.Service<never, string>("app/EnvVar")
1253
+ *
1254
+ * const token = Param.String(Param.flagKind, "token").pipe(
1255
+ * Param.withFallbackConfig(Config.String("APP_TOKEN")),
1256
+ * Param.annotate(EnvVar, "APP_TOKEN")
1257
+ * )
1258
+ * token.kind // => "flag"
1259
+ * ```
1260
+ *
1261
+ * @see {@link Single} for where annotations are stored
1262
+ *
1263
+ * @stability unstable
1264
+ * @category metadata
1265
+ * @since 4.1.3
1266
+ */
1267
+ export const annotate: {
1268
+ /**
1269
+ * Attaches a user-defined annotation to a parameter.
1270
+ *
1271
+ * **When to use**
1272
+ *
1273
+ * Use when documentation tooling needs facts the parser cannot know, such as
1274
+ * the environment variable behind a `withFallbackConfig`, or a deprecation
1275
+ * note. Annotations are keyed by a `Context.Key`, exactly like
1276
+ * `Command.annotate`.
1277
+ *
1278
+ * **Details**
1279
+ *
1280
+ * Annotations never affect parsing, help or completions. They are reported
1281
+ * by `CommandSpec.resolve` on each flag and argument, and survive combinators
1282
+ * applied before or after them.
1283
+ *
1284
+ * **Example** (Recording the environment variable behind a config fallback)
1285
+ *
1286
+ * ```ts import.meta.vitest
1287
+ * import { Config, Context } from "effect"
1288
+ * import { Param } from "effect/cli"
1289
+ *
1290
+ * const EnvVar = Context.Service<never, string>("app/EnvVar")
1291
+ *
1292
+ * const token = Param.String(Param.flagKind, "token").pipe(
1293
+ * Param.withFallbackConfig(Config.String("APP_TOKEN")),
1294
+ * Param.annotate(EnvVar, "APP_TOKEN")
1295
+ * )
1296
+ * token.kind // => "flag"
1297
+ * ```
1298
+ *
1299
+ * @see {@link Single} for where annotations are stored
1300
+ *
1301
+ * @stability unstable
1302
+ * @category metadata
1303
+ * @since 4.1.3
1304
+ */
1305
+ <I, S>(key: Context.Key<I, S>, value: NoInfer<S>): <Kind extends ParamKind, A>(self: Param<Kind, A>) => Param<Kind, A>
1306
+ /**
1307
+ * Attaches a user-defined annotation to a parameter.
1308
+ *
1309
+ * **When to use**
1310
+ *
1311
+ * Use when documentation tooling needs facts the parser cannot know, such as
1312
+ * the environment variable behind a `withFallbackConfig`, or a deprecation
1313
+ * note. Annotations are keyed by a `Context.Key`, exactly like
1314
+ * `Command.annotate`.
1315
+ *
1316
+ * **Details**
1317
+ *
1318
+ * Annotations never affect parsing, help or completions. They are reported
1319
+ * by `CommandSpec.resolve` on each flag and argument, and survive combinators
1320
+ * applied before or after them.
1321
+ *
1322
+ * **Example** (Recording the environment variable behind a config fallback)
1323
+ *
1324
+ * ```ts import.meta.vitest
1325
+ * import { Config, Context } from "effect"
1326
+ * import { Param } from "effect/cli"
1327
+ *
1328
+ * const EnvVar = Context.Service<never, string>("app/EnvVar")
1329
+ *
1330
+ * const token = Param.String(Param.flagKind, "token").pipe(
1331
+ * Param.withFallbackConfig(Config.String("APP_TOKEN")),
1332
+ * Param.annotate(EnvVar, "APP_TOKEN")
1333
+ * )
1334
+ * token.kind // => "flag"
1335
+ * ```
1336
+ *
1337
+ * @see {@link Single} for where annotations are stored
1338
+ *
1339
+ * @stability unstable
1340
+ * @category metadata
1341
+ * @since 4.1.3
1342
+ */
1343
+ <Kind extends ParamKind, A, I, S>(self: Param<Kind, A>, key: Context.Key<I, S>, value: NoInfer<S>): Param<Kind, A>
1344
+ } = dual(3, <Kind extends ParamKind, A, I, S>(
1345
+ self: Param<Kind, A>,
1346
+ key: Context.Key<I, S>,
1347
+ value: NoInfer<S>
1348
+ ): Param<Kind, A> =>
1349
+ transformSingle(self, <X>(single: Single<Kind, X>) =>
1350
+ makeSingle({
1351
+ ...single,
1352
+ annotations: Context.add(single.annotations, key, value)
1353
+ })))
1354
+
1195
1355
  /**
1196
1356
  * Transforms the parsed value of an option using a mapping function.
1197
1357
  *
@@ -1270,7 +1430,8 @@ const transform = <Kind extends ParamKind, A, B>(
1270
1430
  parse: Parse<A>,
1271
1431
  alternatives: ReadonlyArray<LazyArg<Parse<unknown>>>
1272
1432
  ) => Parse<B>,
1273
- alternatives: ReadonlyArray<LazyArg<Param<Kind, unknown>>> = []
1433
+ alternatives: ReadonlyArray<LazyArg<Param<Kind, unknown>>> = [],
1434
+ fallback?: Fallback | undefined
1274
1435
  ): Transform<Kind, A, B> => {
1275
1436
  const alternativeParsers = alternatives.map((alternative) => () => alternative().parse)
1276
1437
  return Object.assign(Object.create(Proto), {
@@ -1279,6 +1440,7 @@ const transform = <Kind extends ParamKind, A, B>(
1279
1440
  param: self,
1280
1441
  alternatives,
1281
1442
  f,
1443
+ fallback,
1282
1444
  parse: f(self.parse, alternativeParsers)
1283
1445
  })
1284
1446
  }
@@ -1801,14 +1963,27 @@ export const withDefault: {
1801
1963
  defaultValue: B | Effect.Effect<B, CliError.CliError, Environment>
1802
1964
  ): Param<Kind, A | B> => {
1803
1965
  if (!Effect.isEffect(defaultValue)) {
1804
- return map(optional(self), Option.getOrElse(() => defaultValue))
1966
+ return transform(
1967
+ optional(self),
1968
+ (parse) => (args) =>
1969
+ Effect.map(
1970
+ parse(args),
1971
+ ([leftover, value]) => [leftover, Option.getOrElse(value, () => defaultValue)] as const
1972
+ ),
1973
+ [],
1974
+ { _tag: "Default", value: defaultValue }
1975
+ )
1805
1976
  }
1806
- return mapEffect(
1807
- optional(self as Param<Kind, A | B>),
1808
- Option.match({
1809
- onNone: () => defaultValue,
1810
- onSome: Effect.succeed
1811
- })
1977
+ return transform(
1978
+ optional(self),
1979
+ (parse): Parse<A | B> => (args) =>
1980
+ Effect.flatMap(parse(args), ([leftover, value]): ReturnType<Parse<A | B>> =>
1981
+ Option.match(value, {
1982
+ onNone: () => Effect.map(defaultValue, (b) => [leftover, b] as const),
1983
+ onSome: (a) => Effect.succeed([leftover, a] as const)
1984
+ })),
1985
+ [],
1986
+ { _tag: "DefaultEffect" }
1812
1987
  )
1813
1988
  })
1814
1989
 
@@ -1917,7 +2092,9 @@ export const withFallbackConfig: {
1917
2092
  (parse) => (args) =>
1918
2093
  parse(args).pipe(
1919
2094
  Effect.catchTag(["MissingOption", "MissingArgument"], (error) => runConfig(error, args))
1920
- )
2095
+ ),
2096
+ [],
2097
+ { _tag: "Config" }
1921
2098
  )
1922
2099
  })
1923
2100
 
@@ -2030,7 +2207,9 @@ export const withFallbackPrompt: {
2030
2207
  (parse) => (args) =>
2031
2208
  parse(args).pipe(
2032
2209
  Effect.catchTag(["MissingOption", "MissingArgument"], (error) => runPrompt(error, args))
2033
- )
2210
+ ),
2211
+ [],
2212
+ { _tag: "Prompt" }
2034
2213
  )
2035
2214
  })
2036
2215
 
@@ -3386,7 +3565,8 @@ const transformSingle = <Kind extends ParamKind, A>(
3386
3565
  transform(
3387
3566
  transformSingle(mapped.param, f),
3388
3567
  mapped.f,
3389
- mapped.alternatives.map((alternative) => () => transformSingle(alternative(), f))
3568
+ mapped.alternatives.map((alternative) => () => transformSingle(alternative(), f)),
3569
+ mapped.fallback
3390
3570
  ),
3391
3571
  Optional: (p) => optional(transformSingle(p.param, f)) as Param<Kind, A>,
3392
3572
  Variadic: (p) =>
@@ -3443,36 +3623,58 @@ export const getUnderlyingSingleOrThrow = <Kind extends ParamKind, A>(
3443
3623
  }
3444
3624
 
3445
3625
  /**
3446
- * Gets param metadata by traversing the structure.
3626
+ * Structural facts about a param, gathered by traversing its combinator nodes.
3447
3627
  *
3448
3628
  * @internal
3449
3629
  */
3450
- export const getParamMetadata = <Kind extends ParamKind, A>(
3451
- param: Param<Kind, A>
3452
- ): {
3630
+ export interface ParamMetadata {
3453
3631
  readonly isOptional: boolean
3454
3632
  readonly isVariadic: boolean
3455
3633
  readonly variadicMin: Option.Option<number>
3456
3634
  readonly variadicMax: Option.Option<number>
3457
- } => {
3458
- return matchParam(param, {
3635
+ /**
3636
+ * Whether parsing fails when the parameter is absent and no fallback
3637
+ * supplies a value: an `optional` wrapper or a zero-minimum variadic makes
3638
+ * a param not required. Help additionally never displays boolean flags as
3639
+ * required; that is a rendering choice, not a parsing one.
3640
+ */
3641
+ readonly isRequired: boolean
3642
+ }
3643
+
3644
+ /**
3645
+ * Gets param metadata by traversing the structure.
3646
+ *
3647
+ * @internal
3648
+ */
3649
+ export const getParamMetadata = <Kind extends ParamKind, A>(param: Param<Kind, A>): ParamMetadata => {
3650
+ const metadata = collectParamMetadata(param)
3651
+ return {
3652
+ ...metadata,
3653
+ isRequired: !metadata.isOptional &&
3654
+ (!metadata.isVariadic || Option.exists(metadata.variadicMin, (min) => min > 0))
3655
+ }
3656
+ }
3657
+
3658
+ const collectParamMetadata = <Kind extends ParamKind, A>(
3659
+ param: Param<Kind, A>
3660
+ ): Omit<ParamMetadata, "isRequired"> =>
3661
+ matchParam(param, {
3459
3662
  Single: () => ({
3460
3663
  isOptional: false,
3461
3664
  isVariadic: false,
3462
3665
  variadicMin: Option.none(),
3463
3666
  variadicMax: Option.none()
3464
3667
  }),
3465
- Map: (mapped) => getParamMetadata(mapped.param),
3466
- Transform: (mapped) => getParamMetadata(mapped.param),
3668
+ Map: (mapped) => collectParamMetadata(mapped.param),
3669
+ Transform: (mapped) => collectParamMetadata(mapped.param),
3467
3670
  Optional: (optional) => ({
3468
- ...getParamMetadata(optional.param),
3671
+ ...collectParamMetadata(optional.param),
3469
3672
  isOptional: true
3470
3673
  }),
3471
3674
  Variadic: (variadic) => ({
3472
- ...getParamMetadata(variadic.param),
3675
+ ...collectParamMetadata(variadic.param),
3473
3676
  isVariadic: true,
3474
3677
  variadicMin: variadic.min,
3475
3678
  variadicMax: variadic.max
3476
3679
  })
3477
3680
  })
3478
- }
package/src/cli/index.ts CHANGED
@@ -35,6 +35,12 @@ export * as CliOutput from "./CliOutput.ts"
35
35
  */
36
36
  export * as Command from "./Command.ts"
37
37
 
38
+ /**
39
+ * @stability unstable
40
+ * @since 4.1.3
41
+ */
42
+ export * as CommandSpec from "./CommandSpec.ts"
43
+
38
44
  /**
39
45
  * @stability unstable
40
46
  * @since 4.0.0
@@ -41,7 +41,7 @@ export interface CommandInternal<Name extends string, Input, E, R, ContextInput>
41
41
  readonly service: Context.Key<CommandContext<Name>, ContextInput>
42
42
  readonly annotations: Context.Context<never>
43
43
  readonly globalFlags: ReadonlyArray<GlobalFlag.GlobalFlag<any>>
44
- readonly parse: (input: ParsedTokens) => Effect.Effect<Input, CliError.CliError, Environment>
44
+ readonly parse: (input: ParsedTokens) => Effect.Effect<Input, E | CliError.CliError, Environment>
45
45
  readonly parseContext: (input: ParsedTokens) => Effect.Effect<ContextInput, CliError.CliError, Environment>
46
46
  readonly handle: (
47
47
  input: Input,
@@ -102,7 +102,7 @@ export const makeCommand = <const Name extends string, Input, E, R, ContextInput
102
102
  readonly unlisted?: boolean | undefined
103
103
  readonly resolveExamples?: ((commandPath: ReadonlyArray<string>) => ReadonlyArray<Command.Example>) | undefined
104
104
  readonly subcommands?: ReadonlyArray<SubcommandGroup> | undefined
105
- readonly parse?: ((input: ParsedTokens) => Effect.Effect<Input, CliError.CliError, Environment>) | undefined
105
+ readonly parse?: ((input: ParsedTokens) => Effect.Effect<Input, E | CliError.CliError, Environment>) | undefined
106
106
  readonly parseContext?:
107
107
  | ((input: ParsedTokens) => Effect.Effect<ContextInput, CliError.CliError, Environment>)
108
108
  | undefined
@@ -141,8 +141,7 @@ export const makeCommand = <const Name extends string, Input, E, R, ContextInput
141
141
  name: single.name,
142
142
  type: single.typeName ?? Primitive.getTypeName(single.primitiveType),
143
143
  description: single.description,
144
- required: !metadata.isOptional &&
145
- (!metadata.isVariadic || Option.exists(metadata.variadicMin, (min) => min > 0)),
144
+ required: metadata.isRequired,
146
145
  variadic: metadata.isVariadic
147
146
  })
148
147
  }
@@ -46,7 +46,8 @@ const buildFlagGroupDeclarations = (
46
46
  lines.push(` done`)
47
47
  lines.push(` local _filtered_flags=""`)
48
48
  groups.forEach((forms, index) => {
49
- lines.push(` [[ -n "$_used_${index}" ]] || _filtered_flags+=" ${forms.join(" ")}"`)
49
+ const guard = flags[index].repeatable === true ? "" : `[[ -n "$_used_${index}" ]] || `
50
+ lines.push(` ${guard}_filtered_flags+=" ${forms.join(" ")}"`)
50
51
  })
51
52
  lines.push(``)
52
53
  }
@@ -173,15 +174,16 @@ const pathsHelper = (helpers: Helpers, lines: Array<string>): void => {
173
174
  lines.push(``)
174
175
  }
175
176
 
177
+ const choicesCompletion = (values: ReadonlyArray<string>, helpers: Helpers): string =>
178
+ `${helpers.choices} "$cur" "$_comp_word" ${values.map((value) => `'${escapeForBash(value)}'`).join(" ")}`
179
+
176
180
  const valueCompletion = (
177
181
  type: Completions.FlagType | Completions.ArgumentType,
178
182
  helpers: Helpers
179
183
  ): string | undefined => {
180
184
  switch (type._tag) {
181
- case "Choice": {
182
- const values = type.values.map((value) => `'${escapeForBash(value)}'`).join(" ")
183
- return `${helpers.choices} "$cur" "$_comp_word" ${values}`
184
- }
185
+ case "Choice":
186
+ return choicesCompletion(type.values, helpers)
185
187
  case "Path":
186
188
  return `${helpers.paths} ${type.pathType === "directory" ? "-d" : "-f"} "$cur" "$_comp_word"`
187
189
  default:
@@ -327,8 +329,8 @@ const generateFunction = (
327
329
  lines.push(` fi`)
328
330
  }
329
331
  } else if (descriptor.subcommands.length > 0) {
330
- const subNames = descriptor.subcommands.map((s) => s.name)
331
- lines.push(` COMPREPLY=( $(compgen -W '${subNames.join(" ")}' -- "$cur") )`)
332
+ // Unlike `compgen -W`, the choice helper replaces only the text after a word break such as `:`.
333
+ lines.push(` ${choicesCompletion(descriptor.subcommands.map((s) => s.name), helpers)}`)
332
334
  }
333
335
 
334
336
  lines.push(`}`)
@@ -69,6 +69,38 @@ const toArgumentType = (single: Param.Single<"argument", unknown>): Completions.
69
69
  // Extraction
70
70
  // ---------------------------------------------------------------------------
71
71
 
72
+ type FlagParam =
73
+ | Param.Single<"flag", unknown>
74
+ | Param.Map<"flag", unknown, unknown>
75
+ | Param.Transform<"flag", unknown, unknown>
76
+ | Param.Optional<"flag", unknown>
77
+ | Param.Variadic<"flag", unknown>
78
+
79
+ /**
80
+ * Pairs each single flag with whether it can be repeated. The outermost
81
+ * variadic decides, and each `orElse` alternative is resolved separately.
82
+ */
83
+ const repeatableSingles = (
84
+ param: Param.Param<"flag", unknown>,
85
+ repeatable?: boolean
86
+ ): Array<readonly [Param.Single<"flag", unknown>, boolean]> => {
87
+ const p = param as FlagParam
88
+ switch (p._tag) {
89
+ case "Single":
90
+ return [[p, repeatable === true]]
91
+ case "Map":
92
+ case "Optional":
93
+ return repeatableSingles(p.param, repeatable)
94
+ case "Transform":
95
+ return [
96
+ ...repeatableSingles(p.param, repeatable),
97
+ ...p.alternatives.flatMap((alternative) => repeatableSingles(alternative(), repeatable))
98
+ ]
99
+ case "Variadic":
100
+ return repeatableSingles(p.param, repeatable ?? !Option.exists(p.max, (max) => max <= 1))
101
+ }
102
+ }
103
+
72
104
  /**
73
105
  * @internal
74
106
  */
@@ -83,9 +115,7 @@ export const fromCommand = (
83
115
  const seen = new Set<string>()
84
116
  // Match help's precedence: local flags first, then ancestors root to leaf.
85
117
  for (const [index, flag] of [...config.flags, ...inheritedFlags].entries()) {
86
- const singles = Param.extractSingleParams(flag)
87
- for (const single of singles) {
88
- if (single.kind !== "flag") continue
118
+ for (const [single, repeatable] of repeatableSingles(flag)) {
89
119
  // Omit hidden flags from completion scripts so tab-completion in the
90
120
  // shell does not advertise flags that are absent from --help.
91
121
  if (single.hidden) continue
@@ -95,8 +125,9 @@ export const fromCommand = (
95
125
  name: single.name,
96
126
  aliases: single.aliases,
97
127
  description: Option.getOrUndefined(single.description),
98
- type: toFlagType(single as Param.Single<"flag", unknown>),
128
+ type: toFlagType(single),
99
129
  optionalValue: single.optionalValue !== undefined,
130
+ repeatable,
100
131
  negation: single.negation
101
132
  })
102
133
  }
@@ -111,7 +142,8 @@ export const fromCommand = (
111
142
  args.push({
112
143
  name: single.name,
113
144
  description: Option.getOrUndefined(single.description),
114
- required: !metadata.isOptional,
145
+ required: !metadata.isOptional &&
146
+ (!metadata.isVariadic || Option.exists(metadata.variadicMin, (min) => min > 0)),
115
147
  variadic: metadata.isVariadic,
116
148
  type: toArgumentType(single as Param.Single<"argument", unknown>)
117
149
  })
@@ -161,8 +161,12 @@ const generateCompletions = (
161
161
 
162
162
  // Flag completions
163
163
  for (const flag of descriptor.flags) {
164
- const dedup = takesSeparateValue(flag) ? valueFlagDedupCondition(flag) : flagContainsOptCondition(flag)
165
- const flagCondition = condition ? `${condition}; and ${dedup}` : dedup
164
+ const dedup = flag.repeatable === true
165
+ ? ""
166
+ : takesSeparateValue(flag)
167
+ ? valueFlagDedupCondition(flag)
168
+ : flagContainsOptCondition(flag)
169
+ const flagCondition = [condition, dedup].filter((part) => part !== "").join("; and ")
166
170
  const flagCondArg = flagCondition ? `-n '${flagCondition}'` : ``
167
171
 
168
172
  const parts = [`complete -c ${executableName}`]
@@ -193,7 +197,9 @@ const generateCompletions = (
193
197
  const bareBase = condition ? `${condition}; and ${notDash}` : notDash
194
198
 
195
199
  for (const flag of descriptor.flags) {
196
- const bareCondition = `${bareBase}; and ${flagContainsOptCondition(flag)}`
200
+ const bareCondition = flag.repeatable === true
201
+ ? bareBase
202
+ : `${bareBase}; and ${flagContainsOptCondition(flag)}`
197
203
  const negation = negatedName(flag)
198
204
 
199
205
  const parts = [`complete -c ${executableName}`]
@@ -53,6 +53,7 @@ const flagEntry = (flag: Completions.FlagDescriptor): string => {
53
53
  `takesValue = $${flag.type._tag !== "Boolean"}; ` +
54
54
  (negation === undefined ? "" : `negation = ${quotePs(`--${negation}`)}; `) +
55
55
  (flag.optionalValue === true ? `optionalValue = $true; ` : "") +
56
+ (flag.repeatable === true ? `repeatable = $true; ` : "") +
56
57
  `${valueFields(flag.type)}; ` +
57
58
  `description = ${psOptional(flag.description)} }`
58
59
  }
@@ -154,7 +155,7 @@ const completer = (dataName: string): string =>
154
155
  $addFlags = {
155
156
  param([string]$typed)
156
157
  foreach ($flag in $context.flags) {
157
- if ($used.ContainsKey($flag.name)) { continue }
158
+ if (-not $flag.repeatable -and $used.ContainsKey($flag.name)) { continue }
158
159
  foreach ($form in $flag.forms) {
159
160
  & $add $form 'ParameterName' $flag.description $typed ''
160
161
  }
@@ -79,7 +79,7 @@ const flagSpecs = (flag: Completions.FlagDescriptor): Array<string> => {
79
79
  const optional = flag.optionalValue === true && flag.type._tag !== "Boolean"
80
80
  const valueSuffix = optional ? "=-" : ""
81
81
  const action = optional ? `:${valueAction(flag.type)}` : valueAction(flag.type)
82
- const excl = `(${allForms(flag).join(" ")})`
82
+ const excl = flag.repeatable === true ? "*" : `(${allForms(flag).join(" ")})`
83
83
 
84
84
  // Primary long name
85
85
  specs.push(`'${excl}--${flag.name}${valueSuffix}${desc}${action}'`)
@@ -132,7 +132,7 @@ const generateFunction = (
132
132
  lines.push(` commands=(`)
133
133
  for (const sub of descriptor.subcommands) {
134
134
  const desc = sub.description ? escapeZsh(sub.description) : ""
135
- lines.push(` '${sub.name}:${desc}'`)
135
+ lines.push(` '${escapeZsh(sub.name)}:${desc}'`)
136
136
  }
137
137
  lines.push(` )`)
138
138
  lines.push(``)
@@ -441,12 +441,7 @@ export const make = Effect.gen(function*() {
441
441
 
442
442
  return requestId
443
443
  },
444
- Effect.retry({
445
- while: (e) => e._tag === "PersistenceError",
446
- times: 3,
447
- schedule: Schedule.exponential(250)
448
- }),
449
- Effect.orDie
444
+ retryPersistenceBounded
450
445
  )
451
446
 
452
447
  const engine = WorkflowEngine.makeUnsafe({
@@ -710,7 +705,9 @@ export const make = Effect.gen(function*() {
710
705
  { discard }
711
706
  )
712
707
  ),
713
- Effect.orDie,
708
+ // A failed save inside a workflow would be stored as its result. Top-level
709
+ // calls still fail, so their callers are not blocked during an outage.
710
+ parent ? retryPersistence : Effect.orDie,
714
711
  Effect.scoped
715
712
  )
716
713
  },
@@ -847,12 +844,8 @@ export const make = Effect.gen(function*() {
847
844
  // It was processed after the first read, so its reply is stored now.
848
845
  return Option.map(yield* replyForRequestId(requestId.value), deferredReplyExit)
849
846
  })),
850
- Effect.retry({
851
- while: (e) => e._tag === "PersistenceError",
852
- times: 3,
853
- schedule: Schedule.exponential(250)
854
- }),
855
- Effect.orDie
847
+ // Uninterruptible exit cleanup reads the interrupt signal, so bound its retries.
848
+ deferred.name === InterruptSignal.name ? retryPersistenceBounded : retryPersistence
856
849
  ),
857
850
 
858
851
  deferredDone: Effect.fnUntraced(
@@ -924,14 +917,20 @@ const retryPolicy = Schedule.min([
924
917
  ])
925
918
 
926
919
  // A transient storage failure must not become the workflow result. Activity,
927
- // clock and deferred requests are saved under a primary key, so a retry after
928
- // a lost acknowledgement is deduplicated instead of stored twice.
920
+ // clock, deferred and child run requests are saved under a primary key, so a
921
+ // retry after a lost acknowledgement is deduplicated instead of stored twice.
929
922
  const retryPersistence = <A, E extends { readonly _tag: string }, R>(effect: Effect.Effect<A, E, R>) =>
930
923
  effect.pipe(
931
924
  Effect.retry({ schedule: retryPolicy, while: (e) => e._tag === "PersistenceError" }),
932
925
  Effect.orDie
933
926
  )
934
927
 
928
+ const retryPersistenceBounded = <A, E extends { readonly _tag: string }, R>(effect: Effect.Effect<A, E, R>) =>
929
+ effect.pipe(
930
+ Effect.retry({ times: 3, schedule: Schedule.exponential(250), while: (e) => e._tag === "PersistenceError" }),
931
+ Effect.orDie
932
+ )
933
+
935
934
  // A cluster abandonment means this owner can no longer complete the effect, so
936
935
  // retrying it would only wait on a retired run. Re-raise it as an annotated
937
936
  // interrupt, so the activation can unwind and its shard can be released.
@@ -791,6 +791,11 @@ export const keepAlive: (
791
791
  never,
792
792
  Sharding | CurrentAddress
793
793
  > = Effect.fnUntraced(function*(enabled: boolean) {
794
+ const ohandler = yield* Effect.serviceOption(KeepAliveHandler)
795
+ if (ohandler._tag === "Some") {
796
+ yield* ohandler.value(enabled)
797
+ return
798
+ }
794
799
  const olatch = yield* Effect.serviceOption(KeepAliveLatch)
795
800
  if (olatch._tag === "None") return
796
801
  if (!enabled) {
@@ -860,3 +865,22 @@ export const KeepAliveRpc = Rpc.make("Cluster/Entity/keepAlive")
860
865
  export class KeepAliveLatch extends Context.Service<KeepAliveLatch, Latch.Latch>()(
861
866
  "effect/cluster/Entity/KeepAliveLatch"
862
867
  ) {}
868
+
869
+ /**
870
+ * Service tag for the runtime hook behind {@link keepAlive}.
871
+ *
872
+ * **Details**
873
+ *
874
+ * Runtimes that support pinning an entity in memory provide this service; the
875
+ * handler receives `true` while at least one keep-alive holder exists and
876
+ * `false` once the last holder is released. When the service is absent,
877
+ * `keepAlive` is a no-op.
878
+ *
879
+ * @stability unstable
880
+ * @category services
881
+ * @since 4.1.3
882
+ */
883
+ export class KeepAliveHandler extends Context.Service<
884
+ KeepAliveHandler,
885
+ (enabled: boolean) => Effect.Effect<void>
886
+ >()("effect/cluster/Entity/KeepAliveHandler") {}