charness 4.1.1 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (643) hide show
  1. package/CHANGELOG.md +186 -2
  2. package/DEVELOPMENT.md +65 -11
  3. package/LICENSE +331 -151
  4. package/MIGRATION_3_TO_4.md +8 -5
  5. package/README.md +23 -8
  6. package/SETUP.md +57 -11
  7. package/agent-plugin/README.md +10 -3
  8. package/agent-plugin/skills/charness-delegate-claude/SKILL.md +18 -26
  9. package/agent-plugin/skills/charness-delegate-opencode/SKILL.md +5 -3
  10. package/agent-plugin/skills/charness-orchestration/SKILL.md +57 -16
  11. package/dist/adapters/adapterNames.d.ts +2 -0
  12. package/dist/adapters/adapterNames.d.ts.map +1 -1
  13. package/dist/adapters/adapterNames.js +3 -1
  14. package/dist/adapters/adapterNames.js.map +1 -1
  15. package/dist/adapters/claudeCliAdapter.d.ts +4 -0
  16. package/dist/adapters/claudeCliAdapter.d.ts.map +1 -1
  17. package/dist/adapters/claudeCliAdapter.js +13 -0
  18. package/dist/adapters/claudeCliAdapter.js.map +1 -1
  19. package/dist/adapters/claudeJsonStreamAdapter.d.ts +150 -10
  20. package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -1
  21. package/dist/adapters/claudeJsonStreamAdapter.js +401 -83
  22. package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
  23. package/dist/adapters/createAdapter.d.ts +12 -3
  24. package/dist/adapters/createAdapter.d.ts.map +1 -1
  25. package/dist/adapters/createAdapter.js +39 -13
  26. package/dist/adapters/createAdapter.js.map +1 -1
  27. package/dist/adapters/openCodeAdapter.d.ts +65 -2
  28. package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
  29. package/dist/adapters/openCodeAdapter.js +202 -19
  30. package/dist/adapters/openCodeAdapter.js.map +1 -1
  31. package/dist/adapters/terminalAdapter.d.ts.map +1 -1
  32. package/dist/adapters/terminalAdapter.js +2 -1
  33. package/dist/adapters/terminalAdapter.js.map +1 -1
  34. package/dist/apiErrorRetry.d.ts +11 -3
  35. package/dist/apiErrorRetry.d.ts.map +1 -1
  36. package/dist/apiErrorRetry.js +33 -3
  37. package/dist/apiErrorRetry.js.map +1 -1
  38. package/dist/apiRetryKick.d.ts +3 -2
  39. package/dist/apiRetryKick.d.ts.map +1 -1
  40. package/dist/apiRetryKick.js +13 -5
  41. package/dist/apiRetryKick.js.map +1 -1
  42. package/dist/bot.d.ts +2 -6
  43. package/dist/bot.d.ts.map +1 -1
  44. package/dist/bot.js +2586 -693
  45. package/dist/bot.js.map +1 -1
  46. package/dist/cli/claudeProfiles.d.ts +31 -6
  47. package/dist/cli/claudeProfiles.d.ts.map +1 -1
  48. package/dist/cli/claudeProfiles.js +97 -22
  49. package/dist/cli/claudeProfiles.js.map +1 -1
  50. package/dist/cli.d.ts.map +1 -1
  51. package/dist/cli.js +2 -1
  52. package/dist/cli.js.map +1 -1
  53. package/dist/connectors/jira/answerSink.d.ts +102 -7
  54. package/dist/connectors/jira/answerSink.d.ts.map +1 -1
  55. package/dist/connectors/jira/answerSink.js +364 -60
  56. package/dist/connectors/jira/answerSink.js.map +1 -1
  57. package/dist/connectors/jira/answerThreads.d.ts +44 -0
  58. package/dist/connectors/jira/answerThreads.d.ts.map +1 -0
  59. package/dist/connectors/jira/answerThreads.js +85 -0
  60. package/dist/connectors/jira/answerThreads.js.map +1 -0
  61. package/dist/connectors/jira/client.d.ts +67 -2
  62. package/dist/connectors/jira/client.d.ts.map +1 -1
  63. package/dist/connectors/jira/client.js +176 -4
  64. package/dist/connectors/jira/client.js.map +1 -1
  65. package/dist/connectors/jira/config.d.ts +6 -0
  66. package/dist/connectors/jira/config.d.ts.map +1 -1
  67. package/dist/connectors/jira/config.js +14 -1
  68. package/dist/connectors/jira/config.js.map +1 -1
  69. package/dist/connectors/jira/connector.d.ts +19 -0
  70. package/dist/connectors/jira/connector.d.ts.map +1 -1
  71. package/dist/connectors/jira/connector.js +68 -6
  72. package/dist/connectors/jira/connector.js.map +1 -1
  73. package/dist/connectors/jira/contextPreamble.d.ts.map +1 -1
  74. package/dist/connectors/jira/contextPreamble.js +6 -1
  75. package/dist/connectors/jira/contextPreamble.js.map +1 -1
  76. package/dist/connectors/jira/inbound.d.ts +21 -6
  77. package/dist/connectors/jira/inbound.d.ts.map +1 -1
  78. package/dist/connectors/jira/inbound.js +22 -16
  79. package/dist/connectors/jira/inbound.js.map +1 -1
  80. package/dist/connectors/jira/issueBlocks.d.ts +8 -1
  81. package/dist/connectors/jira/issueBlocks.d.ts.map +1 -1
  82. package/dist/connectors/jira/issueBlocks.js +38 -2
  83. package/dist/connectors/jira/issueBlocks.js.map +1 -1
  84. package/dist/connectors/jira/operatorIssue.d.ts +28 -0
  85. package/dist/connectors/jira/operatorIssue.d.ts.map +1 -0
  86. package/dist/connectors/jira/operatorIssue.js +81 -0
  87. package/dist/connectors/jira/operatorIssue.js.map +1 -0
  88. package/dist/connectors/jira/outbound.d.ts +8 -4
  89. package/dist/connectors/jira/outbound.d.ts.map +1 -1
  90. package/dist/connectors/jira/outbound.js +16 -8
  91. package/dist/connectors/jira/outbound.js.map +1 -1
  92. package/dist/connectors/jira/outgoingFileCheck.d.ts +37 -0
  93. package/dist/connectors/jira/outgoingFileCheck.d.ts.map +1 -0
  94. package/dist/connectors/jira/outgoingFileCheck.js +279 -0
  95. package/dist/connectors/jira/outgoingFileCheck.js.map +1 -0
  96. package/dist/connectors/jira/outgoingFiles.d.ts +81 -0
  97. package/dist/connectors/jira/outgoingFiles.d.ts.map +1 -0
  98. package/dist/connectors/jira/outgoingFiles.js +268 -0
  99. package/dist/connectors/jira/outgoingFiles.js.map +1 -0
  100. package/dist/connectors/jira/progressComments.d.ts +69 -0
  101. package/dist/connectors/jira/progressComments.d.ts.map +1 -0
  102. package/dist/connectors/jira/progressComments.js +136 -0
  103. package/dist/connectors/jira/progressComments.js.map +1 -0
  104. package/dist/connectors/jira/prompt.d.ts +5 -1
  105. package/dist/connectors/jira/prompt.d.ts.map +1 -1
  106. package/dist/connectors/jira/prompt.js +23 -3
  107. package/dist/connectors/jira/prompt.js.map +1 -1
  108. package/dist/connectors/jira/promptSpill.js +1 -1
  109. package/dist/connectors/jira/promptSpill.js.map +1 -1
  110. package/dist/connectors/jira/trigger.d.ts +13 -5
  111. package/dist/connectors/jira/trigger.d.ts.map +1 -1
  112. package/dist/connectors/jira/trigger.js +13 -7
  113. package/dist/connectors/jira/trigger.js.map +1 -1
  114. package/dist/connectors/jira/uploadedFiles.d.ts +48 -0
  115. package/dist/connectors/jira/uploadedFiles.d.ts.map +1 -0
  116. package/dist/connectors/jira/uploadedFiles.js +123 -0
  117. package/dist/connectors/jira/uploadedFiles.js.map +1 -0
  118. package/dist/connectors/telegram/commands/backendSwitch.d.ts +9 -1
  119. package/dist/connectors/telegram/commands/backendSwitch.d.ts.map +1 -1
  120. package/dist/connectors/telegram/commands/backendSwitch.js +17 -8
  121. package/dist/connectors/telegram/commands/backendSwitch.js.map +1 -1
  122. package/dist/connectors/telegram/commands/botCore.d.ts +5 -2
  123. package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -1
  124. package/dist/connectors/telegram/commands/botSkills.d.ts +2 -0
  125. package/dist/connectors/telegram/commands/botSkills.d.ts.map +1 -1
  126. package/dist/connectors/telegram/commands/botSkills.js +17 -2
  127. package/dist/connectors/telegram/commands/botSkills.js.map +1 -1
  128. package/dist/connectors/telegram/commands/claudeAccounts.d.ts +11 -0
  129. package/dist/connectors/telegram/commands/claudeAccounts.d.ts.map +1 -1
  130. package/dist/connectors/telegram/commands/claudeAccounts.js +36 -42
  131. package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
  132. package/dist/connectors/telegram/commands/compaction.d.ts +20 -3
  133. package/dist/connectors/telegram/commands/compaction.d.ts.map +1 -1
  134. package/dist/connectors/telegram/commands/compaction.js +268 -96
  135. package/dist/connectors/telegram/commands/compaction.js.map +1 -1
  136. package/dist/connectors/telegram/commands/limitReminders.d.ts +21 -0
  137. package/dist/connectors/telegram/commands/limitReminders.d.ts.map +1 -0
  138. package/dist/connectors/telegram/commands/limitReminders.js +95 -0
  139. package/dist/connectors/telegram/commands/limitReminders.js.map +1 -0
  140. package/dist/connectors/telegram/commands/limitsBoard.d.ts +4 -0
  141. package/dist/connectors/telegram/commands/limitsBoard.d.ts.map +1 -1
  142. package/dist/connectors/telegram/commands/limitsBoard.js +27 -6
  143. package/dist/connectors/telegram/commands/limitsBoard.js.map +1 -1
  144. package/dist/connectors/telegram/commands/modelProviders.d.ts +2 -2
  145. package/dist/connectors/telegram/commands/modelProviders.d.ts.map +1 -1
  146. package/dist/connectors/telegram/commands/modelProviders.js +27 -16
  147. package/dist/connectors/telegram/commands/modelProviders.js.map +1 -1
  148. package/dist/connectors/telegram/commands/questionSetAside.d.ts +111 -0
  149. package/dist/connectors/telegram/commands/questionSetAside.d.ts.map +1 -0
  150. package/dist/connectors/telegram/commands/questionSetAside.js +637 -0
  151. package/dist/connectors/telegram/commands/questionSetAside.js.map +1 -0
  152. package/dist/connectors/telegram/commands/questionWait.d.ts +21 -0
  153. package/dist/connectors/telegram/commands/questionWait.d.ts.map +1 -0
  154. package/dist/connectors/telegram/commands/questionWait.js +109 -0
  155. package/dist/connectors/telegram/commands/questionWait.js.map +1 -0
  156. package/dist/connectors/telegram/commands/topicAccess.js +1 -1
  157. package/dist/connectors/telegram/commands/topicAccess.js.map +1 -1
  158. package/dist/connectors/telegram/commands/topicCommand.d.ts +0 -2
  159. package/dist/connectors/telegram/commands/topicCommand.d.ts.map +1 -1
  160. package/dist/connectors/telegram/commands/topicCommand.js +11 -7
  161. package/dist/connectors/telegram/commands/topicCommand.js.map +1 -1
  162. package/dist/connectors/telegram/commands/topicStatus.d.ts +24 -0
  163. package/dist/connectors/telegram/commands/topicStatus.d.ts.map +1 -0
  164. package/dist/connectors/telegram/commands/topicStatus.js +148 -0
  165. package/dist/connectors/telegram/commands/topicStatus.js.map +1 -0
  166. package/dist/connectors/telegram/commands/workerRoles.d.ts +25 -0
  167. package/dist/connectors/telegram/commands/workerRoles.d.ts.map +1 -0
  168. package/dist/connectors/telegram/commands/workerRoles.js +259 -0
  169. package/dist/connectors/telegram/commands/workerRoles.js.map +1 -0
  170. package/dist/connectors/telegram/firstUpdateBatchNote.d.ts +30 -0
  171. package/dist/connectors/telegram/firstUpdateBatchNote.d.ts.map +1 -0
  172. package/dist/connectors/telegram/firstUpdateBatchNote.js +39 -0
  173. package/dist/connectors/telegram/firstUpdateBatchNote.js.map +1 -0
  174. package/dist/connectors/telegram/groupWelcome.d.ts +12 -0
  175. package/dist/connectors/telegram/groupWelcome.d.ts.map +1 -0
  176. package/dist/connectors/telegram/groupWelcome.js +12 -0
  177. package/dist/connectors/telegram/groupWelcome.js.map +1 -0
  178. package/dist/connectors/telegram/inbound.d.ts +19 -0
  179. package/dist/connectors/telegram/inbound.d.ts.map +1 -1
  180. package/dist/connectors/telegram/inbound.js +41 -3
  181. package/dist/connectors/telegram/inbound.js.map +1 -1
  182. package/dist/connectors/telegram/outputFlushPlan.d.ts +12 -0
  183. package/dist/connectors/telegram/outputFlushPlan.d.ts.map +1 -1
  184. package/dist/connectors/telegram/outputFlushPlan.js +12 -0
  185. package/dist/connectors/telegram/outputFlushPlan.js.map +1 -1
  186. package/dist/connectors/telegram/runnerPairingMessages.d.ts +1 -1
  187. package/dist/connectors/telegram/topicIndicator.d.ts +86 -0
  188. package/dist/connectors/telegram/topicIndicator.d.ts.map +1 -0
  189. package/dist/connectors/telegram/topicIndicator.js +588 -0
  190. package/dist/connectors/telegram/topicIndicator.js.map +1 -0
  191. package/dist/connectors/telegram/waitingTopicRenames.d.ts +39 -0
  192. package/dist/connectors/telegram/waitingTopicRenames.d.ts.map +1 -0
  193. package/dist/connectors/telegram/waitingTopicRenames.js +48 -0
  194. package/dist/connectors/telegram/waitingTopicRenames.js.map +1 -0
  195. package/dist/effortLevels.d.ts +6 -0
  196. package/dist/effortLevels.d.ts.map +1 -1
  197. package/dist/effortLevels.js +6 -1
  198. package/dist/effortLevels.js.map +1 -1
  199. package/dist/i18n/de.d.ts.map +1 -1
  200. package/dist/i18n/de.js +141 -13
  201. package/dist/i18n/de.js.map +1 -1
  202. package/dist/i18n/en.d.ts.map +1 -1
  203. package/dist/i18n/en.js +141 -13
  204. package/dist/i18n/en.js.map +1 -1
  205. package/dist/i18n/es.d.ts.map +1 -1
  206. package/dist/i18n/es.js +141 -13
  207. package/dist/i18n/es.js.map +1 -1
  208. package/dist/i18n/fr.d.ts.map +1 -1
  209. package/dist/i18n/fr.js +141 -13
  210. package/dist/i18n/fr.js.map +1 -1
  211. package/dist/i18n/hi.d.ts.map +1 -1
  212. package/dist/i18n/hi.js +141 -13
  213. package/dist/i18n/hi.js.map +1 -1
  214. package/dist/i18n/ja.d.ts.map +1 -1
  215. package/dist/i18n/ja.js +141 -13
  216. package/dist/i18n/ja.js.map +1 -1
  217. package/dist/i18n/ka.d.ts.map +1 -1
  218. package/dist/i18n/ka.js +141 -13
  219. package/dist/i18n/ka.js.map +1 -1
  220. package/dist/i18n/pt.d.ts.map +1 -1
  221. package/dist/i18n/pt.js +141 -13
  222. package/dist/i18n/pt.js.map +1 -1
  223. package/dist/i18n/ru.d.ts.map +1 -1
  224. package/dist/i18n/ru.js +141 -13
  225. package/dist/i18n/ru.js.map +1 -1
  226. package/dist/i18n/uk.d.ts.map +1 -1
  227. package/dist/i18n/uk.js +141 -13
  228. package/dist/i18n/uk.js.map +1 -1
  229. package/dist/i18n/uz.d.ts.map +1 -1
  230. package/dist/i18n/uz.js +141 -13
  231. package/dist/i18n/uz.js.map +1 -1
  232. package/dist/i18n/zh.d.ts.map +1 -1
  233. package/dist/i18n/zh.js +141 -13
  234. package/dist/i18n/zh.js.map +1 -1
  235. package/dist/instanceSettings.d.ts +43 -3
  236. package/dist/instanceSettings.d.ts.map +1 -1
  237. package/dist/instanceSettings.js +109 -4
  238. package/dist/instanceSettings.js.map +1 -1
  239. package/dist/limitNotes/engine.d.ts +47 -0
  240. package/dist/limitNotes/engine.d.ts.map +1 -0
  241. package/dist/limitNotes/engine.js +98 -0
  242. package/dist/limitNotes/engine.js.map +1 -0
  243. package/dist/limitNotes/noteText.d.ts +33 -0
  244. package/dist/limitNotes/noteText.d.ts.map +1 -0
  245. package/dist/limitNotes/noteText.js +55 -0
  246. package/dist/limitNotes/noteText.js.map +1 -0
  247. package/dist/limitNotes/plan.d.ts +147 -0
  248. package/dist/limitNotes/plan.d.ts.map +1 -0
  249. package/dist/limitNotes/plan.js +323 -0
  250. package/dist/limitNotes/plan.js.map +1 -0
  251. package/dist/limitNotes/reminderChoices.d.ts +30 -0
  252. package/dist/limitNotes/reminderChoices.d.ts.map +1 -0
  253. package/dist/limitNotes/reminderChoices.js +48 -0
  254. package/dist/limitNotes/reminderChoices.js.map +1 -0
  255. package/dist/limitNotes/service.d.ts +106 -0
  256. package/dist/limitNotes/service.d.ts.map +1 -0
  257. package/dist/limitNotes/service.js +169 -0
  258. package/dist/limitNotes/service.js.map +1 -0
  259. package/dist/openCodeOpenQuestion.d.ts +12 -4
  260. package/dist/openCodeOpenQuestion.d.ts.map +1 -1
  261. package/dist/openCodeOpenQuestion.js +16 -7
  262. package/dist/openCodeOpenQuestion.js.map +1 -1
  263. package/dist/openCodeQuestionFlow.d.ts +10 -2
  264. package/dist/openCodeQuestionFlow.d.ts.map +1 -1
  265. package/dist/openCodeQuestionFlow.js +27 -5
  266. package/dist/openCodeQuestionFlow.js.map +1 -1
  267. package/dist/openCodeSessionTitle.js +1 -1
  268. package/dist/openCodeSessionTitle.js.map +1 -1
  269. package/dist/outputTrace.d.ts +19 -0
  270. package/dist/outputTrace.d.ts.map +1 -1
  271. package/dist/outputTrace.js +23 -2
  272. package/dist/outputTrace.js.map +1 -1
  273. package/dist/platform/answerSink.d.ts +23 -0
  274. package/dist/platform/answerSink.d.ts.map +1 -1
  275. package/dist/platform/answerSink.js.map +1 -1
  276. package/dist/platform/operatorAlert.d.ts +24 -0
  277. package/dist/platform/operatorAlert.d.ts.map +1 -0
  278. package/dist/platform/operatorAlert.js +9 -0
  279. package/dist/platform/operatorAlert.js.map +1 -0
  280. package/dist/postToSession.d.ts +43 -2
  281. package/dist/postToSession.d.ts.map +1 -1
  282. package/dist/postToSession.js +46 -4
  283. package/dist/postToSession.js.map +1 -1
  284. package/dist/remoteRun/exitCodes.d.ts +2 -2
  285. package/dist/remoteRun/exitCodes.d.ts.map +1 -1
  286. package/dist/remoteRun/exitCodes.js +2 -2
  287. package/dist/remoteRun/exitCodes.js.map +1 -1
  288. package/dist/remoteRun/foreground.d.ts.map +1 -1
  289. package/dist/remoteRun/foreground.js +5 -1
  290. package/dist/remoteRun/foreground.js.map +1 -1
  291. package/dist/remoteRun/runnerClient.d.ts +1 -1
  292. package/dist/remoteRun/runnerClient.d.ts.map +1 -1
  293. package/dist/remoteRun/runnerClient.js +3 -3
  294. package/dist/remoteRun/runnerClient.js.map +1 -1
  295. package/dist/requests/answerRequest.d.ts +3 -0
  296. package/dist/requests/answerRequest.d.ts.map +1 -1
  297. package/dist/requests/answerRequest.js +9 -2
  298. package/dist/requests/answerRequest.js.map +1 -1
  299. package/dist/requests/limitWaitAnswer.d.ts +14 -0
  300. package/dist/requests/limitWaitAnswer.d.ts.map +1 -1
  301. package/dist/requests/limitWaitAnswer.js +26 -4
  302. package/dist/requests/limitWaitAnswer.js.map +1 -1
  303. package/dist/requests/requestHeader.d.ts +37 -5
  304. package/dist/requests/requestHeader.d.ts.map +1 -1
  305. package/dist/requests/requestHeader.js +46 -17
  306. package/dist/requests/requestHeader.js.map +1 -1
  307. package/dist/requests/scheduleWait.d.ts +79 -0
  308. package/dist/requests/scheduleWait.d.ts.map +1 -0
  309. package/dist/requests/scheduleWait.js +101 -0
  310. package/dist/requests/scheduleWait.js.map +1 -0
  311. package/dist/requests/sessionTurnProbe.d.ts +21 -3
  312. package/dist/requests/sessionTurnProbe.d.ts.map +1 -1
  313. package/dist/requests/sessionTurnProbe.js +18 -3
  314. package/dist/requests/sessionTurnProbe.js.map +1 -1
  315. package/dist/requests/topicRequestSettle.d.ts +13 -7
  316. package/dist/requests/topicRequestSettle.d.ts.map +1 -1
  317. package/dist/requests/topicRequestSettle.js +2 -2
  318. package/dist/requests/topicRequestSettle.js.map +1 -1
  319. package/dist/requests/trackerTurnPoster.d.ts +30 -0
  320. package/dist/requests/trackerTurnPoster.d.ts.map +1 -0
  321. package/dist/requests/trackerTurnPoster.js +36 -0
  322. package/dist/requests/trackerTurnPoster.js.map +1 -0
  323. package/dist/requests/types.d.ts +9 -2
  324. package/dist/requests/types.d.ts.map +1 -1
  325. package/dist/requests/wakeUpEngine.d.ts +188 -11
  326. package/dist/requests/wakeUpEngine.d.ts.map +1 -1
  327. package/dist/requests/wakeUpEngine.js +452 -43
  328. package/dist/requests/wakeUpEngine.js.map +1 -1
  329. package/dist/requests/wakeUpRules.d.ts +122 -12
  330. package/dist/requests/wakeUpRules.d.ts.map +1 -1
  331. package/dist/requests/wakeUpRules.js +117 -15
  332. package/dist/requests/wakeUpRules.js.map +1 -1
  333. package/dist/resumeContext.d.ts +2 -2
  334. package/dist/resumeContext.js +3 -3
  335. package/dist/resumeContext.js.map +1 -1
  336. package/dist/runnerUtility/adminService.js +1 -1
  337. package/dist/runnerUtility/adminService.js.map +1 -1
  338. package/dist/runnerUtility/guiAgent.d.ts +1 -1
  339. package/dist/runnerUtility/guiAgent.d.ts.map +1 -1
  340. package/dist/runnerUtility/guiAgent.js +1 -1
  341. package/dist/runnerUtility/guiAgent.js.map +1 -1
  342. package/dist/runnerUtility/managedNode.d.ts +3 -3
  343. package/dist/runnerUtility/managedNode.d.ts.map +1 -1
  344. package/dist/runnerUtility/managedNode.js +2 -2
  345. package/dist/runnerUtility/managedNode.js.map +1 -1
  346. package/dist/runnerUtility/runnerConfig.d.ts +1 -1
  347. package/dist/runnerUtility/runnerHome.d.ts +1 -1
  348. package/dist/runnerUtility/runnerHome.js +1 -1
  349. package/dist/runnerUtility/serviceCommon.d.ts +1 -1
  350. package/dist/runnerUtility/serviceCommon.d.ts.map +1 -1
  351. package/dist/runnerUtility/serviceCommon.js +1 -1
  352. package/dist/runnerUtility/serviceCommon.js.map +1 -1
  353. package/dist/runners/bootstrapLine.js +1 -1
  354. package/dist/runners/hubPackage.d.ts +1 -1
  355. package/dist/runners/hubPackage.js +3 -3
  356. package/dist/runners/hubPackage.js.map +1 -1
  357. package/dist/runners/hubPaths.d.ts +1 -1
  358. package/dist/runners/hubPaths.d.ts.map +1 -1
  359. package/dist/runners/runnerLock.d.ts +2 -2
  360. package/dist/runners/runnerLock.d.ts.map +1 -1
  361. package/dist/runners/runnerLock.js +2 -2
  362. package/dist/runners/runnerLock.js.map +1 -1
  363. package/dist/scheduler/checkRun.d.ts +2 -0
  364. package/dist/scheduler/checkRun.d.ts.map +1 -1
  365. package/dist/scheduler/checkRun.js +5 -1
  366. package/dist/scheduler/checkRun.js.map +1 -1
  367. package/dist/scheduler/delivery.d.ts +57 -0
  368. package/dist/scheduler/delivery.d.ts.map +1 -1
  369. package/dist/scheduler/delivery.js +152 -14
  370. package/dist/scheduler/delivery.js.map +1 -1
  371. package/dist/scheduler/injection.d.ts +6 -0
  372. package/dist/scheduler/injection.d.ts.map +1 -1
  373. package/dist/scheduler/injection.js +10 -0
  374. package/dist/scheduler/injection.js.map +1 -1
  375. package/dist/scheduler/mcpSurface.d.ts +38 -3
  376. package/dist/scheduler/mcpSurface.d.ts.map +1 -1
  377. package/dist/scheduler/mcpSurface.js +291 -175
  378. package/dist/scheduler/mcpSurface.js.map +1 -1
  379. package/dist/scheduler/rebindResume.d.ts +24 -0
  380. package/dist/scheduler/rebindResume.d.ts.map +1 -1
  381. package/dist/scheduler/rebindResume.js +32 -0
  382. package/dist/scheduler/rebindResume.js.map +1 -1
  383. package/dist/scheduler/scheduleToolWording.d.ts +29 -0
  384. package/dist/scheduler/scheduleToolWording.d.ts.map +1 -0
  385. package/dist/scheduler/scheduleToolWording.js +117 -0
  386. package/dist/scheduler/scheduleToolWording.js.map +1 -0
  387. package/dist/scheduler/scheduledRunTarget.d.ts +90 -0
  388. package/dist/scheduler/scheduledRunTarget.d.ts.map +1 -0
  389. package/dist/scheduler/scheduledRunTarget.js +92 -0
  390. package/dist/scheduler/scheduledRunTarget.js.map +1 -0
  391. package/dist/scheduler/store.d.ts +2 -0
  392. package/dist/scheduler/store.d.ts.map +1 -1
  393. package/dist/scheduler/store.js +2 -0
  394. package/dist/scheduler/store.js.map +1 -1
  395. package/dist/scheduler/types.d.ts +10 -0
  396. package/dist/scheduler/types.d.ts.map +1 -1
  397. package/dist/scheduler/workerWatch.d.ts +2 -0
  398. package/dist/scheduler/workerWatch.d.ts.map +1 -1
  399. package/dist/scheduler/workerWatch.js +3 -3
  400. package/dist/scheduler/workerWatch.js.map +1 -1
  401. package/dist/selfUpdate/constants.d.ts +2 -0
  402. package/dist/selfUpdate/constants.d.ts.map +1 -1
  403. package/dist/selfUpdate/constants.js +3 -1
  404. package/dist/selfUpdate/constants.js.map +1 -1
  405. package/dist/selfUpdate/emittedSource.d.ts.map +1 -1
  406. package/dist/selfUpdate/emittedSource.js +1 -1
  407. package/dist/selfUpdate/emittedSource.js.map +1 -1
  408. package/dist/selfUpdate/updateRuntime.js +1 -1
  409. package/dist/selfUpdate/updateRuntime.js.map +1 -1
  410. package/dist/sessionPick.d.ts +1 -1
  411. package/dist/sessionPick.js +1 -1
  412. package/dist/startupPromptBuffer.d.ts +35 -6
  413. package/dist/startupPromptBuffer.d.ts.map +1 -1
  414. package/dist/startupPromptBuffer.js +70 -21
  415. package/dist/startupPromptBuffer.js.map +1 -1
  416. package/dist/state.d.ts +270 -30
  417. package/dist/state.d.ts.map +1 -1
  418. package/dist/state.js +403 -37
  419. package/dist/state.js.map +1 -1
  420. package/dist/testTimings.d.ts +17 -4
  421. package/dist/testTimings.d.ts.map +1 -1
  422. package/dist/testTimings.js +35 -3
  423. package/dist/testTimings.js.map +1 -1
  424. package/dist/threadContextPreamble.d.ts +7 -0
  425. package/dist/threadContextPreamble.d.ts.map +1 -1
  426. package/dist/threadContextPreamble.js +11 -0
  427. package/dist/threadContextPreamble.js.map +1 -1
  428. package/dist/threadRouting.d.ts +12 -0
  429. package/dist/threadRouting.d.ts.map +1 -1
  430. package/dist/threadRouting.js +15 -0
  431. package/dist/threadRouting.js.map +1 -1
  432. package/dist/todos/midTurn.d.ts +15 -41
  433. package/dist/todos/midTurn.d.ts.map +1 -1
  434. package/dist/todos/midTurn.js +27 -171
  435. package/dist/todos/midTurn.js.map +1 -1
  436. package/dist/todos/registry.d.ts +2 -0
  437. package/dist/todos/registry.d.ts.map +1 -1
  438. package/dist/todos/registry.js +3 -1
  439. package/dist/todos/registry.js.map +1 -1
  440. package/dist/types.d.ts +235 -23
  441. package/dist/types.d.ts.map +1 -1
  442. package/dist/types.js +10 -0
  443. package/dist/types.js.map +1 -1
  444. package/dist/utils/backendSwitchPlan.d.ts +3 -3
  445. package/dist/utils/backendSwitchPlan.js +3 -3
  446. package/dist/utils/claudeAccountAlert.d.ts +104 -0
  447. package/dist/utils/claudeAccountAlert.d.ts.map +1 -0
  448. package/dist/utils/claudeAccountAlert.js +130 -0
  449. package/dist/utils/claudeAccountAlert.js.map +1 -0
  450. package/dist/utils/claudeAccountPickerPlan.d.ts +7 -0
  451. package/dist/utils/claudeAccountPickerPlan.d.ts.map +1 -1
  452. package/dist/utils/claudeAccountPickerPlan.js +13 -2
  453. package/dist/utils/claudeAccountPickerPlan.js.map +1 -1
  454. package/dist/utils/claudeAuthRefusal.d.ts +122 -0
  455. package/dist/utils/claudeAuthRefusal.d.ts.map +1 -0
  456. package/dist/utils/claudeAuthRefusal.js +228 -0
  457. package/dist/utils/claudeAuthRefusal.js.map +1 -0
  458. package/dist/utils/claudeCompactHook.d.ts +9 -7
  459. package/dist/utils/claudeCompactHook.d.ts.map +1 -1
  460. package/dist/utils/claudeCompactHook.js +11 -9
  461. package/dist/utils/claudeCompactHook.js.map +1 -1
  462. package/dist/utils/claudeLimitSwitch.d.ts +1 -1
  463. package/dist/utils/claudeLimitSwitch.d.ts.map +1 -1
  464. package/dist/utils/claudeLimitSwitch.js +1 -1
  465. package/dist/utils/claudeLimitSwitch.js.map +1 -1
  466. package/dist/utils/claudeProfileSync.d.ts +88 -0
  467. package/dist/utils/claudeProfileSync.d.ts.map +1 -0
  468. package/dist/utils/claudeProfileSync.js +198 -0
  469. package/dist/utils/claudeProfileSync.js.map +1 -0
  470. package/dist/utils/claudeProfileUsageViews.d.ts +54 -2
  471. package/dist/utils/claudeProfileUsageViews.d.ts.map +1 -1
  472. package/dist/utils/claudeProfileUsageViews.js +44 -1
  473. package/dist/utils/claudeProfileUsageViews.js.map +1 -1
  474. package/dist/utils/claudeProfiles.d.ts +101 -6
  475. package/dist/utils/claudeProfiles.d.ts.map +1 -1
  476. package/dist/utils/claudeProfiles.js +297 -23
  477. package/dist/utils/claudeProfiles.js.map +1 -1
  478. package/dist/utils/claudeRuntimeInfo.d.ts +24 -0
  479. package/dist/utils/claudeRuntimeInfo.d.ts.map +1 -1
  480. package/dist/utils/claudeRuntimeInfo.js +128 -3
  481. package/dist/utils/claudeRuntimeInfo.js.map +1 -1
  482. package/dist/utils/claudeScheduledJobs.d.ts +6 -2
  483. package/dist/utils/claudeScheduledJobs.d.ts.map +1 -1
  484. package/dist/utils/claudeScheduledJobs.js +10 -2
  485. package/dist/utils/claudeScheduledJobs.js.map +1 -1
  486. package/dist/utils/claudeSessionTitle.js +1 -1
  487. package/dist/utils/claudeSessionTitle.js.map +1 -1
  488. package/dist/utils/claudeStreamJson.d.ts +28 -2
  489. package/dist/utils/claudeStreamJson.d.ts.map +1 -1
  490. package/dist/utils/claudeStreamJson.js +33 -3
  491. package/dist/utils/claudeStreamJson.js.map +1 -1
  492. package/dist/utils/claudeTranscriptEpoch.d.ts +14 -0
  493. package/dist/utils/claudeTranscriptEpoch.d.ts.map +1 -1
  494. package/dist/utils/claudeTranscriptEpoch.js +79 -19
  495. package/dist/utils/claudeTranscriptEpoch.js.map +1 -1
  496. package/dist/utils/claudeUsage.d.ts +103 -7
  497. package/dist/utils/claudeUsage.d.ts.map +1 -1
  498. package/dist/utils/claudeUsage.js +108 -15
  499. package/dist/utils/claudeUsage.js.map +1 -1
  500. package/dist/utils/claudeUsageRefresher.d.ts +8 -1
  501. package/dist/utils/claudeUsageRefresher.d.ts.map +1 -1
  502. package/dist/utils/claudeUsageRefresher.js +11 -1
  503. package/dist/utils/claudeUsageRefresher.js.map +1 -1
  504. package/dist/utils/compactOnIdle.d.ts +139 -29
  505. package/dist/utils/compactOnIdle.d.ts.map +1 -1
  506. package/dist/utils/compactOnIdle.js +163 -36
  507. package/dist/utils/compactOnIdle.js.map +1 -1
  508. package/dist/utils/conversationEnding.d.ts +76 -0
  509. package/dist/utils/conversationEnding.d.ts.map +1 -0
  510. package/dist/utils/conversationEnding.js +117 -0
  511. package/dist/utils/conversationEnding.js.map +1 -0
  512. package/dist/utils/cutButtonLabel.d.ts +7 -0
  513. package/dist/utils/cutButtonLabel.d.ts.map +1 -0
  514. package/dist/utils/cutButtonLabel.js +17 -0
  515. package/dist/utils/cutButtonLabel.js.map +1 -0
  516. package/dist/utils/doctorLine.d.ts +10 -0
  517. package/dist/utils/doctorLine.d.ts.map +1 -1
  518. package/dist/utils/doctorLine.js +16 -0
  519. package/dist/utils/doctorLine.js.map +1 -1
  520. package/dist/utils/fallbackBridge.d.ts.map +1 -1
  521. package/dist/utils/fallbackBridge.js +2 -1
  522. package/dist/utils/fallbackBridge.js.map +1 -1
  523. package/dist/utils/fallbackChain.d.ts +2 -0
  524. package/dist/utils/fallbackChain.d.ts.map +1 -1
  525. package/dist/utils/fallbackChain.js +4 -3
  526. package/dist/utils/fallbackChain.js.map +1 -1
  527. package/dist/utils/fallbackSwitchNotice.d.ts +11 -4
  528. package/dist/utils/fallbackSwitchNotice.d.ts.map +1 -1
  529. package/dist/utils/fallbackSwitchNotice.js +9 -5
  530. package/dist/utils/fallbackSwitchNotice.js.map +1 -1
  531. package/dist/utils/fileSendService.d.ts +31 -0
  532. package/dist/utils/fileSendService.d.ts.map +1 -1
  533. package/dist/utils/fileSendService.js +45 -2
  534. package/dist/utils/fileSendService.js.map +1 -1
  535. package/dist/utils/jsonStreamHost.d.ts +2 -0
  536. package/dist/utils/jsonStreamHost.d.ts.map +1 -1
  537. package/dist/utils/jsonStreamHost.js +4 -1
  538. package/dist/utils/jsonStreamHost.js.map +1 -1
  539. package/dist/utils/jsonStreamPendingWork.d.ts +14 -2
  540. package/dist/utils/jsonStreamPendingWork.d.ts.map +1 -1
  541. package/dist/utils/jsonStreamPendingWork.js +25 -5
  542. package/dist/utils/jsonStreamPendingWork.js.map +1 -1
  543. package/dist/utils/jsonStreamUnconsumedInput.d.ts +80 -0
  544. package/dist/utils/jsonStreamUnconsumedInput.d.ts.map +1 -0
  545. package/dist/utils/jsonStreamUnconsumedInput.js +99 -0
  546. package/dist/utils/jsonStreamUnconsumedInput.js.map +1 -0
  547. package/dist/utils/limitEpisodeRecovery.d.ts +43 -4
  548. package/dist/utils/limitEpisodeRecovery.d.ts.map +1 -1
  549. package/dist/utils/limitEpisodeRecovery.js +107 -20
  550. package/dist/utils/limitEpisodeRecovery.js.map +1 -1
  551. package/dist/utils/limitHeldPrompts.d.ts +21 -11
  552. package/dist/utils/limitHeldPrompts.d.ts.map +1 -1
  553. package/dist/utils/limitHeldPrompts.js +12 -9
  554. package/dist/utils/limitHeldPrompts.js.map +1 -1
  555. package/dist/utils/limitRemindersScreenPlan.d.ts +63 -0
  556. package/dist/utils/limitRemindersScreenPlan.d.ts.map +1 -0
  557. package/dist/utils/limitRemindersScreenPlan.js +121 -0
  558. package/dist/utils/limitRemindersScreenPlan.js.map +1 -0
  559. package/dist/utils/limitSwitchPlan.d.ts +44 -0
  560. package/dist/utils/limitSwitchPlan.d.ts.map +1 -0
  561. package/dist/utils/limitSwitchPlan.js +54 -0
  562. package/dist/utils/limitSwitchPlan.js.map +1 -0
  563. package/dist/utils/limitsBoardPlan.d.ts +16 -7
  564. package/dist/utils/limitsBoardPlan.d.ts.map +1 -1
  565. package/dist/utils/limitsBoardPlan.js +41 -9
  566. package/dist/utils/limitsBoardPlan.js.map +1 -1
  567. package/dist/utils/lostWork.d.ts +16 -2
  568. package/dist/utils/lostWork.d.ts.map +1 -1
  569. package/dist/utils/lostWork.js +16 -3
  570. package/dist/utils/lostWork.js.map +1 -1
  571. package/dist/utils/messageContext.d.ts +2 -2
  572. package/dist/utils/messageContext.js +2 -2
  573. package/dist/utils/midTurnInbox.d.ts +79 -0
  574. package/dist/utils/midTurnInbox.d.ts.map +1 -0
  575. package/dist/utils/midTurnInbox.js +265 -0
  576. package/dist/utils/midTurnInbox.js.map +1 -0
  577. package/dist/utils/promptDelivery.d.ts +70 -22
  578. package/dist/utils/promptDelivery.d.ts.map +1 -1
  579. package/dist/utils/promptDelivery.js +100 -42
  580. package/dist/utils/promptDelivery.js.map +1 -1
  581. package/dist/utils/questionWaitChoices.d.ts +20 -0
  582. package/dist/utils/questionWaitChoices.d.ts.map +1 -0
  583. package/dist/utils/questionWaitChoices.js +31 -0
  584. package/dist/utils/questionWaitChoices.js.map +1 -0
  585. package/dist/utils/questionWaitPlan.d.ts +166 -0
  586. package/dist/utils/questionWaitPlan.d.ts.map +1 -0
  587. package/dist/utils/questionWaitPlan.js +237 -0
  588. package/dist/utils/questionWaitPlan.js.map +1 -0
  589. package/dist/utils/replyQuote.d.ts +10 -0
  590. package/dist/utils/replyQuote.d.ts.map +1 -1
  591. package/dist/utils/replyQuote.js +18 -7
  592. package/dist/utils/replyQuote.js.map +1 -1
  593. package/dist/utils/talkerAccess.d.ts +2 -2
  594. package/dist/utils/talkerAccess.d.ts.map +1 -1
  595. package/dist/utils/talkerAccess.js +5 -4
  596. package/dist/utils/talkerAccess.js.map +1 -1
  597. package/dist/utils/telegramError.d.ts +6 -0
  598. package/dist/utils/telegramError.d.ts.map +1 -1
  599. package/dist/utils/telegramError.js +12 -0
  600. package/dist/utils/telegramError.js.map +1 -1
  601. package/dist/utils/topicAccessScreenPlan.d.ts +1 -1
  602. package/dist/utils/topicAccessScreenPlan.d.ts.map +1 -1
  603. package/dist/utils/topicAccessScreenPlan.js +3 -7
  604. package/dist/utils/topicAccessScreenPlan.js.map +1 -1
  605. package/dist/utils/topicIndicatorPlan.d.ts +153 -0
  606. package/dist/utils/topicIndicatorPlan.d.ts.map +1 -0
  607. package/dist/utils/topicIndicatorPlan.js +224 -0
  608. package/dist/utils/topicIndicatorPlan.js.map +1 -0
  609. package/dist/utils/topicIndicatorSources.d.ts +40 -0
  610. package/dist/utils/topicIndicatorSources.d.ts.map +1 -0
  611. package/dist/utils/topicIndicatorSources.js +31 -0
  612. package/dist/utils/topicIndicatorSources.js.map +1 -0
  613. package/dist/utils/topicRequest.d.ts +3 -0
  614. package/dist/utils/topicRequest.d.ts.map +1 -1
  615. package/dist/utils/topicRequest.js +4 -0
  616. package/dist/utils/topicRequest.js.map +1 -1
  617. package/dist/utils/topicStatusPlan.d.ts +90 -0
  618. package/dist/utils/topicStatusPlan.d.ts.map +1 -0
  619. package/dist/utils/topicStatusPlan.js +160 -0
  620. package/dist/utils/topicStatusPlan.js.map +1 -0
  621. package/dist/utils/workerRoles.d.ts +122 -0
  622. package/dist/utils/workerRoles.d.ts.map +1 -0
  623. package/dist/utils/workerRoles.js +160 -0
  624. package/dist/utils/workerRoles.js.map +1 -0
  625. package/dist/utils/workerRolesScreenPlan.d.ts +118 -0
  626. package/dist/utils/workerRolesScreenPlan.d.ts.map +1 -0
  627. package/dist/utils/workerRolesScreenPlan.js +232 -0
  628. package/dist/utils/workerRolesScreenPlan.js.map +1 -0
  629. package/dist/utils/workingSignals.d.ts +49 -0
  630. package/dist/utils/workingSignals.d.ts.map +1 -0
  631. package/dist/utils/workingSignals.js +41 -0
  632. package/dist/utils/workingSignals.js.map +1 -0
  633. package/licensing.json +88 -0
  634. package/npm-shrinkwrap.json +2 -2
  635. package/package.json +7 -7
  636. package/{remoteRun → runner-scripts}/runner.sh +6 -3
  637. package/COMMERCIAL-LICENSE.md +0 -142
  638. package/dist/agentTrigger.d.ts +0 -28
  639. package/dist/agentTrigger.d.ts.map +0 -1
  640. package/dist/agentTrigger.js +0 -53
  641. package/dist/agentTrigger.js.map +0 -1
  642. /package/{remoteRun → runner-scripts}/ensureNode.sh +0 -0
  643. /package/{remoteRun → runner-scripts}/runner-package-lock.json +0 -0
