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,1416 @@
1
+ import * as fs from 'fs';
2
+ import { type ApiRetryState, type JsonStreamTailOffset, type LimitEpisodeMarker, type PendingQuestionState, type ResolvedThreadDisplayPrefs, type SeenWatermark, type ThreadDisplayPrefs } from './types';
3
+ import { type SessionKey } from './sessionKey';
4
+ import type { ClaudeUsageSnapshot } from './utils/claudeUsage';
5
+ import { type FallbackChainEntry } from './utils/fallbackChain';
6
+ import type { ScheduleRecord } from './scheduler/types';
7
+ import type { OpenRequestState, UnreleasedRequestAlert } from './requests/types';
8
+ import { type RequestGroupKey } from './requests/requestGroup';
9
+ import type { Locale } from './i18n';
10
+ import type { LimitHeldPrompt } from './utils/limitHeldPrompts';
11
+ /**
12
+ * @description On-disk state for the multi-thread telegram bot.
13
+ *
14
+ * Replaces the legacy `~/.telegram-bot-messages.json` (which only persisted
15
+ * `messageIds` per user) with a richer per-`SessionKey` schema:
16
+ *
17
+ * - `bindings[key]` → thread is attached to a subdir under `WORK_ROOT`
18
+ * - `agents[key]` → which adapter the thread is using, model, session ids
19
+ * - `messages[key]` → message ids tracked by `/clear`
20
+ *
21
+ * Schema source: plan §9. Field additions for D14 (`claudeSessionId`), §13.19
22
+ * (`opencodeSessionId`) and D49 (`bindings[key].closed`) are inlined here.
23
+ *
24
+ * The file is rewritten atomically (`writeFile(tmp) → fsync(fd) → rename →
25
+ * fsync(parentDir)`, plan §13.14, T4). Concurrent mutations to the same
26
+ * `SessionKey` are serialised by a per-key async lock (plan §13.15, E3).
27
+ *
28
+ * **This module is intentionally NOT yet imported from `bot.ts`.** Plan §11
29
+ * Этап 2 wires state in only on the following commit (Этап 3) — keeping the
30
+ * landing surgical.
31
+ */
32
+ /** Current schema version stamped into `state.json`. Bump on breaking layout changes. */
33
+ export declare const STATE_SCHEMA_VERSION = 1;
34
+ export interface BindingData {
35
+ /** Subdirectory under `WORK_ROOT` this thread is attached to. */
36
+ subdir: string;
37
+ /** ISO timestamp the binding was first created. */
38
+ createdAt: string;
39
+ /**
40
+ * Whether the forum topic is currently marked closed in Telegram.
41
+ * Toggled by `forum_topic_closed` / `forum_topic_reopened` events
42
+ * (plan §13.10, D49). Closed binding is preserved on purpose — closing
43
+ * is reversible, deletion isn't.
44
+ */
45
+ closed?: boolean;
46
+ /**
47
+ * Telegram message id of the per-thread pinned status banner, if any.
48
+ * Set on first `/bind`, edited on every agent state change, unpinned +
49
+ * cleared on `/unbind`. Plan §11 Этап 7 / §20.5 / D52 area. Persisting
50
+ * the id lets a bot restart re-find the pinned message instead of
51
+ * pinning a fresh banner above it (which Telegram allows, producing a
52
+ * stack of stale pins).
53
+ */
54
+ pinnedStatusMessageId?: number;
55
+ /**
56
+ * Last banner text we successfully sent/edited for {@link pinnedStatusMessageId}.
57
+ * The in-memory `pinnedStatusTextCache` is rebuilt from this at boot so the
58
+ * startup banner-refresh wave skips the `editMessageText` round-trip when the
59
+ * computed banner equals what is already displayed (B8) — every restart
60
+ * otherwise re-edits ~9 identical banners, each a wasted "message is not
61
+ * modified" 400 burning the chat-wide send budget. Cleared whenever the
62
+ * banner message is unpinned/deleted or its id is nulled, so a stale text
63
+ * can never suppress a needed edit for a fresh banner message.
64
+ */
65
+ pinnedStatusText?: string;
66
+ /**
67
+ * Forum-topic display name, when known. The Bot API can't query a topic
68
+ * title on demand — the bot only learns it from events (`forum_topic_created`
69
+ * / `forum_topic_edited`) or when it creates the topic itself (`/new`).
70
+ * Persisted so the thread-context preamble (see `threadContextPreamble.ts`)
71
+ * can tell the agent which topic it works in across restarts. Absent for
72
+ * pre-existing topics until a rename event reveals the name.
73
+ */
74
+ topicName?: string;
75
+ }
76
+ export interface AgentData {
77
+ /** Adapter name, e.g. `'claude'` or `'opencode'`. */
78
+ name: string;
79
+ /** Optional model override (e.g. `'sonnet'`, `'anthropic/claude-3-5-sonnet'`). */
80
+ model?: string;
81
+ /**
82
+ * UUID we pass via `claude --session-id <uuid>` on a fresh start and via
83
+ * `claude --resume <uuid>` on later attaches (plan §13.1, D14). Lets two
84
+ * threads share one `workDir` without their histories cross-contaminating.
85
+ */
86
+ claudeSessionId?: string;
87
+ /**
88
+ * Server-assigned OpenCode session id. Used to re-attach the SSE stream
89
+ * after a bot restart (plan §13.19).
90
+ */
91
+ opencodeSessionId?: string;
92
+ /**
93
+ * Per-thread "seen" watermark advanced at each turn end (see
94
+ * {@link SeenWatermark}). Lets a bot restart compute how much output the agent
95
+ * produced WHILE the bot was down and recover it via the reattach recap,
96
+ * instead of silently dropping it. Optional so older state files stay valid —
97
+ * a missing value means "watermark unknown" → the recap uses its fallback
98
+ * (no-count) path. Backend-specific representation; only one sub-field is set.
99
+ */
100
+ seenWatermark?: SeenWatermark;
101
+ /**
102
+ * The digest of the bot-MCP tool definitions the json-stream process was
103
+ * started with (`SchedulerMcpHandle.getToolDigest`). Compared at adopt after a
104
+ * bot restart: a process whose tools are stale is stopped at its next idle
105
+ * point and resumed with the current ones (lifecycle plan L4). Absent for a
106
+ * row written before the digest was tracked — read as stale.
107
+ */
108
+ mcpToolDigest?: string;
109
+ /**
110
+ * json-stream stdout tail position (line-boundary byte offset into the
111
+ * external session's `stdout.jsonl`), advanced as the tail consumes lines.
112
+ * Lets a restarted bot resume the surviving process's output exactly where
113
+ * processing stopped and replay only the downtime gap (plan
114
+ * 2026-07-05-jsonstream-restart-isolation). Optional so older state files
115
+ * stay valid — a missing value seeds the adopt tail to the current EOF.
116
+ * Cleared together with the session ids on explicit release.
117
+ */
118
+ jsonStreamTail?: JsonStreamTailOffset;
119
+ /**
120
+ * When THIS thread's current agent session began, as a local-offset ISO
121
+ * string (`2026-06-27T19:42:10+04:00`, same shape `/timestamps` uses — never
122
+ * `Z`). Set to "now" on a FRESH start (`startAgentSession`) and on a
123
+ * `/sessions` resume PICK (when the thread began using that session — the
124
+ * original transcript creation time isn't cheaply recoverable). PRESERVED
125
+ * across a bot restart (reattach never overwrites an existing value; only
126
+ * backfills a missing one, e.g. an older state file) and across an adapter
127
+ * switch (`/claude_mode`, same conversation). Cleared together with the
128
+ * session ids on explicit release (`/quit`, `/new`, `/unbind`). Surfaced by
129
+ * `/status`. Optional so older state files stay valid.
130
+ */
131
+ startedAt?: string;
132
+ }
133
+ /**
134
+ * One added Claude account profile (`/account add <name>`): the directory is
135
+ * `DATA_DIR/claude-profiles/<name>/`; this record is what the picker shows about it
136
+ * plus room for the balancing phases. All fields but `createdAt` are optional —
137
+ * a record is written the moment the directory exists, before any login.
138
+ */
139
+ export interface ClaudeProfileRecord {
140
+ /** ISO instant the profile was added. */
141
+ createdAt: string;
142
+ /** From the last `claude auth status --json` read under the profile's directory. */
143
+ loggedIn?: boolean;
144
+ email?: string;
145
+ /** `pro` / `max` / `team` / `enterprise` — whatever the CLI reports. */
146
+ subscriptionType?: string;
147
+ orgName?: string;
148
+ /** ISO instant of that read. */
149
+ statusCheckedAt?: string;
150
+ /**
151
+ * Until this instant the profile is known to be at a usage limit (a json-stream session of it was REJECTED
152
+ * on a window; the mark is the window's reset) and the `claude_profiles` ranking leaves it out. The
153
+ * auto-switch phase will act on it; nothing else writes it.
154
+ */
155
+ limitedUntil?: string;
156
+ /** The last usage snapshot read for the profile (`utils/claudeUsage.ts`): the endpoint poll or a stream frame. */
157
+ usage?: ClaudeUsageSnapshot;
158
+ /**
159
+ * Only on the hidden `default` record: the operator signed `~/.claude` out through `/accounts`. The account
160
+ * is left out of the list and every ranking until a probe finds it signed in again.
161
+ */
162
+ isRemoved?: boolean;
163
+ }
164
+ /** The session id of the backend family a thread switched away from, kept for a switch back. */
165
+ export interface ParkedSession {
166
+ /** The adapter the id belongs to. */
167
+ adapterName: string;
168
+ claudeSessionId?: string;
169
+ opencodeSessionId?: string;
170
+ /** ISO instant of the switch. */
171
+ parkedAt: string;
172
+ }
173
+ /**
174
+ * Per-thread compact-on-idle bookkeeping (F2), persisted so a bot restart does
175
+ * not erase the evidence the idle watchdog reasons about. The three instants are
176
+ * epoch ms; each is optional and reads back as `0` when absent, so a state file
177
+ * written before this existed behaves exactly like an untracked thread.
178
+ *
179
+ * The entry is bound to the agent SESSION it describes (`sessionId`), not merely
180
+ * to the thread: the instants mean "THIS session has had a turn since ITS last
181
+ * compaction", so the moment the thread's session is replaced (`/new`, `/quit`
182
+ * then start, a backend switch to a different agent, a `/sessions` resume of an
183
+ * older session) the old marker is meaningless and must read as the initial state.
184
+ * Teardown DOES clear the entry, but that depends on a `stopped`/`closed` event
185
+ * actually firing — a killed or crashed process, or any future path that swaps a
186
+ * session without it, would silently inherit the previous session's marker.
187
+ * Keying on the session id makes the reset self-enforcing regardless of which
188
+ * lifecycle events fired. Deliberate consequence: `/claude_mode` switches the
189
+ * Claude backend by RESUMING the same conversation and keeps `claudeSessionId`, so
190
+ * the marker survives that switch — correct, since the context really is the same
191
+ * and really does have something to compress.
192
+ *
193
+ * - `lastActivityAt` — last REAL activity (user message, command, forwarded
194
+ * prompt, agent output). The countdown is armed from this, so a restart
195
+ * continues where it left off instead of re-arming a flat 55 minutes.
196
+ * - `lastTurnEndAt` — last agent turn that produced output, i.e. the proof
197
+ * there is something to compress.
198
+ * - `lastCompactionAt` — last compaction of this thread (any trigger: manual
199
+ * `/compact`, the F1 tool, or an F2 idle fire).
200
+ *
201
+ * The fire guard is `lastTurnEndAt > lastCompactionAt`, which used to live in a
202
+ * process-local map: after a restart both were `0`, the comparison was false, and
203
+ * (there being no reschedule by D2) the feature stayed dead in every quiet topic
204
+ * until the operator wrote there.
205
+ */
206
+ export interface CompactIdleTrackingEntry {
207
+ /**
208
+ * The agent session these instants describe (`claudeSessionId` /
209
+ * `opencodeSessionId` of the thread's {@link AgentData} at stamping time). A
210
+ * read whose current session id differs — or is unknown — yields all zeros.
211
+ */
212
+ sessionId?: string;
213
+ lastActivityAt?: number;
214
+ lastTurnEndAt?: number;
215
+ lastCompactionAt?: number;
216
+ }
217
+ /**
218
+ * Coarse step (ms) the activity/turn stamps must move past the last PERSISTED
219
+ * value before a save is scheduled. Load-bearing for cost, not correctness:
220
+ * those two stamps are written on EVERY agent output chunk, and `state.json` is
221
+ * rewritten WHOLE (atomically, with fsync) per save — so a `scheduleSave()` per
222
+ * chunk would turn a streaming turn into a debounced disk-rewrite loop. A
223
+ * 60-second granularity is irrelevant against the 55-minute idle threshold.
224
+ */
225
+ export declare const compactIdleTrackingPersistStepMs = 60000;
226
+ export interface StateV1 {
227
+ version: number;
228
+ bindings: Record<string, BindingData>;
229
+ agents: Record<string, AgentData>;
230
+ messages: Record<string, number[]>;
231
+ /**
232
+ * Numeric chat id of the forum supergroup discovered via auto-pairing,
233
+ * persisted so the operator doesn't have to look up the `-100…` id by
234
+ * hand. Only consulted when `ALLOWED_GROUP_ID` env is unset; a numeric
235
+ * env value always wins and disables pairing.
236
+ */
237
+ pairedGroupId?: number;
238
+ /**
239
+ * Epoch milliseconds of the last successful heartbeat write — the bot
240
+ * stamps this every ~10s while running. On boot we compare `now -
241
+ * lastHeartbeatAt` against {@link HOT_RELOAD_THRESHOLD_MS}: small gaps
242
+ * are a hot reload (quiet reattach, keep buffered updates), large gaps
243
+ * (or `undefined` for fresh installs / older state files) are a cold
244
+ * start (allow the per-thread reattach ERROR notice — workDir vanished —
245
+ * optionally drop the stale update backlog).
246
+ *
247
+ * Optional so old `state.json` files (created before heartbeats existed)
248
+ * remain valid — `loadStateFile`'s shape check doesn't require it, and
249
+ * a missing value is interpreted as "treat as cold start", which is the
250
+ * conservative default we want.
251
+ */
252
+ lastHeartbeatAt?: number;
253
+ /**
254
+ * Output-trace toggle (`/trace`). `tracedThreads` holds the {@link SessionKey}
255
+ * strings explicitly opted into tracing; `traceAllThreads` traces every
256
+ * thread (cross-thread forensics). Persisted so the toggle survives a hot
257
+ * rebuild mid-debug — the writer state in `outputTrace.ts` is re-seeded from
258
+ * these at boot. `traceAllThreads` defaults to ON when absent (always-on
259
+ * observability); it is stored EXPLICITLY (incl. `false`) so a `/trace off
260
+ * all` is durable and not re-enabled by the default on the next boot.
261
+ * Lifecycle-independent: only `/trace` mutates them, never session teardown.
262
+ */
263
+ tracedThreads?: string[];
264
+ traceAllThreads?: boolean;
265
+ /**
266
+ * Explicit `/language` overrides, keyed by Telegram chat id (DM chat or whole
267
+ * forum supergroup). These beat Telegram's `from.language_code` until changed
268
+ * or reset to auto. Optional so older state files stay valid.
269
+ */
270
+ chatLocaleOverrides?: Record<string, Locale>;
271
+ /**
272
+ * Last supported Telegram client language seen in each chat, keyed by chat id.
273
+ * Used for bot-originated async events (agent output, scheduled runs) where no
274
+ * live Telegram update carries `from.language_code`. Optional for old state.
275
+ */
276
+ chatTelegramLocales?: Record<string, Locale>;
277
+ /**
278
+ * Threads with the `/timestamps` prompt-injection toggle ON (default OFF —
279
+ * absent list means no thread injects). When ON, every forwarded prompt gets
280
+ * the send-time prepended as a local-offset ISO top line (agent-facing only,
281
+ * never posted to the topic). Same persistence shape as `tracedThreads`
282
+ * (deduped/sorted {@link SessionKey} strings, dropped when empty) and equally
283
+ * lifecycle-independent: only `/timestamps` mutates it, never session
284
+ * teardown. Optional so older state files stay valid.
285
+ */
286
+ timestampThreads?: string[];
287
+ /**
288
+ * The operator's timezone, GLOBAL for the whole bot instance (not per-chat —
289
+ * the mechanism is `process.env.TZ`, which is process-global by nature). Holds
290
+ * either an IANA name (`Europe/Moscow`) or a fixed offset (`+04:00`), as
291
+ * written by `/timezone`. Absent means "use the host zone", so an install that
292
+ * never ran `/timezone` behaves exactly as it did before the setting existed —
293
+ * which is why the field is optional rather than defaulted on disk.
294
+ * Lifecycle-independent: only `/timezone` mutates it, never session teardown.
295
+ */
296
+ timezone?: string;
297
+ /**
298
+ * Providers the operator hid from the `/model` picker, GLOBAL for the whole
299
+ * bot instance (not per-topic). The only lever that works for a provider
300
+ * OpenCode enables from an environment variable (`openrouter` ←
301
+ * `OPENROUTER_API_KEY`), which `DELETE /auth/:id` cannot remove. Hiding
302
+ * filters the PICKER only — an explicit `/model <provider/model>` still
303
+ * resolves a hidden provider, so a saved model pref never breaks. Same
304
+ * persistence shape as `tracedThreads` (deduped/sorted, dropped when empty)
305
+ * and equally lifecycle-independent: only `/model` mutates it, never session
306
+ * teardown. Optional so older state files stay valid.
307
+ */
308
+ hiddenModelProviders?: string[];
309
+ /**
310
+ * `provider/model` ids picked through `/model` on OpenCode topics, most
311
+ * recent first, deduplicated and capped (`utils/modelRecentPlan.ts`). GLOBAL
312
+ * for the whole bot instance: the "Recently used" shortcut of the `/model`
313
+ * picker exists to hop between favourite models of DIFFERENT providers, and
314
+ * a favourite is a favourite in every topic. Entries whose provider or model
315
+ * left the server's catalog are kept on disk (the provider may come back)
316
+ * and filtered at render time. Dropped when empty so a default install
317
+ * leaves no trace; only `/model` mutates it, never session teardown.
318
+ * Optional so older state files stay valid.
319
+ */
320
+ recentModels?: string[];
321
+ /**
322
+ * Compact-on-idle toggle (`/compact_on_idle`). `compactOnIdleEnabled` is the
323
+ * INSTANCE-WIDE default, driven from the General topic; absent ⇒ ON (the
324
+ * feature ships enabled, mirroring `traceAllThreads`), stored EXPLICITLY (incl.
325
+ * `false`) so a General «Disable» is durable and not re-enabled by the default
326
+ * on the next boot. `compactOnIdleOverrides` holds per-thread explicit
327
+ * overrides keyed by {@link SessionKey} string — a present entry (true OR false)
328
+ * wins over the global default; absent ⇒ follow the default. Both optional so
329
+ * older state files stay valid; lifecycle-independent (only `/compact_on_idle`
330
+ * mutates them, never session teardown).
331
+ */
332
+ compactOnIdleEnabled?: boolean;
333
+ compactOnIdleOverrides?: Record<string, boolean>;
334
+ /**
335
+ * Full-compaction-summary toggle (`/compact_summary`). Same shape and discipline
336
+ * as the `compactOnIdle*` pair above: `compactSummaryEnabled` is the
337
+ * INSTANCE-WIDE default driven from General (absent ⇒ OFF — the operator wants a
338
+ * compaction to end in one short line; stored EXPLICITLY incl. `false` so a General
339
+ * choice is durable), and `compactSummaryOverrides` holds per-thread explicit
340
+ * overrides keyed by {@link SessionKey} string, a present entry winning over the
341
+ * default. Both optional so older state files stay valid; lifecycle-independent
342
+ * (only `/compact_summary` mutates them, never session teardown).
343
+ */
344
+ compactSummaryEnabled?: boolean;
345
+ compactSummaryOverrides?: Record<string, boolean>;
346
+ /**
347
+ * Threads whose compact-on-idle user-LATCH is spent (D2). A thread lands here
348
+ * the instant an idle-compaction FIRES and is removed only by the next genuine
349
+ * USER message — so idle compaction runs at most once per user-active period,
350
+ * and (crucially) a bot restart cannot re-enable a second fire: the reattach
351
+ * re-arms the idle timer ONLY for threads absent from this set. Same
352
+ * deduped/sorted {@link SessionKey}-string shape as `timestampThreads` (dropped
353
+ * when empty), and equally lifecycle-independent — only a fire and a user
354
+ * message mutate it, never session teardown. Optional so older state files stay
355
+ * valid (a missing value = no thread latched).
356
+ */
357
+ compactIdleLatchedThreads?: string[];
358
+ /**
359
+ * Per-thread compact-on-idle bookkeeping keyed by {@link SessionKey} string —
360
+ * the idle COUNTDOWN's restart guard (see {@link CompactIdleTrackingEntry} for
361
+ * the three instants and why losing them disabled the feature after every
362
+ * restart). Entries are dropped on session teardown (a fresh session must get
363
+ * the full window) and the whole map is dropped once empty, so an idle bot
364
+ * leaves a clean `state.json`. Optional so older state files stay valid.
365
+ */
366
+ compactIdleTracking?: Record<string, CompactIdleTrackingEntry>;
367
+ /**
368
+ * Limit auto-continue toggle (`/auto_continue_limits`). `autoContinueOnLimitEnabled` is
369
+ * the INSTANCE-WIDE default, driven from the General topic; absent ⇒ ON (the
370
+ * behaviour was unconditional before the toggle existed), stored EXPLICITLY
371
+ * (incl. `false`) so a General «Disable» is durable and not re-enabled by the
372
+ * default on the next boot. `autoContinueOnLimitOverrides` holds per-thread
373
+ * explicit overrides keyed by {@link SessionKey} string — a present entry (true
374
+ * OR false) wins over the global default. Both optional so older state files
375
+ * stay valid; lifecycle-independent (only `/auto_continue_limits` mutates them, never
376
+ * session teardown). Same shape discipline as the `compactOnIdle*` pair.
377
+ */
378
+ autoContinueOnLimitEnabled?: boolean;
379
+ autoContinueOnLimitOverrides?: Record<string, boolean>;
380
+ /**
381
+ * Claude account profiles (`/account`, `utils/claudeProfiles.ts`). `claudeProfiles` is the registry of the
382
+ * profiles the operator ADDED, keyed by name, plus ONE hidden record for `default` (`~/.claude` itself) that
383
+ * carries only its probe result, usage snapshot and limit mark — the registry getters never list it, the
384
+ * usage readers (`getClaudeProfileInfo`) do. A record holds what the picker shows (the last `claude auth
385
+ * status` read), the usage snapshot and the limit mark. `claudeProfileDefault` is the INSTANCE-WIDE pick driven from General
386
+ * (absent ⇒ `default`); `claudeProfileOverrides` the per-thread picks keyed by {@link SessionKey} string, a
387
+ * present entry winning over the default. Same discipline as the `autoContinueOnLimit*` pair: optional so
388
+ * older state files stay valid, lifecycle-independent (only `/account` mutates them).
389
+ */
390
+ claudeProfiles?: Record<string, ClaudeProfileRecord>;
391
+ claudeProfileDefault?: string;
392
+ claudeProfileOverrides?: Record<string, string>;
393
+ /**
394
+ * Auto-switch of the Claude account on a usage limit (`/account`, `utils/claudeLimitSwitch.ts`): whether a
395
+ * topic whose profile hits a limit is moved to another signed-in profile with room by itself. The same
396
+ * instance-default + per-thread-override pair as `autoContinueOnLimit*`, but absent ⇒ OFF — the switch is an
397
+ * account-policy decision the operator opts into.
398
+ */
399
+ claudeAutoSwitchOnLimitEnabled?: boolean;
400
+ claudeAutoSwitchOnLimitOverrides?: Record<string, boolean>;
401
+ /**
402
+ * The fallback chain (`/fallback`, `utils/fallbackChain.ts`): the instance-wide priority list of backend +
403
+ * account / provider + model a topic continues on when its own hits a usage limit. Validated on read
404
+ * (`normaliseFallbackChain`), so a hand edit never breaks the boot. `openCodeModelLimits` are the limit marks
405
+ * of OpenCode `provider/model` labels (ISO instants), the twin of `ClaudeProfileRecord.limitedUntil`.
406
+ * `parkedSessions` keep, per thread, the session id of the backend family the thread LEFT (a cross-backend
407
+ * fallback switch, a `/claude` ↔ `/opencode` change), so a later switch back resumes that conversation; a
408
+ * release (`/new`, `/quit`) drops the parked id with the live ones.
409
+ */
410
+ fallbackChain?: FallbackChainEntry[];
411
+ openCodeModelLimits?: Record<string, string>;
412
+ parkedSessions?: Record<string, ParkedSession>;
413
+ /**
414
+ * Persisted scheduled jobs, keyed by {@link ScheduleRecord.id}. Optional so
415
+ * older state files (created before the scheduler feature) stay valid —
416
+ * `loadStateFile`'s shape check doesn't require it and a missing value is an
417
+ * empty schedule set. The crash-critical `nextRunAt` inside each record is
418
+ * why the engine calls {@link StateStore.flush} after every fire rather than
419
+ * relying on the debounced save.
420
+ */
421
+ schedules?: Record<string, ScheduleRecord>;
422
+ /**
423
+ * Secret keying the HMAC tokens the bot mints for its own scheduler MCP
424
+ * server (see `scheduler/mcpSurface.ts`). Generated once on first use
425
+ * (`getSchedulerMcpSecret`) and persisted so the tokens injected into agent
426
+ * sessions stay valid across restarts. Optional so older state files stay
427
+ * valid — a missing value is created lazily on the first read.
428
+ */
429
+ schedulerMcpSecret?: string;
430
+ /**
431
+ * The loopback port the bot's scheduler MCP server bound on a prior boot (see
432
+ * `scheduler/mcpSurface.ts`). The listen port is EPHEMERAL by default (`0` →
433
+ * an OS-assigned port), which changes on every restart; persisting the bound
434
+ * port lets a later boot reuse it so the `telegramBot` registrations injected
435
+ * into agent sessions (which embed `http://127.0.0.1:<port>/mcp`) stay valid
436
+ * across restarts instead of pointing at a dead port. Not written when the
437
+ * operator fixes the port via `SCHEDULER_MCP_PORT`. Optional so older state
438
+ * files stay valid — a missing value means "no port to reuse, pick fresh".
439
+ */
440
+ schedulerMcpPort?: number;
441
+ /**
442
+ * In-flight interactive agent questions, keyed by {@link SessionKey} string.
443
+ * Persisted so a pending question survives a bot restart / hot reload: the
444
+ * in-memory `pendingQuestions` map (see `bot.ts`) is otherwise lost, leaving
445
+ * the agent's question tool blocked forever and the posted Telegram option
446
+ * buttons dead ("no pending question"). The persisted `messageId` lets the
447
+ * OLD buttons resolve once the map is re-armed at boot, so no question is
448
+ * re-posted. Optional so older state files stay valid — a missing value is
449
+ * an empty set. Restored at boot only for threads whose session reattached
450
+ * and is active; otherwise dropped (the question is unreachable).
451
+ */
452
+ pendingQuestions?: Record<string, PendingQuestionState>;
453
+ /**
454
+ * Armed auto-retries after a provider-side API error, keyed by
455
+ * {@link SessionKey} string. Persisted so a pending retry survives a bot
456
+ * restart / hot reload: the in-memory `apiRetries` map (see `bot.ts`) is
457
+ * otherwise lost, so an agent that died on a rate-limit / usage-limit error
458
+ * would never get its scheduled nudge — especially a multi-hour usage-limit
459
+ * wait. The persisted `fireAt` lets boot re-arm the timer (or fire one
460
+ * immediate catch-up when the time already passed). A record means ARMED: it is
461
+ * cleared once the retry's kick has run its course (its nudge forwarded, or dropped
462
+ * for good), else every restart would fire the kick again — but kept while the nudge
463
+ * only waits in the in-memory startup buffer, which a restart loses. Optional so
464
+ * older state files stay valid — a missing value is an empty set. Restored at boot
465
+ * only after sessions are reattached, so the kick lands in a live session.
466
+ */
467
+ apiRetries?: Record<string, ApiRetryState>;
468
+ /**
469
+ * Prompts held during an armed usage-limit wait (Jira plan R23), keyed by
470
+ * {@link SessionKey} string, oldest first. Kept apart from `apiRetries`: the
471
+ * wait can end without its resume (the operator writes, skips or disables it,
472
+ * the session ends), and the prompts must outlive it until they reach a
473
+ * session (`utils/limitHeldPromptQueue.ts`). Optional — absent when empty.
474
+ */
475
+ limitHeldPrompts?: Record<string, LimitHeldPrompt[]>;
476
+ /**
477
+ * Open requests of the request ledger (`requests/requestLedger.ts`), keyed by
478
+ * the serialized request GROUP (conversation + requester, `requests/requestGroup.ts`)
479
+ * — at most ONE per group (a new request of the group supersedes the open one;
480
+ * another requester's request in the same conversation stays open beside it).
481
+ * Persisted so an unanswered request, its counters
482
+ * and its next wake-up survive a bot restart. Closed requests move to the
483
+ * append-only `DATA_DIR/requests.jsonl`. Optional so older state files stay
484
+ * valid — a missing value is an empty set.
485
+ */
486
+ openRequests?: Record<string, OpenRequestState>;
487
+ /**
488
+ * Per conversation (serialized {@link SessionKey}), the message id of the
489
+ * LATEST pinned `answer_request` answer (request/answer plan S8): a new answer
490
+ * unpins it and takes its place, so a topic never keeps two answers pinned —
491
+ * across restarts too. Optional, dropped when empty.
492
+ */
493
+ answerPins?: Record<string, number>;
494
+ /**
495
+ * Alerts of CLOSED requests that are not released yet (Telegram: still
496
+ * pinned), keyed by request id. A request that closes while it holds an alert
497
+ * lands here in the same save as its close, and leaves only once the release
498
+ * succeeded — so a crash between the close and the unpin re-releases at the
499
+ * next boot instead of leaving the pin forever. Optional — absent when empty.
500
+ */
501
+ unreleasedRequestAlerts?: Record<string, UnreleasedRequestAlert>;
502
+ /**
503
+ * Boot-recovery markers: per {@link SessionKey} string, the `stdout.jsonl`
504
+ * identity the recovery last armed a limit wait from (see
505
+ * {@link LimitEpisodeMarker}). It is what stops a hot reload from resurrecting a
506
+ * wait that was already settled — «⏭ Skip once», a user takeover, or a give-up
507
+ * all clear `apiRetries`, leaving the same trailing error in the log. Optional so
508
+ * older state files stay valid; dropped when the thread's session ids are
509
+ * released or its binding goes away.
510
+ */
511
+ limitEpisodesRecovered?: Record<string, LimitEpisodeMarker>;
512
+ /**
513
+ * Per-thread OpenCode output-verbosity rendering preferences (thinking /
514
+ * tool-results / sub-agent display), keyed by {@link SessionKey} string. Each
515
+ * record only stores NON-default overrides — an absent field (or absent
516
+ * record) means "use the locked default" (see {@link StateStore.getDisplayPrefs}),
517
+ * which keeps `state.json` clean (same delete-when-default idiom as `/trace`).
518
+ * Optional so older state files stay valid — a missing value is "all threads
519
+ * on defaults". Lifecycle-independent: only `/thinking` / `/tool-results` /
520
+ * `/subagent` mutate it, never session teardown. These are bot-side rendering
521
+ * concerns, NOT agent behavior — they never change what is sent to OpenCode.
522
+ */
523
+ displayPrefs?: Record<string, ThreadDisplayPrefs>;
524
+ /**
525
+ * Per-thread TRANSIENT status-frame message ids currently on screen (the
526
+ * "✽ working…" liveness frame, the live thinking indicator, the dedicated
527
+ * sub-agent status), keyed by {@link SessionKey} string. Persisted ONLY so an
528
+ * UNGRACEFUL exit (crash / SIGKILL — the graceful shutdown sweep in `bot.ts`
529
+ * never ran) can delete whatever frame was on screen on the NEXT boot, after
530
+ * reattach (the reattached session is idle, so a leftover frame is stale by
531
+ * definition). Cosmetic, so it rides the debounced save — losing the last
532
+ * <=500ms window before a crash just falls back to the pre-fix orphan for that
533
+ * one frame (S1 covers every graceful path exactly). Optional so older state
534
+ * files stay valid — a missing value is an empty set; an empty list drops the
535
+ * key so an idle bot leaves a clean `state.json`.
536
+ */
537
+ transientFrames?: Record<string, number[]>;
538
+ }
539
+ /**
540
+ * @description Promise-chain per-key lock. The map holds the tail of each
541
+ * key's queue; new callers attach to the tail and append themselves. Errors
542
+ * in one task don't poison followers — the chain only carries scheduling,
543
+ * not values. See plan §13.15 (E3).
544
+ *
545
+ * Exported for unit tests (plan §11 Этап 7, R5).
546
+ */
547
+ export declare class KeyLock {
548
+ private chains;
549
+ withLock<T>(keyStr: string, fn: () => Promise<T>): Promise<T>;
550
+ }
551
+ /**
552
+ * @description Best-effort atomic write of `content` to `finalPath`.
553
+ *
554
+ * Sequence: `writeFile(tmp)` → `fsync(tmp)` → `rename(tmp, final)` →
555
+ * `fsync(parentDir)`. The last step is critical: without it, `rename`
556
+ * survives crashes but the new directory entry can be lost on a power
557
+ * cut on ext4 (plan §13.14, fix to T4).
558
+ *
559
+ * Tmp files are colocated with the final file so `rename` stays on the
560
+ * same filesystem (cross-fs rename would degrade to copy+unlink and break
561
+ * atomicity). Permissions on the tmp default to `0600` so a state file
562
+ * containing model preferences / session ids isn't world-readable on a
563
+ * shared host.
564
+ *
565
+ * Directory `fsync` is wrapped in a soft try/catch: on Windows opening a
566
+ * directory for read isn't supported and would throw. Our deployment
567
+ * target is Linux/Mac (plan §17.4 «Windows: not our case»), so logging
568
+ * and continuing is the right trade.
569
+ */
570
+ export declare function writeFileAtomic(finalPath: string, content: string, options?: {
571
+ mode?: number;
572
+ }): Promise<void>;
573
+ /**
574
+ * @description Try to load the state file. On a successful parse return the
575
+ * structured state. On parse failure archive the broken file to
576
+ * `state.json.corrupted-<iso>` and return `null` so the caller can start fresh.
577
+ *
578
+ * Three cases the caller cares about:
579
+ *
580
+ * 1. File doesn't exist → `null`, no archive. Fresh install.
581
+ * 2. File exists, parses → state object.
582
+ * 3. File exists, parses fails → archived, `null` returned.
583
+ * We also handle EPERM / EACCES on read here for completeness — same
584
+ * treatment: archive (if possible) and start fresh.
585
+ *
586
+ * Exported for unit tests (plan §11 Этап 7, R6).
587
+ */
588
+ export declare function loadStateFile(filePath: string): Promise<{
589
+ ok: true;
590
+ state: StateV1;
591
+ } | {
592
+ ok: false;
593
+ reason: 'missing';
594
+ } | {
595
+ ok: false;
596
+ reason: 'corrupted';
597
+ archivedTo: string | null;
598
+ error: string;
599
+ }>;
600
+ /**
601
+ * @description Migrate the legacy single-folder bot's message-id file.
602
+ *
603
+ * Old layout: `~/.telegram-bot-messages.json` keyed by raw user id.
604
+ * The 2.0 release intentionally doesn't try to merge those ids into the
605
+ * new `SessionKey`-keyed schema — the routing model changed too much for
606
+ * a clean mapping (plan §9). We just rename the file so it's preserved
607
+ * for the user's records and so it stops being read on every boot.
608
+ *
609
+ * Returns the archive path if migration happened, `null` otherwise.
610
+ */
611
+ export declare function migrateLegacyMessageIdsFile(): Promise<string | null>;
612
+ export interface StateStoreOptions {
613
+ /** Override the debounce window for tests. */
614
+ saveDebounceMs?: number;
615
+ }
616
+ /**
617
+ * @description Stateful, async-safe store for `state.json`.
618
+ *
619
+ * Construction is cheap (no I/O). Call `init()` once at boot before any
620
+ * setters fire; init loads or initialises the file, performs the legacy
621
+ * migration, and resolves. Setters return promises so callers can await
622
+ * the resulting persisted state when correctness matters more than
623
+ * throughput; non-critical writes are debounced.
624
+ */
625
+ export declare class StateStore {
626
+ private readonly dataDir;
627
+ private readonly statePath;
628
+ private readonly saveDebounceMs;
629
+ private state;
630
+ /** True if the previous on-disk state file was unreadable / corrupt. */
631
+ private corruptedOnLoad;
632
+ /** Archive path if the previous on-disk state was corrupted. */
633
+ private corruptedArchivePath;
634
+ /** Backup path if the legacy file was migrated. */
635
+ private legacyMigrationPath;
636
+ private saveTimer;
637
+ /** Tail of the chained writes so two flushes don't try to rename simultaneously. */
638
+ private writeChain;
639
+ /**
640
+ * Last compact-on-idle activity/turn stamp each thread actually asked to
641
+ * PERSIST, used to apply {@link compactIdleTrackingPersistStepMs}. In-memory
642
+ * only and deliberately NOT written to disk — it is bookkeeping ABOUT the
643
+ * bookkeeping, and after a restart the first stamp simply schedules one save.
644
+ */
645
+ private readonly compactIdleTrackingSavedAt;
646
+ private readonly keyLock;
647
+ constructor(dataDir: string, options?: StateStoreOptions);
648
+ /**
649
+ * @description One-shot boot. Creates `dataDir` if missing, performs
650
+ * legacy migration, loads the existing state file (or starts fresh on
651
+ * corruption).
652
+ */
653
+ init(): Promise<void>;
654
+ /** Path of the live state file (for logging / docs / smoke-tests). */
655
+ get stateFilePath(): string;
656
+ /** True iff the previous boot's state file was unreadable on this start. */
657
+ wasCorruptedOnLoad(): boolean;
658
+ /** Where the previous corrupted file was moved, if archival succeeded. */
659
+ getCorruptedArchivePath(): string | null;
660
+ /** Where the legacy `~/.telegram-bot-messages.json` was archived, if it existed. */
661
+ getLegacyMigrationPath(): string | null;
662
+ /**
663
+ * @description Run `fn` while holding the per-key lock for `key`. Concurrent
664
+ * calls for the SAME key are serialised; calls for different keys run in
665
+ * parallel. Failure in one holder does NOT propagate to followers (the lock
666
+ * is for serialisation only; error handling is each caller's job).
667
+ */
668
+ withLock<T>(key: SessionKey, fn: () => Promise<T>): Promise<T>;
669
+ getBinding(key: SessionKey): BindingData | null;
670
+ setBinding(key: SessionKey, subdir: string, options?: {
671
+ closed?: boolean;
672
+ topicName?: string;
673
+ }): Promise<void>;
674
+ /**
675
+ * @description Persist the forum-topic display name for a thread. Used by
676
+ * `forum_topic_edited` (rename) when a binding already exists. No-op (no
677
+ * save) when the binding is absent or the name is unchanged — symmetric to
678
+ * {@link setBindingPinnedStatusText}.
679
+ */
680
+ setBindingTopicName(key: SessionKey, topicName: string): Promise<void>;
681
+ setBindingClosed(key: SessionKey, closed: boolean): Promise<void>;
682
+ /**
683
+ * @description Persist the pinned status banner's message id for a thread,
684
+ * or clear it (pass `null`). Skipped if the binding doesn't exist — we
685
+ * don't ever want a pinned-message row dangling without a parent binding.
686
+ *
687
+ * Caller is expected to actually pin / unpin in Telegram around this
688
+ * call; this method only updates the on-disk pointer. Plan §20.5.
689
+ */
690
+ setBindingPinnedStatusMessageId(key: SessionKey, messageId: number | null): Promise<void>;
691
+ /**
692
+ * @description Persist the last banner text sent/edited for a thread, or
693
+ * clear it (pass `null`). Mirrors {@link setBindingPinnedStatusMessageId}:
694
+ * skipped if the binding doesn't exist, and a no-op (no save) when the value
695
+ * is unchanged. Read back at boot to seed `pinnedStatusTextCache` so the
696
+ * startup refresh wave skips identical-banner edits (B8).
697
+ */
698
+ setBindingPinnedStatusText(key: SessionKey, text: string | null): Promise<void>;
699
+ removeBinding(key: SessionKey): Promise<void>;
700
+ listBindings(): Array<{
701
+ key: SessionKey;
702
+ data: BindingData;
703
+ }>;
704
+ /**
705
+ * @description Find every thread currently bound to a given subdir.
706
+ * Plan §10.6 names this for `/bind` UX warning «📁 уже работают треды: ...»
707
+ * — one folder may be reached from several threads (D7).
708
+ */
709
+ listKeysForSubdir(subdir: string): SessionKey[];
710
+ getAgent(key: SessionKey): AgentData | null;
711
+ /**
712
+ * @description Upsert agent state for a thread. `name` is required (we
713
+ * don't keep an agent record without a backend choice); the rest of the
714
+ * fields are patched onto whatever exists.
715
+ */
716
+ setAgent(key: SessionKey, data: {
717
+ name: string;
718
+ } & Partial<Omit<AgentData, 'name'>>): Promise<void>;
719
+ removeAgent(key: SessionKey): Promise<void>;
720
+ getClaudeSessionId(key: SessionKey): string | null;
721
+ /**
722
+ * @description Persist the Claude `--session-id` UUID for `key`.
723
+ *
724
+ * If the thread already has an agent record, only the `claudeSessionId`
725
+ * field is patched — we keep whatever `name` was previously chosen so a
726
+ * thread currently set to `opencode` doesn't get silently flipped to
727
+ * `claude` just because we recorded a UUID. The bot picks the adapter
728
+ * via {@link setAgent} or `setThreadAdapter` — those are the right
729
+ * places to change `name`.
730
+ */
731
+ setClaudeSessionId(key: SessionKey, uuid: string): Promise<void>;
732
+ getOpenCodeSessionId(key: SessionKey): string | null;
733
+ /** Symmetric to {@link setClaudeSessionId} — does not flip `agent.name`. */
734
+ setOpenCodeSessionId(key: SessionKey, id: string): Promise<void>;
735
+ /**
736
+ * @description Advance the per-thread {@link SeenWatermark} (set at each turn
737
+ * end by the adapters via the injected writer). Merges onto the EXISTING agent
738
+ * row only — never flips `agent.name` (symmetric to
739
+ * {@link setClaudeSessionId} / {@link setOpenCodeSessionId}) and, unlike them,
740
+ * never CREATES a row: a watermark is meaningless without a live agent session
741
+ * (which always recorded its row first), so a write for an unknown thread is a
742
+ * no-op, not a dangling agent row.
743
+ */
744
+ setSeenWatermark(key: SessionKey, watermark: SeenWatermark): Promise<void>;
745
+ /**
746
+ * @description Persist the json-stream stdout tail offset (advanced by the
747
+ * adapter's tail poller through the injected writer, sealed by the shutdown
748
+ * `flush()`). Merge-only like {@link setSeenWatermark}: never flips
749
+ * `agent.name` and never creates a row — an offset is meaningless without
750
+ * the agent row its session recorded first.
751
+ */
752
+ setJsonStreamTail(key: SessionKey, tail: JsonStreamTailOffset): Promise<void>;
753
+ /**
754
+ * @description Persist the session-start timestamp (a local-offset ISO string;
755
+ * see {@link AgentData.startedAt}). Merge-only like {@link setSeenWatermark}:
756
+ * never flips `agent.name` and never CREATES a row — the caller records the
757
+ * agent row (via `setAgent` / `persistAdapterSessionIds`) first, so a write
758
+ * for an unknown thread is a no-op rather than a dangling agent row.
759
+ */
760
+ setAgentStartedAt(key: SessionKey, startedAt: string): Promise<void>;
761
+ /** Persist the tool digest a json-stream process was started with (see {@link AgentData.mcpToolDigest}); merge-only. */
762
+ setAgentMcpToolDigest(key: SessionKey, mcpToolDigest: string): Promise<void>;
763
+ /**
764
+ * @description Release both persisted session ids (and the json-stream tail
765
+ * offset, which is meaningless without its session; plus the session-start
766
+ * timestamp, which belongs to the session going away) for `key` while keeping
767
+ * `name` / `model`. Called on explicit user stop (`/quit`, `/quit-all`,
768
+ * `/new`, `/unbind`) so a later bot restart won't auto-reattach a session
769
+ * the user deliberately ended. No-op when the thread has no agent record.
770
+ */
771
+ clearAgentSessionIds(key: SessionKey): Promise<void>;
772
+ getParkedSession(key: SessionKey): ParkedSession | null;
773
+ /** Park the id of the family the thread leaves (`null` clears). Debounced. */
774
+ setParkedSession(key: SessionKey, parked: ParkedSession | null): Promise<void>;
775
+ private dropParkedSession;
776
+ getMessageIds(key: SessionKey): number[];
777
+ /** Append IDs to the bounded in-memory ring while the caller holds the key lock. */
778
+ private appendMessageIds;
779
+ /**
780
+ * @description Append a message id to the per-thread tracking list and
781
+ * trim to the most recent `MESSAGE_ID_RING_CAP`. Anything older falls off
782
+ * the end — Telegram won't let `deleteMessages` touch messages older than
783
+ * 48h anyway (plan §11 Этап 3, U2).
784
+ */
785
+ pushMessageId(key: SessionKey, msgId: number): Promise<void>;
786
+ /** Atomically append and durably persist one Telegram response's message IDs. */
787
+ pushMessageIds(key: SessionKey, messageIds: number[]): Promise<void>;
788
+ /** Atomically hand tracked IDs to `/clear_messages` while later pushes remain tracked. */
789
+ takeMessageIds(key: SessionKey, additionalIds?: number[]): Promise<number[]>;
790
+ /**
791
+ * @description Stamp `lastHeartbeatAt = now` (ms) and schedule a debounced
792
+ * save. Called by the bot on a ~10s interval while running so the next
793
+ * boot can tell a hot reload (gap < threshold) from a real cold start
794
+ * (gap large, or no stamp at all on a fresh install).
795
+ *
796
+ * Cheap by design: a one-field mutation that piggy-backs on the existing
797
+ * debounced save loop. We don't `flush()` here — losing the last 10s
798
+ * heartbeat on a hard crash just biases the next boot toward
799
+ * "cold start", which is the conservative direction.
800
+ */
801
+ touchHeartbeat(now?: number): void;
802
+ /**
803
+ * @description Time since the last persisted heartbeat in ms, or `null`
804
+ * if the state file has no heartbeat stamp (fresh install, or pre-feature
805
+ * state file). `null` should be treated as "unknown → assume cold start".
806
+ *
807
+ * Read at boot to decide hot-vs-cold-start, ideally BEFORE the first
808
+ * `touchHeartbeat()` call or `state.flush()` (otherwise the value
809
+ * compares against ourselves and always looks like a hot reload).
810
+ */
811
+ getDowntimeMs(now?: number): number | null;
812
+ /** The auto-paired forum supergroup id, or `null` if never paired. */
813
+ getPairedGroupId(): number | null;
814
+ /**
815
+ * @description Persist the auto-paired group id and flush immediately.
816
+ *
817
+ * Unlike per-thread mutations this is a rare, one-shot critical write:
818
+ * if the process dies right after pairing we must not lose the id and
819
+ * fall back into pairing mode on the next boot. So we `flush()` rather
820
+ * than debounce.
821
+ */
822
+ setPairedGroupId(groupId: number): Promise<void>;
823
+ /**
824
+ * @description Current persisted trace toggle. `threadKeys` are the
825
+ * {@link SessionKey} strings opted into tracing; `allThreads` traces
826
+ * everything. `allThreads` defaults to TRUE on a fresh or pre-feature state
827
+ * file (always-on observability — only an explicit `/trace off all` turns it
828
+ * off, stored as a durable `false`); `threadKeys` defaults empty. Read at boot
829
+ * to seed `outputTrace.ts`.
830
+ */
831
+ getTraceConfig(): {
832
+ allThreads: boolean;
833
+ threadKeys: string[];
834
+ };
835
+ /**
836
+ * @description Persist the trace toggle. Not crash-critical (a debug aid), so
837
+ * it rides the debounced save loop rather than an immediate `flush()`. The
838
+ * `tracedThreads` array is normalised to a deduped, sorted form so the
839
+ * on-disk shape is stable across toggles; an empty list is dropped.
840
+ *
841
+ * `traceAllThreads` is stored EXPLICITLY as a boolean (including `false`):
842
+ * the all-threads default is now ON ({@link getTraceConfig}), so a `/trace
843
+ * off all` must be DURABLE and distinguishable from "never set" (which reads
844
+ * back as the ON default). Dropping it on `false` would silently re-enable
845
+ * tracing on the next boot.
846
+ */
847
+ setTraceConfig(config: {
848
+ allThreads: boolean;
849
+ threadKeys: string[];
850
+ }): Promise<void>;
851
+ getChatLocaleOverride(chatId: number): Locale | null;
852
+ getChatTelegramLocale(chatId: number): Locale | null;
853
+ setChatLocaleOverride(chatId: number, locale: Locale | null): Promise<void>;
854
+ setChatTelegramLocale(chatId: number, locale: Locale): Promise<void>;
855
+ /**
856
+ * @description Whether `/timestamps` is ON for `key` (default OFF). When ON,
857
+ * `forwardPromptToAgent` prepends the send-time as a local-offset ISO top
858
+ * line to every forwarded prompt.
859
+ */
860
+ checkIsTimestampsEnabled(key: SessionKey): boolean;
861
+ /**
862
+ * @description Persist the per-thread `/timestamps` toggle. Mirrors
863
+ * {@link setTraceConfig}'s shape discipline: the list is deduped + sorted so
864
+ * the on-disk form is stable, and an empty list is dropped (an all-defaults
865
+ * install leaves no trace in `state.json`). Not crash-critical, so it rides
866
+ * the debounced save loop.
867
+ */
868
+ setTimestampsEnabled(key: SessionKey, isEnabled: boolean): Promise<void>;
869
+ /**
870
+ * @description Providers currently hidden from the `/model` picker, in the
871
+ * stable sorted on-disk order. Empty when nothing is hidden (the default).
872
+ */
873
+ getHiddenModelProviders(): string[];
874
+ /**
875
+ * @description Hide/show one provider in the `/model` picker. Mirrors
876
+ * {@link setTimestampsEnabled}'s shape discipline: deduped + sorted so the
877
+ * on-disk form is stable across toggles, and an empty list is dropped (a
878
+ * default install leaves no trace in `state.json`). A picker preference is
879
+ * not crash-critical, so it rides the debounced save loop.
880
+ */
881
+ setModelProviderHidden(provider: string, isHidden: boolean): Promise<void>;
882
+ /**
883
+ * @description The recently used `provider/model` ids, most recent first.
884
+ * Empty on a fresh install. Unfiltered — the picker drops the entries the
885
+ * live catalog no longer serves (`getRecentModelsInCatalog`).
886
+ */
887
+ getRecentModels(): string[];
888
+ /**
889
+ * @description Record a successful model pick: `modelId` moves to the head of
890
+ * the list (deduplicated, capped by {@link pushRecentModel}). Same shape
891
+ * discipline as {@link setModelProviderHidden} — an empty list is dropped —
892
+ * and, like it, a picker preference rides the debounced save loop.
893
+ */
894
+ addRecentModel(modelId: string): Promise<void>;
895
+ /**
896
+ * @description The instance-wide compact-on-idle default (driven from the
897
+ * General topic). ON when unset — same always-on default as
898
+ * {@link getTraceConfig}'s `allThreads`.
899
+ */
900
+ getCompactOnIdleGlobalDefault(): boolean;
901
+ /**
902
+ * @description The per-thread compact-on-idle override, or `undefined` when the
903
+ * thread follows the instance default. A present value (true OR false) wins.
904
+ */
905
+ getCompactOnIdleOverride(key: SessionKey): boolean | undefined;
906
+ /**
907
+ * @description Whether compact-on-idle is effectively enabled for `key`: the
908
+ * per-thread override if set, else the instance default (OFF when unset).
909
+ */
910
+ checkIsCompactOnIdleEnabled(key: SessionKey): boolean;
911
+ /**
912
+ * @description Set the instance-wide compact-on-idle default (from General).
913
+ * Stored EXPLICITLY as a boolean (incl. `false`) so a «Disable» is durable and
914
+ * distinguishable from "never set" (which reads back as the ON default) —
915
+ * mirrors {@link setTraceConfig}'s `traceAllThreads` discipline. Debounced (a
916
+ * preference, not crash-critical).
917
+ */
918
+ setCompactOnIdleGlobalDefault(enabled: boolean): Promise<void>;
919
+ /**
920
+ * @description Set the per-thread compact-on-idle override (from a regular
921
+ * topic). Stored explicitly (a present true/false wins over the global
922
+ * default); the whole map is dropped once empty so an all-default instance
923
+ * leaves a clean `state.json`. Debounced.
924
+ */
925
+ setCompactOnIdleOverride(key: SessionKey, enabled: boolean): Promise<void>;
926
+ /**
927
+ * @description The instance-wide full-compaction-summary default (driven from the
928
+ * General topic). OFF when unset, unlike {@link getCompactOnIdleGlobalDefault}:
929
+ * a compaction ends in one short line unless the summary is turned on.
930
+ */
931
+ getCompactSummaryGlobalDefault(): boolean;
932
+ /**
933
+ * @description The per-thread full-summary override, or `undefined` when the
934
+ * thread follows the instance default. A present value (true OR false) wins.
935
+ */
936
+ getCompactSummaryOverride(key: SessionKey): boolean | undefined;
937
+ /**
938
+ * @description Whether the full compaction summary is posted for `key`: the
939
+ * per-thread override if set, else the instance default (ON when unset).
940
+ */
941
+ checkIsCompactSummaryEnabled(key: SessionKey): boolean;
942
+ /**
943
+ * @description Set the instance-wide full-summary default (from General). Stored
944
+ * EXPLICITLY as a boolean (incl. `false`) so a choice is durable and
945
+ * distinguishable from "never set", which reads back as the OFF default. Debounced
946
+ * (a preference, not crash-critical) — mirrors
947
+ * {@link setCompactOnIdleGlobalDefault}.
948
+ */
949
+ setCompactSummaryGlobalDefault(enabled: boolean): Promise<void>;
950
+ /**
951
+ * @description Set the per-thread full-summary override (from a regular topic).
952
+ * Stored explicitly (a present true/false wins over the global default).
953
+ * Debounced — mirrors {@link setCompactOnIdleOverride}.
954
+ */
955
+ setCompactSummaryOverride(key: SessionKey, enabled: boolean): Promise<void>;
956
+ /**
957
+ * @description Whether `key`'s compact-on-idle user-latch is spent (D2): an
958
+ * idle-compaction already fired this user-active period and no genuine USER
959
+ * message has re-armed it since. Read by the idle watchdog's fire guard and by
960
+ * the timer-arming path (a latched thread never re-arms — so a restart can't
961
+ * re-fire). Default `false` (never latched).
962
+ */
963
+ checkIsCompactIdleLatched(key: SessionKey): boolean;
964
+ /**
965
+ * @description Set/clear `key`'s compact-on-idle user-latch (D2). Set on a
966
+ * fire, cleared on a genuine USER message / fresh session start. Mirrors
967
+ * {@link setTimestampsEnabled}'s shape discipline (deduped + sorted, dropped
968
+ * when empty) and rides the debounced save loop — the persistence is only a
969
+ * restart guard, so losing the last <=500ms is at worst one extra fire.
970
+ */
971
+ setCompactIdleLatched(key: SessionKey, isLatched: boolean): Promise<void>;
972
+ /**
973
+ * @description `key`'s persisted compact-on-idle instants, with every absent
974
+ * field read back as `0`. `0` is the explicit "no history" value both readers
975
+ * rely on: the arming path takes it as "use the full idle window" and the fire
976
+ * guard's `lastTurnEndAt > lastCompactionAt` as "nothing to compress" — so a
977
+ * pre-feature state file behaves exactly like an untracked thread.
978
+ *
979
+ * All zeros are ALSO returned whenever the entry does not belong to the thread's
980
+ * CURRENT agent session (a different `sessionId`, or either id unknown): the
981
+ * instants describe one session's context, so a session swap must reset the
982
+ * marker, and deciding that here — rather than in a teardown handler — makes it
983
+ * true regardless of which lifecycle events fired (a killed process emits none).
984
+ * Unknown-means-zero is conservative in the right direction: at worst the topic
985
+ * waits one more full idle window.
986
+ */
987
+ getCompactIdleTracking(key: SessionKey): {
988
+ lastActivityAt: number;
989
+ lastTurnEndAt: number;
990
+ lastCompactionAt: number;
991
+ };
992
+ /**
993
+ * @description Stamp `key`'s last REAL activity — the instant the idle
994
+ * countdown is measured from. Called on every agent output chunk, so the write
995
+ * is COARSE: the in-memory value is always assigned (readers are exact), but a
996
+ * save is scheduled only once the value has moved a full
997
+ * {@link compactIdleTrackingPersistStepMs} past what was last persisted. The
998
+ * assigned value also rides along for free on the next save the ~10s
999
+ * {@link touchHeartbeat} loop schedules, so the coarse step costs nothing in
1000
+ * correctness — at worst the persisted stamp trails the live one by under a
1001
+ * minute, against a 55-minute threshold.
1002
+ */
1003
+ noteCompactIdleActivity(key: SessionKey, now?: number): void;
1004
+ /**
1005
+ * @description Stamp that an agent turn produced output for `key` — the proof
1006
+ * there is something to compress (the fire guard compares this against
1007
+ * `lastCompactionAt`). Same per-chunk call frequency and therefore the same
1008
+ * coarse-save rule as {@link noteCompactIdleActivity}.
1009
+ */
1010
+ noteCompactIdleTurnEnd(key: SessionKey, now?: number): void;
1011
+ /**
1012
+ * @description Stamp that `key` was just compacted (any trigger: manual
1013
+ * `/compact`, the F1 tool, an F2 idle fire), closing the fire guard until the
1014
+ * next turn produces output. Rare, so it always schedules a save — persisting it
1015
+ * is what stops a restart from re-compacting a session nothing has touched
1016
+ * since.
1017
+ */
1018
+ setCompactIdleCompactedAt(key: SessionKey, now?: number): Promise<void>;
1019
+ /**
1020
+ * @description Drop `key`'s compact-on-idle bookkeeping (session teardown:
1021
+ * `/new`, `/quit`, unbind). Deliberately a full delete rather than a reset —
1022
+ * with no entry the next session start finds `lastActivityAt === 0` and gets
1023
+ * the FULL idle window, which is exactly the wanted behaviour for a fresh
1024
+ * session, so no special case is needed on the start path. The whole map is
1025
+ * dropped once empty so an idle bot leaves a clean `state.json`.
1026
+ */
1027
+ clearCompactIdleTracking(key: SessionKey): Promise<void>;
1028
+ /**
1029
+ * Assign one high-frequency compact-on-idle stamp in memory and schedule a save
1030
+ * only past the coarse step (see {@link noteCompactIdleActivity}). Synchronous
1031
+ * (no key lock) on purpose: it runs on the output hot path, and a single-field
1032
+ * assignment cannot interleave with another write the way a read-modify-write
1033
+ * of a whole record can.
1034
+ */
1035
+ private stampCompactIdleTracking;
1036
+ /**
1037
+ * The thread's CURRENT agent session id — `claudeSessionId` else
1038
+ * `opencodeSessionId` from the persisted {@link AgentData} — or `undefined` when
1039
+ * the thread has neither. A raw `/terminal` shell has no session id and cannot be
1040
+ * compacted anyway, so "no id" means the compact-on-idle marker has nothing to
1041
+ * bind to: reads return zeros and stamps are skipped, keeping `state.json` clean.
1042
+ */
1043
+ private getAgentSessionId;
1044
+ /**
1045
+ * @description The instance-wide limit-auto-continue default (driven from the
1046
+ * General topic). ON when unset — the auto-resume was unconditional before the
1047
+ * toggle, so the default must preserve it.
1048
+ */
1049
+ getAutoContinueOnLimitGlobalDefault(): boolean;
1050
+ /**
1051
+ * @description The per-thread limit-auto-continue override, or `undefined` when
1052
+ * the thread follows the instance default. A present value (true OR false) wins.
1053
+ */
1054
+ getAutoContinueOnLimitOverride(key: SessionKey): boolean | undefined;
1055
+ /**
1056
+ * @description Whether limit auto-continue is effectively enabled for `key`: the
1057
+ * per-thread override if set, else the instance default (ON when unset).
1058
+ */
1059
+ checkIsAutoContinueOnLimitEnabled(key: SessionKey): boolean;
1060
+ /**
1061
+ * @description Set the instance-wide limit-auto-continue default (from General).
1062
+ * Stored EXPLICITLY as a boolean (incl. `false`) so a «Disable» is durable and
1063
+ * distinguishable from "never set" (which reads back as the ON default) —
1064
+ * mirrors {@link setCompactOnIdleGlobalDefault}. Debounced (a preference, not
1065
+ * crash-critical).
1066
+ */
1067
+ setAutoContinueOnLimitGlobalDefault(enabled: boolean): Promise<void>;
1068
+ /**
1069
+ * @description Set the per-thread limit-auto-continue override (from a regular
1070
+ * topic). Stored explicitly (a present true/false wins over the global
1071
+ * default); the map is created lazily on the first override, so an all-default
1072
+ * instance leaves a clean `state.json`. Debounced.
1073
+ */
1074
+ setAutoContinueOnLimitOverride(key: SessionKey, enabled: boolean | null): Promise<void>;
1075
+ /** Remove one thread's override from a toggle map (`null` enabled = back to the instance default); drops an emptied map. */
1076
+ private dropLimitOverride;
1077
+ /** The instance-wide auto-switch default (driven from General). OFF when unset: the switch is opt-in. */
1078
+ getClaudeAutoSwitchOnLimitGlobalDefault(): boolean;
1079
+ /** The per-thread auto-switch override, or `undefined` when the thread follows the instance default. */
1080
+ getClaudeAutoSwitchOnLimitOverride(key: SessionKey): boolean | undefined;
1081
+ /** Whether the bot may move `key` to another Claude account by itself when its own hits a usage limit. */
1082
+ checkIsClaudeAutoSwitchOnLimitEnabled(key: SessionKey): boolean;
1083
+ /** Set the instance-wide auto-switch default (from General); stored explicitly, like {@link setAutoContinueOnLimitGlobalDefault}. */
1084
+ setClaudeAutoSwitchOnLimitGlobalDefault(enabled: boolean): Promise<void>;
1085
+ /** Set the per-thread auto-switch override (from a regular topic; `null` = follow the instance default again); the map is created on the first override. */
1086
+ setClaudeAutoSwitchOnLimitOverride(key: SessionKey, enabled: boolean | null): Promise<void>;
1087
+ /** The chain as persisted, validated entry by entry; `[]` when none was set. */
1088
+ getFallbackChain(): FallbackChainEntry[];
1089
+ /** Replace the chain (an empty one is removed from the file). Flushed at once: the picker re-reads it right after. */
1090
+ setFallbackChain(chain: readonly FallbackChainEntry[]): Promise<void>;
1091
+ /** The limit marks of OpenCode models (`provider/model` → ISO instant), expired ones included. */
1092
+ getOpenCodeModelLimits(): Readonly<Record<string, string>>;
1093
+ getOpenCodeModelLimitedUntil(label: string): string | undefined;
1094
+ /** Mark an OpenCode model limited until the instant (`null` clears). Debounced. */
1095
+ setOpenCodeModelLimitedUntil(label: string, limitedUntil: string | null): void;
1096
+ /** The added profiles by name — `default` is never among them (its hidden record is `getClaudeProfileInfo`'s). */
1097
+ getClaudeProfileRecords(): Readonly<Record<string, ClaudeProfileRecord>>;
1098
+ /** An ADDED profile's record; `undefined` for an unknown name and for `default`. */
1099
+ getClaudeProfileRecord(name: string): ClaudeProfileRecord | undefined;
1100
+ /** The names the resolver treats as known: the added profiles (`default` is implicit). */
1101
+ getClaudeProfileNames(): Set<string>;
1102
+ /** What is known about ANY profile, `default` included (its probe result, usage snapshot, limit mark). */
1103
+ getClaudeProfileInfo(name: string): ClaudeProfileRecord | undefined;
1104
+ /** Every record, the hidden `default` one included — the usage ranking's input. */
1105
+ getAllClaudeProfileInfos(): Readonly<Record<string, ClaudeProfileRecord>>;
1106
+ /**
1107
+ * @description Store a profile's usage snapshot (debounced: a stream frame may update it every API request).
1108
+ * `default` gets its hidden record on first write; an unknown added name is ignored (removed meanwhile).
1109
+ */
1110
+ setClaudeProfileUsage(name: string, usage: ClaudeUsageSnapshot): void;
1111
+ /** The limit mark (`null` clears it); same record rules as the usage. Debounced. */
1112
+ setClaudeProfileLimitedUntil(name: string, limitedUntil: string | null): void;
1113
+ /** The mutable record behind `name`: created for `default`, `null` for an added name that is not registered. */
1114
+ private touchClaudeProfileInfo;
1115
+ /**
1116
+ * @description Add or update a profile record (merge; `createdAt` is kept once written). Flushed
1117
+ * immediately rather than debounced: the record is the registry entry of a directory that already holds
1118
+ * a login, and a crash between the two would leave an orphan directory the picker never shows.
1119
+ */
1120
+ upsertClaudeProfileRecord(name: string, patch: Partial<ClaudeProfileRecord>): Promise<void>;
1121
+ /**
1122
+ * @description Drop a profile from the registry together with every per-thread pick of it (those threads
1123
+ * return to the instance default) and the instance default itself when it named this profile. Returns the
1124
+ * threads whose pick was dropped, so the caller can re-point their live sessions.
1125
+ */
1126
+ removeClaudeProfileRecord(name: string): Promise<SessionKey[]>;
1127
+ /** The instance-wide profile pick (General), `default` when none was ever set. */
1128
+ getClaudeProfileGlobalDefault(): string;
1129
+ /** The thread's own pick as stored (it may name a removed profile), or `undefined` when it follows the default. */
1130
+ getClaudeProfileOverride(key: SessionKey): string | undefined;
1131
+ /** The profile the thread effectively uses — override, then instance default, then `default`. */
1132
+ resolveClaudeProfileName(key: SessionKey): string;
1133
+ /** Threads whose stored pick names `name` (General's default is not a thread). */
1134
+ listClaudeProfileOverrideKeys(name: string): SessionKey[];
1135
+ /** Set the instance-wide pick from General (`default` clears it). Debounced — a preference. */
1136
+ setClaudeProfileGlobalDefault(name: string): Promise<void>;
1137
+ /**
1138
+ * @description Set the thread's own pick; `null` makes the thread follow the instance default again. A pick
1139
+ * of `default` is stored EXPLICITLY (it must win over a non-default instance default). Debounced.
1140
+ */
1141
+ setClaudeProfileOverride(key: SessionKey, name: string | null): Promise<void>;
1142
+ /**
1143
+ * @description The stored operator timezone, or `null` when none is set (the
1144
+ * caller then falls back to the host zone — see `utils/timezone.ts`
1145
+ * `getEffectiveTimezone`). Deliberately NOT defaulted here: the store reports
1146
+ * what is on disk, the resolution rule lives in one place outside it.
1147
+ */
1148
+ getTimezone(): string | null;
1149
+ /**
1150
+ * @description Store the operator timezone, or drop the field on `null`
1151
+ * (reset to the host zone) so a default install leaves no trace in
1152
+ * `state.json` — same shape discipline as {@link setModelProviderHidden}.
1153
+ *
1154
+ * Flushed eagerly rather than riding the debounced save loop: a zone change
1155
+ * immediately recomputes every schedule's `nextRunAt`, and losing the zone
1156
+ * while keeping the recomputed fire times would leave the two disagreeing
1157
+ * after a crash.
1158
+ */
1159
+ setTimezone(timezone: string | null): Promise<void>;
1160
+ /**
1161
+ * @description Fully-resolved display preferences for `key`: every field is
1162
+ * present because the locked default (`minimal` for all three) is applied
1163
+ * wherever the persisted record omits it. The SSE hot path reads this, so it
1164
+ * must never hand back an `undefined` field.
1165
+ *
1166
+ * Read-time normalization: a `state.json` written before the vocabulary was
1167
+ * unified may still hold legacy names (`detailed`/`brief`/`hide`/`compact`)
1168
+ * — those map onto the new vocabulary here, and an unrecognized value falls
1169
+ * back to the default, so old files keep working without a migration pass.
1170
+ */
1171
+ getDisplayPrefs(key: SessionKey): ResolvedThreadDisplayPrefs;
1172
+ /**
1173
+ * @description Persist one display-preference field for `key`. Setting a
1174
+ * field to its locked default DELETES the override (and drops the whole
1175
+ * record / map once empty) so an all-defaults thread leaves a clean
1176
+ * `state.json` — same delete-when-default idiom as {@link setTraceConfig}.
1177
+ * Not crash-critical (a rendering preference), so it rides the debounced
1178
+ * save loop rather than an immediate `flush()`. Callers pass an
1179
+ * already-normalized value — legacy names never reach the store on the write
1180
+ * path. The `view` field (S6) rides the same record and the same idiom, with
1181
+ * its own locked default.
1182
+ */
1183
+ setDisplayPref<TField extends keyof ThreadDisplayPrefs>(key: SessionKey, field: TField, value: NonNullable<ThreadDisplayPrefs[TField]>): Promise<void>;
1184
+ /**
1185
+ * @description Every persisted schedule across all threads, keyed by id.
1186
+ * Read at boot by the engine to re-arm timers. Returns a shallow copy of the
1187
+ * map so callers can't mutate the live state object.
1188
+ */
1189
+ getSchedules(): Record<string, ScheduleRecord>;
1190
+ /** Schedules owned by `key`, in insertion order. Empty array when none. */
1191
+ getThreadSchedules(key: SessionKey): ScheduleRecord[];
1192
+ /**
1193
+ * @description Upsert a schedule by its id. The record's `threadKey` is the
1194
+ * source of truth for ownership; callers build it via the scheduler module's
1195
+ * `createScheduleRecord`. Crash-critical fields (`nextRunAt`) ride the
1196
+ * debounced save like every other mutation — the engine calls
1197
+ * {@link flush} explicitly after a fire when the new `nextRunAt` must hit disk
1198
+ * before the process can die.
1199
+ */
1200
+ upsertSchedule(record: ScheduleRecord): Promise<void>;
1201
+ /** Remove a schedule by id. No-op (no save) when absent. */
1202
+ removeSchedule(id: string): Promise<void>;
1203
+ /**
1204
+ * @description Set the paused flag for a schedule (used by /unbind pause and
1205
+ * /bind resume in S8). Clearing the pause drops both `isPaused` and
1206
+ * `pauseReason` so the on-disk shape stays clean. No-op when the id is absent.
1207
+ */
1208
+ setSchedulePaused(id: string, paused: boolean, reason?: ScheduleRecord['pauseReason']): Promise<void>;
1209
+ /**
1210
+ * @description The HMAC secret keying the scheduler MCP tokens, created lazily
1211
+ * on first read and persisted immediately. Generated once with
1212
+ * `crypto.randomBytes` (32 bytes, hex) so the tokens the bot injects into
1213
+ * agent sessions survive restarts. The first-time write is flushed eagerly
1214
+ * (not debounced) so a crash right after minting the first token can't lose
1215
+ * the secret that token was signed with.
1216
+ */
1217
+ getSchedulerMcpSecret(): Promise<string>;
1218
+ /**
1219
+ * @description The scheduler MCP listen port persisted from a prior boot, or
1220
+ * `undefined` if never persisted (fresh / pre-feature state file). Reused so an
1221
+ * ephemeral port keeps its value across restarts (see
1222
+ * {@link StateV1.schedulerMcpPort}).
1223
+ */
1224
+ getPersistedSchedulerMcpPort(): number | undefined;
1225
+ /**
1226
+ * @description Persist the actually-bound scheduler MCP port and flush eagerly.
1227
+ * Eager (not debounced) mirrors {@link getSchedulerMcpSecret}: the injected
1228
+ * registrations point at this port, so a crash right after binding must not lose
1229
+ * it and hand the next boot a stale port. Called once at boot, only when the
1230
+ * value changed and the operator did not fix the port via env.
1231
+ */
1232
+ setSchedulerMcpPort(port: number): Promise<void>;
1233
+ /**
1234
+ * @description Every persisted pending question across all threads, keyed by
1235
+ * {@link SessionKey} string. Read at boot to re-arm the in-memory map for
1236
+ * threads whose session reattached. Returns a shallow copy so callers can't
1237
+ * mutate the live state object.
1238
+ */
1239
+ getPendingQuestions(): Record<string, PendingQuestionState>;
1240
+ /**
1241
+ * @description Persist (upsert) the pending question for `key`, mirroring the
1242
+ * in-memory `pendingQuestions.set(...)` in `bot.ts` so memory and disk never
1243
+ * drift. Crash-window is acceptable on the debounced save: the worst case
1244
+ * (process dies in the <=500ms before the flush) just falls back to the
1245
+ * pre-fix behaviour for that one question. The `messageId` patch goes through
1246
+ * here too, so the persisted record always carries the live button message.
1247
+ */
1248
+ setPendingQuestion(key: SessionKey, value: PendingQuestionState): Promise<void>;
1249
+ /**
1250
+ * @description Remove the pending question for `key`. Mirrors every in-memory
1251
+ * `pendingQuestions.delete(...)` in `bot.ts`. No-op (no save) when absent. The
1252
+ * whole map is dropped once empty so an idle bot leaves a clean `state.json`.
1253
+ */
1254
+ clearPendingQuestion(key: SessionKey): Promise<void>;
1255
+ /**
1256
+ * @description Every persisted armed auto-retry across all threads, keyed by
1257
+ * {@link SessionKey} string. Read at boot to re-arm the in-memory map after
1258
+ * sessions reattach. Returns a shallow copy so callers can't mutate the live
1259
+ * state object.
1260
+ */
1261
+ getApiRetries(): Record<string, ApiRetryState>;
1262
+ /**
1263
+ * @description Persist (upsert) the armed retry for `key`, mirroring the
1264
+ * in-memory `apiRetries.set(...)` in `bot.ts` so memory and disk never drift.
1265
+ * Crash-window is acceptable on the debounced save: the worst case (process
1266
+ * dies in the <=500ms before the flush) just loses that one armed retry, which
1267
+ * falls back to the pre-fix behaviour for that thread. Each re-arm (next
1268
+ * attempt) goes through here too, so the persisted record always carries the
1269
+ * latest attempt and `fireAt`.
1270
+ */
1271
+ setApiRetry(key: SessionKey, value: ApiRetryState): Promise<void>;
1272
+ /**
1273
+ * @description Remove the armed retry for `key`. Mirrors every in-memory
1274
+ * `apiRetries.delete(...)` in `bot.ts`. No-op (no save) when absent. The whole
1275
+ * map is dropped once empty so an idle bot leaves a clean `state.json`.
1276
+ */
1277
+ clearApiRetry(key: SessionKey): Promise<void>;
1278
+ /** @description The prompts held for `key`, oldest first; `[]` when none. A copy. */
1279
+ getLimitHeldPrompts(key: SessionKey): LimitHeldPrompt[];
1280
+ /**
1281
+ * @description Replace the prompts held for `key`; `[]` drops the entry (and
1282
+ * the map once empty). Synchronous in memory — a take must be atomic against
1283
+ * a concurrent hold — and saved debounced like the retry record it outlives.
1284
+ */
1285
+ setLimitHeldPrompts(key: SessionKey, prompts: readonly LimitHeldPrompt[]): void;
1286
+ /**
1287
+ * @description Every open request across all conversations, keyed by the
1288
+ * serialized {@link RequestGroupKey}. Returns a shallow copy so callers can't
1289
+ * mutate the live state object.
1290
+ */
1291
+ getOpenRequests(): Record<string, OpenRequestState>;
1292
+ /** @description The open request of `group`, or `undefined`. */
1293
+ getOpenRequest(group: RequestGroupKey): OpenRequestState | undefined;
1294
+ /**
1295
+ * @description Replace the open request of `group` with what `mutate` returns
1296
+ * for the current one (`undefined` removes it), under the lock of the group's
1297
+ * CONVERSATION — so a read-decide-write (supersede, close, counter update) is
1298
+ * atomic against a concurrent one for the same conversation, whichever of its
1299
+ * groups it touches. `mutate` runs
1300
+ * synchronously inside the lock; a side effect it performs (the ledger's
1301
+ * history append) therefore happens before any other writer sees the result.
1302
+ * The whole map is dropped once empty so an idle bot leaves a clean
1303
+ * `state.json`.
1304
+ */
1305
+ updateOpenRequest(group: RequestGroupKey, mutate: (current: OpenRequestState | undefined) => OpenRequestState | undefined): Promise<void>;
1306
+ /** @description The alerts of closed requests still to release (a copy). */
1307
+ getUnreleasedRequestAlerts(): Record<string, UnreleasedRequestAlert>;
1308
+ /**
1309
+ * @description Record that a closed request's alert still needs releasing.
1310
+ * Synchronous on purpose: the ledger calls it inside the close's own locked
1311
+ * step, so it rides the same save as the close.
1312
+ */
1313
+ addUnreleasedRequestAlert(requestId: string, alert: UnreleasedRequestAlert): void;
1314
+ /** @description The alert of `requestId` was released; forget it. */
1315
+ removeUnreleasedRequestAlert(requestId: string): void;
1316
+ /** @description The message id of the latest pinned answer in `key`'s conversation, or `undefined`. */
1317
+ getAnswerPinMessageId(key: SessionKey): number | undefined;
1318
+ /**
1319
+ * @description Remember the latest pinned answer of `key`'s conversation; the
1320
+ * record goes away with the thread's binding. Rides the debounced save: a lost
1321
+ * write leaves one extra pinned answer behind, never a wrong unpin.
1322
+ */
1323
+ setAnswerPinMessageId(key: SessionKey, messageId: number): Promise<void>;
1324
+ /**
1325
+ * Drop `k` from one of the optional per-conversation maps, and the map itself
1326
+ * with its last entry (an idle bot leaves a clean `state.json`). `false` when
1327
+ * there was no entry. Caller must hold the key lock.
1328
+ */
1329
+ private dropOptionalMapEntry;
1330
+ /**
1331
+ * @description The `stdout.jsonl` identity recorded when the boot recovery last
1332
+ * armed a limit wait for `key`, or `undefined` when it never did. Compared
1333
+ * against the live stat so an UNCHANGED log is not recovered twice — see
1334
+ * {@link LimitEpisodeMarker}.
1335
+ */
1336
+ getLimitEpisodeRecovered(key: SessionKey): LimitEpisodeMarker | undefined;
1337
+ /**
1338
+ * @description Record the log identity the boot recovery just armed from.
1339
+ * Debounced (a restart guard, not crash-critical: losing the last <=500ms costs
1340
+ * at worst one repeated recovery). NOT cleared by `cancelApiRetry` on purpose —
1341
+ * that fires on «⏭ Skip once» and on every inbound message, which is exactly the
1342
+ * settled-episode case the marker has to outlive.
1343
+ */
1344
+ setLimitEpisodeRecovered(key: SessionKey, value: LimitEpisodeMarker): Promise<void>;
1345
+ /**
1346
+ * Drop `keyStr`'s handled-episode marker (and the whole map once empty). Returns
1347
+ * whether anything changed. Caller must hold the key lock.
1348
+ */
1349
+ private dropLimitEpisodeRecovered;
1350
+ /**
1351
+ * @description Every persisted transient status-frame id list across all
1352
+ * threads, keyed by {@link SessionKey} string. Read at boot (after reattach) to
1353
+ * delete any frame left on screen by an UNGRACEFUL exit. Returns a shallow copy
1354
+ * so callers can't mutate the live state object.
1355
+ */
1356
+ getTransientFrames(): Record<string, number[]>;
1357
+ /**
1358
+ * @description Replace the persisted transient status-frame ids for `key`
1359
+ * (the live "✽ working…" status frame, the thinking indicator, the sub-agent
1360
+ * status — whichever are currently on screen). Mirrors the in-memory
1361
+ * `ThreadMessageState` write in `bot.ts`'s frame-id setters so disk can clean
1362
+ * up what the graceful sweep would have. Debounced (NOT flushed): the frames
1363
+ * are cosmetic. An empty list drops the key (and the whole map once empty) so an
1364
+ * idle bot leaves a clean `state.json`. A no-op (no save) when the id list is
1365
+ * unchanged, so the per-turn create/delete churn doesn't reset the save timer
1366
+ * on every identical re-persist.
1367
+ */
1368
+ setTransientFrames(key: SessionKey, ids: number[]): Promise<void>;
1369
+ /** Schedule a save in `saveDebounceMs`. Repeated calls reset the timer. */
1370
+ private scheduleSave;
1371
+ /**
1372
+ * @description Force a save right now and await on-disk persistence.
1373
+ *
1374
+ * Used by:
1375
+ * - shutdown handlers — to guarantee no in-memory state is lost,
1376
+ * - critical paths (initial corruption-archived fresh-start),
1377
+ * - tests.
1378
+ *
1379
+ * Internally serialises against any in-flight write — only one rename
1380
+ * happens at a time per store.
1381
+ */
1382
+ flush(): Promise<void>;
1383
+ }
1384
+ /**
1385
+ * @description Resolve the default `DATA_DIR` for the running bot.
1386
+ *
1387
+ * Priority:
1388
+ * 1. `process.env.DATA_DIR` (set by the operator — required for the
1389
+ * two-instance setup, plan §10.7).
1390
+ * 2. `~/.telegramCode` — single-instance default.
1391
+ *
1392
+ * Two bots on the same host MUST set distinct `DATA_DIR` values, otherwise
1393
+ * they'd silently share `state.json` and corrupt each other. Plan §16.2
1394
+ * adds a startup `.lock` check; that lives in `bot.ts` (Этап 3), not here.
1395
+ */
1396
+ export declare function resolveDataDir(): string;
1397
+ /**
1398
+ * @description Create-or-fetch the singleton store. The first call performs
1399
+ * `init()` and persists archival/migration side-effects; subsequent calls
1400
+ * just return the cached instance.
1401
+ *
1402
+ * The in-flight promise is cached to keep concurrent first-callers from
1403
+ * each constructing a separate `StateStore` (two stores → two competing
1404
+ * write chains → corrupted JSON). Production triggers only one call from
1405
+ * `startBot()`, but the cost of the guard is trivial.
1406
+ *
1407
+ * Tests should instantiate `new StateStore(...)` directly instead.
1408
+ */
1409
+ export declare function getStateStore(): Promise<StateStore>;
1410
+ /**
1411
+ * @description Reset the singleton — only for tests. Production code should
1412
+ * never call this; doing so would leak in-flight write promises.
1413
+ */
1414
+ export declare function _resetStateStoreSingletonForTests(): void;
1415
+ export { fs as _fsForTests };
1416
+ //# sourceMappingURL=state.d.ts.map