@celljs/ta 4.5.1 → 4.6.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 (510) hide show
  1. package/README.md +27 -23
  2. package/dist/cli.mjs +1634 -50
  3. package/dist/pi/CHANGELOG.md +22 -0
  4. package/dist/pi/dist/bundle/chunks/chunk-44DLKSKE.js +14 -14
  5. package/dist/pi/dist/bundle/chunks/openai-chatgpt.js +1 -1
  6. package/dist/pi/package.json +1 -1
  7. package/dist/pi/packages/ta-channels/README.md +48 -0
  8. package/dist/pi/packages/ta-channels/extension/index.mjs +651 -0
  9. package/dist/pi/packages/ta-channels/host/index.mjs +921 -0
  10. package/dist/pi/packages/ta-channels/lib/agent-menu.d.ts +13 -0
  11. package/dist/pi/packages/ta-channels/lib/agent-menu.d.ts.map +1 -0
  12. package/dist/pi/packages/ta-channels/lib/agent-menu.js +177 -0
  13. package/dist/pi/packages/ta-channels/lib/agent-menu.js.map +1 -0
  14. package/dist/pi/packages/ta-channels/lib/channel-menu.d.ts +12 -0
  15. package/dist/pi/packages/ta-channels/lib/channel-menu.d.ts.map +1 -0
  16. package/dist/pi/packages/ta-channels/lib/channel-menu.js +93 -0
  17. package/dist/pi/packages/ta-channels/lib/channel-menu.js.map +1 -0
  18. package/dist/pi/packages/ta-channels/lib/channels-model.d.ts +192 -0
  19. package/dist/pi/packages/ta-channels/lib/channels-model.d.ts.map +1 -0
  20. package/dist/pi/packages/ta-channels/lib/channels-model.js +49 -0
  21. package/dist/pi/packages/ta-channels/lib/channels-model.js.map +1 -0
  22. package/dist/pi/packages/ta-channels/lib/channels-util.d.ts +149 -0
  23. package/dist/pi/packages/ta-channels/lib/channels-util.d.ts.map +1 -0
  24. package/dist/pi/packages/ta-channels/lib/channels-util.js +544 -0
  25. package/dist/pi/packages/ta-channels/lib/channels-util.js.map +1 -0
  26. package/dist/pi/packages/ta-channels/lib/channels.d.ts +81 -0
  27. package/dist/pi/packages/ta-channels/lib/channels.d.ts.map +1 -0
  28. package/dist/pi/packages/ta-channels/lib/channels.js +181 -0
  29. package/dist/pi/packages/ta-channels/lib/channels.js.map +1 -0
  30. package/dist/pi/packages/ta-channels/lib/create.d.ts +19 -0
  31. package/dist/pi/packages/ta-channels/lib/create.d.ts.map +1 -0
  32. package/dist/pi/packages/ta-channels/lib/create.js +182 -0
  33. package/dist/pi/packages/ta-channels/lib/create.js.map +1 -0
  34. package/dist/pi/packages/ta-channels/lib/extension.d.ts +19 -0
  35. package/dist/pi/packages/ta-channels/lib/extension.d.ts.map +1 -0
  36. package/dist/pi/packages/ta-channels/lib/extension.js +77 -0
  37. package/dist/pi/packages/ta-channels/lib/extension.js.map +1 -0
  38. package/dist/pi/packages/ta-channels/lib/faces.d.ts +17 -0
  39. package/dist/pi/packages/ta-channels/lib/faces.d.ts.map +1 -0
  40. package/dist/pi/packages/ta-channels/lib/faces.js +169 -0
  41. package/dist/pi/packages/ta-channels/lib/faces.js.map +1 -0
  42. package/dist/pi/packages/ta-channels/lib/host.d.ts +7 -0
  43. package/dist/pi/packages/ta-channels/lib/host.d.ts.map +1 -0
  44. package/dist/pi/packages/ta-channels/lib/host.js +14 -0
  45. package/dist/pi/packages/ta-channels/lib/host.js.map +1 -0
  46. package/dist/pi/packages/ta-channels/lib/i18n.d.ts +113 -0
  47. package/dist/pi/packages/ta-channels/lib/i18n.d.ts.map +1 -0
  48. package/dist/pi/packages/ta-channels/lib/i18n.js +223 -0
  49. package/dist/pi/packages/ta-channels/lib/i18n.js.map +1 -0
  50. package/dist/pi/packages/ta-channels/lib/index.d.ts +8 -0
  51. package/dist/pi/packages/ta-channels/lib/index.d.ts.map +1 -0
  52. package/dist/pi/packages/ta-channels/lib/index.js +84 -0
  53. package/dist/pi/packages/ta-channels/lib/index.js.map +1 -0
  54. package/dist/pi/packages/ta-channels/lib/members.d.ts +9 -0
  55. package/dist/pi/packages/ta-channels/lib/members.d.ts.map +1 -0
  56. package/dist/pi/packages/ta-channels/lib/members.js +150 -0
  57. package/dist/pi/packages/ta-channels/lib/members.js.map +1 -0
  58. package/dist/pi/packages/ta-channels/lib/more-menu.d.ts +19 -0
  59. package/dist/pi/packages/ta-channels/lib/more-menu.d.ts.map +1 -0
  60. package/dist/pi/packages/ta-channels/lib/more-menu.js +79 -0
  61. package/dist/pi/packages/ta-channels/lib/more-menu.js.map +1 -0
  62. package/dist/pi/packages/ta-channels/lib/react.d.ts +8 -0
  63. package/dist/pi/packages/ta-channels/lib/react.d.ts.map +1 -0
  64. package/dist/pi/packages/ta-channels/lib/react.js +8 -0
  65. package/dist/pi/packages/ta-channels/lib/react.js.map +1 -0
  66. package/dist/pi/packages/ta-channels/lib/room.d.ts +22 -0
  67. package/dist/pi/packages/ta-channels/lib/room.d.ts.map +1 -0
  68. package/dist/pi/packages/ta-channels/lib/room.js +133 -0
  69. package/dist/pi/packages/ta-channels/lib/room.js.map +1 -0
  70. package/dist/pi/packages/ta-channels/lib/sidebar.d.ts +10 -0
  71. package/dist/pi/packages/ta-channels/lib/sidebar.d.ts.map +1 -0
  72. package/dist/pi/packages/ta-channels/lib/sidebar.js +162 -0
  73. package/dist/pi/packages/ta-channels/lib/sidebar.js.map +1 -0
  74. package/dist/pi/packages/ta-channels/lib/style.d.ts +5 -0
  75. package/dist/pi/packages/ta-channels/lib/style.d.ts.map +1 -0
  76. package/dist/pi/packages/ta-channels/lib/style.js +252 -0
  77. package/dist/pi/packages/ta-channels/lib/style.js.map +1 -0
  78. package/dist/pi/packages/ta-channels/lib/team-tools.d.ts +15 -0
  79. package/dist/pi/packages/ta-channels/lib/team-tools.d.ts.map +1 -0
  80. package/dist/pi/packages/ta-channels/lib/team-tools.js +92 -0
  81. package/dist/pi/packages/ta-channels/lib/team-tools.js.map +1 -0
  82. package/dist/pi/packages/ta-channels/lib/team.d.ts +134 -0
  83. package/dist/pi/packages/ta-channels/lib/team.d.ts.map +1 -0
  84. package/dist/pi/packages/ta-channels/lib/team.js +469 -0
  85. package/dist/pi/packages/ta-channels/lib/team.js.map +1 -0
  86. package/dist/pi/packages/ta-channels/lib/views.d.ts +93 -0
  87. package/dist/pi/packages/ta-channels/lib/views.d.ts.map +1 -0
  88. package/dist/pi/packages/ta-channels/lib/views.js +188 -0
  89. package/dist/pi/packages/ta-channels/lib/views.js.map +1 -0
  90. package/dist/pi/packages/ta-channels/package.json +46 -0
  91. package/dist/pi/packages/ta-channels/web/index.js +3144 -0
  92. package/dist/pi/packages/ta-extensions/README.md +20 -0
  93. package/dist/pi/packages/ta-extensions/host/index.mjs +271 -0
  94. package/dist/pi/packages/ta-extensions/lib/actions.d.ts +42 -0
  95. package/dist/pi/packages/ta-extensions/lib/actions.d.ts.map +1 -0
  96. package/dist/pi/packages/ta-extensions/lib/actions.js +168 -0
  97. package/dist/pi/packages/ta-extensions/lib/actions.js.map +1 -0
  98. package/dist/pi/packages/ta-extensions/lib/archive.d.ts +30 -0
  99. package/dist/pi/packages/ta-extensions/lib/archive.d.ts.map +1 -0
  100. package/dist/pi/packages/ta-extensions/lib/archive.js +213 -0
  101. package/dist/pi/packages/ta-extensions/lib/archive.js.map +1 -0
  102. package/dist/pi/packages/ta-extensions/lib/extensions-util.d.ts +14 -0
  103. package/dist/pi/packages/ta-extensions/lib/extensions-util.d.ts.map +1 -0
  104. package/dist/pi/packages/ta-extensions/lib/extensions-util.js +38 -0
  105. package/dist/pi/packages/ta-extensions/lib/extensions-util.js.map +1 -0
  106. package/dist/pi/packages/ta-extensions/lib/host.d.ts +36 -0
  107. package/dist/pi/packages/ta-extensions/lib/host.d.ts.map +1 -0
  108. package/dist/pi/packages/ta-extensions/lib/host.js +94 -0
  109. package/dist/pi/packages/ta-extensions/lib/host.js.map +1 -0
  110. package/dist/pi/packages/ta-extensions/lib/i18n.d.ts +64 -0
  111. package/dist/pi/packages/ta-extensions/lib/i18n.d.ts.map +1 -0
  112. package/dist/pi/packages/ta-extensions/lib/i18n.js +148 -0
  113. package/dist/pi/packages/ta-extensions/lib/i18n.js.map +1 -0
  114. package/dist/pi/packages/ta-extensions/lib/import-dialog.d.ts +10 -0
  115. package/dist/pi/packages/ta-extensions/lib/import-dialog.d.ts.map +1 -0
  116. package/dist/pi/packages/ta-extensions/lib/import-dialog.js +56 -0
  117. package/dist/pi/packages/ta-extensions/lib/import-dialog.js.map +1 -0
  118. package/dist/pi/packages/ta-extensions/lib/index.d.ts +7 -0
  119. package/dist/pi/packages/ta-extensions/lib/index.d.ts.map +1 -0
  120. package/dist/pi/packages/ta-extensions/lib/index.js +49 -0
  121. package/dist/pi/packages/ta-extensions/lib/index.js.map +1 -0
  122. package/dist/pi/packages/ta-extensions/lib/page.d.ts +22 -0
  123. package/dist/pi/packages/ta-extensions/lib/page.d.ts.map +1 -0
  124. package/dist/pi/packages/ta-extensions/lib/page.js +143 -0
  125. package/dist/pi/packages/ta-extensions/lib/page.js.map +1 -0
  126. package/dist/pi/packages/ta-extensions/lib/pictures.d.ts +6 -0
  127. package/dist/pi/packages/ta-extensions/lib/pictures.d.ts.map +1 -0
  128. package/dist/pi/packages/ta-extensions/lib/pictures.js +62 -0
  129. package/dist/pi/packages/ta-extensions/lib/pictures.js.map +1 -0
  130. package/dist/pi/packages/ta-extensions/lib/react.d.ts +8 -0
  131. package/dist/pi/packages/ta-extensions/lib/react.d.ts.map +1 -0
  132. package/dist/pi/packages/ta-extensions/lib/react.js +8 -0
  133. package/dist/pi/packages/ta-extensions/lib/react.js.map +1 -0
  134. package/dist/pi/packages/ta-extensions/lib/style.d.ts +4 -0
  135. package/dist/pi/packages/ta-extensions/lib/style.d.ts.map +1 -0
  136. package/dist/pi/packages/ta-extensions/lib/style.js +94 -0
  137. package/dist/pi/packages/ta-extensions/lib/style.js.map +1 -0
  138. package/dist/pi/packages/ta-extensions/package.json +46 -0
  139. package/dist/pi/packages/ta-extensions/skills/ta-package/SKILL.md +90 -0
  140. package/dist/pi/packages/ta-extensions/web/index.js +941 -0
  141. package/dist/pi/packages/ta-workspace/README.md +29 -0
  142. package/dist/pi/packages/ta-workspace/lib/browser.d.ts +9 -0
  143. package/dist/pi/packages/ta-workspace/lib/browser.d.ts.map +1 -0
  144. package/dist/pi/packages/ta-workspace/lib/browser.js +162 -0
  145. package/dist/pi/packages/ta-workspace/lib/browser.js.map +1 -0
  146. package/dist/pi/packages/ta-workspace/lib/common.d.ts +63 -0
  147. package/dist/pi/packages/ta-workspace/lib/common.d.ts.map +1 -0
  148. package/dist/pi/packages/ta-workspace/lib/common.js +180 -0
  149. package/dist/pi/packages/ta-workspace/lib/common.js.map +1 -0
  150. package/dist/pi/packages/ta-workspace/lib/editors.d.ts +47 -0
  151. package/dist/pi/packages/ta-workspace/lib/editors.d.ts.map +1 -0
  152. package/dist/pi/packages/ta-workspace/lib/editors.js +353 -0
  153. package/dist/pi/packages/ta-workspace/lib/editors.js.map +1 -0
  154. package/dist/pi/packages/ta-workspace/lib/explorer.d.ts +11 -0
  155. package/dist/pi/packages/ta-workspace/lib/explorer.d.ts.map +1 -0
  156. package/dist/pi/packages/ta-workspace/lib/explorer.js +388 -0
  157. package/dist/pi/packages/ta-workspace/lib/explorer.js.map +1 -0
  158. package/dist/pi/packages/ta-workspace/lib/file-icon.d.ts +9 -0
  159. package/dist/pi/packages/ta-workspace/lib/file-icon.d.ts.map +1 -0
  160. package/dist/pi/packages/ta-workspace/lib/file-icon.js +19 -0
  161. package/dist/pi/packages/ta-workspace/lib/file-icon.js.map +1 -0
  162. package/dist/pi/packages/ta-workspace/lib/host.d.ts +41 -0
  163. package/dist/pi/packages/ta-workspace/lib/host.d.ts.map +1 -0
  164. package/dist/pi/packages/ta-workspace/lib/host.js +117 -0
  165. package/dist/pi/packages/ta-workspace/lib/host.js.map +1 -0
  166. package/dist/pi/packages/ta-workspace/lib/i18n.d.ts +158 -0
  167. package/dist/pi/packages/ta-workspace/lib/i18n.d.ts.map +1 -0
  168. package/dist/pi/packages/ta-workspace/lib/i18n.js +319 -0
  169. package/dist/pi/packages/ta-workspace/lib/i18n.js.map +1 -0
  170. package/dist/pi/packages/ta-workspace/lib/index.d.ts +8 -0
  171. package/dist/pi/packages/ta-workspace/lib/index.d.ts.map +1 -0
  172. package/dist/pi/packages/ta-workspace/lib/index.js +64 -0
  173. package/dist/pi/packages/ta-workspace/lib/index.js.map +1 -0
  174. package/dist/pi/packages/ta-workspace/lib/open-files.d.ts +3 -0
  175. package/dist/pi/packages/ta-workspace/lib/open-files.d.ts.map +1 -0
  176. package/dist/pi/packages/ta-workspace/lib/open-files.js +59 -0
  177. package/dist/pi/packages/ta-workspace/lib/open-files.js.map +1 -0
  178. package/dist/pi/packages/ta-workspace/lib/preview.d.ts +16 -0
  179. package/dist/pi/packages/ta-workspace/lib/preview.d.ts.map +1 -0
  180. package/dist/pi/packages/ta-workspace/lib/preview.js +116 -0
  181. package/dist/pi/packages/ta-workspace/lib/preview.js.map +1 -0
  182. package/dist/pi/packages/ta-workspace/lib/react.d.ts +5 -0
  183. package/dist/pi/packages/ta-workspace/lib/react.d.ts.map +1 -0
  184. package/dist/pi/packages/ta-workspace/lib/react.js +8 -0
  185. package/dist/pi/packages/ta-workspace/lib/react.js.map +1 -0
  186. package/dist/pi/packages/ta-workspace/lib/scm.d.ts +3 -0
  187. package/dist/pi/packages/ta-workspace/lib/scm.d.ts.map +1 -0
  188. package/dist/pi/packages/ta-workspace/lib/scm.js +262 -0
  189. package/dist/pi/packages/ta-workspace/lib/scm.js.map +1 -0
  190. package/dist/pi/packages/ta-workspace/lib/search.d.ts +9 -0
  191. package/dist/pi/packages/ta-workspace/lib/search.d.ts.map +1 -0
  192. package/dist/pi/packages/ta-workspace/lib/search.js +286 -0
  193. package/dist/pi/packages/ta-workspace/lib/search.js.map +1 -0
  194. package/dist/pi/packages/ta-workspace/lib/style.d.ts +5 -0
  195. package/dist/pi/packages/ta-workspace/lib/style.d.ts.map +1 -0
  196. package/dist/pi/packages/ta-workspace/lib/style.js +228 -0
  197. package/dist/pi/packages/ta-workspace/lib/style.js.map +1 -0
  198. package/dist/pi/packages/ta-workspace/lib/terminal.d.ts +24 -0
  199. package/dist/pi/packages/ta-workspace/lib/terminal.d.ts.map +1 -0
  200. package/dist/pi/packages/ta-workspace/lib/terminal.js +283 -0
  201. package/dist/pi/packages/ta-workspace/lib/terminal.js.map +1 -0
  202. package/dist/pi/packages/ta-workspace/lib/util/ansi.d.ts +72 -0
  203. package/dist/pi/packages/ta-workspace/lib/util/ansi.d.ts.map +1 -0
  204. package/dist/pi/packages/ta-workspace/lib/util/ansi.js +434 -0
  205. package/dist/pi/packages/ta-workspace/lib/util/ansi.js.map +1 -0
  206. package/dist/pi/packages/ta-workspace/lib/util/file-icon.d.ts +10 -0
  207. package/dist/pi/packages/ta-workspace/lib/util/file-icon.d.ts.map +1 -0
  208. package/dist/pi/packages/ta-workspace/lib/util/file-icon.js +28 -0
  209. package/dist/pi/packages/ta-workspace/lib/util/file-icon.js.map +1 -0
  210. package/dist/pi/packages/ta-workspace/lib/util/git.d.ts +69 -0
  211. package/dist/pi/packages/ta-workspace/lib/util/git.d.ts.map +1 -0
  212. package/dist/pi/packages/ta-workspace/lib/util/git.js +173 -0
  213. package/dist/pi/packages/ta-workspace/lib/util/git.js.map +1 -0
  214. package/dist/pi/packages/ta-workspace/lib/util/keys.d.ts +14 -0
  215. package/dist/pi/packages/ta-workspace/lib/util/keys.d.ts.map +1 -0
  216. package/dist/pi/packages/ta-workspace/lib/util/keys.js +52 -0
  217. package/dist/pi/packages/ta-workspace/lib/util/keys.js.map +1 -0
  218. package/dist/pi/packages/ta-workspace/lib/util/preview.d.ts +18 -0
  219. package/dist/pi/packages/ta-workspace/lib/util/preview.d.ts.map +1 -0
  220. package/dist/pi/packages/ta-workspace/lib/util/preview.js +92 -0
  221. package/dist/pi/packages/ta-workspace/lib/util/preview.js.map +1 -0
  222. package/dist/pi/packages/ta-workspace/lib/util/search.d.ts +86 -0
  223. package/dist/pi/packages/ta-workspace/lib/util/search.d.ts.map +1 -0
  224. package/dist/pi/packages/ta-workspace/lib/util/search.js +243 -0
  225. package/dist/pi/packages/ta-workspace/lib/util/search.js.map +1 -0
  226. package/dist/pi/packages/ta-workspace/lib/util/seti-font.d.ts +3 -0
  227. package/dist/pi/packages/ta-workspace/lib/util/seti-font.d.ts.map +1 -0
  228. package/dist/pi/packages/ta-workspace/lib/util/seti-font.js +8 -0
  229. package/dist/pi/packages/ta-workspace/lib/util/seti-font.js.map +1 -0
  230. package/dist/pi/packages/ta-workspace/lib/util/seti.d.ts +10 -0
  231. package/dist/pi/packages/ta-workspace/lib/util/seti.d.ts.map +1 -0
  232. package/dist/pi/packages/ta-workspace/lib/util/seti.js +758 -0
  233. package/dist/pi/packages/ta-workspace/lib/util/seti.js.map +1 -0
  234. package/dist/pi/packages/ta-workspace/lib/util/workspace.d.ts +109 -0
  235. package/dist/pi/packages/ta-workspace/lib/util/workspace.d.ts.map +1 -0
  236. package/dist/pi/packages/ta-workspace/lib/util/workspace.js +294 -0
  237. package/dist/pi/packages/ta-workspace/lib/util/workspace.js.map +1 -0
  238. package/dist/pi/packages/ta-workspace/lib/workspace-client.d.ts +22 -0
  239. package/dist/pi/packages/ta-workspace/lib/workspace-client.d.ts.map +1 -0
  240. package/dist/pi/packages/ta-workspace/lib/workspace-client.js +118 -0
  241. package/dist/pi/packages/ta-workspace/lib/workspace-client.js.map +1 -0
  242. package/dist/pi/packages/ta-workspace/package.json +41 -0
  243. package/dist/pi/packages/ta-workspace/scripts/seti.ts +173 -0
  244. package/dist/pi/packages/ta-workspace/web/index.js +7289 -0
  245. package/dist/public/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  246. package/dist/public/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  247. package/dist/public/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  248. package/dist/public/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  249. package/dist/public/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  250. package/dist/public/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  251. package/dist/public/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  252. package/dist/public/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  253. package/dist/public/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  254. package/dist/public/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  255. package/dist/public/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  256. package/dist/public/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  257. package/dist/public/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  258. package/dist/public/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  259. package/dist/public/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  260. package/dist/public/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  261. package/dist/public/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  262. package/dist/public/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  263. package/dist/public/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  264. package/dist/public/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  265. package/dist/public/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  266. package/dist/public/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  267. package/dist/public/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  268. package/dist/public/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  269. package/dist/public/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  270. package/dist/public/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  271. package/dist/public/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  272. package/dist/public/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  273. package/dist/public/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  274. package/dist/public/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  275. package/dist/public/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  276. package/dist/public/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  277. package/dist/public/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  278. package/dist/public/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  279. package/dist/public/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  280. package/dist/public/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  281. package/dist/public/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  282. package/dist/public/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  283. package/dist/public/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  284. package/dist/public/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  285. package/dist/public/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  286. package/dist/public/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  287. package/dist/public/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  288. package/dist/public/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  289. package/dist/public/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  290. package/dist/public/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  291. package/dist/public/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  292. package/dist/public/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  293. package/dist/public/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  294. package/dist/public/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  295. package/dist/public/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  296. package/dist/public/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  297. package/dist/public/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  298. package/dist/public/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  299. package/dist/public/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  300. package/dist/public/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  301. package/dist/public/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  302. package/dist/public/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  303. package/dist/public/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  304. package/dist/public/assets/abap-08VXUWAP.js +1 -0
  305. package/dist/public/assets/abnfDiagram-S7VZAUFO-3_0FZVeo.js +1 -0
  306. package/dist/public/assets/apex-BWPQTe0t.js +1 -0
  307. package/dist/public/assets/architecture-WOLXFQ4H-BX-N-_gd.js +1 -0
  308. package/dist/public/assets/architectureDiagram-YGSQEFNW-Daeu1xjI.js +36 -0
  309. package/dist/public/assets/azcli-Bc_sGQ0U.js +1 -0
  310. package/dist/public/assets/bat-i0X4ZdIN.js +1 -0
  311. package/dist/public/assets/bicep-B5-_aFwp.js +2 -0
  312. package/dist/public/assets/blockDiagram-APKKGZFW-DjJS8902.js +140 -0
  313. package/dist/public/assets/bpmnIcons-APHXDYXF-C0jbCElo.js +1 -0
  314. package/dist/public/assets/browser-D2CY3Lfb.js +1 -0
  315. package/dist/public/assets/browser-DZ1aJcgd.js +12 -0
  316. package/dist/public/assets/c4Diagram-KJ2TOQU5-mKfHFqh9.js +38 -0
  317. package/dist/public/assets/cameligo-DMUM7wLl.js +1 -0
  318. package/dist/public/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
  319. package/dist/public/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
  320. package/dist/public/assets/chunk-6MUBBAK2-Cnx7dsB1.js +2 -0
  321. package/dist/public/assets/chunk-AXFCVDMN-g4Y7Pg2t.js +62 -0
  322. package/dist/public/assets/chunk-BG4553SI-QNE6A_Vg.js +129 -0
  323. package/dist/public/assets/chunk-DQASFODM-DPHr08r0.js +10 -0
  324. package/dist/public/assets/chunk-DUW6YSOI-Dgx8z5s3.js +1 -0
  325. package/dist/public/assets/chunk-HFQBQIA3-CenkxHlV.js +1 -0
  326. package/dist/public/assets/chunk-J5ZVWO5B-oDCd-gWO.js +1 -0
  327. package/dist/public/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
  328. package/dist/public/assets/chunk-KQLB2F66-C3Z8V8R_.js +2 -0
  329. package/dist/public/assets/chunk-KS47KZWR-BbUyxMWY.js +1 -0
  330. package/dist/public/assets/chunk-LEVMRMFU-CKECy4cp.js +1 -0
  331. package/dist/public/assets/chunk-M57EVK23-DuZd8RGI.js +1 -0
  332. package/dist/public/assets/chunk-NGNAAXSQ-Bxuf9Ivc.js +136 -0
  333. package/dist/public/assets/chunk-OY52VR5R-DatO2fu-.js +88 -0
  334. package/dist/public/assets/chunk-QB3YPZ4I-11782Ox2.js +213 -0
  335. package/dist/public/assets/chunk-R3KSYZAL-CCTi2rHV.js +1 -0
  336. package/dist/public/assets/chunk-STOXU5M4-DU6EHCIH.js +72 -0
  337. package/dist/public/assets/chunk-TU62E6Q5-BtgGljqq.js +1 -0
  338. package/dist/public/assets/chunk-X4PVCEUW-Dd_Qy0Gx.js +1 -0
  339. package/dist/public/assets/chunk-XXDRQBXY-DjOrWHxV.js +1 -0
  340. package/dist/public/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
  341. package/dist/public/assets/classDiagram-v2-L25IHNXF-KfN1--CA.js +217 -0
  342. package/dist/public/assets/client-sUFoEC5s.js +1 -0
  343. package/dist/public/assets/clojure-Cm7r79vr.js +1 -0
  344. package/dist/public/assets/codicon-DF1abBS2.ttf +0 -0
  345. package/dist/public/assets/coffee-Ba7i2nA0.js +1 -0
  346. package/dist/public/assets/common-CGQN5htF.js +4 -0
  347. package/dist/public/assets/cose-bilkent-JH36ORCC-BuWVQ5UC.js +1 -0
  348. package/dist/public/assets/cpp-C7h46wYY.js +1 -0
  349. package/dist/public/assets/csharp-BKxtCVv1.js +1 -0
  350. package/dist/public/assets/csp-bTuwJoIa.js +1 -0
  351. package/dist/public/assets/css-DIMkf-bt.js +3 -0
  352. package/dist/public/assets/cynefin-EF2NZ3EQ-D_GZWaFs.js +1 -0
  353. package/dist/public/assets/cynefinDiagram-L36ESFBY-BKljxAVP.js +62 -0
  354. package/dist/public/assets/cypher-CVaqCwHa.js +1 -0
  355. package/dist/public/assets/cytoscape.esm-DpEiRCgp.js +321 -0
  356. package/dist/public/assets/d3-scale-CElPUUud.js +1 -0
  357. package/dist/public/assets/d3-selection-CtCbiJ-r.js +1 -0
  358. package/dist/public/assets/dagre-SPEB5RXH-nD3f86OL.js +4 -0
  359. package/dist/public/assets/dart-onAF5SnQ.js +1 -0
  360. package/dist/public/assets/diagram-3B7GL73J-wSVpHF4f.js +200 -0
  361. package/dist/public/assets/diagram-DNEMPZML-BOkeaSpr.js +24 -0
  362. package/dist/public/assets/diagram-L3MUGCDN-CRCErdiz.js +41 -0
  363. package/dist/public/assets/diagram-LA4NIPWU-y5kaOsii.js +24 -0
  364. package/dist/public/assets/diagram-MHCOC4E2-D7l7ybij.js +3 -0
  365. package/dist/public/assets/diagram-XPFHEONP-kHzV_Ibv.js +30 -0
  366. package/dist/public/assets/dist-B-aKVhGg.js +1 -0
  367. package/dist/public/assets/dockerfile-DZFCIeNp.js +1 -0
  368. package/dist/public/assets/ebnfDiagram-UZSYDL2S-BX_-WdHG.js +1 -0
  369. package/dist/public/assets/ecl-94qehhXe.js +1 -0
  370. package/dist/public/assets/editor-DjpsE8to.css +1 -0
  371. package/dist/public/assets/editor.api-Dwz0wCaW.js +908 -0
  372. package/dist/public/assets/editor.worker-CRz__AKW.js +33 -0
  373. package/dist/public/assets/elixir-6RTg0lbw.js +1 -0
  374. package/dist/public/assets/elk-XV6XMXQE-YaOVo5bZ.js +27 -0
  375. package/dist/public/assets/erDiagram-EYBAPDEH-BXQPjKDV.js +99 -0
  376. package/dist/public/assets/eventmodeling-K75KTNOO-SiGVyftr.js +1 -0
  377. package/dist/public/assets/flow9-C5_-GSwl.js +1 -0
  378. package/dist/public/assets/flowDiagram-MALGAFMO-BHpEyQnS.js +1 -0
  379. package/dist/public/assets/freemarker2-DmbpSxx5.js +3 -0
  380. package/dist/public/assets/fsharp-C8Ef5oNN.js +1 -0
  381. package/dist/public/assets/ganttDiagram-23REXITY-B_i7AN7O.js +292 -0
  382. package/dist/public/assets/gitGraph-VSP46ZUC-CSv9x0vY.js +1 -0
  383. package/dist/public/assets/gitGraphDiagram-STJD7YCW-BMA1YavS.js +106 -0
  384. package/dist/public/assets/go-C-y9NEjX.js +1 -0
  385. package/dist/public/assets/graphlib-DoDw2DoG.js +1 -0
  386. package/dist/public/assets/graphql-fmXr3nnJ.js +1 -0
  387. package/dist/public/assets/handlebars-BVNKBeJT.js +1 -0
  388. package/dist/public/assets/hcl-CpzslTdj.js +1 -0
  389. package/dist/public/assets/html-BHaxuuAl.js +1 -0
  390. package/dist/public/assets/index-DtU34jhH.js +2 -0
  391. package/dist/public/assets/info-OHQRW6UA-Bx2U6fFU.js +1 -0
  392. package/dist/public/assets/infoDiagram-KBXO4MBG-BkNpfsDm.js +2 -0
  393. package/dist/public/assets/ini-sBoK_t0W.js +1 -0
  394. package/dist/public/assets/ishikawaDiagram-M35NCXHK-xTM6C-Kn.js +70 -0
  395. package/dist/public/assets/java-BEtHBSE6.js +1 -0
  396. package/dist/public/assets/javascript-C5dXKvxq.js +1 -0
  397. package/dist/public/assets/journeyDiagram-OPLOXDXO-C6iaT7vL.js +139 -0
  398. package/dist/public/assets/json.worker-CV9fqkUp.js +65 -0
  399. package/dist/public/assets/jsonMode-BD64T5vA.css +1 -0
  400. package/dist/public/assets/jsonMode-Ia_aRv-z.js +29 -0
  401. package/dist/public/assets/julia-Bri6UV-V.js +1 -0
  402. package/dist/public/assets/kanban-definition-BZKZHSQY-MobAdBhz.js +89 -0
  403. package/dist/public/assets/katex-B9z73Mgk.js +257 -0
  404. package/dist/public/assets/katex-BydxR-ky.css +1 -0
  405. package/dist/public/assets/kotlin-BOotOW0E.js +1 -0
  406. package/dist/public/assets/less-B9JPFI3C.js +2 -0
  407. package/dist/public/assets/lexon-CfSJPG6W.js +1 -0
  408. package/dist/public/assets/liquid-CIbIBxiN.js +1 -0
  409. package/dist/public/assets/lua-CsQS60Ue.js +1 -0
  410. package/dist/public/assets/m3-D-oSqn_W.js +1 -0
  411. package/dist/public/assets/markdown-Cimd5fb3.js +1 -0
  412. package/dist/public/assets/mdx-BqruHcEe.js +1 -0
  413. package/dist/public/assets/mermaid-parser.core-kBQmxOUn.js +7 -0
  414. package/dist/public/assets/mermaid.core-BFkQwIYu.js +44 -0
  415. package/dist/public/assets/mindmap-definition-I2QAS2VK-DxpTmvUG.js +98 -0
  416. package/dist/public/assets/mips-CIPQ_RoX.js +1 -0
  417. package/dist/public/assets/module-B8jze-Tx.js +5 -0
  418. package/dist/public/assets/module-Blc8dqbf.js +1 -0
  419. package/dist/public/assets/module-C1y_4M09.js +1061 -0
  420. package/dist/public/assets/module-C9WFrzAc.js +1 -0
  421. package/dist/public/assets/module-CouMtASh.js +1 -0
  422. package/dist/public/assets/module-DYWqfyIP.js +1 -0
  423. package/dist/public/assets/module-EGdAhoOx.js +1 -0
  424. package/dist/public/assets/module-EeaigZHL.js +1 -0
  425. package/dist/public/assets/module-ZhkaqrNe.js +1 -0
  426. package/dist/public/assets/monaco-BRwac88s.js +35 -0
  427. package/dist/public/assets/monaco-BlFvoJcU.css +1 -0
  428. package/dist/public/assets/msdax-DauUninz.js +1 -0
  429. package/dist/public/assets/mysql-SOo6toE5.js +1 -0
  430. package/dist/public/assets/objective-c-FvmIjYaQ.js +1 -0
  431. package/dist/public/assets/packet-JDAUHWVQ-Dy7GyfNz.js +1 -0
  432. package/dist/public/assets/pascal-DrH0SRf2.js +1 -0
  433. package/dist/public/assets/pascaligo-D-ptJ9y-.js +1 -0
  434. package/dist/public/assets/pegDiagram-FD4XPPHP-B3bIVo4u.js +1 -0
  435. package/dist/public/assets/perl-oz_6vUea.js +1 -0
  436. package/dist/public/assets/pgsql-DTj74zXo.js +1 -0
  437. package/dist/public/assets/php-nr791fC2.js +1 -0
  438. package/dist/public/assets/pie-XZMESJXO-B4D2CjUH.js +1 -0
  439. package/dist/public/assets/pieDiagram-J4AKIIQI-CgnbwU0I.js +39 -0
  440. package/dist/public/assets/pla-CopQ2nXW.js +1 -0
  441. package/dist/public/assets/postiats-43DmfD33.js +1 -0
  442. package/dist/public/assets/powerquery-D3hlyOfw.js +1 -0
  443. package/dist/public/assets/powershell-DmHpPYUd.js +1 -0
  444. package/dist/public/assets/protobuf-C531GsRP.js +2 -0
  445. package/dist/public/assets/pug-Z5eAx3Zn.js +1 -0
  446. package/dist/public/assets/python-Cwjb3hEe.js +1 -0
  447. package/dist/public/assets/qsharp-DkqhCAOL.js +1 -0
  448. package/dist/public/assets/quadrantDiagram-XTYBLID2-DWx4wRau.js +7 -0
  449. package/dist/public/assets/r-BwWrilGY.js +1 -0
  450. package/dist/public/assets/radar-ABXABTNO-Dtf3tObc.js +1 -0
  451. package/dist/public/assets/railroad-I3PHUGI6-DKGa9xBx.js +1 -0
  452. package/dist/public/assets/railroad-abnf-LNEFI6M7-CyjF4cc_.js +1 -0
  453. package/dist/public/assets/railroad-ebnf-DWYD2UWJ-D2ypsr5c.js +1 -0
  454. package/dist/public/assets/railroad-peg-JR7BVNR7-Cy6Mde1c.js +1 -0
  455. package/dist/public/assets/railroadDiagram-MRQ6NCDL-B6ya_k_l.js +1 -0
  456. package/dist/public/assets/razor-D_ClW9Lh.js +1 -0
  457. package/dist/public/assets/redis-ClamHrr6.js +1 -0
  458. package/dist/public/assets/redshift-DT7zqm-g.js +1 -0
  459. package/dist/public/assets/requirementDiagram-Y7LWUY3S-Brg8B8VS.js +84 -0
  460. package/dist/public/assets/resolver-B7c_-amj.js +1 -0
  461. package/dist/public/assets/restructuredtext-BYgofb2h.js +1 -0
  462. package/dist/public/assets/rough.esm-Dy-Kn_BL.js +1 -0
  463. package/dist/public/assets/ruby-DezsRK8O.js +1 -0
  464. package/dist/public/assets/rust-DdL9SqIa.js +1 -0
  465. package/dist/public/assets/sankeyDiagram-WGJFYUXA-DbzPDfky.js +40 -0
  466. package/dist/public/assets/sb-CcwsVR0C.js +1 -0
  467. package/dist/public/assets/scala-DHpiXF5c.js +1 -0
  468. package/dist/public/assets/scheme-BeGwcela.js +1 -0
  469. package/dist/public/assets/scss-gp-XZpBa.js +3 -0
  470. package/dist/public/assets/sequenceDiagram-5NDRBG5M-BuN84drT.js +169 -0
  471. package/dist/public/assets/shell-CC2rA5mh.js +1 -0
  472. package/dist/public/assets/sizeCapture-INFHLROL-3uHXrFqA.js +1 -0
  473. package/dist/public/assets/solidity-BEEn4gHE.js +1 -0
  474. package/dist/public/assets/sophia-CRfGWb83.js +1 -0
  475. package/dist/public/assets/sparql-D_Lu-MrJ.js +1 -0
  476. package/dist/public/assets/sql-NEE52Syq.js +1 -0
  477. package/dist/public/assets/st-DbInun42.js +1 -0
  478. package/dist/public/assets/stateDiagram-v2-FJ4FJNEA-C_CTpHMj.js +291 -0
  479. package/dist/public/assets/swift-Bxkupp3x.js +1 -0
  480. package/dist/public/assets/swimlanes-UMQ2AFYF-BvD4v9jw.js +1 -0
  481. package/dist/public/assets/swimlanesDiagram-OMPLPG4O-CMvLg13v.js +8 -0
  482. package/dist/public/assets/systemverilog-Bz4Y3fRF.js +1 -0
  483. package/dist/public/assets/tcl-DISqw1ZD.js +1 -0
  484. package/dist/public/assets/timeline-definition-SEUHKTQE-VE2xWGk8.js +120 -0
  485. package/dist/public/assets/treeView-D4JQ5SDB-ETecwv1j.js +1 -0
  486. package/dist/public/assets/treemap-SAJKECNS-er6ceAYK.js +1 -0
  487. package/dist/public/assets/twig-De2hgUGE.js +1 -0
  488. package/dist/public/assets/typescript-upeNz2VW.js +1 -0
  489. package/dist/public/assets/typespec-B8J7ngcE.js +1 -0
  490. package/dist/public/assets/usecaseDiagram-AFA6YXN4-ZtyyvKye.js +328 -0
  491. package/dist/public/assets/vb-DV3o63ZY.js +1 -0
  492. package/dist/public/assets/vennDiagram-NNMJR3RB-BTEvzrNd.js +34 -0
  493. package/dist/public/assets/wardley-7MLQ67FV-CzrxsjBc.js +1 -0
  494. package/dist/public/assets/wardleyDiagram-S7YFUSEH-CF8wIUhx.js +78 -0
  495. package/dist/public/assets/wgsl-DpFanUEy.js +298 -0
  496. package/dist/public/assets/xml-Cki0HxGb.js +1 -0
  497. package/dist/public/assets/xychartDiagram-GGNKY7IX-DcDpoJ4n.js +7 -0
  498. package/dist/public/assets/yaml-YIY66l1U.js +1 -0
  499. package/dist/public/assets/zh-cn-Bhwk8qWJ.js +12 -0
  500. package/dist/public/favicon.ico +0 -0
  501. package/dist/public/icons/apple-touch-icon.png +0 -0
  502. package/dist/public/icons/icon-192.png +0 -0
  503. package/dist/public/icons/icon-512.png +0 -0
  504. package/dist/public/icons/icon.svg +1 -0
  505. package/dist/public/icons/maskable-512.png +0 -0
  506. package/dist/public/index.html +18 -0
  507. package/dist/public/manifest.webmanifest +40 -0
  508. package/dist/public/sw.js +78 -0
  509. package/dist/serve/index.mjs +8234 -2690
  510. package/package.json +20 -14
