charness 4.1.1 → 4.3.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 (643) hide show
  1. package/CHANGELOG.md +186 -2
  2. package/DEVELOPMENT.md +65 -11
  3. package/LICENSE +331 -151
  4. package/MIGRATION_3_TO_4.md +8 -5
  5. package/README.md +23 -8
  6. package/SETUP.md +57 -11
  7. package/agent-plugin/README.md +10 -3
  8. package/agent-plugin/skills/charness-delegate-claude/SKILL.md +18 -26
  9. package/agent-plugin/skills/charness-delegate-opencode/SKILL.md +5 -3
  10. package/agent-plugin/skills/charness-orchestration/SKILL.md +57 -16
  11. package/dist/adapters/adapterNames.d.ts +2 -0
  12. package/dist/adapters/adapterNames.d.ts.map +1 -1
  13. package/dist/adapters/adapterNames.js +3 -1
  14. package/dist/adapters/adapterNames.js.map +1 -1
  15. package/dist/adapters/claudeCliAdapter.d.ts +4 -0
  16. package/dist/adapters/claudeCliAdapter.d.ts.map +1 -1
  17. package/dist/adapters/claudeCliAdapter.js +13 -0
  18. package/dist/adapters/claudeCliAdapter.js.map +1 -1
  19. package/dist/adapters/claudeJsonStreamAdapter.d.ts +150 -10
  20. package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -1
  21. package/dist/adapters/claudeJsonStreamAdapter.js +401 -83
  22. package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
  23. package/dist/adapters/createAdapter.d.ts +12 -3
  24. package/dist/adapters/createAdapter.d.ts.map +1 -1
  25. package/dist/adapters/createAdapter.js +39 -13
  26. package/dist/adapters/createAdapter.js.map +1 -1
  27. package/dist/adapters/openCodeAdapter.d.ts +65 -2
  28. package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
  29. package/dist/adapters/openCodeAdapter.js +202 -19
  30. package/dist/adapters/openCodeAdapter.js.map +1 -1
  31. package/dist/adapters/terminalAdapter.d.ts.map +1 -1
  32. package/dist/adapters/terminalAdapter.js +2 -1
  33. package/dist/adapters/terminalAdapter.js.map +1 -1
  34. package/dist/apiErrorRetry.d.ts +11 -3
  35. package/dist/apiErrorRetry.d.ts.map +1 -1
  36. package/dist/apiErrorRetry.js +33 -3
  37. package/dist/apiErrorRetry.js.map +1 -1
  38. package/dist/apiRetryKick.d.ts +3 -2
  39. package/dist/apiRetryKick.d.ts.map +1 -1
  40. package/dist/apiRetryKick.js +13 -5
  41. package/dist/apiRetryKick.js.map +1 -1
  42. package/dist/bot.d.ts +2 -6
  43. package/dist/bot.d.ts.map +1 -1
  44. package/dist/bot.js +2586 -693
  45. package/dist/bot.js.map +1 -1
  46. package/dist/cli/claudeProfiles.d.ts +31 -6
  47. package/dist/cli/claudeProfiles.d.ts.map +1 -1
  48. package/dist/cli/claudeProfiles.js +97 -22
  49. package/dist/cli/claudeProfiles.js.map +1 -1
  50. package/dist/cli.d.ts.map +1 -1
  51. package/dist/cli.js +2 -1
  52. package/dist/cli.js.map +1 -1
  53. package/dist/connectors/jira/answerSink.d.ts +102 -7
  54. package/dist/connectors/jira/answerSink.d.ts.map +1 -1
  55. package/dist/connectors/jira/answerSink.js +364 -60
  56. package/dist/connectors/jira/answerSink.js.map +1 -1
  57. package/dist/connectors/jira/answerThreads.d.ts +44 -0
  58. package/dist/connectors/jira/answerThreads.d.ts.map +1 -0
  59. package/dist/connectors/jira/answerThreads.js +85 -0
  60. package/dist/connectors/jira/answerThreads.js.map +1 -0
  61. package/dist/connectors/jira/client.d.ts +67 -2
  62. package/dist/connectors/jira/client.d.ts.map +1 -1
  63. package/dist/connectors/jira/client.js +176 -4
  64. package/dist/connectors/jira/client.js.map +1 -1
  65. package/dist/connectors/jira/config.d.ts +6 -0
  66. package/dist/connectors/jira/config.d.ts.map +1 -1
  67. package/dist/connectors/jira/config.js +14 -1
  68. package/dist/connectors/jira/config.js.map +1 -1
  69. package/dist/connectors/jira/connector.d.ts +19 -0
  70. package/dist/connectors/jira/connector.d.ts.map +1 -1
  71. package/dist/connectors/jira/connector.js +68 -6
  72. package/dist/connectors/jira/connector.js.map +1 -1
  73. package/dist/connectors/jira/contextPreamble.d.ts.map +1 -1
  74. package/dist/connectors/jira/contextPreamble.js +6 -1
  75. package/dist/connectors/jira/contextPreamble.js.map +1 -1
  76. package/dist/connectors/jira/inbound.d.ts +21 -6
  77. package/dist/connectors/jira/inbound.d.ts.map +1 -1
  78. package/dist/connectors/jira/inbound.js +22 -16
  79. package/dist/connectors/jira/inbound.js.map +1 -1
  80. package/dist/connectors/jira/issueBlocks.d.ts +8 -1
  81. package/dist/connectors/jira/issueBlocks.d.ts.map +1 -1
  82. package/dist/connectors/jira/issueBlocks.js +38 -2
  83. package/dist/connectors/jira/issueBlocks.js.map +1 -1
  84. package/dist/connectors/jira/operatorIssue.d.ts +28 -0
  85. package/dist/connectors/jira/operatorIssue.d.ts.map +1 -0
  86. package/dist/connectors/jira/operatorIssue.js +81 -0
  87. package/dist/connectors/jira/operatorIssue.js.map +1 -0
  88. package/dist/connectors/jira/outbound.d.ts +8 -4
  89. package/dist/connectors/jira/outbound.d.ts.map +1 -1
  90. package/dist/connectors/jira/outbound.js +16 -8
  91. package/dist/connectors/jira/outbound.js.map +1 -1
  92. package/dist/connectors/jira/outgoingFileCheck.d.ts +37 -0
  93. package/dist/connectors/jira/outgoingFileCheck.d.ts.map +1 -0
  94. package/dist/connectors/jira/outgoingFileCheck.js +279 -0
  95. package/dist/connectors/jira/outgoingFileCheck.js.map +1 -0
  96. package/dist/connectors/jira/outgoingFiles.d.ts +81 -0
  97. package/dist/connectors/jira/outgoingFiles.d.ts.map +1 -0
  98. package/dist/connectors/jira/outgoingFiles.js +268 -0
  99. package/dist/connectors/jira/outgoingFiles.js.map +1 -0
  100. package/dist/connectors/jira/progressComments.d.ts +69 -0
  101. package/dist/connectors/jira/progressComments.d.ts.map +1 -0
  102. package/dist/connectors/jira/progressComments.js +136 -0
  103. package/dist/connectors/jira/progressComments.js.map +1 -0
  104. package/dist/connectors/jira/prompt.d.ts +5 -1
  105. package/dist/connectors/jira/prompt.d.ts.map +1 -1
  106. package/dist/connectors/jira/prompt.js +23 -3
  107. package/dist/connectors/jira/prompt.js.map +1 -1
  108. package/dist/connectors/jira/promptSpill.js +1 -1
  109. package/dist/connectors/jira/promptSpill.js.map +1 -1
  110. package/dist/connectors/jira/trigger.d.ts +13 -5
  111. package/dist/connectors/jira/trigger.d.ts.map +1 -1
  112. package/dist/connectors/jira/trigger.js +13 -7
  113. package/dist/connectors/jira/trigger.js.map +1 -1
  114. package/dist/connectors/jira/uploadedFiles.d.ts +48 -0
  115. package/dist/connectors/jira/uploadedFiles.d.ts.map +1 -0
  116. package/dist/connectors/jira/uploadedFiles.js +123 -0
  117. package/dist/connectors/jira/uploadedFiles.js.map +1 -0
  118. package/dist/connectors/telegram/commands/backendSwitch.d.ts +9 -1
  119. package/dist/connectors/telegram/commands/backendSwitch.d.ts.map +1 -1
  120. package/dist/connectors/telegram/commands/backendSwitch.js +17 -8
  121. package/dist/connectors/telegram/commands/backendSwitch.js.map +1 -1
  122. package/dist/connectors/telegram/commands/botCore.d.ts +5 -2
  123. package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -1
  124. package/dist/connectors/telegram/commands/botSkills.d.ts +2 -0
  125. package/dist/connectors/telegram/commands/botSkills.d.ts.map +1 -1
  126. package/dist/connectors/telegram/commands/botSkills.js +17 -2
  127. package/dist/connectors/telegram/commands/botSkills.js.map +1 -1
  128. package/dist/connectors/telegram/commands/claudeAccounts.d.ts +11 -0
  129. package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -1
  130. package/dist/connectors/telegram/commands/claudeAccounts.js +36 -42
  131. package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
  132. package/dist/connectors/telegram/commands/compaction.d.ts +20 -3
  133. package/dist/connectors/telegram/commands/compaction.d.ts.map +1 -1
  134. package/dist/connectors/telegram/commands/compaction.js +268 -96
  135. package/dist/connectors/telegram/commands/compaction.js.map +1 -1
  136. package/dist/connectors/telegram/commands/limitReminders.d.ts +21 -0
  137. package/dist/connectors/telegram/commands/limitReminders.d.ts.map +1 -0
  138. package/dist/connectors/telegram/commands/limitReminders.js +95 -0
  139. package/dist/connectors/telegram/commands/limitReminders.js.map +1 -0
  140. package/dist/connectors/telegram/commands/limitsBoard.d.ts +4 -0
  141. package/dist/connectors/telegram/commands/limitsBoard.d.ts.map +1 -1
  142. package/dist/connectors/telegram/commands/limitsBoard.js +27 -6
  143. package/dist/connectors/telegram/commands/limitsBoard.js.map +1 -1
  144. package/dist/connectors/telegram/commands/modelProviders.d.ts +2 -2
  145. package/dist/connectors/telegram/commands/modelProviders.d.ts.map +1 -1
  146. package/dist/connectors/telegram/commands/modelProviders.js +27 -16
  147. package/dist/connectors/telegram/commands/modelProviders.js.map +1 -1
  148. package/dist/connectors/telegram/commands/questionSetAside.d.ts +111 -0
  149. package/dist/connectors/telegram/commands/questionSetAside.d.ts.map +1 -0
  150. package/dist/connectors/telegram/commands/questionSetAside.js +637 -0
  151. package/dist/connectors/telegram/commands/questionSetAside.js.map +1 -0
  152. package/dist/connectors/telegram/commands/questionWait.d.ts +21 -0
  153. package/dist/connectors/telegram/commands/questionWait.d.ts.map +1 -0
  154. package/dist/connectors/telegram/commands/questionWait.js +109 -0
  155. package/dist/connectors/telegram/commands/questionWait.js.map +1 -0
  156. package/dist/connectors/telegram/commands/topicAccess.js +1 -1
  157. package/dist/connectors/telegram/commands/topicAccess.js.map +1 -1
  158. package/dist/connectors/telegram/commands/topicCommand.d.ts +0 -2
  159. package/dist/connectors/telegram/commands/topicCommand.d.ts.map +1 -1
  160. package/dist/connectors/telegram/commands/topicCommand.js +11 -7
  161. package/dist/connectors/telegram/commands/topicCommand.js.map +1 -1
  162. package/dist/connectors/telegram/commands/topicStatus.d.ts +24 -0
  163. package/dist/connectors/telegram/commands/topicStatus.d.ts.map +1 -0
  164. package/dist/connectors/telegram/commands/topicStatus.js +148 -0
  165. package/dist/connectors/telegram/commands/topicStatus.js.map +1 -0
  166. package/dist/connectors/telegram/commands/workerRoles.d.ts +25 -0
  167. package/dist/connectors/telegram/commands/workerRoles.d.ts.map +1 -0
  168. package/dist/connectors/telegram/commands/workerRoles.js +259 -0
  169. package/dist/connectors/telegram/commands/workerRoles.js.map +1 -0
  170. package/dist/connectors/telegram/firstUpdateBatchNote.d.ts +30 -0
  171. package/dist/connectors/telegram/firstUpdateBatchNote.d.ts.map +1 -0
  172. package/dist/connectors/telegram/firstUpdateBatchNote.js +39 -0
  173. package/dist/connectors/telegram/firstUpdateBatchNote.js.map +1 -0
  174. package/dist/connectors/telegram/groupWelcome.d.ts +12 -0
  175. package/dist/connectors/telegram/groupWelcome.d.ts.map +1 -0
  176. package/dist/connectors/telegram/groupWelcome.js +12 -0
  177. package/dist/connectors/telegram/groupWelcome.js.map +1 -0
  178. package/dist/connectors/telegram/inbound.d.ts +19 -0
  179. package/dist/connectors/telegram/inbound.d.ts.map +1 -1
  180. package/dist/connectors/telegram/inbound.js +41 -3
  181. package/dist/connectors/telegram/inbound.js.map +1 -1
  182. package/dist/connectors/telegram/outputFlushPlan.d.ts +12 -0
  183. package/dist/connectors/telegram/outputFlushPlan.d.ts.map +1 -1
  184. package/dist/connectors/telegram/outputFlushPlan.js +12 -0
  185. package/dist/connectors/telegram/outputFlushPlan.js.map +1 -1
  186. package/dist/connectors/telegram/runnerPairingMessages.d.ts +1 -1
  187. package/dist/connectors/telegram/topicIndicator.d.ts +86 -0
  188. package/dist/connectors/telegram/topicIndicator.d.ts.map +1 -0
  189. package/dist/connectors/telegram/topicIndicator.js +588 -0
  190. package/dist/connectors/telegram/topicIndicator.js.map +1 -0
  191. package/dist/connectors/telegram/waitingTopicRenames.d.ts +39 -0
  192. package/dist/connectors/telegram/waitingTopicRenames.d.ts.map +1 -0
  193. package/dist/connectors/telegram/waitingTopicRenames.js +48 -0
  194. package/dist/connectors/telegram/waitingTopicRenames.js.map +1 -0
  195. package/dist/effortLevels.d.ts +6 -0
  196. package/dist/effortLevels.d.ts.map +1 -1
  197. package/dist/effortLevels.js +6 -1
  198. package/dist/effortLevels.js.map +1 -1
  199. package/dist/i18n/de.d.ts.map +1 -1
  200. package/dist/i18n/de.js +141 -13
  201. package/dist/i18n/de.js.map +1 -1
  202. package/dist/i18n/en.d.ts.map +1 -1
  203. package/dist/i18n/en.js +141 -13
  204. package/dist/i18n/en.js.map +1 -1
  205. package/dist/i18n/es.d.ts.map +1 -1
  206. package/dist/i18n/es.js +141 -13
  207. package/dist/i18n/es.js.map +1 -1
  208. package/dist/i18n/fr.d.ts.map +1 -1
  209. package/dist/i18n/fr.js +141 -13
  210. package/dist/i18n/fr.js.map +1 -1
  211. package/dist/i18n/hi.d.ts.map +1 -1
  212. package/dist/i18n/hi.js +141 -13
  213. package/dist/i18n/hi.js.map +1 -1
  214. package/dist/i18n/ja.d.ts.map +1 -1
  215. package/dist/i18n/ja.js +141 -13
  216. package/dist/i18n/ja.js.map +1 -1
  217. package/dist/i18n/ka.d.ts.map +1 -1
  218. package/dist/i18n/ka.js +141 -13
  219. package/dist/i18n/ka.js.map +1 -1
  220. package/dist/i18n/pt.d.ts.map +1 -1
  221. package/dist/i18n/pt.js +141 -13
  222. package/dist/i18n/pt.js.map +1 -1
  223. package/dist/i18n/ru.d.ts.map +1 -1
  224. package/dist/i18n/ru.js +141 -13
  225. package/dist/i18n/ru.js.map +1 -1
  226. package/dist/i18n/uk.d.ts.map +1 -1
  227. package/dist/i18n/uk.js +141 -13
  228. package/dist/i18n/uk.js.map +1 -1
  229. package/dist/i18n/uz.d.ts.map +1 -1
  230. package/dist/i18n/uz.js +141 -13
  231. package/dist/i18n/uz.js.map +1 -1
  232. package/dist/i18n/zh.d.ts.map +1 -1
  233. package/dist/i18n/zh.js +141 -13
  234. package/dist/i18n/zh.js.map +1 -1
  235. package/dist/instanceSettings.d.ts +43 -3
  236. package/dist/instanceSettings.d.ts.map +1 -1
  237. package/dist/instanceSettings.js +109 -4
  238. package/dist/instanceSettings.js.map +1 -1
  239. package/dist/limitNotes/engine.d.ts +47 -0
  240. package/dist/limitNotes/engine.d.ts.map +1 -0
  241. package/dist/limitNotes/engine.js +98 -0
  242. package/dist/limitNotes/engine.js.map +1 -0
  243. package/dist/limitNotes/noteText.d.ts +33 -0
  244. package/dist/limitNotes/noteText.d.ts.map +1 -0
  245. package/dist/limitNotes/noteText.js +55 -0
  246. package/dist/limitNotes/noteText.js.map +1 -0
  247. package/dist/limitNotes/plan.d.ts +147 -0
  248. package/dist/limitNotes/plan.d.ts.map +1 -0
  249. package/dist/limitNotes/plan.js +323 -0
  250. package/dist/limitNotes/plan.js.map +1 -0
  251. package/dist/limitNotes/reminderChoices.d.ts +30 -0
  252. package/dist/limitNotes/reminderChoices.d.ts.map +1 -0
  253. package/dist/limitNotes/reminderChoices.js +48 -0
  254. package/dist/limitNotes/reminderChoices.js.map +1 -0
  255. package/dist/limitNotes/service.d.ts +106 -0
  256. package/dist/limitNotes/service.d.ts.map +1 -0
  257. package/dist/limitNotes/service.js +169 -0
  258. package/dist/limitNotes/service.js.map +1 -0
  259. package/dist/openCodeOpenQuestion.d.ts +12 -4
  260. package/dist/openCodeOpenQuestion.d.ts.map +1 -1
  261. package/dist/openCodeOpenQuestion.js +16 -7
  262. package/dist/openCodeOpenQuestion.js.map +1 -1
  263. package/dist/openCodeQuestionFlow.d.ts +10 -2
  264. package/dist/openCodeQuestionFlow.d.ts.map +1 -1
  265. package/dist/openCodeQuestionFlow.js +27 -5
  266. package/dist/openCodeQuestionFlow.js.map +1 -1
  267. package/dist/openCodeSessionTitle.js +1 -1
  268. package/dist/openCodeSessionTitle.js.map +1 -1
  269. package/dist/outputTrace.d.ts +19 -0
  270. package/dist/outputTrace.d.ts.map +1 -1
  271. package/dist/outputTrace.js +23 -2
  272. package/dist/outputTrace.js.map +1 -1
  273. package/dist/platform/answerSink.d.ts +23 -0
  274. package/dist/platform/answerSink.d.ts.map +1 -1
  275. package/dist/platform/answerSink.js.map +1 -1
  276. package/dist/platform/operatorAlert.d.ts +24 -0
  277. package/dist/platform/operatorAlert.d.ts.map +1 -0
  278. package/dist/platform/operatorAlert.js +9 -0
  279. package/dist/platform/operatorAlert.js.map +1 -0
  280. package/dist/postToSession.d.ts +43 -2
  281. package/dist/postToSession.d.ts.map +1 -1
  282. package/dist/postToSession.js +46 -4
  283. package/dist/postToSession.js.map +1 -1
  284. package/dist/remoteRun/exitCodes.d.ts +2 -2
  285. package/dist/remoteRun/exitCodes.d.ts.map +1 -1
  286. package/dist/remoteRun/exitCodes.js +2 -2
  287. package/dist/remoteRun/exitCodes.js.map +1 -1
  288. package/dist/remoteRun/foreground.d.ts.map +1 -1
  289. package/dist/remoteRun/foreground.js +5 -1
  290. package/dist/remoteRun/foreground.js.map +1 -1
  291. package/dist/remoteRun/runnerClient.d.ts +1 -1
  292. package/dist/remoteRun/runnerClient.d.ts.map +1 -1
  293. package/dist/remoteRun/runnerClient.js +3 -3
  294. package/dist/remoteRun/runnerClient.js.map +1 -1
  295. package/dist/requests/answerRequest.d.ts +3 -0
  296. package/dist/requests/answerRequest.d.ts.map +1 -1
  297. package/dist/requests/answerRequest.js +9 -2
  298. package/dist/requests/answerRequest.js.map +1 -1
  299. package/dist/requests/limitWaitAnswer.d.ts +14 -0
  300. package/dist/requests/limitWaitAnswer.d.ts.map +1 -1
  301. package/dist/requests/limitWaitAnswer.js +26 -4
  302. package/dist/requests/limitWaitAnswer.js.map +1 -1
  303. package/dist/requests/requestHeader.d.ts +37 -5
  304. package/dist/requests/requestHeader.d.ts.map +1 -1
  305. package/dist/requests/requestHeader.js +46 -17
  306. package/dist/requests/requestHeader.js.map +1 -1
  307. package/dist/requests/scheduleWait.d.ts +79 -0
  308. package/dist/requests/scheduleWait.d.ts.map +1 -0
  309. package/dist/requests/scheduleWait.js +101 -0
  310. package/dist/requests/scheduleWait.js.map +1 -0
  311. package/dist/requests/sessionTurnProbe.d.ts +21 -3
  312. package/dist/requests/sessionTurnProbe.d.ts.map +1 -1
  313. package/dist/requests/sessionTurnProbe.js +18 -3
  314. package/dist/requests/sessionTurnProbe.js.map +1 -1
  315. package/dist/requests/topicRequestSettle.d.ts +13 -7
  316. package/dist/requests/topicRequestSettle.d.ts.map +1 -1
  317. package/dist/requests/topicRequestSettle.js +2 -2
  318. package/dist/requests/topicRequestSettle.js.map +1 -1
  319. package/dist/requests/trackerTurnPoster.d.ts +30 -0
  320. package/dist/requests/trackerTurnPoster.d.ts.map +1 -0
  321. package/dist/requests/trackerTurnPoster.js +36 -0
  322. package/dist/requests/trackerTurnPoster.js.map +1 -0
  323. package/dist/requests/types.d.ts +9 -2
  324. package/dist/requests/types.d.ts.map +1 -1
  325. package/dist/requests/wakeUpEngine.d.ts +188 -11
  326. package/dist/requests/wakeUpEngine.d.ts.map +1 -1
  327. package/dist/requests/wakeUpEngine.js +452 -43
  328. package/dist/requests/wakeUpEngine.js.map +1 -1
  329. package/dist/requests/wakeUpRules.d.ts +122 -12
  330. package/dist/requests/wakeUpRules.d.ts.map +1 -1
  331. package/dist/requests/wakeUpRules.js +117 -15
  332. package/dist/requests/wakeUpRules.js.map +1 -1
  333. package/dist/resumeContext.d.ts +2 -2
  334. package/dist/resumeContext.js +3 -3
  335. package/dist/resumeContext.js.map +1 -1
  336. package/dist/runnerUtility/adminService.js +1 -1
  337. package/dist/runnerUtility/adminService.js.map +1 -1
  338. package/dist/runnerUtility/guiAgent.d.ts +1 -1
  339. package/dist/runnerUtility/guiAgent.d.ts.map +1 -1
  340. package/dist/runnerUtility/guiAgent.js +1 -1
  341. package/dist/runnerUtility/guiAgent.js.map +1 -1
  342. package/dist/runnerUtility/managedNode.d.ts +3 -3
  343. package/dist/runnerUtility/managedNode.d.ts.map +1 -1
  344. package/dist/runnerUtility/managedNode.js +2 -2
  345. package/dist/runnerUtility/managedNode.js.map +1 -1
  346. package/dist/runnerUtility/runnerConfig.d.ts +1 -1
  347. package/dist/runnerUtility/runnerHome.d.ts +1 -1
  348. package/dist/runnerUtility/runnerHome.js +1 -1
  349. package/dist/runnerUtility/serviceCommon.d.ts +1 -1
  350. package/dist/runnerUtility/serviceCommon.d.ts.map +1 -1
  351. package/dist/runnerUtility/serviceCommon.js +1 -1
  352. package/dist/runnerUtility/serviceCommon.js.map +1 -1
  353. package/dist/runners/bootstrapLine.js +1 -1
  354. package/dist/runners/hubPackage.d.ts +1 -1
  355. package/dist/runners/hubPackage.js +3 -3
  356. package/dist/runners/hubPackage.js.map +1 -1
  357. package/dist/runners/hubPaths.d.ts +1 -1
  358. package/dist/runners/hubPaths.d.ts.map +1 -1
  359. package/dist/runners/runnerLock.d.ts +2 -2
  360. package/dist/runners/runnerLock.d.ts.map +1 -1
  361. package/dist/runners/runnerLock.js +2 -2
  362. package/dist/runners/runnerLock.js.map +1 -1
  363. package/dist/scheduler/checkRun.d.ts +2 -0
  364. package/dist/scheduler/checkRun.d.ts.map +1 -1
  365. package/dist/scheduler/checkRun.js +5 -1
  366. package/dist/scheduler/checkRun.js.map +1 -1
  367. package/dist/scheduler/delivery.d.ts +57 -0
  368. package/dist/scheduler/delivery.d.ts.map +1 -1
  369. package/dist/scheduler/delivery.js +152 -14
  370. package/dist/scheduler/delivery.js.map +1 -1
  371. package/dist/scheduler/injection.d.ts +6 -0
  372. package/dist/scheduler/injection.d.ts.map +1 -1
  373. package/dist/scheduler/injection.js +10 -0
  374. package/dist/scheduler/injection.js.map +1 -1
  375. package/dist/scheduler/mcpSurface.d.ts +38 -3
  376. package/dist/scheduler/mcpSurface.d.ts.map +1 -1
  377. package/dist/scheduler/mcpSurface.js +291 -175
  378. package/dist/scheduler/mcpSurface.js.map +1 -1
  379. package/dist/scheduler/rebindResume.d.ts +24 -0
  380. package/dist/scheduler/rebindResume.d.ts.map +1 -1
  381. package/dist/scheduler/rebindResume.js +32 -0
  382. package/dist/scheduler/rebindResume.js.map +1 -1
  383. package/dist/scheduler/scheduleToolWording.d.ts +29 -0
  384. package/dist/scheduler/scheduleToolWording.d.ts.map +1 -0
  385. package/dist/scheduler/scheduleToolWording.js +117 -0
  386. package/dist/scheduler/scheduleToolWording.js.map +1 -0
  387. package/dist/scheduler/scheduledRunTarget.d.ts +90 -0
  388. package/dist/scheduler/scheduledRunTarget.d.ts.map +1 -0
  389. package/dist/scheduler/scheduledRunTarget.js +92 -0
  390. package/dist/scheduler/scheduledRunTarget.js.map +1 -0
  391. package/dist/scheduler/store.d.ts +2 -0
  392. package/dist/scheduler/store.d.ts.map +1 -1
  393. package/dist/scheduler/store.js +2 -0
  394. package/dist/scheduler/store.js.map +1 -1
  395. package/dist/scheduler/types.d.ts +10 -0
  396. package/dist/scheduler/types.d.ts.map +1 -1
  397. package/dist/scheduler/workerWatch.d.ts +2 -0
  398. package/dist/scheduler/workerWatch.d.ts.map +1 -1
  399. package/dist/scheduler/workerWatch.js +3 -3
  400. package/dist/scheduler/workerWatch.js.map +1 -1
  401. package/dist/selfUpdate/constants.d.ts +2 -0
  402. package/dist/selfUpdate/constants.d.ts.map +1 -1
  403. package/dist/selfUpdate/constants.js +3 -1
  404. package/dist/selfUpdate/constants.js.map +1 -1
  405. package/dist/selfUpdate/emittedSource.d.ts.map +1 -1
  406. package/dist/selfUpdate/emittedSource.js +1 -1
  407. package/dist/selfUpdate/emittedSource.js.map +1 -1
  408. package/dist/selfUpdate/updateRuntime.js +1 -1
  409. package/dist/selfUpdate/updateRuntime.js.map +1 -1
  410. package/dist/sessionPick.d.ts +1 -1
  411. package/dist/sessionPick.js +1 -1
  412. package/dist/startupPromptBuffer.d.ts +35 -6
  413. package/dist/startupPromptBuffer.d.ts.map +1 -1
  414. package/dist/startupPromptBuffer.js +70 -21
  415. package/dist/startupPromptBuffer.js.map +1 -1
  416. package/dist/state.d.ts +270 -30
  417. package/dist/state.d.ts.map +1 -1
  418. package/dist/state.js +403 -37
  419. package/dist/state.js.map +1 -1
  420. package/dist/testTimings.d.ts +17 -4
  421. package/dist/testTimings.d.ts.map +1 -1
  422. package/dist/testTimings.js +35 -3
  423. package/dist/testTimings.js.map +1 -1
  424. package/dist/threadContextPreamble.d.ts +7 -0
  425. package/dist/threadContextPreamble.d.ts.map +1 -1
  426. package/dist/threadContextPreamble.js +11 -0
  427. package/dist/threadContextPreamble.js.map +1 -1
  428. package/dist/threadRouting.d.ts +12 -0
  429. package/dist/threadRouting.d.ts.map +1 -1
  430. package/dist/threadRouting.js +15 -0
  431. package/dist/threadRouting.js.map +1 -1
  432. package/dist/todos/midTurn.d.ts +15 -41
  433. package/dist/todos/midTurn.d.ts.map +1 -1
  434. package/dist/todos/midTurn.js +27 -171
  435. package/dist/todos/midTurn.js.map +1 -1
  436. package/dist/todos/registry.d.ts +2 -0
  437. package/dist/todos/registry.d.ts.map +1 -1
  438. package/dist/todos/registry.js +3 -1
  439. package/dist/todos/registry.js.map +1 -1
  440. package/dist/types.d.ts +235 -23
  441. package/dist/types.d.ts.map +1 -1
  442. package/dist/types.js +10 -0
  443. package/dist/types.js.map +1 -1
  444. package/dist/utils/backendSwitchPlan.d.ts +3 -3
  445. package/dist/utils/backendSwitchPlan.js +3 -3
  446. package/dist/utils/claudeAccountAlert.d.ts +104 -0
  447. package/dist/utils/claudeAccountAlert.d.ts.map +1 -0
  448. package/dist/utils/claudeAccountAlert.js +130 -0
  449. package/dist/utils/claudeAccountAlert.js.map +1 -0
  450. package/dist/utils/claudeAccountPickerPlan.d.ts +7 -0
  451. package/dist/utils/claudeAccountPickerPlan.d.ts.map +1 -1
  452. package/dist/utils/claudeAccountPickerPlan.js +13 -2
  453. package/dist/utils/claudeAccountPickerPlan.js.map +1 -1
  454. package/dist/utils/claudeAuthRefusal.d.ts +122 -0
  455. package/dist/utils/claudeAuthRefusal.d.ts.map +1 -0
  456. package/dist/utils/claudeAuthRefusal.js +228 -0
  457. package/dist/utils/claudeAuthRefusal.js.map +1 -0
  458. package/dist/utils/claudeCompactHook.d.ts +9 -7
  459. package/dist/utils/claudeCompactHook.d.ts.map +1 -1
  460. package/dist/utils/claudeCompactHook.js +11 -9
  461. package/dist/utils/claudeCompactHook.js.map +1 -1
  462. package/dist/utils/claudeLimitSwitch.d.ts +1 -1
  463. package/dist/utils/claudeLimitSwitch.d.ts.map +1 -1
  464. package/dist/utils/claudeLimitSwitch.js +1 -1
  465. package/dist/utils/claudeLimitSwitch.js.map +1 -1
  466. package/dist/utils/claudeProfileSync.d.ts +88 -0
  467. package/dist/utils/claudeProfileSync.d.ts.map +1 -0
  468. package/dist/utils/claudeProfileSync.js +198 -0
  469. package/dist/utils/claudeProfileSync.js.map +1 -0
  470. package/dist/utils/claudeProfileUsageViews.d.ts +54 -2
  471. package/dist/utils/claudeProfileUsageViews.d.ts.map +1 -1
  472. package/dist/utils/claudeProfileUsageViews.js +44 -1
  473. package/dist/utils/claudeProfileUsageViews.js.map +1 -1
  474. package/dist/utils/claudeProfiles.d.ts +101 -6
  475. package/dist/utils/claudeProfiles.d.ts.map +1 -1
  476. package/dist/utils/claudeProfiles.js +297 -23
  477. package/dist/utils/claudeProfiles.js.map +1 -1
  478. package/dist/utils/claudeRuntimeInfo.d.ts +24 -0
  479. package/dist/utils/claudeRuntimeInfo.d.ts.map +1 -1
  480. package/dist/utils/claudeRuntimeInfo.js +128 -3
  481. package/dist/utils/claudeRuntimeInfo.js.map +1 -1
  482. package/dist/utils/claudeScheduledJobs.d.ts +6 -2
  483. package/dist/utils/claudeScheduledJobs.d.ts.map +1 -1
  484. package/dist/utils/claudeScheduledJobs.js +10 -2
  485. package/dist/utils/claudeScheduledJobs.js.map +1 -1
  486. package/dist/utils/claudeSessionTitle.js +1 -1
  487. package/dist/utils/claudeSessionTitle.js.map +1 -1
  488. package/dist/utils/claudeStreamJson.d.ts +28 -2
  489. package/dist/utils/claudeStreamJson.d.ts.map +1 -1
  490. package/dist/utils/claudeStreamJson.js +33 -3
  491. package/dist/utils/claudeStreamJson.js.map +1 -1
  492. package/dist/utils/claudeTranscriptEpoch.d.ts +14 -0
  493. package/dist/utils/claudeTranscriptEpoch.d.ts.map +1 -1
  494. package/dist/utils/claudeTranscriptEpoch.js +79 -19
  495. package/dist/utils/claudeTranscriptEpoch.js.map +1 -1
  496. package/dist/utils/claudeUsage.d.ts +103 -7
  497. package/dist/utils/claudeUsage.d.ts.map +1 -1
  498. package/dist/utils/claudeUsage.js +108 -15
  499. package/dist/utils/claudeUsage.js.map +1 -1
  500. package/dist/utils/claudeUsageRefresher.d.ts +8 -1
  501. package/dist/utils/claudeUsageRefresher.d.ts.map +1 -1
  502. package/dist/utils/claudeUsageRefresher.js +11 -1
  503. package/dist/utils/claudeUsageRefresher.js.map +1 -1
  504. package/dist/utils/compactOnIdle.d.ts +139 -29
  505. package/dist/utils/compactOnIdle.d.ts.map +1 -1
  506. package/dist/utils/compactOnIdle.js +163 -36
  507. package/dist/utils/compactOnIdle.js.map +1 -1
  508. package/dist/utils/conversationEnding.d.ts +76 -0
  509. package/dist/utils/conversationEnding.d.ts.map +1 -0
  510. package/dist/utils/conversationEnding.js +117 -0
  511. package/dist/utils/conversationEnding.js.map +1 -0
  512. package/dist/utils/cutButtonLabel.d.ts +7 -0
  513. package/dist/utils/cutButtonLabel.d.ts.map +1 -0
  514. package/dist/utils/cutButtonLabel.js +17 -0
  515. package/dist/utils/cutButtonLabel.js.map +1 -0
  516. package/dist/utils/doctorLine.d.ts +10 -0
  517. package/dist/utils/doctorLine.d.ts.map +1 -1
  518. package/dist/utils/doctorLine.js +16 -0
  519. package/dist/utils/doctorLine.js.map +1 -1
  520. package/dist/utils/fallbackBridge.d.ts.map +1 -1
  521. package/dist/utils/fallbackBridge.js +2 -1
  522. package/dist/utils/fallbackBridge.js.map +1 -1
  523. package/dist/utils/fallbackChain.d.ts +2 -0
  524. package/dist/utils/fallbackChain.d.ts.map +1 -1
  525. package/dist/utils/fallbackChain.js +4 -3
  526. package/dist/utils/fallbackChain.js.map +1 -1
  527. package/dist/utils/fallbackSwitchNotice.d.ts +11 -4
  528. package/dist/utils/fallbackSwitchNotice.d.ts.map +1 -1
  529. package/dist/utils/fallbackSwitchNotice.js +9 -5
  530. package/dist/utils/fallbackSwitchNotice.js.map +1 -1
  531. package/dist/utils/fileSendService.d.ts +31 -0
  532. package/dist/utils/fileSendService.d.ts.map +1 -1
  533. package/dist/utils/fileSendService.js +45 -2
  534. package/dist/utils/fileSendService.js.map +1 -1
  535. package/dist/utils/jsonStreamHost.d.ts +2 -0
  536. package/dist/utils/jsonStreamHost.d.ts.map +1 -1
  537. package/dist/utils/jsonStreamHost.js +4 -1
  538. package/dist/utils/jsonStreamHost.js.map +1 -1
  539. package/dist/utils/jsonStreamPendingWork.d.ts +14 -2
  540. package/dist/utils/jsonStreamPendingWork.d.ts.map +1 -1
  541. package/dist/utils/jsonStreamPendingWork.js +25 -5
  542. package/dist/utils/jsonStreamPendingWork.js.map +1 -1
  543. package/dist/utils/jsonStreamUnconsumedInput.d.ts +80 -0
  544. package/dist/utils/jsonStreamUnconsumedInput.d.ts.map +1 -0
  545. package/dist/utils/jsonStreamUnconsumedInput.js +99 -0
  546. package/dist/utils/jsonStreamUnconsumedInput.js.map +1 -0
  547. package/dist/utils/limitEpisodeRecovery.d.ts +43 -4
  548. package/dist/utils/limitEpisodeRecovery.d.ts.map +1 -1
  549. package/dist/utils/limitEpisodeRecovery.js +107 -20
  550. package/dist/utils/limitEpisodeRecovery.js.map +1 -1
  551. package/dist/utils/limitHeldPrompts.d.ts +21 -11
  552. package/dist/utils/limitHeldPrompts.d.ts.map +1 -1
  553. package/dist/utils/limitHeldPrompts.js +12 -9
  554. package/dist/utils/limitHeldPrompts.js.map +1 -1
  555. package/dist/utils/limitRemindersScreenPlan.d.ts +63 -0
  556. package/dist/utils/limitRemindersScreenPlan.d.ts.map +1 -0
  557. package/dist/utils/limitRemindersScreenPlan.js +121 -0
  558. package/dist/utils/limitRemindersScreenPlan.js.map +1 -0
  559. package/dist/utils/limitSwitchPlan.d.ts +44 -0
  560. package/dist/utils/limitSwitchPlan.d.ts.map +1 -0
  561. package/dist/utils/limitSwitchPlan.js +54 -0
  562. package/dist/utils/limitSwitchPlan.js.map +1 -0
  563. package/dist/utils/limitsBoardPlan.d.ts +16 -7
  564. package/dist/utils/limitsBoardPlan.d.ts.map +1 -1
  565. package/dist/utils/limitsBoardPlan.js +41 -9
  566. package/dist/utils/limitsBoardPlan.js.map +1 -1
  567. package/dist/utils/lostWork.d.ts +16 -2
  568. package/dist/utils/lostWork.d.ts.map +1 -1
  569. package/dist/utils/lostWork.js +16 -3
  570. package/dist/utils/lostWork.js.map +1 -1
  571. package/dist/utils/messageContext.d.ts +2 -2
  572. package/dist/utils/messageContext.js +2 -2
  573. package/dist/utils/midTurnInbox.d.ts +79 -0
  574. package/dist/utils/midTurnInbox.d.ts.map +1 -0
  575. package/dist/utils/midTurnInbox.js +265 -0
  576. package/dist/utils/midTurnInbox.js.map +1 -0
  577. package/dist/utils/promptDelivery.d.ts +70 -22
  578. package/dist/utils/promptDelivery.d.ts.map +1 -1
  579. package/dist/utils/promptDelivery.js +100 -42
  580. package/dist/utils/promptDelivery.js.map +1 -1
  581. package/dist/utils/questionWaitChoices.d.ts +20 -0
  582. package/dist/utils/questionWaitChoices.d.ts.map +1 -0
  583. package/dist/utils/questionWaitChoices.js +31 -0
  584. package/dist/utils/questionWaitChoices.js.map +1 -0
  585. package/dist/utils/questionWaitPlan.d.ts +166 -0
  586. package/dist/utils/questionWaitPlan.d.ts.map +1 -0
  587. package/dist/utils/questionWaitPlan.js +237 -0
  588. package/dist/utils/questionWaitPlan.js.map +1 -0
  589. package/dist/utils/replyQuote.d.ts +10 -0
  590. package/dist/utils/replyQuote.d.ts.map +1 -1
  591. package/dist/utils/replyQuote.js +18 -7
  592. package/dist/utils/replyQuote.js.map +1 -1
  593. package/dist/utils/talkerAccess.d.ts +2 -2
  594. package/dist/utils/talkerAccess.d.ts.map +1 -1
  595. package/dist/utils/talkerAccess.js +5 -4
  596. package/dist/utils/talkerAccess.js.map +1 -1
  597. package/dist/utils/telegramError.d.ts +6 -0
  598. package/dist/utils/telegramError.d.ts.map +1 -1
  599. package/dist/utils/telegramError.js +12 -0
  600. package/dist/utils/telegramError.js.map +1 -1
  601. package/dist/utils/topicAccessScreenPlan.d.ts +1 -1
  602. package/dist/utils/topicAccessScreenPlan.d.ts.map +1 -1
  603. package/dist/utils/topicAccessScreenPlan.js +3 -7
  604. package/dist/utils/topicAccessScreenPlan.js.map +1 -1
  605. package/dist/utils/topicIndicatorPlan.d.ts +153 -0
  606. package/dist/utils/topicIndicatorPlan.d.ts.map +1 -0
  607. package/dist/utils/topicIndicatorPlan.js +224 -0
  608. package/dist/utils/topicIndicatorPlan.js.map +1 -0
  609. package/dist/utils/topicIndicatorSources.d.ts +40 -0
  610. package/dist/utils/topicIndicatorSources.d.ts.map +1 -0
  611. package/dist/utils/topicIndicatorSources.js +31 -0
  612. package/dist/utils/topicIndicatorSources.js.map +1 -0
  613. package/dist/utils/topicRequest.d.ts +3 -0
  614. package/dist/utils/topicRequest.d.ts.map +1 -1
  615. package/dist/utils/topicRequest.js +4 -0
  616. package/dist/utils/topicRequest.js.map +1 -1
  617. package/dist/utils/topicStatusPlan.d.ts +90 -0
  618. package/dist/utils/topicStatusPlan.d.ts.map +1 -0
  619. package/dist/utils/topicStatusPlan.js +160 -0
  620. package/dist/utils/topicStatusPlan.js.map +1 -0
  621. package/dist/utils/workerRoles.d.ts +122 -0
  622. package/dist/utils/workerRoles.d.ts.map +1 -0
  623. package/dist/utils/workerRoles.js +160 -0
  624. package/dist/utils/workerRoles.js.map +1 -0
  625. package/dist/utils/workerRolesScreenPlan.d.ts +118 -0
  626. package/dist/utils/workerRolesScreenPlan.d.ts.map +1 -0
  627. package/dist/utils/workerRolesScreenPlan.js +232 -0
  628. package/dist/utils/workerRolesScreenPlan.js.map +1 -0
  629. package/dist/utils/workingSignals.d.ts +49 -0
  630. package/dist/utils/workingSignals.d.ts.map +1 -0
  631. package/dist/utils/workingSignals.js +41 -0
  632. package/dist/utils/workingSignals.js.map +1 -0
  633. package/licensing.json +88 -0
  634. package/npm-shrinkwrap.json +2 -2
  635. package/package.json +7 -7
  636. package/{remoteRun → runner-scripts}/runner.sh +6 -3
  637. package/COMMERCIAL-LICENSE.md +0 -142
  638. package/dist/agentTrigger.d.ts +0 -28
  639. package/dist/agentTrigger.d.ts.map +0 -1
  640. package/dist/agentTrigger.js +0 -53
  641. package/dist/agentTrigger.js.map +0 -1
  642. /package/{remoteRun → runner-scripts}/ensureNode.sh +0 -0
  643. /package/{remoteRun → runner-scripts}/runner-package-lock.json +0 -0
