charness 3.11.0 → 3.13.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 (537) hide show
  1. package/.env.example +5 -0
  2. package/CHANGELOG.md +169 -0
  3. package/DEVELOPMENT.md +81 -18
  4. package/README.md +3 -2
  5. package/SETUP.md +71 -25
  6. package/agent-plugin/README.md +15 -6
  7. package/agent-plugin/skills/charness-delegate-claude/SKILL.md +37 -18
  8. package/agent-plugin/skills/charness-delegate-opencode/SKILL.md +10 -6
  9. package/agent-plugin/skills/charness-delivery-loop/SKILL.md +92 -0
  10. package/agent-plugin/skills/charness-orchestration/SKILL.md +116 -0
  11. package/dist/accessControl.d.ts +43 -0
  12. package/dist/accessControl.d.ts.map +1 -1
  13. package/dist/accessControl.js +50 -1
  14. package/dist/accessControl.js.map +1 -1
  15. package/dist/adapters/claudeCliAdapter.d.ts.map +1 -1
  16. package/dist/adapters/claudeCliAdapter.js +9 -4
  17. package/dist/adapters/claudeCliAdapter.js.map +1 -1
  18. package/dist/adapters/claudeJsonStreamAdapter.js +1 -1
  19. package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
  20. package/dist/adapters/claudePlatformFlags.d.ts +4 -3
  21. package/dist/adapters/claudePlatformFlags.d.ts.map +1 -1
  22. package/dist/adapters/claudePlatformFlags.js +4 -3
  23. package/dist/adapters/claudePlatformFlags.js.map +1 -1
  24. package/dist/adapters/openCodeAdapter.d.ts +52 -13
  25. package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
  26. package/dist/adapters/openCodeAdapter.js +121 -45
  27. package/dist/adapters/openCodeAdapter.js.map +1 -1
  28. package/dist/adapters/terminalAdapter.d.ts.map +1 -1
  29. package/dist/adapters/terminalAdapter.js +5 -3
  30. package/dist/adapters/terminalAdapter.js.map +1 -1
  31. package/dist/agentLogin/agentLogin.d.ts +11 -0
  32. package/dist/agentLogin/agentLogin.d.ts.map +1 -1
  33. package/dist/agentLogin/agentLogin.js +20 -20
  34. package/dist/agentLogin/agentLogin.js.map +1 -1
  35. package/dist/apiErrorRetry.d.ts +5 -0
  36. package/dist/apiErrorRetry.d.ts.map +1 -1
  37. package/dist/apiErrorRetry.js +3 -3
  38. package/dist/apiErrorRetry.js.map +1 -1
  39. package/dist/bot.d.ts +12 -3
  40. package/dist/bot.d.ts.map +1 -1
  41. package/dist/bot.js +634 -153
  42. package/dist/bot.js.map +1 -1
  43. package/dist/cli/claudeProfiles.d.ts +5 -2
  44. package/dist/cli/claudeProfiles.d.ts.map +1 -1
  45. package/dist/cli/claudeProfiles.js +45 -22
  46. package/dist/cli/claudeProfiles.js.map +1 -1
  47. package/dist/cli/claudeProfilesCredit.d.ts +49 -0
  48. package/dist/cli/claudeProfilesCredit.d.ts.map +1 -0
  49. package/dist/cli/claudeProfilesCredit.js +160 -0
  50. package/dist/cli/claudeProfilesCredit.js.map +1 -0
  51. package/dist/cli/flagValue.d.ts +10 -0
  52. package/dist/cli/flagValue.d.ts.map +1 -0
  53. package/dist/cli/flagValue.js +17 -0
  54. package/dist/cli/flagValue.js.map +1 -0
  55. package/dist/connectors/jira/client.js +1 -1
  56. package/dist/connectors/jira/client.js.map +1 -1
  57. package/dist/connectors/jira/config.d.ts +7 -0
  58. package/dist/connectors/jira/config.d.ts.map +1 -1
  59. package/dist/connectors/jira/config.js +12 -1
  60. package/dist/connectors/jira/config.js.map +1 -1
  61. package/dist/connectors/jira/connector.d.ts +7 -0
  62. package/dist/connectors/jira/connector.d.ts.map +1 -1
  63. package/dist/connectors/jira/connector.js +20 -3
  64. package/dist/connectors/jira/connector.js.map +1 -1
  65. package/dist/connectors/jira/inbound.d.ts.map +1 -1
  66. package/dist/connectors/jira/inbound.js +4 -3
  67. package/dist/connectors/jira/inbound.js.map +1 -1
  68. package/dist/connectors/jira/issueBlocks.d.ts +1 -1
  69. package/dist/connectors/jira/trustedGroup.d.ts +21 -6
  70. package/dist/connectors/jira/trustedGroup.d.ts.map +1 -1
  71. package/dist/connectors/jira/trustedGroup.js +46 -6
  72. package/dist/connectors/jira/trustedGroup.js.map +1 -1
  73. package/dist/connectors/telegram/commands/botCore.d.ts +19 -2
  74. package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -1
  75. package/dist/connectors/telegram/commands/botSkills.js +1 -1
  76. package/dist/connectors/telegram/commands/claudeAccounts.d.ts +6 -1
  77. package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -1
  78. package/dist/connectors/telegram/commands/claudeAccounts.js +9 -6
  79. package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
  80. package/dist/connectors/telegram/commands/compaction.d.ts +16 -3
  81. package/dist/connectors/telegram/commands/compaction.d.ts.map +1 -1
  82. package/dist/connectors/telegram/commands/compaction.js +216 -27
  83. package/dist/connectors/telegram/commands/compaction.js.map +1 -1
  84. package/dist/connectors/telegram/commands/runners.d.ts +5 -1
  85. package/dist/connectors/telegram/commands/runners.d.ts.map +1 -1
  86. package/dist/connectors/telegram/commands/runners.js +146 -31
  87. package/dist/connectors/telegram/commands/runners.js.map +1 -1
  88. package/dist/connectors/telegram/commands/todo.d.ts.map +1 -1
  89. package/dist/connectors/telegram/commands/todo.js +2 -2
  90. package/dist/connectors/telegram/commands/todo.js.map +1 -1
  91. package/dist/connectors/telegram/commands/topicAccess.d.ts +30 -0
  92. package/dist/connectors/telegram/commands/topicAccess.d.ts.map +1 -0
  93. package/dist/connectors/telegram/commands/topicAccess.js +399 -0
  94. package/dist/connectors/telegram/commands/topicAccess.js.map +1 -0
  95. package/dist/connectors/telegram/inbound.d.ts +44 -7
  96. package/dist/connectors/telegram/inbound.d.ts.map +1 -1
  97. package/dist/connectors/telegram/inbound.js +142 -24
  98. package/dist/connectors/telegram/inbound.js.map +1 -1
  99. package/dist/connectors/telegram/runnerPairingMessages.d.ts +2 -7
  100. package/dist/connectors/telegram/runnerPairingMessages.d.ts.map +1 -1
  101. package/dist/connectors/telegram/runnerPairingMessages.js +5 -19
  102. package/dist/connectors/telegram/runnerPairingMessages.js.map +1 -1
  103. package/dist/i18n/de.d.ts.map +1 -1
  104. package/dist/i18n/de.js +120 -8
  105. package/dist/i18n/de.js.map +1 -1
  106. package/dist/i18n/en.d.ts.map +1 -1
  107. package/dist/i18n/en.js +120 -8
  108. package/dist/i18n/en.js.map +1 -1
  109. package/dist/i18n/es.d.ts.map +1 -1
  110. package/dist/i18n/es.js +120 -8
  111. package/dist/i18n/es.js.map +1 -1
  112. package/dist/i18n/fr.d.ts.map +1 -1
  113. package/dist/i18n/fr.js +120 -8
  114. package/dist/i18n/fr.js.map +1 -1
  115. package/dist/i18n/hi.d.ts.map +1 -1
  116. package/dist/i18n/hi.js +120 -8
  117. package/dist/i18n/hi.js.map +1 -1
  118. package/dist/i18n/ja.d.ts.map +1 -1
  119. package/dist/i18n/ja.js +120 -8
  120. package/dist/i18n/ja.js.map +1 -1
  121. package/dist/i18n/ka.d.ts.map +1 -1
  122. package/dist/i18n/ka.js +120 -8
  123. package/dist/i18n/ka.js.map +1 -1
  124. package/dist/i18n/pt.d.ts.map +1 -1
  125. package/dist/i18n/pt.js +120 -8
  126. package/dist/i18n/pt.js.map +1 -1
  127. package/dist/i18n/ru.d.ts.map +1 -1
  128. package/dist/i18n/ru.js +120 -8
  129. package/dist/i18n/ru.js.map +1 -1
  130. package/dist/i18n/uk.d.ts.map +1 -1
  131. package/dist/i18n/uk.js +120 -8
  132. package/dist/i18n/uk.js.map +1 -1
  133. package/dist/i18n/uz.d.ts.map +1 -1
  134. package/dist/i18n/uz.js +120 -8
  135. package/dist/i18n/uz.js.map +1 -1
  136. package/dist/i18n/zh.d.ts.map +1 -1
  137. package/dist/i18n/zh.js +120 -8
  138. package/dist/i18n/zh.js.map +1 -1
  139. package/dist/installManager.d.ts +37 -1
  140. package/dist/installManager.d.ts.map +1 -1
  141. package/dist/installManager.js +208 -14
  142. package/dist/installManager.js.map +1 -1
  143. package/dist/instanceLock.d.ts.map +1 -1
  144. package/dist/instanceLock.js +2 -1
  145. package/dist/instanceLock.js.map +1 -1
  146. package/dist/platform/commandRouter.d.ts +13 -1
  147. package/dist/platform/commandRouter.d.ts.map +1 -1
  148. package/dist/platform/commandRouter.js +14 -2
  149. package/dist/platform/commandRouter.js.map +1 -1
  150. package/dist/platform/inbound.d.ts +2 -0
  151. package/dist/platform/inbound.d.ts.map +1 -1
  152. package/dist/platform/outbound.d.ts +14 -1
  153. package/dist/platform/outbound.d.ts.map +1 -1
  154. package/dist/platform/outbound.js.map +1 -1
  155. package/dist/remoteRun/cleanReport.d.ts +45 -0
  156. package/dist/remoteRun/cleanReport.d.ts.map +1 -0
  157. package/dist/remoteRun/cleanReport.js +84 -0
  158. package/dist/remoteRun/cleanReport.js.map +1 -0
  159. package/dist/remoteRun/cliArgs.d.ts +18 -0
  160. package/dist/remoteRun/cliArgs.d.ts.map +1 -1
  161. package/dist/remoteRun/cliArgs.js +100 -4
  162. package/dist/remoteRun/cliArgs.js.map +1 -1
  163. package/dist/remoteRun/commands.d.ts +30 -1
  164. package/dist/remoteRun/commands.d.ts.map +1 -1
  165. package/dist/remoteRun/commands.js +84 -9
  166. package/dist/remoteRun/commands.js.map +1 -1
  167. package/dist/remoteRun/exitCodes.d.ts +5 -0
  168. package/dist/remoteRun/exitCodes.d.ts.map +1 -1
  169. package/dist/remoteRun/exitCodes.js +6 -1
  170. package/dist/remoteRun/exitCodes.js.map +1 -1
  171. package/dist/remoteRun/foreground.d.ts +6 -0
  172. package/dist/remoteRun/foreground.d.ts.map +1 -1
  173. package/dist/remoteRun/foreground.js +13 -1
  174. package/dist/remoteRun/foreground.js.map +1 -1
  175. package/dist/remoteRun/interrupts.d.ts.map +1 -1
  176. package/dist/remoteRun/interrupts.js +2 -2
  177. package/dist/remoteRun/interrupts.js.map +1 -1
  178. package/dist/remoteRun/jobFiles.d.ts +6 -1
  179. package/dist/remoteRun/jobFiles.d.ts.map +1 -1
  180. package/dist/remoteRun/jobFiles.js +14 -0
  181. package/dist/remoteRun/jobFiles.js.map +1 -1
  182. package/dist/remoteRun/jobId.d.ts +5 -0
  183. package/dist/remoteRun/jobId.d.ts.map +1 -1
  184. package/dist/remoteRun/jobId.js +10 -0
  185. package/dist/remoteRun/jobId.js.map +1 -1
  186. package/dist/remoteRun/jobState.d.ts.map +1 -1
  187. package/dist/remoteRun/jobState.js +3 -2
  188. package/dist/remoteRun/jobState.js.map +1 -1
  189. package/dist/remoteRun/pairedRunners.d.ts +1 -1
  190. package/dist/remoteRun/pairedRunners.d.ts.map +1 -1
  191. package/dist/remoteRun/pairedRunners.js +4 -0
  192. package/dist/remoteRun/pairedRunners.js.map +1 -1
  193. package/dist/remoteRun/pathPatterns.d.ts +1 -1
  194. package/dist/remoteRun/pathPatterns.js +1 -1
  195. package/dist/remoteRun/probe.d.ts +58 -5
  196. package/dist/remoteRun/probe.d.ts.map +1 -1
  197. package/dist/remoteRun/probe.js +107 -11
  198. package/dist/remoteRun/probe.js.map +1 -1
  199. package/dist/remoteRun/probeTiming.d.ts +15 -0
  200. package/dist/remoteRun/probeTiming.d.ts.map +1 -0
  201. package/dist/remoteRun/probeTiming.js +23 -0
  202. package/dist/remoteRun/probeTiming.js.map +1 -0
  203. package/dist/remoteRun/project.d.ts +5 -0
  204. package/dist/remoteRun/project.d.ts.map +1 -1
  205. package/dist/remoteRun/project.js +10 -0
  206. package/dist/remoteRun/project.js.map +1 -1
  207. package/dist/remoteRun/projectConfig.d.ts +8 -1
  208. package/dist/remoteRun/projectConfig.d.ts.map +1 -1
  209. package/dist/remoteRun/projectConfig.js +18 -5
  210. package/dist/remoteRun/projectConfig.js.map +1 -1
  211. package/dist/remoteRun/pruneReport.d.ts +48 -0
  212. package/dist/remoteRun/pruneReport.d.ts.map +1 -0
  213. package/dist/remoteRun/pruneReport.js +80 -0
  214. package/dist/remoteRun/pruneReport.js.map +1 -0
  215. package/dist/remoteRun/remoteRunCli.d.ts +1 -1
  216. package/dist/remoteRun/remoteRunCli.d.ts.map +1 -1
  217. package/dist/remoteRun/remoteRunCli.js +20 -0
  218. package/dist/remoteRun/remoteRunCli.js.map +1 -1
  219. package/dist/remoteRun/runnerClient.d.ts +10 -0
  220. package/dist/remoteRun/runnerClient.d.ts.map +1 -1
  221. package/dist/remoteRun/runnerClient.js +19 -5
  222. package/dist/remoteRun/runnerClient.js.map +1 -1
  223. package/dist/remoteRun/runnerWait.d.ts.map +1 -1
  224. package/dist/remoteRun/runnerWait.js +2 -1
  225. package/dist/remoteRun/runnerWait.js.map +1 -1
  226. package/dist/remoteRun/runners.d.ts +48 -7
  227. package/dist/remoteRun/runners.d.ts.map +1 -1
  228. package/dist/remoteRun/runners.js +105 -40
  229. package/dist/remoteRun/runners.js.map +1 -1
  230. package/dist/remoteRun/runnersConfig.d.ts +24 -0
  231. package/dist/remoteRun/runnersConfig.d.ts.map +1 -1
  232. package/dist/remoteRun/runnersConfig.js +29 -2
  233. package/dist/remoteRun/runnersConfig.js.map +1 -1
  234. package/dist/remoteRun/ssh.d.ts +3 -3
  235. package/dist/remoteRun/ssh.d.ts.map +1 -1
  236. package/dist/remoteRun/ssh.js +19 -5
  237. package/dist/remoteRun/ssh.js.map +1 -1
  238. package/dist/remoteRun/submit.d.ts +1 -1
  239. package/dist/remoteRun/submit.d.ts.map +1 -1
  240. package/dist/remoteRun/submit.js +30 -2
  241. package/dist/remoteRun/submit.js.map +1 -1
  242. package/dist/runnerUtility/adminService.d.ts.map +1 -1
  243. package/dist/runnerUtility/adminService.js +5 -5
  244. package/dist/runnerUtility/adminService.js.map +1 -1
  245. package/dist/runnerUtility/appInstall.d.ts +9 -0
  246. package/dist/runnerUtility/appInstall.d.ts.map +1 -1
  247. package/dist/runnerUtility/appInstall.js +12 -2
  248. package/dist/runnerUtility/appInstall.js.map +1 -1
  249. package/dist/runnerUtility/execEnv.d.ts +1 -1
  250. package/dist/runnerUtility/execEnv.d.ts.map +1 -1
  251. package/dist/runnerUtility/execEnv.js +23 -5
  252. package/dist/runnerUtility/execEnv.js.map +1 -1
  253. package/dist/runnerUtility/guiAgentHeal.d.ts +3 -3
  254. package/dist/runnerUtility/guiAgentHeal.d.ts.map +1 -1
  255. package/dist/runnerUtility/guiAgentHeal.js +4 -2
  256. package/dist/runnerUtility/guiAgentHeal.js.map +1 -1
  257. package/dist/runnerUtility/homeFolders.d.ts +1 -0
  258. package/dist/runnerUtility/homeFolders.d.ts.map +1 -1
  259. package/dist/runnerUtility/homeFolders.js +2 -1
  260. package/dist/runnerUtility/homeFolders.js.map +1 -1
  261. package/dist/runnerUtility/iosCheck.d.ts +2 -0
  262. package/dist/runnerUtility/iosCheck.d.ts.map +1 -1
  263. package/dist/runnerUtility/iosCheck.js +12 -3
  264. package/dist/runnerUtility/iosCheck.js.map +1 -1
  265. package/dist/runnerUtility/keepAwake.d.ts +47 -10
  266. package/dist/runnerUtility/keepAwake.d.ts.map +1 -1
  267. package/dist/runnerUtility/keepAwake.js +108 -31
  268. package/dist/runnerUtility/keepAwake.js.map +1 -1
  269. package/dist/runnerUtility/launcher.d.ts +4 -0
  270. package/dist/runnerUtility/launcher.d.ts.map +1 -1
  271. package/dist/runnerUtility/launcher.js +31 -13
  272. package/dist/runnerUtility/launcher.js.map +1 -1
  273. package/dist/runnerUtility/linkLoop.d.ts +4 -0
  274. package/dist/runnerUtility/linkLoop.d.ts.map +1 -1
  275. package/dist/runnerUtility/linkLoop.js +15 -6
  276. package/dist/runnerUtility/linkLoop.js.map +1 -1
  277. package/dist/runnerUtility/managedNode.d.ts +84 -0
  278. package/dist/runnerUtility/managedNode.d.ts.map +1 -0
  279. package/dist/runnerUtility/managedNode.js +165 -0
  280. package/dist/runnerUtility/managedNode.js.map +1 -0
  281. package/dist/runnerUtility/nodeOnPath.d.ts +10 -0
  282. package/dist/runnerUtility/nodeOnPath.d.ts.map +1 -0
  283. package/dist/runnerUtility/nodeOnPath.js +49 -0
  284. package/dist/runnerUtility/nodeOnPath.js.map +1 -0
  285. package/dist/runnerUtility/nodeUpkeep.d.ts +140 -0
  286. package/dist/runnerUtility/nodeUpkeep.d.ts.map +1 -0
  287. package/dist/runnerUtility/nodeUpkeep.js +348 -0
  288. package/dist/runnerUtility/nodeUpkeep.js.map +1 -0
  289. package/dist/runnerUtility/nodeUpkeepTiming.d.ts +14 -0
  290. package/dist/runnerUtility/nodeUpkeepTiming.d.ts.map +1 -0
  291. package/dist/runnerUtility/nodeUpkeepTiming.js +21 -0
  292. package/dist/runnerUtility/nodeUpkeepTiming.js.map +1 -0
  293. package/dist/runnerUtility/packageManagerShims.d.ts +10 -0
  294. package/dist/runnerUtility/packageManagerShims.d.ts.map +1 -1
  295. package/dist/runnerUtility/packageManagerShims.js +67 -3
  296. package/dist/runnerUtility/packageManagerShims.js.map +1 -1
  297. package/dist/runnerUtility/pueueDaemon.d.ts +73 -8
  298. package/dist/runnerUtility/pueueDaemon.d.ts.map +1 -1
  299. package/dist/runnerUtility/pueueDaemon.js +90 -15
  300. package/dist/runnerUtility/pueueDaemon.js.map +1 -1
  301. package/dist/runnerUtility/runnerCommands.d.ts +7 -1
  302. package/dist/runnerUtility/runnerCommands.d.ts.map +1 -1
  303. package/dist/runnerUtility/runnerCommands.js +119 -16
  304. package/dist/runnerUtility/runnerCommands.js.map +1 -1
  305. package/dist/runnerUtility/runnerHome.d.ts +34 -0
  306. package/dist/runnerUtility/runnerHome.d.ts.map +1 -1
  307. package/dist/runnerUtility/runnerHome.js +17 -3
  308. package/dist/runnerUtility/runnerHome.js.map +1 -1
  309. package/dist/runnerUtility/serviceCommon.d.ts +2 -0
  310. package/dist/runnerUtility/serviceCommon.d.ts.map +1 -1
  311. package/dist/runnerUtility/serviceCommon.js +3 -1
  312. package/dist/runnerUtility/serviceCommon.js.map +1 -1
  313. package/dist/runnerUtility/serviceManager.d.ts.map +1 -1
  314. package/dist/runnerUtility/serviceManager.js +7 -2
  315. package/dist/runnerUtility/serviceManager.js.map +1 -1
  316. package/dist/runnerUtility/simctlGuard.d.ts +38 -0
  317. package/dist/runnerUtility/simctlGuard.d.ts.map +1 -0
  318. package/dist/runnerUtility/simctlGuard.js +166 -0
  319. package/dist/runnerUtility/simctlGuard.js.map +1 -0
  320. package/dist/runners/bootstrapLine.d.ts +3 -4
  321. package/dist/runners/bootstrapLine.d.ts.map +1 -1
  322. package/dist/runners/bootstrapLine.js +108 -83
  323. package/dist/runners/bootstrapLine.js.map +1 -1
  324. package/dist/runners/hubPackage.d.ts +1 -1
  325. package/dist/runners/hubPackage.d.ts.map +1 -1
  326. package/dist/runners/hubPackage.js +5 -6
  327. package/dist/runners/hubPackage.js.map +1 -1
  328. package/dist/runners/hubPairing.d.ts +19 -0
  329. package/dist/runners/hubPairing.d.ts.map +1 -1
  330. package/dist/runners/hubPairing.js +38 -0
  331. package/dist/runners/hubPairing.js.map +1 -1
  332. package/dist/runners/hubRegistry.d.ts +8 -0
  333. package/dist/runners/hubRegistry.d.ts.map +1 -1
  334. package/dist/runners/hubRegistry.js +6 -0
  335. package/dist/runners/hubRegistry.js.map +1 -1
  336. package/dist/runners/pairCode.d.ts +34 -3
  337. package/dist/runners/pairCode.d.ts.map +1 -1
  338. package/dist/runners/pairCode.js +65 -13
  339. package/dist/runners/pairCode.js.map +1 -1
  340. package/dist/runners/runnerGroups.d.ts +22 -0
  341. package/dist/runners/runnerGroups.d.ts.map +1 -0
  342. package/dist/runners/runnerGroups.js +41 -0
  343. package/dist/runners/runnerGroups.js.map +1 -0
  344. package/dist/runners/runnerLock.d.ts +36 -1
  345. package/dist/runners/runnerLock.d.ts.map +1 -1
  346. package/dist/runners/runnerLock.js +94 -30
  347. package/dist/runners/runnerLock.js.map +1 -1
  348. package/dist/runners/runnersCli.d.ts +5 -2
  349. package/dist/runners/runnersCli.d.ts.map +1 -1
  350. package/dist/runners/runnersCli.js +59 -9
  351. package/dist/runners/runnersCli.js.map +1 -1
  352. package/dist/runners/runnersList.d.ts +1 -1
  353. package/dist/runners/runnersList.d.ts.map +1 -1
  354. package/dist/runners/runnersList.js +3 -1
  355. package/dist/runners/runnersList.js.map +1 -1
  356. package/dist/runners/runnersOverview.d.ts.map +1 -1
  357. package/dist/runners/runnersOverview.js +8 -4
  358. package/dist/runners/runnersOverview.js.map +1 -1
  359. package/dist/scheduler/checkRun.d.ts +0 -2
  360. package/dist/scheduler/checkRun.d.ts.map +1 -1
  361. package/dist/scheduler/checkRun.js +0 -10
  362. package/dist/scheduler/checkRun.js.map +1 -1
  363. package/dist/scheduler/checkStatus.d.ts +2 -0
  364. package/dist/scheduler/checkStatus.d.ts.map +1 -1
  365. package/dist/scheduler/checkStatus.js +5 -4
  366. package/dist/scheduler/checkStatus.js.map +1 -1
  367. package/dist/scheduler/delivery.d.ts +2 -1
  368. package/dist/scheduler/delivery.d.ts.map +1 -1
  369. package/dist/scheduler/delivery.js +5 -1
  370. package/dist/scheduler/delivery.js.map +1 -1
  371. package/dist/scheduler/mcpSurface.d.ts +7 -3
  372. package/dist/scheduler/mcpSurface.d.ts.map +1 -1
  373. package/dist/scheduler/mcpSurface.js +48 -22
  374. package/dist/scheduler/mcpSurface.js.map +1 -1
  375. package/dist/scheduler/workerWatch.d.ts +33 -10
  376. package/dist/scheduler/workerWatch.d.ts.map +1 -1
  377. package/dist/scheduler/workerWatch.js +37 -11
  378. package/dist/scheduler/workerWatch.js.map +1 -1
  379. package/dist/selfUpdate/bootRollback.d.ts.map +1 -1
  380. package/dist/selfUpdate/bootRollback.js +3 -2
  381. package/dist/selfUpdate/bootRollback.js.map +1 -1
  382. package/dist/selfUpdate/updateRuntime.d.ts.map +1 -1
  383. package/dist/selfUpdate/updateRuntime.js +6 -3
  384. package/dist/selfUpdate/updateRuntime.js.map +1 -1
  385. package/dist/state.d.ts +144 -2
  386. package/dist/state.d.ts.map +1 -1
  387. package/dist/state.js +257 -7
  388. package/dist/state.js.map +1 -1
  389. package/dist/testTimings.d.ts +6 -2
  390. package/dist/testTimings.d.ts.map +1 -1
  391. package/dist/testTimings.js +12 -1
  392. package/dist/testTimings.js.map +1 -1
  393. package/dist/threadContextPreamble.d.ts +15 -1
  394. package/dist/threadContextPreamble.d.ts.map +1 -1
  395. package/dist/threadContextPreamble.js +15 -3
  396. package/dist/threadContextPreamble.js.map +1 -1
  397. package/dist/threadRouting.d.ts +47 -4
  398. package/dist/threadRouting.d.ts.map +1 -1
  399. package/dist/threadRouting.js +31 -4
  400. package/dist/threadRouting.js.map +1 -1
  401. package/dist/todos/projects.d.ts +1 -1
  402. package/dist/todos/projects.d.ts.map +1 -1
  403. package/dist/todos/projects.js +3 -14
  404. package/dist/todos/projects.js.map +1 -1
  405. package/dist/topicTalkerMemory.d.ts +37 -0
  406. package/dist/topicTalkerMemory.d.ts.map +1 -0
  407. package/dist/topicTalkerMemory.js +61 -0
  408. package/dist/topicTalkerMemory.js.map +1 -0
  409. package/dist/topicTalkers.d.ts +123 -0
  410. package/dist/topicTalkers.d.ts.map +1 -0
  411. package/dist/topicTalkers.js +276 -0
  412. package/dist/topicTalkers.js.map +1 -0
  413. package/dist/types.d.ts +7 -5
  414. package/dist/types.d.ts.map +1 -1
  415. package/dist/utils/agentEnvironment.d.ts +23 -0
  416. package/dist/utils/agentEnvironment.d.ts.map +1 -1
  417. package/dist/utils/agentEnvironment.js +33 -1
  418. package/dist/utils/agentEnvironment.js.map +1 -1
  419. package/dist/utils/agentPlugin.d.ts +9 -3
  420. package/dist/utils/agentPlugin.d.ts.map +1 -1
  421. package/dist/utils/agentPlugin.js +13 -6
  422. package/dist/utils/agentPlugin.js.map +1 -1
  423. package/dist/utils/authorMark.d.ts +59 -0
  424. package/dist/utils/authorMark.d.ts.map +1 -0
  425. package/dist/utils/authorMark.js +86 -0
  426. package/dist/utils/authorMark.js.map +1 -0
  427. package/dist/utils/botSkills.d.ts +1 -1
  428. package/dist/utils/claudeApiAgentStop.d.ts +64 -0
  429. package/dist/utils/claudeApiAgentStop.d.ts.map +1 -0
  430. package/dist/utils/claudeApiAgentStop.js +85 -0
  431. package/dist/utils/claudeApiAgentStop.js.map +1 -0
  432. package/dist/utils/claudeApiCredit.d.ts +168 -0
  433. package/dist/utils/claudeApiCredit.d.ts.map +1 -0
  434. package/dist/utils/claudeApiCredit.js +260 -0
  435. package/dist/utils/claudeApiCredit.js.map +1 -0
  436. package/dist/utils/claudeApiCreditRecheck.d.ts +120 -0
  437. package/dist/utils/claudeApiCreditRecheck.d.ts.map +1 -0
  438. package/dist/utils/claudeApiCreditRecheck.js +173 -0
  439. package/dist/utils/claudeApiCreditRecheck.js.map +1 -0
  440. package/dist/utils/claudeCompactHook.d.ts +18 -10
  441. package/dist/utils/claudeCompactHook.d.ts.map +1 -1
  442. package/dist/utils/claudeCompactHook.js +35 -14
  443. package/dist/utils/claudeCompactHook.js.map +1 -1
  444. package/dist/utils/claudeLimitSwitch.d.ts +5 -1
  445. package/dist/utils/claudeLimitSwitch.d.ts.map +1 -1
  446. package/dist/utils/claudeLimitSwitch.js +6 -2
  447. package/dist/utils/claudeLimitSwitch.js.map +1 -1
  448. package/dist/utils/claudeProfileUsageLines.d.ts +14 -2
  449. package/dist/utils/claudeProfileUsageLines.d.ts.map +1 -1
  450. package/dist/utils/claudeProfileUsageLines.js +78 -7
  451. package/dist/utils/claudeProfileUsageLines.js.map +1 -1
  452. package/dist/utils/claudeProfileUsageViews.d.ts +46 -0
  453. package/dist/utils/claudeProfileUsageViews.d.ts.map +1 -0
  454. package/dist/utils/claudeProfileUsageViews.js +114 -0
  455. package/dist/utils/claudeProfileUsageViews.js.map +1 -0
  456. package/dist/utils/claudeProfiles.d.ts +22 -0
  457. package/dist/utils/claudeProfiles.d.ts.map +1 -1
  458. package/dist/utils/claudeProfiles.js +69 -0
  459. package/dist/utils/claudeProfiles.js.map +1 -1
  460. package/dist/utils/claudeUsage.d.ts +145 -51
  461. package/dist/utils/claudeUsage.d.ts.map +1 -1
  462. package/dist/utils/claudeUsage.js +211 -94
  463. package/dist/utils/claudeUsage.js.map +1 -1
  464. package/dist/utils/compactOnIdle.d.ts +140 -15
  465. package/dist/utils/compactOnIdle.d.ts.map +1 -1
  466. package/dist/utils/compactOnIdle.js +209 -23
  467. package/dist/utils/compactOnIdle.js.map +1 -1
  468. package/dist/utils/compactSelfReviewFlags.d.ts +50 -0
  469. package/dist/utils/compactSelfReviewFlags.d.ts.map +1 -0
  470. package/dist/utils/compactSelfReviewFlags.js +120 -0
  471. package/dist/utils/compactSelfReviewFlags.js.map +1 -0
  472. package/dist/utils/fallbackChain.d.ts +18 -7
  473. package/dist/utils/fallbackChain.d.ts.map +1 -1
  474. package/dist/utils/fallbackChain.js +36 -16
  475. package/dist/utils/fallbackChain.js.map +1 -1
  476. package/dist/utils/folderGit.d.ts +9 -0
  477. package/dist/utils/folderGit.d.ts.map +1 -0
  478. package/dist/utils/folderGit.js +33 -0
  479. package/dist/utils/folderGit.js.map +1 -0
  480. package/dist/utils/forwardedMark.d.ts +8 -0
  481. package/dist/utils/forwardedMark.d.ts.map +1 -1
  482. package/dist/utils/forwardedMark.js +2 -0
  483. package/dist/utils/forwardedMark.js.map +1 -1
  484. package/dist/utils/jsonStreamHost.d.ts +2 -1
  485. package/dist/utils/jsonStreamHost.d.ts.map +1 -1
  486. package/dist/utils/jsonStreamHost.js +4 -2
  487. package/dist/utils/jsonStreamHost.js.map +1 -1
  488. package/dist/utils/messageContext.d.ts +22 -7
  489. package/dist/utils/messageContext.d.ts.map +1 -1
  490. package/dist/utils/messageContext.js +19 -5
  491. package/dist/utils/messageContext.js.map +1 -1
  492. package/dist/utils/openCodeCompactPlugin.d.ts +28 -7
  493. package/dist/utils/openCodeCompactPlugin.d.ts.map +1 -1
  494. package/dist/utils/openCodeCompactPlugin.js +80 -15
  495. package/dist/utils/openCodeCompactPlugin.js.map +1 -1
  496. package/dist/utils/personLabel.d.ts +13 -0
  497. package/dist/utils/personLabel.d.ts.map +1 -0
  498. package/dist/utils/personLabel.js +15 -0
  499. package/dist/utils/personLabel.js.map +1 -0
  500. package/dist/utils/replyQuote.d.ts +17 -3
  501. package/dist/utils/replyQuote.d.ts.map +1 -1
  502. package/dist/utils/replyQuote.js +25 -2
  503. package/dist/utils/replyQuote.js.map +1 -1
  504. package/dist/utils/runnersScreenPlan.d.ts +51 -20
  505. package/dist/utils/runnersScreenPlan.d.ts.map +1 -1
  506. package/dist/utils/runnersScreenPlan.js +143 -28
  507. package/dist/utils/runnersScreenPlan.js.map +1 -1
  508. package/dist/utils/streamedCompactionSummary.d.ts +65 -0
  509. package/dist/utils/streamedCompactionSummary.d.ts.map +1 -0
  510. package/dist/utils/streamedCompactionSummary.js +108 -0
  511. package/dist/utils/streamedCompactionSummary.js.map +1 -0
  512. package/dist/utils/talkerAccess.d.ts +9 -0
  513. package/dist/utils/talkerAccess.d.ts.map +1 -0
  514. package/dist/utils/talkerAccess.js +20 -0
  515. package/dist/utils/talkerAccess.js.map +1 -0
  516. package/dist/utils/tmuxExec.d.ts +20 -8
  517. package/dist/utils/tmuxExec.d.ts.map +1 -1
  518. package/dist/utils/tmuxExec.js +27 -7
  519. package/dist/utils/tmuxExec.js.map +1 -1
  520. package/dist/utils/topicAccessScreenPlan.d.ts +253 -0
  521. package/dist/utils/topicAccessScreenPlan.d.ts.map +1 -0
  522. package/dist/utils/topicAccessScreenPlan.js +287 -0
  523. package/dist/utils/topicAccessScreenPlan.js.map +1 -0
  524. package/dist/utils/topicLabel.d.ts +12 -0
  525. package/dist/utils/topicLabel.d.ts.map +1 -0
  526. package/dist/utils/topicLabel.js +12 -0
  527. package/dist/utils/topicLabel.js.map +1 -0
  528. package/dist/utils/topicRequest.d.ts +8 -5
  529. package/dist/utils/topicRequest.d.ts.map +1 -1
  530. package/dist/utils/topicRequest.js +9 -7
  531. package/dist/utils/topicRequest.js.map +1 -1
  532. package/npm-shrinkwrap.json +1003 -0
  533. package/package.json +5 -3
  534. package/remoteRun/ensureNode.sh +288 -0
  535. package/remoteRun/runner.sh +2252 -115
  536. package/agent-plugin/skills/charness-manager/SKILL.md +0 -157
  537. package/remoteRun/pickNode.sh +0 -65
