@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,204 +0,0 @@
1
- import { readFileSync } from 'node:fs';
2
- import { open } from 'node:fs/promises';
3
- import { join, relative, resolve, sep } from 'node:path';
4
- import { pathToFileURL } from 'node:url';
5
- import { CODING_AGENT_OPTIONS, type CodingAgentOptions } from '@celljs/ai-coding-agent';
6
- import { type Application, ApplicationLifecycle, Autowired, Component, Value } from '@celljs/core';
7
- import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
8
- import { TaPackages } from '@celljs/ta-harness/lib/node/ta-packages';
9
- import { type TaExtensionHost, type TaHostAnswer, type TaPackageHostFactory, TaPackageServer, type TaPackageService, TaServer } from '@celljs/ta-protocol';
10
- import { ExtensionDataStore } from './extension-data';
11
- import { PiDirectories } from './remote/remote-protocol';
12
- import { TaErrors } from './ta-errors';
13
-
14
- export const PackageHosts = Symbol('PackageHosts');
15
-
16
- /**
17
- * The server side of built-in packages under `ta serve`: the module a package names in `pi.host` of its
18
- * package.json runs once in this process, with the sessions of the server (TaExtensionHost), and its pi
19
- * extensions reach it by `pi.events` (TA_HOST_EVENT). Work that should go on without a page, such as
20
- * agents answering each other in a channel, lives there.
21
- */
22
- export interface PackageHosts {
23
- /** Starts the hosts of the packages that are on and stops those turned off. */
24
- sync(): Promise<void>;
25
- /** For a pi extension of the package `name`. */
26
- answer(name: string): Promise<Omit<TaHostAnswer, 'files'>>;
27
- /** A method of what the host of the package `name` returned, for its web extension (TaPackageServer.callPackageHost). */
28
- call(name: string, method: string, params: unknown[]): Promise<unknown>;
29
- }
30
-
31
- export namespace PackageHostUtil {
32
- /** The bytes of a session file that hold its header, its first line. */
33
- const HEADER_BYTES = 16384;
34
-
35
- /** The `cwd` of the header of a pi session file; undefined when it has none. */
36
- export async function sessionCwd(file: string): Promise<string | undefined> {
37
- let handle: Awaited<ReturnType<typeof open>> | undefined;
38
- try {
39
- handle = await open(file, 'r');
40
- const buffer = Buffer.alloc(HEADER_BYTES);
41
- const { bytesRead } = await handle.read(buffer, 0, HEADER_BYTES, 0);
42
- const header = JSON.parse(buffer.subarray(0, bytesRead).toString('utf8').split('\n')[0]);
43
- return header?.type === 'session' && typeof header.cwd === 'string' ? header.cwd : undefined;
44
- } catch {
45
- return undefined;
46
- } finally {
47
- await handle?.close();
48
- }
49
- }
50
-
51
- /** The file of `pi.host`, inside the package; undefined when it has none. */
52
- export function entry(root: string): string | undefined {
53
- let host: unknown;
54
- try {
55
- host = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'))?.pi?.host;
56
- } catch {
57
- return undefined;
58
- }
59
- if (typeof host !== 'string' || !host) {
60
- return undefined;
61
- }
62
- const file = resolve(root, host);
63
- const inside = relative(root, file);
64
- return inside && !inside.startsWith('..') && !inside.startsWith(sep) ? file : undefined;
65
- }
66
- }
67
-
68
- interface Running {
69
- service: Promise<TaPackageService | undefined>;
70
- }
71
-
72
- @Component([PackageHosts, ApplicationLifecycle])
73
- export class PackageHostsImpl implements PackageHosts, ApplicationLifecycle<Application> {
74
- @Autowired(PiDirectories)
75
- protected readonly directories: PiDirectories;
76
-
77
- @Value(CODING_AGENT_OPTIONS)
78
- protected readonly codingAgentOptions?: CodingAgentOptions;
79
-
80
- @Autowired(ExtensionDataStore)
81
- protected readonly data: ExtensionDataStore;
82
-
83
- // Read when first asked: the server depends on this class, through the sessions.
84
- @Autowired({ id: TaServer, detached: true })
85
- protected readonly server: TaServer;
86
-
87
- @Autowired({ id: TaPackageServer, detached: true })
88
- protected readonly packages: TaPackageServer;
89
-
90
- protected readonly running = new Map<string, Running>();
91
- protected extensionHost?: TaExtensionHost;
92
-
93
- async onStart(): Promise<void> {
94
- await this.sync();
95
- }
96
-
97
- onStop(): void {
98
- for (const name of [...this.running.keys()]) {
99
- void this.stop(name);
100
- }
101
- }
102
-
103
- async sync(): Promise<void> {
104
- const on = new Map(TaPackages.enabled(this.agentDir()).map(pkg => [pkg.name, PackageHostUtil.entry(pkg.root)] as const));
105
- for (const name of [...this.running.keys()]) {
106
- if (!on.get(name)) {
107
- await this.stop(name);
108
- }
109
- }
110
- await Promise.all(
111
- [...on].map(async ([name, file]) => {
112
- if (file && !this.running.has(name)) {
113
- await this.start(name, file).service;
114
- }
115
- }),
116
- );
117
- }
118
-
119
- async answer(name: string): Promise<Omit<TaHostAnswer, 'files'>> {
120
- return { host: this.host(), service: await this.running.get(name)?.service };
121
- }
122
-
123
- async call(name: string, method: string, params: unknown[]): Promise<unknown> {
124
- const service = (await this.running.get(name)?.service) as Record<string, unknown> | undefined;
125
- if (!service) {
126
- throw TaErrors.invalidArgument(
127
- `The package ${name} has no host running.`,
128
- 'Only packages that come with Ta and are on have one, under ta serve; turn it on, or see the log of ta serve for why it failed.',
129
- );
130
- }
131
- // Its own methods and those of its class, not those every object has, nor what ta serve calls.
132
- const callable =
133
- typeof method === 'string' && method !== 'dispose' && method !== 'constructor' && !method.startsWith('_') && !(method in Object.prototype);
134
- const fn = callable ? service[method] : undefined;
135
- if (typeof fn !== 'function') {
136
- throw TaErrors.invalidArgument(`The host of ${name} has no method ${String(method)}.`, 'Call a method that its module of pi.host returns.');
137
- }
138
- try {
139
- return await fn.apply(service, Array.isArray(params) ? params : []);
140
- } catch (error) {
141
- throw TaErrors.commandFailed(error);
142
- }
143
- }
144
-
145
- protected start(name: string, file: string): Running {
146
- const running: Running = {
147
- service: (async () => {
148
- try {
149
- const module = await import(pathToFileURL(file).href);
150
- const factory = (module.default ?? module) as TaPackageHostFactory;
151
- return (await factory(this.host())) ?? undefined;
152
- } catch (error) {
153
- console.error(`The host of ${name} failed: ${error instanceof Error ? error.message : error}`);
154
- return undefined;
155
- }
156
- })(),
157
- };
158
- this.running.set(name, running);
159
- return running;
160
- }
161
-
162
- protected async stop(name: string): Promise<void> {
163
- const running = this.running.get(name);
164
- this.running.delete(name);
165
- try {
166
- await (await running?.service)?.dispose?.();
167
- } catch (error) {
168
- console.error(`The host of ${name} failed to stop: ${error instanceof Error ? error.message : error}`);
169
- }
170
- }
171
-
172
- protected host(): TaExtensionHost {
173
- if (!this.extensionHost) {
174
- const server = this.server;
175
- const packages = this.packages;
176
- this.extensionHost = {
177
- agentDir: this.agentDir(),
178
- sessionCwd: async file => {
179
- const cwd = await PackageHostUtil.sessionCwd(file);
180
- return cwd === undefined ? undefined : this.directories.fromPi(cwd);
181
- },
182
- listPackages: cwd => packages.listPackages(cwd),
183
- getServerInfo: () => server.getServerInfo(),
184
- listSessions: () => server.listSessions(),
185
- openSession: options => server.openSession(options),
186
- closeSession: sessionId => server.closeSession(sessionId),
187
- setSessionName: (sessionId, name) => server.setSessionName(sessionId, name),
188
- prompt: (sessionId, input) => server.prompt(sessionId, input),
189
- followUp: (sessionId, input) => server.followUp(sessionId, input),
190
- abort: sessionId => server.abort(sessionId),
191
- getState: sessionId => server.getState(sessionId),
192
- getLastAssistantText: sessionId => server.getLastAssistantText(sessionId),
193
- getExtensionData: (name, key, cwd) => packages.getExtensionData(name, key, cwd),
194
- setExtensionData: (name, key, value, cwd) => packages.setExtensionData(name, key, value, cwd),
195
- onExtensionData: listener => this.data.onChange(listener),
196
- };
197
- }
198
- return this.extensionHost;
199
- }
200
-
201
- protected agentDir(): string {
202
- return this.codingAgentOptions?.agentDir ?? TaBrand.agentDir();
203
- }
204
- }
@@ -1,87 +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 TaPackageInfo, TaPackageServer, type TaSettingsScope, type TaWebExtensionInfo, type TaWebExtensionSource } from '@celljs/ta-protocol';
6
- import { ExtensionDataStore, ExtensionDataUtil } from './extension-data';
7
- import { ExtensionDataNotifier } from './extension-data-notifier';
8
- import { WebExtensionCatalog } from './host-protocol';
9
- import { PackageHosts } from './package-hosts';
10
- import { TaErrors } from './ta-errors';
11
-
12
- /** The packages pi loads and the data they keep; `cwd` defaults to the server's directory. */
13
- @Rpc(TaPackageServer)
14
- export class TaPackageServerImpl implements TaPackageServer {
15
- @Autowired(ExecEnvironmentFactory)
16
- protected readonly environments: ExecEnvironmentFactory;
17
-
18
- @Autowired(WebExtensionCatalog)
19
- protected readonly webExtensions: WebExtensionCatalog;
20
-
21
- @Autowired(ExtensionDataStore)
22
- protected readonly extensionData: ExtensionDataStore;
23
-
24
- @Autowired(ExtensionDataNotifier)
25
- protected readonly extensionDataNotifier: ExtensionDataNotifier;
26
-
27
- @Autowired(PackageHosts)
28
- protected readonly packageHosts: PackageHosts;
29
-
30
- listWebExtensions(cwd?: string): Promise<TaWebExtensionInfo[]> {
31
- return TaErrors.guard(async () => this.webExtensions.list(await this.cwd(cwd)));
32
- }
33
-
34
- readWebExtension(id: string, cwd?: string): Promise<TaWebExtensionSource> {
35
- return TaErrors.guard(async () => this.webExtensions.read(await this.cwd(cwd), id));
36
- }
37
-
38
- removeWebExtension(id: string, cwd?: string): Promise<void> {
39
- return TaErrors.guard(async () => this.webExtensions.remove(await this.cwd(cwd), id));
40
- }
41
-
42
- setPackageEnabled(nameOrId: string, enabled: boolean, cwd?: string): Promise<void> {
43
- return TaErrors.guard(async () => {
44
- await this.webExtensions.setEnabled(await this.cwd(cwd), nameOrId, enabled);
45
- await this.packageHosts.sync();
46
- });
47
- }
48
-
49
- listPackages(cwd?: string): Promise<TaPackageInfo[]> {
50
- return TaErrors.guard(async () => this.webExtensions.packages(await this.cwd(cwd)));
51
- }
52
-
53
- installPackage(source: string, scope: TaSettingsScope, cwd?: string): Promise<void> {
54
- return TaErrors.guard(async () => {
55
- if (scope !== 'user' && scope !== 'project') {
56
- throw TaErrors.invalidArgument(`${String(scope)} is not where packages are installed.`, 'Pass user or project.');
57
- }
58
- await this.webExtensions.install(await this.cwd(cwd), source, scope);
59
- });
60
- }
61
-
62
- removePackage(id: string, cwd?: string): Promise<void> {
63
- return TaErrors.guard(async () => this.webExtensions.removePackage(await this.cwd(cwd), id));
64
- }
65
-
66
- callPackageHost(name: string, method: string, params?: unknown[]): Promise<unknown> {
67
- return TaErrors.guard(() => this.packageHosts.call(name, method, params ?? []));
68
- }
69
-
70
- getExtensionData(name: string, key: string, cwd?: string): Promise<unknown> {
71
- return TaErrors.guard(() => {
72
- const connection = RpcContext.connection();
73
- if (connection) {
74
- this.extensionDataNotifier.watch(connection, name, ExtensionDataUtil.checkCwd(cwd));
75
- }
76
- return this.extensionData.get(name, key, cwd);
77
- });
78
- }
79
-
80
- setExtensionData(name: string, key: string, value: unknown, cwd?: string): Promise<void> {
81
- return TaErrors.guard(() => this.extensionData.set(name, key, value, cwd));
82
- }
83
-
84
- protected async cwd(cwd?: string): Promise<string> {
85
- return cwd || (await this.environments.defaultCwd());
86
- }
87
- }
@@ -1,80 +0,0 @@
1
- import { dirname, relative, sep } from 'node:path';
2
- import type { PiSdk } from '@celljs/ai-coding-agent';
3
-
4
- type SettingsManager = ReturnType<PiSdk['SettingsManager']['create']>;
5
- type ResolvedPaths = Awaited<ReturnType<InstanceType<PiSdk['DefaultPackageManager']>['resolve']>>;
6
- type ResolvedResource = ResolvedPaths['extensions'][number];
7
- type PackageSource = NonNullable<ReturnType<SettingsManager['getGlobalSettings']>['packages']>[number];
8
-
9
- /** What pi loads, by the key of its settings. */
10
- export const PI_RESOURCE_TYPES = ['extensions', 'skills', 'prompts', 'themes'] as const;
11
- export type PiResourceType = (typeof PI_RESOURCE_TYPES)[number];
12
-
13
- /** A resource pi resolved, with its kind. */
14
- export interface PiResource {
15
- type: PiResourceType;
16
- resource: ResolvedResource;
17
- }
18
-
19
- /**
20
- * A package on or off as `pi config` turns each of its resources on or off: `+path` or `-path` in the
21
- * resource list of the settings for a resource of `extensions/`, in the filters of its entry of
22
- * `packages` for one of a package. Ta's switch of a package is that of all its resources at once, so
23
- * `ta config` and `ta` in the terminal see the same.
24
- */
25
- export namespace PackageSwitch {
26
- /** The resources of the package in `root`. */
27
- export function resourcesOf(resolved: ResolvedPaths, root: string): PiResource[] {
28
- const inside = (path: string) => path === root || path.startsWith(`${root}${sep}`);
29
- return PI_RESOURCE_TYPES.flatMap(type => resolved[type].filter(resource => inside(resource.path)).map(resource => ({ type, resource })));
30
- }
31
-
32
- /** On while any of its resources loads. */
33
- export function isEnabled(resources: readonly PiResource[]): boolean {
34
- return resources.some(({ resource }) => resource.enabled);
35
- }
36
-
37
- export function set(settings: SettingsManager, resources: readonly PiResource[], enabled: boolean, dirs: { agentDir: string; projectDir: string }): void {
38
- for (const { type, resource } of resources) {
39
- const { metadata } = resource;
40
- const project = metadata.scope === 'project';
41
- if (metadata.origin === 'top-level') {
42
- const base = metadata.baseDir ?? (project ? dirs.projectDir : dirs.agentDir);
43
- const file = project ? settings.getProjectSettings() : settings.getGlobalSettings();
44
- const updated = mark((file[type] as string[] | undefined) ?? [], relative(base, resource.path), enabled);
45
- SETTERS[type](settings, project)(updated);
46
- continue;
47
- }
48
- const file = project ? settings.getProjectSettings() : settings.getGlobalSettings();
49
- const packages: PackageSource[] = [...(file.packages ?? [])];
50
- const index = packages.findIndex(pkg => (typeof pkg === 'string' ? pkg : pkg.source) === metadata.source);
51
- if (index < 0) {
52
- continue;
53
- }
54
- const entry = packages[index];
55
- const pkg = typeof entry === 'string' ? { source: entry } : { ...entry };
56
- const pattern = relative(metadata.baseDir ?? dirname(resource.path), resource.path);
57
- const filters = mark((pkg[type] as string[] | undefined) ?? [], pattern, enabled);
58
- pkg[type] = filters.length > 0 ? filters : undefined;
59
- packages[index] = PI_RESOURCE_TYPES.some(key => pkg[key] !== undefined) ? pkg : pkg.source;
60
- if (project) {
61
- settings.setProjectPackages(packages);
62
- } else {
63
- settings.setPackages(packages);
64
- }
65
- }
66
- }
67
-
68
- /** The list without the entries of `pattern`, and `+pattern` or `-pattern` at its end, as `pi config` writes it. */
69
- function mark(list: readonly string[], pattern: string, enabled: boolean): string[] {
70
- const target = (entry: string) => (/^[!+-]/.test(entry) ? entry.slice(1) : entry);
71
- return [...list.filter(entry => target(entry) !== pattern), `${enabled ? '+' : '-'}${pattern}`];
72
- }
73
-
74
- const SETTERS: Record<PiResourceType, (settings: SettingsManager, project: boolean) => (paths: string[]) => void> = {
75
- extensions: (s, project) => paths => (project ? s.setProjectExtensionPaths(paths) : s.setExtensionPaths(paths)),
76
- skills: (s, project) => paths => (project ? s.setProjectSkillPaths(paths) : s.setSkillPaths(paths)),
77
- prompts: (s, project) => paths => (project ? s.setProjectPromptTemplatePaths(paths) : s.setPromptTemplatePaths(paths)),
78
- themes: (s, project) => paths => (project ? s.setProjectThemePaths(paths) : s.setThemePaths(paths)),
79
- };
80
- }
@@ -1,41 +0,0 @@
1
- import { describe, expect, it } from 'bun:test';
2
- import { ReceiptBook } from './receipt-book';
3
-
4
- const input = (clientMessageId: string, message = 'hi') => ({ clientMessageId, message });
5
-
6
- describe('ReceiptBook', () => {
7
- it('takes a new message and reports the same one again as a duplicate', () => {
8
- const book = new ReceiptBook();
9
- expect(book.take(input('a'))).toBeUndefined();
10
- expect(book.take(input('a'))).toEqual({ clientMessageId: 'a', status: 'duplicate' });
11
- });
12
-
13
- it('refuses the same id for a different message', () => {
14
- const book = new ReceiptBook();
15
- book.take(input('a'));
16
- expect(() => book.take(input('a', 'other'))).toThrow('different message');
17
- });
18
-
19
- it('tells images apart', () => {
20
- const book = new ReceiptBook();
21
- const image = (data: string) => ({ type: 'image', data, mimeType: 'image/png' }) as const;
22
- book.take({ ...input('a'), images: [image('1')] });
23
- expect(() => book.take({ ...input('a'), images: [image('2')] })).toThrow();
24
- });
25
-
26
- it('takes a message again after it was refused', () => {
27
- const book = new ReceiptBook();
28
- book.take(input('a'));
29
- book.forget('a');
30
- expect(book.take(input('a'))).toBeUndefined();
31
- });
32
-
33
- it('remembers only the latest ids', () => {
34
- const book = new ReceiptBook(2);
35
- book.take(input('a'));
36
- book.take(input('b'));
37
- book.take(input('c'));
38
- expect(book.take(input('a'))).toBeUndefined();
39
- expect(book.take(input('c'))?.status).toBe('duplicate');
40
- });
41
- });
@@ -1,40 +0,0 @@
1
- import { createHash } from 'node:crypto';
2
- import type { TaPromptInput, TaPromptReceipt } from '@celljs/ta-protocol';
3
- import { TaErrors } from './ta-errors';
4
-
5
- /** The messages a session has taken, by the id the client gave them; a resend does not run twice. Holds hashes, not messages. */
6
- export class ReceiptBook {
7
- protected readonly seen = new Map<string, string>();
8
-
9
- constructor(protected readonly capacity = 256) {}
10
-
11
- /** The receipt of a message taken before; undefined for a new one, which is now recorded. */
12
- take(input: TaPromptInput): TaPromptReceipt | undefined {
13
- const hash = this.hash(input);
14
- const seen = this.seen.get(input.clientMessageId);
15
- if (seen === hash) {
16
- return { clientMessageId: input.clientMessageId, status: 'duplicate' };
17
- }
18
- if (seen !== undefined) {
19
- throw TaErrors.messageConflict(input.clientMessageId);
20
- }
21
- this.seen.set(input.clientMessageId, hash);
22
- if (this.seen.size > this.capacity) {
23
- this.seen.delete(this.seen.keys().next().value as string);
24
- }
25
- return undefined;
26
- }
27
-
28
- /** The message was refused: the client may send it again. */
29
- forget(clientMessageId: string): void {
30
- this.seen.delete(clientMessageId);
31
- }
32
-
33
- protected hash(input: TaPromptInput): string {
34
- const hash = createHash('sha1').update(input.message);
35
- for (const image of input.images ?? []) {
36
- hash.update(image.data);
37
- }
38
- return hash.digest('base64');
39
- }
40
- }
@@ -1,94 +0,0 @@
1
- import { unwatchFile, watchFile } from 'node:fs';
2
- import type { Server } from 'node:http';
3
- import type { AddressInfo } from 'node:net';
4
- import { type Application, ApplicationLifecycle, Autowired, Component } from '@celljs/core';
5
- import { Rpc } from '@celljs/rpc';
6
- import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
7
- import { TA_WEBSOCKET_PATH, type TaRelayDevice, type TaRelayInfo, TaRelayServer } from '@celljs/ta-protocol';
8
- import { RELAY_DEFAULT_URL, RelayHost, RelayPairingUtil, RelayStore } from '@celljs/ta-relay/lib/node';
9
- import { ServerAware } from '@celljs/web/lib/node';
10
- import { TA_ACCESS, type TaAccess } from './ta-access';
11
- import { TaErrors } from './ta-errors';
12
-
13
- /** The id of {@link RelayBridge}, for TaRelayServerImpl. */
14
- export const RELAY_BRIDGE = Symbol('RelayBridge');
15
-
16
- /** How often relay.json is looked at, for devices that `ta pair` adds or removes while the server runs. */
17
- const WATCH_INTERVAL_MS = 2000;
18
-
19
- /**
20
- * Paired devices reach this server through a relay (@celljs/ta-relay): with a device in relay.json, it
21
- * keeps a connection out to the relay and gives each device a connection of its own to this server.
22
- * Without one it does nothing.
23
- */
24
- @Component([RELAY_BRIDGE, ServerAware, ApplicationLifecycle])
25
- export class RelayBridge implements ServerAware, ApplicationLifecycle<Application> {
26
- @Autowired(TA_ACCESS)
27
- protected readonly access: TaAccess;
28
-
29
- readonly store = new RelayStore(TaBrand.agentDir());
30
- protected host?: RelayHost;
31
-
32
- get online(): boolean {
33
- return this.host?.online ?? false;
34
- }
35
-
36
- /** relay.json changed here: no need to wait for the watch. */
37
- refresh(): void {
38
- this.host?.refresh();
39
- }
40
-
41
- async setServer(server: Server): Promise<void> {
42
- const start = () => this.start(server);
43
- if (server.listening) {
44
- start();
45
- } else {
46
- server.once('listening', start);
47
- }
48
- }
49
-
50
- async onStop(): Promise<void> {
51
- unwatchFile(this.store.file);
52
- this.host?.stop();
53
- }
54
-
55
- protected start(server: Server): void {
56
- const { port } = server.address() as AddressInfo;
57
- const localUrl = `ws://127.0.0.1:${port}${TA_WEBSOCKET_PATH}?token=${encodeURIComponent(this.access.token)}`;
58
- const host = new RelayHost({ store: this.store, localUrl });
59
- this.host = host;
60
- host.start();
61
- watchFile(this.store.file, { interval: WATCH_INTERVAL_MS }, () => host.refresh());
62
- }
63
- }
64
- const device = ({ id, name, createdAt }: TaRelayDevice): TaRelayDevice => ({ id, name, createdAt });
65
-
66
- /** `ta pair` for clients: the devices of relay.json, which RelayBridge serves. Their keys never leave, but in the link of a new one. */
67
- @Rpc(TaRelayServer)
68
- export class TaRelayServerImpl implements TaRelayServer {
69
- @Autowired(RELAY_BRIDGE)
70
- protected readonly bridge: RelayBridge;
71
-
72
- async getRelay(): Promise<TaRelayInfo> {
73
- const { url, devices } = this.bridge.store.read();
74
- return { relay: url, defaultRelay: RELAY_DEFAULT_URL, online: this.bridge.online, devices: devices.map(device) };
75
- }
76
-
77
- pair(relay: string, name: string): Promise<{ link: string; device: TaRelayDevice }> {
78
- return TaErrors.guard(() => {
79
- const url = typeof relay === 'string' ? relay.trim().replace(/\/+$/, '') : '';
80
- if (!/^https?:\/\/[^/\s]+$/.test(url)) {
81
- throw TaErrors.invalidArgument(`${relay} is not the address of a relay.`, 'Pass https://<host> of a relay, such as the default one.');
82
- }
83
- const pairing = this.bridge.store.pair(url, (typeof name === 'string' && name.trim()) || 'device');
84
- this.bridge.refresh();
85
- const created = this.bridge.store.device(pairing.device);
86
- return { link: RelayPairingUtil.link(pairing), device: device(created ?? { id: pairing.device, name, createdAt: Date.now(), key: '' }) };
87
- });
88
- }
89
-
90
- async unpair(deviceId: string): Promise<void> {
91
- this.bridge.store.remove(deviceId);
92
- this.bridge.refresh();
93
- }
94
- }
@@ -1,5 +0,0 @@
1
- export * from './pi-directories';
2
- export * from './port-forwards';
3
- export * from './remote-hosts';
4
- export * from './remote-protocol';
5
- export * from './remote-server-impl';
@@ -1,49 +0,0 @@
1
- import { mkdirSync } from 'node:fs';
2
- import { join, sep } from 'node:path';
3
- import { CODING_AGENT_OPTIONS, type CodingAgentOptions } from '@celljs/ai-coding-agent';
4
- import { Component, Value } from '@celljs/core';
5
- import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
6
- import { TaLocation } from '@celljs/ta-protocol';
7
- import { TA_EXEC_OPTIONS, type TaExecOptions } from '../host-protocol';
8
- import { PiDirectories } from './remote-protocol';
9
-
10
- /**
11
- * `<agent directory>/remote/ssh/<host>/<path>` for `ssh://<host>/<path>`. With `ta.exec.url` every
12
- * directory is one of the machine of the exec server: `<agent directory>/remote/exec/<path>`.
13
- */
14
- @Component(PiDirectories)
15
- export class DefaultPiDirectories implements PiDirectories {
16
- @Value(CODING_AGENT_OPTIONS)
17
- protected readonly codingAgentOptions?: CodingAgentOptions;
18
-
19
- @Value(TA_EXEC_OPTIONS)
20
- protected readonly execOptions?: TaExecOptions;
21
-
22
- toPi(location: string): string {
23
- const remote = TaLocation.parse(location);
24
- const prefix = remote ? join('ssh', remote.host) : this.execOptions?.url ? 'exec' : undefined;
25
- if (!prefix) {
26
- return location;
27
- }
28
- const path = remote ? remote.path : location;
29
- const cwd = join(this.root(), prefix, ...path.split('/').filter(Boolean));
30
- mkdirSync(cwd, { recursive: true });
31
- return cwd;
32
- }
33
-
34
- fromPi(cwd: string): string {
35
- const root = this.root() + sep;
36
- if (!cwd.startsWith(root)) {
37
- return cwd;
38
- }
39
- const [kind, ...rest] = cwd.slice(root.length).split(sep);
40
- if (kind === 'ssh' && rest.length > 0 && TaLocation.isHost(rest[0])) {
41
- return TaLocation.ssh(rest[0], `/${rest.slice(1).join('/')}`);
42
- }
43
- return kind === 'exec' ? `/${rest.join('/')}` : cwd;
44
- }
45
-
46
- protected root(): string {
47
- return join(this.codingAgentOptions?.agentDir ?? TaBrand.agentDir(), 'remote');
48
- }
49
- }