package/dist/cli.mjs CHANGED
@@ -1,4 +1,1250 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __returnValue = (v) => v;
3
+ function __exportSetter(name, newValue) {
4
+ this[name] = __returnValue.bind(null, newValue);
5
+ }
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true,
11
+ configurable: true,
12
+ set: __exportSetter.bind(all, name)
13
+ });
14
+ };
15
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
16
+
17
+ // ../../packages/core/esm/common/utils/event.js
18
+ var Event, CallbackList;
19
+ var init_event = __esm(() => {
20
+ (function(Event2) {
21
+ const _disposable = { dispose() {} };
22
+ Event2.None = Object.assign(function() {
23
+ return _disposable;
24
+ }, {
25
+ get maxListeners() {
26
+ return 0;
27
+ },
28
+ set maxListeners(maxListeners) {}
29
+ });
30
+ function map(event, mapFunc) {
31
+ return Object.assign((listener, thisArgs, disposables) => event((i) => listener.call(thisArgs, mapFunc(i)), undefined, disposables), {
32
+ maxListeners: 0
33
+ });
34
+ }
35
+ Event2.map = map;
36
+ })(Event || (Event = {}));
37
+ CallbackList = class CallbackList {
38
+ get length() {
39
+ return this._callbacks && this._callbacks.length || 0;
40
+ }
41
+ add(callback, context = undefined, bucket) {
42
+ if (!this._callbacks) {
43
+ this._callbacks = [];
44
+ this._contexts = [];
45
+ }
46
+ this._callbacks.push(callback);
47
+ this._contexts.push(context);
48
+ if (Array.isArray(bucket)) {
49
+ bucket.push({ dispose: () => this.remove(callback, context) });
50
+ }
51
+ }
52
+ remove(callback, context = undefined) {
53
+ if (!this._callbacks) {
54
+ return;
55
+ }
56
+ let foundCallbackWithDifferentContext = false;
57
+ for (let i = 0;i < this._callbacks.length; i++) {
58
+ if (this._callbacks[i] === callback) {
59
+ if (this._contexts[i] === context) {
60
+ this._callbacks.splice(i, 1);
61
+ this._contexts.splice(i, 1);
62
+ return;
63
+ } else {
64
+ foundCallbackWithDifferentContext = true;
65
+ }
66
+ }
67
+ }
68
+ if (foundCallbackWithDifferentContext) {
69
+ throw new Error("When adding a listener with a context, you should remove it with the same context");
70
+ }
71
+ }
72
+ *[Symbol.iterator]() {
73
+ if (!this._callbacks) {
74
+ return;
75
+ }
76
+ const callbacks = this._callbacks.slice(0);
77
+ const contexts = this._contexts.slice(0);
78
+ for (let i = 0;i < callbacks.length; i++) {
79
+ const callback = callbacks[i];
80
+ const context = contexts[i];
81
+ yield (...args) => callback.apply(context, args);
82
+ }
83
+ }
84
+ invoke(...args) {
85
+ if (!this._callbacks) {
86
+ return [];
87
+ }
88
+ const callbacks = this._callbacks.slice(0);
89
+ const contexts = this._contexts.slice(0);
90
+ const ret = [];
91
+ for (let i = 0;i < callbacks.length; i++) {
92
+ try {
93
+ ret.push(callbacks[i].apply(contexts[i], args));
94
+ } catch (e) {
95
+ console.error(e);
96
+ }
97
+ }
98
+ return ret;
99
+ }
100
+ isEmpty() {
101
+ return !this._callbacks || this._callbacks.length === 0;
102
+ }
103
+ dispose() {
104
+ this._callbacks = undefined;
105
+ this._contexts = undefined;
106
+ }
107
+ };
108
+ });
109
+
110
+ // ../../packages/core/esm/common/utils/emitter.js
111
+ class Emitter {
112
+ constructor(_options) {
113
+ this._options = _options;
114
+ this._disposed = false;
115
+ this._leakWarnCountdown = 0;
116
+ }
117
+ get event() {
118
+ if (!this._event) {
119
+ this._event = Object.assign((listener, thisArgs, disposables) => {
120
+ if (!this._callbacks) {
121
+ this._callbacks = new CallbackList;
122
+ }
123
+ if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
124
+ this._options.onFirstListenerAdd(this);
125
+ }
126
+ this._callbacks.add(listener, thisArgs);
127
+ const removeMaxListenersCheck = this.checkMaxListeners(this._event.maxListeners);
128
+ const result = {
129
+ dispose: () => {
130
+ if (removeMaxListenersCheck) {
131
+ removeMaxListenersCheck();
132
+ }
133
+ result.dispose = Emitter._noop;
134
+ if (!this._disposed) {
135
+ this._callbacks.remove(listener, thisArgs);
136
+ result.dispose = Emitter._noop;
137
+ if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {
138
+ this._options.onLastListenerRemove(this);
139
+ }
140
+ }
141
+ }
142
+ };
143
+ if (Array.isArray(disposables)) {
144
+ disposables.push(result);
145
+ }
146
+ return result;
147
+ }, {
148
+ maxListeners: Emitter.LEAK_WARNING_THRESHHOLD
149
+ });
150
+ }
151
+ return this._event;
152
+ }
153
+ checkMaxListeners(maxListeners) {
154
+ if (maxListeners === 0 || !this._callbacks) {
155
+ return;
156
+ }
157
+ const listenerCount = this._callbacks.length;
158
+ if (listenerCount <= maxListeners) {
159
+ return;
160
+ }
161
+ const popStack = this.pushLeakingStack();
162
+ this._leakWarnCountdown -= 1;
163
+ if (this._leakWarnCountdown <= 0) {
164
+ this._leakWarnCountdown = maxListeners * 0.5;
165
+ let topStack;
166
+ let topCount = 0;
167
+ this._leakingStacks.forEach((stackCount, stack) => {
168
+ if (!topStack || topCount < stackCount) {
169
+ topStack = stack;
170
+ topCount = stackCount;
171
+ }
172
+ });
173
+ console.warn(`Possible Emitter memory leak detected. ${listenerCount} listeners added. Use event.maxListeners to increase the limit (${maxListeners}). MOST frequent listener (${topCount}):`);
174
+ console.warn(topStack);
175
+ }
176
+ return popStack;
177
+ }
178
+ pushLeakingStack() {
179
+ if (!this._leakingStacks) {
180
+ this._leakingStacks = new Map;
181
+ }
182
+ const stack = new Error().stack.split(`
183
+ `).slice(3).join(`
184
+ `);
185
+ const count = this._leakingStacks.get(stack) || 0;
186
+ this._leakingStacks.set(stack, count + 1);
187
+ return () => this.popLeakingStack(stack);
188
+ }
189
+ popLeakingStack(stack) {
190
+ if (!this._leakingStacks) {
191
+ return;
192
+ }
193
+ const count = this._leakingStacks.get(stack) || 0;
194
+ this._leakingStacks.set(stack, count - 1);
195
+ }
196
+ get hasListeners() {
197
+ return !!this._callbacks && !this._callbacks.isEmpty();
198
+ }
199
+ fire(event) {
200
+ if (this._callbacks) {
201
+ this._callbacks.invoke(event);
202
+ }
203
+ }
204
+ async sequence(processor) {
205
+ if (this._callbacks) {
206
+ for (const listener of this._callbacks) {
207
+ if (!await processor(listener)) {
208
+ break;
209
+ }
210
+ }
211
+ }
212
+ }
213
+ dispose() {
214
+ if (this._leakingStacks) {
215
+ this._leakingStacks.clear();
216
+ this._leakingStacks = undefined;
217
+ }
218
+ if (this._callbacks) {
219
+ this._callbacks.dispose();
220
+ this._callbacks = undefined;
221
+ }
222
+ this._disposed = true;
223
+ }
224
+ }
225
+ var WaitUntilEvent;
226
+ var init_emitter = __esm(() => {
227
+ init_event();
228
+ Emitter.LEAK_WARNING_THRESHHOLD = 175;
229
+ Emitter._noop = function() {};
230
+ (function(WaitUntilEvent2) {
231
+ async function fire(emitter, event, timeout = undefined) {
232
+ const waitables = [];
233
+ const asyncEvent = Object.assign(event, {
234
+ waitUntil: (thenable) => {
235
+ if (Object.isFrozen(waitables)) {
236
+ throw new Error("waitUntil cannot be called asynchronously.");
237
+ }
238
+ waitables.push(thenable);
239
+ }
240
+ });
241
+ try {
242
+ emitter.fire(asyncEvent);
243
+ Object.freeze(waitables);
244
+ } finally {
245
+ delete asyncEvent["waitUntil"];
246
+ }
247
+ if (!waitables.length) {
248
+ return;
249
+ }
250
+ if (timeout !== undefined) {
251
+ await Promise.race([Promise.all(waitables), new Promise((resolve) => setTimeout(resolve, timeout))]);
252
+ } else {
253
+ await Promise.all(waitables);
254
+ }
255
+ }
256
+ WaitUntilEvent2.fire = fire;
257
+ })(WaitUntilEvent || (WaitUntilEvent = {}));
258
+ });
259
+
260
+ // ../../packages/rpc/esm/node/websocket/websocket-frames.js
261
+ class WebSocketFrameParser {
262
+ constructor(maxPayload) {
263
+ this.maxPayload = maxPayload;
264
+ this.buffer = Buffer.alloc(0);
265
+ }
266
+ push(chunk) {
267
+ this.buffer = this.buffer.length ? Buffer.concat([this.buffer, chunk]) : chunk;
268
+ const frames = [];
269
+ for (let frame = this.next();frame; frame = this.next()) {
270
+ frames.push(frame);
271
+ }
272
+ return frames;
273
+ }
274
+ next() {
275
+ const buffer = this.buffer;
276
+ if (buffer.length < 2) {
277
+ return;
278
+ }
279
+ const fin = (buffer[0] & 128) !== 0;
280
+ const opcode = buffer[0] & 15;
281
+ if ((buffer[0] & 112) !== 0) {
282
+ throw new WebSocketProtocolError(1002, "Reserved bits are set.");
283
+ }
284
+ if (![0, 1, 2, 8, 9, 10].includes(opcode)) {
285
+ throw new WebSocketProtocolError(1002, `Unknown opcode ${opcode}.`);
286
+ }
287
+ if ((buffer[1] & 128) === 0) {
288
+ throw new WebSocketProtocolError(1002, "Frames of a client must be masked.");
289
+ }
290
+ let length = buffer[1] & 127;
291
+ let offset = 2;
292
+ if (length === 126) {
293
+ if (buffer.length < 4) {
294
+ return;
295
+ }
296
+ length = buffer.readUInt16BE(2);
297
+ offset = 4;
298
+ } else if (length === 127) {
299
+ if (buffer.length < 10) {
300
+ return;
301
+ }
302
+ const high = buffer.readUInt32BE(2);
303
+ if (high > 2097151) {
304
+ throw new WebSocketProtocolError(1009, "The frame is too large.");
305
+ }
306
+ length = high * 4294967296 + buffer.readUInt32BE(6);
307
+ offset = 10;
308
+ }
309
+ if (WebSocketFrames.isControl(opcode) && (length > 125 || !fin)) {
310
+ throw new WebSocketProtocolError(1002, "Control frames are at most 125 bytes and not fragmented.");
311
+ }
312
+ if (length > this.maxPayload) {
313
+ throw new WebSocketProtocolError(1009, `The message is larger than ${this.maxPayload} bytes.`);
314
+ }
315
+ if (buffer.length < offset + 4 + length) {
316
+ return;
317
+ }
318
+ const mask = buffer.subarray(offset, offset + 4);
319
+ const payload = Buffer.from(buffer.subarray(offset + 4, offset + 4 + length));
320
+ for (let i = 0;i < payload.length; i++) {
321
+ payload[i] ^= mask[i & 3];
322
+ }
323
+ this.buffer = buffer.subarray(offset + 4 + length);
324
+ return { fin, opcode, payload };
325
+ }
326
+ }
327
+ var WebSocketProtocolError, WebSocketFrames;
328
+ var init_websocket_frames = __esm(() => {
329
+ WebSocketProtocolError = class WebSocketProtocolError extends Error {
330
+ constructor(code, message) {
331
+ super(message);
332
+ this.code = code;
333
+ }
334
+ };
335
+ (function(WebSocketFrames2) {
336
+ WebSocketFrames2.CONTINUATION = 0;
337
+ WebSocketFrames2.TEXT = 1;
338
+ WebSocketFrames2.BINARY = 2;
339
+ WebSocketFrames2.CLOSE = 8;
340
+ WebSocketFrames2.PING = 9;
341
+ WebSocketFrames2.PONG = 10;
342
+ function encode(opcode, payload = Buffer.alloc(0)) {
343
+ const length = payload.length;
344
+ const size = length < 126 ? 2 : length < 65536 ? 4 : 10;
345
+ const header = Buffer.alloc(size);
346
+ header[0] = 128 | opcode;
347
+ if (length < 126) {
348
+ header[1] = length;
349
+ } else if (length < 65536) {
350
+ header[1] = 126;
351
+ header.writeUInt16BE(length, 2);
352
+ } else {
353
+ header[1] = 127;
354
+ header.writeUInt32BE(Math.floor(length / 4294967296), 2);
355
+ header.writeUInt32BE(length >>> 0, 6);
356
+ }
357
+ return Buffer.concat([header, payload]);
358
+ }
359
+ WebSocketFrames2.encode = encode;
360
+ function closePayload(code, reason = "") {
361
+ const text = Buffer.from(reason).subarray(0, 123);
362
+ const payload = Buffer.alloc(2 + text.length);
363
+ payload.writeUInt16BE(code, 0);
364
+ text.copy(payload, 2);
365
+ return payload;
366
+ }
367
+ WebSocketFrames2.closePayload = closePayload;
368
+ function isControl(opcode) {
369
+ return (opcode & 8) !== 0;
370
+ }
371
+ WebSocketFrames2.isControl = isControl;
372
+ })(WebSocketFrames || (WebSocketFrames = {}));
373
+ });
374
+
375
+ // ../../packages/rpc/esm/node/websocket/websocket-connection.js
376
+ import { createHash } from "node:crypto";
377
+
378
+ class WebSocketConnection {
379
+ static runtimeSupported(bunVersion) {
380
+ var _a;
381
+ var _b;
382
+ if (bunVersion === undefined) {
383
+ bunVersion = (_b = (_a = globalThis.Bun) === null || _a === undefined ? undefined : _a.version) !== null && _b !== undefined ? _b : null;
384
+ }
385
+ if (bunVersion === null) {
386
+ return true;
387
+ }
388
+ const [major, minor] = bunVersion.split(".").map(Number);
389
+ return major > 1 || major === 1 && minor >= 4;
390
+ }
391
+ static check(request) {
392
+ var _a, _b;
393
+ const upgrade = String((_a = request.headers.upgrade) !== null && _a !== undefined ? _a : "").toLowerCase();
394
+ const connection = String((_b = request.headers.connection) !== null && _b !== undefined ? _b : "").toLowerCase();
395
+ const key = request.headers["sec-websocket-key"];
396
+ if (request.method !== "GET" || upgrade !== "websocket" || !connection.includes("upgrade")) {
397
+ return { status: 400, message: "Not a WebSocket upgrade request." };
398
+ }
399
+ if (request.headers["sec-websocket-version"] !== "13") {
400
+ return { status: 426, message: "Only WebSocket version 13 is supported." };
401
+ }
402
+ if (typeof key !== "string" || Buffer.from(key, "base64").length !== 16) {
403
+ return { status: 400, message: "Missing or invalid Sec-WebSocket-Key." };
404
+ }
405
+ return { key };
406
+ }
407
+ static accept(key) {
408
+ return createHash("sha1").update(key + WebSocketConnection.GUID).digest("base64");
409
+ }
410
+ static open(socket, key, head, options) {
411
+ socket.write(`HTTP/1.1 101 Switching Protocols\r
412
+ Upgrade: websocket\r
413
+ Connection: Upgrade\r
414
+ Sec-WebSocket-Accept: ${WebSocketConnection.accept(key)}\r
415
+ \r
416
+ `);
417
+ const connection = new WebSocketConnection(socket, options);
418
+ connection.start(head);
419
+ return connection;
420
+ }
421
+ static refuse(socket, status, message) {
422
+ socket.on("error", () => socket.destroy());
423
+ socket.end(`HTTP/1.1 ${status} ${message}\r
424
+ Connection: close\r
425
+ Content-Type: text/plain\r
426
+ Content-Length: ${Buffer.byteLength(message)}\r
427
+ \r
428
+ ${message}`);
429
+ }
430
+ constructor(socket, options) {
431
+ this.socket = socket;
432
+ this.options = options;
433
+ this.onMessageEmitter = new Emitter;
434
+ this.onCloseEmitter = new Emitter;
435
+ this.decoder = new TextDecoder("utf-8", { fatal: true });
436
+ this.fragments = [];
437
+ this.fragmentsLength = 0;
438
+ this.state = "open";
439
+ this.alive = true;
440
+ this.parser = new WebSocketFrameParser(options.maxPayload);
441
+ }
442
+ get onMessage() {
443
+ return this.onMessageEmitter.event;
444
+ }
445
+ get onClose() {
446
+ return this.onCloseEmitter.event;
447
+ }
448
+ get open() {
449
+ return this.state === "open";
450
+ }
451
+ send(text) {
452
+ if (this.state === "open") {
453
+ this.socket.write(WebSocketFrames.encode(WebSocketFrames.TEXT, Buffer.from(text)));
454
+ }
455
+ }
456
+ close(code = 1000, reason = "") {
457
+ var _a, _b;
458
+ if (this.state !== "open") {
459
+ return;
460
+ }
461
+ this.state = "closing";
462
+ this.socket.write(WebSocketFrames.encode(WebSocketFrames.CLOSE, WebSocketFrames.closePayload(code, reason)));
463
+ (_b = (_a = setTimeout(() => this.socket.destroy(), 1000)).unref) === null || _b === undefined || _b.call(_a);
464
+ this.finish(code, reason);
465
+ }
466
+ start(head) {
467
+ var _a, _b;
468
+ this.socket.on("data", (chunk) => this.receive(chunk));
469
+ this.socket.on("close", () => this.finish(1006, ""));
470
+ this.socket.on("error", () => this.socket.destroy());
471
+ if (this.options.heartbeat > 0) {
472
+ this.heartbeat = setInterval(() => {
473
+ if (!this.alive) {
474
+ this.socket.destroy();
475
+ return;
476
+ }
477
+ this.alive = false;
478
+ this.socket.write(WebSocketFrames.encode(WebSocketFrames.PING));
479
+ }, this.options.heartbeat);
480
+ (_b = (_a = this.heartbeat).unref) === null || _b === undefined || _b.call(_a);
481
+ }
482
+ if (head.length) {
483
+ this.receive(head);
484
+ }
485
+ }
486
+ receive(chunk) {
487
+ try {
488
+ for (const frame of this.parser.push(chunk)) {
489
+ this.alive = true;
490
+ this.handle(frame.opcode, frame.fin, frame.payload);
491
+ }
492
+ } catch (error) {
493
+ this.close(error instanceof WebSocketProtocolError ? error.code : 1011, error instanceof Error ? error.message : "");
494
+ }
495
+ }
496
+ handle(opcode, fin, payload) {
497
+ switch (opcode) {
498
+ case WebSocketFrames.PING:
499
+ this.socket.write(WebSocketFrames.encode(WebSocketFrames.PONG, payload));
500
+ return;
501
+ case WebSocketFrames.PONG:
502
+ return;
503
+ case WebSocketFrames.CLOSE: {
504
+ const code = payload.length >= 2 ? payload.readUInt16BE(0) : 1005;
505
+ if (this.state === "open") {
506
+ this.state = "closing";
507
+ this.socket.end(WebSocketFrames.encode(WebSocketFrames.CLOSE, payload.subarray(0, 2)));
508
+ } else {
509
+ this.socket.end();
510
+ }
511
+ this.finish(code, payload.subarray(2).toString());
512
+ return;
513
+ }
514
+ case WebSocketFrames.BINARY:
515
+ throw new WebSocketProtocolError(1003, "Only text messages are accepted.");
516
+ case WebSocketFrames.TEXT:
517
+ if (this.fragments.length) {
518
+ throw new WebSocketProtocolError(1002, "A new message started inside a fragmented one.");
519
+ }
520
+ break;
521
+ case WebSocketFrames.CONTINUATION:
522
+ if (!this.fragments.length) {
523
+ throw new WebSocketProtocolError(1002, "A continuation frame without a message.");
524
+ }
525
+ break;
526
+ }
527
+ this.fragmentsLength += payload.length;
528
+ if (this.fragmentsLength > this.options.maxPayload) {
529
+ throw new WebSocketProtocolError(1009, `The message is larger than ${this.options.maxPayload} bytes.`);
530
+ }
531
+ this.fragments.push(payload);
532
+ if (fin) {
533
+ const message = this.fragments.length === 1 ? this.fragments[0] : Buffer.concat(this.fragments);
534
+ this.fragments = [];
535
+ this.fragmentsLength = 0;
536
+ let text;
537
+ try {
538
+ text = this.decoder.decode(message);
539
+ } catch (_a) {
540
+ throw new WebSocketProtocolError(1007, "The message is not UTF-8.");
541
+ }
542
+ if (this.state === "open") {
543
+ this.onMessageEmitter.fire(text);
544
+ }
545
+ }
546
+ }
547
+ finish(code, reason) {
548
+ if (this.state === "closed") {
549
+ return;
550
+ }
551
+ this.state = "closed";
552
+ clearInterval(this.heartbeat);
553
+ this.onCloseEmitter.fire({ code, reason });
554
+ this.onMessageEmitter.dispose();
555
+ this.onCloseEmitter.dispose();
556
+ }
557
+ }
558
+ var init_websocket_connection = __esm(() => {
559
+ init_emitter();
560
+ init_websocket_frames();
561
+ WebSocketConnection.GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
562
+ });
563
+
564
+ // ../../ta-packages/ta-relay/esm/common/relay-protocol.js
565
+ var exports_relay_protocol = {};
566
+ __export(exports_relay_protocol, {
567
+ RelayCloseCode: () => RelayCloseCode,
568
+ RELAY_PROOF: () => RELAY_PROOF,
569
+ RELAY_PAIR_PATH: () => RELAY_PAIR_PATH,
570
+ RELAY_PAIR_PAGE: () => RELAY_PAIR_PAGE,
571
+ RELAY_ID: () => RELAY_ID,
572
+ RELAY_HOST_PATH: () => RELAY_HOST_PATH,
573
+ RELAY_DEFAULT_URL: () => RELAY_DEFAULT_URL,
574
+ RELAY_CONNECT_PATH: () => RELAY_CONNECT_PATH
575
+ });
576
+ var RELAY_DEFAULT_URL = "https://relay.cellbang.com", RELAY_HOST_PATH = "/v1/host/", RELAY_CONNECT_PATH = "/v1/connect/", RELAY_PAIR_PATH = "/pair", RELAY_PAIR_PAGE = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Ta</title>
577
+ <body style="font:16px system-ui;max-width:32em;margin:3em auto;padding:0 1em">
578
+ <h1>Ta</h1><p>Open this link in the Ta app, or paste it there, to reach your Ta from this device.</p>
579
+ <p>打开 Ta 应用,粘贴这个链接,就能从这台设备连到你的 Ta。</p></body>`, RELAY_ID, RelayCloseCode, RELAY_PROOF = "ta-relay ready";
580
+ var init_relay_protocol = __esm(() => {
581
+ RELAY_ID = /^[A-Za-z0-9_-]{16,64}$/;
582
+ (function(RelayCloseCode2) {
583
+ RelayCloseCode2[RelayCloseCode2["HOST_OFFLINE"] = 4404] = "HOST_OFFLINE";
584
+ RelayCloseCode2[RelayCloseCode2["REFUSED"] = 4401] = "REFUSED";
585
+ RelayCloseCode2[RelayCloseCode2["REPLACED"] = 4409] = "REPLACED";
586
+ RelayCloseCode2[RelayCloseCode2["CLOSED_BY_HOST"] = 4410] = "CLOSED_BY_HOST";
587
+ RelayCloseCode2[RelayCloseCode2["FULL"] = 4429] = "FULL";
588
+ })(RelayCloseCode || (RelayCloseCode = {}));
589
+ });
590
+
591
+ // ../../ta-packages/ta-relay/esm/common/relay-room.js
592
+ class RelayRoom {
593
+ constructor(peers) {
594
+ this.peers = peers;
595
+ }
596
+ clientOpened(channel) {
597
+ const host = this.peers.host();
598
+ if (!host) {
599
+ return RelayCloseCode.HOST_OFFLINE;
600
+ }
601
+ if (this.peers.clients().length > RELAY_MAX_CLIENTS) {
602
+ return RelayCloseCode.FULL;
603
+ }
604
+ this.toHost(host, { t: "open", ch: channel });
605
+ return;
606
+ }
607
+ fromClient(channel, text) {
608
+ const host = this.peers.host();
609
+ if (host) {
610
+ this.toHost(host, { t: "data", ch: channel, d: text });
611
+ }
612
+ }
613
+ clientClosed(channel) {
614
+ const host = this.peers.host();
615
+ if (host) {
616
+ this.toHost(host, { t: "close", ch: channel });
617
+ }
618
+ }
619
+ fromHost(text) {
620
+ let message;
621
+ try {
622
+ message = JSON.parse(text);
623
+ } catch (_a) {
624
+ return;
625
+ }
626
+ const client = typeof message.ch === "string" ? this.peers.client(message.ch) : undefined;
627
+ if (message.t === "data" && typeof message.d === "string") {
628
+ client === null || client === undefined || client.send(message.d);
629
+ } else if (message.t === "close") {
630
+ client === null || client === undefined || client.close(RelayCloseCode.CLOSED_BY_HOST, "Closed by the host.");
631
+ }
632
+ }
633
+ hostClosed() {
634
+ for (const client of this.peers.clients()) {
635
+ client.close(RelayCloseCode.HOST_OFFLINE, "The host went offline.");
636
+ }
637
+ }
638
+ toHost(host, message) {
639
+ host.send(JSON.stringify(message));
640
+ }
641
+ }
642
+ var RELAY_MAX_CLIENTS = 16;
643
+ var init_relay_room = __esm(() => {
644
+ init_relay_protocol();
645
+ });
646
+
647
+ // ../../ta-packages/ta-relay/esm/node/relay-server.js
648
+ var exports_relay_server = {};
649
+ __export(exports_relay_server, {
650
+ RelayServer: () => RelayServer
651
+ });
652
+ import { createHash as createHash2, randomBytes, timingSafeEqual } from "node:crypto";
653
+ import { createServer as createServer2 } from "node:http";
654
+
655
+ class RelayServer {
656
+ constructor(options = {}) {
657
+ this.options = options;
658
+ this.rooms = new Map;
659
+ }
660
+ listen() {
661
+ const server = createServer2((request, response) => {
662
+ var _a;
663
+ const page = ((_a = request.url) !== null && _a !== undefined ? _a : "/").split(/[?#]/)[0] === RELAY_PAIR_PATH;
664
+ response.writeHead(200, { "content-type": page ? "text/html; charset=utf-8" : "text/plain" });
665
+ response.end(page ? RELAY_PAIR_PAGE : `Ta relay
666
+ `);
667
+ });
668
+ server.on("upgrade", (request, socket, head) => this.upgrade(request, socket, head));
669
+ this.server = server;
670
+ return new Promise((resolve, reject) => {
671
+ var _a, _b;
672
+ server.once("error", reject);
673
+ server.listen((_a = this.options.port) !== null && _a !== undefined ? _a : 0, (_b = this.options.host) !== null && _b !== undefined ? _b : "127.0.0.1", () => {
674
+ const { address, port } = server.address();
675
+ resolve(`http://${address.includes(":") ? `[${address}]` : address}:${port}`);
676
+ });
677
+ });
678
+ }
679
+ close() {
680
+ var _a;
681
+ for (const room of this.rooms.values()) {
682
+ (_a = room.host) === null || _a === undefined || _a.close(1001, "The relay is stopping.");
683
+ for (const client of room.clients.values()) {
684
+ client.close(1001, "The relay is stopping.");
685
+ }
686
+ }
687
+ this.rooms.clear();
688
+ return new Promise((resolve) => this.server ? this.server.close(() => resolve()) : resolve());
689
+ }
690
+ upgrade(request, socket, head) {
691
+ var _a, _b;
692
+ const url = new URL((_a = request.url) !== null && _a !== undefined ? _a : "/", "http://relay");
693
+ const checked = WebSocketConnection.check(request);
694
+ if ("status" in checked) {
695
+ WebSocketConnection.refuse(socket, checked.status, checked.message);
696
+ return;
697
+ }
698
+ const [path, id] = url.pathname.startsWith(RELAY_HOST_PATH) ? [RELAY_HOST_PATH, url.pathname.slice(RELAY_HOST_PATH.length)] : [RELAY_CONNECT_PATH, url.pathname.slice(RELAY_CONNECT_PATH.length)];
699
+ if (!url.pathname.startsWith(path) || !RELAY_ID.test(id)) {
700
+ WebSocketConnection.refuse(socket, 404, "Not found.");
701
+ return;
702
+ }
703
+ const connection = WebSocketConnection.open(socket, checked.key, head, WEBSOCKET);
704
+ if (path === RELAY_HOST_PATH) {
705
+ this.openHost(id, (_b = url.searchParams.get("secret")) !== null && _b !== undefined ? _b : "", connection);
706
+ } else {
707
+ this.openClient(id, connection);
708
+ }
709
+ }
710
+ openHost(id, secret, connection) {
711
+ var _a;
712
+ var _b;
713
+ const hash = createHash2("sha256").update(secret).digest("base64url");
714
+ const room = (_b = this.rooms.get(id)) !== null && _b !== undefined ? _b : this.createRoom(id, hash);
715
+ if (secret.length < 32 || !RelayServer.same(room.secretHash, hash)) {
716
+ connection.close(RelayCloseCode.REFUSED, "Refused.");
717
+ return;
718
+ }
719
+ (_a = room.host) === null || _a === undefined || _a.close(RelayCloseCode.REPLACED, "The host connected again.");
720
+ room.host = connection;
721
+ connection.onMessage((text) => room.relay.fromHost(text));
722
+ connection.onClose(() => {
723
+ if (room.host === connection) {
724
+ room.host = undefined;
725
+ room.relay.hostClosed();
726
+ }
727
+ });
728
+ }
729
+ openClient(id, connection) {
730
+ const room = this.rooms.get(id);
731
+ const channel = randomBytes(9).toString("base64url");
732
+ room === null || room === undefined || room.clients.set(channel, connection);
733
+ const refused = room ? room.relay.clientOpened(channel) : RelayCloseCode.HOST_OFFLINE;
734
+ if (!room || refused !== undefined) {
735
+ room === null || room === undefined || room.clients.delete(channel);
736
+ connection.close(refused !== null && refused !== undefined ? refused : RelayCloseCode.HOST_OFFLINE, "The host is not available.");
737
+ return;
738
+ }
739
+ connection.onMessage((text) => room.relay.fromClient(channel, text));
740
+ connection.onClose(() => {
741
+ if (room.clients.delete(channel)) {
742
+ room.relay.clientClosed(channel);
743
+ }
744
+ });
745
+ }
746
+ createRoom(id, secretHash) {
747
+ const room = {
748
+ secretHash,
749
+ clients: new Map,
750
+ relay: new RelayRoom({
751
+ host: () => room.host ? peer(room.host) : undefined,
752
+ client: (channel) => {
753
+ const client = room.clients.get(channel);
754
+ return client ? peer(client) : undefined;
755
+ },
756
+ clients: () => [...room.clients.values()].map(peer)
757
+ })
758
+ };
759
+ this.rooms.set(id, room);
760
+ return room;
761
+ }
762
+ static same(a, b) {
763
+ const [left, right] = [Buffer.from(a), Buffer.from(b)];
764
+ return left.length === right.length && timingSafeEqual(left, right);
765
+ }
766
+ }
767
+ var WEBSOCKET, peer = (connection) => ({ send: (text) => connection.send(text), close: (code, reason) => connection.close(code, reason) });
768
+ var init_relay_server = __esm(() => {
769
+ init_websocket_connection();
770
+ init_relay_protocol();
771
+ init_relay_room();
772
+ WEBSOCKET = { maxPayload: 32 * 1024 * 1024, heartbeat: 30000 };
773
+ });
774
+
775
+ // ../../ta-packages/ta-relay/esm/node/relay-store.js
776
+ var exports_relay_store = {};
777
+ __export(exports_relay_store, {
778
+ RelayStore: () => RelayStore
779
+ });
780
+ import { createHash as createHash3, randomBytes as randomBytes2 } from "node:crypto";
781
+ import { chmodSync as chmodSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync5, renameSync as renameSync2, writeFileSync as writeFileSync4 } from "node:fs";
782
+ import { hostname as hostname2 } from "node:os";
783
+ import { dirname as dirname4, join as join5 } from "node:path";
784
+
785
+ class RelayStore {
786
+ constructor(agentDir) {
787
+ this.agentDir = agentDir;
788
+ }
789
+ get file() {
790
+ return join5(this.agentDir, RelayStore.FILE);
791
+ }
792
+ read() {
793
+ try {
794
+ const config = JSON.parse(readFileSync5(this.file, "utf8"));
795
+ return { url: config.url, host: config.host, devices: Array.isArray(config.devices) ? config.devices : [] };
796
+ } catch (_a) {
797
+ return { devices: [] };
798
+ }
799
+ }
800
+ device(deviceId) {
801
+ return this.read().devices.find((device) => device.id === deviceId);
802
+ }
803
+ pair(relay, deviceName) {
804
+ const url = relay.replace(/\/+$/, "");
805
+ const before = this.read();
806
+ const config = before.url === url && before.host ? before : { url, host: { id: id(), secret: randomBytes2(32).toString("base64url") }, devices: [] };
807
+ const device = { id: id(), name: deviceName, key: randomBytes2(32).toString("base64url"), createdAt: Date.now() };
808
+ config.devices.push(device);
809
+ this.write(config);
810
+ return { relay: url, host: config.host.id, device: device.id, key: device.key, name: hostname2() };
811
+ }
812
+ remove(deviceId) {
813
+ const config = this.read();
814
+ const devices = config.devices.filter((device) => device.id !== deviceId);
815
+ if (devices.length === config.devices.length) {
816
+ return false;
817
+ }
818
+ this.write({ ...config, devices });
819
+ return true;
820
+ }
821
+ static secretHash(secret) {
822
+ return createHash3("sha256").update(secret).digest("base64url");
823
+ }
824
+ write(config) {
825
+ mkdirSync4(dirname4(this.file), { recursive: true });
826
+ const temporary = `${this.file}.${process.pid}.tmp`;
827
+ writeFileSync4(temporary, `${JSON.stringify(config, null, 2)}
828
+ `, { mode: 384 });
829
+ chmodSync2(temporary, 384);
830
+ renameSync2(temporary, this.file);
831
+ }
832
+ }
833
+ var id = () => randomBytes2(16).toString("base64url");
834
+ var init_relay_store = __esm(() => {
835
+ RelayStore.FILE = "relay.json";
836
+ });
837
+
838
+ // ../../ta-packages/ta-relay/esm/common/relay-pairing.js
839
+ var exports_relay_pairing = {};
840
+ __export(exports_relay_pairing, {
841
+ RelayPairingUtil: () => RelayPairingUtil
842
+ });
843
+ var RelayPairingUtil;
844
+ var init_relay_pairing = __esm(() => {
845
+ init_relay_protocol();
846
+ (function(RelayPairingUtil2) {
847
+ function link(pairing) {
848
+ const fragment = new URLSearchParams({ v: "1", h: pairing.host, d: pairing.device, k: pairing.key });
849
+ if (pairing.name) {
850
+ fragment.set("n", pairing.name);
851
+ }
852
+ return `${pairing.relay}${RELAY_PAIR_PATH}#${fragment}`;
853
+ }
854
+ RelayPairingUtil2.link = link;
855
+ function parse(link2) {
856
+ var _a;
857
+ const url = new URL(link2.trim());
858
+ const fragment = new URLSearchParams(url.hash.slice(1));
859
+ const [host, device, key] = ["h", "d", "k"].map((name) => {
860
+ var _a2;
861
+ return (_a2 = fragment.get(name)) !== null && _a2 !== undefined ? _a2 : "";
862
+ });
863
+ if (!/^https?:$/.test(url.protocol) || url.pathname !== RELAY_PAIR_PATH || fragment.get("v") !== "1" || !RELAY_ID.test(host) || !RELAY_ID.test(device) || !/^[A-Za-z0-9_-]{43}$/.test(key)) {
864
+ throw new Error("Not a pairing link of Ta.");
865
+ }
866
+ return { relay: url.origin, host, device, key, name: (_a = fragment.get("n")) !== null && _a !== undefined ? _a : undefined };
867
+ }
868
+ RelayPairingUtil2.parse = parse;
869
+ function websocketUrl(relay, path) {
870
+ return relay.replace(/^http/, "ws") + path;
871
+ }
872
+ RelayPairingUtil2.websocketUrl = websocketUrl;
873
+ })(RelayPairingUtil || (RelayPairingUtil = {}));
874
+ });
875
+
876
+ // ../../ta-packages/ta-exec/esm/node/exec-rpc.js
877
+ var ExecRpc;
878
+ var init_exec_rpc = __esm(() => {
879
+ (function(ExecRpc2) {
880
+ ExecRpc2.PATH = "/exec";
881
+ ExecRpc2.Method = {
882
+ INITIALIZE: "initialize",
883
+ EXEC: "process/exec",
884
+ SPAWN: "process/spawn",
885
+ WRITE: "process/write",
886
+ KILL: "process/kill",
887
+ READ_FILE: "fs/readFile",
888
+ WRITE_FILE: "fs/writeFile",
889
+ STAT: "fs/stat",
890
+ READDIR: "fs/readdir",
891
+ MKDIR: "fs/mkdir",
892
+ REMOVE: "fs/remove"
893
+ };
894
+ ExecRpc2.Notification = {
895
+ OUTPUT: "process/output",
896
+ STDERR: "process/stderr",
897
+ EXIT: "process/exit"
898
+ };
899
+ ExecRpc2.ErrorCode = {
900
+ STALE_EPOCH: "CELL_TA_EXEC_STALE_EPOCH",
901
+ NOT_INITIALIZED: "CELL_TA_EXEC_NOT_INITIALIZED",
902
+ FAILED: "CELL_TA_EXEC_FAILED",
903
+ CONNECTION_LOST: "CELL_TA_EXEC_CONNECTION_LOST"
904
+ };
905
+ ExecRpc2.ERROR = -32060;
906
+ function error(id2, code, message) {
907
+ return { jsonrpc: "2.0", id: id2, error: { code: ExecRpc2.ERROR, message, data: { code } } };
908
+ }
909
+ ExecRpc2.error = error;
910
+ function toBase64(data) {
911
+ return Buffer.from(data).toString("base64");
912
+ }
913
+ ExecRpc2.toBase64 = toBase64;
914
+ function fromBase64(data) {
915
+ return Buffer.from(data, "base64");
916
+ }
917
+ ExecRpc2.fromBase64 = fromBase64;
918
+ })(ExecRpc || (ExecRpc = {}));
919
+ });
920
+
921
+ // ../../ta-packages/ta-exec/esm/node/local-exec-environment.js
922
+ import { spawn as spawn2 } from "node:child_process";
923
+ import { mkdir, readdir, readFile, rm, stat, writeFile } from "node:fs/promises";
924
+ import { resolve } from "node:path";
925
+
926
+ class LocalExecEnvironment {
927
+ constructor(cwd) {
928
+ this.cwd = cwd;
929
+ this.local = true;
930
+ }
931
+ exec(command, options = {}) {
932
+ var _a, _b;
933
+ const [shell, ...args] = process.platform === "win32" ? ["cmd.exe", "/d", "/s", "/c"] : ["/bin/sh", "-c"];
934
+ const child = spawn2(shell, [...args, command], {
935
+ cwd: resolve(this.cwd, (_a = options.cwd) !== null && _a !== undefined ? _a : "."),
936
+ env: (_b = options.env) !== null && _b !== undefined ? _b : process.env,
937
+ stdio: ["ignore", "pipe", "pipe"],
938
+ detached: process.platform !== "win32"
939
+ });
940
+ return new Promise((done) => {
941
+ var _a2, _b2, _c, _d;
942
+ const kill = () => this.killGroup(child);
943
+ const timer = options.timeout ? setTimeout(kill, options.timeout) : undefined;
944
+ (_a2 = options.signal) === null || _a2 === undefined || _a2.addEventListener("abort", kill, { once: true });
945
+ if ((_b2 = options.signal) === null || _b2 === undefined ? undefined : _b2.aborted) {
946
+ kill();
947
+ }
948
+ (_c = child.stdout) === null || _c === undefined || _c.on("data", (data) => {
949
+ var _a3;
950
+ return (_a3 = options.onData) === null || _a3 === undefined ? undefined : _a3.call(options, data);
951
+ });
952
+ (_d = child.stderr) === null || _d === undefined || _d.on("data", (data) => {
953
+ var _a3;
954
+ return (_a3 = options.onData) === null || _a3 === undefined ? undefined : _a3.call(options, data);
955
+ });
956
+ const finish = (exitCode) => {
957
+ var _a3;
958
+ clearTimeout(timer);
959
+ (_a3 = options.signal) === null || _a3 === undefined || _a3.removeEventListener("abort", kill);
960
+ done({ exitCode });
961
+ };
962
+ child.once("error", () => finish(null));
963
+ child.once("close", finish);
964
+ });
965
+ }
966
+ spawn(command, args, options = {}) {
967
+ var _a, _b;
968
+ const child = spawn2(command, args, {
969
+ cwd: resolve(this.cwd, (_a = options.cwd) !== null && _a !== undefined ? _a : "."),
970
+ env: (_b = options.env) !== null && _b !== undefined ? _b : process.env,
971
+ stdio: ["pipe", "pipe", "pipe"]
972
+ });
973
+ child.stdin.on("error", () => {
974
+ return;
975
+ });
976
+ return {
977
+ write: (data) => child.stdin.write(data),
978
+ onStdout: (listener) => child.stdout.on("data", listener),
979
+ onStderr: (listener) => child.stderr.on("data", listener),
980
+ onExit: (listener) => {
981
+ child.once("error", () => listener(null));
982
+ child.once("close", listener);
983
+ },
984
+ kill: () => child.kill()
985
+ };
986
+ }
987
+ readFile(path) {
988
+ return readFile(this.resolve(path));
989
+ }
990
+ writeFile(path, data) {
991
+ return writeFile(this.resolve(path), data);
992
+ }
993
+ async stat(path) {
994
+ try {
995
+ const info = await stat(this.resolve(path));
996
+ return { isDirectory: info.isDirectory(), size: info.size, mtimeMs: info.mtimeMs };
997
+ } catch (error) {
998
+ if (error.code === "ENOENT") {
999
+ return;
1000
+ }
1001
+ throw error;
1002
+ }
1003
+ }
1004
+ async readdir(path) {
1005
+ const entries = await readdir(this.resolve(path), { withFileTypes: true });
1006
+ return entries.map((entry) => ({ name: entry.name, isDirectory: entry.isDirectory() }));
1007
+ }
1008
+ async mkdir(path) {
1009
+ await mkdir(this.resolve(path), { recursive: true });
1010
+ }
1011
+ remove(path, options = {}) {
1012
+ return rm(this.resolve(path), { recursive: options.recursive, force: true });
1013
+ }
1014
+ resolve(path) {
1015
+ return resolve(this.cwd, path);
1016
+ }
1017
+ killGroup(child) {
1018
+ if (child.pid === undefined) {
1019
+ return;
1020
+ }
1021
+ try {
1022
+ if (process.platform === "win32") {
1023
+ child.kill();
1024
+ } else {
1025
+ process.kill(-child.pid, "SIGKILL");
1026
+ }
1027
+ } catch (_a) {}
1028
+ }
1029
+ }
1030
+ var init_local_exec_environment = () => {};
1031
+
1032
+ // ../../ta-packages/ta-exec/esm/node/exec-server.js
1033
+ var exports_exec_server = {};
1034
+ __export(exports_exec_server, {
1035
+ ExecServer: () => ExecServer,
1036
+ ExecPeer: () => ExecPeer
1037
+ });
1038
+ import { timingSafeEqual as timingSafeEqual2 } from "node:crypto";
1039
+ import { createServer as createServer3 } from "node:http";
1040
+
1041
+ class ExecServer {
1042
+ constructor(options) {
1043
+ this.options = options;
1044
+ this.epoch = 0;
1045
+ this.peers = new Set;
1046
+ }
1047
+ get cwd() {
1048
+ var _a;
1049
+ return (_a = this.options.cwd) !== null && _a !== undefined ? _a : process.cwd();
1050
+ }
1051
+ async listen() {
1052
+ var _a;
1053
+ const server = createServer3((_request, response) => response.writeHead(404).end());
1054
+ server.on("upgrade", (request, socket, head) => this.upgrade(request, socket, head));
1055
+ this.server = server;
1056
+ await new Promise((resolve2) => {
1057
+ var _a2, _b;
1058
+ return server.listen((_a2 = this.options.port) !== null && _a2 !== undefined ? _a2 : 0, (_b = this.options.host) !== null && _b !== undefined ? _b : "127.0.0.1", resolve2);
1059
+ });
1060
+ const { port } = server.address();
1061
+ return `ws://${(_a = this.options.host) !== null && _a !== undefined ? _a : "127.0.0.1"}:${port}${ExecRpc.PATH}`;
1062
+ }
1063
+ async close() {
1064
+ for (const peer2 of this.peers) {
1065
+ peer2.close(1001, "The server stops.");
1066
+ }
1067
+ await new Promise((resolve2) => this.server ? this.server.close(() => resolve2()) : resolve2());
1068
+ }
1069
+ admit(peer2, epoch) {
1070
+ if (epoch < this.epoch) {
1071
+ return false;
1072
+ }
1073
+ if (epoch > this.epoch) {
1074
+ this.epoch = epoch;
1075
+ for (const other of this.peers) {
1076
+ if (other !== peer2 && other.epoch !== undefined && other.epoch < epoch) {
1077
+ other.close(4001, "A host with a newer epoch connected.");
1078
+ }
1079
+ }
1080
+ }
1081
+ return true;
1082
+ }
1083
+ isCurrent(epoch) {
1084
+ return epoch === this.epoch;
1085
+ }
1086
+ upgrade(request, socket, head) {
1087
+ var _a, _b;
1088
+ const url = new URL((_a = request.url) !== null && _a !== undefined ? _a : "/", "http://localhost");
1089
+ if (url.pathname !== ExecRpc.PATH) {
1090
+ WebSocketConnection.refuse(socket, 404, "Not found.");
1091
+ return;
1092
+ }
1093
+ const checked = WebSocketConnection.check(request);
1094
+ if ("status" in checked) {
1095
+ WebSocketConnection.refuse(socket, checked.status, checked.message);
1096
+ return;
1097
+ }
1098
+ const header = request.headers.authorization;
1099
+ const token = (header === null || header === undefined ? undefined : header.startsWith("Bearer ")) ? header.slice("Bearer ".length) : url.searchParams.get("token");
1100
+ if (!token || !this.matches(token)) {
1101
+ WebSocketConnection.refuse(socket, 401, "Not authorized.");
1102
+ return;
1103
+ }
1104
+ const connection = WebSocketConnection.open(socket, checked.key, head, { maxPayload: (_b = this.options.maxPayload) !== null && _b !== undefined ? _b : 67108864, heartbeat: 30000 });
1105
+ const peer2 = new ExecPeer(this, connection);
1106
+ this.peers.add(peer2);
1107
+ connection.onClose(() => {
1108
+ this.peers.delete(peer2);
1109
+ peer2.dispose();
1110
+ });
1111
+ }
1112
+ matches(token) {
1113
+ const [left, right] = [Buffer.from(token), Buffer.from(this.options.token)];
1114
+ return left.length === right.length && timingSafeEqual2(left, right);
1115
+ }
1116
+ }
1117
+
1118
+ class ExecPeer {
1119
+ constructor(server, connection) {
1120
+ this.server = server;
1121
+ this.connection = connection;
1122
+ this.running = new Map;
1123
+ this.spawned = new Map;
1124
+ connection.onMessage((text) => void this.receive(text));
1125
+ }
1126
+ close(code, reason) {
1127
+ this.dispose();
1128
+ this.connection.close(code, reason);
1129
+ }
1130
+ dispose() {
1131
+ for (const controller of this.running.values()) {
1132
+ controller.abort();
1133
+ }
1134
+ for (const child of this.spawned.values()) {
1135
+ child.kill();
1136
+ }
1137
+ this.running.clear();
1138
+ this.spawned.clear();
1139
+ }
1140
+ async receive(text) {
1141
+ var _a;
1142
+ let message;
1143
+ try {
1144
+ message = JSON.parse(text);
1145
+ } catch (_b) {
1146
+ this.connection.close(1007, "Not JSON.");
1147
+ return;
1148
+ }
1149
+ const { id: id2, method, params } = message;
1150
+ let reply;
1151
+ if (method === ExecRpc.Method.INITIALIZE) {
1152
+ reply = this.initialize(id2, params);
1153
+ } else if (this.epoch === undefined) {
1154
+ reply = ExecRpc.error(id2, ExecRpc.ErrorCode.NOT_INITIALIZED, "Call initialize first.");
1155
+ } else if (!this.server.isCurrent(this.epoch)) {
1156
+ reply = ExecRpc.error(id2, ExecRpc.ErrorCode.STALE_EPOCH, "A host with a newer epoch took over.");
1157
+ } else {
1158
+ try {
1159
+ reply = { jsonrpc: "2.0", id: id2, result: (_a = await this.call(method, params)) !== null && _a !== undefined ? _a : null };
1160
+ } catch (error) {
1161
+ reply = ExecRpc.error(id2, ExecRpc.ErrorCode.FAILED, error instanceof Error ? error.message : String(error));
1162
+ }
1163
+ }
1164
+ if (id2 !== undefined) {
1165
+ this.send(reply);
1166
+ }
1167
+ }
1168
+ initialize(id2, params) {
1169
+ if (typeof (params === null || params === undefined ? undefined : params.epoch) !== "number" || !this.server.admit(this, params.epoch)) {
1170
+ return ExecRpc.error(id2, ExecRpc.ErrorCode.STALE_EPOCH, "A host with a newer epoch is connected.");
1171
+ }
1172
+ this.epoch = params.epoch;
1173
+ const result = { platform: process.platform, cwd: this.server.cwd };
1174
+ return { jsonrpc: "2.0", id: id2, result };
1175
+ }
1176
+ async call(method, params) {
1177
+ var _a, _b, _c;
1178
+ var _d;
1179
+ const environment = new LocalExecEnvironment((_d = params.root) !== null && _d !== undefined ? _d : this.server.cwd);
1180
+ switch (method) {
1181
+ case ExecRpc.Method.EXEC:
1182
+ return this.exec(environment, params);
1183
+ case ExecRpc.Method.SPAWN:
1184
+ return this.spawn(environment, params);
1185
+ case ExecRpc.Method.WRITE:
1186
+ (_a = this.spawned.get(params.id)) === null || _a === undefined || _a.write(ExecRpc.fromBase64(params.data));
1187
+ return;
1188
+ case ExecRpc.Method.KILL:
1189
+ (_b = this.running.get(params.id)) === null || _b === undefined || _b.abort();
1190
+ (_c = this.spawned.get(params.id)) === null || _c === undefined || _c.kill();
1191
+ return;
1192
+ case ExecRpc.Method.READ_FILE:
1193
+ return ExecRpc.toBase64(await environment.readFile(params.path));
1194
+ case ExecRpc.Method.WRITE_FILE:
1195
+ return environment.writeFile(params.path, ExecRpc.fromBase64(params.data));
1196
+ case ExecRpc.Method.STAT:
1197
+ return environment.stat(params.path);
1198
+ case ExecRpc.Method.READDIR:
1199
+ return environment.readdir(params.path);
1200
+ case ExecRpc.Method.MKDIR:
1201
+ return environment.mkdir(params.path);
1202
+ case ExecRpc.Method.REMOVE:
1203
+ return environment.remove(params.path, { recursive: params.recursive });
1204
+ default:
1205
+ throw new Error(`No method ${method}.`);
1206
+ }
1207
+ }
1208
+ async exec(environment, params) {
1209
+ const controller = new AbortController;
1210
+ this.running.set(params.id, controller);
1211
+ try {
1212
+ return await environment.exec(params.command, {
1213
+ cwd: params.cwd,
1214
+ env: { ...process.env, ...params.env },
1215
+ timeout: params.timeout,
1216
+ signal: controller.signal,
1217
+ onData: (data) => this.notify(ExecRpc.Notification.OUTPUT, { id: params.id, data: ExecRpc.toBase64(data) })
1218
+ });
1219
+ } finally {
1220
+ this.running.delete(params.id);
1221
+ }
1222
+ }
1223
+ spawn(environment, params) {
1224
+ const child = environment.spawn(params.command, params.args, { cwd: params.cwd, env: { ...process.env, ...params.env } });
1225
+ this.spawned.set(params.id, child);
1226
+ child.onStdout((data) => this.notify(ExecRpc.Notification.OUTPUT, { id: params.id, data: ExecRpc.toBase64(data) }));
1227
+ child.onStderr((data) => this.notify(ExecRpc.Notification.STDERR, { id: params.id, data: ExecRpc.toBase64(data) }));
1228
+ child.onExit((exitCode) => {
1229
+ this.spawned.delete(params.id);
1230
+ this.notify(ExecRpc.Notification.EXIT, { id: params.id, exitCode });
1231
+ });
1232
+ }
1233
+ notify(method, params) {
1234
+ this.send({ jsonrpc: "2.0", method, params });
1235
+ }
1236
+ send(message) {
1237
+ this.connection.send(JSON.stringify(message));
1238
+ }
1239
+ }
1240
+ var init_exec_server = __esm(() => {
1241
+ init_websocket_connection();
1242
+ init_exec_rpc();
1243
+ init_local_exec_environment();
1244
+ });
1245
+
1
1246
  // ../../ta-packages/ta-harness/esm/node/ta-cli.js
