charness 3.1.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (417) hide show
  1. package/.env.example +11 -13
  2. package/DEVELOPMENT.md +27 -6
  3. package/MIGRATION_1_TO_2.md +1 -1
  4. package/MIGRATION_RENAME_TO_CHARNESS.md +133 -0
  5. package/README.md +185 -618
  6. package/SETUP.md +644 -0
  7. package/dist/adapters/adapterEventRouting.d.ts +2 -1
  8. package/dist/adapters/adapterEventRouting.d.ts.map +1 -1
  9. package/dist/adapters/adapterEventRouting.js +3 -0
  10. package/dist/adapters/adapterEventRouting.js.map +1 -1
  11. package/dist/adapters/adapterNames.d.ts +13 -0
  12. package/dist/adapters/adapterNames.d.ts.map +1 -1
  13. package/dist/adapters/adapterNames.js +16 -0
  14. package/dist/adapters/adapterNames.js.map +1 -1
  15. package/dist/adapters/backendUnavailableError.d.ts +11 -0
  16. package/dist/adapters/backendUnavailableError.d.ts.map +1 -0
  17. package/dist/adapters/backendUnavailableError.js +19 -0
  18. package/dist/adapters/backendUnavailableError.js.map +1 -0
  19. package/dist/adapters/claudeCliAdapter.d.ts +30 -7
  20. package/dist/adapters/claudeCliAdapter.d.ts.map +1 -1
  21. package/dist/adapters/claudeCliAdapter.js +71 -17
  22. package/dist/adapters/claudeCliAdapter.js.map +1 -1
  23. package/dist/adapters/claudeJsonStreamAdapter.d.ts +36 -3
  24. package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -1
  25. package/dist/adapters/claudeJsonStreamAdapter.js +95 -31
  26. package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
  27. package/dist/adapters/createAdapter.d.ts +3 -14
  28. package/dist/adapters/createAdapter.d.ts.map +1 -1
  29. package/dist/adapters/createAdapter.js +9 -19
  30. package/dist/adapters/createAdapter.js.map +1 -1
  31. package/dist/adapters/openCodeAdapter.d.ts +140 -12
  32. package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
  33. package/dist/adapters/openCodeAdapter.js +386 -120
  34. package/dist/adapters/openCodeAdapter.js.map +1 -1
  35. package/dist/apiErrorRetry.d.ts +70 -6
  36. package/dist/apiErrorRetry.d.ts.map +1 -1
  37. package/dist/apiErrorRetry.js +312 -34
  38. package/dist/apiErrorRetry.js.map +1 -1
  39. package/dist/apiRetryKick.d.ts +26 -1
  40. package/dist/apiRetryKick.d.ts.map +1 -1
  41. package/dist/apiRetryKick.js +41 -2
  42. package/dist/apiRetryKick.js.map +1 -1
  43. package/dist/bot.d.ts +2 -1
  44. package/dist/bot.d.ts.map +1 -1
  45. package/dist/bot.js +743 -190
  46. package/dist/bot.js.map +1 -1
  47. package/dist/cli/bot.d.ts +4 -2
  48. package/dist/cli/bot.d.ts.map +1 -1
  49. package/dist/cli/bot.js +11 -3
  50. package/dist/cli/bot.js.map +1 -1
  51. package/dist/cli/botEntry.js +3 -1
  52. package/dist/cli/botEntry.js.map +1 -1
  53. package/dist/cli/claudeProfiles.d.ts +4 -4
  54. package/dist/cli/claudeProfiles.js +5 -5
  55. package/dist/cli/claudeProfiles.js.map +1 -1
  56. package/dist/cli/envLoader.d.ts +6 -5
  57. package/dist/cli/envLoader.d.ts.map +1 -1
  58. package/dist/cli/envLoader.js +8 -27
  59. package/dist/cli/envLoader.js.map +1 -1
  60. package/dist/cli/hot.d.ts +9 -3
  61. package/dist/cli/hot.d.ts.map +1 -1
  62. package/dist/cli/hot.js +55 -19
  63. package/dist/cli/hot.js.map +1 -1
  64. package/dist/cli.js +12 -12
  65. package/dist/cli.js.map +1 -1
  66. package/dist/configDirFile.d.ts +73 -0
  67. package/dist/configDirFile.d.ts.map +1 -0
  68. package/dist/configDirFile.js +216 -0
  69. package/dist/configDirFile.js.map +1 -0
  70. package/dist/connectors/jira/adf.d.ts +21 -0
  71. package/dist/connectors/jira/adf.d.ts.map +1 -1
  72. package/dist/connectors/jira/adf.js +39 -0
  73. package/dist/connectors/jira/adf.js.map +1 -1
  74. package/dist/connectors/jira/answerSink.d.ts +20 -3
  75. package/dist/connectors/jira/answerSink.d.ts.map +1 -1
  76. package/dist/connectors/jira/answerSink.js +126 -13
  77. package/dist/connectors/jira/answerSink.js.map +1 -1
  78. package/dist/connectors/jira/client.d.ts +4 -0
  79. package/dist/connectors/jira/client.d.ts.map +1 -1
  80. package/dist/connectors/jira/client.js +3 -0
  81. package/dist/connectors/jira/client.js.map +1 -1
  82. package/dist/connectors/jira/config.d.ts +10 -1
  83. package/dist/connectors/jira/config.d.ts.map +1 -1
  84. package/dist/connectors/jira/config.js +11 -2
  85. package/dist/connectors/jira/config.js.map +1 -1
  86. package/dist/connectors/jira/connector.d.ts +7 -1
  87. package/dist/connectors/jira/connector.d.ts.map +1 -1
  88. package/dist/connectors/jira/connector.js +23 -4
  89. package/dist/connectors/jira/connector.js.map +1 -1
  90. package/dist/connectors/jira/contextLedger.d.ts +6 -0
  91. package/dist/connectors/jira/contextLedger.d.ts.map +1 -1
  92. package/dist/connectors/jira/contextLedger.js +16 -0
  93. package/dist/connectors/jira/contextLedger.js.map +1 -1
  94. package/dist/connectors/jira/contextPreamble.d.ts.map +1 -1
  95. package/dist/connectors/jira/contextPreamble.js +6 -3
  96. package/dist/connectors/jira/contextPreamble.js.map +1 -1
  97. package/dist/connectors/jira/inbound.d.ts +60 -7
  98. package/dist/connectors/jira/inbound.d.ts.map +1 -1
  99. package/dist/connectors/jira/inbound.js +169 -16
  100. package/dist/connectors/jira/inbound.js.map +1 -1
  101. package/dist/connectors/jira/issueBlocks.d.ts +6 -1
  102. package/dist/connectors/jira/issueBlocks.d.ts.map +1 -1
  103. package/dist/connectors/jira/issueBlocks.js +5 -1
  104. package/dist/connectors/jira/issueBlocks.js.map +1 -1
  105. package/dist/connectors/jira/prompt.d.ts +2 -0
  106. package/dist/connectors/jira/prompt.d.ts.map +1 -1
  107. package/dist/connectors/jira/prompt.js +16 -0
  108. package/dist/connectors/jira/prompt.js.map +1 -1
  109. package/dist/connectors/jira/trigger.d.ts +12 -3
  110. package/dist/connectors/jira/trigger.d.ts.map +1 -1
  111. package/dist/connectors/jira/trigger.js +8 -1
  112. package/dist/connectors/jira/trigger.js.map +1 -1
  113. package/dist/connectors/jira/triggerLog.d.ts +10 -3
  114. package/dist/connectors/jira/triggerLog.d.ts.map +1 -1
  115. package/dist/connectors/jira/triggerLog.js +18 -2
  116. package/dist/connectors/jira/triggerLog.js.map +1 -1
  117. package/dist/connectors/telegram/commands/autoContinueLimits.d.ts +2 -2
  118. package/dist/connectors/telegram/commands/autoContinueLimits.d.ts.map +1 -1
  119. package/dist/connectors/telegram/commands/autoContinueLimits.js +4 -4
  120. package/dist/connectors/telegram/commands/autoContinueLimits.js.map +1 -1
  121. package/dist/connectors/telegram/commands/backendSwitch.d.ts +25 -0
  122. package/dist/connectors/telegram/commands/backendSwitch.d.ts.map +1 -0
  123. package/dist/connectors/telegram/commands/backendSwitch.js +104 -0
  124. package/dist/connectors/telegram/commands/backendSwitch.js.map +1 -0
  125. package/dist/connectors/telegram/commands/callbackMessage.d.ts +12 -0
  126. package/dist/connectors/telegram/commands/callbackMessage.d.ts.map +1 -1
  127. package/dist/connectors/telegram/commands/callbackMessage.js +24 -0
  128. package/dist/connectors/telegram/commands/callbackMessage.js.map +1 -1
  129. package/dist/connectors/telegram/commands/callbackToast.d.ts +36 -0
  130. package/dist/connectors/telegram/commands/callbackToast.d.ts.map +1 -0
  131. package/dist/connectors/telegram/commands/callbackToast.js +83 -0
  132. package/dist/connectors/telegram/commands/callbackToast.js.map +1 -0
  133. package/dist/connectors/telegram/commands/claudeAccounts.d.ts +18 -0
  134. package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -1
  135. package/dist/connectors/telegram/commands/claudeAccounts.js +220 -66
  136. package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
  137. package/dist/connectors/telegram/commands/displayModes.d.ts.map +1 -1
  138. package/dist/connectors/telegram/commands/displayModes.js +4 -2
  139. package/dist/connectors/telegram/commands/displayModes.js.map +1 -1
  140. package/dist/connectors/telegram/commands/fallbackChain.d.ts +5 -8
  141. package/dist/connectors/telegram/commands/fallbackChain.d.ts.map +1 -1
  142. package/dist/connectors/telegram/commands/fallbackChain.js +183 -193
  143. package/dist/connectors/telegram/commands/fallbackChain.js.map +1 -1
  144. package/dist/connectors/telegram/commands/limitsBoard.d.ts +40 -0
  145. package/dist/connectors/telegram/commands/limitsBoard.d.ts.map +1 -0
  146. package/dist/connectors/telegram/commands/limitsBoard.js +281 -0
  147. package/dist/connectors/telegram/commands/limitsBoard.js.map +1 -0
  148. package/dist/connectors/telegram/commands/modelPage.d.ts +130 -0
  149. package/dist/connectors/telegram/commands/modelPage.d.ts.map +1 -0
  150. package/dist/connectors/telegram/commands/modelPage.js +120 -0
  151. package/dist/connectors/telegram/commands/modelPage.js.map +1 -0
  152. package/dist/connectors/telegram/commands/modelProviders.d.ts +9 -1
  153. package/dist/connectors/telegram/commands/modelProviders.d.ts.map +1 -1
  154. package/dist/connectors/telegram/commands/modelProviders.js +203 -111
  155. package/dist/connectors/telegram/commands/modelProviders.js.map +1 -1
  156. package/dist/connectors/telegram/commands/stt.d.ts +32 -0
  157. package/dist/connectors/telegram/commands/stt.d.ts.map +1 -0
  158. package/dist/connectors/telegram/commands/stt.js +460 -0
  159. package/dist/connectors/telegram/commands/stt.js.map +1 -0
  160. package/dist/effortLevels.d.ts +57 -7
  161. package/dist/effortLevels.d.ts.map +1 -1
  162. package/dist/effortLevels.js +65 -9
  163. package/dist/effortLevels.js.map +1 -1
  164. package/dist/i18n/de.d.ts.map +1 -1
  165. package/dist/i18n/de.js +160 -17
  166. package/dist/i18n/de.js.map +1 -1
  167. package/dist/i18n/en.d.ts.map +1 -1
  168. package/dist/i18n/en.js +160 -17
  169. package/dist/i18n/en.js.map +1 -1
  170. package/dist/i18n/es.d.ts.map +1 -1
  171. package/dist/i18n/es.js +160 -17
  172. package/dist/i18n/es.js.map +1 -1
  173. package/dist/i18n/fr.d.ts.map +1 -1
  174. package/dist/i18n/fr.js +160 -17
  175. package/dist/i18n/fr.js.map +1 -1
  176. package/dist/i18n/hi.d.ts.map +1 -1
  177. package/dist/i18n/hi.js +160 -17
  178. package/dist/i18n/hi.js.map +1 -1
  179. package/dist/i18n/ja.d.ts.map +1 -1
  180. package/dist/i18n/ja.js +160 -17
  181. package/dist/i18n/ja.js.map +1 -1
  182. package/dist/i18n/ka.d.ts.map +1 -1
  183. package/dist/i18n/ka.js +160 -17
  184. package/dist/i18n/ka.js.map +1 -1
  185. package/dist/i18n/pt.d.ts.map +1 -1
  186. package/dist/i18n/pt.js +160 -17
  187. package/dist/i18n/pt.js.map +1 -1
  188. package/dist/i18n/ru.d.ts.map +1 -1
  189. package/dist/i18n/ru.js +160 -17
  190. package/dist/i18n/ru.js.map +1 -1
  191. package/dist/i18n/uk.d.ts.map +1 -1
  192. package/dist/i18n/uk.js +160 -17
  193. package/dist/i18n/uk.js.map +1 -1
  194. package/dist/i18n/uz.d.ts.map +1 -1
  195. package/dist/i18n/uz.js +160 -17
  196. package/dist/i18n/uz.js.map +1 -1
  197. package/dist/i18n/zh.d.ts.map +1 -1
  198. package/dist/i18n/zh.js +160 -17
  199. package/dist/i18n/zh.js.map +1 -1
  200. package/dist/index.js +1 -1
  201. package/dist/index.js.map +1 -1
  202. package/dist/installManager.d.ts +36 -6
  203. package/dist/installManager.d.ts.map +1 -1
  204. package/dist/installManager.js +124 -26
  205. package/dist/installManager.js.map +1 -1
  206. package/dist/instanceLock.d.ts.map +1 -1
  207. package/dist/instanceLock.js +10 -8
  208. package/dist/instanceLock.js.map +1 -1
  209. package/dist/instanceSettings.d.ts +52 -0
  210. package/dist/instanceSettings.d.ts.map +1 -0
  211. package/dist/instanceSettings.js +136 -0
  212. package/dist/instanceSettings.js.map +1 -0
  213. package/dist/legacyMigration.d.ts +69 -0
  214. package/dist/legacyMigration.d.ts.map +1 -0
  215. package/dist/legacyMigration.js +338 -0
  216. package/dist/legacyMigration.js.map +1 -0
  217. package/dist/legacyNames.d.ts +107 -0
  218. package/dist/legacyNames.d.ts.map +1 -0
  219. package/dist/legacyNames.js +230 -0
  220. package/dist/legacyNames.js.map +1 -0
  221. package/dist/pinnedStatus.d.ts +7 -1
  222. package/dist/pinnedStatus.d.ts.map +1 -1
  223. package/dist/pinnedStatus.js +1 -1
  224. package/dist/pinnedStatus.js.map +1 -1
  225. package/dist/platform/answerSink.d.ts +5 -0
  226. package/dist/platform/answerSink.d.ts.map +1 -1
  227. package/dist/platform/answerSink.js.map +1 -1
  228. package/dist/requests/answerRequest.d.ts +2 -0
  229. package/dist/requests/answerRequest.d.ts.map +1 -1
  230. package/dist/requests/answerRequest.js +3 -1
  231. package/dist/requests/answerRequest.js.map +1 -1
  232. package/dist/requests/answerStyle.d.ts +11 -0
  233. package/dist/requests/answerStyle.d.ts.map +1 -0
  234. package/dist/requests/answerStyle.js +14 -0
  235. package/dist/requests/answerStyle.js.map +1 -0
  236. package/dist/requests/answerTail.d.ts.map +1 -1
  237. package/dist/requests/answerTail.js +2 -0
  238. package/dist/requests/answerTail.js.map +1 -1
  239. package/dist/requests/requestHeader.d.ts.map +1 -1
  240. package/dist/requests/requestHeader.js +3 -0
  241. package/dist/requests/requestHeader.js.map +1 -1
  242. package/dist/requests/requestLedger.d.ts +8 -0
  243. package/dist/requests/requestLedger.d.ts.map +1 -1
  244. package/dist/requests/requestLedger.js +20 -2
  245. package/dist/requests/requestLedger.js.map +1 -1
  246. package/dist/requests/types.d.ts +3 -1
  247. package/dist/requests/types.d.ts.map +1 -1
  248. package/dist/scheduler/mcpSurface.d.ts +9 -1
  249. package/dist/scheduler/mcpSurface.d.ts.map +1 -1
  250. package/dist/scheduler/mcpSurface.js +49 -16
  251. package/dist/scheduler/mcpSurface.js.map +1 -1
  252. package/dist/shutdown.d.ts +14 -0
  253. package/dist/shutdown.d.ts.map +1 -1
  254. package/dist/shutdown.js +16 -0
  255. package/dist/shutdown.js.map +1 -1
  256. package/dist/state.d.ts +57 -3
  257. package/dist/state.d.ts.map +1 -1
  258. package/dist/state.js +67 -3
  259. package/dist/state.js.map +1 -1
  260. package/dist/stt/sttAutoInstall.d.ts +39 -0
  261. package/dist/stt/sttAutoInstall.d.ts.map +1 -0
  262. package/dist/stt/sttAutoInstall.js +158 -0
  263. package/dist/stt/sttAutoInstall.js.map +1 -0
  264. package/dist/stt/sttChildEnv.d.ts +11 -0
  265. package/dist/stt/sttChildEnv.d.ts.map +1 -0
  266. package/dist/stt/sttChildEnv.js +30 -0
  267. package/dist/stt/sttChildEnv.js.map +1 -0
  268. package/dist/stt/sttConfigEdit.d.ts +71 -0
  269. package/dist/stt/sttConfigEdit.d.ts.map +1 -0
  270. package/dist/stt/sttConfigEdit.js +144 -0
  271. package/dist/stt/sttConfigEdit.js.map +1 -0
  272. package/dist/stt/sttInstall.d.ts +147 -0
  273. package/dist/stt/sttInstall.d.ts.map +1 -0
  274. package/dist/stt/sttInstall.js +491 -0
  275. package/dist/stt/sttInstall.js.map +1 -0
  276. package/dist/stt/sttInstallEntry.d.ts +2 -0
  277. package/dist/stt/sttInstallEntry.d.ts.map +1 -0
  278. package/dist/stt/sttInstallEntry.js +31 -0
  279. package/dist/stt/sttInstallEntry.js.map +1 -0
  280. package/dist/stt/sttInstallReporter.d.ts +45 -0
  281. package/dist/stt/sttInstallReporter.d.ts.map +1 -0
  282. package/dist/stt/sttInstallReporter.js +57 -0
  283. package/dist/stt/sttInstallReporter.js.map +1 -0
  284. package/dist/stt/sttRuntime.d.ts +35 -0
  285. package/dist/stt/sttRuntime.d.ts.map +1 -0
  286. package/dist/stt/sttRuntime.js +73 -0
  287. package/dist/stt/sttRuntime.js.map +1 -0
  288. package/dist/stt/sttScreenPlan.d.ts +193 -0
  289. package/dist/stt/sttScreenPlan.d.ts.map +1 -0
  290. package/dist/stt/sttScreenPlan.js +541 -0
  291. package/dist/stt/sttScreenPlan.js.map +1 -0
  292. package/dist/stt/sttSettings.d.ts +201 -0
  293. package/dist/stt/sttSettings.d.ts.map +1 -0
  294. package/dist/stt/sttSettings.js +387 -0
  295. package/dist/stt/sttSettings.js.map +1 -0
  296. package/dist/stt/sttSidecarOwner.d.ts +115 -0
  297. package/dist/stt/sttSidecarOwner.d.ts.map +1 -0
  298. package/dist/stt/sttSidecarOwner.js +475 -0
  299. package/dist/stt/sttSidecarOwner.js.map +1 -0
  300. package/dist/stt/transcribeChain.d.ts +36 -0
  301. package/dist/stt/transcribeChain.d.ts.map +1 -0
  302. package/dist/stt/transcribeChain.js +42 -0
  303. package/dist/stt/transcribeChain.js.map +1 -0
  304. package/dist/types.d.ts +77 -4
  305. package/dist/types.d.ts.map +1 -1
  306. package/dist/utils/adapterSwitchSessionIds.d.ts +32 -0
  307. package/dist/utils/adapterSwitchSessionIds.d.ts.map +1 -0
  308. package/dist/utils/adapterSwitchSessionIds.js +44 -0
  309. package/dist/utils/adapterSwitchSessionIds.js.map +1 -0
  310. package/dist/utils/backendSwitchPlan.d.ts +63 -0
  311. package/dist/utils/backendSwitchPlan.d.ts.map +1 -0
  312. package/dist/utils/backendSwitchPlan.js +73 -0
  313. package/dist/utils/backendSwitchPlan.js.map +1 -0
  314. package/dist/utils/claudeAccountPickerPlan.d.ts +12 -1
  315. package/dist/utils/claudeAccountPickerPlan.d.ts.map +1 -1
  316. package/dist/utils/claudeAccountPickerPlan.js +20 -1
  317. package/dist/utils/claudeAccountPickerPlan.js.map +1 -1
  318. package/dist/utils/claudeProfiles.d.ts +7 -0
  319. package/dist/utils/claudeProfiles.d.ts.map +1 -1
  320. package/dist/utils/claudeProfiles.js +19 -0
  321. package/dist/utils/claudeProfiles.js.map +1 -1
  322. package/dist/utils/claudeTranscriptContent.d.ts +24 -0
  323. package/dist/utils/claudeTranscriptContent.d.ts.map +1 -0
  324. package/dist/utils/claudeTranscriptContent.js +107 -0
  325. package/dist/utils/claudeTranscriptContent.js.map +1 -0
  326. package/dist/utils/claudeUsage.d.ts +47 -8
  327. package/dist/utils/claudeUsage.d.ts.map +1 -1
  328. package/dist/utils/claudeUsage.js +76 -14
  329. package/dist/utils/claudeUsage.js.map +1 -1
  330. package/dist/utils/claudeUsageRefresher.d.ts +8 -1
  331. package/dist/utils/claudeUsageRefresher.d.ts.map +1 -1
  332. package/dist/utils/claudeUsageRefresher.js +9 -4
  333. package/dist/utils/claudeUsageRefresher.js.map +1 -1
  334. package/dist/utils/effortPickerPlan.d.ts +54 -0
  335. package/dist/utils/effortPickerPlan.d.ts.map +1 -0
  336. package/dist/utils/effortPickerPlan.js +56 -0
  337. package/dist/utils/effortPickerPlan.js.map +1 -0
  338. package/dist/utils/ensureSessionPlan.d.ts +20 -4
  339. package/dist/utils/ensureSessionPlan.d.ts.map +1 -1
  340. package/dist/utils/ensureSessionPlan.js +17 -4
  341. package/dist/utils/ensureSessionPlan.js.map +1 -1
  342. package/dist/utils/fallbackBridge.d.ts +6 -2
  343. package/dist/utils/fallbackBridge.d.ts.map +1 -1
  344. package/dist/utils/fallbackBridge.js +10 -3
  345. package/dist/utils/fallbackBridge.js.map +1 -1
  346. package/dist/utils/fallbackChain.d.ts +36 -0
  347. package/dist/utils/fallbackChain.d.ts.map +1 -1
  348. package/dist/utils/fallbackChain.js +65 -1
  349. package/dist/utils/fallbackChain.js.map +1 -1
  350. package/dist/utils/fallbackSwitchNotice.d.ts +41 -0
  351. package/dist/utils/fallbackSwitchNotice.d.ts.map +1 -0
  352. package/dist/utils/fallbackSwitchNotice.js +75 -0
  353. package/dist/utils/fallbackSwitchNotice.js.map +1 -0
  354. package/dist/utils/fileSendService.d.ts +33 -10
  355. package/dist/utils/fileSendService.d.ts.map +1 -1
  356. package/dist/utils/fileSendService.js +78 -27
  357. package/dist/utils/fileSendService.js.map +1 -1
  358. package/dist/utils/jsonStreamHost.d.ts +39 -0
  359. package/dist/utils/jsonStreamHost.d.ts.map +1 -1
  360. package/dist/utils/jsonStreamHost.js +60 -1
  361. package/dist/utils/jsonStreamHost.js.map +1 -1
  362. package/dist/utils/limitEpisodeRecovery.d.ts +16 -2
  363. package/dist/utils/limitEpisodeRecovery.d.ts.map +1 -1
  364. package/dist/utils/limitEpisodeRecovery.js +44 -3
  365. package/dist/utils/limitEpisodeRecovery.js.map +1 -1
  366. package/dist/utils/limitSettings.d.ts +25 -0
  367. package/dist/utils/limitSettings.d.ts.map +1 -0
  368. package/dist/utils/limitSettings.js +31 -0
  369. package/dist/utils/limitSettings.js.map +1 -0
  370. package/dist/utils/limitsBoardPlan.d.ts +52 -0
  371. package/dist/utils/limitsBoardPlan.d.ts.map +1 -0
  372. package/dist/utils/limitsBoardPlan.js +93 -0
  373. package/dist/utils/limitsBoardPlan.js.map +1 -0
  374. package/dist/utils/openCodeCompactPlugin.d.ts +11 -3
  375. package/dist/utils/openCodeCompactPlugin.d.ts.map +1 -1
  376. package/dist/utils/openCodeCompactPlugin.js +37 -5
  377. package/dist/utils/openCodeCompactPlugin.js.map +1 -1
  378. package/dist/utils/openCodeUsage.d.ts +93 -0
  379. package/dist/utils/openCodeUsage.d.ts.map +1 -0
  380. package/dist/utils/openCodeUsage.js +248 -0
  381. package/dist/utils/openCodeUsage.js.map +1 -0
  382. package/dist/utils/operatorSwitchPlan.d.ts +61 -0
  383. package/dist/utils/operatorSwitchPlan.d.ts.map +1 -0
  384. package/dist/utils/operatorSwitchPlan.js +32 -0
  385. package/dist/utils/operatorSwitchPlan.js.map +1 -0
  386. package/dist/utils/promptDelivery.d.ts +40 -0
  387. package/dist/utils/promptDelivery.d.ts.map +1 -1
  388. package/dist/utils/promptDelivery.js +31 -0
  389. package/dist/utils/promptDelivery.js.map +1 -1
  390. package/dist/utils/recvPreviewRedaction.d.ts +14 -4
  391. package/dist/utils/recvPreviewRedaction.d.ts.map +1 -1
  392. package/dist/utils/recvPreviewRedaction.js +19 -7
  393. package/dist/utils/recvPreviewRedaction.js.map +1 -1
  394. package/dist/utils/startupReadiness.d.ts +3 -3
  395. package/dist/utils/startupReadiness.d.ts.map +1 -1
  396. package/dist/utils/startupReadiness.js +2 -2
  397. package/dist/utils/startupReadiness.js.map +1 -1
  398. package/dist/utils/threadStatusReport.d.ts +3 -1
  399. package/dist/utils/threadStatusReport.d.ts.map +1 -1
  400. package/dist/utils/threadStatusReport.js +4 -3
  401. package/dist/utils/threadStatusReport.js.map +1 -1
  402. package/dist/utils/timezone.d.ts +23 -0
  403. package/dist/utils/timezone.d.ts.map +1 -1
  404. package/dist/utils/timezone.js +38 -0
  405. package/dist/utils/timezone.js.map +1 -1
  406. package/dist/utils/transcribeAudio.d.ts +25 -12
  407. package/dist/utils/transcribeAudio.d.ts.map +1 -1
  408. package/dist/utils/transcribeAudio.js +39 -21
  409. package/dist/utils/transcribeAudio.js.map +1 -1
  410. package/dist/utils/usageRefreshBudget.d.ts +9 -0
  411. package/dist/utils/usageRefreshBudget.d.ts.map +1 -0
  412. package/dist/utils/usageRefreshBudget.js +27 -0
  413. package/dist/utils/usageRefreshBudget.js.map +1 -0
  414. package/examples/.env.example +13 -9
  415. package/examples/docker-compose.yml +20 -17
  416. package/package.json +4 -1
  417. package/stt/gigaam_sidecar.py +800 -0
