charness 4.1.0 → 4.2.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 (312) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/DEVELOPMENT.md +11 -5
  3. package/{COMMERCIAL-LICENSE.md → LICENSE-COMMERCIAL.md} +1 -1
  4. package/MIGRATION_3_TO_4.md +1 -1
  5. package/README.md +4 -1
  6. package/SETUP.md +37 -9
  7. package/agent-plugin/skills/charness-delegate-claude/SKILL.md +1 -0
  8. package/agent-plugin/skills/charness-orchestration/SKILL.md +1 -0
  9. package/dist/adapters/adapterNames.d.ts +2 -0
  10. package/dist/adapters/adapterNames.d.ts.map +1 -1
  11. package/dist/adapters/adapterNames.js +3 -1
  12. package/dist/adapters/adapterNames.js.map +1 -1
  13. package/dist/adapters/claudeJsonStreamAdapter.d.ts +74 -5
  14. package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -1
  15. package/dist/adapters/claudeJsonStreamAdapter.js +164 -20
  16. package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
  17. package/dist/adapters/openCodeAdapter.d.ts +31 -2
  18. package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
  19. package/dist/adapters/openCodeAdapter.js +84 -8
  20. package/dist/adapters/openCodeAdapter.js.map +1 -1
  21. package/dist/adapters/terminalAdapter.d.ts.map +1 -1
  22. package/dist/adapters/terminalAdapter.js +2 -1
  23. package/dist/adapters/terminalAdapter.js.map +1 -1
  24. package/dist/bot.d.ts.map +1 -1
  25. package/dist/bot.js +769 -118
  26. package/dist/bot.js.map +1 -1
  27. package/dist/cli/claudeProfiles.d.ts +3 -0
  28. package/dist/cli/claudeProfiles.d.ts.map +1 -1
  29. package/dist/cli/claudeProfiles.js +8 -0
  30. package/dist/cli/claudeProfiles.js.map +1 -1
  31. package/dist/connectors/jira/answerSink.d.ts +8 -0
  32. package/dist/connectors/jira/answerSink.d.ts.map +1 -1
  33. package/dist/connectors/jira/answerSink.js +15 -0
  34. package/dist/connectors/jira/answerSink.js.map +1 -1
  35. package/dist/connectors/jira/config.d.ts +16 -0
  36. package/dist/connectors/jira/config.d.ts.map +1 -1
  37. package/dist/connectors/jira/config.js +21 -2
  38. package/dist/connectors/jira/config.js.map +1 -1
  39. package/dist/connectors/jira/connector.d.ts +10 -3
  40. package/dist/connectors/jira/connector.d.ts.map +1 -1
  41. package/dist/connectors/jira/connector.js +21 -3
  42. package/dist/connectors/jira/connector.js.map +1 -1
  43. package/dist/connectors/jira/inbound.d.ts +200 -18
  44. package/dist/connectors/jira/inbound.d.ts.map +1 -1
  45. package/dist/connectors/jira/inbound.js +814 -43
  46. package/dist/connectors/jira/inbound.js.map +1 -1
  47. package/dist/connectors/jira/prompt.d.ts +46 -0
  48. package/dist/connectors/jira/prompt.d.ts.map +1 -1
  49. package/dist/connectors/jira/prompt.js +123 -15
  50. package/dist/connectors/jira/prompt.js.map +1 -1
  51. package/dist/connectors/jira/trigger.d.ts +27 -4
  52. package/dist/connectors/jira/trigger.d.ts.map +1 -1
  53. package/dist/connectors/jira/trigger.js +35 -1
  54. package/dist/connectors/jira/trigger.js.map +1 -1
  55. package/dist/connectors/jira/triggerLog.d.ts +60 -5
  56. package/dist/connectors/jira/triggerLog.d.ts.map +1 -1
  57. package/dist/connectors/jira/triggerLog.js +116 -7
  58. package/dist/connectors/jira/triggerLog.js.map +1 -1
  59. package/dist/connectors/telegram/commands/botCore.d.ts +5 -2
  60. package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -1
  61. package/dist/connectors/telegram/commands/claudeAccounts.d.ts +5 -0
  62. package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -1
  63. package/dist/connectors/telegram/commands/claudeAccounts.js +15 -39
  64. package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
  65. package/dist/connectors/telegram/commands/compaction.d.ts +6 -0
  66. package/dist/connectors/telegram/commands/compaction.d.ts.map +1 -1
  67. package/dist/connectors/telegram/commands/compaction.js +8 -1
  68. package/dist/connectors/telegram/commands/compaction.js.map +1 -1
  69. package/dist/connectors/telegram/commands/questionSetAside.d.ts +111 -0
  70. package/dist/connectors/telegram/commands/questionSetAside.d.ts.map +1 -0
  71. package/dist/connectors/telegram/commands/questionSetAside.js +637 -0
  72. package/dist/connectors/telegram/commands/questionSetAside.js.map +1 -0
  73. package/dist/connectors/telegram/commands/questionWait.d.ts +21 -0
  74. package/dist/connectors/telegram/commands/questionWait.d.ts.map +1 -0
  75. package/dist/connectors/telegram/commands/questionWait.js +109 -0
  76. package/dist/connectors/telegram/commands/questionWait.js.map +1 -0
  77. package/dist/connectors/telegram/commands/runners.d.ts +28 -1
  78. package/dist/connectors/telegram/commands/runners.d.ts.map +1 -1
  79. package/dist/connectors/telegram/commands/runners.js +75 -40
  80. package/dist/connectors/telegram/commands/runners.js.map +1 -1
  81. package/dist/connectors/telegram/commands/topicAccess.js +1 -1
  82. package/dist/connectors/telegram/commands/topicAccess.js.map +1 -1
  83. package/dist/connectors/telegram/commands/topicCommand.d.ts +0 -2
  84. package/dist/connectors/telegram/commands/topicCommand.d.ts.map +1 -1
  85. package/dist/connectors/telegram/commands/topicCommand.js +4 -5
  86. package/dist/connectors/telegram/commands/topicCommand.js.map +1 -1
  87. package/dist/connectors/telegram/commands/topicStatus.d.ts +24 -0
  88. package/dist/connectors/telegram/commands/topicStatus.d.ts.map +1 -0
  89. package/dist/connectors/telegram/commands/topicStatus.js +148 -0
  90. package/dist/connectors/telegram/commands/topicStatus.js.map +1 -0
  91. package/dist/connectors/telegram/firstUpdateBatchNote.d.ts +30 -0
  92. package/dist/connectors/telegram/firstUpdateBatchNote.d.ts.map +1 -0
  93. package/dist/connectors/telegram/firstUpdateBatchNote.js +39 -0
  94. package/dist/connectors/telegram/firstUpdateBatchNote.js.map +1 -0
  95. package/dist/connectors/telegram/inbound.d.ts +12 -0
  96. package/dist/connectors/telegram/inbound.d.ts.map +1 -1
  97. package/dist/connectors/telegram/inbound.js +31 -3
  98. package/dist/connectors/telegram/inbound.js.map +1 -1
  99. package/dist/connectors/telegram/sendOutcome.d.ts +3 -1
  100. package/dist/connectors/telegram/sendOutcome.d.ts.map +1 -1
  101. package/dist/connectors/telegram/sendOutcome.js.map +1 -1
  102. package/dist/connectors/telegram/telegramFailureRetry.d.ts +8 -0
  103. package/dist/connectors/telegram/telegramFailureRetry.d.ts.map +1 -1
  104. package/dist/connectors/telegram/telegramFailureRetry.js +8 -0
  105. package/dist/connectors/telegram/telegramFailureRetry.js.map +1 -1
  106. package/dist/connectors/telegram/topicIndicator.d.ts +86 -0
  107. package/dist/connectors/telegram/topicIndicator.d.ts.map +1 -0
  108. package/dist/connectors/telegram/topicIndicator.js +490 -0
  109. package/dist/connectors/telegram/topicIndicator.js.map +1 -0
  110. package/dist/connectors/telegram/waitingTopicRenames.d.ts +39 -0
  111. package/dist/connectors/telegram/waitingTopicRenames.d.ts.map +1 -0
  112. package/dist/connectors/telegram/waitingTopicRenames.js +48 -0
  113. package/dist/connectors/telegram/waitingTopicRenames.js.map +1 -0
  114. package/dist/i18n/de.d.ts.map +1 -1
  115. package/dist/i18n/de.js +51 -0
  116. package/dist/i18n/de.js.map +1 -1
  117. package/dist/i18n/en.d.ts.map +1 -1
  118. package/dist/i18n/en.js +51 -0
  119. package/dist/i18n/en.js.map +1 -1
  120. package/dist/i18n/es.d.ts.map +1 -1
  121. package/dist/i18n/es.js +51 -0
  122. package/dist/i18n/es.js.map +1 -1
  123. package/dist/i18n/fr.d.ts.map +1 -1
  124. package/dist/i18n/fr.js +51 -0
  125. package/dist/i18n/fr.js.map +1 -1
  126. package/dist/i18n/hi.d.ts.map +1 -1
  127. package/dist/i18n/hi.js +51 -0
  128. package/dist/i18n/hi.js.map +1 -1
  129. package/dist/i18n/ja.d.ts.map +1 -1
  130. package/dist/i18n/ja.js +51 -0
  131. package/dist/i18n/ja.js.map +1 -1
  132. package/dist/i18n/ka.d.ts.map +1 -1
  133. package/dist/i18n/ka.js +51 -0
  134. package/dist/i18n/ka.js.map +1 -1
  135. package/dist/i18n/pt.d.ts.map +1 -1
  136. package/dist/i18n/pt.js +51 -0
  137. package/dist/i18n/pt.js.map +1 -1
  138. package/dist/i18n/ru.d.ts.map +1 -1
  139. package/dist/i18n/ru.js +51 -0
  140. package/dist/i18n/ru.js.map +1 -1
  141. package/dist/i18n/uk.d.ts.map +1 -1
  142. package/dist/i18n/uk.js +51 -0
  143. package/dist/i18n/uk.js.map +1 -1
  144. package/dist/i18n/uz.d.ts.map +1 -1
  145. package/dist/i18n/uz.js +51 -0
  146. package/dist/i18n/uz.js.map +1 -1
  147. package/dist/i18n/zh.d.ts.map +1 -1
  148. package/dist/i18n/zh.js +51 -0
  149. package/dist/i18n/zh.js.map +1 -1
  150. package/dist/i18n.d.ts.map +1 -1
  151. package/dist/i18n.js +2 -1
  152. package/dist/i18n.js.map +1 -1
  153. package/dist/instanceSettings.d.ts +19 -1
  154. package/dist/instanceSettings.d.ts.map +1 -1
  155. package/dist/instanceSettings.js +35 -2
  156. package/dist/instanceSettings.js.map +1 -1
  157. package/dist/openCodeOpenQuestion.d.ts +12 -4
  158. package/dist/openCodeOpenQuestion.d.ts.map +1 -1
  159. package/dist/openCodeOpenQuestion.js +16 -7
  160. package/dist/openCodeOpenQuestion.js.map +1 -1
  161. package/dist/openCodeQuestionFlow.d.ts +10 -2
  162. package/dist/openCodeQuestionFlow.d.ts.map +1 -1
  163. package/dist/openCodeQuestionFlow.js +27 -5
  164. package/dist/openCodeQuestionFlow.js.map +1 -1
  165. package/dist/postToSession.d.ts +9 -0
  166. package/dist/postToSession.d.ts.map +1 -1
  167. package/dist/postToSession.js +15 -2
  168. package/dist/postToSession.js.map +1 -1
  169. package/dist/requests/requestHeader.d.ts.map +1 -1
  170. package/dist/requests/requestHeader.js +1 -0
  171. package/dist/requests/requestHeader.js.map +1 -1
  172. package/dist/requests/types.d.ts +4 -1
  173. package/dist/requests/types.d.ts.map +1 -1
  174. package/dist/requests/wakeUpEngine.d.ts +31 -1
  175. package/dist/requests/wakeUpEngine.d.ts.map +1 -1
  176. package/dist/requests/wakeUpEngine.js +94 -2
  177. package/dist/requests/wakeUpEngine.js.map +1 -1
  178. package/dist/requests/wakeUpRules.d.ts +7 -0
  179. package/dist/requests/wakeUpRules.d.ts.map +1 -1
  180. package/dist/requests/wakeUpRules.js +14 -0
  181. package/dist/requests/wakeUpRules.js.map +1 -1
  182. package/dist/scheduler/engine.d.ts +17 -4
  183. package/dist/scheduler/engine.d.ts.map +1 -1
  184. package/dist/scheduler/engine.js +55 -10
  185. package/dist/scheduler/engine.js.map +1 -1
  186. package/dist/scheduler/mcpBoot.d.ts +6 -2
  187. package/dist/scheduler/mcpBoot.d.ts.map +1 -1
  188. package/dist/scheduler/mcpBoot.js +7 -1
  189. package/dist/scheduler/mcpBoot.js.map +1 -1
  190. package/dist/scheduler/mcpSurface.d.ts.map +1 -1
  191. package/dist/scheduler/mcpSurface.js +18 -9
  192. package/dist/scheduler/mcpSurface.js.map +1 -1
  193. package/dist/sendErrorClassifier.d.ts +6 -0
  194. package/dist/sendErrorClassifier.d.ts.map +1 -1
  195. package/dist/sendErrorClassifier.js +9 -0
  196. package/dist/sendErrorClassifier.js.map +1 -1
  197. package/dist/startupPromptBuffer.d.ts +8 -8
  198. package/dist/startupPromptBuffer.d.ts.map +1 -1
  199. package/dist/startupPromptBuffer.js +7 -5
  200. package/dist/startupPromptBuffer.js.map +1 -1
  201. package/dist/state.d.ts +98 -6
  202. package/dist/state.d.ts.map +1 -1
  203. package/dist/state.js +149 -7
  204. package/dist/state.js.map +1 -1
  205. package/dist/testTimings.d.ts +12 -3
  206. package/dist/testTimings.d.ts.map +1 -1
  207. package/dist/testTimings.js +23 -2
  208. package/dist/testTimings.js.map +1 -1
  209. package/dist/threadRouting.d.ts +23 -0
  210. package/dist/threadRouting.d.ts.map +1 -1
  211. package/dist/threadRouting.js +28 -0
  212. package/dist/threadRouting.js.map +1 -1
  213. package/dist/todos/registry.d.ts +2 -0
  214. package/dist/todos/registry.d.ts.map +1 -1
  215. package/dist/todos/registry.js +3 -1
  216. package/dist/todos/registry.js.map +1 -1
  217. package/dist/trackers/taskAgentSlots.d.ts +42 -3
  218. package/dist/trackers/taskAgentSlots.d.ts.map +1 -1
  219. package/dist/trackers/taskAgentSlots.js +31 -11
  220. package/dist/trackers/taskAgentSlots.js.map +1 -1
  221. package/dist/types.d.ts +95 -0
  222. package/dist/types.d.ts.map +1 -1
  223. package/dist/utils/claudeCompactHook.d.ts +3 -1
  224. package/dist/utils/claudeCompactHook.d.ts.map +1 -1
  225. package/dist/utils/claudeCompactHook.js +3 -1
  226. package/dist/utils/claudeCompactHook.js.map +1 -1
  227. package/dist/utils/claudeLimitSwitch.d.ts +1 -1
  228. package/dist/utils/claudeLimitSwitch.d.ts.map +1 -1
  229. package/dist/utils/claudeLimitSwitch.js +1 -1
  230. package/dist/utils/claudeLimitSwitch.js.map +1 -1
  231. package/dist/utils/claudeProfileSync.d.ts +88 -0
  232. package/dist/utils/claudeProfileSync.d.ts.map +1 -0
  233. package/dist/utils/claudeProfileSync.js +198 -0
  234. package/dist/utils/claudeProfileSync.js.map +1 -0
  235. package/dist/utils/claudeProfiles.d.ts +101 -6
  236. package/dist/utils/claudeProfiles.d.ts.map +1 -1
  237. package/dist/utils/claudeProfiles.js +288 -23
  238. package/dist/utils/claudeProfiles.js.map +1 -1
  239. package/dist/utils/claudeUsageRefresher.d.ts +8 -1
  240. package/dist/utils/claudeUsageRefresher.d.ts.map +1 -1
  241. package/dist/utils/claudeUsageRefresher.js +11 -1
  242. package/dist/utils/claudeUsageRefresher.js.map +1 -1
  243. package/dist/utils/cutButtonLabel.d.ts +7 -0
  244. package/dist/utils/cutButtonLabel.d.ts.map +1 -0
  245. package/dist/utils/cutButtonLabel.js +17 -0
  246. package/dist/utils/cutButtonLabel.js.map +1 -0
  247. package/dist/utils/fileSendPlan.d.ts +30 -8
  248. package/dist/utils/fileSendPlan.d.ts.map +1 -1
  249. package/dist/utils/fileSendPlan.js +37 -12
  250. package/dist/utils/fileSendPlan.js.map +1 -1
  251. package/dist/utils/fileSendService.d.ts +1 -1
  252. package/dist/utils/fileSendService.d.ts.map +1 -1
  253. package/dist/utils/fileSendService.js +9 -1
  254. package/dist/utils/fileSendService.js.map +1 -1
  255. package/dist/utils/imageDimensions.d.ts +32 -0
  256. package/dist/utils/imageDimensions.d.ts.map +1 -0
  257. package/dist/utils/imageDimensions.js +181 -0
  258. package/dist/utils/imageDimensions.js.map +1 -0
  259. package/dist/utils/jsonStreamHost.d.ts +35 -9
  260. package/dist/utils/jsonStreamHost.d.ts.map +1 -1
  261. package/dist/utils/jsonStreamHost.js +59 -16
  262. package/dist/utils/jsonStreamHost.js.map +1 -1
  263. package/dist/utils/limitSwitchPlan.d.ts +44 -0
  264. package/dist/utils/limitSwitchPlan.d.ts.map +1 -0
  265. package/dist/utils/limitSwitchPlan.js +54 -0
  266. package/dist/utils/limitSwitchPlan.js.map +1 -0
  267. package/dist/utils/lostWork.d.ts +8 -2
  268. package/dist/utils/lostWork.d.ts.map +1 -1
  269. package/dist/utils/lostWork.js +9 -5
  270. package/dist/utils/lostWork.js.map +1 -1
  271. package/dist/utils/promptDelivery.d.ts +11 -2
  272. package/dist/utils/promptDelivery.d.ts.map +1 -1
  273. package/dist/utils/promptDelivery.js +3 -3
  274. package/dist/utils/promptDelivery.js.map +1 -1
  275. package/dist/utils/questionWaitChoices.d.ts +20 -0
  276. package/dist/utils/questionWaitChoices.d.ts.map +1 -0
  277. package/dist/utils/questionWaitChoices.js +31 -0
  278. package/dist/utils/questionWaitChoices.js.map +1 -0
  279. package/dist/utils/questionWaitPlan.d.ts +166 -0
  280. package/dist/utils/questionWaitPlan.d.ts.map +1 -0
  281. package/dist/utils/questionWaitPlan.js +237 -0
  282. package/dist/utils/questionWaitPlan.js.map +1 -0
  283. package/dist/utils/replyQuote.d.ts +10 -0
  284. package/dist/utils/replyQuote.d.ts.map +1 -1
  285. package/dist/utils/replyQuote.js +18 -7
  286. package/dist/utils/replyQuote.js.map +1 -1
  287. package/dist/utils/talkerAccess.d.ts +2 -2
  288. package/dist/utils/talkerAccess.d.ts.map +1 -1
  289. package/dist/utils/talkerAccess.js +5 -4
  290. package/dist/utils/talkerAccess.js.map +1 -1
  291. package/dist/utils/telegramError.d.ts +6 -0
  292. package/dist/utils/telegramError.d.ts.map +1 -1
  293. package/dist/utils/telegramError.js +12 -0
  294. package/dist/utils/telegramError.js.map +1 -1
  295. package/dist/utils/topicAccessScreenPlan.d.ts +1 -1
  296. package/dist/utils/topicAccessScreenPlan.d.ts.map +1 -1
  297. package/dist/utils/topicAccessScreenPlan.js +3 -7
  298. package/dist/utils/topicAccessScreenPlan.js.map +1 -1
  299. package/dist/utils/topicIndicatorPlan.d.ts +143 -0
  300. package/dist/utils/topicIndicatorPlan.d.ts.map +1 -0
  301. package/dist/utils/topicIndicatorPlan.js +202 -0
  302. package/dist/utils/topicIndicatorPlan.js.map +1 -0
  303. package/dist/utils/topicIndicatorSources.d.ts +40 -0
  304. package/dist/utils/topicIndicatorSources.d.ts.map +1 -0
  305. package/dist/utils/topicIndicatorSources.js +31 -0
  306. package/dist/utils/topicIndicatorSources.js.map +1 -0
  307. package/dist/utils/topicStatusPlan.d.ts +90 -0
  308. package/dist/utils/topicStatusPlan.d.ts.map +1 -0
  309. package/dist/utils/topicStatusPlan.js +160 -0
  310. package/dist/utils/topicStatusPlan.js.map +1 -0
  311. package/npm-shrinkwrap.json +2 -2
  312. package/package.json +2 -2
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mentionTriggerIdPrefix = exports.createdTriggerId = void 0;
3
+ exports.updatesPausedTriggerIdPrefix = exports.heldMentionTriggerIdPrefix = exports.commentTriggerIdPrefix = exports.mentionTriggerIdPrefix = exports.createdTriggerId = void 0;
4
4
  exports.createMentionTrigger = createMentionTrigger;
