charness 0.0.0-stage → 3.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 (1044) hide show
  1. package/.env.example +88 -0
  2. package/DEVELOPMENT.md +110 -0
  3. package/LICENSE +21 -0
  4. package/MIGRATION_1_TO_2.md +24 -0
  5. package/README.md +1196 -2
  6. package/dist/accessControl.d.ts +71 -0
  7. package/dist/accessControl.d.ts.map +1 -0
  8. package/dist/accessControl.js +108 -0
  9. package/dist/accessControl.js.map +1 -0
  10. package/dist/adapters/adapterEventRouting.d.ts +51 -0
  11. package/dist/adapters/adapterEventRouting.d.ts.map +1 -0
  12. package/dist/adapters/adapterEventRouting.js +74 -0
  13. package/dist/adapters/adapterEventRouting.js.map +1 -0
  14. package/dist/adapters/adapterNames.d.ts +19 -0
  15. package/dist/adapters/adapterNames.d.ts.map +1 -0
  16. package/dist/adapters/adapterNames.js +25 -0
  17. package/dist/adapters/adapterNames.js.map +1 -0
  18. package/dist/adapters/claudeCliAdapter.d.ts +1351 -0
  19. package/dist/adapters/claudeCliAdapter.d.ts.map +1 -0
  20. package/dist/adapters/claudeCliAdapter.js +4239 -0
  21. package/dist/adapters/claudeCliAdapter.js.map +1 -0
  22. package/dist/adapters/claudeConfigDir.d.ts +40 -0
  23. package/dist/adapters/claudeConfigDir.d.ts.map +1 -0
  24. package/dist/adapters/claudeConfigDir.js +3 -0
  25. package/dist/adapters/claudeConfigDir.js.map +1 -0
  26. package/dist/adapters/claudeJsonStreamAdapter.d.ts +580 -0
  27. package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -0
  28. package/dist/adapters/claudeJsonStreamAdapter.js +1891 -0
  29. package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -0
  30. package/dist/adapters/claudePlatformFlags.d.ts +35 -0
  31. package/dist/adapters/claudePlatformFlags.d.ts.map +1 -0
  32. package/dist/adapters/claudePlatformFlags.js +46 -0
  33. package/dist/adapters/claudePlatformFlags.js.map +1 -0
  34. package/dist/adapters/createAdapter.d.ts +260 -0
  35. package/dist/adapters/createAdapter.d.ts.map +1 -0
  36. package/dist/adapters/createAdapter.js +512 -0
  37. package/dist/adapters/createAdapter.js.map +1 -0
  38. package/dist/adapters/openCodeAdapter.d.ts +1469 -0
  39. package/dist/adapters/openCodeAdapter.d.ts.map +1 -0
  40. package/dist/adapters/openCodeAdapter.js +4623 -0
  41. package/dist/adapters/openCodeAdapter.js.map +1 -0
  42. package/dist/adapters/sessionLaunchDefaults.d.ts +28 -0
  43. package/dist/adapters/sessionLaunchDefaults.d.ts.map +1 -0
  44. package/dist/adapters/sessionLaunchDefaults.js +15 -0
  45. package/dist/adapters/sessionLaunchDefaults.js.map +1 -0
  46. package/dist/adapters/terminalAdapter.d.ts +68 -0
  47. package/dist/adapters/terminalAdapter.d.ts.map +1 -0
  48. package/dist/adapters/terminalAdapter.js +371 -0
  49. package/dist/adapters/terminalAdapter.js.map +1 -0
  50. package/dist/agentLogin/agentLogin.d.ts +44 -0
  51. package/dist/agentLogin/agentLogin.d.ts.map +1 -0
  52. package/dist/agentLogin/agentLogin.js +530 -0
  53. package/dist/agentLogin/agentLogin.js.map +1 -0
  54. package/dist/agentTrigger.d.ts +28 -0
  55. package/dist/agentTrigger.d.ts.map +1 -0
  56. package/dist/agentTrigger.js +53 -0
  57. package/dist/agentTrigger.js.map +1 -0
  58. package/dist/apiErrorRetry.d.ts +214 -0
  59. package/dist/apiErrorRetry.d.ts.map +1 -0
  60. package/dist/apiErrorRetry.js +382 -0
  61. package/dist/apiErrorRetry.js.map +1 -0
  62. package/dist/apiRetryKick.d.ts +157 -0
  63. package/dist/apiRetryKick.d.ts.map +1 -0
  64. package/dist/apiRetryKick.js +174 -0
  65. package/dist/apiRetryKick.js.map +1 -0
  66. package/dist/bootClassifier.d.ts +46 -0
  67. package/dist/bootClassifier.d.ts.map +1 -0
  68. package/dist/bootClassifier.js +43 -0
  69. package/dist/bootClassifier.js.map +1 -0
  70. package/dist/bot.d.ts +207 -0
  71. package/dist/bot.d.ts.map +1 -0
  72. package/dist/bot.js +11226 -0
  73. package/dist/bot.js.map +1 -0
  74. package/dist/botFileStorage.d.ts +60 -0
  75. package/dist/botFileStorage.d.ts.map +1 -0
  76. package/dist/botFileStorage.js +205 -0
  77. package/dist/botFileStorage.js.map +1 -0
  78. package/dist/cli/applyDnsFix.d.ts +7 -0
  79. package/dist/cli/applyDnsFix.d.ts.map +1 -0
  80. package/dist/cli/applyDnsFix.js +46 -0
  81. package/dist/cli/applyDnsFix.js.map +1 -0
  82. package/dist/cli/bot.d.ts +27 -0
  83. package/dist/cli/bot.d.ts.map +1 -0
  84. package/dist/cli/bot.js +98 -0
  85. package/dist/cli/bot.js.map +1 -0
  86. package/dist/cli/botEntry.d.ts +3 -0
  87. package/dist/cli/botEntry.d.ts.map +1 -0
  88. package/dist/cli/botEntry.js +11 -0
  89. package/dist/cli/botEntry.js.map +1 -0
  90. package/dist/cli/claudeProfiles.d.ts +42 -0
  91. package/dist/cli/claudeProfiles.d.ts.map +1 -0
  92. package/dist/cli/claudeProfiles.js +106 -0
  93. package/dist/cli/claudeProfiles.js.map +1 -0
  94. package/dist/cli/connectorGuards.d.ts +31 -0
  95. package/dist/cli/connectorGuards.d.ts.map +1 -0
  96. package/dist/cli/connectorGuards.js +159 -0
  97. package/dist/cli/connectorGuards.js.map +1 -0
  98. package/dist/cli/envLoader.d.ts +34 -0
  99. package/dist/cli/envLoader.d.ts.map +1 -0
  100. package/dist/cli/envLoader.js +132 -0
  101. package/dist/cli/envLoader.js.map +1 -0
  102. package/dist/cli/hot.d.ts +82 -0
  103. package/dist/cli/hot.d.ts.map +1 -0
  104. package/dist/cli/hot.js +323 -0
  105. package/dist/cli/hot.js.map +1 -0
  106. package/dist/cli.d.ts +3 -0
  107. package/dist/cli.d.ts.map +1 -0
  108. package/dist/cli.js +140 -0
  109. package/dist/cli.js.map +1 -0
  110. package/dist/connectors/jira/adf.d.ts +74 -0
  111. package/dist/connectors/jira/adf.d.ts.map +1 -0
  112. package/dist/connectors/jira/adf.js +412 -0
  113. package/dist/connectors/jira/adf.js.map +1 -0
  114. package/dist/connectors/jira/agentBinaries.d.ts +14 -0
  115. package/dist/connectors/jira/agentBinaries.d.ts.map +1 -0
  116. package/dist/connectors/jira/agentBinaries.js +75 -0
  117. package/dist/connectors/jira/agentBinaries.js.map +1 -0
  118. package/dist/connectors/jira/answerSink.d.ts +59 -0
  119. package/dist/connectors/jira/answerSink.d.ts.map +1 -0
  120. package/dist/connectors/jira/answerSink.js +234 -0
  121. package/dist/connectors/jira/answerSink.js.map +1 -0
  122. package/dist/connectors/jira/attachmentDownload.d.ts +41 -0
  123. package/dist/connectors/jira/attachmentDownload.d.ts.map +1 -0
  124. package/dist/connectors/jira/attachmentDownload.js +92 -0
  125. package/dist/connectors/jira/attachmentDownload.js.map +1 -0
  126. package/dist/connectors/jira/attachmentTool.d.ts +50 -0
  127. package/dist/connectors/jira/attachmentTool.d.ts.map +1 -0
  128. package/dist/connectors/jira/attachmentTool.js +166 -0
  129. package/dist/connectors/jira/attachmentTool.js.map +1 -0
  130. package/dist/connectors/jira/client.d.ts +522 -0
  131. package/dist/connectors/jira/client.d.ts.map +1 -0
  132. package/dist/connectors/jira/client.js +491 -0
  133. package/dist/connectors/jira/client.js.map +1 -0
  134. package/dist/connectors/jira/config.d.ts +104 -0
  135. package/dist/connectors/jira/config.d.ts.map +1 -0
  136. package/dist/connectors/jira/config.js +323 -0
  137. package/dist/connectors/jira/config.js.map +1 -0
  138. package/dist/connectors/jira/configFile.d.ts +10 -0
  139. package/dist/connectors/jira/configFile.d.ts.map +1 -0
  140. package/dist/connectors/jira/configFile.js +50 -0
  141. package/dist/connectors/jira/configFile.js.map +1 -0
  142. package/dist/connectors/jira/connector.d.ts +71 -0
  143. package/dist/connectors/jira/connector.d.ts.map +1 -0
  144. package/dist/connectors/jira/connector.js +312 -0
  145. package/dist/connectors/jira/connector.js.map +1 -0
  146. package/dist/connectors/jira/contextLedger.d.ts +60 -0
  147. package/dist/connectors/jira/contextLedger.d.ts.map +1 -0
  148. package/dist/connectors/jira/contextLedger.js +196 -0
  149. package/dist/connectors/jira/contextLedger.js.map +1 -0
  150. package/dist/connectors/jira/contextPreamble.d.ts +18 -0
  151. package/dist/connectors/jira/contextPreamble.d.ts.map +1 -0
  152. package/dist/connectors/jira/contextPreamble.js +31 -0
  153. package/dist/connectors/jira/contextPreamble.js.map +1 -0
  154. package/dist/connectors/jira/inbound.d.ts +141 -0
  155. package/dist/connectors/jira/inbound.d.ts.map +1 -0
  156. package/dist/connectors/jira/inbound.js +331 -0
  157. package/dist/connectors/jira/inbound.js.map +1 -0
  158. package/dist/connectors/jira/issueBlocks.d.ts +74 -0
  159. package/dist/connectors/jira/issueBlocks.d.ts.map +1 -0
  160. package/dist/connectors/jira/issueBlocks.js +257 -0
  161. package/dist/connectors/jira/issueBlocks.js.map +1 -0
  162. package/dist/connectors/jira/issueContext.d.ts +31 -0
  163. package/dist/connectors/jira/issueContext.d.ts.map +1 -0
  164. package/dist/connectors/jira/issueContext.js +70 -0
  165. package/dist/connectors/jira/issueContext.js.map +1 -0
  166. package/dist/connectors/jira/issueDelta.d.ts +38 -0
  167. package/dist/connectors/jira/issueDelta.d.ts.map +1 -0
  168. package/dist/connectors/jira/issueDelta.js +59 -0
  169. package/dist/connectors/jira/issueDelta.js.map +1 -0
  170. package/dist/connectors/jira/mediaPlaceholders.d.ts +22 -0
  171. package/dist/connectors/jira/mediaPlaceholders.d.ts.map +1 -0
  172. package/dist/connectors/jira/mediaPlaceholders.js +105 -0
  173. package/dist/connectors/jira/mediaPlaceholders.js.map +1 -0
  174. package/dist/connectors/jira/outbound.d.ts +6 -0
  175. package/dist/connectors/jira/outbound.d.ts.map +1 -0
  176. package/dist/connectors/jira/outbound.js +38 -0
  177. package/dist/connectors/jira/outbound.js.map +1 -0
  178. package/dist/connectors/jira/prompt.d.ts +39 -0
  179. package/dist/connectors/jira/prompt.d.ts.map +1 -0
  180. package/dist/connectors/jira/prompt.js +102 -0
  181. package/dist/connectors/jira/prompt.js.map +1 -0
  182. package/dist/connectors/jira/promptSpill.d.ts +50 -0
  183. package/dist/connectors/jira/promptSpill.d.ts.map +1 -0
  184. package/dist/connectors/jira/promptSpill.js +157 -0
  185. package/dist/connectors/jira/promptSpill.js.map +1 -0
  186. package/dist/connectors/jira/promptText.d.ts +7 -0
  187. package/dist/connectors/jira/promptText.d.ts.map +1 -0
  188. package/dist/connectors/jira/promptText.js +26 -0
  189. package/dist/connectors/jira/promptText.js.map +1 -0
  190. package/dist/connectors/jira/sessionKeyCodec.d.ts +18 -0
  191. package/dist/connectors/jira/sessionKeyCodec.d.ts.map +1 -0
  192. package/dist/connectors/jira/sessionKeyCodec.js +106 -0
  193. package/dist/connectors/jira/sessionKeyCodec.js.map +1 -0
  194. package/dist/connectors/jira/trigger.d.ts +54 -0
  195. package/dist/connectors/jira/trigger.d.ts.map +1 -0
  196. package/dist/connectors/jira/trigger.js +101 -0
  197. package/dist/connectors/jira/trigger.js.map +1 -0
  198. package/dist/connectors/jira/triggerLog.d.ts +53 -0
  199. package/dist/connectors/jira/triggerLog.d.ts.map +1 -0
  200. package/dist/connectors/jira/triggerLog.js +78 -0
  201. package/dist/connectors/jira/triggerLog.js.map +1 -0
  202. package/dist/connectors/jira/trustedGroup.d.ts +54 -0
  203. package/dist/connectors/jira/trustedGroup.d.ts.map +1 -0
  204. package/dist/connectors/jira/trustedGroup.js +98 -0
  205. package/dist/connectors/jira/trustedGroup.js.map +1 -0
  206. package/dist/connectors/jira/unconfirmedPosts.d.ts +58 -0
  207. package/dist/connectors/jira/unconfirmedPosts.d.ts.map +1 -0
  208. package/dist/connectors/jira/unconfirmedPosts.js +105 -0
  209. package/dist/connectors/jira/unconfirmedPosts.js.map +1 -0
  210. package/dist/connectors/telegram/answerSink.d.ts +46 -0
  211. package/dist/connectors/telegram/answerSink.d.ts.map +1 -0
  212. package/dist/connectors/telegram/answerSink.js +71 -0
  213. package/dist/connectors/telegram/answerSink.js.map +1 -0
  214. package/dist/connectors/telegram/commands/autoContinueLimits.d.ts +34 -0
  215. package/dist/connectors/telegram/commands/autoContinueLimits.d.ts.map +1 -0
  216. package/dist/connectors/telegram/commands/autoContinueLimits.js +112 -0
  217. package/dist/connectors/telegram/commands/autoContinueLimits.js.map +1 -0
  218. package/dist/connectors/telegram/commands/botCore.d.ts +46 -0
  219. package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -0
  220. package/dist/connectors/telegram/commands/botCore.js +3 -0
  221. package/dist/connectors/telegram/commands/botCore.js.map +1 -0
  222. package/dist/connectors/telegram/commands/callbackMessage.d.ts +12 -0
  223. package/dist/connectors/telegram/commands/callbackMessage.d.ts.map +1 -0
  224. package/dist/connectors/telegram/commands/callbackMessage.js +13 -0
  225. package/dist/connectors/telegram/commands/callbackMessage.js.map +1 -0
  226. package/dist/connectors/telegram/commands/claudeAccounts.d.ts +58 -0
  227. package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -0
  228. package/dist/connectors/telegram/commands/claudeAccounts.js +591 -0
  229. package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -0
  230. package/dist/connectors/telegram/commands/compaction.d.ts +47 -0
  231. package/dist/connectors/telegram/commands/compaction.d.ts.map +1 -0
  232. package/dist/connectors/telegram/commands/compaction.js +868 -0
  233. package/dist/connectors/telegram/commands/compaction.js.map +1 -0
  234. package/dist/connectors/telegram/commands/displayModes.d.ts +13 -0
  235. package/dist/connectors/telegram/commands/displayModes.d.ts.map +1 -0
  236. package/dist/connectors/telegram/commands/displayModes.js +335 -0
  237. package/dist/connectors/telegram/commands/displayModes.js.map +1 -0
  238. package/dist/connectors/telegram/commands/fallbackChain.d.ts +49 -0
  239. package/dist/connectors/telegram/commands/fallbackChain.d.ts.map +1 -0
  240. package/dist/connectors/telegram/commands/fallbackChain.js +624 -0
  241. package/dist/connectors/telegram/commands/fallbackChain.js.map +1 -0
  242. package/dist/connectors/telegram/commands/modelProviders.d.ts +117 -0
  243. package/dist/connectors/telegram/commands/modelProviders.d.ts.map +1 -0
  244. package/dist/connectors/telegram/commands/modelProviders.js +966 -0
  245. package/dist/connectors/telegram/commands/modelProviders.js.map +1 -0
  246. package/dist/connectors/telegram/commands/reminders.d.ts +54 -0
  247. package/dist/connectors/telegram/commands/reminders.d.ts.map +1 -0
  248. package/dist/connectors/telegram/commands/reminders.js +624 -0
  249. package/dist/connectors/telegram/commands/reminders.js.map +1 -0
  250. package/dist/connectors/telegram/fileIntake.d.ts +166 -0
  251. package/dist/connectors/telegram/fileIntake.d.ts.map +1 -0
  252. package/dist/connectors/telegram/fileIntake.js +304 -0
  253. package/dist/connectors/telegram/fileIntake.js.map +1 -0
  254. package/dist/connectors/telegram/fileSendGateway.d.ts +57 -0
  255. package/dist/connectors/telegram/fileSendGateway.d.ts.map +1 -0
  256. package/dist/connectors/telegram/fileSendGateway.js +221 -0
  257. package/dist/connectors/telegram/fileSendGateway.js.map +1 -0
  258. package/dist/connectors/telegram/foreignKeyFallbacks.d.ts +52 -0
  259. package/dist/connectors/telegram/foreignKeyFallbacks.d.ts.map +1 -0
  260. package/dist/connectors/telegram/foreignKeyFallbacks.js +71 -0
  261. package/dist/connectors/telegram/foreignKeyFallbacks.js.map +1 -0
  262. package/dist/connectors/telegram/inbound.d.ts +131 -0
  263. package/dist/connectors/telegram/inbound.d.ts.map +1 -0
  264. package/dist/connectors/telegram/inbound.js +278 -0
  265. package/dist/connectors/telegram/inbound.js.map +1 -0
  266. package/dist/connectors/telegram/languagePicker.d.ts +32 -0
  267. package/dist/connectors/telegram/languagePicker.d.ts.map +1 -0
  268. package/dist/connectors/telegram/languagePicker.js +55 -0
  269. package/dist/connectors/telegram/languagePicker.js.map +1 -0
  270. package/dist/connectors/telegram/messageSplit.d.ts +62 -0
  271. package/dist/connectors/telegram/messageSplit.d.ts.map +1 -0
  272. package/dist/connectors/telegram/messageSplit.js +119 -0
  273. package/dist/connectors/telegram/messageSplit.js.map +1 -0
  274. package/dist/connectors/telegram/outbound.d.ts +62 -0
  275. package/dist/connectors/telegram/outbound.d.ts.map +1 -0
  276. package/dist/connectors/telegram/outbound.js +116 -0
  277. package/dist/connectors/telegram/outbound.js.map +1 -0
  278. package/dist/connectors/telegram/output/createOutputTransport.d.ts +34 -0
  279. package/dist/connectors/telegram/output/createOutputTransport.d.ts.map +1 -0
  280. package/dist/connectors/telegram/output/createOutputTransport.js +77 -0
  281. package/dist/connectors/telegram/output/createOutputTransport.js.map +1 -0
  282. package/dist/connectors/telegram/output/dmOutputTransport.d.ts +47 -0
  283. package/dist/connectors/telegram/output/dmOutputTransport.d.ts.map +1 -0
  284. package/dist/connectors/telegram/output/dmOutputTransport.js +412 -0
  285. package/dist/connectors/telegram/output/dmOutputTransport.js.map +1 -0
  286. package/dist/connectors/telegram/outputBacklogGlue.d.ts +38 -0
  287. package/dist/connectors/telegram/outputBacklogGlue.d.ts.map +1 -0
  288. package/dist/connectors/telegram/outputBacklogGlue.js +49 -0
  289. package/dist/connectors/telegram/outputBacklogGlue.js.map +1 -0
  290. package/dist/connectors/telegram/outputFlushPlan.d.ts +93 -0
  291. package/dist/connectors/telegram/outputFlushPlan.d.ts.map +1 -0
  292. package/dist/connectors/telegram/outputFlushPlan.js +120 -0
  293. package/dist/connectors/telegram/outputFlushPlan.js.map +1 -0
  294. package/dist/connectors/telegram/questionKeyboards.d.ts +30 -0
  295. package/dist/connectors/telegram/questionKeyboards.d.ts.map +1 -0
  296. package/dist/connectors/telegram/questionKeyboards.js +37 -0
  297. package/dist/connectors/telegram/questionKeyboards.js.map +1 -0
  298. package/dist/connectors/telegram/renderAgentHtml.d.ts +27 -0
  299. package/dist/connectors/telegram/renderAgentHtml.d.ts.map +1 -0
  300. package/dist/connectors/telegram/renderAgentHtml.js +97 -0
  301. package/dist/connectors/telegram/renderAgentHtml.js.map +1 -0
  302. package/dist/connectors/telegram/sessionKeyCodec.d.ts +28 -0
  303. package/dist/connectors/telegram/sessionKeyCodec.d.ts.map +1 -0
  304. package/dist/connectors/telegram/sessionKeyCodec.js +107 -0
  305. package/dist/connectors/telegram/sessionKeyCodec.js.map +1 -0
  306. package/dist/connectors/telegram/telegramCallGuard.d.ts +19 -0
  307. package/dist/connectors/telegram/telegramCallGuard.d.ts.map +1 -0
  308. package/dist/connectors/telegram/telegramCallGuard.js +35 -0
  309. package/dist/connectors/telegram/telegramCallGuard.js.map +1 -0
  310. package/dist/connectors/telegram/timezonePicker.d.ts +85 -0
  311. package/dist/connectors/telegram/timezonePicker.d.ts.map +1 -0
  312. package/dist/connectors/telegram/timezonePicker.js +142 -0
  313. package/dist/connectors/telegram/timezonePicker.js.map +1 -0
  314. package/dist/connectors/telegram/updateDispatcher.d.ts +85 -0
  315. package/dist/connectors/telegram/updateDispatcher.d.ts.map +1 -0
  316. package/dist/connectors/telegram/updateDispatcher.js +159 -0
  317. package/dist/connectors/telegram/updateDispatcher.js.map +1 -0
  318. package/dist/connectors/test/connector.d.ts +52 -0
  319. package/dist/connectors/test/connector.d.ts.map +1 -0
  320. package/dist/connectors/test/connector.js +143 -0
  321. package/dist/connectors/test/connector.js.map +1 -0
  322. package/dist/connectors/test/sessionKeyCodec.d.ts +25 -0
  323. package/dist/connectors/test/sessionKeyCodec.d.ts.map +1 -0
  324. package/dist/connectors/test/sessionKeyCodec.js +50 -0
  325. package/dist/connectors/test/sessionKeyCodec.js.map +1 -0
  326. package/dist/diagLog.d.ts +6 -0
  327. package/dist/diagLog.d.ts.map +1 -0
  328. package/dist/diagLog.js +58 -0
  329. package/dist/diagLog.js.map +1 -0
  330. package/dist/effortLevels.d.ts +68 -0
  331. package/dist/effortLevels.d.ts.map +1 -0
  332. package/dist/effortLevels.js +114 -0
  333. package/dist/effortLevels.js.map +1 -0
  334. package/dist/folderName.d.ts +42 -0
  335. package/dist/folderName.d.ts.map +1 -0
  336. package/dist/folderName.js +51 -0
  337. package/dist/folderName.js.map +1 -0
  338. package/dist/i18n/de.d.ts +2 -0
  339. package/dist/i18n/de.d.ts.map +1 -0
  340. package/dist/i18n/de.js +665 -0
  341. package/dist/i18n/de.js.map +1 -0
  342. package/dist/i18n/en.d.ts +7 -0
  343. package/dist/i18n/en.d.ts.map +1 -0
  344. package/dist/i18n/en.js +694 -0
  345. package/dist/i18n/en.js.map +1 -0
  346. package/dist/i18n/es.d.ts +2 -0
  347. package/dist/i18n/es.d.ts.map +1 -0
  348. package/dist/i18n/es.js +665 -0
  349. package/dist/i18n/es.js.map +1 -0
  350. package/dist/i18n/fr.d.ts +2 -0
  351. package/dist/i18n/fr.d.ts.map +1 -0
  352. package/dist/i18n/fr.js +665 -0
  353. package/dist/i18n/fr.js.map +1 -0
  354. package/dist/i18n/hi.d.ts +2 -0
  355. package/dist/i18n/hi.d.ts.map +1 -0
  356. package/dist/i18n/hi.js +665 -0
  357. package/dist/i18n/hi.js.map +1 -0
  358. package/dist/i18n/ja.d.ts +2 -0
  359. package/dist/i18n/ja.d.ts.map +1 -0
  360. package/dist/i18n/ja.js +665 -0
  361. package/dist/i18n/ja.js.map +1 -0
  362. package/dist/i18n/ka.d.ts +2 -0
  363. package/dist/i18n/ka.d.ts.map +1 -0
  364. package/dist/i18n/ka.js +665 -0
  365. package/dist/i18n/ka.js.map +1 -0
  366. package/dist/i18n/pt.d.ts +2 -0
  367. package/dist/i18n/pt.d.ts.map +1 -0
  368. package/dist/i18n/pt.js +665 -0
  369. package/dist/i18n/pt.js.map +1 -0
  370. package/dist/i18n/ru.d.ts +6 -0
  371. package/dist/i18n/ru.d.ts.map +1 -0
  372. package/dist/i18n/ru.js +668 -0
  373. package/dist/i18n/ru.js.map +1 -0
  374. package/dist/i18n/uk.d.ts +8 -0
  375. package/dist/i18n/uk.d.ts.map +1 -0
  376. package/dist/i18n/uk.js +670 -0
  377. package/dist/i18n/uk.js.map +1 -0
  378. package/dist/i18n/uz.d.ts +2 -0
  379. package/dist/i18n/uz.d.ts.map +1 -0
  380. package/dist/i18n/uz.js +665 -0
  381. package/dist/i18n/uz.js.map +1 -0
  382. package/dist/i18n/zh.d.ts +2 -0
  383. package/dist/i18n/zh.d.ts.map +1 -0
  384. package/dist/i18n/zh.js +665 -0
  385. package/dist/i18n/zh.js.map +1 -0
  386. package/dist/i18n.d.ts +115 -0
  387. package/dist/i18n.d.ts.map +1 -0
  388. package/dist/i18n.js +233 -0
  389. package/dist/i18n.js.map +1 -0
  390. package/dist/index.d.ts +3 -0
  391. package/dist/index.d.ts.map +1 -0
  392. package/dist/index.js +10 -0
  393. package/dist/index.js.map +1 -0
  394. package/dist/installManager.d.ts +99 -0
  395. package/dist/installManager.d.ts.map +1 -0
  396. package/dist/installManager.js +943 -0
  397. package/dist/installManager.js.map +1 -0
  398. package/dist/instanceLock.d.ts +161 -0
  399. package/dist/instanceLock.d.ts.map +1 -0
  400. package/dist/instanceLock.js +388 -0
  401. package/dist/instanceLock.js.map +1 -0
  402. package/dist/mcpConfig.d.ts +76 -0
  403. package/dist/mcpConfig.d.ts.map +1 -0
  404. package/dist/mcpConfig.js +270 -0
  405. package/dist/mcpConfig.js.map +1 -0
  406. package/dist/openCodeOpenQuestion.d.ts +44 -0
  407. package/dist/openCodeOpenQuestion.d.ts.map +1 -0
  408. package/dist/openCodeOpenQuestion.js +64 -0
  409. package/dist/openCodeOpenQuestion.js.map +1 -0
  410. package/dist/openCodeQuestionFlow.d.ts +105 -0
  411. package/dist/openCodeQuestionFlow.d.ts.map +1 -0
  412. package/dist/openCodeQuestionFlow.js +143 -0
  413. package/dist/openCodeQuestionFlow.js.map +1 -0
  414. package/dist/openCodeSessionRouting.d.ts +133 -0
  415. package/dist/openCodeSessionRouting.d.ts.map +1 -0
  416. package/dist/openCodeSessionRouting.js +253 -0
  417. package/dist/openCodeSessionRouting.js.map +1 -0
  418. package/dist/openCodeSessionTitle.d.ts +50 -0
  419. package/dist/openCodeSessionTitle.d.ts.map +1 -0
  420. package/dist/openCodeSessionTitle.js +84 -0
  421. package/dist/openCodeSessionTitle.js.map +1 -0
  422. package/dist/outputTrace.d.ts +108 -0
  423. package/dist/outputTrace.d.ts.map +1 -0
  424. package/dist/outputTrace.js +430 -0
  425. package/dist/outputTrace.js.map +1 -0
  426. package/dist/pendingQuestionRepost.d.ts +47 -0
  427. package/dist/pendingQuestionRepost.d.ts.map +1 -0
  428. package/dist/pendingQuestionRepost.js +29 -0
  429. package/dist/pendingQuestionRepost.js.map +1 -0
  430. package/dist/pinnedStatus.d.ts +52 -0
  431. package/dist/pinnedStatus.d.ts.map +1 -0
  432. package/dist/pinnedStatus.js +36 -0
  433. package/dist/pinnedStatus.js.map +1 -0
  434. package/dist/platform/answerSink.d.ts +93 -0
  435. package/dist/platform/answerSink.d.ts.map +1 -0
  436. package/dist/platform/answerSink.js +31 -0
  437. package/dist/platform/answerSink.js.map +1 -0
  438. package/dist/platform/capabilityFallback.d.ts +39 -0
  439. package/dist/platform/capabilityFallback.d.ts.map +1 -0
  440. package/dist/platform/capabilityFallback.js +55 -0
  441. package/dist/platform/capabilityFallback.js.map +1 -0
  442. package/dist/platform/commandRouter.d.ts +51 -0
  443. package/dist/platform/commandRouter.d.ts.map +1 -0
  444. package/dist/platform/commandRouter.js +53 -0
  445. package/dist/platform/commandRouter.js.map +1 -0
  446. package/dist/platform/connectorSet.d.ts +39 -0
  447. package/dist/platform/connectorSet.d.ts.map +1 -0
  448. package/dist/platform/connectorSet.js +55 -0
  449. package/dist/platform/connectorSet.js.map +1 -0
  450. package/dist/platform/inbound.d.ts +147 -0
  451. package/dist/platform/inbound.d.ts.map +1 -0
  452. package/dist/platform/inbound.js +18 -0
  453. package/dist/platform/inbound.js.map +1 -0
  454. package/dist/platform/outbound.d.ts +225 -0
  455. package/dist/platform/outbound.d.ts.map +1 -0
  456. package/dist/platform/outbound.js +30 -0
  457. package/dist/platform/outbound.js.map +1 -0
  458. package/dist/platform/unservedStateGuard.d.ts +27 -0
  459. package/dist/platform/unservedStateGuard.d.ts.map +1 -0
  460. package/dist/platform/unservedStateGuard.js +42 -0
  461. package/dist/platform/unservedStateGuard.js.map +1 -0
  462. package/dist/postToSession.d.ts +94 -0
  463. package/dist/postToSession.d.ts.map +1 -0
  464. package/dist/postToSession.js +56 -0
  465. package/dist/postToSession.js.map +1 -0
  466. package/dist/progressLine.d.ts +180 -0
  467. package/dist/progressLine.d.ts.map +1 -0
  468. package/dist/progressLine.js +293 -0
  469. package/dist/progressLine.js.map +1 -0
  470. package/dist/rateLimiter.d.ts +246 -0
  471. package/dist/rateLimiter.d.ts.map +1 -0
  472. package/dist/rateLimiter.js +555 -0
  473. package/dist/rateLimiter.js.map +1 -0
  474. package/dist/requests/answerRequest.d.ts +57 -0
  475. package/dist/requests/answerRequest.d.ts.map +1 -0
  476. package/dist/requests/answerRequest.js +96 -0
  477. package/dist/requests/answerRequest.js.map +1 -0
  478. package/dist/requests/answerTail.d.ts +83 -0
  479. package/dist/requests/answerTail.d.ts.map +1 -0
  480. package/dist/requests/answerTail.js +102 -0
  481. package/dist/requests/answerTail.js.map +1 -0
  482. package/dist/requests/limitWaitAnswer.d.ts +87 -0
  483. package/dist/requests/limitWaitAnswer.d.ts.map +1 -0
  484. package/dist/requests/limitWaitAnswer.js +83 -0
  485. package/dist/requests/limitWaitAnswer.js.map +1 -0
  486. package/dist/requests/requestGroup.d.ts +44 -0
  487. package/dist/requests/requestGroup.d.ts.map +1 -0
  488. package/dist/requests/requestGroup.js +63 -0
  489. package/dist/requests/requestGroup.js.map +1 -0
  490. package/dist/requests/requestHeader.d.ts +70 -0
  491. package/dist/requests/requestHeader.d.ts.map +1 -0
  492. package/dist/requests/requestHeader.js +83 -0
  493. package/dist/requests/requestHeader.js.map +1 -0
  494. package/dist/requests/requestLedger.d.ts +217 -0
  495. package/dist/requests/requestLedger.d.ts.map +1 -0
  496. package/dist/requests/requestLedger.js +468 -0
  497. package/dist/requests/requestLedger.js.map +1 -0
  498. package/dist/requests/sessionTurnProbe.d.ts +52 -0
  499. package/dist/requests/sessionTurnProbe.d.ts.map +1 -0
  500. package/dist/requests/sessionTurnProbe.js +29 -0
  501. package/dist/requests/sessionTurnProbe.js.map +1 -0
  502. package/dist/requests/types.d.ts +181 -0
  503. package/dist/requests/types.d.ts.map +1 -0
  504. package/dist/requests/types.js +9 -0
  505. package/dist/requests/types.js.map +1 -0
  506. package/dist/requests/wakeUpEngine.d.ts +160 -0
  507. package/dist/requests/wakeUpEngine.d.ts.map +1 -0
  508. package/dist/requests/wakeUpEngine.js +399 -0
  509. package/dist/requests/wakeUpEngine.js.map +1 -0
  510. package/dist/requests/wakeUpRules.d.ts +151 -0
  511. package/dist/requests/wakeUpRules.d.ts.map +1 -0
  512. package/dist/requests/wakeUpRules.js +167 -0
  513. package/dist/requests/wakeUpRules.js.map +1 -0
  514. package/dist/resumeContext.d.ts +87 -0
  515. package/dist/resumeContext.d.ts.map +1 -0
  516. package/dist/resumeContext.js +114 -0
  517. package/dist/resumeContext.js.map +1 -0
  518. package/dist/scheduler/checkRun.d.ts +95 -0
  519. package/dist/scheduler/checkRun.d.ts.map +1 -0
  520. package/dist/scheduler/checkRun.js +172 -0
  521. package/dist/scheduler/checkRun.js.map +1 -0
  522. package/dist/scheduler/delivery.d.ts +99 -0
  523. package/dist/scheduler/delivery.d.ts.map +1 -0
  524. package/dist/scheduler/delivery.js +212 -0
  525. package/dist/scheduler/delivery.js.map +1 -0
  526. package/dist/scheduler/deliveryKind.d.ts +29 -0
  527. package/dist/scheduler/deliveryKind.d.ts.map +1 -0
  528. package/dist/scheduler/deliveryKind.js +39 -0
  529. package/dist/scheduler/deliveryKind.js.map +1 -0
  530. package/dist/scheduler/directoryThreads.d.ts +19 -0
  531. package/dist/scheduler/directoryThreads.d.ts.map +1 -0
  532. package/dist/scheduler/directoryThreads.js +28 -0
  533. package/dist/scheduler/directoryThreads.js.map +1 -0
  534. package/dist/scheduler/engine.d.ts +77 -0
  535. package/dist/scheduler/engine.d.ts.map +1 -0
  536. package/dist/scheduler/engine.js +337 -0
  537. package/dist/scheduler/engine.js.map +1 -0
  538. package/dist/scheduler/injection.d.ts +102 -0
  539. package/dist/scheduler/injection.d.ts.map +1 -0
  540. package/dist/scheduler/injection.js +122 -0
  541. package/dist/scheduler/injection.js.map +1 -0
  542. package/dist/scheduler/mcpBoot.d.ts +65 -0
  543. package/dist/scheduler/mcpBoot.d.ts.map +1 -0
  544. package/dist/scheduler/mcpBoot.js +60 -0
  545. package/dist/scheduler/mcpBoot.js.map +1 -0
  546. package/dist/scheduler/mcpSurface.d.ts +363 -0
  547. package/dist/scheduler/mcpSurface.d.ts.map +1 -0
  548. package/dist/scheduler/mcpSurface.js +1297 -0
  549. package/dist/scheduler/mcpSurface.js.map +1 -0
  550. package/dist/scheduler/rebindResume.d.ts +27 -0
  551. package/dist/scheduler/rebindResume.d.ts.map +1 -0
  552. package/dist/scheduler/rebindResume.js +17 -0
  553. package/dist/scheduler/rebindResume.js.map +1 -0
  554. package/dist/scheduler/recurrence.d.ts +58 -0
  555. package/dist/scheduler/recurrence.d.ts.map +1 -0
  556. package/dist/scheduler/recurrence.js +210 -0
  557. package/dist/scheduler/recurrence.js.map +1 -0
  558. package/dist/scheduler/runLedger.d.ts +59 -0
  559. package/dist/scheduler/runLedger.d.ts.map +1 -0
  560. package/dist/scheduler/runLedger.js +54 -0
  561. package/dist/scheduler/runLedger.js.map +1 -0
  562. package/dist/scheduler/store.d.ts +97 -0
  563. package/dist/scheduler/store.d.ts.map +1 -0
  564. package/dist/scheduler/store.js +124 -0
  565. package/dist/scheduler/store.js.map +1 -0
  566. package/dist/scheduler/timezoneRecompute.d.ts +61 -0
  567. package/dist/scheduler/timezoneRecompute.d.ts.map +1 -0
  568. package/dist/scheduler/timezoneRecompute.js +46 -0
  569. package/dist/scheduler/timezoneRecompute.js.map +1 -0
  570. package/dist/scheduler/types.d.ts +139 -0
  571. package/dist/scheduler/types.d.ts.map +1 -0
  572. package/dist/scheduler/types.js +8 -0
  573. package/dist/scheduler/types.js.map +1 -0
  574. package/dist/sendErrorClassifier.d.ts +45 -0
  575. package/dist/sendErrorClassifier.d.ts.map +1 -0
  576. package/dist/sendErrorClassifier.js +65 -0
  577. package/dist/sendErrorClassifier.js.map +1 -0
  578. package/dist/sessionKey.d.ts +136 -0
  579. package/dist/sessionKey.d.ts.map +1 -0
  580. package/dist/sessionKey.js +153 -0
  581. package/dist/sessionKey.js.map +1 -0
  582. package/dist/sessionPick.d.ts +42 -0
  583. package/dist/sessionPick.d.ts.map +1 -0
  584. package/dist/sessionPick.js +39 -0
  585. package/dist/sessionPick.js.map +1 -0
  586. package/dist/shutdown.d.ts +126 -0
  587. package/dist/shutdown.d.ts.map +1 -0
  588. package/dist/shutdown.js +164 -0
  589. package/dist/shutdown.js.map +1 -0
  590. package/dist/startupPromptBuffer.d.ts +85 -0
  591. package/dist/startupPromptBuffer.d.ts.map +1 -0
  592. package/dist/startupPromptBuffer.js +123 -0
  593. package/dist/startupPromptBuffer.js.map +1 -0
  594. package/dist/state.d.ts +1416 -0
  595. package/dist/state.d.ts.map +1 -0
  596. package/dist/state.js +2128 -0
  597. package/dist/state.js.map +1 -0
  598. package/dist/threadContextPreamble.d.ts +89 -0
  599. package/dist/threadContextPreamble.d.ts.map +1 -0
  600. package/dist/threadContextPreamble.js +102 -0
  601. package/dist/threadContextPreamble.js.map +1 -0
  602. package/dist/threadRouting.d.ts +164 -0
  603. package/dist/threadRouting.d.ts.map +1 -0
  604. package/dist/threadRouting.js +182 -0
  605. package/dist/threadRouting.js.map +1 -0
  606. package/dist/types.d.ts +1022 -0
  607. package/dist/types.d.ts.map +1 -0
  608. package/dist/types.js +3 -0
  609. package/dist/types.js.map +1 -0
  610. package/dist/utils/abortableFifo.d.ts +10 -0
  611. package/dist/utils/abortableFifo.d.ts.map +1 -0
  612. package/dist/utils/abortableFifo.js +55 -0
  613. package/dist/utils/abortableFifo.js.map +1 -0
  614. package/dist/utils/adoptedToolList.d.ts +27 -0
  615. package/dist/utils/adoptedToolList.d.ts.map +1 -0
  616. package/dist/utils/adoptedToolList.js +22 -0
  617. package/dist/utils/adoptedToolList.js.map +1 -0
  618. package/dist/utils/agentEnvironment.d.ts +42 -0
  619. package/dist/utils/agentEnvironment.d.ts.map +1 -0
  620. package/dist/utils/agentEnvironment.js +122 -0
  621. package/dist/utils/agentEnvironment.js.map +1 -0
  622. package/dist/utils/ansiClean.d.ts +11 -0
  623. package/dist/utils/ansiClean.d.ts.map +1 -0
  624. package/dist/utils/ansiClean.js +139 -0
  625. package/dist/utils/ansiClean.js.map +1 -0
  626. package/dist/utils/autoContinueOnLimit.d.ts +56 -0
  627. package/dist/utils/autoContinueOnLimit.d.ts.map +1 -0
  628. package/dist/utils/autoContinueOnLimit.js +79 -0
  629. package/dist/utils/autoContinueOnLimit.js.map +1 -0
  630. package/dist/utils/canonicalPathContainment.d.ts +7 -0
  631. package/dist/utils/canonicalPathContainment.d.ts.map +1 -0
  632. package/dist/utils/canonicalPathContainment.js +48 -0
  633. package/dist/utils/canonicalPathContainment.js.map +1 -0
  634. package/dist/utils/claudeAccountPickerPlan.d.ts +85 -0
  635. package/dist/utils/claudeAccountPickerPlan.d.ts.map +1 -0
  636. package/dist/utils/claudeAccountPickerPlan.js +123 -0
  637. package/dist/utils/claudeAccountPickerPlan.js.map +1 -0
  638. package/dist/utils/claudeAuthLogin.d.ts +71 -0
  639. package/dist/utils/claudeAuthLogin.d.ts.map +1 -0
  640. package/dist/utils/claudeAuthLogin.js +93 -0
  641. package/dist/utils/claudeAuthLogin.js.map +1 -0
  642. package/dist/utils/claudeChunkClassifier.d.ts +97 -0
  643. package/dist/utils/claudeChunkClassifier.d.ts.map +1 -0
  644. package/dist/utils/claudeChunkClassifier.js +254 -0
  645. package/dist/utils/claudeChunkClassifier.js.map +1 -0
  646. package/dist/utils/claudeCodeVersion.d.ts +31 -0
  647. package/dist/utils/claudeCodeVersion.d.ts.map +1 -0
  648. package/dist/utils/claudeCodeVersion.js +62 -0
  649. package/dist/utils/claudeCodeVersion.js.map +1 -0
  650. package/dist/utils/claudeCompactHook.d.ts +64 -0
  651. package/dist/utils/claudeCompactHook.d.ts.map +1 -0
  652. package/dist/utils/claudeCompactHook.js +98 -0
  653. package/dist/utils/claudeCompactHook.js.map +1 -0
  654. package/dist/utils/claudeLimitSwitch.d.ts +40 -0
  655. package/dist/utils/claudeLimitSwitch.d.ts.map +1 -0
  656. package/dist/utils/claudeLimitSwitch.js +54 -0
  657. package/dist/utils/claudeLimitSwitch.js.map +1 -0
  658. package/dist/utils/claudeLivenessAction.d.ts +208 -0
  659. package/dist/utils/claudeLivenessAction.d.ts.map +1 -0
  660. package/dist/utils/claudeLivenessAction.js +135 -0
  661. package/dist/utils/claudeLivenessAction.js.map +1 -0
  662. package/dist/utils/claudeMcpHeal.d.ts +92 -0
  663. package/dist/utils/claudeMcpHeal.d.ts.map +1 -0
  664. package/dist/utils/claudeMcpHeal.js +91 -0
  665. package/dist/utils/claudeMcpHeal.js.map +1 -0
  666. package/dist/utils/claudeProfileUsageLines.d.ts +15 -0
  667. package/dist/utils/claudeProfileUsageLines.d.ts.map +1 -0
  668. package/dist/utils/claudeProfileUsageLines.js +42 -0
  669. package/dist/utils/claudeProfileUsageLines.js.map +1 -0
  670. package/dist/utils/claudeProfiles.d.ts +117 -0
  671. package/dist/utils/claudeProfiles.d.ts.map +1 -0
  672. package/dist/utils/claudeProfiles.js +285 -0
  673. package/dist/utils/claudeProfiles.js.map +1 -0
  674. package/dist/utils/claudeRelayRouting.d.ts +86 -0
  675. package/dist/utils/claudeRelayRouting.d.ts.map +1 -0
  676. package/dist/utils/claudeRelayRouting.js +159 -0
  677. package/dist/utils/claudeRelayRouting.js.map +1 -0
  678. package/dist/utils/claudeRuntimeInfo.d.ts +26 -0
  679. package/dist/utils/claudeRuntimeInfo.d.ts.map +1 -0
  680. package/dist/utils/claudeRuntimeInfo.js +151 -0
  681. package/dist/utils/claudeRuntimeInfo.js.map +1 -0
  682. package/dist/utils/claudeScrapeShapes.d.ts +256 -0
  683. package/dist/utils/claudeScrapeShapes.d.ts.map +1 -0
  684. package/dist/utils/claudeScrapeShapes.js +290 -0
  685. package/dist/utils/claudeScrapeShapes.js.map +1 -0
  686. package/dist/utils/claudeSessionTitle.d.ts +27 -0
  687. package/dist/utils/claudeSessionTitle.d.ts.map +1 -0
  688. package/dist/utils/claudeSessionTitle.js +90 -0
  689. package/dist/utils/claudeSessionTitle.js.map +1 -0
  690. package/dist/utils/claudeStreamJson.d.ts +214 -0
  691. package/dist/utils/claudeStreamJson.d.ts.map +1 -0
  692. package/dist/utils/claudeStreamJson.js +364 -0
  693. package/dist/utils/claudeStreamJson.js.map +1 -0
  694. package/dist/utils/claudeSubagentTail.d.ts +93 -0
  695. package/dist/utils/claudeSubagentTail.d.ts.map +1 -0
  696. package/dist/utils/claudeSubagentTail.js +136 -0
  697. package/dist/utils/claudeSubagentTail.js.map +1 -0
  698. package/dist/utils/claudeUsage.d.ts +209 -0
  699. package/dist/utils/claudeUsage.d.ts.map +1 -0
  700. package/dist/utils/claudeUsage.js +413 -0
  701. package/dist/utils/claudeUsage.js.map +1 -0
  702. package/dist/utils/claudeUsageRefresher.d.ts +44 -0
  703. package/dist/utils/claudeUsageRefresher.d.ts.map +1 -0
  704. package/dist/utils/claudeUsageRefresher.js +95 -0
  705. package/dist/utils/claudeUsageRefresher.js.map +1 -0
  706. package/dist/utils/clearThreadOutputQueues.d.ts +43 -0
  707. package/dist/utils/clearThreadOutputQueues.d.ts.map +1 -0
  708. package/dist/utils/clearThreadOutputQueues.js +39 -0
  709. package/dist/utils/clearThreadOutputQueues.js.map +1 -0
  710. package/dist/utils/compactCommandRoute.d.ts +45 -0
  711. package/dist/utils/compactCommandRoute.d.ts.map +1 -0
  712. package/dist/utils/compactCommandRoute.js +36 -0
  713. package/dist/utils/compactCommandRoute.js.map +1 -0
  714. package/dist/utils/compactOnIdle.d.ts +329 -0
  715. package/dist/utils/compactOnIdle.d.ts.map +1 -0
  716. package/dist/utils/compactOnIdle.js +379 -0
  717. package/dist/utils/compactOnIdle.js.map +1 -0
  718. package/dist/utils/consoleFileTap.d.ts +51 -0
  719. package/dist/utils/consoleFileTap.d.ts.map +1 -0
  720. package/dist/utils/consoleFileTap.js +86 -0
  721. package/dist/utils/consoleFileTap.js.map +1 -0
  722. package/dist/utils/displayVerbosity.d.ts +44 -0
  723. package/dist/utils/displayVerbosity.d.ts.map +1 -0
  724. package/dist/utils/displayVerbosity.js +75 -0
  725. package/dist/utils/displayVerbosity.js.map +1 -0
  726. package/dist/utils/download.d.ts +72 -0
  727. package/dist/utils/download.d.ts.map +1 -0
  728. package/dist/utils/download.js +216 -0
  729. package/dist/utils/download.js.map +1 -0
  730. package/dist/utils/draftFinalize.d.ts +110 -0
  731. package/dist/utils/draftFinalize.d.ts.map +1 -0
  732. package/dist/utils/draftFinalize.js +100 -0
  733. package/dist/utils/draftFinalize.js.map +1 -0
  734. package/dist/utils/draftId.d.ts +36 -0
  735. package/dist/utils/draftId.d.ts.map +1 -0
  736. package/dist/utils/draftId.js +46 -0
  737. package/dist/utils/draftId.js.map +1 -0
  738. package/dist/utils/draftPacer.d.ts +72 -0
  739. package/dist/utils/draftPacer.d.ts.map +1 -0
  740. package/dist/utils/draftPacer.js +53 -0
  741. package/dist/utils/draftPacer.js.map +1 -0
  742. package/dist/utils/effortStartupKeystroke.d.ts +20 -0
  743. package/dist/utils/effortStartupKeystroke.d.ts.map +1 -0
  744. package/dist/utils/effortStartupKeystroke.js +28 -0
  745. package/dist/utils/effortStartupKeystroke.js.map +1 -0
  746. package/dist/utils/ensureSessionPlan.d.ts +70 -0
  747. package/dist/utils/ensureSessionPlan.d.ts.map +1 -0
  748. package/dist/utils/ensureSessionPlan.js +54 -0
  749. package/dist/utils/ensureSessionPlan.js.map +1 -0
  750. package/dist/utils/fallbackBridge.d.ts +32 -0
  751. package/dist/utils/fallbackBridge.d.ts.map +1 -0
  752. package/dist/utils/fallbackBridge.js +62 -0
  753. package/dist/utils/fallbackBridge.js.map +1 -0
  754. package/dist/utils/fallbackChain.d.ts +299 -0
  755. package/dist/utils/fallbackChain.d.ts.map +1 -0
  756. package/dist/utils/fallbackChain.js +542 -0
  757. package/dist/utils/fallbackChain.js.map +1 -0
  758. package/dist/utils/fileSendPlan.d.ts +217 -0
  759. package/dist/utils/fileSendPlan.d.ts.map +1 -0
  760. package/dist/utils/fileSendPlan.js +291 -0
  761. package/dist/utils/fileSendPlan.js.map +1 -0
  762. package/dist/utils/fileSendService.d.ts +94 -0
  763. package/dist/utils/fileSendService.d.ts.map +1 -0
  764. package/dist/utils/fileSendService.js +387 -0
  765. package/dist/utils/fileSendService.js.map +1 -0
  766. package/dist/utils/groupFinalizePlan.d.ts +38 -0
  767. package/dist/utils/groupFinalizePlan.d.ts.map +1 -0
  768. package/dist/utils/groupFinalizePlan.js +35 -0
  769. package/dist/utils/groupFinalizePlan.js.map +1 -0
  770. package/dist/utils/identicalOutputGuard.d.ts +83 -0
  771. package/dist/utils/identicalOutputGuard.d.ts.map +1 -0
  772. package/dist/utils/identicalOutputGuard.js +99 -0
  773. package/dist/utils/identicalOutputGuard.js.map +1 -0
  774. package/dist/utils/isoTimestamp.d.ts +16 -0
  775. package/dist/utils/isoTimestamp.d.ts.map +1 -0
  776. package/dist/utils/isoTimestamp.js +34 -0
  777. package/dist/utils/isoTimestamp.js.map +1 -0
  778. package/dist/utils/jsonStreamBusyWatchdog.d.ts +130 -0
  779. package/dist/utils/jsonStreamBusyWatchdog.d.ts.map +1 -0
  780. package/dist/utils/jsonStreamBusyWatchdog.js +122 -0
  781. package/dist/utils/jsonStreamBusyWatchdog.js.map +1 -0
  782. package/dist/utils/jsonStreamHost.d.ts +238 -0
  783. package/dist/utils/jsonStreamHost.d.ts.map +1 -0
  784. package/dist/utils/jsonStreamHost.js +438 -0
  785. package/dist/utils/jsonStreamHost.js.map +1 -0
  786. package/dist/utils/keyedTransitionQueue.d.ts +18 -0
  787. package/dist/utils/keyedTransitionQueue.d.ts.map +1 -0
  788. package/dist/utils/keyedTransitionQueue.js +34 -0
  789. package/dist/utils/keyedTransitionQueue.js.map +1 -0
  790. package/dist/utils/limitEpisodeRecovery.d.ts +92 -0
  791. package/dist/utils/limitEpisodeRecovery.d.ts.map +1 -0
  792. package/dist/utils/limitEpisodeRecovery.js +133 -0
  793. package/dist/utils/limitEpisodeRecovery.js.map +1 -0
  794. package/dist/utils/limitHeldPromptQueue.d.ts +48 -0
  795. package/dist/utils/limitHeldPromptQueue.d.ts.map +1 -0
  796. package/dist/utils/limitHeldPromptQueue.js +59 -0
  797. package/dist/utils/limitHeldPromptQueue.js.map +1 -0
  798. package/dist/utils/limitHeldPrompts.d.ts +58 -0
  799. package/dist/utils/limitHeldPrompts.d.ts.map +1 -0
  800. package/dist/utils/limitHeldPrompts.js +65 -0
  801. package/dist/utils/limitHeldPrompts.js.map +1 -0
  802. package/dist/utils/linkPreviewSuppression.d.ts +18 -0
  803. package/dist/utils/linkPreviewSuppression.d.ts.map +1 -0
  804. package/dist/utils/linkPreviewSuppression.js +37 -0
  805. package/dist/utils/linkPreviewSuppression.js.map +1 -0
  806. package/dist/utils/localClock.d.ts +15 -0
  807. package/dist/utils/localClock.d.ts.map +1 -0
  808. package/dist/utils/localClock.js +29 -0
  809. package/dist/utils/localClock.js.map +1 -0
  810. package/dist/utils/markdownTableRender.d.ts +83 -0
  811. package/dist/utils/markdownTableRender.d.ts.map +1 -0
  812. package/dist/utils/markdownTableRender.js +298 -0
  813. package/dist/utils/markdownTableRender.js.map +1 -0
  814. package/dist/utils/mediaGroupCollector.d.ts +51 -0
  815. package/dist/utils/mediaGroupCollector.d.ts.map +1 -0
  816. package/dist/utils/mediaGroupCollector.js +90 -0
  817. package/dist/utils/mediaGroupCollector.js.map +1 -0
  818. package/dist/utils/messageSendService.d.ts +136 -0
  819. package/dist/utils/messageSendService.d.ts.map +1 -0
  820. package/dist/utils/messageSendService.js +165 -0
  821. package/dist/utils/messageSendService.js.map +1 -0
  822. package/dist/utils/minutesOverride.d.ts +7 -0
  823. package/dist/utils/minutesOverride.d.ts.map +1 -0
  824. package/dist/utils/minutesOverride.js +16 -0
  825. package/dist/utils/minutesOverride.js.map +1 -0
  826. package/dist/utils/modelPickerPlan.d.ts +119 -0
  827. package/dist/utils/modelPickerPlan.d.ts.map +1 -0
  828. package/dist/utils/modelPickerPlan.js +171 -0
  829. package/dist/utils/modelPickerPlan.js.map +1 -0
  830. package/dist/utils/modelRecentPlan.d.ts +56 -0
  831. package/dist/utils/modelRecentPlan.d.ts.map +1 -0
  832. package/dist/utils/modelRecentPlan.js +107 -0
  833. package/dist/utils/modelRecentPlan.js.map +1 -0
  834. package/dist/utils/modelSetReplyDecision.d.ts +67 -0
  835. package/dist/utils/modelSetReplyDecision.d.ts.map +1 -0
  836. package/dist/utils/modelSetReplyDecision.js +27 -0
  837. package/dist/utils/modelSetReplyDecision.js.map +1 -0
  838. package/dist/utils/openCodeAuthLogin.d.ts +181 -0
  839. package/dist/utils/openCodeAuthLogin.d.ts.map +1 -0
  840. package/dist/utils/openCodeAuthLogin.js +393 -0
  841. package/dist/utils/openCodeAuthLogin.js.map +1 -0
  842. package/dist/utils/openCodeCompactPlugin.d.ts +81 -0
  843. package/dist/utils/openCodeCompactPlugin.d.ts.map +1 -0
  844. package/dist/utils/openCodeCompactPlugin.js +146 -0
  845. package/dist/utils/openCodeCompactPlugin.js.map +1 -0
  846. package/dist/utils/openCodeTurnActivity.d.ts +67 -0
  847. package/dist/utils/openCodeTurnActivity.d.ts.map +1 -0
  848. package/dist/utils/openCodeTurnActivity.js +27 -0
  849. package/dist/utils/openCodeTurnActivity.js.map +1 -0
  850. package/dist/utils/outputDebounce.d.ts +24 -0
  851. package/dist/utils/outputDebounce.d.ts.map +1 -0
  852. package/dist/utils/outputDebounce.js +30 -0
  853. package/dist/utils/outputDebounce.js.map +1 -0
  854. package/dist/utils/outputFlushTiming.d.ts +54 -0
  855. package/dist/utils/outputFlushTiming.d.ts.map +1 -0
  856. package/dist/utils/outputFlushTiming.js +48 -0
  857. package/dist/utils/outputFlushTiming.js.map +1 -0
  858. package/dist/utils/paginateList.d.ts +25 -0
  859. package/dist/utils/paginateList.d.ts.map +1 -0
  860. package/dist/utils/paginateList.js +32 -0
  861. package/dist/utils/paginateList.js.map +1 -0
  862. package/dist/utils/paneDiff.d.ts +55 -0
  863. package/dist/utils/paneDiff.d.ts.map +1 -0
  864. package/dist/utils/paneDiff.js +88 -0
  865. package/dist/utils/paneDiff.js.map +1 -0
  866. package/dist/utils/paneResizeGuard.d.ts +69 -0
  867. package/dist/utils/paneResizeGuard.d.ts.map +1 -0
  868. package/dist/utils/paneResizeGuard.js +91 -0
  869. package/dist/utils/paneResizeGuard.js.map +1 -0
  870. package/dist/utils/persistAdapterSessionIds.d.ts +39 -0
  871. package/dist/utils/persistAdapterSessionIds.d.ts.map +1 -0
  872. package/dist/utils/persistAdapterSessionIds.js +28 -0
  873. package/dist/utils/persistAdapterSessionIds.js.map +1 -0
  874. package/dist/utils/pinnedBannerSkipDecision.d.ts +44 -0
  875. package/dist/utils/pinnedBannerSkipDecision.d.ts.map +1 -0
  876. package/dist/utils/pinnedBannerSkipDecision.js +20 -0
  877. package/dist/utils/pinnedBannerSkipDecision.js.map +1 -0
  878. package/dist/utils/pollBackoff.d.ts +45 -0
  879. package/dist/utils/pollBackoff.d.ts.map +1 -0
  880. package/dist/utils/pollBackoff.js +44 -0
  881. package/dist/utils/pollBackoff.js.map +1 -0
  882. package/dist/utils/promptDelivery.d.ts +46 -0
  883. package/dist/utils/promptDelivery.d.ts.map +1 -0
  884. package/dist/utils/promptDelivery.js +49 -0
  885. package/dist/utils/promptDelivery.js.map +1 -0
  886. package/dist/utils/providerDisconnectPlan.d.ts +82 -0
  887. package/dist/utils/providerDisconnectPlan.d.ts.map +1 -0
  888. package/dist/utils/providerDisconnectPlan.js +110 -0
  889. package/dist/utils/providerDisconnectPlan.js.map +1 -0
  890. package/dist/utils/rateLimitLog.d.ts +48 -0
  891. package/dist/utils/rateLimitLog.d.ts.map +1 -0
  892. package/dist/utils/rateLimitLog.js +43 -0
  893. package/dist/utils/rateLimitLog.js.map +1 -0
  894. package/dist/utils/recentRelayWindow.d.ts +165 -0
  895. package/dist/utils/recentRelayWindow.d.ts.map +1 -0
  896. package/dist/utils/recentRelayWindow.js +284 -0
  897. package/dist/utils/recentRelayWindow.js.map +1 -0
  898. package/dist/utils/recvPreviewRedaction.d.ts +23 -0
  899. package/dist/utils/recvPreviewRedaction.d.ts.map +1 -0
  900. package/dist/utils/recvPreviewRedaction.js +39 -0
  901. package/dist/utils/recvPreviewRedaction.js.map +1 -0
  902. package/dist/utils/reminderFlow.d.ts +148 -0
  903. package/dist/utils/reminderFlow.d.ts.map +1 -0
  904. package/dist/utils/reminderFlow.js +122 -0
  905. package/dist/utils/reminderFlow.js.map +1 -0
  906. package/dist/utils/reminderScheduleText.d.ts +87 -0
  907. package/dist/utils/reminderScheduleText.d.ts.map +1 -0
  908. package/dist/utils/reminderScheduleText.js +135 -0
  909. package/dist/utils/reminderScheduleText.js.map +1 -0
  910. package/dist/utils/reminderWizard.d.ts +710 -0
  911. package/dist/utils/reminderWizard.d.ts.map +1 -0
  912. package/dist/utils/reminderWizard.js +1164 -0
  913. package/dist/utils/reminderWizard.js.map +1 -0
  914. package/dist/utils/replyQuote.d.ts +111 -0
  915. package/dist/utils/replyQuote.d.ts.map +1 -0
  916. package/dist/utils/replyQuote.js +122 -0
  917. package/dist/utils/replyQuote.js.map +1 -0
  918. package/dist/utils/resolveBinary.d.ts +25 -0
  919. package/dist/utils/resolveBinary.d.ts.map +1 -0
  920. package/dist/utils/resolveBinary.js +99 -0
  921. package/dist/utils/resolveBinary.js.map +1 -0
  922. package/dist/utils/retryAfterHeader.d.ts +7 -0
  923. package/dist/utils/retryAfterHeader.d.ts.map +1 -0
  924. package/dist/utils/retryAfterHeader.js +17 -0
  925. package/dist/utils/retryAfterHeader.js.map +1 -0
  926. package/dist/utils/rotatingJsonlFile.d.ts +40 -0
  927. package/dist/utils/rotatingJsonlFile.d.ts.map +1 -0
  928. package/dist/utils/rotatingJsonlFile.js +106 -0
  929. package/dist/utils/rotatingJsonlFile.js.map +1 -0
  930. package/dist/utils/rotatingLogFile.d.ts +25 -0
  931. package/dist/utils/rotatingLogFile.d.ts.map +1 -0
  932. package/dist/utils/rotatingLogFile.js +74 -0
  933. package/dist/utils/rotatingLogFile.js.map +1 -0
  934. package/dist/utils/sendRateTracker.d.ts +59 -0
  935. package/dist/utils/sendRateTracker.d.ts.map +1 -0
  936. package/dist/utils/sendRateTracker.js +144 -0
  937. package/dist/utils/sendRateTracker.js.map +1 -0
  938. package/dist/utils/serialQueue.d.ts +5 -0
  939. package/dist/utils/serialQueue.d.ts.map +1 -0
  940. package/dist/utils/serialQueue.js +14 -0
  941. package/dist/utils/serialQueue.js.map +1 -0
  942. package/dist/utils/sseStreamLifecycle.d.ts +32 -0
  943. package/dist/utils/sseStreamLifecycle.d.ts.map +1 -0
  944. package/dist/utils/sseStreamLifecycle.js +41 -0
  945. package/dist/utils/sseStreamLifecycle.js.map +1 -0
  946. package/dist/utils/startupReadiness.d.ts +119 -0
  947. package/dist/utils/startupReadiness.d.ts.map +1 -0
  948. package/dist/utils/startupReadiness.js +148 -0
  949. package/dist/utils/startupReadiness.js.map +1 -0
  950. package/dist/utils/statusFlushDecision.d.ts +18 -0
  951. package/dist/utils/statusFlushDecision.d.ts.map +1 -0
  952. package/dist/utils/statusFlushDecision.js +53 -0
  953. package/dist/utils/statusFlushDecision.js.map +1 -0
  954. package/dist/utils/subagentRender.d.ts +52 -0
  955. package/dist/utils/subagentRender.d.ts.map +1 -0
  956. package/dist/utils/subagentRender.js +66 -0
  957. package/dist/utils/subagentRender.js.map +1 -0
  958. package/dist/utils/subagentStatusRender.d.ts +90 -0
  959. package/dist/utils/subagentStatusRender.d.ts.map +1 -0
  960. package/dist/utils/subagentStatusRender.js +124 -0
  961. package/dist/utils/subagentStatusRender.js.map +1 -0
  962. package/dist/utils/telegramError.d.ts +2 -0
  963. package/dist/utils/telegramError.d.ts.map +1 -0
  964. package/dist/utils/telegramError.js +16 -0
  965. package/dist/utils/telegramError.js.map +1 -0
  966. package/dist/utils/terminalEmitPlan.d.ts +74 -0
  967. package/dist/utils/terminalEmitPlan.d.ts.map +1 -0
  968. package/dist/utils/terminalEmitPlan.js +86 -0
  969. package/dist/utils/terminalEmitPlan.js.map +1 -0
  970. package/dist/utils/thinkingRender.d.ts +74 -0
  971. package/dist/utils/thinkingRender.d.ts.map +1 -0
  972. package/dist/utils/thinkingRender.js +85 -0
  973. package/dist/utils/thinkingRender.js.map +1 -0
  974. package/dist/utils/threadStatusReport.d.ts +79 -0
  975. package/dist/utils/threadStatusReport.d.ts.map +1 -0
  976. package/dist/utils/threadStatusReport.js +88 -0
  977. package/dist/utils/threadStatusReport.js.map +1 -0
  978. package/dist/utils/threadToggle.d.ts +29 -0
  979. package/dist/utils/threadToggle.d.ts.map +1 -0
  980. package/dist/utils/threadToggle.js +39 -0
  981. package/dist/utils/threadToggle.js.map +1 -0
  982. package/dist/utils/timezone.d.ts +125 -0
  983. package/dist/utils/timezone.d.ts.map +1 -0
  984. package/dist/utils/timezone.js +278 -0
  985. package/dist/utils/timezone.js.map +1 -0
  986. package/dist/utils/tmuxExec.d.ts +61 -0
  987. package/dist/utils/tmuxExec.d.ts.map +1 -0
  988. package/dist/utils/tmuxExec.js +109 -0
  989. package/dist/utils/tmuxExec.js.map +1 -0
  990. package/dist/utils/tmuxSessionName.d.ts +34 -0
  991. package/dist/utils/tmuxSessionName.d.ts.map +1 -0
  992. package/dist/utils/tmuxSessionName.js +51 -0
  993. package/dist/utils/tmuxSessionName.js.map +1 -0
  994. package/dist/utils/toolResultRender.d.ts +61 -0
  995. package/dist/utils/toolResultRender.d.ts.map +1 -0
  996. package/dist/utils/toolResultRender.js +62 -0
  997. package/dist/utils/toolResultRender.js.map +1 -0
  998. package/dist/utils/topicRequest.d.ts +61 -0
  999. package/dist/utils/topicRequest.d.ts.map +1 -0
  1000. package/dist/utils/topicRequest.js +68 -0
  1001. package/dist/utils/topicRequest.js.map +1 -0
  1002. package/dist/utils/topicView.d.ts +55 -0
  1003. package/dist/utils/topicView.d.ts.map +1 -0
  1004. package/dist/utils/topicView.js +56 -0
  1005. package/dist/utils/topicView.js.map +1 -0
  1006. package/dist/utils/transcribeAudio.d.ts +89 -0
  1007. package/dist/utils/transcribeAudio.d.ts.map +1 -0
  1008. package/dist/utils/transcribeAudio.js +249 -0
  1009. package/dist/utils/transcribeAudio.js.map +1 -0
  1010. package/dist/utils/transientFrames.d.ts +52 -0
  1011. package/dist/utils/transientFrames.d.ts.map +1 -0
  1012. package/dist/utils/transientFrames.js +41 -0
  1013. package/dist/utils/transientFrames.js.map +1 -0
  1014. package/dist/utils/typingActive.d.ts +35 -0
  1015. package/dist/utils/typingActive.d.ts.map +1 -0
  1016. package/dist/utils/typingActive.js +22 -0
  1017. package/dist/utils/typingActive.js.map +1 -0
  1018. package/dist/utils/typingLoopBackstop.d.ts +64 -0
  1019. package/dist/utils/typingLoopBackstop.d.ts.map +1 -0
  1020. package/dist/utils/typingLoopBackstop.js +68 -0
  1021. package/dist/utils/typingLoopBackstop.js.map +1 -0
  1022. package/dist/utils/verbosityRender.d.ts +18 -0
  1023. package/dist/utils/verbosityRender.d.ts.map +1 -0
  1024. package/dist/utils/verbosityRender.js +17 -0
  1025. package/dist/utils/verbosityRender.js.map +1 -0
  1026. package/dist/utils/wedgeRecovery.d.ts +57 -0
  1027. package/dist/utils/wedgeRecovery.d.ts.map +1 -0
  1028. package/dist/utils/wedgeRecovery.js +24 -0
  1029. package/dist/utils/wedgeRecovery.js.map +1 -0
  1030. package/dist/utils.d.ts +30 -0
  1031. package/dist/utils.d.ts.map +1 -0
  1032. package/dist/utils.js +61 -0
  1033. package/dist/utils.js.map +1 -0
  1034. package/dist/validation.d.ts +113 -0
  1035. package/dist/validation.d.ts.map +1 -0
  1036. package/dist/validation.js +226 -0
  1037. package/dist/validation.js.map +1 -0
  1038. package/dist/voiceQueue.d.ts +7 -0
  1039. package/dist/voiceQueue.d.ts.map +1 -0
  1040. package/dist/voiceQueue.js +33 -0
  1041. package/dist/voiceQueue.js.map +1 -0
  1042. package/examples/.env.example +17 -0
  1043. package/examples/docker-compose.yml +36 -0
  1044. package/package.json +83 -4