@@ -37,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.openCodeCompactPluginId = exports.openCodeCompactPluginFileName = void 0;
40
+ exports.legacyOpenCodeCompactPluginId = exports.legacyOpenCodeCompactPluginFileName = exports.openCodeCompactPluginId = exports.openCodeCompactPluginFileName = void 0;
41
41
  exports.getOpenCodeCompactPluginContext = getOpenCodeCompactPluginContext;
42
42
  exports.buildOpenCodeCompactPluginSource = buildOpenCodeCompactPluginSource;
43
43
  exports.resolveOpenCodeGlobalPluginDir = resolveOpenCodeGlobalPluginDir;
@@ -48,10 +48,18 @@ const fs_1 = __importDefault(require("fs"));
48
48
  const os_1 = __importDefault(require("os"));
49
49
  const path_1 = __importDefault(require("path"));
50
50
  const compactOnIdle_1 = require("./compactOnIdle");
51
+ const legacyNames_1 = require("../legacyNames");
51
52
  /** File name of the plugin in OpenCode's plugin folder; also how the bot recognises it in `GET /config`. */
52
- exports.openCodeCompactPluginFileName = 'telegramcode-compaction.js';
53
+ exports.openCodeCompactPluginFileName = 'charness-compaction.js';
53
54
  /** OpenCode requires a path plugin to export an id. */
