@multiplayer-app/agent 0.1.20 → 0.1.22

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 (298) hide show
  1. package/README.md +14 -7
  2. package/dist/agent/definition.test.js +8 -3
  3. package/dist/agent/definition.test.js.map +1 -1
  4. package/dist/agent/profiles/coding.d.ts +1 -1
  5. package/dist/agent/profiles/coding.d.ts.map +1 -1
  6. package/dist/agent/profiles/coding.js +21 -4
  7. package/dist/agent/profiles/coding.js.map +1 -1
  8. package/dist/agent/profiles/index.js +1 -1
  9. package/dist/agent/profiles/index.js.map +1 -1
  10. package/dist/agent/profiles/research.d.ts.map +1 -1
  11. package/dist/agent/profiles/research.js +2 -2
  12. package/dist/agent/profiles/research.js.map +1 -1
  13. package/dist/agent/turn-history.d.ts.map +1 -1
  14. package/dist/agent/turn-history.js +7 -1
  15. package/dist/agent/turn-history.js.map +1 -1
  16. package/dist/agent/turn-runner.d.ts +8 -0
  17. package/dist/agent/turn-runner.d.ts.map +1 -1
  18. package/dist/agent/turn-runner.js +35 -10
  19. package/dist/agent/turn-runner.js.map +1 -1
  20. package/dist/app/app-host.d.ts +57 -0
  21. package/dist/app/app-host.d.ts.map +1 -0
  22. package/dist/app/app-host.js +252 -0
  23. package/dist/app/app-host.js.map +1 -0
  24. package/dist/app/app-host.test.d.ts +2 -0
  25. package/dist/app/app-host.test.d.ts.map +1 -0
  26. package/dist/app/app-host.test.js +639 -0
  27. package/dist/app/app-host.test.js.map +1 -0
  28. package/dist/app/build-log.d.ts +14 -0
  29. package/dist/app/build-log.d.ts.map +1 -0
  30. package/dist/app/build-log.js +173 -0
  31. package/dist/app/build-log.js.map +1 -0
  32. package/dist/app/build-log.test.d.ts +2 -0
  33. package/dist/app/build-log.test.d.ts.map +1 -0
  34. package/dist/app/build-log.test.js +255 -0
  35. package/dist/app/build-log.test.js.map +1 -0
  36. package/dist/app/config.d.ts +196 -0
  37. package/dist/app/config.d.ts.map +1 -0
  38. package/dist/app/config.js +362 -0
  39. package/dist/app/config.js.map +1 -0
  40. package/dist/app/config.test.d.ts +2 -0
  41. package/dist/app/config.test.d.ts.map +1 -0
  42. package/dist/app/config.test.js +224 -0
  43. package/dist/app/config.test.js.map +1 -0
  44. package/dist/app/detect.d.ts +68 -0
  45. package/dist/app/detect.d.ts.map +1 -0
  46. package/dist/app/detect.js +449 -0
  47. package/dist/app/detect.js.map +1 -0
  48. package/dist/app/detect.test.d.ts +2 -0
  49. package/dist/app/detect.test.d.ts.map +1 -0
  50. package/dist/app/detect.test.js +267 -0
  51. package/dist/app/detect.test.js.map +1 -0
  52. package/dist/app/env.d.ts +5 -0
  53. package/dist/app/env.d.ts.map +1 -0
  54. package/dist/app/env.js +22 -0
  55. package/dist/app/env.js.map +1 -0
  56. package/dist/app/functions-cli.d.ts +3 -0
  57. package/dist/app/functions-cli.d.ts.map +1 -0
  58. package/dist/app/functions-cli.js +27 -0
  59. package/dist/app/functions-cli.js.map +1 -0
  60. package/dist/app/functions-host.d.ts +15 -0
  61. package/dist/app/functions-host.d.ts.map +1 -0
  62. package/dist/app/functions-host.js +276 -0
  63. package/dist/app/functions-host.js.map +1 -0
  64. package/dist/app/functions-host.test.d.ts +2 -0
  65. package/dist/app/functions-host.test.d.ts.map +1 -0
  66. package/dist/app/functions-host.test.js +117 -0
  67. package/dist/app/functions-host.test.js.map +1 -0
  68. package/dist/app/functions-routes.d.ts +23 -0
  69. package/dist/app/functions-routes.d.ts.map +1 -0
  70. package/dist/app/functions-routes.js +85 -0
  71. package/dist/app/functions-routes.js.map +1 -0
  72. package/dist/app/functions-routes.test.d.ts +2 -0
  73. package/dist/app/functions-routes.test.d.ts.map +1 -0
  74. package/dist/app/functions-routes.test.js +40 -0
  75. package/dist/app/functions-routes.test.js.map +1 -0
  76. package/dist/app/manifest.d.ts +17 -0
  77. package/dist/app/manifest.d.ts.map +1 -0
  78. package/dist/app/manifest.js +64 -0
  79. package/dist/app/manifest.js.map +1 -0
  80. package/dist/app/manifest.test.d.ts +2 -0
  81. package/dist/app/manifest.test.d.ts.map +1 -0
  82. package/dist/app/manifest.test.js +173 -0
  83. package/dist/app/manifest.test.js.map +1 -0
  84. package/dist/app/release-artifacts.d.ts +43 -0
  85. package/dist/app/release-artifacts.d.ts.map +1 -0
  86. package/dist/app/release-artifacts.js +239 -0
  87. package/dist/app/release-artifacts.js.map +1 -0
  88. package/dist/app/release-artifacts.test.d.ts +2 -0
  89. package/dist/app/release-artifacts.test.d.ts.map +1 -0
  90. package/dist/app/release-artifacts.test.js +326 -0
  91. package/dist/app/release-artifacts.test.js.map +1 -0
  92. package/dist/app/route-pattern.d.ts +23 -0
  93. package/dist/app/route-pattern.d.ts.map +1 -0
  94. package/dist/app/route-pattern.js +339 -0
  95. package/dist/app/route-pattern.js.map +1 -0
  96. package/dist/app/route-pattern.test.d.ts +2 -0
  97. package/dist/app/route-pattern.test.d.ts.map +1 -0
  98. package/dist/app/route-pattern.test.js +187 -0
  99. package/dist/app/route-pattern.test.js.map +1 -0
  100. package/dist/app/rules.d.ts +61 -0
  101. package/dist/app/rules.d.ts.map +1 -0
  102. package/dist/app/rules.js +90 -0
  103. package/dist/app/rules.js.map +1 -0
  104. package/dist/app/rules.test.d.ts +2 -0
  105. package/dist/app/rules.test.d.ts.map +1 -0
  106. package/dist/app/rules.test.js +69 -0
  107. package/dist/app/rules.test.js.map +1 -0
  108. package/dist/app/runner.d.ts +109 -0
  109. package/dist/app/runner.d.ts.map +1 -0
  110. package/dist/app/runner.js +429 -0
  111. package/dist/app/runner.js.map +1 -0
  112. package/dist/app/site.d.ts +73 -0
  113. package/dist/app/site.d.ts.map +1 -0
  114. package/dist/app/site.js +161 -0
  115. package/dist/app/site.js.map +1 -0
  116. package/dist/app/site.test.d.ts +2 -0
  117. package/dist/app/site.test.d.ts.map +1 -0
  118. package/dist/app/site.test.js +291 -0
  119. package/dist/app/site.test.js.map +1 -0
  120. package/dist/app/static-server.d.ts +20 -0
  121. package/dist/app/static-server.d.ts.map +1 -0
  122. package/dist/app/static-server.js +145 -0
  123. package/dist/app/static-server.js.map +1 -0
  124. package/dist/persistence/conversation-store.d.ts +21 -0
  125. package/dist/persistence/conversation-store.d.ts.map +1 -0
  126. package/dist/persistence/conversation-store.js +59 -0
  127. package/dist/persistence/conversation-store.js.map +1 -0
  128. package/dist/persistence/conversation-store.test.d.ts +2 -0
  129. package/dist/persistence/conversation-store.test.d.ts.map +1 -0
  130. package/dist/persistence/conversation-store.test.js +98 -0
  131. package/dist/persistence/conversation-store.test.js.map +1 -0
  132. package/dist/persistence/git-sync.d.ts +14 -1
  133. package/dist/persistence/git-sync.d.ts.map +1 -1
  134. package/dist/persistence/git-sync.js +73 -17
  135. package/dist/persistence/git-sync.js.map +1 -1
  136. package/dist/persistence/git-sync.test.js +155 -6
  137. package/dist/persistence/git-sync.test.js.map +1 -1
  138. package/dist/persistence/snapshot-sync.d.ts +19 -2
  139. package/dist/persistence/snapshot-sync.d.ts.map +1 -1
  140. package/dist/persistence/snapshot-sync.js +194 -83
  141. package/dist/persistence/snapshot-sync.js.map +1 -1
  142. package/dist/persistence/snapshot-sync.test.js +145 -27
  143. package/dist/persistence/snapshot-sync.test.js.map +1 -1
  144. package/dist/persistence/workspace.d.ts +3 -0
  145. package/dist/persistence/workspace.d.ts.map +1 -1
  146. package/dist/persistence/workspace.js +1 -0
  147. package/dist/persistence/workspace.js.map +1 -1
  148. package/dist/research/extract-texts.d.ts.map +1 -1
  149. package/dist/research/extract-texts.js +6 -13
  150. package/dist/research/extract-texts.js.map +1 -1
  151. package/dist/research/filingramp/attachment-tools.d.ts.map +1 -1
  152. package/dist/research/filingramp/attachment-tools.js +7 -4
  153. package/dist/research/filingramp/attachment-tools.js.map +1 -1
  154. package/dist/research/filingramp/shared.d.ts.map +1 -1
  155. package/dist/research/filingramp/shared.js +5 -5
  156. package/dist/research/filingramp/shared.js.map +1 -1
  157. package/dist/runtime/app-mode.d.ts +10 -0
  158. package/dist/runtime/app-mode.d.ts.map +1 -0
  159. package/dist/runtime/app-mode.js +172 -0
  160. package/dist/runtime/app-mode.js.map +1 -0
  161. package/dist/runtime/app-mode.test.d.ts +2 -0
  162. package/dist/runtime/app-mode.test.d.ts.map +1 -0
  163. package/dist/runtime/app-mode.test.js +130 -0
  164. package/dist/runtime/app-mode.test.js.map +1 -0
  165. package/dist/runtime/app-rehearsal.d.ts +2 -0
  166. package/dist/runtime/app-rehearsal.d.ts.map +1 -0
  167. package/dist/runtime/app-rehearsal.js +56 -0
  168. package/dist/runtime/app-rehearsal.js.map +1 -0
  169. package/dist/runtime/build-mode.d.ts +18 -0
  170. package/dist/runtime/build-mode.d.ts.map +1 -0
  171. package/dist/runtime/build-mode.js +108 -0
  172. package/dist/runtime/build-mode.js.map +1 -0
  173. package/dist/runtime/build-mode.test.d.ts +2 -0
  174. package/dist/runtime/build-mode.test.d.ts.map +1 -0
  175. package/dist/runtime/build-mode.test.js +159 -0
  176. package/dist/runtime/build-mode.test.js.map +1 -0
  177. package/dist/runtime/cli.js +7 -2
  178. package/dist/runtime/cli.js.map +1 -1
  179. package/dist/runtime/config.d.ts +4 -0
  180. package/dist/runtime/config.d.ts.map +1 -1
  181. package/dist/runtime/config.js +13 -2
  182. package/dist/runtime/config.js.map +1 -1
  183. package/dist/runtime/guest-server.d.ts +3 -0
  184. package/dist/runtime/guest-server.d.ts.map +1 -0
  185. package/dist/runtime/{lambda-microvm.js → guest-server.js} +49 -18
  186. package/dist/runtime/guest-server.js.map +1 -0
  187. package/dist/runtime/image-hooks.d.ts +5 -0
  188. package/dist/runtime/image-hooks.d.ts.map +1 -0
  189. package/dist/runtime/image-hooks.js +68 -0
  190. package/dist/runtime/image-hooks.js.map +1 -0
  191. package/dist/runtime/image-hooks.test.d.ts +2 -0
  192. package/dist/runtime/image-hooks.test.d.ts.map +1 -0
  193. package/dist/runtime/image-hooks.test.js +74 -0
  194. package/dist/runtime/image-hooks.test.js.map +1 -0
  195. package/dist/runtime/index.d.ts +8 -3
  196. package/dist/runtime/index.d.ts.map +1 -1
  197. package/dist/runtime/index.js +53 -35
  198. package/dist/runtime/index.js.map +1 -1
  199. package/dist/runtime/listening-ports.d.ts +13 -0
  200. package/dist/runtime/listening-ports.d.ts.map +1 -0
  201. package/dist/runtime/listening-ports.js +78 -0
  202. package/dist/runtime/listening-ports.js.map +1 -0
  203. package/dist/runtime/listening-ports.test.d.ts +2 -0
  204. package/dist/runtime/listening-ports.test.d.ts.map +1 -0
  205. package/dist/runtime/listening-ports.test.js +39 -0
  206. package/dist/runtime/listening-ports.test.js.map +1 -0
  207. package/dist/runtime/preview-proxy.d.ts +56 -0
  208. package/dist/runtime/preview-proxy.d.ts.map +1 -0
  209. package/dist/runtime/preview-proxy.js +302 -0
  210. package/dist/runtime/preview-proxy.js.map +1 -0
  211. package/dist/runtime/preview-proxy.test.d.ts +2 -0
  212. package/dist/runtime/preview-proxy.test.d.ts.map +1 -0
  213. package/dist/runtime/preview-proxy.test.js +122 -0
  214. package/dist/runtime/preview-proxy.test.js.map +1 -0
  215. package/dist/runtime/session-mode.d.ts +3 -0
  216. package/dist/runtime/session-mode.d.ts.map +1 -0
  217. package/dist/runtime/session-mode.js +60 -0
  218. package/dist/runtime/session-mode.js.map +1 -0
  219. package/dist/runtime/workload.d.ts +44 -0
  220. package/dist/runtime/workload.d.ts.map +1 -0
  221. package/dist/runtime/workload.js +222 -0
  222. package/dist/runtime/workload.js.map +1 -0
  223. package/dist/runtime/workload.test.d.ts +2 -0
  224. package/dist/runtime/workload.test.d.ts.map +1 -0
  225. package/dist/runtime/workload.test.js +235 -0
  226. package/dist/runtime/workload.test.js.map +1 -0
  227. package/dist/session/conversation.d.ts +3 -2
  228. package/dist/session/conversation.d.ts.map +1 -1
  229. package/dist/session/conversation.js +11 -7
  230. package/dist/session/conversation.js.map +1 -1
  231. package/dist/session/conversation.test.js +2 -3
  232. package/dist/session/conversation.test.js.map +1 -1
  233. package/dist/session/runtime.d.ts +16 -3
  234. package/dist/session/runtime.d.ts.map +1 -1
  235. package/dist/session/runtime.js +80 -13
  236. package/dist/session/runtime.js.map +1 -1
  237. package/dist/session/runtime.test.js +18 -7
  238. package/dist/session/runtime.test.js.map +1 -1
  239. package/dist/session/tools.d.ts.map +1 -1
  240. package/dist/session/tools.js +3 -3
  241. package/dist/session/tools.js.map +1 -1
  242. package/dist/task/loop.d.ts.map +1 -1
  243. package/dist/task/loop.js +6 -4
  244. package/dist/task/loop.js.map +1 -1
  245. package/dist/tools/exec-tools.d.ts +12 -0
  246. package/dist/tools/exec-tools.d.ts.map +1 -1
  247. package/dist/tools/exec-tools.js +46 -3
  248. package/dist/tools/exec-tools.js.map +1 -1
  249. package/dist/tools/exec-tools.test.d.ts +2 -0
  250. package/dist/tools/exec-tools.test.d.ts.map +1 -0
  251. package/dist/tools/exec-tools.test.js +48 -0
  252. package/dist/tools/exec-tools.test.js.map +1 -0
  253. package/dist/tools/fs-tools.d.ts.map +1 -1
  254. package/dist/tools/fs-tools.js +5 -5
  255. package/dist/tools/fs-tools.js.map +1 -1
  256. package/dist/transport/link.d.ts.map +1 -1
  257. package/dist/transport/link.js +16 -5
  258. package/dist/transport/link.js.map +1 -1
  259. package/dist/transport/link.test.js +24 -0
  260. package/dist/transport/link.test.js.map +1 -1
  261. package/dist/transport/protocol.d.ts +215 -3
  262. package/dist/transport/protocol.d.ts.map +1 -1
  263. package/dist/transport/protocol.js +163 -7
  264. package/dist/transport/protocol.js.map +1 -1
  265. package/dist/transport/protocol.test.js +41 -0
  266. package/dist/transport/protocol.test.js.map +1 -1
  267. package/dist/workspace-sync/eligibility.d.ts +14 -0
  268. package/dist/workspace-sync/eligibility.d.ts.map +1 -0
  269. package/dist/workspace-sync/eligibility.js +53 -0
  270. package/dist/workspace-sync/eligibility.js.map +1 -0
  271. package/dist/workspace-sync/merge.d.ts +15 -0
  272. package/dist/workspace-sync/merge.d.ts.map +1 -0
  273. package/dist/workspace-sync/merge.js +66 -0
  274. package/dist/workspace-sync/merge.js.map +1 -0
  275. package/dist/workspace-sync/merge.test.d.ts +2 -0
  276. package/dist/workspace-sync/merge.test.d.ts.map +1 -0
  277. package/dist/workspace-sync/merge.test.js +28 -0
  278. package/dist/workspace-sync/merge.test.js.map +1 -0
  279. package/dist/workspace-sync/workspace-sync.d.ts +48 -0
  280. package/dist/workspace-sync/workspace-sync.d.ts.map +1 -0
  281. package/dist/workspace-sync/workspace-sync.js +308 -0
  282. package/dist/workspace-sync/workspace-sync.js.map +1 -0
  283. package/dist/workspace-sync/workspace-sync.test.d.ts +2 -0
  284. package/dist/workspace-sync/workspace-sync.test.d.ts.map +1 -0
  285. package/dist/workspace-sync/workspace-sync.test.js +111 -0
  286. package/dist/workspace-sync/workspace-sync.test.js.map +1 -0
  287. package/dist/workspace-sync/write-drafts.d.ts +24 -0
  288. package/dist/workspace-sync/write-drafts.d.ts.map +1 -0
  289. package/dist/workspace-sync/write-drafts.js +87 -0
  290. package/dist/workspace-sync/write-drafts.js.map +1 -0
  291. package/dist/workspace-sync/write-drafts.test.d.ts +2 -0
  292. package/dist/workspace-sync/write-drafts.test.d.ts.map +1 -0
  293. package/dist/workspace-sync/write-drafts.test.js +36 -0
  294. package/dist/workspace-sync/write-drafts.test.js.map +1 -0
  295. package/package.json +12 -2
  296. package/dist/runtime/lambda-microvm.d.ts +0 -3
  297. package/dist/runtime/lambda-microvm.d.ts.map +0 -1
  298. package/dist/runtime/lambda-microvm.js.map +0 -1
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseListeningPorts = parseListeningPorts;
4
+ exports.listListeningPorts = listListeningPorts;
5
+ exports.watchListeningPorts = watchListeningPorts;
6
+ // Which ports the live preview can offer: every TCP listener the preview proxy can reach over
7
+ // loopback, read from the kernel's socket tables, so a dev server shows up whether the model
8
+ // started it, a script did, or the user did over SSH.
9
+ const promises_1 = require("fs/promises");
10
+ const protocol_1 = require("../transport/protocol");
11
+ const LISTEN_STATE = '0A';
12
+ const SOCKET_TABLES = ['/proc/net/tcp', '/proc/net/tcp6'];
13
+ const POLL_INTERVAL_MS = 2000;
14
+ /** A /proc/net/tcp{,6} local address the proxy reaches on loopback: any-address or loopback itself. */
15
+ function reachableOverLoopback(addressHex) {
16
+ if (/^0+$/.test(addressHex))
17
+ return true; // 0.0.0.0 or ::
18
+ // IPv4 bytes are stored little-endian, so 127.x.y.z ends in 7F.
19
+ if (addressHex.length === 8)
20
+ return addressHex.slice(6).toUpperCase() === '7F';
21
+ const v6 = addressHex.toUpperCase();
22
+ return v6 === '00000000000000000000000001000000' // ::1
23
+ || (v6.startsWith('0000000000000000FFFF0000') && v6.slice(30) === '7F'); // ::ffff:127.x.y.z
24
+ }
25
+ /** Listening, loopback-reachable ports in one /proc/net/tcp{,6} table. */
26
+ function parseListeningPorts(table) {
27
+ const ports = new Set();
28
+ for (const line of table.split('\n').slice(1)) {
29
+ const [, local, , state] = line.trim().split(/\s+/);
30
+ if (state !== LISTEN_STATE || !local)
31
+ continue;
32
+ const [addressHex, portHex] = local.split(':');
33
+ if (!portHex || !reachableOverLoopback(addressHex))
34
+ continue;
35
+ const port = parseInt(portHex, 16);
36
+ if (port > 0 && !protocol_1.GUEST_RESERVED_PORTS.includes(port))
37
+ ports.add(port);
38
+ }
39
+ return [...ports];
40
+ }
41
+ /** Every previewable port, ascending. Empty off Linux, where there is no /proc to read. */
42
+ async function listListeningPorts(tables = SOCKET_TABLES) {
43
+ const ports = new Set();
44
+ for (const table of tables) {
45
+ const content = await (0, promises_1.readFile)(table, 'utf8').catch(() => '');
46
+ for (const port of parseListeningPorts(content))
47
+ ports.add(port);
48
+ }
49
+ return [...ports].sort((a, b) => a - b);
50
+ }
51
+ /**
52
+ * Calls `onChange` with the current ports once, then whenever they change. Returns the stop.
53
+ * Polled, not watched: /proc files emit no change events.
54
+ */
55
+ function watchListeningPorts(onChange, options = {}) {
56
+ var _a, _b;
57
+ const list = (_a = options.list) !== null && _a !== void 0 ? _a : (() => listListeningPorts());
58
+ let last;
59
+ let stopped = false;
60
+ const scan = async () => {
61
+ const ports = await list().catch(() => undefined);
62
+ if (stopped || !ports)
63
+ return;
64
+ const key = ports.join(',');
65
+ if (key === last)
66
+ return;
67
+ last = key;
68
+ onChange(ports);
69
+ };
70
+ void scan();
71
+ const timer = setInterval(() => void scan(), (_b = options.intervalMs) !== null && _b !== void 0 ? _b : POLL_INTERVAL_MS);
72
+ timer.unref();
73
+ return () => {
74
+ stopped = true;
75
+ clearInterval(timer);
76
+ };
77
+ }
78
+ //# sourceMappingURL=listening-ports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listening-ports.js","sourceRoot":"","sources":["../../src/runtime/listening-ports.ts"],"names":[],"mappings":";;AAqBA,kDAWC;AAGD,gDAOC;AAMD,kDAsBC;AAtED,8FAA8F;AAC9F,6FAA6F;AAC7F,sDAAsD;AACtD,0CAAsC;AACtC,oDAA4D;AAE5D,MAAM,YAAY,GAAG,IAAI,CAAA;AACzB,MAAM,aAAa,GAAG,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAA;AACzD,MAAM,gBAAgB,GAAG,IAAK,CAAA;AAE9B,uGAAuG;AACvG,SAAS,qBAAqB,CAAC,UAAkB;IAC/C,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;QAAE,OAAO,IAAI,CAAA,CAAC,gBAAgB;IACzD,gEAAgE;IAChE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,IAAI,CAAA;IAC9E,MAAM,EAAE,GAAG,UAAU,CAAC,WAAW,EAAE,CAAA;IACnC,OAAO,EAAE,KAAK,kCAAkC,CAAC,MAAM;WAClD,CAAC,EAAE,CAAC,UAAU,CAAC,0BAA0B,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,CAAA,CAAC,mBAAmB;AAC/F,CAAC;AAED,0E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AO,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AACzC,CAAC;AAED;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,QAAmC,EACnC,UAAmE,EAAE;;IAErE,MAAM,IAAI,GAAG,MAAA,OAAO,CAAC,IAAI,mCAAI,CAAC,GAAG,EAAE,CAAC,kBAAkB,EAAE,CAAC,CAAA;IACzD,IAAI,IAAwB,CAAA;IAC5B,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;QACtB,MAAM,KAAK,GAAG,MAAM,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;QACjD,IAAI,OAAO,IAAI,CAAC,KAAK;YAAE,OAAM;QAC7B,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC3B,IAAI,GAAG,KAAK,IAAI;YAAE,OAAM;QACxB,IAAI,GAAG,GAAG,CAAA;QACV,QAAQ,CAAC,KAAK,CAAC,CAAA;IACjB,CAAC,CAAA;IACD,KAAK,IAAI,EAAE,CAAA;IACX,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE,EAAE,MAAA,OAAO,CAAC,UAAU,mCAAI,gBAAgB,CAAC,CAAA;IACpF,KAAK,CAAC,KAAK,EAAE,CAAA;IACb,OAAO,GAAG,EAAE;QACV,OAAO,GAAG,IAAI,CAAA;QACd,aAAa,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=listening-ports.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listening-ports.test.d.ts","sourceRoot":"","sources":["../../src/runtime/listening-ports.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const strict_1 = __importDefault(require("node:assert/strict"));
7
+ const node_test_1 = require("node:test");
8
+ const listening_ports_1 = require("./listening-ports");
9
+ const HEADER = ' sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode';
10
+ (0, node_test_1.it)('lists loopback-reachable listeners and skips connections, other hosts and the guest\'s own ports', () => {
11
+ const tcp = [
12
+ HEADER,
13
+ ' 0: 00000000:0BB8 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 1 1', // 0.0.0.0:3000
14
+ ' 1: 0100007F:1435 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 2 1', // 127.0.0.1:5173
15
+ ' 2: 0F02000A:0050 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 3 1', // 10.0.2.15:80
16
+ ' 3: 00000000:1F90 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 4 1', // :8080 (preview proxy)
17
+ ' 4: 0100007F:0BB8 0100007F:D431 01 00000000:00000000 00:00000000 00000000 0 0 5 1', // established
18
+ ].join('\n');
19
+ strict_1.default.deepEqual((0, listening_ports_1.parseListeningPorts)(tcp).sort(), [3000, 5173]);
20
+ const tcp6 = [
21
+ HEADER,
22
+ ' 0: 00000000000000000000000001000000:22B8 00000000000000000000000000000000:0000 0A 0 0 0 0 0 6 1', // [::1]:8888
23
+ ' 1: 00000000000000000000000000000000:0FA1 00000000000000000000000000000000:0000 0A 0 0 0 0 0 7 1', // [::]:4001
24
+ ' 2: 0000000000000000FFFF00000100007F:0FA2 00000000000000000000000000000000:0000 0A 0 0 0 0 0 8 1', // [::ffff:127.0.0.1]:4002
25
+ ].join('\n');
26
+ strict_1.default.deepEqual((0, listening_ports_1.parseListeningPorts)(tcp6).sort(), [4001, 4002, 8888]);
27
+ });
28
+ (0, node_test_1.it)('reports the first scan, then only changes', async () => {
29
+ const scans = [[3000], [3000], [3000, 5173]];
30
+ const seen = [];
31
+ const stop = (0, listening_ports_1.watchListeningPorts)((ports) => seen.push(ports), {
32
+ intervalMs: 5,
33
+ list: async () => { var _a; return (_a = scans.shift()) !== null && _a !== void 0 ? _a : [3000, 5173]; },
34
+ });
35
+ await new Promise((resolve) => setTimeout(resolve, 40));
36
+ stop();
37
+ strict_1.default.deepEqual(seen, [[3000], [3000, 5173]]);
38
+ });
39
+ //# sourceMappingURL=listening-ports.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listening-ports.test.js","sourceRoot":"","sources":["../../src/runtime/listening-ports.test.ts"],"names":[],"mappings":";;;;;AAAA,gEAAuC;AACvC,yCAA8B;AAC9B,uDAA4E;AAE5E,MAAM,MAAM,GAAG,kGAAkG,CAAA;AAEjH,IAAA,cAAE,EAAC,kGAAkG,EAAE,GAAG,EAAE;IAC1G,MAAM,GAAG,GAAG;QACV,MAAM;QACN,gGAAgG,EAAE,eAAe;QACjH,gGAAgG,EAAE,iBAAiB;QACnH,gGAAgG,EAAE,eAAe;QACjH,gGAAgG,EAAE,wBAAwB;QAC1H,gGAAgG,EAAE,cAAc;KACjH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACZ,gBAAM,CAAC,SAAS,CAAC,IAAA,qCAAmB,EAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IAE/D,MAAM,IAAI,GAAG;QACX,MAAM;QACN,oGAAoG,EAAE,aAAa;QACnH,oGAAoG,EAAE,YAAY;QAClH,oGAAoG,EAAE,0BAA0B;KACjI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACZ,gBAAM,CAAC,SAAS,CAAC,IAAA,qCAAmB,EAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AACxE,CAAC,CAAC,CAAA;AAEF,IAAA,cAAE,EAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;IACzD,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IAC5C,MAAM,IAAI,GAAe,EAAE,CAAA;IAC3B,MAAM,IAAI,GAAG,IAAA,qCAAmB,EAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QAC5D,UAAU,EAAE,CAAC;QACb,IAAI,EAAE,KAAK,IAAI,EAAE,WAAC,OAAA,MAAA,KAAK,CAAC,KAAK,EAAE,mCAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA,EAAA;KAChD,CAAC,CAAA;IACF,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;IACvD,IAAI,EAAE,CAAA;IACN,gBAAM,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;AAChD,CAAC,CAAC,CAAA"}
@@ -0,0 +1,56 @@
1
+ import http from 'http';
2
+ import net from 'net';
3
+ import type { Duplex } from 'stream';
4
+ /** Where the guest serves its lifecycle hooks and this proxy. */
5
+ export declare const GUEST_HTTP_PORT = 8080;
6
+ /** A connected socket to whatever listens on loopback `port`. */
7
+ export declare function connectLocal(port: number): Promise<net.Socket>;
8
+ /** The request headers as the app expects them from a browser on the guest itself. */
9
+ export declare function localRequestHeaders(headers: http.IncomingHttpHeaders, port: number): http.OutgoingHttpHeaders;
10
+ /** A redirect to the app's own local address, pointed at the public preview instead. */
11
+ export declare function publicLocation(location: string, port: number, origin: string): string;
12
+ /** The app's side of the guest's port 8080: the router of the workspace's app (src/app). */
13
+ export interface AppRequestHandler {
14
+ /** False when no app runs, so the request goes to the default port instead. */
15
+ handleRequest(req: http.IncomingMessage, res: http.ServerResponse): boolean;
16
+ handleUpgrade(req: http.IncomingMessage, socket: Duplex, head: Buffer): boolean;
17
+ }
18
+ export declare function setAppHandler(handler: AppRequestHandler | undefined): void;
19
+ /**
20
+ * A deployment (AGENT_MODE=app) is its app: requests without PREVIEW_PORT_HEADER go to it too
21
+ * (proxyAppRequest), not only a session URL's.
22
+ */
23
+ export declare function serveAppUnaddressed(): void;
24
+ /**
25
+ * Forwards a request to whatever listens on loopback `port`, as from a browser on the guest.
26
+ * `extraHeaders` go on the answer, over any of the same name (the app's builder.json `headers`).
27
+ */
28
+ export declare function proxyToPort(req: http.IncomingMessage, res: http.ServerResponse, port: number, extraHeaders?: ReadonlyArray<{
29
+ key: string;
30
+ value: string;
31
+ }>): void;
32
+ /**
33
+ * The guest's request handler, made safe: it runs the agent and serves the app, so a throw from one
34
+ * request, which nothing above would catch, must fail that request and not take all of it down.
35
+ */
36
+ export declare function guardRequests(handler: http.RequestListener): http.RequestListener;
37
+ /** The same for an upgrade request. */
38
+ export declare function guardUpgrades(handler: (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void): (req: http.IncomingMessage, socket: Duplex, head: Buffer) => void;
39
+ /** Handles a preview request; false when the request isn't one (no PREVIEW_PORT_HEADER). */
40
+ export declare function proxyPreviewRequest(req: http.IncomingMessage, res: http.ServerResponse): boolean;
41
+ /** In a deployment, any other request is the app's; false elsewhere (or until serveAppUnaddressed). */
42
+ export declare function proxyAppRequest(req: http.IncomingMessage, res: http.ServerResponse): boolean;
43
+ /**
44
+ * Handles a preview WebSocket upgrade by splicing the two connections together once the
45
+ * request reaches the app; false when the request isn't one. The app answers the handshake.
46
+ */
47
+ export declare function proxyPreviewUpgrade(req: http.IncomingMessage, socket: Duplex, head: Buffer): boolean;
48
+ /** Splices an upgrade request through to whatever listens on loopback `port`. */
49
+ export declare function upgradeToPort(req: http.IncomingMessage, socket: Duplex, head: Buffer, port: number): void;
50
+ /**
51
+ * The preview proxy on its own, for entrypoints with no lifecycle hook server holding
52
+ * GUEST_HTTP_PORT (cli.ts: QEMU, Firecracker). Anything but a preview (or, in a deployment, the
53
+ * app) gets a 404.
54
+ */
55
+ export declare function startPreviewServer(port?: number): http.Server;
56
+ //# sourceMappingURL=preview-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-proxy.d.ts","sourceRoot":"","sources":["../../src/runtime/preview-proxy.ts"],"names":[],"mappings":"AAQA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAIpC,iEAAiE;AACjE,eAAO,MAAM,eAAe,OAAO,CAAA;AAOnC,iEAAiE;AACjE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAiB9D;AAoBD,sFAAsF;AACtF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,mBAAmB,CAW7G;AAED,wFAAwF;AACxF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMrF;AAkBD,4FAA4F;AAC5F,MAAM,WAAW,iBAAiB;IAChC,+EAA+E;IAC/E,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE,IAAI,CAAC,cAAc,GAAG,OAAO,CAAA;IAC3E,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;CAChF;AAKD,wBAAgB,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG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;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,SAAkB,GAAG,IAAI,CAAC,MAAM,CAatE"}
@@ -0,0 +1,302 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GUEST_HTTP_PORT = void 0;
7
+ exports.connectLocal = connectLocal;
8
+ exports.localRequestHeaders = localRequestHeaders;
9
+ exports.publicLocation = publicLocation;
10
+ exports.setAppHandler = setAppHandler;
11
+ exports.serveAppUnaddressed = serveAppUnaddressed;
12
+ exports.proxyToPort = proxyToPort;
13
+ exports.guardRequests = guardRequests;
14
+ exports.guardUpgrades = guardUpgrades;
15
+ exports.proxyPreviewRequest = proxyPreviewRequest;
16
+ exports.proxyAppRequest = proxyAppRequest;
17
+ exports.proxyPreviewUpgrade = proxyPreviewUpgrade;
18
+ exports.upgradeToPort = upgradeToPort;
19
+ exports.startPreviewServer = startPreviewServer;
20
+ // The guest end of the live preview. Every engine reaches only the guest's port 8080; a request
21
+ // the gateway addressed to <vmId>-<port>.apps.<domain> arrives there carrying PREVIEW_PORT_HEADER
22
+ // and goes on to whatever listens on localhost:<port>, WebSocket upgrades (hot reload) included.
23
+ // A session's own URL carries APP_PREVIEW_TARGET instead: the workspace's app (src/app) routes it
24
+ // (src/app), else it goes to the default port.
25
+ // Dev servers bind localhost and check Host and Origin by default, so the request is made to look
26
+ // local: Host becomes localhost:<port>, an Origin or Referer naming the public preview names the
27
+ // local one instead, and a redirect to localhost points back at the public preview.
28
+ const http_1 = __importDefault(require("http"));
29
+ const net_1 = __importDefault(require("net"));
30
+ const protocol_1 = require("../transport/protocol");
31
+ const listening_ports_1 = require("./listening-ports");
32
+ /** Where the guest serves its lifecycle hooks and this proxy. */
33
+ exports.GUEST_HTTP_PORT = 8080;
34
+ // IPv4 first; Vite on `localhost` can end up bound to ::1 only.
35
+ const LOOPBACK_HOSTS = ['127.0.0.1', '::1'];
36
+ // Per connection, never forwarded: the proxy has its own connection to each side.
37
+ const HOP_BY_HOP_HEADERS = ['connection', 'keep-alive', 'proxy-connection', 'transfer-encoding', 'upgrade'];
38
+ /** A connected socket to whatever listens on loopback `port`. */
39
+ function connectLocal(port) {
40
+ return new Promise((resolve, reject) => {
41
+ const attempt = (index) => {
42
+ const socket = net_1.default.connect({ host: LOOPBACK_HOSTS[index], port });
43
+ const onError = (error) => {
44
+ socket.destroy();
45
+ if (index + 1 < LOOPBACK_HOSTS.length)
46
+ attempt(index + 1);
47
+ else
48
+ reject(error);
49
+ };
50
+ socket.once('error', onError);
51
+ socket.once('connect', () => {
52
+ socket.off('error', onError);
53
+ resolve(socket);
54
+ });
55
+ };
56
+ attempt(0);
57
+ });
58
+ }
59
+ function first(value) {
60
+ return Array.isArray(value) ? value[0] : value;
61
+ }
62
+ /** The preview's public origin, from the X-Forwarded-* headers the gateway sets. */
63
+ function publicOrigin(headers) {
64
+ const host = first(headers['x-forwarded-host']);
65
+ if (!host)
66
+ return undefined;
67
+ return `${first(headers['x-forwarded-proto']) === 'https' ? 'https' : 'http'}://${host}`;
68
+ }
69
+ /** `value` with the origin `from` swapped for `to`, or undefined when `value` isn't on `from`. */
70
+ function replacePrefix(value, from, to) {
71
+ if (!value.startsWith(from))
72
+ return undefined;
73
+ const rest = value.slice(from.length);
74
+ return rest === '' || /^[/?#]/.test(rest) ? to + rest : undefined;
75
+ }
76
+ /** The request headers as the app expects them from a browser on the guest itself. */
77
+ function localRequestHeaders(headers, port) {
78
+ const local = `http://localhost:${port}`;
79
+ const out = { ...headers, host: `localhost:${port}` };
80
+ delete out[protocol_1.PREVIEW_PORT_HEADER];
81
+ const origin = publicOrigin(headers);
82
+ if (origin) {
83
+ if (headers.origin === origin)
84
+ out.origin = local;
85
+ const referer = typeof headers.referer === 'string' ? replacePrefix(headers.referer, origin, local) : undefined;
86
+ if (referer)
87
+ out.referer = referer;
88
+ }
89
+ return out;
90
+ }
91
+ /** A redirect to the app's own local address, pointed at the public preview instead. */
92
+ function publicLocation(location, port, origin) {
93
+ for (const host of [`localhost:${port}`, `127.0.0.1:${port}`]) {
94
+ const replaced = replacePrefix(location, `http://${host}`, origin);
95
+ if (replaced)
96
+ return replaced;
97
+ }
98
+ return location;
99
+ }
100
+ function withoutHopByHop(headers) {
101
+ const out = { ...headers };
102
+ for (const name of HOP_BY_HOP_HEADERS)
103
+ delete out[name];
104
+ return out;
105
+ }
106
+ function htmlPage(res, status, title, text) {
107
+ const body = `<!doctype html><title>${title}</title><p>${text}</p>`;
108
+ res.writeHead(status, { 'Content-Type': 'text/html; charset=utf-8', 'Content-Length': Buffer.byteLength(body) });
109
+ res.end(body);
110
+ }
111
+ function nothingListening(res, port) {
112
+ htmlPage(res, 502, `Nothing on port ${port}`, `Nothing is listening on port ${port} in the session VM yet. Start the app, then reload.`);
113
+ }
114
+ let appHandler;
115
+ let appUnaddressed = false;
116
+ function setAppHandler(handler) {
117
+ appHandler = handler;
118
+ }
119
+ /**
120
+ * A deployment (AGENT_MODE=app) is its app: requests without PREVIEW_PORT_HEADER go to it too
121
+ * (proxyAppRequest), not only a session URL's.
122
+ */
123
+ function serveAppUnaddressed() {
124
+ appUnaddressed = true;
125
+ }
126
+ /**
127
+ * Forwards a request to whatever listens on loopback `port`, as from a browser on the guest.
128
+ * `extraHeaders` go on the answer, over any of the same name (the app's builder.json `headers`).
129
+ */
130
+ function proxyToPort(req, res, port, extraHeaders = []) {
131
+ const origin = publicOrigin(req.headers);
132
+ connectLocal(port).then((socket) => {
133
+ const upstream = http_1.default.request({
134
+ method: req.method,
135
+ path: req.url,
136
+ headers: withoutHopByHop(localRequestHeaders(req.headers, port)),
137
+ createConnection: () => socket,
138
+ }, (response) => {
139
+ var _a;
140
+ const headers = withoutHopByHop(response.headers);
141
+ if (origin && typeof headers.location === 'string')
142
+ headers.location = publicLocation(headers.location, port, origin);
143
+ for (const { key, value } of extraHeaders)
144
+ headers[key.toLowerCase()] = value;
145
+ res.writeHead((_a = response.statusCode) !== null && _a !== void 0 ? _a : 502, headers);
146
+ response.pipe(res);
147
+ });
148
+ upstream.on('error', () => {
149
+ if (res.headersSent)
150
+ res.destroy();
151
+ else
152
+ nothingListening(res, port);
153
+ });
154
+ res.on('close', () => upstream.destroy());
155
+ req.pipe(upstream);
156
+ }, () => nothingListening(res, port));
157
+ }
158
+ /** A session URL with no app: the default port (DEFAULT_APP_PORT when it listens, else the lowest). */
159
+ function proxyToDefaultPort(req, res) {
160
+ (0, listening_ports_1.listListeningPorts)().then((ports) => {
161
+ const port = (0, protocol_1.defaultAppPort)(ports);
162
+ if (port === undefined)
163
+ htmlPage(res, 502, 'Nothing running', 'Nothing is listening in the session VM yet. Start the app, then reload.');
164
+ else
165
+ proxyToPort(req, res, port);
166
+ }, () => htmlPage(res, 502, 'Nothing running', 'The session VM could not list its listening ports.'));
167
+ }
168
+ /**
169
+ * The guest's request handler, made safe: it runs the agent and serves the app, so a throw from one
170
+ * request, which nothing above would catch, must fail that request and not take all of it down.
171
+ */
172
+ function guardRequests(handler) {
173
+ return (req, res) => {
174
+ try {
175
+ handler(req, res);
176
+ }
177
+ catch (error) {
178
+ console.error('[guest] request failed:', error instanceof Error ? error.message : error);
179
+ if (!res.headersSent)
180
+ res.writeHead(500);
181
+ res.end();
182
+ }
183
+ };
184
+ }
185
+ /** The same for an upgrade request. */
186
+ function guardUpgrades(handler) {
187
+ return (req, socket, head) => {
188
+ try {
189
+ handler(req, socket, head);
190
+ }
191
+ catch (error) {
192
+ console.error('[guest] upgrade failed:', error instanceof Error ? error.message : error);
193
+ socket.destroy();
194
+ }
195
+ };
196
+ }
197
+ /** Handles a preview request; false when the request isn't one (no PREVIEW_PORT_HEADER). */
198
+ function proxyPreviewRequest(req, res) {
199
+ if (!(protocol_1.PREVIEW_PORT_HEADER in req.headers))
200
+ return false;
201
+ const target = (0, protocol_1.parsePreviewTarget)(req.headers[protocol_1.PREVIEW_PORT_HEADER]);
202
+ if (target === undefined) {
203
+ res.writeHead(400);
204
+ res.end();
205
+ }
206
+ else if (target !== protocol_1.APP_PREVIEW_TARGET) {
207
+ proxyToPort(req, res, target);
208
+ }
209
+ else if (!(appHandler === null || appHandler === void 0 ? void 0 : appHandler.handleRequest(req, res))) {
210
+ proxyToDefaultPort(req, res);
211
+ }
212
+ return true;
213
+ }
214
+ /** In a deployment, any other request is the app's; false elsewhere (or until serveAppUnaddressed). */
215
+ function proxyAppRequest(req, res) {
216
+ if (!appUnaddressed)
217
+ return false;
218
+ if (!(appHandler === null || appHandler === void 0 ? void 0 : appHandler.handleRequest(req, res))) {
219
+ res.setHeader('Retry-After', '2');
220
+ htmlPage(res, 503, 'Starting', 'The app is starting. Reload in a moment.');
221
+ }
222
+ return true;
223
+ }
224
+ function requestHead(req, headers) {
225
+ let head = `${req.method} ${req.url} HTTP/1.1\r\n`;
226
+ for (const [name, value] of Object.entries(headers)) {
227
+ if (value === undefined)
228
+ continue;
229
+ for (const item of Array.isArray(value) ? value : [value])
230
+ head += `${name}: ${item}\r\n`;
231
+ }
232
+ return `${head}\r\n`;
233
+ }
234
+ /**
235
+ * Handles a preview WebSocket upgrade by splicing the two connections together once the
236
+ * request reaches the app; false when the request isn't one. The app answers the handshake.
237
+ */
238
+ function proxyPreviewUpgrade(req, socket, head) {
239
+ const addressed = protocol_1.PREVIEW_PORT_HEADER in req.headers;
240
+ if (!addressed && !appUnaddressed)
241
+ return false;
242
+ socket.on('error', () => socket.destroy());
243
+ // The HTTP server's sockets stay half-open after the client's FIN; a WebSocket never needs
244
+ // that, and an app that ignores the FIN must not keep the client's connection alive.
245
+ if (socket instanceof net_1.default.Socket)
246
+ socket.allowHalfOpen = false;
247
+ const target = addressed ? (0, protocol_1.parsePreviewTarget)(req.headers[protocol_1.PREVIEW_PORT_HEADER]) : protocol_1.APP_PREVIEW_TARGET;
248
+ if (target === undefined) {
249
+ socket.end('HTTP/1.1 400 Bad Request\r\nConnection: close\r\n\r\n');
250
+ }
251
+ else if (target !== protocol_1.APP_PREVIEW_TARGET) {
252
+ upgradeToPort(req, socket, head, target);
253
+ }
254
+ else if (!(appHandler === null || appHandler === void 0 ? void 0 : appHandler.handleUpgrade(req, socket, head))) {
255
+ if (!addressed)
256
+ socket.end('HTTP/1.1 503 Service Unavailable\r\nConnection: close\r\n\r\n');
257
+ else
258
+ (0, listening_ports_1.listListeningPorts)().then((ports) => {
259
+ const port = (0, protocol_1.defaultAppPort)(ports);
260
+ if (port === undefined)
261
+ socket.end('HTTP/1.1 502 Bad Gateway\r\nConnection: close\r\n\r\n');
262
+ else
263
+ upgradeToPort(req, socket, head, port);
264
+ }, () => socket.destroy());
265
+ }
266
+ return true;
267
+ }
268
+ /** Splices an upgrade request through to whatever listens on loopback `port`. */
269
+ function upgradeToPort(req, socket, head, port) {
270
+ connectLocal(port).then((upstream) => {
271
+ upstream.on('error', () => socket.destroy());
272
+ upstream.on('close', () => socket.destroy());
273
+ socket.on('close', () => upstream.destroy());
274
+ upstream.write(requestHead(req, localRequestHeaders(req.headers, port)));
275
+ if (head.length)
276
+ upstream.write(head);
277
+ upstream.pipe(socket);
278
+ socket.pipe(upstream);
279
+ }, () => socket.end('HTTP/1.1 502 Bad Gateway\r\nConnection: close\r\n\r\n'));
280
+ }
281
+ /**
282
+ * The preview proxy on its own, for entrypoints with no lifecycle hook server holding
283
+ * GUEST_HTTP_PORT (cli.ts: QEMU, Firecracker). Anything but a preview (or, in a deployment, the
284
+ * app) gets a 404.
285
+ */
286
+ function startPreviewServer(port = exports.GUEST_HTTP_PORT) {
287
+ const server = http_1.default.createServer(guardRequests((req, res) => {
288
+ if (proxyPreviewRequest(req, res) || proxyAppRequest(req, res))
289
+ return;
290
+ res.writeHead(404);
291
+ res.end();
292
+ }));
293
+ server.on('upgrade', guardUpgrades((req, socket, head) => {
294
+ if (!proxyPreviewUpgrade(req, socket, head))
295
+ socket.destroy();
296
+ }));
297
+ // An app the user started on this port first keeps it; the agent runs without previews then.
298
+ server.on('error', (error) => console.error(`[preview] cannot serve on ${port}:`, error.message));
299
+ server.listen(port);
300
+ return server;
301
+ }
302
+ //# sourceMappingURL=preview-proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-proxy.js","sourceRoot":"","sources":["../../src/runtime/preview-proxy.ts"],"names":[],"mappings":";;;;;;AAuBA,oCAiBC;AAqBD,kDAWC;AAGD,wCAMC;AA4BD,sCAEC;AAMD,kDAEC;AAMD,kCA8BC;AAeD,sCAUC;AAGD,sCASC;AAGD,kDAYC;AAGD,0CAOC;AAeD,kDAqBC;AAGD,sCAUC;AAOD,gDAaC;AA9RD,gGAAgG;AAChG,kGAAkG;AAClG,iGAAiG;AACjG,kGAAkG;AAClG,+CAA+C;AAC/C,kGAAkG;AAClG,iGAAiG;AACjG,oFAAoF;AACpF,gDAAuB;AACvB,8CAAqB;AAErB,oDAAmH;AACnH,uDAAsD;AAEtD,iEAAiE;AACpD,QAAA,eAAe,GAAG,IAAI,CAAA;AAEnC,gEAAgE;AAChE,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;AAC3C,kFAAkF;AAClF,MAAM,kBAAkB,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,SAAS,CAAC,CAAA;AAE3G,iEAAiE;AACjE,SAAgB,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,EAAE;YAChC,MAAM,MAAM,GAAG,aAAG,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;YACjE,MAAM,OAAO,GAAG,CAAC,KAAY,EAAE,EAAE;gBAC/B,MAAM,CAAC,OAAO,EAAE,CAAA;gBAChB,IAAI,KAAK,GAAG,CAAC,GAAG,cAAc,CAAC,MAAM;oBAAE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],"names":[],"mappings":""}