@@ -10,8 +10,11 @@ const sessionKeyCodec_1 = require("../sessionKeyCodec");
10
10
  const i18n_1 = require("../../../i18n");
11
11
  const compactCommandRoute_1 = require("../../../utils/compactCommandRoute");
12
12
  const compactOnIdle_1 = require("../../../utils/compactOnIdle");
13
+ const streamedCompactionSummary_1 = require("../../../utils/streamedCompactionSummary");
14
+ const compactSelfReviewFlags_1 = require("../../../utils/compactSelfReviewFlags");
13
15
  const questionKeyboards_1 = require("../questionKeyboards");
14
16
  const messageSplit_1 = require("../messageSplit");
17
+ const inbound_1 = require("../inbound");
15
18
  const openCodeQuestionFlow_1 = require("../../../openCodeQuestionFlow");
16
19
  const callbackMessage_1 = require("./callbackMessage");
17
20
  const callbackToast_1 = require("./callbackToast");
@@ -21,8 +24,8 @@ const compactCommandText = '/compact';
21
24
  const terminalAdapterName = 'terminal';
22
25
  /**
23
26
  * @description Compose the per-invocation compaction instruction for a thread's
24
- * backend (D3 summary guidance + the resume guidance — loaded skills and the
25
- * next-steps checklist — + the optional F2 closing section). The general guidance
27
+ * backend (D3 summary guidance + the resume guidance — the self-review section while `/compact_self_review` is on, the loaded
28
+ * skills and the next-steps checklist — + the optional F2 closing section). The general guidance
26
29
  * is skipped for OpenCode (baked in its fork prompt) and appended for the Claude
27
30
  * backends; the resume guidance is skipped when the backend's own compaction
28
31
  * prompt already gets it (an OpenCode server running the bot's compaction
@@ -33,7 +36,7 @@ async function getCompactionInstruction(adapter, key, opts) {
33
36
  bakesSummaryGuidance: adapter.name === adapterNames_1.openCodeAdapterName,
34
37
  summaryGuidance: compactOnIdle_1.compactionSummaryGuidance,
35
38
  bakesResumeGuidance: (await adapter.checkHasCompactionResumeHook?.(key)) ?? false,
36
- resumeGuidance: compactOnIdle_1.compactionResumeGuidance,
39
+ resumeGuidance: (0, compactOnIdle_1.getCompactionResumeGuidance)(opts.isWithInstructionGaps),
37
40
  closingSectionInstruction: opts.withClosingSection
38
41
  ? (0, i18n_1.t)('compact.closingSectionInstruction', {
39
42
  startMarker: compactOnIdle_1.compactionClosingStartMarker,
@@ -52,7 +55,7 @@ async function getCompactionInstruction(adapter, key, opts) {
52
55
  const deferredCompactionPollMs = 3_000;
53
56
  /**
54
57
  * Build the `/compact_on_idle` picker keyboard: Enable / Disable, then Show / Hide
55
- * summary, ✓ on the current value of each.
58
+ * summary, then Show / Hide self-review, ✓ on the current value of each.
56
59
  */
