charness 4.3.1 → 4.4.1

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 (428) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/DEVELOPMENT.md +3 -1
  3. package/README.md +2 -1
  4. package/agent-plugin/README.md +6 -5
  5. package/agent-plugin/skills/charness-delegate-opencode/SKILL.md +4 -1
  6. package/agent-plugin/skills/charness-delivery-loop/SKILL.md +9 -9
  7. package/agent-plugin/skills/charness-orchestration/SKILL.md +8 -4
  8. package/dist/adapters/adapterEventRouting.d.ts +2 -1
  9. package/dist/adapters/adapterEventRouting.d.ts.map +1 -1
  10. package/dist/adapters/adapterEventRouting.js +3 -0
  11. package/dist/adapters/adapterEventRouting.js.map +1 -1
  12. package/dist/adapters/claudeCliAdapter.d.ts.map +1 -1
  13. package/dist/adapters/claudeCliAdapter.js +11 -6
  14. package/dist/adapters/claudeCliAdapter.js.map +1 -1
  15. package/dist/adapters/claudeJsonStreamAdapter.d.ts +11 -3
  16. package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -1
  17. package/dist/adapters/claudeJsonStreamAdapter.js +48 -16
  18. package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
  19. package/dist/adapters/createAdapter.d.ts +1 -0
  20. package/dist/adapters/createAdapter.d.ts.map +1 -1
  21. package/dist/adapters/createAdapter.js +4 -0
  22. package/dist/adapters/createAdapter.js.map +1 -1
  23. package/dist/adapters/openCodeAdapter.d.ts +68 -11
  24. package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
  25. package/dist/adapters/openCodeAdapter.js +194 -70
  26. package/dist/adapters/openCodeAdapter.js.map +1 -1
  27. package/dist/adapters/terminalAdapter.js +1 -1
  28. package/dist/adapters/terminalAdapter.js.map +1 -1
  29. package/dist/agentLogin/agentLogin.d.ts.map +1 -1
  30. package/dist/agentLogin/agentLogin.js +6 -5
  31. package/dist/agentLogin/agentLogin.js.map +1 -1
  32. package/dist/bot.d.ts.map +1 -1
  33. package/dist/bot.js +109 -97
  34. package/dist/bot.js.map +1 -1
  35. package/dist/botFileStorage.d.ts.map +1 -1
  36. package/dist/botFileStorage.js +6 -5
  37. package/dist/botFileStorage.js.map +1 -1
  38. package/dist/cli/bot.d.ts +2 -1
  39. package/dist/cli/bot.d.ts.map +1 -1
  40. package/dist/cli/bot.js +14 -10
  41. package/dist/cli/bot.js.map +1 -1
  42. package/dist/cli/claudeProfiles.d.ts +4 -1
  43. package/dist/cli/claudeProfiles.d.ts.map +1 -1
  44. package/dist/cli/claudeProfiles.js +42 -3
  45. package/dist/cli/claudeProfiles.js.map +1 -1
  46. package/dist/cli/hot.d.ts +3 -0
  47. package/dist/cli/hot.d.ts.map +1 -1
  48. package/dist/cli/hot.js +32 -3
  49. package/dist/cli/hot.js.map +1 -1
  50. package/dist/configDirFile.d.ts +23 -5
  51. package/dist/configDirFile.d.ts.map +1 -1
  52. package/dist/configDirFile.js +59 -19
  53. package/dist/configDirFile.js.map +1 -1
  54. package/dist/configDirectory.d.ts +9 -0
  55. package/dist/configDirectory.d.ts.map +1 -0
  56. package/dist/configDirectory.js +57 -0
  57. package/dist/configDirectory.js.map +1 -0
  58. package/dist/connectors/jira/agentBinaries.d.ts.map +1 -1
  59. package/dist/connectors/jira/agentBinaries.js +7 -6
  60. package/dist/connectors/jira/agentBinaries.js.map +1 -1
  61. package/dist/connectors/jira/attachmentDownload.d.ts.map +1 -1
  62. package/dist/connectors/jira/attachmentDownload.js +3 -3
  63. package/dist/connectors/jira/attachmentDownload.js.map +1 -1
  64. package/dist/connectors/jira/attachmentTool.d.ts.map +1 -1
  65. package/dist/connectors/jira/attachmentTool.js +4 -3
  66. package/dist/connectors/jira/attachmentTool.js.map +1 -1
  67. package/dist/connectors/jira/contextLedger.d.ts.map +1 -1
  68. package/dist/connectors/jira/contextLedger.js +5 -4
  69. package/dist/connectors/jira/contextLedger.js.map +1 -1
  70. package/dist/connectors/jira/promptSpill.d.ts.map +1 -1
  71. package/dist/connectors/jira/promptSpill.js +5 -5
  72. package/dist/connectors/jira/promptSpill.js.map +1 -1
  73. package/dist/connectors/telegram/commands/claudeAccounts.d.ts +12 -1
  74. package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -1
  75. package/dist/connectors/telegram/commands/claudeAccounts.js +253 -89
  76. package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
  77. package/dist/connectors/telegram/commands/fallbackChain.d.ts.map +1 -1
  78. package/dist/connectors/telegram/commands/fallbackChain.js +8 -7
  79. package/dist/connectors/telegram/commands/fallbackChain.js.map +1 -1
  80. package/dist/connectors/telegram/commands/limitsBoard.d.ts.map +1 -1
  81. package/dist/connectors/telegram/commands/limitsBoard.js +3 -1
  82. package/dist/connectors/telegram/commands/limitsBoard.js.map +1 -1
  83. package/dist/connectors/telegram/commands/modelPage.d.ts +2 -0
  84. package/dist/connectors/telegram/commands/modelPage.d.ts.map +1 -1
  85. package/dist/connectors/telegram/commands/modelPage.js +1 -1
  86. package/dist/connectors/telegram/commands/modelPage.js.map +1 -1
  87. package/dist/dataDirFs.d.ts +95 -0
  88. package/dist/dataDirFs.d.ts.map +1 -0
  89. package/dist/dataDirFs.js +348 -0
  90. package/dist/dataDirFs.js.map +1 -0
  91. package/dist/diagLog.d.ts.map +1 -1
  92. package/dist/diagLog.js +7 -3
  93. package/dist/diagLog.js.map +1 -1
  94. package/dist/i18n/de.d.ts.map +1 -1
  95. package/dist/i18n/de.js +42 -25
  96. package/dist/i18n/de.js.map +1 -1
  97. package/dist/i18n/en.d.ts.map +1 -1
  98. package/dist/i18n/en.js +42 -25
  99. package/dist/i18n/en.js.map +1 -1
  100. package/dist/i18n/es.d.ts.map +1 -1
  101. package/dist/i18n/es.js +42 -25
  102. package/dist/i18n/es.js.map +1 -1
  103. package/dist/i18n/fr.d.ts.map +1 -1
  104. package/dist/i18n/fr.js +42 -25
  105. package/dist/i18n/fr.js.map +1 -1
  106. package/dist/i18n/hi.d.ts.map +1 -1
  107. package/dist/i18n/hi.js +42 -25
  108. package/dist/i18n/hi.js.map +1 -1
  109. package/dist/i18n/ja.d.ts.map +1 -1
  110. package/dist/i18n/ja.js +42 -25
  111. package/dist/i18n/ja.js.map +1 -1
  112. package/dist/i18n/ka.d.ts.map +1 -1
  113. package/dist/i18n/ka.js +42 -25
  114. package/dist/i18n/ka.js.map +1 -1
  115. package/dist/i18n/pt.d.ts.map +1 -1
  116. package/dist/i18n/pt.js +42 -25
  117. package/dist/i18n/pt.js.map +1 -1
  118. package/dist/i18n/ru.d.ts.map +1 -1
  119. package/dist/i18n/ru.js +42 -25
  120. package/dist/i18n/ru.js.map +1 -1
  121. package/dist/i18n/uk.d.ts.map +1 -1
  122. package/dist/i18n/uk.js +42 -25
  123. package/dist/i18n/uk.js.map +1 -1
  124. package/dist/i18n/uz.d.ts.map +1 -1
  125. package/dist/i18n/uz.js +42 -25
  126. package/dist/i18n/uz.js.map +1 -1
  127. package/dist/i18n/zh.d.ts.map +1 -1
  128. package/dist/i18n/zh.js +42 -25
  129. package/dist/i18n/zh.js.map +1 -1
  130. package/dist/i18n.d.ts +0 -12
  131. package/dist/i18n.d.ts.map +1 -1
  132. package/dist/i18n.js +6 -4
  133. package/dist/i18n.js.map +1 -1
  134. package/dist/installManager.d.ts +2 -2
  135. package/dist/installManager.d.ts.map +1 -1
  136. package/dist/installManager.js +53 -64
  137. package/dist/installManager.js.map +1 -1
  138. package/dist/instanceLock.d.ts +95 -0
  139. package/dist/instanceLock.d.ts.map +1 -1
  140. package/dist/instanceLock.js +293 -28
  141. package/dist/instanceLock.js.map +1 -1
  142. package/dist/instanceSettings.d.ts +4 -1
  143. package/dist/instanceSettings.d.ts.map +1 -1
  144. package/dist/instanceSettings.js +5 -1
  145. package/dist/instanceSettings.js.map +1 -1
  146. package/dist/legacyNames.d.ts +11 -0
  147. package/dist/legacyNames.d.ts.map +1 -1
  148. package/dist/legacyNames.js +12 -1
  149. package/dist/legacyNames.js.map +1 -1
  150. package/dist/mcpConfig.d.ts.map +1 -1
  151. package/dist/mcpConfig.js +10 -9
  152. package/dist/mcpConfig.js.map +1 -1
  153. package/dist/outputTrace.d.ts.map +1 -1
  154. package/dist/outputTrace.js +12 -6
  155. package/dist/outputTrace.js.map +1 -1
  156. package/dist/processIdentity.d.ts +18 -0
  157. package/dist/processIdentity.d.ts.map +1 -0
  158. package/dist/processIdentity.js +136 -0
  159. package/dist/processIdentity.js.map +1 -0
  160. package/dist/remoteRun/commands.d.ts.map +1 -1
  161. package/dist/remoteRun/commands.js +4 -4
  162. package/dist/remoteRun/commands.js.map +1 -1
  163. package/dist/remoteRun/heldBackNotice.d.ts.map +1 -1
  164. package/dist/remoteRun/heldBackNotice.js +4 -3
  165. package/dist/remoteRun/heldBackNotice.js.map +1 -1
  166. package/dist/remoteRun/jobFiles.d.ts.map +1 -1
  167. package/dist/remoteRun/jobFiles.js +3 -2
  168. package/dist/remoteRun/jobFiles.js.map +1 -1
  169. package/dist/remoteRun/jobRecords.d.ts.map +1 -1
  170. package/dist/remoteRun/jobRecords.js +4 -3
  171. package/dist/remoteRun/jobRecords.js.map +1 -1
  172. package/dist/remoteRun/runners.d.ts.map +1 -1
  173. package/dist/remoteRun/runners.js +5 -4
  174. package/dist/remoteRun/runners.js.map +1 -1
  175. package/dist/remoteRun/safeCopy.d.ts.map +1 -1
  176. package/dist/remoteRun/safeCopy.js +5 -4
  177. package/dist/remoteRun/safeCopy.js.map +1 -1
  178. package/dist/remoteRun/ssh.d.ts.map +1 -1
  179. package/dist/remoteRun/ssh.js +4 -4
  180. package/dist/remoteRun/ssh.js.map +1 -1
  181. package/dist/remoteRun/submit.d.ts.map +1 -1
  182. package/dist/remoteRun/submit.js +2 -1
  183. package/dist/remoteRun/submit.js.map +1 -1
  184. package/dist/requests/wakeUpEngine.d.ts +8 -0
  185. package/dist/requests/wakeUpEngine.d.ts.map +1 -1
  186. package/dist/requests/wakeUpEngine.js +19 -2
  187. package/dist/requests/wakeUpEngine.js.map +1 -1
  188. package/dist/runnerUtility/appInstall.d.ts.map +1 -1
  189. package/dist/runnerUtility/appInstall.js +11 -10
  190. package/dist/runnerUtility/appInstall.js.map +1 -1
  191. package/dist/runnerUtility/appUpdate.d.ts.map +1 -1
  192. package/dist/runnerUtility/appUpdate.js +3 -3
  193. package/dist/runnerUtility/appUpdate.js.map +1 -1
  194. package/dist/runnerUtility/execEnv.d.ts +0 -5
  195. package/dist/runnerUtility/execEnv.d.ts.map +1 -1
  196. package/dist/runnerUtility/execEnv.js +2 -24
  197. package/dist/runnerUtility/execEnv.js.map +1 -1
  198. package/dist/runnerUtility/guiAgent.d.ts.map +1 -1
  199. package/dist/runnerUtility/guiAgent.js +12 -11
  200. package/dist/runnerUtility/guiAgent.js.map +1 -1
  201. package/dist/runnerUtility/guiAgentHeal.d.ts.map +1 -1
  202. package/dist/runnerUtility/guiAgentHeal.js +4 -3
  203. package/dist/runnerUtility/guiAgentHeal.js.map +1 -1
  204. package/dist/runnerUtility/iosCheck.d.ts.map +1 -1
  205. package/dist/runnerUtility/iosCheck.js +2 -1
  206. package/dist/runnerUtility/iosCheck.js.map +1 -1
  207. package/dist/runnerUtility/keepAwake.d.ts.map +1 -1
  208. package/dist/runnerUtility/keepAwake.js +2 -1
  209. package/dist/runnerUtility/keepAwake.js.map +1 -1
  210. package/dist/runnerUtility/launcher.d.ts.map +1 -1
  211. package/dist/runnerUtility/launcher.js +2 -1
  212. package/dist/runnerUtility/launcher.js.map +1 -1
  213. package/dist/runnerUtility/nodeUpkeep.d.ts.map +1 -1
  214. package/dist/runnerUtility/nodeUpkeep.js +4 -3
  215. package/dist/runnerUtility/nodeUpkeep.js.map +1 -1
  216. package/dist/runnerUtility/packageManagerShims.d.ts.map +1 -1
  217. package/dist/runnerUtility/packageManagerShims.js +5 -4
  218. package/dist/runnerUtility/packageManagerShims.js.map +1 -1
  219. package/dist/runnerUtility/pueueDaemon.d.ts.map +1 -1
  220. package/dist/runnerUtility/pueueDaemon.js +3 -2
  221. package/dist/runnerUtility/pueueDaemon.js.map +1 -1
  222. package/dist/runnerUtility/runnerCli.js +2 -1
  223. package/dist/runnerUtility/runnerCli.js.map +1 -1
  224. package/dist/runnerUtility/runnerCommands.d.ts.map +1 -1
  225. package/dist/runnerUtility/runnerCommands.js +6 -5
  226. package/dist/runnerUtility/runnerCommands.js.map +1 -1
  227. package/dist/runnerUtility/runnerConfig.d.ts.map +1 -1
  228. package/dist/runnerUtility/runnerConfig.js +2 -1
  229. package/dist/runnerUtility/runnerConfig.js.map +1 -1
  230. package/dist/runnerUtility/runnerFlags.d.ts.map +1 -1
  231. package/dist/runnerUtility/runnerFlags.js +3 -2
  232. package/dist/runnerUtility/runnerFlags.js.map +1 -1
  233. package/dist/runnerUtility/runnerKeys.d.ts.map +1 -1
  234. package/dist/runnerUtility/runnerKeys.js +2 -1
  235. package/dist/runnerUtility/runnerKeys.js.map +1 -1
  236. package/dist/runnerUtility/serviceManager.d.ts.map +1 -1
  237. package/dist/runnerUtility/serviceManager.js +15 -14
  238. package/dist/runnerUtility/serviceManager.js.map +1 -1
  239. package/dist/runnerUtility/simctlGuard.d.ts.map +1 -1
  240. package/dist/runnerUtility/simctlGuard.js +3 -2
  241. package/dist/runnerUtility/simctlGuard.js.map +1 -1
  242. package/dist/runnerUtility/toolInstall.d.ts.map +1 -1
  243. package/dist/runnerUtility/toolInstall.js +11 -10
  244. package/dist/runnerUtility/toolInstall.js.map +1 -1
  245. package/dist/runners/authorizedKeys.d.ts.map +1 -1
  246. package/dist/runners/authorizedKeys.js +2 -1
  247. package/dist/runners/authorizedKeys.js.map +1 -1
  248. package/dist/runners/gateLink.d.ts.map +1 -1
  249. package/dist/runners/gateLink.js +4 -3
  250. package/dist/runners/gateLink.js.map +1 -1
  251. package/dist/runners/hubLock.d.ts.map +1 -1
  252. package/dist/runners/hubLock.js +9 -8
  253. package/dist/runners/hubLock.js.map +1 -1
  254. package/dist/runners/hubPackage.d.ts.map +1 -1
  255. package/dist/runners/hubPackage.js +5 -4
  256. package/dist/runners/hubPackage.js.map +1 -1
  257. package/dist/runners/linkControl.d.ts.map +1 -1
  258. package/dist/runners/linkControl.js +7 -6
  259. package/dist/runners/linkControl.js.map +1 -1
  260. package/dist/scheduler/injection.d.ts +5 -3
  261. package/dist/scheduler/injection.d.ts.map +1 -1
  262. package/dist/scheduler/injection.js +15 -4
  263. package/dist/scheduler/injection.js.map +1 -1
  264. package/dist/scheduler/mcpSurface.d.ts.map +1 -1
  265. package/dist/scheduler/mcpSurface.js +19 -13
  266. package/dist/scheduler/mcpSurface.js.map +1 -1
  267. package/dist/selfUpdate/gitSource.d.ts.map +1 -1
  268. package/dist/selfUpdate/gitSource.js +2 -2
  269. package/dist/selfUpdate/gitSource.js.map +1 -1
  270. package/dist/selfUpdate/hostLock.d.ts.map +1 -1
  271. package/dist/selfUpdate/hostLock.js +4 -3
  272. package/dist/selfUpdate/hostLock.js.map +1 -1
  273. package/dist/selfUpdate/restart.d.ts +8 -0
  274. package/dist/selfUpdate/restart.d.ts.map +1 -1
  275. package/dist/selfUpdate/restart.js +10 -0
  276. package/dist/selfUpdate/restart.js.map +1 -1
  277. package/dist/selfUpdate/selfCheck.d.ts.map +1 -1
  278. package/dist/selfUpdate/selfCheck.js +3 -2
  279. package/dist/selfUpdate/selfCheck.js.map +1 -1
  280. package/dist/selfUpdate/updatePending.d.ts.map +1 -1
  281. package/dist/selfUpdate/updatePending.js +2 -1
  282. package/dist/selfUpdate/updatePending.js.map +1 -1
  283. package/dist/state.d.ts +21 -4
  284. package/dist/state.d.ts.map +1 -1
  285. package/dist/state.js +53 -20
  286. package/dist/state.js.map +1 -1
  287. package/dist/stt/sttAutoInstall.d.ts.map +1 -1
  288. package/dist/stt/sttAutoInstall.js +9 -2
  289. package/dist/stt/sttAutoInstall.js.map +1 -1
  290. package/dist/stt/sttInstall.d.ts.map +1 -1
  291. package/dist/stt/sttInstall.js +18 -17
  292. package/dist/stt/sttInstall.js.map +1 -1
  293. package/dist/stt/sttInstallEntry.js +12 -2
  294. package/dist/stt/sttInstallEntry.js.map +1 -1
  295. package/dist/stt/sttSettings.d.ts.map +1 -1
  296. package/dist/stt/sttSettings.js +6 -2
  297. package/dist/stt/sttSettings.js.map +1 -1
  298. package/dist/stt/sttSidecarOwner.d.ts +0 -3
  299. package/dist/stt/sttSidecarOwner.d.ts.map +1 -1
  300. package/dist/stt/sttSidecarOwner.js +11 -12
  301. package/dist/stt/sttSidecarOwner.js.map +1 -1
  302. package/dist/todos/projects.d.ts.map +1 -1
  303. package/dist/todos/projects.js +2 -1
  304. package/dist/todos/projects.js.map +1 -1
  305. package/dist/todos/store.d.ts.map +1 -1
  306. package/dist/todos/store.js +5 -4
  307. package/dist/todos/store.js.map +1 -1
  308. package/dist/types.d.ts +8 -1
  309. package/dist/types.d.ts.map +1 -1
  310. package/dist/types.js.map +1 -1
  311. package/dist/utils/agentEnvironment.d.ts +19 -8
  312. package/dist/utils/agentEnvironment.d.ts.map +1 -1
  313. package/dist/utils/agentEnvironment.js +32 -12
  314. package/dist/utils/agentEnvironment.js.map +1 -1
  315. package/dist/utils/agentPlugin.d.ts +2 -0
  316. package/dist/utils/agentPlugin.d.ts.map +1 -1
  317. package/dist/utils/agentPlugin.js +8 -6
  318. package/dist/utils/agentPlugin.js.map +1 -1
  319. package/dist/utils/backendSwitchPlan.d.ts +4 -1
  320. package/dist/utils/backendSwitchPlan.d.ts.map +1 -1
  321. package/dist/utils/backendSwitchPlan.js +6 -2
  322. package/dist/utils/backendSwitchPlan.js.map +1 -1
  323. package/dist/utils/claudeAccountAlert.d.ts +6 -3
  324. package/dist/utils/claudeAccountAlert.d.ts.map +1 -1
  325. package/dist/utils/claudeAccountAlert.js +13 -7
  326. package/dist/utils/claudeAccountAlert.js.map +1 -1
  327. package/dist/utils/claudeAccountPickerPlan.d.ts +17 -3
  328. package/dist/utils/claudeAccountPickerPlan.d.ts.map +1 -1
  329. package/dist/utils/claudeAccountPickerPlan.js +19 -4
  330. package/dist/utils/claudeAccountPickerPlan.js.map +1 -1
  331. package/dist/utils/claudeApiCredit.d.ts.map +1 -1
  332. package/dist/utils/claudeApiCredit.js +4 -1
  333. package/dist/utils/claudeApiCredit.js.map +1 -1
  334. package/dist/utils/claudeCompactHook.js +5 -5
  335. package/dist/utils/claudeCompactHook.js.map +1 -1
  336. package/dist/utils/claudeProfileLabels.d.ts +160 -0
  337. package/dist/utils/claudeProfileLabels.d.ts.map +1 -0
  338. package/dist/utils/claudeProfileLabels.js +283 -0
  339. package/dist/utils/claudeProfileLabels.js.map +1 -0
  340. package/dist/utils/claudeProfileUsageViews.d.ts +2 -0
  341. package/dist/utils/claudeProfileUsageViews.d.ts.map +1 -1
  342. package/dist/utils/claudeProfileUsageViews.js +3 -1
  343. package/dist/utils/claudeProfileUsageViews.js.map +1 -1
  344. package/dist/utils/claudeProfiles.d.ts +9 -0
  345. package/dist/utils/claudeProfiles.d.ts.map +1 -1
  346. package/dist/utils/claudeProfiles.js +19 -17
  347. package/dist/utils/claudeProfiles.js.map +1 -1
  348. package/dist/utils/claudeStreamJson.d.ts +1 -0
  349. package/dist/utils/claudeStreamJson.d.ts.map +1 -1
  350. package/dist/utils/claudeStreamJson.js +2 -1
  351. package/dist/utils/claudeStreamJson.js.map +1 -1
  352. package/dist/utils/claudeTranscriptContent.d.ts.map +1 -1
  353. package/dist/utils/claudeTranscriptContent.js +2 -1
  354. package/dist/utils/claudeTranscriptContent.js.map +1 -1
  355. package/dist/utils/claudeUsage.d.ts +5 -0
  356. package/dist/utils/claudeUsage.d.ts.map +1 -1
  357. package/dist/utils/claudeUsage.js +1 -0
  358. package/dist/utils/claudeUsage.js.map +1 -1
  359. package/dist/utils/compactSelfReviewFlags.d.ts.map +1 -1
  360. package/dist/utils/compactSelfReviewFlags.js +5 -4
  361. package/dist/utils/compactSelfReviewFlags.js.map +1 -1
  362. package/dist/utils/consoleFileTap.d.ts +11 -5
  363. package/dist/utils/consoleFileTap.d.ts.map +1 -1
  364. package/dist/utils/consoleFileTap.js +55 -18
  365. package/dist/utils/consoleFileTap.js.map +1 -1
  366. package/dist/utils/download.d.ts.map +1 -1
  367. package/dist/utils/download.js +3 -4
  368. package/dist/utils/download.js.map +1 -1
  369. package/dist/utils/fallbackChain.d.ts +4 -2
  370. package/dist/utils/fallbackChain.d.ts.map +1 -1
  371. package/dist/utils/fallbackChain.js +4 -3
  372. package/dist/utils/fallbackChain.js.map +1 -1
  373. package/dist/utils/fallbackSwitchNotice.d.ts +1 -1
  374. package/dist/utils/fallbackSwitchNotice.d.ts.map +1 -1
  375. package/dist/utils/fallbackSwitchNotice.js +4 -3
  376. package/dist/utils/fallbackSwitchNotice.js.map +1 -1
  377. package/dist/utils/fileSendService.js +6 -4
  378. package/dist/utils/fileSendService.js.map +1 -1
  379. package/dist/utils/jsonStreamHost.d.ts +1 -1
  380. package/dist/utils/jsonStreamHost.d.ts.map +1 -1
  381. package/dist/utils/jsonStreamHost.js +6 -5
  382. package/dist/utils/jsonStreamHost.js.map +1 -1
  383. package/dist/utils/jsonStreamUnconsumedInput.d.ts +2 -0
  384. package/dist/utils/jsonStreamUnconsumedInput.d.ts.map +1 -1
  385. package/dist/utils/jsonStreamUnconsumedInput.js.map +1 -1
  386. package/dist/utils/limitsBoardPlan.d.ts +6 -4
  387. package/dist/utils/limitsBoardPlan.d.ts.map +1 -1
  388. package/dist/utils/limitsBoardPlan.js +11 -5
  389. package/dist/utils/limitsBoardPlan.js.map +1 -1
  390. package/dist/utils/midTurnAnswerWatch.d.ts +69 -0
  391. package/dist/utils/midTurnAnswerWatch.d.ts.map +1 -0
  392. package/dist/utils/midTurnAnswerWatch.js +87 -0
  393. package/dist/utils/midTurnAnswerWatch.js.map +1 -0
  394. package/dist/utils/midTurnInbox.d.ts.map +1 -1
  395. package/dist/utils/midTurnInbox.js +9 -8
  396. package/dist/utils/midTurnInbox.js.map +1 -1
  397. package/dist/utils/openCodeCompactPlugin.d.ts +6 -0
  398. package/dist/utils/openCodeCompactPlugin.d.ts.map +1 -1
  399. package/dist/utils/openCodeCompactPlugin.js +46 -7
  400. package/dist/utils/openCodeCompactPlugin.js.map +1 -1
  401. package/dist/utils/openCodeMessageId.d.ts +16 -0
  402. package/dist/utils/openCodeMessageId.d.ts.map +1 -0
  403. package/dist/utils/openCodeMessageId.js +51 -0
  404. package/dist/utils/openCodeMessageId.js.map +1 -0
  405. package/dist/utils/parseEnvFile.d.ts +11 -0
  406. package/dist/utils/parseEnvFile.d.ts.map +1 -0
  407. package/dist/utils/parseEnvFile.js +31 -0
  408. package/dist/utils/parseEnvFile.js.map +1 -0
  409. package/dist/utils/promptDelivery.d.ts +37 -1
  410. package/dist/utils/promptDelivery.d.ts.map +1 -1
  411. package/dist/utils/promptDelivery.js +52 -0
  412. package/dist/utils/promptDelivery.js.map +1 -1
  413. package/dist/utils/rotatingJsonlFile.d.ts.map +1 -1
  414. package/dist/utils/rotatingJsonlFile.js +4 -3
  415. package/dist/utils/rotatingJsonlFile.js.map +1 -1
  416. package/dist/utils/rotatingLogFile.d.ts.map +1 -1
  417. package/dist/utils/rotatingLogFile.js +2 -1
  418. package/dist/utils/rotatingLogFile.js.map +1 -1
  419. package/dist/utils/threadStatusReport.d.ts +2 -0
  420. package/dist/utils/threadStatusReport.d.ts.map +1 -1
  421. package/dist/utils/threadStatusReport.js +4 -3
  422. package/dist/utils/threadStatusReport.js.map +1 -1
  423. package/dist/utils/tmuxExec.d.ts +6 -6
  424. package/dist/utils/tmuxExec.d.ts.map +1 -1
  425. package/dist/utils/tmuxExec.js +9 -9
  426. package/dist/utils/tmuxExec.js.map +1 -1
  427. package/npm-shrinkwrap.json +2 -2
  428. package/package.json +1 -1