54
- exports.openCodeCompactPluginId = 'telegramcode-compaction';
55
+ exports.openCodeCompactPluginId = 'charness-compaction';
56
+ /**
57
+ * The file and id the same plugin had before the rename. A folder instance that
58
+ * loaded it keeps it in memory, so it still counts as "has the plugin"; the FILE
59
+ * is removed on install so a new instance does not load both.
60
+ */
61
+ exports.legacyOpenCodeCompactPluginFileName = 'telegramcode-compaction.js';
62
+ exports.legacyOpenCodeCompactPluginId = 'telegramcode-compaction';
55
63
  /**
56
64
  * @description The text the plugin adds to every compaction prompt. OpenCode
57
65
  * appends it AFTER the bot's per-invocation instruction, which may end with the
@@ -92,7 +100,9 @@ function checkHasOpenCodeCompactPlugin(pluginSpecs) {
92
100
  return false;
93
101
  return pluginSpecs.some((entry) => {
94
102
  const spec = Array.isArray(entry) ? entry[0] : entry;
95
- return typeof spec === 'string' && spec.endsWith(`/${exports.openCodeCompactPluginFileName}`);
103
+ return (typeof spec === 'string' &&
104
+ (spec.endsWith(`/${exports.openCodeCompactPluginFileName}`) ||
105
+ spec.endsWith(`/${exports.legacyOpenCodeCompactPluginFileName}`)));
96
106
  });
97
107
  }
98
108
  /**
@@ -110,14 +120,36 @@ function getCompactPluginActivation(input) {
110
120
  const isAnyBusy = Object.values(status).some((entry) => !entry || typeof entry !== 'object' || entry.type !== 'idle');
111
121
  return isAnyBusy ? 'busy' : 'recreate';
112
122
  }
123
+ /**
124
+ * @description Remove the plugin file a pre-rename release installed, so a folder
125
+ * instance never loads two copies of the guidance. Only a file that is the bot's
126
+ * own (it exports the legacy id) is removed; anything else under that name is
127
+ * the user's and stays. Best-effort: a failure leaves a duplicate guidance, which
128
+ * is harmless.
129
+ */
130
+ function removeLegacyOpenCodeCompactPlugin(pluginDir) {
131
+ const legacyPath = path_1.default.join(pluginDir, exports.legacyOpenCodeCompactPluginFileName);
132
+ try {
133
+ const source = fs_1.default.readFileSync(legacyPath, 'utf-8');
134
+ if (!source.includes(JSON.stringify(exports.legacyOpenCodeCompactPluginId)))
135
+ return;
136
+ fs_1.default.unlinkSync(legacyPath);
137
+ }
138
+ catch {
139
+ return;
140
+ }
141
+ (0, legacyNames_1.warnLegacyNameOnce)('opencode-compact-plugin', `${(0, legacyNames_1.formatDeprecation)(legacyPath, path_1.default.join(pluginDir, exports.openCodeCompactPluginFileName))}; the old file was removed`);
142
+ }
113
143
  /**
114
144
  * @description Put the plugin into OpenCode's global plugin folder. Idempotent:
115
145
  * an identical file is left alone, a stale one is replaced atomically (a folder
116
146
  * instance being created concurrently never reads half a file). Any failure is
117
147
  * logged and returned — the plugin improves a summary, it must never block an
118
- * OpenCode start or the bot's boot.
148
+ * OpenCode start or the bot's boot. The file a pre-rename release installed is
149
+ * removed first.
119
150
  */