@@ -11,8 +11,12 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.buildClaudeProfileUsageView = buildClaudeProfileUsageView;
13
13
  exports.buildClaudeProfileUsageViews = buildClaudeProfileUsageViews;
14
+ exports.pickClaudeProfileInstead = pickClaudeProfileInstead;
15
+ exports.resolveClaudeProfileForLaunch = resolveClaudeProfileForLaunch;
16
+ exports.planClaudeAuthRefusalMove = planClaudeAuthRefusalMove;
14
17
  exports.addClaudeApiCreditToReport = addClaudeApiCreditToReport;
15
18
  exports.buildClaudeProfilesCreditReport = buildClaudeProfilesCreditReport;
19
+ const claudeAuthRefusal_1 = require("./claudeAuthRefusal");
16
20
  const claudeProfiles_1 = require("./claudeProfiles");
17
21
  const claudeApiCredit_1 = require("./claudeApiCredit");
18
22
  const claudeUsage_1 = require("./claudeUsage");
@@ -22,7 +26,9 @@ function buildClaudeProfileUsageView(input) {
22
26
  return {
23
27
  name,
24
28
  configDir: (0, claudeProfiles_1.resolveClaudeProfileDir)(input.dataDir, name),
25
- loggedIn: record?.loggedIn,
29
+ // A refusal by the CLI counts as signed out until the account is signed in again (`utils/claudeAuthRefusal.ts`).
30
+ loggedIn: (0, claudeAuthRefusal_1.getClaudeProfileSignedIn)(record),
31
+ ...(record?.authRefusal ? { authRefusal: record.authRefusal } : {}),
26
32
  email: record?.email ?? null,
27
33
  subscriptionType: record?.subscriptionType ?? null,
28
34
  usage: record?.usage,
@@ -53,6 +59,43 @@ function buildClaudeProfileUsageViews(input) {
53
59
  .sort(([, a], [, b]) => a.createdAt.localeCompare(b.createdAt));
54
60
  return [...(isDefaultRemoved ? [] : [toView('default', input.records.default)]), ...added.map(([name, record]) => toView(name, record))];
55
61
  }
62
+ /**
63
+ * @description The account a conversation goes to instead of `currentProfile` (one it cannot run on): the account `claude_profiles`
64
+ * recommends for a session leaving it — the same launch pick (`getClaudeLaunchPick` through `buildClaudeProfilesCreditReport`): only
65
+ * the accounts the `/limits` list holds with an enabled rung once it names any Claude account (`chainScope`), an API-credit account of
66
+ * it first, then the usable subscription whose weekly window resets soonest. An agents-only hold (`agentHoldUntil`) is not read: a
67
+ * conversation is not an agent's worker. `null` when no other account is usable.
68
+ */
69
+ function pickClaudeProfileInstead(input) {
70
+ const views = input.views.map((view) => ({ ...view, agentHoldUntil: null }));
71
+ const { recommended } = buildClaudeProfilesCreditReport(views, input.model, input.nowMs, { currentProfile: input.currentProfile, chainScope: input.chainScope });
72
+ return recommended === input.currentProfile ? null : recommended;
73
+ }
74
+ /**
75
+ * @description The account a conversation's next Claude process starts on (a start, a resume, an account switch): `resolved` — its
76
+ * own pick, else General's, else `default` — unless that account is known not to work (`checkIsClaudeProfileKnownUnusable`: not
77
+ * signed in by its last probe, or refused by the CLI since); then {@link pickClaudeProfileInstead}, or `resolved` all the same when
78
+ * no other account is usable (the turn then fails and is surfaced as before). `isMoved`: the conversation leaves `resolved`.
79
+ */
80
+ function resolveClaudeProfileForLaunch(input) {
81
+ if (!(0, claudeAuthRefusal_1.checkIsClaudeProfileKnownUnusable)(input.record))
82
+ return { name: input.resolved, isMoved: false };
83
+ const instead = pickClaudeProfileInstead({ ...input, currentProfile: input.resolved });
84
+ return instead === null ? { name: input.resolved, isMoved: false } : { name: instead, isMoved: true };
85
+ }
86
+ /**
87
+ * @description What the CLI's refusal of the account a conversation runs on leads to: `isMarked` — the account is to be marked
88
+ * refused (`refused` names a Claude account, and the error is not one replayed from before the boot: the login may have been fixed
89
+ * since); `to` — the account the conversation moves to, {@link pickClaudeProfileInstead} read as if the mark were already there;
90
+ * `null` = nowhere (the logged-out notice, as before).
91
+ */
92
+ function planClaudeAuthRefusalMove(input) {
93
+ const { refused } = input;
94
+ if (refused === null || input.isReplayed)
95
+ return { isMarked: false, to: null };
96
+ const views = input.views.map((view) => (view.name === refused ? { ...view, loggedIn: false, authRefusal: input.refusal } : view));
97
+ return { isMarked: true, to: pickClaudeProfileInstead({ ...input, views, currentProfile: refused }) };
98
+ }
56
99
  /** What the bot can tell of an API account's credit now; `null` for any other account and when it knows nothing worth a line. */
57
100
  function getClaudeProfileCreditEstimate(profile, nowMs) {
58
101
  return profile.billing === 'api'
@@ -1 +1 @@
1
- {"version":3,"file":"claudeProfileUsageViews.js","sourceRoot":"","sources":["../../src/utils/claudeProfileUsageViews.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAQH,kEA4BC;AAOD,oEAeC;AA4CD,gEAQC;AAQD,0EAQC;AA3HD,qDAA2D;AAC3D,uDAAyL;AACzL,+CAA+K;AAE/K,uJAAuJ;AACvJ,SAAgB,2BAA2B,CAAC,KAO3C;IACC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAC7C,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,IAAA,wCAAuB,EAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;QACvD,QAAQ,EAAE,MAAM,EAAE,QAAQ;QAC1B,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,IAAI;QAC5B,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,IAAI,IAAI;QAClD,KAAK,EAAE,MAAM,EAAE,KAAK;QACpB,YAAY,EAAE,MAAM,EAAE,YAAY,IAAI,IAAI;QAC1C,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5E,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,IAAI;QAChC,yHAAyH;QACzH,sEAAsE;QACtE,iBAAiB,EAAE,MAAM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AAC,CAAC,IAAI,EAAE,EAAE,CAAC,8BAA8B,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACrI,CAAC;AAED;;;GAGG;AACH,SAAgB,0BAA0B,CAAC,MAA4B,EAAE,KAAwC,EAAE,KAAa;IAC9H,OAAO;QACL,GAAG,MAAM;QACT,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAA4B,EAAE;YAChE,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC;YACtE,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,4BAA4B,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QACjG,CAAC,CAAC;KACH,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,+BAA+B,CAC7C,KAAwC,EACxC,KAAoB,EACpB,KAAa,EACb,UAAuC,EAAE;IAEzC,MAAM,eAAe,GAAG,0BAA0B,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACjE,OAAO,0BAA0B,CAAC,IAAA,uCAAyB,EAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AACnI,CAAC"}
@@ -9,12 +9,19 @@
9
9
  * `~/.claude`, so a conversation started under one account resumes under another and every account sees
10
10
  * the same hooks and skills.
11
11
  *
12
+ * Everything Claude Code loads as USER-level configuration from that directory (instructions, rules, skills, subagents, commands,
13
+ * output styles, workflows, mods, plugins, the settings with their hooks) is therefore kept a link into `~/.claude`: a profile folder is
14
+ * writable by the user the bot and every agent run as, so an agent on the account could otherwise plant files there that every later
15
+ * session on it would follow. {@link repairClaudeProfileLayout} restores the links right before a launch under the folder and moves
16
+ * whatever stood in their place aside; the account's own state (login, `.claude.json`, history, caches) is never touched.
17
+ *
12
18
  * The profile `default` IS `~/.claude` itself: nothing is set for it and nothing is migrated. A process is
13
19
  * never switched by swapping files under `~/.claude` (the CLI re-reads its credentials live and EVERY running
14
20
  * session would change account at once); the variable is per process, set at spawn.
15
21
  *
16
22
  * Pure helpers (layout, name gate, resolution, parsers) — the registry and the selection live in
17
- * `state.json` (`StateStore`), the spawn-side use in the adapters, the UI in
23
+ * `state.json` (`StateStore`), kept in step with the disk and the CLI by `utils/claudeProfileSync.ts` (a folder signed in by hand is
24
+ * adopted without Telegram), the spawn-side use in the adapters, the UI in
18
25
  * `connectors/telegram/commands/claudeAccounts.ts`. Shaped for the later phases: a record carries room for a
19
26
  * `limitedUntil` mark and a cached usage snapshot, and the resolver takes the known names so a selection that
20
27
  * names a removed profile falls back instead of launching a dead directory.
@@ -30,7 +37,18 @@ export declare const claudeProfilesDirName = "claude-profiles";
30
37
  * file the CLI tries to read on every start).
31
38
  */
32
39
  export declare const claudeProfileSharedEntries: readonly ["projects", "settings.json", "skills", "plugins"];
33
- export declare const claudeProfileOptionalSharedEntries: readonly ["CLAUDE.md"];
40
+ /**
41
+ * The other user-level entries Claude Code loads from its config directory (code.claude.com/docs, «Explore the .claude directory»,
42
+ * «Create a mod»): `CLAUDE.md` and `rules/` (instructions, loaded at session start), `agents/` (subagent prompts, with their hooks and
43
+ * MCP servers in the frontmatter), `commands/` and `output-styles/` (prompts and instruction sets), `workflows/` (scripts the runtime
44
+ * runs), and `dev-mods/<session id>/` (mods Claude wrote — loaded again when that session is RESUMED, which is what the bot does).
45
+ * They mirror `~/.claude` the way the four above do, but only while `~/.claude` HAS the entry (a link to nothing would be read at every
46
+ * start for nothing): where it has none, a profile must hold none either, so anything found there is moved aside.
47
+ * Not in the list, on purpose: `keybindings.json` and `themes/` (the docs give them no instruction or executable role),
48
+ * `settings.local.json` (the docs scope it to a project's `.claude/`, not the user directory) and `agent-memory/` (subagent memory —
49
+ * the account's own state, loaded only by a subagent that opts in).
50
+ */
51
+ export declare const claudeProfileOptionalSharedEntries: readonly ["CLAUDE.md", "rules", "agents", "commands", "output-styles", "workflows", "dev-mods"];
34
52
  /** Profile names are safe slugs: they become a directory name and a button's `callback_data`. */
35
53
  export declare const claudeProfileNameMaxLength = 32;
36
54
  /** Longest `callback_data` prefix the account picker uses; with the name cap it stays far under Telegram's 64 bytes. */
@@ -51,16 +69,93 @@ export declare function resolveClaudeProfileDir(dataDir: string, name: string):
51
69
  /** `~/.claude` — the directory the shared entries link back into. */
52
70
  export declare function resolveHomeClaudeDir(homeDir?: string): string;
53
71
  /**
54
- * @description Create a profile's config directory: `0700`, with the shared entries symlinked into `~/.claude`.
55
- * Idempotent — an existing directory keeps its login and only gains a missing link, so a re-run after a crash is
56
- * safe. Refuses `default` and an invalid name (defence in depth: the command gate already rejected them).
57
- * `~/.claude/projects` is created when absent so the link never dangles into the one entry the bot reads.
72
+ * @description Create a profile's config directory: `0700`, with the entries it mirrors from `~/.claude` linked
73
+ * ({@link repairClaudeProfileLayout}). Idempotent — an existing directory keeps its login and its state, gains a missing link, and has
74
+ * anything that stands in a link's place moved aside; so a re-run after a crash is safe. Refuses `default` and an invalid name
75
+ * (defence in depth: the command gate already rejected them). `~/.claude/projects` is created when absent so the link never dangles
76
+ * into the one entry the bot reads. A folder another user owns (an operator locked it) is not chmod'ed, and one this user cannot write is not written to.
58
77
  */
59
78
  export declare function createClaudeProfileLayout(input: {
60
79
  dataDir: string;
61
80
  name: string;
62
81
  homeClaudeDir?: string;
82
+ uid?: number | null;
63
83
  }): string;
84
+ /** What stood where a link into `~/.claude` belongs. */
85
+ export type ClaudeProfileEntryFinding = 'missing' | 'wrongLink' | 'file' | 'directory' | 'other';
86
+ /** One entry the repair found wrong and what it did (or would have done) about it. */
87
+ export interface ClaudeProfileRepairAction {
88
+ entry: string;
89
+ found: ClaudeProfileEntryFinding;
90
+ /** Where what stood there was moved aside to; `null` when nothing stood there. */
91
+ movedTo: string | null;
92
+ /** The target the link was restored to; `null` when `~/.claude` has no such entry and none belongs there. */
93
+ linkedTo: string | null;
94
+ }
95
+ export interface ClaudeProfileRepairResult {
96
+ /** The folder; `null` for `default`, an invalid name or an absent folder (nothing was looked at). */
97
+ dir: string | null;
98
+ /** `ok`: right already, or repaired; `notOwned`: wrong, in another user's folder this user cannot write — nothing was written; `failed`: a write failed. */
99
+ status: 'ok' | 'skipped' | 'notOwned' | 'failed';
100
+ /** What was repaired. */
101
+ actions: ClaudeProfileRepairAction[];
102
+ /** The entries still wrong afterwards (`notOwned`, `failed`). */
103
+ pending: string[];
104
+ }
105
+ /** For tests only: forget which profiles were warned about. */
106
+ export declare function resetClaudeProfileRepairWarningsForTests(): void;
107
+ /**
108
+ * @description Put a profile's folder back the way {@link createClaudeProfileLayout} made it, as far as the entries Claude Code loads
109
+ * as user-level configuration go ({@link claudeProfileSharedEntries} always, {@link claudeProfileOptionalSharedEntries} where
110
+ * `~/.claude` has them): each is a link to `~/.claude/<entry>`. Run right before every launch under the folder, so it is cheap — a few
111
+ * `lstat`s, and NOT ONE write when the layout is right (a link into `~/.claude` that dangles is right: it is the one the bot made).
112
+ * What stands in a link's place — a real file or directory, a link elsewhere, an entry `~/.claude` has no counterpart of — is MOVED
113
+ * ASIDE as `<entry>.moved-<UTC time>`, never deleted (it may hold the operator's data), one log line each, and the right link restored.
114
+ *
115
+ * Everything else in the folder is the account's own state — `.credentials.json`, `.claude.json`, backups, history, caches, the
116
+ * contents behind the `projects` link — and is never touched.
117
+ *
118
+ * A folder another user owns that this user cannot write (an operator locked it) is not written to: a wrong layout there is warned
119
+ * about ONCE per profile per process, and the launch goes ahead — the agent runs as the same user as the bot, so a folder the bot
120
+ * cannot write is one the agent could not plant in either. A locked folder this user CAN still write (its group or ACL lets the CLI
121
+ * save its own files there) is repaired like any other — an agent could add entries to it — as far as the operator's entries allow
122
+ * (with the sticky bit their links cannot be moved). A write that fails is warned about once the same way, unless `isStrict` (the
123
+ * creation path), which throws it.
124
+ */
125
+ export declare function repairClaudeProfileLayout(input: {
126
+ dataDir: string;
127
+ name: string;
128
+ homeClaudeDir?: string;
129
+ isStrict?: boolean;
130
+ /** The uid that decides ownership; the process's own unless a test says otherwise. `null`: no owner to ask. */
131
+ uid?: number | null;
132
+ now?: () => number;
133
+ log?: (line: string) => void;
134
+ }): ClaudeProfileRepairResult;
135
+ /**
136
+ * @description What a profile's `.claude.json` — the account's own state, which the repair never edits — holds that Claude Code treats
137
+ * as configuration with an effect: MCP servers (the docs keep them in `~/.claude.json`, per project under `projects.<path>.mcpServers`,
138
+ * and a profile's file carries them at the top level too), and, defensively, the settings-style keys `hooks`, `env`, `apiKeyHelper`
139
+ * and `statusLine` (the docs place those in `settings.json`; whether the CLI honours them in `.claude.json` is not documented, so a
140
+ * mention is a pointer, not a verdict). Names only — never a command, argument or value. `[]` for a file that is absent, too big or
141
+ * not JSON.
142
+ */
143
+ export declare function listClaudeProfileConfigRisks(configDir: string): string[];
144
+ /**
145
+ * @description THE call every launch under a profile folder makes first (a bot session, a sign-in or status probe, a worker the bot or
146
+ * the CLI points at an account): repair the folder's layout ({@link repairClaudeProfileLayout}), then say — once per distinct finding,
147
+ * not per launch — what its `.claude.json` configures ({@link listClaudeProfileConfigRisks}); the file is read only when its size or
148
+ * time moved. `configDir` is the directory a process is about to get as `CLAUDE_CONFIG_DIR`: `null` (the default account) and any
149
+ * directory that is not `<dataDir>/claude-profiles/<valid name>` are left alone. Never throws — a launch must not fail on a repair.
150
+ */
151
+ export declare function repairClaudeProfileFolderForLaunch(input: {
152
+ dataDir: string;
153
+ configDir: string | null;
154
+ homeClaudeDir?: string;
155
+ uid?: number | null;
156
+ now?: () => number;
157
+ log?: (line: string) => void;
158
+ }): ClaudeProfileRepairResult;
64
159
  /**
65
160
  * @description Remove a profile's directory — its login with it. `fs.rmSync` removes the symlinks AS LINKS, so
66
161
  * the shared `~/.claude` entries behind them are never touched. Refuses `default`.
@@ -1 +1 @@
1
- {"version":3,"file":"claudeProfiles.d.ts","sourceRoot":"","sources":["../../src/utils/claudeProfiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAOH,uEAAuE;AACvE,eAAO,MAAM,wBAAwB,YAAY,CAAC;AAElD,8EAA8E;AAC9E,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,6DAA8D,CAAC;AACtG,eAAO,MAAM,kCAAkC,wBAAyB,CAAC;AAEzE,iGAAiG;AACjG,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAG7C,wHAAwH;AACxH,eAAO,MAAM,2BAA2B,UAAU,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED,2GAA2G;AAC3G,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGpF;AAED,qEAAqE;AACrE,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,MAAqB,GAAG,MAAM,CAE3E;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CA6BlH;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,M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MAAM,GAAG,IAAI,CAIxE;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAAC,iBAAiB,EAAE,OAAO,EAAE,OAAO,GAAE,MAAqB,GAAG,MAAM,GAAG,IAAI,CAExH;AAED,4HAA4H;AAC5H,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAO7E;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAMhF;AAED,sGAAsG;AACtG,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAKjE;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAM7D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAKjF;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC;AAErE,uHAAuH;AACvH,wBAAgB,oBAAoB,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,iBAAiB,CAMvF;AAID,eAAO,MAAM,2BAA2B,sBAAsB,CAAC;AAE/D;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC,UAAU,CAK3F;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAQ7F;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM9E"}
@@ -10,12 +10,19 @@
10
10
  * `~/.claude`, so a conversation started under one account resumes under another and every account sees
11
11
  * the same hooks and skills.
12
12
  *
13
+ * Everything Claude Code loads as USER-level configuration from that directory (instructions, rules, skills, subagents, commands,
14
+ * output styles, workflows, mods, plugins, the settings with their hooks) is therefore kept a link into `~/.claude`: a profile folder is
15
+ * writable by the user the bot and every agent run as, so an agent on the account could otherwise plant files there that every later
16
+ * session on it would follow. {@link repairClaudeProfileLayout} restores the links right before a launch under the folder and moves
17
+ * whatever stood in their place aside; the account's own state (login, `.claude.json`, history, caches) is never touched.
18
+ *
13
19
  * The profile `default` IS `~/.claude` itself: nothing is set for it and nothing is migrated. A process is
14
20
  * never switched by swapping files under `~/.claude` (the CLI re-reads its credentials live and EVERY running
15
21
  * session would change account at once); the variable is per process, set at spawn.
16
22
  *
17
23
  * Pure helpers (layout, name gate, resolution, parsers) — the registry and the selection live in
18
- * `state.json` (`StateStore`), the spawn-side use in the adapters, the UI in
24
+ * `state.json` (`StateStore`), kept in step with the disk and the CLI by `utils/claudeProfileSync.ts` (a folder signed in by hand is
25
+ * adopted without Telegram), the spawn-side use in the adapters, the UI in
19
26
  * `connectors/telegram/commands/claudeAccounts.ts`. Shaped for the later phases: a record carries room for a
20
27
  * `limitedUntil` mark and a cached usage snapshot, and the resolver takes the known names so a selection that
21
28
  * names a removed profile falls back instead of launching a dead directory.
@@ -61,6 +68,10 @@ exports.resolveClaudeProfilesRoot = resolveClaudeProfilesRoot;
61
68
  exports.resolveClaudeProfileDir = resolveClaudeProfileDir;
62
69
  exports.resolveHomeClaudeDir = resolveHomeClaudeDir;
63
70
  exports.createClaudeProfileLayout = createClaudeProfileLayout;
71
+ exports.resetClaudeProfileRepairWarningsForTests = resetClaudeProfileRepairWarningsForTests;
72
+ exports.repairClaudeProfileLayout = repairClaudeProfileLayout;
73
+ exports.listClaudeProfileConfigRisks = listClaudeProfileConfigRisks;
74
+ exports.repairClaudeProfileFolderForLaunch = repairClaudeProfileFolderForLaunch;
64
75
  exports.removeClaudeProfileLayout = removeClaudeProfileLayout;
65
76
  exports.signOutDefaultClaudeLogin = signOutDefaultClaudeLogin;
66
77
  exports.checkClaudeProfileDirExists = checkClaudeProfileDirExists;
@@ -97,7 +108,18 @@ exports.claudeProfilesDirName = 'claude-profiles';
97
108
  * file the CLI tries to read on every start).
98
109
  */
99
110
  exports.claudeProfileSharedEntries = ['projects', 'settings.json', 'skills', 'plugins'];
100
- exports.claudeProfileOptionalSharedEntries = ['CLAUDE.md'];
111
+ /**
112
+ * The other user-level entries Claude Code loads from its config directory (code.claude.com/docs, «Explore the .claude directory»,
113
+ * «Create a mod»): `CLAUDE.md` and `rules/` (instructions, loaded at session start), `agents/` (subagent prompts, with their hooks and
114
+ * MCP servers in the frontmatter), `commands/` and `output-styles/` (prompts and instruction sets), `workflows/` (scripts the runtime
115
+ * runs), and `dev-mods/<session id>/` (mods Claude wrote — loaded again when that session is RESUMED, which is what the bot does).
116
+ * They mirror `~/.claude` the way the four above do, but only while `~/.claude` HAS the entry (a link to nothing would be read at every
117
+ * start for nothing): where it has none, a profile must hold none either, so anything found there is moved aside.
118
+ * Not in the list, on purpose: `keybindings.json` and `themes/` (the docs give them no instruction or executable role),
119
+ * `settings.local.json` (the docs scope it to a project's `.claude/`, not the user directory) and `agent-memory/` (subagent memory —
120
+ * the account's own state, loaded only by a subagent that opts in).
121
+ */
122
+ exports.claudeProfileOptionalSharedEntries = ['CLAUDE.md', 'rules', 'agents', 'commands', 'output-styles', 'workflows', 'dev-mods'];
101
123
  /** Profile names are safe slugs: they become a directory name and a button's `callback_data`. */
102
124
  exports.claudeProfileNameMaxLength = 32;
103
125
  const claudeProfileNameRe = /^[a-z0-9][a-z0-9_-]{0,31}$/;
@@ -130,11 +152,37 @@ function resolveClaudeProfileDir(dataDir, name) {
130
152
  function resolveHomeClaudeDir(homeDir = os.homedir()) {
131
153
  return path.join(homeDir, '.claude');
132
154
  }
155
+ /** Whether this process may chmod a folder `stat` describes: root, the folder's owner, or a platform with no owner to ask. */
156
+ function checkCanChmod(stat, uid) {
157
+ return uid === null || uid === 0 || stat.uid === uid;
158
+ }
159
+ /**
160
+ * Whether this process may write into the folder `dir` (`stat` describes it): its owner or root may, and so may anyone the folder's
161
+ * group or ACL lets write — a locked folder the CLI must still save its own files in is one an agent can add entries to, so it is not
162
+ * left alone for being another user's. With a `uid` other than the process's own (a test standing in for another owner) only the
163
+ * permission check speaks.
164
+ */
165
+ function checkCanWriteInto(dir, stat, uid) {
166
+ if (checkCanChmod(stat, uid) && uid === readCurrentUid())
167
+ return true;
168
+ try {
169
+ fs.accessSync(dir, fs.constants.W_OK);
170
+ return true;
171
+ }
172
+ catch {
173
+ return false;
174
+ }
175
+ }
176
+ /** The uid of this process; `null` where there is none (Windows). */
177
+ function readCurrentUid() {
178
+ return typeof process.getuid === 'function' ? process.getuid() : null;
179
+ }
133
180
  /**
134
- * @description Create a profile's config directory: `0700`, with the shared entries symlinked into `~/.claude`.
135
- * Idempotent — an existing directory keeps its login and only gains a missing link, so a re-run after a crash is
136
- * safe. Refuses `default` and an invalid name (defence in depth: the command gate already rejected them).
137
- * `~/.claude/projects` is created when absent so the link never dangles into the one entry the bot reads.
181
+ * @description Create a profile's config directory: `0700`, with the entries it mirrors from `~/.claude` linked
182
+ * ({@link repairClaudeProfileLayout}). Idempotent — an existing directory keeps its login and its state, gains a missing link, and has
183
+ * anything that stands in a link's place moved aside; so a re-run after a crash is safe. Refuses `default` and an invalid name
184
+ * (defence in depth: the command gate already rejected them). `~/.claude/projects` is created when absent so the link never dangles
185
+ * into the one entry the bot reads. A folder another user owns (an operator locked it) is not chmod'ed, and one this user cannot write is not written to.
138
186
  */
139
187
  function createClaudeProfileLayout(input) {
140
188
  const { dataDir, name } = input;
@@ -146,31 +194,257 @@ function createClaudeProfileLayout(input) {
146
194
  throw new Error('the default profile has no directory of its own');
147
195
  fs.mkdirSync(resolveClaudeProfilesRoot(dataDir), { recursive: true, mode: 0o700 });
148
196
  fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
149
- fs.chmodSync(dir, 0o700);
197
+ const dirStat = fs.statSync(dir);
198
+ // Only the owner may chmod (anyone else gets EPERM), and nothing is written when the mode is already right.
199
+ if (checkCanChmod(dirStat, input.uid === undefined ? readCurrentUid() : input.uid) && (dirStat.mode & 0o777) !== 0o700)
200
+ fs.chmodSync(dir, 0o700);
150
201
  fs.mkdirSync(path.join(homeClaudeDir, 'projects'), { recursive: true });
151
- const linked = [...exports.claudeProfileSharedEntries];
152
- for (const entry of exports.claudeProfileOptionalSharedEntries) {
153
- if (fs.existsSync(path.join(homeClaudeDir, entry)))
154
- linked.push(entry);
202
+ repairClaudeProfileLayout({ dataDir, name, homeClaudeDir, uid: input.uid, isStrict: true });
203
+ return dir;
204
+ }
205
+ /** Profiles whose unrepairable layout was already warned about by this process: one warning each, not one per launch. */
206
+ const unrepairedWarnedDirs = new Set();
207
+ /** For tests only: forget which profiles were warned about. */
208
+ function resetClaudeProfileRepairWarningsForTests() {
209
+ unrepairedWarnedDirs.clear();
210
+ configRiskSeen.clear();
211
+ }
212
+ /** Whether the link at `linkPath` points at `target`: the same path, or paths that resolve to one real entry (an old spelling of it). */
213
+ function checkIsLinkTo(linkPath, target) {
214
+ let raw;
215
+ try {
216
+ raw = fs.readlinkSync(linkPath);
217
+ }
218
+ catch {
219
+ return false;
220
+ }
221
+ if (path.resolve(path.dirname(linkPath), raw) === path.resolve(target))
222
+ return true;
223
+ try {
224
+ return fs.realpathSync(linkPath) === fs.realpathSync(target);
225
+ }
226
+ catch {
227
+ return false;
228
+ }
229
+ }
230
+ /** `YYYYMMDDTHHMMSSZ` of an instant — the suffix of a moved-aside entry. */
231
+ function formatMovedAsideStamp(nowMs) {
232
+ return new Date(nowMs).toISOString().replace(/[-:]/g, '').replace(/\.\d+Z$/, 'Z');
233
+ }
234
+ /** A free `<entry>.moved-<UTC time>` name in `dir` (`-2`, `-3`… when two moves land in one second). */
235
+ function pickMovedAsideName(dir, entry, nowMs) {
236
+ const base = `${entry}.moved-${formatMovedAsideStamp(nowMs)}`;
237
+ let candidate = base;
238
+ for (let n = 2; fs.existsSync(path.join(dir, candidate)) || isDanglingLink(path.join(dir, candidate)); n += 1)
239
+ candidate = `${base}-${n}`;
240
+ return candidate;
241
+ }
242
+ function isDanglingLink(linkPath) {
243
+ try {
244
+ return fs.lstatSync(linkPath).isSymbolicLink();
245
+ }
246
+ catch {
247
+ return false;
155
248
  }
156
- for (const entry of linked) {
157
- const linkPath = path.join(dir, entry);
249
+ }
250
+ /**
251
+ * @description Put a profile's folder back the way {@link createClaudeProfileLayout} made it, as far as the entries Claude Code loads
252
+ * as user-level configuration go ({@link claudeProfileSharedEntries} always, {@link claudeProfileOptionalSharedEntries} where
253
+ * `~/.claude` has them): each is a link to `~/.claude/<entry>`. Run right before every launch under the folder, so it is cheap — a few
254
+ * `lstat`s, and NOT ONE write when the layout is right (a link into `~/.claude` that dangles is right: it is the one the bot made).
255
+ * What stands in a link's place — a real file or directory, a link elsewhere, an entry `~/.claude` has no counterpart of — is MOVED
256
+ * ASIDE as `<entry>.moved-<UTC time>`, never deleted (it may hold the operator's data), one log line each, and the right link restored.
257
+ *
258
+ * Everything else in the folder is the account's own state — `.credentials.json`, `.claude.json`, backups, history, caches, the
259
+ * contents behind the `projects` link — and is never touched.
260
+ *
261
+ * A folder another user owns that this user cannot write (an operator locked it) is not written to: a wrong layout there is warned
262
+ * about ONCE per profile per process, and the launch goes ahead — the agent runs as the same user as the bot, so a folder the bot
263
+ * cannot write is one the agent could not plant in either. A locked folder this user CAN still write (its group or ACL lets the CLI
264
+ * save its own files there) is repaired like any other — an agent could add entries to it — as far as the operator's entries allow
265
+ * (with the sticky bit their links cannot be moved). A write that fails is warned about once the same way, unless `isStrict` (the
266
+ * creation path), which throws it.
267
+ */
268
+ function repairClaudeProfileLayout(input) {
269
+ const { dataDir, name } = input;
270
+ const log = input.log ?? ((line) => console.warn(line));
271
+ const dir = resolveClaudeProfileDir(dataDir, name);
272
+ const skipped = { dir: null, status: 'skipped', actions: [], pending: [] };
273
+ if (dir === null || !checkIsValidClaudeProfileName(name))
274
+ return skipped;
275
+ let dirStat;
276
+ try {
277
+ dirStat = fs.statSync(dir);
278
+ }
279
+ catch {
280
+ return skipped;
281
+ }
282
+ if (!dirStat.isDirectory())
283
+ return skipped;
284
+ const homeClaudeDir = input.homeClaudeDir ?? resolveHomeClaudeDir();
285
+ const specs = [
286
+ ...exports.claudeProfileSharedEntries.map((entry) => ({ entry, isAlwaysLinked: true })),
287
+ ...exports.claudeProfileOptionalSharedEntries.map((entry) => ({ entry, isAlwaysLinked: false })),
288
+ ];
289
+ const plan = [];
290
+ for (const { entry, isAlwaysLinked } of specs) {
158
291
  const target = path.join(homeClaudeDir, entry);
292
+ const isLinkWanted = isAlwaysLinked || fs.existsSync(target);
293
+ let stat = null;
159
294
  try {
160
- const existing = fs.lstatSync(linkPath);
161
- // A real file or dir of the profile's own (the CLI wrote one before the link existed) is left alone.
162
- if (!existing.isSymbolicLink())
163
- continue;
164
- if (fs.readlinkSync(linkPath) === target)
165
- continue;
166
- fs.unlinkSync(linkPath);
295
+ stat = fs.lstatSync(path.join(dir, entry));
167
296
  }
168
297
  catch {
169
- /* absent → create below */
298
+ stat = null;
299
+ }
300
+ if (stat === null) {
301
+ if (isLinkWanted)
302
+ plan.push({ entry, found: 'missing', isMoveNeeded: false, target });
303
+ }
304
+ else if (stat.isSymbolicLink()) {
305
+ if (!checkIsLinkTo(path.join(dir, entry), target))
306
+ plan.push({ entry, found: 'wrongLink', isMoveNeeded: true, target: isLinkWanted ? target : null });
307
+ }
308
+ else {
309
+ plan.push({ entry, found: stat.isDirectory() ? 'directory' : stat.isFile() ? 'file' : 'other', isMoveNeeded: true, target: isLinkWanted ? target : null });
170
310
  }
171
- fs.symlinkSync(target, linkPath);
172
311
  }
173
- return dir;
312
+ if (plan.length === 0)
313
+ return { dir, status: 'ok', actions: [], pending: [] };
314
+ const warnOnce = (line) => {
315
+ if (unrepairedWarnedDirs.has(dir))
316
+ return;
317
+ unrepairedWarnedDirs.add(dir);
318
+ log(line);
319
+ };
320
+ const uid = input.uid === undefined ? readCurrentUid() : input.uid;
321
+ if (!checkCanWriteInto(dir, dirStat, uid)) {
322
+ const pending = plan.map((step) => step.entry);
323
+ warnOnce(`[accounts] profile ${name}: ${pending.join(', ')} ${pending.length === 1 ? 'is' : 'are'} not what the layout expects, but this user cannot write the folder (another user locked it), so nothing was changed; launching anyway`);
324
+ return { dir, status: 'notOwned', actions: [], pending };
325
+ }
326
+ const nowMs = (input.now ?? Date.now)();
327
+ const actions = [];
328
+ const pending = [];
329
+ let firstError = null;
330
+ for (const step of plan) {
331
+ const entryPath = path.join(dir, step.entry);
332
+ try {
333
+ let movedTo = null;
334
+ if (step.isMoveNeeded) {
335
+ movedTo = pickMovedAsideName(dir, step.entry, nowMs);
336
+ fs.renameSync(entryPath, path.join(dir, movedTo));
337
+ log(`[accounts] profile ${name}: ${step.entry} was ${step.found === 'wrongLink' ? 'a link to somewhere else' : `a ${step.found} of its own`}, not the link into ~/.claude — moved aside to ${movedTo}${step.target === null ? ' (~/.claude has no such entry)' : ''}`);
338
+ }
339
+ if (step.target !== null) {
340
+ if (step.entry === 'projects')
341
+ fs.mkdirSync(step.target, { recursive: true });
342
+ try {
343
+ fs.symlinkSync(step.target, entryPath);
344
+ }
345
+ catch (linkError) {
346
+ // Another process — the bot's watch of the profiles folder adopting this very folder, a CLI call — made the same link between the plan
347
+ // and this write: the layout is what this step wanted, so it is done. Anything else at that path is a failure as before.
348
+ const isLinkMadeMeanwhile = linkError instanceof Error && 'code' in linkError && linkError.code === 'EEXIST' && checkIsLinkTo(entryPath, step.target);
349
+ if (!isLinkMadeMeanwhile)
350
+ throw linkError;
351
+ }
352
+ }
353
+ actions.push({ entry: step.entry, found: step.found, movedTo, linkedTo: step.target });
354
+ }
355
+ catch (e) {
356
+ pending.push(step.entry);
357
+ firstError ??= e;
358
+ }
359
+ }
360
+ if (pending.length === 0)
361
+ return { dir, status: 'ok', actions, pending };
362
+ if (input.isStrict === true)
363
+ throw firstError;
364
+ warnOnce(`[accounts] profile ${name}: ${pending.join(', ')} could not be put right (${firstError instanceof Error ? firstError.message : String(firstError)}); launching anyway`);
365
+ return { dir, status: 'failed', actions, pending };
366
+ }
367
+ /**
368
+ * @description What a profile's `.claude.json` — the account's own state, which the repair never edits — holds that Claude Code treats
369
+ * as configuration with an effect: MCP servers (the docs keep them in `~/.claude.json`, per project under `projects.<path>.mcpServers`,
370
+ * and a profile's file carries them at the top level too), and, defensively, the settings-style keys `hooks`, `env`, `apiKeyHelper`
371
+ * and `statusLine` (the docs place those in `settings.json`; whether the CLI honours them in `.claude.json` is not documented, so a
372
+ * mention is a pointer, not a verdict). Names only — never a command, argument or value. `[]` for a file that is absent, too big or
373
+ * not JSON.
374
+ */
375
+ function listClaudeProfileConfigRisks(configDir) {
376
+ const file = path.join(configDir, '.claude.json');
377
+ let parsed;
378
+ try {
379
+ if (fs.statSync(file).size > claudeJsonMaxReadBytes)
380
+ return [];
381
+ parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
382
+ }
383
+ catch {
384
+ return [];
385
+ }
386
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
387
+ return [];
388
+ const record = parsed;
389
+ const risks = [];
390
+ const nameServers = (servers) => (servers && typeof servers === 'object' && !Array.isArray(servers)
391
+ ? Object.keys(servers).slice(0, configRiskNameLimit).map((serverName) => serverName.replace(/[^\w.@ -]/g, '?').slice(0, 40))
392
+ : []);
393
+ const topServers = nameServers(record.mcpServers);
394
+ if (topServers.length > 0)
395
+ risks.push(`mcpServers: ${topServers.join(', ')}`);
396
+ const projects = record.projects && typeof record.projects === 'object' && !Array.isArray(record.projects) ? Object.values(record.projects) : [];
397
+ const projectServerCount = projects.filter((project) => project && typeof project === 'object' && nameServers(project.mcpServers).length > 0).length;
398
+ if (projectServerCount > 0)
399
+ risks.push(`projects.*.mcpServers: ${projectServerCount} project(s)`);
400
+ for (const key of claudeJsonSettingsLikeKeys) {
401
+ if (key in record)
402
+ risks.push(`${key} (a settings key, not documented for this file)`);
403
+ }
404
+ return risks;
405
+ }
406
+ /** A `.claude.json` bigger than this is not read for the warning (the real ones are ~100 kB). */
407
+ const claudeJsonMaxReadBytes = 8 * 1024 * 1024;
408
+ const configRiskNameLimit = 10;
409
+ const claudeJsonSettingsLikeKeys = ['hooks', 'env', 'apiKeyHelper', 'statusLine'];
410
+ /** What `.claude.json` held the last time the warning looked, per folder: `size:mtime` (skip the read while it is the same) and the risks said. */
411
+ const configRiskSeen = new Map();
412
+ /**
413
+ * @description THE call every launch under a profile folder makes first (a bot session, a sign-in or status probe, a worker the bot or
414
+ * the CLI points at an account): repair the folder's layout ({@link repairClaudeProfileLayout}), then say — once per distinct finding,
415
+ * not per launch — what its `.claude.json` configures ({@link listClaudeProfileConfigRisks}); the file is read only when its size or
416
+ * time moved. `configDir` is the directory a process is about to get as `CLAUDE_CONFIG_DIR`: `null` (the default account) and any
417
+ * directory that is not `<dataDir>/claude-profiles/<valid name>` are left alone. Never throws — a launch must not fail on a repair.
418
+ */
419
+ function repairClaudeProfileFolderForLaunch(input) {
420
+ const skipped = { dir: null, status: 'skipped', actions: [], pending: [] };
421
+ if (input.configDir === null)
422
+ return skipped;
423
+ const log = input.log ?? ((line) => console.warn(line));
424
+ const resolved = path.resolve(input.configDir);
425
+ const name = path.basename(resolved);
426
+ if (path.dirname(resolved) !== path.resolve(resolveClaudeProfilesRoot(input.dataDir)) || !checkIsValidClaudeProfileName(name))
427
+ return skipped;
428
+ try {
429
+ const result = repairClaudeProfileLayout({ dataDir: input.dataDir, name, homeClaudeDir: input.homeClaudeDir, uid: input.uid, now: input.now, log });
430
+ if (result.dir === null)
431
+ return result;
432
+ const stat = fs.statSync(path.join(result.dir, '.claude.json'), { throwIfNoEntry: false });
433
+ const stamp = stat === undefined ? 'none' : `${stat.size}:${stat.mtimeMs}`;
434
+ const seen = configRiskSeen.get(result.dir);
435
+ if (seen?.stamp !== stamp) {
436
+ const said = listClaudeProfileConfigRisks(result.dir).join('; ');
437
+ configRiskSeen.set(result.dir, { stamp, said });
438
+ if (said !== '' && said !== seen?.said) {
439
+ log(`[accounts] profile ${name}: its .claude.json (the account's own state — not checked or edited by the bot) configures ${said}. These run as this account's user-level config; make sure they are yours`);
440
+ }
441
+ }
442
+ return result;
443
+ }
444
+ catch (e) {
445
+ log(`[accounts] profile ${name}: the pre-launch repair of its folder failed: ${e instanceof Error ? e.message : String(e)}`);
446
+ return skipped;
447
+ }
174
448
  }
175
449
  /**
176
450
  * @description Remove a profile's directory — its login with it. `fs.rmSync` removes the symlinks AS LINKS, so