package/dist/bot.js CHANGED
@@ -54,6 +54,7 @@ const createAdapter_1 = require("./adapters/createAdapter");
54
54
  const claudeJsonStreamAdapter_1 = require("./adapters/claudeJsonStreamAdapter");
55
55
  const adapterNames_1 = require("./adapters/adapterNames");
56
56
  const resumeContext_1 = require("./resumeContext");
57
+ const midTurnAnswerWatch_1 = require("./utils/midTurnAnswerWatch");
57
58
  const createOutputTransport_1 = require("./connectors/telegram/output/createOutputTransport");
58
59
  const sessionKey_1 = require("./sessionKey");
59
60
  const sessionKeyCodec_1 = require("./connectors/telegram/sessionKeyCodec");
@@ -203,6 +204,7 @@ const instanceSettings_1 = require("./instanceSettings");
203
204
  const taskAgentLimit_1 = require("./trackers/taskAgentLimit");
204
205
  const taskAgentSlots_1 = require("./trackers/taskAgentSlots");
205
206
  const botSkills_1 = require("./utils/botSkills");
207
+ const claudeProfileLabels_1 = require("./utils/claudeProfileLabels");
206
208
  const constants_1 = require("./selfUpdate/constants");
207
209
  const launchEnvironment_1 = require("./selfUpdate/launchEnvironment");
