@celljs/ta-host 4.6.1 → 4.8.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 (245) hide show
  1. package/README.en.md +70 -0
  2. package/README.md +16 -3
  3. package/cell.schema.json +21 -0
  4. package/cell.yml +7 -0
  5. package/esm/node/auth-server-impl.d.ts +2 -0
  6. package/esm/node/auth-server-impl.js +7 -0
  7. package/esm/node/auth-server-impl.js.map +1 -1
  8. package/esm/node/exec-environment-factory.d.ts +8 -4
  9. package/esm/node/exec-environment-factory.js +28 -6
  10. package/esm/node/exec-environment-factory.js.map +1 -1
  11. package/esm/node/extension-providers.d.ts +22 -0
  12. package/esm/node/extension-providers.js +52 -0
  13. package/esm/node/extension-providers.js.map +1 -0
  14. package/esm/node/index.d.ts +3 -0
  15. package/esm/node/index.js +3 -0
  16. package/esm/node/index.js.map +1 -1
  17. package/esm/node/package-host-extension.d.ts +4 -2
  18. package/esm/node/package-host-extension.js +4 -3
  19. package/esm/node/package-host-extension.js.map +1 -1
  20. package/esm/node/package-hosts.d.ts +6 -2
  21. package/esm/node/package-hosts.js +32 -0
  22. package/esm/node/package-hosts.js.map +1 -1
  23. package/esm/node/remote/index.d.ts +5 -0
  24. package/esm/node/remote/index.js +6 -0
  25. package/esm/node/remote/index.js.map +1 -0
  26. package/esm/node/remote/pi-directories.d.ts +14 -0
  27. package/esm/node/remote/pi-directories.js +64 -0
  28. package/esm/node/remote/pi-directories.js.map +1 -0
  29. package/esm/node/remote/port-forwards.d.ts +35 -0
  30. package/esm/node/remote/port-forwards.js +150 -0
  31. package/esm/node/remote/port-forwards.js.map +1 -0
  32. package/esm/node/remote/remote-hosts.d.ts +40 -0
  33. package/esm/node/remote/remote-hosts.js +170 -0
  34. package/esm/node/remote/remote-hosts.js.map +1 -0
  35. package/esm/node/remote/remote-protocol.d.ts +51 -0
  36. package/esm/node/remote/remote-protocol.js +5 -0
  37. package/esm/node/remote/remote-protocol.js.map +1 -0
  38. package/esm/node/remote/remote-server-impl.d.ts +19 -0
  39. package/esm/node/remote/remote-server-impl.js +66 -0
  40. package/esm/node/remote/remote-server-impl.js.map +1 -0
  41. package/esm/node/remote-ui-context.d.ts +6 -1
  42. package/esm/node/remote-ui-context.js +31 -3
  43. package/esm/node/remote-ui-context.js.map +1 -1
  44. package/esm/node/session-files.d.ts +18 -0
  45. package/esm/node/session-files.js +32 -0
  46. package/esm/node/session-files.js.map +1 -0
  47. package/esm/node/settings-server-impl.d.ts +1 -0
  48. package/esm/node/settings-server-impl.js +8 -0
  49. package/esm/node/settings-server-impl.js.map +1 -1
  50. package/esm/node/settings-store.d.ts +9 -2
  51. package/esm/node/settings-store.js +26 -5
  52. package/esm/node/settings-store.js.map +1 -1
  53. package/esm/node/ta-server-impl.d.ts +2 -0
  54. package/esm/node/ta-server-impl.js +16 -4
  55. package/esm/node/ta-server-impl.js.map +1 -1
  56. package/esm/node/ta-session-factory.d.ts +19 -2
  57. package/esm/node/ta-session-factory.js +54 -11
  58. package/esm/node/ta-session-factory.js.map +1 -1
  59. package/esm/node/ta-session.d.ts +4 -0
  60. package/esm/node/ta-session.js +6 -1
  61. package/esm/node/ta-session.js.map +1 -1
  62. package/esm/node/terminal-service.d.ts +18 -2
  63. package/esm/node/terminal-service.js +46 -10
  64. package/esm/node/terminal-service.js.map +1 -1
  65. package/esm/node/terminal-util.d.ts +14 -0
  66. package/esm/node/terminal-util.js +30 -1
  67. package/esm/node/terminal-util.js.map +1 -1
  68. package/esm/node/web-extension-catalog.d.ts +3 -1
  69. package/esm/node/web-extension-catalog.js +8 -2
  70. package/esm/node/web-extension-catalog.js.map +1 -1
  71. package/esm/node/working-directory.d.ts +12 -1
  72. package/esm/node/working-directory.js +22 -1
  73. package/esm/node/working-directory.js.map +1 -1
  74. package/esm/node/workspace-files.d.ts +1 -1
  75. package/esm/node/workspace-files.js +3 -3
  76. package/esm/node/workspace-files.js.map +1 -1
  77. package/esm/node/workspace-protocol.d.ts +2 -0
  78. package/esm/node/workspace-server-impl.d.ts +2 -1
  79. package/esm/node/workspace-server-impl.js +13 -1
  80. package/esm/node/workspace-server-impl.js.map +1 -1
  81. package/esm/node/workspace-service.d.ts +1 -0
  82. package/esm/node/workspace-service.js +15 -3
  83. package/esm/node/workspace-service.js.map +1 -1
  84. package/lib/node/auth-server-impl.d.ts +2 -0
  85. package/lib/node/auth-server-impl.d.ts.map +1 -1
  86. package/lib/node/auth-server-impl.js +7 -0
  87. package/lib/node/auth-server-impl.js.map +1 -1
  88. package/lib/node/exec-environment-factory.d.ts +8 -4
  89. package/lib/node/exec-environment-factory.d.ts.map +1 -1
  90. package/lib/node/exec-environment-factory.js +28 -6
  91. package/lib/node/exec-environment-factory.js.map +1 -1
  92. package/lib/node/extension-providers.d.ts +23 -0
  93. package/lib/node/extension-providers.d.ts.map +1 -0
  94. package/lib/node/extension-providers.js +55 -0
  95. package/lib/node/extension-providers.js.map +1 -0
  96. package/lib/node/index.d.ts +3 -0
  97. package/lib/node/index.d.ts.map +1 -1
  98. package/lib/node/index.js +3 -0
  99. package/lib/node/index.js.map +1 -1
  100. package/lib/node/package-host-extension.d.ts +4 -2
  101. package/lib/node/package-host-extension.d.ts.map +1 -1
  102. package/lib/node/package-host-extension.js +4 -3
  103. package/lib/node/package-host-extension.js.map +1 -1
  104. package/lib/node/package-hosts.d.ts +6 -2
  105. package/lib/node/package-hosts.d.ts.map +1 -1
  106. package/lib/node/package-hosts.js +32 -0
  107. package/lib/node/package-hosts.js.map +1 -1
  108. package/lib/node/remote/index.d.ts +6 -0
  109. package/lib/node/remote/index.d.ts.map +1 -0
  110. package/lib/node/remote/index.js +22 -0
  111. package/lib/node/remote/index.js.map +1 -0
  112. package/lib/node/remote/pi-directories.d.ts +15 -0
  113. package/lib/node/remote/pi-directories.d.ts.map +1 -0
  114. package/lib/node/remote/pi-directories.js +67 -0
  115. package/lib/node/remote/pi-directories.js.map +1 -0
  116. package/lib/node/remote/port-forwards.d.ts +36 -0
  117. package/lib/node/remote/port-forwards.d.ts.map +1 -0
  118. package/lib/node/remote/port-forwards.js +153 -0
  119. package/lib/node/remote/port-forwards.js.map +1 -0
  120. package/lib/node/remote/remote-hosts.d.ts +41 -0
  121. package/lib/node/remote/remote-hosts.d.ts.map +1 -0
  122. package/lib/node/remote/remote-hosts.js +173 -0
  123. package/lib/node/remote/remote-hosts.js.map +1 -0
  124. package/lib/node/remote/remote-protocol.d.ts +52 -0
  125. package/lib/node/remote/remote-protocol.d.ts.map +1 -0
  126. package/lib/node/remote/remote-protocol.js +8 -0
  127. package/lib/node/remote/remote-protocol.js.map +1 -0
  128. package/lib/node/remote/remote-server-impl.d.ts +20 -0
  129. package/lib/node/remote/remote-server-impl.d.ts.map +1 -0
  130. package/lib/node/remote/remote-server-impl.js +69 -0
  131. package/lib/node/remote/remote-server-impl.js.map +1 -0
  132. package/lib/node/remote/remote.spec.d.ts +2 -0
  133. package/lib/node/remote/remote.spec.d.ts.map +1 -0
  134. package/lib/node/remote/remote.spec.js +130 -0
  135. package/lib/node/remote/remote.spec.js.map +1 -0
  136. package/lib/node/remote-ui-context.d.ts +6 -1
  137. package/lib/node/remote-ui-context.d.ts.map +1 -1
  138. package/lib/node/remote-ui-context.js +31 -3
  139. package/lib/node/remote-ui-context.js.map +1 -1
  140. package/lib/node/remote-ui-context.spec.js +23 -0
  141. package/lib/node/remote-ui-context.spec.js.map +1 -1
  142. package/lib/node/session-files.d.ts +19 -0
  143. package/lib/node/session-files.d.ts.map +1 -0
  144. package/lib/node/session-files.js +36 -0
  145. package/lib/node/session-files.js.map +1 -0
  146. package/lib/node/session-files.spec.d.ts +2 -0
  147. package/lib/node/session-files.spec.d.ts.map +1 -0
  148. package/lib/node/session-files.spec.js +51 -0
  149. package/lib/node/session-files.spec.js.map +1 -0
  150. package/lib/node/settings-server-impl.d.ts +1 -0
  151. package/lib/node/settings-server-impl.d.ts.map +1 -1
  152. package/lib/node/settings-server-impl.js +8 -0
  153. package/lib/node/settings-server-impl.js.map +1 -1
  154. package/lib/node/settings-store.d.ts +9 -2
  155. package/lib/node/settings-store.d.ts.map +1 -1
  156. package/lib/node/settings-store.js +26 -5
  157. package/lib/node/settings-store.js.map +1 -1
  158. package/lib/node/settings-store.spec.js +5 -2
  159. package/lib/node/settings-store.spec.js.map +1 -1
  160. package/lib/node/ta-server-impl.d.ts +2 -0
  161. package/lib/node/ta-server-impl.d.ts.map +1 -1
  162. package/lib/node/ta-server-impl.js +16 -4
  163. package/lib/node/ta-server-impl.js.map +1 -1
  164. package/lib/node/ta-session-factory.d.ts +19 -2
  165. package/lib/node/ta-session-factory.d.ts.map +1 -1
  166. package/lib/node/ta-session-factory.js +53 -10
  167. package/lib/node/ta-session-factory.js.map +1 -1
  168. package/lib/node/ta-session.d.ts +4 -0
  169. package/lib/node/ta-session.d.ts.map +1 -1
  170. package/lib/node/ta-session.js +6 -1
  171. package/lib/node/ta-session.js.map +1 -1
  172. package/lib/node/terminal-service.d.ts +18 -2
  173. package/lib/node/terminal-service.d.ts.map +1 -1
  174. package/lib/node/terminal-service.js +45 -9
  175. package/lib/node/terminal-service.js.map +1 -1
  176. package/lib/node/terminal-service.spec.js +31 -0
  177. package/lib/node/terminal-service.spec.js.map +1 -1
  178. package/lib/node/terminal-util.d.ts +14 -0
  179. package/lib/node/terminal-util.d.ts.map +1 -1
  180. package/lib/node/terminal-util.js +30 -1
  181. package/lib/node/terminal-util.js.map +1 -1
  182. package/lib/node/terminal-util.spec.js +24 -0
  183. package/lib/node/terminal-util.spec.js.map +1 -1
  184. package/lib/node/web-extension-catalog.d.ts +3 -1
  185. package/lib/node/web-extension-catalog.d.ts.map +1 -1
  186. package/lib/node/web-extension-catalog.js +7 -1
  187. package/lib/node/web-extension-catalog.js.map +1 -1
  188. package/lib/node/web-extension-catalog.spec.js +1 -1
  189. package/lib/node/web-extension-catalog.spec.js.map +1 -1
  190. package/lib/node/working-directory.d.ts +12 -1
  191. package/lib/node/working-directory.d.ts.map +1 -1
  192. package/lib/node/working-directory.js +22 -1
  193. package/lib/node/working-directory.js.map +1 -1
  194. package/lib/node/workspace-files.d.ts +1 -1
  195. package/lib/node/workspace-files.d.ts.map +1 -1
  196. package/lib/node/workspace-files.js +3 -3
  197. package/lib/node/workspace-files.js.map +1 -1
  198. package/lib/node/workspace-protocol.d.ts +2 -0
  199. package/lib/node/workspace-protocol.d.ts.map +1 -1
  200. package/lib/node/workspace-server-impl.d.ts +2 -1
  201. package/lib/node/workspace-server-impl.d.ts.map +1 -1
  202. package/lib/node/workspace-server-impl.js +12 -0
  203. package/lib/node/workspace-server-impl.js.map +1 -1
  204. package/lib/node/workspace-service.d.ts +1 -0
  205. package/lib/node/workspace-service.d.ts.map +1 -1
  206. package/lib/node/workspace-service.js +15 -3
  207. package/lib/node/workspace-service.js.map +1 -1
  208. package/lib/node/workspace-service.spec.js +9 -0
  209. package/lib/node/workspace-service.spec.js.map +1 -1
  210. package/package.json +14 -10
  211. package/src/node/auth-server-impl.ts +6 -0
  212. package/src/node/exec-environment-factory.ts +26 -6
  213. package/src/node/extension-providers.ts +49 -0
  214. package/src/node/index.ts +3 -0
  215. package/src/node/package-host-extension.ts +7 -4
  216. package/src/node/package-hosts.ts +32 -2
  217. package/src/node/remote/index.ts +5 -0
  218. package/src/node/remote/pi-directories.ts +49 -0
  219. package/src/node/remote/port-forwards.ts +148 -0
  220. package/src/node/remote/remote-hosts.ts +170 -0
  221. package/src/node/remote/remote-protocol.ts +57 -0
  222. package/src/node/remote/remote-server-impl.ts +60 -0
  223. package/src/node/remote/remote.spec.ts +142 -0
  224. package/src/node/remote-ui-context.spec.ts +25 -0
  225. package/src/node/remote-ui-context.ts +34 -5
  226. package/src/node/session-files.spec.ts +52 -0
  227. package/src/node/session-files.ts +41 -0
  228. package/src/node/settings-server-impl.ts +9 -0
  229. package/src/node/settings-store.spec.ts +5 -2
  230. package/src/node/settings-store.ts +25 -6
  231. package/src/node/ta-server-impl.ts +18 -4
  232. package/src/node/ta-session-factory.ts +56 -10
  233. package/src/node/ta-session.ts +9 -1
  234. package/src/node/terminal-service.spec.ts +35 -0
  235. package/src/node/terminal-service.ts +47 -15
  236. package/src/node/terminal-util.spec.ts +31 -0
  237. package/src/node/terminal-util.ts +32 -1
  238. package/src/node/web-extension-catalog.spec.ts +1 -1
  239. package/src/node/web-extension-catalog.ts +7 -2
  240. package/src/node/working-directory.ts +35 -2
  241. package/src/node/workspace-files.ts +3 -3
  242. package/src/node/workspace-protocol.ts +2 -0
  243. package/src/node/workspace-server-impl.ts +18 -0
  244. package/src/node/workspace-service.spec.ts +11 -1
  245. package/src/node/workspace-service.ts +15 -3
