@celljs/ta-host 4.8.0 → 4.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 (435) hide show
  1. package/README.en.md +33 -5
  2. package/README.md +33 -5
  3. package/cell.schema.json +4 -0
  4. package/cell.yml +2 -0
  5. package/esm/node/client-tool-broker.d.ts +11 -3
  6. package/esm/node/client-tool-broker.js +23 -3
  7. package/esm/node/host-protocol.d.ts +22 -1
  8. package/esm/node/host-protocol.js +1 -0
  9. package/esm/node/index.d.ts +4 -0
  10. package/esm/node/index.js +4 -0
  11. package/esm/node/live-run.d.ts +22 -0
  12. package/esm/node/live-run.js +58 -0
  13. package/esm/node/message-page.d.ts +17 -0
  14. package/esm/node/message-page.js +71 -0
  15. package/esm/node/package-server-impl.d.ts +9 -1
  16. package/esm/node/package-server-impl.js +16 -1
  17. package/esm/node/relay-bridge.d.ts +9 -1
  18. package/esm/node/relay-bridge.js +44 -4
  19. package/esm/node/session-catalog.d.ts +69 -0
  20. package/esm/node/session-catalog.js +211 -0
  21. package/esm/node/session-info-util.d.ts +4 -1
  22. package/esm/node/session-info-util.js +8 -3
  23. package/esm/node/settings-store.d.ts +1 -4
  24. package/esm/node/settings-store.js +11 -3
  25. package/esm/node/sign-in/access-server-impl.d.ts +19 -0
  26. package/esm/node/sign-in/access-server-impl.js +82 -0
  27. package/esm/node/sign-in/access-store.d.ts +65 -0
  28. package/esm/node/sign-in/access-store.js +175 -0
  29. package/esm/node/sign-in/index.d.ts +7 -0
  30. package/esm/node/sign-in/index.js +8 -0
  31. package/esm/node/sign-in/sign-in-flow.d.ts +58 -0
  32. package/esm/node/sign-in/sign-in-flow.js +104 -0
  33. package/esm/node/sign-in/sign-in-middleware.d.ts +10 -0
  34. package/esm/node/sign-in/sign-in-middleware.js +48 -0
  35. package/esm/node/sign-in/sign-in-pages.d.ts +31 -0
  36. package/esm/node/sign-in/sign-in-pages.js +118 -0
  37. package/esm/node/sign-in/sign-in-provider.d.ts +135 -0
  38. package/esm/node/sign-in/sign-in-provider.js +225 -0
  39. package/esm/node/sign-in/ta-sign-in.d.ts +10 -0
  40. package/esm/node/sign-in/ta-sign-in.js +32 -0
  41. package/esm/node/ta-access.d.ts +7 -0
  42. package/esm/node/ta-access.js +30 -1
  43. package/esm/node/ta-server-impl.d.ts +8 -3
  44. package/esm/node/ta-server-impl.js +25 -6
  45. package/esm/node/ta-session-factory.d.ts +1 -1
  46. package/esm/node/ta-session-factory.js +14 -4
  47. package/esm/node/ta-session-registry.d.ts +2 -0
  48. package/esm/node/ta-session-registry.js +23 -3
  49. package/esm/node/ta-session.d.ts +24 -2
  50. package/esm/node/ta-session.js +83 -6
  51. package/esm/node/temporary-packages.d.ts +46 -0
  52. package/esm/node/temporary-packages.js +114 -0
  53. package/esm/node/temporary-purge.d.ts +13 -0
  54. package/esm/node/temporary-purge.js +51 -0
  55. package/esm/node/web-extension-catalog.d.ts +28 -1
  56. package/esm/node/web-extension-catalog.js +173 -5
  57. package/esm/node/web-extension-util.d.ts +5 -1
  58. package/esm/node/web-extension-util.js +36 -5
  59. package/esm/node/workspace-service.js +1 -1
  60. package/lib/node/client-tool-broker.d.ts +11 -3
  61. package/lib/node/client-tool-broker.js +23 -3
  62. package/lib/node/host-protocol.d.ts +22 -1
  63. package/lib/node/host-protocol.js +2 -1
  64. package/lib/node/index.d.ts +4 -0
  65. package/lib/node/index.js +4 -0
  66. package/lib/node/live-run.d.ts +23 -0
  67. package/lib/node/live-run.js +62 -0
  68. package/lib/node/message-page.d.ts +18 -0
  69. package/lib/node/message-page.js +74 -0
  70. package/lib/node/package-server-impl.d.ts +9 -1
  71. package/lib/node/package-server-impl.js +15 -0
  72. package/lib/node/relay-bridge.d.ts +9 -1
  73. package/lib/node/relay-bridge.js +43 -3
  74. package/lib/node/session-catalog.d.ts +70 -0
  75. package/lib/node/session-catalog.js +214 -0
  76. package/lib/node/session-info-util.d.ts +4 -1
  77. package/lib/node/session-info-util.js +7 -2
  78. package/lib/node/settings-store.d.ts +1 -4
  79. package/lib/node/settings-store.js +11 -3
  80. package/lib/node/sign-in/access-server-impl.d.ts +20 -0
  81. package/lib/node/sign-in/access-server-impl.js +85 -0
  82. package/lib/node/sign-in/access-store.d.ts +66 -0
  83. package/lib/node/sign-in/access-store.js +179 -0
  84. package/lib/node/sign-in/index.d.ts +8 -0
  85. package/lib/node/sign-in/index.js +24 -0
  86. package/lib/node/sign-in/sign-in-flow.d.ts +59 -0
  87. package/lib/node/sign-in/sign-in-flow.js +108 -0
  88. package/lib/node/sign-in/sign-in-middleware.d.ts +11 -0
  89. package/lib/node/sign-in/sign-in-middleware.js +51 -0
  90. package/lib/node/sign-in/sign-in-pages.d.ts +32 -0
  91. package/lib/node/sign-in/sign-in-pages.js +121 -0
  92. package/lib/node/sign-in/sign-in-provider.d.ts +136 -0
  93. package/lib/node/sign-in/sign-in-provider.js +232 -0
  94. package/lib/node/sign-in/ta-sign-in.d.ts +11 -0
  95. package/lib/node/sign-in/ta-sign-in.js +35 -0
  96. package/lib/node/ta-access.d.ts +7 -0
  97. package/lib/node/ta-access.js +30 -1
  98. package/lib/node/ta-server-impl.d.ts +8 -3
  99. package/lib/node/ta-server-impl.js +24 -5
  100. package/lib/node/ta-session-factory.d.ts +1 -1
  101. package/lib/node/ta-session-factory.js +14 -4
  102. package/lib/node/ta-session-registry.d.ts +2 -0
  103. package/lib/node/ta-session-registry.js +23 -3
  104. package/lib/node/ta-session.d.ts +24 -2
  105. package/lib/node/ta-session.js +83 -6
  106. package/lib/node/temporary-packages.d.ts +47 -0
  107. package/lib/node/temporary-packages.js +118 -0
  108. package/lib/node/temporary-purge.d.ts +14 -0
  109. package/lib/node/temporary-purge.js +54 -0
  110. package/lib/node/web-extension-catalog.d.ts +28 -1
  111. package/lib/node/web-extension-catalog.js +172 -4
  112. package/lib/node/web-extension-util.d.ts +5 -1
  113. package/lib/node/web-extension-util.js +36 -5
  114. package/lib/node/workspace-service.js +1 -1
  115. package/package.json +17 -12
  116. package/esm/node/auth-server-impl.js.map +0 -1
  117. package/esm/node/client-channel.js.map +0 -1
  118. package/esm/node/client-tool-broker.js.map +0 -1
  119. package/esm/node/event-log.js.map +0 -1
  120. package/esm/node/exec-environment-factory.js.map +0 -1
  121. package/esm/node/extension-data-notifier.js.map +0 -1
  122. package/esm/node/extension-data.js.map +0 -1
  123. package/esm/node/extension-providers.js.map +0 -1
  124. package/esm/node/host-protocol.js.map +0 -1
  125. package/esm/node/index.js.map +0 -1
  126. package/esm/node/module.js.map +0 -1
  127. package/esm/node/package-host-extension.js.map +0 -1
  128. package/esm/node/package-hosts.js.map +0 -1
  129. package/esm/node/package-server-impl.js.map +0 -1
  130. package/esm/node/package-switch.js.map +0 -1
  131. package/esm/node/receipt-book.js.map +0 -1
  132. package/esm/node/relay-bridge.js.map +0 -1
  133. package/esm/node/remote/index.js.map +0 -1
  134. package/esm/node/remote/pi-directories.js.map +0 -1
  135. package/esm/node/remote/port-forwards.js.map +0 -1
  136. package/esm/node/remote/remote-hosts.js.map +0 -1
  137. package/esm/node/remote/remote-protocol.js.map +0 -1
  138. package/esm/node/remote/remote-server-impl.js.map +0 -1
  139. package/esm/node/remote-ui-context.js.map +0 -1
  140. package/esm/node/session-files.js.map +0 -1
  141. package/esm/node/session-info-util.js.map +0 -1
  142. package/esm/node/session-storage/file-session-storage.js.map +0 -1
  143. package/esm/node/session-storage/index.js.map +0 -1
  144. package/esm/node/session-storage/session-storage-protocol.js.map +0 -1
  145. package/esm/node/session-storage/stored-session.js.map +0 -1
  146. package/esm/node/settings-server-impl.js.map +0 -1
  147. package/esm/node/settings-store.js.map +0 -1
  148. package/esm/node/ta-access.js.map +0 -1
  149. package/esm/node/ta-errors.js.map +0 -1
  150. package/esm/node/ta-event-util.js.map +0 -1
  151. package/esm/node/ta-server-impl.js.map +0 -1
  152. package/esm/node/ta-session-factory.js.map +0 -1
  153. package/esm/node/ta-session-registry.js.map +0 -1
  154. package/esm/node/ta-session.js.map +0 -1
  155. package/esm/node/terminal-protocol.js.map +0 -1
  156. package/esm/node/terminal-service.js.map +0 -1
  157. package/esm/node/terminal-util.js.map +0 -1
  158. package/esm/node/web-extension-catalog.js.map +0 -1
  159. package/esm/node/web-extension-util.js.map +0 -1
  160. package/esm/node/working-directory.js.map +0 -1
  161. package/esm/node/workspace-files.js.map +0 -1
  162. package/esm/node/workspace-protocol.js.map +0 -1
  163. package/esm/node/workspace-server-impl.js.map +0 -1
  164. package/esm/node/workspace-service.js.map +0 -1
  165. package/esm/node/workspace-util.js.map +0 -1
  166. package/lib/node/auth-server-impl.d.ts.map +0 -1
  167. package/lib/node/auth-server-impl.js.map +0 -1
  168. package/lib/node/auth-server-impl.spec.d.ts +0 -2
  169. package/lib/node/auth-server-impl.spec.d.ts.map +0 -1
  170. package/lib/node/auth-server-impl.spec.js +0 -47
  171. package/lib/node/auth-server-impl.spec.js.map +0 -1
  172. package/lib/node/client-channel.d.ts.map +0 -1
  173. package/lib/node/client-channel.js.map +0 -1
  174. package/lib/node/client-channel.spec.d.ts +0 -2
  175. package/lib/node/client-channel.spec.d.ts.map +0 -1
  176. package/lib/node/client-channel.spec.js +0 -106
  177. package/lib/node/client-channel.spec.js.map +0 -1
  178. package/lib/node/client-tool-broker.d.ts.map +0 -1
  179. package/lib/node/client-tool-broker.js.map +0 -1
  180. package/lib/node/client-tool-broker.spec.d.ts +0 -2
  181. package/lib/node/client-tool-broker.spec.d.ts.map +0 -1
  182. package/lib/node/client-tool-broker.spec.js +0 -49
  183. package/lib/node/client-tool-broker.spec.js.map +0 -1
  184. package/lib/node/event-log.d.ts.map +0 -1
  185. package/lib/node/event-log.js.map +0 -1
  186. package/lib/node/event-log.spec.d.ts +0 -2
  187. package/lib/node/event-log.spec.d.ts.map +0 -1
  188. package/lib/node/event-log.spec.js +0 -48
  189. package/lib/node/event-log.spec.js.map +0 -1
  190. package/lib/node/exec-environment-factory.d.ts.map +0 -1
  191. package/lib/node/exec-environment-factory.js.map +0 -1
  192. package/lib/node/extension-data-notifier.d.ts.map +0 -1
  193. package/lib/node/extension-data-notifier.js.map +0 -1
  194. package/lib/node/extension-data-notifier.spec.d.ts +0 -2
  195. package/lib/node/extension-data-notifier.spec.d.ts.map +0 -1
  196. package/lib/node/extension-data-notifier.spec.js +0 -35
  197. package/lib/node/extension-data-notifier.spec.js.map +0 -1
  198. package/lib/node/extension-data.d.ts.map +0 -1
  199. package/lib/node/extension-data.js.map +0 -1
  200. package/lib/node/extension-data.spec.d.ts +0 -2
  201. package/lib/node/extension-data.spec.d.ts.map +0 -1
  202. package/lib/node/extension-data.spec.js +0 -99
  203. package/lib/node/extension-data.spec.js.map +0 -1
  204. package/lib/node/extension-providers.d.ts.map +0 -1
  205. package/lib/node/extension-providers.js.map +0 -1
  206. package/lib/node/host-protocol.d.ts.map +0 -1
  207. package/lib/node/host-protocol.js.map +0 -1
  208. package/lib/node/index.d.ts.map +0 -1
  209. package/lib/node/index.js.map +0 -1
  210. package/lib/node/module.d.ts.map +0 -1
  211. package/lib/node/module.js.map +0 -1
  212. package/lib/node/package-host-extension.d.ts.map +0 -1
  213. package/lib/node/package-host-extension.js.map +0 -1
  214. package/lib/node/package-hosts.d.ts.map +0 -1
  215. package/lib/node/package-hosts.js.map +0 -1
  216. package/lib/node/package-hosts.spec.d.ts +0 -2
  217. package/lib/node/package-hosts.spec.d.ts.map +0 -1
  218. package/lib/node/package-hosts.spec.js +0 -53
  219. package/lib/node/package-hosts.spec.js.map +0 -1
  220. package/lib/node/package-server-impl.d.ts.map +0 -1
  221. package/lib/node/package-server-impl.js.map +0 -1
  222. package/lib/node/package-switch.d.ts.map +0 -1
  223. package/lib/node/package-switch.js.map +0 -1
  224. package/lib/node/receipt-book.d.ts.map +0 -1
  225. package/lib/node/receipt-book.js.map +0 -1
  226. package/lib/node/receipt-book.spec.d.ts +0 -2
  227. package/lib/node/receipt-book.spec.d.ts.map +0 -1
  228. package/lib/node/receipt-book.spec.js +0 -39
  229. package/lib/node/receipt-book.spec.js.map +0 -1
  230. package/lib/node/relay-bridge.d.ts.map +0 -1
  231. package/lib/node/relay-bridge.js.map +0 -1
  232. package/lib/node/remote/index.d.ts.map +0 -1
  233. package/lib/node/remote/index.js.map +0 -1
  234. package/lib/node/remote/pi-directories.d.ts.map +0 -1
  235. package/lib/node/remote/pi-directories.js.map +0 -1
  236. package/lib/node/remote/port-forwards.d.ts.map +0 -1
  237. package/lib/node/remote/port-forwards.js.map +0 -1
  238. package/lib/node/remote/remote-hosts.d.ts.map +0 -1
  239. package/lib/node/remote/remote-hosts.js.map +0 -1
  240. package/lib/node/remote/remote-protocol.d.ts.map +0 -1
  241. package/lib/node/remote/remote-protocol.js.map +0 -1
  242. package/lib/node/remote/remote-server-impl.d.ts.map +0 -1
  243. package/lib/node/remote/remote-server-impl.js.map +0 -1
  244. package/lib/node/remote/remote.spec.d.ts +0 -2
  245. package/lib/node/remote/remote.spec.d.ts.map +0 -1
  246. package/lib/node/remote/remote.spec.js +0 -130
  247. package/lib/node/remote/remote.spec.js.map +0 -1
  248. package/lib/node/remote-ui-context.d.ts.map +0 -1
  249. package/lib/node/remote-ui-context.js.map +0 -1
  250. package/lib/node/remote-ui-context.spec.d.ts +0 -2
  251. package/lib/node/remote-ui-context.spec.d.ts.map +0 -1
  252. package/lib/node/remote-ui-context.spec.js +0 -85
  253. package/lib/node/remote-ui-context.spec.js.map +0 -1
  254. package/lib/node/session-files.d.ts.map +0 -1
  255. package/lib/node/session-files.js.map +0 -1
  256. package/lib/node/session-files.spec.d.ts +0 -2
  257. package/lib/node/session-files.spec.d.ts.map +0 -1
  258. package/lib/node/session-files.spec.js +0 -51
  259. package/lib/node/session-files.spec.js.map +0 -1
  260. package/lib/node/session-info-util.d.ts.map +0 -1
  261. package/lib/node/session-info-util.js.map +0 -1
  262. package/lib/node/session-info-util.spec.d.ts +0 -2
  263. package/lib/node/session-info-util.spec.d.ts.map +0 -1
  264. package/lib/node/session-info-util.spec.js +0 -22
  265. package/lib/node/session-info-util.spec.js.map +0 -1
  266. package/lib/node/session-storage/file-session-storage.d.ts.map +0 -1
  267. package/lib/node/session-storage/file-session-storage.js.map +0 -1
  268. package/lib/node/session-storage/file-session-storage.spec.d.ts +0 -2
  269. package/lib/node/session-storage/file-session-storage.spec.d.ts.map +0 -1
  270. package/lib/node/session-storage/file-session-storage.spec.js +0 -70
  271. package/lib/node/session-storage/file-session-storage.spec.js.map +0 -1
  272. package/lib/node/session-storage/index.d.ts.map +0 -1
  273. package/lib/node/session-storage/index.js.map +0 -1
  274. package/lib/node/session-storage/session-storage-protocol.d.ts.map +0 -1
  275. package/lib/node/session-storage/session-storage-protocol.js.map +0 -1
  276. package/lib/node/session-storage/stored-session.d.ts.map +0 -1
  277. package/lib/node/session-storage/stored-session.js.map +0 -1
  278. package/lib/node/session-storage/stored-session.spec.d.ts +0 -2
  279. package/lib/node/session-storage/stored-session.spec.d.ts.map +0 -1
  280. package/lib/node/session-storage/stored-session.spec.js +0 -73
  281. package/lib/node/session-storage/stored-session.spec.js.map +0 -1
  282. package/lib/node/settings-server-impl.d.ts.map +0 -1
  283. package/lib/node/settings-server-impl.js.map +0 -1
  284. package/lib/node/settings-store.d.ts.map +0 -1
  285. package/lib/node/settings-store.js.map +0 -1
  286. package/lib/node/settings-store.spec.d.ts +0 -2
  287. package/lib/node/settings-store.spec.d.ts.map +0 -1
  288. package/lib/node/settings-store.spec.js +0 -148
  289. package/lib/node/settings-store.spec.js.map +0 -1
  290. package/lib/node/ta-access.d.ts.map +0 -1
  291. package/lib/node/ta-access.js.map +0 -1
  292. package/lib/node/ta-access.spec.d.ts +0 -2
  293. package/lib/node/ta-access.spec.d.ts.map +0 -1
  294. package/lib/node/ta-access.spec.js +0 -33
  295. package/lib/node/ta-access.spec.js.map +0 -1
  296. package/lib/node/ta-errors.d.ts.map +0 -1
  297. package/lib/node/ta-errors.js.map +0 -1
  298. package/lib/node/ta-errors.spec.d.ts +0 -2
  299. package/lib/node/ta-errors.spec.d.ts.map +0 -1
  300. package/lib/node/ta-errors.spec.js +0 -25
  301. package/lib/node/ta-errors.spec.js.map +0 -1
  302. package/lib/node/ta-event-util.d.ts.map +0 -1
  303. package/lib/node/ta-event-util.js.map +0 -1
  304. package/lib/node/ta-event-util.spec.d.ts +0 -2
  305. package/lib/node/ta-event-util.spec.d.ts.map +0 -1
  306. package/lib/node/ta-event-util.spec.js +0 -28
  307. package/lib/node/ta-event-util.spec.js.map +0 -1
  308. package/lib/node/ta-server-impl.d.ts.map +0 -1
  309. package/lib/node/ta-server-impl.js.map +0 -1
  310. package/lib/node/ta-session-factory.d.ts.map +0 -1
  311. package/lib/node/ta-session-factory.js.map +0 -1
  312. package/lib/node/ta-session-registry.d.ts.map +0 -1
  313. package/lib/node/ta-session-registry.js.map +0 -1
  314. package/lib/node/ta-session.d.ts.map +0 -1
  315. package/lib/node/ta-session.js.map +0 -1
  316. package/lib/node/terminal-protocol.d.ts.map +0 -1
  317. package/lib/node/terminal-protocol.js.map +0 -1
  318. package/lib/node/terminal-service.d.ts.map +0 -1
  319. package/lib/node/terminal-service.js.map +0 -1
  320. package/lib/node/terminal-service.spec.d.ts +0 -2
  321. package/lib/node/terminal-service.spec.d.ts.map +0 -1
  322. package/lib/node/terminal-service.spec.js +0 -110
  323. package/lib/node/terminal-service.spec.js.map +0 -1
  324. package/lib/node/terminal-util.d.ts.map +0 -1
  325. package/lib/node/terminal-util.js.map +0 -1
  326. package/lib/node/terminal-util.spec.d.ts +0 -2
  327. package/lib/node/terminal-util.spec.d.ts.map +0 -1
  328. package/lib/node/terminal-util.spec.js +0 -95
  329. package/lib/node/terminal-util.spec.js.map +0 -1
  330. package/lib/node/web-extension-catalog.d.ts.map +0 -1
  331. package/lib/node/web-extension-catalog.js.map +0 -1
  332. package/lib/node/web-extension-catalog.spec.d.ts +0 -2
  333. package/lib/node/web-extension-catalog.spec.d.ts.map +0 -1
  334. package/lib/node/web-extension-catalog.spec.js +0 -157
  335. package/lib/node/web-extension-catalog.spec.js.map +0 -1
  336. package/lib/node/web-extension-util.d.ts.map +0 -1
  337. package/lib/node/web-extension-util.js.map +0 -1
  338. package/lib/node/working-directory.d.ts.map +0 -1
  339. package/lib/node/working-directory.js.map +0 -1
  340. package/lib/node/workspace-files.d.ts.map +0 -1
  341. package/lib/node/workspace-files.js.map +0 -1
  342. package/lib/node/workspace-files.spec.d.ts +0 -2
  343. package/lib/node/workspace-files.spec.d.ts.map +0 -1
  344. package/lib/node/workspace-files.spec.js +0 -133
  345. package/lib/node/workspace-files.spec.js.map +0 -1
  346. package/lib/node/workspace-protocol.d.ts.map +0 -1
  347. package/lib/node/workspace-protocol.js.map +0 -1
  348. package/lib/node/workspace-server-impl.d.ts.map +0 -1
  349. package/lib/node/workspace-server-impl.js.map +0 -1
  350. package/lib/node/workspace-service.d.ts.map +0 -1
  351. package/lib/node/workspace-service.js.map +0 -1
  352. package/lib/node/workspace-service.spec.d.ts +0 -2
  353. package/lib/node/workspace-service.spec.d.ts.map +0 -1
  354. package/lib/node/workspace-service.spec.js +0 -113
  355. package/lib/node/workspace-service.spec.js.map +0 -1
  356. package/lib/node/workspace-util.d.ts.map +0 -1
  357. package/lib/node/workspace-util.js.map +0 -1
  358. package/lib/node/workspace-util.spec.d.ts +0 -2
  359. package/lib/node/workspace-util.spec.d.ts.map +0 -1
  360. package/lib/node/workspace-util.spec.js +0 -44
  361. package/lib/node/workspace-util.spec.js.map +0 -1
  362. package/src/node/auth-server-impl.spec.ts +0 -49
  363. package/src/node/auth-server-impl.ts +0 -258
  364. package/src/node/client-channel.spec.ts +0 -117
  365. package/src/node/client-channel.ts +0 -94
  366. package/src/node/client-tool-broker.spec.ts +0 -53
  367. package/src/node/client-tool-broker.ts +0 -106
  368. package/src/node/event-log.spec.ts +0 -52
  369. package/src/node/event-log.ts +0 -59
  370. package/src/node/exec-environment-factory.ts +0 -66
  371. package/src/node/extension-data-notifier.spec.ts +0 -34
  372. package/src/node/extension-data-notifier.ts +0 -124
  373. package/src/node/extension-data.spec.ts +0 -105
  374. package/src/node/extension-data.ts +0 -180
  375. package/src/node/extension-providers.ts +0 -49
  376. package/src/node/host-protocol.ts +0 -62
  377. package/src/node/index.ts +0 -39
  378. package/src/node/module.ts +0 -4
  379. package/src/node/package-host-extension.ts +0 -23
  380. package/src/node/package-hosts.spec.ts +0 -54
  381. package/src/node/package-hosts.ts +0 -204
  382. package/src/node/package-server-impl.ts +0 -87
  383. package/src/node/package-switch.ts +0 -80
  384. package/src/node/receipt-book.spec.ts +0 -41
  385. package/src/node/receipt-book.ts +0 -40
  386. package/src/node/relay-bridge.ts +0 -94
  387. package/src/node/remote/index.ts +0 -5
  388. package/src/node/remote/pi-directories.ts +0 -49
  389. package/src/node/remote/port-forwards.ts +0 -148
  390. package/src/node/remote/remote-hosts.ts +0 -170
  391. package/src/node/remote/remote-protocol.ts +0 -57
  392. package/src/node/remote/remote-server-impl.ts +0 -60
  393. package/src/node/remote/remote.spec.ts +0 -142
  394. package/src/node/remote-ui-context.spec.ts +0 -93
  395. package/src/node/remote-ui-context.ts +0 -197
  396. package/src/node/session-files.spec.ts +0 -52
  397. package/src/node/session-files.ts +0 -41
  398. package/src/node/session-info-util.spec.ts +0 -23
  399. package/src/node/session-info-util.ts +0 -55
  400. package/src/node/session-storage/file-session-storage.spec.ts +0 -72
  401. package/src/node/session-storage/file-session-storage.ts +0 -145
  402. package/src/node/session-storage/index.ts +0 -3
  403. package/src/node/session-storage/session-storage-protocol.ts +0 -81
  404. package/src/node/session-storage/stored-session.spec.ts +0 -80
  405. package/src/node/session-storage/stored-session.ts +0 -149
  406. package/src/node/settings-server-impl.ts +0 -42
  407. package/src/node/settings-store.spec.ts +0 -158
  408. package/src/node/settings-store.ts +0 -327
  409. package/src/node/ta-access.spec.ts +0 -36
  410. package/src/node/ta-access.ts +0 -156
  411. package/src/node/ta-errors.spec.ts +0 -25
  412. package/src/node/ta-errors.ts +0 -75
  413. package/src/node/ta-event-util.spec.ts +0 -29
  414. package/src/node/ta-event-util.ts +0 -23
  415. package/src/node/ta-server-impl.ts +0 -341
  416. package/src/node/ta-session-factory.ts +0 -216
  417. package/src/node/ta-session-registry.ts +0 -75
  418. package/src/node/ta-session.ts +0 -241
  419. package/src/node/terminal-protocol.ts +0 -18
  420. package/src/node/terminal-service.spec.ts +0 -119
  421. package/src/node/terminal-service.ts +0 -291
  422. package/src/node/terminal-util.spec.ts +0 -109
  423. package/src/node/terminal-util.ts +0 -197
  424. package/src/node/web-extension-catalog.spec.ts +0 -172
  425. package/src/node/web-extension-catalog.ts +0 -177
  426. package/src/node/web-extension-util.ts +0 -144
  427. package/src/node/working-directory.ts +0 -71
  428. package/src/node/workspace-files.spec.ts +0 -145
  429. package/src/node/workspace-files.ts +0 -256
  430. package/src/node/workspace-protocol.ts +0 -24
  431. package/src/node/workspace-server-impl.ts +0 -108
  432. package/src/node/workspace-service.spec.ts +0 -123
  433. package/src/node/workspace-service.ts +0 -235
  434. package/src/node/workspace-util.spec.ts +0 -47
  435. package/src/node/workspace-util.ts +0 -103