208
210
  const restart_1 = require("./selfUpdate/restart");
@@ -322,6 +324,7 @@ const claudeApiCreditRecheck_1 = require("./utils/claudeApiCreditRecheck");
322
324
  const claudeProfileUsageLines_1 = require("./utils/claudeProfileUsageLines");
323
325
  const resolveBinary_1 = require("./utils/resolveBinary");
324
326
  const runnerSummary_1 = require("./remoteRun/runnerSummary");
327
+ const dataDirFs_1 = require("./dataDirFs");
325
328
  // ═══════════════════════════════════════════════════════════════════════════════
326
329
  // ENV parsing & fatal validation
327
330
  // ═══════════════════════════════════════════════════════════════════════════════
@@ -2079,7 +2082,7 @@ async function announceUsageLimitOrSwitch(key, cls, episodeId, initialWait, atte
2079
2082
  if (plan.action === 'auto') {
2080
2083
  const to = plan.to;
2081
2084
  const outcome = await switchTopicToFallbackEntry(key, plan.from, to, { isAnnounced: true, isAutomatic: true }).catch((e) => {
2082
- console.warn(`[fallback] ${(0, sessionKey_1.keyToString)(key)}: the auto-switch to ${formatFallbackEntry(to)} failed:`, e instanceof Error ? e.message : e);
2085
+ console.warn(`[fallback] ${(0, sessionKey_1.keyToString)(key)}: the auto-switch to ${formatFallbackEntryById(to)} failed:`, e instanceof Error ? e.message : e);
2083
2086
  return { isSwitched: false };
2084
2087
  });
2085
2088
  if (outcome.isSwitched)
@@ -2107,11 +2110,11 @@ function buildFallbackSwitchKeyboard(episodeId, candidates) {
2107
2110
  telegraf_1.Markup.button.callback((0, i18n_1.t)('fallback.switchButton', { label: formatFallbackEntry(entry) }), (0, fallbackChain_1.buildFallbackSwitchCallbackData)(episodeId, index)),
2108
2111
  ]));
