charness 4.1.1 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (643) hide show
  1. package/CHANGELOG.md +186 -2
  2. package/DEVELOPMENT.md +65 -11
  3. package/LICENSE +331 -151
  4. package/MIGRATION_3_TO_4.md +8 -5
  5. package/README.md +23 -8
  6. package/SETUP.md +57 -11
  7. package/agent-plugin/README.md +10 -3
  8. package/agent-plugin/skills/charness-delegate-claude/SKILL.md +18 -26
  9. package/agent-plugin/skills/charness-delegate-opencode/SKILL.md +5 -3
  10. package/agent-plugin/skills/charness-orchestration/SKILL.md +57 -16
  11. package/dist/adapters/adapterNames.d.ts +2 -0
  12. package/dist/adapters/adapterNames.d.ts.map +1 -1
  13. package/dist/adapters/adapterNames.js +3 -1
  14. package/dist/adapters/adapterNames.js.map +1 -1
  15. package/dist/adapters/claudeCliAdapter.d.ts +4 -0
  16. package/dist/adapters/claudeCliAdapter.d.ts.map +1 -1
  17. package/dist/adapters/claudeCliAdapter.js +13 -0
  18. package/dist/adapters/claudeCliAdapter.js.map +1 -1
  19. package/dist/adapters/claudeJsonStreamAdapter.d.ts +150 -10
  20. package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -1
  21. package/dist/adapters/claudeJsonStreamAdapter.js +401 -83
  22. package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
  23. package/dist/adapters/createAdapter.d.ts +12 -3
  24. package/dist/adapters/createAdapter.d.ts.map +1 -1
  25. package/dist/adapters/createAdapter.js +39 -13
  26. package/dist/adapters/createAdapter.js.map +1 -1
  27. package/dist/adapters/openCodeAdapter.d.ts +65 -2
  28. package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
  29. package/dist/adapters/openCodeAdapter.js +202 -19
  30. package/dist/adapters/openCodeAdapter.js.map +1 -1
  31. package/dist/adapters/terminalAdapter.d.ts.map +1 -1
  32. package/dist/adapters/terminalAdapter.js +2 -1
  33. package/dist/adapters/terminalAdapter.js.map +1 -1
  34. package/dist/apiErrorRetry.d.ts +11 -3
  35. package/dist/apiErrorRetry.d.ts.map +1 -1
  36. package/dist/apiErrorRetry.js +33 -3
  37. package/dist/apiErrorRetry.js.map +1 -1
  38. package/dist/apiRetryKick.d.ts +3 -2
  39. package/dist/apiRetryKick.d.ts.map +1 -1
  40. package/dist/apiRetryKick.js +13 -5
  41. package/dist/apiRetryKick.js.map +1 -1
  42. package/dist/bot.d.ts +2 -6
  43. package/dist/bot.d.ts.map +1 -1
  44. package/dist/bot.js +2586 -693
  45. package/dist/bot.js.map +1 -1
  46. package/dist/cli/claudeProfiles.d.ts +31 -6
  47. package/dist/cli/claudeProfiles.d.ts.map +1 -1
  48. package/dist/cli/claudeProfiles.js +97 -22
  49. package/dist/cli/claudeProfiles.js.map +1 -1
  50. package/dist/cli.d.ts.map +1 -1
  51. package/dist/cli.js +2 -1
  52. package/dist/cli.js.map +1 -1
  53. package/dist/connectors/jira/answerSink.d.ts +102 -7
  54. package/dist/connectors/jira/answerSink.d.ts.map +1 -1
  55. package/dist/connectors/jira/answerSink.js +364 -60
  56. package/dist/connectors/jira/answerSink.js.map +1 -1
  57. package/dist/connectors/jira/answerThreads.d.ts +44 -0
  58. package/dist/connectors/jira/answerThreads.d.ts.map +1 -0
  59. package/dist/connectors/jira/answerThreads.js +85 -0
  60. package/dist/connectors/jira/answerThreads.js.map +1 -0
  61. package/dist/connectors/jira/client.d.ts +67 -2
  62. package/dist/connectors/jira/client.d.ts.map +1 -1
  63. package/dist/connectors/jira/client.js +176 -4
  64. package/dist/connectors/jira/client.js.map +1 -1
  65. package/dist/connectors/jira/config.d.ts +6 -0
  66. package/dist/connectors/jira/config.d.ts.map +1 -1
  67. package/dist/connectors/jira/config.js +14 -1
  68. package/dist/connectors/jira/config.js.map +1 -1
  69. package/dist/connectors/jira/connector.d.ts +19 -0
  70. package/dist/connectors/jira/connector.d.ts.map +1 -1
  71. package/dist/connectors/jira/connector.js +68 -6
  72. package/dist/connectors/jira/connector.js.map +1 -1
  73. package/dist/connectors/jira/contextPreamble.d.ts.map +1 -1
  74. package/dist/connectors/jira/contextPreamble.js +6 -1
  75. package/dist/connectors/jira/contextPreamble.js.map +1 -1
  76. package/dist/connectors/jira/inbound.d.ts +21 -6
  77. package/dist/connectors/jira/inbound.d.ts.map +1 -1
  78. package/dist/connectors/jira/inbound.js +22 -16
  79. package/dist/connectors/jira/inbound.js.map +1 -1
  80. package/dist/connectors/jira/issueBlocks.d.ts +8 -1
  81. package/dist/connectors/jira/issueBlocks.d.ts.map +1 -1
  82. package/dist/connectors/jira/issueBlocks.js +38 -2
  83. package/dist/connectors/jira/issueBlocks.js.map +1 -1
  84. package/dist/connectors/jira/operatorIssue.d.ts +28 -0
  85. package/dist/connectors/jira/operatorIssue.d.ts.map +1 -0
  86. package/dist/connectors/jira/operatorIssue.js +81 -0
  87. package/dist/connectors/jira/operatorIssue.js.map +1 -0
  88. package/dist/connectors/jira/outbound.d.ts +8 -4
  89. package/dist/connectors/jira/outbound.d.ts.map +1 -1
  90. package/dist/connectors/jira/outbound.js +16 -8
  91. package/dist/connectors/jira/outbound.js.map +1 -1
  92. package/dist/connectors/jira/outgoingFileCheck.d.ts +37 -0
  93. package/dist/connectors/jira/outgoingFileCheck.d.ts.map +1 -0
  94. package/dist/connectors/jira/outgoingFileCheck.js +279 -0
  95. package/dist/connectors/jira/outgoingFileCheck.js.map +1 -0
  96. package/dist/connectors/jira/outgoingFiles.d.ts +81 -0
  97. package/dist/connectors/jira/outgoingFiles.d.ts.map +1 -0
  98. package/dist/connectors/jira/outgoingFiles.js +268 -0
  99. package/dist/connectors/jira/outgoingFiles.js.map +1 -0
  100. package/dist/connectors/jira/progressComments.d.ts +69 -0
  101. package/dist/connectors/jira/progressComments.d.ts.map +1 -0
  102. package/dist/connectors/jira/progressComments.js +136 -0
  103. package/dist/connectors/jira/progressComments.js.map +1 -0
  104. package/dist/connectors/jira/prompt.d.ts +5 -1
  105. package/dist/connectors/jira/prompt.d.ts.map +1 -1
  106. package/dist/connectors/jira/prompt.js +23 -3
  107. package/dist/connectors/jira/prompt.js.map +1 -1
  108. package/dist/connectors/jira/promptSpill.js +1 -1
  109. package/dist/connectors/jira/promptSpill.js.map +1 -1
  110. package/dist/connectors/jira/trigger.d.ts +13 -5
  111. package/dist/connectors/jira/trigger.d.ts.map +1 -1
  112. package/dist/connectors/jira/trigger.js +13 -7
  113. package/dist/connectors/jira/trigger.js.map +1 -1
  114. package/dist/connectors/jira/uploadedFiles.d.ts +48 -0
  115. package/dist/connectors/jira/uploadedFiles.d.ts.map +1 -0
  116. package/dist/connectors/jira/uploadedFiles.js +123 -0
  117. package/dist/connectors/jira/uploadedFiles.js.map +1 -0
  118. package/dist/connectors/telegram/commands/backendSwitch.d.ts +9 -1
  119. package/dist/connectors/telegram/commands/backendSwitch.d.ts.map +1 -1
  120. package/dist/connectors/telegram/commands/backendSwitch.js +17 -8
  121. package/dist/connectors/telegram/commands/backendSwitch.js.map +1 -1
  122. package/dist/connectors/telegram/commands/botCore.d.ts +5 -2
  123. package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -1
  124. package/dist/connectors/telegram/commands/botSkills.d.ts +2 -0
  125. package/dist/connectors/telegram/commands/botSkills.d.ts.map +1 -1
  126. package/dist/connectors/telegram/commands/botSkills.js +17 -2
  127. package/dist/connectors/telegram/commands/botSkills.js.map +1 -1
  128. package/dist/connectors/telegram/commands/claudeAccounts.d.ts +11 -0
  129. package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -1
  130. package/dist/connectors/telegram/commands/claudeAccounts.js +36 -42
  131. package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
  132. package/dist/connectors/telegram/commands/compaction.d.ts +20 -3
  133. package/dist/connectors/telegram/commands/compaction.d.ts.map +1 -1
  134. package/dist/connectors/telegram/commands/compaction.js +268 -96
  135. package/dist/connectors/telegram/commands/compaction.js.map +1 -1
  136. package/dist/connectors/telegram/commands/limitReminders.d.ts +21 -0
  137. package/dist/connectors/telegram/commands/limitReminders.d.ts.map +1 -0
  138. package/dist/connectors/telegram/commands/limitReminders.js +95 -0
  139. package/dist/connectors/telegram/commands/limitReminders.js.map +1 -0
  140. package/dist/connectors/telegram/commands/limitsBoard.d.ts +4 -0
  141. package/dist/connectors/telegram/commands/limitsBoard.d.ts.map +1 -1
  142. package/dist/connectors/telegram/commands/limitsBoard.js +27 -6
  143. package/dist/connectors/telegram/commands/limitsBoard.js.map +1 -1
  144. package/dist/connectors/telegram/commands/modelProviders.d.ts +2 -2
  145. package/dist/connectors/telegram/commands/modelProviders.d.ts.map +1 -1
  146. package/dist/connectors/telegram/commands/modelProviders.js +27 -16
  147. package/dist/connectors/telegram/commands/modelProviders.js.map +1 -1
  148. package/dist/connectors/telegram/commands/questionSetAside.d.ts +111 -0
  149. package/dist/connectors/telegram/commands/questionSetAside.d.ts.map +1 -0
  150. package/dist/connectors/telegram/commands/questionSetAside.js +637 -0
  151. package/dist/connectors/telegram/commands/questionSetAside.js.map +1 -0
  152. package/dist/connectors/telegram/commands/questionWait.d.ts +21 -0
  153. package/dist/connectors/telegram/commands/questionWait.d.ts.map +1 -0
  154. package/dist/connectors/telegram/commands/questionWait.js +109 -0
  155. package/dist/connectors/telegram/commands/questionWait.js.map +1 -0
  156. package/dist/connectors/telegram/commands/topicAccess.js +1 -1
  157. package/dist/connectors/telegram/commands/topicAccess.js.map +1 -1
  158. package/dist/connectors/telegram/commands/topicCommand.d.ts +0 -2
  159. package/dist/connectors/telegram/commands/topicCommand.d.ts.map +1 -1
  160. package/dist/connectors/telegram/commands/topicCommand.js +11 -7
  161. package/dist/connectors/telegram/commands/topicCommand.js.map +1 -1
  162. package/dist/connectors/telegram/commands/topicStatus.d.ts +24 -0
  163. package/dist/connectors/telegram/commands/topicStatus.d.ts.map +1 -0
  164. package/dist/connectors/telegram/commands/topicStatus.js +148 -0
  165. package/dist/connectors/telegram/commands/topicStatus.js.map +1 -0
  166. package/dist/connectors/telegram/commands/workerRoles.d.ts +25 -0
  167. package/dist/connectors/telegram/commands/workerRoles.d.ts.map +1 -0
  168. package/dist/connectors/telegram/commands/workerRoles.js +259 -0
  169. package/dist/connectors/telegram/commands/workerRoles.js.map +1 -0
  170. package/dist/connectors/telegram/firstUpdateBatchNote.d.ts +30 -0
  171. package/dist/connectors/telegram/firstUpdateBatchNote.d.ts.map +1 -0
  172. package/dist/connectors/telegram/firstUpdateBatchNote.js +39 -0
  173. package/dist/connectors/telegram/firstUpdateBatchNote.js.map +1 -0
  174. package/dist/connectors/telegram/groupWelcome.d.ts +12 -0
  175. package/dist/connectors/telegram/groupWelcome.d.ts.map +1 -0
  176. package/dist/connectors/telegram/groupWelcome.js +12 -0
  177. package/dist/connectors/telegram/groupWelcome.js.map +1 -0
  178. package/dist/connectors/telegram/inbound.d.ts +19 -0
  179. package/dist/connectors/telegram/inbound.d.ts.map +1 -1
  180. package/dist/connectors/telegram/inbound.js +41 -3
  181. package/dist/connectors/telegram/inbound.js.map +1 -1
  182. package/dist/connectors/telegram/outputFlushPlan.d.ts +12 -0
  183. package/dist/connectors/telegram/outputFlushPlan.d.ts.map +1 -1
  184. package/dist/connectors/telegram/outputFlushPlan.js +12 -0
  185. package/dist/connectors/telegram/outputFlushPlan.js.map +1 -1
  186. package/dist/connectors/telegram/runnerPairingMessages.d.ts +1 -1
  187. package/dist/connectors/telegram/topicIndicator.d.ts +86 -0
  188. package/dist/connectors/telegram/topicIndicator.d.ts.map +1 -0
  189. package/dist/connectors/telegram/topicIndicator.js +588 -0
  190. package/dist/connectors/telegram/topicIndicator.js.map +1 -0
  191. package/dist/connectors/telegram/waitingTopicRenames.d.ts +39 -0
  192. package/dist/connectors/telegram/waitingTopicRenames.d.ts.map +1 -0
  193. package/dist/connectors/telegram/waitingTopicRenames.js +48 -0
  194. package/dist/connectors/telegram/waitingTopicRenames.js.map +1 -0
  195. package/dist/effortLevels.d.ts +6 -0
  196. package/dist/effortLevels.d.ts.map +1 -1
  197. package/dist/effortLevels.js +6 -1
  198. package/dist/effortLevels.js.map +1 -1
  199. package/dist/i18n/de.d.ts.map +1 -1
  200. package/dist/i18n/de.js +141 -13
  201. package/dist/i18n/de.js.map +1 -1
  202. package/dist/i18n/en.d.ts.map +1 -1
  203. package/dist/i18n/en.js +141 -13
  204. package/dist/i18n/en.js.map +1 -1
  205. package/dist/i18n/es.d.ts.map +1 -1
  206. package/dist/i18n/es.js +141 -13
  207. package/dist/i18n/es.js.map +1 -1
  208. package/dist/i18n/fr.d.ts.map +1 -1
  209. package/dist/i18n/fr.js +141 -13
  210. package/dist/i18n/fr.js.map +1 -1
  211. package/dist/i18n/hi.d.ts.map +1 -1
  212. package/dist/i18n/hi.js +141 -13
  213. package/dist/i18n/hi.js.map +1 -1
  214. package/dist/i18n/ja.d.ts.map +1 -1
  215. package/dist/i18n/ja.js +141 -13
  216. package/dist/i18n/ja.js.map +1 -1
  217. package/dist/i18n/ka.d.ts.map +1 -1
  218. package/dist/i18n/ka.js +141 -13
  219. package/dist/i18n/ka.js.map +1 -1
  220. package/dist/i18n/pt.d.ts.map +1 -1
  221. package/dist/i18n/pt.js +141 -13
  222. package/dist/i18n/pt.js.map +1 -1
  223. package/dist/i18n/ru.d.ts.map +1 -1
  224. package/dist/i18n/ru.js +141 -13
  225. package/dist/i18n/ru.js.map +1 -1
  226. package/dist/i18n/uk.d.ts.map +1 -1
  227. package/dist/i18n/uk.js +141 -13
  228. package/dist/i18n/uk.js.map +1 -1
  229. package/dist/i18n/uz.d.ts.map +1 -1
  230. package/dist/i18n/uz.js +141 -13
  231. package/dist/i18n/uz.js.map +1 -1
  232. package/dist/i18n/zh.d.ts.map +1 -1
  233. package/dist/i18n/zh.js +141 -13
  234. package/dist/i18n/zh.js.map +1 -1
  235. package/dist/instanceSettings.d.ts +43 -3
  236. package/dist/instanceSettings.d.ts.map +1 -1
  237. package/dist/instanceSettings.js +109 -4
  238. package/dist/instanceSettings.js.map +1 -1
  239. package/dist/limitNotes/engine.d.ts +47 -0
  240. package/dist/limitNotes/engine.d.ts.map +1 -0
  241. package/dist/limitNotes/engine.js +98 -0
  242. package/dist/limitNotes/engine.js.map +1 -0
  243. package/dist/limitNotes/noteText.d.ts +33 -0
  244. package/dist/limitNotes/noteText.d.ts.map +1 -0
  245. package/dist/limitNotes/noteText.js +55 -0
  246. package/dist/limitNotes/noteText.js.map +1 -0
  247. package/dist/limitNotes/plan.d.ts +147 -0
  248. package/dist/limitNotes/plan.d.ts.map +1 -0
  249. package/dist/limitNotes/plan.js +323 -0
  250. package/dist/limitNotes/plan.js.map +1 -0
  251. package/dist/limitNotes/reminderChoices.d.ts +30 -0
  252. package/dist/limitNotes/reminderChoices.d.ts.map +1 -0
  253. package/dist/limitNotes/reminderChoices.js +48 -0
  254. package/dist/limitNotes/reminderChoices.js.map +1 -0
  255. package/dist/limitNotes/service.d.ts +106 -0
  256. package/dist/limitNotes/service.d.ts.map +1 -0
  257. package/dist/limitNotes/service.js +169 -0
  258. package/dist/limitNotes/service.js.map +1 -0
  259. package/dist/openCodeOpenQuestion.d.ts +12 -4
  260. package/dist/openCodeOpenQuestion.d.ts.map +1 -1
  261. package/dist/openCodeOpenQuestion.js +16 -7
  262. package/dist/openCodeOpenQuestion.js.map +1 -1
  263. package/dist/openCodeQuestionFlow.d.ts +10 -2
  264. package/dist/openCodeQuestionFlow.d.ts.map +1 -1
  265. package/dist/openCodeQuestionFlow.js +27 -5
  266. package/dist/openCodeQuestionFlow.js.map +1 -1
  267. package/dist/openCodeSessionTitle.js +1 -1
  268. package/dist/openCodeSessionTitle.js.map +1 -1
  269. package/dist/outputTrace.d.ts +19 -0
  270. package/dist/outputTrace.d.ts.map +1 -1
  271. package/dist/outputTrace.js +23 -2
  272. package/dist/outputTrace.js.map +1 -1
  273. package/dist/platform/answerSink.d.ts +23 -0
  274. package/dist/platform/answerSink.d.ts.map +1 -1
  275. package/dist/platform/answerSink.js.map +1 -1
  276. package/dist/platform/operatorAlert.d.ts +24 -0
  277. package/dist/platform/operatorAlert.d.ts.map +1 -0
  278. package/dist/platform/operatorAlert.js +9 -0
  279. package/dist/platform/operatorAlert.js.map +1 -0
  280. package/dist/postToSession.d.ts +43 -2
  281. package/dist/postToSession.d.ts.map +1 -1
  282. package/dist/postToSession.js +46 -4
  283. package/dist/postToSession.js.map +1 -1
  284. package/dist/remoteRun/exitCodes.d.ts +2 -2
  285. package/dist/remoteRun/exitCodes.d.ts.map +1 -1
  286. package/dist/remoteRun/exitCodes.js +2 -2
  287. package/dist/remoteRun/exitCodes.js.map +1 -1
  288. package/dist/remoteRun/foreground.d.ts.map +1 -1
  289. package/dist/remoteRun/foreground.js +5 -1
  290. package/dist/remoteRun/foreground.js.map +1 -1
  291. package/dist/remoteRun/runnerClient.d.ts +1 -1
  292. package/dist/remoteRun/runnerClient.d.ts.map +1 -1
  293. package/dist/remoteRun/runnerClient.js +3 -3
  294. package/dist/remoteRun/runnerClient.js.map +1 -1
  295. package/dist/requests/answerRequest.d.ts +3 -0
  296. package/dist/requests/answerRequest.d.ts.map +1 -1
  297. package/dist/requests/answerRequest.js +9 -2
  298. package/dist/requests/answerRequest.js.map +1 -1
  299. package/dist/requests/limitWaitAnswer.d.ts +14 -0
  300. package/dist/requests/limitWaitAnswer.d.ts.map +1 -1
  301. package/dist/requests/limitWaitAnswer.js +26 -4
  302. package/dist/requests/limitWaitAnswer.js.map +1 -1
  303. package/dist/requests/requestHeader.d.ts +37 -5
  304. package/dist/requests/requestHeader.d.ts.map +1 -1
  305. package/dist/requests/requestHeader.js +46 -17
  306. package/dist/requests/requestHeader.js.map +1 -1
  307. package/dist/requests/scheduleWait.d.ts +79 -0
  308. package/dist/requests/scheduleWait.d.ts.map +1 -0
  309. package/dist/requests/scheduleWait.js +101 -0
  310. package/dist/requests/scheduleWait.js.map +1 -0
  311. package/dist/requests/sessionTurnProbe.d.ts +21 -3
  312. package/dist/requests/sessionTurnProbe.d.ts.map +1 -1
  313. package/dist/requests/sessionTurnProbe.js +18 -3
  314. package/dist/requests/sessionTurnProbe.js.map +1 -1
  315. package/dist/requests/topicRequestSettle.d.ts +13 -7
  316. package/dist/requests/topicRequestSettle.d.ts.map +1 -1
  317. package/dist/requests/topicRequestSettle.js +2 -2
  318. package/dist/requests/topicRequestSettle.js.map +1 -1
  319. package/dist/requests/trackerTurnPoster.d.ts +30 -0
  320. package/dist/requests/trackerTurnPoster.d.ts.map +1 -0
  321. package/dist/requests/trackerTurnPoster.js +36 -0
  322. package/dist/requests/trackerTurnPoster.js.map +1 -0
  323. package/dist/requests/types.d.ts +9 -2
  324. package/dist/requests/types.d.ts.map +1 -1
  325. package/dist/requests/wakeUpEngine.d.ts +188 -11
  326. package/dist/requests/wakeUpEngine.d.ts.map +1 -1
  327. package/dist/requests/wakeUpEngine.js +452 -43
  328. package/dist/requests/wakeUpEngine.js.map +1 -1
  329. package/dist/requests/wakeUpRules.d.ts +122 -12
  330. package/dist/requests/wakeUpRules.d.ts.map +1 -1
  331. package/dist/requests/wakeUpRules.js +117 -15
  332. package/dist/requests/wakeUpRules.js.map +1 -1
  333. package/dist/resumeContext.d.ts +2 -2
  334. package/dist/resumeContext.js +3 -3
  335. package/dist/resumeContext.js.map +1 -1
  336. package/dist/runnerUtility/adminService.js +1 -1
  337. package/dist/runnerUtility/adminService.js.map +1 -1
  338. package/dist/runnerUtility/guiAgent.d.ts +1 -1
  339. package/dist/runnerUtility/guiAgent.d.ts.map +1 -1
  340. package/dist/runnerUtility/guiAgent.js +1 -1
  341. package/dist/runnerUtility/guiAgent.js.map +1 -1
  342. package/dist/runnerUtility/managedNode.d.ts +3 -3
  343. package/dist/runnerUtility/managedNode.d.ts.map +1 -1
  344. package/dist/runnerUtility/managedNode.js +2 -2
  345. package/dist/runnerUtility/managedNode.js.map +1 -1
  346. package/dist/runnerUtility/runnerConfig.d.ts +1 -1
  347. package/dist/runnerUtility/runnerHome.d.ts +1 -1
  348. package/dist/runnerUtility/runnerHome.js +1 -1
  349. package/dist/runnerUtility/serviceCommon.d.ts +1 -1
  350. package/dist/runnerUtility/serviceCommon.d.ts.map +1 -1
  351. package/dist/runnerUtility/serviceCommon.js +1 -1
  352. package/dist/runnerUtility/serviceCommon.js.map +1 -1
  353. package/dist/runners/bootstrapLine.js +1 -1
  354. package/dist/runners/hubPackage.d.ts +1 -1
  355. package/dist/runners/hubPackage.js +3 -3
  356. package/dist/runners/hubPackage.js.map +1 -1
  357. package/dist/runners/hubPaths.d.ts +1 -1
  358. package/dist/runners/hubPaths.d.ts.map +1 -1
  359. package/dist/runners/runnerLock.d.ts +2 -2
  360. package/dist/runners/runnerLock.d.ts.map +1 -1
  361. package/dist/runners/runnerLock.js +2 -2
  362. package/dist/runners/runnerLock.js.map +1 -1
  363. package/dist/scheduler/checkRun.d.ts +2 -0
  364. package/dist/scheduler/checkRun.d.ts.map +1 -1
  365. package/dist/scheduler/checkRun.js +5 -1
  366. package/dist/scheduler/checkRun.js.map +1 -1
  367. package/dist/scheduler/delivery.d.ts +57 -0
  368. package/dist/scheduler/delivery.d.ts.map +1 -1
  369. package/dist/scheduler/delivery.js +152 -14
  370. package/dist/scheduler/delivery.js.map +1 -1
  371. package/dist/scheduler/injection.d.ts +6 -0
  372. package/dist/scheduler/injection.d.ts.map +1 -1
  373. package/dist/scheduler/injection.js +10 -0
  374. package/dist/scheduler/injection.js.map +1 -1
  375. package/dist/scheduler/mcpSurface.d.ts +38 -3
  376. package/dist/scheduler/mcpSurface.d.ts.map +1 -1
  377. package/dist/scheduler/mcpSurface.js +291 -175
  378. package/dist/scheduler/mcpSurface.js.map +1 -1
  379. package/dist/scheduler/rebindResume.d.ts +24 -0
  380. package/dist/scheduler/rebindResume.d.ts.map +1 -1
  381. package/dist/scheduler/rebindResume.js +32 -0
  382. package/dist/scheduler/rebindResume.js.map +1 -1
  383. package/dist/scheduler/scheduleToolWording.d.ts +29 -0
  384. package/dist/scheduler/scheduleToolWording.d.ts.map +1 -0
  385. package/dist/scheduler/scheduleToolWording.js +117 -0
  386. package/dist/scheduler/scheduleToolWording.js.map +1 -0
  387. package/dist/scheduler/scheduledRunTarget.d.ts +90 -0
  388. package/dist/scheduler/scheduledRunTarget.d.ts.map +1 -0
  389. package/dist/scheduler/scheduledRunTarget.js +92 -0
  390. package/dist/scheduler/scheduledRunTarget.js.map +1 -0
  391. package/dist/scheduler/store.d.ts +2 -0
  392. package/dist/scheduler/store.d.ts.map +1 -1
  393. package/dist/scheduler/store.js +2 -0
  394. package/dist/scheduler/store.js.map +1 -1
  395. package/dist/scheduler/types.d.ts +10 -0
  396. package/dist/scheduler/types.d.ts.map +1 -1
  397. package/dist/scheduler/workerWatch.d.ts +2 -0
  398. package/dist/scheduler/workerWatch.d.ts.map +1 -1
  399. package/dist/scheduler/workerWatch.js +3 -3
  400. package/dist/scheduler/workerWatch.js.map +1 -1
  401. package/dist/selfUpdate/constants.d.ts +2 -0
  402. package/dist/selfUpdate/constants.d.ts.map +1 -1
  403. package/dist/selfUpdate/constants.js +3 -1
  404. package/dist/selfUpdate/constants.js.map +1 -1
  405. package/dist/selfUpdate/emittedSource.d.ts.map +1 -1
  406. package/dist/selfUpdate/emittedSource.js +1 -1
  407. package/dist/selfUpdate/emittedSource.js.map +1 -1
  408. package/dist/selfUpdate/updateRuntime.js +1 -1
  409. package/dist/selfUpdate/updateRuntime.js.map +1 -1
  410. package/dist/sessionPick.d.ts +1 -1
  411. package/dist/sessionPick.js +1 -1
  412. package/dist/startupPromptBuffer.d.ts +35 -6
  413. package/dist/startupPromptBuffer.d.ts.map +1 -1
  414. package/dist/startupPromptBuffer.js +70 -21
  415. package/dist/startupPromptBuffer.js.map +1 -1
  416. package/dist/state.d.ts +270 -30
  417. package/dist/state.d.ts.map +1 -1
  418. package/dist/state.js +403 -37
  419. package/dist/state.js.map +1 -1
  420. package/dist/testTimings.d.ts +17 -4
  421. package/dist/testTimings.d.ts.map +1 -1
  422. package/dist/testTimings.js +35 -3
  423. package/dist/testTimings.js.map +1 -1
  424. package/dist/threadContextPreamble.d.ts +7 -0
  425. package/dist/threadContextPreamble.d.ts.map +1 -1
  426. package/dist/threadContextPreamble.js +11 -0
  427. package/dist/threadContextPreamble.js.map +1 -1
  428. package/dist/threadRouting.d.ts +12 -0
  429. package/dist/threadRouting.d.ts.map +1 -1
  430. package/dist/threadRouting.js +15 -0
  431. package/dist/threadRouting.js.map +1 -1
  432. package/dist/todos/midTurn.d.ts +15 -41
  433. package/dist/todos/midTurn.d.ts.map +1 -1
  434. package/dist/todos/midTurn.js +27 -171
  435. package/dist/todos/midTurn.js.map +1 -1
  436. package/dist/todos/registry.d.ts +2 -0
  437. package/dist/todos/registry.d.ts.map +1 -1
  438. package/dist/todos/registry.js +3 -1
  439. package/dist/todos/registry.js.map +1 -1
  440. package/dist/types.d.ts +235 -23
  441. package/dist/types.d.ts.map +1 -1
  442. package/dist/types.js +10 -0
  443. package/dist/types.js.map +1 -1
  444. package/dist/utils/backendSwitchPlan.d.ts +3 -3
  445. package/dist/utils/backendSwitchPlan.js +3 -3
  446. package/dist/utils/claudeAccountAlert.d.ts +104 -0
  447. package/dist/utils/claudeAccountAlert.d.ts.map +1 -0
  448. package/dist/utils/claudeAccountAlert.js +130 -0
  449. package/dist/utils/claudeAccountAlert.js.map +1 -0
  450. package/dist/utils/claudeAccountPickerPlan.d.ts +7 -0
  451. package/dist/utils/claudeAccountPickerPlan.d.ts.map +1 -1
  452. package/dist/utils/claudeAccountPickerPlan.js +13 -2
  453. package/dist/utils/claudeAccountPickerPlan.js.map +1 -1
  454. package/dist/utils/claudeAuthRefusal.d.ts +122 -0
  455. package/dist/utils/claudeAuthRefusal.d.ts.map +1 -0
  456. package/dist/utils/claudeAuthRefusal.js +228 -0
  457. package/dist/utils/claudeAuthRefusal.js.map +1 -0
  458. package/dist/utils/claudeCompactHook.d.ts +9 -7
  459. package/dist/utils/claudeCompactHook.d.ts.map +1 -1
  460. package/dist/utils/claudeCompactHook.js +11 -9
  461. package/dist/utils/claudeCompactHook.js.map +1 -1
  462. package/dist/utils/claudeLimitSwitch.d.ts +1 -1
  463. package/dist/utils/claudeLimitSwitch.d.ts.map +1 -1
  464. package/dist/utils/claudeLimitSwitch.js +1 -1
  465. package/dist/utils/claudeLimitSwitch.js.map +1 -1
  466. package/dist/utils/claudeProfileSync.d.ts +88 -0
  467. package/dist/utils/claudeProfileSync.d.ts.map +1 -0
  468. package/dist/utils/claudeProfileSync.js +198 -0
  469. package/dist/utils/claudeProfileSync.js.map +1 -0
  470. package/dist/utils/claudeProfileUsageViews.d.ts +54 -2
  471. package/dist/utils/claudeProfileUsageViews.d.ts.map +1 -1
  472. package/dist/utils/claudeProfileUsageViews.js +44 -1
  473. package/dist/utils/claudeProfileUsageViews.js.map +1 -1
  474. package/dist/utils/claudeProfiles.d.ts +101 -6
  475. package/dist/utils/claudeProfiles.d.ts.map +1 -1
  476. package/dist/utils/claudeProfiles.js +297 -23
  477. package/dist/utils/claudeProfiles.js.map +1 -1
  478. package/dist/utils/claudeRuntimeInfo.d.ts +24 -0
  479. package/dist/utils/claudeRuntimeInfo.d.ts.map +1 -1
  480. package/dist/utils/claudeRuntimeInfo.js +128 -3
  481. package/dist/utils/claudeRuntimeInfo.js.map +1 -1
  482. package/dist/utils/claudeScheduledJobs.d.ts +6 -2
  483. package/dist/utils/claudeScheduledJobs.d.ts.map +1 -1
  484. package/dist/utils/claudeScheduledJobs.js +10 -2
  485. package/dist/utils/claudeScheduledJobs.js.map +1 -1
  486. package/dist/utils/claudeSessionTitle.js +1 -1
  487. package/dist/utils/claudeSessionTitle.js.map +1 -1
  488. package/dist/utils/claudeStreamJson.d.ts +28 -2
  489. package/dist/utils/claudeStreamJson.d.ts.map +1 -1
  490. package/dist/utils/claudeStreamJson.js +33 -3
  491. package/dist/utils/claudeStreamJson.js.map +1 -1
  492. package/dist/utils/claudeTranscriptEpoch.d.ts +14 -0
  493. package/dist/utils/claudeTranscriptEpoch.d.ts.map +1 -1
  494. package/dist/utils/claudeTranscriptEpoch.js +79 -19
  495. package/dist/utils/claudeTranscriptEpoch.js.map +1 -1
  496. package/dist/utils/claudeUsage.d.ts +103 -7
  497. package/dist/utils/claudeUsage.d.ts.map +1 -1
  498. package/dist/utils/claudeUsage.js +108 -15
  499. package/dist/utils/claudeUsage.js.map +1 -1
  500. package/dist/utils/claudeUsageRefresher.d.ts +8 -1
  501. package/dist/utils/claudeUsageRefresher.d.ts.map +1 -1
  502. package/dist/utils/claudeUsageRefresher.js +11 -1
  503. package/dist/utils/claudeUsageRefresher.js.map +1 -1
  504. package/dist/utils/compactOnIdle.d.ts +139 -29
  505. package/dist/utils/compactOnIdle.d.ts.map +1 -1
  506. package/dist/utils/compactOnIdle.js +163 -36
  507. package/dist/utils/compactOnIdle.js.map +1 -1
  508. package/dist/utils/conversationEnding.d.ts +76 -0
  509. package/dist/utils/conversationEnding.d.ts.map +1 -0
  510. package/dist/utils/conversationEnding.js +117 -0
  511. package/dist/utils/conversationEnding.js.map +1 -0
  512. package/dist/utils/cutButtonLabel.d.ts +7 -0
  513. package/dist/utils/cutButtonLabel.d.ts.map +1 -0
  514. package/dist/utils/cutButtonLabel.js +17 -0
  515. package/dist/utils/cutButtonLabel.js.map +1 -0
  516. package/dist/utils/doctorLine.d.ts +10 -0
  517. package/dist/utils/doctorLine.d.ts.map +1 -1
  518. package/dist/utils/doctorLine.js +16 -0
  519. package/dist/utils/doctorLine.js.map +1 -1
  520. package/dist/utils/fallbackBridge.d.ts.map +1 -1
  521. package/dist/utils/fallbackBridge.js +2 -1
  522. package/dist/utils/fallbackBridge.js.map +1 -1
  523. package/dist/utils/fallbackChain.d.ts +2 -0
  524. package/dist/utils/fallbackChain.d.ts.map +1 -1
  525. package/dist/utils/fallbackChain.js +4 -3
  526. package/dist/utils/fallbackChain.js.map +1 -1
  527. package/dist/utils/fallbackSwitchNotice.d.ts +11 -4
  528. package/dist/utils/fallbackSwitchNotice.d.ts.map +1 -1
  529. package/dist/utils/fallbackSwitchNotice.js +9 -5
  530. package/dist/utils/fallbackSwitchNotice.js.map +1 -1
  531. package/dist/utils/fileSendService.d.ts +31 -0
  532. package/dist/utils/fileSendService.d.ts.map +1 -1
  533. package/dist/utils/fileSendService.js +45 -2
  534. package/dist/utils/fileSendService.js.map +1 -1
  535. package/dist/utils/jsonStreamHost.d.ts +2 -0
  536. package/dist/utils/jsonStreamHost.d.ts.map +1 -1
  537. package/dist/utils/jsonStreamHost.js +4 -1
  538. package/dist/utils/jsonStreamHost.js.map +1 -1
  539. package/dist/utils/jsonStreamPendingWork.d.ts +14 -2
  540. package/dist/utils/jsonStreamPendingWork.d.ts.map +1 -1
  541. package/dist/utils/jsonStreamPendingWork.js +25 -5
  542. package/dist/utils/jsonStreamPendingWork.js.map +1 -1
  543. package/dist/utils/jsonStreamUnconsumedInput.d.ts +80 -0
  544. package/dist/utils/jsonStreamUnconsumedInput.d.ts.map +1 -0
  545. package/dist/utils/jsonStreamUnconsumedInput.js +99 -0
  546. package/dist/utils/jsonStreamUnconsumedInput.js.map +1 -0
  547. package/dist/utils/limitEpisodeRecovery.d.ts +43 -4
  548. package/dist/utils/limitEpisodeRecovery.d.ts.map +1 -1
  549. package/dist/utils/limitEpisodeRecovery.js +107 -20
  550. package/dist/utils/limitEpisodeRecovery.js.map +1 -1
  551. package/dist/utils/limitHeldPrompts.d.ts +21 -11
  552. package/dist/utils/limitHeldPrompts.d.ts.map +1 -1
  553. package/dist/utils/limitHeldPrompts.js +12 -9
  554. package/dist/utils/limitHeldPrompts.js.map +1 -1
  555. package/dist/utils/limitRemindersScreenPlan.d.ts +63 -0
  556. package/dist/utils/limitRemindersScreenPlan.d.ts.map +1 -0
  557. package/dist/utils/limitRemindersScreenPlan.js +121 -0
  558. package/dist/utils/limitRemindersScreenPlan.js.map +1 -0
  559. package/dist/utils/limitSwitchPlan.d.ts +44 -0
  560. package/dist/utils/limitSwitchPlan.d.ts.map +1 -0
  561. package/dist/utils/limitSwitchPlan.js +54 -0
  562. package/dist/utils/limitSwitchPlan.js.map +1 -0
  563. package/dist/utils/limitsBoardPlan.d.ts +16 -7
  564. package/dist/utils/limitsBoardPlan.d.ts.map +1 -1
  565. package/dist/utils/limitsBoardPlan.js +41 -9
  566. package/dist/utils/limitsBoardPlan.js.map +1 -1
  567. package/dist/utils/lostWork.d.ts +16 -2
  568. package/dist/utils/lostWork.d.ts.map +1 -1
  569. package/dist/utils/lostWork.js +16 -3
  570. package/dist/utils/lostWork.js.map +1 -1
  571. package/dist/utils/messageContext.d.ts +2 -2
  572. package/dist/utils/messageContext.js +2 -2
  573. package/dist/utils/midTurnInbox.d.ts +79 -0
  574. package/dist/utils/midTurnInbox.d.ts.map +1 -0
  575. package/dist/utils/midTurnInbox.js +265 -0
  576. package/dist/utils/midTurnInbox.js.map +1 -0
  577. package/dist/utils/promptDelivery.d.ts +70 -22
  578. package/dist/utils/promptDelivery.d.ts.map +1 -1
  579. package/dist/utils/promptDelivery.js +100 -42
  580. package/dist/utils/promptDelivery.js.map +1 -1
  581. package/dist/utils/questionWaitChoices.d.ts +20 -0
  582. package/dist/utils/questionWaitChoices.d.ts.map +1 -0
  583. package/dist/utils/questionWaitChoices.js +31 -0
  584. package/dist/utils/questionWaitChoices.js.map +1 -0
  585. package/dist/utils/questionWaitPlan.d.ts +166 -0
  586. package/dist/utils/questionWaitPlan.d.ts.map +1 -0
  587. package/dist/utils/questionWaitPlan.js +237 -0
  588. package/dist/utils/questionWaitPlan.js.map +1 -0
  589. package/dist/utils/replyQuote.d.ts +10 -0
  590. package/dist/utils/replyQuote.d.ts.map +1 -1
  591. package/dist/utils/replyQuote.js +18 -7
  592. package/dist/utils/replyQuote.js.map +1 -1
  593. package/dist/utils/talkerAccess.d.ts +2 -2
  594. package/dist/utils/talkerAccess.d.ts.map +1 -1
  595. package/dist/utils/talkerAccess.js +5 -4
  596. package/dist/utils/talkerAccess.js.map +1 -1
  597. package/dist/utils/telegramError.d.ts +6 -0
  598. package/dist/utils/telegramError.d.ts.map +1 -1
  599. package/dist/utils/telegramError.js +12 -0
  600. package/dist/utils/telegramError.js.map +1 -1
  601. package/dist/utils/topicAccessScreenPlan.d.ts +1 -1
  602. package/dist/utils/topicAccessScreenPlan.d.ts.map +1 -1
  603. package/dist/utils/topicAccessScreenPlan.js +3 -7
  604. package/dist/utils/topicAccessScreenPlan.js.map +1 -1
  605. package/dist/utils/topicIndicatorPlan.d.ts +153 -0
  606. package/dist/utils/topicIndicatorPlan.d.ts.map +1 -0
  607. package/dist/utils/topicIndicatorPlan.js +224 -0
  608. package/dist/utils/topicIndicatorPlan.js.map +1 -0
  609. package/dist/utils/topicIndicatorSources.d.ts +40 -0
  610. package/dist/utils/topicIndicatorSources.d.ts.map +1 -0
  611. package/dist/utils/topicIndicatorSources.js +31 -0
  612. package/dist/utils/topicIndicatorSources.js.map +1 -0
  613. package/dist/utils/topicRequest.d.ts +3 -0
  614. package/dist/utils/topicRequest.d.ts.map +1 -1
  615. package/dist/utils/topicRequest.js +4 -0
  616. package/dist/utils/topicRequest.js.map +1 -1
  617. package/dist/utils/topicStatusPlan.d.ts +90 -0
  618. package/dist/utils/topicStatusPlan.d.ts.map +1 -0
  619. package/dist/utils/topicStatusPlan.js +160 -0
  620. package/dist/utils/topicStatusPlan.js.map +1 -0
  621. package/dist/utils/workerRoles.d.ts +122 -0
  622. package/dist/utils/workerRoles.d.ts.map +1 -0
  623. package/dist/utils/workerRoles.js +160 -0
  624. package/dist/utils/workerRoles.js.map +1 -0
  625. package/dist/utils/workerRolesScreenPlan.d.ts +118 -0
  626. package/dist/utils/workerRolesScreenPlan.d.ts.map +1 -0
  627. package/dist/utils/workerRolesScreenPlan.js +232 -0
  628. package/dist/utils/workerRolesScreenPlan.js.map +1 -0
  629. package/dist/utils/workingSignals.d.ts +49 -0
  630. package/dist/utils/workingSignals.d.ts.map +1 -0
  631. package/dist/utils/workingSignals.js +41 -0
  632. package/dist/utils/workingSignals.js.map +1 -0
  633. package/licensing.json +88 -0
  634. package/npm-shrinkwrap.json +2 -2
  635. package/package.json +7 -7
  636. package/{remoteRun → runner-scripts}/runner.sh +6 -3
  637. package/COMMERCIAL-LICENSE.md +0 -142
  638. package/dist/agentTrigger.d.ts +0 -28
  639. package/dist/agentTrigger.d.ts.map +0 -1
  640. package/dist/agentTrigger.js +0 -53
  641. package/dist/agentTrigger.js.map +0 -1
  642. /package/{remoteRun → runner-scripts}/ensureNode.sh +0 -0
  643. /package/{remoteRun → runner-scripts}/runner-package-lock.json +0 -0
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jiraQuestionContinueText = exports.jiraReadBackDelayMs = exports.jiraReadBackClockSkewMs = exports.jiraReadBackCommentCount = void 0;
3
+ exports.jiraFilesUnavailableError = exports.jiraQuestionContinueText = exports.jiraReadBackDelayMs = exports.jiraReadBackClockSkewMs = exports.jiraReadBackCommentCount = void 0;
4
4
  exports.buildJiraAlertText = buildJiraAlertText;