1247
+ import { randomBytes as randomBytes3 } from "node:crypto";
2
1248
  import { parseArgs } from "node:util";
3
1249
 
4
1250
  // ../../ai-packages/ai-coding-agent/esm/node/pi/pi-bundle-util.js
@@ -42,7 +1288,7 @@ var BugReport;
42
1288
  function issueUrl(description, environment) {
43
1289
  var _a;
44
1290
  const url = new URL(BugReport2.ISSUES_URL);
45
- url.searchParams.set("title", `[ta] ${description.trim() || "Describe the bug"}`);
1291
+ url.searchParams.set("title", `[Ta] ${description.trim() || "Describe the bug"}`);
46
1292
  url.searchParams.set("labels", "ta");
47
1293
  url.searchParams.set("body", [
48
1294
  "## What happened",
@@ -51,7 +1297,7 @@ var BugReport;
51
1297
  "",
52
1298
  "## Environment",
53
1299
  "",
54
- `- ta ${environment.version}`,
1300
+ `- Ta ${environment.version}`,
55
1301
  `- model: ${(_a = environment.model) !== null && _a !== undefined ? _a : "none"}`,
56
1302
  `- ${environment.platform}, Node.js ${environment.node}`
57
1303
  ].join(`
@@ -202,15 +1448,15 @@ class TaHeader {
202
1448
  }
203
1449
  intro(width) {
204
1450
  const { theme } = this;
205
- const title = `ta v${this.options.version}`;
1451
+ const title = `Ta v${this.options.version}`;
206
1452
  const green = (text) => DinoLogo.paint(theme.getColorMode(), text);
207
1453
  return [
208
- this.span(title, width, (text) => text === title ? `${theme.bold(green("ta"))} ${theme.fg("dim", title.slice(4))}` : green(text)),
1454
+ this.span(title, width, (text) => text === title ? `${theme.bold(green("Ta"))} ${theme.fg("dim", title.slice(4))}` : green(text)),
209
1455
  this.span("a coding agent on Cell and pi", width, (text) => theme.fg("muted", text)),
210
1456
  { text: "", width: 0 },
211
1457
  ...COMPACT_HINTS.flatMap((group) => this.flow(this.hints(group), width)),
212
1458
  { text: "", width: 0 },
213
- this.span("Ask ta how to use or extend it.", width, (text) => theme.fg("dim", text))
1459
+ this.span("Ask Ta how to use or extend it.", width, (text) => theme.fg("dim", text))
214
1460
  ];
215
1461
  }
216
1462
  flow(hints, width) {
@@ -277,13 +1523,13 @@ class BrandExtension {
277
1523
  }
278
1524
  });
279
1525
  pi.registerCommand("bug", {
280
- description: "Open an issue for ta on GitHub",
1526
+ description: "Open an issue for Ta on GitHub",
281
1527
  handler: async (args, ctx) => {
282
1528
  const url = BugReport.issueUrl(args, BugReport.currentEnvironment(this.sdk.VERSION, ctx.model));
283
1529
  if (ctx.mode === "tui") {
284
1530
  BugReport.open(url);
285
1531
  }
286
- ctx.ui.notify(`A new issue for ta, with its version, the model and the platform and nothing else, opens in the browser. If it did not:
1532
+ ctx.ui.notify(`A new issue for Ta, with its version, the model and the platform and nothing else, opens in the browser. If it did not:
287
1533
  ${url}`, "info");
288
1534
  }
289
1535
  });
