charness 4.2.0 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (553) hide show
  1. package/CHANGELOG.md +168 -2
  2. package/DEVELOPMENT.md +58 -10
  3. package/LICENSE +331 -151
  4. package/MIGRATION_3_TO_4.md +8 -5
  5. package/README.md +21 -9
  6. package/SETUP.md +54 -10
  7. package/agent-plugin/README.md +10 -3
  8. package/agent-plugin/skills/charness-delegate-claude/SKILL.md +18 -27
  9. package/agent-plugin/skills/charness-delegate-opencode/SKILL.md +5 -3
  10. package/agent-plugin/skills/charness-orchestration/SKILL.md +62 -16
  11. package/dist/adapters/claudeCliAdapter.d.ts +4 -0
  12. package/dist/adapters/claudeCliAdapter.d.ts.map +1 -1
  13. package/dist/adapters/claudeCliAdapter.js +13 -0
  14. package/dist/adapters/claudeCliAdapter.js.map +1 -1
  15. package/dist/adapters/claudeJsonStreamAdapter.d.ts +136 -10
  16. package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -1
  17. package/dist/adapters/claudeJsonStreamAdapter.js +365 -77
  18. package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
  19. package/dist/adapters/createAdapter.d.ts +12 -3
  20. package/dist/adapters/createAdapter.d.ts.map +1 -1
  21. package/dist/adapters/createAdapter.js +39 -13
  22. package/dist/adapters/createAdapter.js.map +1 -1
  23. package/dist/adapters/openCodeAdapter.d.ts +34 -0
  24. package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
  25. package/dist/adapters/openCodeAdapter.js +118 -11
  26. package/dist/adapters/openCodeAdapter.js.map +1 -1
  27. package/dist/apiErrorRetry.d.ts +11 -3
  28. package/dist/apiErrorRetry.d.ts.map +1 -1
  29. package/dist/apiErrorRetry.js +33 -3
  30. package/dist/apiErrorRetry.js.map +1 -1
  31. package/dist/apiRetryKick.d.ts +18 -7
  32. package/dist/apiRetryKick.d.ts.map +1 -1
  33. package/dist/apiRetryKick.js +26 -13
  34. package/dist/apiRetryKick.js.map +1 -1
  35. package/dist/bot.d.ts +2 -6
  36. package/dist/bot.d.ts.map +1 -1
  37. package/dist/bot.js +2055 -653
  38. package/dist/bot.js.map +1 -1
  39. package/dist/cli/claudeProfiles.d.ts +28 -6
  40. package/dist/cli/claudeProfiles.d.ts.map +1 -1
  41. package/dist/cli/claudeProfiles.js +89 -22
  42. package/dist/cli/claudeProfiles.js.map +1 -1
  43. package/dist/cli.d.ts.map +1 -1
  44. package/dist/cli.js +2 -1
  45. package/dist/cli.js.map +1 -1
  46. package/dist/connectors/jira/answerSink.d.ts +102 -7
  47. package/dist/connectors/jira/answerSink.d.ts.map +1 -1
  48. package/dist/connectors/jira/answerSink.js +366 -60
  49. package/dist/connectors/jira/answerSink.js.map +1 -1
  50. package/dist/connectors/jira/answerThreads.d.ts +44 -0
  51. package/dist/connectors/jira/answerThreads.d.ts.map +1 -0
  52. package/dist/connectors/jira/answerThreads.js +85 -0
  53. package/dist/connectors/jira/answerThreads.js.map +1 -0
  54. package/dist/connectors/jira/client.d.ts +67 -2
  55. package/dist/connectors/jira/client.d.ts.map +1 -1
  56. package/dist/connectors/jira/client.js +176 -4
  57. package/dist/connectors/jira/client.js.map +1 -1
  58. package/dist/connectors/jira/config.d.ts +6 -0
  59. package/dist/connectors/jira/config.d.ts.map +1 -1
  60. package/dist/connectors/jira/config.js +14 -1
  61. package/dist/connectors/jira/config.js.map +1 -1
  62. package/dist/connectors/jira/connector.d.ts +19 -0
  63. package/dist/connectors/jira/connector.d.ts.map +1 -1
  64. package/dist/connectors/jira/connector.js +68 -6
  65. package/dist/connectors/jira/connector.js.map +1 -1
  66. package/dist/connectors/jira/contextPreamble.d.ts.map +1 -1
  67. package/dist/connectors/jira/contextPreamble.js +6 -1
  68. package/dist/connectors/jira/contextPreamble.js.map +1 -1
  69. package/dist/connectors/jira/inbound.d.ts +21 -6
  70. package/dist/connectors/jira/inbound.d.ts.map +1 -1
  71. package/dist/connectors/jira/inbound.js +22 -16
  72. package/dist/connectors/jira/inbound.js.map +1 -1
  73. package/dist/connectors/jira/issueBlocks.d.ts +8 -1
  74. package/dist/connectors/jira/issueBlocks.d.ts.map +1 -1
  75. package/dist/connectors/jira/issueBlocks.js +38 -2
  76. package/dist/connectors/jira/issueBlocks.js.map +1 -1
  77. package/dist/connectors/jira/operatorIssue.d.ts +28 -0
  78. package/dist/connectors/jira/operatorIssue.d.ts.map +1 -0
  79. package/dist/connectors/jira/operatorIssue.js +81 -0
  80. package/dist/connectors/jira/operatorIssue.js.map +1 -0
  81. package/dist/connectors/jira/outbound.d.ts +8 -4
  82. package/dist/connectors/jira/outbound.d.ts.map +1 -1
  83. package/dist/connectors/jira/outbound.js +16 -8
  84. package/dist/connectors/jira/outbound.js.map +1 -1
  85. package/dist/connectors/jira/outgoingFileCheck.d.ts +37 -0
  86. package/dist/connectors/jira/outgoingFileCheck.d.ts.map +1 -0
  87. package/dist/connectors/jira/outgoingFileCheck.js +279 -0
  88. package/dist/connectors/jira/outgoingFileCheck.js.map +1 -0
  89. package/dist/connectors/jira/outgoingFiles.d.ts +81 -0
  90. package/dist/connectors/jira/outgoingFiles.d.ts.map +1 -0
  91. package/dist/connectors/jira/outgoingFiles.js +268 -0
  92. package/dist/connectors/jira/outgoingFiles.js.map +1 -0
  93. package/dist/connectors/jira/progressComments.d.ts +69 -0
  94. package/dist/connectors/jira/progressComments.d.ts.map +1 -0
  95. package/dist/connectors/jira/progressComments.js +136 -0
  96. package/dist/connectors/jira/progressComments.js.map +1 -0
  97. package/dist/connectors/jira/prompt.d.ts +5 -1
  98. package/dist/connectors/jira/prompt.d.ts.map +1 -1
  99. package/dist/connectors/jira/prompt.js +23 -3
  100. package/dist/connectors/jira/prompt.js.map +1 -1
  101. package/dist/connectors/jira/promptSpill.js +1 -1
  102. package/dist/connectors/jira/promptSpill.js.map +1 -1
  103. package/dist/connectors/jira/trigger.d.ts +13 -5
  104. package/dist/connectors/jira/trigger.d.ts.map +1 -1
  105. package/dist/connectors/jira/trigger.js +13 -7
  106. package/dist/connectors/jira/trigger.js.map +1 -1
  107. package/dist/connectors/jira/uploadedFiles.d.ts +48 -0
  108. package/dist/connectors/jira/uploadedFiles.d.ts.map +1 -0
  109. package/dist/connectors/jira/uploadedFiles.js +123 -0
  110. package/dist/connectors/jira/uploadedFiles.js.map +1 -0
  111. package/dist/connectors/telegram/commands/backendSwitch.d.ts +9 -1
  112. package/dist/connectors/telegram/commands/backendSwitch.d.ts.map +1 -1
  113. package/dist/connectors/telegram/commands/backendSwitch.js +17 -8
  114. package/dist/connectors/telegram/commands/backendSwitch.js.map +1 -1
  115. package/dist/connectors/telegram/commands/botSkills.d.ts +2 -0
  116. package/dist/connectors/telegram/commands/botSkills.d.ts.map +1 -1
  117. package/dist/connectors/telegram/commands/botSkills.js +17 -2
  118. package/dist/connectors/telegram/commands/botSkills.js.map +1 -1
  119. package/dist/connectors/telegram/commands/claudeAccounts.d.ts +6 -0
  120. package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -1
  121. package/dist/connectors/telegram/commands/claudeAccounts.js +22 -4
  122. package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
  123. package/dist/connectors/telegram/commands/compaction.d.ts +14 -3
  124. package/dist/connectors/telegram/commands/compaction.d.ts.map +1 -1
  125. package/dist/connectors/telegram/commands/compaction.js +261 -96
  126. package/dist/connectors/telegram/commands/compaction.js.map +1 -1
  127. package/dist/connectors/telegram/commands/limitReminders.d.ts +21 -0
  128. package/dist/connectors/telegram/commands/limitReminders.d.ts.map +1 -0
  129. package/dist/connectors/telegram/commands/limitReminders.js +95 -0
  130. package/dist/connectors/telegram/commands/limitReminders.js.map +1 -0
  131. package/dist/connectors/telegram/commands/limitsBoard.d.ts +4 -0
  132. package/dist/connectors/telegram/commands/limitsBoard.d.ts.map +1 -1
  133. package/dist/connectors/telegram/commands/limitsBoard.js +27 -6
  134. package/dist/connectors/telegram/commands/limitsBoard.js.map +1 -1
  135. package/dist/connectors/telegram/commands/modelProviders.d.ts +2 -2
  136. package/dist/connectors/telegram/commands/modelProviders.d.ts.map +1 -1
  137. package/dist/connectors/telegram/commands/modelProviders.js +27 -16
  138. package/dist/connectors/telegram/commands/modelProviders.js.map +1 -1
  139. package/dist/connectors/telegram/commands/topicCommand.d.ts.map +1 -1
  140. package/dist/connectors/telegram/commands/topicCommand.js +7 -2
  141. package/dist/connectors/telegram/commands/topicCommand.js.map +1 -1
  142. package/dist/connectors/telegram/commands/workerRoles.d.ts +25 -0
  143. package/dist/connectors/telegram/commands/workerRoles.d.ts.map +1 -0
  144. package/dist/connectors/telegram/commands/workerRoles.js +259 -0
  145. package/dist/connectors/telegram/commands/workerRoles.js.map +1 -0
  146. package/dist/connectors/telegram/groupWelcome.d.ts +12 -0
  147. package/dist/connectors/telegram/groupWelcome.d.ts.map +1 -0
  148. package/dist/connectors/telegram/groupWelcome.js +12 -0
  149. package/dist/connectors/telegram/groupWelcome.js.map +1 -0
  150. package/dist/connectors/telegram/inbound.d.ts +7 -0
  151. package/dist/connectors/telegram/inbound.d.ts.map +1 -1
  152. package/dist/connectors/telegram/inbound.js +10 -0
  153. package/dist/connectors/telegram/inbound.js.map +1 -1
  154. package/dist/connectors/telegram/outputFlushPlan.d.ts +12 -0
  155. package/dist/connectors/telegram/outputFlushPlan.d.ts.map +1 -1
  156. package/dist/connectors/telegram/outputFlushPlan.js +12 -0
  157. package/dist/connectors/telegram/outputFlushPlan.js.map +1 -1
  158. package/dist/connectors/telegram/runnerPairingMessages.d.ts +1 -1
  159. package/dist/connectors/telegram/topicIndicator.d.ts +1 -1
  160. package/dist/connectors/telegram/topicIndicator.d.ts.map +1 -1
  161. package/dist/connectors/telegram/topicIndicator.js +103 -5
  162. package/dist/connectors/telegram/topicIndicator.js.map +1 -1
  163. package/dist/effortLevels.d.ts +6 -0
  164. package/dist/effortLevels.d.ts.map +1 -1
  165. package/dist/effortLevels.js +6 -1
  166. package/dist/effortLevels.js.map +1 -1
  167. package/dist/i18n/de.d.ts.map +1 -1
  168. package/dist/i18n/de.js +95 -14
  169. package/dist/i18n/de.js.map +1 -1
  170. package/dist/i18n/en.d.ts.map +1 -1
  171. package/dist/i18n/en.js +95 -14
  172. package/dist/i18n/en.js.map +1 -1
  173. package/dist/i18n/es.d.ts.map +1 -1
  174. package/dist/i18n/es.js +95 -14
  175. package/dist/i18n/es.js.map +1 -1
  176. package/dist/i18n/fr.d.ts.map +1 -1
  177. package/dist/i18n/fr.js +95 -14
  178. package/dist/i18n/fr.js.map +1 -1
  179. package/dist/i18n/hi.d.ts.map +1 -1
  180. package/dist/i18n/hi.js +95 -14
  181. package/dist/i18n/hi.js.map +1 -1
  182. package/dist/i18n/ja.d.ts.map +1 -1
  183. package/dist/i18n/ja.js +95 -14
  184. package/dist/i18n/ja.js.map +1 -1
  185. package/dist/i18n/ka.d.ts.map +1 -1
  186. package/dist/i18n/ka.js +95 -14
  187. package/dist/i18n/ka.js.map +1 -1
  188. package/dist/i18n/pt.d.ts.map +1 -1
  189. package/dist/i18n/pt.js +95 -14
  190. package/dist/i18n/pt.js.map +1 -1
  191. package/dist/i18n/ru.d.ts.map +1 -1
  192. package/dist/i18n/ru.js +95 -14
  193. package/dist/i18n/ru.js.map +1 -1
  194. package/dist/i18n/uk.d.ts.map +1 -1
  195. package/dist/i18n/uk.js +95 -14
  196. package/dist/i18n/uk.js.map +1 -1
  197. package/dist/i18n/uz.d.ts.map +1 -1
  198. package/dist/i18n/uz.js +95 -14
  199. package/dist/i18n/uz.js.map +1 -1
  200. package/dist/i18n/zh.d.ts.map +1 -1
  201. package/dist/i18n/zh.js +95 -14
  202. package/dist/i18n/zh.js.map +1 -1
  203. package/dist/instanceSettings.d.ts +24 -2
  204. package/dist/instanceSettings.d.ts.map +1 -1
  205. package/dist/instanceSettings.js +75 -3
  206. package/dist/instanceSettings.js.map +1 -1
  207. package/dist/limitNotes/engine.d.ts +47 -0
  208. package/dist/limitNotes/engine.d.ts.map +1 -0
  209. package/dist/limitNotes/engine.js +98 -0
  210. package/dist/limitNotes/engine.js.map +1 -0
  211. package/dist/limitNotes/noteText.d.ts +33 -0
  212. package/dist/limitNotes/noteText.d.ts.map +1 -0
  213. package/dist/limitNotes/noteText.js +55 -0
  214. package/dist/limitNotes/noteText.js.map +1 -0
  215. package/dist/limitNotes/plan.d.ts +147 -0
  216. package/dist/limitNotes/plan.d.ts.map +1 -0
  217. package/dist/limitNotes/plan.js +323 -0
  218. package/dist/limitNotes/plan.js.map +1 -0
  219. package/dist/limitNotes/reminderChoices.d.ts +30 -0
  220. package/dist/limitNotes/reminderChoices.d.ts.map +1 -0
  221. package/dist/limitNotes/reminderChoices.js +48 -0
  222. package/dist/limitNotes/reminderChoices.js.map +1 -0
  223. package/dist/limitNotes/service.d.ts +106 -0
  224. package/dist/limitNotes/service.d.ts.map +1 -0
  225. package/dist/limitNotes/service.js +169 -0
  226. package/dist/limitNotes/service.js.map +1 -0
  227. package/dist/openCodeSessionTitle.js +1 -1
  228. package/dist/openCodeSessionTitle.js.map +1 -1
  229. package/dist/outputTrace.d.ts +19 -0
  230. package/dist/outputTrace.d.ts.map +1 -1
  231. package/dist/outputTrace.js +23 -2
  232. package/dist/outputTrace.js.map +1 -1
  233. package/dist/platform/answerSink.d.ts +23 -0
  234. package/dist/platform/answerSink.d.ts.map +1 -1
  235. package/dist/platform/answerSink.js.map +1 -1
  236. package/dist/platform/operatorAlert.d.ts +24 -0
  237. package/dist/platform/operatorAlert.d.ts.map +1 -0
  238. package/dist/platform/operatorAlert.js +9 -0
  239. package/dist/platform/operatorAlert.js.map +1 -0
  240. package/dist/postToSession.d.ts +34 -2
  241. package/dist/postToSession.d.ts.map +1 -1
  242. package/dist/postToSession.js +31 -2
  243. package/dist/postToSession.js.map +1 -1
  244. package/dist/remoteRun/exitCodes.d.ts +2 -2
  245. package/dist/remoteRun/exitCodes.d.ts.map +1 -1
  246. package/dist/remoteRun/exitCodes.js +2 -2
  247. package/dist/remoteRun/exitCodes.js.map +1 -1
  248. package/dist/remoteRun/foreground.d.ts.map +1 -1
  249. package/dist/remoteRun/foreground.js +5 -1
  250. package/dist/remoteRun/foreground.js.map +1 -1
  251. package/dist/remoteRun/runnerClient.d.ts +1 -1
  252. package/dist/remoteRun/runnerClient.d.ts.map +1 -1
  253. package/dist/remoteRun/runnerClient.js +3 -3
  254. package/dist/remoteRun/runnerClient.js.map +1 -1
  255. package/dist/requests/answerRequest.d.ts +3 -0
  256. package/dist/requests/answerRequest.d.ts.map +1 -1
  257. package/dist/requests/answerRequest.js +9 -2
  258. package/dist/requests/answerRequest.js.map +1 -1
  259. package/dist/requests/limitWaitAnswer.d.ts +14 -0
  260. package/dist/requests/limitWaitAnswer.d.ts.map +1 -1
  261. package/dist/requests/limitWaitAnswer.js +26 -4
  262. package/dist/requests/limitWaitAnswer.js.map +1 -1
  263. package/dist/requests/requestHeader.d.ts +37 -5
  264. package/dist/requests/requestHeader.d.ts.map +1 -1
  265. package/dist/requests/requestHeader.js +70 -17
  266. package/dist/requests/requestHeader.js.map +1 -1
  267. package/dist/requests/scheduleWait.d.ts +79 -0
  268. package/dist/requests/scheduleWait.d.ts.map +1 -0
  269. package/dist/requests/scheduleWait.js +101 -0
  270. package/dist/requests/scheduleWait.js.map +1 -0
  271. package/dist/requests/sessionTurnProbe.d.ts +26 -3
  272. package/dist/requests/sessionTurnProbe.d.ts.map +1 -1
  273. package/dist/requests/sessionTurnProbe.js +22 -3
  274. package/dist/requests/sessionTurnProbe.js.map +1 -1
  275. package/dist/requests/topicRequestSettle.d.ts +13 -7
  276. package/dist/requests/topicRequestSettle.d.ts.map +1 -1
  277. package/dist/requests/topicRequestSettle.js +2 -2
  278. package/dist/requests/topicRequestSettle.js.map +1 -1
  279. package/dist/requests/trackerTurnPoster.d.ts +30 -0
  280. package/dist/requests/trackerTurnPoster.d.ts.map +1 -0
  281. package/dist/requests/trackerTurnPoster.js +36 -0
  282. package/dist/requests/trackerTurnPoster.js.map +1 -0
  283. package/dist/requests/types.d.ts +26 -5
  284. package/dist/requests/types.d.ts.map +1 -1
  285. package/dist/requests/wakeUpEngine.d.ts +201 -12
  286. package/dist/requests/wakeUpEngine.d.ts.map +1 -1
  287. package/dist/requests/wakeUpEngine.js +514 -44
  288. package/dist/requests/wakeUpEngine.js.map +1 -1
  289. package/dist/requests/wakeUpRules.d.ts +185 -14
  290. package/dist/requests/wakeUpRules.d.ts.map +1 -1
  291. package/dist/requests/wakeUpRules.js +169 -36
  292. package/dist/requests/wakeUpRules.js.map +1 -1
  293. package/dist/resumeContext.d.ts +2 -2
  294. package/dist/resumeContext.js +3 -3
  295. package/dist/resumeContext.js.map +1 -1
  296. package/dist/runnerUtility/adminService.js +1 -1
  297. package/dist/runnerUtility/adminService.js.map +1 -1
  298. package/dist/runnerUtility/guiAgent.d.ts +1 -1
  299. package/dist/runnerUtility/guiAgent.d.ts.map +1 -1
  300. package/dist/runnerUtility/guiAgent.js +1 -1
  301. package/dist/runnerUtility/guiAgent.js.map +1 -1
  302. package/dist/runnerUtility/managedNode.d.ts +3 -3
  303. package/dist/runnerUtility/managedNode.d.ts.map +1 -1
  304. package/dist/runnerUtility/managedNode.js +2 -2
  305. package/dist/runnerUtility/managedNode.js.map +1 -1
  306. package/dist/runnerUtility/runnerConfig.d.ts +1 -1
  307. package/dist/runnerUtility/runnerHome.d.ts +1 -1
  308. package/dist/runnerUtility/runnerHome.js +1 -1
  309. package/dist/runnerUtility/serviceCommon.d.ts +1 -1
  310. package/dist/runnerUtility/serviceCommon.d.ts.map +1 -1
  311. package/dist/runnerUtility/serviceCommon.js +1 -1
  312. package/dist/runnerUtility/serviceCommon.js.map +1 -1
  313. package/dist/runners/bootstrapLine.js +1 -1
  314. package/dist/runners/hubPackage.d.ts +1 -1
  315. package/dist/runners/hubPackage.js +3 -3
  316. package/dist/runners/hubPackage.js.map +1 -1
  317. package/dist/runners/hubPaths.d.ts +1 -1
  318. package/dist/runners/hubPaths.d.ts.map +1 -1
  319. package/dist/runners/runnerLock.d.ts +2 -2
  320. package/dist/runners/runnerLock.d.ts.map +1 -1
  321. package/dist/runners/runnerLock.js +2 -2
  322. package/dist/runners/runnerLock.js.map +1 -1
  323. package/dist/scheduler/checkRun.d.ts +2 -0
  324. package/dist/scheduler/checkRun.d.ts.map +1 -1
  325. package/dist/scheduler/checkRun.js +5 -1
  326. package/dist/scheduler/checkRun.js.map +1 -1
  327. package/dist/scheduler/delivery.d.ts +57 -0
  328. package/dist/scheduler/delivery.d.ts.map +1 -1
  329. package/dist/scheduler/delivery.js +152 -14
  330. package/dist/scheduler/delivery.js.map +1 -1
  331. package/dist/scheduler/injection.d.ts +6 -0
  332. package/dist/scheduler/injection.d.ts.map +1 -1
  333. package/dist/scheduler/injection.js +10 -0
  334. package/dist/scheduler/injection.js.map +1 -1
  335. package/dist/scheduler/mcpSurface.d.ts +68 -4
  336. package/dist/scheduler/mcpSurface.d.ts.map +1 -1
  337. package/dist/scheduler/mcpSurface.js +363 -189
  338. package/dist/scheduler/mcpSurface.js.map +1 -1
  339. package/dist/scheduler/rebindResume.d.ts +24 -0
  340. package/dist/scheduler/rebindResume.d.ts.map +1 -1
  341. package/dist/scheduler/rebindResume.js +32 -0
  342. package/dist/scheduler/rebindResume.js.map +1 -1
  343. package/dist/scheduler/scheduleToolWording.d.ts +29 -0
  344. package/dist/scheduler/scheduleToolWording.d.ts.map +1 -0
  345. package/dist/scheduler/scheduleToolWording.js +117 -0
  346. package/dist/scheduler/scheduleToolWording.js.map +1 -0
  347. package/dist/scheduler/scheduledRunTarget.d.ts +90 -0
  348. package/dist/scheduler/scheduledRunTarget.d.ts.map +1 -0
  349. package/dist/scheduler/scheduledRunTarget.js +92 -0
  350. package/dist/scheduler/scheduledRunTarget.js.map +1 -0
  351. package/dist/scheduler/store.d.ts +2 -0
  352. package/dist/scheduler/store.d.ts.map +1 -1
  353. package/dist/scheduler/store.js +2 -0
  354. package/dist/scheduler/store.js.map +1 -1
  355. package/dist/scheduler/types.d.ts +10 -0
  356. package/dist/scheduler/types.d.ts.map +1 -1
  357. package/dist/scheduler/workerWatch.d.ts +2 -0
  358. package/dist/scheduler/workerWatch.d.ts.map +1 -1
  359. package/dist/scheduler/workerWatch.js +3 -3
  360. package/dist/scheduler/workerWatch.js.map +1 -1
  361. package/dist/selfUpdate/constants.d.ts +2 -0
  362. package/dist/selfUpdate/constants.d.ts.map +1 -1
  363. package/dist/selfUpdate/constants.js +3 -1
  364. package/dist/selfUpdate/constants.js.map +1 -1
  365. package/dist/selfUpdate/emittedSource.d.ts.map +1 -1
  366. package/dist/selfUpdate/emittedSource.js +1 -1
  367. package/dist/selfUpdate/emittedSource.js.map +1 -1
  368. package/dist/selfUpdate/updateRuntime.js +1 -1
  369. package/dist/selfUpdate/updateRuntime.js.map +1 -1
  370. package/dist/sessionPick.d.ts +1 -1
  371. package/dist/sessionPick.js +1 -1
  372. package/dist/shutdown.d.ts +12 -0
  373. package/dist/shutdown.d.ts.map +1 -1
  374. package/dist/shutdown.js +11 -0
  375. package/dist/shutdown.js.map +1 -1
  376. package/dist/startupPromptBuffer.d.ts +35 -6
  377. package/dist/startupPromptBuffer.d.ts.map +1 -1
  378. package/dist/startupPromptBuffer.js +70 -21
  379. package/dist/startupPromptBuffer.js.map +1 -1
  380. package/dist/state.d.ts +173 -25
  381. package/dist/state.d.ts.map +1 -1
  382. package/dist/state.js +282 -58
  383. package/dist/state.js.map +1 -1
  384. package/dist/testTimings.d.ts +8 -3
  385. package/dist/testTimings.d.ts.map +1 -1
  386. package/dist/testTimings.js +15 -2
  387. package/dist/testTimings.js.map +1 -1
  388. package/dist/threadContextPreamble.d.ts +7 -0
  389. package/dist/threadContextPreamble.d.ts.map +1 -1
  390. package/dist/threadContextPreamble.js +11 -0
  391. package/dist/threadContextPreamble.js.map +1 -1
  392. package/dist/threadRouting.d.ts +12 -0
  393. package/dist/threadRouting.d.ts.map +1 -1
  394. package/dist/threadRouting.js +15 -0
  395. package/dist/threadRouting.js.map +1 -1
  396. package/dist/todos/midTurn.d.ts +15 -41
  397. package/dist/todos/midTurn.d.ts.map +1 -1
  398. package/dist/todos/midTurn.js +27 -171
  399. package/dist/todos/midTurn.js.map +1 -1
  400. package/dist/types.d.ts +147 -23
  401. package/dist/types.d.ts.map +1 -1
  402. package/dist/types.js +10 -0
  403. package/dist/types.js.map +1 -1
  404. package/dist/utils/backendSwitchPlan.d.ts +3 -3
  405. package/dist/utils/backendSwitchPlan.js +3 -3
  406. package/dist/utils/claudeAccountAlert.d.ts +104 -0
  407. package/dist/utils/claudeAccountAlert.d.ts.map +1 -0
  408. package/dist/utils/claudeAccountAlert.js +130 -0
  409. package/dist/utils/claudeAccountAlert.js.map +1 -0
  410. package/dist/utils/claudeAccountPickerPlan.d.ts +7 -0
  411. package/dist/utils/claudeAccountPickerPlan.d.ts.map +1 -1
  412. package/dist/utils/claudeAccountPickerPlan.js +13 -2
  413. package/dist/utils/claudeAccountPickerPlan.js.map +1 -1
  414. package/dist/utils/claudeAuthRefusal.d.ts +122 -0
  415. package/dist/utils/claudeAuthRefusal.d.ts.map +1 -0
  416. package/dist/utils/claudeAuthRefusal.js +228 -0
  417. package/dist/utils/claudeAuthRefusal.js.map +1 -0
  418. package/dist/utils/claudeCompactHook.d.ts +6 -6
  419. package/dist/utils/claudeCompactHook.js +8 -8
  420. package/dist/utils/claudeCompactHook.js.map +1 -1
  421. package/dist/utils/claudeProfileUsageViews.d.ts +54 -2
  422. package/dist/utils/claudeProfileUsageViews.d.ts.map +1 -1
  423. package/dist/utils/claudeProfileUsageViews.js +44 -1
  424. package/dist/utils/claudeProfileUsageViews.js.map +1 -1
  425. package/dist/utils/claudeProfiles.d.ts.map +1 -1
  426. package/dist/utils/claudeProfiles.js +10 -1
  427. package/dist/utils/claudeProfiles.js.map +1 -1
  428. package/dist/utils/claudeRuntimeInfo.d.ts +24 -0
  429. package/dist/utils/claudeRuntimeInfo.d.ts.map +1 -1
  430. package/dist/utils/claudeRuntimeInfo.js +128 -3
  431. package/dist/utils/claudeRuntimeInfo.js.map +1 -1
  432. package/dist/utils/claudeScheduledJobs.d.ts +6 -2
  433. package/dist/utils/claudeScheduledJobs.d.ts.map +1 -1
  434. package/dist/utils/claudeScheduledJobs.js +10 -2
  435. package/dist/utils/claudeScheduledJobs.js.map +1 -1
  436. package/dist/utils/claudeSessionTitle.js +1 -1
  437. package/dist/utils/claudeSessionTitle.js.map +1 -1
  438. package/dist/utils/claudeStreamJson.d.ts +28 -2
  439. package/dist/utils/claudeStreamJson.d.ts.map +1 -1
  440. package/dist/utils/claudeStreamJson.js +33 -3
  441. package/dist/utils/claudeStreamJson.js.map +1 -1
  442. package/dist/utils/claudeTranscriptEpoch.d.ts +14 -0
  443. package/dist/utils/claudeTranscriptEpoch.d.ts.map +1 -1
  444. package/dist/utils/claudeTranscriptEpoch.js +79 -19
  445. package/dist/utils/claudeTranscriptEpoch.js.map +1 -1
  446. package/dist/utils/claudeUsage.d.ts +103 -7
  447. package/dist/utils/claudeUsage.d.ts.map +1 -1
  448. package/dist/utils/claudeUsage.js +108 -15
  449. package/dist/utils/claudeUsage.js.map +1 -1
  450. package/dist/utils/compactOnIdle.d.ts +139 -29
  451. package/dist/utils/compactOnIdle.d.ts.map +1 -1
  452. package/dist/utils/compactOnIdle.js +163 -36
  453. package/dist/utils/compactOnIdle.js.map +1 -1
  454. package/dist/utils/conversationEnding.d.ts +76 -0
  455. package/dist/utils/conversationEnding.d.ts.map +1 -0
  456. package/dist/utils/conversationEnding.js +117 -0
  457. package/dist/utils/conversationEnding.js.map +1 -0
  458. package/dist/utils/doctorLine.d.ts +10 -0
  459. package/dist/utils/doctorLine.d.ts.map +1 -1
  460. package/dist/utils/doctorLine.js +16 -0
  461. package/dist/utils/doctorLine.js.map +1 -1
  462. package/dist/utils/fallbackBridge.d.ts.map +1 -1
  463. package/dist/utils/fallbackBridge.js +2 -1
  464. package/dist/utils/fallbackBridge.js.map +1 -1
  465. package/dist/utils/fallbackChain.d.ts +2 -0
  466. package/dist/utils/fallbackChain.d.ts.map +1 -1
  467. package/dist/utils/fallbackChain.js +4 -3
  468. package/dist/utils/fallbackChain.js.map +1 -1
  469. package/dist/utils/fallbackSwitchNotice.d.ts +11 -4
  470. package/dist/utils/fallbackSwitchNotice.d.ts.map +1 -1
  471. package/dist/utils/fallbackSwitchNotice.js +9 -5
  472. package/dist/utils/fallbackSwitchNotice.js.map +1 -1
  473. package/dist/utils/fileSendService.d.ts +31 -0
  474. package/dist/utils/fileSendService.d.ts.map +1 -1
  475. package/dist/utils/fileSendService.js +45 -2
  476. package/dist/utils/fileSendService.js.map +1 -1
  477. package/dist/utils/jsonStreamHost.d.ts +2 -0
  478. package/dist/utils/jsonStreamHost.d.ts.map +1 -1
  479. package/dist/utils/jsonStreamHost.js +4 -1
  480. package/dist/utils/jsonStreamHost.js.map +1 -1
  481. package/dist/utils/jsonStreamPendingWork.d.ts +14 -2
  482. package/dist/utils/jsonStreamPendingWork.d.ts.map +1 -1
  483. package/dist/utils/jsonStreamPendingWork.js +25 -5
  484. package/dist/utils/jsonStreamPendingWork.js.map +1 -1
  485. package/dist/utils/jsonStreamUnconsumedInput.d.ts +80 -0
  486. package/dist/utils/jsonStreamUnconsumedInput.d.ts.map +1 -0
  487. package/dist/utils/jsonStreamUnconsumedInput.js +99 -0
  488. package/dist/utils/jsonStreamUnconsumedInput.js.map +1 -0
  489. package/dist/utils/limitEpisodeRecovery.d.ts +43 -4
  490. package/dist/utils/limitEpisodeRecovery.d.ts.map +1 -1
  491. package/dist/utils/limitEpisodeRecovery.js +107 -20
  492. package/dist/utils/limitEpisodeRecovery.js.map +1 -1
  493. package/dist/utils/limitHeldPrompts.d.ts +21 -11
  494. package/dist/utils/limitHeldPrompts.d.ts.map +1 -1
  495. package/dist/utils/limitHeldPrompts.js +12 -9
  496. package/dist/utils/limitHeldPrompts.js.map +1 -1
  497. package/dist/utils/limitRemindersScreenPlan.d.ts +63 -0
  498. package/dist/utils/limitRemindersScreenPlan.d.ts.map +1 -0
  499. package/dist/utils/limitRemindersScreenPlan.js +121 -0
  500. package/dist/utils/limitRemindersScreenPlan.js.map +1 -0
  501. package/dist/utils/limitSwitchPlan.d.ts +51 -14
  502. package/dist/utils/limitSwitchPlan.d.ts.map +1 -1
  503. package/dist/utils/limitSwitchPlan.js +33 -15
  504. package/dist/utils/limitSwitchPlan.js.map +1 -1
  505. package/dist/utils/limitsBoardPlan.d.ts +16 -7
  506. package/dist/utils/limitsBoardPlan.d.ts.map +1 -1
  507. package/dist/utils/limitsBoardPlan.js +41 -9
  508. package/dist/utils/limitsBoardPlan.js.map +1 -1
  509. package/dist/utils/lostWork.d.ts +16 -2
  510. package/dist/utils/lostWork.d.ts.map +1 -1
  511. package/dist/utils/lostWork.js +16 -3
  512. package/dist/utils/lostWork.js.map +1 -1
  513. package/dist/utils/messageContext.d.ts +2 -2
  514. package/dist/utils/messageContext.js +2 -2
  515. package/dist/utils/midTurnInbox.d.ts +79 -0
  516. package/dist/utils/midTurnInbox.d.ts.map +1 -0
  517. package/dist/utils/midTurnInbox.js +265 -0
  518. package/dist/utils/midTurnInbox.js.map +1 -0
  519. package/dist/utils/promptDelivery.d.ts +70 -22
  520. package/dist/utils/promptDelivery.d.ts.map +1 -1
  521. package/dist/utils/promptDelivery.js +100 -42
  522. package/dist/utils/promptDelivery.js.map +1 -1
  523. package/dist/utils/topicIndicatorPlan.d.ts +13 -3
  524. package/dist/utils/topicIndicatorPlan.d.ts.map +1 -1
  525. package/dist/utils/topicIndicatorPlan.js +26 -4
  526. package/dist/utils/topicIndicatorPlan.js.map +1 -1
  527. package/dist/utils/topicRequest.d.ts +3 -0
  528. package/dist/utils/topicRequest.d.ts.map +1 -1
  529. package/dist/utils/topicRequest.js +4 -0
  530. package/dist/utils/topicRequest.js.map +1 -1
  531. package/dist/utils/workerRoles.d.ts +122 -0
  532. package/dist/utils/workerRoles.d.ts.map +1 -0
  533. package/dist/utils/workerRoles.js +160 -0
  534. package/dist/utils/workerRoles.js.map +1 -0
  535. package/dist/utils/workerRolesScreenPlan.d.ts +118 -0
  536. package/dist/utils/workerRolesScreenPlan.d.ts.map +1 -0
  537. package/dist/utils/workerRolesScreenPlan.js +232 -0
  538. package/dist/utils/workerRolesScreenPlan.js.map +1 -0
  539. package/dist/utils/workingSignals.d.ts +59 -0
  540. package/dist/utils/workingSignals.d.ts.map +1 -0
  541. package/dist/utils/workingSignals.js +60 -0
  542. package/dist/utils/workingSignals.js.map +1 -0
  543. package/licensing.json +88 -0
  544. package/npm-shrinkwrap.json +2 -2
  545. package/package.json +7 -7
  546. package/{remoteRun → runner-scripts}/runner.sh +6 -3
  547. package/LICENSE-COMMERCIAL.md +0 -142
  548. package/dist/agentTrigger.d.ts +0 -28
  549. package/dist/agentTrigger.d.ts.map +0 -1
  550. package/dist/agentTrigger.js +0 -53
  551. package/dist/agentTrigger.js.map +0 -1
  552. /package/{remoteRun → runner-scripts}/ensureNode.sh +0 -0
  553. /package/{remoteRun → runner-scripts}/runner-package-lock.json +0 -0