@@ -8,6 +8,7 @@
8
8
  * mirroring `getCompactCommandRoute` in `compactCommandRoute.ts`.
9
9
  */
10
10
  import type { CompactCommandRoute } from './compactCommandRoute';
11
+ import { type BackgroundWorkSignal, type IdleHeldNoticeReason, type WorkingSignal } from './workingSignals';
11
12
  /**
12
13
  * Idle interval before an untouched, idle agent session is auto-compacted (F2)
13
14
  * and, on a backend that can be suspended, stopped (lifecycle plan L3). Chosen
@@ -27,7 +28,8 @@ export declare function getAgentIdleMs(overrideMinutes: string | undefined): num
27
28
  * Floor delay for an OVERDUE arm (the thread has been idle longer than
28
29
  * {@link idleCompactMs}, across one or more bot restarts). Never fire instantly at
29
30
  * boot: the reattach is still adopting sessions and the topic may be about to
30
- * receive a real prompt, so give it a minute of grace first.
31
+ * receive a real prompt, so give it a minute of grace first. At a shortened idle window (a test's) it
32
+ * shortens in proportion, see {@link getIdleCompactionArmDecision}.
31
33
  */
32
34
  export declare const compactIdleOverdueMinDelayMs = 60000;
33
35
  /**
@@ -71,10 +73,13 @@ export interface IdleCompactionArmDecision {
71
73
  * fire soon, but staggered: {@link compactIdleOverdueMinDelayMs} plus a
72
74
  * per-thread offset inside {@link compactIdleOverdueSpreadMs}. The boot
73
75
  * reattach adopts every live session at once; without the stagger every
74
- * overdue topic would start an LLM compaction turn and post its notice in the
75
- * same instant. Spreading them over ~1–11 minutes keeps the backlog orderly,
76
+ * overdue topic would be stopped (and its session slept) in the same instant.
77
+ * Spreading them over ~1–11 minutes keeps the backlog orderly,
76
78
  * and deriving the offset from the thread key keeps it deterministic (hence
77
- * testable) instead of random.
79
+ * testable) instead of random. At a shortened window (`AGENT_IDLE_MINUTES`, a
80
+ * test's) the floor and the spread shorten in the same proportion, so a flow
81
+ * with a 12 s window does not wait out minutes; at the default window they are
82
+ * exactly the constants.
78
83
  *
79
84
  * The stagger being DETERMINISTIC was considered and chosen, not overlooked: a
80
85
  * thread whose offset lands near the top of the spread never fires while the bot
@@ -85,12 +90,11 @@ export interface IdleCompactionArmDecision {
85
90
  * frequent a FULL-window arm starves just as surely, so the stagger is not
86
91
  * uniquely affected. Do not re-litigate this as an oversight.
87
92
  *
88
- * An overdue thread is compacted even though its prompt cache has long gone
89
- * cold. The 55-minute interval exists to make the compaction TURN itself cheap
90
- * against a warm cache, but the payoff of compacting is that every SUBSEQUENT
91
- * turn in that session reads a small context instead of a huge one — clearly
92
- * worth one uncached read, whereas skipping it leaves the session permanently
93
- * bloated.
93
+ * An overdue fire does NOT compact (the owner's rule, replacing an earlier decision to compact anyway): the 55-minute interval
94
+ * exists so the compaction TURN reads the still-warm prompt cache, and past the window that cache is gone — compacting then is
95
+ * only an expensive uncached read, the same reason a held mark is never compacted late (see {@link getIdleFireDecision}). The
96
+ * overdue fire only decides the STOP of the idle process; the conversation is compacted at the idle mark of a later period,
97
+ * while the cache is warm.
94
98
  */