@@ -339,7 +1585,7 @@ class SessionLockExtension {
339
1585
  });
340
1586
  }
341
1587
  refuse(file, ctx) {
342
- const message = `This session is open in another ta process. If that process is gone, delete ${this.lock.path(file)}.`;
1588
+ const message = `This session is open in another Ta process. If that process is gone, delete ${this.lock.path(file)}.`;
343
1589
  if (ctx.mode === "tui") {
344
1590
  ctx.ui.notify(message, "error");
345
1591
  ctx.shutdown();
@@ -351,11 +1597,100 @@ class SessionLockExtension {
351
1597
  }
352
1598
  }
353
1599
 
1600
+ // ../../ta-packages/ta-harness/esm/node/serve-state.js
1601
+ import { chmodSync, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
1602
+ import { createServer } from "node:net";
1603
+ import { dirname, join as join3 } from "node:path";
1604
+
1605
+ // ../../ta-packages/ta-harness/esm/node/ta-brand.js
1606
+ import { readFileSync } from "node:fs";
1607
+ import { homedir } from "node:os";
1608
+ import { join as join2 } from "node:path";
1609
+ var TaBrand;
1610
+ (function(TaBrand2) {
1611
+ TaBrand2.NAME = "ta";
1612
+ TaBrand2.ENV_ALIASES = {
1613
+ TA_OFFLINE: "PI_OFFLINE",
1614
+ TA_SELF_UPDATE_COMMAND: "PI_SELF_UPDATE_COMMAND",
1615
+ TA_TELEMETRY: "PI_TELEMETRY",
1616
+ TA_SKIP_VERSION_CHECK: "PI_SKIP_VERSION_CHECK"
1617
+ };
1618
+ function agentDir() {
1619
+ var _a;
1620
+ return (_a = process.env.TA_CODING_AGENT_DIR) !== null && _a !== undefined ? _a : join2(homedir(), ".ta", "agent");
1621
+ }
1622
+ TaBrand2.agentDir = agentDir;
1623
+ function version() {
1624
+ var _a, _b;
1625
+ try {
1626
+ return (_b = JSON.parse(readFileSync(join2((_a = process.env.PI_PACKAGE_DIR) !== null && _a !== undefined ? _a : "", "package.json"), "utf8")).version) !== null && _b !== undefined ? _b : "unknown";
1627
+ } catch (_c) {
1628
+ return "unknown";
1629
+ }
1630
+ }
1631
+ TaBrand2.version = version;
1632
+ function activate(brandDir) {
1633
+ var _a, _b;
1634
+ var _c, _d;
1635
+ process.env.PI_PACKAGE_DIR = brandDir;
1636
+ for (const [ta, pi] of Object.entries(TaBrand2.ENV_ALIASES)) {
1637
+ if (process.env[ta] !== undefined) {
1638
+ process.env[pi] = process.env[ta];
1639
+ }
1640
+ }
1641
+ (_a = (_c = process.env).PI_SKIP_VERSION_CHECK) !== null && _a !== undefined || (_c.PI_SKIP_VERSION_CHECK = "1");
1642
+ (_b = (_d = process.env).PI_TELEMETRY) !== null && _b !== undefined || (_d.PI_TELEMETRY = "0");
1643
+ process.env.PI_CODING_AGENT = "true";
1644
+ process.env.AI_AGENT = TaBrand2.NAME;
1645
+ process.title = TaBrand2.NAME;
1646
+ process.emitWarning = () => {
1647
+ return;
1648
+ };
1649
+ }
1650
+ TaBrand2.activate = activate;
1651
+ })(TaBrand || (TaBrand = {}));
1652
+
1653
+ // ../../ta-packages/ta-harness/esm/node/serve-state.js
1654
+ var TaServeStateUtil;
1655
+ (function(TaServeStateUtil2) {
1656
+ TaServeStateUtil2.FILE = "serve-state.json";
1657
+ function file(agentDir = TaBrand.agentDir()) {
1658
+ return join3(agentDir, TaServeStateUtil2.FILE);
1659
+ }
1660
+ TaServeStateUtil2.file = file;
1661
+ function read(path = file()) {
1662
+ try {
1663
+ const { port, token } = JSON.parse(readFileSync2(path, "utf8"));
1664
+ return {
1665
+ port: typeof port === "number" && Number.isInteger(port) && port > 0 && port < 65536 ? port : undefined,
1666
+ token: typeof token === "string" && token.length > 0 ? token : undefined
1667
+ };
1668
+ } catch (_a) {
1669
+ return {};
1670
+ }
1671
+ }
1672
+ TaServeStateUtil2.read = read;
1673
+ function write(state, path = file()) {
1674
+ mkdirSync(dirname(path), { recursive: true });
1675
+ writeFileSync(path, JSON.stringify(state), { mode: 384 });
1676
+ chmodSync(path, 384);
1677
+ }
1678
+ TaServeStateUtil2.write = write;
1679
+ function isFree(port, host) {
1680
+ return new Promise((resolve) => {
1681
+ const server = createServer();
1682
+ server.once("error", () => resolve(false));
1683
+ server.listen(port, host, () => server.close(() => resolve(true)));
1684
+ });
1685
+ }
1686
+ TaServeStateUtil2.isFree = isFree;
1687
+ })(TaServeStateUtil || (TaServeStateUtil = {}));
1688
+
354
1689
  // ../../ta-packages/ta-harness/esm/node/session-lock.js
355
1690
  import { randomUUID } from "node:crypto";
356
- import { linkSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
1691
+ import { linkSync, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
357
1692
  import { hostname } from "node:os";
358
- import { dirname } from "node:path";
1693
+ import { dirname as dirname2 } from "node:path";
359
1694
 
360
1695
  class SessionLock {
361
1696
  constructor() {
@@ -366,7 +1701,7 @@ class SessionLock {
366
1701
  if (this.held.has(sessionFile)) {
367
1702
  return true;
368
1703
  }
369
- mkdirSync(dirname(sessionFile), { recursive: true });
1704
+ mkdirSync2(dirname2(sessionFile), { recursive: true });
370
1705
  for (let attempt = 0;attempt < 2; attempt++) {
371
1706
  if (this.create(sessionFile)) {
372
1707
  this.held.add(sessionFile);
@@ -399,7 +1734,7 @@ class SessionLock {
399
1734
  create(sessionFile) {
400
1735
  const lock = { owner: this.owner, pid: process.pid, host: hostname(), createdAt: Date.now() };
401
1736
  const draft = `${this.path(sessionFile)}.${this.owner}`;
402
- writeFileSync(draft, JSON.stringify(lock));
1737
+ writeFileSync2(draft, JSON.stringify(lock));
403
1738
  try {
404
1739
  linkSync(draft, this.path(sessionFile));
405
1740
  return true;
@@ -414,7 +1749,7 @@ class SessionLock {
414
1749
  }
415
1750
  read(sessionFile) {
416
1751
  try {
417
- return JSON.parse(readFileSync(this.path(sessionFile), "utf8"));
1752
+ return JSON.parse(readFileSync3(this.path(sessionFile), "utf8"));
418
1753
  } catch (error) {
419
1754
  if (error.code === "ENOENT") {
420
1755
  return;
@@ -435,55 +1770,194 @@ class SessionLock {
435
1770
  }
436
1771
  }
437
1772
 
438
- // ../../ta-packages/ta-harness/esm/node/ta-brand.js
439
- import { homedir } from "node:os";
440
- import { join as join2 } from "node:path";
441
- var TaBrand;
442
- (function(TaBrand2) {
443
- TaBrand2.NAME = "ta";
444
- TaBrand2.ENV_ALIASES = {
445
- TA_OFFLINE: "PI_OFFLINE",
446
- TA_SELF_UPDATE_COMMAND: "PI_SELF_UPDATE_COMMAND",
447
- TA_TELEMETRY: "PI_TELEMETRY",
448
- TA_SKIP_VERSION_CHECK: "PI_SKIP_VERSION_CHECK"
449
- };
450
- function agentDir() {
1773
+ // ../../ta-packages/ta-harness/esm/node/ta-packages.js
1774
+ import { fileURLToPath as __cellFileURLToPath2 } from "node:url";
1775
+ import { dirname as __cellDirname2 } from "node:path";
1776
+ import { existsSync as existsSync2, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync4, renameSync, writeFileSync as writeFileSync3 } from "node:fs";
1777
+ import { createRequire as createRequire2 } from "node:module";
1778
+ import { dirname as dirname3, join as join4, sep } from "node:path";
1779
+ var __filename3 = __cellFileURLToPath2(import.meta.url);
1780
+ var __dirname3 = __cellDirname2(__filename3);
1781
+ var PACKAGE_COMMANDS = new Set(["install", "remove", "uninstall", "update", "list", "config"]);
1782
+ var TaPackages;
1783
+ (function(TaPackages2) {
1784
+ TaPackages2.BUILTIN = ["@celljs/ta-workspace", "@celljs/ta-channels", "@celljs/ta-extensions"];
1785
+ TaPackages2.SETTINGS_FILE = "ta.json";
1786
+ function builtins(packageDir = process.env.PI_PACKAGE_DIR) {
1787
+ const dir = packageDir ? join4(packageDir, "packages") : undefined;
1788
+ return dir && existsSync2(dir) ? described(subdirectories(dir)) : workspace();
1789
+ }
1790
+ TaPackages2.builtins = builtins;
1791
+ function workspace() {
1792
+ const resolve = createRequire2(__filename3).resolve;
1793
+ return described(TaPackages2.BUILTIN.flatMap((name) => {
1794
+ try {
1795
+ return [dirname3(resolve(`${name}/package.json`))];
1796
+ } catch (_a) {
1797
+ return [];
1798
+ }
1799
+ }));
1800
+ }
1801
+ TaPackages2.workspace = workspace;
1802
+ function directoryName(name) {
1803
+ return name.slice(name.lastIndexOf("/") + 1);
1804
+ }
1805
+ TaPackages2.directoryName = directoryName;
1806
+ function disabled(agentDir) {
451
1807
  var _a;
452
- return (_a = process.env.TA_CODING_AGENT_DIR) !== null && _a !== undefined ? _a : join2(homedir(), ".ta", "agent");
1808
+ return new Set((_a = readSettings(agentDir).disabledPackages) !== null && _a !== undefined ? _a : []);
453
1809
  }
454
- TaBrand2.agentDir = agentDir;
455
- function activate(brandDir) {
456
- var _a, _b;
457
- var _c, _d;
458
- process.env.PI_PACKAGE_DIR = brandDir;
459
- for (const [ta, pi] of Object.entries(TaBrand2.ENV_ALIASES)) {
460
- if (process.env[ta] !== undefined) {
461
- process.env[pi] = process.env[ta];
1810
+ TaPackages2.disabled = disabled;
1811
+ function setEnabled(agentDir, name, enabled2) {
1812
+ toggle(agentDir, "disabledPackages", name, enabled2);
1813
+ }
1814
+ TaPackages2.setEnabled = setEnabled;
1815
+ function disabledWeb(agentDir) {
1816
+ var _a;
1817
+ return new Set((_a = readSettings(agentDir).disabledWeb) !== null && _a !== undefined ? _a : []);
1818
+ }
1819
+ TaPackages2.disabledWeb = disabledWeb;
1820
+ function setWebEnabled(agentDir, root, enabled2) {
1821
+ toggle(agentDir, "disabledWeb", root, enabled2);
1822
+ }
1823
+ TaPackages2.setWebEnabled = setWebEnabled;
1824
+ function enabled(agentDir, packageDir) {
1825
+ const off = disabled(agentDir);
1826
+ return builtins(packageDir).filter((pkg) => !off.has(pkg.name));
1827
+ }
1828
+ TaPackages2.enabled = enabled;
1829
+ function extensionPaths(agentDir, packageDir) {
1830
+ return enabled(agentDir, packageDir).filter((pkg) => pkg.resources).map((pkg) => pkg.root);
1831
+ }
1832
+ TaPackages2.extensionPaths = extensionPaths;
1833
+ function loaderOptions(agentDir, packageDir) {
1834
+ const roots = builtins(packageDir).filter((pkg) => pkg.resources).map((pkg) => pkg.root);
1835
+ const keeper = () => {
1836
+ const on = new Set(extensionPaths(agentDir, packageDir));
1837
+ const off = roots.filter((root) => !on.has(root));
1838
+ return (path) => !path || !off.some((root) => path === root || path.startsWith(`${root}${sep}`));
1839
+ };
1840
+ return {
1841
+ additionalExtensionPaths: roots,
1842
+ extensionsOverride: (result) => {
1843
+ const keep = keeper();
1844
+ return {
1845
+ ...result,
1846
+ extensions: result.extensions.filter((extension) => keep(extension.resolvedPath) && keep(extension.path)),
1847
+ errors: result.errors.filter((error) => keep(error.path))
1848
+ };
1849
+ },
1850
+ skillsOverride: (result) => {
1851
+ const keep = keeper();
1852
+ return { ...result, skills: result.skills.filter((skill) => keep(skill.filePath)), diagnostics: result.diagnostics.filter((d) => keep(d.path)) };
1853
+ },
1854
+ promptsOverride: (result) => {
1855
+ const keep = keeper();
1856
+ return {
1857
+ ...result,
1858
+ prompts: result.prompts.filter((prompt) => keep(prompt.filePath)),
1859
+ diagnostics: result.diagnostics.filter((d) => keep(d.path))
1860
+ };
462
1861
  }
1862
+ };
1863
+ }
1864
+ TaPackages2.loaderOptions = loaderOptions;
1865
+ function withExtensions(argv, agentDir, packageDir) {
1866
+ if (PACKAGE_COMMANDS.has(argv[0]) || argv.includes("--no-extensions") || argv.includes("-ne")) {
1867
+ return argv;
463
1868
  }
464
- (_a = (_c = process.env).PI_SKIP_VERSION_CHECK) !== null && _a !== undefined || (_c.PI_SKIP_VERSION_CHECK = "1");
465
- (_b = (_d = process.env).PI_TELEMETRY) !== null && _b !== undefined || (_d.PI_TELEMETRY = "0");
466
- process.env.PI_CODING_AGENT = "true";
467
- process.env.AI_AGENT = TaBrand2.NAME;
468
- process.title = TaBrand2.NAME;
469
- process.emitWarning = () => {
1869
+ return [...argv, ...extensionPaths(agentDir, packageDir).flatMap((root) => ["--extension", root])];
1870
+ }
1871
+ TaPackages2.withExtensions = withExtensions;
1872
+ function describe(root) {
1873
+ var _a;
1874
+ try {
1875
+ const manifest = JSON.parse(readFileSync4(join4(root, "package.json"), "utf8"));
1876
+ const declared = (key) => {
1877
+ var _a2;
1878
+ const paths = (_a2 = manifest.pi) === null || _a2 === undefined ? undefined : _a2[key];
1879
+ return Array.isArray(paths) && paths.length > 0;
1880
+ };
1881
+ return { name: (_a = manifest.name) !== null && _a !== undefined ? _a : directoryName(root), root, resources: declared("extensions") || declared("skills") || declared("prompts") };
1882
+ } catch (_b) {
470
1883
  return;
471
- };
1884
+ }
472
1885
  }
473
- TaBrand2.activate = activate;
474
- })(TaBrand || (TaBrand = {}));
1886
+ function subdirectories(dir) {
1887
+ return readdirSync(dir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => join4(dir, entry.name)).sort();
1888
+ }
1889
+ function described(roots) {
1890
+ return roots.flatMap((root) => {
1891
+ const pkg = describe(root);
1892
+ return pkg ? [pkg] : [];
1893
+ });
1894
+ }
1895
+ function toggle(agentDir, key, value, enabled2) {
1896
+ var _a;
1897
+ const settings = readSettings(agentDir);
1898
+ const off = new Set((_a = settings[key]) !== null && _a !== undefined ? _a : []);
1899
+ if (enabled2) {
1900
+ off.delete(value);
1901
+ } else {
1902
+ off.add(value);
1903
+ }
1904
+ const file = join4(agentDir, TaPackages2.SETTINGS_FILE);
1905
+ mkdirSync3(agentDir, { recursive: true });
1906
+ writeFileSync3(`${file}.tmp`, `${JSON.stringify({ ...settings, [key]: off.size > 0 || settings[key] ? [...off].sort() : undefined }, null, 2)}
1907
+ `);
1908
+ renameSync(`${file}.tmp`, file);
1909
+ }
1910
+ function readSettings(agentDir) {
1911
+ try {
1912
+ return JSON.parse(readFileSync4(join4(agentDir, TaPackages2.SETTINGS_FILE), "utf8"));
1913
+ } catch (_a) {
1914
+ return {};
1915
+ }
1916
+ }
1917
+ })(TaPackages || (TaPackages = {}));
475
1918
 
476
1919
  // ../../ta-packages/ta-harness/esm/node/ta-cli.js
477
- var SERVE_HELP = `Usage: ta serve [--host <host>] [--port <port>]
1920
+ var SERVE_HELP = `Usage: ta serve [--host <host>] [--port <port>] [--web] [--exec <url>]
478
1921
 
479
- Serves pi sessions over WebSocket to any number of clients. Stops on SIGINT or SIGTERM.
1922
+ Serves ta sessions over WebSocket to any number of clients, and the web client. Stops on SIGINT or SIGTERM.
480
1923
 
481
1924
  --host Address to listen on. Default: 127.0.0.1
482
- --port Port to listen on. Default: a free port
1925
+ --port Port to listen on. Default: the port of the last start if it is free, so that a web app
1926
+ installed from it finds it again; otherwise a free port
1927
+ --web Open the web client in the browser
1928
+ --exec Run the sessions' commands and file operations on a ta exec-server; TA_EXEC_TOKEN is its token
483
1929
 
484
- The URL and the access token are written to serve.json in the agent directory.
1930
+ The URL and the access token are written to serve.json in the agent directory. The token stays the
1931
+ same across restarts (serve-state.json there; remove it for a new token and port).
485
1932
  Set TA_SERVE_TOKEN to choose the token.
486
1933
  `;
1934
+ var EXEC_SERVER_HELP = `Usage: ta exec-server [--host <host>] [--port <port>] [--cwd <dir>]
1935
+
1936
+ Runs the commands and file operations of the sessions of a ta serve on this machine, for example a
1937
+ container or a sandbox, while the agent runs elsewhere: ta serve --exec <url>. Stops on SIGINT or SIGTERM.
1938
+
1939
+ --host Address to listen on. Default: 127.0.0.1
1940
+ --port Port to listen on. Default: a free port
1941
+ --cwd Where sessions run when the host names no directory. Default: the current directory
1942
+
1943
+ Set TA_EXEC_TOKEN to choose the token hosts must present; otherwise a random one is printed.
1944
+ `;
1945
+ var RELAY_HELP = `Usage: ta relay [--host <host>] [--port <port>]
1946
+
1947
+ Runs a relay, through which paired devices reach a ta serve from anywhere (ta pair). It only forwards:
1948
+ what goes through is encrypted end to end. Put it behind HTTPS. Stops on SIGINT or SIGTERM.
1949
+
1950
+ --host Address to listen on. Default: 127.0.0.1
1951
+ --port Port to listen on. Default: 8080
1952
+ `;
1953
+ var PAIR_HELP = `Usage: ta pair [<relay url>] [--name <device>]
1954
+ ta pair --list
1955
+ ta pair --remove <device id>
1956
+
1957
+ Pairs a device, such as a phone, with the ta serve of this user: prints a link to paste in the Ta app on
1958
+ it. The relay is https://relay.cellbang.com unless named. With a device paired, ta serve connects to the relay; what goes through it is encrypted end to end,
1959
+ with a key only the device and ta serve have. The devices are in relay.json in the agent directory.
1960
+ `;
487
1961
  var TaCli;
488
1962
  (function(TaCli2) {
489
1963
  async function run(argv, options) {
@@ -492,25 +1966,135 @@ var TaCli;
492
1966
  await serve(argv.slice(1), options.serveEntry);
493
1967
  return;
494
1968
  }
1969
+ if (argv[0] === "relay") {
1970
+ await relay(argv.slice(1));
1971
+ return;
1972
+ }
1973
+ if (argv[0] === "pair") {
1974
+ await pair(argv.slice(1));
1975
+ return;
1976
+ }
1977
+ if (argv[0] === "exec-server") {
1978
+ await execServer(argv.slice(1));
1979
+ return;
1980
+ }
495
1981
  const sdk = await import(PiBundleUtil.specifier());
496
1982
  const builtIn = TaExtensionUtil.bundle([new SessionLockExtension(new SessionLock), new BrandExtension(sdk)]);
497
- await sdk.main(argv, { extensionFactories: [builtIn] });
1983
+ await sdk.main(TaPackages.withExtensions(argv, TaBrand.agentDir()), { extensionFactories: [builtIn] });
498
1984
  }
499
1985
  TaCli2.run = run;
500
1986
  async function serve(argv, entry) {
501
- const { values } = parseArgs({ args: argv, options: { host: { type: "string" }, port: { type: "string" }, help: { type: "boolean", short: "h" } } });
1987
+ var _a;
1988
+ const { values } = parseArgs({
1989
+ args: argv,
1990
+ options: {
1991
+ host: { type: "string" },
1992
+ port: { type: "string" },
1993
+ web: { type: "boolean" },
1994
+ exec: { type: "string" },
1995
+ help: { type: "boolean", short: "h" }
1996
+ }
1997
+ });
502
1998
  if (values.help) {
503
1999
  process.stdout.write(SERVE_HELP);
504
2000
  return;
505
2001
  }
2002
+ delete process.env.ELECTRON_RUN_AS_NODE;
506
2003
  if (values.host) {
507
2004
  process.env.CELL_SERVER__HOST = values.host;
508
2005
  }
509
2006
  if (values.port) {
510
2007
  process.env.CELL_SERVER__PORT = values.port;
2008
+ } else if (!process.env.CELL_SERVER__PORT) {
2009
+ const { port } = TaServeStateUtil.read();
2010
+ if (port && await TaServeStateUtil.isFree(port, (_a = process.env.CELL_SERVER__HOST) !== null && _a !== undefined ? _a : "127.0.0.1")) {
2011
+ process.env.CELL_SERVER__PORT = String(port);
2012
+ }
2013
+ }
2014
+ if (values.web) {
2015
+ process.env.TA_SERVE_OPEN_WEB = "1";
2016
+ }
2017
+ if (values.exec) {
2018
+ process.env.CELL_TA__EXEC__URL = values.exec;
2019
+ }
2020
+ if (process.env.TA_EXEC_TOKEN) {
2021
+ process.env.CELL_TA__EXEC__TOKEN = process.env.TA_EXEC_TOKEN;
511
2022
  }
512
2023
  await import(entry);
513
2024
  }
2025
+ async function relay(argv) {
2026
+ const { values } = parseArgs({ args: argv, options: { host: { type: "string" }, port: { type: "string" }, help: { type: "boolean", short: "h" } } });
2027
+ if (values.help) {
2028
+ process.stdout.write(RELAY_HELP);
2029
+ return;
2030
+ }
2031
+ const { RelayServer: RelayServer2 } = await Promise.resolve().then(() => (init_relay_server(), exports_relay_server));
2032
+ const server = new RelayServer2({ host: values.host, port: values.port ? Number(values.port) : 8080 });
2033
+ console.log(`ta relay: ${await server.listen()}`);
2034
+ const stop = () => void server.close().then(() => process.exit(0));
2035
+ process.once("SIGINT", stop);
2036
+ process.once("SIGTERM", stop);
2037
+ }
2038
+ async function pair(argv) {
2039
+ var _a;
2040
+ const { values, positionals } = parseArgs({
2041
+ args: argv,
2042
+ allowPositionals: true,
2043
+ options: { name: { type: "string" }, list: { type: "boolean" }, remove: { type: "string" }, help: { type: "boolean", short: "h" } }
2044
+ });
2045
+ const { RelayStore: RelayStore2 } = await Promise.resolve().then(() => (init_relay_store(), exports_relay_store));
2046
+ const { RelayPairingUtil: RelayPairingUtil2 } = await Promise.resolve().then(() => (init_relay_pairing(), exports_relay_pairing));
2047
+ const store = new RelayStore2(TaBrand.agentDir());
2048
+ if (values.list) {
2049
+ const { url, devices } = store.read();
2050
+ console.log(devices.length === 0 ? "No devices are paired." : `Relay: ${url}`);
2051
+ for (const device of devices) {
2052
+ console.log(`${device.id} ${device.name} ${new Date(device.createdAt).toISOString()}`);
2053
+ }
2054
+ return;
2055
+ }
2056
+ if (values.remove) {
2057
+ if (!store.remove(values.remove)) {
2058
+ console.error(`ta pair: no device ${values.remove}`);
2059
+ process.exitCode = 1;
2060
+ }
2061
+ return;
2062
+ }
2063
+ const { RELAY_DEFAULT_URL: RELAY_DEFAULT_URL2 } = await Promise.resolve().then(() => (init_relay_protocol(), exports_relay_protocol));
2064
+ const [relayUrl = RELAY_DEFAULT_URL2] = positionals;
2065
+ if (values.help || !/^https?:\/\//.test(relayUrl)) {
2066
+ process.stdout.write(PAIR_HELP);
2067
+ process.exitCode = values.help ? 0 : 1;
2068
+ return;
2069
+ }
2070
+ const pairing = store.pair(relayUrl, (_a = values.name) !== null && _a !== undefined ? _a : "device");
2071
+ console.log(`Paste this link in the Ta app on the device. Anyone with it can reach your Ta: keep it to yourself.
2072
+ `);
2073
+ console.log(RelayPairingUtil2.link(pairing));
2074
+ console.log(`
2075
+ Device id: ${pairing.device} (ta pair --remove ${pairing.device} to unpair it)`);
2076
+ }
2077
+ async function execServer(argv) {
2078
+ const { values } = parseArgs({
2079
+ args: argv,
2080
+ options: { host: { type: "string" }, port: { type: "string" }, cwd: { type: "string" }, help: { type: "boolean", short: "h" } }
2081
+ });
2082
+ if (values.help) {
2083
+ process.stdout.write(EXEC_SERVER_HELP);
2084
+ return;
2085
+ }
2086
+ const { ExecServer: ExecServer2 } = await Promise.resolve().then(() => (init_exec_server(), exports_exec_server));
2087
+ const token = process.env.TA_EXEC_TOKEN || randomBytes3(32).toString("base64url");
2088
+ const server = new ExecServer2({ host: values.host, port: values.port ? Number(values.port) : undefined, cwd: values.cwd, token });
2089
+ const url = await server.listen();
2090
+ console.log(`ta exec-server: ${url}`);
2091
+ if (!process.env.TA_EXEC_TOKEN) {
2092
+ console.log(`token: ${token}`);
2093
+ }
2094
+ const stop = () => void server.close().then(() => process.exit(0));
2095
+ process.once("SIGINT", stop);
2096
+ process.once("SIGTERM", stop);
2097
+ }
514
2098
  })(TaCli || (TaCli = {}));
515
2099
  export {
516
2100
  TaCli