@@ -6,24 +6,30 @@ import type { LatePromptOutcome } from '../utils/promptDelivery';
6
6
  * restart's replay and the person was told) closes the request it opened, so the engine never prods the agent for a turn that
7
7
  * never started. A module of its own, over ports, so both outcomes are tested for real; `bot.ts` wires the engine and the ledger.
8
8
  */
9
- /** The part of a request's opening the settle needs: its id, `null` when no request was opened (a slash command, requests off). */
9
+ /**
10
+ * The part of a request's opening the settle needs: its id, `null` when no request was opened (a slash command, requests off).
11
+ * `isScheduledRun` — a scheduler fire opened it (the scheduler's request): its turn is that fire's scheduled run, said by the forward
12
+ * that started it — the wake-up rules never read a turn's kind from the request (`src/requests/README.md` § Scheduled runs).
13
+ */
10
14
  export interface TopicRequestRef {
11
15
  requestId: string | null;
16
+ isScheduledRun?: boolean;
12
17
  }
13
18
  export interface TopicRequestSettlePorts {
14
- /** The wake-up engine starts watching the turn the request's prompt began (`trackForwardedTurn`, as a request prompt). */
15
- trackTurn: (key: SessionKey, requestId: string) => Promise<void>;
19
+ /** The wake-up engine starts watching the turn the request's prompt began (`trackForwardedTurn`, as a request prompt — a scheduled run's too with `isScheduledRun`). */
20
+ trackTurn: (key: SessionKey, requestId: string, options: {
21
+ isScheduledRun: boolean;
22
+ }) => Promise<void>;
16
23
  /** The ledger closes the request as cancelled (`closeRequest(id, 'cancelled')`). */
17
24
  cancelRequest: (requestId: string) => Promise<void>;
18
25
  warn: (message: string) => void;
19
26
  }