2109
2112
  }
2110
- /** Whose API credits a balance notice names: a Claude account `«console»`, an OpenCode `provider/model`. */
2113
+ /** Whose API credits a balance notice names: a Claude account by its display name `«Console»`, an OpenCode `provider/model`. */
2111
2114
  function formatBalanceOwner(from) {
2112
2115
  if (from === null)
2113
2116
  return (0, i18n_1.t)('fallback.backendClaude');
2114
- return from.backend === 'claude' ? `«${from.profile}»` : (0, fallbackChain_1.buildOpenCodeModelLabel)(from);
2117
+ return from.backend === 'claude' ? `«${(0, claudeProfileLabels_1.getClaudeProfileLabel)(from.profile)}»` : (0, fallbackChain_1.buildOpenCodeModelLabel)(from);
2115
2118
  }
2116
2119
  /**
2117
2120
  * @description A used-up API credit balance on `key` («Credit balance is too low», `isBalanceExhausted`): nothing resets
@@ -2161,7 +2164,7 @@ async function handleBalanceExhausted(key, cls) {
2161
2164
  if ((0, sessionKeyCodec_1.checkIsTelegramKey)(key))
2162
2165
  await replyToThread(key, notice);
2163
2166
  outcome = await switchTopicToFallbackEntry(key, plan.from, to, { isAnnounced: true, isAutomatic: true, ending }).catch((e) => {
2164
- console.warn(`[fallback] ${k}: the auto-switch to ${formatFallbackEntry(to)} failed:`, e instanceof Error ? e.message : e);
2167
+ console.warn(`[fallback] ${k}: the auto-switch to ${formatFallbackEntryById(to)} failed:`, e instanceof Error ? e.message : e);
2165
2168
  return { isSwitched: false };
2166
2169
  });
2167
2170
  }
@@ -2483,7 +2486,7 @@ const { cancelPendingLogin, checkIsAuthLoginAwaitingCode, cancelClaudeAuthLogin,
2483
2486
  clearAuthNotice,
2484
2487
  execFileAsync,
2485
2488
  onClaudeProfileAuthStatus: (key, profile, status) => claudeProfileAuthStatusSink?.(key, profile, status) ?? Promise.resolve(),
2486
- onClaudeProfileApiKey: (key, profile, apiKey) => claudeProfileApiKeySink?.(key, profile, apiKey) ?? Promise.resolve((0, i18n_1.t)('account.apiKeyNoDirectory', { name: profile.name })),
2489
+ onClaudeProfileApiKey: (key, profile, apiKey) => claudeProfileApiKeySink?.(key, profile, apiKey) ?? Promise.resolve((0, i18n_1.t)('account.apiKeyNoDirectory', { name: (0, claudeProfileLabels_1.getClaudeProfileLabel)(profile.name) })),
2487
2490
  checkIsProfileMissingFromLimitsList: (name) => (0, fallbackChain_1.checkIsClaudeProfileMissingFromChain)(state.getFallbackChain(), name),
2488
2491
  });
2489
2492
  /**
@@ -5394,6 +5397,16 @@ function handleAgentTurnEnded(key, turnEnd) {
5394
5397
  // resumes the session through the ensure, which queues behind the stop (`requests/README.md` § Turn starts).
5395
5398
  settleEndedTurnsAndHandOver(key);
5396
5399
  }
5400
+ /**
5401
+ * @description A turn took a person's message in mid-turn and ended with no delivered answer after it — no successful call of the
5402
+ * send tools or `answer_request` (an answer in plain text may have gone into a hidden reasoning block, or read like narration): the
5403
+ * conversation is continued at once with one line asking for the answer through the send tool. The line is the
5404
+ * bot's own prompt, never a person's, so its turn arms no watch: one reminder per such turn, never a loop.
5405
+ */
5406
+ function remindMidTurnAnswerMissing(key) {
5407
+ console.log(`[mid-turn] ${(0, sessionKey_1.keyToString)(key)}: a message taken in mid-turn got no answer through the send tools — reminding the agent`);
5408
+ void deliverPromptOrBuffer(key, midTurnAnswerWatch_1.midTurnAnswerReminderPrompt).catch((e) => console.warn(`[mid-turn] ${(0, sessionKey_1.keyToString)(key)}: the reminder was not delivered:`, e instanceof Error ? e.message : e));
5409
+ }
5397
5410
  /**
5398
5411
  * @description Settle `key`'s watches whose turn already ended (`RequestWakeUpEngine.settleEndedTurnsOf`, synchronous up to the
5399
5412
  * decisions) and hand the reminders they decided, once persisted, to a post on its way to its write (`deliverOrHandOverWake`), else
@@ -5467,7 +5480,7 @@ async function replayBufferedPrompts(key) {
5467
5480
  // A guard: the replay writes into the process the start brought up, never an adopted one, so no wake can come up empty here. If
5468
5481
  // one did, the buffer settles the prompt `dropped` — never «replayed» for a prompt no agent got (review 21, own pass).
5469
5482
  if (outcome === 'noSession')
5470
- throw new Error(noSessionForPostError);
5483
+ throw new Error(promptDelivery_1.noSessionForPostError);
5471
5484
  },
5472
5485
  afterReplay: async () => {
5473
5486
  // A command that ends or replaces the conversation runs (a move's own start among them): the held prompts wait for the first
@@ -5511,8 +5524,9 @@ async function replayBufferedPrompts(key) {
5511
5524
  * An adapter without the method forwards directly.
5512
5525
  *
5513
5526
  * Resolves where the prompt went (`LatePromptOutcome`): `forwarded` to the session, `buffered` behind a stop window, `noSession`
5514
- * (nothing to take it; the person was told), `dropped` (a technical prompt found no live idle session). Only a prompt that waited
5515
- * for an adopt replay can come out as anything but `forwarded`; most callers have no use for the answer.
5527
+ * (nothing took it: the topic is told — unless a wake's own notice already said so —, except for a bot-made prompt that the buffer's
5528
+ * re-route after its wait found with no session: that one is only logged), `dropped` (a technical prompt found no live idle session).
5529
+ * Only a prompt that waited for an adopt replay can come out as anything but `forwarded`; most callers have no use for the answer.
5516
5530
  */
