codebase-onboarder 0.6.0 → 1.0.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 (526) hide show
  1. package/README.md +284 -53
  2. package/bin/build-if-source.js +23 -0
  3. package/bin/onboarder.js +0 -0
  4. package/cli/agent/command.d.ts +71 -0
  5. package/cli/agent/command.js +177 -0
  6. package/cli/agent/command.js.map +1 -0
  7. package/cli/agent/config.d.ts +31 -0
  8. package/cli/agent/config.js +98 -0
  9. package/cli/agent/config.js.map +1 -0
  10. package/cli/agent/contracts.d.ts +77 -0
  11. package/cli/agent/contracts.js +2 -0
  12. package/cli/agent/contracts.js.map +1 -0
  13. package/cli/agent/files.d.ts +19 -0
  14. package/cli/agent/files.js +109 -0
  15. package/cli/agent/files.js.map +1 -0
  16. package/cli/agent/gitSource.d.ts +18 -0
  17. package/cli/agent/gitSource.js +69 -0
  18. package/cli/agent/gitSource.js.map +1 -0
  19. package/cli/agent/github.d.ts +21 -0
  20. package/cli/agent/github.js +94 -0
  21. package/cli/agent/github.js.map +1 -0
  22. package/cli/agent/mcp.d.ts +15 -0
  23. package/cli/agent/mcp.js +78 -0
  24. package/cli/agent/mcp.js.map +1 -0
  25. package/cli/agent/process.d.ts +18 -0
  26. package/cli/agent/process.js +118 -0
  27. package/cli/agent/process.js.map +1 -0
  28. package/cli/agent/protocol.d.ts +3 -0
  29. package/cli/agent/protocol.js +26 -0
  30. package/cli/agent/protocol.js.map +1 -0
  31. package/cli/agent/runner.d.ts +34 -0
  32. package/cli/agent/runner.js +152 -0
  33. package/cli/agent/runner.js.map +1 -0
  34. package/cli/agent/stdio.d.ts +1 -0
  35. package/cli/agent/stdio.js +62 -0
  36. package/cli/agent/stdio.js.map +1 -0
  37. package/cli/agent/tools.d.ts +7 -0
  38. package/cli/agent/tools.js +201 -0
  39. package/cli/agent/tools.js.map +1 -0
  40. package/cli/chat/app.d.ts +16 -0
  41. package/cli/chat/app.js +345 -0
  42. package/cli/chat/app.js.map +1 -0
  43. package/cli/chat/commands.d.ts +11 -0
  44. package/cli/chat/commands.js +120 -0
  45. package/cli/chat/commands.js.map +1 -0
  46. package/cli/chat/composer.d.ts +75 -0
  47. package/cli/chat/composer.js +467 -0
  48. package/cli/chat/composer.js.map +1 -0
  49. package/cli/chat/controller.d.ts +60 -0
  50. package/cli/chat/controller.js +393 -0
  51. package/cli/chat/controller.js.map +1 -0
  52. package/cli/chat/logo.d.ts +3 -0
  53. package/cli/chat/logo.js +14 -0
  54. package/cli/chat/logo.js.map +1 -0
  55. package/cli/chat/models.d.ts +18 -0
  56. package/cli/chat/models.js +88 -0
  57. package/cli/chat/models.js.map +1 -0
  58. package/cli/chat/profile.d.ts +5 -0
  59. package/cli/chat/profile.js +98 -0
  60. package/cli/chat/profile.js.map +1 -0
  61. package/cli/chat/render.d.ts +40 -0
  62. package/cli/chat/render.js +259 -0
  63. package/cli/chat/render.js.map +1 -0
  64. package/cli/chat/screen.d.ts +26 -0
  65. package/cli/chat/screen.js +117 -0
  66. package/cli/chat/screen.js.map +1 -0
  67. package/cli/chat/source.d.ts +29 -0
  68. package/cli/chat/source.js +116 -0
  69. package/cli/chat/source.js.map +1 -0
  70. package/cli/chat/store.d.ts +43 -0
  71. package/cli/chat/store.js +94 -0
  72. package/cli/chat/store.js.map +1 -0
  73. package/cli/chat/text.d.ts +4 -0
  74. package/cli/chat/text.js +27 -0
  75. package/cli/chat/text.js.map +1 -0
  76. package/cli/commands.d.ts +26 -0
  77. package/cli/commands.js +836 -811
  78. package/cli/commands.js.map +1 -0
  79. package/cli/explorer/advanced.d.ts +14 -0
  80. package/cli/explorer/advanced.js +321 -329
  81. package/cli/explorer/advanced.js.map +1 -0
  82. package/cli/explorer/app.d.ts +2 -0
  83. package/cli/explorer/app.js +404 -314
  84. package/cli/explorer/app.js.map +1 -0
  85. package/cli/explorer/assistant.d.ts +9 -0
  86. package/cli/explorer/assistant.js +58 -0
  87. package/cli/explorer/assistant.js.map +1 -0
  88. package/cli/explorer/commands.d.ts +17 -0
  89. package/cli/explorer/commands.js +373 -302
  90. package/cli/explorer/commands.js.map +1 -0
  91. package/cli/explorer/featureViews.d.ts +124 -0
  92. package/cli/explorer/featureViews.js +179 -0
  93. package/cli/explorer/featureViews.js.map +1 -0
  94. package/cli/explorer/github.d.ts +21 -0
  95. package/cli/explorer/github.js +42 -44
  96. package/cli/explorer/github.js.map +1 -0
  97. package/cli/explorer/graphs.d.ts +7 -0
  98. package/cli/explorer/graphs.js +90 -95
  99. package/cli/explorer/graphs.js.map +1 -0
  100. package/cli/explorer/picker.d.ts +22 -0
  101. package/cli/explorer/picker.js +150 -0
  102. package/cli/explorer/picker.js.map +1 -0
  103. package/cli/explorer/report.d.ts +85 -0
  104. package/cli/explorer/report.js +60 -0
  105. package/cli/explorer/report.js.map +1 -0
  106. package/cli/explorer/session.d.ts +449 -0
  107. package/cli/explorer/session.js +143 -144
  108. package/cli/explorer/session.js.map +1 -0
  109. package/cli/explorer/views.d.ts +19 -0
  110. package/cli/explorer/views.js +465 -482
  111. package/cli/explorer/views.js.map +1 -0
  112. package/cli/explorer/wrap.d.ts +1 -0
  113. package/cli/explorer/wrap.js +28 -44
  114. package/cli/explorer/wrap.js.map +1 -0
  115. package/cli/main.d.ts +1 -0
  116. package/cli/main.js +251 -164
  117. package/cli/main.js.map +1 -0
  118. package/cli/prompt.d.ts +5 -0
  119. package/cli/prompt.js +84 -80
  120. package/cli/prompt.js.map +1 -0
  121. package/cli/scanOptions.d.ts +2 -0
  122. package/cli/scanOptions.js +11 -0
  123. package/cli/scanOptions.js.map +1 -0
  124. package/cli/ui.d.ts +33 -0
  125. package/cli/ui.js +35 -44
  126. package/cli/ui.js.map +1 -0
  127. package/cli/wizard.d.ts +187 -0
  128. package/cli/wizard.js +304 -284
  129. package/cli/wizard.js.map +1 -0
  130. package/docs/HERMES_RESEARCH.md +51 -0
  131. package/package.json +16 -4
  132. package/public/app.d.ts +1 -0
  133. package/public/app.js +1133 -1011
  134. package/public/app.js.map +1 -0
  135. package/public/assets/onboarder-mark.svg +11 -0
  136. package/public/browser.d.ts +71 -0
  137. package/public/browser.js +2 -0
  138. package/public/browser.js.map +1 -0
  139. package/public/index.html +54 -20
  140. package/public/js/about.d.ts +6 -0
  141. package/public/js/about.js +152 -172
  142. package/public/js/about.js.map +1 -0
  143. package/public/js/aiDraft.d.ts +4 -0
  144. package/public/js/aiDraft.js +166 -125
  145. package/public/js/aiDraft.js.map +1 -0
  146. package/public/js/analysisPanel.d.ts +7 -0
  147. package/public/js/analysisPanel.js +166 -166
  148. package/public/js/analysisPanel.js.map +1 -0
  149. package/public/js/analysisReport.d.ts +38 -0
  150. package/public/js/analysisReport.js +105 -110
  151. package/public/js/analysisReport.js.map +1 -0
  152. package/public/js/api.d.ts +29 -0
  153. package/public/js/api.js +198 -166
  154. package/public/js/api.js.map +1 -0
  155. package/public/js/atlas.d.ts +6 -0
  156. package/public/js/atlas.js +50 -58
  157. package/public/js/atlas.js.map +1 -0
  158. package/public/js/blameView.d.ts +2 -0
  159. package/public/js/blameView.js +36 -37
  160. package/public/js/blameView.js.map +1 -0
  161. package/public/js/codeTab.d.ts +3 -0
  162. package/public/js/codeTab.js +175 -180
  163. package/public/js/codeTab.js.map +1 -0
  164. package/public/js/codeViewer.d.ts +5 -0
  165. package/public/js/codeViewer.js +162 -150
  166. package/public/js/codeViewer.js.map +1 -0
  167. package/public/js/components/FileChip.d.ts +9 -0
  168. package/public/js/components/FileChip.js +45 -49
  169. package/public/js/components/FileChip.js.map +1 -0
  170. package/public/js/components/MetricSparkline.d.ts +7 -0
  171. package/public/js/components/MetricSparkline.js +35 -44
  172. package/public/js/components/MetricSparkline.js.map +1 -0
  173. package/public/js/components/RiskBadge.d.ts +9 -0
  174. package/public/js/components/RiskBadge.js +55 -63
  175. package/public/js/components/RiskBadge.js.map +1 -0
  176. package/public/js/deepAnalysisView.d.ts +99 -0
  177. package/public/js/deepAnalysisView.js +282 -302
  178. package/public/js/deepAnalysisView.js.map +1 -0
  179. package/public/js/diagramPane.d.ts +9 -0
  180. package/public/js/diagramPane.js +138 -135
  181. package/public/js/diagramPane.js.map +1 -0
  182. package/public/js/diffView.d.ts +6 -0
  183. package/public/js/diffView.js +222 -209
  184. package/public/js/diffView.js.map +1 -0
  185. package/public/js/docsView.d.ts +2 -0
  186. package/public/js/docsView.js +441 -442
  187. package/public/js/docsView.js.map +1 -0
  188. package/public/js/dom.d.ts +197 -0
  189. package/public/js/dom.js +5 -0
  190. package/public/js/dom.js.map +1 -0
  191. package/public/js/fileSourceBrowser.d.ts +5 -0
  192. package/public/js/fileSourceBrowser.js +33 -41
  193. package/public/js/fileSourceBrowser.js.map +1 -0
  194. package/public/js/flameGraph.d.ts +5 -0
  195. package/public/js/flameGraph.js +62 -72
  196. package/public/js/flameGraph.js.map +1 -0
  197. package/public/js/forceGraph.d.ts +10 -0
  198. package/public/js/forceGraph.js +581 -556
  199. package/public/js/forceGraph.js.map +1 -0
  200. package/public/js/heatmap.d.ts +4 -0
  201. package/public/js/heatmap.js +142 -164
  202. package/public/js/heatmap.js.map +1 -0
  203. package/public/js/highlight.d.ts +2 -0
  204. package/public/js/highlight.js +116 -107
  205. package/public/js/highlight.js.map +1 -0
  206. package/public/js/html.d.ts +2 -0
  207. package/public/js/html.js +14 -44
  208. package/public/js/html.js.map +1 -0
  209. package/public/js/insightsView.d.ts +5 -0
  210. package/public/js/insightsView.js +93 -111
  211. package/public/js/insightsView.js.map +1 -0
  212. package/public/js/inspector.d.ts +37 -0
  213. package/public/js/inspector.js +416 -445
  214. package/public/js/inspector.js.map +1 -0
  215. package/public/js/llm.d.ts +115 -0
  216. package/public/js/llm.js +246 -278
  217. package/public/js/llm.js.map +1 -0
  218. package/public/js/mapView.d.ts +3 -0
  219. package/public/js/mapView.js +121 -120
  220. package/public/js/mapView.js.map +1 -0
  221. package/public/js/markdown.d.ts +3 -0
  222. package/public/js/markdown.js +84 -91
  223. package/public/js/markdown.js.map +1 -0
  224. package/public/js/mindmap.d.ts +32 -0
  225. package/public/js/mindmap.js +244 -259
  226. package/public/js/mindmap.js.map +1 -0
  227. package/public/js/mobilePanels.d.ts +5 -0
  228. package/public/js/mobilePanels.js +50 -0
  229. package/public/js/mobilePanels.js.map +1 -0
  230. package/public/js/repoFiles.d.ts +12 -0
  231. package/public/js/repoFiles.js +29 -28
  232. package/public/js/repoFiles.js.map +1 -0
  233. package/public/js/reviewView.d.ts +28 -0
  234. package/public/js/reviewView.js +256 -0
  235. package/public/js/reviewView.js.map +1 -0
  236. package/public/js/sbomView.d.ts +3 -0
  237. package/public/js/sbomView.js +59 -67
  238. package/public/js/sbomView.js.map +1 -0
  239. package/public/js/scanCache.d.ts +16 -0
  240. package/public/js/scanCache.js +67 -65
  241. package/public/js/scanCache.js.map +1 -0
  242. package/public/js/search.d.ts +7 -0
  243. package/public/js/search.js +868 -800
  244. package/public/js/search.js.map +1 -0
  245. package/public/js/searchLocal.d.ts +42 -0
  246. package/public/js/searchLocal.js +87 -0
  247. package/public/js/searchLocal.js.map +1 -0
  248. package/public/js/serverSettings.d.ts +5 -0
  249. package/public/js/serverSettings.js +153 -164
  250. package/public/js/serverSettings.js.map +1 -0
  251. package/public/js/state.d.ts +798 -0
  252. package/public/js/state.js +114 -122
  253. package/public/js/state.js.map +1 -0
  254. package/public/js/tour.d.ts +6 -0
  255. package/public/js/tour.js +5 -7
  256. package/public/js/tour.js.map +1 -0
  257. package/public/js/transitions.d.ts +2 -0
  258. package/public/js/transitions.js +9 -10
  259. package/public/js/transitions.js.map +1 -0
  260. package/public/js/tree.d.ts +12 -0
  261. package/public/js/tree.js +157 -154
  262. package/public/js/tree.js.map +1 -0
  263. package/public/js/workflowsView.d.ts +3 -0
  264. package/public/js/workflowsView.js +15 -22
  265. package/public/js/workflowsView.js.map +1 -0
  266. package/public/search.css +495 -0
  267. package/public/styles.css +188 -346
  268. package/public/workbench.css +166 -0
  269. package/server/apiAuth.d.ts +3 -0
  270. package/server/apiAuth.js +18 -20
  271. package/server/apiAuth.js.map +1 -0
  272. package/server/apiDiff.d.ts +2 -0
  273. package/server/apiDiff.js +20 -18
  274. package/server/apiDiff.js.map +1 -0
  275. package/server/apiDocs.d.ts +2 -0
  276. package/server/apiDocs.js +38 -40
  277. package/server/apiDocs.js.map +1 -0
  278. package/server/apiFile.d.ts +1 -0
  279. package/server/apiFile.js +14 -17
  280. package/server/apiFile.js.map +1 -0
  281. package/server/apiGitBlame.d.ts +2 -0
  282. package/server/apiGitBlame.js +50 -51
  283. package/server/apiGitBlame.js.map +1 -0
  284. package/server/apiMcp.d.ts +4 -0
  285. package/server/apiMcp.js +64 -66
  286. package/server/apiMcp.js.map +1 -0
  287. package/server/apiReview.d.ts +2 -0
  288. package/server/apiReview.js +45 -0
  289. package/server/apiReview.js.map +1 -0
  290. package/server/apiScan.d.ts +5 -0
  291. package/server/apiScan.js +90 -71
  292. package/server/apiScan.js.map +1 -0
  293. package/server/apiSearch.d.ts +33 -0
  294. package/server/apiSearch.js +184 -200
  295. package/server/apiSearch.js.map +1 -0
  296. package/server/apiSettings.d.ts +4 -0
  297. package/server/apiSettings.js +84 -85
  298. package/server/apiSettings.js.map +1 -0
  299. package/server/apiTools.d.ts +3 -0
  300. package/server/apiTools.js +55 -56
  301. package/server/apiTools.js.map +1 -0
  302. package/server/auth.d.ts +5 -0
  303. package/server/auth.js +54 -51
  304. package/server/auth.js.map +1 -0
  305. package/server/config.d.ts +42 -0
  306. package/server/config.js +189 -194
  307. package/server/config.js.map +1 -0
  308. package/server/daemon.d.ts +12 -0
  309. package/server/daemon.js +124 -114
  310. package/server/daemon.js.map +1 -0
  311. package/server/fileSourceNode.d.ts +2 -0
  312. package/server/fileSourceNode.js +34 -36
  313. package/server/fileSourceNode.js.map +1 -0
  314. package/server/gitClone.d.ts +9 -0
  315. package/server/gitClone.js +59 -61
  316. package/server/gitClone.js.map +1 -0
  317. package/server/gitDiff.d.ts +36 -0
  318. package/server/gitDiff.js +271 -169
  319. package/server/gitDiff.js.map +1 -0
  320. package/server/gitHistory.d.ts +12 -0
  321. package/server/gitHistory.js +80 -80
  322. package/server/gitHistory.js.map +1 -0
  323. package/server/gitRemote.d.ts +12 -0
  324. package/server/gitRemote.js +37 -38
  325. package/server/gitRemote.js.map +1 -0
  326. package/server/hermesChat.d.ts +13 -0
  327. package/server/hermesChat.js +145 -0
  328. package/server/hermesChat.js.map +1 -0
  329. package/server/htmlText.d.ts +4 -0
  330. package/server/htmlText.js +16 -23
  331. package/server/htmlText.js.map +1 -0
  332. package/server/http.d.ts +6 -0
  333. package/server/http.js +27 -34
  334. package/server/http.js.map +1 -0
  335. package/server/httpGuards.d.ts +2 -0
  336. package/server/httpGuards.js +47 -43
  337. package/server/httpGuards.js.map +1 -0
  338. package/server/https.d.ts +34 -0
  339. package/server/https.js +121 -111
  340. package/server/https.js.map +1 -0
  341. package/server/index.d.ts +40 -0
  342. package/server/index.js +139 -147
  343. package/server/index.js.map +1 -0
  344. package/server/layout.d.ts +26 -0
  345. package/server/layout.js +59 -64
  346. package/server/layout.js.map +1 -0
  347. package/server/llmProxy.d.ts +3 -0
  348. package/server/llmProxy.js +137 -135
  349. package/server/llmProxy.js.map +1 -0
  350. package/server/logger.d.ts +38 -0
  351. package/server/logger.js +198 -211
  352. package/server/logger.js.map +1 -0
  353. package/server/mcp/analysis.d.ts +29 -0
  354. package/server/mcp/analysis.js +99 -120
  355. package/server/mcp/analysis.js.map +1 -0
  356. package/server/mcp/http.d.ts +9 -0
  357. package/server/mcp/http.js +128 -137
  358. package/server/mcp/http.js.map +1 -0
  359. package/server/mcp/runner.d.ts +68 -0
  360. package/server/mcp/runner.js +208 -218
  361. package/server/mcp/runner.js.map +1 -0
  362. package/server/mcp/server.d.ts +29 -0
  363. package/server/mcp/server.js +167 -180
  364. package/server/mcp/server.js.map +1 -0
  365. package/server/mcp/standalone.d.ts +1 -0
  366. package/server/mcp/standalone.js +8 -10
  367. package/server/mcp/standalone.js.map +1 -0
  368. package/server/mcp/tools.d.ts +2020 -0
  369. package/server/mcp/tools.js +523 -574
  370. package/server/mcp/tools.js.map +1 -0
  371. package/server/paths.d.ts +3 -0
  372. package/server/paths.js +17 -15
  373. package/server/paths.js.map +1 -0
  374. package/server/pidfile.d.ts +9 -0
  375. package/server/pidfile.js +43 -45
  376. package/server/pidfile.js.map +1 -0
  377. package/server/review.d.ts +5 -0
  378. package/server/review.js +35 -0
  379. package/server/review.js.map +1 -0
  380. package/server/router.d.ts +33 -0
  381. package/server/router.js +195 -197
  382. package/server/router.js.map +1 -0
  383. package/server/scanRequest.d.ts +3 -0
  384. package/server/scanRequest.js +36 -0
  385. package/server/scanRequest.js.map +1 -0
  386. package/server/searchIndex.d.ts +17 -0
  387. package/server/searchIndex.js +83 -80
  388. package/server/searchIndex.js.map +1 -0
  389. package/server/sessions.d.ts +14 -0
  390. package/server/sessions.js +62 -70
  391. package/server/sessions.js.map +1 -0
  392. package/server/startup.d.ts +118 -0
  393. package/server/startup.js +143 -148
  394. package/server/startup.js.map +1 -0
  395. package/server/static.d.ts +6 -0
  396. package/server/static.js +28 -31
  397. package/server/static.js.map +1 -0
  398. package/server/tools/install.d.ts +4 -0
  399. package/server/tools/install.js +176 -185
  400. package/server/tools/install.js.map +1 -0
  401. package/server/tools/parse.d.ts +8 -0
  402. package/server/tools/parse.js +112 -114
  403. package/server/tools/parse.js.map +1 -0
  404. package/server/tools/platform.d.ts +9 -0
  405. package/server/tools/platform.js +49 -47
  406. package/server/tools/platform.js.map +1 -0
  407. package/server/tools/registry.d.ts +137 -0
  408. package/server/tools/registry.js +173 -172
  409. package/server/tools/registry.js.map +1 -0
  410. package/server/tools/scan.d.ts +34 -0
  411. package/server/tools/scan.js +89 -98
  412. package/server/tools/scan.js.map +1 -0
  413. package/server/tools.d.ts +34 -0
  414. package/server/tools.js +94 -107
  415. package/server/tools.js.map +1 -0
  416. package/server/tunnel.d.ts +29 -0
  417. package/server/tunnel.js +61 -66
  418. package/server/tunnel.js.map +1 -0
  419. package/shared/analyzer/docs.d.ts +16 -0
  420. package/shared/analyzer/docs.js +99 -93
  421. package/shared/analyzer/docs.js.map +1 -0
  422. package/shared/analyzer/explainLocal.d.ts +4 -0
  423. package/shared/analyzer/explainLocal.js +122 -142
  424. package/shared/analyzer/explainLocal.js.map +1 -0
  425. package/shared/analyzer/github.d.ts +37 -0
  426. package/shared/analyzer/github.js +41 -43
  427. package/shared/analyzer/github.js.map +1 -0
  428. package/shared/analyzer/graph.d.ts +41 -0
  429. package/shared/analyzer/graph.js +393 -400
  430. package/shared/analyzer/graph.js.map +1 -0
  431. package/shared/analyzer/health.d.ts +33 -0
  432. package/shared/analyzer/health.js +197 -193
  433. package/shared/analyzer/health.js.map +1 -0
  434. package/shared/analyzer/history.d.ts +29 -0
  435. package/shared/analyzer/history.js +110 -111
  436. package/shared/analyzer/history.js.map +1 -0
  437. package/shared/analyzer/jsonConfig.d.ts +2 -0
  438. package/shared/analyzer/jsonConfig.js +61 -0
  439. package/shared/analyzer/jsonConfig.js.map +1 -0
  440. package/shared/analyzer/languages/csharp.d.ts +26 -0
  441. package/shared/analyzer/languages/csharp.js +83 -88
  442. package/shared/analyzer/languages/csharp.js.map +1 -0
  443. package/shared/analyzer/languages/generic.d.ts +23 -0
  444. package/shared/analyzer/languages/generic.js +94 -105
  445. package/shared/analyzer/languages/generic.js.map +1 -0
  446. package/shared/analyzer/languages/go.d.ts +24 -0
  447. package/shared/analyzer/languages/go.js +45 -54
  448. package/shared/analyzer/languages/go.js.map +1 -0
  449. package/shared/analyzer/languages/index.d.ts +6 -0
  450. package/shared/analyzer/languages/index.js +19 -20
  451. package/shared/analyzer/languages/index.js.map +1 -0
  452. package/shared/analyzer/languages/java.d.ts +20 -0
  453. package/shared/analyzer/languages/java.js +73 -78
  454. package/shared/analyzer/languages/java.js.map +1 -0
  455. package/shared/analyzer/languages/javascript.d.ts +12 -0
  456. package/shared/analyzer/languages/javascript.js +258 -209
  457. package/shared/analyzer/languages/javascript.js.map +1 -0
  458. package/shared/analyzer/languages/python.d.ts +23 -0
  459. package/shared/analyzer/languages/python.js +92 -100
  460. package/shared/analyzer/languages/python.js.map +1 -0
  461. package/shared/analyzer/languages/rust.d.ts +17 -0
  462. package/shared/analyzer/languages/rust.js +96 -98
  463. package/shared/analyzer/languages/rust.js.map +1 -0
  464. package/shared/analyzer/languages/typescript.d.ts +11 -0
  465. package/shared/analyzer/languages/typescript.js +117 -116
  466. package/shared/analyzer/languages/typescript.js.map +1 -0
  467. package/shared/analyzer/licenses.d.ts +18 -0
  468. package/shared/analyzer/licenses.js +130 -133
  469. package/shared/analyzer/licenses.js.map +1 -0
  470. package/shared/analyzer/metrics.d.ts +20 -0
  471. package/shared/analyzer/metrics.js +112 -104
  472. package/shared/analyzer/metrics.js.map +1 -0
  473. package/shared/analyzer/pathUtil.d.ts +10 -0
  474. package/shared/analyzer/pathUtil.js +29 -35
  475. package/shared/analyzer/pathUtil.js.map +1 -0
  476. package/shared/analyzer/patterns.d.ts +11 -0
  477. package/shared/analyzer/patterns.js +231 -253
  478. package/shared/analyzer/patterns.js.map +1 -0
  479. package/shared/analyzer/scan.d.ts +62 -0
  480. package/shared/analyzer/scan.js +451 -442
  481. package/shared/analyzer/scan.js.map +1 -0
  482. package/shared/analyzer/scanControl.d.ts +11 -0
  483. package/shared/analyzer/scanControl.js +62 -0
  484. package/shared/analyzer/scanControl.js.map +1 -0
  485. package/shared/analyzer/security.d.ts +18 -0
  486. package/shared/analyzer/security.js +159 -159
  487. package/shared/analyzer/security.js.map +1 -0
  488. package/shared/analyzer/services.d.ts +5 -0
  489. package/shared/analyzer/services.js +141 -138
  490. package/shared/analyzer/services.js.map +1 -0
  491. package/shared/analyzer/stack.d.ts +6 -0
  492. package/shared/analyzer/stack.js +134 -141
  493. package/shared/analyzer/stack.js.map +1 -0
  494. package/shared/analyzer/tour.d.ts +2 -0
  495. package/shared/analyzer/tour.js +45 -53
  496. package/shared/analyzer/tour.js.map +1 -0
  497. package/shared/analyzer/util.d.ts +8 -0
  498. package/shared/analyzer/util.js +130 -76
  499. package/shared/analyzer/util.js.map +1 -0
  500. package/shared/analyzer/workflows.d.ts +8 -0
  501. package/shared/analyzer/workflows.js +139 -134
  502. package/shared/analyzer/workflows.js.map +1 -0
  503. package/shared/contracts.d.ts +250 -0
  504. package/shared/contracts.js +2 -0
  505. package/shared/contracts.js.map +1 -0
  506. package/shared/diagram/aiFacts.d.ts +35 -0
  507. package/shared/diagram/aiFacts.js +102 -105
  508. package/shared/diagram/aiFacts.js.map +1 -0
  509. package/shared/diagram/aiMermaid.d.ts +5 -0
  510. package/shared/diagram/aiMermaid.js +50 -46
  511. package/shared/diagram/aiMermaid.js.map +1 -0
  512. package/shared/diagram/atlas.d.ts +16 -0
  513. package/shared/diagram/atlas.js +51 -60
  514. package/shared/diagram/atlas.js.map +1 -0
  515. package/shared/diagram/mermaid.d.ts +43 -0
  516. package/shared/diagram/mermaid.js +348 -370
  517. package/shared/diagram/mermaid.js.map +1 -0
  518. package/shared/review/contracts.d.ts +95 -0
  519. package/shared/review/contracts.js +2 -0
  520. package/shared/review/contracts.js.map +1 -0
  521. package/shared/review/review.d.ts +10 -0
  522. package/shared/review/review.js +184 -0
  523. package/shared/review/review.js.map +1 -0
  524. package/shared/search/query.d.ts +32 -0
  525. package/shared/search/query.js +395 -388
  526. package/shared/search/query.js.map +1 -0
