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
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * @description The choices of the «question wait» setting and how long each lets a question wait — kept apart from
4
+ * `questionWaitPlan.ts` (the texts and the routing of a set-aside question) because the instance settings, the state store and the
5
+ * test timings need only these, and they load before any env file is read: this module imports nothing.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.setAsideRetryDelayMs = exports.longestQuestionWaitMs = exports.questionWaitMs = exports.defaultQuestionWaitChoice = exports.questionWaitChoices = void 0;
9
+ exports.checkIsQuestionWaitChoice = checkIsQuestionWaitChoice;
10
+ const msPerMinute = 60_000;
11
+ /** The question wait, in the order a picker lists it: `dontWait` sets a question aside at once, `untilAnswered` never does. */
12
+ exports.questionWaitChoices = ['dontWait', 'tenMinutes', 'thirtyMinutes', 'oneHour', 'untilAnswered'];
13
+ /** @description Whether `value` is one of the wait choices (a hand-edited state or settings file may hold anything). */
14
+ function checkIsQuestionWaitChoice(value) {
15
+ return exports.questionWaitChoices.some((choice) => choice === value);
16
+ }
17
+ /** What an instance does until the operator chooses: the owner's figure. */
18
+ exports.defaultQuestionWaitChoice = 'thirtyMinutes';
19
+ /** How long each choice lets a question wait; `null` = for as long as it takes (the pre-set-aside behaviour). */
20
+ exports.questionWaitMs = {
21
+ dontWait: 0,
22
+ tenMinutes: 10 * msPerMinute,
23
+ thirtyMinutes: 30 * msPerMinute,
24
+ oneHour: 60 * msPerMinute,
25
+ untilAnswered: null,
26
+ };
27
+ /** The longest finite wait the setting offers: the ceiling a test's shorter window (`CHARNESS_TEST_TIMINGS`) may name. */
28
+ exports.longestQuestionWaitMs = 60 * msPerMinute;
29
+ /** After the agent's server did not take what sets a question aside, the bot tries again this long after: the ceiling a test's shorter window may name. */
30
+ exports.setAsideRetryDelayMs = 30_000;
31
+ //# sourceMappingURL=questionWaitChoices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"questionWaitChoices.js","sourceRoot":"","sources":["../../src/utils/questionWaitChoices.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAWH,8DAEC;AAXD,MAAM,WAAW,GAAG,MAAM,CAAC;AAE3B,+HAA+H;AAClH,QAAA,mBAAmB,GAAG,CAAC,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,CAAU,CAAC;AAKpH,wHAAwH;AACxH,SAAgB,yBAAyB,CAAC,KAAyB;IACjE,OAAO,2BAAmB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,4EAA4E;AAC/D,QAAA,yBAAyB,GAAuB,eAAe,CAAC;AAE7E,iHAAiH;AACpG,QAAA,cAAc,GAA8C;IACvE,QAAQ,EAAE,CAAC;IACX,UAAU,EAAE,EAAE,GAAG,WAAW;IAC5B,aAAa,EAAE,EAAE,GAAG,WAAW;IAC/B,OAAO,EAAE,EAAE,GAAG,WAAW;IACzB,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF,0HAA0H;AAC7G,QAAA,qBAAqB,GAAG,EAAE,GAAG,WAAW,CAAC;AAEtD,2JAA2J;AAC9I,QAAA,oBAAoB,GAAG,MAAM,CAAC"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * @description Pure plan for «a question the agent asked never stops its work»: how long a question waits for the owner
3
+ * (the «question wait» setting and its resolution), what the agent is told when the wait ends and the question is set aside,
4
+ * what it is told when the answer comes later, how a typed message is routed while questions wait or are set aside, and how
5
+ * many set-aside questions stay open at once.
6
+ *
7
+ * The bot owns every side effect (the timer, the deny / reply to the CLI, the Telegram edit and pin, the delivery of the late
8
+ * answer); this module only decides and words — so the rules are unit-testable without a live agent. The texts here are
9
+ * agent-facing English, never i18n, and the only place the model learns what «set aside» means: they are literal and
10
+ * never phrased as the user's words.
11
+ */
12
+ import type { OpenCodeQuestion, SetAsideQuestionRecord } from '../types';
13
+ import { type QuestionWaitChoice } from './questionWaitChoices';
14
+ /** The most questions set aside and still open in one conversation; a further one closes the oldest. */
15
+ export declare const maxSetAsideQuestions = 5;
16
+ /**
17
+ * @description The wait that applies to a topic: its own choice, else General's (the instance default), else
18
+ * {@link defaultQuestionWaitChoice}.
19
+ */
20
+ export declare function resolveQuestionWait(topicChoice: QuestionWaitChoice | undefined, generalChoice: QuestionWaitChoice | undefined): QuestionWaitChoice;
21
+ /**
22
+ * @description How long from `nowMs` until a question asked at `askedAtMs` is to be set aside: `0` when its wait is over
23
+ * (also a `dontWait`), `null` when its choice never sets it aside. The point is `askedAtMs + wait` whatever the agent's
24
+ * process looks like — the timer is armed from this at ask time and again at boot, so a restart keeps the original moment.
25
+ * `shortenedToMs` is a test instance's own window (`CHARNESS_TEST_TIMINGS`): it cuts a finite wait to at most that, and
26
+ * leaves `dontWait` and `untilAnswered` as they are.
27
+ */
28
+ export declare function getQuestionSetAsideDelayMs(askedAtMs: number, choice: QuestionWaitChoice, nowMs: number, shortenedToMs?: number): number | null;
29
+ /** @description What {@link buildQuestionSetAsideText} words. */
30
+ export interface QuestionSetAsideTextInput {
31
+ /** The questions of the call the agent is blocked on. */
32
+ questions: OpenCodeQuestion[];
33
+ /** One slot per question: the answer given before the wait ended, `null` while open. */
34
+ answers: (string[] | null)[];
35
+ askedAtMs: number;
36
+ /** The moment the text is written: the end of the wait (or of an earlier set-aside, for the question asked again). */
37
+ nowMs: number;
38
+ /** The agent asked a question whose set-aside copy is still open: told it is the same one, not a new one. */
39
+ isAlreadyOpen?: boolean;
40
+ }
41
+ /**
42
+ * @description The text the agent gets as the result of its question when the wait ends: Claude's `can_use_tool` deny
43
+ * message, OpenCode's custom answer of every question left open. It says the truth — nobody answered, the question stays
44
+ * open, the answer arrives later as a message — and tells the agent to go on, so its turn does not stop on the tool call.
45
+ * Answers given before the wait ended are named, so the agent does not lose them.
46
+ */
47
+ export declare function buildQuestionSetAsideText(input: QuestionSetAsideTextInput): string;
48
+ /** One answer of a late-answer prompt: the question and what the person answered (a label, labels or typed text). */
49
+ export interface LateAnswerEntry {
50
+ question: OpenCodeQuestion;
51
+ answer: string[];
52
+ }
53
+ /** @description What {@link buildLateAnswerPrompt} words. */
54
+ export interface LateAnswerPromptInput {
55
+ /** The questions answered now — one for an ordinary question, several when a call's remaining questions are answered together. */
56
+ entries: [LateAnswerEntry, ...LateAnswerEntry[]];
57
+ askedAtMs: number;
58
+ setAsideAtMs: number;
59
+ /** The moment of the answer: clocks of an earlier day read with their date. */
60
+ nowMs: number;
61
+ }
62
+ /**
63
+ * @description The message that carries a late answer to the agent, which went on without it: names the question, the
64
+ * answer, and asks the agent to check what it did meanwhile. The words of the question and the answer cannot open a line
65
+ * the way one of the bot's own headers does (`neutraliseHeaderLookalikes`) — an answer may be typed by a topic member.
66
+ */
67
+ export declare function buildLateAnswerPrompt(input: LateAnswerPromptInput): string;
68
+ /**
69
+ * @description The id of the set-aside record made from the topic's `sequence`-th set-aside question (the counter starts at 1,
70
+ * only goes up, and is kept for the topic's lifetime — closing a record, an eviction or a new conversation never resets it). A
71
+ * counter, not a hash or a clock: two questions can never share an id, so an old keyboard that stayed live can never answer a
72
+ * newer question. Short, as the button data holds 64 bytes.
73
+ */
74
+ export declare function createSetAsideQuestionId(sequence: number): string;
75
+ /**
76
+ * @description Whether `messageId` is one of the messages that show a set-aside question: the live one (`messageId`) or, when a
77
+ * re-post put a copy at the bottom, the original it left up (`originalMessageId`). A reply to either answers the record, and a
78
+ * tap is honoured only on one of them.
79
+ */
80
+ export declare function checkIsSetAsideRecordMessage(record: SetAsideQuestionRecord, messageId: number): boolean;
81
+ /**
82
+ * @description The question of a set-aside record a late answer goes to: its first one still open (the questions of one call
83
+ * are answered in order, like on screen), `null` when none is. `index` is its place in `record.questions` / `record.answers`.
84
+ */
85
+ export declare function getSetAsideAnswerTarget(record: SetAsideQuestionRecord): {
86
+ index: number;
87
+ question: OpenCodeQuestion;
88
+ } | null;
89
+ /** @description What {@link getSetAsideRecordAskedAgain} found. */
90
+ export interface SetAsideRecordAskedAgain {
91
+ record: SetAsideQuestionRecord;
92
+ /** One slot per question of the call the agent asks now: what the owner answered before, `null` for a question still open. */
93
+ answers: (string[] | null)[];
94
+ }
95
+ /**
96
+ * @description The set-aside record the question the agent asks NOW repeats — it did not take «do not ask it again»: the same question
97
+ * texts AND option labels (the header does not count), in the same order, as the record's whole call — the answers the owner
98
+ * already gave ride along — or as the questions the record still has open (the rest of a call the owner answered in part, asked
99
+ * again alone). The newest such record; `null` for a question that is new.
100
+ */
101
+ export declare function getSetAsideRecordAskedAgain(records: SetAsideQuestionRecord[], questions: OpenCodeQuestion[]): SetAsideRecordAskedAgain | null;
102
+ /**
103
+ * @description How a message typed in the topic is routed while a question may wait or may be set aside.
104
+ * - `answer` / `cancel` — a question is still waiting (the agent is blocked on it): today's route, see {@link getQuestionReplyRoute};
105
+ * - `answerSetAside` — the message answers the open question `questionIndex` of the set-aside record `recordId`, with `answer`
106
+ * (a reply: the label a bare option number names, else the typed text);
107
+ * - `prompt` — an ordinary message: it closes nothing and interrupts nothing, a set-aside question stays open.
108
+ */
109
+ export type QuestionReplyRouteWithSetAside = {
110
+ kind: 'answer';
111
+ labels: string[];
112
+ } | {
113
+ kind: 'cancel';
114
+ } | {
115
+ kind: 'answerSetAside';
116
+ recordId: string;
117
+ questionIndex: number;
118
+ answer: string[];
119
+ } | {
120
+ kind: 'prompt';
121
+ };
122
+ /** @description What {@link getQuestionReplyRouteWithSetAside} decides on. */
123
+ export interface QuestionReplyRouteInput {
124
+ text: string;
125
+ /** The Telegram message the text replies to, `null` when it is not a reply. */
126
+ replyToMessageId: number | null;
127
+ /** The question on screen that the agent is blocked on right now, if any. */
128
+ liveQuestion: OpenCodeQuestion | undefined;
129
+ /** The conversation's open set-aside questions, oldest first. */
130
+ setAside: readonly SetAsideQuestionRecord[];
131
+ /**
132
+ * The message is a forward: somebody else's words are content, never control, so it answers no question (the same rule as
133
+ * `deliverActivePrompt`'s). A waiting question is still cancelled by it, as by any other message that is not a pick.
134
+ */
135
+ isForwarded: boolean;
136
+ /**
137
+ * Whether the reply may be the answer in the person's own words. The operator's may; a topic member's answers only with an option
138
+ * number or an option's label — their free text is an ordinary prompt, as on the waiting-question route.
139
+ */
140
+ canAnswerWithFreeText: boolean;
141
+ }
142
+ /**
143
+ * @description Route a typed message, in this order. A forwarded message is somebody else's words — content, never control —
144
+ * so it does not answer a set-aside question (1), and answers no waiting question either (2: it cancels it, like any message
145
+ * that is not a pick).
146
+ * 1. a REPLY to either message of a set-aside question answers that question — whatever else is open, the person named it: a
147
+ * bare option number in range picks that label, so does an option's own label (both read without the quotes and the closing
148
+ * punctuation around them, which a transcript adds), and any other text is the answer itself, as it was typed — but
149
+ * only where `canAnswerWithFreeText` (a topic member's other text routes on, as an ordinary message; a reply with no text routes
150
+ * on too);
151
+ * 2. a question still waiting keeps its route (a number answers it, other text cancels it and goes as a prompt);
152
+ * 3. anything else is an ordinary prompt — it never closes a set-aside question. In particular a bare number with nothing
153
+ * waiting is NOT an answer to one: the agent writes new numbered text right after a set-aside, and no guard on it can be kept
154
+ * across a restart, so a set-aside question is answered late only by a tap on its buttons or a reply to its message.
155
+ */
156
+ export declare function getQuestionReplyRouteWithSetAside(input: QuestionReplyRouteInput): QuestionReplyRouteWithSetAside;
157
+ /**
158
+ * @description Add a newly set-aside question to the conversation's list (oldest first), keeping at most
159
+ * {@link maxSetAsideQuestions}: the oldest ones that no longer fit are handed back as `evicted`, for the bot to close as
160
+ * «not answered» and unpin.
161
+ */
162
+ export declare function addSetAsideQuestion(records: readonly SetAsideQuestionRecord[], added: SetAsideQuestionRecord): {
163
+ records: SetAsideQuestionRecord[];
164
+ evicted: SetAsideQuestionRecord[];
165
+ };
166
+ //# sourceMappingURL=questionWaitPlan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"questionWaitPlan.d.ts","sourceRoot":"","sources":["../../src/utils/questionWaitPlan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGzE,OAAO,EAA6C,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAI3G,wGAAwG;AACxG,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,kBAAkB,GAAG,SAAS,EAC3C,aAAa,EAAE,kBAAkB,GAAG,SAAS,GAC5C,kBAAkB,CAEpB;AAED;;;;;;GAMG;AACH,wBAAg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,EAAE,SAAS,sBAAsB,EAAE,EAC1C,KAAK,EAAE,sBAAsB,GAC5B;IAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;IAAC,OAAO,EAAE,sBAAsB,EAAE,CAAA;CAAE,CAI1E"}
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ /**
3
+ * @description Pure plan for «a question the agent asked never stops its work»: how long a question waits for the owner
4
+ * (the «question wait» setting and its resolution), what the agent is told when the wait ends and the question is set aside,
5
+ * what it is told when the answer comes later, how a typed message is routed while questions wait or are set aside, and how
6
+ * many set-aside questions stay open at once.
7
+ *
8
+ * The bot owns every side effect (the timer, the deny / reply to the CLI, the Telegram edit and pin, the delivery of the late
9
+ * answer); this module only decides and words — so the rules are unit-testable without a live agent. The texts here are
10
+ * agent-facing English, never i18n, and the only place the model learns what «set aside» means: they are literal and
11
+ * never phrased as the user's words.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.maxSetAsideQuestions = void 0;
15
+ exports.resolveQuestionWait = resolveQuestionWait;
16
+ exports.getQuestionSetAsideDelayMs = getQuestionSetAsideDelayMs;
17
+ exports.buildQuestionSetAsideText = buildQuestionSetAsideText;
18
+ exports.buildLateAnswerPrompt = buildLateAnswerPrompt;
19
+ exports.createSetAsideQuestionId = createSetAsideQuestionId;
20
+ exports.checkIsSetAsideRecordMessage = checkIsSetAsideRecordMessage;
21
+ exports.getSetAsideAnswerTarget = getSetAsideAnswerTarget;
22
+ exports.getSetAsideRecordAskedAgain = getSetAsideRecordAskedAgain;
23
+ exports.getQuestionReplyRouteWithSetAside = getQuestionReplyRouteWithSetAside;
24
+ exports.addSetAsideQuestion = addSetAsideQuestion;
25
+ const openCodeQuestionFlow_1 = require("../openCodeQuestionFlow");
26
+ const authorMark_1 = require("./authorMark");
27
+ const localClock_1 = require("./localClock");
28
+ const questionWaitChoices_1 = require("./questionWaitChoices");
29
+ const msPerMinute = 60_000;
30
+ /** The most questions set aside and still open in one conversation; a further one closes the oldest. */
31
+ exports.maxSetAsideQuestions = 5;
32
+ /**
33
+ * @description The wait that applies to a topic: its own choice, else General's (the instance default), else
34
+ * {@link defaultQuestionWaitChoice}.
35
+ */
36
+ function resolveQuestionWait(topicChoice, generalChoice) {
37
+ return topicChoice ?? generalChoice ?? questionWaitChoices_1.defaultQuestionWaitChoice;
38
+ }
39
+ /**
40
+ * @description How long from `nowMs` until a question asked at `askedAtMs` is to be set aside: `0` when its wait is over
41
+ * (also a `dontWait`), `null` when its choice never sets it aside. The point is `askedAtMs + wait` whatever the agent's
42
+ * process looks like — the timer is armed from this at ask time and again at boot, so a restart keeps the original moment.
43
+ * `shortenedToMs` is a test instance's own window (`CHARNESS_TEST_TIMINGS`): it cuts a finite wait to at most that, and
44
+ * leaves `dontWait` and `untilAnswered` as they are.
45
+ */
46
+ function getQuestionSetAsideDelayMs(askedAtMs, choice, nowMs, shortenedToMs) {
47
+ const waitMs = questionWaitChoices_1.questionWaitMs[choice];
48
+ if (waitMs === null)
49
+ return null;
50
+ const effectiveWaitMs = shortenedToMs === undefined ? waitMs : Math.min(waitMs, shortenedToMs);
51
+ return Math.max(askedAtMs + effectiveWaitMs - nowMs, 0);
52
+ }
53
+ /** What a question is called to the agent: its full text, else its header. */
54
+ function getQuestionText(question) {
55
+ return question.question || question.header || 'Question';
56
+ }
57
+ /** A multi-select answer reads as its labels in a row. */
58
+ function formatAnswer(answer) {
59
+ return answer.join(', ');
60
+ }
61
+ /**
62
+ * A text of somebody's words inside a line of ours, as a JSON string: the agent cannot mistake it for a line of the text around
63
+ * it. The line breaks (`\n` and the others a reader takes for one: U+2028, U+2029, a carriage return) go through
64
+ * `neutraliseHeaderLookalikes` first — JSON leaves U+2028 / U+2029 raw, and an answer carries a topic member's name.
65
+ */
66
+ function quoteWords(words) {
67
+ return JSON.stringify((0, authorMark_1.neutraliseHeaderLookalikes)(words));
68
+ }
69
+ /** What the agent's tool result says about a call's questions that were answered before the wait ended. */
70
+ function formatGivenAnswers(questions, answers) {
71
+ const given = [];
72
+ questions.forEach((question, index) => {
73
+ const answer = answers[index];
74
+ if (answer)
75
+ given.push(`${quoteWords(getQuestionText(question))} = ${quoteWords(formatAnswer(answer))}`);
76
+ });
77
+ return given.length > 0 ? `(Answers already given in this call: ${given.join('; ')}.)` : null;
78
+ }
79
+ /**
80
+ * @description The text the agent gets as the result of its question when the wait ends: Claude's `can_use_tool` deny
81
+ * message, OpenCode's custom answer of every question left open. It says the truth — nobody answered, the question stays
82
+ * open, the answer arrives later as a message — and tells the agent to go on, so its turn does not stop on the tool call.
83
+ * Answers given before the wait ended are named, so the agent does not lose them.
84
+ */
85
+ function buildQuestionSetAsideText(input) {
86
+ const asked = (0, localClock_1.formatLocalClockWithDateIfNotToday)(input.askedAtMs, input.nowMs);
87
+ const waitedMinutes = Math.round((input.nowMs - input.askedAtMs) / msPerMinute);
88
+ const waited = waitedMinutes >= 1 ? `waited ${waitedMinutes} min` : 'set aside at once';
89
+ const firstLine = input.isAlreadyOpen
90
+ ? `[Charness] This question is still open: the user has not answered it yet (asked ${asked}). This is NOT an answer.`
91
+ : `[Charness] The user has not answered yet (asked ${asked}, ${waited}). This is NOT an answer.`;
92
+ const givenAnswers = formatGivenAnswers(input.questions, input.answers);
93
+ return [
94
+ firstLine,
95
+ 'The question stays open for them in the topic; do not ask it again and do not wait for it.',
96
+ 'Go on with work that does not depend on it; if nothing is left, end your turn.',
97
+ 'Their answer, when it comes, arrives as a new message headed "[Late answer to your question …]".',
98
+ ...(givenAnswers ? [givenAnswers] : []),
99
+ ].join('\n');
100
+ }
101
+ /**
102
+ * @description The message that carries a late answer to the agent, which went on without it: names the question, the
103
+ * answer, and asks the agent to check what it did meanwhile. The words of the question and the answer cannot open a line
104
+ * the way one of the bot's own headers does (`neutraliseHeaderLookalikes`) — an answer may be typed by a topic member.
105
+ */
106
+ function buildLateAnswerPrompt(input) {
107
+ const asked = (0, localClock_1.formatLocalClockWithDateIfNotToday)(input.askedAtMs, input.nowMs);
108
+ const setAside = (0, localClock_1.formatLocalClockWithDateIfNotToday)(input.setAsideAtMs, input.nowMs);
109
+ const isSeveral = input.entries.length > 1;
110
+ const pairs = input.entries.map((entry) => [
111
+ `Question: ${(0, authorMark_1.neutraliseHeaderLookalikes)(getQuestionText(entry.question))}`,
112
+ `Answer: ${(0, authorMark_1.neutraliseHeaderLookalikes)(formatAnswer(entry.answer))}`,
113
+ ].join('\n'));
114
+ return [
115
+ `[Late answer to your question asked ${asked}, set aside ${setAside}]`,
116
+ pairs.join('\n\n'),
117
+ isSeveral
118
+ ? 'You went on without them — check whether anything you did meanwhile conflicts with these answers, and adjust.'
119
+ : 'You went on without it — check whether anything you did meanwhile conflicts with this answer, and adjust.',
120
+ ].join('\n');
121
+ }
122
+ /** Radix of a record id: letters and digits only, so the `_` that separates the parts of the button data never occurs in one. */
123
+ const setAsideQuestionIdRadix = 36;
124
+ /**
125
+ * @description The id of the set-aside record made from the topic's `sequence`-th set-aside question (the counter starts at 1,
126
+ * only goes up, and is kept for the topic's lifetime — closing a record, an eviction or a new conversation never resets it). A
127
+ * counter, not a hash or a clock: two questions can never share an id, so an old keyboard that stayed live can never answer a
128
+ * newer question. Short, as the button data holds 64 bytes.
129
+ */
130
+ function createSetAsideQuestionId(sequence) {
131
+ return sequence.toString(setAsideQuestionIdRadix);
132
+ }
133
+ /**
134
+ * @description Whether `messageId` is one of the messages that show a set-aside question: the live one (`messageId`) or, when a
135
+ * re-post put a copy at the bottom, the original it left up (`originalMessageId`). A reply to either answers the record, and a
136
+ * tap is honoured only on one of them.
137
+ */
138
+ function checkIsSetAsideRecordMessage(record, messageId) {
139
+ return record.messageId === messageId || record.originalMessageId === messageId;
140
+ }
141
+ /**
142
+ * @description The question of a set-aside record a late answer goes to: its first one still open (the questions of one call
143
+ * are answered in order, like on screen), `null` when none is. `index` is its place in `record.questions` / `record.answers`.
144
+ */
145
+ function getSetAsideAnswerTarget(record) {
146
+ const index = record.answers.findIndex((answer) => answer === null);
147
+ if (index === -1)
148
+ return null;
149
+ const question = record.questions[index];
150
+ return question ? { index, question } : null;
151
+ }
152
+ /**
153
+ * A question as the check «the same question again» reads it: its text and its option labels, in order. A run of whitespace and the
154
+ * ends do not tell two apart; the header and the option descriptions do not count. The labels are part of it because short
155
+ * questions repeat word for word across unrelated steps («Proceed?»), and only a question with the same choices has the same answers.
156
+ */
157
+ function getQuestionMatchKey(question) {
158
+ const normalise = (words) => words.replace(/\s+/g, ' ').trim();
159
+ return JSON.stringify([normalise(getQuestionText(question)), question.options.map((option) => normalise(option.label))]);
160
+ }
161
+ /**
162
+ * @description The set-aside record the question the agent asks NOW repeats — it did not take «do not ask it again»: the same question
163
+ * texts AND option labels (the header does not count), in the same order, as the record's whole call — the answers the owner
164
+ * already gave ride along — or as the questions the record still has open (the rest of a call the owner answered in part, asked
165
+ * again alone). The newest such record; `null` for a question that is new.
166
+ */
167
+ function getSetAsideRecordAskedAgain(records, questions) {
168
+ if (questions.length === 0)
169
+ return null;
170
+ const askedKeys = questions.map(getQuestionMatchKey);
171
+ const checkIsAsked = (candidates) => candidates.length === askedKeys.length && candidates.every((candidate, index) => getQuestionMatchKey(candidate) === askedKeys[index]);
172
+ for (const record of [...records].reverse()) {
173
+ if (checkIsAsked(record.questions))
174
+ return { record, answers: record.answers };
175
+ const openQuestions = record.questions.filter((_, index) => record.answers[index] === null);
176
+ if (checkIsAsked(openQuestions))
177
+ return { record, answers: openQuestions.map(() => null) };
178
+ }
179
+ return null;
180
+ }
181
+ /**
182
+ * What does not tell two replies apart at their ends: the quotes a person wraps an option in, and the sentence punctuation a speech
183
+ * engine puts after a lone answer («1.», «Wait for the review.»). Leading quotes and trailing quotes and punctuation only — a
184
+ * punctuation mark inside the words stays.
185
+ */
186
+ const replyEdgeNoise = /^[\s"'`«»“”„‘’]+|[\s"'`«»“”„‘’.,;:!?…]+$/g;
187
+ /** A reply, or an option label, as an option is matched against it: without the noise at its ends, and with no regard to the case. */
188
+ function normaliseReplyText(text) {
189
+ return text.replace(replyEdgeNoise, '').toLowerCase();
190
+ }
191
+ /**
192
+ * @description Route a typed message, in this order. A forwarded message is somebody else's words — content, never control —
193
+ * so it does not answer a set-aside question (1), and answers no waiting question either (2: it cancels it, like any message
194
+ * that is not a pick).
195
+ * 1. a REPLY to either message of a set-aside question answers that question — whatever else is open, the person named it: a
196
+ * bare option number in range picks that label, so does an option's own label (both read without the quotes and the closing
197
+ * punctuation around them, which a transcript adds), and any other text is the answer itself, as it was typed — but
198
+ * only where `canAnswerWithFreeText` (a topic member's other text routes on, as an ordinary message; a reply with no text routes
199
+ * on too);
200
+ * 2. a question still waiting keeps its route (a number answers it, other text cancels it and goes as a prompt);
201
+ * 3. anything else is an ordinary prompt — it never closes a set-aside question. In particular a bare number with nothing
202
+ * waiting is NOT an answer to one: the agent writes new numbered text right after a set-aside, and no guard on it can be kept
203
+ * across a restart, so a set-aside question is answered late only by a tap on its buttons or a reply to its message.
204
+ */
205
+ function getQuestionReplyRouteWithSetAside(input) {
206
+ const text = input.text.trim();
207
+ const { replyToMessageId } = input;
208
+ const repliedRecord = !input.isForwarded && replyToMessageId !== null
209
+ ? input.setAside.find((record) => checkIsSetAsideRecordMessage(record, replyToMessageId))
210
+ : undefined;
211
+ const repliedTarget = repliedRecord ? getSetAsideAnswerTarget(repliedRecord) : null;
212
+ if (repliedRecord && repliedTarget && text !== '') {
213
+ // A reply is read the way it was probably meant: a voice reply's transcript carries a full stop after the «1» or the label it says.
214
+ const meant = normaliseReplyText(text);
215
+ const numberRoute = (0, openCodeQuestionFlow_1.getQuestionReplyRoute)(meant, repliedTarget.question);
216
+ const ownLabel = meant === '' ? undefined : repliedTarget.question.options.find((option) => normaliseReplyText(option.label) === meant)?.label;
217
+ const answer = numberRoute.kind === 'answer' ? numberRoute.labels : ownLabel !== undefined ? [ownLabel] : input.canAnswerWithFreeText ? [text] : null;
218
+ if (answer !== null)
219
+ return { kind: 'answerSetAside', recordId: repliedRecord.id, questionIndex: repliedTarget.index, answer };
220
+ }
221
+ if (input.liveQuestion) {
222
+ const liveRoute = (0, openCodeQuestionFlow_1.getQuestionReplyRoute)(text, input.liveQuestion);
223
+ return input.isForwarded && liveRoute.kind === 'answer' ? { kind: 'cancel' } : liveRoute;
224
+ }
225
+ return { kind: 'prompt' };
226
+ }
227
+ /**
228
+ * @description Add a newly set-aside question to the conversation's list (oldest first), keeping at most
229
+ * {@link maxSetAsideQuestions}: the oldest ones that no longer fit are handed back as `evicted`, for the bot to close as
230
+ * «not answered» and unpin.
231
+ */
232
+ function addSetAsideQuestion(records, added) {
233
+ const all = [...records, added];
234
+ const overflow = Math.max(all.length - exports.maxSetAsideQuestions, 0);
235
+ return { records: all.slice(overflow), evicted: all.slice(0, overflow) };
236
+ }
237
+ //# sourceMappingURL=questionWaitPlan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"questionWaitPlan.js","sourceRoot":"","sources":["../../src/utils/questionWaitPlan.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAiBH,kDAKC;AASD,gEAKC;AAkDD,8DAeC;AAuBD,sDAiBC;AAWD,4DAEC;AAOD,oEAEC;AAMD,0DAKC;AAyBD,kEAWC;AA8DD,8EAuBC;AAOD,kDAOC;AAnTD,kEAAgE;AAEhE,6CAA0D;AAC1D,6CAAkE;AAClE,+DAA2G;AAE3G,MAAM,WAAW,GAAG,MAAM,CAAC;AAE3B,wGAAwG;AAC3F,QAAA,oBAAoB,GAAG,CAAC,CAAC;AAEtC;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,WAA2C,EAC3C,aAA6C;IAE7C,OAAO,WAAW,IAAI,aAAa,IAAI,+CAAyB,CAAC;AACnE,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,0BAA0B,CAAC,SAAiB,EAAE,MAA0B,EAAE,KAAa,EAAE,aAAsB;IAC7H,MAAM,MAAM,GAAG,oCAAc,CAAC,MAAM,CAAC,CAAC;IACtC,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACjC,MAAM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export interface ExtractedReplyQuote {
81
81
  /** Who first wrote the quoted message, when it was forwarded into the topic. */
82
82
  forwardedFrom?: string;
83
83
  }
