@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
@@ -10,6 +10,8 @@ export declare class DefaultTaSessionRegistry implements TaSessionRegistry {
10
10
  protected readonly channels: WeakMap<RpcConnection, ClientChannel>;
11
11
  /** Sessions being created count against the limit too. */
12
12
  protected opening: number;
13
+ /** The closes under way, by session file: out of the list already, their files locked until they end. */
14
+ protected readonly closing: Map<string, Promise<void>>;
13
15
  open(options: TaOpenSessionOptions): Promise<TaSession>;
14
16
  require(sessionId: string): TaSession;
15
17
  list(): TaSession[];
@@ -19,8 +19,15 @@ let DefaultTaSessionRegistry = class DefaultTaSessionRegistry {
19
19
  this.channels = new WeakMap();
20
20
  /** Sessions being created count against the limit too. */
21
21
  this.opening = 0;
22
+ /** The closes under way, by session file: out of the list already, their files locked until they end. */
23
+ this.closing = new Map();
22
24
  }
23
25
  async open(options) {
26
+ // A conversation closed a moment ago (idle, or by another client) opens once it is closed, not refused.
27
+ const closing = options.sessionFile && this.closing.get(options.sessionFile);
28
+ if (closing) {
29
+ await closing.catch(() => undefined);
30
+ }
24
31
  if (this.sessions.size + this.opening >= this.options.maxSessions) {
25
32
  throw TaErrors.tooManySessions(this.options.maxSessions);
26
33
  }
@@ -46,9 +53,22 @@ let DefaultTaSessionRegistry = class DefaultTaSessionRegistry {
46
53
  }
47
54
  async close(sessionId) {
48
55
  const session = this.sessions.get(sessionId);
49
- if (session) {
50
- this.sessions.delete(sessionId);
51
- await session.close();
56
+ if (!session) {
57
+ return;
58
+ }
59
+ this.sessions.delete(sessionId);
60
+ const file = session.pi.sessionFile;
61
+ const closing = session.close();
62
+ if (file) {
63
+ this.closing.set(file, closing);
64
+ }
65
+ try {
66
+ await closing;
67
+ }
68
+ finally {
69
+ if (file && this.closing.get(file) === closing) {
70
+ this.closing.delete(file);
71
+ }
52
72
  }
53
73
  }
54
74
  async closeAll() {
@@ -1,9 +1,10 @@
1
1
  import type { SessionLock } from '@celljs/ta-harness';
2
- import type { RpcExtensionUIResponse, TaAttachResult, TaClientToolResult, TaEvent, TaNavigateResult, TaPromptInput, TaPromptReceipt, TaSessionInfo } from '@celljs/ta-protocol';
2
+ import type { RpcExtensionUIResponse, TaAttachOptions, TaAttachResult, TaClientToolResult, TaEvent, TaMessagePage, TaNavigateResult, TaPromptInput, TaPromptReceipt, TaSessionInfo } from '@celljs/ta-protocol';
3
3
  import type { ClientChannel } from './client-channel.js';
4
4
  import type { ClientToolBroker } from './client-tool-broker.js';
5
5
  import { EventLog } from './event-log.js';
6
6
  import type { TaHostOptions } from './host-protocol.js';
7
+ import { LiveRun } from './live-run.js';
7
8
  import { ReceiptBook } from './receipt-book.js';
8
9
  import { RemoteUiContext } from './remote-ui-context.js';
9
10
  type AgentSessionRuntime = import('@earendil-works/pi-coding-agent', { with: { 'resolution-mode': 'import' } }).AgentSessionRuntime;
@@ -19,6 +20,8 @@ export interface TaSessionContext {
19
20
  requestClose(session: TaSession): void;
20
21
  /** TaOpenSessionOptions.group. */
21
22
  group?: string;
23
+ /** TaOpenSessionOptions.appendSystemPrompt: kept in the session file, for when it opens again from it. */
24
+ role?: string;
22
25
  /** The location of the directory pi works in (PiDirectories.fromPi); default: that directory. */
23
26
  locate?(cwd: string): string;
24
27
  }
@@ -35,6 +38,7 @@ export declare class TaSession {
35
38
  protected readonly log: EventLog;
36
39
  protected readonly receipts: ReceiptBook;
37
40
  protected readonly channels: Set<ClientChannel>;
41
+ protected readonly live: LiveRun;
38
42
  protected unsubscribe?: () => void;
39
43
  protected idleTimer?: ReturnType<typeof setTimeout>;
40
44
  protected started: boolean;
@@ -44,16 +48,34 @@ export declare class TaSession {
44
48
  get cwd(): string;
45
49
  start(): Promise<void>;
46
50
  info(): TaSessionInfo;
47
- attach(channel: ClientChannel, afterSeq?: number): TaAttachResult;
51
+ attach(channel: ClientChannel, afterSeq?: number, options?: TaAttachOptions): TaAttachResult;
52
+ earlierMessages(before: number | undefined, timestamp: number | undefined, budget: number): TaMessagePage;
48
53
  detach(channel: ClientChannel): void;
49
54
  respondUi(response: RpcExtensionUIResponse): boolean;
55
+ /** Only a client attached runs a call: one that left would hold it for nobody. */
56
+ claimClientTool(channel: ClientChannel, id: string): boolean;
50
57
  respondClientTool(result: TaClientToolResult): boolean;
51
58
  prompt(input: TaPromptInput): Promise<TaPromptReceipt>;
52
59
  steer(input: TaPromptInput): Promise<TaPromptReceipt>;
53
60
  followUp(input: TaPromptInput): Promise<TaPromptReceipt>;
61
+ /**
62
+ * Takes one waiting message out of the queue. pi only clears the whole of it, so this reaches into its
63
+ * two lists: the texts it shows and the messages its agent will take, which keep their images.
64
+ */
65
+ removeQueued(kind: 'steering' | 'followUp', index: number): boolean;
54
66
  /** pi's runtime says nothing of a move in the tree: the clients are told to read the conversation again. */
55
67
  navigateTree(targetId: string, options?: Parameters<AgentSession['navigateTree']>[1]): Promise<TaNavigateResult>;
68
+ /** As pi's `/reload`; the clients are told to read the commands again, which pi says nothing of. */
69
+ reload(): Promise<void>;
70
+ /**
71
+ * Ends the session, and unlocks its file whatever happens: a lock left behind is held by this live process,
72
+ * and refuses its conversation (CELL_TA_SESSION_LOCKED) until ta serve restarts. A run that does not stop
73
+ * (a tool that ignores the abort, a stream that hangs) or an extension slow to shut down is given
74
+ * `closeTimeoutMs`; then pi is cut off from its agent, so that nothing more goes into the file.
75
+ */
56
76
  close(): Promise<void>;
77
+ /** False when `work` takes longer than closeTimeoutMs. */
78
+ protected within(work: Promise<void>): Promise<boolean>;
57
79
  protected accept(input: TaPromptInput, run: () => Promise<PromptDisposition>): Promise<TaPromptReceipt>;
58
80
  /** Connects this object to the session the runtime has now: at the start and after each replacement. */
59
81
  protected bind(): Promise<void>;
@@ -1,7 +1,10 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { EventLog } from './event-log.js';
3
+ import { LiveRun } from './live-run.js';
4
+ import { MessagePage } from './message-page.js';
3
5
  import { ReceiptBook } from './receipt-book.js';
4
6
  import { RemoteUiContext } from './remote-ui-context.js';
7
+ import { SessionCatalogUtil } from './session-catalog.js';
5
8
  import { SessionInfoUtil } from './session-info-util.js';
6
9
  import { TaEventUtil } from './ta-event-util.js';
7
10
  /**
@@ -15,6 +18,7 @@ export class TaSession {
15
18
  this.createdAt = Date.now();
16
19
  this.receipts = new ReceiptBook();
17
20
  this.channels = new Set();
21
+ this.live = new LiveRun();
18
22
  this.started = false;
19
23
  this.runtime = context.runtime;
20
24
  this.log = new EventLog(this.id, context.options.eventBufferBytes);
@@ -54,13 +58,16 @@ export class TaSession {
54
58
  group: this.context.group,
55
59
  };
56
60
  }
57
- attach(channel, afterSeq) {
61
+ attach(channel, afterSeq, options = {}) {
58
62
  this.channels.add(channel);
59
63
  this.watchIdle();
60
64
  const { events, gap } = afterSeq === undefined ? { events: [], gap: false } : this.log.since(afterSeq);
61
65
  return {
62
66
  info: this.info(),
63
67
  events,
68
+ conversation: afterSeq === undefined || gap
69
+ ? MessagePage.recent(this.live.conversation(this.pi.messages, this.pi.isStreaming), options.recentBytes)
70
+ : undefined,
64
71
  pendingUi: this.ui.pendingRequests,
65
72
  shownUi: this.ui.shownRequests,
66
73
  pendingClientTools: this.context.clientTools.pendingRequests,
@@ -68,14 +75,22 @@ export class TaSession {
68
75
  gap,
69
76
  };
70
77
  }
78
+ earlierMessages(before, timestamp, budget) {
79
+ return MessagePage.before(this.live.conversation(this.pi.messages, this.pi.isStreaming).messages, before, timestamp, budget);
80
+ }
71
81
  detach(channel) {
72
82
  if (this.channels.delete(channel)) {
83
+ this.context.clientTools.release(channel);
73
84
  this.watchIdle();
74
85
  }
75
86
  }
76
87
  respondUi(response) {
77
88
  return this.ui.respond(response);
78
89
  }
90
+ /** Only a client attached runs a call: one that left would hold it for nobody. */
91
+ claimClientTool(channel, id) {
92
+ return this.channels.has(channel) && this.context.clientTools.claim(id, channel);
93
+ }
79
94
  respondClientTool(result) {
80
95
  return this.context.clientTools.respond(result);
81
96
  }
@@ -99,14 +114,48 @@ export class TaSession {
99
114
  followUp(input) {
100
115
  return this.accept(input, () => this.pi.followUp(input.message, input.images, { source: 'rpc' }));
101
116
  }
117
+ /**
118
+ * Takes one waiting message out of the queue. pi only clears the whole of it, so this reaches into its
119
+ * two lists: the texts it shows and the messages its agent will take, which keep their images.
120
+ */
121
+ removeQueued(kind, index) {
122
+ const pi = this.pi;
123
+ const texts = kind === 'steering' ? pi._steeringMessages : pi._followUpMessages;
124
+ const queue = kind === 'steering' ? pi.agent.steeringQueue : pi.agent.followUpQueue;
125
+ const text = texts === null || texts === void 0 ? void 0 : texts[index];
126
+ if (text === undefined || !Array.isArray(queue === null || queue === void 0 ? void 0 : queue.messages)) {
127
+ return false;
128
+ }
129
+ // The agent takes from the front and pi forgets a text when its message starts: match by the text.
130
+ const at = queue.messages.findIndex(message => { var _a, _b; return ((_b = (_a = message.content) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.text) === text; });
131
+ if (at === -1) {
132
+ return false;
133
+ }
134
+ queue.messages = queue.messages.filter((_, i) => i !== at);
135
+ texts.splice(index, 1);
136
+ pi._emitQueueUpdate();
137
+ return true;
138
+ }
102
139
  /** pi's runtime says nothing of a move in the tree: the clients are told to read the conversation again. */
103
140
  async navigateTree(targetId, options) {
104
141
  const { cancelled, editorText } = await this.pi.navigateTree(targetId, options);
105
142
  if (!cancelled) {
143
+ this.live.reset(this.pi.messages);
106
144
  this.publish({ type: 'session_replaced', info: this.info() });
107
145
  }
108
146
  return { cancelled, editorText };
109
147
  }
148
+ /** As pi's `/reload`; the clients are told to read the commands again, which pi says nothing of. */
149
+ async reload() {
150
+ await this.pi.reload();
151
+ this.publish({ type: 'session_reloaded' });
152
+ }
153
+ /**
154
+ * Ends the session, and unlocks its file whatever happens: a lock left behind is held by this live process,
155
+ * and refuses its conversation (CELL_TA_SESSION_LOCKED) until ta serve restarts. A run that does not stop
156
+ * (a tool that ignores the abort, a stream that hangs) or an extension slow to shut down is given
157
+ * `closeTimeoutMs`; then pi is cut off from its agent, so that nothing more goes into the file.
158
+ */
110
159
  async close() {
111
160
  var _a;
112
161
  clearTimeout(this.idleTimer);
@@ -115,11 +164,31 @@ export class TaSession {
115
164
  this.publish({ type: 'session_closed' });
116
165
  this.channels.clear();
117
166
  (_a = this.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(this);
118
- if (this.pi.isStreaming) {
119
- await this.pi.abort();
167
+ try {
168
+ if (this.pi.isStreaming) {
169
+ // Its failure is no reason to keep the session: dispose below aborts the run as well.
170
+ await this.within(this.pi.abort().catch(() => undefined));
171
+ }
172
+ if (!(await this.within(this.runtime.dispose()))) {
173
+ this.pi.dispose();
174
+ }
175
+ }
176
+ finally {
177
+ this.context.lock.releaseAll();
178
+ }
179
+ }
180
+ /** False when `work` takes longer than closeTimeoutMs. */
181
+ async within(work) {
182
+ let timer;
183
+ const late = new Promise(resolve => {
184
+ timer = setTimeout(() => resolve(false), this.context.options.closeTimeoutMs);
185
+ });
186
+ try {
187
+ return await Promise.race([work.then(() => true), late]);
188
+ }
189
+ finally {
190
+ clearTimeout(timer);
120
191
  }
121
- await this.runtime.dispose();
122
- this.context.lock.releaseAll();
123
192
  }
124
193
  async accept(input, run) {
125
194
  const duplicate = this.receipts.take(input);
@@ -140,6 +209,12 @@ export class TaSession {
140
209
  var _a;
141
210
  (_a = this.unsubscribe) === null || _a === void 0 ? void 0 : _a.call(this);
142
211
  const { pi, runtime } = this;
212
+ if (this.context.group) {
213
+ SessionCatalogUtil.markGroup(pi.sessionManager, this.context.group);
214
+ }
215
+ if (this.context.role) {
216
+ SessionCatalogUtil.markRole(pi.sessionManager, this.context.role);
217
+ }
143
218
  await pi.bindExtensions({
144
219
  uiContext: this.ui,
145
220
  mode: 'rpc',
@@ -149,12 +224,14 @@ export class TaSession {
149
224
  fork: async (entryId, options) => ({ cancelled: (await runtime.fork(entryId, options)).cancelled }),
150
225
  navigateTree: async (targetId, options) => ({ cancelled: (await this.navigateTree(targetId, options)).cancelled }),
151
226
  switchSession: (sessionPath, options) => runtime.switchSession(sessionPath, options),
152
- reload: () => pi.reload(),
227
+ reload: () => this.reload(),
153
228
  },
154
229
  shutdownHandler: () => this.context.requestClose(this),
155
230
  onError: error => this.publish({ type: 'extension_error', extensionPath: error.extensionPath, event: error.event, error: error.error }),
156
231
  });
232
+ this.live.reset(pi.messages);
157
233
  this.unsubscribe = pi.subscribe(event => {
234
+ this.live.observe(event, pi.messages);
158
235
  this.publish(TaEventUtil.toWire(event));
159
236
  if (event.type === 'agent_settled') {
160
237
  this.watchIdle();
@@ -0,0 +1,46 @@
1
+ import type { TaTemporaryFrom, TaTemporaryInfo } from '@celljs/ta-protocol';
2
+ /** A package opened without installing: where it is, and what Ta knows of it. */
3
+ export interface TemporaryRecord extends TaTemporaryInfo {
4
+ root: string;
5
+ }
6
+ interface TemporaryFile {
7
+ /** After how many days unused a package not kept goes; 0 never. */
8
+ retentionDays?: number;
9
+ packages?: TemporaryRecord[];
10
+ }
11
+ /**
12
+ * The temporary packages of an agent directory (`ta-launcher.md`): `temporary.json` lists them, and
13
+ * `temporary/` holds the directories Ta owns (made by an agent), which are temporary without a record
14
+ * too. Read and written whole: it is small, and only `ta serve` writes it.
15
+ */
16
+ export declare class TemporaryStore {
17
+ protected readonly agentDir: string;
18
+ protected readonly now: () => number;
19
+ static readonly FILE = "temporary.json";
20
+ static readonly DIRECTORY = "temporary";
21
+ static readonly DEFAULT_RETENTION_DAYS = 30;
22
+ static readonly DAY_MS: number;
23
+ constructor(agentDir: string, now?: () => number);
24
+ /** Where an agent makes a temporary package: `<agent dir>/temporary`. */
25
+ get directory(): string;
26
+ /** Whether Ta owns the directory, so that removing the package deletes it. */
27
+ owns(root: string): boolean;
28
+ /** Those whose directory is there: the records, and the directories of `temporary/` without one (made by an agent). */
29
+ list(): TemporaryRecord[];
30
+ find(match: (record: TemporaryRecord) => boolean): TemporaryRecord | undefined;
31
+ /** Notes a package opened from `source`, or that it was opened again. */
32
+ add(root: string, source: string, from: TaTemporaryFrom): TemporaryRecord;
33
+ update(root: string, change: {
34
+ used?: boolean;
35
+ kept?: boolean;
36
+ }): void;
37
+ forget(root: string): void;
38
+ get retentionDays(): number;
39
+ set retentionDays(days: number);
40
+ /** Those not kept and unused (since they were opened, when never used) for longer than the retention. */
41
+ expired(): TemporaryRecord[];
42
+ protected save(packages: TemporaryRecord[]): void;
43
+ protected read(): TemporaryFile;
44
+ protected write(file: TemporaryFile): void;
45
+ }
46
+ export {};
@@ -0,0 +1,114 @@
1
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
2
+ import { join, relative, resolve, sep } from 'node:path';
3
+ import { WebExtensionUtil } from './web-extension-util.js';
4
+ /**
5
+ * The temporary packages of an agent directory (`ta-launcher.md`): `temporary.json` lists them, and
6
+ * `temporary/` holds the directories Ta owns (made by an agent), which are temporary without a record
7
+ * too. Read and written whole: it is small, and only `ta serve` writes it.
8
+ */
9
+ export class TemporaryStore {
10
+ constructor(agentDir, now = Date.now) {
11
+ this.agentDir = agentDir;
12
+ this.now = now;
13
+ }
14
+ /** Where an agent makes a temporary package: `<agent dir>/temporary`. */
15
+ get directory() {
16
+ return join(this.agentDir, TemporaryStore.DIRECTORY);
17
+ }
18
+ /** Whether Ta owns the directory, so that removing the package deletes it. */
19
+ owns(root) {
20
+ const path = relative(this.directory, resolve(root));
21
+ return path !== '' && !path.startsWith('..') && !path.includes(sep) && !path.startsWith(sep);
22
+ }
23
+ /** Those whose directory is there: the records, and the directories of `temporary/` without one (made by an agent). */
24
+ list() {
25
+ var _a, _b;
26
+ const file = this.read();
27
+ const records = ((_a = file.packages) !== null && _a !== void 0 ? _a : []).filter(record => existsSync(join(record.root, 'package.json')));
28
+ const known = new Set(records.map(record => resolve(record.root)));
29
+ const now = this.now();
30
+ for (const root of WebExtensionUtil.packageDirectories(this.directory)) {
31
+ if (!known.has(resolve(root))) {
32
+ records.push({ root, source: root, from: 'agent', openedAt: now, usedAt: 0, kept: false });
33
+ }
34
+ }
35
+ if (records.length !== ((_b = file.packages) !== null && _b !== void 0 ? _b : []).length || records.some((record, index) => { var _a; return record !== ((_a = file.packages) === null || _a === void 0 ? void 0 : _a[index]); })) {
36
+ this.write({ ...file, packages: records });
37
+ }
38
+ return records;
39
+ }
40
+ find(match) {
41
+ return this.list().find(match);
42
+ }
43
+ /** Notes a package opened from `source`, or that it was opened again. */
44
+ add(root, source, from) {
45
+ var _a;
46
+ const now = this.now();
47
+ const records = this.list();
48
+ const found = records.find(record => resolve(record.root) === resolve(root));
49
+ // A directory of temporary/ seen before its record (list() notes it as an agent's) takes where it came from.
50
+ const known = found && !(found.from === 'agent' && found.source === found.root && from !== 'agent');
51
+ const record = known ? { ...found, usedAt: now } : { root, source, from, openedAt: now, usedAt: now, kept: (_a = found === null || found === void 0 ? void 0 : found.kept) !== null && _a !== void 0 ? _a : false };
52
+ this.save(found ? records.map(other => (other === found ? record : other)) : [...records, record]);
53
+ return record;
54
+ }
55
+ update(root, change) {
56
+ const records = this.list();
57
+ this.save(records.map(record => { var _a; return resolve(record.root) === resolve(root)
58
+ ? { ...record, usedAt: change.used ? this.now() : record.usedAt, kept: (_a = change.kept) !== null && _a !== void 0 ? _a : record.kept }
59
+ : record; }));
60
+ }
61
+ forget(root) {
62
+ this.save(this.list().filter(record => resolve(record.root) !== resolve(root)));
63
+ }
64
+ get retentionDays() {
65
+ const days = this.read().retentionDays;
66
+ return typeof days === 'number' && Number.isInteger(days) && days >= 0 ? days : TemporaryStore.DEFAULT_RETENTION_DAYS;
67
+ }
68
+ set retentionDays(days) {
69
+ this.write({ ...this.read(), retentionDays: days });
70
+ }
71
+ /** Those not kept and unused (since they were opened, when never used) for longer than the retention. */
72
+ expired() {
73
+ const days = this.retentionDays;
74
+ if (days === 0) {
75
+ return [];
76
+ }
77
+ const before = this.now() - days * TemporaryStore.DAY_MS;
78
+ return this.list().filter(record => !record.kept && Math.max(record.usedAt, record.openedAt) < before);
79
+ }
80
+ save(packages) {
81
+ this.write({ ...this.read(), packages });
82
+ }
83
+ read() {
84
+ var _a;
85
+ try {
86
+ const value = JSON.parse(readFileSync(join(this.agentDir, TemporaryStore.FILE), 'utf8'));
87
+ return value && typeof value === 'object' ? { ...value, packages: ((_a = value.packages) !== null && _a !== void 0 ? _a : []).filter(isRecord) } : {};
88
+ }
89
+ catch (_b) {
90
+ return {};
91
+ }
92
+ }
93
+ write(file) {
94
+ mkdirSync(this.agentDir, { recursive: true });
95
+ const path = join(this.agentDir, TemporaryStore.FILE);
96
+ writeFileSync(`${path}.tmp`, `${JSON.stringify(file, undefined, 2)}\n`);
97
+ renameSync(`${path}.tmp`, path);
98
+ }
99
+ }
100
+ TemporaryStore.FILE = 'temporary.json';
101
+ TemporaryStore.DIRECTORY = 'temporary';
102
+ TemporaryStore.DEFAULT_RETENTION_DAYS = 30;
103
+ TemporaryStore.DAY_MS = 24 * 60 * 60 * 1000;
104
+ function isRecord(value) {
105
+ const record = value;
106
+ return (!!record &&
107
+ typeof record.root === 'string' &&
108
+ typeof record.source === 'string' &&
109
+ (record.from === 'market' || record.from === 'link' || record.from === 'agent') &&
110
+ typeof record.openedAt === 'number' &&
111
+ typeof record.usedAt === 'number' &&
112
+ typeof record.kept === 'boolean');
113
+ }
114
+ //# sourceMappingURL=temporary-packages.js.map
@@ -0,0 +1,13 @@
1
+ import { type Application, ApplicationLifecycle } from '@celljs/core';
2
+ import { ExecEnvironmentFactory } from '@celljs/ta-exec';
3
+ import { WebExtensionCatalog } from './host-protocol.js';
4
+ /** Clears the temporary packages not kept and unused for longer than their retention (TemporaryStore). */
5
+ export declare class TemporaryPurge implements ApplicationLifecycle<Application> {
6
+ protected readonly catalog: WebExtensionCatalog;
7
+ protected readonly environments: ExecEnvironmentFactory;
8
+ protected first?: ReturnType<typeof setTimeout>;
9
+ protected timer?: ReturnType<typeof setInterval>;
10
+ onStart(): void;
11
+ onStop(): void;
12
+ purge(): Promise<number>;
13
+ }
@@ -0,0 +1,51 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { ApplicationLifecycle, Autowired, Component } from '@celljs/core';
11
+ import { ExecEnvironmentFactory } from '@celljs/ta-exec';
12
+ import { WebExtensionCatalog } from './host-protocol.js';
13
+ /** How often the temporary packages unused too long are looked for, besides when the server starts. */
14
+ const EVERY_MS = 12 * 60 * 60 * 1000;
15
+ /** Clears the temporary packages not kept and unused for longer than their retention (TemporaryStore). */
16
+ let TemporaryPurge = class TemporaryPurge {
17
+ onStart() {
18
+ var _a, _b, _c, _d;
19
+ // Not in the way of the start: a while after it.
20
+ this.first = setTimeout(() => void this.purge(), 30000);
21
+ (_b = (_a = this.first).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
22
+ this.timer = setInterval(() => void this.purge(), EVERY_MS);
23
+ (_d = (_c = this.timer).unref) === null || _d === void 0 ? void 0 : _d.call(_c);
24
+ }
25
+ onStop() {
26
+ clearTimeout(this.first);
27
+ clearInterval(this.timer);
28
+ }
29
+ async purge() {
30
+ try {
31
+ return await this.catalog.purgeTemporary(await this.environments.defaultCwd());
32
+ }
33
+ catch (error) {
34
+ console.warn('Could not clear the temporary packages:', error);
35
+ return 0;
36
+ }
37
+ }
38
+ };
39
+ __decorate([
40
+ Autowired(WebExtensionCatalog),
41
+ __metadata("design:type", Object)
42
+ ], TemporaryPurge.prototype, "catalog", void 0);
43
+ __decorate([
44
+ Autowired(ExecEnvironmentFactory),
45
+ __metadata("design:type", Object)
46
+ ], TemporaryPurge.prototype, "environments", void 0);
47
+ TemporaryPurge = __decorate([
48
+ Component(ApplicationLifecycle)
49
+ ], TemporaryPurge);
50
+ export { TemporaryPurge };
51
+ //# sourceMappingURL=temporary-purge.js.map
@@ -1,7 +1,8 @@
1
1
  import { type CodingAgentOptions, type PiSdk } from '@celljs/ai-coding-agent';
2
- import type { TaPackageInfo, TaSettingsScope, TaWebExtensionInfo, TaWebExtensionSource } from '@celljs/ta-protocol';
2
+ import type { TaPackageInfo, TaSettingsScope, TaTemporaryFrom, TaTemporaryInfo, TaWebExtensionInfo, TaWebExtensionSource } from '@celljs/ta-protocol';
3
3
  import { WebExtensionCatalog } from './host-protocol.js';
4
4
  import { PiDirectories } from './remote/remote-protocol.js';
5
+ import { type TemporaryRecord, TemporaryStore } from './temporary-packages.js';
5
6
  import { type WebExtensionPackage } from './web-extension-util.js';
6
7
  type PackageManager = InstanceType<PiSdk['DefaultPackageManager']>;
7
8
  type SettingsManager = ReturnType<PiSdk['SettingsManager']['create']>;
@@ -11,6 +12,8 @@ interface Loaded {
11
12
  settings: SettingsManager;
12
13
  trusted: boolean;
13
14
  projectDir: string;
15
+ /** pi's, a directory of this machine. */
16
+ cwd: string;
14
17
  }
15
18
  /**
16
19
  * Finds packages, and their web extensions, where pi finds extensions: in the packages that come with ta, in the packages of
@@ -22,6 +25,24 @@ export declare class WebExtensionCatalogImpl implements WebExtensionCatalog {
22
25
  protected readonly directories: PiDirectories;
23
26
  packages(cwd: string): Promise<TaPackageInfo[]>;
24
27
  install(cwd: string, source: string, scope: TaSettingsScope): Promise<void>;
28
+ openTemporary(cwd: string, source: string, from: TaTemporaryFrom): Promise<TaWebExtensionInfo[]>;
29
+ updateTemporary(cwd: string, id: string, change: {
30
+ used?: boolean;
31
+ kept?: boolean;
32
+ }): Promise<void>;
33
+ installTemporary(cwd: string, id: string): Promise<void>;
34
+ /** Removes the temporary packages unused for longer than the retention, not kept; how many went. */
35
+ purgeTemporary(cwd: string): Promise<number>;
36
+ get temporaryRetention(): number;
37
+ setTemporaryRetention(days: number): void;
38
+ protected temporary(): TemporaryStore;
39
+ packageOf(cwd: string, id: string): Promise<TaPackageInfo>;
40
+ /** A package another computer shared by a link, put in Ta's own temporary directory (RelayShareUtil). */
41
+ protected fetchShare(link: string): Promise<string>;
42
+ protected fetch(manager: PackageManager, source: string): Promise<string>;
43
+ protected findTemporary(cwd: string, id: string): Promise<WebExtensionPackage>;
44
+ /** Ta's own directory is deleted, what pi fetched removed, a path of the user's only forgotten. */
45
+ protected dropTemporary(record: TemporaryRecord, manager: PackageManager): Promise<void>;
25
46
  removePackage(cwd: string, id: string): Promise<void>;
26
47
  list(cwd: string): Promise<TaWebExtensionInfo[]>;
27
48
  read(cwd: string, id: string): Promise<TaWebExtensionSource>;
@@ -37,4 +58,10 @@ export declare class WebExtensionCatalogImpl implements WebExtensionCatalog {
37
58
  protected resolve(manager: PackageManager): Promise<import("@earendil-works/pi-coding-agent").ResolvedPaths>;
38
59
  protected load(location: string): Promise<Loaded>;
39
60
  }
61
+ export declare namespace TemporaryUtil {
62
+ /** A source of the file system, as pi takes it: not `npm:`, `git:` or a URL. */
63
+ function isPath(source: string): boolean;
64
+ function expand(path: string): string;
65
+ function info({ source, from, openedAt, usedAt, kept }: TemporaryRecord): TaTemporaryInfo;
66
+ }
40
67
  export {};