@@ -1,148 +0,0 @@
1
- import { createServer, type Server, type Socket } from 'node:net';
2
- import { type Application, ApplicationLifecycle, Autowired, Component } from '@celljs/core';
3
- import { type ExecEnvironment, ExecEnvironmentFactory, type ExecSocket } from '@celljs/ta-exec';
4
- import { type TaForwardedPort, TaLocation } from '@celljs/ta-protocol';
5
- import { TaErrors } from '../ta-errors';
6
- import { PortForwards, RemoteHosts } from './remote-protocol';
7
-
8
- interface Forward {
9
- info: TaForwardedPort;
10
- server: Server;
11
- sockets: Set<Socket>;
12
- }
13
-
14
- /**
15
- * A port of another machine as a port of 127.0.0.1 here: each connection to it is one from the server
16
- * of Ta there (ExecEnvironment.connect). The same number when it is free here, as VS Code does, so that
17
- * the pages of a dev server keep their links.
18
- */
19
- @Component([PortForwards, ApplicationLifecycle])
20
- export class DefaultPortForwards implements PortForwards, ApplicationLifecycle<Application> {
21
- @Autowired(ExecEnvironmentFactory)
22
- protected readonly environments: ExecEnvironmentFactory;
23
-
24
- @Autowired(RemoteHosts)
25
- protected readonly hosts: RemoteHosts;
26
-
27
- protected readonly forwards = new Map<string, Promise<Forward>>();
28
- /** Those open. */
29
- protected readonly open = new Map<string, TaForwardedPort>();
30
- protected watching = false;
31
-
32
- async forward(cwd: string, port: number): Promise<TaForwardedPort> {
33
- if (!Number.isInteger(port) || port < 1 || port > 65535) {
34
- throw TaErrors.invalidArgument(`${port} is not a port.`, 'Pass a port from 1 to 65535.');
35
- }
36
- const env = this.environments.create(cwd);
37
- const host = TaLocation.host(cwd) ?? '';
38
- if (!env.connect) {
39
- return { host, remotePort: port, localPort: port };
40
- }
41
- this.watch();
42
- const key = `${host}:${port}`;
43
- let forward = this.forwards.get(key);
44
- if (!forward) {
45
- forward = this.listenFor(env, host, port);
46
- this.forwards.set(key, forward);
47
- forward.then(
48
- ({ info }) => this.forwards.has(key) && this.open.set(key, info),
49
- () => this.forwards.delete(key),
50
- );
51
- }
52
- return (await forward).info;
53
- }
54
-
55
- list(): TaForwardedPort[] {
56
- return [...this.open.values()];
57
- }
58
-
59
- async close(host: string, remotePort: number): Promise<void> {
60
- const key = `${host}:${remotePort}`;
61
- const forward = await this.forwards.get(key)?.catch(() => undefined);
62
- this.forwards.delete(key);
63
- this.open.delete(key);
64
- if (forward) {
65
- for (const socket of forward.sockets) {
66
- socket.destroy();
67
- }
68
- await new Promise<void>(resolve => forward.server.close(() => resolve()));
69
- }
70
- }
71
-
72
- async onStop(): Promise<void> {
73
- await Promise.all([...this.forwards.keys()].map(key => this.close(...this.split(key))));
74
- }
75
-
76
- protected async listenFor(env: ExecEnvironment, host: string, port: number): Promise<Forward> {
77
- const sockets = new Set<Socket>();
78
- const server = createServer(socket => {
79
- sockets.add(socket);
80
- socket.once('close', () => sockets.delete(socket));
81
- void this.pipe(env, port, socket);
82
- });
83
- const localPort = await this.listen(server, port).catch(() => this.listen(server, 0));
84
- return { info: { host, remotePort: port, localPort }, server, sockets };
85
- }
86
-
87
- protected listen(server: Server, port: number): Promise<number> {
88
- return new Promise((resolve, reject) => {
89
- const failed = (error: Error) => reject(error);
90
- server.once('error', failed);
91
- server.listen(port, '127.0.0.1', () => {
92
- server.removeListener('error', failed);
93
- resolve((server.address() as { port: number }).port);
94
- });
95
- });
96
- }
97
-
98
- /** One connection: data both ways until either side ends it. */
99
- protected async pipe(env: ExecEnvironment, port: number, socket: Socket): Promise<void> {
100
- // What comes before the other end is there waits for it.
101
- const early: Buffer[] = [];
102
- let ended = false;
103
- let remote: ExecSocket | undefined;
104
- const end = () => {
105
- if (remote) {
106
- remote.end();
107
- } else {
108
- ended = true;
109
- }
110
- };
111
- socket.on('data', data => (remote ? remote.write(data) : early.push(data)));
112
- socket.once('end', end);
113
- socket.once('error', end);
114
- try {
115
- remote = await (env.connect as NonNullable<ExecEnvironment['connect']>)(port);
116
- } catch {
117
- socket.destroy();
118
- return;
119
- }
120
- remote.onData(data => socket.write(data));
121
- remote.onClose(() => socket.end());
122
- for (const data of early) {
123
- remote.write(data);
124
- }
125
- if (ended) {
126
- remote.end();
127
- }
128
- }
129
-
130
- /** A host disconnected on purpose takes its ports with it. */
131
- protected watch(): void {
132
- if (!this.watching) {
133
- this.watching = true;
134
- this.hosts.onDisconnect(host => {
135
- for (const key of [...this.forwards.keys()]) {
136
- if (key.startsWith(`${host}:`)) {
137
- void this.close(...this.split(key));
138
- }
139
- }
140
- });
141
- }
142
- }
143
-
144
- protected split(key: string): [string, number] {
145
- const at = key.lastIndexOf(':');
146
- return [key.slice(0, at), Number(key.slice(at + 1))];
147
- }
148
- }
@@ -1,170 +0,0 @@
1
- import { randomUUID } from 'node:crypto';
2
- import { CODING_AGENT_OPTIONS, type CodingAgentOptions } from '@celljs/ai-coding-agent';
3
- import { type Application, ApplicationLifecycle, Autowired, Component, Value } from '@celljs/core';
4
- import type { RpcConnection } from '@celljs/rpc/lib/node';
5
- import { type ExecClient, SshConfig, SshHost, type SshQuestion } from '@celljs/ta-exec';
6
- import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
7
- import { TaClient, TaLocation, type TaRemoteEvent, type TaRemoteHost, type TaRemotePrompt } from '@celljs/ta-protocol';
8
- import { TaErrors } from '../ta-errors';
9
- import { TaWorkingDirectory } from '../working-directory';
10
- import { RemoteHosts, TA_REMOTE_OPTIONS, type TaRemoteOptions } from './remote-protocol';
11
-
12
- /** A prompt nobody answers is cancelled after this: ssh gives up. */
13
- const PROMPT_TIMEOUT_MS = 5 * 60 * 1000;
14
-
15
- interface Waiting {
16
- prompt: TaRemotePrompt;
17
- settle(value: string | undefined): void;
18
- }
19
-
20
- /**
21
- * One SshHost per host, which connects on the first call there and again after a loss. What ssh asks
22
- * goes to every client that watches, and the first answer counts, as with the dialogs of sessions.
23
- */
24
- @Component([RemoteHosts, ApplicationLifecycle])
25
- export class DefaultRemoteHosts implements RemoteHosts, ApplicationLifecycle<Application> {
26
- @Value(TA_REMOTE_OPTIONS)
27
- protected readonly options?: TaRemoteOptions;
28
-
29
- @Value(CODING_AGENT_OPTIONS)
30
- protected readonly codingAgentOptions?: CodingAgentOptions;
31
-
32
- @Autowired(TaWorkingDirectory)
33
- protected readonly workingDirectory: TaWorkingDirectory;
34
-
35
- protected readonly hosts = new Map<string, SshHost>();
36
- protected readonly waiting = new Map<string, Waiting>();
37
- protected readonly watchers = new Set<RpcConnection>();
38
- protected readonly disconnectListeners = new Set<(host: string) => void>();
39
-
40
- client(host: string): ExecClient {
41
- this.check(host);
42
- let ssh = this.hosts.get(host);
43
- if (!ssh) {
44
- ssh = new SshHost({
45
- host,
46
- stateDir: this.codingAgentOptions?.agentDir ?? TaBrand.agentDir(),
47
- ssh: this.options?.ssh || undefined,
48
- sshArgs: this.options?.sshArgs,
49
- nodeMirror: this.options?.nodeMirror || undefined,
50
- ask: question => this.ask(host, question),
51
- onStep: (step, detail) => this.broadcast({ type: 'progress', host, step, detail }),
52
- });
53
- ssh.client.onState((connected, error) => {
54
- if (connected) {
55
- this.workingDirectory.addRecentHost(host);
56
- }
57
- this.broadcast(error ? { type: 'connection', host, connected, error } : { type: 'connection', host, connected });
58
- });
59
- this.hosts.set(host, ssh);
60
- }
61
- return ssh.client;
62
- }
63
-
64
- list(): TaRemoteHost[] {
65
- const recent = this.workingDirectory.recentHosts();
66
- const config = SshConfig.hosts().filter(host => TaLocation.isHost(host) && !recent.includes(host));
67
- return [
68
- ...recent.map(host => ({ host, source: 'recent' as const, connected: this.connected(host) })),
69
- ...config.map(host => ({ host, source: 'config' as const, connected: this.connected(host) })),
70
- ];
71
- }
72
-
73
- add(host: string): void {
74
- this.workingDirectory.addRecentHost(this.check(host));
75
- }
76
-
77
- async remove(host: string): Promise<void> {
78
- await this.disconnect(host);
79
- this.workingDirectory.removeRecentHost(host);
80
- }
81
-
82
- async resolve(location: string): Promise<string> {
83
- const remote = this.parse(location);
84
- if (!remote || remote.path) {
85
- return location;
86
- }
87
- return TaLocation.ssh(remote.host, (await this.client(remote.host).info()).cwd);
88
- }
89
-
90
- async disconnect(host: string): Promise<void> {
91
- const ssh = this.hosts.get(host);
92
- this.hosts.delete(host);
93
- for (const listener of this.disconnectListeners) {
94
- listener(host);
95
- }
96
- await ssh?.dispose();
97
- }
98
-
99
- onDisconnect(listener: (host: string) => void): () => void {
100
- this.disconnectListeners.add(listener);
101
- return () => this.disconnectListeners.delete(listener);
102
- }
103
-
104
- watch(connection: RpcConnection): TaRemotePrompt[] {
105
- if (!this.watchers.has(connection)) {
106
- this.watchers.add(connection);
107
- connection.onClose(() => this.watchers.delete(connection));
108
- }
109
- return [...this.waiting.values()].map(({ prompt }) => prompt);
110
- }
111
-
112
- answer(promptId: string, value: string | null): boolean {
113
- const waiting = this.waiting.get(promptId);
114
- waiting?.settle(typeof value === 'string' ? value : undefined);
115
- return waiting !== undefined;
116
- }
117
-
118
- async onStop(): Promise<void> {
119
- for (const waiting of [...this.waiting.values()]) {
120
- waiting.settle(undefined);
121
- }
122
- await Promise.all([...this.hosts.keys()].map(host => this.disconnect(host)));
123
- }
124
-
125
- protected ask(host: string, question: SshQuestion): Promise<string | undefined> {
126
- const prompt: TaRemotePrompt = { promptId: randomUUID(), host, ...question };
127
- return new Promise(resolve => {
128
- const timer = setTimeout(() => settle(undefined), PROMPT_TIMEOUT_MS);
129
- const settle = (value: string | undefined) => {
130
- clearTimeout(timer);
131
- if (this.waiting.delete(prompt.promptId)) {
132
- this.broadcast({ type: 'prompt_closed', promptId: prompt.promptId });
133
- resolve(value);
134
- }
135
- };
136
- this.waiting.set(prompt.promptId, { prompt, settle });
137
- this.broadcast({ type: 'prompt', prompt });
138
- });
139
- }
140
-
141
- protected broadcast(event: TaRemoteEvent): void {
142
- for (const connection of this.watchers) {
143
- if (!connection.closed) {
144
- connection
145
- .client<TaClient>(TaClient)
146
- .onRemoteEvent(event)
147
- .catch(() => undefined);
148
- }
149
- }
150
- }
151
-
152
- protected check(host: string): string {
153
- if (typeof host !== 'string' || !TaLocation.isHost(host)) {
154
- throw TaErrors.invalidArgument(`${JSON.stringify(host)} is not a host.`, 'Name a Host of ~/.ssh/config, or [user@]host[:port].');
155
- }
156
- return host;
157
- }
158
-
159
- protected connected(host: string): boolean {
160
- return this.hosts.get(host)?.client.connected ?? false;
161
- }
162
-
163
- protected parse(location: string): TaLocation.Remote | undefined {
164
- try {
165
- return TaLocation.parse(location);
166
- } catch (error) {
167
- throw TaErrors.invalidArgument((error as Error).message, 'Write ssh://<host>/<absolute path>.');
168
- }
169
- }
170
- }
@@ -1,57 +0,0 @@
1
- import type { RpcConnection } from '@celljs/rpc/lib/node';
2
- import type { ExecClient } from '@celljs/ta-exec';
3
- import type { TaForwardedPort, TaRemoteHost, TaRemotePrompt } from '@celljs/ta-protocol';
4
-
5
- export const TA_REMOTE_OPTIONS = 'ta.remote';
6
-
7
- /** `ta.remote`: how ta serve reaches other machines. */
8
- export interface TaRemoteOptions {
9
- /** The ssh command; default `ssh`. */
10
- ssh?: string;
11
- /** Before each host, as `-F <file>`. */
12
- sshArgs?: string[];
13
- /** Where Node.js comes from for hosts without one; empty: nodejs.org. */
14
- nodeMirror?: string;
15
- }
16
-
17
- export const RemoteHosts = Symbol('RemoteHosts');
18
- export const PiDirectories = Symbol('PiDirectories');
19
- export const PortForwards = Symbol('PortForwards');
20
-
21
- /** The hosts of `ssh://` locations, one connection each, and what their ssh asks the users. */
22
- export interface RemoteHosts {
23
- /** The connection to a host, made on its first call. */
24
- client(host: string): ExecClient;
25
- list(): TaRemoteHost[];
26
- /** Keeps a host in the list without connecting; throws for what is not a host. */
27
- add(host: string): void;
28
- /** Disconnects and drops it from the list of those opened before. */
29
- remove(host: string): Promise<void>;
30
- /** The location with the home directory as its path when it has none. */
31
- resolve(location: string): Promise<string>;
32
- disconnect(host: string): Promise<void>;
33
- /** Runs once a host is disconnected on purpose. */
34
- onDisconnect(listener: (host: string) => void): () => void;
35
- /** The connection hears TaClient.onRemoteEvent; the prompts that wait now. */
36
- watch(connection: RpcConnection): TaRemotePrompt[];
37
- answer(promptId: string, value: string | null): boolean;
38
- }
39
-
40
- /**
41
- * The directory pi works in for a location. pi reads and writes this machine's files in it (its
42
- * sessions are named after it, the project's settings are there), so a directory of another machine
43
- * gets one here, empty, under `<agent directory>/remote/`; the agent's tools work there.
44
- */
45
- export interface PiDirectories {
46
- /** Creates it when it is not there. */
47
- toPi(location: string): string;
48
- /** The location of a directory that `toPi` gave; any other is a directory of this machine. */
49
- fromPi(cwd: string): string;
50
- }
51
-
52
- /** Ports of other machines, opened on this one. */
53
- export interface PortForwards {
54
- forward(cwd: string, port: number): Promise<TaForwardedPort>;
55
- list(): TaForwardedPort[];
56
- close(host: string, remotePort: number): Promise<void>;
57
- }
@@ -1,60 +0,0 @@
1
- import { Autowired } from '@celljs/core';
2
- import { Rpc } from '@celljs/rpc';
3
- import { RpcContext } from '@celljs/rpc/lib/node';
4
- import { ExecEnvironmentFactory } from '@celljs/ta-exec';
5
- import { type TaForwardedPort, type TaRemoteHost, type TaRemotePrompt, TaRemoteServer } from '@celljs/ta-protocol';
6
- import { TaErrors } from '../ta-errors';
7
- import { PortForwards, RemoteHosts } from './remote-protocol';
8
-
9
- /** The other machines that conversations work on, for the clients. */
10
- @Rpc(TaRemoteServer)
11
- export class TaRemoteServerImpl implements TaRemoteServer {
12
- @Autowired(RemoteHosts)
13
- protected readonly hosts: RemoteHosts;
14
-
15
- @Autowired(PortForwards)
16
- protected readonly ports: PortForwards;
17
-
18
- @Autowired(ExecEnvironmentFactory)
19
- protected readonly environments: ExecEnvironmentFactory;
20
-
21
- async listHosts(): Promise<TaRemoteHost[]> {
22
- return TaErrors.guard(() => this.hosts.list());
23
- }
24
-
25
- addHost(host: string): Promise<void> {
26
- return TaErrors.guard(() => this.hosts.add(host));
27
- }
28
-
29
- removeHost(host: string): Promise<void> {
30
- return TaErrors.guard(() => this.hosts.remove(host));
31
- }
32
-
33
- resolveLocation(location: string): Promise<string> {
34
- return TaErrors.guard(() => this.hosts.resolve(location));
35
- }
36
-
37
- forwardPort(port: number, cwd?: string): Promise<TaForwardedPort> {
38
- return TaErrors.guard(async () => this.ports.forward(cwd || (await this.environments.defaultCwd()), port));
39
- }
40
-
41
- async listForwardedPorts(): Promise<TaForwardedPort[]> {
42
- return this.ports.list();
43
- }
44
-
45
- closeForwardedPort(host: string, remotePort: number): Promise<void> {
46
- return TaErrors.guard(() => this.ports.close(host, remotePort));
47
- }
48
-
49
- async watch(): Promise<TaRemotePrompt[]> {
50
- return this.hosts.watch(RpcContext.requireConnection());
51
- }
52
-
53
- async answer(promptId: string, value: string | null): Promise<boolean> {
54
- return this.hosts.answer(promptId, value);
55
- }
56
-
57
- disconnect(host: string): Promise<void> {
58
- return TaErrors.guard(() => this.hosts.disconnect(host));
59
- }
60
- }
@@ -1,142 +0,0 @@
1
- import { afterAll, describe, expect, it } from 'bun:test';
2
- import { existsSync, mkdtempSync } from 'node:fs';
3
- import { createServer } from 'node:net';
4
- import { tmpdir } from 'node:os';
5
- import { join } from 'node:path';
6
- import type { RpcConnection } from '@celljs/rpc/lib/node';
7
- import { type ExecEnvironment, type ExecSocket, LocalExecEnvironment } from '@celljs/ta-exec';
8
- import type { TaRemoteEvent } from '@celljs/ta-protocol';
9
- import { DefaultPiDirectories } from './pi-directories';
10
- import { DefaultPortForwards } from './port-forwards';
11
- import { DefaultRemoteHosts } from './remote-hosts';
12
-
13
- const root = mkdtempSync(join(tmpdir(), 'ta-remote-'));
14
-
15
- function directories(execUrl = ''): DefaultPiDirectories {
16
- return Object.assign(new DefaultPiDirectories(), { codingAgentOptions: { agentDir: root }, execOptions: { url: execUrl } });
17
- }
18
-
19
- describe('DefaultPiDirectories', () => {
20
- it('keeps a directory of this machine', () => {
21
- expect(directories().toPi('/work/app')).toBe('/work/app');
22
- expect(directories().fromPi('/work/app')).toBe('/work/app');
23
- });
24
-
25
- it('gives a directory of another machine one here, and back', () => {
26
- const dirs = directories();
27
- const cwd = dirs.toPi('ssh://me@dev:2222/srv/app');
28
- expect(cwd).toBe(join(root, 'remote', 'ssh', 'me@dev:2222', 'srv', 'app'));
29
- expect(existsSync(cwd)).toBe(true);
30
- expect(dirs.fromPi(cwd)).toBe('ssh://me@dev:2222/srv/app');
31
- expect(dirs.fromPi(dirs.toPi('ssh://dev/'))).toBe('ssh://dev/');
32
- });
33
-
34
- it('gives every directory one here with an exec server', () => {
35
- const dirs = directories('ws://exec');
36
- const cwd = dirs.toPi('/srv/app');
37
- expect(cwd).toBe(join(root, 'remote', 'exec', 'srv', 'app'));
38
- expect(dirs.fromPi(cwd)).toBe('/srv/app');
39
- });
40
- });
41
-
42
- describe('DefaultRemoteHosts', () => {
43
- it('asks every client that watches, and the first answer counts', async () => {
44
- const events: TaRemoteEvent[][] = [[], []];
45
- const connections = events.map(
46
- received =>
47
- ({
48
- closed: false,
49
- onClose: () => undefined,
50
- client: () => ({ onRemoteEvent: async (event: TaRemoteEvent) => void received.push(event) }),
51
- }) as unknown as RpcConnection,
52
- );
53
- const hosts = new DefaultRemoteHosts();
54
- expect(hosts.watch(connections[0])).toEqual([]);
55
- const asked = (hosts as unknown as { ask: DefaultRemoteHosts['ask'] }).ask.call(hosts, 'dev', { kind: 'secret', message: 'Password:' });
56
- const [prompt] = hosts.watch(connections[1]);
57
- expect(prompt).toMatchObject({ host: 'dev', kind: 'secret', message: 'Password:' });
58
- expect(events[0]).toEqual([{ type: 'prompt', prompt }]);
59
- expect(hosts.answer(prompt.promptId, 's3cret')).toBe(true);
60
- expect(hosts.answer(prompt.promptId, 'again')).toBe(false);
61
- expect(await asked).toBe('s3cret');
62
- expect(events[1]).toEqual([{ type: 'prompt_closed', promptId: prompt.promptId }]);
63
- });
64
-
65
- it('refuses a host that ssh would read as an option', () => {
66
- expect(() => new DefaultRemoteHosts().client('-oProxyCommand=x')).toThrow();
67
- expect(() => new DefaultRemoteHosts().add('-oProxyCommand=x')).toThrow();
68
- });
69
-
70
- it('keeps the hosts added, the latest first, and forgets one removed', async () => {
71
- let recent: string[] = [];
72
- const hosts = Object.assign(new DefaultRemoteHosts(), {
73
- workingDirectory: {
74
- recentHosts: () => recent,
75
- addRecentHost: (host: string) => (recent = [host, ...recent.filter(other => other !== host)]),
76
- removeRecentHost: (host: string) => (recent = recent.filter(other => other !== host)),
77
- },
78
- });
79
- hosts.add('dev');
80
- hosts.add('me@prod:2222');
81
- expect(hosts.list().filter(host => host.source === 'recent')).toEqual([
82
- { host: 'me@prod:2222', source: 'recent', connected: false },
83
- { host: 'dev', source: 'recent', connected: false },
84
- ]);
85
- await hosts.remove('dev');
86
- expect(recent).toEqual(['me@prod:2222']);
87
- });
88
- });
89
-
90
- describe('DefaultPortForwards', () => {
91
- /** A machine whose connections are those of this one, as the server of Ta makes them there. */
92
- class Remote extends LocalExecEnvironment {
93
- async connect(port: number): Promise<ExecSocket> {
94
- const { connect } = await import('node:net');
95
- const socket = connect(port, '127.0.0.1');
96
- await new Promise((resolve, reject) => socket.once('connect', resolve).once('error', reject));
97
- return {
98
- write: data => socket.write(data),
99
- end: () => socket.end(),
100
- onData: listener => socket.on('data', listener),
101
- onClose: listener => socket.once('close', listener),
102
- };
103
- }
104
- }
105
- const forwards = new DefaultPortForwards();
106
- const local = new LocalExecEnvironment(root);
107
- const remote = new Remote(root);
108
- Object.assign(forwards, {
109
- environments: { create: (cwd: string): ExecEnvironment => (cwd.startsWith('ssh://') ? remote : local) },
110
- hosts: { onDisconnect: () => () => undefined },
111
- });
112
- afterAll(() => forwards.onStop());
113
-
114
- it('keeps a port of this machine as it is', async () => {
115
- expect(await forwards.forward('/work', 3000)).toEqual({ host: '', remotePort: 3000, localPort: 3000 });
116
- await expect(forwards.forward('/work', 70000)).rejects.toThrow();
117
- });
118
-
119
- it('opens a port of another machine here, and carries data both ways', async () => {
120
- const server = createServer(socket => socket.on('data', data => socket.end(`echo:${data}`)));
121
- await new Promise<void>(resolve => server.listen(0, '127.0.0.1', resolve));
122
- const port = (server.address() as { port: number }).port;
123
- try {
124
- const forwarded = await forwards.forward('ssh://dev/srv', port);
125
- expect(forwarded.host).toBe('dev');
126
- expect(forwarded.localPort).not.toBe(port);
127
- expect(await forwards.forward('ssh://dev/srv', port)).toEqual(forwarded);
128
- expect(forwards.list()).toEqual([forwarded]);
129
- const { connect } = await import('node:net');
130
- const client = connect(forwarded.localPort, '127.0.0.1');
131
- const received: Buffer[] = [];
132
- client.on('data', data => received.push(data));
133
- client.write('hi');
134
- await new Promise(resolve => client.once('close', resolve));
135
- expect(Buffer.concat(received).toString()).toBe('echo:hi');
136
- await forwards.close('dev', port);
137
- expect(forwards.list()).toEqual([]);
138
- } finally {
139
- server.close();
140
- }
141
- });
142
- });
@@ -1,93 +0,0 @@
1
- import { describe, expect, it } from 'bun:test';
2
- import type { TaEvent } from '@celljs/ta-protocol';
3
- import { RemoteUiContext } from './remote-ui-context';
4
-
5
- function setup() {
6
- const events: any[] = [];
7
- return { ui: new RemoteUiContext((event: TaEvent) => events.push(event)), events };
8
- }
9
-
10
- describe('RemoteUiContext', () => {
11
- it('publishes a dialog and resolves with the first answer', async () => {
12
- const { ui, events } = setup();
13
- const answer = ui.confirm('Sure?', 'Really');
14
- expect(events[0]).toMatchObject({ type: 'extension_ui_request', method: 'confirm', title: 'Sure?' });
15
- expect(ui.pendingRequests).toHaveLength(1);
16
- expect(ui.respond({ type: 'extension_ui_response', id: events[0].id, confirmed: true })).toBe(true);
17
- expect(ui.respond({ type: 'extension_ui_response', id: events[0].id, confirmed: false })).toBe(false);
18
- expect(await answer).toBe(true);
19
- expect(events[1]).toEqual({ type: 'ui_request_resolved', id: events[0].id });
20
- expect(ui.pendingRequests).toEqual([]);
21
- });
22
-
23
- it('gives the extension its default at the timeout, or when aborted', async () => {
24
- const { ui, events } = setup();
25
- expect(await ui.confirm('t', 'm', { timeout: 10 })).toBe(false);
26
- expect(events.at(-1).type).toBe('ui_request_resolved');
27
- const controller = new AbortController();
28
- const selected = ui.select('t', ['a'], { signal: controller.signal });
29
- controller.abort();
30
- expect(await selected).toBeUndefined();
31
- });
32
-
33
- it('treats a cancelled answer as no answer', async () => {
34
- const { ui, events } = setup();
35
- const value = ui.input('t');
36
- ui.respond({ type: 'extension_ui_response', id: events[0].id, cancelled: true });
37
- expect(await value).toBeUndefined();
38
- });
39
-
40
- it('ends open dialogs when the session closes', async () => {
41
- const { ui } = setup();
42
- const answer = ui.editor('t');
43
- ui.cancelAll();
44
- expect(await answer).toBeUndefined();
45
- });
46
-
47
- it('sends what needs no answer and forgets it', () => {
48
- const { ui, events } = setup();
49
- ui.notify('hello', 'info');
50
- ui.setStatus('k', 'v');
51
- expect(events.map(event => event.method)).toEqual(['notify', 'setStatus']);
52
- expect(ui.pendingRequests).toEqual([]);
53
- });
54
-
55
- it('sends only widgets a client can draw', () => {
56
- const { ui, events } = setup();
57
- ui.setWidget('w', () => undefined);
58
- expect(events).toEqual([]);
59
- ui.setWidget('w', ['line']);
60
- expect(events[0]).toMatchObject({ method: 'setWidget', widgetLines: ['line'] });
61
- });
62
-
63
- it('leaves styled text plain', () => {
64
- const { ui } = setup();
65
- expect(ui.theme.fg('accent', 'text')).toBe('text');
66
- expect(ui.theme.bold('text')).toBe('text');
67
- });
68
-
69
- it('keeps its methods when pi copies it, as it does when it binds extensions', () => {
70
- const { ui, events } = setup();
71
- // pi's runner copies the context so: only own properties survive.
72
- const copy: Pick<RemoteUiContext, 'notify' | 'setStatus'> = Object.assign({}, ui);
73
- copy.notify('Saved', 'warning');
74
- copy.setStatus('k', 'v');
75
- expect(events.map(event => event.method)).toEqual(['notify', 'setStatus']);
76
- expect(events[0]).toMatchObject({ type: 'extension_ui_request', message: 'Saved', notifyType: 'warning' });
77
- });
78
-
79
- it('keeps what the extensions show now, for a client that attaches later', () => {
80
- const { ui } = setup();
81
- ui.setStatus('wx', '[WeChat] ⏳ signing in');
82
- ui.setStatus('wx', '[WeChat] ✅ connected');
83
- ui.setStatus('git', 'clean');
84
- ui.setStatus('git', undefined);
85
- ui.setWidget('todo', ['- a', '- b'], { placement: 'belowEditor' });
86
- ui.setWidget('gone', ['x']);
87
- ui.setWidget('gone', undefined);
88
- expect(ui.shownRequests).toMatchObject([
89
- { method: 'setStatus', statusKey: 'wx', statusText: '[WeChat] ✅ connected' },
90
- { method: 'setWidget', widgetKey: 'todo', widgetLines: ['- a', '- b'], widgetPlacement: 'belowEditor' },
91
- ]);
92
- });
93
- });