5517
5531
  async function forwardPromptToAgent(key, adapter, text, sentAtMs, options = {}) {
5518
5532
  // The next turn begins: an agent that went wrong is no longer stuck (`checkIsTopicStuck`), and its name follows.
@@ -5533,6 +5547,8 @@ async function forwardPromptToAgent(key, adapter, text, sentAtMs, options = {})
5533
5547
  // dropped without a word: never buffered, never a resume, never a "no session" line to the person.
5534
5548
  const isTechnicalPrompt = options.isTechnicalPrompt === true;
5535
5549
  const isPersonInput = options.isPersonInput === true;
5550
+ // Where the buffer port's own routing put a bot-made prompt: one that found no session there answers `noSession` below.
5551
+ const reroute = { delivery: 'forwarded' };
5536
5552
  const outcome = await (0, promptDelivery_1.deliverLatePrompt)({
5537
5553
  isTechnical: isTechnicalPrompt,
5538
5554
  // A post waits again here, after the replay wait: a move may have begun during it (review 28 nit 2).
@@ -5549,16 +5565,16 @@ async function forwardPromptToAgent(key, adapter, text, sentAtMs, options = {})
5549
5565
  buffer: async () => {
5550
5566
  const bufferedText = `${options.requestHeader ?? ''}${getPromptWithThreadMessageContext(key, text, options.messageContext)}`;
5551
5567
  // A post's wait is for this delivery's own routing; the startup buffer keeps none for the replay (`deliverPromptOrBuffer`).
5552
- const bufferedOptions = { isPersonInput: options.isPersonInput, isAccountsNoteCarrier: options.isAccountsNoteCarrier, lostWorkTelling: options.lostWorkTelling, waitBeforeRoute: options.waitBeforeRoute };
5568
+ const bufferedOptions = { isPersonInput: options.isPersonInput, isMidTurnAnswerWatched: options.isMidTurnAnswerWatched, isAccountsNoteCarrier: options.isAccountsNoteCarrier, lostWorkTelling: options.lostWorkTelling, waitBeforeRoute: options.waitBeforeRoute };
5553
5569
  // A person's prompt that is dropped there is told about and closes its request, as at the person's own buffer.
5554
5570
  if (isPersonInput) {
5555
5571
  await deliverPromptOrBuffer(key, bufferedText, createPersonBufferedSettle(key, options.requestId ?? null), bufferedOptions);
5556
5572
  return;
5557
5573
  }
5558
- // A bot-made prompt (a wake-up) that waits here counts only once its replay reached the agent, as at any other buffer.
5559
- const buffered = createBufferedOutcome();
5560
- await deliverPromptOrBuffer(key, bufferedText, buffered.settle, bufferedOptions);
5561
- await buffered.assertReplayed();
5574
+ // A bot-made prompt (a wake-up) that waits here counts only once its replay reached the agent, as at any other buffer. The
5575
+ // delivery routes again after its own `waitBeforeRoute`: a window that closed meanwhile forwards it, or finds no session — kept,
5576
+ // so the caller closes what it opened for the prompt.
5577
+ reroute.delivery = await (0, promptDelivery_1.waitForPromptInSession)((onBufferedSettled) => deliverPromptOrBuffer(key, bufferedText, onBufferedSettled, bufferedOptions));
5562
5578
  },
5563
5579
  wake: () => wakeSleepingSessionForPrompt(key),
5564
5580
  forward: async () => {
@@ -5573,6 +5589,8 @@ async function forwardPromptToAgent(key, adapter, text, sentAtMs, options = {})
5573
5589
  });
5574
5590
  if (outcome === 'dropped')
5575
5591
  console.log(`[adopt] ${(0, sessionKey_1.keyToString)(key)}: the technical prompt found no live, idle session after the replay wait; it is dropped`);
5592
+ if (outcome === 'buffered' && reroute.delivery === 'noSession')
5593
+ return 'noSession';
5576
5594
  return outcome;
5577
5595
  }
5578
5596
  /** @description The forward itself, for a session that is ready to take the prompt: {@link forwardPromptToAgent} minus the replay wait. */
@@ -5713,7 +5731,9 @@ async function forwardPromptToLiveAgent(key, adapter, text, sentAtMs, options =
5713
5731
  // reminder, as its start carried none. Read after the interrupt above, so a person's prompt that ended a bookkeeping turn is judged
5714
5732
  // on its own.
5715
5733
  getLimitNotes().noteTurnStart(key, { isBookkeeping: options.isAccountsNoteCarrier !== true && !isSlashCommand, isSessionIdle: adapter.checkIsBusy?.(key) === false });
5716
- const written = adapter.sendInputAndWait ? adapter.sendInputAndWait(key, promptText) : (adapter.sendInput(key, promptText), Promise.resolve());
5734
+ // A watched message (decided at the person's write) that the backend takes into a running turn has its answer watched.
5735
+ const sendInputOptions = { isMidTurnAnswerWatched: options.isMidTurnAnswerWatched === true };
5736
+ const written = adapter.sendInputAndWait ? adapter.sendInputAndWait(key, promptText, sendInputOptions) : (adapter.sendInput(key, promptText, sendInputOptions), Promise.resolve());
5717
5737
  // S2 busy-onset arm: start the Claude liveness loop the moment the prompt is
5718
5738
  // forwarded — driven by `checkIsBusy`, not by waiting for an opportunistic
5719
5739
  // scrape emit that may never come during a long quiet think. The arming grace
@@ -6539,7 +6559,7 @@ async function createWorkFolder(key, rawName) {
6539
6559
  const targetPath = path.join(ENV.workRoot, validated.name);
6540
6560
  const alreadyExisted = fs.existsSync(targetPath);
6541
6561
  try {
6542
- fs.mkdirSync(targetPath, { recursive: true });
6562
+ dataDirFs_1.dataDirFs.mkdirSync(targetPath, { recursive: true });
6543
6563
  }
6544
6564
  catch (e) {
6545
6565
  await replyToThread(key, (0, i18n_1.t)('bind.create_failed', {
@@ -7885,7 +7905,8 @@ async function deliverClaudeAccountAlert(alert) {
7885
7905
  posts.push(postClaudeAccountAlertToTelegram(alert));
7886
7906
  const isActionRequired = alert.lost.length > 0;
7887
7907
  for (const channel of operatorAlertChannels) {
7888
- const text = (0, i18n_1.runWithLocale)('en', () => (0, claudeAccountAlert_1.renderClaudeAccountAlert)(alert, getHostClaudeSignInHow));
7908
+ // The connectors' channels render Markdown (a Jira comment): the operator's free-text names are escaped there.
7909
+ const text = (0, i18n_1.runWithLocale)('en', () => (0, claudeAccountAlert_1.renderClaudeAccountAlert)(alert, getHostClaudeSignInHow, { formatLabel: claudeProfileLabels_1.escapeClaudeProfileLabelForMarkdown }));
7889
7910
  posts.push(channel.post(text, { isActionRequired }).then((result) => {
7890
7911
  if (!result.ok)
7891
7912
  console.warn(`[accounts] the operator alert did not reach ${channel.label}: ${result.error}`);
@@ -7895,7 +7916,7 @@ async function deliverClaudeAccountAlert(alert) {
7895
7916
  }
7896
7917
  /**
7897
7918
  * @description The account alert in General, like the updater's: worded in that chat's language, the sign-in named as
7898
- * `/accounts login <name>`; an alert that asks to act is pinned (the pin is what reaches a muted operator) in place of the previous
7919
+ * `/accounts login <display name>` (its id when that name would find another account); an alert that asks to act is pinned (the pin is what reaches a muted operator) in place of the previous
7899
7920
  * one, and once no told account is left unusable the pin goes. `isPrivateChatClosed`: Telegram refused the private message about a
7900
7921
  * signed-out account (403) — the alert then also asks the operator to open a private chat with the bot.
7901
7922
  */
@@ -7906,7 +7927,7 @@ async function postClaudeAccountAlertToGeneral(alert, options) {
7906
7927
  return;
7907
7928
  }
7908
7929
  const renderOptions = options.isPrivateChatClosed ? { closedPrivateChatBot: getBotLabel() } : {};
7909
- const text = withThreadLocale(generalKey, () => (0, claudeAccountAlert_1.renderClaudeAccountAlert)(alert, (name) => `/accounts login ${name}`, renderOptions));
7930
+ const text = withThreadLocale(generalKey, () => (0, claudeAccountAlert_1.renderClaudeAccountAlert)(alert, (name) => `/accounts login ${(0, claudeProfileLabels_1.getClaudeProfileCommandName)(name)}`, renderOptions));
7910
7931
  const messageId = await replyToThread(generalKey, text);
7911
7932
  if (alert.lost.length === 0 || messageId === null) {
7912
7933
  await releaseClaudeAccountAlertPin();
@@ -7984,7 +8005,7 @@ async function settleClaudeAccountSignOutDms(alert) {
7984
8005
  */
7985
8006
  async function markClaudeAccountSignOutDmSignedIn(privateKey, name, messageId) {
7986
8007
  await state.setClaudeAccountAlertSignOutMessageId(name, null);
7987
- const text = withThreadLocale(privateKey, () => (0, i18n_1.t)('accounts.alert.back', { name }));
8008
+ const text = withThreadLocale(privateKey, () => (0, i18n_1.t)('accounts.alert.back', { name: (0, claudeProfileLabels_1.getClaudeProfileLabel)(name) }));
7988
8009
  if (await editThreadMessage(privateKey, messageId, text))
7989
8010
  console.log(`[accounts] the private message about ${name} now says it is signed in again`);
7990
8011
  else
@@ -8081,7 +8102,8 @@ async function handleClaudeAuthRefusal(key, cls) {
8081
8102
  if (!(0, sessionKeyCodec_1.checkIsTelegramKey)(key) && requestLimitWaitAnswerDeps) {
8082
8103
  await (0, limitWaitAnswer_1.answerOpenRequestsWithBotNotice)(requestLimitWaitAnswerDeps, key, {
8083
8104
  identity: `claudeAccountMove:${instead}`,
8084
- body: (0, i18n_1.t)('requests.account.movedAnswer', { from: from.profile, reason: (0, claudeAccountAlert_1.formatClaudeAccountRefusal)(reason), to: instead }),
8105
+ // A tracker's comment renders Markdown: the operator's free-text names are escaped.
8106
+ body: (0, i18n_1.t)('requests.account.movedAnswer', { from: (0, claudeProfileLabels_1.escapeClaudeProfileLabelForMarkdown)((0, claudeProfileLabels_1.getClaudeProfileLabel)(from.profile)), reason: (0, claudeAccountAlert_1.formatClaudeAccountRefusal)(reason), to: (0, claudeProfileLabels_1.escapeClaudeProfileLabelForMarkdown)((0, claudeProfileLabels_1.getClaudeProfileLabel)(instead)) }),
8085
8107
  isWakeStopped: false,
8086
8108
  }).catch((e) => console.warn(`[accounts] ${k}: telling the requests about the move failed:`, e instanceof Error ? e.message : e));
8087
8109
  }
@@ -8109,7 +8131,7 @@ async function waitForClaudeAccount(key) {
8109
8131
  }
8110
8132
  const reasons = getClaudeProfileUsageViews()
8111
8133
  .map((view) => ({ name: view.name, usability: (0, claudeAuthRefusal_1.getClaudeProfileUsability)(state.getClaudeProfileInfo(view.name)) }))
8112
- .flatMap(({ name, usability }) => (usability === 'usable' ? [] : [`«${name}» ${(0, claudeAccountAlert_1.formatClaudeAccountRefusal)(usability)}`]))
8134
+ .flatMap(({ name, usability }) => (usability === 'usable' ? [] : [`«${(0, claudeProfileLabels_1.escapeClaudeProfileLabelForMarkdown)((0, claudeProfileLabels_1.getClaudeProfileLabel)(name))}» ${(0, claudeAccountAlert_1.formatClaudeAccountRefusal)(usability)}`]))
8113
8135
  .join('; ');
8114
8136
  await (0, limitWaitAnswer_1.answerOpenRequestsWithBotNotice)(requestLimitWaitAnswerDeps, key, {
8115
8137
  // One wait, one answer per request: a later refused turn of the same wait (a new request's prompt) answers only the new request.
@@ -8366,7 +8388,7 @@ function getClaudeProfileUsageViews() {
8366
8388
  }
8367
8389
  /** One profile's usage view — the very one `/limits` renders, for the rows of `/accounts`. */
8368
8390
  function getClaudeProfileUsageView(name) {
8369
- return (0, claudeProfileUsageViews_1.buildClaudeProfileUsageView)({ dataDir: (0, state_1.resolveDataDir)(), name, record: state.getClaudeProfileInfo(name), creditAnchor: syncClaudeApiCreditAnchors()[name] });
8391
+ return (0, claudeProfileUsageViews_1.buildClaudeProfileUsageView)({ dataDir: (0, state_1.resolveDataDir)(), name, record: state.getClaudeProfileInfo(name), creditAnchor: syncClaudeApiCreditAnchors()[name], records: state.getAllClaudeProfileInfos() });
8370
8392
  }
8371
8393
  /** The model a topic's Claude session runs (or last ran), for the usage ranking's choice of windows. */
8372
8394
  function getThreadClaudeModel(key) {
@@ -8377,7 +8399,7 @@ function readStatusAccountSource(name) {
8377
8399
  syncClaudeApiCreditAnchors();
8378
8400
  const info = state.getClaudeProfileInfo(name);
8379
8401
  return {
8380
- name, email: info?.email ?? null, loggedIn: (0, claudeAuthRefusal_1.getClaudeProfileSignedIn)(info), limitedUntil: info?.limitedUntil ?? null,
8402
+ name, label: (0, claudeProfileLabels_1.getClaudeProfileLabel)(name), email: info?.email ?? null, loggedIn: (0, claudeAuthRefusal_1.getClaudeProfileSignedIn)(info), limitedUntil: info?.limitedUntil ?? null,
8381
8403
  billing: info?.billing ?? null, creditExhaustedAt: info?.creditExhaustedAt ?? null, ...(info?.apiSpend ? { apiSpend: info.apiSpend } : {}),
8382
8404
  };
8383
8405
  }
@@ -8387,8 +8409,15 @@ function checkIsClaudeProfileBackend(key) {
8387
8409
  return adapter instanceof claudeJsonStreamAdapter_1.ClaudeJsonStreamAdapter || adapter instanceof claudeCliAdapter_1.ClaudeCliAdapter;
8388
8410
  }
8389
8411
  // ── the fallback chain (`/fallback`): `utils/fallbackChain.ts`, `utils/fallbackBridge.ts`, `commands/fallbackChain.ts` ──
8390
- /** A chain rung for the topic's own language (the picker and the notices name it the same way). */
8412
+ /** A chain rung for the topic's own language (the picker and the notices name it the same way: an account by its display name). */
8391
8413
  function formatFallbackEntry(entry) {
8414
+ return (0, fallbackChain_1.formatFallbackEntryLabel)(entry, { claude: (0, i18n_1.t)('fallback.backendClaude'), openCode: (0, i18n_1.t)('fallback.backendOpenCode'), topicModel: (0, i18n_1.t)('fallback.topicModel'), profileLabel: claudeProfileLabels_1.getClaudeProfileLabel });
8415
+ }
8416
+ /**
8417
+ * A chain rung for the log and for the agent's context bridge: the same words, an account by its fixed id — what agents record and pass
8418
+ * to `claude_profiles` (a display name may change, and may hold an email).
8419
+ */
8420
+ function formatFallbackEntryById(entry) {
8392
8421
  return (0, fallbackChain_1.formatFallbackEntryLabel)(entry, { claude: (0, i18n_1.t)('fallback.backendClaude'), openCode: (0, i18n_1.t)('fallback.backendOpenCode'), topicModel: (0, i18n_1.t)('fallback.topicModel') });
8393
8422
  }
8394
8423
  /**
@@ -8551,9 +8580,9 @@ async function planFallbackSwitch(key, cls, episodeId) {
8551
8580
  fallbackSwitchOffers.set(k, { episodeId, from, candidates: plan.candidates });
8552
8581
  else
8553
8582
  fallbackSwitchOffers.delete(k);
8554
- const detail = plan.action === 'auto' ? ` → ${formatFallbackEntry(plan.to)}` : plan.action === 'offer' ? ` [${plan.candidates.map(formatFallbackEntry).join(', ')}]` : '';
8583
+ const detail = plan.action === 'auto' ? ` → ${formatFallbackEntryById(plan.to)}` : plan.action === 'offer' ? ` [${plan.candidates.map(formatFallbackEntryById).join(', ')}]` : '';
8555
8584
  // Nothing has room: the wait should end on the rung whose limit resets EARLIEST, not necessarily this one.
8556
- console.log(`[fallback] ${k}: usage limit on ${formatFallbackEntry(from)}; switch plan: ${plan.action}${detail}${waitTarget ? `; earliest reset: ${formatFallbackEntry(waitTarget.entry)} at ${new Date(waitTarget.untilMs).toISOString()}` : ''}`);
8585
+ console.log(`[fallback] ${k}: usage limit on ${formatFallbackEntryById(from)}; switch plan: ${plan.action}${detail}${waitTarget ? `; earliest reset: ${formatFallbackEntryById(waitTarget.entry)} at ${new Date(waitTarget.untilMs).toISOString()}` : ''}`);
8557
8586
  return { ...plan, from, earliest: waitTarget };
8558
8587
  }
8559
8588
  /** When the rung that hit the limit comes back, as a clock in the topic's zone; `null` when unknown or past. */
@@ -8577,7 +8606,7 @@ function getFallbackSwitchedNotice(from, to, runningModel, reason = 'limit') {
8577
8606
  const info = to.backend === 'claude' ? state.getClaudeProfileInfo(to.profile) : undefined;
8578
8607
  if (to.backend !== 'claude' || info?.billing !== 'api')
8579
8608
  return notice;
8580
- return `${notice}\n${(0, i18n_1.t)('fallback.switchedToApi', { name: to.profile, spent: (0, claudeApiSpend_1.formatUsd)(info.apiSpend?.totalUsd ?? 0) })}`;
8609
+ return `${notice}\n${(0, i18n_1.t)('fallback.switchedToApi', { name: (0, claudeProfileLabels_1.getClaudeProfileLabel)(to.profile), spent: (0, claudeApiSpend_1.formatUsd)(info.apiSpend?.totalUsd ?? 0) })}`;
8581
8610
  }
8582
8611
  /** The spend line a «credits used up» notice ends with (what the account spent through the bot); `''` before any spend. */
8583
8612
  function getBalanceSpentLine(from) {
@@ -8686,7 +8715,6 @@ async function switchTopicToFallbackEntry(key, from, to, options) {
8686
8715
  async function switchTopicToFallbackEntryNow(key, from, to, options) {
8687
8716
  const reason = options.reason ?? 'limit';
8688
8717
  const k = (0, sessionKey_1.keyToString)(key);
8689
- const fromLabel = from ? formatFallbackEntry(from) : '?';
8690
8718
  const toLabel = formatFallbackEntry(to);
8691
8719
  const runningModel = readRunningModelBeforeMove(key, from, to);
8692
8720
  // The notice is a topic message: a conversation of another platform (a Jira issue) hears nothing — the log line below says it — and
@@ -8742,8 +8770,8 @@ async function switchTopicToFallbackEntryNow(key, from, to, options) {
8742
8770
  let bridge;
8743
8771
  try {
8744
8772
  bridge = await buildFallbackBridge(key, {
8745
- fromLabel: from ? formatFallbackEntry(from) : formatThreadBackend(key),
8746
- toLabel: toLabel,
8773
+ fromLabel: from ? formatFallbackEntryById(from) : formatThreadBackend(key),
8774
+ toLabel: formatFallbackEntryById(to),
8747
8775
  reason: 'limit',
8748
8776
  resetsAtText: getFallbackResetTime(from),
8749
8777
  });
@@ -8769,7 +8797,7 @@ async function switchTopicToFallbackEntryNow(key, from, to, options) {
8769
8797
  try {
8770
8798
  cancelApiRetry(key); // retires the offer too: the switch consumed it
8771
8799
  const notice = `${getFallbackSwitchedNotice(from, to, runningModel, reason)}${isStoppingBackground ? `\n${(0, i18n_1.t)('fallback.backgroundStopped')}` : ''}`;
8772
- console.log(`[fallback] ${k}: switched from ${fromLabel} to ${toLabel} after ${reason === 'signIn' ? 'its account was refused' : 'a usage limit'}${firstPrompt ? ' (cross-backend, bridged)' : ''}; resuming`);
8800
+ console.log(`[fallback] ${k}: switched from ${from ? formatFallbackEntryById(from) : '?'} to ${formatFallbackEntryById(to)} after ${reason === 'signIn' ? 'its account was refused' : 'a usage limit'}${firstPrompt ? ' (cross-backend, bridged)' : ''}; resuming`);
8773
8801
  await say(notice);
8774
8802
  await resumeTopicOnNewSession(key, {
8775
8803
  modelToPin: (0, fallbackChain_1.getFallbackModelToPin)(to, runningModel),
@@ -9012,7 +9040,7 @@ async function switchTopicByOperator(key, to) {
9012
9040
  return { kind: 'refused', text: moved.notice };
9013
9041
  if (to.backend === 'opencode')
9014
9042
  return { kind: 'switched', text: (0, i18n_1.t)('backendSwitch.switched', { to: label }), label };
9015
- return { kind: 'switched', text: (0, i18n_1.t)('account.setThisTopic', { name: to.profile, apply: (0, i18n_1.t)(`account.applied.${moved.isSwitched ? 'respawned' : 'deferred'}`) }), label };
9043
+ return { kind: 'switched', text: (0, i18n_1.t)('account.setThisTopic', { name: (0, claudeProfileLabels_1.getClaudeProfileLabel)(to.profile), apply: (0, i18n_1.t)(`account.applied.${moved.isSwitched ? 'respawned' : 'deferred'}`) }), label };
9016
9044
  }
9017
9045
  case 'sameFamily': {
9018
9046
  if (to.backend === 'opencode') {
@@ -9027,7 +9055,7 @@ async function switchTopicByOperator(key, to) {
9027
9055
  if (!isModelChangeOnly) {
9028
9056
  await state.setClaudeProfileOverride(key, to.profile);
9029
9057
  const outcome = await applyClaudeProfileToThread(key);
9030
- switchedText = (0, i18n_1.t)('account.setThisTopic', { name: to.profile, apply: (0, i18n_1.t)(`account.applied.${outcome}`) });
9058
+ switchedText = (0, i18n_1.t)('account.setThisTopic', { name: (0, claudeProfileLabels_1.getClaudeProfileLabel)(to.profile), apply: (0, i18n_1.t)(`account.applied.${outcome}`) });
9031
9059
  }
9032
9060
  const modelToPin = (0, fallbackChain_1.getFallbackModelToPin)(to, runningModel);
9033
9061
  if (modelToPin === null)
@@ -9560,10 +9588,11 @@ command(escapeCommandNames, async (ctx, key) => {
9560
9588
  // A talker's /esc only interrupts the running turn: the prompts below are an admin's (a sign-in, a name for an account or a
9561
9589
  // topic), and ending one is the admin's own word.
9562
9590
  if ((await authoriseTopicSpeaker(ctx))?.role !== 'talker') {
9563
- // A pending «Add account» name prompt, a pending sign-in (`/login`, `/connect` OAuth) and a `/topic` wizard take
9564
- // priority: the first /esc only cancels it, so the topic stops waiting for typed input.
9565
- if (cancelProfileNameCapture(key)) {
9566
- await replyToThread(key, (0, i18n_1.t)('account.askNameCancelled'));
9591
+ // A pending «Add account» name prompt (or ✏️'s new name), a pending sign-in (`/login`, `/connect` OAuth) and a `/topic` wizard
9592
+ // take priority: the first /esc only cancels it, so the topic stops waiting for typed input.
9593
+ const cancelledCapture = cancelProfileNameCapture(key);
9594
+ if (cancelledCapture !== null) {
9595
+ await replyToThread(key, (0, i18n_1.t)(cancelledCapture === 'rename' ? 'account.renameCancelled' : 'account.askNameCancelled'));
9567
9596
  return;
9568
9597
  }
9569
9598
  if (cancelPendingLogin(key)) {
@@ -10356,7 +10385,7 @@ async function processVoiceJob(key, fileId, durationSeconds, requesterId, warmed
10356
10385
  return;
10357
10386
  }
10358
10387
  const result = await transcribeVoiceFile(key, tempFile, durationSeconds, warmedEndpoint);
10359
- fs.unlink(tempFile, () => { });
10388
+ dataDirFs_1.dataDirFs.unlink(tempFile, () => { });
10360
10389
  // Text or failure — either way the wait is over. The note is gone BEFORE the echo or the failure notice goes out (the finish is
10361
10390
  // bounded, so a stalled delete holds the answer back for a moment at most; what it cut short ends in the background).
10362
10391
  await progressNote.finish();
@@ -10543,7 +10572,7 @@ async function downloadIncomingFile(ctx, key, meta, onError) {
10543
10572
  */
10544
10573
  const promptDeliveryDeps = {
10545
10574
  startupBuffer: startupPromptBuffer,
10546
- forwardPrompt: (key, text, options) => forwardPromptToAgent(key, (0, createAdapter_1.getThreadAdapter)(key), text, undefined, { isPersonInput: options.isPersonInput, isAccountsNoteCarrier: options.isAccountsNoteCarrier, lostWorkTelling: options.lostWorkTelling, waitBeforeRoute: options.waitBeforeRoute }),
10575
+ forwardPrompt: (key, text, options) => forwardPromptToAgent(key, (0, createAdapter_1.getThreadAdapter)(key), text, undefined, { isPersonInput: options.isPersonInput, isMidTurnAnswerWatched: options.isMidTurnAnswerWatched, isAccountsNoteCarrier: options.isAccountsNoteCarrier, lostWorkTelling: options.lostWorkTelling, waitBeforeRoute: options.waitBeforeRoute }),
10547
10576
  checkIsSessionActive: (key) => checkIsAcceptingInput(key),
10548
10577
  // A tracker conversation has no topic to say a resume's notice in: it is logged.
10549
10578
  wakeSession: (key) => ((0, sessionKeyCodec_1.checkIsTelegramKey)(key)
@@ -11668,6 +11697,8 @@ function checkIsPersonPromptRefused(key, requestId) {
11668
11697
  function deliverPersonPromptAtWrite(key, text, options) {
11669
11698
  const { opening, sentAtMs, messageContext, isAccountsNoteCarrier } = options;
11670
11699
  const { header: requestHeader, requestId } = opening;
11700
+ // Decided once, here, where the request is known; the buffered and the forwarded paths carry it.
11701
+ const isMidTurnAnswerWatched = (0, midTurnAnswerWatch_1.checkIsMidTurnAnswerWatched)({ isPersonInput: true, requestId }, state.getDisplayPrefs(key).view);
11671
11702
  return (0, promptDelivery_1.deliverLatePrompt)({
11672
11703
  checkIsWindowOpen: () => startupPromptBuffer.checkIsStarting((0, sessionKey_1.keyToString)(key)),
11673
11704
  checkIsSessionActive: () => checkIsAcceptingInput(key),
@@ -11679,10 +11710,10 @@ function deliverPersonPromptAtWrite(key, text, options) {
11679
11710
  reportRefused: () => reportDroppedPersonPrompt(key, requestId, true),
11680
11711
  buffer: async () => {
11681
11712
  const bufferedText = `${requestHeader}${getPromptWithThreadMessageContext(key, text, messageContext)}`;
11682
- await deliverPromptOrBuffer(key, bufferedText, createPersonBufferedSettle(key, requestId), { isPersonInput: true, isAccountsNoteCarrier });
11713
+ await deliverPromptOrBuffer(key, bufferedText, createPersonBufferedSettle(key, requestId), { isPersonInput: true, isMidTurnAnswerWatched, isAccountsNoteCarrier });
11683
11714
  },
11684
11715
  wake: () => wakeSleepingSessionForPrompt(key),
11685
- forward: () => forwardPromptToAgent(key, (0, createAdapter_1.getThreadAdapter)(key), text, sentAtMs, { messageContext, requestHeader, requestId, isPersonInput: true, isAccountsNoteCarrier }),
11716
+ forward: () => forwardPromptToAgent(key, (0, createAdapter_1.getThreadAdapter)(key), text, sentAtMs, { messageContext, requestHeader, requestId, isPersonInput: true, isMidTurnAnswerWatched, isAccountsNoteCarrier }),
11686
11717
  reportNoSession: async (isAlreadyTold) => {
11687
11718
  if (!isAlreadyTold)
11688
11719
  await replyToThread(key, (0, i18n_1.t)('agent.no_session'));
@@ -13251,44 +13282,15 @@ async function resumeConversationForLostWork(key) {
13251
13282
  await state.setLostWork(key, (0, lostWork_1.mergeLostWorkRecords)(state.getLostWork(key), record));
13252
13283
  return false;
13253
13284
  }
13254
- /** Why a session post failed when its prompt found no session at the write and nothing to wake (`deliverPromptOrBuffer` → `noSession`). */
13255
- const noSessionForPostError = 'the session went away before the prompt was written, and nothing could be woken for it';
13256
13285
  /** The session post of a lost-work note: a bot note to the agent, not a request — no request is opened for it. */
13257
13286
  function createLostWorkPostDeps() {
13258
13287
  return {
13259
13288
  ...createSessionPostDeps(),
13260
13289
  forwardPrompt: async (conversationKey, text) => {
13261
- const buffered = createBufferedOutcome();
13262
- const delivery = await deliverPostPrompt((0, sessionKey_1.keyFromString)(conversationKey), text, buffered.settle);
13263
- if (delivery === 'buffered')
13264
- await buffered.assertReplayed();
13265
- if (delivery === 'noSession')
13266
- throw new Error(noSessionForPostError);
13267
- },
13268
- };
13269
- }
13270
- /**
13271
- * @description How a prompt that waited in the startup buffer ended, for a post that must know it reached the session:
13272
- * `settle` is the buffer's callback; `getOutcome` resolves with that outcome (`replayed` or `dropped`) for a caller that acts on
13273
- * either (the scheduler's request a fire opened closes on `dropped`); `assertReplayed` resolves once it was replayed into the session
13274
- * and rejects when it was dropped — the start failed, or its write did not reach the agent.
13275
- */
13276
- function createBufferedOutcome() {
13277
- let settle = () => { };
13278
- const outcome = new Promise((resolve) => {
13279
- settle = resolve;
13280
- });
13281
- return {
13282
- settle: (result) => settle(result),
13283
- getOutcome: () => outcome,
13284
- assertReplayed: async () => {
13285
- if ((await outcome) !== 'replayed')
13286
- throw new Error(bufferedPromptDroppedError);
13290
+ await (0, promptDelivery_1.deliverPromptToSession)((onBufferedSettled) => deliverPostPrompt((0, sessionKey_1.keyFromString)(conversationKey), text, onBufferedSettled));
13287
13291
  },
13288
13292
  };
13289
13293
  }
13290
- /** Why a post whose prompt waited for a session start failed: the window dropped it. */
13291
- const bufferedPromptDroppedError = 'the prompt waited for the session to start and never reached the agent';
13292
13294
  function handleAgentError(key, error) {
13293
13295
  console.error(`[Bot] adapter error ${(0, sessionKey_1.keyToString)(key)}:`, error.message);
13294
13296
  topicsStuckUntilNextTurn.add((0, sessionKey_1.keyToString)(key));
@@ -14528,7 +14530,7 @@ async function forwardRequestWakeUp(key, _request, message) {
14528
14530
  // A wake that waited for an adopted session's replay and then found no session reached no agent: a failed wake (a post retry later,
14529
14531
  // the backstop for a restart wake, else `wakeFailed`), never a delivered one whose turn the engine would watch (review 21, own pass).
14530
14532
  if (outcome === 'noSession')
14531
- throw new Error(noSessionForPostError);
14533
+ throw new Error(promptDelivery_1.noSessionForPostError);
14532
14534
  }
14533
14535
  /**
14534
14536
  * @description Remind the agent, in its own session, of what it wrote after its
@@ -14640,14 +14642,9 @@ function createSessionPostDeps() {
14640
14642
  return { ok: false, reason };
14641
14643
  },
14642
14644
  forwardPrompt: async (conversationKey, text) => {
14643
- const buffered = createBufferedOutcome();
14644
- const delivery = await deliverPostPrompt((0, sessionKey_1.keyFromString)(conversationKey), text, buffered.settle, { isAccountsNoteCarrier: true });
14645
- // A prompt that waited for the session's start counts only once it reached it: a replay whose write failed is a failed post.
14646
- if (delivery === 'buffered')
14647
- await buffered.assertReplayed();
14648
- // The session the post ensured went to sleep before the write, and nothing could be woken for it: no turn will take the prompt.
14649
- if (delivery === 'noSession')
14650
- throw new Error(noSessionForPostError);
14645
+ // A prompt that waited for the session's start counts only once it reached it (a replay whose write failed is a failed post), and
14646
+ // one whose session went to sleep before the write with nothing to wake fails the post: no turn will take it.
14647
+ await (0, promptDelivery_1.deliverPromptToSession)((onBufferedSettled) => deliverPostPrompt((0, sessionKey_1.keyFromString)(conversationKey), text, onBufferedSettled, { isAccountsNoteCarrier: true }));
14651
14648
  },
14652
14649
  // The watches whose turn ended are settled before the post picks a request and builds its text; the reminders they decided, and the
14653
14650
  // ones handed to the post while it waited, are delivered after the post's own write (`requests/README.md` § Turn starts).
@@ -14714,16 +14711,12 @@ async function forwardScheduledRun(conversationKey, text, ridden) {
14714
14711
  const key = (0, sessionKey_1.keyFromString)(conversationKey);
14715
14712
  // Read in the tick of the pick (the caller picked `ridden` and called here with no await between).
14716
14713
  const headerRequest = getScheduledRunHeaderRequest(key, ridden?.requestId ?? null);
14717
- const buffered = createBufferedOutcome();
14718
14714
  // A tracker fire whose ridden request owes nothing, or with none open: its header says when to answer, so a lost-work note riding it
14719
14715
  // defers to it and claims no watch (a comment notifies the requester and the issue's watchers). A topic keeps its own resume and wording.
14720
14716
  const lostWorkTelling = !(0, sessionKeyCodec_1.checkIsTelegramKey)(key) && ridden?.isAnswerOwed !== true ? 'runHeader' : 'plain';
14721
- const delivery = await deliverPostPrompt(key, text, buffered.settle, { isAccountsNoteCarrier: true, lostWorkTelling }, headerRequest);
14722
- // A prompt that waited for the session's start counts only once it reached it: a replay whose write failed is a failed post.
14723
- if (delivery === 'buffered')
14724
- await buffered.assertReplayed();
14725
- if (delivery === 'noSession')
14726
- throw new Error(noSessionForPostError);
14717
+ // A prompt that waited for the session's start counts only once it reached it: a replay whose write failed is a failed post, and so
14718
+ // is one that found no session. It fails before any watch is made.
14719
+ await (0, promptDelivery_1.deliverPromptToSession)((onBufferedSettled) => deliverPostPrompt(key, text, onBufferedSettled, { isAccountsNoteCarrier: true, lostWorkTelling }, headerRequest));
14727
14720
  if (ridden !== null) {
14728
14721
  await requestWakeUpEngine?.trackForwardedTurn(key, ridden.requestId, { isRequestPrompt: false, isScheduledRun: true, isRequestJob: ridden.isRequestJob });
14729
14722
  }
@@ -14731,28 +14724,40 @@ async function forwardScheduledRun(conversationKey, text, ridden) {
14731
14724
  /**
14732
14725
  * @description A topic's scheduled run with no request to ride (`pickTopicRunTarget` → `ownRequest`): open the scheduler's request
14733
14726
  * (S7, the scheduler's requester — it replaces only one the bot gave up on), forward the prompt behind its header and settle it as
14734
- * the request's own scheduled run — the turn is tracked as one. A prompt that never reached the agent (its window dropped it, or it
14735
- * found no session) closes the request nobody was told about and fails the post, as {@link forwardScheduledRun} does (review 21 #2).
14727
+ * the request's own scheduled run — the turn is tracked as one. A prompt that never reached the agent (its window dropped it — an adopt
14728
+ * replay's re-route's too —, it found no session, or its write failed) closes the request nobody was told about and fails the post, as
14729
+ * {@link forwardScheduledRun} does (review 21 #2).
14736
14730
  */
14737
14731
  async function forwardTopicSchedulerRequestRun(conversationKey, text) {
14738
14732
  const key = (0, sessionKey_1.keyFromString)(conversationKey);
14739
14733
  // Read at the pick, ahead of the open: a command during the open's flush closes the request it opens, and counts.
14740
14734
  const refusalSerialAtPick = conversationEndings.readRefusalSerial(conversationKey);
14741
14735
  const opening = await openTopicRequest(key, text, { source: 'scheduledRun', requesterId: topicRequest_1.scheduledRunRequester });
14742
- const buffered = createBufferedOutcome();
14736
+ const buffered = (0, promptDelivery_1.createBufferedOutcome)();
14743
14737
  const headerRequest = getScheduledRunHeaderRequest(key, opening.requestId, refusalSerialAtPick);
14744
- const delivery = await deliverPostPrompt(key, `${opening.header}${text}`, buffered.settle, { isAccountsNoteCarrier: true }, headerRequest);
14738
+ let delivery;
14739
+ try {
14740
+ delivery = await deliverPostPrompt(key, `${opening.header}${text}`, buffered.settle, { isAccountsNoteCarrier: true }, headerRequest);
14741
+ }
14742
+ catch (error) {
14743
+ // The post failed before it could say where the prompt went: a write that failed, or a prompt an adopt replay's re-route buffered and
14744
+ // its window dropped. The scheduler's request nobody was told about closes as one that found no session. A request a command closed
14745
+ // (the header's own, refused before the routing) is closed already.
14746
+ if (!(error instanceof delivery_1.ScheduledRunTargetClosedError))
14747
+ await settleTopicRequestAfterDelivery(key, opening, 'noSession');
14748
+ throw error;
14749
+ }
14745
14750
  // A prompt that waited for the session's start counts only once it reached it, and only then is its turn watched (a watch made in
14746
14751
  // the window would wait for good if the window dropped it). Dropped, the scheduler's request nobody was told about closes like one
14747
14752
  // that found no session, and the post fails.
14748
14753
  if (delivery === 'buffered' && (await buffered.getOutcome()) === 'dropped') {
14749
14754
  await settleTopicRequestAfterDelivery(key, opening, 'noSession');
14750
- throw new Error(bufferedPromptDroppedError);
14755
+ throw new Error(promptDelivery_1.bufferedPromptDroppedError);
14751
14756
  }
14752
14757
  await settleTopicRequestAfterDelivery(key, { ...opening, isScheduledRun: true }, delivery);
14753
14758
  // Closed by the settle when no session was left to take the prompt: the post fails, not read as delivered.
14754
14759
  if (delivery === 'noSession')
14755
- throw new Error(noSessionForPostError);
14760
+ throw new Error(promptDelivery_1.noSessionForPostError);
14756
14761
  }
14757
14762
  /**
14758
14763
  * @description Construct the scheduler stack (S8): run ledger → delivery (thin
@@ -15251,6 +15256,8 @@ async function startBot() {
15251
15256
  (0, createAdapter_1.registerClaudeConfigDirReader)(resolveThreadClaudeConfigDir);
15252
15257
  // The «Bot skills» switch (`/bot_skills`): every agent start, the OpenCode server's start and the bot MCP's instructions read it.
15253
15258
  (0, botSkills_1.setBotSkillsReader)(botSkillsReader);
15259
+ // Every screen that names a Claude account shows its display name (`/accounts` ✏️), read live off the registry.
15260
+ (0, claudeProfileLabels_1.setClaudeProfileLabelReader)(() => state.getAllClaudeProfileInfos());
15254
15261
  // The flags the CLI's and OpenCode's own compactions read for `/compact_self_review` follow the saved settings from the start.
15255
15262
  syncAllCompactSelfReviewFlags();
15256
15263
  (0, createAdapter_1.registerClaudeRateLimitSink)(onClaudeRateLimitEvent);
@@ -15477,6 +15484,7 @@ async function startBot() {
15477
15484
  void todoReminderEngine?.noteAdapterTurnEnd(key).catch((e) => console.warn(`[todos] the turn end of ${(0, sessionKey_1.keyToString)(key)} was not noted:`, e instanceof Error ? e.message : e));
15478
15485
  handleAgentTurnEnded(key, turnEnd);
15479
15486
  }),
15487
+ onMidTurnAnswerMissing: (key) => (0, adapterEventRouting_1.dispatchAdapterEvent)(key, 'midTurnAnswerMissing', () => remindMidTurnAnswerMissing(key)),
15480
15488
  onContextCompacted: (key, trigger) => (0, adapterEventRouting_1.dispatchAdapterEvent)(key, 'contextCompacted', () => {
15481
15489
  noteConversationContextReset(key, `compaction (${trigger ?? 'bot'})`);
15482
15490
  // The CLI's own overflow compaction: nobody else posts its self-review section (a bot-issued one is its caller's).
@@ -15845,13 +15853,17 @@ async function startBot() {
15845
15853
  // opencode survive the bot process by design and are picked back up
15846
15854
  // by `reattachExistingSessions` on the next boot.
15847
15855
  // The ordered sequence is the same for a signal and for an update's restart; only what happens AFTER it differs
15848
- // (`exit` ends the process, the restart replaces it with a fresh image of the same install).
15849
- const runShutdown = (signal, exit) => (0, shutdown_1.gracefulShutdown)({
15856
+ // (`exit` ends the process, the restart replaces it with a fresh image of the same install). A restart in place keeps the
15857
+ // instance lock (`isLockKept`): the new image, the same pid, replaces it, so the data dir is never without a holder; if
15858
+ // `execve` fails the process exits and the exit handler releases it. Only the forward update keeps it: its new image is this
15859
+ // release or a later one, which knows a kept lock; a boot rollback restarts onto older code and releases it first.
15860
+ const keepLockAcrossRestart = () => { };
15861
+ const runShutdown = (signal, exit, isLockKept = false) => (0, shutdown_1.gracefulShutdown)({
15850
15862
  signal,
15851
15863
  // Without Telegram there is no polling to stop, and `bot.stop` throws when it never launched.
15852
15864
  bot: ENV.isTelegramServed ? bot : { stop: () => { } },
15853
15865
  state,
15854
- releaseLock: instanceLock_1.releaseLock,
15866
+ releaseLock: isLockKept ? keepLockAcrossRestart : instanceLock_1.releaseLock,
15855
15867
  exit,
15856
15868
  drainPendingUpdates: () => updateDispatcher.drainIdle(updateDrainTimeoutMs),
15857
15869
  finalizePendingOutput: () => finalizePendingOutputOnShutdown(),
@@ -15916,7 +15928,7 @@ async function startBot() {
15916
15928
  },
15917
15929
  getIdleVerdict: getUpdateIdleVerdict,
15918
15930
  postToGeneral: postUpdateMessageToGeneral,
15919
- restartInPlace: () => runShutdown('update', () => (0, restart_1.reexecProcess)(updateRuntime.reexecTarget, (0, launchEnvironment_1.getLaunchEnvironment)(), (0, restart_1.createDefaultReexecDeps)())),
15931
+ restartInPlace: () => runShutdown('update', () => (0, restart_1.reexecProcess)(updateRuntime.reexecTarget, (0, launchEnvironment_1.getLaunchEnvironment)(), (0, restart_1.createDefaultReexecDeps)()), true),
15920
15932
  });
15921
15933
  const startUpdates = async () => {
15922
15934
  try {