20
27
  export interface TopicRequestSettler {
21
28
  /**
22
- * The request's prompt was handed to the prompt path (forwarded, or buffered behind a session start — the turn probe holds a
23
- * starting session, so tracking now is right either way). Fire and forget: a failed track is logged, never thrown.
29
+ * The prompt came back from the prompt path with `delivery`: track its turn, or close the request when no session took it. A prompt
30
+ * forwarded, or buffered behind a session start (the turn probe holds a starting session, so tracking now is right either way), has its
31
+ * turn tracked fire and forget: a failed track is logged, never thrown.
24
32
  */
25
- trackTurn: (key: SessionKey, opening: TopicRequestRef) => void;
26
- /** The prompt came back from the prompt path with `delivery`: track its turn, or close the request when no session took it. */
27
33
  settleAfterDelivery: (key: SessionKey, opening: TopicRequestRef, delivery: LatePromptOutcome) => Promise<void>;
28
34
  }
29
35
  export declare function createTopicRequestSettler(ports: TopicRequestSettlePorts): TopicRequestSettler;
@@ -1 +1 @@
1
- {"version":3,"file":"topicRequestSettle.d.ts","sourceRoot":"","sources":["../../src/requests/topicRequestSettle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE;;;;;GAKG;AAEH,mIAAmI;AACnI,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC,0HAA0H;IAC1H,SAAS,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,oFAAoF;IACpF,aAAa,EAAE,CAAC,SA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,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChH;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,uBAAuB,GAAG,mBAAmB,CAsB7F"}
@@ -6,7 +6,7 @@ function createTopicRequestSettler(ports) {
6
6
  const { requestId } = opening;
7
7
  if (requestId === null)
8
8
  return;
9
- ports.trackTurn(key, requestId).catch((error) => ports.warn(`[requests] tracking the turn of ${requestId} failed: ${error instanceof Error ? error.message : error}`));
9
+ ports.trackTurn(key, requestId, { isScheduledRun: opening.isScheduledRun === true }).catch((error) => ports.warn(`[requests] tracking the turn of ${requestId} failed: ${error instanceof Error ? error.message : error}`));
10
10
  };
11
11
  const settleAfterDelivery = async (key, opening, delivery) => {
12
12
  if (delivery !== 'noSession') {
@@ -18,6 +18,6 @@ function createTopicRequestSettler(ports) {
18
18
  return;
19
19
  await ports.cancelRequest(requestId).catch((error) => ports.warn(`[requests] closing the request ${requestId} of a prompt that found no session failed: ${error instanceof Error ? error.message : error}`));
20
20
  };
21
- return { trackTurn, settleAfterDelivery };
21
+ return { settleAfterDelivery };
22
22
  }
23
23
  //# sourceMappingURL=topicRequestSettle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"topicRequestSettle.js","sourceRoot":"","sources":["../../src/requests/topicRequestSettle.ts"],"names":[],"mappings":";;AAiCA,8DAsBC;AAtBD,SAAgB,yBAAyB,CAAC,KAA8B;IACtE,MAAM,SAAS,GAAG,CAAC,GAAe,EAAE,OAAwB,EAAQ,EAAE;QACpE,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;QAC9B,IAAI,SAAS,KAAK,IAAI;YAAE,OAAO;QAC/B,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAC9C,KAAK,CAAC,IAAI,CAAC,mCAAmC,SAAS,YA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,SAAS,YAAY,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CACrH,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,mBAAmB,GAAG,KAAK,EAAE,GAAe,EAAE,OAAwB,EAAE,QAA2B,EAAiB,EAAE;QAC1H,IAAI,QAAQ,KAAK,WAAW,EAAE,CAAC;YAC7B,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YACxB,OAAO;QACT,CAAC;QACD,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;QAC9B,IAAI,SAAS,KAAK,IAAI;YAAE,OAAO;QAC/B,MAAM,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CACnD,KAAK,CAAC,IAAI,CAAC,kCAAkC,SAAS,8CAA8C,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CACtJ,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { SessionKey } from '../sessionKey';
2
+ import type { PostToSessionOptions, PostToSessionResult, SessionPromptText } from '../postToSession';
3
+ import type { RequestWakeUpEngine } from './wakeUpEngine';
4
+ /**
5
+ * @description What a tracker conversation's request prompt and issue update do once handed to the session post: the post itself,
6
+ * then the wake-up engine's part — watch the turn the prompt started, hand a failed post to the retries (R28), or, for a requester's
7
+ * comment HELD over a usage-limit wait, record that the request owes an answer from now on (`notePersonInputHeld`: no turn starts
8
+ * for it until the wait ends, and the turn that carries it then must be read against what the request owes). The turn is watched
9
+ * INSIDE the post, right after the write (`afterForward`): a reminder the post delivers after it then joins a turn this request
10
+ * started, so a job the agent arms in it is armed under this request (`requests/README.md` § Turn starts). A module of its own,
11
+ * over ports, so every branch is tested for real; `bot.ts` wires the shared session post and the engine.
12
+ */
13
+ /** The wake-up engine's part in posting a tracker turn. */
14
+ export type TrackerTurnEngine = Pick<RequestWakeUpEngine, 'trackForwardedTurn' | 'notePostFailed' | 'notePersonInputHeld'>;
15
+ export interface TrackerTurnPosterPorts {
16
+ /** The shared session post (`postToSession`) of this conversation's adapter; `afterForward` watches the turn the write started. */
17
+ post: (key: SessionKey, prompt: SessionPromptText, options: Pick<PostToSessionOptions, 'afterForward'>) => Promise<PostToSessionResult>;
18
+ /** A person's message restarts the idle countdown like a topic's message does (and lifts the todo reminder's silence). */
19
+ notePersonActivity: (key: SessionKey) => void;
20
+ /** The wake-up engine, read at call time: it is built after the connector's deps. */
21
+ getEngine: () => TrackerTurnEngine | null;
22
+ }
23
+ export interface TrackerTurnPoster {
24
+ /** Post a request's prompt; a failure is handed to the engine's post retries and thrown back to the connector. */
25
+ postRequest: (key: SessionKey, requestId: string, prompt: SessionPromptText) => Promise<void>;
26
+ /** Post an issue update for the request `getTargetRequestId` names (read once the update is written); opens no request. */
27
+ postUpdate: (key: SessionKey, prompt: SessionPromptText, getTargetRequestId: () => string) => Promise<void>;
28
+ }
29
+ export declare function createTrackerTurnPoster(ports: TrackerTurnPosterPorts): TrackerTurnPoster;
30
+ //# sourceMappingURL=trackerTurnPoster.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackerTurnPoster.d.ts","sourceRoot":"","sources":["../../src/requests/trackerTurnPoster.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;;;;;;;GAQG;AAEH,2DAA2D;AAC3D,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,mBAAmB,EAAE,oBAAoB,GAAG,gBAAgB,GAAG,qBAAqB,CAAC,CAAC;AAE3H,MAAM,WAAW,sBAAsB;IACrC,mIAAmI;IACnI,IAAI,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,cAAc,CAAC,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACxI,0HAA0H;IAC1H,kBAAkB,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,IAAI,CAAC;IAC9C,qFAAqF;IACrF,SAAS,EAAE,MAAM,iBAAiB,GAAG,IAAI,CAAC;CAC3C;AAED,MAAM,WAAW,iBAAiB;IAChC,kHAAkH;IAClH,WAAW,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9F,2HAA2H;IAC3H,UAAU,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7G;AAMD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,sBAAsB,GAAG,iBAAiB,CA0BxF"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTrackerTurnPoster = createTrackerTurnPoster;
4
+ function getPostFailureMessage(posted) {
5
+ return posted.reason === 'forward-failed' ? posted.error : `session ${posted.reason}`;
6
+ }
7
+ function createTrackerTurnPoster(ports) {
8
+ return {
9
+ postRequest: async (key, requestId, prompt) => {
10
+ ports.notePersonActivity(key);
11
+ // A held request is tracked when the wait's resume, or else its next wake-up, posts its prompt (R21): it has no answer yet,
12
+ // so it owes one the whole time.
13
+ const posted = await ports.post(key, prompt, {
14
+ afterForward: async () => { await ports.getEngine()?.trackForwardedTurn(key, requestId, { isRequestPrompt: true }); },
15
+ });
16
+ if (!posted.ok) {
17
+ // R28: retried at about 1, 5 and 15 min, outside the wake-up cap.
18
+ await ports.getEngine()?.notePostFailed(key, requestId);
19
+ throw new Error(getPostFailureMessage(posted));
20
+ }
21
+ },
22
+ postUpdate: async (key, prompt, getTargetRequestId) => {
23
+ ports.notePersonActivity(key);
24
+ // A requester's comment carries a person's words: forwarded, the turn it starts owes them an answer; held, they are owed already.
25
+ const posted = await ports.post(key, prompt, {
26
+ afterForward: async () => { await ports.getEngine()?.trackForwardedTurn(key, getTargetRequestId(), { isRequestPrompt: false, isPersonInput: true }); },
27
+ });
28
+ // A failure goes back to the connector, which decides the comment again.
29
+ if (!posted.ok)
30
+ throw new Error(getPostFailureMessage(posted));
31
+ if (posted.isHeld)
32
+ await ports.getEngine()?.notePersonInputHeld(key, getTargetRequestId());
33
+ },
34
+ };
35
+ }
36
+ //# sourceMappingURL=trackerTurnPoster.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackerTurnPoster.js","sourceRoot":"","sources":["../../src/requests/trackerTurnPoster.ts"],"names":[],"mappings":";;AAqCA,0DA0BC;AA9BD,SAAS,qBAAqB,CAAC,MAAmD;IAChF,OAAO,MAAM,CAAC,MAAM,KAAK,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,MAAM,EAAE,CAAC;AACxF,CAAC;AAED,SAAgB,uBAAuB,CAAC,KAA6B;IACnE,OAAO;QACL,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE;YAC5C,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;YAC9B,4HAA4H;YAC5H,iCAAiC;YACjC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE;gBAC3C,YAAY,EAAE,KAAK,IAAI,EAAE,GAAG,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,kBAAkB,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;aACtH,CAAC,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;gBACf,kEAAkE;gBAClE,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,cAAc,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;gBACxD,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;QACD,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,kBAAkB,EAAE,EAAE;YACpD,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;YAC9B,kIAAkI;YAClI,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE;gBAC3C,YAAY,EAAE,KAAK,IAAI,EAAE,GAAG,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,kBAAkB,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;aACvJ,CAAC,CAAC;YACH,yEAAyE;YACzE,IAAI,CAAC,MAAM,CAAC,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC;YAC/D,IAAI,MAAM,CAAC,MAAM;gBAAE,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,mBAAmB,CAAC,GAAG,EAAE,kBAAkB,EAAE,CAAC,CAAC;QAC7F,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -60,8 +60,16 @@ export interface OpenRequestState {
60
60
  progressAnswerCount: number;
61
61
  /** Consecutive turns that ended without any answer. */
62
62
  silentTurnCount: number;
63
- /** Wake-ups delivered for this request (the loop-guard cap counts these). */
63
+ /** Wake-ups delivered since the agent last answered one with a progress note (the loop-guard cap counts these). */
64
64
  wakeCount: number;
65
+ /**
66
+ * A tracker's rules only (`wakeUpRules.ts` `WakeUpRuleSet`): the turn ends in a row that left the request open with nothing armed to
67
+ * wake the agent — a progress note with no job armed under it, or a silent turn. The first gets the nudge (`nothingArmed`), the second
68
+ * gives the request up. A delivered answer does not reset it (a note changes nothing about what wakes the agent); a turn end the
69
+ * request's schedule holds does, and so do a person's words forwarded for the request, the end of a turn the agent's own work held
70
+ * open once that work ended by itself, and the end of a limit wait. Absent = 0.
71
+ */
72
+ stalledTurnCount?: number;
65
73
  /** Epoch ms of the next scheduled wake-up, when one is armed. */
66
74
  nextWakeAt?: number;
67
75
  /** Epoch ms the agent was last seen working on it (the backstop counts from here). */
@@ -89,6 +97,13 @@ export interface OpenRequestState {
89
97
  * when a limit wait later ends with a resume. Absent = not stopped.
90
98
  */
91
99
  isLimitStopped?: boolean;
100
+ /**
101
+ * A person's words reached the agent after the request's last answer (an issue update, a re-posted prompt) and nothing was
102
+ * answered yet. Persisted, because the engine's watches are in memory: a request that waits for its schedule is held between
103
+ * turns only while it owes nobody an answer (`checkIsAnswerOwed`), so a turn whose watch was lost (a restart, a dead process)
104
+ * still reaches the backstop. Cleared when an answer is delivered. Absent = none owed beyond the ones the other fields show.
105
+ */
106
+ isPersonInputUnanswered?: boolean;
92
107
  /**
93
108
  * Which limit wait the bot already answered this request about (see
94
109
  * `getUsageLimitWaitIdentity`), so each request hears about each wait once.
@@ -114,7 +129,7 @@ export interface OpenRequestState {
114
129
  * @description The fields of an open request the answer handling and the
115
130
  * wake-up engine may change.
116
131
  */
117
- export type OpenRequestUpdate = Partial<Pick<OpenRequestState, 'progressAnswerCount' | 'silentTurnCount' | 'wakeCount' | 'nextWakeAt' | 'lastTurnActivityAt' | 'isWakeStopped' | 'isLimitStopped' | 'limitWaitAnsweredFor' | 'alertRef' | 'isPromptTakenIn' | 'postRetryCount' | 'nextPostRetryAt'>>;
132
+ export type OpenRequestUpdate = Partial<Pick<OpenRequestState, 'progressAnswerCount' | 'silentTurnCount' | 'wakeCount' | 'stalledTurnCount' | 'nextWakeAt' | 'lastTurnActivityAt' | 'isWakeStopped' | 'isLimitStopped' | 'isPersonInputUnanswered' | 'limitWaitAnsweredFor' | 'alertRef' | 'isPromptTakenIn' | 'postRetryCount' | 'nextPostRetryAt'>>;
118
133
  /**
119
134
  * @name ClosedRequestRecord
120
135
  * @description One line of the request history (`DATA_DIR/requests.jsonl`): the
@@ -156,7 +171,12 @@ export type RequestAnswerKind = 'progress' | 'question' | 'final';
156
171
  * @name RequestWakeUpReason
157
172
  * @description Why the agent is reminded of an open request.
158
173
  * - `silentTurn` — its turn ended without any answer.
159
- * - `progressFollowUp` — it sent a progress note and the follow-up delay passed.
174
+ * - `progressFollowUp` — it sent a progress note and the follow-up delay passed (a topic's rules).
175
+ * - `nothingArmed` — a tracker's rules: its turn ended with a progress note while nothing is set to wake it (no job under the
176
+ * request, or only a watch that fired; none of its own background work running): the one nudge, sent at once, in place of a
177
+ * follow-up on a clock.
178
+ * - `ownWorkHoldLapsed` — a tracker's rules: the agent's own background work held the request for the whole bound (6 h) since
179
+ * its last prompt or reminder, and still runs: a stall (its notes do not extend the bound).
160
180
  * - `backstop` — nothing was seen working on it for the backstop window (a dead
161
181
  * process, or tracking lost across a restart).
162
182
  * - `postRetry` — the request's prompt could not be posted; tried again soon
@@ -165,11 +185,12 @@ export type RequestAnswerKind = 'progress' | 'question' | 'final';
165
185
  * back without it, or it died with its own work pending) while the request was
166
186
  * open: woken at once instead of at the backstop.
167
187
  */
168
- export type RequestWakeUpReason = 'silentTurn' | 'progressFollowUp' | 'backstop' | 'postRetry' | 'restarted';
188
+ export type RequestWakeUpReason = 'silentTurn' | 'progressFollowUp' | 'nothingArmed' | 'ownWorkHoldLapsed' | 'backstop' | 'postRetry' | 'restarted';
169
189
  /**
170
190
  * @name RequestAlertReason
171
191
  * @description Why the wake-up rules gave up and a person is told.
172
- * - `silentTurns` — the agent ended turns without answering twice in a row.
192
+ * - `silentTurns` — the agent ended turns without answering twice in a row (a tracker's rules: or left the request open with
193
+ * nothing armed to wake it twice in a row, the nudge between them, progress notes or not).
173
194
  * - `wakeCap` — the request used up its wake-ups (the loop guard).
174
195
  * - `wakeFailed` — the session could not be reached to deliver a reminder.
175
196
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/requests/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,cAAc,GAAG,cAAc,GAAG,gBAAgB,CAAC;AAE/F;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,iBAAiB,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,UAAU,GAAG,YAAY,GAAG,WAAW,CAAC;AAEnF;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,SAAS,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,aAAa,CAAC;IACtB,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,mBAAmB,EAAE,MAAM,CAAC;IAC5B,uDAAuD;IACvD,eAAe,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sFAAsF;IACtF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iFAAiF;IACjF,aAAa,EAAE,OAAO,CAAC;IACvB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8EAA8E;IA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,eAAe,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG,kBAAkB,GAAG,cAAc,GAAG,mBAAmB,GAAG,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC;AAEpJ;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,SAAS,GAAG,YAAY,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
@@ -1,8 +1,9 @@
1
1
  import { type SessionKey } from '../sessionKey';
2
2
  import type { RequestLedger } from './requestLedger';
3
+ import { type RequestScheduleWait } from './scheduleWait';
3
4
  import type { OpenRequestState, RequestAlertReason, RequestAnswerKind } from './types';
4
5
  import { type WakeUpMessage } from './requestHeader';
5
- import { type SessionTurnProbe } from './wakeUpRules';
6
+ import { type SessionTurnProbe, type WakeUpRuleSet } from './wakeUpRules';
6
7
  /**
7
8
  * @description The wake-up engine of the request/answer core (S4): it watches
8
9
  * the turn each request (or reminder) started until that turn ends — one watch
@@ -21,6 +22,12 @@ import { type SessionTurnProbe } from './wakeUpRules';
21
22
  *
22
23
  * A wake-up is a reminder forwarded into the SAME session — never a request.
23
24
  * The answer tails are in memory as well: a restart forgets them.
25
+ *
26
+ * A request waits for its schedule while a job armed under it counts (`scheduleWait.ts`, read through the optional
27
+ * `getScheduleWait` port at every decision): the rules then neither prod it nor wake it at a restart, and a turn a scheduler
28
+ * fire started (`isScheduledRun`) that ends without an answer is not silence. A request that owes a person an answer
29
+ * (`checkIsAnswerOwed`) is never held: it is read from the persisted request, so a turn whose watch a restart lost still reaches the
30
+ * backstop. The complete table is `README.md` § Wake-ups.
24
31
  */
25
32
  /** How often a watched turn is polled for its end. */
26
33
  export declare const watchedTurnPollMs = 10000;
@@ -47,6 +54,12 @@ export declare const restartWakeStaggerMs = 30000;
47
54
  export interface RequestWakeUpEngineDeps {
48
55
  ledger: Pick<RequestLedger, 'getOpenRequestById' | 'listOpenRequestsOf' | 'listOpenRequests' | 'updateOpenRequest' | 'closeRequest' | 'recordAlert'>;
49
56
  probeTurn: (key: SessionKey) => SessionTurnProbe;
57
+ /**
58
+ * Bring what the bot knows of the conversation's live process up to what it wrote so far, right before
59
+ * {@link RequestWakeUpEngine.readPromptsReachedOrHeld} probes it: the json-stream tail is polled with a backoff, so an echo the
60
+ * process already wrote may not be read yet (review 28, own pass). Absent: the probe is current.
61
+ */
62
+ refreshProcessState?: (key: SessionKey) => void;
50
63
  prepareWakeUpSession: (key: SessionKey, message: WakeUpMessage) => Promise<boolean>;
51
64
  /** Forward the wake-up's message (the request's prompt again, or a reminder) into the session. */
52
65
  forwardWakeUp: (key: SessionKey, request: OpenRequestState, message: WakeUpMessage) => Promise<void>;
@@ -58,6 +71,8 @@ export interface RequestWakeUpEngineDeps {
58
71
  pollIntervalMs?: number;
59
72
  /** The first retry of a prompt that could not be posted; absent: `postRetryDelaysMs[0]` (a test instance shortens it). */
60
73
  firstPostRetryDelayMs?: number;
74
+ /** How long after a progress note the agent is reminded; absent: {@link progressFollowUpDelayMs} (a test instance shortens it). */
75
+ progressFollowUpMs?: number;
61
76
  /** The gap between two `restarted` wakes, and before the first; absent: {@link restartWakeStaggerMs} (a test instance shortens it). */
62
77
  restartWakeStaggerMs?: number;
63
78
  /** A `restarted` wake reached the conversation's session (the bot keeps the stamp its crash-loop guard reads). */
@@ -66,6 +81,13 @@ export interface RequestWakeUpEngineDeps {
66
81
  checkIsAnswerTailWatched?: (key: SessionKey) => boolean;
67
82
  /** Bring the session up (resume only) and forward the answer-tail reminder; `false` when it could not be reached. */
68
83
  remindAnswerTail?: (key: SessionKey, text: string) => Promise<boolean>;
84
+ /**
85
+ * What the request's armed jobs say about it (`scheduleWait.ts`), read when a decision is made — never cached. Absent: a
86
+ * request never waits for a schedule.
87
+ */
88
+ getScheduleWait?: (key: SessionKey, request: OpenRequestState) => RequestScheduleWait;
89
+ /** The rule set a conversation's turns end under (`WakeUpRuleSet`: a tracker's has no follow-up on a clock). Absent: a topic's for every conversation. */
90
+ getWakeUpRules?: (key: SessionKey) => WakeUpRuleSet;
69
91
  now?: () => number;
70
92
  }
71
93
  export declare class RequestWakeUpEngine {
@@ -73,18 +95,30 @@ export declare class RequestWakeUpEngine {
73
95
  private readonly now;
74
96
  /** The watched turns by REQUEST id (a conversation may hold one per requester). */
75
97
  private readonly watched;
98
+ /**
99
+ * The process the last prompt written into each conversation went to (serialized key → process), stamped at the write choke point
100
+ * ({@link noteWrite}): a watch tracked after that process went down — a re-spawn takes it down right after a post's write, and the
101
+ * post tracks several awaits later — is named from it, never left unnamed (review 22 nit 2).
102
+ */
103
+ private readonly writtenProcesses;
76
104
  /** Last persisted live-turn activity per request id, for the persist step. */
77
105
  private readonly activityPersistedAt;
78
106
  /** The tail after the latest final answer, by serialized conversation key. */
79
107
  private readonly answerTails;
80
108
  /** The request whose tail was last reminded and how often, by serialized conversation key (the reminder cap). */
81
109
  private readonly answerTailReminders;
110
+ /** How many posts are on their way to their write, by serialized conversation key ({@link notePostInFlight}). */
111
+ private readonly postsInFlight;
112
+ /** The wake-up deliveries handed to a post in flight, by serialized conversation key, in the order they were decided. */
113
+ private readonly wakesHandedToPost;
82
114
  private pollTimer;
83
115
  private sweepTimer;
84
116
  private isPolling;
85
117
  private isSweeping;
86
118
  /** The `restarted` wakes waiting for their turn, by serialized conversation key (one per conversation). */
87
119
  private readonly restartWakeTimers;
120
+ /** Conversations whose pending restart wake was asked for by a LOST-WORK loss, not by a boot: no watch holds that one. */
121
+ private readonly lostWorkWakes;
88
122
  /** When the last scheduled `restarted` wake is due: the next one is a stagger after it. */
89
123
  private lastRestartWakeDueAt;
90
124
  constructor(deps: RequestWakeUpEngineDeps);
@@ -101,9 +135,14 @@ export declare class RequestWakeUpEngine {
101
135
  * process that died with its own work pending): wake them `restarted`, a stagger after the last wake scheduled so,
102
136
  * instead of at the backstop. One wake per conversation at a time — a second call while one waits changes nothing.
103
137
  * Whether the requests still need it is decided when it is due (`decideRestartWake`). Returns `false` when one
104
- * was already waiting. The timer is unref'd: it never keeps the process alive.
138
+ * was already waiting, or when every open request is held by a watch that is not failing and owes nobody an answer
139
+ * (`checkIsHeldBetweenTurns`: a BOOT wakes nobody then, as in a topic). `isLostWork` — the process ended with the agent's own work
140
+ * pending — is the other event: a topic resumes on it whatever is armed, so no watch holds the wake, and a boot wake already
141
+ * waiting becomes one (the flag is remembered, the call still returns `false`). The timer is unref'd: it never keeps the process alive.
105
142
  */
106
- scheduleRestartWake(key: SessionKey): boolean;
143
+ scheduleRestartWake(key: SessionKey, options?: {
144
+ isLostWork?: boolean;
145
+ }): boolean;
107
146
  /**
108
147
  * @description The `restarted` wake of `key`'s conversation, now: every open request nobody watches that the rule
109
148
  * lets be woken gets its wake-up counted, and ONE forward carries them all — the prompt of each request the session
@@ -111,21 +150,61 @@ export declare class RequestWakeUpEngine {
111
150
  * continuation nudge's turn is. A request at the cap gets its alert instead. A delivery that fails is logged and
112
151
  * left to the backstop (counted from now): no alert of its own. Exported for tests (the timer calls it).
113
152
  */
114
- wakeAfterRestart(key: SessionKey): Promise<void>;
153
+ wakeAfterRestart(key: SessionKey, options?: {
154
+ isLostWork?: boolean;
155
+ }): Promise<void>;
115
156
  /** The open request `requestId` when it belongs to `key`'s conversation, else `undefined`. */
116
157
  private getOpenRequestOf;
158
+ /** The ids of the requests whose turns the engine watches in `key`'s conversation: the requests the agent is working on right now. */
159
+ getWatchedRequestIdsOf(key: SessionKey): string[];
160
+ /**
161
+ * The watched requests of `key`'s conversation whose watch a forward of their OWN started (not a conversation-wide nudge), the
162
+ * oldest own forward first: the first is the request whose forward started the running turn.
163
+ */
164
+ getOwnForwardWatchedRequestIdsOf(key: SessionKey): string[];
165
+ /**
166
+ * @description The request a job armed NOW in `key`'s conversation is armed under (`pickRequestToArmUnder` over the ledger's open
167
+ * requests and this engine's watches); `undefined` when no request is open.
168
+ */
169
+ getArmingRequestIdOf(key: SessionKey): string | undefined;
117
170
  /** The watched turns of `key`'s conversation. */
118
171
  private getWatchedTurnsOf;
119
172
  /**
120
173
  * @description A request's message (or a reminder for it) was just forwarded to
121
174
  * the conversation's session: watch the turn it starts. A watch already there
122
- * for the SAME request is replaced — its newest message is the one that counts;
123
- * another requester's request in the conversation keeps its own watch. A post
124
- * retry still pending is moot from now on (R28): the session has the request.
175
+ * for the SAME request is MERGED with it (the forward joined a turn that still runs: one that ended was settled before the write,
176
+ * `settleEndedTurnsOf`): the progress count keeps
177
+ * its earlier start, and the turn is the alarm's only if both were — except for the bot's own «continue»
178
+ * (`isContinuation`: the nudge after an API error or a limit wait), which keeps the alarm's kind but
179
+ * starts the progress count afresh: a note sent before the error is not this turn's — and for a person's
180
+ * words that join the running turn, which start the count afresh too: a note sent before them is not their answer. Another requester's
181
+ * request in the conversation keeps its own watch. Whether the turn is a scheduled run's (`isScheduledRun`) is said by the FORWARD
182
+ * that started it — a fire riding the request, or the fire that opened the scheduler's request — and never read from the request's
183
+ * state: an answered request's fire turn is a fire's as much as an unanswered one's (`src/requests/README.md` § Scheduled runs).
184
+ * A fire of ANOTHER job that only rides the request (`isRequestJob` false) is not the request's activity: its forward records none,
185
+ * and its watch keeps that (a merge is the request's own if either side is; a «continue» keeps what the turn was), so its busy time and
186
+ * its quiet end leave the request's follow-up and backstop alone (`src/requests/README.md` § Scheduled runs).
187
+ * A post retry still pending is moot from now on (R28): the session has the request — unless the forward is a fire riding the
188
+ * request, which carries none of its prompt. A forward that carries a person's words (a request prompt, an issue update) marks the
189
+ * request as owing an answer (`isPersonInputUnanswered`, persisted): that, not the kind of the turn, is
190
+ * what stops the turn's end from reading as a quiet one (`decideTurnEnd`).
125
191
  */
126
192
  trackForwardedTurn(key: SessionKey, requestId: string, options?: {
127
193
  isRequestPrompt: boolean;
194
+ isScheduledRun?: boolean;
195
+ isRequestJob?: boolean;
196
+ isPersonInput?: boolean;
197
+ isContinuation?: boolean;
198
+ isConversationForward?: boolean;
128
199
  }): Promise<void>;
200
+ /**
201
+ * @description A person's words for the request were HELD — an armed usage-limit wait keeps them back, and they reach the agent
202
+ * only inside whatever prompt the wait's end forwards first (a «continue», a scheduled run, the operator's next message). No
203
+ * turn starts for them now, so nothing is tracked, but the request owes an answer from this moment: persisted, so the turn
204
+ * that finally carries the words — under any watch, or none after a restart during the wait — is read against it
205
+ * (`checkIsAnswerOwed`). A request that owes it already, and a scheduler fire's own request, are left as they are.
206
+ */
207
+ notePersonInputHeld(key: SessionKey, requestId: string): Promise<void>;
129
208
  /**
130
209
  * @description The request's prompt could not be posted to the session (no
131
210
  * session came up, the forward failed): try again soon (R28). Once the retries
@@ -148,25 +227,48 @@ export declare class RequestWakeUpEngine {
148
227
  noteAnswerTailOutput(key: SessionKey): void;
149
228
  /** Drop every watch of `key`'s conversation, its answer tail included. */
150
229
  private unwatchConversation;
230
+ /**
231
+ * @description The requests of `key` whose prompt is NOT lost if the conversation ends now, read off its live process at this moment:
232
+ * a prompt the process took in — R21's own test ({@link checkIsPromptTakenInNow}) on a probe taken now, once what the process wrote so
233
+ * far is read (`refreshProcessState`), which the persisted mark lags behind until a settle or the 10-second poll (review 26 #1) — and a
234
+ * prompt still waiting in a start's or a stop's window, whose window's drop tells its person. Synchronous: a command reads it BEFORE it
235
+ * stops or replaces the process (the default of {@link cancelConversation}; the `/resume` pick ahead of its resume).
236
+ */
237
+ readPromptsReachedOrHeld(key: SessionKey): ReadonlySet<string>;
151
238
  /**
152
239
  * @description The person took over (interrupted, quit, restarted, switched or
153
240
  * resumed the session, left the folder): every open request of the
154
- * conversation closes silently and nothing wakes them.
241
+ * conversation closes and nothing wakes them. Resolves the ids of the requests
242
+ * this call closed that carry a person's words the agent never took in (not the
243
+ * scheduler's request, whose prompt is no person's): a command that ends or replaces the
244
+ * conversation tells those people, since nobody reads their words (review 25 #3, review 26 #2);
245
+ * an interrupt closes silently. «Never taken in» reads the persisted mark and `reachedOrHeld`
246
+ * ({@link readPromptsReachedOrHeld}), read by default when this is called — synchronously, before
247
+ * the first await, so off the process the command has not stopped yet.
155
248
  */
156
- cancelConversation(key: SessionKey): Promise<void>;
249
+ cancelConversation(key: SessionKey, reachedOrHeld?: ReadonlySet<string>): Promise<string[]>;
157
250
  /**
158
251
  * @description The bot itself forwarded a "continue" nudge into the session (an
159
- * API-error retry fired, or a usage-limit wait ended): watch the turn it starts
160
- * as a fresh one, so the idle the error left behind is never read as its end.
252
+ * API-error retry fired, or a usage-limit wait ended): watch the turn it starts, so the idle the
253
+ * error left behind is never read as its end. The nudge carries no person's words and is no alarm,
254
+ * so it KEEPS the alarm's kind of the turn it continues but its progress count starts afresh: a progress
255
+ * note sent before the error does not make a silent continuation a «progress» turn. What the turn owes a
256
+ * person is not its kind but the persisted request (`checkIsAnswerOwed`): words answered before the error
257
+ * are owed no more, words still unanswered stay owed.
161
258
  * `isCountersReset` (the end of a limit wait) starts every open request's
162
259
  * wake-up bookkeeping from zero — the wait was not the agent's silence — and
163
260
  * lifts a limit stop: the work continues, so does the waking. A request the
164
261
  * rules already gave up on stays given up. The one session turn the nudge
165
262
  * starts is watched for every open request of the conversation.
263
+ * `carriedRequestIds` — the requests whose prompts the message carries, never taken in (R21: a limit or account resume re-posts
264
+ * them) — is a fact about EACH request, named when the message was BUILT (`getPromptsNotTakenIn`): only such a request has its words
265
+ * in the message (they are owed an answer, as any request prompt's), every other open request gets the plain «continue». It is
266
+ * never read again here: a buffered message is tracked at its replay, and a request opened in between did not ride it (review 21
267
+ * nit 3). A carried request whose prompt the session took in meanwhile is a plain «continue» too.
166
268
  */
167
269
  trackContinuationTurn(key: SessionKey, options: {
168
270
  isCountersReset: boolean;
169
- isRequestPrompt?: boolean;
271
+ carriedRequestIds?: readonly string[];
170
272
  }): Promise<void>;
171
273
  /**
172
274
  * @description A usage-limit wait will not end by itself (auto-resume is off,
@@ -180,14 +282,101 @@ export declare class RequestWakeUpEngine {
180
282
  stopWakingForLimitWait(key: SessionKey): Promise<void>;
181
283
  /** @description One poll over the watched turns; exported for tests (the timer calls it). */
182
284
  pollWatchedTurns(): Promise<void>;
285
+ /**
286
+ * @description A new prompt is about to be written into `key`'s conversation: settle every watch of it whose turn has already
287
+ * ENDED, on a probe taken now — before the write — exactly as the poll's next tick would have. A prompt that waited behind a running
288
+ * turn is forwarded within seconds of its end (`postToSession` polls busy every 5 s, this engine every 10 s), usually before the tick
289
+ * saw the idle; the old watch would then read the NEW turn as its own: arm its jobs under the old request, count its busy time as
290
+ * the old request's activity, and decide the old request only at the new turn's end. A watch whose turn still runs is left — the
291
+ * forward joins it (`trackForwardedTurn` merges), its prompt marked taken in if the live process took it (R21, as the poll marks); a
292
+ * session that is gone is left to the poll.
293
+ * Synchronous up to the decisions: the ended watches are dropped and decided against the request as it is NOW, so a forward that
294
+ * does not await (a write must run in its caller's tick) is never read into them. The decisions are persisted after, in order; the
295
+ * returned promise resolves once they are (a post that picks a request awaits it first, so the pick and the header see the result)
296
+ * with the delivery of the wake-ups they decided. The CALLER delivers them — after its own write, so the prompt it writes starts the
297
+ * turn and a reminder joins it, as the tick would have reminded seconds later; a call with no write of its own (the adapter's turn end)
298
+ * hands them to a post on its way to its write, else delivers them at once ({@link deliverOrHandOverWake}). Never rejects, and neither
299
+ * does the delivery.
300
+ */
301
+ settleEndedTurnsOf(key: SessionKey): Promise<() => Promise<void>>;
302
+ /**
303
+ * @description A post (`postToSession`) is on its way to write a prompt into `key`'s conversation, waiting for the running turn's
304
+ * idle maybe. Until the returned release, a wake-up decided for the conversation — at the adapter's turn end, by the poll, by the sweep
305
+ * ({@link deliverOrHandOverWake}) — is HANDED to the post instead of written at once: the post takes it with its settle
306
+ * ({@link settleEndedTurnsForPost}) and delivers it after its own write, so the prompt that waited for the turn starts the next one and
307
+ * the reminder joins it (written first, the reminder would start that turn and the reminded request would read as its starter). The
308
+ * release delivers what is still handed over once the last post in flight is done: one that never took it (held over a limit wait,
309
+ * an ensure that failed) or a wake decided after its settle. It never rejects, and a second call does nothing.
310
+ */
311
+ notePostInFlight(key: SessionKey): () => Promise<void>;
312
+ /** @description Deliver a decided wake-up now, or hand it to a post in flight in `key`'s conversation ({@link notePostInFlight}). Never rejects. */
313
+ deliverOrHandOverWake(key: SessionKey, deliver: () => Promise<void>): Promise<void>;
314
+ /**
315
+ * @description A write into `key`'s live process (the write choke point, synchronously before the adapter write): the process it goes
316
+ * to is stamped, for a watch that is tracked only after that process went down ({@link writtenProcesses}). Synchronous; a probe that
317
+ * names no process (a window holds the prompt) stamps nothing.
318
+ */
319
+ noteWrite(key: SessionKey): void;
320
+ /**
321
+ * @description A write into `key`'s live process during the replay of a start's buffer (the write choke point, right after its settle;
322
+ * the bot calls it at every write while `StartupPromptBuffer.checkIsReplaying`: a replayed prompt, the held prompts after them, a prompt
323
+ * written at once while the replay runs — all go to the process the replay writes into). A watch tracked while its prompt waited in that
324
+ * buffer names no process yet, and the replay took the whole buffer to write it into this process, so its prompt is in this one. Never
325
+ * called for a write outside a replay: a watch whose buffer was DROPPED stays unnamed — its prompt reached no process
326
+ * (`checkIsPromptNeverWritten`) — and the request it opened is closed with the person told (`bot.ts`, the person's buffered prompt's
327
+ * settle). Only a person's prompt is tracked before its replay: every bot-made caller watches its turn once its prompt reached a session
328
+ * (`src/requests/README.md`, the callers table). Synchronous; a session with no process named does nothing.
329
+ */
330
+ noteReplayedWrite(key: SessionKey): void;
331
+ /**
332
+ * @description The settle of a post about to write ({@link settleEndedTurnsOf}): resolves ONE delivery for the post to run after its
333
+ * write — the wake-ups handed to it so far, in order, then this settle's own. Never rejects, and neither does the delivery.
334
+ */
335
+ settleEndedTurnsForPost(key: SessionKey): Promise<() => Promise<void>>;
336
+ /** The delivery of the wake-ups handed to a post in `conversationKey`, taken (a later post or release finds none of them). */
337
+ private takeWakesHandedToPost;
338
+ /** The decision at the end of `turn`, read against `request` and its jobs as they are now. */
339
+ private decideWatchedTurnEnd;
340
+ /** R21 for a request prompt the ended turn took in (a later wake-up is a reminder), then `decision` persisted; resolves its wake's delivery. */
341
+ private persistEndedTurn;
342
+ /**
343
+ * R21: once the backend took a request prompt in, a wake-up is a reminder — the agent has read the request. A held turn end is read like
344
+ * any other: what the backend still lists as unread is unread. A prompt queued behind a turn that ended in an error result stays listed
345
+ * until its own echo (the json-stream adapter keeps it; the CLI runs it as its next turn, measured), and the prompt of the turn that
346
+ * failed was read by it — a resume that posted it again would repeat words the agent already has.
347
+ * Read only off the process the prompt was written to (`writtenToProcess`): a re-spawn that replaced it — an account move after a limit,
348
+ * a model change — kills a message still queued there, and the new process lists nothing unread. Left unmarked, the prompt is posted
349
+ * again: by the resume's «continue» (`getPromptNotTakenIn`), or as the wake-up of the turn's end. A prompt that names no process while
350
+ * one is live never reached any (`checkIsTurnInputConsumed`): nothing is marked.
351
+ */
352
+ private markPromptTakenIn;
183
353
  private pollWatchedTurn;
184
354
  /** @description One sweep over the open requests nobody watches; exported for tests. */
185
355
  sweepUnwatchedRequests(): Promise<void>;
186
356
  private sweepOpenRequest;
357
+ /**
358
+ * ANY tracker request of the conversation nobody watches while the agent's own pending work holds it (`checkIsHeldByOwnWork`) — a
359
+ * restart dropped the watch that held it, or the work is another request's (one request's work holds every open request of the
360
+ * conversation that owes nobody an answer; the work's end nudges each one left open with nothing armed): watch it, so the turn that
361
+ * work starts by itself is decided when it ends, not left to the backstop. Not while its prompt waits for a post retry (that forward
362
+ * is watched: the sweep's decision runs it), nor once nothing may wake it. `true` — it is watched now.
363
+ */
364
+ private watchTurnOfOwnWork;
365
+ /** The rule set `key`'s conversation is woken under; a topic's when the port is not wired. */
366
+ private getRules;
367
+ /** The request's reading of its armed jobs now; `none` when the port is not wired. */
368
+ private getScheduleWait;
187
369
  private sweepAnswerTail;
188
370
  /** Persist that the agent is working on it, at most once per step unless forced. */
189
371
  private recordTurnActivity;
190
372
  private applyDecision;
373
+ /**
374
+ * Persist `decision` (an alert is raised here too) and resolve the delivery of its wake-up, or `null` when it decided none or the
375
+ * request changed meanwhile. Split from the delivery so a settle before a write can persist at once and deliver after the write.
376
+ */
377
+ private persistDecision;
378
+ /** Deliver a persisted wake-up: the reminder (or the request's prompt again, R21), then its turn watched, or the failure handled. */
379
+ private deliverWake;
191
380
  /**
192
381
  * Resume the session if needed, re-check the request, forward the reminder. A
193
382
  * step that threw did not reach the session: same as one that could not.
@@ -1 +1 @@
1
- {"version":3,"file":"wakeUpEngine.d.ts","sourceRoot":"","sources":["../../src/requests/wakeUpEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AASvE,OAAO,EASL,KAAK,gBAAgB,EAGtB,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;;;;GAkBG;AAEH,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,QAAS,CAAC;AACxC,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,QAAS,CAAC;AACvC,4FAA4F;AAC5F,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAChD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAE3C;;;;;;;;;GASG;AACH,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,oBAAoB,GAAG,oBAAoB,GAAG,kBAAkB,GAAG,mBAAmB,GAAG,cAAc,GAAG,aAAa,CAAC,CAAC;IACrJ,SAAS,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,gB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