5
5
  exports.buildJiraParkText = buildJiraParkText;
6
6
  exports.buildJiraMentionParkText = buildJiraMentionParkText;
7
7
  exports.buildJiraUpdatesPausedText = buildJiraUpdatesPausedText;
8
8
  exports.buildJiraQueuedText = buildJiraQueuedText;
9
9
  exports.buildJiraReplyLeftOutWarning = buildJiraReplyLeftOutWarning;
10
+ exports.buildJiraOtherThreadsWarning = buildJiraOtherThreadsWarning;
11
+ exports.buildJiraThreadRefusedWarning = buildJiraThreadRefusedWarning;
12
+ exports.buildJiraProgressUpdatedText = buildJiraProgressUpdatedText;
13
+ exports.buildJiraProgressClosedText = buildJiraProgressClosedText;
10
14
  exports.buildJiraUntrustedText = buildJiraUntrustedText;
15
+ exports.getOriginThreadRootId = getOriginThreadRootId;
11
16
  exports.createJiraAnswerSink = createJiraAnswerSink;
12
17
  const requestGroup_1 = require("../../requests/requestGroup");
13
18
  const adf_1 = require("./adf");
@@ -16,6 +21,8 @@ const client_1 = require("./client");
16
21
  const unconfirmedPosts_1 = require("./unconfirmedPosts");
