ontrackd 0.0.1 → 0.11.1

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 (684) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +133 -2
  3. package/dist/cli/build.d.ts +1 -0
  4. package/dist/cli/build.js +172 -0
  5. package/dist/cli/build.js.map +1 -0
  6. package/dist/cli/cloud.d.ts +20 -0
  7. package/dist/cli/cloud.js +395 -0
  8. package/dist/cli/cloud.js.map +1 -0
  9. package/dist/cli/feedback.d.ts +4 -0
  10. package/dist/cli/feedback.js +90 -0
  11. package/dist/cli/feedback.js.map +1 -0
  12. package/dist/cli/hugo.d.ts +1 -0
  13. package/dist/cli/hugo.js +396 -0
  14. package/dist/cli/hugo.js.map +1 -0
  15. package/dist/cli/init.d.ts +8 -0
  16. package/dist/cli/init.js +346 -0
  17. package/dist/cli/init.js.map +1 -0
  18. package/dist/cli/invite.d.ts +2 -0
  19. package/dist/cli/invite.js +65 -0
  20. package/dist/cli/invite.js.map +1 -0
  21. package/dist/cli/link.d.ts +20 -0
  22. package/dist/cli/link.js +287 -0
  23. package/dist/cli/link.js.map +1 -0
  24. package/dist/cli/pull.d.ts +31 -0
  25. package/dist/cli/pull.js +273 -0
  26. package/dist/cli/pull.js.map +1 -0
  27. package/dist/cli/push.d.ts +9 -0
  28. package/dist/cli/push.js +57 -0
  29. package/dist/cli/push.js.map +1 -0
  30. package/dist/cli/remote.d.ts +1 -0
  31. package/dist/cli/remote.js +114 -0
  32. package/dist/cli/remote.js.map +1 -0
  33. package/dist/cli/serve.d.ts +1 -0
  34. package/dist/cli/serve.js +178 -0
  35. package/dist/cli/serve.js.map +1 -0
  36. package/dist/cli/sidecar.d.ts +9 -0
  37. package/dist/cli/sidecar.js +23 -0
  38. package/dist/cli/sidecar.js.map +1 -0
  39. package/dist/core/anchorId.d.ts +42 -0
  40. package/dist/core/anchorId.js +50 -0
  41. package/dist/core/anchorId.js.map +1 -0
  42. package/dist/core/apiKind.d.ts +42 -0
  43. package/dist/core/apiKind.js +83 -0
  44. package/dist/core/apiKind.js.map +1 -0
  45. package/dist/core/astroAnchors.d.ts +39 -0
  46. package/dist/core/astroAnchors.js +217 -0
  47. package/dist/core/astroAnchors.js.map +1 -0
  48. package/dist/core/attachmentTypes.d.ts +74 -0
  49. package/dist/core/attachmentTypes.js +199 -0
  50. package/dist/core/attachmentTypes.js.map +1 -0
  51. package/dist/core/elementHints.d.ts +40 -0
  52. package/dist/core/elementHints.js +116 -0
  53. package/dist/core/elementHints.js.map +1 -0
  54. package/dist/core/exportTaskDoc.d.ts +81 -0
  55. package/dist/core/exportTaskDoc.js +828 -0
  56. package/dist/core/exportTaskDoc.js.map +1 -0
  57. package/dist/core/feedbackTypes.d.ts +241 -0
  58. package/dist/core/feedbackTypes.js +2 -0
  59. package/dist/core/feedbackTypes.js.map +1 -0
  60. package/dist/core/fingerprint.d.ts +12 -0
  61. package/dist/core/fingerprint.js +24 -0
  62. package/dist/core/fingerprint.js.map +1 -0
  63. package/dist/core/htmlAnchors.d.ts +18 -0
  64. package/dist/core/htmlAnchors.js +157 -0
  65. package/dist/core/htmlAnchors.js.map +1 -0
  66. package/dist/core/imageSniff.d.ts +7 -0
  67. package/dist/core/imageSniff.js +12 -0
  68. package/dist/core/imageSniff.js.map +1 -0
  69. package/dist/core/ordering.d.ts +16 -0
  70. package/dist/core/ordering.js +10 -0
  71. package/dist/core/ordering.js.map +1 -0
  72. package/dist/core/oxcAst.d.ts +39 -0
  73. package/dist/core/oxcAst.js +147 -0
  74. package/dist/core/oxcAst.js.map +1 -0
  75. package/dist/core/pageUrl.d.ts +10 -0
  76. package/dist/core/pageUrl.js +27 -0
  77. package/dist/core/pageUrl.js.map +1 -0
  78. package/dist/core/participants.d.ts +14 -0
  79. package/dist/core/participants.js +38 -0
  80. package/dist/core/participants.js.map +1 -0
  81. package/dist/core/ports.d.ts +86 -0
  82. package/dist/core/ports.js +2 -0
  83. package/dist/core/ports.js.map +1 -0
  84. package/dist/core/projectSecret.d.ts +9 -0
  85. package/dist/core/projectSecret.js +57 -0
  86. package/dist/core/projectSecret.js.map +1 -0
  87. package/dist/core/recipe.d.ts +117 -0
  88. package/dist/core/recipe.js +181 -0
  89. package/dist/core/recipe.js.map +1 -0
  90. package/dist/core/recordingSummary.d.ts +12 -0
  91. package/dist/core/recordingSummary.js +150 -0
  92. package/dist/core/recordingSummary.js.map +1 -0
  93. package/dist/core/resolveAnchors.d.ts +70 -0
  94. package/dist/core/resolveAnchors.js +101 -0
  95. package/dist/core/resolveAnchors.js.map +1 -0
  96. package/dist/core/scriptImport.d.ts +10 -0
  97. package/dist/core/scriptImport.js +18 -0
  98. package/dist/core/scriptImport.js.map +1 -0
  99. package/dist/core/sourceAnchors.d.ts +62 -0
  100. package/dist/core/sourceAnchors.js +82 -0
  101. package/dist/core/sourceAnchors.js.map +1 -0
  102. package/dist/core/sourceContext.d.ts +62 -0
  103. package/dist/core/sourceContext.js +182 -0
  104. package/dist/core/sourceContext.js.map +1 -0
  105. package/dist/core/sourcePath.d.ts +2 -0
  106. package/dist/core/sourcePath.js +11 -0
  107. package/dist/core/sourcePath.js.map +1 -0
  108. package/dist/core/staleness.d.ts +118 -0
  109. package/dist/core/staleness.js +155 -0
  110. package/dist/core/staleness.js.map +1 -0
  111. package/dist/core/styleOrigin.d.ts +98 -0
  112. package/dist/core/styleOrigin.js +142 -0
  113. package/dist/core/styleOrigin.js.map +1 -0
  114. package/dist/core/svelteAnchors.d.ts +18 -0
  115. package/dist/core/svelteAnchors.js +125 -0
  116. package/dist/core/svelteAnchors.js.map +1 -0
  117. package/dist/core/taskFiles.d.ts +31 -0
  118. package/dist/core/taskFiles.js +55 -0
  119. package/dist/core/taskFiles.js.map +1 -0
  120. package/dist/core/untrusted.d.ts +57 -0
  121. package/dist/core/untrusted.js +268 -0
  122. package/dist/core/untrusted.js.map +1 -0
  123. package/dist/core/vueAnchors.d.ts +21 -0
  124. package/dist/core/vueAnchors.js +130 -0
  125. package/dist/core/vueAnchors.js.map +1 -0
  126. package/dist/expo/app/Avatar.d.ts +6 -0
  127. package/dist/expo/app/Avatar.js +12 -0
  128. package/dist/expo/app/Avatar.js.map +1 -0
  129. package/dist/expo/app/Bars.d.ts +9 -0
  130. package/dist/expo/app/Bars.js +38 -0
  131. package/dist/expo/app/Bars.js.map +1 -0
  132. package/dist/expo/app/CommentThreadSheet.d.ts +35 -0
  133. package/dist/expo/app/CommentThreadSheet.js +200 -0
  134. package/dist/expo/app/CommentThreadSheet.js.map +1 -0
  135. package/dist/expo/app/CommentsSheet.d.ts +22 -0
  136. package/dist/expo/app/CommentsSheet.js +76 -0
  137. package/dist/expo/app/CommentsSheet.js.map +1 -0
  138. package/dist/expo/app/Files.d.ts +16 -0
  139. package/dist/expo/app/Files.js +62 -0
  140. package/dist/expo/app/Files.js.map +1 -0
  141. package/dist/expo/app/Highlight.d.ts +5 -0
  142. package/dist/expo/app/Highlight.js +12 -0
  143. package/dist/expo/app/Highlight.js.map +1 -0
  144. package/dist/expo/app/Icon.d.ts +9 -0
  145. package/dist/expo/app/Icon.js +22 -0
  146. package/dist/expo/app/Icon.js.map +1 -0
  147. package/dist/expo/app/MarkerPins.d.ts +10 -0
  148. package/dist/expo/app/MarkerPins.js +70 -0
  149. package/dist/expo/app/MarkerPins.js.map +1 -0
  150. package/dist/expo/app/Provider.d.ts +13 -0
  151. package/dist/expo/app/Provider.js +597 -0
  152. package/dist/expo/app/Provider.js.map +1 -0
  153. package/dist/expo/app/Sheet.d.ts +53 -0
  154. package/dist/expo/app/Sheet.js +106 -0
  155. package/dist/expo/app/Sheet.js.map +1 -0
  156. package/dist/expo/app/Toolbar.d.ts +26 -0
  157. package/dist/expo/app/Toolbar.js +71 -0
  158. package/dist/expo/app/Toolbar.js.map +1 -0
  159. package/dist/expo/app/adapter.d.ts +55 -0
  160. package/dist/expo/app/adapter.js +145 -0
  161. package/dist/expo/app/adapter.js.map +1 -0
  162. package/dist/expo/app/api.d.ts +68 -0
  163. package/dist/expo/app/api.js +86 -0
  164. package/dist/expo/app/api.js.map +1 -0
  165. package/dist/expo/app/assets/attach.png +0 -0
  166. package/dist/expo/app/assets/close.png +0 -0
  167. package/dist/expo/app/assets/comment.png +0 -0
  168. package/dist/expo/app/assets/edit.png +0 -0
  169. package/dist/expo/app/assets/file.png +0 -0
  170. package/dist/expo/app/assets/narrow.png +0 -0
  171. package/dist/expo/app/assets/panel.png +0 -0
  172. package/dist/expo/app/assets/pins.png +0 -0
  173. package/dist/expo/app/assets/pinsOff.png +0 -0
  174. package/dist/expo/app/assets/remove.png +0 -0
  175. package/dist/expo/app/assets/reopen.png +0 -0
  176. package/dist/expo/app/assets/resolve.png +0 -0
  177. package/dist/expo/app/assets/send.png +0 -0
  178. package/dist/expo/app/assets/widen.png +0 -0
  179. package/dist/expo/app/attachments.d.ts +93 -0
  180. package/dist/expo/app/attachments.js +181 -0
  181. package/dist/expo/app/attachments.js.map +1 -0
  182. package/dist/expo/app/cloudApi.d.ts +63 -0
  183. package/dist/expo/app/cloudApi.js +330 -0
  184. package/dist/expo/app/cloudApi.js.map +1 -0
  185. package/dist/expo/app/cloudAuth.d.ts +20 -0
  186. package/dist/expo/app/cloudAuth.js +71 -0
  187. package/dist/expo/app/cloudAuth.js.map +1 -0
  188. package/dist/expo/app/cloudHttp.d.ts +20 -0
  189. package/dist/expo/app/cloudHttp.js +46 -0
  190. package/dist/expo/app/cloudHttp.js.map +1 -0
  191. package/dist/expo/app/cloudSession.d.ts +30 -0
  192. package/dist/expo/app/cloudSession.js +72 -0
  193. package/dist/expo/app/cloudSession.js.map +1 -0
  194. package/dist/expo/app/comments.d.ts +20 -0
  195. package/dist/expo/app/comments.js +131 -0
  196. package/dist/expo/app/comments.js.map +1 -0
  197. package/dist/expo/app/devMenuNone.d.ts +5 -0
  198. package/dist/expo/app/devMenuNone.js +3 -0
  199. package/dist/expo/app/devMenuNone.js.map +1 -0
  200. package/dist/expo/app/devServerNone.d.ts +4 -0
  201. package/dist/expo/app/devServerNone.js +4 -0
  202. package/dist/expo/app/devServerNone.js.map +1 -0
  203. package/dist/expo/app/embeddedConfig.d.ts +1 -0
  204. package/dist/expo/app/embeddedConfig.js +12 -0
  205. package/dist/expo/app/embeddedConfig.js.map +1 -0
  206. package/dist/expo/app/embeddedConfigCloud.d.ts +2 -0
  207. package/dist/expo/app/embeddedConfigCloud.js +8 -0
  208. package/dist/expo/app/embeddedConfigCloud.js.map +1 -0
  209. package/dist/expo/app/embeddedConfigNone.d.ts +2 -0
  210. package/dist/expo/app/embeddedConfigNone.js +3 -0
  211. package/dist/expo/app/embeddedConfigNone.js.map +1 -0
  212. package/dist/expo/app/expo.d.ts +4 -0
  213. package/dist/expo/app/expo.js +35 -0
  214. package/dist/expo/app/expo.js.map +1 -0
  215. package/dist/expo/app/expoGo.d.ts +4 -0
  216. package/dist/expo/app/expoGo.js +33 -0
  217. package/dist/expo/app/expoGo.js.map +1 -0
  218. package/dist/expo/app/expoPickers.d.ts +11 -0
  219. package/dist/expo/app/expoPickers.js +91 -0
  220. package/dist/expo/app/expoPickers.js.map +1 -0
  221. package/dist/expo/app/expoRandom.d.ts +6 -0
  222. package/dist/expo/app/expoRandom.js +21 -0
  223. package/dist/expo/app/expoRandom.js.map +1 -0
  224. package/dist/expo/app/idle.d.ts +4 -0
  225. package/dist/expo/app/idle.js +7 -0
  226. package/dist/expo/app/idle.js.map +1 -0
  227. package/dist/expo/app/index.d.ts +3 -0
  228. package/dist/expo/app/index.js +3 -0
  229. package/dist/expo/app/index.js.map +1 -0
  230. package/dist/expo/app/interactions.d.ts +38 -0
  231. package/dist/expo/app/interactions.js +40 -0
  232. package/dist/expo/app/interactions.js.map +1 -0
  233. package/dist/expo/app/markers.d.ts +28 -0
  234. package/dist/expo/app/markers.js +187 -0
  235. package/dist/expo/app/markers.js.map +1 -0
  236. package/dist/expo/app/movedAnchors.d.ts +46 -0
  237. package/dist/expo/app/movedAnchors.js +39 -0
  238. package/dist/expo/app/movedAnchors.js.map +1 -0
  239. package/dist/expo/app/native.d.ts +12 -0
  240. package/dist/expo/app/native.js +78 -0
  241. package/dist/expo/app/native.js.map +1 -0
  242. package/dist/expo/app/panel.d.ts +27 -0
  243. package/dist/expo/app/panel.js +37 -0
  244. package/dist/expo/app/panel.js.map +1 -0
  245. package/dist/expo/app/payload.d.ts +43 -0
  246. package/dist/expo/app/payload.js +22 -0
  247. package/dist/expo/app/payload.js.map +1 -0
  248. package/dist/expo/app/pick.d.ts +14 -0
  249. package/dist/expo/app/pick.js +124 -0
  250. package/dist/expo/app/pick.js.map +1 -0
  251. package/dist/expo/app/pickerNone.d.ts +1 -0
  252. package/dist/expo/app/pickerNone.js +2 -0
  253. package/dist/expo/app/pickerNone.js.map +1 -0
  254. package/dist/expo/app/placement.d.ts +53 -0
  255. package/dist/expo/app/placement.js +100 -0
  256. package/dist/expo/app/placement.js.map +1 -0
  257. package/dist/expo/app/random.d.ts +13 -0
  258. package/dist/expo/app/random.js +56 -0
  259. package/dist/expo/app/random.js.map +1 -0
  260. package/dist/expo/app/reactNative.d.ts +2 -0
  261. package/dist/expo/app/reactNative.js +3 -0
  262. package/dist/expo/app/reactNative.js.map +1 -0
  263. package/dist/expo/app/runtimeConfig.d.ts +30 -0
  264. package/dist/expo/app/runtimeConfig.js +104 -0
  265. package/dist/expo/app/runtimeConfig.js.map +1 -0
  266. package/dist/expo/app/sheetMotion.d.ts +22 -0
  267. package/dist/expo/app/sheetMotion.js +39 -0
  268. package/dist/expo/app/sheetMotion.js.map +1 -0
  269. package/dist/expo/app/signIn.d.ts +32 -0
  270. package/dist/expo/app/signIn.js +28 -0
  271. package/dist/expo/app/signIn.js.map +1 -0
  272. package/dist/expo/app/state.d.ts +45 -0
  273. package/dist/expo/app/state.js +32 -0
  274. package/dist/expo/app/state.js.map +1 -0
  275. package/dist/expo/app/theme.d.ts +15 -0
  276. package/dist/expo/app/theme.js +9 -0
  277. package/dist/expo/app/theme.js.map +1 -0
  278. package/dist/expo/app/types.d.ts +87 -0
  279. package/dist/expo/app/types.js +2 -0
  280. package/dist/expo/app/types.js.map +1 -0
  281. package/dist/expo/app/useCloudReviewer.d.ts +75 -0
  282. package/dist/expo/app/useCloudReviewer.js +211 -0
  283. package/dist/expo/app/useCloudReviewer.js.map +1 -0
  284. package/dist/expo/app/useComments.d.ts +64 -0
  285. package/dist/expo/app/useComments.js +156 -0
  286. package/dist/expo/app/useComments.js.map +1 -0
  287. package/dist/expo/app/useUploads.d.ts +32 -0
  288. package/dist/expo/app/useUploads.js +106 -0
  289. package/dist/expo/app/useUploads.js.map +1 -0
  290. package/dist/expo/expoGoMetro.cjs +83 -0
  291. package/dist/expo/expoMetro.cjs +86 -0
  292. package/dist/expo/metro.cjs +304 -0
  293. package/dist/expo/metroBuild.d.ts +22 -0
  294. package/dist/expo/metroBuild.js +169 -0
  295. package/dist/expo/metroBuild.js.map +1 -0
  296. package/dist/expo/middleware.d.ts +11 -0
  297. package/dist/expo/middleware.js +26 -0
  298. package/dist/expo/middleware.js.map +1 -0
  299. package/dist/expo/mode.d.ts +20 -0
  300. package/dist/expo/mode.js +37 -0
  301. package/dist/expo/mode.js.map +1 -0
  302. package/dist/expo/publicConfig.d.ts +37 -0
  303. package/dist/expo/publicConfig.js +87 -0
  304. package/dist/expo/publicConfig.js.map +1 -0
  305. package/dist/expo/transform.d.ts +22 -0
  306. package/dist/expo/transform.js +38 -0
  307. package/dist/expo/transform.js.map +1 -0
  308. package/dist/expo/transformer.cjs +73 -0
  309. package/dist/index.d.ts +21 -0
  310. package/dist/index.js +17 -0
  311. package/dist/index.js.map +1 -0
  312. package/dist/integration/apiRoutes.d.ts +2 -0
  313. package/dist/integration/apiRoutes.js +3 -0
  314. package/dist/integration/apiRoutes.js.map +1 -0
  315. package/dist/integration/buildCredentials.d.ts +12 -0
  316. package/dist/integration/buildCredentials.js +97 -0
  317. package/dist/integration/buildCredentials.js.map +1 -0
  318. package/dist/integration/buildSession.d.ts +8 -0
  319. package/dist/integration/buildSession.js +96 -0
  320. package/dist/integration/buildSession.js.map +1 -0
  321. package/dist/integration/bundleCheck.d.ts +43 -0
  322. package/dist/integration/bundleCheck.js +111 -0
  323. package/dist/integration/bundleCheck.js.map +1 -0
  324. package/dist/integration/commentPull.d.ts +134 -0
  325. package/dist/integration/commentPull.js +260 -0
  326. package/dist/integration/commentPull.js.map +1 -0
  327. package/dist/integration/configuredApi.d.ts +7 -0
  328. package/dist/integration/configuredApi.js +24 -0
  329. package/dist/integration/configuredApi.js.map +1 -0
  330. package/dist/integration/devCloud.d.ts +27 -0
  331. package/dist/integration/devCloud.js +56 -0
  332. package/dist/integration/devCloud.js.map +1 -0
  333. package/dist/integration/devReviewLinks.d.ts +2 -0
  334. package/dist/integration/devReviewLinks.js +10 -0
  335. package/dist/integration/devReviewLinks.js.map +1 -0
  336. package/dist/integration/gitBranch.d.ts +19 -0
  337. package/dist/integration/gitBranch.js +56 -0
  338. package/dist/integration/gitBranch.js.map +1 -0
  339. package/dist/integration/importPlan.d.ts +19 -0
  340. package/dist/integration/importPlan.js +90 -0
  341. package/dist/integration/importPlan.js.map +1 -0
  342. package/dist/integration/index.d.ts +14 -0
  343. package/dist/integration/index.js +13 -0
  344. package/dist/integration/index.js.map +1 -0
  345. package/dist/integration/manifest.d.ts +120 -0
  346. package/dist/integration/manifest.js +147 -0
  347. package/dist/integration/manifest.js.map +1 -0
  348. package/dist/integration/manifestParts.d.ts +29 -0
  349. package/dist/integration/manifestParts.js +65 -0
  350. package/dist/integration/manifestParts.js.map +1 -0
  351. package/dist/integration/manifestSink.d.ts +75 -0
  352. package/dist/integration/manifestSink.js +157 -0
  353. package/dist/integration/manifestSink.js.map +1 -0
  354. package/dist/integration/manifestUpload.d.ts +64 -0
  355. package/dist/integration/manifestUpload.js +177 -0
  356. package/dist/integration/manifestUpload.js.map +1 -0
  357. package/dist/integration/middleware.d.ts +55 -0
  358. package/dist/integration/middleware.js +379 -0
  359. package/dist/integration/middleware.js.map +1 -0
  360. package/dist/integration/nextStyles.d.ts +4 -0
  361. package/dist/integration/nextStyles.js +121 -0
  362. package/dist/integration/nextStyles.js.map +1 -0
  363. package/dist/integration/requestGuards.d.ts +71 -0
  364. package/dist/integration/requestGuards.js +255 -0
  365. package/dist/integration/requestGuards.js.map +1 -0
  366. package/dist/integration/sharedBuild.d.ts +71 -0
  367. package/dist/integration/sharedBuild.js +105 -0
  368. package/dist/integration/sharedBuild.js.map +1 -0
  369. package/dist/integration/sharedInject.d.ts +88 -0
  370. package/dist/integration/sharedInject.js +164 -0
  371. package/dist/integration/sharedInject.js.map +1 -0
  372. package/dist/integration/sidecarProcess.d.ts +26 -0
  373. package/dist/integration/sidecarProcess.js +137 -0
  374. package/dist/integration/sidecarProcess.js.map +1 -0
  375. package/dist/integration/styleCollector.d.ts +49 -0
  376. package/dist/integration/styleCollector.js +220 -0
  377. package/dist/integration/styleCollector.js.map +1 -0
  378. package/dist/integration/transform.d.ts +24 -0
  379. package/dist/integration/transform.js +36 -0
  380. package/dist/integration/transform.js.map +1 -0
  381. package/dist/integration/tunnelClient.d.ts +44 -0
  382. package/dist/integration/tunnelClient.js +148 -0
  383. package/dist/integration/tunnelClient.js.map +1 -0
  384. package/dist/integration/tunnelProtocol.d.ts +152 -0
  385. package/dist/integration/tunnelProtocol.js +110 -0
  386. package/dist/integration/tunnelProtocol.js.map +1 -0
  387. package/dist/mcp/cli.d.ts +2 -0
  388. package/dist/mcp/cli.js +327 -0
  389. package/dist/mcp/cli.js.map +1 -0
  390. package/dist/mcp/cloudRefresh.d.ts +36 -0
  391. package/dist/mcp/cloudRefresh.js +52 -0
  392. package/dist/mcp/cloudRefresh.js.map +1 -0
  393. package/dist/mcp/context.d.ts +7 -0
  394. package/dist/mcp/context.js +18 -0
  395. package/dist/mcp/context.js.map +1 -0
  396. package/dist/mcp/files.d.ts +66 -0
  397. package/dist/mcp/files.js +157 -0
  398. package/dist/mcp/files.js.map +1 -0
  399. package/dist/mcp/search.d.ts +3 -0
  400. package/dist/mcp/search.js +9 -0
  401. package/dist/mcp/search.js.map +1 -0
  402. package/dist/mcp/server.d.ts +50 -0
  403. package/dist/mcp/server.js +555 -0
  404. package/dist/mcp/server.js.map +1 -0
  405. package/dist/overlay/anchors.d.ts +130 -0
  406. package/dist/overlay/anchors.js +365 -0
  407. package/dist/overlay/anchors.js.map +1 -0
  408. package/dist/overlay/api.d.ts +150 -0
  409. package/dist/overlay/api.js +259 -0
  410. package/dist/overlay/api.js.map +1 -0
  411. package/dist/overlay/attachments.d.ts +60 -0
  412. package/dist/overlay/attachments.js +163 -0
  413. package/dist/overlay/attachments.js.map +1 -0
  414. package/dist/overlay/browser.d.ts +1 -0
  415. package/dist/overlay/browser.js +203 -0
  416. package/dist/overlay/browser.js.map +1 -0
  417. package/dist/overlay/chip.d.ts +27 -0
  418. package/dist/overlay/chip.js +31 -0
  419. package/dist/overlay/chip.js.map +1 -0
  420. package/dist/overlay/compact.d.ts +11 -0
  421. package/dist/overlay/compact.js +21 -0
  422. package/dist/overlay/compact.js.map +1 -0
  423. package/dist/overlay/cssScope.d.ts +46 -0
  424. package/dist/overlay/cssScope.js +180 -0
  425. package/dist/overlay/cssScope.js.map +1 -0
  426. package/dist/overlay/cursor.d.ts +2 -0
  427. package/dist/overlay/cursor.js +68 -0
  428. package/dist/overlay/cursor.js.map +1 -0
  429. package/dist/overlay/devBrowser.d.ts +1 -0
  430. package/dist/overlay/devBrowser.js +18 -0
  431. package/dist/overlay/devBrowser.js.map +1 -0
  432. package/dist/overlay/devReview.d.ts +4 -0
  433. package/dist/overlay/devReview.js +18 -0
  434. package/dist/overlay/devReview.js.map +1 -0
  435. package/dist/overlay/directReviewer.d.ts +149 -0
  436. package/dist/overlay/directReviewer.js +448 -0
  437. package/dist/overlay/directReviewer.js.map +1 -0
  438. package/dist/overlay/elementDescription.d.ts +10 -0
  439. package/dist/overlay/elementDescription.js +251 -0
  440. package/dist/overlay/elementDescription.js.map +1 -0
  441. package/dist/overlay/icons.d.ts +8 -0
  442. package/dist/overlay/icons.js +36 -0
  443. package/dist/overlay/icons.js.map +1 -0
  444. package/dist/overlay/identity.d.ts +48 -0
  445. package/dist/overlay/identity.js +125 -0
  446. package/dist/overlay/identity.js.map +1 -0
  447. package/dist/overlay/localMachine.d.ts +23 -0
  448. package/dist/overlay/localMachine.js +40 -0
  449. package/dist/overlay/localMachine.js.map +1 -0
  450. package/dist/overlay/magicLink.d.ts +10 -0
  451. package/dist/overlay/magicLink.js +87 -0
  452. package/dist/overlay/magicLink.js.map +1 -0
  453. package/dist/overlay/modern-screenshot.js +1676 -0
  454. package/dist/overlay/movedAnchors.d.ts +30 -0
  455. package/dist/overlay/movedAnchors.js +128 -0
  456. package/dist/overlay/movedAnchors.js.map +1 -0
  457. package/dist/overlay/notificationGroups.d.ts +2 -0
  458. package/dist/overlay/notificationGroups.js +41 -0
  459. package/dist/overlay/notificationGroups.js.map +1 -0
  460. package/dist/overlay/permissions.d.ts +10 -0
  461. package/dist/overlay/permissions.js +9 -0
  462. package/dist/overlay/permissions.js.map +1 -0
  463. package/dist/overlay/pinGroups.d.ts +16 -0
  464. package/dist/overlay/pinGroups.js +17 -0
  465. package/dist/overlay/pinGroups.js.map +1 -0
  466. package/dist/overlay/presence.d.ts +50 -0
  467. package/dist/overlay/presence.js +258 -0
  468. package/dist/overlay/presence.js.map +1 -0
  469. package/dist/overlay/projectChannel.d.ts +11 -0
  470. package/dist/overlay/projectChannel.js +111 -0
  471. package/dist/overlay/projectChannel.js.map +1 -0
  472. package/dist/overlay/recorder.d.ts +56 -0
  473. package/dist/overlay/recorder.js +130 -0
  474. package/dist/overlay/recorder.js.map +1 -0
  475. package/dist/overlay/reviewMode.d.ts +21 -0
  476. package/dist/overlay/reviewMode.js +59 -0
  477. package/dist/overlay/reviewMode.js.map +1 -0
  478. package/dist/overlay/reviewerAuth.d.ts +131 -0
  479. package/dist/overlay/reviewerAuth.js +279 -0
  480. package/dist/overlay/reviewerAuth.js.map +1 -0
  481. package/dist/overlay/route.d.ts +18 -0
  482. package/dist/overlay/route.js +56 -0
  483. package/dist/overlay/route.js.map +1 -0
  484. package/dist/overlay/rrweb-record.js +63 -0
  485. package/dist/overlay/runtime.d.ts +1 -0
  486. package/dist/overlay/runtime.js +4857 -0
  487. package/dist/overlay/runtime.js.map +1 -0
  488. package/dist/overlay/session.d.ts +32 -0
  489. package/dist/overlay/session.js +76 -0
  490. package/dist/overlay/session.js.map +1 -0
  491. package/dist/overlay/sharedMode.d.ts +38 -0
  492. package/dist/overlay/sharedMode.js +37 -0
  493. package/dist/overlay/sharedMode.js.map +1 -0
  494. package/dist/overlay/sheet.d.ts +73 -0
  495. package/dist/overlay/sheet.js +278 -0
  496. package/dist/overlay/sheet.js.map +1 -0
  497. package/dist/overlay/snapshot.d.ts +26 -0
  498. package/dist/overlay/snapshot.js +185 -0
  499. package/dist/overlay/snapshot.js.map +1 -0
  500. package/dist/overlay/state.d.ts +63 -0
  501. package/dist/overlay/state.js +241 -0
  502. package/dist/overlay/state.js.map +1 -0
  503. package/dist/overlay/steps.d.ts +22 -0
  504. package/dist/overlay/steps.js +34 -0
  505. package/dist/overlay/steps.js.map +1 -0
  506. package/dist/overlay/styles.d.ts +7 -0
  507. package/dist/overlay/styles.js +1449 -0
  508. package/dist/overlay/styles.js.map +1 -0
  509. package/dist/overlay/trace.d.ts +19 -0
  510. package/dist/overlay/trace.js +29 -0
  511. package/dist/overlay/trace.js.map +1 -0
  512. package/dist/overlay/upload.d.ts +35 -0
  513. package/dist/overlay/upload.js +99 -0
  514. package/dist/overlay/upload.js.map +1 -0
  515. package/dist/plugin/astro.d.ts +31 -0
  516. package/dist/plugin/astro.js +22 -0
  517. package/dist/plugin/astro.js.map +1 -0
  518. package/dist/plugin/eleventy.d.ts +44 -0
  519. package/dist/plugin/eleventy.js +186 -0
  520. package/dist/plugin/eleventy.js.map +1 -0
  521. package/dist/plugin/next-loader.cjs +11 -0
  522. package/dist/plugin/next.d.ts +29 -0
  523. package/dist/plugin/next.js +176 -0
  524. package/dist/plugin/next.js.map +1 -0
  525. package/dist/plugin/nextOverlay.d.ts +2 -0
  526. package/dist/plugin/nextOverlay.js +22 -0
  527. package/dist/plugin/nextOverlay.js.map +1 -0
  528. package/dist/plugin/nextTransform.d.ts +19 -0
  529. package/dist/plugin/nextTransform.js +29 -0
  530. package/dist/plugin/nextTransform.js.map +1 -0
  531. package/dist/plugin/rsbuild.d.ts +25 -0
  532. package/dist/plugin/rsbuild.js +56 -0
  533. package/dist/plugin/rsbuild.js.map +1 -0
  534. package/dist/plugin/vite.d.ts +40 -0
  535. package/dist/plugin/vite.js +585 -0
  536. package/dist/plugin/vite.js.map +1 -0
  537. package/dist/plugin/webpack.d.ts +69 -0
  538. package/dist/plugin/webpack.js +192 -0
  539. package/dist/plugin/webpack.js.map +1 -0
  540. package/dist/remote/account.d.ts +41 -0
  541. package/dist/remote/account.js +177 -0
  542. package/dist/remote/account.js.map +1 -0
  543. package/dist/remote/base64url.d.ts +14 -0
  544. package/dist/remote/base64url.js +71 -0
  545. package/dist/remote/base64url.js.map +1 -0
  546. package/dist/remote/branchLabel.d.ts +12 -0
  547. package/dist/remote/branchLabel.js +20 -0
  548. package/dist/remote/branchLabel.js.map +1 -0
  549. package/dist/remote/client.d.ts +340 -0
  550. package/dist/remote/client.js +424 -0
  551. package/dist/remote/client.js.map +1 -0
  552. package/dist/remote/cloudApi.d.ts +72 -0
  553. package/dist/remote/cloudApi.js +72 -0
  554. package/dist/remote/cloudApi.js.map +1 -0
  555. package/dist/remote/codec.d.ts +54 -0
  556. package/dist/remote/codec.js +62 -0
  557. package/dist/remote/codec.js.map +1 -0
  558. package/dist/remote/config.d.ts +30 -0
  559. package/dist/remote/config.js +112 -0
  560. package/dist/remote/config.js.map +1 -0
  561. package/dist/remote/content-schema.d.ts +428 -0
  562. package/dist/remote/content-schema.js +209 -0
  563. package/dist/remote/content-schema.js.map +1 -0
  564. package/dist/remote/content.d.ts +44 -0
  565. package/dist/remote/content.js +75 -0
  566. package/dist/remote/content.js.map +1 -0
  567. package/dist/remote/envelope.d.ts +76 -0
  568. package/dist/remote/envelope.js +109 -0
  569. package/dist/remote/envelope.js.map +1 -0
  570. package/dist/remote/errors.d.ts +55 -0
  571. package/dist/remote/errors.js +63 -0
  572. package/dist/remote/errors.js.map +1 -0
  573. package/dist/remote/ids.d.ts +8 -0
  574. package/dist/remote/ids.js +25 -0
  575. package/dist/remote/ids.js.map +1 -0
  576. package/dist/remote/index.d.ts +7 -0
  577. package/dist/remote/index.js +8 -0
  578. package/dist/remote/index.js.map +1 -0
  579. package/dist/remote/keys.d.ts +62 -0
  580. package/dist/remote/keys.js +162 -0
  581. package/dist/remote/keys.js.map +1 -0
  582. package/dist/remote/localAnchors.d.ts +4 -0
  583. package/dist/remote/localAnchors.js +23 -0
  584. package/dist/remote/localAnchors.js.map +1 -0
  585. package/dist/remote/mapping.d.ts +11 -0
  586. package/dist/remote/mapping.js +22 -0
  587. package/dist/remote/mapping.js.map +1 -0
  588. package/dist/remote/presence.d.ts +63 -0
  589. package/dist/remote/presence.js +143 -0
  590. package/dist/remote/presence.js.map +1 -0
  591. package/dist/remote/realtime.d.ts +142 -0
  592. package/dist/remote/realtime.js +326 -0
  593. package/dist/remote/realtime.js.map +1 -0
  594. package/dist/remote/store.d.ts +183 -0
  595. package/dist/remote/store.js +907 -0
  596. package/dist/remote/store.js.map +1 -0
  597. package/dist/remote/sync.d.ts +113 -0
  598. package/dist/remote/sync.js +370 -0
  599. package/dist/remote/sync.js.map +1 -0
  600. package/dist/remote/types.d.ts +99 -0
  601. package/dist/remote/types.js +6 -0
  602. package/dist/remote/types.js.map +1 -0
  603. package/dist/setup/agents.d.ts +23 -0
  604. package/dist/setup/agents.js +80 -0
  605. package/dist/setup/agents.js.map +1 -0
  606. package/dist/setup/configure.d.ts +27 -0
  607. package/dist/setup/configure.js +201 -0
  608. package/dist/setup/configure.js.map +1 -0
  609. package/dist/setup/connect.d.ts +60 -0
  610. package/dist/setup/connect.js +244 -0
  611. package/dist/setup/connect.js.map +1 -0
  612. package/dist/setup/detect.d.ts +67 -0
  613. package/dist/setup/detect.js +168 -0
  614. package/dist/setup/detect.js.map +1 -0
  615. package/dist/setup/frameworks.d.ts +41 -0
  616. package/dist/setup/frameworks.js +81 -0
  617. package/dist/setup/frameworks.js.map +1 -0
  618. package/dist/sidecar/cli.d.ts +1 -0
  619. package/dist/sidecar/cli.js +70 -0
  620. package/dist/sidecar/cli.js.map +1 -0
  621. package/dist/sidecar/cloudSync.d.ts +33 -0
  622. package/dist/sidecar/cloudSync.js +139 -0
  623. package/dist/sidecar/cloudSync.js.map +1 -0
  624. package/dist/sidecar/commentFiles.d.ts +59 -0
  625. package/dist/sidecar/commentFiles.js +217 -0
  626. package/dist/sidecar/commentFiles.js.map +1 -0
  627. package/dist/sidecar/cssAttribution.d.ts +26 -0
  628. package/dist/sidecar/cssAttribution.js +114 -0
  629. package/dist/sidecar/cssAttribution.js.map +1 -0
  630. package/dist/sidecar/exportTasks.d.ts +38 -0
  631. package/dist/sidecar/exportTasks.js +249 -0
  632. package/dist/sidecar/exportTasks.js.map +1 -0
  633. package/dist/sidecar/http.d.ts +20 -0
  634. package/dist/sidecar/http.js +904 -0
  635. package/dist/sidecar/http.js.map +1 -0
  636. package/dist/sidecar/inviteTarget.d.ts +4 -0
  637. package/dist/sidecar/inviteTarget.js +32 -0
  638. package/dist/sidecar/inviteTarget.js.map +1 -0
  639. package/dist/sidecar/presence.d.ts +4 -0
  640. package/dist/sidecar/presence.js +92 -0
  641. package/dist/sidecar/presence.js.map +1 -0
  642. package/dist/storage/cliSession.d.ts +8 -0
  643. package/dist/storage/cliSession.js +41 -0
  644. package/dist/storage/cliSession.js.map +1 -0
  645. package/dist/storage/devStyleMap.d.ts +12 -0
  646. package/dist/storage/devStyleMap.js +31 -0
  647. package/dist/storage/devStyleMap.js.map +1 -0
  648. package/dist/storage/fileCache.d.ts +34 -0
  649. package/dist/storage/fileCache.js +122 -0
  650. package/dist/storage/fileCache.js.map +1 -0
  651. package/dist/storage/localAttachments.d.ts +82 -0
  652. package/dist/storage/localAttachments.js +276 -0
  653. package/dist/storage/localAttachments.js.map +1 -0
  654. package/dist/storage/localComments.d.ts +31 -0
  655. package/dist/storage/localComments.js +159 -0
  656. package/dist/storage/localComments.js.map +1 -0
  657. package/dist/storage/localCredentials.d.ts +74 -0
  658. package/dist/storage/localCredentials.js +210 -0
  659. package/dist/storage/localCredentials.js.map +1 -0
  660. package/dist/storage/localParticipants.d.ts +33 -0
  661. package/dist/storage/localParticipants.js +110 -0
  662. package/dist/storage/localParticipants.js.map +1 -0
  663. package/dist/storage/localRecipe.d.ts +22 -0
  664. package/dist/storage/localRecipe.js +46 -0
  665. package/dist/storage/localRecipe.js.map +1 -0
  666. package/dist/storage/localScreenshots.d.ts +23 -0
  667. package/dist/storage/localScreenshots.js +55 -0
  668. package/dist/storage/localScreenshots.js.map +1 -0
  669. package/dist/storage/localSource.d.ts +31 -0
  670. package/dist/storage/localSource.js +175 -0
  671. package/dist/storage/localSource.js.map +1 -0
  672. package/dist/storage/pulledComments.d.ts +81 -0
  673. package/dist/storage/pulledComments.js +107 -0
  674. package/dist/storage/pulledComments.js.map +1 -0
  675. package/dist/storage/remoteRecipe.d.ts +7 -0
  676. package/dist/storage/remoteRecipe.js +85 -0
  677. package/dist/storage/remoteRecipe.js.map +1 -0
  678. package/dist/storage/savedRemote.d.ts +2 -0
  679. package/dist/storage/savedRemote.js +22 -0
  680. package/dist/storage/savedRemote.js.map +1 -0
  681. package/dist/storage/sidecarAccess.d.ts +7 -0
  682. package/dist/storage/sidecarAccess.js +68 -0
  683. package/dist/storage/sidecarAccess.js.map +1 -0
  684. package/package.json +306 -4