120
151
  function installOpenCodeCompactPlugin(pluginDir = resolveOpenCodeGlobalPluginDir(process.env)) {
152
+ removeLegacyOpenCodeCompactPlugin(pluginDir);
121
153
  const pluginPath = path_1.default.join(pluginDir, exports.openCodeCompactPluginFileName);
122
154
  const source = buildOpenCodeCompactPluginSource(getOpenCodeCompactPluginContext());
123
155
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"openCodeCompactPlugin.js","sourceRoot":"","sources":["../../src/utils/openCodeCompactPlugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;;;;;AAmBH,0EAEC;AAGD,4EAcC;AAGD,wEAGC;AAOD,sEAMC;AAcD,gEAWC;AAYD,oEAqBC;AAjHD,4CAAoB;AACpB,4CAAoB;AACpB,gDAAwB;AACxB,mDAA2D;AAE3D,4GAA4G;AAC/F,QAAA,6BAA6B,GAAG,4BAA4B,CAAC;AAE1E,uDAAuD;AAC1C,QAAA,uBAAuB,GAAG,yBAAyB,C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5C,CAAC;IACD,MAAM,OAAO,GAAG,GAAG,UAAU,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC;IACjE,IAAI,CAAC;QACH,YAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7C,YAAE,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAClC,YAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CAAC,iCAAiC,UAAU,GAAG,EAAE,CAAC,CAAC,CAAC;QAChE,IAAI,CAAC;YAAC,YAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,mBAAmB,CAAC,CAAC;QAC7D,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * @description The USAGE of OpenCode providers signed in through a SUBSCRIPTION — what `/limits` and `/accounts` print
3
+ * beside an OpenCode provider the way they print a Claude account's windows. v1 knows one provider: `openai` signed in
4
+ * with a ChatGPT subscription (an `oauth` record in OpenCode's `auth.json`), read off
5
+ * `GET https://chatgpt.com/backend-api/wham/usage` — the endpoint the Codex CLI and ChatGPT's own settings page use. It
6
+ * has no published schema; the field names below (`rate_limit.primary_window` / `secondary_window`, each with
7
+ * `used_percent`, `limit_window_seconds`, `reset_after_seconds`, `reset_at`) come from third-party documentation of it
8
+ * (the codex-lb proxy's API reference), so the parser is tolerant and an unknown shape yields no windows — the row just
9
+ * has no usage. API-key providers and other subscriptions have no reader: they show their auth kind only.
10
+ *
11
+ * Like a Claude profile's usage (`claudeUsage.ts`): the stored token is used as is and NEVER refreshed here (OpenCode
12
+ * renews it; a bot-side refresh would race it) — a token past its expiry is not sent and marks the snapshot stale; the
13
+ * token is never logged. Snapshots reuse the Claude shape (`ClaudeUsageSnapshot`: the primary window is `session`, the
14
+ * secondary `weekly_all`), so `formatClaudeProfileUsageLines` renders them unchanged. Pure except
15
+ * {@link readOpenCodeCredentials} (one file read) and the injectable fetch.
16
+ */
17
+ import { type ClaudeUsageBucket, type ClaudeUsageFetchResult, type ClaudeUsageSnapshot, type UsageFetchLike } from './claudeUsage';
18
+ export declare const chatGptUsageEndpoint = "https://chatgpt.com/backend-api/wham/usage";
19
+ /** The OpenCode provider a ChatGPT subscription signs in to. */
20
+ export declare const chatGptProviderId = "openai";
21
+ /** How a provider is signed in: through a subscription (`oauth`), an API key (`api`), or any other record. */
22
+ export type OpenCodeAuthKind = 'subscription' | 'apiKey' | 'unknown';
23
+ /**
24
+ * What `state.json` keeps per OpenCode provider (`openCodeProviderUsage`): how it is signed in, and for a subscription
25
+ * with a reader the last usage snapshot. Written by the poller only; a provider it does not list is never touched.
26
+ */
27
+ export interface OpenCodeProviderUsageRecord {
28
+ authKind: OpenCodeAuthKind;
29
+ usage?: ClaudeUsageSnapshot;
30
+ }
31
+ /**
32
+ * One provider's record in `auth.json`: its kind, and for a subscription the access token, its expiry and the account
33
+ * id. The token stays inside this object — nothing here logs or returns it other than to the reader that needs it.
34
+ */
35
+ export interface OpenCodeProviderCredential {
36
+ kind: OpenCodeAuthKind;
37
+ accessToken: string | null;
38
+ /** Epoch ms; `null` when the record carries none. */
39
+ expiresAtMs: number | null;
40
+ accountId: string | null;
41
+ }
42
+ /**
43
+ * @description The providers of a parsed `auth.json` with their credential kind; a malformed entry is skipped, never
44
+ * thrown on. `null` when the document is not an object.
45
+ */
46
+ export declare function parseOpenCodeCredentials(authJson: unknown): Record<string, OpenCodeProviderCredential> | null;
47
+ /** @description {@link parseOpenCodeCredentials} of the file at `authFilePath`; `null` when it is missing or unreadable. */
48
+ export declare function readOpenCodeCredentials(authFilePath: string): Record<string, OpenCodeProviderCredential> | null;
49
+ /**
50
+ * @description The windows of a ChatGPT usage response as Claude-shaped buckets. A window is the 5-hour `session` when
51
+ * its length (`limit_window_seconds`) is a day or less, else the weekly one; a window that names no length is read by
52
+ * its place (primary = 5-hour, secondary = weekly). An account with one window only (a weekly-only plan) yields that
53
+ * bucket. A body of another shape yields none.
54
+ */
55
+ export declare function parseChatGptUsageResponse(body: unknown, nowMs: number): ClaudeUsageBucket[];
56
+ /**
57
+ * @description One GET of the ChatGPT usage endpoint with the subscription's token and account id (the id off the record,
58
+ * else off the token). Never throws; the token never appears in the result.
59
+ */
60
+ export declare function fetchChatGptUsage(credential: OpenCodeProviderCredential, options?: {
61
+ fetchImpl?: UsageFetchLike;
62
+ timeoutMs?: number;
63
+ nowMs?: number;
64
+ }): Promise<ClaudeUsageFetchResult>;
65
+ /** A provider's subscription usage reader: one poll with the stored credential. */
66
+ export type OpenCodeUsageReader = (credential: OpenCodeProviderCredential) => Promise<ClaudeUsageFetchResult>;
67
+ /** The subscription usage readers by provider id; a provider not here shows only its auth kind. */
68
+ export declare const openCodeUsageReaders: Readonly<Record<string, OpenCodeUsageReader>>;
69
+ export interface OpenCodeUsagePollerDeps {
70
+ /** `auth.json` as parsed; `null` when it is missing or unreadable (nothing is touched then). */
71
+ readCredentials: () => Record<string, OpenCodeProviderCredential> | null;
72
+ getRecord: (providerId: string) => OpenCodeProviderUsageRecord | undefined;
73
+ saveRecord: (providerId: string, record: OpenCodeProviderUsageRecord) => void;
74
+ /** The reader of a provider's subscription usage; absent ⇒ none exists. Injectable so a test never reaches a network. */
75
+ readers?: Readonly<Record<string, OpenCodeUsageReader>>;
76
+ now?: () => number;
77
+ log?: (line: string) => void;
78
+ }
79
+ export interface OpenCodeUsagePoller {
80
+ /** Poll every provider `auth.json` lists; with `maxAgeMs`, only the subscriptions whose snapshot is older (or stale). */
81
+ refreshAll: (options?: {
82
+ maxAgeMs?: number;
83
+ }) => Promise<void>;
84
+ }
85
+ /**
86
+ * @description The poller of OpenCode providers' usage. For each provider in `auth.json`: an API key or an unknown record
87
+ * is stored as its kind alone (no usage); a subscription with a reader is polled — an expired token is not sent and marks
88
+ * the snapshot stale, a failed poll keeps the last figures marked stale. A provider `auth.json` does not list (one
89
+ * enabled by an environment variable) is left as it is. A failure is logged once per change of its reason — a poll every
90
+ * ten minutes must not fill the log — and never reported to error tracking (nothing for us to fix).
91
+ */
92
+ export declare function createOpenCodeUsagePoller(deps: OpenCodeUsagePollerDeps): OpenCodeUsagePoller;
93
+ //# sourceMappingURL=openCodeUsage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openCodeUsage.d.ts","sourceRoot":"","sources":["../../src/utils/openCodeUsage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAIL,KAAK,iBAAiB,EAEtB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AAEvB,eAAO,MAAM,oBAAoB,+CAA+C,CAAC;AAEjF,gEAAgE;AAChE,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,8GAA8G;AAC9G,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,QAAQ,GAAG,SAAS,CAAC;AAErE;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,CAAC,EAAE,mBAAmB,CAAC;CAC7B;AAKD;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,gBAAgB,CAAC;IACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,qDAAqD;IACrD,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAYD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,GAAG,IAAI,CAa7G;AAED,4HAA4H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zH,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChE;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,uBAAuB,GAAG,mBAAmB,CAsD5F"}
@@ -0,0 +1,248 @@
1
+ "use strict";
2
+ /**
3
+ * @description The USAGE of OpenCode providers signed in through a SUBSCRIPTION — what `/limits` and `/accounts` print
4
+ * beside an OpenCode provider the way they print a Claude account's windows. v1 knows one provider: `openai` signed in
5
+ * with a ChatGPT subscription (an `oauth` record in OpenCode's `auth.json`), read off
6
+ * `GET https://chatgpt.com/backend-api/wham/usage` — the endpoint the Codex CLI and ChatGPT's own settings page use. It
7
+ * has no published schema; the field names below (`rate_limit.primary_window` / `secondary_window`, each with
8
+ * `used_percent`, `limit_window_seconds`, `reset_after_seconds`, `reset_at`) come from third-party documentation of it
9
+ * (the codex-lb proxy's API reference), so the parser is tolerant and an unknown shape yields no windows — the row just
10
+ * has no usage. API-key providers and other subscriptions have no reader: they show their auth kind only.
11
+ *
12
+ * Like a Claude profile's usage (`claudeUsage.ts`): the stored token is used as is and NEVER refreshed here (OpenCode
13
+ * renews it; a bot-side refresh would race it) — a token past its expiry is not sent and marks the snapshot stale; the
14
+ * token is never logged. Snapshots reuse the Claude shape (`ClaudeUsageSnapshot`: the primary window is `session`, the
15
+ * secondary `weekly_all`), so `formatClaudeProfileUsageLines` renders them unchanged. Pure except
16
+ * {@link readOpenCodeCredentials} (one file read) and the injectable fetch.
17
+ */
18
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ var desc = Object.getOwnPropertyDescriptor(m, k);
21
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
22
+ desc = { enumerable: true, get: function() { return m[k]; } };
23
+ }
24
+ Object.defineProperty(o, k2, desc);
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
30
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
31
+ }) : function(o, v) {
32
+ o["default"] = v;
33
+ });
34
+ var __importStar = (this && this.__importStar) || (function () {
35
+ var ownKeys = function(o) {
36
+ ownKeys = Object.getOwnPropertyNames || function (o) {
37
+ var ar = [];
38
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
39
+ return ar;
40
+ };
41
+ return ownKeys(o);
42
+ };
43
+ return function (mod) {
44
+ if (mod && mod.__esModule) return mod;
45
+ var result = {};
46
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
47
+ __setModuleDefault(result, mod);
48
+ return result;
49
+ };
50
+ })();
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.openCodeUsageReaders = exports.chatGptProviderId = exports.chatGptUsageEndpoint = void 0;
53
+ exports.parseOpenCodeCredentials = parseOpenCodeCredentials;
54
+ exports.readOpenCodeCredentials = readOpenCodeCredentials;
55
+ exports.parseChatGptUsageResponse = parseChatGptUsageResponse;
56
+ exports.fetchChatGptUsage = fetchChatGptUsage;
57
+ exports.createOpenCodeUsagePoller = createOpenCodeUsagePoller;
58
+ const fs = __importStar(require("fs"));
59
+ const claudeUsage_1 = require("./claudeUsage");
60
+ exports.chatGptUsageEndpoint = 'https://chatgpt.com/backend-api/wham/usage';
61
+ /** The OpenCode provider a ChatGPT subscription signs in to. */
62
+ exports.chatGptProviderId = 'openai';
63
+ /** A window up to this long counts as the short (5-hour) one, a longer window as the weekly one. */
64
+ const shortWindowMaxSeconds = 24 * 3600;
65
+ function checkIsRecord(value) {
66
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
67
+ }
68
+ function readAuthKind(type) {
69
+ if (type === 'oauth')
70
+ return 'subscription';
71
+ if (type === 'api')
72
+ return 'apiKey';
73
+ return 'unknown';
74
+ }
75
+ /**
76
+ * @description The providers of a parsed `auth.json` with their credential kind; a malformed entry is skipped, never
77
+ * thrown on. `null` when the document is not an object.
78
+ */
79
+ function parseOpenCodeCredentials(authJson) {
80
+ if (!checkIsRecord(authJson))
81
+ return null;
82
+ const credentials = {};
83
+ for (const [providerId, entry] of Object.entries(authJson)) {
84
+ if (!checkIsRecord(entry))
85
+ continue;
86
+ credentials[providerId] = {
87
+ kind: readAuthKind(entry.type),
88
+ accessToken: typeof entry.access === 'string' && entry.access !== '' ? entry.access : null,
89
+ expiresAtMs: typeof entry.expires === 'number' ? entry.expires : null,
90
+ accountId: typeof entry.accountId === 'string' && entry.accountId !== '' ? entry.accountId : null,
91
+ };
92
+ }
93
+ return credentials;
94
+ }
95
+ /** @description {@link parseOpenCodeCredentials} of the file at `authFilePath`; `null` when it is missing or unreadable. */
96
+ function readOpenCodeCredentials(authFilePath) {
97
+ try {
98
+ return parseOpenCodeCredentials(JSON.parse(fs.readFileSync(authFilePath, 'utf8')));
99
+ }
100
+ catch {
101
+ return null;
102
+ }
103
+ }
104
+ // ── the ChatGPT reader ──
105
+ /** The account id inside a ChatGPT access token (a JWT): the claim `chatgpt_account_id` under `https://api.openai.com/auth`. */
106
+ function readAccountIdFromJwt(accessToken) {
107
+ const payload = accessToken.split('.')[1];
108
+ if (payload === undefined)
109
+ return null;
110
+ try {
111
+ const claims = JSON.parse(Buffer.from(payload, 'base64url').toString('utf8'));
112
+ const auth = checkIsRecord(claims) ? claims['https://api.openai.com/auth'] : null;
113
+ return checkIsRecord(auth) && typeof auth.chatgpt_account_id === 'string' ? auth.chatgpt_account_id : null;
114
+ }
115
+ catch {
116
+ return null;
117
+ }
118
+ }
119
+ function clampPercent(value) {
120
+ return Math.max(0, Math.min(100, Math.round(value)));
121
+ }
122
+ /** A window's reset as an ISO instant: its own `reset_at` (Unix seconds), else `reset_after_seconds` from now. */
123
+ function readResetsAt(window, nowMs) {
124
+ if (typeof window.reset_at === 'number')
125
+ return new Date(window.reset_at * 1000).toISOString();
126
+ if (typeof window.reset_after_seconds === 'number')
127
+ return new Date(nowMs + window.reset_after_seconds * 1000).toISOString();
128
+ return null;
129
+ }
130
+ /**
131
+ * @description The windows of a ChatGPT usage response as Claude-shaped buckets. A window is the 5-hour `session` when
132
+ * its length (`limit_window_seconds`) is a day or less, else the weekly one; a window that names no length is read by
133
+ * its place (primary = 5-hour, secondary = weekly). An account with one window only (a weekly-only plan) yields that
134
+ * bucket. A body of another shape yields none.
135
+ */
136
+ function parseChatGptUsageResponse(body, nowMs) {
137
+ const rateLimit = checkIsRecord(body) ? body.rate_limit : null;
138
+ if (!checkIsRecord(rateLimit))
139
+ return [];
140
+ const buckets = [];
141
+ for (const [field, placeKind] of [['primary_window', 'session'], ['secondary_window', 'weekly_all']]) {
142
+ const window = rateLimit[field];
143
+ if (!checkIsRecord(window) || typeof window.used_percent !== 'number')
144
+ continue;
145
+ const length = window.limit_window_seconds;
146
+ const kind = typeof length === 'number' ? (length <= shortWindowMaxSeconds ? 'session' : 'weekly_all') : placeKind;
147
+ if (buckets.some((bucket) => bucket.kind === kind))
148
+ continue;
149
+ buckets.push({ kind, percent: clampPercent(window.used_percent), resetsAt: readResetsAt(window, nowMs), scopeModel: null });
150
+ }
151
+ return buckets;
152
+ }
153
+ /**
154
+ * @description One GET of the ChatGPT usage endpoint with the subscription's token and account id (the id off the record,
155
+ * else off the token). Never throws; the token never appears in the result.
156
+ */
157
+ function fetchChatGptUsage(credential, options = {}) {
158
+ const accessToken = credential.accessToken ?? '';
159
+ const accountId = credential.accountId ?? readAccountIdFromJwt(accessToken);
160
+ const nowMs = options.nowMs ?? Date.now();
161
+ return (0, claudeUsage_1.fetchUsageBuckets)({
162
+ url: exports.chatGptUsageEndpoint,
163
+ headers: {
164
+ Authorization: `Bearer ${accessToken}`,
165
+ Accept: 'application/json',
166
+ ...(accountId === null ? {} : { 'ChatGPT-Account-Id': accountId }),
167
+ },
168
+ parse: (body) => parseChatGptUsageResponse(body, nowMs),
169
+ fetchImpl: options.fetchImpl,
170
+ timeoutMs: options.timeoutMs,
171
+ });
172
+ }
173
+ /** The subscription usage readers by provider id; a provider not here shows only its auth kind. */
174
+ exports.openCodeUsageReaders = {
175
+ [exports.chatGptProviderId]: (credential) => fetchChatGptUsage(credential),
176
+ };
177
+ /**
178
+ * @description The poller of OpenCode providers' usage. For each provider in `auth.json`: an API key or an unknown record
179
+ * is stored as its kind alone (no usage); a subscription with a reader is polled — an expired token is not sent and marks
180
+ * the snapshot stale, a failed poll keeps the last figures marked stale. A provider `auth.json` does not list (one
181
+ * enabled by an environment variable) is left as it is. A failure is logged once per change of its reason — a poll every
182
+ * ten minutes must not fill the log — and never reported to error tracking (nothing for us to fix).
183
+ */
184
+ function createOpenCodeUsagePoller(deps) {
185
+ const now = deps.now ?? (() => Date.now());
186
+ const log = deps.log ?? ((line) => console.log(line));
187
+ const readers = deps.readers ?? exports.openCodeUsageReaders;
188
+ function saveIfChanged(providerId, previous, next) {
189
+ if (JSON.stringify(previous) !== JSON.stringify(next))
190
+ deps.saveRecord(providerId, next);
191
+ }
192
+ function logFailureOnce(providerId, previous, reason) {
193
+ if (previous?.usage?.isStale && previous.usage.error === reason)
194
+ return;
195
+ log(`[usage] OpenCode ${providerId}: usage unavailable (${reason})`);
196
+ }
197
+ async function pollSubscription(providerId, credential, previous) {
198
+ const reader = readers[providerId];
199
+ if (reader === undefined) {
200
+ saveIfChanged(providerId, previous, { authKind: 'subscription' });
201
+ return;
202
+ }
203
+ const markStale = (reason) => {
204
+ logFailureOnce(providerId, previous, reason);
205
+ saveIfChanged(providerId, previous, { authKind: 'subscription', usage: (0, claudeUsage_1.markClaudeUsageSnapshotStale)(previous?.usage, reason, now()) });
206
+ };
207
+ if (credential.accessToken === null) {
208
+ markStale('not signed in');
209
+ return;
210
+ }
211
+ if (credential.expiresAtMs !== null && credential.expiresAtMs <= now()) {
212
+ markStale('token expired');
213
+ return;
214
+ }
215
+ const result = await reader(credential);
216
+ if (!result.ok) {
217
+ markStale(result.error);
218
+ return;
219
+ }
220
+ deps.saveRecord(providerId, { authKind: 'subscription', usage: (0, claudeUsage_1.mergeClaudeUsageSnapshot)(previous?.usage, result.buckets, 'api', now()) });
221
+ }
222
+ function checkNeedsPoll(previous, maxAgeMs) {
223
+ if (maxAgeMs === undefined || !previous?.usage || previous.usage.isStale)
224
+ return true;
225
+ return now() - Date.parse(previous.usage.fetchedAt) >= maxAgeMs;
226
+ }
227
+ async function refreshAll(options = {}) {
228
+ const credentials = deps.readCredentials();
229
+ if (credentials === null)
230
+ return;
231
+ await Promise.all(Object.entries(credentials).map(async ([providerId, credential]) => {
232
+ const previous = deps.getRecord(providerId);
233
+ try {
234
+ if (credential.kind !== 'subscription') {
235
+ saveIfChanged(providerId, previous, { authKind: credential.kind });
236
+ }
237
+ else if (checkNeedsPoll(previous, options.maxAgeMs)) {
238
+ await pollSubscription(providerId, credential, previous);
239
+ }
240
+ }
241
+ catch (e) {
242
+ log(`[usage] OpenCode ${providerId}: usage poll threw: ${e instanceof Error ? e.message : String(e)}`);
243
+ }
244
+ }));
245
+ }
246
+ return { refreshAll };
247
+ }
248
+ //# sourceMappingURL=openCodeUsage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openCodeUsage.js","sourceRoot":"","sources":["../../src/utils/openCodeUsage.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DH,4DAaC;AAGD,0DAMC;AAkCD,8DAaC;AAMD,8CAkBC;AAmCD,8DAsDC;AAhPD,uCAAyB;AACzB,+CASuB;AAEV,QAAA,oBAAoB,GAAG,4CAA4C,CAAC;AAEjF,gEAAgE;AACnD,QAAA,iBAAiB,GAAG,QAAQ,CAAC;AAc1C,oGAAoG;AACpG,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,CAA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,GAAG,CAAC,KAAK,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE;YACnF,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YAC5C,IAAI,CAAC;gBACH,IAAI,UAAU,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;oBACvC,aAAa,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;gBACrE,CAAC;qBAAM,IAAI,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACtD,MAAM,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;gBAC3D,CAAC;YACH,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,GAAG,CAAC,oBAAoB,UAAU,uBAAuB,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACzG,CAAC;QACH,CAAC,CAAC,CAAC,CAAC;IACN,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @description The pure decision behind the ONE switch path the operator's own picks share — a row of `/limits` or
3
+ * `/accounts`, a model page, `/accounts use`: given where the topic runs and where it was told to go, WHICH kind of
4
+ * move it is. `bot.ts` (`switchTopicByOperator`) makes the move; the screens only ask for it and word their toast
5
+ * from the outcome.
6
+ */
7
+ import type { FallbackChainEntry } from './fallbackChain';
8
+ import type { BackendFamily } from './backendSwitchPlan';
9
+ /**
10
+ * How the topic gets to the picked rung:
11
+ * - `limitMove` — a usage-limit wait is armed: the pick is the limit move (the wait is dropped, the work continues,
12
+ * a conversation is handed over without the question);
13
+ * - `sameFamily` — the topic stays on the backend it runs (or has none, and a Claude account is only recorded for
14
+ * its next start): a Claude pick changes the account, an OpenCode pick the model — the conversation is kept;
15
+ * - `askFirst` — the other backend, with a conversation to hand over: the operator is asked first;
16
+ * - `switchNow` — the other backend with nothing to carry (or no agent yet): the target is started at once.
17
+ */
18
+ export type OperatorSwitchRoute = 'limitMove' | 'sameFamily' | 'askFirst' | 'switchNow';
19
+ /**
20
+ * What a screen is told about a pick. `switched` carries the bot's own confirmation line (`text`) and where the topic runs now
21
+ * in words (`label`: `Claude «work» (sonnet)`, `OpenCode openai/gpt-5`), from which a screen words its short toast; `asked` means
22
+ * the hand-over question is already in the topic and nothing more is to be said; `refused` carries why nothing moved.
23
+ */
24
+ export type OperatorSwitchOutcome = {
25
+ kind: 'switched';
26
+ text: string;
27
+ label: string;
28
+ } | {
29
+ kind: 'asked';
30
+ } | {
31
+ kind: 'refused';
32
+ text: string;
33
+ };
34
+ export interface OperatorSwitchInput {
35
+ /** A usage-limit wait is armed for the topic. */
36
+ isUsageLimitWaitArmed: boolean;
37
+ /** The rung the topic runs on now; `null` for no agent, a shell, or an OpenCode on the server's default model. */
38
+ from: FallbackChainEntry | null;
39
+ to: FallbackChainEntry;
40
+ /** The backend family the topic's agent runs on; `null` for no agent or a shell. */
41
+ currentFamily: BackendFamily | null;
42
+ /** Whether the agent being left holds a conversation to hand over (only read when the families differ). */
43
+ hasConversation: boolean;
44
+ /**
45
+ * The pick names another model of the SAME Claude account and that model is clear of the exhausted window (a Fable-only
46
+ * weekly limit does not stop `sonnet`): the work can continue on it, so with a wait armed the pick is the limit move.
47
+ */
48
+ isPickBeyondLimit?: boolean;
49
+ }
50
+ /**
51
+ * @description The route of a pick, in this order:
52
+ * 1. a wait is armed and the pick leaves the account (Claude) / model (OpenCode) that hit the limit, or names a model of the
53
+ * same Claude account that the limit does not cover → `limitMove`; a pick still inside the limit's scope (another model
54
+ * under the same exhausted window) only changes the model and the wait stays;
55
+ * 2. the topic runs no agent of a family (nothing, a shell): a Claude pick is recorded for the next start
56
+ * (`sameFamily`), an OpenCode pick starts OpenCode on it (`switchNow`);
57
+ * 3. the topic runs the picked family → `sameFamily`;
58
+ * 4. otherwise the other backend: `askFirst` with a conversation, `switchNow` without.
59
+ */
60
+ export declare function decideOperatorSwitch(input: OperatorSwitchInput): OperatorSwitchRoute;
61
+ //# sourceMappingURL=operatorSwitchPlan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operatorSwitchPlan.d.ts","sourceRoot":"","sources":["../../src/utils/operatorSwitchPlan.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,CAAC;AAExF;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC,MAAM,WAAW,mBAAmB;IAClC,iDAAiD;IACjD,qBAAqB,EAAE,OAAO,CAAC;IAC/B,kHAAkH;IAClH,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAChC,EAAE,EAAE,kBAAkB,CAAC;IACvB,oFAAoF;IACpF,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,2GAA2G;IAC3G,eAAe,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CAOpF"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ /**
3
+ * @description The pure decision behind the ONE switch path the operator's own picks share — a row of `/limits` or
4
+ * `/accounts`, a model page, `/accounts use`: given where the topic runs and where it was told to go, WHICH kind of
5
+ * move it is. `bot.ts` (`switchTopicByOperator`) makes the move; the screens only ask for it and word their toast
6
+ * from the outcome.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.decideOperatorSwitch = decideOperatorSwitch;
10
+ const fallbackChain_1 = require("./fallbackChain");
11
+ /**
12
+ * @description The route of a pick, in this order:
13
+ * 1. a wait is armed and the pick leaves the account (Claude) / model (OpenCode) that hit the limit, or names a model of the
14
+ * same Claude account that the limit does not cover → `limitMove`; a pick still inside the limit's scope (another model
15
+ * under the same exhausted window) only changes the model and the wait stays;
16
+ * 2. the topic runs no agent of a family (nothing, a shell): a Claude pick is recorded for the next start
17
+ * (`sameFamily`), an OpenCode pick starts OpenCode on it (`switchNow`);
18
+ * 3. the topic runs the picked family → `sameFamily`;
19
+ * 4. otherwise the other backend: `askFirst` with a conversation, `switchNow` without.
20
+ */
21
+ function decideOperatorSwitch(input) {
22
+ const { from, to, currentFamily } = input;
23
+ const isLeavingLimitedRung = from === null || !(0, fallbackChain_1.checkIsSameFallbackAccount)(from, to);
24
+ if (input.isUsageLimitWaitArmed && currentFamily !== null && (isLeavingLimitedRung || input.isPickBeyondLimit === true))
25
+ return 'limitMove';
26
+ if (currentFamily === null)
27
+ return to.backend === 'claude' ? 'sameFamily' : 'switchNow';
28
+ if (currentFamily === to.backend)
29
+ return 'sameFamily';
30
+ return input.hasConversation ? 'askFirst' : 'switchNow';
31
+ }
32
+ //# sourceMappingURL=operatorSwitchPlan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operatorSwitchPlan.js","sourceRoot":"","sources":["../../src/utils/operatorSwitchPlan.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAsDH,oDAOC;AA1DD,mDAA6D;AAyC7D;;;;;;;;;GASG;AACH,SAAgB,oBAAoB,CAAC,KAA0B;IAC7D,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IAC1C,MAAM,oBAAoB,GAAG,IAAI,KAAK,IAAI,IAAI,CAAC,IAAA,0CAA0B,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACpF,IAAI,KAAK,CAAC,qBAAqB,IAAI,aAAa,KAAK,IAAI,IAAI,CAAC,oBAAoB,IAAI,KAAK,CAAC,iBAAiB,KAAK,IAAI,CAAC;QAAE,OAAO,WAAW,CAAC;IAC5I,IAAI,aAAa,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC;IACxF,IAAI,aAAa,KAAK,EAAE,CAAC,OAAO;QAAE,OAAO,YAAY,CAAC;IACtD,OAAO,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;AAC1D,CAAC"}
@@ -43,4 +43,44 @@ export type PromptDelivery = 'forwarded' | 'buffered';
43
43
  * buffered before the notice went out.