57
60
  function buildCompactOnIdleKeyboard(picker) {
58
61
  return telegraf_1.Markup.inlineKeyboard([
@@ -64,6 +67,10 @@ function buildCompactOnIdleKeyboard(picker) {
64
67
  telegraf_1.Markup.button.callback((0, i18n_1.t)('compactOnIdle.summaryShowButton') + (picker.isSummaryEnabled ? ' ✓' : ''), 'coi_sum_on'),
65
68
  telegraf_1.Markup.button.callback((0, i18n_1.t)('compactOnIdle.summaryHideButton') + (!picker.isSummaryEnabled ? ' ✓' : ''), 'coi_sum_off'),
66
69
  ],
70
+ [
71
+ telegraf_1.Markup.button.callback((0, i18n_1.t)('compactOnIdle.selfReviewShowButton') + (picker.isSelfReviewEnabled ? ' ✓' : ''), 'coi_sr_on'),
72
+ telegraf_1.Markup.button.callback((0, i18n_1.t)('compactOnIdle.selfReviewHideButton') + (!picker.isSelfReviewEnabled ? ' ✓' : ''), 'coi_sr_off'),
73
+ ],
67
74
  ]);
68
75
  }
69
76
  /**
@@ -72,7 +79,7 @@ function buildCompactOnIdleKeyboard(picker) {
72
79
  * state the typing loop and the request probe read, and the `register…()` calls.
73
80
  */