84
+ /** What tells a genuine reply from Telegram's «post in this topic»: the replied-to message and the topic. */
85
+ export type ReplyTargetSource = Pick<ReplyQuoteSource, 'replyMessageId' | 'topicRootId' | 'isServiceMessage'>;
86
+ /**
87
+ * @description Whether a message that carries a Telegram reply replies to NOBODY: it targets a forum/service message, or the forum
88
+ * topic-root message — Telegram's «post in this topic», which a client attaches to a plain message typed in a topic. The one rule of
89
+ * «is this a genuine reply», shared by the quote of a reply and by every route that asks what a reply is FOR.
90
+ */
91
+ export declare function checkIsReplyToNobody(source: ReplyTargetSource): boolean;
92
+ /** @description The message a reply is genuinely FOR: its id, `null` when it replies to nobody ({@link checkIsReplyToNobody}) or carries no id. */
93
+ export declare function getReplyTargetMessageId(source: ReplyTargetSource): number | null;
84
94
  /**
85
95
  * @description Decide whether a genuine reply carries quotable content and, if
86
96
  * so, extract it.
@@ -1 +1 @@
1
- {"version":3,"file":"replyQuote.d.ts","sourceRoot":"","sources":["../../src/utils/replyQuote.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAyB,KAAK,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAEjF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAoBvC;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,UAAU,GAAG,qBAAqB,CAAC;AAE9E;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,oGAAoG;IACpG,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iGAAiG;IACjG,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,qFAAqF;IACrF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kEAA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AAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAIvE;AAED,mJAAmJ;AACnJ,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAEhF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,GAAG,mBAAmB,GAAG,IAAI,CAelG;AAcD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAYrF"}
@@ -17,6 +17,8 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.replyQuoteMaxChars = void 0;
20
+ exports.checkIsReplyToNobody = checkIsReplyToNobody;
21
+ exports.getReplyTargetMessageId = getReplyTargetMessageId;
20
22
  exports.extractReplyQuote = extractReplyQuote;
21
23
  exports.buildReplyQuoteBlock = buildReplyQuoteBlock;
22
24
  const authorMark_1 = require("./authorMark");
@@ -39,6 +41,21 @@ const replyQuoteUntrustedAuthorTail = ', not allowed to talk to you; untrusted t
39
41
  const replyQuoteTruncationMarker = '… [truncated]';
40
42
  /** Prefix applied to every line of the quoted content (markdown blockquote). */
