charness 3.7.0 → 3.9.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 (393) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/DEVELOPMENT.md +8 -2
  3. package/README.md +5 -5
  4. package/SETUP.md +17 -5
  5. package/agent-plugin/skills/charness-manager/SKILL.md +3 -3
  6. package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
  7. package/dist/adapters/openCodeAdapter.js +2 -1
  8. package/dist/adapters/openCodeAdapter.js.map +1 -1
  9. package/dist/bot.d.ts.map +1 -1
  10. package/dist/bot.js +50 -9
  11. package/dist/bot.js.map +1 -1
  12. package/dist/cli.d.ts +2 -0
  13. package/dist/cli.d.ts.map +1 -1
  14. package/dist/cli.js +56 -6
  15. package/dist/cli.js.map +1 -1
  16. package/dist/configDirFile.d.ts +7 -3
  17. package/dist/configDirFile.d.ts.map +1 -1
  18. package/dist/configDirFile.js +12 -5
  19. package/dist/configDirFile.js.map +1 -1
  20. package/dist/connectors/telegram/commands/botCore.d.ts +5 -1
  21. package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -1
  22. package/dist/connectors/telegram/commands/runners.d.ts +52 -0
  23. package/dist/connectors/telegram/commands/runners.d.ts.map +1 -0
  24. package/dist/connectors/telegram/commands/runners.js +524 -0
  25. package/dist/connectors/telegram/commands/runners.js.map +1 -0
  26. package/dist/connectors/telegram/runnerPairingMessages.d.ts +29 -0
  27. package/dist/connectors/telegram/runnerPairingMessages.d.ts.map +1 -0
  28. package/dist/connectors/telegram/runnerPairingMessages.js +112 -0
  29. package/dist/connectors/telegram/runnerPairingMessages.js.map +1 -0
  30. package/dist/i18n/de.d.ts.map +1 -1
  31. package/dist/i18n/de.js +60 -0
  32. package/dist/i18n/de.js.map +1 -1
  33. package/dist/i18n/en.d.ts.map +1 -1
  34. package/dist/i18n/en.js +60 -0
  35. package/dist/i18n/en.js.map +1 -1
  36. package/dist/i18n/es.d.ts.map +1 -1
  37. package/dist/i18n/es.js +60 -0
  38. package/dist/i18n/es.js.map +1 -1
  39. package/dist/i18n/fr.d.ts.map +1 -1
  40. package/dist/i18n/fr.js +60 -0
  41. package/dist/i18n/fr.js.map +1 -1
  42. package/dist/i18n/hi.d.ts.map +1 -1
  43. package/dist/i18n/hi.js +60 -0
  44. package/dist/i18n/hi.js.map +1 -1
  45. package/dist/i18n/ja.d.ts.map +1 -1
  46. package/dist/i18n/ja.js +60 -0
  47. package/dist/i18n/ja.js.map +1 -1
  48. package/dist/i18n/ka.d.ts.map +1 -1
  49. package/dist/i18n/ka.js +60 -0
  50. package/dist/i18n/ka.js.map +1 -1
  51. package/dist/i18n/pt.d.ts.map +1 -1
  52. package/dist/i18n/pt.js +60 -0
  53. package/dist/i18n/pt.js.map +1 -1
  54. package/dist/i18n/ru.d.ts.map +1 -1
  55. package/dist/i18n/ru.js +60 -0
  56. package/dist/i18n/ru.js.map +1 -1
  57. package/dist/i18n/uk.d.ts.map +1 -1
  58. package/dist/i18n/uk.js +60 -0
  59. package/dist/i18n/uk.js.map +1 -1
  60. package/dist/i18n/uz.d.ts.map +1 -1
  61. package/dist/i18n/uz.js +60 -0
  62. package/dist/i18n/uz.js.map +1 -1
  63. package/dist/i18n/zh.d.ts.map +1 -1
  64. package/dist/i18n/zh.js +60 -0
  65. package/dist/i18n/zh.js.map +1 -1
  66. package/dist/index.d.ts +1 -1
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +3 -1
  69. package/dist/index.js.map +1 -1
  70. package/dist/installManager.d.ts +57 -1
  71. package/dist/installManager.d.ts.map +1 -1
  72. package/dist/installManager.js +88 -10
  73. package/dist/installManager.js.map +1 -1
  74. package/dist/instanceSettings.d.ts +12 -2
  75. package/dist/instanceSettings.d.ts.map +1 -1
  76. package/dist/instanceSettings.js +17 -3
  77. package/dist/instanceSettings.js.map +1 -1
  78. package/dist/outputTrace.d.ts +6 -0
  79. package/dist/outputTrace.d.ts.map +1 -1
  80. package/dist/outputTrace.js +24 -1
  81. package/dist/outputTrace.js.map +1 -1
  82. package/dist/remoteRun/cliArgs.d.ts +2 -0
  83. package/dist/remoteRun/cliArgs.d.ts.map +1 -1
  84. package/dist/remoteRun/cliArgs.js +11 -2
  85. package/dist/remoteRun/cliArgs.js.map +1 -1
  86. package/dist/remoteRun/commands.d.ts +21 -0
  87. package/dist/remoteRun/commands.d.ts.map +1 -1
  88. package/dist/remoteRun/commands.js +38 -17
  89. package/dist/remoteRun/commands.js.map +1 -1
  90. package/dist/remoteRun/interrupts.d.ts +10 -0
  91. package/dist/remoteRun/interrupts.d.ts.map +1 -1
  92. package/dist/remoteRun/interrupts.js +43 -6
  93. package/dist/remoteRun/interrupts.js.map +1 -1
  94. package/dist/remoteRun/output.d.ts +2 -0
  95. package/dist/remoteRun/output.d.ts.map +1 -1
  96. package/dist/remoteRun/output.js +45 -0
  97. package/dist/remoteRun/output.js.map +1 -1
  98. package/dist/remoteRun/pairedRunners.d.ts +51 -0
  99. package/dist/remoteRun/pairedRunners.d.ts.map +1 -0
  100. package/dist/remoteRun/pairedRunners.js +165 -0
  101. package/dist/remoteRun/pairedRunners.js.map +1 -0
  102. package/dist/remoteRun/probe.d.ts +23 -1
  103. package/dist/remoteRun/probe.d.ts.map +1 -1
  104. package/dist/remoteRun/probe.js +45 -11
  105. package/dist/remoteRun/probe.js.map +1 -1
  106. package/dist/remoteRun/remoteRunCli.d.ts +13 -6
  107. package/dist/remoteRun/remoteRunCli.d.ts.map +1 -1
  108. package/dist/remoteRun/remoteRunCli.js +34 -59
  109. package/dist/remoteRun/remoteRunCli.js.map +1 -1
  110. package/dist/remoteRun/runnerClient.d.ts +2 -0
  111. package/dist/remoteRun/runnerClient.d.ts.map +1 -1
  112. package/dist/remoteRun/runnerClient.js +5 -1
  113. package/dist/remoteRun/runnerClient.js.map +1 -1
  114. package/dist/remoteRun/runnerSummary.d.ts +24 -0
  115. package/dist/remoteRun/runnerSummary.d.ts.map +1 -0
  116. package/dist/remoteRun/runnerSummary.js +86 -0
  117. package/dist/remoteRun/runnerSummary.js.map +1 -0
  118. package/dist/remoteRun/runnerWait.d.ts +68 -0
  119. package/dist/remoteRun/runnerWait.d.ts.map +1 -0
  120. package/dist/remoteRun/runnerWait.js +137 -0
  121. package/dist/remoteRun/runnerWait.js.map +1 -0
  122. package/dist/remoteRun/runnerWaitTiming.d.ts +16 -0
  123. package/dist/remoteRun/runnerWaitTiming.d.ts.map +1 -0
  124. package/dist/remoteRun/runnerWaitTiming.js +37 -0
  125. package/dist/remoteRun/runnerWaitTiming.js.map +1 -0
  126. package/dist/remoteRun/runners.d.ts +15 -8
  127. package/dist/remoteRun/runners.d.ts.map +1 -1
  128. package/dist/remoteRun/runners.js +59 -19
  129. package/dist/remoteRun/runners.js.map +1 -1
  130. package/dist/remoteRun/runnersCatalog.d.ts +14 -0
  131. package/dist/remoteRun/runnersCatalog.d.ts.map +1 -0
  132. package/dist/remoteRun/runnersCatalog.js +68 -0
  133. package/dist/remoteRun/runnersCatalog.js.map +1 -0
  134. package/dist/remoteRun/runnersConfig.d.ts +31 -20
  135. package/dist/remoteRun/runnersConfig.d.ts.map +1 -1
  136. package/dist/remoteRun/runnersConfig.js +14 -12
  137. package/dist/remoteRun/runnersConfig.js.map +1 -1
  138. package/dist/remoteRun/ssh.d.ts +22 -2
  139. package/dist/remoteRun/ssh.d.ts.map +1 -1
  140. package/dist/remoteRun/ssh.js +41 -7
  141. package/dist/remoteRun/ssh.js.map +1 -1
  142. package/dist/runnerUtility/adminCheck.d.ts +18 -0
  143. package/dist/runnerUtility/adminCheck.d.ts.map +1 -0
  144. package/dist/runnerUtility/adminCheck.js +69 -0
  145. package/dist/runnerUtility/adminCheck.js.map +1 -0
  146. package/dist/runnerUtility/adminService.d.ts +22 -0
  147. package/dist/runnerUtility/adminService.d.ts.map +1 -0
  148. package/dist/runnerUtility/adminService.js +145 -0
  149. package/dist/runnerUtility/adminService.js.map +1 -0
  150. package/dist/runnerUtility/appInstall.d.ts +25 -0
  151. package/dist/runnerUtility/appInstall.d.ts.map +1 -0
  152. package/dist/runnerUtility/appInstall.js +147 -0
  153. package/dist/runnerUtility/appInstall.js.map +1 -0
  154. package/dist/runnerUtility/appUpdate.d.ts +39 -0
  155. package/dist/runnerUtility/appUpdate.d.ts.map +1 -0
  156. package/dist/runnerUtility/appUpdate.js +90 -0
  157. package/dist/runnerUtility/appUpdate.js.map +1 -0
  158. package/dist/runnerUtility/execEnv.d.ts +21 -0
  159. package/dist/runnerUtility/execEnv.d.ts.map +1 -0
  160. package/dist/runnerUtility/execEnv.js +109 -0
  161. package/dist/runnerUtility/execEnv.js.map +1 -0
  162. package/dist/runnerUtility/execSession.d.ts +13 -0
  163. package/dist/runnerUtility/execSession.d.ts.map +1 -0
  164. package/dist/runnerUtility/execSession.js +58 -0
  165. package/dist/runnerUtility/execSession.js.map +1 -0
  166. package/dist/runnerUtility/hubClient.d.ts +30 -0
  167. package/dist/runnerUtility/hubClient.d.ts.map +1 -0
  168. package/dist/runnerUtility/hubClient.js +127 -0
  169. package/dist/runnerUtility/hubClient.js.map +1 -0
  170. package/dist/runnerUtility/injectStream.d.ts +9 -0
  171. package/dist/runnerUtility/injectStream.d.ts.map +1 -0
  172. package/dist/runnerUtility/injectStream.js +12 -0
  173. package/dist/runnerUtility/injectStream.js.map +1 -0
  174. package/dist/runnerUtility/iosCheck.d.ts +62 -0
  175. package/dist/runnerUtility/iosCheck.d.ts.map +1 -0
  176. package/dist/runnerUtility/iosCheck.js +200 -0
  177. package/dist/runnerUtility/iosCheck.js.map +1 -0
  178. package/dist/runnerUtility/launcher.d.ts +5 -0
  179. package/dist/runnerUtility/launcher.d.ts.map +1 -0
  180. package/dist/runnerUtility/launcher.js +85 -0
  181. package/dist/runnerUtility/launcher.js.map +1 -0
  182. package/dist/runnerUtility/linkLoop.d.ts +39 -0
  183. package/dist/runnerUtility/linkLoop.d.ts.map +1 -0
  184. package/dist/runnerUtility/linkLoop.js +274 -0
  185. package/dist/runnerUtility/linkLoop.js.map +1 -0
  186. package/dist/runnerUtility/localLinkStop.d.ts +23 -0
  187. package/dist/runnerUtility/localLinkStop.d.ts.map +1 -0
  188. package/dist/runnerUtility/localLinkStop.js +79 -0
  189. package/dist/runnerUtility/localLinkStop.js.map +1 -0
  190. package/dist/runnerUtility/machineReport.d.ts +39 -0
  191. package/dist/runnerUtility/machineReport.d.ts.map +1 -0
  192. package/dist/runnerUtility/machineReport.js +161 -0
  193. package/dist/runnerUtility/machineReport.js.map +1 -0
  194. package/dist/runnerUtility/packageId.d.ts +5 -0
  195. package/dist/runnerUtility/packageId.d.ts.map +1 -0
  196. package/dist/runnerUtility/packageId.js +64 -0
  197. package/dist/runnerUtility/packageId.js.map +1 -0
  198. package/dist/runnerUtility/pairArgs.d.ts +16 -0
  199. package/dist/runnerUtility/pairArgs.d.ts.map +1 -0
  200. package/dist/runnerUtility/pairArgs.js +17 -0
  201. package/dist/runnerUtility/pairArgs.js.map +1 -0
  202. package/dist/runnerUtility/pairingRecovery.d.ts +31 -0
  203. package/dist/runnerUtility/pairingRecovery.d.ts.map +1 -0
  204. package/dist/runnerUtility/pairingRecovery.js +24 -0
  205. package/dist/runnerUtility/pairingRecovery.js.map +1 -0
  206. package/dist/runnerUtility/pueueDaemon.d.ts +36 -0
  207. package/dist/runnerUtility/pueueDaemon.d.ts.map +1 -0
  208. package/dist/runnerUtility/pueueDaemon.js +165 -0
  209. package/dist/runnerUtility/pueueDaemon.js.map +1 -0
  210. package/dist/runnerUtility/rootServiceCli.d.ts +8 -0
  211. package/dist/runnerUtility/rootServiceCli.d.ts.map +1 -0
  212. package/dist/runnerUtility/rootServiceCli.js +31 -0
  213. package/dist/runnerUtility/rootServiceCli.js.map +1 -0
  214. package/dist/runnerUtility/runnerCli.d.ts +18 -0
  215. package/dist/runnerUtility/runnerCli.d.ts.map +1 -0
  216. package/dist/runnerUtility/runnerCli.js +190 -0
  217. package/dist/runnerUtility/runnerCli.js.map +1 -0
  218. package/dist/runnerUtility/runnerCommands.d.ts +76 -0
  219. package/dist/runnerUtility/runnerCommands.d.ts.map +1 -0
  220. package/dist/runnerUtility/runnerCommands.js +464 -0
  221. package/dist/runnerUtility/runnerCommands.js.map +1 -0
  222. package/dist/runnerUtility/runnerConfig.d.ts +63 -0
  223. package/dist/runnerUtility/runnerConfig.d.ts.map +1 -0
  224. package/dist/runnerUtility/runnerConfig.js +153 -0
  225. package/dist/runnerUtility/runnerConfig.js.map +1 -0
  226. package/dist/runnerUtility/runnerFlags.d.ts +9 -0
  227. package/dist/runnerUtility/runnerFlags.d.ts.map +1 -0
  228. package/dist/runnerUtility/runnerFlags.js +53 -0
  229. package/dist/runnerUtility/runnerFlags.js.map +1 -0
  230. package/dist/runnerUtility/runnerHome.d.ts +30 -0
  231. package/dist/runnerUtility/runnerHome.d.ts.map +1 -0
  232. package/dist/runnerUtility/runnerHome.js +82 -0
  233. package/dist/runnerUtility/runnerHome.js.map +1 -0
  234. package/dist/runnerUtility/runnerKeys.d.ts +11 -0
  235. package/dist/runnerUtility/runnerKeys.d.ts.map +1 -0
  236. package/dist/runnerUtility/runnerKeys.js +80 -0
  237. package/dist/runnerUtility/runnerKeys.js.map +1 -0
  238. package/dist/runnerUtility/runnerServers.d.ts +40 -0
  239. package/dist/runnerUtility/runnerServers.d.ts.map +1 -0
  240. package/dist/runnerUtility/runnerServers.js +79 -0
  241. package/dist/runnerUtility/runnerServers.js.map +1 -0
  242. package/dist/runnerUtility/serviceCommon.d.ts +97 -0
  243. package/dist/runnerUtility/serviceCommon.d.ts.map +1 -0
  244. package/dist/runnerUtility/serviceCommon.js +209 -0
  245. package/dist/runnerUtility/serviceCommon.js.map +1 -0
  246. package/dist/runnerUtility/serviceManager.d.ts +51 -0
  247. package/dist/runnerUtility/serviceManager.d.ts.map +1 -0
  248. package/dist/runnerUtility/serviceManager.js +344 -0
  249. package/dist/runnerUtility/serviceManager.js.map +1 -0
  250. package/dist/runnerUtility/serviceUnits.d.ts +38 -0
  251. package/dist/runnerUtility/serviceUnits.d.ts.map +1 -0
  252. package/dist/runnerUtility/serviceUnits.js +189 -0
  253. package/dist/runnerUtility/serviceUnits.js.map +1 -0
  254. package/dist/runnerUtility/toolInstall.d.ts +95 -0
  255. package/dist/runnerUtility/toolInstall.d.ts.map +1 -0
  256. package/dist/runnerUtility/toolInstall.js +232 -0
  257. package/dist/runnerUtility/toolInstall.js.map +1 -0
  258. package/dist/runnerUtility/versionPollTiming.d.ts +16 -0
  259. package/dist/runnerUtility/versionPollTiming.d.ts.map +1 -0
  260. package/dist/runnerUtility/versionPollTiming.js +36 -0
  261. package/dist/runnerUtility/versionPollTiming.js.map +1 -0
  262. package/dist/runners/authorizedKeys.d.ts +52 -0
  263. package/dist/runners/authorizedKeys.d.ts.map +1 -0
  264. package/dist/runners/authorizedKeys.js +153 -0
  265. package/dist/runners/authorizedKeys.js.map +1 -0
  266. package/dist/runners/bootstrapLine.d.ts +13 -0
  267. package/dist/runners/bootstrapLine.d.ts.map +1 -0
  268. package/dist/runners/bootstrapLine.js +154 -0
  269. package/dist/runners/bootstrapLine.js.map +1 -0
  270. package/dist/runners/gate.d.ts +41 -0
  271. package/dist/runners/gate.d.ts.map +1 -0
  272. package/dist/runners/gate.js +225 -0
  273. package/dist/runners/gate.js.map +1 -0
  274. package/dist/runners/gateLink.d.ts +26 -0
  275. package/dist/runners/gateLink.d.ts.map +1 -0
  276. package/dist/runners/gateLink.js +240 -0
  277. package/dist/runners/gateLink.js.map +1 -0
  278. package/dist/runners/gateProtocol.d.ts +104 -0
  279. package/dist/runners/gateProtocol.d.ts.map +1 -0
  280. package/dist/runners/gateProtocol.js +151 -0
  281. package/dist/runners/gateProtocol.js.map +1 -0
  282. package/dist/runners/gateWrapper.d.ts +6 -0
  283. package/dist/runners/gateWrapper.d.ts.map +1 -0
  284. package/dist/runners/gateWrapper.js +70 -0
  285. package/dist/runners/gateWrapper.js.map +1 -0
  286. package/dist/runners/hubAddress.d.ts +33 -0
  287. package/dist/runners/hubAddress.d.ts.map +1 -0
  288. package/dist/runners/hubAddress.js +88 -0
  289. package/dist/runners/hubAddress.js.map +1 -0
  290. package/dist/runners/hubAddressCandidates.d.ts +16 -0
  291. package/dist/runners/hubAddressCandidates.d.ts.map +1 -0
  292. package/dist/runners/hubAddressCandidates.js +96 -0
  293. package/dist/runners/hubAddressCandidates.js.map +1 -0
  294. package/dist/runners/hubIds.d.ts +16 -0
  295. package/dist/runners/hubIds.d.ts.map +1 -0
  296. package/dist/runners/hubIds.js +25 -0
  297. package/dist/runners/hubIds.js.map +1 -0
  298. package/dist/runners/hubKey.d.ts +6 -0
  299. package/dist/runners/hubKey.d.ts.map +1 -0
  300. package/dist/runners/hubKey.js +78 -0
  301. package/dist/runners/hubKey.js.map +1 -0
  302. package/dist/runners/hubLock.d.ts +7 -0
  303. package/dist/runners/hubLock.d.ts.map +1 -0
  304. package/dist/runners/hubLock.js +230 -0
  305. package/dist/runners/hubLock.js.map +1 -0
  306. package/dist/runners/hubPackage.d.ts +23 -0
  307. package/dist/runners/hubPackage.d.ts.map +1 -0
  308. package/dist/runners/hubPackage.js +184 -0
  309. package/dist/runners/hubPackage.js.map +1 -0
  310. package/dist/runners/hubPairing.d.ts +70 -0
  311. package/dist/runners/hubPairing.d.ts.map +1 -0
  312. package/dist/runners/hubPairing.js +277 -0
  313. package/dist/runners/hubPairing.js.map +1 -0
  314. package/dist/runners/hubPaths.d.ts +42 -0
  315. package/dist/runners/hubPaths.d.ts.map +1 -0
  316. package/dist/runners/hubPaths.js +96 -0
  317. package/dist/runners/hubPaths.js.map +1 -0
  318. package/dist/runners/hubRegistry.d.ts +134 -0
  319. package/dist/runners/hubRegistry.d.ts.map +1 -0
  320. package/dist/runners/hubRegistry.js +256 -0
  321. package/dist/runners/hubRegistry.js.map +1 -0
  322. package/dist/runners/linkControl.d.ts +38 -0
  323. package/dist/runners/linkControl.d.ts.map +1 -0
  324. package/dist/runners/linkControl.js +171 -0
  325. package/dist/runners/linkControl.js.map +1 -0
  326. package/dist/runners/pairCode.d.ts +30 -0
  327. package/dist/runners/pairCode.d.ts.map +1 -0
  328. package/dist/runners/pairCode.js +46 -0
  329. package/dist/runners/pairCode.js.map +1 -0
  330. package/dist/runners/pairingTiming.d.ts +18 -0
  331. package/dist/runners/pairingTiming.d.ts.map +1 -0
  332. package/dist/runners/pairingTiming.js +42 -0
  333. package/dist/runners/pairingTiming.js.map +1 -0
  334. package/dist/runners/removalTiming.d.ts +13 -0
  335. package/dist/runners/removalTiming.d.ts.map +1 -0
  336. package/dist/runners/removalTiming.js +17 -0
  337. package/dist/runners/removalTiming.js.map +1 -0
  338. package/dist/runners/runnerProxy.d.ts +9 -0
  339. package/dist/runners/runnerProxy.d.ts.map +1 -0
  340. package/dist/runners/runnerProxy.js +67 -0
  341. package/dist/runners/runnerProxy.js.map +1 -0
  342. package/dist/runners/runnerRemoval.d.ts +21 -0
  343. package/dist/runners/runnerRemoval.d.ts.map +1 -0
  344. package/dist/runners/runnerRemoval.js +94 -0
  345. package/dist/runners/runnerRemoval.js.map +1 -0
  346. package/dist/runners/runnerServiceKind.d.ts +10 -0
  347. package/dist/runners/runnerServiceKind.d.ts.map +1 -0
  348. package/dist/runners/runnerServiceKind.js +13 -0
  349. package/dist/runners/runnerServiceKind.js.map +1 -0
  350. package/dist/runners/runnersCli.d.ts +25 -0
  351. package/dist/runners/runnersCli.d.ts.map +1 -0
  352. package/dist/runners/runnersCli.js +239 -0
  353. package/dist/runners/runnersCli.js.map +1 -0
  354. package/dist/runners/runnersList.d.ts +14 -0
  355. package/dist/runners/runnersList.d.ts.map +1 -0
  356. package/dist/runners/runnersList.js +51 -0
  357. package/dist/runners/runnersList.js.map +1 -0
  358. package/dist/runners/runnersOverview.d.ts +20 -0
  359. package/dist/runners/runnersOverview.d.ts.map +1 -0
  360. package/dist/runners/runnersOverview.js +56 -0
  361. package/dist/runners/runnersOverview.js.map +1 -0
  362. package/dist/runners/sshKeys.d.ts +26 -0
  363. package/dist/runners/sshKeys.d.ts.map +1 -0
  364. package/dist/runners/sshKeys.js +60 -0
  365. package/dist/runners/sshKeys.js.map +1 -0
  366. package/dist/runners/tarArchive.d.ts +20 -0
  367. package/dist/runners/tarArchive.d.ts.map +1 -0
  368. package/dist/runners/tarArchive.js +70 -0
  369. package/dist/runners/tarArchive.js.map +1 -0
  370. package/dist/scheduler/mcpSurface.d.ts +11 -5
  371. package/dist/scheduler/mcpSurface.d.ts.map +1 -1
  372. package/dist/scheduler/mcpSurface.js +59 -26
  373. package/dist/scheduler/mcpSurface.js.map +1 -1
  374. package/dist/selfUpdate/selfCheck.d.ts +13 -0
  375. package/dist/selfUpdate/selfCheck.d.ts.map +1 -1
  376. package/dist/selfUpdate/selfCheck.js +9 -3
  377. package/dist/selfUpdate/selfCheck.js.map +1 -1
  378. package/dist/stt/sttInstallEntry.js +7 -4
  379. package/dist/stt/sttInstallEntry.js.map +1 -1
  380. package/dist/testTimings.d.ts +5 -2
  381. package/dist/testTimings.d.ts.map +1 -1
  382. package/dist/testTimings.js +10 -1
  383. package/dist/testTimings.js.map +1 -1
  384. package/dist/utils/agentEnvironment.d.ts +6 -2
  385. package/dist/utils/agentEnvironment.d.ts.map +1 -1
  386. package/dist/utils/agentEnvironment.js +13 -2
  387. package/dist/utils/agentEnvironment.js.map +1 -1
  388. package/dist/utils/runnersScreenPlan.d.ts +141 -0
  389. package/dist/utils/runnersScreenPlan.d.ts.map +1 -0
  390. package/dist/utils/runnersScreenPlan.js +272 -0
  391. package/dist/utils/runnersScreenPlan.js.map +1 -0
  392. package/package.json +5 -2
  393. package/remoteRun/runner.sh +81 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hubPaths.d.ts","sourceRoot":"","sources":["../../src/runners/hubPaths.ts"],"names":[],"mappings":"AAeA,8GAA8G;AAC9G,MAAM,WAAW,UAAU;IACzB,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,yGAAyG;IACzG,kBAAkB,EAAE,MAAM,CAAC;IAC3B,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,gGAAgG;IAChG,WAAW,EAAE,MAAM,CAAC;IACpB,sIAAsI;IACtI,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qHAAqH;AACrH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAOD,iGAAiG;AACjG,wBAAgB,gBAAgB,CAAC,SAAS,GAAE,OAAO,CAAC,UAAU,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,UAAU,CAWvG;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAYzD;AAED,6GAA6G;AAC7G,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,CAGjF;AAED,0HAA0H;AAC1H,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE3D"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getHandMadeRunnersPath = getHandMadeRunnersPath;