17
22
  const trigger_1 = require("./trigger");
18
23
  const issueBlocks_1 = require("./issueBlocks");
24
+ const outgoingFiles_1 = require("./outgoingFiles");
25
+ const progressComments_1 = require("./progressComments");
19
26
  /**
20
27
  * @description The Jira connector's answer sink (plan J6, D20, R18): an answer
21
28
  * becomes one or more comments by the AI account, in order; a `question` or a
@@ -30,6 +37,37 @@ const issueBlocks_1 = require("./issueBlocks");
30
37
  * request, the issue is read first and a comment that did land is not posted
31
38
  * twice. The agent cannot look at the issue itself, so every failure tells it
32
39
  * what to send again. Bot texts on the issue are English (D20).
40
+ *
41
+ * Comment threads: an answer goes into the thread of the first comment it replies to (`replyToCommentIds`), else into
42
+ * the thread the request's latest issue update came from (`answerThreads.ts`: its newest comment was a reply there; the
43
+ * agent's answer delivered uses it up, a notice the bot writes does not), else into the thread its request was opened
44
+ * in (the origin's {@link jiraReplyThreadAttribute}), else it is a top-level comment; the request's alert and the
45
+ * notices about its trigger follow the request's own thread. Jira threads are one level deep, so a reply always names
46
+ * the thread's top-level comment. A thread Jira refuses (400: its comments are gone)
47
+ * gets the comment top-level instead, and the agent is told.
48
+ *
49
+ * Files: an answer's `files` are attached to the issue BEFORE its comment is posted and shown in it, after its text
50
+ * (`outgoingFiles.ts`); a file that cannot be attached fails the answer with nothing posted. `postFiles` is
51
+ * `send_file_to_user` on an issue: the files, and the caption as text, in a comment of their own.
52
+ *
53
+ * One progress comment per request (`progressComments.ts`): the first `progress` answer of a request posts a comment and the sink
54
+ * remembers it (on disk); each next one EDITS it to the newest text, with a line saying when it was last updated, in the thread
55
+ * the first stood in — an edit moves nothing and notifies nobody. A `question` or `final` answer is a new comment as ever, and it
56
+ * closes the progress comments it ends — its request's and those of the requests it replaced, the ones let go earlier (an issue
57
+ * update, a note that was a comment of its own, the alert) included: a line on top says the notes were interim and the answer (or
58
+ * the question) is in a newer comment, so no note still reads as work under way ("pipeline 42 is running now, I'll report when it
59
+ * finishes") once the answer stands below it. The closing comes after the hand-back: it is cosmetic, the hand-back notifies. An edit Jira refuses (the comment is gone, 400, 403), or
60
+ * one of unknown outcome whose read-back shows the old text and whose one repeat does not land, posts the text as a new comment
61
+ * instead (with R18's read-back) and that one is remembered — the text is never lost. An edit of unknown outcome whose comment cannot be read is an error that tells the agent
62
+ * to send it again: nothing is posted, and the resend edits the same comment (a new comment would show the text twice). A progress answer is kept as that one comment only when it is a plain note: it carries no
63
+ * files, replies to no comment (an edit notifies nobody, a reply is meant to) and fits one comment; any other is a comment of its
64
+ * own, like a question, and the progress comment is let go, so the next note starts below it. So is an issue update the request
65
+ * receives (`noteIssueUpdate`, a reply or a top-level comment): what the agent answers to the person is a new comment below theirs
66
+ * — in the thread it asked for — and the notes after it edit that one. The bot's own notice that repeats for a request (`RequestAnswerDelivery.repeatKey`: a
67
+ * usage-limit wait once more) is kept the same way, in a slot of its own — but only for back-to-back repeats: once the agent's own
68
+ * answer is delivered (posted or edited), another bot comment of its own stands below it (an account moved, no account usable, the
69
+ * give-up alert) or an issue update arrives, the notice is let go and the next one is a new comment below; a bot notice without a
70
+ * key is a comment each time.
33
71
  */