@@ -0,0 +1,175 @@
1
+ import { mkdir, readFile, readdir, realpath, stat, writeFile } from 'node:fs/promises';
2
+ import { existsSync, readFileSync as readSync } from 'node:fs';
3
+ import path from 'node:path';
4
+ /**
5
+ * Reads the project from disk.
6
+ *
7
+ * The only implementation of `SourceReader`, and deliberately so. Every path is checked
8
+ * twice before it is touched: lexically, which rejects `../` walks and absolute paths, and
9
+ * then against its resolved real path, which rejects symlinks that leave the project.
10
+ *
11
+ * The second check is not theoretical. `path.resolve` does not follow links, so a link
12
+ * inside the project resolves to something that looks inside it and the read then follows
13
+ * the link straight out. pnpm and monorepo workspaces fill `node_modules` with links that
14
+ * leave the project by design, and `/__fb/source` is reachable from the page, so a lexical
15
+ * check on its own is an arbitrary file read.
16
+ */
17
+ /**
18
+ * The nearest ancestor that declares a workspace, or null.
19
+ *
20
+ * Read from the repository's own files. A reviewer cannot influence it, and nothing here is
21
+ * inferred from directory shape: an undeclared monorepo is not a case served silently.
22
+ */
23
+ function findWorkspaceRoot(from) {
24
+ let current = from;
25
+ for (let depth = 0; depth < 24; depth += 1) {
26
+ if (existsSync(path.join(current, 'pnpm-workspace.yaml')))
27
+ return current;
28
+ const manifest = path.join(current, 'package.json');
29
+ if (existsSync(manifest)) {
30
+ try {
31
+ const parsed = JSON.parse(readSync(manifest, 'utf8'));
32
+ if (parsed.workspaces)
33
+ return current;
34
+ }
35
+ catch {
36
+ // An unreadable manifest is not a workspace declaration.
37
+ }
38
+ }
39
+ const parent = path.dirname(current);
40
+ if (parent === current)
41
+ break;
42
+ current = parent;
43
+ }
44
+ return null;
45
+ }
46
+ export class LocalSourceReader {
47
+ projectRoot;
48
+ workspaceRoot;
49
+ /** Resolved once per root: a root may itself sit under a link, as /tmp does on macOS. */
50
+ realRoots = new Map();
51
+ constructor(projectRoot) {
52
+ this.projectRoot = path.resolve(projectRoot);
53
+ this.workspaceRoot = findWorkspaceRoot(this.projectRoot) ?? this.projectRoot;
54
+ }
55
+ async readFile(relativePath) {
56
+ const absolutePath = await this.resolveInside(relativePath);
57
+ if (!absolutePath) {
58
+ return null;
59
+ }
60
+ try {
61
+ return await readFile(absolutePath, 'utf8');
62
+ }
63
+ catch {
64
+ return null;
65
+ }
66
+ }
67
+ async isFile(relativePath) {
68
+ const absolutePath = await this.resolveInside(relativePath);
69
+ if (!absolutePath) {
70
+ return false;
71
+ }
72
+ try {
73
+ return (await stat(absolutePath)).isFile();
74
+ }
75
+ catch {
76
+ return false;
77
+ }
78
+ }
79
+ async listDirectory(relativePath) {
80
+ const absolutePath = await this.resolveInside(relativePath);
81
+ if (!absolutePath) {
82
+ return [];
83
+ }
84
+ try {
85
+ const entries = await readdir(absolutePath, { withFileTypes: true });
86
+ return entries.map((entry) => ({ name: entry.name, isDirectory: entry.isDirectory() }));
87
+ }
88
+ catch {
89
+ return [];
90
+ }
91
+ }
92
+ async writeArtefact(relativePath, contents) {
93
+ const absolutePath = await this.resolveInside(relativePath);
94
+ if (!absolutePath) {
95
+ throw new Error(`Refusing to write outside the project: ${relativePath}`);
96
+ }
97
+ await mkdir(path.dirname(absolutePath), { recursive: true });
98
+ await writeFile(absolutePath, contents, 'utf8');
99
+ }
100
+ /** Reads beneath the workspace root. Local, export-time, never behind an HTTP route. */
101
+ async readWorkspaceFile(relativePath) {
102
+ const absolutePath = await this.resolveInside(relativePath, this.workspaceRoot);
103
+ if (!absolutePath)
104
+ return null;
105
+ try {
106
+ return await readFile(absolutePath, 'utf8');
107
+ }
108
+ catch {
109
+ return null;
110
+ }
111
+ }
112
+ async listWorkspaceDirectory(relativePath) {
113
+ const absolutePath = await this.resolveInside(relativePath, this.workspaceRoot);
114
+ if (!absolutePath)
115
+ return [];
116
+ try {
117
+ const entries = await readdir(absolutePath, { withFileTypes: true });
118
+ return entries.map((entry) => ({ name: entry.name, isDirectory: entry.isDirectory() }));
119
+ }
120
+ catch {
121
+ return [];
122
+ }
123
+ }
124
+ realRootOf(root) {
125
+ let cached = this.realRoots.get(root);
126
+ if (!cached) {
127
+ cached = realpath(root).catch(() => root);
128
+ this.realRoots.set(root, cached);
129
+ }
130
+ return cached;
131
+ }
132
+ /**
133
+ * Resolves a project-relative path, or null if it leaves the project by any route.
134
+ *
135
+ * Returns the lexical path rather than the real one, so callers still see paths under
136
+ * the root they asked about; the real path is used for the check alone.
137
+ */
138
+ async resolveInside(relativePath, bound = this.projectRoot) {
139
+ const lexical = path.resolve(bound, relativePath);
140
+ if (!this.contains(bound, lexical)) {
141
+ return null;
142
+ }
143
+ const root = await this.realRootOf(bound);
144
+ const real = await this.realPathOfNearestExisting(lexical);
145
+ // Nothing on the path exists yet, which is normal for a write. The lexical check has
146
+ // already passed and there is no link to follow, so allow it.
147
+ return real === null || this.contains(root, real) ? lexical : null;
148
+ }
149
+ /**
150
+ * Real path of the target, or of the closest ancestor that exists.
151
+ *
152
+ * A file being written does not exist yet, so the link check has to apply to the
153
+ * directory it will land in. Returns null when nothing along the path exists.
154
+ */
155
+ async realPathOfNearestExisting(target) {
156
+ let current = target;
157
+ for (let depth = 0; depth < 64; depth += 1) {
158
+ try {
159
+ return await realpath(current);
160
+ }
161
+ catch {
162
+ const parent = path.dirname(current);
163
+ if (parent === current) {
164
+ return null;
165
+ }
166
+ current = parent;
167
+ }
168
+ }
169
+ return null;
170
+ }
171
+ contains(root, candidate) {
172
+ return candidate === root || candidate.startsWith(`${root}${path.sep}`);
173
+ }
174
+ }
175
+ //# sourceMappingURL=localSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localSource.js","sourceRoot":"","sources":["../../src/storage/localSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,YAAY,IAAI,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B;;;;;;;;;;;;GAYG;AACH;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,IAAY;IACrC,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC3C,IAAI,UAA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OAAO,GAAG,MAAM,CAAC;YACnB,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,QAAQ,CAAC,IAAY,EAAE,SAAiB;QAC9C,OAAO,SAAS,KAAK,IAAI,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF"}
@@ -0,0 +1,81 @@
1
+ import type { Comment } from '../core/feedbackTypes.js';
2
+ import type { CommentFreshness } from '../core/staleness.js';
3
+ /**
4
+ * Comments pulled from the cloud, as this machine holds them.
5
+ *
6
+ * **A separate file from `comments.json`, deliberately.** The sidecar is the single writer of
7
+ * the local store, and that is what makes the store safe without locking - two overlapping
8
+ * read-modify-writes would silently discard one. `feedback pull` is a different process, often
9
+ * running while the dev server is up, so writing into the same file would break exactly that
10
+ * guarantee. It owns this file instead, and the sidecar only ever reads it.
11
+ *
12
+ * Resolution has already happened by the time anything lands here: the ids are gone and the
13
+ * comments carry real paths and lines. Everything downstream - the MCP tools, the exporter, the
14
+ * read plan - sees ordinary comments and never learns which mode they came from.
15
+ */
16
+ export type PulledStore = {
17
+ version: 1;
18
+ projectId: string;
19
+ pulledAt: string;
20
+ /** Resolved comments, in the shape the rest of the product already understands. */
21
+ comments: Comment[];
22
+ /** Whether each one's code still looks the way it did, keyed by comment id. */
23
+ freshness: Record<string, CommentFreshness>;
24
+ /** Ids that resolved to nothing, with the build they came from, so pull can explain itself. */
25
+ unresolved: {
26
+ commentId: string;
27
+ buildId: string;
28
+ ids: string[];
29
+ }[];
30
+ };
31
+ export declare function pulledPath(projectRoot: string): string;
32
+ /** Local status changes for pulled comments, applied on read. See `setPulledStatus`. */
33
+ export declare function pulledStatusPath(projectRoot: string): string;
34
+ export declare function writePulled(projectRoot: string, store: PulledStore): Promise<string>;
35
+ export declare function readPulled(projectRoot: string): Promise<PulledStore | null>;
36
+ /**
37
+ * One local record of a status change, and whether the cloud has it.
38
+ *
39
+ * `synced: false` is the state that matters. The agent's work is done whether or not the request
40
+ * reached the cloud, so a failed write-back must not undo the local resolution - but a comment
41
+ * closed here and open there is exactly the silent divergence this project keeps producing. It
42
+ * is recorded rather than swallowed, and `pull` retries it.
43
+ */
44
+ export type LocalStatus = {
45
+ status: 'open' | 'resolved';
46
+ synced: boolean;
47
+ at: string;
48
+ /** Why the last attempt failed, for a developer wondering why the reviewer still sees it open. */
49
+ reason?: string;
50
+ };
51
+ /**
52
+ * Resolving a pulled comment, here and in the cloud.
53
+ *
54
+ * The local record is written whatever happens to the request, and that order is deliberate: it
55
+ * is what stops the agent being handed the same task again on the next export. The push is what
56
+ * makes the reviewer's screen move, which is most of what makes a review loop feel like one.
57
+ *
58
+ * `push` is injected rather than imported so this module stays free of the network, and so the
59
+ * unlinked case - a purely local project - has an honest answer instead of a stub.
60
+ */
61
+ export declare function setPulledStatus(projectRoot: string, commentId: string, status: 'open' | 'resolved', push?: (id: string, next: 'open' | 'resolved') => Promise<{
62
+ ok: true;
63
+ } | {
64
+ ok: false;
65
+ reason: string;
66
+ gone?: boolean;
67
+ }>): Promise<LocalStatus>;
68
+ /** Status changes the cloud has not acknowledged, so `pull` can retry them. */
69
+ export declare function unsyncedStatuses(projectRoot: string): Promise<[string, LocalStatus][]>;
70
+ /** Drops a record entirely, for a comment absent from the cloud. */
71
+ export declare function forgetStatus(projectRoot: string, commentId: string): Promise<void>;
72
+ export declare function markSynced(projectRoot: string, commentId: string): Promise<void>;
73
+ /**
74
+ * Pulled comments with local status applied.
75
+ *
76
+ * Returns an empty list when there is no pull on this machine, which is the ordinary state in
77
+ * local mode rather than an error - nothing calls this expecting comments to exist.
78
+ */
79
+ export declare function listPulled(projectRoot: string): Promise<Comment[]>;
80
+ /** Freshness for the pulled set, for the exporter. Empty when nothing has been pulled. */
81
+ export declare function pulledFreshness(projectRoot: string): Promise<Record<string, CommentFreshness>>;
@@ -0,0 +1,107 @@
1
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ export function pulledPath(projectRoot) {
4
+ return path.join(projectRoot, '.feedback', 'pulled.json');
5
+ }
6
+ /** Local status changes for pulled comments, applied on read. See `setPulledStatus`. */
7
+ export function pulledStatusPath(projectRoot) {
8
+ return path.join(projectRoot, '.feedback', 'pulled-status.json');
9
+ }
10
+ export async function writePulled(projectRoot, store) {
11
+ const target = pulledPath(projectRoot);
12
+ await mkdir(path.dirname(target), { recursive: true });
13
+ await writeFile(target, `${JSON.stringify(store, null, 2)}\n`, 'utf8');
14
+ return target;
15
+ }
16
+ export async function readPulled(projectRoot) {
17
+ const raw = await readFile(pulledPath(projectRoot), 'utf8').catch(() => null);
18
+ if (raw === null)
19
+ return null;
20
+ try {
21
+ const parsed = JSON.parse(raw);
22
+ return Array.isArray(parsed.comments) ? parsed : null;
23
+ }
24
+ catch {
25
+ return null;
26
+ }
27
+ }
28
+ /**
29
+ * Resolving a pulled comment, here and in the cloud.
30
+ *
31
+ * The local record is written whatever happens to the request, and that order is deliberate: it
32
+ * is what stops the agent being handed the same task again on the next export. The push is what
33
+ * makes the reviewer's screen move, which is most of what makes a review loop feel like one.
34
+ *
35
+ * `push` is injected rather than imported so this module stays free of the network, and so the
36
+ * unlinked case - a purely local project - has an honest answer instead of a stub.
37
+ */
38
+ export async function setPulledStatus(projectRoot, commentId, status, push) {
39
+ const outcome = push
40
+ ? await push(commentId, status)
41
+ : { ok: false, reason: 'this project is not linked, so the cloud was not told' };
42
+ const record = outcome.ok
43
+ ? { status, synced: true, at: new Date().toISOString() }
44
+ : { status, synced: false, at: new Date().toISOString(), reason: outcome.reason };
45
+ const statuses = await readStatuses(projectRoot);
46
+ statuses[commentId] = record;
47
+ const target = pulledStatusPath(projectRoot);
48
+ await mkdir(path.dirname(target), { recursive: true });
49
+ await writeFile(target, `${JSON.stringify(statuses, null, 2)}\n`, 'utf8');
50
+ return record;
51
+ }
52
+ /** Status changes the cloud has not acknowledged, so `pull` can retry them. */
53
+ export async function unsyncedStatuses(projectRoot) {
54
+ const statuses = await readStatuses(projectRoot);
55
+ return Object.entries(statuses).filter(([, record]) => !record.synced);
56
+ }
57
+ /** Drops a record entirely, for a comment absent from the cloud. */
58
+ export async function forgetStatus(projectRoot, commentId) {
59
+ const statuses = await readStatuses(projectRoot);
60
+ if (!(commentId in statuses))
61
+ return;
62
+ delete statuses[commentId];
63
+ await writeFile(pulledStatusPath(projectRoot), `${JSON.stringify(statuses, null, 2)}\n`, 'utf8');
64
+ }
65
+ export async function markSynced(projectRoot, commentId) {
66
+ const statuses = await readStatuses(projectRoot);
67
+ const record = statuses[commentId];
68
+ if (!record)
69
+ return;
70
+ statuses[commentId] = { status: record.status, synced: true, at: record.at };
71
+ await writeFile(pulledStatusPath(projectRoot), `${JSON.stringify(statuses, null, 2)}\n`, 'utf8');
72
+ }
73
+ async function readStatuses(projectRoot) {
74
+ const raw = await readFile(pulledStatusPath(projectRoot), 'utf8').catch(() => null);
75
+ if (raw === null)
76
+ return {};
77
+ try {
78
+ const parsed = JSON.parse(raw);
79
+ // Files written before write-back existed held a bare status string. Read as unsynced, which
80
+ // is true rather than a guess: nothing had ever pushed them.
81
+ return Object.fromEntries(Object.entries(parsed).map(([id, value]) => typeof value === 'string'
82
+ ? [id, { status: value, synced: false, at: new Date(0).toISOString() }]
83
+ : [id, value]));
84
+ }
85
+ catch {
86
+ return {};
87
+ }
88
+ }
89
+ /**
90
+ * Pulled comments with local status applied.
91
+ *
92
+ * Returns an empty list when there is no pull on this machine, which is the ordinary state in
93
+ * local mode rather than an error - nothing calls this expecting comments to exist.
94
+ */
95
+ export async function listPulled(projectRoot) {
96
+ const store = await readPulled(projectRoot);
97
+ if (!store)
98
+ return [];
99
+ const statuses = await readStatuses(projectRoot);
100
+ return store.comments.map((comment) => statuses[comment.id] ? { ...comment, status: statuses[comment.id].status } : comment);
101
+ }
102
+ /** Freshness for the pulled set, for the exporter. Empty when nothing has been pulled. */
103
+ export async function pulledFreshness(projectRoot) {
104
+ const store = await readPulled(projectRoot);
105
+ return store?.freshness ?? {};
106
+ }
107
+ //# sourceMappingURL=pulledComments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pulledComments.js","sourceRoot":"","sources":["../../src/storage/pulledComments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,IAAI,MAAM,WAAW,CAAC;AA8B7B,MAAM,UAAU,UAAU,CAAC,WAAmB;IAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;AAC5D,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IAClD,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,oBAAoB,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,WAAmB,EAAE,KAAkB;IACvE,MAAM,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACvC,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,MAAM,SAAS,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACvE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,WAAmB;IAClD,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAC9E,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC9B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,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AAC,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AAC1F,CAAC;AAED,0FAA0F;AAC1F,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,WAAmB;IACvD,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,WAAW,CAAC,CAAC;IAC5C,OAAO,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;AAChC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type Recipe } from '../core/recipe.js';
2
+ /** Public, data-only contract specification. No project data or credentials leave the machine. */
3
+ export declare function loadRemoteRecipe(projectRoot: string, apiBase: string, fetchImpl?: typeof fetch, now?: () => number): Promise<{
4
+ recipe: Recipe;
5
+ source: "cloud" | "bundled";
6
+ reason?: string;
7
+ }>;
@@ -0,0 +1,85 @@
1
+ import { createHash, randomUUID } from 'node:crypto';
2
+ import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { checkRecipe, resolveRecipe } from '../core/recipe.js';
5
+ import { normalizeBaseUrl } from '../remote/client.js';
6
+ /** Public, data-only contract specification. No project data or credentials leave the machine. */
7
+ export async function loadRemoteRecipe(projectRoot, apiBase, fetchImpl = fetch, now = Date.now) {
8
+ const fallback = resolveRecipe(null);
9
+ let endpoint;
10
+ try {
11
+ // Format 1 is the Recipe shape, matching specification.format in the Worker contract.
12
+ // The recipe becomes the work order's instructions, so it is fetched only where a network
13
+ // attacker cannot rewrite it: https, or plain http to a loopback address (the v0 client rule).
14
+ endpoint = new URL(`${normalizeBaseUrl(apiBase.trim())}/v0/markdown-spec?format=1`).href;
15
+ }
16
+ catch {
17
+ return fallback;
18
+ }
19
+ // Bind the ETag and content to the endpoint so changing deployments cannot reuse its cache.
20
+ const key = createHash('sha256').update(endpoint).digest('hex').slice(0, 24);
21
+ const target = path.join(projectRoot, '.feedback', `markdown-spec-${key}.json`);
22
+ let cached = null;
23
+ try {
24
+ const raw = JSON.parse(await readFile(target, 'utf8'));
25
+ if (raw.endpoint === endpoint && validSpec(raw.spec)) {
26
+ cached = { ...raw, etag: typeof raw.etag === 'string' ? raw.etag : null };
27
+ }
28
+ }
29
+ catch { /* A missing or damaged cache is the bundled recipe. */ }
30
+ if (cached && Number.isSafeInteger(cached.expiresAt) && cached.expiresAt > now()) {
31
+ return resolveRecipe(cached.spec);
32
+ }
33
+ try {
34
+ const response = await fetchImpl(endpoint, {
35
+ headers: cached?.etag ? { 'If-None-Match': cached.etag } : {},
36
+ signal: AbortSignal.timeout(2_000),
37
+ redirect: 'error',
38
+ });
39
+ if (response.status === 304 && !cached)
40
+ return fallback;
41
+ if (response.status !== 304 && !response.ok)
42
+ return resolveRecipe(cached?.spec);
43
+ const spec = response.status === 304 ? cached.spec : await response.json();
44
+ if (!validSpec(spec))
45
+ return resolveRecipe(cached?.spec);
46
+ if (cached && cached.spec.version > spec.version)
47
+ return resolveRecipe(cached.spec);
48
+ const maxAgeSeconds = cacheMaxAge(response, response.status === 304 ? cached?.maxAgeSeconds : undefined);
49
+ const age = Number(response.headers.get('age') ?? 0);
50
+ const remaining = Math.max(0, maxAgeSeconds - (Number.isFinite(age) && age >= 0 ? age : maxAgeSeconds));
51
+ const entry = {
52
+ endpoint, etag: response.headers.get('etag') ?? (response.status === 304 ? cached.etag : null), spec,
53
+ maxAgeSeconds, expiresAt: now() + remaining * 1000,
54
+ };
55
+ const temporary = `${target}.${randomUUID()}.tmp`;
56
+ try {
57
+ await mkdir(path.dirname(target), { recursive: true });
58
+ await writeFile(temporary, `${JSON.stringify(entry)}\n`, 'utf8');
59
+ await rename(temporary, target);
60
+ }
61
+ catch { /* Read-only storage must not prevent an export. */ }
62
+ finally {
63
+ await rm(temporary, { force: true }).catch(() => undefined);
64
+ }
65
+ return resolveRecipe(spec);
66
+ }
67
+ catch {
68
+ return resolveRecipe(cached?.spec);
69
+ }
70
+ }
71
+ function cacheMaxAge(response, previous = 0) {
72
+ const control = response.headers.get('cache-control');
73
+ if (control === null)
74
+ return previous;
75
+ if (/(?:^|,)\s*(?:no-cache|no-store)\b/i.test(control))
76
+ return 0;
77
+ const seconds = Number(control.match(/(?:^|,)\s*max-age\s*=\s*"?(\d+)"?\s*(?:,|$)/i)?.[1] ?? 0);
78
+ return Number.isSafeInteger(seconds * 1000) ? seconds : 0;
79
+ }
80
+ function validSpec(value) {
81
+ if (!value || typeof value !== 'object' || value.format !== 1)
82
+ return false;
83
+ return checkRecipe(value).ok && resolveRecipe(value).source === 'cloud';
84
+ }
85
+ //# sourceMappingURL=remoteRecipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remoteRecipe.js","sourceRoot":"","sources":["../../src/storage/remoteRecipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAe,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAOvD,kGAAkG;AAClG,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,WAAmB,EACnB,OAAe,EACf,YAA0B,KAAK,EAC/B,MAAoB,IAAI,CAAC,GAAG;IAE5B,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACrC,IAAI,QAAgB,CAAC;IACrB,IAAI,CAAC;QACH,sFAAsF;QACtF,0FAA0F;QAC1F,+FAA+F;QAC/F,QAAQ,GAAG,IAAI,GAAG,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,4BAA4B,CAAC,CAAC,IAAI,CAAC;IAC3F,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,KAAK,CAAC,8CAA8C,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAChG,OAAO,MAAM,CAAC,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAK,KAA8B,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtG,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,2 @@
1
+ /** Read saved remote metadata without migrating files or requiring a key for public spec access. */
2
+ export declare function readSavedRemote(root: string): Promise<Record<string, unknown> | null>;
@@ -0,0 +1,22 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ /** Read saved remote metadata without migrating files or requiring a key for public spec access. */
4
+ export async function readSavedRemote(root) {
5
+ const object = (value) => value && typeof value === 'object' && !Array.isArray(value) ? value : null;
6
+ try {
7
+ return object(JSON.parse(await readFile(path.join(root, '.feedback', 'remote.json'), 'utf8')));
8
+ }
9
+ catch (error) {
10
+ // An existing but invalid isolated config must not resurrect stale legacy identifiers.
11
+ if (error.code !== 'ENOENT')
12
+ return null;
13
+ }
14
+ try {
15
+ const legacy = JSON.parse(await readFile(path.join(root, '.feedback', 'credentials.json'), 'utf8'));
16
+ return object(legacy?.remote);
17
+ }
18
+ catch {
19
+ return null;
20
+ }
21
+ }
22
+ //# sourceMappingURL=savedRemote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"savedRemote.js","sourceRoot":"","sources":["../../src/storage/savedRemote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,oGAAoG;AACpG,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAY;IAChD,MAAM,MAAM,GAAG,CAAC,KAAc,EAAkC,EAAE,CAChE,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAgC,CAAC,CAAC,CAAC,IAAI,CAAC;IACxG,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,aAAa,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IACjG,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,uFAAuF;QACvF,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;IACtE,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,kBAAkB,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QACpG,OAAO,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,IAAI,CAAC;IAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const sidecarAccessPath: (root: string, port: number) => string;
2
+ /** A fresh capability per listener, independent of the project key and never served over HTTP. */
3
+ export declare function saveSidecarAccess(root: string, port: number, token: string): Promise<void>;
4
+ export declare function readSidecarAuthorization(root: string, port: number): Promise<string>;
5
+ export declare function removeSidecarAccess(root: string, port: number, token: string): Promise<void>;
6
+ /** Called only for remote startup. Never remove another listener's live capability. */
7
+ export declare function sweepSidecarAccess(root: string, activePort: number): Promise<void>;
@@ -0,0 +1,68 @@
1
+ import { randomBytes } from 'node:crypto';
2
+ import { mkdir, readdir, readFile, rename, unlink, writeFile } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { connect } from 'node:net';
5
+ export const sidecarAccessPath = (root, port) => path.join(root, '.feedback', `sidecar-access-${port}.json`);
6
+ /** A fresh capability per listener, independent of the project key and never served over HTTP. */
7
+ export async function saveSidecarAccess(root, port, token) {
8
+ const target = sidecarAccessPath(root, port), temporary = `${target}.${randomBytes(8).toString('hex')}.tmp`;
9
+ await mkdir(path.dirname(target), { recursive: true, mode: 0o700 });
10
+ try {
11
+ await writeFile(temporary, JSON.stringify({ port, token }), { mode: 0o600, flag: 'wx' });
12
+ await rename(temporary, target);
13
+ }
14
+ finally {
15
+ await unlink(temporary).catch(() => { });
16
+ }
17
+ }
18
+ export async function readSidecarAuthorization(root, port) {
19
+ let raw;
20
+ try {
21
+ raw = await readFile(sidecarAccessPath(root, port), 'utf8');
22
+ }
23
+ catch (error) {
24
+ if (error.code === 'ENOENT')
25
+ throw new Error(`Sidecar access file is missing. Restart the sidecar on port ${port} and retry this command.`);
26
+ throw error;
27
+ }
28
+ const saved = JSON.parse(raw);
29
+ if (saved.port !== port || typeof saved.token !== 'string' || !/^[a-f0-9]{64}$/.test(saved.token))
30
+ throw new Error('Invalid sidecar access file');
31
+ return `Bearer ${saved.token}`;
32
+ }
33
+ export async function removeSidecarAccess(root, port, token) {
34
+ // A replacement listener can already own the same port by the time cleanup finishes.
35
+ if (await readSidecarAuthorization(root, port).catch(() => null) === `Bearer ${token}`)
36
+ await unlink(sidecarAccessPath(root, port)).catch(() => { });
37
+ }
38
+ /** Only a refused connection proves the port is stale; preserve slow or reused listeners. */
39
+ function portAnswers(port) {
40
+ return new Promise((resolve) => {
41
+ const socket = connect({ host: '127.0.0.1', port });
42
+ const finish = (answers) => { socket.destroy(); resolve(answers); };
43
+ socket.once('connect', () => finish(true));
44
+ socket.once('error', (error) => finish(error.code !== 'ECONNREFUSED'));
45
+ socket.setTimeout(500, () => finish(true));
46
+ });
47
+ }
48
+ /** Called only for remote startup. Never remove another listener's live capability. */
49
+ export async function sweepSidecarAccess(root, activePort) {
50
+ const directory = path.join(root, '.feedback');
51
+ const entries = await readdir(directory, { withFileTypes: true }).catch((error) => {
52
+ if (error.code === 'ENOENT')
53
+ return [];
54
+ throw error;
55
+ });
56
+ for (const entry of entries) {
57
+ const match = /^sidecar-access-([0-9]+)\.json$/.exec(entry.name);
58
+ if (!entry.isFile() || !match)
59
+ continue;
60
+ const port = Number(match[1]);
61
+ if (port === activePort || port < 1 || port > 65535)
62
+ continue;
63
+ const authorization = await readSidecarAuthorization(root, port).catch(() => null);
64
+ if (authorization && !await portAnswers(port))
65
+ await removeSidecarAccess(root, port, authorization.slice('Bearer '.length));
66
+ }
67
+ }
68
+ //# sourceMappingURL=sidecarAccess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidecarAccess.js","sourceRoot":"","sources":["../../src/storage/sidecarAccess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,kBAAkB,IAAI,OAAO,CAAC,CAAC;AAE7H,kGAAkG;AAClG,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAY,EAAE,IAAY,EAAE,KAAa;IAC/E,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG,MAAM,IAAI,W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