37
+ exports.createHubContext = createHubContext;
38
+ exports.getHubFilePaths = getHubFilePaths;
39
+ exports.getRunnerLinkPaths = getRunnerLinkPaths;
40
+ exports.getRunnerHostAlias = getRunnerHostAlias;
41
+ const os = __importStar(require("os"));
42
+ const path = __importStar(require("path"));
43
+ const runnersConfig_1 = require("../remoteRun/runnersConfig");
44
+ /**
45
+ * @description Where the hub keeps what paired runners need. ONE folder per OS user — `~/.config/charness/runners/`, beside the
46
+ * hand-made `runners.json` — and every `authorized_keys` line NAMES it (`gate --dir <dir>`), so nothing the gate does depends on
47
+ * `$HOME`, `DATA_DIR` or which instance runs it: any charness instance of the user, the bot and the CLI alike, shares one registry.
48
+ */
49
+ const runnersDirName = 'runners';
50
+ const sshDirName = '.ssh';
51
+ const authorizedKeysFileName = 'authorized_keys';
52
+ const cliFileName = 'cli.js';
53
+ /** @description The hand-made `runners.json` that sits beside the registry folder (see {@link createHubContext}). */
54
+ function getHandMadeRunnersPath(dir) {
55
+ return path.join(path.dirname(dir), 'runners.json');
56
+ }
57
+ /** @description `dist/cli.js` of the running charness: this file is `dist/runners/hubPaths.js`. */
58
+ function getOwnCliPath() {
59
+ return path.resolve(__dirname, '..', cliFileName);
60
+ }
61
+ /** @description The context of the real machine for `homeDir`; every field can be overridden. */
62
+ function createHubContext(overrides = {}) {
63
+ const homeDir = overrides.homeDir ?? os.homedir();
64
+ const cliPath = overrides.cliPath ?? getOwnCliPath();
65
+ return {
66
+ dir: overrides.dir ?? path.join(path.dirname((0, runnersConfig_1.getRunnersConfigPath)(homeDir)), runnersDirName),
67
+ authorizedKeysPath: overrides.authorizedKeysPath ?? path.join(homeDir, sshDirName, authorizedKeysFileName),
68
+ nodePath: overrides.nodePath ?? process.execPath,
69
+ cliPath,
70
+ packageRoot: overrides.packageRoot ?? path.resolve(path.dirname(cliPath), '..'),
71
+ log: overrides.log ?? ((line) => { console.warn(`[runners] ${line}`); }),
72
+ };
73
+ }
74
+ function getHubFilePaths(dir) {
75
+ return {
76
+ paired: path.join(dir, 'paired.json'),
77
+ pending: path.join(dir, 'pending.json'),
78
+ closed: path.join(dir, 'closed.json'),
79
+ hubKey: path.join(dir, 'hub_ed25519'),
80
+ hubPublicKey: path.join(dir, 'hub_ed25519.pub'),
81
+ knownHosts: path.join(dir, 'known_hosts'),
82
+ gate: path.join(dir, 'gate'),
83
+ linkDir: path.join(dir, 'link'),
84
+ packageDir: path.join(dir, 'package'),
85
+ };
86
+ }
87
+ /** @description The socket the gate of runner `runnerId` listens on, and the file that says who holds it. */
88
+ function getRunnerLinkPaths(dir, runnerId) {
89
+ const linkDir = getHubFilePaths(dir).linkDir;
90
+ return { socket: path.join(linkDir, `${runnerId}.sock`), state: path.join(linkDir, `${runnerId}.json`) };
91
+ }
92
+ /** @description The host alias of a runner in the hub's `known_hosts` (and the `HostKeyAlias` of the ssh calls to it). */
93
+ function getRunnerHostAlias(runnerId) {
94
+ return `charness-runner-${runnerId}`;
95
+ }
96
+ //# sourceMappingURL=hubPaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hubPaths.js","sourceRoot":"","sources":["../../src/runners/hubPaths.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,wDAEC;AAaD,4CAWC;AAED,0CAYC;AAGD,gDAGC;AAGD,gDAEC;AA/FD,uCAAyB;AACzB,2CAA6B;AAC7B,8DAAkE;AAElE;;;;GAIG;AAEH,MAAM,cAAc,GAAG,SAAS,CAAC;AACjC,MAAM,UAAU,GAAG,MAAM,CAAC;AAC1B,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AACjD,MAAM,WAAW,GAAG,QAAQ,CAAC;AA8B7B,qHAAqH;AACrH,SAAgB,sBAAsB,CAAC,GAAW;IAChD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC,CAAC;AACtD,CAAC;AAOD,mGAAmG;AACnG,SAAS,aAAa;IACpB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AACpD,CAAC;AAED,iGAAiG;AACjG,SAAgB,gBAAgB,CAAC,YAAwD,EAAE;IACzF,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;IAClD,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,IAAI,aAAa,EAAE,CAAC;IACrD,OAAO;QACL,GAAG,EAAE,SAAS,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAA,oCAAoB,EAAC,OAAO,CAAC,CAAC,EAAE,cAAc,CAAC;QAC5F,kBAAkB,EAAE,SAAS,C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AAC,OAAO,CAAC;IAC7C,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,QAAQ,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,QAAQ,OAAO,CAAC,EAAE,CAAC;AAC3G,CAAC;AAED,0HAA0H;AAC1H,SAAgB,kBAAkB,CAAC,QAAgB;IACjD,OAAO,mBAAmB,QAAQ,EAAE,CAAC;AACvC,CAAC"}
@@ -0,0 +1,134 @@
1
+ import { z } from 'zod';
2
+ import { type HubContext } from './hubPaths';
3
+ /** @description How the runner utility says it is kept running (reported at pairing). */
4
+ export declare const runnerServiceKinds: readonly ["foreground", "user-service", "system-service", "unknown"];
5
+ export type RunnerServiceKind = (typeof runnerServiceKinds)[number];
6
+ declare const pairedRunnerSchema: z.ZodObject<{
7
+ id: z.ZodString;
8
+ name: z.ZodString;
9
+ publicKey: z.ZodString;
10
+ keyFingerprint: z.ZodString;
11
+ hostKey: z.ZodString;
12
+ workDir: z.ZodString;
13
+ os: z.ZodString;
14
+ arch: z.ZodString;
15
+ version: z.ZodString;
16
+ serviceKind: z.ZodEnum<{
17
+ unknown: "unknown";
18
+ foreground: "foreground";
19
+ "user-service": "user-service";
20
+ "system-service": "system-service";
21
+ }>;
22
+ pairedAtMs: z.ZodNumber;
23
+ pairId: z.ZodString;
24
+ label: z.ZodString;
25
+ host: z.ZodString;
26
+ port: z.ZodNumber;
27
+ isPaused: z.ZodBoolean;
28
+ }, z.core.$strict>;
29
+ export declare const pairedFileSchema: z.ZodObject<{
30
+ rev: z.ZodNumber;
31
+ runners: z.ZodArray<z.ZodObject<{
32
+ id: z.ZodString;
33
+ name: z.ZodString;
34
+ publicKey: z.ZodString;
35
+ keyFingerprint: z.ZodString;
36
+ hostKey: z.ZodString;
37
+ workDir: z.ZodString;
38
+ os: z.ZodString;
39
+ arch: z.ZodString;
40
+ version: z.ZodString;
41
+ serviceKind: z.ZodEnum<{
42
+ unknown: "unknown";
43
+ foreground: "foreground";
44
+ "user-service": "user-service";
45
+ "system-service": "system-service";
46
+ }>;
47
+ pairedAtMs: z.ZodNumber;
48
+ pairId: z.ZodString;
49
+ label: z.ZodString;
50
+ host: z.ZodString;
51
+ port: z.ZodNumber;
52
+ isPaused: z.ZodBoolean;
53
+ }, z.core.$strict>>;
54
+ }, z.core.$strict>;
55
+ declare const pendingPairingSchema: z.ZodObject<{
56
+ pairId: z.ZodString;
57
+ publicKey: z.ZodString;
58
+ keyFingerprint: z.ZodString;
59
+ expiresAtMs: z.ZodNumber;
60
+ host: z.ZodString;
61
+ port: z.ZodNumber;
62
+ label: z.ZodString;
63
+ messageRef: z.ZodNullable<z.ZodString>;
64
+ }, z.core.$strict>;
65
+ declare const pendingFileSchema: z.ZodObject<{
66
+ pending: z.ZodArray<z.ZodObject<{
67
+ pairId: z.ZodString;
68
+ publicKey: z.ZodString;
69
+ keyFingerprint: z.ZodString;
70
+ expiresAtMs: z.ZodNumber;
71
+ host: z.ZodString;
72
+ port: z.ZodNumber;
73
+ label: z.ZodString;
74
+ messageRef: z.ZodNullable<z.ZodString>;
75
+ }, z.core.$strict>>;
76
+ }, z.core.$strict>;
77
+ declare const closedCodeSchema: z.ZodObject<{
78
+ pairId: z.ZodString;
79
+ closedAtMs: z.ZodNumber;
80
+ }, z.core.$strict>;
81
+ /** @name PairedRunner @description One attached machine. */
82
+ export type PairedRunner = z.infer<typeof pairedRunnerSchema>;
83
+ /** @name PairedFile @description `paired.json`. */
84
+ export type PairedFile = z.infer<typeof pairedFileSchema>;
85
+ /** @name PendingPairing @description One pairing code that is out. */
86
+ export type PendingPairing = z.infer<typeof pendingPairingSchema>;
87
+ /** @name PendingFile @description `pending.json`. */
88
+ export type PendingFile = z.infer<typeof pendingFileSchema>;
89
+ /** @name ClosedCode @description A pairing code that was closed unused, and when. */
90
+ export type ClosedCode = z.infer<typeof closedCodeSchema>;
91
+ /** @name ClosedCodesRead @description What `closed.json` holds, and — when it could not be used — why (the caller says it, once). */
92
+ export interface ClosedCodesRead {
93
+ codes: ClosedCode[];
94
+ problem: string | null;
95
+ }
96
+ export declare class HubRegistryError extends Error {
97
+ constructor(message: string);
98
+ }
99
+ /** @description The registry files were written but a file derived from them could not be; the next locked operation repairs it. */
100
+ export declare class HubDerivedFilesError extends HubRegistryError {
101
+ constructor(fileName: string, errnoCode: string);
102
+ }
103
+ /** @description `paired.json` right now (missing = nobody paired). */
104
+ export declare function readPairedFile(dir: string): PairedFile;
105
+ /** @description `pending.json` right now (missing = no code out). */
106
+ export declare function readPendingFile(dir: string): PendingFile;
107
+ /**
108
+ * @description `closed.json` right now: its codes, or none — with the problem named — when it cannot be read or does not validate. A trace
109
+ * must never stop the caller, so unlike the registry files this does not throw; the caller says the problem once.
110
+ */
111
+ export declare function readClosedCodes(dir: string): ClosedCodesRead;
112
+ /**
113
+ * @description Note that the code `pairId` was closed at `nowMs` (the newest {@link maxClosedCodes} are kept); the registry lock must be held. BEST
114
+ * EFFORT: a trace that cannot be written is said through `ctx.log` and costs only the nicer text («this line was used on a machine that was
115
+ * already paired» reads «expired»), never the closing it describes. A file that cannot be used is replaced.
116
+ */
117
+ export declare function recordClosedCode(ctx: HubContext, pairId: string, nowMs: number): void;
118
+ /** @description Write `paired.json`; the registry lock must be held. */
119
+ export declare function writePairedFile(dir: string, file: PairedFile): void;
120
+ /** @description Write `pending.json`; the registry lock must be held. */
121
+ export declare function writePendingFile(dir: string, file: PendingFile): void;
122
+ /** @description The `known_hosts` text for the ssh calls through the links: one line per runner, under its alias. */
123
+ export declare function renderKnownHosts(runners: readonly PairedRunner[]): string;
124
+ /** @description The lines of the managed `authorized_keys` block: every pairing code still open, then every paired runner. */
125
+ export declare function renderManagedBlockLines(ctx: HubContext, pending: readonly PendingPairing[], runners: readonly PairedRunner[], nowMs: number): string[];
126
+ /**
127
+ * @description Bring the derived files in line with the two registry files: `known_hosts` and the `authorized_keys` block, each written
128
+ * only when it differs, and the link files of runners that are no longer registered deleted. The registry lock must be held. The block goes LAST, so a key is never allowed before the files its gate reads
129
+ * are in place. The registry files are authoritative and are written BEFORE this runs; a failure here is reported as
130
+ * {@link HubDerivedFilesError} and mends itself, because every locked operation ends with this same call.
131
+ */
132
+ export declare function syncDerivedHubFiles(ctx: HubContext, pending: PendingFile, paired: PairedFile, nowMs: number): void;
133
+ export {};
134
+ //# sourceMappingURL=hubRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hubRegistry.d.ts","sourceRoot":"","sources":["../../src/runners/hubRegistry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAuC,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AA4BlF,yFAAyF;AACzF,eAAO,MAAM,kBAAkB,sEAAuE,CAAC;AACvG,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;kBAsBtB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;kBAI3B,CAAC;AAEH,QAAA,MAAM,oBAAoB;;;;;;;;;kBAYxB,CAAC;AAEH,QAAA,MAAM,iBAAiB;;;;;;;;;;;kBAA6D,CAAC;AAErF,QAAA,MAAM,gBAAgB;;;kBAAsF,CAAC;AAK7G,4DAA4D;AAC5D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,mDAAmD;AACnD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,sEAAsE;AACtE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,qDAAqD;AACrD,MAAM,MAAM,WAAW,GAAG,CA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,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAOtJ;AAUD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAelH"}
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.HubDerivedFilesError = exports.HubRegistryError = exports.pairedFileSchema = exports.runnerServiceKinds = void 0;
37
+ exports.readPairedFile = readPairedFile;
38
+ exports.readPendingFile = readPendingFile;
39
+ exports.readClosedCodes = readClosedCodes;
40
+ exports.recordClosedCode = recordClosedCode;
41
+ exports.writePairedFile = writePairedFile;
42
+ exports.writePendingFile = writePendingFile;
43
+ exports.renderKnownHosts = renderKnownHosts;
44
+ exports.renderManagedBlockLines = renderManagedBlockLines;
45
+ exports.syncDerivedHubFiles = syncDerivedHubFiles;
46
+ const fs = __importStar(require("fs"));
47
+ const zod_1 = require("zod");
48
+ const configDirFile_1 = require("../configDirFile");
49
+ const runnersConfig_1 = require("../remoteRun/runnersConfig");
50
+ const authorizedKeys_1 = require("./authorizedKeys");
51
+ const hubIds_1 = require("./hubIds");
52
+ const hubPaths_1 = require("./hubPaths");
53
+ const hubLock_1 = require("./hubLock");
54
+ const linkControl_1 = require("./linkControl");
55
+ const configDirFile_2 = require("../configDirFile");
56
+ const sshKeys_1 = require("./sshKeys");
57
+ /**
58
+ * @description The hub's registry files and what is derived from them. `paired.json` is the machines that are attached,
59
+ * `pending.json` the pairing codes that are out. Both are read freely (every write is a rename, a reader sees a whole file) and
60
+ * written only under the registry lock (`hubLock.ts`). `known_hosts` (the runners' host keys, for the ssh calls through the link)
61
+ * and the managed `authorized_keys` block are DERIVED from the two on every change — never edited on their own.
62
+ *
63
+ * A file that does not parse or validate stops the caller with the problem named (field and rule, no values): a registry that is
64
+ * silently treated as empty would be rewritten empty and lose every pairing.
65
+ *
66
+ * `closed.json` is the odd one out: a TRACE, not part of the registry's truth — the codes that were closed unused, so a code that was
67
+ * closed (its line was pasted for a machine that was already paired) can be told from one that ran out. Nothing depends on it for
68
+ * correctness, so it is read leniently (a file that cannot be used reads as none, and the problem is handed to the caller to say once) and
69
+ * its write never blocks the close it describes. It is a file of its own, not a field of a pending entry: the sweep drops pending entries
70
+ * at expiry, which would lose the trace for an instance that was down, and every reader of the pending list would have to honour it.
71
+ */
72
+ const registryFileMode = 0o600;
73
+ const knownHostsMode = 0o644;
74
+ const maxTextLength = 200;
75
+ const publicKeySchema = zod_1.z.string().refine(sshKeys_1.checkIsEd25519PublicKey, 'must be an ed25519 public key (type and key, no comment)');
76
+ /** @description How the runner utility says it is kept running (reported at pairing). */
77
+ exports.runnerServiceKinds = ['foreground', 'user-service', 'system-service', 'unknown'];
78
+ const pairedRunnerSchema = zod_1.z.strictObject({
79
+ id: hubIds_1.hubIdSchema,
80
+ name: zod_1.z.string().regex(runnersConfig_1.runnerNamePattern, 'must be lowercase letters, digits and single dashes').max(40),
81
+ /** The runner's own client key: what its `authorized_keys` line holds. */
82
+ publicKey: publicKeySchema,
83
+ keyFingerprint: zod_1.z.string().max(maxTextLength),
84
+ /** The host key of the runner's built-in ssh server: pinned by the gate and by `known_hosts`. */
85
+ hostKey: publicKeySchema,
86
+ workDir: runnersConfig_1.runnerWorkDirSchema,
87
+ os: zod_1.z.string().max(maxTextLength),
88
+ arch: zod_1.z.string().max(maxTextLength),
89
+ version: zod_1.z.string().max(maxTextLength),
90
+ serviceKind: zod_1.z.enum(exports.runnerServiceKinds),
91
+ pairedAtMs: zod_1.z.number().int().nonnegative(),
92
+ /** The pairing that made it: how the instance that offered the code finds out that it was used, and what makes a retry of `redeem` idempotent. */
93
+ pairId: hubIds_1.hubIdSchema,
94
+ /** What the runner was told about this hub (kept so a retried `redeem` is answered the same way after the pending entry is gone). */
95
+ label: zod_1.z.string().min(1).max(maxTextLength),
96
+ host: hubIds_1.hubHostSchema,
97
+ port: hubIds_1.hubPortSchema,
98
+ /** Set from the hub: the runner stays attached, but no job is sent to it. */
99
+ isPaused: zod_1.z.boolean(),
100
+ });
101
+ exports.pairedFileSchema = zod_1.z.strictObject({
102
+ /** Counts every change: a keyboard built from one revision never acts on a later list. */
103
+ rev: zod_1.z.number().int().nonnegative(),
104
+ runners: zod_1.z.array(pairedRunnerSchema),
105
+ });
106
+ const pendingPairingSchema = zod_1.z.strictObject({
107
+ pairId: hubIds_1.hubIdSchema,
108
+ /** The temporary key's PUBLIC half (the private half is in the code only). */
109
+ publicKey: publicKeySchema,
110
+ keyFingerprint: zod_1.z.string().max(maxTextLength),
111
+ expiresAtMs: zod_1.z.number().int().nonnegative(),
112
+ host: hubIds_1.hubHostSchema,
113
+ port: hubIds_1.hubPortSchema,
114
+ /** Whose charness it is, as the runner shows it (`@ExampleBot`, a host name). */
115
+ label: zod_1.z.string().min(1).max(maxTextLength),
116
+ /** The message the offering instance edits when the code is used or expires (opaque to the hub); `null` for the CLI. */
117
+ messageRef: zod_1.z.string().max(maxTextLength).nullable(),
118
+ });
119
+ const pendingFileSchema = zod_1.z.strictObject({ pending: zod_1.z.array(pendingPairingSchema) });
120
+ const closedCodeSchema = zod_1.z.strictObject({ pairId: hubIds_1.hubIdSchema, closedAtMs: zod_1.z.number().int().nonnegative() });
121
+ const closedFileSchema = zod_1.z.strictObject({ closed: zod_1.z.array(closedCodeSchema) });
122
+ /** The newest this many closings are kept: a closing is rare and its trace is wanted by a message that is still unsettled, so a cap is all the bound it needs. */
123
+ const maxClosedCodes = 50;
124
+ class HubRegistryError extends Error {
125
+ constructor(message) {
126
+ super(message);
127
+ this.name = 'HubRegistryError';
128
+ }
129
+ }
130
+ exports.HubRegistryError = HubRegistryError;
131
+ /** @description The registry files were written but a file derived from them could not be; the next locked operation repairs it. */
132
+ class HubDerivedFilesError extends HubRegistryError {
133
+ constructor(fileName, errnoCode) {
134
+ super(`the registry was updated but ${fileName} could not be written (${errnoCode}); the next runners command repairs it`);
135
+ this.name = 'HubDerivedFilesError';
136
+ }
137
+ }
138
+ exports.HubDerivedFilesError = HubDerivedFilesError;
139
+ function readRegistryFile(filePath, fileName, schema, createEmpty) {
140
+ let text;
141
+ try {
142
+ text = fs.readFileSync(filePath, 'utf8');
143
+ }
144
+ catch (error) {
145
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
146
+ return createEmpty();
147
+ throw new HubRegistryError(`${fileName} could not be read`);
148
+ }
149
+ let parsedJson;
150
+ try {
151
+ parsedJson = JSON.parse(text);
152
+ }
153
+ catch {
154
+ throw new HubRegistryError(`${fileName} is not valid JSON; fix or remove it by hand (nothing was changed)`);
155
+ }
156
+ const parsed = schema.safeParse(parsedJson);
157
+ if (parsed.success)
158
+ return parsed.data;
159
+ throw new HubRegistryError(`${fileName} is invalid: ${parsed.error.issues.map((issue) => `${issue.path.join('.') || '(root)'} ${issue.message}`).join('; ')}`);
160
+ }
161
+ /** @description `paired.json` right now (missing = nobody paired). */
162
+ function readPairedFile(dir) {
163
+ return readRegistryFile((0, hubPaths_1.getHubFilePaths)(dir).paired, 'paired.json', exports.pairedFileSchema, () => ({ rev: 0, runners: [] }));
164
+ }
165
+ /** @description `pending.json` right now (missing = no code out). */
166
+ function readPendingFile(dir) {
167
+ return readRegistryFile((0, hubPaths_1.getHubFilePaths)(dir).pending, 'pending.json', pendingFileSchema, () => ({ pending: [] }));
168
+ }
169
+ /**
170
+ * @description `closed.json` right now: its codes, or none — with the problem named — when it cannot be read or does not validate. A trace
171
+ * must never stop the caller, so unlike the registry files this does not throw; the caller says the problem once.
172
+ */
173
+ function readClosedCodes(dir) {
174
+ try {
175
+ return { codes: readRegistryFile((0, hubPaths_1.getHubFilePaths)(dir).closed, 'closed.json', closedFileSchema, () => ({ closed: [] })).closed, problem: null };
176
+ }
177
+ catch (error) {
178
+ if (error instanceof HubRegistryError)
179
+ return { codes: [], problem: `${error.message}; the codes in it read as expired` };
180
+ throw error;
181
+ }
182
+ }
183
+ /**
184
+ * @description Note that the code `pairId` was closed at `nowMs` (the newest {@link maxClosedCodes} are kept); the registry lock must be held. BEST
185
+ * EFFORT: a trace that cannot be written is said through `ctx.log` and costs only the nicer text («this line was used on a machine that was
186
+ * already paired» reads «expired»), never the closing it describes. A file that cannot be used is replaced.
187
+ */
188
+ function recordClosedCode(ctx, pairId, nowMs) {
189
+ const { codes, problem } = readClosedCodes(ctx.dir);
190
+ if (problem !== null)
191
+ ctx.log(`${problem}; it is written anew`);
192
+ try {
193
+ (0, hubLock_1.ensureHubDir)(ctx.dir);
194
+ (0, configDirFile_1.writeJsonFileAtomically)((0, hubPaths_1.getHubFilePaths)(ctx.dir).closed, closedFileSchema.parse({ closed: [...codes.filter((entry) => entry.pairId !== pairId), { pairId, closedAtMs: nowMs }].slice(-maxClosedCodes) }), registryFileMode);
195
+ }
196
+ catch (error) {
197
+ ctx.log(`closed.json could not be written (${(0, configDirFile_2.getCaughtErrnoCode)(error)}); the messages of the code that was just closed will read as expired`);
198
+ }
199
+ }
200
+ /** @description Write `paired.json`; the registry lock must be held. */
201
+ function writePairedFile(dir, file) {
202
+ (0, hubLock_1.ensureHubDir)(dir);
203
+ (0, configDirFile_1.writeJsonFileAtomically)((0, hubPaths_1.getHubFilePaths)(dir).paired, exports.pairedFileSchema.parse(file), registryFileMode);
204
+ }
205
+ /** @description Write `pending.json`; the registry lock must be held. */
206
+ function writePendingFile(dir, file) {
207
+ (0, hubLock_1.ensureHubDir)(dir);
208
+ (0, configDirFile_1.writeJsonFileAtomically)((0, hubPaths_1.getHubFilePaths)(dir).pending, pendingFileSchema.parse(file), registryFileMode);
209
+ }
210
+ /** @description The `known_hosts` text for the ssh calls through the links: one line per runner, under its alias. */
211
+ function renderKnownHosts(runners) {
212
+ return runners.map((runner) => `${(0, hubPaths_1.getRunnerHostAlias)(runner.id)} ${runner.hostKey}\n`).join('');
213
+ }
214
+ /** @description The lines of the managed `authorized_keys` block: every pairing code still open, then every paired runner. */
215
+ function renderManagedBlockLines(ctx, pending, runners, nowMs) {
216
+ const gatePath = (0, hubPaths_1.getHubFilePaths)(ctx.dir).gate;
217
+ const common = { gatePath, keysPath: ctx.authorizedKeysPath, dir: ctx.dir };
218
+ return [
219
+ ...pending.filter((pairing) => pairing.expiresAtMs > nowMs).map((pairing) => (0, authorizedKeys_1.buildTempKeyLine)({ ...common, publicKey: pairing.publicKey, expiresAtMs: pairing.expiresAtMs, pairId: pairing.pairId })),
220
+ ...runners.map((runner) => (0, authorizedKeys_1.buildRunnerKeyLine)({ ...common, publicKey: runner.publicKey, runnerId: runner.id })),
221
+ ];
222
+ }
223
+ function readTextIfPresent(filePath) {
224
+ try {
225
+ return fs.readFileSync(filePath, 'utf8');
226
+ }
227
+ catch {
228
+ return null;
229
+ }
230
+ }
231
+ /**
232
+ * @description Bring the derived files in line with the two registry files: `known_hosts` and the `authorized_keys` block, each written
233
+ * only when it differs, and the link files of runners that are no longer registered deleted. The registry lock must be held. The block goes LAST, so a key is never allowed before the files its gate reads
234
+ * are in place. The registry files are authoritative and are written BEFORE this runs; a failure here is reported as
235
+ * {@link HubDerivedFilesError} and mends itself, because every locked operation ends with this same call.
236
+ */
237
+ function syncDerivedHubFiles(ctx, pending, paired, nowMs) {
238
+ const knownHostsPath = (0, hubPaths_1.getHubFilePaths)(ctx.dir).knownHosts;
239
+ const knownHosts = renderKnownHosts(paired.runners);
240
+ try {
241
+ if (readTextIfPresent(knownHostsPath) !== knownHosts)
242
+ (0, configDirFile_1.writeTextFileAtomically)(knownHostsPath, knownHosts, knownHostsMode);
243
+ }
244
+ catch (error) {
245
+ throw new HubDerivedFilesError('known_hosts', (0, configDirFile_2.getCaughtErrnoCode)(error));
246
+ }
247
+ try {
248
+ (0, authorizedKeys_1.writeManagedBlock)(ctx.authorizedKeysPath, renderManagedBlockLines(ctx, pending.pending, paired.runners, nowMs));
249
+ }
250
+ catch (error) {
251
+ throw new HubDerivedFilesError('authorized_keys', (0, configDirFile_2.getCaughtErrnoCode)(error));
252
+ }
253
+ // The link files of a runner the registry does not know are leftovers: best effort, it cannot fail the operation that has already written its files.
254
+ (0, linkControl_1.sweepOrphanLinkRecords)(ctx.dir, paired.runners.map((runner) => runner.id), ctx.log);
255
+ }
256
+ //# sourceMappingURL=hubRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hubRegistry.js","sourceRoot":"","sources":["../../src/runners/hubRegistry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6IA,wCAEC;AAGD,0CAEC;AAMD,0CAOC;AAOD,4CASC;AAGD,0CAGC;AAGD,4CAGC;AAGD,4CAEC;AA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IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,oBAAoB,CAAC,iBAAiB,EAAE,IAAA,kCAAkB,EAAC,KAAK,CAAC,CAAC,CAAC;IAC/E,CAAC;IACD,qJAAqJ;IACrJ,IAAA,oCAAsB,EAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;AACtF,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { z } from 'zod';
2
+ declare const linkStateSchema: z.ZodObject<{
3
+ pid: z.ZodNumber;
4
+ sinceMs: z.ZodNumber;
5
+ lastBeatMs: z.ZodNumber;
6
+ endedAtMs: z.ZodNullable<z.ZodNumber>;
7
+ }, z.core.$strict>;
8
+ /** @name LinkState @description `link/<id>.json`. */
9
+ export type LinkState = z.infer<typeof linkStateSchema>;
10
+ export interface RunnerLinkStatus {
11
+ isOnline: boolean;
12
+ /** When the link in force started (only while online). */
13
+ sinceMs: number | null;
14
+ /** The last time the hub knew the link alive; `null` if it never was. */
15
+ lastSeenMs: number | null;
16
+ }
17
+ export declare function readLinkState(dir: string, runnerId: string): LinkState | null;
18
+ export declare function writeLinkState(dir: string, runnerId: string, state: LinkState): void;
19
+ /** @description Does anything accept a connection on the unix socket `socketPath` right now? */
20
+ export declare function probeSocket(socketPath: string, timeoutMs?: number): Promise<boolean>;
21
+ export declare function getRunnerLinkStatus(dir: string, runnerId: string): Promise<RunnerLinkStatus>;
22
+ /** @description Is `pid` a charness gate serving runner `runnerId`? (A pid in an old json may belong to anything by now.) */
23
+ export declare function checkIsGateProcessOf(pid: number, runnerId: string): boolean;
24
+ /** @description Cut the link of a runner that was removed: no new connection reaches it, its gate leaves, and its link files are deleted. */
25
+ export declare function cutRunnerLink(dir: string, runnerId: string): void;
26
+ /**
27
+ * @description Delete the link files (`<id>.json`, `<id>.sock`) of every runner that is not in `registeredRunnerIds`: a removal that was cut
28
+ * short, a gate that wrote its status after the removal, a runner dropped from the registry by hand. Records of a runner whose gate is still
29
+ * running are kept — it is on its way out, and {@link cutRunnerLink} still needs the pid to stop it.
30
+ *
31
+ * Best effort, and it NEVER throws: the registry operation that calls it has already written its files, and a folder that cannot be listed
32
+ * or a file that cannot be deleted is only leftover clutter, tried again by the next operation. What went wrong is handed to `onProblem`,
33
+ * which the caller must give (a sweep that cannot say what failed would hide exactly what it exists to report); a missing folder is not a
34
+ * problem: nothing was ever linked. Returns the names deleted.
35
+ */
36
+ export declare function sweepOrphanLinkRecords(dir: string, registeredRunnerIds: readonly string[], onProblem: (message: string) => void): string[];
37
+ export {};
38
+ //# sourceMappingURL=linkControl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linkControl.d.ts","sourceRoot":"","sources":["../../src/runners/linkControl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBxB,QAAA,MAAM,eAAe;;;;;kBAMnB,CAAC;AAEH,qDAAqD;AACrD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,yEAAyE;IACzE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAO7E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAGpF;AAED,gGAAgG;AAChG,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,GAAE,MAAuB,GAAG,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