74
81
  function createCompaction(ports) {
75
- const { startTypingLoader, forwardPromptToAgent, pendingQuestions, clearPendingQuestion, closeQuestionMessage, idleWindowMs, checkIsLimitWaitArmed, suspendThreadSession, resumeSleepingSessionForCompaction, getThreadAdapter, deliverLabel, resumeSleepingSessionForPrompt, checkIsStarting, closeOrphanQuestionMessage, notePersonActivity, bot, command, getState, replyToThread, editThreadKeyboard, authoriseContext, withThreadLocale, checkIsGeneral, wakeSleepingSession } = ports;
82
+ const { startTypingLoader, forwardPromptToAgent, pendingQuestions, clearPendingQuestion, closeQuestionMessage, idleWindowMs, checkIsLimitWaitArmed, suspendThreadSession, resumeSleepingSessionForCompaction, getThreadAdapter, deliverLabel, resumeSleepingSessionForPrompt, checkIsStarting, closeOrphanQuestionMessage, notePersonActivity, compactSelfReviewFlagDirs, bot, command, getState, replyToThread, editThreadKeyboard, authoriseContext, authoriseSpeaker, withThreadLocale, checkIsGeneral, wakeSleepingSession } = ports;
76
83
  /**
77
84
  * @description Resolve the `/compact` route for a thread's current backend — the
78
85
  * pure {@link getCompactCommandRoute} wrapped with the live adapter reading.
@@ -132,7 +139,8 @@ function createCompaction(ports) {
132
139
  // D3: every bot-issued compaction carries the maximally-complete-summary
133
140
  // guidance (baked in the OpenCode fork, appended for the Claude backends), plus
134
141
  // the F2 closing-section directive when requested.
135
- const instruction = await getCompactionInstruction(adapter, key, { withClosingSection: opts.withClosingSection });
142
+ const isSelfReviewEnabled = getState().checkIsCompactSelfReviewEnabled(key);
143
+ const instruction = await getCompactionInstruction(adapter, key, { withClosingSection: opts.withClosingSection, isWithInstructionGaps: isSelfReviewEnabled });
136
144
  const kStr = (0, sessionKey_1.keyToString)(key);
137
145
  threadsCompacting.add(kStr);
138
146
  // S3: `threadsCompacting` is set FIRST, so the loader's very first keep-alive
@@ -157,18 +165,18 @@ function createCompaction(ports) {
157
165
  const compaction = await adapter.compactContext(key, instruction);
158
166
  if (!compaction.ok)
159
167
  return { ok: false, error: compaction.error };
160
- const isWithSummary = (0, compactOnIdle_1.checkShouldPostCompactionSummary)({
161
- isEnabled: getState().checkIsCompactSummaryEnabled(key),
162
- streamsOwnSummary: Boolean(adapter.streamsCompactionSummary),
163
- route,
164
- });
165
- // A transcript / HTTP read, made only when the summary will be posted.
166
- const summary = isWithSummary && adapter.getLatestCompactionSummary
168
+ const isSummaryEnabled = getState().checkIsCompactSummaryEnabled(key);
169
+ const streamsOwnSummary = Boolean(adapter.streamsCompactionSummary);
170
+ const isWithSummary = (0, compactOnIdle_1.checkShouldPostCompactionSummary)({ isEnabled: isSummaryEnabled, streamsOwnSummary, route });
171
+ const isWithInstructionGaps = (0, compactOnIdle_1.checkShouldPostInstructionGaps)({ isEnabled: isSelfReviewEnabled, isSummaryEnabled, streamsOwnSummary, isBotIssued: true, route });
172
+ // A transcript / HTTP read, made only when something of the summary will be posted.
173
+ const summary = (isWithSummary || isWithInstructionGaps) && adapter.getLatestCompactionSummary
167
174
  ? await adapter.getLatestCompactionSummary(key).catch(() => null)
168
175
  : null;
169
176
  return {
170
177
  ok: true,
171
- summary: summary ? (0, compactOnIdle_1.stripCompactionClosingMarkers)(summary) : null,
178
+ summary: isWithSummary && summary ? (0, compactOnIdle_1.formatCompactionSummaryForTopic)(summary, (0, i18n_1.t)('compact.selfReviewHeader')) : null,
179
+ instructionGaps: isWithInstructionGaps && summary ? (0, compactOnIdle_1.extractCompactionInstructionGaps)(summary) : null,
172
180
  preTokens: compaction.preTokens,
173
181
  postTokens: compaction.postTokens,
174
182
  };
@@ -234,6 +242,8 @@ function createCompaction(ports) {
234
242
  : (0, i18n_1.t)('compact.done'));
235
243
  if (result.summary)
236
244
  await postCompactionSummary(key, result.summary);
245
+ if (result.instructionGaps)
246
+ await postCompactionInstructionGaps(key, result.instructionGaps);
237
247
  }
238
248
  /**
239
249
  * @description Post a compaction's FULL summary into the topic — the single poster
@@ -249,10 +259,72 @@ function createCompaction(ports) {
249
259
  * the `threadsCompacting` guard exists to prevent.
250
260
  */
251
261
  async function postCompactionSummary(key, summary) {
252
- const chunks = (0, messageSplit_1.splitMessage)(`${(0, i18n_1.t)('compact.summaryHeader')}\n\n${summary}`, messageSplit_1.MAX_MESSAGE_LEN);
253
- for (const chunk of chunks)
262
+ await postHeadedPlainText(key, (0, i18n_1.t)('compact.summaryHeader'), summary);
263
+ }
264
+ /**
265
+ * @description Post the SELF-REVIEW section of a compaction summary as a message of its own — the part of the
266
+ * summary the person sees even in `/compact_summary` hide mode ({@link checkShouldPostInstructionGaps}). The agent only
267
+ * proposes these instruction changes; the header says so, so the message reads as a proposal and never as something
268
+ * already changed. Same plain-text, split-never-truncated send as {@link postCompactionSummary}.
269
+ */
270
+ async function postCompactionInstructionGaps(key, instructionGaps) {
271
+ await postHeadedPlainText(key, (0, i18n_1.t)('compact.selfReviewHeader'), instructionGaps);
272
+ }
273
+ async function postHeadedPlainText(key, header, body) {
274
+ for (const chunk of (0, messageSplit_1.splitMessage)(`${header}\n\n${body}`, messageSplit_1.MAX_MESSAGE_LEN))
254
275
  await replyToThread(key, chunk);
255
276
  }
277
+ /**
278
+ * @description A compaction the bot did NOT issue finished — the CLI's own, at a context overflow (json-stream's
279
+ * `contextCompacted` event): post its self-review section. Nobody posts such a compaction's summary, in show mode
280
+ * no more than in hide mode, so the section is read out of the transcript and posted whatever `/compact_summary` says.
281
+ * A compaction the bot issued is left to its caller (it is in {@link threadsCompacting} when its completion is
282
+ * announced), which posts what the setting asks for.
283
+ */
284
+ async function postOwnCompactionInstructionGaps(key) {
285
+ if (!(0, sessionKeyCodec_1.checkIsTelegramKey)(key) || threadsCompacting.has((0, sessionKey_1.keyToString)(key)))
286
+ return;
287
+ const adapter = getThreadAdapter(key);
288
+ if (!(0, compactOnIdle_1.checkShouldPostInstructionGaps)({
289
+ isEnabled: getState().checkIsCompactSelfReviewEnabled(key),
290
+ isSummaryEnabled: getState().checkIsCompactSummaryEnabled(key),
291
+ streamsOwnSummary: Boolean(adapter.streamsCompactionSummary),
292
+ isBotIssued: false,
293
+ route: getThreadCompactRoute(key),
294
+ }))
295
+ return;
296
+ const summary = adapter.getLatestCompactionSummary ? await adapter.getLatestCompactionSummary(key).catch(() => null) : null;
297
+ const instructionGaps = summary ? (0, compactOnIdle_1.extractCompactionInstructionGaps)(summary) : null;
298
+ if (instructionGaps)
299
+ await withThreadLocale(key, () => postCompactionInstructionGaps(key, instructionGaps));
300
+ }
301
+ /** The summary each thread's backend is streaming (OpenCode): what `streamedCompactionSummary.ts` follows tail by tail. */
302
+ const streamedSummaryTracker = (0, streamedCompactionSummary_1.createStreamedSummaryTracker)();
303
+ /**
304
+ * @description One tail of a compaction summary that a backend STREAMS (OpenCode), on its way to the topic: the one place
305
+ * that decides what of it the topic sees. Called by `handleAgentOutput` for every tail marked `isCompactionSummary`; the
306
+ * tail goes on to the topic as the returned text (`null`: nothing of it does).
307
+ *
308
+ * - `/compact_summary` ON: the summary is shown, minus the scaffolding the agent was asked to write (the marker lines,
309
+ * the «none» line), with the self-review section under its header;
310
+ * - OFF: nothing is shown, and the section is posted on its own — here, once complete, only for a compaction the BACKEND
311
+ * ran (an overflow). One the bot issued has its section read after the compaction, in order ({@link runThreadCompaction}).
312
+ *
313
+ * A non-Telegram conversation has no topic to post into: its tails go on as they are.
314
+ */
315
+ function routeStreamedCompactionSummaryTail(key, tail, hints) {
316
+ const isContinuation = hints.isContinuation === true;
317
+ if (!(0, sessionKeyCodec_1.checkIsTelegramKey)(key))
318
+ return { text: tail, isContinuation };
319
+ const kStr = (0, sessionKey_1.keyToString)(key);
320
+ const outcome = streamedSummaryTracker.push(kStr, { text: tail, isContinuation, summaryId: hints.compactionSummaryMessageId ?? null, isBotIssued: hints.isBotIssuedCompaction === true }, { isSummaryShown: getState().checkIsCompactSummaryEnabled(key), isInstructionGapsEnabled: getState().checkIsCompactSelfReviewEnabled(key), gapsHeader: (0, i18n_1.t)('compact.selfReviewHeader') });
321
+ if (outcome.instructionGaps !== null) {
322
+ const instructionGaps = outcome.instructionGaps;
323
+ void withThreadLocale(key, () => postCompactionInstructionGaps(key, instructionGaps))
324
+ .catch((error) => console.warn(`[compact] ${kStr} the self-review section was not posted:`, error instanceof Error ? error.message : error));
325
+ }
326
+ return outcome.shown;
327
+ }
256
328
  const threadCompactionStates = new Map();
257
329
  function getThreadCompactionState(kStr) {
258
330
  let existing = threadCompactionStates.get(kStr);
@@ -405,6 +477,7 @@ function createCompaction(ports) {
405
477
  if (compactionState?.idleTimer)
406
478
  clearTimeout(compactionState.idleTimer);
407
479
  threadCompactionStates.delete(kStr);
480
+ streamedSummaryTracker.clear(kStr);
408
481
  // Drop the persisted instants too, so the NEXT session in this topic starts with
409
482
  // no history and therefore gets the FULL idle window — which is why the fresh-start
410
483
  // path needs no special case (do not "fix" it by adding one).
@@ -560,12 +633,13 @@ function createCompaction(ports) {
560
633
  // The compaction failed but the question is already rejected — re-ask it so
561
634
  // the user isn't left without the pending decision (no notice: nothing was
562
635
  // compacted).
563
- await postIdleCompactionResult(key, { noticeText: null, summary: null }, reAsked);
636
+ await postIdleCompactionResult(key, { noticeText: null, summary: null, instructionGaps: null }, reAsked);
564
637
  return;
565
638
  }
566
639
  await postIdleCompactionResult(key, {
567
640
  noticeText: (0, i18n_1.t)('compactOnIdle.notice'),
568
641
  summary: result.summary ?? null,
642
+ instructionGaps: result.instructionGaps ?? null,
569
643
  }, reAsked);
570
644
  }
571
645
  /**
@@ -848,7 +922,7 @@ function createCompaction(ports) {
848
922
  /**
849
923
  * @description Post the idle-compaction outcome (D1/D2) as SEPARATE messages in
850
924
  * the §1.4 order: the short notice → the full summary (when `/compact_summary` is
851
- * on) → the RE-ASKED question with its option buttons, LAST.
925
+ * on) or else the self-review section alone → the RE-ASKED question with its option buttons, LAST.
852
926
  *
853
927
  * The three used to be one joined message. They are split because the re-asked
854
928
  * question carries inline buttons the operator must be able to reach: glued behind
@@ -872,6 +946,8 @@ function createCompaction(ports) {
872
946
  await replyToThread(key, plan.notice);
873
947
  if (plan.summary)
874
948
  await postCompactionSummary(key, plan.summary);
949
+ if (plan.instructionGaps)
950
+ await postCompactionInstructionGaps(key, plan.instructionGaps);
875
951
  if (!reAsked)
876
952
  return;
877
953
  // From here the re-ask is decided: a record taken meanwhile (a number typed) is not posted, and whoever puts it back finishes it.
@@ -905,11 +981,13 @@ function createCompaction(ports) {
905
981
  * the chosen answer in place of the buttons.
906
982
  */
907
983
  async function handleReAskedQuestionTap(ctx, optionIndex) {
908
- const key = await authoriseContext(ctx);
909
- if (!key) {
984
+ // A topic member may answer the agent's question: this tap is one of the few they may make (the speaker gate, not the admin one).
985
+ const speaker = await authoriseSpeaker(ctx);
986
+ if (!speaker) {
910
987
  await ctx.answerCbQuery((0, i18n_1.t)('cb.access_denied'));
911
988
  return;
912
989
  }
990
+ const { key } = speaker;
913
991
  const tappedMessageId = (0, callbackMessage_1.getCallbackMessageId)(ctx);
914
992
  const reAsked = peekReAskedQuestion(key);
915
993
  // A re-ask whose send has not returned has no message id, and when the old message has none either there is nothing to tell
@@ -967,7 +1045,7 @@ function createCompaction(ports) {
967
1045
  // An answer to the agent's own question is never a request (S7), even delivered as a prompt. Routed at delivery,
968
1046
  // not on the `checkIsStarting` read above: the stop may have ended during the toast, and a label buffered into its closed
969
1047
  // window was never replayed.
970
- const outcome = await deliverLabel(key, label);
1048
+ const outcome = await deliverLabel(key, label, speaker.role === 'talker' && ctx.from ? (0, inbound_1.getTelegramTalkerContext)(ctx.from) : undefined);
971
1049
  // The label reached no session (the topic was told why): the question is still open, so are its buttons.
972
1050
  if (outcome === 'noSession') {
973
1051
  await returnReAskedQuestionAfterTap(key, reAsked, reAskedMessageId);
@@ -984,7 +1062,7 @@ function createCompaction(ports) {
984
1062
  * number would count as the person writing something else: the question would end «not answered» and the agent would get a
985
1063
  * bare «2». Resolves whether the text was such a number (and was handled).
986
1064
  */
987
- async function answerReAskedQuestionByNumber(key, text) {
1065
+ async function answerReAskedQuestionByNumber(key, text, messageContext) {
988
1066
  const reAsked = peekReAskedQuestion(key);
989
1067
  if (!reAsked)
990
1068
  return false;
@@ -997,7 +1075,7 @@ function createCompaction(ports) {
997
1075
  takeReAskedQuestionForAnswer(key);
998
1076
  // A person wrote — the latch clears like for any message; the record is gone, so nothing is closed as «not answered».
999
1077
  notePersonActivity(key);
1000
- const outcome = await deliverLabel(key, label);
1078
+ const outcome = await deliverLabel(key, label, messageContext);
1001
1079
  if (outcome === 'noSession') {
1002
1080
  const isPutBack = await returnReAskedQuestionAfterTap(key, reAsked, reAsked.messageId ?? reAsked.predecessorMessageId);
1003
1081
  if (isPutBack)
@@ -1120,13 +1198,21 @@ function createCompaction(ports) {
1120
1198
  }
1121
1199
  }
1122
1200
  /**
1123
- * @description Both switches as the `/compact_on_idle` picker shows them: in General
1201
+ * @description The switches as the `/compact_on_idle` picker shows them: in General
1124
1202
  * the instance-wide defaults, in a regular topic what applies to that topic.
1125
1203
  */
1126
1204
  function getCompactOnIdlePickerState(key, isGeneral) {
1127
1205
  return isGeneral
1128
- ? { isIdleEnabled: getState().getCompactOnIdleGlobalDefault(), isSummaryEnabled: getState().getCompactSummaryGlobalDefault() }
1129
- : { isIdleEnabled: getState().checkIsCompactOnIdleEnabled(key), isSummaryEnabled: getState().checkIsCompactSummaryEnabled(key) };
1206
+ ? {
1207
+ isIdleEnabled: getState().getCompactOnIdleGlobalDefault(),
1208
+ isSummaryEnabled: getState().getCompactSummaryGlobalDefault(),
1209
+ isSelfReviewEnabled: getState().getCompactSelfReviewGlobalDefault(),
1210
+ }
1211
+ : {
1212
+ isIdleEnabled: getState().checkIsCompactOnIdleEnabled(key),
1213
+ isSummaryEnabled: getState().checkIsCompactSummaryEnabled(key),
1214
+ isSelfReviewEnabled: getState().checkIsCompactSelfReviewEnabled(key),
1215
+ };
1130
1216
  }
1131
1217
  /**
1132
1218
  * @description A tap on the `/compact_on_idle` picker — either row. `apply` writes
@@ -1197,6 +1283,69 @@ function createCompaction(ports) {
1197
1283
  if (pickerMessageId !== null)
1198
1284
  await editThreadKeyboard(key, pickerMessageId, buildCompactSummaryKeyboard(enabled).reply_markup, 'csum_cb');
1199
1285
  }
1286
+ /**
1287
+ * @description Make the hook and plugin flags of `key`'s agent sessions — the current ones and the parked ones — say what
1288
+ * `/compact_self_review` resolves to for its topic. Called when the setting changes for the topic and when a session starts, so
1289
+ * the CLI's and OpenCode's own compactions — which read the flag inside the agent's process — follow the setting of the
1290
+ * session they run in.
1291
+ */
1292
+ function syncThreadCompactSelfReviewFlags(key) {
1293
+ (0, compactSelfReviewFlags_1.syncCompactSelfReviewFlags)([{ ...getState().getAgentSessionIds(key), isEnabled: getState().checkIsCompactSelfReviewEnabled(key) }], compactSelfReviewFlagDirs);
1294
+ }
1295
+ /**
1296
+ * @description {@link syncThreadCompactSelfReviewFlags} for every thread, and the Claude flags no OFF topic owns any more are
1297
+ * removed (a session a topic left, a topic that is gone): at boot, and when the General default changes.
1298
+ */
1299
+ function syncAllCompactSelfReviewFlags() {
1300
+ const sessions = getState().listAgentSessionIds().map(({ key, claudeSessionIds, opencodeSessionIds }) => ({
1301
+ claudeSessionIds,
1302
+ opencodeSessionIds,
1303
+ isEnabled: getState().checkIsCompactSelfReviewEnabled(key),
1304
+ }));
1305
+ (0, compactSelfReviewFlags_1.syncCompactSelfReviewFlags)(sessions, compactSelfReviewFlagDirs);
1306
+ (0, compactSelfReviewFlags_1.pruneStaleClaudeCompactSelfReviewFlags)(sessions, compactSelfReviewFlagDirs.claudeOffDir);
1307
+ }
1308
+ /**
1309
+ * @description Apply the `/compact_self_review` setting and RETURN the confirmation text — the single write path behind the
1310
+ * command, its picker buttons and the self-review row of the `/compact_on_idle` picker. Regular topic → the per-thread
1311
+ * override; General → the instance-wide default. The flags the compactions of the agent's own process read are brought in
1312
+ * step with it before the confirmation goes out.
1313
+ */
1314
+ async function applyCompactSelfReview(key, isGeneral, enabled) {
1315
+ const stateWord = enabled ? (0, i18n_1.t)('compactSelfReview.on') : (0, i18n_1.t)('compactSelfReview.off');
1316
+ if (isGeneral) {
1317
+ await getState().setCompactSelfReviewGlobalDefault(enabled);
1318
+ syncAllCompactSelfReviewFlags();
1319
+ return (0, i18n_1.t)('compactSelfReview.setGlobal', { state: stateWord });
1320
+ }
1321
+ await getState().setCompactSelfReviewOverride(key, enabled);
1322
+ syncThreadCompactSelfReviewFlags(key);
1323
+ return (0, i18n_1.t)('compactSelfReview.setThisTopic', { state: stateWord });
1324
+ }
1325
+ /** Build the `/compact_self_review` picker keyboard (Enable / Disable, ✓ on current). */
1326
+ function buildCompactSelfReviewKeyboard(isEnabled) {
1327
+ return telegraf_1.Markup.inlineKeyboard([
1328
+ telegraf_1.Markup.button.callback((0, i18n_1.t)('compactSelfReview.enableButton') + (isEnabled ? ' ✓' : ''), 'csr_on'),
1329
+ telegraf_1.Markup.button.callback((0, i18n_1.t)('compactSelfReview.disableButton') + (!isEnabled ? ' ✓' : ''), 'csr_off'),
1330
+ ]);
1331
+ }
1332
+ /** `/compact_self_review` picker button. A REPEATED-USE picker, so it re-renders its keyboard in place, like `csum_on` / `csum_off`. */
1333
+ async function handleCompactSelfReviewCallback(ctx, enabled) {
1334
+ const key = await authoriseContext(ctx);
1335
+ if (!key) {
1336
+ await ctx.answerCbQuery((0, i18n_1.t)('cb.access_denied'));
1337
+ return;
1338
+ }
1339
+ const isGeneral = checkIsGeneral(key);
1340
+ // Answered first for the reason given in `handleCompactOnIdleCallback`.
1341
+ await ctx.answerCbQuery();
1342
+ await withThreadLocale(key, async () => {
1343
+ await replyToThread(key, await applyCompactSelfReview(key, isGeneral, enabled));
1344
+ });
1345
+ const pickerMessageId = (0, callbackMessage_1.getCallbackMessageId)(ctx);
1346
+ if (pickerMessageId !== null)
1347
+ await editThreadKeyboard(key, pickerMessageId, buildCompactSelfReviewKeyboard(enabled).reply_markup, 'csr_cb');
1348
+ }
1200
1349
  function registerCompactionCommands() {
1201
1350
  // `/compact` — shrink the agent's context. BOT-OWNED, because "forward the text
1202
1351
  // and hope" only works for a backend that parses slash commands itself: OpenCode's
@@ -1230,7 +1379,7 @@ function createCompaction(ports) {
1230
1379
  // → per-thread override; General → the instance-wide default. Bare → a picker:
1231
1380
  // Enable/Disable, plus a Show/Hide row for the `/compact_summary` setting, which
1232
1381
  // is what decides whether an idle compaction ends in one line or with the whole
1233
- // summary (✓ on current). Only meaningful for an agent topic with an active
1382
+ // summary, and one for `/compact_self_review` (the self-review section; ✓ on current). Only meaningful for an agent topic with an active
1234
1383
  // session (terminal / unbound → the "nothing to compact" reply).
1235
1384
  command('compact_on_idle', async (_ctx, key, parsed) => {
1236
1385
  const arg = parsed.args.join(' ').toLowerCase();
@@ -1251,6 +1400,9 @@ function createCompaction(ports) {
1251
1400
  summaryLine: (0, i18n_1.t)('compactOnIdle.summaryLine', {
1252
1401
  state: picker.isSummaryEnabled ? (0, i18n_1.t)('compactSummary.on') : (0, i18n_1.t)('compactSummary.off'),
1253
1402
  }),
1403
+ selfReviewLine: (0, i18n_1.t)('compactOnIdle.selfReviewLine', {
1404
+ state: picker.isSelfReviewEnabled ? (0, i18n_1.t)('compactSelfReview.on') : (0, i18n_1.t)('compactSelfReview.off'),
1405
+ }),
1254
1406
  };
1255
1407
  const title = isGeneral ? (0, i18n_1.t)('compactOnIdle.titleGeneral', vars) : (0, i18n_1.t)('compactOnIdle.title', vars);
1256
1408
  await replyToThread(key, title, buildCompactOnIdleKeyboard(picker));
@@ -1281,6 +1433,31 @@ function createCompaction(ports) {
1281
1433
  : (0, i18n_1.t)('compactSummary.title', { state: stateWord });
1282
1434
  await replyToThread(key, title, buildCompactSummaryKeyboard(isEnabled));
1283
1435
  });
1436
+ // `/compact_self_review` — toggle the self-review section of a compaction summary: whether the agent is asked for it
1437
+ // (every kind of compaction, the CLI's and OpenCode's own included) and whether the bot posts it. Regular topic →
1438
+ // per-thread override; General → the instance-wide default. ON by default. Bare → an Enable/Disable picker (✓ on
1439
+ // current). Like `/compact_summary` it is read when a compaction runs, so it is not gated on an active session; only a
1440
+ // raw shell, with no context to compact, is refused.
1441
+ command('compact_self_review', async (_ctx, key, parsed) => {
1442
+ const arg = parsed.args.join(' ').toLowerCase();
1443
+ const isGeneral = checkIsGeneral(key);
1444
+ if (!isGeneral && getThreadCompactRoute(key) === 'notSupported') {
1445
+ await replyToThread(key, (0, i18n_1.t)('compactSelfReview.unsupported'));
1446
+ return;
1447
+ }
1448
+ if (arg === 'on' || arg === 'off') {
1449
+ await replyToThread(key, await applyCompactSelfReview(key, isGeneral, arg === 'on'));
1450
+ return;
1451
+ }
1452
+ const isEnabled = isGeneral
1453
+ ? getState().getCompactSelfReviewGlobalDefault()
1454
+ : getState().checkIsCompactSelfReviewEnabled(key);
1455
+ const stateWord = isEnabled ? (0, i18n_1.t)('compactSelfReview.on') : (0, i18n_1.t)('compactSelfReview.off');
1456
+ const title = isGeneral
1457
+ ? (0, i18n_1.t)('compactSelfReview.titleGeneral', { state: stateWord })
1458
+ : (0, i18n_1.t)('compactSelfReview.title', { state: stateWord });
1459
+ await replyToThread(key, title, buildCompactSelfReviewKeyboard(isEnabled));
1460
+ });
1284
1461
  }
1285
1462
  function registerCompactionCallbacks() {
1286
1463
  bot.action('coi_on', (ctx) => handleCompactOnIdleCallback(ctx, (key, isGeneral) => applyCompactOnIdle(key, isGeneral, true)));
@@ -1291,8 +1468,16 @@ function createCompaction(ports) {
1291
1468
  bot.action('coi_sum_off', (ctx) => handleCompactOnIdleCallback(ctx, async (key, isGeneral) => {
1292
1469
  await replyToThread(key, await applyCompactSummary(key, isGeneral, false));
1293
1470
  }));
1471
+ bot.action('coi_sr_on', (ctx) => handleCompactOnIdleCallback(ctx, async (key, isGeneral) => {
1472
+ await replyToThread(key, await applyCompactSelfReview(key, isGeneral, true));
1473
+ }));
1474
+ bot.action('coi_sr_off', (ctx) => handleCompactOnIdleCallback(ctx, async (key, isGeneral) => {
1475
+ await replyToThread(key, await applyCompactSelfReview(key, isGeneral, false));
1476
+ }));
1294
1477
  bot.action('csum_on', (ctx) => handleCompactSummaryCallback(ctx, true));
1295
1478
  bot.action('csum_off', (ctx) => handleCompactSummaryCallback(ctx, false));
1479
+ bot.action('csr_on', (ctx) => handleCompactSelfReviewCallback(ctx, true));
1480
+ bot.action('csr_off', (ctx) => handleCompactSelfReviewCallback(ctx, false));
1296
1481
  bot.action(/^reask_(\d+)$/, (ctx) => handleReAskedQuestionTap(ctx, parseInt(ctx.match[1], 10)));
1297
1482
  }
1298
1483
  return {
@@ -1300,6 +1485,10 @@ function createCompaction(ports) {
1300
1485
  noteThreadActivity,
1301
1486
  noteThreadUserActivity,
1302
1487
  markThreadTurnProducedOutput,
1488
+ postOwnCompactionInstructionGaps,
1489
+ syncThreadCompactSelfReviewFlags,
1490
+ syncAllCompactSelfReviewFlags,
1491
+ routeStreamedCompactionSummaryTail,
1303
1492
  clearThreadCompaction,
1304
1493
  rearmThreadIdleTimer,
1305
1494
  armDeferredCompaction,