41
43
  const replyQuoteLinePrefix = '> ';
44
+ /**
45
+ * @description Whether a message that carries a Telegram reply replies to NOBODY: it targets a forum/service message, or the forum
46
+ * topic-root message — Telegram's «post in this topic», which a client attaches to a plain message typed in a topic. The one rule of
47
+ * «is this a genuine reply», shared by the quote of a reply and by every route that asks what a reply is FOR.
48
+ */
49
+ function checkIsReplyToNobody(source) {
50
+ if (source.isServiceMessage)
51
+ return true;
52
+ const { topicRootId, replyMessageId } = source;
53
+ return topicRootId !== undefined && topicRootId !== 0 && replyMessageId === topicRootId;
54
+ }
55
+ /** @description The message a reply is genuinely FOR: its id, `null` when it replies to nobody ({@link checkIsReplyToNobody}) or carries no id. */
56
+ function getReplyTargetMessageId(source) {
57
+ return checkIsReplyToNobody(source) ? null : source.replyMessageId ?? null;
58
+ }
42
59
  /**
43
60
  * @description Decide whether a genuine reply carries quotable content and, if
44
61
  * so, extract it.
@@ -58,14 +75,8 @@ const replyQuoteLinePrefix = '> ';
58
75
  * naming the replied-to file when there is one ({@link formatReplyAttachment}).
59
76
  */