5
+ exports.createCommentTrigger = createCommentTrigger;
6
+ exports.checkIsHandOverTriggerId = checkIsHandOverTriggerId;
7
+ exports.compareJiraCommentIds = compareJiraCommentIds;
5
8
  exports.getItemField = getItemField;
6
9
  exports.findNewestTrigger = findNewestTrigger;
7
10
  exports.getIssueTrigger = getIssueTrigger;
@@ -26,10 +29,41 @@ const personAccountType = 'atlassian';
26
29
  const appAccountType = 'app';
27
30
  /** The trigger id of a comment that mentioned the AI account is this prefix and the comment's id (a changelog id is numeric: no clash). */
28
31
  exports.mentionTriggerIdPrefix = 'mention:';
32
+ /** The trigger id of a comment on an issue handed to the AI account (its comment scan) is this prefix and the comment's id. */
33
+ exports.commentTriggerIdPrefix = 'comment:';
34
+ /**
35
+ * Marks a mention held back from its issue update — the cap on updates paused it, or its post failed — and not decided yet:
36
+ * this prefix and the comment's id. The mention scan keeps it, outside the mention window too, until it is delivered.
37
+ */
38
+ exports.heldMentionTriggerIdPrefix = 'held-mention:';
39
+ /** The trigger id of a pause of an issue's updates (the cap): this prefix and the pause's end (epoch ms). */
40
+ exports.updatesPausedTriggerIdPrefix = 'updates-paused:';
29
41
  /** @description The trigger of the comment `commentId`, written by `author`, that mentions the AI account. */