34
72
  /** How many of the issue's newest comments R18's read-back looks through. */
35
73
  exports.jiraReadBackCommentCount = 20;
@@ -48,13 +86,18 @@ exports.jiraReadBackDelayMs = 10_000;
48
86
  /** How much of the first unposted part a partial delivery quotes, so the agent can tell where to resend from. */
49
87
  const missingPartPreviewChars = 80;
50
88
  const alertTexts = {
51
- silentTurns: 'the agent ended its turns without answering, and the reminders gave up',
52
- wakeCap: 'the agent was reminded as many times as allowed without answering',
53
- wakeFailed: "the agent's session could not be reached to remind it",
89
+ silentTurns: 'The AI stopped working on this without giving an answer, even after it was reminded.',
90
+ wakeCap: 'The AI was reminded as many times as allowed and still gave no answer here.',
91
+ wakeFailed: "The AI's session could not be reached to remind it, so there is no answer here.",
54
92
  };
55
- /** @description The alert comment: which request, why, and that a person is needed (D20). */
56
- function buildJiraAlertText(requestId, reason) {
57
- return `⚠️ The AI could not finish request ${requestId}: ${alertTexts[reason]}. A person needs to look at this issue.`;
93
+ /**
94
+ * @description The alert comment (D20), in words a reader of the issue understands: what happened, and in one line what it means for
95
+ * them — nothing more happens by itself, a person has to look, and how to try again. The request's id stays out of it (the bot's log
96
+ * names it). A turn refused for the AI's Claude account never ends here: the bot says that in words of its own and moves the work, or
97
+ * the work waits for the account (`bot.ts` `handleClaudeAuthRefusal`).
98
+ */
99
+ function buildJiraAlertText(reason) {
100
+ return `⚠️ ${alertTexts[reason]} It will not go on by itself: a person needs to look at this issue. To try again, hand it to the AI again or mention it in a comment.`;
58
101
  }
59
102
  /** @description The park notice (D12): over the run budget, handed back without a new request. Hand-overs and mentions share the budget. */
60
103
  function buildJiraParkText(runBudgetPer24h) {
@@ -94,6 +137,38 @@ function buildJiraReplyLeftOutWarning(commentIds) {
94
137
  return `Delivered, but these comments' authors were not mentioned: ${commentIds.join(', ')}. ` +
95
138
  'Only comments you were shown in this conversation, written by a trusted person, can be replied to this way.';
96
139
  }
140
+ /**
141
+ * @description The warning of an answer that replied to comments in several threads: one answer is one place, so it
142
+ * went into the thread of the first comment it replied to; the others' authors were only mentioned.
143
+ */
144
+ function buildJiraOtherThreadsWarning(threadRootId, commentIds) {
145
+ return `Delivered in the thread of comment ${threadRootId}, but ${commentIds.length === 1 ? 'comment' : 'comments'} ${commentIds.join(', ')} ` +
146
+ `${commentIds.length === 1 ? 'is' : 'are'} in another thread: ${commentIds.length === 1 ? 'its author was' : 'their authors were'} mentioned, ` +
147
+ 'and the answer is not there. To answer in that thread too, send a separate answer that replies to it.';
148
+ }
149
+ /** @description The warning of an answer whose thread Jira refused (its comments are gone): it was posted as a new top-level comment. */
150
+ function buildJiraThreadRefusedWarning(threadRootId) {
151
+ return `The thread of comment ${threadRootId} no longer takes replies (Jira refused it), so the answer was posted as a new comment instead.`;
152
+ }
153
+ /** A moment as the notices tell time: UTC, to the minute. */
154
+ function formatUtcMinute(atMs) {
155
+ return `${new Date(atMs).toISOString().slice(0, 16).replace('T', ' ')} UTC`;
156
+ }
157
+ /** @description The line an edited progress comment ends with: when it was last updated. */
158
+ function buildJiraProgressUpdatedText(atMs) {
159
+ return `Last updated ${formatUtcMinute(atMs)}`;
160
+ }
161
+ const progressDoneMark = '✅ Done';
162
+ const progressPausedMark = '⏸ Paused';
163
+ /**
164
+ * @description The line a progress comment gets on top once its request has its answer (`final`) or asks the requester (`question`):
165
+ * the notes below it were interim, and where to read on.
166
+ */
167
+ function buildJiraProgressClosedText(kind, atMs) {
168
+ return kind === 'final'
169
+ ? `${progressDoneMark} ${formatUtcMinute(atMs)}: these were interim notes, the answer is in a newer comment.`
170
+ : `${progressPausedMark} ${formatUtcMinute(atMs)} for a question: these were interim notes, the question is in a newer comment.`;
171
+ }
97
172
  /** @description The last paragraph of a hand-over's `question` comment: how the requester lets the agent go on. */
98
173
  exports.jiraQuestionContinueText = 'To let me go on, answer in a comment and assign the issue back to me.';
99
174
  /**
@@ -103,6 +178,32 @@ exports.jiraQuestionContinueText = 'To let me go on, answer in a comment and ass
103
178
  function buildJiraUntrustedText(groupName) {
104
179
  return `Only members of the AI's trusted group (${groupName}) can hand it work, so nothing was started. Ask a member to hand it over.`;
105
180
  }
181
+ /** The refusal of files where the sink has no way to attach them. */
182
+ exports.jiraFilesUnavailableError = 'files cannot be attached to a Jira issue on this instance; nothing was posted';
183
+ /** Jira's answer to a reply whose thread it does not have: the request is refused, nothing was posted. */
184
+ const threadRefusedStatus = 400;
185
+ /**
186
+ * The slot an answer is kept in as ONE comment edited by the next such answer, or `null` when it is a comment of its own: only a
187
+ * plain `progress` note — no files, no reply to a comment — and, of the bot's notices, one that carries a repeat key.
188
+ */
189
+ function getEditableSlot(delivery) {
190
+ const isPlain = delivery.kind === 'progress' && (delivery.files?.length ?? 0) === 0 && (delivery.replyToCommentIds?.length ?? 0) === 0;
191
+ if (!isPlain)
192
+ return null;
193
+ if (!delivery.isBotNotice)
194
+ return progressComments_1.jiraProgressSlot;
195
+ return delivery.repeatKey === undefined ? null : (0, progressComments_1.getJiraNoticeSlot)(delivery.repeatKey);
196
+ }
197
+ /** `body` with the line saying when it was last updated as one more paragraph, in italics. */
198
+ function getBodyWithUpdatedLine(body, atMs) {
199
+ const updatedParagraph = { type: 'paragraph', content: [{ type: 'text', text: buildJiraProgressUpdatedText(atMs), marks: [{ type: 'em' }] }] };
200
+ return { ...body, content: [...body.content, updatedParagraph] };
201
+ }
202
+ /** The thread a request's answers go into by default: the origin's {@link jiraReplyThreadAttribute}, when it is a comment id. */
203
+ function getOriginThreadRootId(origin) {
204
+ const threadRootId = origin.attributes[trigger_1.jiraReplyThreadAttribute];
205
+ return threadRootId !== undefined && /^\d+$/.test(threadRootId) ? threadRootId : null;
206
+ }
106
207
  /** A comment's text as the read-back compares it: its plain text, whitespace collapsed. */
107
208
  function getComparableText(body) {
108
209
  return (0, promptText_1.getSingleLineText)((0, adf_1.getAdfText)(body));
@@ -119,13 +220,14 @@ function getBodyWithContinueLine(body) {
119
220
  }
120
221
  function createJiraAnswerSink(deps) {
121
222
  const { client } = deps;
122
- /** Is the comment on the issue, by the AI account, dated from the post's start on? `null` — the issue could not be read. */
123
- async function checkIsCommentOnIssue(issueKey, comparableText, postStartedAt) {
223
+ /** The comment on the issue, by the AI account, dated from the post's start on, with this text: its id; `false` — none; `null` — the issue could not be read. */
224
+ async function findCommentOnIssue(issueKey, comparableText, postStartedAt) {
124
225
  try {
125
226
  const comments = await client.getRecentComments(issueKey, exports.jiraReadBackCommentCount);
126
- return comments.some((comment) => comment.author?.accountId === deps.aiAccountId
227
+ const found = comments.find((comment) => comment.author?.accountId === deps.aiAccountId
127
228
  && Date.parse(comment.created) >= postStartedAt - exports.jiraReadBackClockSkewMs
128
229
  && getComparableText(comment.body) === comparableText);
230
+ return found ? found.id : false;
129
231
  }
130
232
  catch (error) {
131
233
  console.warn(`[jira] ${issueKey}: read-back failed: ${error instanceof Error ? error.message : String(error)}`);
@@ -133,52 +235,127 @@ function createJiraAnswerSink(deps) {
133
235
  }
134
236
  }
135
237
  /**
136
- * Post one comment. With a `requestId`, a post left unconfirmed is remembered,
137
- * and a resend of a remembered one reads the issue first (R29).
238
+ * Post one comment, in the thread of `parentId` (a top-level comment's id) or top-level (`null`). With a
239
+ * `requestId`, a post left unconfirmed is remembered, and a resend of a remembered one reads the issue first (R29).
138
240
  */
139
- async function postComment(issueKey, body, requestId) {
241
+ async function postComment(issueKey, body, requestId, parentId) {
140
242
  const comparableText = getComparableText(body);
141
243
  const bodyHash = (0, unconfirmedPosts_1.getCommentBodyHash)(comparableText);
142
244
  const earlierPostedAt = requestId === null ? null : deps.unconfirmedPosts.getPostedAt(requestId, bodyHash);
143
245
  if (requestId !== null && earlierPostedAt !== null) {
144
- const isEarlierOnIssue = await checkIsCommentOnIssue(issueKey, comparableText, earlierPostedAt);
145
- if (isEarlierOnIssue === null) {
246
+ const earlierCommentId = await findCommentOnIssue(issueKey, comparableText, earlierPostedAt);
247
+ if (earlierCommentId === null) {
146
248
  return { kind: 'unchecked', detail: 'the issue could not be read to check whether the earlier attempt landed' };
147
249
  }
148
250
  deps.unconfirmedPosts.settle(requestId, bodyHash);
149
- if (isEarlierOnIssue)
150
- return 'posted';
251
+ if (earlierCommentId !== false)
252
+ return { kind: 'posted', commentId: earlierCommentId };
151
253
  }
152
254
  const postStartedAt = deps.now();
153
255
  let result;
154
256
  try {
155
- result = await client.addComment(issueKey, body);
257
+ result = await client.addComment(issueKey, body, parentId);
156
258
  }
157
259
  catch (error) {
158
- return { kind: 'refused', detail: error instanceof Error ? error.message : String(error) };
260
+ return { kind: 'refused', detail: error instanceof Error ? error.message : String(error), status: error instanceof client_1.JiraHttpError ? error.status : 0 };
159
261
  }
160
262
  if (result.outcome === 'created')
161
- return 'posted';
263
+ return { kind: 'posted', commentId: result.id };
162
264
  // R18: a post that timed out or met a 5xx may still be committing on Jira's side.
163
265
  await deps.wait(exports.jiraReadBackDelayMs);
164
- const isOnIssue = await checkIsCommentOnIssue(issueKey, comparableText, postStartedAt);
165
- if (isOnIssue === true)
166
- return 'posted';
266
+ const landedCommentId = await findCommentOnIssue(issueKey, comparableText, postStartedAt);
267
+ if (landedCommentId !== false && landedCommentId !== null)
268
+ return { kind: 'posted', commentId: landedCommentId };
167
269
  if (requestId !== null)
168
270
  deps.unconfirmedPosts.recordUnconfirmed(requestId, bodyHash, postStartedAt);
169
- return isOnIssue === false
271
+ return landedCommentId === false
170
272
  ? { kind: 'notPosted', detail: `${result.reason}; it was not on the issue ${exports.jiraReadBackDelayMs / 1000} s later` }
171
273
  : { kind: 'unknown', detail: result.reason };
172
274
  }
173
- async function postComments(issueKey, bodies, requestId) {
174
- let postedCount = 0;
275
+ /**
276
+ * Post `bodies` in order, in the thread of `threadRootId` or top-level (`null`). A reply Jira refuses with 400 — the
277
+ * thread's comments are gone — is posted top-level instead, and so is the rest of the answer: a refusal posted nothing.
278
+ */
279
+ async function postComments(issueKey, bodies, requestId, threadRootId) {
280
+ const commentIds = [];
281
+ let parentId = threadRootId;
282
+ let refusedThreadRootId = null;
175
283
  for (const body of bodies) {
176
- const outcome = await postComment(issueKey, body, requestId);
177
- if (outcome !== 'posted')
178
- return { postedCount, failure: outcome };
179
- postedCount += 1;
284
+ let outcome = await postComment(issueKey, body, requestId, parentId);
285
+ if (outcome.kind === 'refused' && outcome.status === threadRefusedStatus && parentId !== null) {
286
+ console.warn(`[jira] ${issueKey}: the thread of comment ${parentId} was refused (${outcome.detail}); posting top-level`);
287
+ refusedThreadRootId = parentId;
288
+ parentId = null;
289
+ outcome = await postComment(issueKey, body, requestId, null);
290
+ }
291
+ if (outcome.kind !== 'posted')
292
+ return { postedCount: commentIds.length, commentIds, failure: outcome, refusedThreadRootId };
293
+ commentIds.push(outcome.commentId);
294
+ }
295
+ return { postedCount: commentIds.length, commentIds, failure: null, refusedThreadRootId };
296
+ }
297
+ /** One try at the edit: `edited`, a refusal that changed nothing (404, 400, 403, a rate limit), or an outcome Jira did not confirm. */
298
+ async function sendEdit(issueKey, commentId, body) {
299
+ try {
300
+ await client.editComment(issueKey, commentId, body);
301
+ return 'edited';
302
+ }
303
+ catch (error) {
304
+ const status = error instanceof client_1.JiraHttpError || error instanceof client_1.JiraAuthError ? error.status : 0;
305
+ const isRefused = error instanceof client_1.JiraAuthError || (status >= 400 && status < 500);
306
+ return { kind: isRefused ? 'refused' : 'unconfirmed', detail: error instanceof Error ? error.message : String(error) };
307
+ }
308
+ }
309
+ /**
310
+ * Replace the text of comment `commentId` with `body`. `edited` — it is there now. `notEdited` — it is not (the comment is gone, Jira
311
+ * refuses the edit): the caller posts the text as a new comment. `unknown` — Jira did not confirm the edit and the comment could not
312
+ * be read to check: nothing may be posted (the edit may have landed — the text would stand twice), and the agent is told to send it
313
+ * again, which edits the same comment again. An edit repeats harmlessly, so after an outcome Jira did not confirm (a timeout, a 5xx
314
+ * after the client's retries) the comment is read after the read-back's wait: the new text on it counts as edited, the OLD text
315
+ * gets ONE more edit (the first may still be committing, or was lost) before the text goes into a new comment.
316
+ */
317
+ async function editCommentText(issueKey, commentId, body) {
318
+ const first = await sendEdit(issueKey, commentId, body);
319
+ if (first === 'edited')
320
+ return first;
321
+ if (first.kind === 'refused')
322
+ return { kind: 'notEdited', detail: first.detail };
323
+ await deps.wait(exports.jiraReadBackDelayMs);
324
+ let shown;
325
+ try {
326
+ shown = await client.getComment(issueKey, commentId);
327
+ }
328
+ catch (readError) {
329
+ // A comment that is gone cannot have been edited; one that cannot be read leaves the outcome open.
330
+ if (readError instanceof client_1.JiraHttpError && readError.status === 404)
331
+ return { kind: 'notEdited', detail: `${first.detail}; the comment is gone` };
332
+ console.warn(`[jira] ${issueKey}: read-back of comment ${commentId} after an edit of unknown outcome failed: ${readError instanceof Error ? readError.message : String(readError)}`);
333
+ return { kind: 'unknown', detail: first.detail };
334
+ }
335
+ if (getComparableText(shown.body) === getComparableText(body))
336
+ return 'edited';
337
+ const second = await sendEdit(issueKey, commentId, body);
338
+ return second === 'edited' ? second : { kind: 'notEdited', detail: second.detail };
339
+ }
340
+ /**
341
+ * Put the closing line on top of each progress comment an answer of `kind` ends. Cosmetic: the answer has landed, so a comment that
342
+ * cannot be read or edited stays as it is, with a warning; one that already carries a closing line is left alone.
343
+ */
344
+ async function closeProgressComments(issueKey, commentIds, kind) {
345
+ const [closedParagraph] = (0, adf_1.createPlainTextAdf)(buildJiraProgressClosedText(kind, deps.now())).content;
346
+ for (const commentId of commentIds) {
347
+ try {
348
+ const shown = await client.getComment(issueKey, commentId);
349
+ const content = shown.body?.content ?? [];
350
+ const firstLine = (0, adf_1.getAdfText)(content[0] ?? null);
351
+ if (firstLine.startsWith(progressDoneMark) || firstLine.startsWith(progressPausedMark))
352
+ continue;
353
+ await client.editComment(issueKey, commentId, { version: 1, type: 'doc', content: [closedParagraph, ...content] });
354
+ }
355
+ catch (error) {
356
+ console.warn(`[jira] ${issueKey}: progress comment ${commentId} could not be marked ${kind === 'final' ? 'done' : 'paused'}: ${error instanceof Error ? error.message : String(error)}`);
357
+ }
180
358
  }
181
- return { postedCount, failure: null };
182
359
  }
183
360
  /**
184
361
  * The person a mention request is about: its comment's author, when it is the request's requester and a person
@@ -201,9 +378,9 @@ function createJiraAnswerSink(deps) {
201
378
  }
202
379
  }
203
380
  /**
204
- * The author of comment `commentId` when the agent may reply to it that way: the conversation was shown it and
205
- * its text was readable then, its author is a person other than the AI account, and — with a trusted group —
206
- * the comment is trusted now (author and last editor). `null` otherwise.
381
+ * Comment `commentId` when the agent may reply to it — its author to mention, the thread the answer goes into:
382
+ * the conversation was shown it and its text was readable then, its author is a person other than the AI account,
383
+ * and — with a trusted group — the comment is trusted now (author and last editor). `null` otherwise.
207
384
  */
208
385
  async function getReplyTarget(issueKey, commentId) {
209
386
  const shown = deps.contextLedger.getShownBlock(issueKey, `comment:${commentId}`);
@@ -215,7 +392,7 @@ function createJiraAnswerSink(deps) {
215
392
  if (!author || author.accountId === deps.aiAccountId || !(0, trigger_1.checkIsPersonAccount)(author))
216
393
  return null;
217
394
  const trust = deps.getTrust();
218
- return trust && !(0, issueBlocks_1.checkIsCommentTrusted)(comment, trust) ? null : author;
395
+ return trust && !(0, issueBlocks_1.checkIsCommentTrusted)(comment, trust) ? null : { author, threadRootId: (0, client_1.getCommentThreadRootId)(comment) };
219
396
  }
220
397
  catch (error) {
221
398
  // An id Jira does not know is the agent's slip, told to it in the result; anything else is the operator's to see.
@@ -227,9 +404,10 @@ function createJiraAnswerSink(deps) {
227
404
  }
228
405
  /**
229
406
  * Whom an answer notifies, requester first, each once: the requester of a mention request, and the authors of the
230
- * comments the answer replies to. `leftOutCommentIds` are the replies that did not qualify.
407
+ * comments the answer replies to. `leftOutCommentIds` are the replies that did not qualify; `threadRootId` is the
408
+ * thread of the first that did (`null`: none did), and `otherThreadCommentIds` those that qualified in another thread.
231
409
  */
232
- async function resolveMentionTargets(issueKey, delivery) {
410
+ async function resolveReplyTargets(issueKey, delivery) {
233
411
  const targets = new Map();
234
412
  if (delivery.origin.kind === 'trackerMention') {
235
413
  const requester = await getMentionRequester(issueKey, delivery.origin);
@@ -237,14 +415,34 @@ function createJiraAnswerSink(deps) {
237
415
  targets.set(requester.accountId, requester);
238
416
  }
239
417
  const leftOutCommentIds = [];
418
+ const otherThreadCommentIds = [];
419
+ let threadRootId = null;
240
420
  for (const commentId of new Set(delivery.replyToCommentIds ?? [])) {
241
- const author = await getReplyTarget(issueKey, commentId);
242
- if (author)
243
- targets.set(author.accountId, author);
244
- else
421
+ const target = await getReplyTarget(issueKey, commentId);
422
+ if (!target) {
245
423
  leftOutCommentIds.push(commentId);
424
+ continue;
425
+ }
426
+ targets.set(target.author.accountId, target.author);
427
+ if (threadRootId === null)
428
+ threadRootId = target.threadRootId;
429
+ else if (target.threadRootId !== threadRootId)
430
+ otherThreadCommentIds.push(commentId);
431
+ }
432
+ return { targets: [...targets.values()], leftOutCommentIds, threadRootId, otherThreadCommentIds };
433
+ }
434
+ /** The answer's files attached (`null`: it carries none), or why they could not be. */
435
+ async function attachAnswerFiles(issueKey, paths) {
436
+ if (!paths || paths.length === 0)
437
+ return null;
438
+ if (!deps.attachFiles)
439
+ return { ok: false, error: exports.jiraFilesUnavailableError };
440
+ try {
441
+ return await deps.attachFiles(issueKey, paths, { isShownInline: true });
442
+ }
443
+ catch (error) {
444
+ return { ok: false, error: `the files could not be attached (${error instanceof Error ? error.message : String(error)}); nothing was posted` };
246
445
  }
247
- return { targets: [...targets.values()], leftOutCommentIds };
248
446
  }
249
447
  /** Hand the issue back to the requester while it is still the AI's; a warning when that could not happen. */
250
448
  async function handBack(issueKey, requesterAccountId) {
@@ -266,16 +464,16 @@ function createJiraAnswerSink(deps) {
266
464
  * A notice the bot writes itself (no agent ran), then the hand-back to the requester. A notice that did not land
267
465
  * is a warning and no hand-back: the issue stays the AI's, and the trigger is recorded already, so it is not repeated.
268
466
  */
269
- async function postNoticeAndHandBack(issueKey, requester, notice, noticeKind) {
270
- if (!await postNotice(issueKey, notice, noticeKind))
467
+ async function postNoticeAndHandBack(issueKey, requester, notice, noticeKind, threadRootId) {
468
+ if (!await postNotice(issueKey, notice, noticeKind, threadRootId))
271
469
  return;
272
470
  const handBackWarning = await handBack(issueKey, requester?.accountId ?? requestGroup_1.emptyRequester);
273
471
  if (handBackWarning)
274
472
  console.warn(`[jira] ${issueKey}: ${noticeKind}: ${handBackWarning}`);
275
473
  }
276
- /** A notice the bot writes itself; `false` (and a warning) when it did not land. */
277
- async function postNotice(issueKey, notice, noticeKind) {
278
- const posted = await postComments(issueKey, [notice], null);
474
+ /** A notice the bot writes itself, in the thread of `threadRootId` or top-level; `false` (and a warning) when it did not land. */
475
+ async function postNotice(issueKey, notice, noticeKind, threadRootId) {
476
+ const posted = await postComments(issueKey, [notice], null, threadRootId);
279
477
  if (posted.postedCount === 0 && posted.failure) {
280
478
  console.warn(`[jira] ${issueKey}: ${noticeKind} notice not posted: ${getNothingPostedError(posted.failure)}`);
281
479
  return false;
@@ -301,6 +499,11 @@ function createJiraAnswerSink(deps) {
301
499
  return `Nothing was posted: ${failure.detail}. Send the answer again in a few minutes`;
302
500
  }
303
501
  }
502
+ /** The edit of the progress comment was not confirmed and the comment could not be read: nothing was posted, the resend edits it again. */
503
+ function getEditUnknownError(detail) {
504
+ return `Jira did not confirm the edit of your progress comment and the comment could not be read to check it (${detail}); it may be edited already. ` +
505
+ 'Nothing was posted. Send the progress again, unchanged: the same comment is edited again, which is safe to repeat';
506
+ }
304
507
  /** A failure after some comments landed: where the unposted rest starts, so only that rest is sent again. */
305
508
  function getMissingPartsWarning(bodies, posted, failure) {
306
509
  const restStart = `"${getTextPreview(bodies[posted.postedCount])}"`;
@@ -315,25 +518,85 @@ function createJiraAnswerSink(deps) {
315
518
  return `${postedPart}, the rest did not (${failure.detail}). Send the rest again, starting at ${restStart} — not the comments already posted`;
316
519
  }
317
520
  return {
521
+ noteIssueUpdate(requestId, threadRootId) {
522
+ deps.answerThreads.note(requestId, threadRootId);
523
+ deps.progressComments.forgetAll(requestId);
524
+ },
525
+ noteLinkedIssueUpdate(requestId) {
526
+ deps.progressComments.forgetAll(requestId);
527
+ },
318
528
  async deliverAnswer(key, delivery) {
319
529
  const issueKey = key.thread;
320
- const { targets, leftOutCommentIds } = await resolveMentionTargets(issueKey, delivery);
321
- const bodies = targets.length > 0
530
+ const replies = await resolveReplyTargets(issueKey, delivery);
531
+ const { targets, leftOutCommentIds } = replies;
532
+ // The comment the agent replies to decides the thread; else the thread an update of the request came from; else the
533
+ // thread the request was opened in; else top-level.
534
+ let threadRootId = replies.threadRootId ?? deps.answerThreads.get(delivery.requestId) ?? getOriginThreadRootId(delivery.origin);
535
+ const textBodies = targets.length > 0
322
536
  ? (0, adf_1.createCommentBodiesWithLeadingNode)(delivery.body, (0, adf_1.createMentionParagraph)(targets))
323
537
  : (0, adf_1.createCommentBodies)(delivery.body);
324
- if (bodies.length === 0)
538
+ if (textBodies.length === 0)
325
539
  return { ok: false, error: 'the answer is empty' };
540
+ // Attached before anything is posted: a file that cannot be attached leaves the answer undelivered, safe to send again.
541
+ const files = await attachAnswerFiles(issueKey, delivery.files);
542
+ if (files && !files.ok)
543
+ return { ok: false, error: files.error };
544
+ const bodies = files ? (0, outgoingFiles_1.appendNodesToBodies)(textBodies, files.nodes) : textBodies;
326
545
  // Only a hand-over's question hands the issue back, so only it carries the line saying how to give it back —
327
546
  // and only while its request is open: a superseded request's question hands nothing back.
328
547
  const isHandOver = delivery.origin.kind === 'trackerEvent';
329
548
  if (isHandOver && delivery.isRequestOpen && delivery.kind === 'question')
330
549
  bodies[bodies.length - 1] = getBodyWithContinueLine(bodies[bodies.length - 1]);
331
- const posted = await postComments(issueKey, bodies, delivery.requestId);
550
+ // A plain note that fits one comment is kept as that comment, edited by the next one.
551
+ const slot = bodies.length === 1 ? getEditableSlot(delivery) : null;
552
+ const kept = slot === null ? null : deps.progressComments.get(delivery.requestId, slot);
553
+ if (slot !== null && kept !== null) {
554
+ const edited = await editCommentText(issueKey, kept.commentId, getBodyWithUpdatedLine(bodies[0], deps.now()));
555
+ if (edited === 'edited') {
556
+ // The agent has spoken since the bot's notices: the next one of them is a new comment below, not an edit above.
557
+ if (!delivery.isBotNotice)
558
+ deps.progressComments.forgetAll(delivery.requestId, [slot]);
559
+ return { ok: true };
560
+ }
561
+ // An edit that may have landed: nothing is posted, the comment stays the kept one and the resend edits it again.
562
+ if (edited.kind === 'unknown')
563
+ return { ok: false, error: getEditUnknownError(edited.detail) };
564
+ // The text goes into a new comment in the thread the old one stood in, which stays the progress comment's.
565
+ console.warn(`[jira] ${issueKey}: comment ${kept.commentId} could not be edited (${edited.detail}); posting the progress as a new comment`);
566
+ threadRootId = kept.threadRootId;
567
+ }
568
+ // The progress comments this answer ends: its request's and those of the requests it replaced, kept or released.
569
+ const isEndingAnswer = !delivery.isBotNotice && (delivery.kind === 'final' || delivery.kind === 'question');
570
+ const endedRequestIds = isEndingAnswer ? [delivery.requestId, ...(delivery.supersededRequestIds ?? [])] : [];
571
+ const endedProgressCommentIds = [...new Set(endedRequestIds.flatMap((requestId) => deps.progressComments.listToClose(requestId)))];
572
+ const posted = await postComments(issueKey, bodies, delivery.requestId, threadRootId);
332
573
  if (posted.postedCount === 0 && posted.failure)
333
574
  return { ok: false, error: getNothingPostedError(posted.failure) };
334
- const warnings = [];
575
+ // The agent's answer is there: the thread an update put it in is used up, the next answer goes where they go by default.
576
+ // A notice the bot wrote (a usage limit, a refused sign-in) goes into that thread too but uses nothing up: the agent's
577
+ // answer to the reply is still owed, and comes after the resume.
578
+ if (!delivery.isBotNotice)
579
+ deps.answerThreads.consume(delivery.requestId);
580
+ if (slot !== null)
581
+ deps.progressComments.remember(delivery.requestId, slot, posted.commentIds[0], posted.refusedThreadRootId === null ? threadRootId : null);
582
+ // A comment was added: every chain of edits that stands above it ends, so the next of each is a new comment below — a notice
583
+ // of the bot's own is one chain, the agent's progress note another. The agent's answer ends the bot's notices (a question, a
584
+ // final answer or a note that is a comment of its own ends its progress comment too); a bot comment that stands on its own
585
+ // (an account moved, no account usable) ends the notices and leaves the agent's note, which it has nothing to do with. A request
586
+ // this answer ends is settled instead: everything it keeps is dropped at once, with no release line for a comment just closed.
587
+ if (!endedRequestIds.includes(delivery.requestId)) {
588
+ deps.progressComments.forgetAll(delivery.requestId, [...(slot === null ? [] : [slot]), ...(delivery.isBotNotice ? [progressComments_1.jiraProgressSlot] : [])]);
589
+ }
590
+ for (const requestId of endedRequestIds)
591
+ deps.progressComments.settle(requestId);
592
+ const warnings = [...(files?.notes ?? [])];
335
593
  if (leftOutCommentIds.length > 0)
336
594
  warnings.push(buildJiraReplyLeftOutWarning(leftOutCommentIds));
595
+ if (replies.threadRootId !== null && replies.otherThreadCommentIds.length > 0) {
596
+ warnings.push(buildJiraOtherThreadsWarning(replies.threadRootId, replies.otherThreadCommentIds));
597
+ }
598
+ if (posted.refusedThreadRootId !== null)
599
+ warnings.push(buildJiraThreadRefusedWarning(posted.refusedThreadRootId));
337
600
  if (posted.failure)
338
601
  warnings.push(getMissingPartsWarning(bodies, posted, posted.failure));
339
602
  // An answer to a request that is no longer open (superseded by a newer one) must not take the issue from it.
@@ -343,13 +606,20 @@ function createJiraAnswerSink(deps) {
343
606
  if (handBackWarning)
344
607
  warnings.push(handBackWarning);
345
608
  }
609
+ // Cosmetic, so after what notifies the requester: a slow Jira delays the closing lines, never the hand-back.
610
+ if (isEndingAnswer) {
611
+ await closeProgressComments(issueKey, endedProgressCommentIds.filter((commentId) => !posted.commentIds.includes(commentId)), delivery.kind === 'final' ? 'final' : 'question');
612
+ }
346
613
  return warnings.length > 0 ? { ok: true, warning: warnings.join('; ') } : { ok: true };
347
614
  },
348
615
  async deliverAlert(key, alert) {
349
616
  const issueKey = key.thread;
350
- const posted = await postComments(issueKey, [(0, adf_1.convertMarkdownToAdf)(buildJiraAlertText(alert.requestId, alert.reason))], alert.requestId);
617
+ const posted = await postComments(issueKey, [(0, adf_1.convertMarkdownToAdf)(buildJiraAlertText(alert.reason))], alert.requestId, getOriginThreadRootId(alert.origin));
351
618
  if (posted.postedCount === 0 && posted.failure)
352
619
  return { ok: false, error: getNothingPostedError(posted.failure) };
620
+ // The comment names no request: the log does. Everything kept up to date above it stays as it is: later notes start below.
621
+ console.log(`[jira] ${issueKey}: request ${alert.requestId} given up (${alert.reason}); the alert comment is posted`);
622
+ deps.progressComments.forgetAll(alert.requestId);
353
623
  if (alert.origin.kind === 'trackerEvent') {
354
624
  const handBackWarning = await handBack(issueKey, (0, requestGroup_1.getRequestRequester)(alert.origin));
355
625
  if (handBackWarning)
@@ -359,17 +629,51 @@ function createJiraAnswerSink(deps) {
359
629
  return { ok: true };
360
630
  },
361
631
  async releaseAlert() { },
362
- parkIssue: (issueKey, requester) => postNoticeAndHandBack(issueKey, requester, (0, adf_1.convertMarkdownToAdf)(buildJiraParkText(deps.runBudgetPer24h)), 'park'),
363
- parkMention: async (issueKey) => {
364
- await postNotice(issueKey, (0, adf_1.convertMarkdownToAdf)(buildJiraMentionParkText(deps.runBudgetPer24h)), 'mention park');
632
+ parkIssue: (issueKey, requester, threadRootId = null) => postNoticeAndHandBack(issueKey, requester, (0, adf_1.convertMarkdownToAdf)(buildJiraParkText(deps.runBudgetPer24h)), 'park', threadRootId),
633
+ parkMention: async (issueKey, threadRootId = null) => {
634
+ await postNotice(issueKey, (0, adf_1.convertMarkdownToAdf)(buildJiraMentionParkText(deps.runBudgetPer24h)), 'mention park', threadRootId);
365
635
  },
636
+ // The issue's, not a trigger's: top-level.
366
637
  postUpdatesPausedNotice: async (issueKey, maxUpdates, untilMs) => {
367
- await postNotice(issueKey, (0, adf_1.createPlainTextAdf)(buildJiraUpdatesPausedText(maxUpdates, untilMs)), 'updates paused');
638
+ await postNotice(issueKey, (0, adf_1.createPlainTextAdf)(buildJiraUpdatesPausedText(maxUpdates, untilMs)), 'updates paused', null);
639
+ },
640
+ postQueuedNotice: async (issueKey, queue, threadRootId = null) => {
641
+ await postNotice(issueKey, (0, adf_1.convertMarkdownToAdf)(buildJiraQueuedText(queue.maxConcurrent, queue.aheadCount)), 'queued', threadRootId);
368
642
  },
369
- postQueuedNotice: async (issueKey, queue) => {
370
- await postNotice(issueKey, (0, adf_1.convertMarkdownToAdf)(buildJiraQueuedText(queue.maxConcurrent, queue.aheadCount)), 'queued');
643
+ // A hand-over's: it has no comment, so top-level.
644
+ refuseUntrusted: (issueKey, requester, groupName) => postNoticeAndHandBack(issueKey, requester, (0, adf_1.createPlainTextAdf)(buildJiraUntrustedText(groupName)), 'untrusted', null),
645
+ postFiles: async (issueKey, request, threadRootId) => {
646
+ if (!deps.attachFiles)
647
+ return { ok: false, error: exports.jiraFilesUnavailableError };
648
+ let files;
649
+ try {
650
+ files = await deps.attachFiles(issueKey, request.paths, { isShownInline: !request.isAsLinks });
651
+ }
652
+ catch (error) {
653
+ return { ok: false, error: `the files could not be attached (${error instanceof Error ? error.message : String(error)}); nothing was posted` };
654
+ }
655
+ if (!files.ok)
656
+ return { ok: false, error: files.error };
657
+ const caption = request.caption?.trim() ?? '';
658
+ const bodies = (0, outgoingFiles_1.appendNodesToBodies)(caption === '' ? [] : (0, adf_1.createCommentBodies)(caption), files.nodes);
659
+ const posted = await postComments(issueKey, bodies, null, threadRootId);
660
+ if (posted.postedCount === 0 && posted.failure) {
661
+ const error = `the files are attached to ${issueKey} — ${files.summary} — but the comment that shows them was not posted (${posted.failure.detail}); ` +
662
+ 'sending them again reuses the attachments';
663
+ return posted.failure.kind === 'unknown' ? { ok: false, kind: 'deliveryUnknown', error } : { ok: false, error };
664
+ }
665
+ const notes = [
666
+ ...files.notes,
667
+ ...(posted.refusedThreadRootId === null ? [] : [buildJiraThreadRefusedWarning(posted.refusedThreadRootId)]),
668
+ ...(posted.failure ? [`only the first ${posted.postedCount} of the comment's ${bodies.length} parts were posted (${posted.failure.detail})`] : []),
669
+ ];
670
+ const place = threadRootId === null || posted.refusedThreadRootId !== null ? 'a comment' : `a comment in the thread of comment ${threadRootId}`;
671
+ return {
672
+ ok: true,
673
+ summary: `Posted in ${place} on ${issueKey}: ${files.summary}.${notes.length > 0 ? ` Note: ${notes.join('; ')}.` : ''}`,
674
+ sentKinds: files.sentKinds,
675
+ };
371
676
  },
372
- refuseUntrusted: (issueKey, requester, groupName) => postNoticeAndHandBack(issueKey, requester, (0, adf_1.createPlainTextAdf)(buildJiraUntrustedText(groupName)), 'untrusted'),
373
677
  };
374
678
  }
375
679
  //# sourceMappingURL=answerSink.js.map