package/server/http.js CHANGED
@@ -2,54 +2,47 @@
2
2
  // does. Pulled out of the router so a handler can be read on its own, and so
3
3
  // the body limit is one number in one place rather than a check repeated per
4
4
  // route and forgotten on the next one.
5
-
6
- // A scan request carries a path or a URL; an explain request carries a prompt
7
- // and a slice of facts. Two megabytes is far more than either needs, and the
8
- // point is to have a ceiling at all: a local server with no auth should not let
9
- // a stray fetch hold memory open.
10
5
  export const MAX_BODY_BYTES = 2 * 1024 * 1024;
11
-
12
6
  // Resolves to the parsed JSON body, or `{}` for an empty one — a POST with no
13
7
  // body is a valid "just the defaults" request and every caller would otherwise
14
8
  // need the same guard. Rejects on oversized or malformed input; the router turns
15
9
  // that into a 500 with the message.
16
10
  export function readBody(req, limit = MAX_BODY_BYTES) {
17
- return new Promise((resolve, reject) => {
18
- let size = 0;
19
- const chunks = [];
20
- req.on('data', (chunk) => {
21
- size += chunk.length;
22
- if (size > limit) {
23
- reject(new Error('Request body too large.'));
24
- req.destroy();
25
- return;
26
- }
27
- chunks.push(chunk);
11
+ return new Promise((resolve, reject) => {
12
+ let size = 0;
13
+ const chunks = [];
14
+ req.on('data', (chunk) => {
15
+ size += chunk.length;
16
+ if (size > limit) {
17
+ reject(new Error('Request body too large.'));
18
+ req.destroy();
19
+ return;
20
+ }
21
+ chunks.push(chunk);
22
+ });
23
+ req.on('end', () => {
24
+ try {
25
+ resolve(chunks.length ? JSON.parse(Buffer.concat(chunks).toString('utf8')) : {});
26
+ }
27
+ catch {
28
+ reject(new Error('The request body was not valid JSON.'));
29
+ }
30
+ });
31
+ req.on('error', reject);
28
32
  });
29
- req.on('end', () => {
30
- try {
31
- resolve(chunks.length ? JSON.parse(Buffer.concat(chunks).toString('utf8')) : {});
32
- } catch {
33
- reject(new Error('The request body was not valid JSON.'));
34
- }
35
- });
36
- req.on('error', reject);
37
- });
38
33
  }
39
-
40
34
  export function sendJSON(res, status, data, headers = {}) {
41
- res.writeHead(status, { 'content-type': 'application/json; charset=utf-8', ...headers });
42
- res.end(JSON.stringify(data));
35
+ res.writeHead(status, { 'content-type': 'application/json; charset=utf-8', ...headers });
36
+ res.end(JSON.stringify(data));
43
37
  }
44
-
45
38
  // Every error the UI shows comes back through here, so the shape is fixed:
46
39
  // `{ error }` with a sentence a person can act on. The front end reads `.error`
47
40
  // and nothing else.
48
41
  export function sendError(res, status, message) {
49
- sendJSON(res, status, { error: message });
42
+ sendJSON(res, status, { error: message });
50
43
  }
51
-
52
44
  export function sendText(res, status, text) {
53
- res.writeHead(status, { 'content-type': 'text/plain; charset=utf-8' });
54
- res.end(text);
45
+ res.writeHead(status, { 'content-type': 'text/plain; charset=utf-8' });
46
+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QACH,CAAC,CAAC,CAAC;QACH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAmB,EAAE,MAAc,EAAE,IAAa,EAAE,OAAO,GAA+C,EAAE;IACnI,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,iCAAiC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACzF,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;AAChC,CAAC;AAED,2EAA2E;AAC3E,gFAAgF;AAChF,oBAAoB;AACpB,MAAM,UAAU,SAAS,CAAC,GAAmB,EAAE,MAAc,EAAE,OAAe;IAC5E,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAmB,EAAE,MAAc,EAAE,IAAY;IACxE,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,2BAA2B,EAAE,CAAC,CAAC;IACvE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC","sourcesContent":["// Reading a request body and writing a response — the two things every route\n// does. Pulled out of the router so a handler can be read on its own, and so\n// the body limit is one number in one place rather than a check repeated per\n// route and forgotten on the next one.\n\n// A scan request carries a path or a URL; an explain request carries a prompt\n// and a slice of facts. Two megabytes is far more than either needs, and the\n// point is to have a ceiling at all: a local server with no auth should not let\n// a stray fetch hold memory open.\nimport type { IncomingMessage, ServerResponse } from 'node:http';\n\nexport const MAX_BODY_BYTES = 2 * 1024 * 1024;\n\n// Resolves to the parsed JSON body, or `{}` for an empty one — a POST with no\n// body is a valid \"just the defaults\" request and every caller would otherwise\n// need the same guard. Rejects on oversized or malformed input; the router turns\n// that into a 500 with the message.\nexport function readBody(req: IncomingMessage, limit = MAX_BODY_BYTES): Promise<unknown> {\n return new Promise((resolve, reject) => {\n let size = 0;\n const chunks: Buffer[] = [];\n req.on('data', (chunk: Buffer) => {\n size += chunk.length;\n if (size > limit) {\n reject(new Error('Request body too large.'));\n req.destroy();\n return;\n }\n chunks.push(chunk);\n });\n req.on('end', () => {\n try {\n resolve(chunks.length ? JSON.parse(Buffer.concat(chunks).toString('utf8')) : {});\n } catch {\n reject(new Error('The request body was not valid JSON.'));\n }\n });\n req.on('error', reject);\n });\n}\n\nexport function sendJSON(res: ServerResponse, status: number, data: unknown, headers: Record<string, string | number | string[]> = {}) {\n res.writeHead(status, { 'content-type': 'application/json; charset=utf-8', ...headers });\n res.end(JSON.stringify(data));\n}\n\n// Every error the UI shows comes back through here, so the shape is fixed:\n// `{ error }` with a sentence a person can act on. The front end reads `.error`\n// and nothing else.\nexport function sendError(res: ServerResponse, status: number, message: string) {\n sendJSON(res, status, { error: message });\n}\n\nexport function sendText(res: ServerResponse, status: number, text: string) {\n res.writeHead(status, { 'content-type': 'text/plain; charset=utf-8' });\n res.end(text);\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function rebindingReason(req: any, extraHosts?: any[]): string;
2
+ export declare function crossOriginReason(req: any): string;
@@ -6,22 +6,18 @@
6
6
  // authenticate. Both exist to stop some *other* page the user happens to have
7
7
  // open from driving this server on their behalf. Binding to 127.0.0.1 keeps
8
8
  // the network out; it does nothing about the browser, which is already inside.
9
-
10
9
  import net from 'node:net';
11
-
12
10
  const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]', '::1']);
13
-
14
11
  // "localhost:4310" -> "localhost", "[::1]:4310" -> "[::1]"
15
12
  function hostnameOf(hostHeader) {
16
- const raw = String(hostHeader ?? '').trim().toLowerCase();
17
- if (raw.startsWith('[')) {
18
- const close = raw.indexOf(']');
19
- return close === -1 ? raw : raw.slice(0, close + 1);
20
- }
21
- const colon = raw.lastIndexOf(':');
22
- return colon === -1 ? raw : raw.slice(0, colon);
13
+ const raw = String(hostHeader ?? '').trim().toLowerCase();
14
+ if (raw.startsWith('[')) {
15
+ const close = raw.indexOf(']');
16
+ return close === -1 ? raw : raw.slice(0, close + 1);
17
+ }
18
+ const colon = raw.lastIndexOf(':');
19
+ return colon === -1 ? raw : raw.slice(0, colon);
23
20
  }
24
-
25
21
  // DNS rebinding, the attack this server's loopback bind does not cover: a page
26
22
  // on evil.com whose DNS answer flips to 127.0.0.1 reaches us anyway, and from
27
23
  // then on the browser treats evil.com as the same origin as everything we
@@ -38,25 +34,31 @@ function hostnameOf(hostHeader) {
38
34
  //
39
35
  // Returns null when the request is fine, or a short reason when it isn't.
40
36
  export function rebindingReason(req, extraHosts = []) {
41
- const host = req.headers?.host;
42
- if (!host) return 'The request arrived with no Host header.';
43
- const name = hostnameOf(host);
44
- if (LOOPBACK_HOSTS.has(name)) return null;
45
- for (const extra of extraHosts) {
46
- if (extra === 'ip:*' && net.isIP(name.replace(/^\[|\]$/g, '')) > 0) return null;
47
- if (extra === 'ipv4:*' && net.isIP(name) === 4) return null;
48
- if (extra === 'ipv6:*' && net.isIP(name.replace(/^\[|\]$/g, '')) === 6) return null;
49
- if (extra.startsWith('*.')) {
50
- // "*.trycloudflare.com" matches "abc.trycloudflare.com" but not the bare
51
- // suffix itself and not "evil-trycloudflare.com".
52
- if (name.endsWith(extra.slice(1)) && name.length > extra.length) return null;
53
- } else if (name === extra) {
54
- return null;
37
+ const host = req.headers?.host;
38
+ if (!host)
39
+ return 'The request arrived with no Host header.';
40
+ const name = hostnameOf(host);
41
+ if (LOOPBACK_HOSTS.has(name))
42
+ return null;
43
+ for (const extra of extraHosts) {
44
+ if (extra === 'ip:*' && net.isIP(name.replace(/^\[|\]$/g, '')) > 0)
45
+ return null;
46
+ if (extra === 'ipv4:*' && net.isIP(name) === 4)
47
+ return null;
48
+ if (extra === 'ipv6:*' && net.isIP(name.replace(/^\[|\]$/g, '')) === 6)
49
+ return null;
50
+ if (extra.startsWith('*.')) {
51
+ // "*.trycloudflare.com" matches "abc.trycloudflare.com" but not the bare
52
+ // suffix itself and not "evil-trycloudflare.com".
53
+ if (name.endsWith(extra.slice(1)) && name.length > extra.length)
54
+ return null;
55
+ }
56
+ else if (name === extra) {
57
+ return null;
58
+ }
55
59
  }
56
- }
57
- return `It arrived addressed to ${name}.`;
60
+ return `It arrived addressed to ${name}.`;
58
61
  }
59
-
60
62
  // Cross-site requests: any page in the browser can POST here without being
61
63
  // able to read the answer, and "without being able to read the answer" is not
62
64
  // the same as harmless — /api/scan walks a directory the caller names, and
@@ -74,19 +76,21 @@ export function rebindingReason(req, extraHosts = []) {
74
76
  // A request carrying neither header isn't a browser at all — curl, a test, a
75
77
  // script — and there is no cross-site story for those, so they pass.
76
78
  export function crossOriginReason(req) {
77
- const site = req.headers?.['sec-fetch-site'];
78
- if (site && site !== 'same-origin' && site !== 'none') {
79
- return `The browser reported it as ${site}.`;
80
- }
81
- const origin = req.headers?.origin;
82
- if (origin) {
83
- // The host was just vetted by the rebinding check, so the origin only has
84
- // to agree with it. Both schemes are accepted: a self-hosted server behind
85
- // a tunnel is reached over https while the page's fetches still arrive
86
- // here addressed to the same host the tunnel forwarded.
87
- const host = String(req.headers.host ?? '').trim().toLowerCase();
88
- const expected = new Set(['http://' + host, 'https://' + host]);
89
- if (!expected.has(String(origin).trim().toLowerCase())) return `It came from ${origin}.`;
90
- }
91
- return null;
79
+ const site = req.headers?.['sec-fetch-site'];
80
+ if (site && site !== 'same-origin' && site !== 'none') {
81
+ return `The browser reported it as ${site}.`;
82
+ }
83
+ const origin = req.headers?.origin;
84
+ if (origin) {
85
+ // The host was just vetted by the rebinding check, so the origin only has
86
+ // to agree with it. Both schemes are accepted: a self-hosted server behind
87
+ // a tunnel is reached over https while the page's fetches still arrive
88
+ // here addressed to the same host the tunnel forwarded.
89
+ const host = String(req.headers.host ?? '').trim().toLowerCase();
90
+ const expected = new Set(['http://' + host, 'https://' + host]);
91
+ if (!expected.has(String(origin).trim().toLowerCase()))
92
+ return `It came from ${origin}.`;
93
+ }
94
+ return null;
92
95
  }
96
+ //# sourceMappingURL=httpGuards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpGuards.js","sourceRoot":"","sources":["../src/server/httpGuards.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,4EAA4E;AAC5E,iCAAiC;AACjC,EAAE;AACF,qEAAqE;AACrE,8EAA8E;AAC9E,4EAA4E;AAC5E,+EAA+E;AAE/E,OAAO,GAAG,MAAM,UAAU,CAAC;AAE3B,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAE3E,2DAA2D;AAC3D,SAAS,UAAU,CAAC,UAAU;IAC5B,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC1D,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC/B,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;IACD,MAAM,KAAK,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAClD,CAAC;AAED,+EAA+E;AAC/E,8EAA8E;AAC9E,0EAA0E;AAC1E,0EAA0E;AAC1E,6EAA6E;AAC7E,4CAA4C;AAC5C,EAAE;AACF,4EAA4E;AAC5E,+EAA+E;AAC/E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5C,CAAC;AAED,2EAA2E;AAC3E,8EAA8E;AAC9E,2EAA2E;AAC3E,sDAAsD;AACtD,EAAE;AACF,iEAAiE;AACjE,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,sEAAsE;AACtE,8EAA8E;AAC9E,+EAA+E;AAC/E,mDAAmD;AACnD,EAAE;AACF,6EAA6E;AAC7E,qEAAqE;AACrE,MAAM,UAAU,iBAAiB,CAAC,GAAG;IACnC,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,gBAAgB,CAAC,CAAC;IAC7C,IAAI,IAAI,IAAI,IAAI,KAAK,aAAa,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACtD,OAAO,8BAA8B,IAAI,GAAG,CAAC;IAC/C,CAAC;IACD,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC;IACnC,IAAI,MAAM,EAAE,CAAC;QACX,0EAA0E;QAC1E,2EAA2E;QAC3E,uEAAuE;QACvE,wDAAwD;QACxD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACjE,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,GAAG,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC;QAChE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YAAE,OAAO,gBAAgB,MAAM,GAAG,CAAC;IAC3F,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// Two questions worth asking about a request before it is allowed to do\n// anything: did it arrive at a name that really is this machine, and did it\n// come from this app's own page?\n//\n// Neither is authentication — a single-user local tool has nobody to\n// authenticate. Both exist to stop some *other* page the user happens to have\n// open from driving this server on their behalf. Binding to 127.0.0.1 keeps\n// the network out; it does nothing about the browser, which is already inside.\n\nimport net from 'node:net';\n\nconst LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]', '::1']);\n\n// \"localhost:4310\" -> \"localhost\", \"[::1]:4310\" -> \"[::1]\"\nfunction hostnameOf(hostHeader) {\n const raw = String(hostHeader ?? '').trim().toLowerCase();\n if (raw.startsWith('[')) {\n const close = raw.indexOf(']');\n return close === -1 ? raw : raw.slice(0, close + 1);\n }\n const colon = raw.lastIndexOf(':');\n return colon === -1 ? raw : raw.slice(0, colon);\n}\n\n// DNS rebinding, the attack this server's loopback bind does not cover: a page\n// on evil.com whose DNS answer flips to 127.0.0.1 reaches us anyway, and from\n// then on the browser treats evil.com as the same origin as everything we\n// return — so the origin check below is looking at `same-origin` and sees\n// nothing wrong. What still gives it away is the Host header, which the page\n// cannot set and which still says evil.com.\n//\n// `extraHosts` is the self-hosted escape hatch: the domain and bind address\n// from the settings file, so a server that was deliberately put on the network\n// answers to its own name and nothing else. A local server passes nothing and\n// keeps the loopback-only rule. Entries may be exact names or `*.suffix`\n// wildcards — enabled tunnels put their random upstream names here, which\n// cannot be known ahead of time.\n//\n// Returns null when the request is fine, or a short reason when it isn't.\nexport function rebindingReason(req, extraHosts = []) {\n const host = req.headers?.host;\n if (!host) return 'The request arrived with no Host header.';\n const name = hostnameOf(host);\n if (LOOPBACK_HOSTS.has(name)) return null;\n for (const extra of extraHosts) {\n if (extra === 'ip:*' && net.isIP(name.replace(/^\\[|\\]$/g, '')) > 0) return null;\n if (extra === 'ipv4:*' && net.isIP(name) === 4) return null;\n if (extra === 'ipv6:*' && net.isIP(name.replace(/^\\[|\\]$/g, '')) === 6) return null;\n if (extra.startsWith('*.')) {\n // \"*.trycloudflare.com\" matches \"abc.trycloudflare.com\" but not the bare\n // suffix itself and not \"evil-trycloudflare.com\".\n if (name.endsWith(extra.slice(1)) && name.length > extra.length) return null;\n } else if (name === extra) {\n return null;\n }\n }\n return `It arrived addressed to ${name}.`;\n}\n\n// Cross-site requests: any page in the browser can POST here without being\n// able to read the answer, and \"without being able to read the answer\" is not\n// the same as harmless — /api/scan walks a directory the caller names, and\n// /api/explain will POST to any URL the caller names.\n//\n// Two signals, and a request only has to fail one to be refused:\n//\n// Sec-Fetch-Site set by the browser, unsettable by page script. `none`\n// means the user did it themselves — typed the URL, opened\n// a bookmark — which no attacking page can arrange.\n// Origin sent on every fetch that isn't GET/HEAD. Compared against\n// this server's own origin, which is `http://` plus the Host\n// we just confirmed is loopback.\n//\n// A request carrying neither header isn't a browser at all — curl, a test, a\n// script — and there is no cross-site story for those, so they pass.\nexport function crossOriginReason(req) {\n const site = req.headers?.['sec-fetch-site'];\n if (site && site !== 'same-origin' && site !== 'none') {\n return `The browser reported it as ${site}.`;\n }\n const origin = req.headers?.origin;\n if (origin) {\n // The host was just vetted by the rebinding check, so the origin only has\n // to agree with it. Both schemes are accepted: a self-hosted server behind\n // a tunnel is reached over https while the page's fetches still arrive\n // here addressed to the same host the tunnel forwarded.\n const host = String(req.headers.host ?? '').trim().toLowerCase();\n const expected = new Set(['http://' + host, 'https://' + host]);\n if (!expected.has(String(origin).trim().toLowerCase())) return `It came from ${origin}.`;\n }\n return null;\n}\n"]}
@@ -0,0 +1,34 @@
1
+ export declare function caddyfilePath(configFile?: string): string;
2
+ export declare function renderCaddyfile(settings: any): string;
3
+ export declare function httpsReadiness(settings: any, { configFile, resolve, probe, tool, running }?: Record<string, any>): Promise<{
4
+ ok: boolean;
5
+ checks: {
6
+ id: string;
7
+ ok: boolean;
8
+ required: boolean;
9
+ detail: string;
10
+ }[];
11
+ caddy: any;
12
+ addresses: any[];
13
+ local: any[];
14
+ }>;
15
+ export declare function httpsStatus(settings: any, configFile?: string): {
16
+ enabled: boolean;
17
+ domain: string;
18
+ url: string;
19
+ caddyfile: string;
20
+ caddyInstalled: boolean;
21
+ caddyVersion: string;
22
+ configured: boolean;
23
+ command: string;
24
+ };
25
+ export declare function writeCaddyfile(settings: any, configFile?: string): Promise<string>;
26
+ export declare function caddyValidate(settings: any, configFile?: string): Promise<{
27
+ file: string;
28
+ output: string;
29
+ }>;
30
+ export declare function caddyRun(settings: any, configFile?: string, action?: string): {
31
+ action: string;
32
+ file: string;
33
+ output: string;
34
+ };
package/server/https.js CHANGED
@@ -4,139 +4,149 @@ import net from 'node:net';
4
4
  import os from 'node:os';
5
5
  import path from 'node:path';
6
6
  import { spawnSync } from 'node:child_process';
7
-
8
7
  import { configPath, normalizeSettings } from './config.js';
9
8
  import { findOnPath, installHint } from './tunnel.js';
10
-
11
9
  export function caddyfilePath(configFile = configPath()) {
12
- return path.join(path.dirname(configFile), 'Caddyfile');
10
+ return path.join(path.dirname(configFile), 'Caddyfile');
13
11
  }
14
-
15
12
  export function renderCaddyfile(settings) {
16
- const s = normalizeSettings(settings);
17
- if (!s.domain) throw new Error('HTTPS needs a domain. Run `onboarder setup` and enter one first.');
18
- return `# Managed by Onboarder. Edits are replaced by \`onboarder https setup\`.\n${s.domain} {\n reverse_proxy 127.0.0.1:${s.port}\n}\n`;
13
+ const s = normalizeSettings(settings);
14
+ if (!s.domain)
15
+ throw new Error('HTTPS needs a domain. Run `onboarder setup` and enter one first.');
16
+ return `# Managed by Onboarder. Edits are replaced by \`onboarder https setup\`.\n${s.domain} {\n reverse_proxy 127.0.0.1:${s.port}\n}\n`;
19
17
  }
20
-
21
18
  function portIsFree(port, host = '0.0.0.0') {
22
- return new Promise((resolve) => {
23
- const probe = net.createServer();
24
- probe.once('error', () => resolve(false));
25
- probe.listen(port, host, () => probe.close(() => resolve(true)));
26
- });
19
+ return new Promise((resolve) => {
20
+ const probe = net.createServer();
21
+ probe.once('error', () => resolve(false));
22
+ probe.listen(port, host, () => probe.close(() => resolve(true)));
23
+ });
27
24
  }
28
-
29
25
  async function resolveDomain(domain) {
30
- const [v4, v6] = await Promise.allSettled([dns.resolve4(domain), dns.resolve6(domain)]);
31
- const addresses = [
32
- ...(v4.status === 'fulfilled' ? v4.value : []),
33
- ...(v6.status === 'fulfilled' ? v6.value : []),
34
- ];
35
- return [...new Set(addresses)];
26
+ const [v4, v6] = await Promise.allSettled([dns.resolve4(domain), dns.resolve6(domain)]);
27
+ const addresses = [
28
+ ...(v4.status === 'fulfilled' ? v4.value : []),
29
+ ...(v6.status === 'fulfilled' ? v6.value : []),
30
+ ];
31
+ return [...new Set(addresses)];
36
32
  }
37
-
38
33
  function localAddresses() {
39
- const found = [];
40
- for (const list of Object.values(os.networkInterfaces())) {
41
- for (const address of list || []) if (!address.internal) found.push(address.address);
42
- }
43
- return found;
34
+ const found = [];
35
+ for (const list of Object.values(os.networkInterfaces())) {
36
+ for (const address of list || [])
37
+ if (!address.internal)
38
+ found.push(address.address);
39
+ }
40
+ return found;
44
41
  }
45
-
46
42
  async function caddyIsRunning(probe = portIsFree) {
47
- // If 80 and 443 are both occupied, probe Caddy's local admin endpoint. This
48
- // distinguishes the Ubuntu service from an unknown listener without sudo.
49
- if (await probe(80)) return false;
50
- if (await probe(443)) return false;
51
- return new Promise((resolve) => {
52
- const socket = net.connect(2019, '127.0.0.1');
53
- const finish = (value) => { socket.destroy(); resolve(value); };
54
- socket.setTimeout(800, () => finish(false));
55
- socket.once('connect', () => finish(true));
56
- socket.once('error', () => finish(false));
57
- });
43
+ // If 80 and 443 are both occupied, probe Caddy's local admin endpoint. This
44
+ // distinguishes the Ubuntu service from an unknown listener without sudo.
45
+ if (await probe(80))
46
+ return false;
47
+ if (await probe(443))
48
+ return false;
49
+ return new Promise((resolve) => {
50
+ const socket = net.connect(2019, '127.0.0.1');
51
+ const finish = (value) => { socket.destroy(); resolve(value); };
52
+ socket.setTimeout(800, () => finish(false));
53
+ socket.once('connect', () => finish(true));
54
+ socket.once('error', () => finish(false));
55
+ });
58
56
  }
59
-
60
57
  export async function httpsReadiness(settings, { configFile = configPath(), resolve = resolveDomain, probe = portIsFree, tool = findOnPath, running = caddyIsRunning } = {}) {
61
- const s = normalizeSettings(settings);
62
- const caddy = tool('caddy');
63
- const checks = [{ id: 'domain', ok: Boolean(s.domain), required: true, detail: s.domain || 'not configured' }];
64
- if (!s.domain) return { ok: false, checks, caddy, addresses: [], local: [] };
65
-
66
- let addresses = [];
67
- let dnsError = '';
68
- try { addresses = await resolve(s.domain); } catch (error) { dnsError = error.code || error.message; }
69
- checks.push({ id: 'dns', ok: addresses.length > 0, required: true, detail: addresses.length ? addresses.join(', ') : `does not resolve${dnsError ? ` (${dnsError})` : ''}` });
70
- const local = localAddresses();
71
- const matches = addresses.some((address) => local.includes(address));
72
- checks.push({ id: 'dns-target', ok: matches, required: false, detail: matches ? 'resolves to this machine' : 'does not match a local interface address (NAT/public-IP and proxy setups can still be valid)' });
73
-
74
- const serviceRunning = await running(probe);
75
- for (const port of [80, 443]) {
76
- const free = await probe(port);
77
- const ownedByCaddy = !free && serviceRunning;
78
- checks.push({
79
- id: `port-${port}`,
80
- ok: free || ownedByCaddy,
81
- required: true,
82
- detail: free ? 'available for Caddy' : ownedByCaddy ? 'in use by the running Caddy service' : 'already in use — stop the existing web server or proxy',
83
- });
84
- }
85
- checks.push({ id: 'caddy', ok: caddy.installed, required: true, detail: caddy.installed ? caddy.version : 'not installed — ' + installHint('caddy') });
86
- return { ok: checks.every((check) => check.ok || !check.required), checks, caddy, addresses, local };
58
+ const s = normalizeSettings(settings);
59
+ const caddy = tool('caddy');
60
+ const checks = [{ id: 'domain', ok: Boolean(s.domain), required: true, detail: s.domain || 'not configured' }];
61
+ if (!s.domain)
62
+ return { ok: false, checks, caddy, addresses: [], local: [] };
63
+ let addresses = [];
64
+ let dnsError = '';
65
+ try {
66
+ addresses = await resolve(s.domain);
67
+ }
68
+ catch (error) {
69
+ dnsError = error.code || error.message;
70
+ }
71
+ checks.push({ id: 'dns', ok: addresses.length > 0, required: true, detail: addresses.length ? addresses.join(', ') : `does not resolve${dnsError ? ` (${dnsError})` : ''}` });
72
+ const local = localAddresses();
73
+ const matches = addresses.some((address) => local.includes(address));
74
+ checks.push({ id: 'dns-target', ok: matches, required: false, detail: matches ? 'resolves to this machine' : 'does not match a local interface address (NAT/public-IP and proxy setups can still be valid)' });
75
+ const serviceRunning = await running(probe);
76
+ for (const port of [80, 443]) {
77
+ const free = await probe(port);
78
+ const ownedByCaddy = !free && serviceRunning;
79
+ checks.push({
80
+ id: `port-${port}`,
81
+ ok: free || ownedByCaddy,
82
+ required: true,
83
+ detail: free ? 'available for Caddy' : ownedByCaddy ? 'in use by the running Caddy service' : 'already in use — stop the existing web server or proxy',
84
+ });
85
+ }
86
+ checks.push({ id: 'caddy', ok: caddy.installed, required: true, detail: caddy.installed ? caddy.version : 'not installed — ' + installHint('caddy') });
87
+ return { ok: checks.every((check) => check.ok || !check.required), checks, caddy, addresses, local };
87
88
  }
88
-
89
89
  export function httpsStatus(settings, configFile = configPath()) {
90
- const s = normalizeSettings(settings);
91
- const file = caddyfilePath(configFile);
92
- const caddy = findOnPath('caddy');
93
- let configured = false;
94
- try { configured = Boolean(statSync(file)); } catch { configured = false; }
95
- return {
96
- enabled: Boolean(s.domain && s.https),
97
- domain: s.domain,
98
- url: s.domain && s.https ? `https://${s.domain}` : '',
99
- caddyfile: file,
100
- caddyInstalled: caddy.installed,
101
- caddyVersion: caddy.version || '',
102
- configured,
103
- command: s.domain && s.https ? `caddy start --config ${file}` : '',
104
- };
90
+ const s = normalizeSettings(settings);
91
+ const file = caddyfilePath(configFile);
92
+ const caddy = findOnPath('caddy');
93
+ let configured = false;
94
+ try {
95
+ configured = Boolean(statSync(file));
96
+ }
97
+ catch {
98
+ configured = false;
99
+ }
100
+ return {
101
+ enabled: Boolean(s.domain && s.https),
102
+ domain: s.domain,
103
+ url: s.domain && s.https ? `https://${s.domain}` : '',
104
+ caddyfile: file,
105
+ caddyInstalled: caddy.installed,
106
+ caddyVersion: caddy.version || '',
107
+ configured,
108
+ command: s.domain && s.https ? `caddy start --config ${file}` : '',
109
+ };
105
110
  }
106
-
107
111
  export async function writeCaddyfile(settings, configFile = configPath()) {
108
- const file = caddyfilePath(configFile);
109
- await fs.mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
110
- await fs.writeFile(file, renderCaddyfile(settings), { encoding: 'utf8', mode: 0o600 });
111
- return file;
112
+ const file = caddyfilePath(configFile);
113
+ await fs.mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
114
+ await fs.writeFile(file, renderCaddyfile(settings), { encoding: 'utf8', mode: 0o600 });
115
+ return file;
112
116
  }
113
-
114
117
  export async function caddyValidate(settings, configFile = configPath()) {
115
- const s = normalizeSettings(settings);
116
- if (!s.domain) throw new Error('HTTPS needs a domain. Run `onboarder setup` and enter one first.');
117
- const caddy = findOnPath('caddy');
118
- if (!caddy.installed) throw new Error('Caddy is not installed. ' + installHint('caddy'));
119
- const file = caddyfilePath(configFile);
120
- const result = spawnSync('caddy', ['validate', '--config', file], { encoding: 'utf8' });
121
- if (result.error) throw result.error;
122
- if (result.status !== 0) throw new Error(String(result.stderr || result.stdout || 'Caddy configuration is invalid.').trim());
123
- return { file, output: String(result.stdout || result.stderr || '').trim() };
118
+ const s = normalizeSettings(settings);
119
+ if (!s.domain)
120
+ throw new Error('HTTPS needs a domain. Run `onboarder setup` and enter one first.');
121
+ const caddy = findOnPath('caddy');
122
+ if (!caddy.installed)
123
+ throw new Error('Caddy is not installed. ' + installHint('caddy'));
124
+ const file = caddyfilePath(configFile);
125
+ const result = spawnSync('caddy', ['validate', '--config', file], { encoding: 'utf8' });
126
+ if (result.error)
127
+ throw result.error;
128
+ if (result.status !== 0)
129
+ throw new Error(String(result.stderr || result.stdout || 'Caddy configuration is invalid.').trim());
130
+ return { file, output: String(result.stdout || result.stderr || '').trim() };
124
131
  }
125
-
126
132
  export function caddyRun(settings, configFile = configPath(), action = 'start') {
127
- const s = normalizeSettings(settings);
128
- if (!s.domain || !s.https) throw new Error('Enable HTTPS with a domain first: `onboarder setup`.');
129
- const caddy = findOnPath('caddy');
130
- if (!caddy.installed) throw new Error('Caddy is not installed. ' + installHint('caddy'));
131
- const file = caddyfilePath(configFile);
132
- const result = spawnSync('caddy', [action, '--config', file], { encoding: 'utf8' });
133
- if (result.error) throw result.error;
134
- if (result.status !== 0) {
135
- const message = String(result.stderr || result.stdout || `caddy ${action} failed`).trim();
136
- if (/permission denied|address already in use/i.test(message) && process.platform !== 'win32') {
137
- throw new Error(`${message}\nStart the packaged service with: sudo systemctl enable --now caddy`);
133
+ const s = normalizeSettings(settings);
134
+ if (!s.domain || !s.https)
135
+ throw new Error('Enable HTTPS with a domain first: `onboarder setup`.');
136
+ const caddy = findOnPath('caddy');
137
+ if (!caddy.installed)
138
+ throw new Error('Caddy is not installed. ' + installHint('caddy'));
139
+ const file = caddyfilePath(configFile);
140
+ const result = spawnSync('caddy', [action, '--config', file], { encoding: 'utf8' });
141
+ if (result.error)
142
+ throw result.error;
143
+ if (result.status !== 0) {
144
+ const message = String(result.stderr || result.stdout || `caddy ${action} failed`).trim();
145
+ if (/permission denied|address already in use/i.test(message) && process.platform !== 'win32') {
146
+ throw new Error(`${message}\nStart the packaged service with: sudo systemctl enable --now caddy`);
147
+ }
148
+ throw new Error(message);
138
149
  }
139
- throw new Error(message);
140
- }
141
- return { action, file, output: String(result.stdout || result.stderr || '').trim() };
150
+ return { action, file, output: String(result.stdout || result.stderr || '').trim() };
142
151
  }
152
+ //# sourceMappingURL=https.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"https.js","sourceRoot":"","sources":["../src/server/https.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,GAAG,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,a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AE,CAAC;QAC1F,IAAI,2CAA2C,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YAC9F,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,sEAAsE,CAAC,CAAC;QACpG,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AACvF,CAAC","sourcesContent":["import { promises as dns } from 'node:dns';\nimport { promises as fs, statSync } from 'node:fs';\nimport net from 'node:net';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { spawnSync } from 'node:child_process';\n\nimport { configPath, normalizeSettings } from './config.js';\nimport { findOnPath, installHint } from './tunnel.js';\n\nexport function caddyfilePath(configFile = configPath()) {\n return path.join(path.dirname(configFile), 'Caddyfile');\n}\n\nexport function renderCaddyfile(settings) {\n const s = normalizeSettings(settings);\n if (!s.domain) throw new Error('HTTPS needs a domain. Run `onboarder setup` and enter one first.');\n return `# Managed by Onboarder. Edits are replaced by \\`onboarder https setup\\`.\\n${s.domain} {\\n reverse_proxy 127.0.0.1:${s.port}\\n}\\n`;\n}\n\nfunction portIsFree(port, host = '0.0.0.0') {\n return new Promise((resolve) => {\n const probe = net.createServer();\n probe.once('error', () => resolve(false));\n probe.listen(port, host, () => probe.close(() => resolve(true)));\n });\n}\n\nasync function resolveDomain(domain) {\n const [v4, v6] = await Promise.allSettled([dns.resolve4(domain), dns.resolve6(domain)]);\n const addresses = [\n ...(v4.status === 'fulfilled' ? v4.value : []),\n ...(v6.status === 'fulfilled' ? v6.value : []),\n ];\n return [...new Set(addresses)];\n}\n\nfunction localAddresses() {\n const found = [];\n for (const list of Object.values(os.networkInterfaces())) {\n for (const address of list || []) if (!address.internal) found.push(address.address);\n }\n return found;\n}\n\nasync function caddyIsRunning(probe = portIsFree) {\n // If 80 and 443 are both occupied, probe Caddy's local admin endpoint. This\n // distinguishes the Ubuntu service from an unknown listener without sudo.\n if (await probe(80)) return false;\n if (await probe(443)) return false;\n return new Promise((resolve) => {\n const socket = net.connect(2019, '127.0.0.1');\n const finish = (value) => { socket.destroy(); resolve(value); };\n socket.setTimeout(800, () => finish(false));\n socket.once('connect', () => finish(true));\n socket.once('error', () => finish(false));\n });\n}\n\nexport async function httpsReadiness(settings, { configFile = configPath(), resolve = resolveDomain, probe = portIsFree, tool = findOnPath, running = caddyIsRunning }: Record<string, any> = {}) {\n const s = normalizeSettings(settings);\n const caddy = tool('caddy');\n const checks = [{ id: 'domain', ok: Boolean(s.domain), required: true, detail: s.domain || 'not configured' }];\n if (!s.domain) return { ok: false, checks, caddy, addresses: [], local: [] };\n\n let addresses = [];\n let dnsError = '';\n try { addresses = await resolve(s.domain); } catch (error) { dnsError = error.code || error.message; }\n checks.push({ id: 'dns', ok: addresses.length > 0, required: true, detail: addresses.length ? addresses.join(', ') : `does not resolve${dnsError ? ` (${dnsError})` : ''}` });\n const local = localAddresses();\n const matches = addresses.some((address) => local.includes(address));\n checks.push({ id: 'dns-target', ok: matches, required: false, detail: matches ? 'resolves to this machine' : 'does not match a local interface address (NAT/public-IP and proxy setups can still be valid)' });\n\n const serviceRunning = await running(probe);\n for (const port of [80, 443]) {\n const free = await probe(port);\n const ownedByCaddy = !free && serviceRunning;\n checks.push({\n id: `port-${port}`,\n ok: free || ownedByCaddy,\n required: true,\n detail: free ? 'available for Caddy' : ownedByCaddy ? 'in use by the running Caddy service' : 'already in use — stop the existing web server or proxy',\n });\n }\n checks.push({ id: 'caddy', ok: caddy.installed, required: true, detail: caddy.installed ? caddy.version : 'not installed — ' + installHint('caddy') });\n return { ok: checks.every((check) => check.ok || !check.required), checks, caddy, addresses, local };\n}\n\nexport function httpsStatus(settings, configFile = configPath()) {\n const s = normalizeSettings(settings);\n const file = caddyfilePath(configFile);\n const caddy = findOnPath('caddy');\n let configured = false;\n try { configured = Boolean(statSync(file)); } catch { configured = false; }\n return {\n enabled: Boolean(s.domain && s.https),\n domain: s.domain,\n url: s.domain && s.https ? `https://${s.domain}` : '',\n caddyfile: file,\n caddyInstalled: caddy.installed,\n caddyVersion: caddy.version || '',\n configured,\n command: s.domain && s.https ? `caddy start --config ${file}` : '',\n };\n}\n\nexport async function writeCaddyfile(settings, configFile = configPath()) {\n const file = caddyfilePath(configFile);\n await fs.mkdir(path.dirname(file), { recursive: true, mode: 0o700 });\n await fs.writeFile(file, renderCaddyfile(settings), { encoding: 'utf8', mode: 0o600 });\n return file;\n}\n\nexport async function caddyValidate(settings, configFile = configPath()) {\n const s = normalizeSettings(settings);\n if (!s.domain) throw new Error('HTTPS needs a domain. Run `onboarder setup` and enter one first.');\n const caddy = findOnPath('caddy');\n if (!caddy.installed) throw new Error('Caddy is not installed. ' + installHint('caddy'));\n const file = caddyfilePath(configFile);\n const result = spawnSync('caddy', ['validate', '--config', file], { encoding: 'utf8' });\n if (result.error) throw result.error;\n if (result.status !== 0) throw new Error(String(result.stderr || result.stdout || 'Caddy configuration is invalid.').trim());\n return { file, output: String(result.stdout || result.stderr || '').trim() };\n}\n\nexport function caddyRun(settings, configFile = configPath(), action = 'start') {\n const s = normalizeSettings(settings);\n if (!s.domain || !s.https) throw new Error('Enable HTTPS with a domain first: `onboarder setup`.');\n const caddy = findOnPath('caddy');\n if (!caddy.installed) throw new Error('Caddy is not installed. ' + installHint('caddy'));\n const file = caddyfilePath(configFile);\n const result = spawnSync('caddy', [action, '--config', file], { encoding: 'utf8' });\n if (result.error) throw result.error;\n if (result.status !== 0) {\n const message = String(result.stderr || result.stdout || `caddy ${action} failed`).trim();\n if (/permission denied|address already in use/i.test(message) && process.platform !== 'win32') {\n throw new Error(`${message}\\nStart the packaged service with: sudo systemctl enable --now caddy`);\n }\n throw new Error(message);\n }\n return { action, file, output: String(result.stdout || result.stderr || '').trim() };\n}\n"]}
@@ -0,0 +1,40 @@
1
+ import http from 'node:http';
2
+ export declare const CONFIG: {
3
+ projectRoot: string;
4
+ publicDir: string;
5
+ sharedDir: string;
6
+ mcp: import("./mcp/runner.js").McpRunner;
7
+ };
8
+ export declare function createServer(config?: typeof CONFIG & {
9
+ configPath?: string;
10
+ getSettings?: () => Promise<import('../shared/contracts.js').Settings>;
11
+ boot?: {
12
+ host: string;
13
+ port: number;
14
+ domain: string;
15
+ https: boolean;
16
+ };
17
+ }): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
18
+ export declare function startupBanner(settings: any, { configFile, columns }?: Record<string, any>): string;
19
+ export declare function openInBrowser(url: any): void;
20
+ export declare function listenError(error: any, { host, port, pid }?: Record<string, any>): any;
21
+ export declare function startServer({ configFile, openBrowser, log }?: Record<string, any>): Promise<{
22
+ server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
23
+ settings: {
24
+ version: number;
25
+ mode: 'local' | 'self-hosted';
26
+ domain: string;
27
+ https: boolean;
28
+ accessKey: string;
29
+ autoOpen: boolean;
30
+ account: import("../shared/contracts.js").AccountSettings;
31
+ tunnel: {
32
+ cloudflare: boolean;
33
+ tailscale: boolean;
34
+ };
35
+ host: string;
36
+ port: number;
37
+ };
38
+ host: string;
39
+ port: number;
40
+ }>;