@@ -69,6 +69,15 @@ function workspace() {
69
69
  await (0, bun_test_1.expect)(workspace().writeFile(repo, 'src', 'a')).rejects.toThrow('cannot be written');
70
70
  await (0, bun_test_1.expect)(workspace().writeFile(repo, '../secret.txt', 'a')).rejects.toThrow('outside');
71
71
  });
72
+ (0, bun_test_1.it)('uploads bytes in parts, making the folders on the way', async () => {
73
+ await workspace().uploadFile(root, 'up/load/a.bin', new Uint8Array([0, 1, 2]), false);
74
+ await workspace().uploadFile(root, 'up/load/a.bin', new Uint8Array([3]), true);
75
+ (0, bun_test_1.expect)([...(0, node_fs_1.readFileSync)((0, node_path_1.join)(root, 'up/load/a.bin'))]).toEqual([0, 1, 2, 3]);
76
+ await workspace().uploadFile(root, 'up/load/a.bin', new Uint8Array([9]), false);
77
+ (0, bun_test_1.expect)([...(0, node_fs_1.readFileSync)((0, node_path_1.join)(root, 'up/load/a.bin'))]).toEqual([9]);
78
+ await (0, bun_test_1.expect)(workspace().uploadFile(root, 'up', new Uint8Array([1]), false)).rejects.toThrow('is a directory');
79
+ await (0, bun_test_1.expect)(workspace().uploadFile(root, '../out.bin', new Uint8Array([1]), false)).rejects.toThrow('outside');
80
+ });
72
81
  (0, bun_test_1.it)('reads the start of a large file', async () => {
73
82
  write((0, node_path_1.join)(root, 'big/large.txt'), 'x'.repeat(1024 * 1024 + 10));
74
83
  const content = await workspace().readFile((0, node_path_1.join)(root, 'big'), 'large.txt');
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-service.spec.js","sourceRoot":"","sources":["../../src/node/workspace-service.spec.ts"],"names":[],"mappings":";;AAAA,uCAAqE;AACrE,2DAA8C;AAC9C,qCAAsF;AACtF,qCAAiC;AACjC,yCAAiC;AACjC,6CAAuD;AACvD,2DAAyD;AAEzD,SAAS,KAAK,CAAC,IAAY,EAAE,OAA4B;IACrD,IAAA,mBAAS,EAAC,IAAA,gBAAI,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACjD,IAAA,uBAAa,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,SAAS;IACd,MAAM,OAAO,GAAG,IAAI,sCAAkB,EAAE,CAAC;IACzC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,8BAAoB,CAAC,GAAG,CAAC,EAAE,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAC5I,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,IAAA,mBAAQ,EAAC,oBAAoB,EAAE,GAAG,EAAE;IAChC,IAAI,IAAY,CAAC;IACjB,IAAI,IAAY,CAAC;IACjB,MAAM,GAAG,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,IAAA,6BAAQ,EAAC,wCAAwC,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IAE3H,IAAA,oBAAS,EAAC,GAAG,EAAE;QACX,IAAI,GAAG,IAAA,sBAAY,EAAC,IAAA,qBAAW,EAAC,IAAA,gBAAI,EAAC,IAAA,gBAAM,GAAE,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;QAClE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EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACjI,IAAA,iBAAM,EAAC,CAAC,MAAM,SAAS,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC/F,MAAM,IAAA,iBAAM,EAAC,SAAS,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-host",
3
- "version": "4.6.1",
3
+ "version": "4.8.0",
4
4
  "description": "ta serve: pi sessions for many clients over WebSocket",
5
5
  "keywords": [
6
6
  "cell-component"
@@ -33,15 +33,15 @@
33
33
  "watch": "tsc -b -w --preserveWatchOutput"
34
34
  },
35
35
  "dependencies": {
36
- "@celljs/ai-agent": "4.6.1",
37
- "@celljs/ai-coding-agent": "4.6.1",
38
- "@celljs/core": "4.6.1",
39
- "@celljs/rpc": "4.6.1",
40
- "@celljs/ta-exec": "4.6.1",
41
- "@celljs/ta-harness": "4.6.1",
42
- "@celljs/ta-protocol": "4.6.1",
43
- "@celljs/ta-relay": "4.6.1",
44
- "@celljs/web": "4.6.1",
36
+ "@celljs/ai-agent": "4.8.0",
37
+ "@celljs/ai-coding-agent": "4.8.0",
38
+ "@celljs/core": "4.8.0",
39
+ "@celljs/rpc": "4.8.0",
40
+ "@celljs/ta-exec": "4.8.0",
41
+ "@celljs/ta-harness": "4.8.0",
42
+ "@celljs/ta-protocol": "4.8.0",
43
+ "@celljs/ta-relay": "4.8.0",
44
+ "@celljs/web": "4.8.0",
45
45
  "@earendil-works/pi-coding-agent": "^1.5.0"
46
46
  },
47
47
  "devDependencies": {
@@ -70,6 +70,10 @@
70
70
  "import": "./esm/node/index.js",
71
71
  "default": "./lib/node/index.js"
72
72
  },
73
+ "./lib/node/remote": {
74
+ "import": "./esm/node/remote/index.js",
75
+ "default": "./lib/node/remote/index.js"
76
+ },
73
77
  "./lib/node/session-storage": {
74
78
  "import": "./esm/node/session-storage/index.js",
75
79
  "default": "./lib/node/session-storage/index.js"
@@ -4,6 +4,7 @@ import { Autowired, Value } from '@celljs/core';
4
4
  import { Rpc } from '@celljs/rpc';
5
5
  import { type RpcConnection, RpcContext } from '@celljs/rpc/lib/node';
6
6
  import { type TaAuthEvent, type TaAuthPrompt, type TaAuthProvider, TaAuthServer, type TaAuthType, TaClient } from '@celljs/ta-protocol';
7
+ import { ExtensionProviders } from './extension-providers';
7
8
  import { TaSessionRegistry } from './host-protocol';
8
9
  import { TaErrors } from './ta-errors';
9
10
 
@@ -130,6 +131,9 @@ export class TaAuthServerImpl implements TaAuthServer {
130
131
  @Autowired(TaSessionRegistry)
131
132
  protected readonly sessions: TaSessionRegistry;
132
133
 
134
+ @Autowired(ExtensionProviders)
135
+ protected readonly extensionProviders: ExtensionProviders;
136
+
133
137
  @Value(CODING_AGENT_OPTIONS)
134
138
  protected readonly codingAgentOptions?: CodingAgentOptions;
135
139
 
@@ -139,6 +143,8 @@ export class TaAuthServerImpl implements TaAuthServer {
139
143
  listProviders(): Promise<TaAuthProvider[]> {
140
144
  return TaErrors.guard(async () => {
141
145
  const runtime = await this.modelRuntimeProvider.provide();
146
+ // Those of pi packages count, as in a session: an agent of ta-agents needs no sign-in here.
147
+ await this.extensionProviders.ensure();
142
148
  const stored = new Set((await runtime.listCredentials()).map(credential => credential.providerId));
143
149
  return AuthServerUtil.providers(runtime, stored);
144
150
  });
@@ -1,12 +1,16 @@
1
1
  import { Autowired, Component, Optional, Value } from '@celljs/core';
2
2
  import { ExecClient, type ExecEnvironment, ExecEnvironmentFactory, LocalExecEnvironment, RemoteExecEnvironment } from '@celljs/ta-exec';
3
+ import { TaLocation } from '@celljs/ta-protocol';
3
4
  import { TA_EXEC_OPTIONS, type TaExecOptions } from './host-protocol';
5
+ import { RemoteHosts } from './remote/remote-protocol';
6
+ import { TaErrors } from './ta-errors';
4
7
  import { TaWorkingDirectory } from './working-directory';
5
8
 
6
9
  /**
7
- * Sessions run on this machine, or, with `ta.exec.url`, on the machine of a `ta exec-server`: the
8
- * agent loop stays here, commands and files are there. All sessions share one connection. The default
9
- * directory is the one the user chose (TaWorkingDirectory), if any.
10
+ * Where a location runs. `ssh://<host>/<path>`: on that host, through ssh (RemoteHosts). A path: on this
11
+ * machine, or with `ta.exec.url` on the machine of a `ta exec-server`, all sessions on one connection.
12
+ * The agent loop stays here; commands and files are there. The default directory is the one the user
13
+ * chose (TaWorkingDirectory), if any.
10
14
  */
11
15
  @Component(ExecEnvironmentFactory)
12
16
  export class DefaultExecEnvironmentFactory implements ExecEnvironmentFactory {
@@ -17,11 +21,27 @@ export class DefaultExecEnvironmentFactory implements ExecEnvironmentFactory {
17
21
  @Optional()
18
22
  protected readonly workingDirectory?: TaWorkingDirectory;
19
23
 
24
+ @Autowired(RemoteHosts)
25
+ protected readonly remoteHosts: RemoteHosts;
26
+
20
27
  protected client?: ExecClient;
21
28
 
22
- create(cwd: string): ExecEnvironment {
29
+ /** Its `cwd` is the path there: the one to resolve paths against, not the location. */
30
+ create(location: string): ExecEnvironment {
31
+ let remote: TaLocation.Remote | undefined;
32
+ try {
33
+ remote = TaLocation.parse(location);
34
+ } catch (error) {
35
+ throw TaErrors.invalidArgument((error as Error).message, 'Write ssh://<host>/<absolute path>.');
36
+ }
37
+ if (remote) {
38
+ if (!remote.path) {
39
+ throw TaErrors.invalidArgument(`${location} names no directory.`, 'Resolve it first (TaRemoteServer.resolveLocation), or write its path.');
40
+ }
41
+ return new RemoteExecEnvironment(this.remoteHosts.client(remote.host), remote.path);
42
+ }
23
43
  const client = this.remote();
24
- return client ? new RemoteExecEnvironment(client, cwd) : new LocalExecEnvironment(cwd);
44
+ return client ? new RemoteExecEnvironment(client, location) : new LocalExecEnvironment(location);
25
45
  }
26
46
 
27
47
  /** The working directory the user chose, else that of this process, or of the exec server. */
@@ -40,7 +60,7 @@ export class DefaultExecEnvironmentFactory implements ExecEnvironmentFactory {
40
60
  return undefined;
41
61
  }
42
62
  // A host started later fences the ones before it.
43
- this.client ??= new ExecClient({ url, token, epoch: epoch || Date.now() });
63
+ this.client ??= new ExecClient({ connect: ExecClient.webSocket(url, token), epoch: epoch || Date.now() });
44
64
  return this.client;
45
65
  }
46
66
  }
@@ -0,0 +1,49 @@
1
+ import { homedir } from 'node:os';
2
+ import { CODING_AGENT_OPTIONS, type CodingAgentOptions, ModelRuntimeProvider, PiSdkUtil } from '@celljs/ai-coding-agent';
3
+ import { Autowired, Component, Value } from '@celljs/core';
4
+ import { TaPackages } from '@celljs/ta-harness';
5
+
6
+ export const ExtensionProviders = Symbol('ExtensionProviders');
7
+
8
+ /**
9
+ * The model providers that pi packages register (`pi.registerProvider`), before any session: pi registers
10
+ * them in the model runtime that the sessions of ta serve share when it loads a session's extensions, so
11
+ * until a session opened, a client would see none of them (no sign-in, no model to pick).
12
+ */
13
+ export interface ExtensionProviders {
14
+ /** Loads the extensions of the user once, for the providers they register; later calls wait for that. */
15
+ ensure(): Promise<void>;
16
+ }
17
+
18
+ @Component(ExtensionProviders)
19
+ export class ExtensionProvidersImpl implements ExtensionProviders {
20
+ @Value(CODING_AGENT_OPTIONS)
21
+ protected readonly codingAgentOptions?: CodingAgentOptions;
22
+
23
+ @Autowired(ModelRuntimeProvider)
24
+ protected readonly modelRuntimeProvider: ModelRuntimeProvider;
25
+
26
+ protected loading?: Promise<void>;
27
+
28
+ ensure(): Promise<void> {
29
+ this.loading ??= this.load().catch(() => undefined);
30
+ return this.loading;
31
+ }
32
+
33
+ /**
34
+ * pi's services of a directory without a project (the home directory, its project resources not
35
+ * trusted): the built-in packages and those of the user's settings, as a session loads them.
36
+ */
37
+ protected async load(): Promise<void> {
38
+ const sdk = await PiSdkUtil.load();
39
+ const agentDir = this.codingAgentOptions?.agentDir ?? sdk.getAgentDir();
40
+ const cwd = homedir();
41
+ await sdk.createAgentSessionServices({
42
+ cwd,
43
+ agentDir,
44
+ settingsManager: sdk.SettingsManager.create(cwd, agentDir, { projectTrusted: false }),
45
+ modelRuntime: await this.modelRuntimeProvider.provide(),
46
+ resourceLoaderOptions: TaPackages.loaderOptions(agentDir),
47
+ });
48
+ }
49
+ }
package/src/node/index.ts CHANGED
@@ -5,13 +5,16 @@ export * from './event-log';
5
5
  export * from './exec-environment-factory';
6
6
  export * from './extension-data';
7
7
  export * from './extension-data-notifier';
8
+ export * from './extension-providers';
8
9
  export * from './host-protocol';
9
10
  export * from './package-host-extension';
10
11
  export * from './package-hosts';
11
12
  export * from './package-server-impl';
12
13
  export * from './receipt-book';
13
14
  export * from './relay-bridge';
15
+ export * from './remote';
14
16
  export * from './remote-ui-context';
17
+ export * from './session-files';
15
18
  export * from './session-info-util';
16
19
  export * from './session-storage';
17
20
  export * from './settings-server-impl';
@@ -1,19 +1,22 @@
1
1
  import type { ExtensionAPI, TaExtension } from '@celljs/ta-harness';
2
- import { TA_HOST_EVENT, type TaHostRequest } from '@celljs/ta-protocol';
2
+ import { TA_HOST_EVENT, type TaHostRequest, type TaSessionFiles } from '@celljs/ta-protocol';
3
3
  import type { PackageHosts } from './package-hosts';
4
4
 
5
- /** Answers the pi extensions of a session that ask for the host of their package (TA_HOST_EVENT). */
5
+ /** Answers the pi extensions of a session that ask for the host of their package (TA_HOST_EVENT), with the session's files. */
6
6
  export class PackageHostExtension implements TaExtension {
7
7
  readonly name = 'ta-package-host';
8
8
 
9
- constructor(protected readonly hosts: PackageHosts) {}
9
+ constructor(
10
+ protected readonly hosts: PackageHosts,
11
+ protected readonly files: TaSessionFiles,
12
+ ) {}
10
13
 
11
14
  register(pi: ExtensionAPI): void {
12
15
  pi.events.on(TA_HOST_EVENT, data => {
13
16
  const request = data as Partial<TaHostRequest> | undefined;
14
17
  if (typeof request?.name === 'string' && typeof request.resolve === 'function') {
15
18
  const resolve = request.resolve;
16
- void this.hosts.answer(request.name).then(answer => resolve(answer));
19
+ void this.hosts.answer(request.name).then(answer => resolve({ ...answer, files: this.files }));
17
20
  }
18
21
  });
19
22
  }
@@ -1,4 +1,5 @@
1
1
  import { readFileSync } from 'node:fs';
2
+ import { open } from 'node:fs/promises';
2
3
  import { join, relative, resolve, sep } from 'node:path';
3
4
  import { pathToFileURL } from 'node:url';
4
5
  import { CODING_AGENT_OPTIONS, type CodingAgentOptions } from '@celljs/ai-coding-agent';
@@ -7,6 +8,7 @@ import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
7
8
  import { TaPackages } from '@celljs/ta-harness/lib/node/ta-packages';
8
9
  import { type TaExtensionHost, type TaHostAnswer, type TaPackageHostFactory, TaPackageServer, type TaPackageService, TaServer } from '@celljs/ta-protocol';
9
10
  import { ExtensionDataStore } from './extension-data';
11
+ import { PiDirectories } from './remote/remote-protocol';
10
12
  import { TaErrors } from './ta-errors';
11
13
 
12
14
  export const PackageHosts = Symbol('PackageHosts');
@@ -21,12 +23,31 @@ export interface PackageHosts {
21
23
  /** Starts the hosts of the packages that are on and stops those turned off. */
22
24
  sync(): Promise<void>;
23
25
  /** For a pi extension of the package `name`. */
24
- answer(name: string): Promise<TaHostAnswer>;
26
+ answer(name: string): Promise<Omit<TaHostAnswer, 'files'>>;
25
27
  /** A method of what the host of the package `name` returned, for its web extension (TaPackageServer.callPackageHost). */
26
28
  call(name: string, method: string, params: unknown[]): Promise<unknown>;
27
29
  }
28
30
 
29
31
  export namespace PackageHostUtil {
32
+ /** The bytes of a session file that hold its header, its first line. */
33
+ const HEADER_BYTES = 16384;
34
+
35
+ /** The `cwd` of the header of a pi session file; undefined when it has none. */
36
+ export async function sessionCwd(file: string): Promise<string | undefined> {
37
+ let handle: Awaited<ReturnType<typeof open>> | undefined;
38
+ try {
39
+ handle = await open(file, 'r');
40
+ const buffer = Buffer.alloc(HEADER_BYTES);
41
+ const { bytesRead } = await handle.read(buffer, 0, HEADER_BYTES, 0);
42
+ const header = JSON.parse(buffer.subarray(0, bytesRead).toString('utf8').split('\n')[0]);
43
+ return header?.type === 'session' && typeof header.cwd === 'string' ? header.cwd : undefined;
44
+ } catch {
45
+ return undefined;
46
+ } finally {
47
+ await handle?.close();
48
+ }
49
+ }
50
+
30
51
  /** The file of `pi.host`, inside the package; undefined when it has none. */
31
52
  export function entry(root: string): string | undefined {
32
53
  let host: unknown;
@@ -50,6 +71,9 @@ interface Running {
50
71
 
51
72
  @Component([PackageHosts, ApplicationLifecycle])
52
73
  export class PackageHostsImpl implements PackageHosts, ApplicationLifecycle<Application> {
74
+ @Autowired(PiDirectories)
75
+ protected readonly directories: PiDirectories;
76
+
53
77
  @Value(CODING_AGENT_OPTIONS)
54
78
  protected readonly codingAgentOptions?: CodingAgentOptions;
55
79
 
@@ -92,7 +116,7 @@ export class PackageHostsImpl implements PackageHosts, ApplicationLifecycle<Appl
92
116
  );
93
117
  }
94
118
 
95
- async answer(name: string): Promise<TaHostAnswer> {
119
+ async answer(name: string): Promise<Omit<TaHostAnswer, 'files'>> {
96
120
  return { host: this.host(), service: await this.running.get(name)?.service };
97
121
  }
98
122
 
@@ -151,13 +175,19 @@ export class PackageHostsImpl implements PackageHosts, ApplicationLifecycle<Appl
151
175
  const packages = this.packages;
152
176
  this.extensionHost = {
153
177
  agentDir: this.agentDir(),
178
+ sessionCwd: async file => {
179
+ const cwd = await PackageHostUtil.sessionCwd(file);
180
+ return cwd === undefined ? undefined : this.directories.fromPi(cwd);
181
+ },
154
182
  listPackages: cwd => packages.listPackages(cwd),
155
183
  getServerInfo: () => server.getServerInfo(),
156
184
  listSessions: () => server.listSessions(),
157
185
  openSession: options => server.openSession(options),
186
+ closeSession: sessionId => server.closeSession(sessionId),
158
187
  setSessionName: (sessionId, name) => server.setSessionName(sessionId, name),
159
188
  prompt: (sessionId, input) => server.prompt(sessionId, input),
160
189
  followUp: (sessionId, input) => server.followUp(sessionId, input),
190
+ abort: sessionId => server.abort(sessionId),
161
191
  getState: sessionId => server.getState(sessionId),
162
192
  getLastAssistantText: sessionId => server.getLastAssistantText(sessionId),
163
193
  getExtensionData: (name, key, cwd) => packages.getExtensionData(name, key, cwd),
@@ -0,0 +1,5 @@
1
+ export * from './pi-directories';
2
+ export * from './port-forwards';
3
+ export * from './remote-hosts';
4
+ export * from './remote-protocol';
5
+ export * from './remote-server-impl';
@@ -0,0 +1,49 @@
1
+ import { mkdirSync } from 'node:fs';
2
+ import { join, sep } from 'node:path';
3
+ import { CODING_AGENT_OPTIONS, type CodingAgentOptions } from '@celljs/ai-coding-agent';
4
+ import { Component, Value } from '@celljs/core';
5
+ import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
6
+ import { TaLocation } from '@celljs/ta-protocol';
7
+ import { TA_EXEC_OPTIONS, type TaExecOptions } from '../host-protocol';
8
+ import { PiDirectories } from './remote-protocol';
9
+
10
+ /**
11
+ * `<agent directory>/remote/ssh/<host>/<path>` for `ssh://<host>/<path>`. With `ta.exec.url` every
12
+ * directory is one of the machine of the exec server: `<agent directory>/remote/exec/<path>`.
13
+ */
14
+ @Component(PiDirectories)
15
+ export class DefaultPiDirectories implements PiDirectories {
16
+ @Value(CODING_AGENT_OPTIONS)
17
+ protected readonly codingAgentOptions?: CodingAgentOptions;
18
+
19
+ @Value(TA_EXEC_OPTIONS)
20
+ protected readonly execOptions?: TaExecOptions;
21
+
22
+ toPi(location: string): string {
23
+ const remote = TaLocation.parse(location);
24
+ const prefix = remote ? join('ssh', remote.host) : this.execOptions?.url ? 'exec' : undefined;
25
+ if (!prefix) {
26
+ return location;
27
+ }
28
+ const path = remote ? remote.path : location;
29
+ const cwd = join(this.root(), prefix, ...path.split('/').filter(Boolean));
30
+ mkdirSync(cwd, { recursive: true });
31
+ return cwd;
32
+ }
33
+
34
+ fromPi(cwd: string): string {
35
+ const root = this.root() + sep;
36
+ if (!cwd.startsWith(root)) {
37
+ return cwd;
38
+ }
39
+ const [kind, ...rest] = cwd.slice(root.length).split(sep);
40
+ if (kind === 'ssh' && rest.length > 0 && TaLocation.isHost(rest[0])) {
41
+ return TaLocation.ssh(rest[0], `/${rest.slice(1).join('/')}`);
42
+ }
43
+ return kind === 'exec' ? `/${rest.join('/')}` : cwd;
44
+ }
45
+
46
+ protected root(): string {
47
+ return join(this.codingAgentOptions?.agentDir ?? TaBrand.agentDir(), 'remote');
48
+ }
49
+ }
@@ -0,0 +1,148 @@
1
+ import { createServer, type Server, type Socket } from 'node:net';
2
+ import { type Application, ApplicationLifecycle, Autowired, Component } from '@celljs/core';
3
+ import { type ExecEnvironment, ExecEnvironmentFactory, type ExecSocket } from '@celljs/ta-exec';
4
+ import { type TaForwardedPort, TaLocation } from '@celljs/ta-protocol';
5
+ import { TaErrors } from '../ta-errors';
6
+ import { PortForwards, RemoteHosts } from './remote-protocol';
7
+
8
+ interface Forward {
9
+ info: TaForwardedPort;
10
+ server: Server;
11
+ sockets: Set<Socket>;
12
+ }
13
+
14
+ /**
15
+ * A port of another machine as a port of 127.0.0.1 here: each connection to it is one from the server
16
+ * of Ta there (ExecEnvironment.connect). The same number when it is free here, as VS Code does, so that
17
+ * the pages of a dev server keep their links.
18
+ */
19
+ @Component([PortForwards, ApplicationLifecycle])
20
+ export class DefaultPortForwards implements PortForwards, ApplicationLifecycle<Application> {
21
+ @Autowired(ExecEnvironmentFactory)
22
+ protected readonly environments: ExecEnvironmentFactory;
23
+
24
+ @Autowired(RemoteHosts)
25
+ protected readonly hosts: RemoteHosts;
26
+
27
+ protected readonly forwards = new Map<string, Promise<Forward>>();
28
+ /** Those open. */
29
+ protected readonly open = new Map<string, TaForwardedPort>();
30
+ protected watching = false;
31
+
32
+ async forward(cwd: string, port: number): Promise<TaForwardedPort> {
33
+ if (!Number.isInteger(port) || port < 1 || port > 65535) {
34
+ throw TaErrors.invalidArgument(`${port} is not a port.`, 'Pass a port from 1 to 65535.');
35
+ }
36
+ const env = this.environments.create(cwd);
37
+ const host = TaLocation.host(cwd) ?? '';
38
+ if (!env.connect) {
39
+ return { host, remotePort: port, localPort: port };
40
+ }
41
+ this.watch();
42
+ const key = `${host}:${port}`;
43
+ let forward = this.forwards.get(key);
44
+ if (!forward) {
45
+ forward = this.listenFor(env, host, port);
46
+ this.forwards.set(key, forward);
47
+ forward.then(
48
+ ({ info }) => this.forwards.has(key) && this.open.set(key, info),
49
+ () => this.forwards.delete(key),
50
+ );
51
+ }
52
+ return (await forward).info;
53
+ }
54
+
55
+ list(): TaForwardedPort[] {
56
+ return [...this.open.values()];
57
+ }
58
+
59
+ async close(host: string, remotePort: number): Promise<void> {
60
+ const key = `${host}:${remotePort}`;
61
+ const forward = await this.forwards.get(key)?.catch(() => undefined);
62
+ this.forwards.delete(key);
63
+ this.open.delete(key);
64
+ if (forward) {
65
+ for (const socket of forward.sockets) {
66
+ socket.destroy();
67
+ }
68
+ await new Promise<void>(resolve => forward.server.close(() => resolve()));
69
+ }
70
+ }
71
+
72
+ async onStop(): Promise<void> {
73
+ await Promise.all([...this.forwards.keys()].map(key => this.close(...this.split(key))));
74
+ }
75
+
76
+ protected async listenFor(env: ExecEnvironment, host: string, port: number): Promise<Forward> {
77
+ const sockets = new Set<Socket>();
78
+ const server = createServer(socket => {
79
+ sockets.add(socket);
80
+ socket.once('close', () => sockets.delete(socket));
81
+ void this.pipe(env, port, socket);
82
+ });
83
+ const localPort = await this.listen(server, port).catch(() => this.listen(server, 0));
84
+ return { info: { host, remotePort: port, localPort }, server, sockets };
85
+ }
86
+
87
+ protected listen(server: Server, port: number): Promise<number> {
88
+ return new Promise((resolve, reject) => {
89
+ const failed = (error: Error) => reject(error);
90
+ server.once('error', failed);
91
+ server.listen(port, '127.0.0.1', () => {
92
+ server.removeListener('error', failed);
93
+ resolve((server.address() as { port: number }).port);
94
+ });
95
+ });
96
+ }
97
+
98
+ /** One connection: data both ways until either side ends it. */
99
+ protected async pipe(env: ExecEnvironment, port: number, socket: Socket): Promise<void> {
100
+ // What comes before the other end is there waits for it.
101
+ const early: Buffer[] = [];
102
+ let ended = false;
103
+ let remote: ExecSocket | undefined;
104
+ const end = () => {
105
+ if (remote) {
106
+ remote.end();
107
+ } else {
108
+ ended = true;
109
+ }
110
+ };
111
+ socket.on('data', data => (remote ? remote.write(data) : early.push(data)));
112
+ socket.once('end', end);
113
+ socket.once('error', end);
114
+ try {
115
+ remote = await (env.connect as NonNullable<ExecEnvironment['connect']>)(port);
116
+ } catch {
117
+ socket.destroy();
118
+ return;
119
+ }
120
+ remote.onData(data => socket.write(data));
121
+ remote.onClose(() => socket.end());
122
+ for (const data of early) {
123
+ remote.write(data);
124
+ }
125
+ if (ended) {
126
+ remote.end();
127
+ }
128
+ }
129
+
130
+ /** A host disconnected on purpose takes its ports with it. */
131
+ protected watch(): void {
132
+ if (!this.watching) {
133
+ this.watching = true;
134
+ this.hosts.onDisconnect(host => {
135
+ for (const key of [...this.forwards.keys()]) {
136
+ if (key.startsWith(`${host}:`)) {
137
+ void this.close(...this.split(key));
138
+ }
139
+ }
140
+ });
141
+ }
142
+ }
143
+
144
+ protected split(key: string): [string, number] {
145
+ const at = key.lastIndexOf(':');
146
+ return [key.slice(0, at), Number(key.slice(at + 1))];
147
+ }
148
+ }