44
44
  */
45
45
  export declare function deliverPromptOrBuffer(deps: PromptDeliveryDeps, key: SessionKey, text: string, isStarting: boolean, onBufferedSettled?: BufferedPromptSettled): Promise<PromptDelivery>;
46
+ /**
47
+ * @name LatePromptRoute
48
+ * @description How a prompt decided on when it ARRIVED is delivered once its handler is ready to forward it:
49
+ * `buffer` — a start or the idle stop is under way (its window is open: the prompt waits there, and the stop resumes the
50
+ * session for it); `wake` — the process is gone meanwhile (the conversation sleeps: wake it, then forward); `forward`.
51
+ */
52
+ export type LatePromptRoute = 'buffer' | 'wake' | 'forward';
53
+ /**
54
+ * @description The {@link LatePromptRoute} of a prompt, read at the moment it is forwarded. The idle stop posts a
55
+ * re-asked question just before it stops the process, and a handler awaits between reading the session's state and the
56
+ * forward (the tap's toast, the request it opens): written into a process being stopped the prompt was lost, and
57
+ * into one already gone it was dropped.
58
+ */
59
+ export declare function getLatePromptRoute(input: {
60
+ isWindowOpen: boolean;
61
+ isSessionActive: boolean;
62
+ }): LatePromptRoute;
63
+ /**
64
+ * @name LatePromptDeliveryPorts
65
+ * @description What {@link deliverLatePrompt} acts through, for one prompt: the session's state read NOW, and the three
66
+ * ways out. `reportNoSession` runs when the wake found nothing to resume (the ids released, the topic unbound, a start
67
+ * that failed): it tells the person, as the arrival-time paths do, and closes what the prompt opened.
68
+ */
69
+ export interface LatePromptDeliveryPorts {
70
+ checkIsWindowOpen: () => boolean;
71
+ checkIsSessionActive: () => boolean;
72
+ buffer: () => Promise<void>;
73
+ /** Resume the sleeping conversation; `true` once a session is up to forward to. */
74
+ wake: () => Promise<boolean>;
75
+ forward: () => Promise<void>;
76
+ reportNoSession: () => Promise<void>;
77
+ }
78
+ /** @description Where {@link deliverLatePrompt} put the prompt; `noSession` — nowhere: nothing to deliver it to. */
79
+ export type LatePromptOutcome = 'buffered' | 'forwarded' | 'noSession';
80
+ /**
81
+ * @description Deliver a prompt whose handler decided, when it arrived, that the session is live — routed again by
82
+ * {@link getLatePromptRoute} now, after the handler's awaits. A wake that finds nothing never forwards: the forward
83
+ * would show the topic as working while the adapter drops the text.
84
+ */
85
+ export declare function deliverLatePrompt(ports: LatePromptDeliveryPorts): Promise<LatePromptOutcome>;
46
86
  //# sourceMappingURL=promptDelivery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"promptDelivery.d.ts","sourceRoot":"","sources":["../../src/utils/promptDelivery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAEzF;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,IAAI,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;IACtD,aAAa,EAAE,CAA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