95
99
  export declare function getIdleCompactionArmDecision(input: {
96
100
  threadKeyString: string;
@@ -125,6 +129,70 @@ export declare function resolveCompactSummaryEnabled(globalDefault: boolean | un
125
129
  * Read at COMPACTION time, like {@link resolveCompactSummaryEnabled}, so it is meaningful in a topic with no live session.
126
130
  */
127
131
  export declare function resolveCompactSelfReviewEnabled(globalDefault: boolean | undefined, threadOverride: boolean | undefined): boolean;
132
+ /**
133
+ * The growth of a conversation's context, in tokens, that makes an idle compaction worth running (owner, 2026-11-22: «if the
134
+ * number grows by about 30 000 over what it was after the last compaction, with every instruction and skill loaded, it makes sense
135
+ * to compact»). The default of `/compact_on_idle`'s threshold, which the General topic and each topic can change.
136
+ */
137
+ export declare const defaultCompactGrowthTokens = 30000;
138
+ /** The choices the `/compact_on_idle` picker offers for the threshold, in tokens; a typed value may be any other in range. */
139
+ export declare const compactGrowthPresetTokens: readonly number[];
140
+ /** The largest threshold a person may type: a model's context window is the most a conversation can ever grow by. */
141
+ export declare const maxCompactGrowthTokens = 1000000;
142
+ /** How long after the last output of a backend with no turn-end signal its context size is read: the turn has most likely settled. */
143
+ export declare const contextSampleDebounceMs = 5000;
144
+ /**
145
+ * @description The growth threshold in force: the topic's own value, else the instance default (General's), else
146
+ * {@link defaultCompactGrowthTokens}. A per-thread value always wins.
147
+ */
148
+ export declare function resolveCompactGrowthTokens(globalDefault: number | undefined, threadOverride: number | undefined): number;
149
+ /**
150
+ * @description The threshold a person typed, in tokens — a whole number, with a `k` for thousands and blanks, commas or
151
+ * underscores as digit separators ignored — or `null` when it is no number or outside 0…{@link maxCompactGrowthTokens} (0 asks for
152
+ * a compaction at every idle mark with a new turn, as before the threshold existed).
153
+ */
154
+ export declare function parseCompactGrowthTokens(text: string): number | null;
155
+ /**
156
+ * @description How far the context has grown, in tokens, since the conversation's baseline — what its FIRST model call after the last
157
+ * compaction saw (the summary, every instruction and skill loaded again, the prompt; the compaction's own `post=` figure is not it)
158
+ * — up to the newest turn read. `null` when either reading is missing: the growth cannot be told ({@link checkIsContextGrownEnough}
159
+ * says what that means for the compaction). Never negative: a context that shrank has not grown.
160
+ */
161
+ export declare function getContextGrowthTokens(input: {
162
+ baselineContextTokens: number | null;
163
+ lastContextTokens: number | null;
164
+ }): number | null;
165
+ /**
166
+ * @description Whether the context grew enough for an idle compaction to be worth running: the growth reached the threshold. When it
167
+ * cannot be told (`null`) a conversation never compacted is not held back — there is nothing to measure from yet — but one that WAS
168
+ * compacted is: nothing is known to have grown, and a backend whose compaction raises no signal of its own (the tmux Claude types
169
+ * `/compact` into its TUI) would otherwise be compacted at every idle mark, its own output re-arming the next.
170
+ */
171
+ export declare function checkIsContextGrownEnough(input: {
172
+ contextGrowthTokens: number | null;
173
+ growthThresholdTokens: number;
174
+ hasEarlierCompaction: boolean;
175
+ }): boolean;
176
+ /**
177
+ * @description The baseline after a context reading. With none yet (the first turn that ends after a compaction, a conversation the
178
+ * bot has no figures of, a measure at the idle mark) it is the context of the epoch's FIRST model call — the compacted summary, the
179
+ * instructions, the skills and the prompt, read from the conversation's history — and `null` while that cannot be told (it is read
180
+ * again at the next reading). A compaction the bot did NOT issue since the last reading (`isNewEpoch`: the CLI's own overflow
181
+ * compaction, the server's own, counted by the adapter) replaced the epoch, so the baseline it had is the older epoch's: the new
182
+ * epoch's first call takes its place, `null` while there is none yet. A RECHECK (`isBaselineRecheck`: the first call is read again
183
+ * although a baseline is there — the first reading of a bot lifetime, a sleeping conversation's every read — because a compaction may
184
+ * have gone by that no count saw) replaces the baseline with the figure when the read gave one and keeps it when it gave none: the
185
+ * first call of the epoch the conversation is in IS its baseline, and a failed read says nothing against the old one. Otherwise a
186
+ * baseline stays — except that a context SMALLER than it is the same sign for a compaction nothing counted (the tmux Claude's own): it
187
+ * is dropped, to be read again from the new epoch.
188
+ */
189
+ export declare function getContextBaselineAfterReading(input: {
190
+ baselineContextTokens: number | null;
191
+ lastContextTokens: number;
192
+ firstCallContextTokens: number | null;
193
+ isNewEpoch: boolean;
194
+ isBaselineRecheck?: boolean;
195
+ }): number | null;
128
196
  /**
129
197
  * @description Whether the session is busy for a REAL running turn, as opposed
130
198
  * to merely idle-WAITING on an unanswered interactive question. Both states make
@@ -138,18 +206,17 @@ export declare function checkIsBusyForRealTurn(input: {
138
206
  hasPendingQuestion: boolean;
139
207
  }): boolean;
140
208
  /**
141
- * @description Whether the process is WORKING at the idle fire (L-D2): a real
142
- * running turn ({@link checkIsBusyForRealTurn} — a pending question excuses the
143
- * turn, D1) OR background work the question never excuses (a background task,
144
- * input not yet taken in, a compaction in flight). The two are read apart so a
145
- * question pending over a running background task still reads as working: the
146
- * D1 reject-compact-re-ask would otherwise end in a stop that kills the task.
209
+ * @description What keeps the process WORKING at the idle fire (L-D2), by name: a real running turn
210
+ * ({@link checkIsBusyForRealTurn} — a pending question excuses the turn, D1) and the background signals the question
211
+ * never excuses (a background task, input not yet taken in, a compaction in flight). The two are read apart so a question
212
+ * pending over a running background task still reads as working: the D1 reject-compact-re-ask would otherwise end in a
213
+ * stop that kills the task. Empty when the process is idle.
147
214
  */
148
- export declare function checkIsWorkingAtIdle(input: {
215
+ export declare function getWorkingSignalsAtIdle(input: {
149
216
  isBusy: boolean;
150
217
  hasPendingQuestion: boolean;
151
- hasBackgroundWork: boolean;
152
- }): boolean;
218
+ backgroundSignals: readonly BackgroundWorkSignal[];
219
+ }): WorkingSignal[];
153
220
  /** Past the pending-work hold's end by this much, the re-check finds the hold spent rather than a few ms left. */
154
221
  export declare const pendingWorkRecheckMarginMs = 1000;
155
222
  /**
@@ -162,9 +229,18 @@ export declare function getPendingWorkRecheckDelayMs(input: {
162
229
  idleWindowMs: number;
163
230
  holdRemainingMs: number | null;
164
231
  }): number;
232
+ /**
233
+ * @description Whether the idle mark of the thread's CURRENT idle period was already held: a fire found the process working and
234
+ * forwent its compaction (`lastHeldMarkAt`), and no activity has come since (`lastActivityAt` — activity warms the prompt cache
235
+ * again and starts a new idle period, whose mark may compact). Both instants are persisted, so a restart keeps the answer.
236
+ */
237
+ export declare function checkIsIdleMarkSpent(input: {
238
+ lastActivityAt: number;
239
+ lastHeldMarkAt: number;
240
+ }): boolean;
165
241
  /** What the idle timer does when it fires: the compaction half and the stop half, each with its reasons. */
166
242
  export interface IdleFireDecision {
167
- /** Run the idle compaction (D1/D2). */
243
+ /** Run the idle compaction (D1). */
168
244
  shouldCompact: boolean;
169
245
  /** Why the compaction is skipped — logged, since a silent skip was the feature's blind spot. */
170
246
  compactionSkipReasons: string[];
@@ -172,20 +248,41 @@ export interface IdleFireDecision {
172
248
  shouldSuspend: boolean;
173
249
  /** Why the process stays. */
174
250
  suspendSkipReasons: string[];
251
+ /**
252
+ * This fire forgoes a compaction that was due ONLY because the process is held: the caller remembers the idle mark as held
253
+ * (see {@link getIdleFireDecision}'s `isIdleMarkSpent`). False for a re-check, which has nothing new to remember.
254
+ */
255
+ isIdleMarkHeld: boolean;
256
+ /** What to tell the topic about the forgone compaction — once, at the fire that holds the mark; `null`: nothing to say. */
257
+ heldNoticeReason: IdleHeldNoticeReason | null;
175
258
  }
176
259
  /**
177
260
  * @description The idle-fire decision, taken the moment the idle timer fires
178
261
  * (lifecycle plan L3). Nothing happens to a session that is not there or is
179
262
  * WORKING (L-D2: a real running turn, a background task, input not yet taken in,
180
263
  * a compaction in flight — a pending interactive question is NOT work, see
181
- * {@link checkIsBusyForRealTurn}; D1); the next activity re-arms the timer.
264
+ * {@link checkIsBusyForRealTurn}; D1); the next activity re-arms the timer. The reasons name WHICH signals hold the
265
+ * process (`working (busy turn, unconsumed input 2)`).
266
+ *
267
+ * The compaction runs only when the feature is enabled for the thread, at least one agent turn has completed since the
268
+ * last compaction (otherwise there is nothing new to compress), no usage-limit wait is armed (L-D6: a compaction turn would hit
269
+ * the limit), and the conversation's context GREW enough to be worth compressing (owner, 2026-11-22: «if the context did not
270
+ * grow much there is no point in compacting»): by `growthThresholdTokens` over what its first model call after the last
271
+ * compaction saw (see {@link getContextGrowthTokens}). A conversation with no such reading (`contextGrowthTokens: null`) is not
272
+ * held back by it only while it was never compacted ({@link checkIsContextGrownEnough}). There is no once-per-active-period
273
+ * latch any more: the growth threshold is what keeps a process that stays alive from being compacted over and over, and the stop
274
+ * ends the idle period of one that does not — so a topic woken only by its own checks and worker watches is compacted again before
275
+ * it sleeps once it has grown enough (owner, 2026-11-22: «compaction first, then the topic goes to sleep»).
182
276
  *
183
- * The compaction runs only when the feature is enabled for the thread, the
184
- * per-thread user-latch is NOT already spent (D2 — after a fire it stays latched
185
- * until the next genuine USER message re-arms it, so idle compaction runs at most
186
- * once per user-active period), at least one agent turn has completed since the
187
- * last compaction (otherwise there is nothing new to compress), and no
188
- * usage-limit wait is armed (L-D6: a compaction turn would hit the limit).
277
+ * The compaction belongs to the IDLE MARK alone: it exists to read the still-warm prompt cache, which is gone a little after the
278
+ * idle window (`idleCompactMs`), so a compaction later than the mark is only an expensive one. A process held at the mark
279
+ * (a compaction that was otherwise due is then `isIdleMarkHeld`) does NOT get its compaction on a later look: once the mark is
280
+ * spent (`isIdleMarkSpent` — it was held and no activity has re-warmed the cache since) every later fire, the re-checks of a
281
+ * held process, decides only the stop. Nor does a fire whose countdown was armed AFTER the mark had already passed
282
+ * (`isIdleMarkMissed`: the overdue arm — the bot came back from downtime past the window, or a re-spawn or a per-turn wake found
283
+ * the topic idle for longer than that) compact: it decides only the stop too, and a hold at it costs nothing, so there is no
284
+ * mark to hold and nothing to tell.
285
+ * Activity re-arms the countdown, and with it the next mark's compaction.
189
286
  *
190
287
  * The STOP happens whether or not the compaction runs (L-D1: a resume restores
191
288
  * the full history, so a stopped process loses nothing) — on a backend that can
@@ -193,11 +290,24 @@ export interface IdleFireDecision {
193
290
  */
194
291
  export declare function getIdleFireDecision(input: {
195
292
  isSessionActive: boolean;
196
- isWorking: boolean;
293
+ /** What holds the process now (empty: idle); see {@link getWorkingSignalsAtIdle}. */
294
+ workingSignals: readonly WorkingSignal[];
295
+ /** The idle mark of this idle period was already held (a fire found the process working and forwent its compaction). */
296
+ isIdleMarkSpent: boolean;
297
+ /** This fire's countdown was armed (the overdue arm) when the idle mark had already passed: the prompt cache is cold. */
298
+ isIdleMarkMissed: boolean;
197
299
  isEnabled: boolean;
198
- isLatched: boolean;
199
300
  hasCompletedTurnSinceCompaction: boolean;
200
301
  isLimitWaitArmed: boolean;
302
+ /**
303
+ * How far the context has grown since what the conversation's first model call after its last compaction saw, in tokens
304
+ * ({@link getContextGrowthTokens}); `null` when that cannot be told.
305
+ */
306
+ contextGrowthTokens: number | null;
307
+ /** The growth that makes the compaction worth it (`/compact_on_idle`, {@link resolveCompactGrowthTokens}). */
308
+ growthThresholdTokens: number;
309
+ /** The conversation was compacted before (the saved `lastCompactionAt` is set): an unknown growth then holds the compaction back. */
310
+ hasEarlierCompaction: boolean;
201
311
  canSuspend: boolean;
202
312
  }): IdleFireDecision;
203
313
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"compactOnIdle.d.ts","sourceRoot":"","sources":["../../src/utils/compactOnIdle.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAIjE;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,QAAiB,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAE1E;AAED;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,QAAS,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,QAAiB,CAAC;AAoBzD;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG,WAAW,GAAG,SAAS,CAAC;AAE3E,8FAA8F;AAC9F,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,qBAAqB,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE;IAClD,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,+FAA+F;IAC/F,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,yBAAyB,CAW5B;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,OAAO,GAAG,SAAS,EAClC,cAAc,EAAE,OAAO,GAAG,SAAS,GAClC,OAAO,CAET;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAC1C,aAAa,EAAE,OAAO,GAAG,SAAS,EAClC,cAAc,EAAE,OAAO,GAAG,SAAS,GAClC,OAAO,CAET;AAED;;;;;;GAMG;AACH,wBAAgB,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21 @@
9
9
  * mirroring `getCompactCommandRoute` in `compactCommandRoute.ts`.
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.compactionClosingEndMarker = exports.compactionClosingStartMarker = exports.compactionResumeGuidance = exports.compactionResumeGuidanceWithoutGaps = exports.compactionGapsGuidance = exports.compactionNoGapsLine = exports.compactionGapsEndMarker = exports.compactionGapsStartMarker = exports.compactionChecklistGuidance = exports.compactionChecklistSkillsItem = exports.compactionSkillsGuidance = exports.compactionSkillsBlockGuidance = exports.compactionSkillsBlockMaxNameLength = exports.compactionSkillsBlockEndMarker = exports.compactionSkillsBlockStartMarker = exports.compactionSummaryGuidance = exports.pendingWorkRecheckMarginMs = exports.compactIdleOverdueSpreadMs = exports.compactIdleOverdueMinDelayMs = exports.idleCompactMs = void 0;
12
+ exports.compactionClosingEndMarker = exports.compactionClosingStartMarker = exports.compactionResumeGuidance = exports.compactionResumeGuidanceWithoutGaps = exports.compactionGapsGuidance = exports.compactionNoGapsLine = exports.compactionGapsEndMarker = exports.compactionGapsStartMarker = exports.compactionChecklistGuidance = exports.compactionChecklistSkillsItem = exports.compactionSkillsGuidance = exports.compactionSkillsBlockGuidance = exports.compactionSkillsBlockMaxNameLength = exports.compactionSkillsBlockEndMarker = exports.compactionSkillsBlockStartMarker = exports.compactionSummaryGuidance = exports.pendingWorkRecheckMarginMs = exports.contextSampleDebounceMs = exports.maxCompactGrowthTokens = exports.compactGrowthPresetTokens = exports.defaultCompactGrowthTokens = exports.compactIdleOverdueSpreadMs = exports.compactIdleOverdueMinDelayMs = exports.idleCompactMs = void 0;
13
13
  exports.getAgentIdleMs = getAgentIdleMs;
14
14
  exports.getIdleCompactionArmDecision = getIdleCompactionArmDecision;
15
15
  exports.resolveCompactOnIdleEnabled = resolveCompactOnIdleEnabled;
16
16
  exports.resolveCompactSummaryEnabled = resolveCompactSummaryEnabled;
17
17
  exports.resolveCompactSelfReviewEnabled = resolveCompactSelfReviewEnabled;
18
+ exports.resolveCompactGrowthTokens = resolveCompactGrowthTokens;
19
+ exports.parseCompactGrowthTokens = parseCompactGrowthTokens;
20
+ exports.getContextGrowthTokens = getContextGrowthTokens;
21
+ exports.checkIsContextGrownEnough = checkIsContextGrownEnough;
22
+ exports.getContextBaselineAfterReading = getContextBaselineAfterReading;
18
23
  exports.checkIsBusyForRealTurn = checkIsBusyForRealTurn;
19
- exports.checkIsWorkingAtIdle = checkIsWorkingAtIdle;
24
+ exports.getWorkingSignalsAtIdle = getWorkingSignalsAtIdle;
20
25
  exports.getPendingWorkRecheckDelayMs = getPendingWorkRecheckDelayMs;
26
+ exports.checkIsIdleMarkSpent = checkIsIdleMarkSpent;
21
27
  exports.getIdleFireDecision = getIdleFireDecision;
22
28
  exports.getCompactionResumeGuidance = getCompactionResumeGuidance;
23
29
  exports.buildCompactionInstruction = buildCompactionInstruction;
@@ -37,6 +43,7 @@ exports.checkShouldAnnounceCompactionStart = checkShouldAnnounceCompactionStart;
37
43
  exports.buildIdleCompactionNoticeParts = buildIdleCompactionNoticeParts;
38
44
  const threadToggle_1 = require("./threadToggle");
39
45
  const minutesOverride_1 = require("./minutesOverride");
46
+ const workingSignals_1 = require("./workingSignals");
40
47
  /**
41
48
  * Idle interval before an untouched, idle agent session is auto-compacted (F2)
42
49
  * and, on a backend that can be suspended, stopped (lifecycle plan L3). Chosen
@@ -58,7 +65,8 @@ function getAgentIdleMs(overrideMinutes) {
58
65
  * Floor delay for an OVERDUE arm (the thread has been idle longer than
59
66
  * {@link idleCompactMs}, across one or more bot restarts). Never fire instantly at
60
67
  * boot: the reattach is still adopting sessions and the topic may be about to
61
- * receive a real prompt, so give it a minute of grace first.
68
+ * receive a real prompt, so give it a minute of grace first. At a shortened idle window (a test's) it
69
+ * shortens in proportion, see {@link getIdleCompactionArmDecision}.
62
70
  */
63
71
  exports.compactIdleOverdueMinDelayMs = 60_000;
64
72
  /**
@@ -106,10 +114,13 @@ function getStableHash(text) {
106
114
  * fire soon, but staggered: {@link compactIdleOverdueMinDelayMs} plus a
107
115
  * per-thread offset inside {@link compactIdleOverdueSpreadMs}. The boot
108
116
  * reattach adopts every live session at once; without the stagger every
109
- * overdue topic would start an LLM compaction turn and post its notice in the
110
- * same instant. Spreading them over ~1–11 minutes keeps the backlog orderly,
117
+ * overdue topic would be stopped (and its session slept) in the same instant.
118
+ * Spreading them over ~1–11 minutes keeps the backlog orderly,
111
119
  * and deriving the offset from the thread key keeps it deterministic (hence
112
- * testable) instead of random.
120
+ * testable) instead of random. At a shortened window (`AGENT_IDLE_MINUTES`, a
121
+ * test's) the floor and the spread shorten in the same proportion, so a flow
122
+ * with a 12 s window does not wait out minutes; at the default window they are
123
+ * exactly the constants.
113
124
  *
114
125
  * The stagger being DETERMINISTIC was considered and chosen, not overlooked: a
115
126
  * thread whose offset lands near the top of the spread never fires while the bot
@@ -120,12 +131,11 @@ function getStableHash(text) {
120
131
  * frequent a FULL-window arm starves just as surely, so the stagger is not
121
132
  * uniquely affected. Do not re-litigate this as an oversight.
122
133
  *
123
- * An overdue thread is compacted even though its prompt cache has long gone
124
- * cold. The 55-minute interval exists to make the compaction TURN itself cheap
125
- * against a warm cache, but the payoff of compacting is that every SUBSEQUENT
126
- * turn in that session reads a small context instead of a huge one — clearly
127
- * worth one uncached read, whereas skipping it leaves the session permanently
128
- * bloated.
134
+ * An overdue fire does NOT compact (the owner's rule, replacing an earlier decision to compact anyway): the 55-minute interval
135
+ * exists so the compaction TURN reads the still-warm prompt cache, and past the window that cache is gone — compacting then is
136
+ * only an expensive uncached read, the same reason a held mark is never compacted late (see {@link getIdleFireDecision}). The
137
+ * overdue fire only decides the STOP of the idle process; the conversation is compacted at the idle mark of a later period,
138
+ * while the cache is warm.
129
139
  */
130
140
  function getIdleCompactionArmDecision(input) {
131
141
  const idleWindowMs = input.idleWindowMs ?? exports.idleCompactMs;
@@ -136,8 +146,11 @@ function getIdleCompactionArmDecision(input) {
136
146
  // remainder must never exceed the window it is a remainder of.
137
147
  if (remainingMs > 0)
138
148
  return { delayMs: Math.min(remainingMs, idleWindowMs), kind: 'remainder' };
149
+ // Never LONGER than the production constants: a window above the default keeps them.
150
+ const windowRatio = Math.min(1, idleWindowMs / exports.idleCompactMs);
151
+ const spreadMs = Math.max(1, Math.round(exports.compactIdleOverdueSpreadMs * windowRatio));
139
152
  return {
140
- delayMs: exports.compactIdleOverdueMinDelayMs + (getStableHash(input.threadKeyString) % exports.compactIdleOverdueSpreadMs),
153
+ delayMs: Math.round(exports.compactIdleOverdueMinDelayMs * windowRatio) + (getStableHash(input.threadKeyString) % spreadMs),
141
154
  kind: 'overdue',
142
155
  };
143
156
  }
@@ -173,6 +186,81 @@ function resolveCompactSummaryEnabled(globalDefault, threadOverride) {
173
186
  function resolveCompactSelfReviewEnabled(globalDefault, threadOverride) {
174
187
  return (0, threadToggle_1.resolveDefaultOnThreadToggle)(globalDefault, threadOverride);
175
188
  }
189
+ /**
190
+ * The growth of a conversation's context, in tokens, that makes an idle compaction worth running (owner, 2026-11-22: «if the
191
+ * number grows by about 30 000 over what it was after the last compaction, with every instruction and skill loaded, it makes sense
192
+ * to compact»). The default of `/compact_on_idle`'s threshold, which the General topic and each topic can change.
193
+ */
194
+ exports.defaultCompactGrowthTokens = 30_000;
195
+ /** The choices the `/compact_on_idle` picker offers for the threshold, in tokens; a typed value may be any other in range. */
196
+ exports.compactGrowthPresetTokens = [10_000, 20_000, 30_000, 50_000, 100_000];
197
+ /** The largest threshold a person may type: a model's context window is the most a conversation can ever grow by. */
198
+ exports.maxCompactGrowthTokens = 1_000_000;
199
+ /** How long after the last output of a backend with no turn-end signal its context size is read: the turn has most likely settled. */
200
+ exports.contextSampleDebounceMs = 5000;
201
+ /**
202
+ * @description The growth threshold in force: the topic's own value, else the instance default (General's), else
203
+ * {@link defaultCompactGrowthTokens}. A per-thread value always wins.
204
+ */
205
+ function resolveCompactGrowthTokens(globalDefault, threadOverride) {
206
+ return threadOverride ?? globalDefault ?? exports.defaultCompactGrowthTokens;
207
+ }
208
+ /** `50000`, `50 000`, `50,000` or `50k` (the thousands, any case) — what a person types after `/compact_on_idle`. */
209
+ const growthTokensTypedRe = /^(\d+)(k?)$/;
210
+ /**
211
+ * @description The threshold a person typed, in tokens — a whole number, with a `k` for thousands and blanks, commas or
212
+ * underscores as digit separators ignored — or `null` when it is no number or outside 0…{@link maxCompactGrowthTokens} (0 asks for
213
+ * a compaction at every idle mark with a new turn, as before the threshold existed).
214
+ */
215
+ function parseCompactGrowthTokens(text) {
216
+ const match = growthTokensTypedRe.exec(text.toLowerCase().replace(/[\s,_\u202f\u00a0]/g, ''));
217
+ if (!match)
218
+ return null;
219
+ const tokens = Number(match[1]) * (match[2] === 'k' ? 1000 : 1);
220
+ return Number.isSafeInteger(tokens) && tokens <= exports.maxCompactGrowthTokens ? tokens : null;
221
+ }
222
+ /**
223
+ * @description How far the context has grown, in tokens, since the conversation's baseline — what its FIRST model call after the last
224
+ * compaction saw (the summary, every instruction and skill loaded again, the prompt; the compaction's own `post=` figure is not it)
225
+ * — up to the newest turn read. `null` when either reading is missing: the growth cannot be told ({@link checkIsContextGrownEnough}
226
+ * says what that means for the compaction). Never negative: a context that shrank has not grown.
227
+ */
228
+ function getContextGrowthTokens(input) {
229
+ if (input.baselineContextTokens === null || input.lastContextTokens === null)
230
+ return null;
231
+ return Math.max(0, input.lastContextTokens - input.baselineContextTokens);
232
+ }
233
+ /**
234
+ * @description Whether the context grew enough for an idle compaction to be worth running: the growth reached the threshold. When it
235
+ * cannot be told (`null`) a conversation never compacted is not held back — there is nothing to measure from yet — but one that WAS
236
+ * compacted is: nothing is known to have grown, and a backend whose compaction raises no signal of its own (the tmux Claude types
237
+ * `/compact` into its TUI) would otherwise be compacted at every idle mark, its own output re-arming the next.
238
+ */
239
+ function checkIsContextGrownEnough(input) {
240
+ if (input.contextGrowthTokens === null)
241
+ return !input.hasEarlierCompaction;
242
+ return input.contextGrowthTokens >= input.growthThresholdTokens;
243
+ }
244
+ /**
245
+ * @description The baseline after a context reading. With none yet (the first turn that ends after a compaction, a conversation the
246
+ * bot has no figures of, a measure at the idle mark) it is the context of the epoch's FIRST model call — the compacted summary, the
247
+ * instructions, the skills and the prompt, read from the conversation's history — and `null` while that cannot be told (it is read
248
+ * again at the next reading). A compaction the bot did NOT issue since the last reading (`isNewEpoch`: the CLI's own overflow
249
+ * compaction, the server's own, counted by the adapter) replaced the epoch, so the baseline it had is the older epoch's: the new
250
+ * epoch's first call takes its place, `null` while there is none yet. A RECHECK (`isBaselineRecheck`: the first call is read again
251
+ * although a baseline is there — the first reading of a bot lifetime, a sleeping conversation's every read — because a compaction may
252
+ * have gone by that no count saw) replaces the baseline with the figure when the read gave one and keeps it when it gave none: the
253
+ * first call of the epoch the conversation is in IS its baseline, and a failed read says nothing against the old one. Otherwise a
254
+ * baseline stays — except that a context SMALLER than it is the same sign for a compaction nothing counted (the tmux Claude's own): it
255
+ * is dropped, to be read again from the new epoch.
256
+ */
257
+ function getContextBaselineAfterReading(input) {
258
+ if (input.isNewEpoch || input.baselineContextTokens === null)
259
+ return input.firstCallContextTokens;
260
+ if (input.isBaselineRecheck && input.firstCallContextTokens !== null)
261
+ return input.firstCallContextTokens;
262
+ return input.lastContextTokens < input.baselineContextTokens ? null : input.baselineContextTokens;
263
+ }
176
264
  /**
177
265
  * @description Whether the session is busy for a REAL running turn, as opposed
178
266
  * to merely idle-WAITING on an unanswered interactive question. Both states make
@@ -185,15 +273,14 @@ function checkIsBusyForRealTurn(input) {
185
273
  return input.isBusy && !input.hasPendingQuestion;
186
274
  }
187
275
  /**
188
- * @description Whether the process is WORKING at the idle fire (L-D2): a real
189
- * running turn ({@link checkIsBusyForRealTurn} — a pending question excuses the
190
- * turn, D1) OR background work the question never excuses (a background task,
191
- * input not yet taken in, a compaction in flight). The two are read apart so a
192
- * question pending over a running background task still reads as working: the
193
- * D1 reject-compact-re-ask would otherwise end in a stop that kills the task.
276
+ * @description What keeps the process WORKING at the idle fire (L-D2), by name: a real running turn
277
+ * ({@link checkIsBusyForRealTurn} — a pending question excuses the turn, D1) and the background signals the question
278
+ * never excuses (a background task, input not yet taken in, a compaction in flight). The two are read apart so a question
279
+ * pending over a running background task still reads as working: the D1 reject-compact-re-ask would otherwise end in a
280
+ * stop that kills the task. Empty when the process is idle.
194
281
  */
195
- function checkIsWorkingAtIdle(input) {
196
- return checkIsBusyForRealTurn(input) || input.hasBackgroundWork;
282
+ function getWorkingSignalsAtIdle(input) {
283
+ return checkIsBusyForRealTurn(input) ? [{ kind: 'turn' }, ...input.backgroundSignals] : [...input.backgroundSignals];
197
284
  }
198
285
  /** Past the pending-work hold's end by this much, the re-check finds the hold spent rather than a few ms left. */
199
286
  exports.pendingWorkRecheckMarginMs = 1000;
@@ -208,43 +295,83 @@ function getPendingWorkRecheckDelayMs(input) {
208
295
  return input.idleWindowMs;
209
296
  return Math.min(input.idleWindowMs, input.holdRemainingMs + exports.pendingWorkRecheckMarginMs);
210
297
  }
298
+ /**
299
+ * @description Whether the idle mark of the thread's CURRENT idle period was already held: a fire found the process working and
300
+ * forwent its compaction (`lastHeldMarkAt`), and no activity has come since (`lastActivityAt` — activity warms the prompt cache
301
+ * again and starts a new idle period, whose mark may compact). Both instants are persisted, so a restart keeps the answer.
302
+ */
303
+ function checkIsIdleMarkSpent(input) {
304
+ return input.lastHeldMarkAt > input.lastActivityAt;
305
+ }
211
306
  /**
212
307
  * @description The idle-fire decision, taken the moment the idle timer fires
213
308
  * (lifecycle plan L3). Nothing happens to a session that is not there or is
214
309
  * WORKING (L-D2: a real running turn, a background task, input not yet taken in,
215
310
  * a compaction in flight — a pending interactive question is NOT work, see
216
- * {@link checkIsBusyForRealTurn}; D1); the next activity re-arms the timer.
311
+ * {@link checkIsBusyForRealTurn}; D1); the next activity re-arms the timer. The reasons name WHICH signals hold the
312
+ * process (`working (busy turn, unconsumed input 2)`).
217
313
  *
218
- * The compaction runs only when the feature is enabled for the thread, the
219
- * per-thread user-latch is NOT already spent (D2 — after a fire it stays latched
220
- * until the next genuine USER message re-arms it, so idle compaction runs at most
221
- * once per user-active period), at least one agent turn has completed since the
222
- * last compaction (otherwise there is nothing new to compress), and no
223
- * usage-limit wait is armed (L-D6: a compaction turn would hit the limit).
314
+ * The compaction runs only when the feature is enabled for the thread, at least one agent turn has completed since the
315
+ * last compaction (otherwise there is nothing new to compress), no usage-limit wait is armed (L-D6: a compaction turn would hit
316
+ * the limit), and the conversation's context GREW enough to be worth compressing (owner, 2026-11-22: «if the context did not
317
+ * grow much there is no point in compacting»): by `growthThresholdTokens` over what its first model call after the last
318
+ * compaction saw (see {@link getContextGrowthTokens}). A conversation with no such reading (`contextGrowthTokens: null`) is not
319
+ * held back by it only while it was never compacted ({@link checkIsContextGrownEnough}). There is no once-per-active-period
320
+ * latch any more: the growth threshold is what keeps a process that stays alive from being compacted over and over, and the stop
321
+ * ends the idle period of one that does not — so a topic woken only by its own checks and worker watches is compacted again before
322
+ * it sleeps once it has grown enough (owner, 2026-11-22: «compaction first, then the topic goes to sleep»).
323
+ *
324
+ * The compaction belongs to the IDLE MARK alone: it exists to read the still-warm prompt cache, which is gone a little after the
325
+ * idle window (`idleCompactMs`), so a compaction later than the mark is only an expensive one. A process held at the mark
326
+ * (a compaction that was otherwise due is then `isIdleMarkHeld`) does NOT get its compaction on a later look: once the mark is
327
+ * spent (`isIdleMarkSpent` — it was held and no activity has re-warmed the cache since) every later fire, the re-checks of a
328
+ * held process, decides only the stop. Nor does a fire whose countdown was armed AFTER the mark had already passed
329
+ * (`isIdleMarkMissed`: the overdue arm — the bot came back from downtime past the window, or a re-spawn or a per-turn wake found
330
+ * the topic idle for longer than that) compact: it decides only the stop too, and a hold at it costs nothing, so there is no
331
+ * mark to hold and nothing to tell.
332
+ * Activity re-arms the countdown, and with it the next mark's compaction.
224
333
  *
225
334
  * The STOP happens whether or not the compaction runs (L-D1: a resume restores
226
335
  * the full history, so a stopped process loses nothing) — on a backend that can
227
336
  * be suspended; the tmux TUI and OpenCode stay (L-D8).
228
337
  */
229
338
  function getIdleFireDecision(input) {
339
+ const isWorking = input.workingSignals.length > 0;
340
+ const compactionBlockers = [
341
+ !input.isEnabled && 'disabled',
342
+ !input.hasCompletedTurnSinceCompaction && 'nothing to compress',
343
+ !checkIsContextGrownEnough(input)
344
+ && (input.contextGrowthTokens === null
345
+ ? 'the context size since the last compaction is not known yet, so nothing is known to have grown'
346
+ : `the context grew by ${formatTokenCount(input.contextGrowthTokens)} tokens since its first call after the last compaction, ${formatTokenCount(input.growthThresholdTokens)} are needed`),
347
+ input.isLimitWaitArmed && 'a usage-limit wait is armed (L-D6)',
348
+ input.isIdleMarkMissed && 'the idle mark had already passed when the countdown was armed (the prompt cache is cold by now)',
349
+ ].filter((reason) => typeof reason === 'string');
230
350
  const notIdleReasons = [
231
351
  !input.isSessionActive && 'no active session',
232
- input.isWorking && 'working',
352
+ isWorking && `working (${(0, workingSignals_1.describeWorkingSignals)(input.workingSignals)})`,
233
353
  ].filter((reason) => typeof reason === 'string');
234
354
  if (notIdleReasons.length > 0) {
235
- return { shouldCompact: false, compactionSkipReasons: notIdleReasons, shouldSuspend: false, suspendSkipReasons: notIdleReasons };
355
+ const isIdleMarkHeld = input.isSessionActive && isWorking && !input.isIdleMarkSpent && compactionBlockers.length === 0;
356
+ return {
357
+ shouldCompact: false,
358
+ compactionSkipReasons: notIdleReasons,
359
+ shouldSuspend: false,
360
+ suspendSkipReasons: notIdleReasons,
361
+ isIdleMarkHeld,
362
+ heldNoticeReason: isIdleMarkHeld ? (0, workingSignals_1.getIdleHeldNoticeReason)(input.workingSignals) : null,
363
+ };
236
364
  }
237
- const compactionSkipReasons = [
238
- !input.isEnabled && 'disabled',
239
- input.isLatched && 'latched (D2)',
240
- !input.hasCompletedTurnSinceCompaction && 'nothing to compress',
241
- input.isLimitWaitArmed && 'a usage-limit wait is armed (L-D6)',
242
- ].filter((reason) => typeof reason === 'string');
365
+ const compactionSkipReasons = input.isIdleMarkSpent
366
+ ? [...compactionBlockers, 'the idle mark passed while the process was held (the prompt cache is cold by now)']
367
+ : compactionBlockers;
243
368
  return {
244
369
  shouldCompact: compactionSkipReasons.length === 0,
245
370
  compactionSkipReasons,
246
371
  shouldSuspend: input.canSuspend,
247
372
  suspendSkipReasons: input.canSuspend ? [] : ['the backend is not suspended'],
373
+ isIdleMarkHeld: false,
374
+ heldNoticeReason: null,
248
375
  };
249
376
  }
250
377
  /**