30
42
  function createMentionTrigger(commentId, author) {
31
43
  return { triggerId: `${exports.mentionTriggerIdPrefix}${commentId}`, kind: 'mentioned', author, commentId };
32
44
  }
45
+ /**
46
+ * @description The trigger of the new comments `commentIds` (oldest first) on an issue handed to the AI account while no
47
+ * hand-over request of it is open: the newest one names it, and its author (`author`) is the requester.
48
+ */
49
+ function createCommentTrigger(commentIds, author) {
50
+ const commentId = commentIds[commentIds.length - 1];
51
+ return { triggerId: `${exports.commentTriggerIdPrefix}${commentId}`, kind: 'commented', author, commentId, commentIds };
52
+ }
53
+ /** @description A hand-over's trigger (a changelog entry, a creation) — not a comment's or a mention's. */
54
+ function checkIsHandOverTriggerId(triggerId) {
55
+ return !triggerId.startsWith(exports.mentionTriggerIdPrefix) && !triggerId.startsWith(exports.commentTriggerIdPrefix);
56
+ }
57
+ /**
58
+ * @description Order two Jira comment ids: they are numbers that grow with every comment of the site, so a later comment
59
+ * has the greater id. Compared as digit strings (any length); an id that is not one falls back to a text compare.
60
+ */
61
+ function compareJiraCommentIds(left, right) {
62
+ const isNumeric = /^\d+$/.test(left) && /^\d+$/.test(right);
63
+ if (isNumeric && left.length !== right.length)
64
+ return left.length - right.length;
65
+ return left < right ? -1 : left > right ? 1 : 0;
66
+ }
33
67
  /** A changelog item names its field by `fieldId` (stable) or, on older entries, only by `field`. */