60
77
  function extractReplyQuote(source) {
61
- if (!source)
78
+ if (!source || checkIsReplyToNobody(source))
62
79
  return null;
63
- if (source.isServiceMessage)
64
- return null;
65
- const { topicRootId, replyMessageId } = source;
66
- if (topicRootId !== undefined && topicRootId !== 0 && replyMessageId === topicRootId) {
67
- return null;
68
- }
69
80
  const candidates = [source.manualQuoteText, source.replyText, source.replyCaption];
70
81
  const text = candidates.map((candidate) => candidate?.trim()).find((trimmed) => !!trimmed);
71
82
  const attachmentLine = source.replyAttachment ? formatReplyAttachment(source.replyAttachment) : undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"replyQuote.js","sourceRoot":"","sources":["../../src/utils/replyQuote.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AA+GH,8CAqBC;AAoBD,oDAYC;AAlKD,6CAAiF;AAEjF;;;;GAIG;AACU,QAAA,kBAAkB,GAAG,IAAI,CAAC;AAEvC,gFAAgF;AAChF,MAAM,sBAAsB,GAAG,0CAA0C,CAAC;AAE1E,6FAA6F;AAC7F,MAAM,gCAAgC,GAAG,mBAAmB,CAAC;AAE7D;;;GAGG;AACH,MAAM,6BAA6B,GAAG,8CAA8C,CAAC;AAErF,uEAAuE;AACvE,MAAM,0BAA0B,GAAG,eAAe,CAAC;AAEnD,gFAAgF;AAChF,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAkElC;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,iBAAiB,CAAC,MAAoC;IACpE,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,MAAM,CAAC,gBAAgB;QAAE,OAAO,IAAI,CAAC;IAEzC,MAAM,E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C,KAAK,CAAC,GAAG,aAAa,GAAG,KAAK,CAAC,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;IAClK,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,oBAAoB,GAAG,IAAI,EAAE,CAAC,CAAC;IACxF,OAAO,CAAC,MAAM,EAAE,GAAG,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,SAAS,wBAAwB,CAAC,KAA0B;IAC1D,IAAI,KAAK,CAAC,UAAU,KAAK,KAAK;QAAE,OAAO,WAAW,CAAC;IACnD,IAAI,KAAK,CAAC,UAAU,KAAK,UAAU;QAAE,OAAO,MAAM,CAAC;IACnD,OAAO,IAAA,kCAAqB,EAAC,KAAK,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,IAAI,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC;AACnH,CAAC"}
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @description The buttons a talker (a person an admin let talk to the agent in one topic) may tap. Everything else on a
3
3
  * button is the admins': a picker, a wizard, a setting. The set is closed — default-deny, like the commands — and holds only
4
- * the taps that ANSWER the agent: an option of a question it put to the topic, and the same question asked again after a
5
- * compaction.
4
+ * the taps that ANSWER the agent: an option of a question it put to the topic, the same question asked again after a
5
+ * compaction, and a question the bot set aside because nobody answered it in time.
6
6
  */
7
7
  /** @description Whether a button with this `callback_data` is one a talker may tap. */
8
8
  export declare function checkIsTalkerCallback(callbackData: string | undefined): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"talkerAccess.d.ts","sourceRoot":"","sources":["../../src/utils/talkerAccess.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,uFAAuF;AACvF,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAE/E"}
1
+ {"version":3,"file":"talkerAccess.d.ts","sourceRoot":"","sources":["../../src/utils/talkerAccess.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,uFAAuF;AACvF,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAE/E"}
@@ -2,17 +2,18 @@
2
2
  /**
3
3
  * @description The buttons a talker (a person an admin let talk to the agent in one topic) may tap. Everything else on a
4
4
  * button is the admins': a picker, a wizard, a setting. The set is closed — default-deny, like the commands — and holds only
5
- * the taps that ANSWER the agent: an option of a question it put to the topic, and the same question asked again after a
6
- * compaction.
5
+ * the taps that ANSWER the agent: an option of a question it put to the topic, the same question asked again after a
6
+ * compaction, and a question the bot set aside because nobody answered it in time.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.checkIsTalkerCallback = checkIsTalkerCallback;
10
10
  /**
11
- * The callback data of the agent's own question buttons: `qa_<question>_<option>` (a question) and `reask_<option>` (asked again).
11
+ * The callback data of the agent's own question buttons: `qa_<question>_<option>` (a question), `reask_<option>` (asked again) and
12
+ * `qs_<record id>_<option>` (set aside; the id is base 36).
12
13
  * `opt_<n>` (a Claude TUI selector) is NOT one: no code builds such a button any more, and its handler types a digit into whatever the
13
14
  * TUI shows — an admin's dialog, a login picker.
14
15
  */
15
- const talkerCallbackPatterns = [/^qa_\d+_\d+$/, /^reask_\d+$/];
16
+ const talkerCallbackPatterns = [/^qa_\d+_\d+$/, /^reask_\d+$/, /^qs_[0-9a-z]+_\d+$/];
16
17
  /** @description Whether a button with this `callback_data` is one a talker may tap. */
17
18
  function checkIsTalkerCallback(callbackData) {
18
19
  return callbackData !== undefined && talkerCallbackPatterns.some((pattern) => pattern.test(callbackData));
@@ -1 +1 @@
1
- {"version":3,"file":"talkerAccess.js","sourceRoot":"","sources":["../../src/utils/talkerAccess.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAUH,sDAEC;AAVD;;;;GAIG;AACH,MAAM,sBAAsB,GAAsB,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;AAElF,uFAAuF;AACvF,SAAgB,qBAAqB,CAAC,YAAgC;IACpE,OAAO,YAAY,KAAK,SAAS,IAAI,sBAAsB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;AAC5G,CAAC"}
1
+ {"version":3,"file":"talkerAccess.js","sourceRoot":"","sources":["../../src/utils/talkerAccess.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAWH,sDAEC;AAXD;;;;;GAKG;AACH,MAAM,sBAAsB,GAAsB,CAAC,cAAc,EAAE,aAAa,EAAE,oBAAoB,CAAC,CAAC;AAExG,uFAAuF;AACvF,SAAgB,qBAAqB,CAAC,YAAgC;IACpE,OAAO,YAAY,KAAK,SAAS,IAAI,sBAAsB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;AAC5G,CAAC"}
@@ -5,6 +5,12 @@ export declare function checkIsStaleAnswerCallbackQueryError(err: unknown): bool
5
5
  * (older than 48 hours, no right) — that message stays.
6
6
  */
7
7
  export declare function checkIsMessageNotFoundError(err: unknown): boolean;
8
+ /**
9
+ * @description Whether a Telegram error is the REFUSAL to delete a message — no right to delete (`not enough rights`,
10
+ * `CHAT_ADMIN_REQUIRED`) or a message Telegram will not delete (`message can't be deleted`: older than 48 hours, say). The
11
+ * answer is final until the right changes; a timeout, a reset or a 429 is none of these and a later try may well work.
12
+ */
13
+ export declare function checkIsMessageDeletionRefusedError(err: unknown): boolean;
8
14
  /**
9
15
  * @description Whether an error is the network's rather than a Bot API answer or a bug of ours: node-fetch's `FetchError`
10
16
  * (any of its types — a system error, a timeout), a Node socket / DNS error code, or the «socket hang up» / «network timeout»
@@ -1 +1 @@
1
- {"version":3,"file":"telegramError.d.ts","sourceRoot":"","sources":["../../src/utils/telegramError.ts"],"names":[],"mappings":"AAYA,wBAAgB,oCAAoC,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAS1E;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAIjE;AAmBD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAKzD;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAKnE"}
1
+ {"version":3,"file":"telegramError.d.ts","sourceRoot":"","sources":["../../src/utils/telegramError.ts"],"names":[],"mappings":"AAYA,wBAAgB,oCAAoC,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAS1E;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAIjE;AAED;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAIxE;AAmBD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAKzD;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAKnE"}