@@ -0,0 +1,1164 @@
1
+ "use strict";
2
+ /**
3
+ * @description Pure core of the `/reminders` wizard — the bot-LOCAL reminder
4
+ * feature: an inline-button flow that produces a {@link ScheduleSpec} with ZERO
5
+ * agent involvement (the `/schedule` path, by contrast, hands free text to the
6
+ * agent and lets it call the `schedule_*` MCP tools).
7
+ *
8
+ * Everything here is pure: no I/O, no `Date.now()` (every entry point takes the
9
+ * caller's `nowMs`), no telegraf, no `t()`. It returns STRUCTURED data —
10
+ * keyboard PLANS carrying i18n KEY names plus `callback_data`, and structured
11
+ * schedule descriptors — which `bot.ts` maps onto `Markup.inlineKeyboard` and
12
+ * `t(...)`. The split is mandatory rather than stylistic: user-facing text lives
13
+ * behind the ASYNC `t()` in 12 locales, so a pure layer that emitted prose could
14
+ * neither be localized nor unit-tested, and `bot.ts` itself cannot be imported
15
+ * by a test (its module-scope `parseEnv()` exits the process).
16
+ *
17
+ * Time math is HOST-LOCAL on purpose: the instance-wide `/timezone` setting is
18
+ * applied to `process.env.TZ` at boot, so plain `Date` arithmetic already IS the
19
+ * operator's clock and threading a zone through here would create a second
20
+ * source of truth.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.reminderListPageSize = exports.reminderSummaryTextMaxLength = exports.reminderNameFallback = exports.reminderNameMaxLength = exports.reminderTextMaxLength = exports.reminderWizardErrorCodes = exports.reminderDeleteCallbackRe = exports.reminderCardCallbackRe = exports.reminderListPageCallbackRe = exports.reminderCloseCallback = exports.reminderHubCallback = exports.reminderAddCallback = exports.reminderWizardCallbackRe = exports.reminderWizardIdMaxLength = exports.reminderWizardCallbackPrefix = exports.reminderRepeatLabelKeys = exports.reminderWeekdayLabelKeys = exports.reminderLabelKeys = exports.reminderWeekdayDisplayOrder = exports.reminderMinuteStep = exports.reminderQuickTimes = exports.reminderWizardSteps = exports.reminderRepeatKinds = void 0;
24
+ exports.checkIsReminderRepeatKind = checkIsReminderRepeatKind;
25
+ exports.createReminderWizardId = createReminderWizardId;
26
+ exports.buildReminderRepeatCallback = buildReminderRepeatCallback;
27
+ exports.buildReminderDateGridCallback = buildReminderDateGridCallback;
28
+ exports.buildReminderDateCallback = buildReminderDateCallback;
29
+ exports.buildReminderWeekdayCallback = buildReminderWeekdayCallback;
30
+ exports.buildReminderDayOfMonthGridCallback = buildReminderDayOfMonthGridCallback;
31
+ exports.buildReminderDayOfMonthCallback = buildReminderDayOfMonthCallback;
32
+ exports.buildReminderQuickTimeCallback = buildReminderQuickTimeCallback;
33
+ exports.buildReminderHourGridCallback = buildReminderHourGridCallback;
34
+ exports.buildReminderHourCallback = buildReminderHourCallback;
35
+ exports.buildReminderMinuteCallback = buildReminderMinuteCallback;
36
+ exports.buildReminderBackCallback = buildReminderBackCallback;
37
+ exports.buildReminderCancelCallback = buildReminderCancelCallback;
38
+ exports.parseReminderWizardCallback = parseReminderWizardCallback;
39
+ exports.buildReminderListPageCallback = buildReminderListPageCallback;
40
+ exports.buildReminderCardCallback = buildReminderCardCallback;
41
+ exports.buildReminderDeleteCallback = buildReminderDeleteCallback;
42
+ exports.parseReminderListPageCallback = parseReminderListPageCallback;
43
+ exports.parseReminderCardCallback = parseReminderCardCallback;
44
+ exports.parseReminderDeleteCallback = parseReminderDeleteCallback;
45
+ exports.createReminderWizardState = createReminderWizardState;
46
+ exports.getReminderStepAfterRepeat = getReminderStepAfterRepeat;
47
+ exports.getReminderPreviousStep = getReminderPreviousStep;
48
+ exports.getReminderStateForStep = getReminderStateForStep;
49
+ exports.getReminderStateForRetime = getReminderStateForRetime;
50
+ exports.getReminderActionAfterTime = getReminderActionAfterTime;
51
+ exports.applyReminderWizardCallback = applyReminderWizardCallback;
52
+ exports.buildReminderStepKeyboard = buildReminderStepKeyboard;
53
+ exports.getReminderPicksFromState = getReminderPicksFromState;
54
+ exports.buildReminderSpec = buildReminderSpec;
55
+ exports.getReminderScheduleDescriptor = getReminderScheduleDescriptor;
56
+ exports.getShortenedText = getShortenedText;
57
+ exports.getReminderNameFromText = getReminderNameFromText;
58
+ exports.buildReminderHubKeyboard = buildReminderHubKeyboard;
59
+ exports.buildReminderListPlan = buildReminderListPlan;
60
+ exports.getReminderRowAt = getReminderRowAt;
61
+ exports.getReminderCardBackPage = getReminderCardBackPage;
62
+ exports.buildReminderCardPlan = buildReminderCardPlan;
63
+ exports.getReminderDeleteTarget = getReminderDeleteTarget;
64
+ exports.formatReminderTime = formatReminderTime;
65
+ exports.formatReminderDateIso = formatReminderDateIso;
66
+ exports.formatReminderDayMonth = formatReminderDayMonth;
67
+ exports.getLocalDateAtDayOffset = getLocalDateAtDayOffset;
68
+ exports.createReminderInstant = createReminderInstant;
69
+ const paginateList_1 = require("./paginateList");
70
+ // ─── vocabularies ────────────────────────────────────────────────────
71
+ /**
72
+ * @name ReminderRepeatKind
73
+ * @description How often a reminder fires. `once` is an absolute instant; the
74
+ * other four map onto the exactly four cron shapes `describeCron`
75
+ * (`scheduler/recurrence.ts`) renders as words — deliberate, so a
76
+ * wizard-created job never shows up as a raw cron expression anywhere.
77
+ */
78
+ exports.reminderRepeatKinds = ['once', 'daily', 'weekdays', 'weekly', 'monthly'];
79
+ function checkIsReminderRepeatKind(value) {
80
+ return exports.reminderRepeatKinds.includes(value);
81
+ }
82
+ /**
83
+ * @name ReminderWizardStep
84
+ * @description Which screen the wizard is on. `dateGrid`, `dayOfMonthGrid`,
85
+ * `hour` and `minute` are the "other …" expansions of their quick-pick steps —
86
+ * separate steps rather than modes so `back` has one unambiguous meaning
87
+ * everywhere.
88
+ */
89
+ exports.reminderWizardSteps = [
90
+ 'repeat',
91
+ 'date',
92
+ 'dateGrid',
93
+ 'weekday',
94
+ 'dayOfMonth',
95
+ 'dayOfMonthGrid',
96
+ 'time',
97
+ 'hour',
98
+ 'minute',
99
+ 'text',
100
+ ];
101
+ /** Quick-pick times offered on the time step, in render order. */
102
+ exports.reminderQuickTimes = [
103
+ { hour: 9, minute: 0 },
104
+ { hour: 12, minute: 0 },
105
+ { hour: 18, minute: 0 },
106
+ { hour: 21, minute: 0 },
107
+ ];
108
+ /**
109
+ * Granularity of the custom-minute grid. Five minutes keeps the grid at 12
110
+ * buttons (4 rows of 3) — a full 0–59 grid would need 60, which is past
111
+ * Telegram's comfortable keyboard size and unreadable on a phone.
112
+ */
113
+ exports.reminderMinuteStep = 5;
114
+ /** Cron `dow` values in Monday-first DISPLAY order (Sunday is `0` in cron). */
115
+ exports.reminderWeekdayDisplayOrder = [1, 2, 3, 4, 5, 6, 0];
116
+ /** Quick-pick days of the month, laid out as rendered (3 per row). */
117
+ const reminderQuickDayOfMonthRows = [
118
+ [1, 5, 10],
119
+ [15, 20, 25],
120
+ ];
121
+ /** Repeat buttons, laid out as rendered. */
122
+ const reminderRepeatKindRows = [
123
+ ['once', 'daily'],
124
+ ['weekdays', 'weekly'],
125
+ ['monthly'],
126
+ ];
127
+ /** Weekday buttons per row on the weekday step (Mon Tue Wed / Thu Fri Sat / Sun). */
128
+ const reminderWeekdayColumns = 3;
129
+ /** Date buttons per row in the "other date" grid (`DD.MM` labels). */
130
+ const reminderDateGridColumns = 4;
131
+ /** Day buttons per row in the full 1–31 grid. */
132
+ const reminderDayOfMonthGridColumns = 7;
133
+ /** Hour buttons per row in the custom-hour grid. */
134
+ const reminderHourGridColumns = 4;
135
+ /** Minute buttons per row in the custom-minute grid. */
136
+ const reminderMinuteGridColumns = 3;
137
+ /**
138
+ * First day offered by the "other date" grid. `0` (today) and `1` (tomorrow)
139
+ * already have their own buttons on the date step, so the grid starts after
140
+ * them instead of repeating two entries.
141
+ */
142
+ const reminderDateGridStartOffsetDays = 2;
143
+ /** How many days the "other date" grid offers (4 full rows of 4). */
144
+ const reminderDateGridDayCount = 16;
145
+ /** Highest day-of-month a cron `dom` field accepts. */
146
+ const maxDayOfMonth = 31;
147
+ const hoursPerDay = 24;
148
+ const minutesPerHour = 60;
149
+ const maxWeekdayValue = 6;
150
+ /** Field count of a 5-field cron expression (`min hour dom mon dow`). */
151
+ const cronFieldCount = 5;
152
+ /** Cron `dow` field for Monday–Friday — the shape `describeCron` calls "weekdays". */
153
+ const weekdaysCronDayOfWeek = '1-5';
154
+ /** Cron wildcard for an unconstrained field. */
155
+ const cronWildcard = '*';
156
+ // ─── label keys ──────────────────────────────────────────────────────
157
+ /**
158
+ * @description i18n keys the keyboard plans reference. Collected in one object
159
+ * so the strings exist exactly once (and so the i18n scope has a single list to
160
+ * mirror into every locale); the pure layer never resolves them.
161
+ */
162
+ exports.reminderLabelKeys = {
163
+ hubAdd: 'reminders.addButton',
164
+ hubList: 'reminders.listButton',
165
+ repeatOnce: 'reminders.repeatOnceButton',
166
+ repeatDaily: 'reminders.repeatDailyButton',
167
+ repeatWeekdays: 'reminders.repeatWeekdaysButton',
168
+ repeatWeekly: 'reminders.repeatWeeklyButton',
169
+ repeatMonthly: 'reminders.repeatMonthlyButton',
170
+ dateToday: 'reminders.dateTodayButton',
171
+ dateTomorrow: 'reminders.dateTomorrowButton',
172
+ dateOther: 'reminders.dateOtherButton',
173
+ dayOfMonthOther: 'reminders.dayOfMonthOtherButton',
174
+ timeOther: 'reminders.timeOtherButton',
175
+ back: 'reminders.backButton',
176
+ cancel: 'reminders.cancelButton',
177
+ listPrev: 'reminders.listPrevButton',
178
+ listNext: 'reminders.listNextButton',
179
+ listBackToHub: 'reminders.listBackToHubButton',
180
+ cardDelete: 'reminders.cardDeleteButton',
181
+ cardBackToList: 'reminders.cardBackToListButton',
182
+ };
183
+ /**
184
+ * Weekday button label keys, indexed by CRON `dow` value (Sunday = 0) so the
185
+ * display order and the stored value never drift apart.
186
+ */
187
+ exports.reminderWeekdayLabelKeys = [
188
+ 'reminders.weekdaySundayButton',
189
+ 'reminders.weekdayMondayButton',
190
+ 'reminders.weekdayTuesdayButton',
191
+ 'reminders.weekdayWednesdayButton',
192
+ 'reminders.weekdayThursdayButton',
193
+ 'reminders.weekdayFridayButton',
194
+ 'reminders.weekdaySaturdayButton',
195
+ ];
196
+ /**
197
+ * Repeat-kind → its button label key. Exported because the wizard's running
198
+ * summary ("Repeat: Every day") must name the pick with the SAME word its button
199
+ * carried — a second wording would read as a different option.
200
+ */
201
+ exports.reminderRepeatLabelKeys = {
202
+ once: exports.reminderLabelKeys.repeatOnce,
203
+ daily: exports.reminderLabelKeys.repeatDaily,
204
+ weekdays: exports.reminderLabelKeys.repeatWeekdays,
205
+ weekly: exports.reminderLabelKeys.repeatWeekly,
206
+ monthly: exports.reminderLabelKeys.repeatMonthly,
207
+ };
208
+ function buildKeyButton(key, callbackData) {
209
+ return { label: { kind: 'key', key }, callbackData };
210
+ }
211
+ function buildLiteralButton(text, callbackData) {
212
+ return { label: { kind: 'literal', text }, callbackData };
213
+ }
214
+ /** Split a flat button list into rows of at most `columns` entries. */
215
+ function getButtonRows(buttons, columns) {
216
+ const rows = [];
217
+ for (let index = 0; index < buttons.length; index += columns) {
218
+ rows.push(buttons.slice(index, index + columns));
219
+ }
220
+ return rows;
221
+ }
222
+ // ─── callback codec ──────────────────────────────────────────────────
223
+ /**
224
+ * Wizard `callback_data` prefix. Every wizard button also bakes in the wizard
225
+ * id, because an inline keyboard stays tappable forever: without it a tap on a
226
+ * wizard the operator abandoned hours ago would feed picks into whatever wizard
227
+ * is live now (the same class of bug the `/disconnect` picker's per-message
228
+ * snapshot and `acl_skip_<fireAt>`'s baked instant guard against).
229
+ */
230
+ exports.reminderWizardCallbackPrefix = 'rw_';
231
+ /**
232
+ * Max wizard-id length. Bounded so the longest producible `callback_data` is
233
+ * provably inside Telegram's 64-byte cap, and so a malformed id can never make
234
+ * the anchored matcher accept garbage.
235
+ */
236
+ exports.reminderWizardIdMaxLength = 12;
237
+ /** Short action tokens carried by a wizard callback (the wire vocabulary). */
238
+ const reminderWizardTokens = {
239
+ repeat: 'r',
240
+ dateGrid: 'dg',
241
+ date: 'd',
242
+ weekday: 'w',
243
+ dayOfMonthGrid: 'mg',
244
+ dayOfMonth: 'm',
245
+ quickTime: 'q',
246
+ hourGrid: 'hg',
247
+ hour: 'h',
248
+ minute: 'i',
249
+ back: 'b',
250
+ cancel: 'x',
251
+ };
252
+ /** Digits in the compact `YYYYMMDD` date argument. */
253
+ const compactDateLength = 8;
254
+ /**
255
+ * Anchored matcher for `bot.action(...)`. Built from the id-length constant so
256
+ * the wire format has exactly one definition. The id charset excludes `_`
257
+ * precisely because `_` is the field separator.
258
+ */
259
+ exports.reminderWizardCallbackRe = new RegExp(`^${exports.reminderWizardCallbackPrefix}([A-Za-z0-9]{1,${exports.reminderWizardIdMaxLength}})_([a-z]{1,2})(?:_(\\d{1,${compactDateLength}}))?$`);
260
+ /**
261
+ * @description Mint a wizard id from the caller's clock: base36 of the epoch ms.
262
+ * Pure (the instant is an argument), 8–9 chars, and monotonically increasing —
263
+ * so a freshly opened wizard can never collide with the one it replaced, which
264
+ * is the whole point of the stale-tap guard.
265
+ */
266
+ function createReminderWizardId(nowMs) {
267
+ return Math.floor(nowMs).toString(36);
268
+ }
269
+ function buildWizardCallback(wizardId, token, argument) {
270
+ const suffix = argument === undefined ? '' : `_${argument}`;
271
+ return `${exports.reminderWizardCallbackPrefix}${wizardId}_${token}${suffix}`;
272
+ }
273
+ function buildReminderRepeatCallback(wizardId, repeatKind) {
274
+ return buildWizardCallback(wizardId, reminderWizardTokens.repeat, exports.reminderRepeatKinds.indexOf(repeatKind));
275
+ }
276
+ function buildReminderDateGridCallback(wizardId) {
277
+ return buildWizardCallback(wizardId, reminderWizardTokens.dateGrid);
278
+ }
279
+ function buildReminderDateCallback(wizardId, dateIso) {
280
+ return buildWizardCallback(wizardId, reminderWizardTokens.date, encodeCompactDate(dateIso));
281
+ }
282
+ function buildReminderWeekdayCallback(wizardId, weekday) {
283
+ return buildWizardCallback(wizardId, reminderWizardTokens.weekday, weekday);
284
+ }
285
+ function buildReminderDayOfMonthGridCallback(wizardId) {
286
+ return buildWizardCallback(wizardId, reminderWizardTokens.dayOfMonthGrid);
287
+ }
288
+ function buildReminderDayOfMonthCallback(wizardId, dayOfMonth) {
289
+ return buildWizardCallback(wizardId, reminderWizardTokens.dayOfMonth, dayOfMonth);
290
+ }
291
+ function buildReminderQuickTimeCallback(wizardId, quickTimeIndex) {
292
+ return buildWizardCallback(wizardId, reminderWizardTokens.quickTime, quickTimeIndex);
293
+ }
294
+ function buildReminderHourGridCallback(wizardId) {
295
+ return buildWizardCallback(wizardId, reminderWizardTokens.hourGrid);
296
+ }
297
+ function buildReminderHourCallback(wizardId, hour) {
298
+ return buildWizardCallback(wizardId, reminderWizardTokens.hour, hour);
299
+ }
300
+ function buildReminderMinuteCallback(wizardId, minute) {
301
+ return buildWizardCallback(wizardId, reminderWizardTokens.minute, minute);
302
+ }
303
+ function buildReminderBackCallback(wizardId) {
304
+ return buildWizardCallback(wizardId, reminderWizardTokens.back);
305
+ }
306
+ function buildReminderCancelCallback(wizardId) {
307
+ return buildWizardCallback(wizardId, reminderWizardTokens.cancel);
308
+ }
309
+ /**
310
+ * @description Decode one wizard `callback_data`, or `null` when it is not ours
311
+ * / malformed / carries an out-of-range argument.
312
+ *
313
+ * Range and calendar validation happens HERE rather than at apply time so an
314
+ * impossible value (weekday `9`, `2026-02-31`, a minute off the 5-minute grid)
315
+ * can never reach the spec assembler — a forged or truncated callback is
316
+ * indistinguishable from a stale one to the caller, and both must be inert.
317
+ */
318
+ function parseReminderWizardCallback(callbackData) {
319
+ const match = exports.reminderWizardCallbackRe.exec(callbackData);
320
+ if (!match)
321
+ return null;
322
+ const wizardId = match[1];
323
+ const token = match[2];
324
+ const rawArgument = match[3];
325
+ const action = getWizardAction(token, rawArgument);
326
+ return action === null ? null : { wizardId, action };
327
+ }
328
+ function getWizardAction(token, rawArgument) {
329
+ switch (token) {
330
+ case reminderWizardTokens.back:
331
+ return rawArgument === undefined ? { kind: 'back' } : null;
332
+ case reminderWizardTokens.cancel:
333
+ return rawArgument === undefined ? { kind: 'cancel' } : null;
334
+ case reminderWizardTokens.dateGrid:
335
+ return rawArgument === undefined ? { kind: 'openDateGrid' } : null;
336
+ case reminderWizardTokens.dayOfMonthGrid:
337
+ return rawArgument === undefined ? { kind: 'openDayOfMonthGrid' } : null;
338
+ case reminderWizardTokens.hourGrid:
339
+ return rawArgument === undefined ? { kind: 'openHourGrid' } : null;
340
+ case reminderWizardTokens.repeat: {
341
+ const repeatKind = rawArgument === undefined ? undefined : exports.reminderRepeatKinds[Number(rawArgument)];
342
+ return repeatKind === undefined ? null : { kind: 'pickRepeat', repeatKind };
343
+ }
344
+ case reminderWizardTokens.date: {
345
+ const dateIso = rawArgument === undefined ? null : decodeCompactDate(rawArgument);
346
+ return dateIso === null ? null : { kind: 'pickDate', dateIso };
347
+ }
348
+ case reminderWizardTokens.weekday: {
349
+ const weekday = getBoundedNumber(rawArgument, 0, maxWeekdayValue);
350
+ return weekday === null ? null : { kind: 'pickWeekday', weekday };
351
+ }
352
+ case reminderWizardTokens.dayOfMonth: {
353
+ const dayOfMonth = getBoundedNumber(rawArgument, 1, maxDayOfMonth);
354
+ return dayOfMonth === null ? null : { kind: 'pickDayOfMonth', dayOfMonth };
355
+ }
356
+ case reminderWizardTokens.quickTime: {
357
+ const index = getBoundedNumber(rawArgument, 0, exports.reminderQuickTimes.length - 1);
358
+ if (index === null)
359
+ return null;
360
+ const quickTime = exports.reminderQuickTimes[index];
361
+ return { kind: 'pickQuickTime', hour: quickTime.hour, minute: quickTime.minute };
362
+ }
363
+ case reminderWizardTokens.hour: {
364
+ const hour = getBoundedNumber(rawArgument, 0, hoursPerDay - 1);
365
+ return hour === null ? null : { kind: 'pickHour', hour };
366
+ }
367
+ case reminderWizardTokens.minute: {
368
+ const minute = getBoundedNumber(rawArgument, 0, minutesPerHour - 1);
369
+ if (minute === null || minute % exports.reminderMinuteStep !== 0)
370
+ return null;
371
+ return { kind: 'pickMinute', minute };
372
+ }
373
+ default:
374
+ return null;
375
+ }
376
+ }
377
+ /** A callback argument parsed as an in-range integer, or `null`. */
378
+ function getBoundedNumber(rawArgument, min, max) {
379
+ if (rawArgument === undefined)
380
+ return null;
381
+ const value = Number(rawArgument);
382
+ if (!Number.isInteger(value) || value < min || value > max)
383
+ return null;
384
+ return value;
385
+ }
386
+ // ─── hub / list / card codec ─────────────────────────────────────────
387
+ /** Hub → open the add wizard. */
388
+ exports.reminderAddCallback = 'rmadd';
389
+ /** → the hub screen (from the list). */
390
+ exports.reminderHubCallback = 'rmhub';
391
+ /**
392
+ * Dismiss the reminders screen (hub / done card): the message is relabelled and
393
+ * its keyboard dropped. Declared here with the other flat `rm*` ids so the whole
394
+ * reminder callback namespace has ONE definition site and a future id cannot
395
+ * silently collide; the row it sits on is composed by the screen builder.
396
+ */
397
+ exports.reminderCloseCallback = 'rmclose';
398
+ const reminderListPageCallbackPrefix = 'rmlp_';
399
+ const reminderCardCallbackPrefix = 'rmc_';
400
+ const reminderDeleteCallbackPrefix = 'rmdel_';
401
+ /** Anchored matchers for `bot.action(...)`, beside their builders. */
402
+ exports.reminderListPageCallbackRe = /^rmlp_(\d+)$/;
403
+ exports.reminderCardCallbackRe = /^rmc_(\d+)$/;
404
+ /**
405
+ * The id charset mirrors `generateScheduleId` output — `slugify` lowercases and
406
+ * collapses everything else to hyphens, so lowercase alnum + `-` is the full
407
+ * alphabet a real reminder id can contain. A forged id still parses and simply
408
+ * resolves to `notFound` (see {@link getReminderDeleteTarget}).
409
+ */
410
+ exports.reminderDeleteCallbackRe = /^rmdel_([a-z0-9-]+)$/;
411
+ function buildReminderListPageCallback(page) {
412
+ return `${reminderListPageCallbackPrefix}${page}`;
413
+ }
414
+ /** A list row's button — the ABSOLUTE index into the thread's reminder list. */
415
+ function buildReminderCardCallback(reminderIndex) {
416
+ return `${reminderCardCallbackPrefix}${reminderIndex}`;
417
+ }
418
+ /**
419
+ * @description The card's delete button. Carries the reminder's OWN id, never a
420
+ * positional index: deletion is destructive and an old keyboard stays tappable,
421
+ * so an index resolved against a list that has since changed would delete a
422
+ * DIFFERENT reminder. A schedule id is `slugify(name)` (≤40) + `-` + a 6-char
423
+ * suffix, so prefix + id stays well inside the 64-byte cap.
424
+ */
425
+ function buildReminderDeleteCallback(reminderId) {
426
+ return `${reminderDeleteCallbackPrefix}${reminderId}`;
427
+ }
428
+ function parseReminderListPageCallback(callbackData) {
429
+ const match = exports.reminderListPageCallbackRe.exec(callbackData);
430
+ return match ? Number(match[1]) : null;
431
+ }
432
+ function parseReminderCardCallback(callbackData) {
433
+ const match = exports.reminderCardCallbackRe.exec(callbackData);
434
+ return match ? Number(match[1]) : null;
435
+ }
436
+ function parseReminderDeleteCallback(callbackData) {
437
+ const match = exports.reminderDeleteCallbackRe.exec(callbackData);
438
+ return match ? match[1] : null;
439
+ }
440
+ /** A fresh wizard, parked on the repeat step with nothing picked. */
441
+ function createReminderWizardState(wizardId) {
442
+ return {
443
+ wizardId,
444
+ step: 'repeat',
445
+ repeatKind: null,
446
+ dateIso: null,
447
+ weekday: null,
448
+ dayOfMonth: null,
449
+ hour: null,
450
+ minute: null,
451
+ text: null,
452
+ };
453
+ }
454
+ /**
455
+ * @description The step that follows the repeat pick. `daily` and `weekdays`
456
+ * need no second pick at all, so they SKIP straight to the time step — the one
457
+ * reason this is a function of the state rather than a fixed sequence.
458
+ */
459
+ function getReminderStepAfterRepeat(repeatKind) {
460
+ switch (repeatKind) {
461
+ case 'once':
462
+ return 'date';
463
+ case 'weekly':
464
+ return 'weekday';
465
+ case 'monthly':
466
+ return 'dayOfMonth';
467
+ case 'daily':
468
+ case 'weekdays':
469
+ return 'time';
470
+ }
471
+ }
472
+ /**
473
+ * @description Where `back` lands, or `null` for "leave the wizard and show the
474
+ * hub" (which is what back means on the first step).
475
+ *
476
+ * Reads the repeat kind because the step BEFORE the time step differs per kind
477
+ * — and is the repeat step itself for `daily` / `weekdays`, which have no second
478
+ * step to return to.
479
+ */
480
+ function getReminderPreviousStep(state) {
481
+ switch (state.step) {
482
+ case 'repeat':
483
+ return null;
484
+ case 'date':
485
+ case 'weekday':
486
+ case 'dayOfMonth':
487
+ return 'repeat';
488
+ case 'dateGrid':
489
+ return 'date';
490
+ case 'dayOfMonthGrid':
491
+ return 'dayOfMonth';
492
+ case 'time': {
493
+ if (state.repeatKind === null)
494
+ return 'repeat';
495
+ const secondStep = getReminderStepAfterRepeat(state.repeatKind);
496
+ return secondStep === 'time' ? 'repeat' : secondStep;
497
+ }
498
+ case 'hour':
499
+ return 'time';
500
+ case 'minute':
501
+ return 'hour';
502
+ case 'text':
503
+ return 'time';
504
+ }
505
+ }
506
+ /**
507
+ * @description The state as it must look when the wizard RE-ENTERS `step`: the
508
+ * picks owned by that step and by every later step are cleared, so stepping back
509
+ * into a screen never silently keeps the value the operator came to change.
510
+ *
511
+ * The three date/weekday/day-of-month fields are cleared together because they
512
+ * are mutually exclusive alternatives of the same (second) step.
513
+ *
514
+ * An already-captured `text` is the ONE thing no re-entry clears: the operator
515
+ * types it exactly once, and re-picking the schedule is not a reason to ask again.
516
+ */
517
+ function getReminderStateForStep(state, step) {
518
+ switch (step) {
519
+ case 'repeat':
520
+ return { ...createReminderWizardState(state.wizardId), step: 'repeat', text: state.text };
521
+ case 'date':
522
+ case 'dateGrid':
523
+ case 'weekday':
524
+ case 'dayOfMonth':
525
+ case 'dayOfMonthGrid':
526
+ return { ...state, step, dateIso: null, weekday: null, dayOfMonth: null, hour: null, minute: null };
527
+ case 'time':
528
+ case 'hour':
529
+ return { ...state, step, hour: null, minute: null };
530
+ case 'minute':
531
+ return { ...state, step, minute: null };
532
+ case 'text':
533
+ return { ...state, step };
534
+ }
535
+ }
536
+ /**
537
+ * @description The state to re-render when the reminder text is already in hand
538
+ * but the picked `once` instant has gone by while the operator was typing: back on
539
+ * the TIME step, with the text RETAINED.
540
+ *
541
+ * Retaining it is the whole point. The flow is buttons precisely so the operator
542
+ * types exactly once, and re-entering the text step to collect the same sentence
543
+ * again defeats that — so only the time is re-asked, and the next time pick creates
544
+ * the reminder outright (see {@link getReminderActionAfterTime}).
545
+ */
546
+ function getReminderStateForRetime(state, text) {
547
+ return getReminderStateForStep({ ...state, text }, 'time');
548
+ }
549
+ // ─── transitions ─────────────────────────────────────────────────────
550
+ /**
551
+ * @name ReminderWizardErrorCode
552
+ * @description Machine-readable reasons a step cannot be completed, so `bot.ts`
553
+ * picks the i18n key. `pastTime` is the load-bearing one: «today» plus a time
554
+ * that has already gone by must SAY so on the time step, never silently roll the
555
+ * reminder to tomorrow (a locked product decision — a silent roll means the
556
+ * operator is reminded 24h off what they asked for).
557
+ *
558
+ * `invalidDate` and `invalidTime` are deliberately separate: a date that does not
559
+ * exist sends the operator back to the DATE step, whereas a wall-clock time a DST
560
+ * spring-forward skips happens on a perfectly good date and must send them back to
561
+ * the TIME step — one code for both told them to re-pick a date that was fine.
562
+ */
563
+ exports.reminderWizardErrorCodes = [
564
+ 'pastTime',
565
+ 'invalidDate',
566
+ 'invalidTime',
567
+ 'textTooLong',
568
+ ];
569
+ /**
570
+ * @description Decide whether the text step is still owed. A state that HOLDS the
571
+ * text is past it: the operator sent it, the picked `once` instant then went stale
572
+ * while they typed, and this is the replacement time pick — so the reminder is
573
+ * created from the text already in hand. Re-asking here would make them type the
574
+ * same note twice, which is exactly what the button flow exists to avoid.
575
+ */
576
+ function getReminderActionAfterTime(state) {
577
+ return state.text === null ? { kind: 'askText' } : { kind: 'createNow', text: state.text };
578
+ }
579
+ /** Whether an action can legitimately arrive while the wizard shows `step`. */
580
+ function checkIsActionAllowedOnStep(actionKind, step) {
581
+ switch (actionKind) {
582
+ case 'back':
583
+ case 'cancel':
584
+ return true;
585
+ case 'pickRepeat':
586
+ return step === 'repeat';
587
+ case 'openDateGrid':
588
+ return step === 'date';
589
+ case 'pickDate':
590
+ return step === 'date' || step === 'dateGrid';
591
+ case 'pickWeekday':
592
+ return step === 'weekday';
593
+ case 'openDayOfMonthGrid':
594
+ return step === 'dayOfMonth';
595
+ case 'pickDayOfMonth':
596
+ return step === 'dayOfMonth' || step === 'dayOfMonthGrid';
597
+ case 'pickQuickTime':
598
+ case 'openHourGrid':
599
+ return step === 'time';
600
+ case 'pickHour':
601
+ return step === 'hour';
602
+ case 'pickMinute':
603
+ return step === 'minute';
604
+ }
605
+ }
606
+ /**
607
+ * @description Apply one tapped `callback_data` to a wizard state.
608
+ *
609
+ * Takes the RAW callback string (not a pre-parsed action) so the stale-tap guard
610
+ * cannot be forgotten at a call site: a tap whose baked wizard id is not this
611
+ * wizard's — or that belongs to a step this wizard has left — returns `expired`
612
+ * and mutates nothing.
613
+ */
614
+ function applyReminderWizardCallback(input) {
615
+ const { state, nowMs } = input;
616
+ const parsed = parseReminderWizardCallback(input.callbackData);
617
+ if (parsed === null || parsed.wizardId !== state.wizardId)
618
+ return { kind: 'expired' };
619
+ const { action } = parsed;
620
+ if (!checkIsActionAllowedOnStep(action.kind, state.step))
621
+ return { kind: 'expired' };
622
+ switch (action.kind) {
623
+ case 'cancel':
624
+ return { kind: 'cancelled' };
625
+ case 'back': {
626
+ const previousStep = getReminderPreviousStep(state);
627
+ if (previousStep === null)
628
+ return { kind: 'backToHub' };
629
+ return { kind: 'render', state: getReminderStateForStep(state, previousStep) };
630
+ }
631
+ case 'pickRepeat': {
632
+ // A repeat change invalidates every later SCHEDULE pick, so restart from a
633
+ // clean state — but an already-captured text survives it, exactly as it
634
+ // survives a `back` to the repeat step.
635
+ const fresh = createReminderWizardState(state.wizardId);
636
+ return {
637
+ kind: 'render',
638
+ state: {
639
+ ...fresh,
640
+ text: state.text,
641
+ repeatKind: action.repeatKind,
642
+ step: getReminderStepAfterRepeat(action.repeatKind),
643
+ },
644
+ };
645
+ }
646
+ case 'openDateGrid':
647
+ return { kind: 'render', state: { ...state, step: 'dateGrid' } };
648
+ case 'pickDate':
649
+ return { kind: 'render', state: { ...state, dateIso: action.dateIso, step: 'time' } };
650
+ case 'pickWeekday':
651
+ return { kind: 'render', state: { ...state, weekday: action.weekday, step: 'time' } };
652
+ case 'openDayOfMonthGrid':
653
+ return { kind: 'render', state: { ...state, step: 'dayOfMonthGrid' } };
654
+ case 'pickDayOfMonth':
655
+ return { kind: 'render', state: { ...state, dayOfMonth: action.dayOfMonth, step: 'time' } };
656
+ case 'openHourGrid':
657
+ return { kind: 'render', state: { ...state, step: 'hour' } };
658
+ case 'pickHour':
659
+ return { kind: 'render', state: { ...state, hour: action.hour, step: 'minute' } };
660
+ case 'pickQuickTime':
661
+ return getTimeCommitTransition({ state, hour: action.hour, minute: action.minute, nowMs });
662
+ case 'pickMinute': {
663
+ // The minute grid is only reachable after an hour pick; a minute tap with
664
+ // no hour in state is therefore a forged/raced callback, not a real screen.
665
+ if (state.hour === null)
666
+ return { kind: 'expired' };
667
+ return getTimeCommitTransition({ state, hour: state.hour, minute: action.minute, nowMs });
668
+ }
669
+ }
670
+ }
671
+ /**
672
+ * @description Commit the time pick — the moment the whole schedule becomes
673
+ * decidable, and therefore the only place the past-time error can arise (the guard
674
+ * itself lives in {@link buildReminderSpec}, so it covers every `once` date the
675
+ * wizard can offer, not just «today»). On error the time is NOT committed, so the
676
+ * operator can simply pick again — with any held text still on the screen.
677
+ *
678
+ * Which screen they pick on differs by cause. `pastTime` re-renders the screen the
679
+ * tap came from, where a later minute is a valid fix. A DST-skipped time is skipped
680
+ * for the WHOLE transition hour, so re-picking a minute inside it could only fail
681
+ * again: that one returns to the time step, where the hour itself can be changed.
682
+ */
683
+ function getTimeCommitTransition(input) {
684
+ const withTime = { ...input.state, hour: input.hour, minute: input.minute };
685
+ const picks = getReminderPicksFromState(withTime);
686
+ // Unreachable through the keyboards (every earlier pick is committed before
687
+ // the time step renders); an incomplete state means a forged callback.
688
+ if (picks === null)
689
+ return { kind: 'expired' };
690
+ const result = buildReminderSpec({ picks, nowMs: input.nowMs });
691
+ if (!result.ok) {
692
+ const errorState = result.code === 'invalidTime' ? getReminderStateForStep(input.state, 'time') : input.state;
693
+ return { kind: 'error', code: result.code, state: errorState };
694
+ }
695
+ const nextState = { ...withTime, step: 'text' };
696
+ const afterTime = getReminderActionAfterTime(withTime);
697
+ if (afterTime.kind === 'createNow') {
698
+ return { kind: 'createNow', state: nextState, spec: result.spec, text: afterTime.text };
699
+ }
700
+ return { kind: 'awaitText', state: nextState };
701
+ }
702
+ // ─── step keyboards ──────────────────────────────────────────────────
703
+ /** The `back` + `cancel` row every wizard step carries. */
704
+ function buildWizardNavigationRow(wizardId) {
705
+ return [
706
+ buildKeyButton(exports.reminderLabelKeys.back, buildReminderBackCallback(wizardId)),
707
+ buildKeyButton(exports.reminderLabelKeys.cancel, buildReminderCancelCallback(wizardId)),
708
+ ];
709
+ }
710
+ /**
711
+ * @description Build the keyboard plan for the wizard's CURRENT step.
712
+ *
713
+ * One dispatcher rather than a builder per step because `bot.ts` renders
714
+ * whatever `state.step` says after every transition — it never needs to know
715
+ * which screen it is drawing. `nowMs` is required because the date step's
716
+ * buttons are dated at RENDER time (see {@link buildReminderDateCallback}).
717
+ */
718
+ function buildReminderStepKeyboard(input) {
719
+ const { state, nowMs } = input;
720
+ const { wizardId } = state;
721
+ const navigationRow = buildWizardNavigationRow(wizardId);
722
+ switch (state.step) {
723
+ case 'repeat': {
724
+ const rows = reminderRepeatKindRows.map((row) => row.map((repeatKind) => buildKeyButton(exports.reminderRepeatLabelKeys[repeatKind], buildReminderRepeatCallback(wizardId, repeatKind))));
725
+ return [...rows, navigationRow];
726
+ }
727
+ case 'date': {
728
+ const todayIso = formatReminderDateIso(getLocalDateAtDayOffset(nowMs, 0));
729
+ const tomorrowIso = formatReminderDateIso(getLocalDateAtDayOffset(nowMs, 1));
730
+ return [
731
+ [
732
+ buildKeyButton(exports.reminderLabelKeys.dateToday, buildReminderDateCallback(wizardId, todayIso)),
733
+ buildKeyButton(exports.reminderLabelKeys.dateTomorrow, buildReminderDateCallback(wizardId, tomorrowIso)),
734
+ ],
735
+ [buildKeyButton(exports.reminderLabelKeys.dateOther, buildReminderDateGridCallback(wizardId))],
736
+ navigationRow,
737
+ ];
738
+ }
739
+ case 'dateGrid': {
740
+ const buttons = [];
741
+ for (let offset = 0; offset < reminderDateGridDayCount; offset += 1) {
742
+ const date = getLocalDateAtDayOffset(nowMs, reminderDateGridStartOffsetDays + offset);
743
+ const dateIso = formatReminderDateIso(date);
744
+ buttons.push(buildLiteralButton(formatReminderDayMonth(date), buildReminderDateCallback(wizardId, dateIso)));
745
+ }
746
+ return [...getButtonRows(buttons, reminderDateGridColumns), navigationRow];
747
+ }
748
+ case 'weekday': {
749
+ const buttons = exports.reminderWeekdayDisplayOrder.map((weekday) => buildKeyButton(exports.reminderWeekdayLabelKeys[weekday], buildReminderWeekdayCallback(wizardId, weekday)));
750
+ return [...getButtonRows(buttons, reminderWeekdayColumns), navigationRow];
751
+ }
752
+ case 'dayOfMonth': {
753
+ const rows = reminderQuickDayOfMonthRows.map((row) => row.map((dayOfMonth) => buildLiteralButton(dayOfMonth.toString(), buildReminderDayOfMonthCallback(wizardId, dayOfMonth))));
754
+ return [
755
+ ...rows,
756
+ [buildKeyButton(exports.reminderLabelKeys.dayOfMonthOther, buildReminderDayOfMonthGridCallback(wizardId))],
757
+ navigationRow,
758
+ ];
759
+ }
760
+ case 'dayOfMonthGrid': {
761
+ const buttons = [];
762
+ for (let dayOfMonth = 1; dayOfMonth <= maxDayOfMonth; dayOfMonth += 1) {
763
+ buttons.push(buildLiteralButton(dayOfMonth.toString(), buildReminderDayOfMonthCallback(wizardId, dayOfMonth)));
764
+ }
765
+ return [...getButtonRows(buttons, reminderDayOfMonthGridColumns), navigationRow];
766
+ }
767
+ case 'time': {
768
+ const quickRow = exports.reminderQuickTimes.map((quickTime, quickTimeIndex) => buildLiteralButton(formatReminderTime(quickTime), buildReminderQuickTimeCallback(wizardId, quickTimeIndex)));
769
+ return [
770
+ quickRow,
771
+ [buildKeyButton(exports.reminderLabelKeys.timeOther, buildReminderHourGridCallback(wizardId))],
772
+ navigationRow,
773
+ ];
774
+ }
775
+ case 'hour': {
776
+ const buttons = [];
777
+ for (let hour = 0; hour < hoursPerDay; hour += 1) {
778
+ buttons.push(buildLiteralButton(padTwo(hour), buildReminderHourCallback(wizardId, hour)));
779
+ }
780
+ return [...getButtonRows(buttons, reminderHourGridColumns), navigationRow];
781
+ }
782
+ case 'minute': {
783
+ const buttons = [];
784
+ for (let minute = 0; minute < minutesPerHour; minute += exports.reminderMinuteStep) {
785
+ buttons.push(buildLiteralButton(`:${padTwo(minute)}`, buildReminderMinuteCallback(wizardId, minute)));
786
+ }
787
+ return [...getButtonRows(buttons, reminderMinuteGridColumns), navigationRow];
788
+ }
789
+ case 'text':
790
+ return [navigationRow];
791
+ }
792
+ }
793
+ /**
794
+ * @description Lift a complete pick set out of a wizard state, or `null` when a
795
+ * pick the chosen repeat kind needs is still missing.
796
+ */
797
+ function getReminderPicksFromState(state) {
798
+ const { repeatKind, hour, minute } = state;
799
+ if (repeatKind === null || hour === null || minute === null)
800
+ return null;
801
+ switch (repeatKind) {
802
+ case 'once':
803
+ return state.dateIso === null ? null : { repeatKind: 'once', dateIso: state.dateIso, hour, minute };
804
+ case 'weekly':
805
+ return state.weekday === null ? null : { repeatKind: 'weekly', weekday: state.weekday, hour, minute };
806
+ case 'monthly':
807
+ return state.dayOfMonth === null
808
+ ? null
809
+ : { repeatKind: 'monthly', dayOfMonth: state.dayOfMonth, hour, minute };
810
+ case 'daily':
811
+ return { repeatKind: 'daily', hour, minute };
812
+ case 'weekdays':
813
+ return { repeatKind: 'weekdays', hour, minute };
814
+ }
815
+ }
816
+ /**
817
+ * @description Turn a complete pick set into a {@link ScheduleSpec}.
818
+ *
819
+ * The four recurring kinds emit exactly the cron shapes `describeCron`
820
+ * (`scheduler/recurrence.ts`) renders as words — `m h * * *`, `m h * * 1-5`,
821
+ * `m h * * d`, `m h D * *`. That is why the wizard offers these five options and
822
+ * no others: any further shape would surface to the operator as a raw cron
823
+ * expression. None of them can fire more often than daily, so
824
+ * `minFireIntervalMs` is unreachable by construction.
825
+ *
826
+ * `once` is assembled in HOST-LOCAL time (the operator's `/timezone` is already
827
+ * applied to `process.env.TZ`) and stored as a UTC ISO instant, which
828
+ * `new Date(...)` round-trips exactly.
829
+ */
830
+ function buildReminderSpec(input) {
831
+ const { picks, nowMs } = input;
832
+ const { hour, minute } = picks;
833
+ switch (picks.repeatKind) {
834
+ case 'daily':
835
+ return { ok: true, spec: { kind: 'cron', cronExpr: buildCronExpr(minute, hour, cronWildcard, cronWildcard) } };
836
+ case 'weekdays':
837
+ return {
838
+ ok: true,
839
+ spec: { kind: 'cron', cronExpr: buildCronExpr(minute, hour, cronWildcard, weekdaysCronDayOfWeek) },
840
+ };
841
+ case 'weekly':
842
+ return {
843
+ ok: true,
844
+ spec: { kind: 'cron', cronExpr: buildCronExpr(minute, hour, cronWildcard, picks.weekday.toString()) },
845
+ };
846
+ case 'monthly':
847
+ return {
848
+ ok: true,
849
+ spec: {
850
+ kind: 'cron',
851
+ cronExpr: buildCronExpr(minute, hour, picks.dayOfMonth.toString(), cronWildcard),
852
+ },
853
+ };
854
+ case 'once': {
855
+ const resolved = createReminderInstant(picks.dateIso, hour, minute);
856
+ if (!resolved.ok)
857
+ return { ok: false, code: resolved.code };
858
+ // A past instant is reported, never rolled forward: the operator asked for
859
+ // a specific day, and firing 24h later would be a different reminder.
860
+ if (resolved.instant.getTime() <= nowMs)
861
+ return { ok: false, code: 'pastTime' };
862
+ return { ok: true, spec: { kind: 'once', onceAtIso: resolved.instant.toISOString() } };
863
+ }
864
+ }
865
+ }
866
+ function buildCronExpr(minute, hour, dayOfMonth, dayOfWeek) {
867
+ return `${minute} ${hour} ${dayOfMonth} ${cronWildcard} ${dayOfWeek}`;
868
+ }
869
+ /** Decompose a spec for localized rendering; see {@link ReminderScheduleDescriptor}. */
870
+ function getReminderScheduleDescriptor(spec) {
871
+ if (spec.kind === 'once') {
872
+ const at = new Date(spec.onceAtIso);
873
+ if (Number.isNaN(at.getTime()))
874
+ return { kind: 'raw', text: spec.onceAtIso };
875
+ return {
876
+ kind: 'once',
877
+ dateIso: formatReminderDateIso(at),
878
+ time: formatReminderTime({ hour: at.getHours(), minute: at.getMinutes() }),
879
+ };
880
+ }
881
+ const rawDescriptor = { kind: 'raw', text: spec.cronExpr };
882
+ // An N-times job has a run budget no wizard shape carries; describing it as a
883
+ // plain recurring reminder would hide that it expires.
884
+ if (typeof spec.remainingRuns === 'number')
885
+ return rawDescriptor;
886
+ const fields = spec.cronExpr.trim().split(/\s+/);
887
+ if (fields.length !== cronFieldCount)
888
+ return rawDescriptor;
889
+ const [minuteField, hourField, dayOfMonthField, monthField, dayOfWeekField] = fields;
890
+ if (monthField !== cronWildcard)
891
+ return rawDescriptor;
892
+ const minute = getCronFieldNumber(minuteField, 0, minutesPerHour - 1);
893
+ const hour = getCronFieldNumber(hourField, 0, hoursPerDay - 1);
894
+ if (minute === null || hour === null)
895
+ return rawDescriptor;
896
+ const time = formatReminderTime({ hour, minute });
897
+ if (dayOfMonthField === cronWildcard) {
898
+ if (dayOfWeekField === cronWildcard)
899
+ return { kind: 'daily', time };
900
+ if (dayOfWeekField === weekdaysCronDayOfWeek)
901
+ return { kind: 'weekdays', time };
902
+ const weekday = getCronFieldNumber(dayOfWeekField, 0, maxWeekdayValue);
903
+ return weekday === null ? rawDescriptor : { kind: 'weekly', weekday, time };
904
+ }
905
+ if (dayOfWeekField !== cronWildcard)
906
+ return rawDescriptor;
907
+ const dayOfMonth = getCronFieldNumber(dayOfMonthField, 1, maxDayOfMonth);
908
+ return dayOfMonth === null ? rawDescriptor : { kind: 'monthly', dayOfMonth, time };
909
+ }
910
+ /** A plain-integer cron field within `[min, max]`, or `null` (step/range/list). */
911
+ function getCronFieldNumber(field, min, max) {
912
+ if (!/^\d{1,2}$/.test(field))
913
+ return null;
914
+ const value = Number(field);
915
+ return value >= min && value <= max ? value : null;
916
+ }
917
+ // ─── text shortening and name derivation ─────────────────────────────
918
+ /**
919
+ * Longest reminder TEXT accepted from the operator. The text is interpolated into
920
+ * the fire announcement and, alongside the schedule and next-run lines, into the
921
+ * card and the created-screen — all of which are single Telegram messages under the
922
+ * 4096-character cap. The bound therefore has to leave generous headroom for the
923
+ * surrounding template in ANY of the 12 locales, which is why it sits far below
924
+ * that cap rather than just under it. Past it the text is REJECTED, never
925
+ * truncated: it is the operator's own words, and this all-buttons flow exists so
926
+ * they type it exactly once.
927
+ */
928
+ exports.reminderTextMaxLength = 1000;
929
+ /**
930
+ * Longest reminder name kept, INCLUDING the ellipsis. Matches `slugify`'s
931
+ * `slugMaxLength` so the derived name and the id minted from it stay in step.
932
+ */
933
+ exports.reminderNameMaxLength = 40;
934
+ /**
935
+ * Name used when the body text carries no letter or digit (whitespace only,
936
+ * punctuation only, emoji only). A stable fallback rather than an empty row —
937
+ * mirrors `slugify`'s `'job'` guarantee, which the id generator relies on.
938
+ */
939
+ exports.reminderNameFallback = 'reminder';
940
+ const reminderNameEllipsis = '…';
941
+ /**
942
+ * Longest reminder text echoed back in the wizard's running summary. The summary
943
+ * exists so the operator can SEE what was kept after a stale-instant retry — not to
944
+ * reprint the whole note, which would push the step's question off the screen.
945
+ */
946
+ exports.reminderSummaryTextMaxLength = 80;
947
+ /**
948
+ * @description `text` shortened to at most `maxLength` characters — the ellipsis
949
+ * counted INSIDE that budget — cut on a word boundary when there is one. `''` when
950
+ * the budget cannot even hold the ellipsis, leaving the caller to decide what an
951
+ * empty result means.
952
+ *
953
+ * Shared by the derived reminder name, the wizard's text summary and the list-row
954
+ * button caption, so they shorten identically instead of growing three slightly
955
+ * different cuts.
956
+ */
957
+ function getShortenedText(text, maxLength) {
958
+ if (text.length <= maxLength)
959
+ return text;
960
+ const budget = maxLength - reminderNameEllipsis.length;
961
+ if (budget <= 0)
962
+ return '';
963
+ const head = text.slice(0, budget);
964
+ const lastSpaceIndex = head.lastIndexOf(' ');
965
+ const cut = lastSpaceIndex > 0 ? head.slice(0, lastSpaceIndex) : head;
966
+ return `${cut.trimEnd()}${reminderNameEllipsis}`;
967
+ }
968
+ /**
969
+ * @description Derive a reminder's display name from its body text. The wizard
970
+ * deliberately never ASKS for a name — one less typing step — so the list rows
971
+ * and the card show the first words of the reminder itself.
972
+ *
973
+ * Whitespace is collapsed (a multi-line body must not render as a ragged row) and
974
+ * the result never exceeds {@link reminderNameMaxLength}.
975
+ */
976
+ function getReminderNameFromText(text) {
977
+ const collapsed = text.replace(/\s+/g, ' ').trim();
978
+ if (!/[\p{L}\p{N}]/u.test(collapsed))
979
+ return exports.reminderNameFallback;
980
+ return getShortenedText(collapsed, exports.reminderNameMaxLength);
981
+ }
982
+ // ─── hub, list and card plans ────────────────────────────────────────
983
+ /** Reminders listed per page. One row each, so the keyboard stays phone-sized. */
984
+ exports.reminderListPageSize = 8;
985
+ /**
986
+ * @description The hub keyboard: «add» and «list» SIDE BY SIDE on one row (the
987
+ * locked layout — «close» is a separate row the caller appends). «list» is drawn
988
+ * only when there is something to list; a list button that opens an empty screen is
989
+ * a dead end. The count rides as a label var so the caller can render "📋 List (3)".
990
+ *
991
+ * `isAddOffered` is the per-thread REMINDER cap (counted apart from the agent's
992
+ * schedule cap): at the cap there is nothing an «add» tap could create, so the
993
+ * button is not drawn (same dead-end reasoning as the list button). The caller
994
+ * owns that comparison — the cap lives in the scheduler store, not here — and it
995
+ * defaults to offering «add».
996
+ */
997
+ function buildReminderHubKeyboard(reminderCount, options = {}) {
998
+ const actionRow = [];
999
+ if (options.isAddOffered !== false) {
1000
+ actionRow.push(buildKeyButton(exports.reminderLabelKeys.hubAdd, exports.reminderAddCallback));
1001
+ }
1002
+ if (reminderCount > 0) {
1003
+ actionRow.push({
1004
+ label: { kind: 'key', key: exports.reminderLabelKeys.hubList, vars: { count: reminderCount } },
1005
+ callbackData: buildReminderListPageCallback(0),
1006
+ });
1007
+ }
1008
+ // Both suppressed at once (an empty thread under a non-positive cap): an EMPTY
1009
+ // row is not a keyboard Telegram accepts, so no row is emitted at all.
1010
+ return actionRow.length === 0 ? [] : [actionRow];
1011
+ }
1012
+ /**
1013
+ * @description Build a list page: one row per reminder, then the prev/next
1014
+ * navigation (only the arrows the page can actually use), then back-to-hub.
1015
+ *
1016
+ * A row's CAPTION is the reminder's name plus its schedule — planned as a `listRow`
1017
+ * label, because the schedule has to be localized and only the caller holds `t`.
1018
+ * The whole list therefore rides the buttons, and the message text stays a short
1019
+ * header (the split the `/model` picker uses).
1020
+ *
1021
+ * Row buttons carry the ABSOLUTE index into `rows` — pagination is the one
1022
+ * index-based thing here, and opening a card is non-destructive. The card's
1023
+ * delete button carries the reminder's own id instead (see
1024
+ * {@link buildReminderDeleteCallback}).
1025
+ */
1026
+ function buildReminderListPlan(rows, page) {
1027
+ const { slice, currentPage, totalPages } = (0, paginateList_1.paginateList)(rows, page, exports.reminderListPageSize);
1028
+ const pageOffset = currentPage * exports.reminderListPageSize;
1029
+ const keyboard = slice.map((row, sliceIndex) => [
1030
+ {
1031
+ label: { kind: 'listRow', name: row.name, descriptor: row.descriptor },
1032
+ callbackData: buildReminderCardCallback(pageOffset + sliceIndex),
1033
+ },
1034
+ ]);
1035
+ const hasPrev = currentPage > 0;
1036
+ const hasNext = currentPage < totalPages - 1;
1037
+ const navigationRow = [];
1038
+ if (hasPrev) {
1039
+ navigationRow.push(buildKeyButton(exports.reminderLabelKeys.listPrev, buildReminderListPageCallback(currentPage - 1)));
1040
+ }
1041
+ if (hasNext) {
1042
+ navigationRow.push(buildKeyButton(exports.reminderLabelKeys.listNext, buildReminderListPageCallback(currentPage + 1)));
1043
+ }
1044
+ if (navigationRow.length > 0)
1045
+ keyboard.push(navigationRow);
1046
+ keyboard.push([buildKeyButton(exports.reminderLabelKeys.listBackToHub, exports.reminderHubCallback)]);
1047
+ return { rows: slice, currentPage, totalPages, hasPrev, hasNext, keyboard };
1048
+ }
1049
+ /**
1050
+ * @description Resolve a tapped list row back to its reminder, or `null` when
1051
+ * the index no longer resolves (the list shrank between render and tap). Stale
1052
+ * keyboards stay tappable forever in Telegram, so an out-of-range index must
1053
+ * answer "expired" rather than open a neighbour — same contract as
1054
+ * `getTimezoneAt`.
1055
+ */
1056
+ function getReminderRowAt(rows, reminderIndex) {
1057
+ if (!Number.isInteger(reminderIndex) || reminderIndex < 0)
1058
+ return null;
1059
+ return rows[reminderIndex] ?? null;
1060
+ }
1061
+ /**
1062
+ * @description The list page a row at `reminderIndex` was rendered on — what the
1063
+ * card's back button returns to. Derived from the index rather than carried in
1064
+ * the callback, so the card needs no extra state to come back to where it was
1065
+ * opened from.
1066
+ */
1067
+ function getReminderCardBackPage(reminderIndex) {
1068
+ return Math.max(0, Math.floor(reminderIndex / exports.reminderListPageSize));
1069
+ }
1070
+ /** Build a reminder's card, or `null` for a stale row index. */
1071
+ function buildReminderCardPlan(rows, reminderIndex) {
1072
+ const row = getReminderRowAt(rows, reminderIndex);
1073
+ if (row === null)
1074
+ return null;
1075
+ const listPage = getReminderCardBackPage(reminderIndex);
1076
+ return {
1077
+ row,
1078
+ listPage,
1079
+ keyboard: [
1080
+ [buildKeyButton(exports.reminderLabelKeys.cardDelete, buildReminderDeleteCallback(row.id))],
1081
+ [buildKeyButton(exports.reminderLabelKeys.cardBackToList, buildReminderListPageCallback(listPage))],
1082
+ ],
1083
+ };
1084
+ }
1085
+ /** Resolve a delete tap by the reminder ID baked into its `callback_data`. */
1086
+ function getReminderDeleteTarget(rows, reminderId) {
1087
+ const row = rows.find((candidate) => candidate.id === reminderId);
1088
+ return row === undefined ? { kind: 'notFound' } : { kind: 'found', row };
1089
+ }
1090
+ // ─── date / time formatting ──────────────────────────────────────────
1091
+ function padTwo(value) {
1092
+ return value.toString().padStart(2, '0');
1093
+ }
1094
+ /** `{hour: 9, minute: 0}` → `"09:00"`. Locale-neutral, hence a literal label. */
1095
+ function formatReminderTime(time) {
1096
+ return `${padTwo(time.hour)}:${padTwo(time.minute)}`;
1097
+ }
1098
+ /** A local `Date` → its calendar date as `YYYY-MM-DD` (never UTC-shifted). */
1099
+ function formatReminderDateIso(date) {
1100
+ return `${date.getFullYear()}-${padTwo(date.getMonth() + 1)}-${padTwo(date.getDate())}`;
1101
+ }
1102
+ /** Date-grid button label: `DD.MM` — digits only, so no locale is implied. */
1103
+ function formatReminderDayMonth(date) {
1104
+ return `${padTwo(date.getDate())}.${padTwo(date.getMonth() + 1)}`;
1105
+ }
1106
+ /**
1107
+ * @description The local calendar date `offsetDays` after the day containing
1108
+ * `nowMs`. Built from the date PARTS rather than by adding 24h so a DST
1109
+ * transition cannot shift the result into the neighbouring day.
1110
+ */
1111
+ function getLocalDateAtDayOffset(nowMs, offsetDays) {
1112
+ const base = new Date(nowMs);
1113
+ return new Date(base.getFullYear(), base.getMonth(), base.getDate() + offsetDays);
1114
+ }
1115
+ /**
1116
+ * @description The local instant a `once` reminder fires at.
1117
+ *
1118
+ * The calendar date is probed on its OWN midnight instant, independently of the
1119
+ * picked time, so the two causes of failure stay distinguishable: `2026-02-31` is
1120
+ * no date at all (`invalidDate`), while `02:30` on a spring-forward day is a real
1121
+ * date whose wall clock simply skips that hour (`invalidTime`) — the JS `Date`
1122
+ * constructor silently shifts such a time forward instead of refusing it.
1123
+ */
1124
+ function createReminderInstant(dateIso, hour, minute) {
1125
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(dateIso);
1126
+ if (!match)
1127
+ return { ok: false, code: 'invalidDate' };
1128
+ const year = Number(match[1]);
1129
+ const month = Number(match[2]);
1130
+ const day = Number(match[3]);
1131
+ const dateProbe = new Date(year, month - 1, day);
1132
+ if (dateProbe.getFullYear() !== year ||
1133
+ dateProbe.getMonth() !== month - 1 ||
1134
+ dateProbe.getDate() !== day) {
1135
+ return { ok: false, code: 'invalidDate' };
1136
+ }
1137
+ const instant = new Date(year, month - 1, day, hour, minute, 0, 0);
1138
+ if (instant.getHours() !== hour || instant.getMinutes() !== minute) {
1139
+ return { ok: false, code: 'invalidTime' };
1140
+ }
1141
+ return { ok: true, instant };
1142
+ }
1143
+ /** `YYYY-MM-DD` → the compact `YYYYMMDD` a date callback carries. */
1144
+ function encodeCompactDate(dateIso) {
1145
+ return dateIso.split('-').join('');
1146
+ }
1147
+ /**
1148
+ * @description `YYYYMMDD` → `YYYY-MM-DD`, or `null` when the digits are not a
1149
+ * real calendar date (`20260231`). Validated here so an impossible date can
1150
+ * never reach the spec assembler.
1151
+ */
1152
+ function decodeCompactDate(rawDate) {
1153
+ if (rawDate.length !== compactDateLength || !/^\d+$/.test(rawDate))
1154
+ return null;
1155
+ const year = Number(rawDate.slice(0, 4));
1156
+ const month = Number(rawDate.slice(4, 6));
1157
+ const day = Number(rawDate.slice(6, 8));
1158
+ const probe = new Date(year, month - 1, day);
1159
+ if (probe.getFullYear() !== year || probe.getMonth() !== month - 1 || probe.getDate() !== day) {
1160
+ return null;
1161
+ }
1162
+ return `${year.toString().padStart(4, '0')}-${padTwo(month)}-${padTwo(day)}`;
1163
+ }
1164
+ //# sourceMappingURL=reminderWizard.js.map