34
68
  function getItemField(item) {
35
69
  return item.fieldId ?? item.field;
@@ -1 +1 @@
1
- {"version":3,"file":"trigger.js","sourceRoot":"","sources":["../../../src/connectors/jira/trigger.ts"],"names":[],"mappings":";;;AAsCA,oDAEC;AAQD,oCAEC;AAuBD,8CAMC;AAGD,0CAMC;AAGD,oDAEC;AAGD,8CAEC;AAaD,8CAUC;AAQD,oCAQC;AAvID;;;;;;;;GAQG;AAEH,iEAAiE;AACpD,QAAA,gBAAgB,GAAG,SAAS,CAAC;AAC1C,wCAAwC;AACxC,MAAM,iBAAiB,GAAG,WAAW,CAAC;AACtC,oDAAoD;AACpD,MAAM,cAAc,GAAG,KAAK,CAAC;AAI7B,2IAA2I;AAC9H,QAAA,sBAAsB,GAAG,UAAU,CAAC;AAejD,8GAA8G;AAC9G,SAAgB,oBAAoB,CAAC,SAAiB,EAAE,MAA0B;IAChF,OAAO,EAAE,SAAS,EAAE,GAAG,8BAAsB,GAAG,SAAS,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AACtG,CAAC;AAOD,oGAAoG;AACpG,SAAgB,YAAY,CAAC,IAA2C;IACtE,OAAO,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC;AACpC,CAAC;AAED,SAAS,cAAc,CAAC,OAA6B,EAAE,KAAuB;IAC5E,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,YAAY,CAAC,IAA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AyB,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC;QAAE,OAAO,OAAO,CAAC,MAAM,CAAC;IAClF,OAAO,iBAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,CAAC,IAAI,QAAQ,CAAC;AACxE,CAAC"}
@@ -8,20 +8,31 @@ import { RotatingJsonlFile } from '../../utils/rotatingJsonlFile';
8
8
  * owned, so the core request ledger stays platform-agnostic.
9
9
  */
10
10
  export declare const jiraTriggerLogFileName = "jira-triggers.jsonl";
11
+ /**
12
+ * How long a mention held back from its issue update stays in the mention scan after it was first held: past the longest
13
+ * pause of the cap on updates (24 h), with a day to spare for a bot that was down when the pause ended.
14
+ */
15
+ export declare const jiraHeldMentionKeepMs: number;
11
16
  /**
12
17
  * @name JiraTriggerOutcome
13
18
  * @description `request` — a request was opened; `selfAuthored` — the AI account
14
- * made the change itself; `parked` — the issue was over its run budget;
15
- * `untrusted` — the hand-over (or the mention) was made by someone the trusted group
16
- * does not back; `covered` — a mention by the requester of an open hand-over request
17
- * of the issue, which that run already carries (it opens no request and counts for nothing).
19
+ * made the change itself; `parked` — the issue was over its run budget (and, under an
20
+ * `updates-paused:` or `held-mention:` trigger id, a pause of the issue's updates and a
21
+ * mention that pause or a failed post held back: neither decides a comment);
22
+ * `untrusted` — the hand-over (or the mention, or the comment) was made by someone the trusted
23
+ * group does not back; `covered` — with `wakeOnComment` off, a mention by the requester of an
24
+ * open hand-over request of the issue, recorded and not delivered (it opens no request and
25
+ * counts for nothing); `update` — a comment that reached the agent inside an open hand-over
26
+ * request (an issue update), or alongside a newer comment's request of the same poll (it opens
27
+ * no request and counts for nothing).
18
28
  */
19
- export type JiraTriggerOutcome = 'request' | 'selfAuthored' | 'parked' | 'untrusted' | 'covered';
29
+ export type JiraTriggerOutcome = 'request' | 'selfAuthored' | 'parked' | 'untrusted' | 'covered' | 'update';
20
30
  declare const triggerRecordSchema: z.ZodObject<{
21
31
  issueKey: z.ZodString;
22
32
  triggerId: z.ZodString;
23
33
  outcome: z.ZodEnum<{
24
34
  request: "request";
35
+ update: "update";
25
36
  untrusted: "untrusted";
26
37
  selfAuthored: "selfAuthored";
27
38
  parked: "parked";
@@ -29,6 +40,7 @@ declare const triggerRecordSchema: z.ZodObject<{
29
40
  }>;
30
41
  at: z.ZodNumber;
31
42
  requestId: z.ZodOptional<z.ZodString>;
43
+ newestCommentId: z.ZodOptional<z.ZodString>;
32
44
  isNoticePosted: z.ZodOptional<z.ZodBoolean>;
33
45
  }, z.core.$strip>;
34
46
  export type JiraTriggerRecord = z.infer<typeof triggerRecordSchema>;
@@ -37,16 +49,59 @@ export declare class JiraTriggerLog {
37
49
  private readonly seen;
38
50
  private readonly requestTimesByIssue;
39
51
  private readonly mentionParkNoticeTimesByIssue;
52
+ private readonly updatesPausedNoticeTimesByIssue;
53
+ /** Per issue, the mentions held back from their issue update and not decided since: comment id → when first held. */
54
+ private readonly heldMentionsByIssue;
55
+ private readonly newestCommentIdByIssue;
56
+ /** Per issue, when each issue update was posted (its comments share the time). */
57
+ private readonly updateTimesByIssue;
58
+ private readonly lastDecidedAtByIssue;
40
59
  constructor(file: RotatingJsonlFile<JiraTriggerRecord>);
41
60
  static createForDataDir(filePath: string): JiraTriggerLog;
42
61
  /** @description Index the file. A line that does not parse is skipped with a warning (never fatal). */
43
62
  load(): Promise<void>;
44
63
  private index;
64
+ /** Where a posted notice of `record` is counted: a mention's park notice, or a pause's "updates paused" one; else nowhere. */
65
+ private getNoticeTimesByIssue;
66
+ /** A held mention joins the issue's list unless its comment was decided already; a comment's or a mention's decision ends it. */
67
+ private indexHeldMention;
45
68
  checkIsSeen(issueKey: string, triggerId: string): boolean;
46
69
  /** @description Requests opened for the issue in the rolling 24 h before `nowMs`: hand-overs and mentions together. */
47
70
  getRequestCountLastDay(issueKey: string, nowMs: number): number;
71
+ /**
72
+ * @description The newest comment id any recorded prompt of the issue was built from (see `newestCommentId`), or
73
+ * `null` when no decision of the issue recorded one.
74
+ */
75
+ getNewestShownCommentId(issueKey: string): string | null;
76
+ /** @description When the newest decision on the issue was made (epoch ms), or `null` when none is recorded. */
77
+ getLastDecidedAt(issueKey: string): number | null;
78
+ /**
79
+ * @description Issue updates posted on the issue in the rolling 24 h before `nowMs` — one per post, however many comments
80
+ * it carried (they are recorded with its time) — for the cap on updates.
81
+ */
82
+ getUpdateCountLastDay(issueKey: string, nowMs: number): number;
83
+ /**
84
+ * @description When the oldest issue update of the rolling 24 h before `nowMs` leaves that window — the moment a capped
85
+ * issue may get an update again — or `null` when there is none.
86
+ */
87
+ getUpdateWindowEnd(issueKey: string, nowMs: number): number | null;
48
88
  /** @description Was a mention park notice posted on the issue in the rolling 24 h before `nowMs`? */
49
89
  checkIsMentionParkNoticePostedLastDay(issueKey: string, nowMs: number): boolean;
90
+ /** @description Was an "updates are paused" notice posted on the issue in the rolling 24 h before `nowMs`? */
91
+ checkIsUpdatesPausedNoticePostedLastDay(issueKey: string, nowMs: number): boolean;
92
+ /**
93
+ * @description The comment ids of the issue's mentions held back from their issue update (see `held-mention:`), first
94
+ * held within {@link jiraHeldMentionKeepMs} before `nowMs`, and not decided since.
95
+ */
96
+ listHeldMentionIds(issueKey: string, nowMs: number): string[];
97
+ /** @description The issues with a held mention (see {@link listHeldMentionIds}). */
98
+ listHeldMentionIssueKeys(nowMs: number): string[];
99
+ /**
100
+ * @description Stop keeping a held mention: its comment was decided, a prompt carried it since, or it can never be
101
+ * decided (the comment or its issue gone). Indexing a decision ends it for good; a call by the scan holds for this
102
+ * process only — after a restart the scan finds it once more and lets it go again.
103
+ */
104
+ forgetHeldMention(issueKey: string, commentId: string): void;
50
105
  /** @description Persist a decision; `false` when the line could not be written (then nothing is indexed). */
51
106
  record(record: JiraTriggerRecord): boolean;
52
107
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"triggerLog.d.ts","sourceRoot":"","sources":["../../../src/connectors/jira/triggerLog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAA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void 0;
3
+ exports.JiraTriggerLog = exports.jiraHeldMentionKeepMs = exports.jiraTriggerLogFileName = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const rotatingJsonlFile_1 = require("../../utils/rotatingJsonlFile");
6
6
  const trigger_1 = require("./trigger");
@@ -15,16 +15,27 @@ exports.jiraTriggerLogFileName = 'jira-triggers.jsonl';
15
15
  /** Ample for years of triggers; the one `.1` backup is read too. */
16
16
  const jiraTriggerLogMaxBytes = 10 * 1024 * 1024;
17
17
  const msPerDay = 24 * 60 * 60 * 1000;
18
+ /**
19
+ * How long a mention held back from its issue update stays in the mention scan after it was first held: past the longest
20
+ * pause of the cap on updates (24 h), with a day to spare for a bot that was down when the pause ended.
21
+ */
22
+ exports.jiraHeldMentionKeepMs = 2 * msPerDay;
18
23
  const triggerRecordSchema = zod_1.z.object({
19
24
  issueKey: zod_1.z.string().min(1),
20
25
  triggerId: zod_1.z.string().min(1),
21
- outcome: zod_1.z.enum(['request', 'selfAuthored', 'parked', 'untrusted', 'covered']),
26
+ outcome: zod_1.z.enum(['request', 'selfAuthored', 'parked', 'untrusted', 'covered', 'update']),
22
27
  /** Epoch ms. */
23
28
  at: zod_1.z.number(),
24
29
  requestId: zod_1.z.string().optional(),
25
30
  /**
26
- * A `parked` mention only: whether its park notice was posted (at most one per issue per rolling 24 h, the others
27
- * are recorded silently). Absent → posted, as every older line was.
31
+ * The newest comment of the issue (by id) the prompt that went with this decision was built from: the conversation
32
+ * was shown every comment up to it, so only a later one is new to it — whatever a compaction or a fresh session
33
+ * made it forget. Absent on a decision that sent no prompt, and on every line written before it was recorded.
34
+ */
35
+ newestCommentId: zod_1.z.string().optional(),
36
+ /**
37
+ * A `parked` mention, or a pause of the issue's updates: whether its notice was posted (at most one of each kind per issue
38
+ * per rolling 24 h, the others are recorded silently). Absent → posted, as every older line was.
28
39
  */
29
40
  isNoticePosted: zod_1.z.boolean().optional(),
30
41
  });
@@ -36,6 +47,13 @@ class JiraTriggerLog {
36
47
  seen = new Set();
37
48
  requestTimesByIssue = new Map();
38
49
  mentionParkNoticeTimesByIssue = new Map();
50
+ updatesPausedNoticeTimesByIssue = new Map();
51
+ /** Per issue, the mentions held back from their issue update and not decided since: comment id → when first held. */
52
+ heldMentionsByIssue = new Map();
53
+ newestCommentIdByIssue = new Map();
54
+ /** Per issue, when each issue update was posted (its comments share the time). */
55
+ updateTimesByIssue = new Map();
56
+ lastDecidedAtByIssue = new Map();
39
57
  constructor(file) {
40
58
  this.file = file;
41
59
  }
@@ -52,10 +70,22 @@ class JiraTriggerLog {
52
70
  }
53
71
  index(record) {
54
72
  this.seen.add(getTriggerIdentity(record.issueKey, record.triggerId));
55
- if (record.outcome === 'parked' && record.triggerId.startsWith(trigger_1.mentionTriggerIdPrefix) && record.isNoticePosted !== false) {
56
- const noticeTimes = this.mentionParkNoticeTimesByIssue.get(record.issueKey) ?? [];
73
+ this.lastDecidedAtByIssue.set(record.issueKey, Math.max(record.at, this.lastDecidedAtByIssue.get(record.issueKey) ?? record.at));
74
+ const shownBefore = this.newestCommentIdByIssue.get(record.issueKey);
75
+ if (record.newestCommentId !== undefined && (shownBefore === undefined || (0, trigger_1.compareJiraCommentIds)(record.newestCommentId, shownBefore) > 0)) {
76
+ this.newestCommentIdByIssue.set(record.issueKey, record.newestCommentId);
77
+ }
78
+ const noticeTimesByIssue = this.getNoticeTimesByIssue(record);
79
+ if (noticeTimesByIssue) {
80
+ const noticeTimes = noticeTimesByIssue.get(record.issueKey) ?? [];
57
81
  noticeTimes.push(record.at);
58
- this.mentionParkNoticeTimesByIssue.set(record.issueKey, noticeTimes);
82
+ noticeTimesByIssue.set(record.issueKey, noticeTimes);
83
+ }
84
+ this.indexHeldMention(record);
85
+ if (record.outcome === 'update') {
86
+ const updateTimes = this.updateTimesByIssue.get(record.issueKey) ?? new Set();
87
+ updateTimes.add(record.at);
88
+ this.updateTimesByIssue.set(record.issueKey, updateTimes);
59
89
  }
60
90
  if (record.outcome !== 'request')
61
91
  return;
@@ -63,6 +93,31 @@ class JiraTriggerLog {
63
93
  times.push(record.at);
64
94
  this.requestTimesByIssue.set(record.issueKey, times);
65
95
  }
96
+ /** Where a posted notice of `record` is counted: a mention's park notice, or a pause's "updates paused" one; else nowhere. */
97
+ getNoticeTimesByIssue(record) {
98
+ if (record.outcome !== 'parked' || record.isNoticePosted === false)
99
+ return null;
100
+ if (record.triggerId.startsWith(trigger_1.mentionTriggerIdPrefix))
101
+ return this.mentionParkNoticeTimesByIssue;
102
+ return record.triggerId.startsWith(trigger_1.updatesPausedTriggerIdPrefix) ? this.updatesPausedNoticeTimesByIssue : null;
103
+ }
104
+ /** A held mention joins the issue's list unless its comment was decided already; a comment's or a mention's decision ends it. */
105
+ indexHeldMention(record) {
106
+ const { issueKey, triggerId } = record;
107
+ if (triggerId.startsWith(trigger_1.heldMentionTriggerIdPrefix)) {
108
+ const commentId = triggerId.slice(trigger_1.heldMentionTriggerIdPrefix.length);
109
+ if (this.checkIsSeen(issueKey, `${trigger_1.mentionTriggerIdPrefix}${commentId}`) || this.checkIsSeen(issueKey, `${trigger_1.commentTriggerIdPrefix}${commentId}`))
110
+ return;
111
+ const held = this.heldMentionsByIssue.get(issueKey) ?? new Map();
112
+ if (!held.has(commentId))
113
+ held.set(commentId, record.at);
114
+ this.heldMentionsByIssue.set(issueKey, held);
115
+ return;
116
+ }
117
+ const decidedPrefix = [trigger_1.mentionTriggerIdPrefix, trigger_1.commentTriggerIdPrefix].find((prefix) => triggerId.startsWith(prefix));
118
+ if (decidedPrefix !== undefined)
119
+ this.forgetHeldMention(issueKey, triggerId.slice(decidedPrefix.length));
120
+ }
66
121
  checkIsSeen(issueKey, triggerId) {
67
122
  return this.seen.has(getTriggerIdentity(issueKey, triggerId));
68
123
  }
@@ -70,10 +125,64 @@ class JiraTriggerLog {
70
125
  getRequestCountLastDay(issueKey, nowMs) {
71
126
  return (this.requestTimesByIssue.get(issueKey) ?? []).filter((at) => at > nowMs - msPerDay).length;
72
127
  }
128
+ /**
129
+ * @description The newest comment id any recorded prompt of the issue was built from (see `newestCommentId`), or
130
+ * `null` when no decision of the issue recorded one.
131
+ */
132
+ getNewestShownCommentId(issueKey) {
133
+ return this.newestCommentIdByIssue.get(issueKey) ?? null;
134
+ }
135
+ /** @description When the newest decision on the issue was made (epoch ms), or `null` when none is recorded. */
136
+ getLastDecidedAt(issueKey) {
137
+ return this.lastDecidedAtByIssue.get(issueKey) ?? null;
138
+ }
139
+ /**
140
+ * @description Issue updates posted on the issue in the rolling 24 h before `nowMs` — one per post, however many comments
141
+ * it carried (they are recorded with its time) — for the cap on updates.
142
+ */
143
+ getUpdateCountLastDay(issueKey, nowMs) {
144
+ return [...(this.updateTimesByIssue.get(issueKey) ?? [])].filter((at) => at > nowMs - msPerDay).length;
145
+ }
146
+ /**
147
+ * @description When the oldest issue update of the rolling 24 h before `nowMs` leaves that window — the moment a capped
148
+ * issue may get an update again — or `null` when there is none.
149
+ */
150
+ getUpdateWindowEnd(issueKey, nowMs) {
151
+ const inWindow = [...(this.updateTimesByIssue.get(issueKey) ?? [])].filter((at) => at > nowMs - msPerDay);
152
+ return inWindow.length === 0 ? null : Math.min(...inWindow) + msPerDay;
153
+ }
73
154
  /** @description Was a mention park notice posted on the issue in the rolling 24 h before `nowMs`? */
74
155
  checkIsMentionParkNoticePostedLastDay(issueKey, nowMs) {
75
156
  return (this.mentionParkNoticeTimesByIssue.get(issueKey) ?? []).some((at) => at > nowMs - msPerDay);
76
157
  }
158
+ /** @description Was an "updates are paused" notice posted on the issue in the rolling 24 h before `nowMs`? */
159
+ checkIsUpdatesPausedNoticePostedLastDay(issueKey, nowMs) {
160
+ return (this.updatesPausedNoticeTimesByIssue.get(issueKey) ?? []).some((at) => at > nowMs - msPerDay);
161
+ }
162
+ /**
163
+ * @description The comment ids of the issue's mentions held back from their issue update (see `held-mention:`), first
164
+ * held within {@link jiraHeldMentionKeepMs} before `nowMs`, and not decided since.
165
+ */
166
+ listHeldMentionIds(issueKey, nowMs) {
167
+ return [...(this.heldMentionsByIssue.get(issueKey) ?? [])].filter(([, at]) => at > nowMs - exports.jiraHeldMentionKeepMs).map(([commentId]) => commentId);
168
+ }
169
+ /** @description The issues with a held mention (see {@link listHeldMentionIds}). */
170
+ listHeldMentionIssueKeys(nowMs) {
171
+ return [...this.heldMentionsByIssue.keys()].filter((issueKey) => this.listHeldMentionIds(issueKey, nowMs).length > 0);
172
+ }
173
+ /**
174
+ * @description Stop keeping a held mention: its comment was decided, a prompt carried it since, or it can never be
175
+ * decided (the comment or its issue gone). Indexing a decision ends it for good; a call by the scan holds for this
176
+ * process only — after a restart the scan finds it once more and lets it go again.
177
+ */
178
+ forgetHeldMention(issueKey, commentId) {
179
+ const held = this.heldMentionsByIssue.get(issueKey);
180
+ if (!held)
181
+ return;
182
+ held.delete(commentId);
183
+ if (held.size === 0)
184
+ this.heldMentionsByIssue.delete(issueKey);
185
+ }
77
186
  /** @description Persist a decision; `false` when the line could not be written (then nothing is indexed). */
78
187
  record(record) {
79
188
  if (!this.file.append(record))
@@ -1 +1 @@
1
- {"version":3,"file":"triggerLog.js","sourceRoot":"","sources":["../../../src/connectors/jira/triggerLog.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,qEAAkE;AAClE,uCAAmD;AAEnD;;;;;;GAMG;AAEU,QAAA,sBAAsB,GAAG,qBAAqB,CAAC;AAC5D,oEAAoE;AACpE,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAChD,MAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAYrC,MAAM,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IACnC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,OAAO,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,S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AAQ,CAAC,CAAC;IACjE,CAAC;IAED,6GAA6G;IAC7G,MAAM,CAAC,MAAyB;QAC9B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;YAAE,OAAO,KAAK,CAAC;QAC5C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,MAAyB;QAChC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC;CACF;AAjKD,wCAiKC"}
@@ -60,8 +60,11 @@ export interface BotCore {
60
60
  * from one that failed — for a caller that would otherwise post the same message again later.
61
61
  */
62
62
  replyToThreadDetailed: (key: SessionKey, text: string, extra?: object, options?: ReplyToThreadPortOptions) => Promise<ThreadSendOutcome>;
63
- /** Edit a message of the topic in place; `false` when the edit failed. */
64
- editThreadMessage: (key: SessionKey, messageId: number, text: string, extra?: object) => Promise<boolean>;
63
+ /**
64
+ * Edit a message of the topic in place; `false` when the edit failed. `plainFallbackText` is the text a Telegram that cannot
65
+ * parse the markup of `text` is given instead (default: `text` itself).
66
+ */
67
+ editThreadMessage: (key: SessionKey, messageId: number, text: string, extra?: object, plainFallbackText?: string) => Promise<boolean>;
65
68
  /** The same edit, telling a message that is gone from one that failed to change — for a caller that must not retry a message nobody can edit any more. */
66
69
  editThreadMessageDetailed: (key: SessionKey, messageId: number, text: string, extra?: object) => Promise<ThreadMessageEdit>;
67
70
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"botCore.d.ts","sourceRoot":"","sources":["../../../../src/connectors/telegram/commands/botCore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAClG,OAAO,KAA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G,IAAI,CAAC,CAAC;IACjE,4DAA4D;IAC5D,gBAAgB,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,OAAO,KAAK,OAAO,CAAC;IAC3E,cAAc,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC;IAC7C,4DAA4D;IAC5D,kBAAkB,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,6FAA6F;IAC7F,yBAAyB,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAC;IACrD;;;;OAIG;IACH,mBAAmB,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAClE"}
@@ -6,6 +6,7 @@ import type { BackendFamily } from '../../../utils/backendSwitchPlan';
6
6
  import type { OperatorSwitchOutcome } from '../../../utils/operatorSwitchPlan';
7
7
  import { type ClaudeAuthStatus } from '../../../utils/claudeProfiles';
8
8
  import type { AnthropicApiKeyCheck } from '../../../utils/anthropicApiKeyCheck';
9
+ import { type ClaudeProfileSyncResult } from '../../../utils/claudeProfileSync';
9
10
  import type { ClaudeProfileUsageView } from '../../../utils/claudeUsage';
10
11
  import type { BotCore } from './botCore';
11
12
  /**
@@ -25,6 +26,10 @@ export interface ClaudeAccountsPorts extends Pick<BotCore, 'bot' | 'command' | '
25
26
  refreshClaudeUsage: (options: {
26
27
  maxAgeMs?: number;
27
28
  }) => Promise<void>;
29
+ /** The shared profile scan (`utils/claudeProfileSync.ts`, the very one the usage poll runs): adopt folders signed in by hand, probe the profiles. */
30
+ syncClaudeProfiles: (options: {
31
+ isForced: boolean;
32
+ }) => Promise<ClaudeProfileSyncResult>;
28
33
  /** `claude auth status --json` under `configDir` (`null` = `~/.claude`); `null` when the probe fails. */
29
34
  readClaudeAuthStatus: (configDir: string | null) => Promise<ClaudeAuthStatus | null>;
30
35
  /** Start the out-of-band sign-in of `profile`; the relay posts the link and the outcome into the topic. */
@@ -1 +1 @@
1
- {"version":3,"file":"claudeAccounts.d.ts","sourceRoot":"","sources":["../../../../src/connectors/telegram/commands/claudeAccounts.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAItD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAwB,KAAK,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAC/F,OAAO,EAAoF,KAAK,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACzJ,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAGtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAaL,KAAK,gBAAgB,EAEtB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAGhF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAsCzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,0BAA0B,GAAG,iBAAiB,CAAC;AAEvF;;;GAGG;AACH,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,OAAO,EACP,KAAK,GAAG,SAAS,GAAG,UAAU,GAAG,eAAe,GAAG,mBAAmB,GAAG,qBAAqB,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,gBAAgB,CAC5J;IACD,UAAU,EAAE,MAAM,MAAM,CAAC;IACzB,uEAAuE;IACvE,mBAAmB,EAAE,MAAM,MAAM,CAAC;IAClC,wGAAwG;IACxG,kBAAkB,EAAE,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,yGAAyG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OAAO,CAAC;CACvE;AAKD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,mBAAmB;yCAwgBnB,IAAI;0CAwEH,IAAI;sCA9JN,UAAU,KAAG,OAAO;oCAKtB,UAAU,KAAG,OAAO;6BAoBrB,UAAU,QAAQ,MAAM,cAAc,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;6BA5JpE,UAAU,aAAa,OAAO,QAAQ,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;sCA9MpD,UAAU,WAAW,kBAAkB,UAAU,gBAAgB,GAAG,IAAI,KAAG,OAAO,CAAC,IAAI,CAAC;kCAoB5F,UAAU,WAAW,kBAAkB,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC;EAgpBrH"}
@@ -19,6 +19,7 @@ const openCodeUsage_1 = require("../../../utils/openCodeUsage");
19
19
  const modelPickerPlan_1 = require("../../../utils/modelPickerPlan");
20
20
  const claudeProfiles_1 = require("../../../utils/claudeProfiles");
21
21
  const claudeProfileUsageLines_1 = require("../../../utils/claudeProfileUsageLines");
22
+ const claudeProfileSync_1 = require("../../../utils/claudeProfileSync");
22
23
  const usageRefreshBudget_1 = require("../../../utils/usageRefreshBudget");
23
24
  const claudeAccountPickerPlan_1 = require("../../../utils/claudeAccountPickerPlan");
24
25
  const openCodeAdapter_1 = require("../../../adapters/openCodeAdapter");
@@ -33,7 +34,7 @@ const providerSnapshotLimit = 50;
33
34
  * auth-status sink the sign-in driver reports to.
34
35
  */
35
36
  function createClaudeAccounts(ports) {
36
- const { bot, command, getState, replyToThread, editThreadMessage, deleteThreadMessage, authoriseContext, withThreadLocale, checkIsGeneral, getDataDir, getInstanceTimezone, refreshClaudeUsage, readClaudeAuthStatus, startClaudeProfileLogin, applyClaudeProfile, applyClaudeProfileEverywhere, switchTopicByOperator, detectOpenCodeProviders, listOpenCodeModels, getTopicRun, disconnectOpenCodeProvider, startOpenCodeConnect, applyAutoSwitch, getHomeClaudeDir, verifyAnthropicApiKey, getProfileUsageView, checkIsProfileMissingFromLimitsList, } = ports;
37
+ const { bot, command, getState, replyToThread, editThreadMessage, deleteThreadMessage, authoriseContext, withThreadLocale, checkIsGeneral, getDataDir, getInstanceTimezone, refreshClaudeUsage, syncClaudeProfiles, readClaudeAuthStatus, startClaudeProfileLogin, applyClaudeProfile, applyClaudeProfileEverywhere, switchTopicByOperator, detectOpenCodeProviders, listOpenCodeModels, getTopicRun, disconnectOpenCodeProvider, startOpenCodeConnect, applyAutoSwitch, getHomeClaudeDir, verifyAnthropicApiKey, getProfileUsageView, checkIsProfileMissingFromLimitsList, } = ports;
37
38
  const answerWithWholeText = (0, callbackToast_1.createWholeTextAnswerer)(replyToThread);
38
39
  /**
39
40
  * Topics whose next plain message is an answer to «➕»: the name of a new Claude profile (a subscription one, or one
@@ -97,44 +98,17 @@ function createClaudeAccounts(ports) {
97
98
  return getState().getClaudeProfileInfo(name)?.billing ?? null;
98
99
  }
99
100
  /**
100
- * @description Re-read every added profile's auth status (and the default's) and persist what changed, so the
101
- * picker shows the CLI's truth, not the state of the last sign-in. One short `claude auth status` per profile,
102
- * in parallel; a failed probe leaves the record as it was.
101
+ * @description Re-read every profile's auth status (the default's too) and persist what changed, so the picker shows the CLI's
102
+ * truth, not the state of the last sign-in — and adopt a profile folder signed in by hand that has no record yet. The shared scan
103
+ * (`utils/claudeProfileSync.ts`), forced: one short `claude auth status` per profile, in parallel; a failed probe leaves the
104
+ * record as it was.
103
105
  */
104
106
  async function refreshProfileStatuses() {
105
- const names = Object.keys(getState().getClaudeProfileRecords());
106
- const [defaultStatus, ...statuses] = await Promise.all([
107
- readClaudeAuthStatus(null),
108
- ...names.map((name) => readClaudeAuthStatus(resolveDir(name))),
109
- ]);
110
- await Promise.all([
111
- recordProfileStatus(claudeProfiles_1.defaultClaudeProfileName, defaultStatus),
112
- ...names.map((name, index) => recordProfileStatus(name, statuses[index])),
113
- ]);
114
- return defaultStatus;
107
+ return (await syncClaudeProfiles({ isForced: true })).defaultStatus;
115
108
  }
116
- /**
117
- * Persist a probe's answer on the profile's record (nothing for a failed probe). `default` gets its hidden
118
- * record, so the usage ranking and the CLI twin know whether it is signed in and as whom.
119
- */
120
- async function recordProfileStatus(name, status) {
121
- if (status === null)
122
- return;
123
- if (name !== claudeProfiles_1.defaultClaudeProfileName && getState().getClaudeProfileRecord(name) === undefined)
124
- return; // removed meanwhile
125
- await getState().upsertClaudeProfileRecord(name, {
126
- // A removed `default` comes back by itself the moment it is signed in again.
127
- ...(name === claudeProfiles_1.defaultClaudeProfileName && status.loggedIn ? { isRemoved: undefined } : {}),
128
- // The CLI's word on how the account pays wins over the kind it was added as, both ways.
129
- ...(status.billing !== null ? { billing: status.billing } : {}),
130
- // Which key the sessions use decides whether the stored one may be asked on (the daily credit recheck of `default`).
131
- isConsoleLoginKey: status.apiKeySource === claudeProfiles_1.claudeConsoleLoginKeySource,
132
- loggedIn: status.loggedIn,
133
- email: status.email ?? undefined,
134
- subscriptionType: status.subscriptionType ?? undefined,
135
- orgName: status.orgName ?? undefined,
136
- statusCheckedAt: new Date().toISOString(),
137
- });
109
+ /** Persist a probe's answer on the profile's record (nothing for a failed probe) — the shared `recordClaudeProfileStatus`. */
110
+ function recordProfileStatus(name, status) {
111
+ return (0, claudeProfileSync_1.recordClaudeProfileStatus)(getState(), name, status);
138
112
  }
139
113
  /**
140
114
  * The sign-in driver's report at the end of a profile sign-in: record it, then move live sessions onto it. A Console
@@ -412,7 +386,7 @@ function createClaudeAccounts(ports) {
412
386
  * @description Remove a profile — the SAFE way: `default` is `~/.claude` and is never removed; the instance
413
387
  * default is refused until General picks another (otherwise every following topic would silently change
414
388
  * account); topics that picked the profile explicitly return to the instance default and are moved at once,
415
- * and the confirmation says how many. The directory (its login with it) goes last, after the registry.
389
+ * and the confirmation says how many. The directory (its login with it) goes first, before the registry, so the profile scan never finds a record-less folder to adopt.
416
390
  */
417
391
  async function removeProfile(name) {
418
392
  if (name === claudeProfiles_1.defaultClaudeProfileName)
@@ -421,13 +395,15 @@ function createClaudeAccounts(ports) {
421
395
  return (0, i18n_1.t)('account.unknown', { name });
422
396
  if (getState().getClaudeProfileGlobalDefault() === name)
423
397
  return (0, i18n_1.t)('account.removeInstanceDefaultRefused', { name });
424
- const dropped = await getState().removeClaudeProfileRecord(name);
398
+ // The directory goes FIRST: a folder with no record is what the profile scan adopts (`utils/claudeProfileSync.ts`), so a scan
399
+ // landing between the two steps — or a crash between them — would bring the profile back.
425
400
  try {
426
401
  (0, claudeProfiles_1.removeClaudeProfileLayout)(getDataDir(), name);
427
402
  }
428
403
  catch (e) {
429
- console.error(`[account] removing the directory of ${name} failed:`, e instanceof Error ? e.message : e);
404
+ console.error(`[account] removing the directory of ${name} failed (the scan adopts it again until it is deleted by hand):`, e instanceof Error ? e.message : e);
430
405
  }
406
+ const dropped = await getState().removeClaudeProfileRecord(name);
431
407
  await applyClaudeProfileEverywhere();
432
408
  return (0, i18n_1.t)('account.removed', { name, count: dropped.length });
433
409
  }