flucto 1.18.0 → 1.21.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 (385) hide show
  1. package/CHANGELOG.md +36 -3
  2. package/README.md +172 -26
  3. package/dist-electron/cli/args.js +127 -2
  4. package/dist-electron/cli/args.js.map +1 -1
  5. package/dist-electron/cli/index.js +334 -9
  6. package/dist-electron/cli/index.js.map +1 -1
  7. package/dist-electron/cli/jobOutput.js.map +1 -1
  8. package/dist-electron/cli/output.js +24 -1
  9. package/dist-electron/cli/output.js.map +1 -1
  10. package/dist-electron/main/analysis/avCommands.js +144 -0
  11. package/dist-electron/main/analysis/avCommands.js.map +1 -0
  12. package/dist-electron/main/analysis/csvWriter.js +121 -0
  13. package/dist-electron/main/analysis/csvWriter.js.map +1 -0
  14. package/dist-electron/main/analysis/ffmpegSignals.js +337 -0
  15. package/dist-electron/main/analysis/ffmpegSignals.js.map +1 -0
  16. package/dist-electron/main/handlers.js +189 -2
  17. package/dist-electron/main/handlers.js.map +1 -1
  18. package/dist-electron/main/index.js +36 -1
  19. package/dist-electron/main/index.js.map +1 -1
  20. package/dist-electron/main/platforms/threads.js +128 -6
  21. package/dist-electron/main/platforms/threads.js.map +1 -1
  22. package/dist-electron/main/search/dailymotion.js +5 -1
  23. package/dist-electron/main/search/dailymotion.js.map +1 -1
  24. package/dist-electron/main/services/aiVideoDiscovery.js +193 -0
  25. package/dist-electron/main/services/aiVideoDiscovery.js.map +1 -0
  26. package/dist-electron/main/services/aiVideoEvidence.js +75 -0
  27. package/dist-electron/main/services/aiVideoEvidence.js.map +1 -0
  28. package/dist-electron/main/services/analysisReport.js +413 -0
  29. package/dist-electron/main/services/analysisReport.js.map +1 -0
  30. package/dist-electron/main/services/binaryInstaller.js +427 -108
  31. package/dist-electron/main/services/binaryInstaller.js.map +1 -1
  32. package/dist-electron/main/services/binaryResolver.js +2 -0
  33. package/dist-electron/main/services/binaryResolver.js.map +1 -1
  34. package/dist-electron/main/services/cinematicAnalysis.js +574 -0
  35. package/dist-electron/main/services/cinematicAnalysis.js.map +1 -0
  36. package/dist-electron/main/services/codexVisionRuntime.js +353 -0
  37. package/dist-electron/main/services/codexVisionRuntime.js.map +1 -0
  38. package/dist-electron/main/services/craftTaxonomy.js +373 -0
  39. package/dist-electron/main/services/craftTaxonomy.js.map +1 -0
  40. package/dist-electron/main/services/mediaDownload.js +50 -0
  41. package/dist-electron/main/services/mediaDownload.js.map +1 -1
  42. package/dist-electron/main/services/mediaInfo.js +44 -0
  43. package/dist-electron/main/services/mediaInfo.js.map +1 -1
  44. package/dist-electron/main/services/visionProvider.js +220 -0
  45. package/dist-electron/main/services/visionProvider.js.map +1 -0
  46. package/dist-electron/main/services/ytDlpRuntimeSources.js +24 -0
  47. package/dist-electron/main/services/ytDlpRuntimeSources.js.map +1 -0
  48. package/dist-electron/main/spawn.js +50 -4
  49. package/dist-electron/main/spawn.js.map +1 -1
  50. package/dist-electron/main/store.js +5 -0
  51. package/dist-electron/main/store.js.map +1 -1
  52. package/dist-electron/preload/index.js +24 -0
  53. package/dist-electron/preload/index.js.map +1 -1
  54. package/dist-electron/shared/analysisOutputPath.js +24 -0
  55. package/dist-electron/shared/analysisOutputPath.js.map +1 -0
  56. package/dist-electron/shared/analysisTypes.js +29 -0
  57. package/dist-electron/shared/analysisTypes.js.map +1 -0
  58. package/node_modules/@isaacs/fs-minipass/LICENSE +15 -0
  59. package/node_modules/@isaacs/fs-minipass/README.md +71 -0
  60. package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.d.ts +118 -0
  61. package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.d.ts.map +1 -0
  62. package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.js +430 -0
  63. package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.js.map +1 -0
  64. package/node_modules/@isaacs/fs-minipass/dist/commonjs/package.json +3 -0
  65. package/node_modules/@isaacs/fs-minipass/dist/esm/index.d.ts +118 -0
  66. package/node_modules/@isaacs/fs-minipass/dist/esm/index.d.ts.map +1 -0
  67. package/node_modules/@isaacs/fs-minipass/dist/esm/index.js +420 -0
  68. package/node_modules/@isaacs/fs-minipass/dist/esm/index.js.map +1 -0
  69. package/node_modules/@isaacs/fs-minipass/dist/esm/package.json +3 -0
  70. package/node_modules/@isaacs/fs-minipass/package.json +72 -0
  71. package/node_modules/chownr/LICENSE.md +63 -0
  72. package/node_modules/chownr/README.md +3 -0
  73. package/node_modules/chownr/dist/commonjs/index.d.ts +3 -0
  74. package/node_modules/chownr/dist/commonjs/index.d.ts.map +1 -0
  75. package/node_modules/chownr/dist/commonjs/index.js +93 -0
  76. package/node_modules/chownr/dist/commonjs/index.js.map +1 -0
  77. package/node_modules/chownr/dist/commonjs/package.json +3 -0
  78. package/node_modules/chownr/dist/esm/index.d.ts +3 -0
  79. package/node_modules/chownr/dist/esm/index.d.ts.map +1 -0
  80. package/node_modules/chownr/dist/esm/index.js +85 -0
  81. package/node_modules/chownr/dist/esm/index.js.map +1 -0
  82. package/node_modules/chownr/dist/esm/package.json +3 -0
  83. package/node_modules/chownr/package.json +69 -0
  84. package/node_modules/minipass/LICENSE.md +55 -0
  85. package/node_modules/minipass/README.md +825 -0
  86. package/node_modules/minipass/dist/commonjs/index.d.ts +545 -0
  87. package/node_modules/minipass/dist/commonjs/index.d.ts.map +1 -0
  88. package/node_modules/minipass/dist/commonjs/index.js +1038 -0
  89. package/node_modules/minipass/dist/commonjs/index.js.map +1 -0
  90. package/node_modules/minipass/dist/commonjs/package.json +3 -0
  91. package/node_modules/minipass/dist/esm/index.d.ts +545 -0
  92. package/node_modules/minipass/dist/esm/index.d.ts.map +1 -0
  93. package/node_modules/minipass/dist/esm/index.js +1020 -0
  94. package/node_modules/minipass/dist/esm/index.js.map +1 -0
  95. package/node_modules/minipass/dist/esm/package.json +3 -0
  96. package/node_modules/minipass/package.json +77 -0
  97. package/node_modules/minizlib/LICENSE +26 -0
  98. package/node_modules/minizlib/README.md +64 -0
  99. package/node_modules/minizlib/dist/commonjs/constants.d.ts +2 -0
  100. package/node_modules/minizlib/dist/commonjs/constants.d.ts.map +1 -0
  101. package/node_modules/minizlib/dist/commonjs/constants.js +123 -0
  102. package/node_modules/minizlib/dist/commonjs/constants.js.map +1 -0
  103. package/node_modules/minizlib/dist/commonjs/index.d.ts +99 -0
  104. package/node_modules/minizlib/dist/commonjs/index.d.ts.map +1 -0
  105. package/node_modules/minizlib/dist/commonjs/index.js +416 -0
  106. package/node_modules/minizlib/dist/commonjs/index.js.map +1 -0
  107. package/node_modules/minizlib/dist/commonjs/package.json +3 -0
  108. package/node_modules/minizlib/dist/esm/constants.d.ts +2 -0
  109. package/node_modules/minizlib/dist/esm/constants.d.ts.map +1 -0
  110. package/node_modules/minizlib/dist/esm/constants.js +117 -0
  111. package/node_modules/minizlib/dist/esm/constants.js.map +1 -0
  112. package/node_modules/minizlib/dist/esm/index.d.ts +99 -0
  113. package/node_modules/minizlib/dist/esm/index.d.ts.map +1 -0
  114. package/node_modules/minizlib/dist/esm/index.js +363 -0
  115. package/node_modules/minizlib/dist/esm/index.js.map +1 -0
  116. package/node_modules/minizlib/dist/esm/package.json +3 -0
  117. package/node_modules/minizlib/package.json +80 -0
  118. package/node_modules/tar/LICENSE.md +55 -0
  119. package/node_modules/tar/README.md +1233 -0
  120. package/node_modules/tar/dist/commonjs/create.d.ts +3 -0
  121. package/node_modules/tar/dist/commonjs/create.d.ts.map +1 -0
  122. package/node_modules/tar/dist/commonjs/create.js +82 -0
  123. package/node_modules/tar/dist/commonjs/create.js.map +1 -0
  124. package/node_modules/tar/dist/commonjs/cwd-error.d.ts +8 -0
  125. package/node_modules/tar/dist/commonjs/cwd-error.d.ts.map +1 -0
  126. package/node_modules/tar/dist/commonjs/cwd-error.js +18 -0
  127. package/node_modules/tar/dist/commonjs/cwd-error.js.map +1 -0
  128. package/node_modules/tar/dist/commonjs/extract.d.ts +3 -0
  129. package/node_modules/tar/dist/commonjs/extract.d.ts.map +1 -0
  130. package/node_modules/tar/dist/commonjs/extract.js +88 -0
  131. package/node_modules/tar/dist/commonjs/extract.js.map +1 -0
  132. package/node_modules/tar/dist/commonjs/get-write-flag.d.ts +2 -0
  133. package/node_modules/tar/dist/commonjs/get-write-flag.d.ts.map +1 -0
  134. package/node_modules/tar/dist/commonjs/get-write-flag.js +32 -0
  135. package/node_modules/tar/dist/commonjs/get-write-flag.js.map +1 -0
  136. package/node_modules/tar/dist/commonjs/header.d.ts +53 -0
  137. package/node_modules/tar/dist/commonjs/header.d.ts.map +1 -0
  138. package/node_modules/tar/dist/commonjs/header.js +348 -0
  139. package/node_modules/tar/dist/commonjs/header.js.map +1 -0
  140. package/node_modules/tar/dist/commonjs/index.d.ts +20 -0
  141. package/node_modules/tar/dist/commonjs/index.d.ts.map +1 -0
  142. package/node_modules/tar/dist/commonjs/index.js +64 -0
  143. package/node_modules/tar/dist/commonjs/index.js.map +1 -0
  144. package/node_modules/tar/dist/commonjs/index.min.js +4 -0
  145. package/node_modules/tar/dist/commonjs/index.min.js.map +7 -0
  146. package/node_modules/tar/dist/commonjs/large-numbers.d.ts +3 -0
  147. package/node_modules/tar/dist/commonjs/large-numbers.d.ts.map +1 -0
  148. package/node_modules/tar/dist/commonjs/large-numbers.js +99 -0
  149. package/node_modules/tar/dist/commonjs/large-numbers.js.map +1 -0
  150. package/node_modules/tar/dist/commonjs/list.d.ts +7 -0
  151. package/node_modules/tar/dist/commonjs/list.d.ts.map +1 -0
  152. package/node_modules/tar/dist/commonjs/list.js +153 -0
  153. package/node_modules/tar/dist/commonjs/list.js.map +1 -0
  154. package/node_modules/tar/dist/commonjs/make-command.d.ts +49 -0
  155. package/node_modules/tar/dist/commonjs/make-command.d.ts.map +1 -0
  156. package/node_modules/tar/dist/commonjs/make-command.js +52 -0
  157. package/node_modules/tar/dist/commonjs/make-command.js.map +1 -0
  158. package/node_modules/tar/dist/commonjs/mkdir.d.ts +25 -0
  159. package/node_modules/tar/dist/commonjs/mkdir.d.ts.map +1 -0
  160. package/node_modules/tar/dist/commonjs/mkdir.js +187 -0
  161. package/node_modules/tar/dist/commonjs/mkdir.js.map +1 -0
  162. package/node_modules/tar/dist/commonjs/mode-fix.d.ts +2 -0
  163. package/node_modules/tar/dist/commonjs/mode-fix.d.ts.map +1 -0
  164. package/node_modules/tar/dist/commonjs/mode-fix.js +29 -0
  165. package/node_modules/tar/dist/commonjs/mode-fix.js.map +1 -0
  166. package/node_modules/tar/dist/commonjs/normalize-unicode.d.ts +2 -0
  167. package/node_modules/tar/dist/commonjs/normalize-unicode.d.ts.map +1 -0
  168. package/node_modules/tar/dist/commonjs/normalize-unicode.js +38 -0
  169. package/node_modules/tar/dist/commonjs/normalize-unicode.js.map +1 -0
  170. package/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts +2 -0
  171. package/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts.map +1 -0
  172. package/node_modules/tar/dist/commonjs/normalize-windows-path.js +12 -0
  173. package/node_modules/tar/dist/commonjs/normalize-windows-path.js.map +1 -0
  174. package/node_modules/tar/dist/commonjs/options.d.ts +604 -0
  175. package/node_modules/tar/dist/commonjs/options.d.ts.map +1 -0
  176. package/node_modules/tar/dist/commonjs/options.js +66 -0
  177. package/node_modules/tar/dist/commonjs/options.js.map +1 -0
  178. package/node_modules/tar/dist/commonjs/pack.d.ts +105 -0
  179. package/node_modules/tar/dist/commonjs/pack.d.ts.map +1 -0
  180. package/node_modules/tar/dist/commonjs/pack.js +544 -0
  181. package/node_modules/tar/dist/commonjs/pack.js.map +1 -0
  182. package/node_modules/tar/dist/commonjs/package.json +3 -0
  183. package/node_modules/tar/dist/commonjs/parse.d.ts +92 -0
  184. package/node_modules/tar/dist/commonjs/parse.d.ts.map +1 -0
  185. package/node_modules/tar/dist/commonjs/parse.js +655 -0
  186. package/node_modules/tar/dist/commonjs/parse.js.map +1 -0
  187. package/node_modules/tar/dist/commonjs/path-reservations.d.ts +11 -0
  188. package/node_modules/tar/dist/commonjs/path-reservations.d.ts.map +1 -0
  189. package/node_modules/tar/dist/commonjs/path-reservations.js +170 -0
  190. package/node_modules/tar/dist/commonjs/path-reservations.js.map +1 -0
  191. package/node_modules/tar/dist/commonjs/pax.d.ts +26 -0
  192. package/node_modules/tar/dist/commonjs/pax.d.ts.map +1 -0
  193. package/node_modules/tar/dist/commonjs/pax.js +182 -0
  194. package/node_modules/tar/dist/commonjs/pax.js.map +1 -0
  195. package/node_modules/tar/dist/commonjs/process-umask.d.ts +2 -0
  196. package/node_modules/tar/dist/commonjs/process-umask.d.ts.map +1 -0
  197. package/node_modules/tar/dist/commonjs/process-umask.js +7 -0
  198. package/node_modules/tar/dist/commonjs/process-umask.js.map +1 -0
  199. package/node_modules/tar/dist/commonjs/read-entry.d.ts +36 -0
  200. package/node_modules/tar/dist/commonjs/read-entry.d.ts.map +1 -0
  201. package/node_modules/tar/dist/commonjs/read-entry.js +136 -0
  202. package/node_modules/tar/dist/commonjs/read-entry.js.map +1 -0
  203. package/node_modules/tar/dist/commonjs/replace.d.ts +2 -0
  204. package/node_modules/tar/dist/commonjs/replace.d.ts.map +1 -0
  205. package/node_modules/tar/dist/commonjs/replace.js +227 -0
  206. package/node_modules/tar/dist/commonjs/replace.js.map +1 -0
  207. package/node_modules/tar/dist/commonjs/strip-absolute-path.d.ts +2 -0
  208. package/node_modules/tar/dist/commonjs/strip-absolute-path.d.ts.map +1 -0
  209. package/node_modules/tar/dist/commonjs/strip-absolute-path.js +29 -0
  210. package/node_modules/tar/dist/commonjs/strip-absolute-path.js.map +1 -0
  211. package/node_modules/tar/dist/commonjs/strip-trailing-slashes.d.ts +2 -0
  212. package/node_modules/tar/dist/commonjs/strip-trailing-slashes.d.ts.map +1 -0
  213. package/node_modules/tar/dist/commonjs/strip-trailing-slashes.js +18 -0
  214. package/node_modules/tar/dist/commonjs/strip-trailing-slashes.js.map +1 -0
  215. package/node_modules/tar/dist/commonjs/symlink-error.d.ts +9 -0
  216. package/node_modules/tar/dist/commonjs/symlink-error.d.ts.map +1 -0
  217. package/node_modules/tar/dist/commonjs/symlink-error.js +19 -0
  218. package/node_modules/tar/dist/commonjs/symlink-error.js.map +1 -0
  219. package/node_modules/tar/dist/commonjs/types.d.ts +16 -0
  220. package/node_modules/tar/dist/commonjs/types.d.ts.map +1 -0
  221. package/node_modules/tar/dist/commonjs/types.js +70 -0
  222. package/node_modules/tar/dist/commonjs/types.js.map +1 -0
  223. package/node_modules/tar/dist/commonjs/unpack.d.ts +101 -0
  224. package/node_modules/tar/dist/commonjs/unpack.d.ts.map +1 -0
  225. package/node_modules/tar/dist/commonjs/unpack.js +932 -0
  226. package/node_modules/tar/dist/commonjs/unpack.js.map +1 -0
  227. package/node_modules/tar/dist/commonjs/update.d.ts +2 -0
  228. package/node_modules/tar/dist/commonjs/update.d.ts.map +1 -0
  229. package/node_modules/tar/dist/commonjs/update.js +33 -0
  230. package/node_modules/tar/dist/commonjs/update.js.map +1 -0
  231. package/node_modules/tar/dist/commonjs/warn-method.d.ts +24 -0
  232. package/node_modules/tar/dist/commonjs/warn-method.d.ts.map +1 -0
  233. package/node_modules/tar/dist/commonjs/warn-method.js +31 -0
  234. package/node_modules/tar/dist/commonjs/warn-method.js.map +1 -0
  235. package/node_modules/tar/dist/commonjs/winchars.d.ts +3 -0
  236. package/node_modules/tar/dist/commonjs/winchars.d.ts.map +1 -0
  237. package/node_modules/tar/dist/commonjs/winchars.js +14 -0
  238. package/node_modules/tar/dist/commonjs/winchars.js.map +1 -0
  239. package/node_modules/tar/dist/commonjs/write-entry.d.ts +129 -0
  240. package/node_modules/tar/dist/commonjs/write-entry.d.ts.map +1 -0
  241. package/node_modules/tar/dist/commonjs/write-entry.js +698 -0
  242. package/node_modules/tar/dist/commonjs/write-entry.js.map +1 -0
  243. package/node_modules/tar/dist/esm/create.d.ts +3 -0
  244. package/node_modules/tar/dist/esm/create.d.ts.map +1 -0
  245. package/node_modules/tar/dist/esm/create.js +76 -0
  246. package/node_modules/tar/dist/esm/create.js.map +1 -0
  247. package/node_modules/tar/dist/esm/cwd-error.d.ts +8 -0
  248. package/node_modules/tar/dist/esm/cwd-error.d.ts.map +1 -0
  249. package/node_modules/tar/dist/esm/cwd-error.js +14 -0
  250. package/node_modules/tar/dist/esm/cwd-error.js.map +1 -0
  251. package/node_modules/tar/dist/esm/extract.d.ts +3 -0
  252. package/node_modules/tar/dist/esm/extract.d.ts.map +1 -0
  253. package/node_modules/tar/dist/esm/extract.js +49 -0
  254. package/node_modules/tar/dist/esm/extract.js.map +1 -0
  255. package/node_modules/tar/dist/esm/get-write-flag.d.ts +2 -0
  256. package/node_modules/tar/dist/esm/get-write-flag.d.ts.map +1 -0
  257. package/node_modules/tar/dist/esm/get-write-flag.js +26 -0
  258. package/node_modules/tar/dist/esm/get-write-flag.js.map +1 -0
  259. package/node_modules/tar/dist/esm/header.d.ts +53 -0
  260. package/node_modules/tar/dist/esm/header.d.ts.map +1 -0
  261. package/node_modules/tar/dist/esm/header.js +311 -0
  262. package/node_modules/tar/dist/esm/header.js.map +1 -0
  263. package/node_modules/tar/dist/esm/index.d.ts +20 -0
  264. package/node_modules/tar/dist/esm/index.d.ts.map +1 -0
  265. package/node_modules/tar/dist/esm/index.js +20 -0
  266. package/node_modules/tar/dist/esm/index.js.map +1 -0
  267. package/node_modules/tar/dist/esm/index.min.js +4 -0
  268. package/node_modules/tar/dist/esm/index.min.js.map +7 -0
  269. package/node_modules/tar/dist/esm/large-numbers.d.ts +3 -0
  270. package/node_modules/tar/dist/esm/large-numbers.d.ts.map +1 -0
  271. package/node_modules/tar/dist/esm/large-numbers.js +94 -0
  272. package/node_modules/tar/dist/esm/large-numbers.js.map +1 -0
  273. package/node_modules/tar/dist/esm/list.d.ts +7 -0
  274. package/node_modules/tar/dist/esm/list.d.ts.map +1 -0
  275. package/node_modules/tar/dist/esm/list.js +113 -0
  276. package/node_modules/tar/dist/esm/list.js.map +1 -0
  277. package/node_modules/tar/dist/esm/make-command.d.ts +49 -0
  278. package/node_modules/tar/dist/esm/make-command.d.ts.map +1 -0
  279. package/node_modules/tar/dist/esm/make-command.js +48 -0
  280. package/node_modules/tar/dist/esm/make-command.js.map +1 -0
  281. package/node_modules/tar/dist/esm/mkdir.d.ts +25 -0
  282. package/node_modules/tar/dist/esm/mkdir.d.ts.map +1 -0
  283. package/node_modules/tar/dist/esm/mkdir.js +179 -0
  284. package/node_modules/tar/dist/esm/mkdir.js.map +1 -0
  285. package/node_modules/tar/dist/esm/mode-fix.d.ts +2 -0
  286. package/node_modules/tar/dist/esm/mode-fix.d.ts.map +1 -0
  287. package/node_modules/tar/dist/esm/mode-fix.js +25 -0
  288. package/node_modules/tar/dist/esm/mode-fix.js.map +1 -0
  289. package/node_modules/tar/dist/esm/normalize-unicode.d.ts +2 -0
  290. package/node_modules/tar/dist/esm/normalize-unicode.d.ts.map +1 -0
  291. package/node_modules/tar/dist/esm/normalize-unicode.js +34 -0
  292. package/node_modules/tar/dist/esm/normalize-unicode.js.map +1 -0
  293. package/node_modules/tar/dist/esm/normalize-windows-path.d.ts +2 -0
  294. package/node_modules/tar/dist/esm/normalize-windows-path.d.ts.map +1 -0
  295. package/node_modules/tar/dist/esm/normalize-windows-path.js +9 -0
  296. package/node_modules/tar/dist/esm/normalize-windows-path.js.map +1 -0
  297. package/node_modules/tar/dist/esm/options.d.ts +604 -0
  298. package/node_modules/tar/dist/esm/options.d.ts.map +1 -0
  299. package/node_modules/tar/dist/esm/options.js +54 -0
  300. package/node_modules/tar/dist/esm/options.js.map +1 -0
  301. package/node_modules/tar/dist/esm/pack.d.ts +105 -0
  302. package/node_modules/tar/dist/esm/pack.d.ts.map +1 -0
  303. package/node_modules/tar/dist/esm/pack.js +502 -0
  304. package/node_modules/tar/dist/esm/pack.js.map +1 -0
  305. package/node_modules/tar/dist/esm/package.json +3 -0
  306. package/node_modules/tar/dist/esm/parse.d.ts +92 -0
  307. package/node_modules/tar/dist/esm/parse.d.ts.map +1 -0
  308. package/node_modules/tar/dist/esm/parse.js +651 -0
  309. package/node_modules/tar/dist/esm/parse.js.map +1 -0
  310. package/node_modules/tar/dist/esm/path-reservations.d.ts +11 -0
  311. package/node_modules/tar/dist/esm/path-reservations.d.ts.map +1 -0
  312. package/node_modules/tar/dist/esm/path-reservations.js +166 -0
  313. package/node_modules/tar/dist/esm/path-reservations.js.map +1 -0
  314. package/node_modules/tar/dist/esm/pax.d.ts +26 -0
  315. package/node_modules/tar/dist/esm/pax.d.ts.map +1 -0
  316. package/node_modules/tar/dist/esm/pax.js +178 -0
  317. package/node_modules/tar/dist/esm/pax.js.map +1 -0
  318. package/node_modules/tar/dist/esm/process-umask.d.ts +2 -0
  319. package/node_modules/tar/dist/esm/process-umask.d.ts.map +1 -0
  320. package/node_modules/tar/dist/esm/process-umask.js +3 -0
  321. package/node_modules/tar/dist/esm/process-umask.js.map +1 -0
  322. package/node_modules/tar/dist/esm/read-entry.d.ts +36 -0
  323. package/node_modules/tar/dist/esm/read-entry.d.ts.map +1 -0
  324. package/node_modules/tar/dist/esm/read-entry.js +132 -0
  325. package/node_modules/tar/dist/esm/read-entry.js.map +1 -0
  326. package/node_modules/tar/dist/esm/replace.d.ts +2 -0
  327. package/node_modules/tar/dist/esm/replace.d.ts.map +1 -0
  328. package/node_modules/tar/dist/esm/replace.js +221 -0
  329. package/node_modules/tar/dist/esm/replace.js.map +1 -0
  330. package/node_modules/tar/dist/esm/strip-absolute-path.d.ts +2 -0
  331. package/node_modules/tar/dist/esm/strip-absolute-path.d.ts.map +1 -0
  332. package/node_modules/tar/dist/esm/strip-absolute-path.js +25 -0
  333. package/node_modules/tar/dist/esm/strip-absolute-path.js.map +1 -0
  334. package/node_modules/tar/dist/esm/strip-trailing-slashes.d.ts +2 -0
  335. package/node_modules/tar/dist/esm/strip-trailing-slashes.d.ts.map +1 -0
  336. package/node_modules/tar/dist/esm/strip-trailing-slashes.js +14 -0
  337. package/node_modules/tar/dist/esm/strip-trailing-slashes.js.map +1 -0
  338. package/node_modules/tar/dist/esm/symlink-error.d.ts +9 -0
  339. package/node_modules/tar/dist/esm/symlink-error.d.ts.map +1 -0
  340. package/node_modules/tar/dist/esm/symlink-error.js +15 -0
  341. package/node_modules/tar/dist/esm/symlink-error.js.map +1 -0
  342. package/node_modules/tar/dist/esm/types.d.ts +16 -0
  343. package/node_modules/tar/dist/esm/types.d.ts.map +1 -0
  344. package/node_modules/tar/dist/esm/types.js +65 -0
  345. package/node_modules/tar/dist/esm/types.js.map +1 -0
  346. package/node_modules/tar/dist/esm/unpack.d.ts +101 -0
  347. package/node_modules/tar/dist/esm/unpack.d.ts.map +1 -0
  348. package/node_modules/tar/dist/esm/unpack.js +891 -0
  349. package/node_modules/tar/dist/esm/unpack.js.map +1 -0
  350. package/node_modules/tar/dist/esm/update.d.ts +2 -0
  351. package/node_modules/tar/dist/esm/update.d.ts.map +1 -0
  352. package/node_modules/tar/dist/esm/update.js +30 -0
  353. package/node_modules/tar/dist/esm/update.js.map +1 -0
  354. package/node_modules/tar/dist/esm/warn-method.d.ts +24 -0
  355. package/node_modules/tar/dist/esm/warn-method.d.ts.map +1 -0
  356. package/node_modules/tar/dist/esm/warn-method.js +27 -0
  357. package/node_modules/tar/dist/esm/warn-method.js.map +1 -0
  358. package/node_modules/tar/dist/esm/winchars.d.ts +3 -0
  359. package/node_modules/tar/dist/esm/winchars.d.ts.map +1 -0
  360. package/node_modules/tar/dist/esm/winchars.js +9 -0
  361. package/node_modules/tar/dist/esm/winchars.js.map +1 -0
  362. package/node_modules/tar/dist/esm/write-entry.d.ts +129 -0
  363. package/node_modules/tar/dist/esm/write-entry.d.ts.map +1 -0
  364. package/node_modules/tar/dist/esm/write-entry.js +656 -0
  365. package/node_modules/tar/dist/esm/write-entry.js.map +1 -0
  366. package/node_modules/tar/node_modules/yallist/LICENSE.md +63 -0
  367. package/node_modules/tar/node_modules/yallist/README.md +205 -0
  368. package/node_modules/tar/node_modules/yallist/dist/commonjs/index.d.ts +39 -0
  369. package/node_modules/tar/node_modules/yallist/dist/commonjs/index.d.ts.map +1 -0
  370. package/node_modules/tar/node_modules/yallist/dist/commonjs/index.js +384 -0
  371. package/node_modules/tar/node_modules/yallist/dist/commonjs/index.js.map +1 -0
  372. package/node_modules/tar/node_modules/yallist/dist/commonjs/package.json +3 -0
  373. package/node_modules/tar/node_modules/yallist/dist/esm/index.d.ts +39 -0
  374. package/node_modules/tar/node_modules/yallist/dist/esm/index.d.ts.map +1 -0
  375. package/node_modules/tar/node_modules/yallist/dist/esm/index.js +379 -0
  376. package/node_modules/tar/node_modules/yallist/dist/esm/index.js.map +1 -0
  377. package/node_modules/tar/node_modules/yallist/dist/esm/package.json +3 -0
  378. package/node_modules/tar/node_modules/yallist/package.json +68 -0
  379. package/node_modules/tar/package.json +298 -0
  380. package/package.json +7 -2
  381. package/schemas/analysis-run.v1.schema.json +66 -0
  382. package/skills/searching-social-media/SKILL.md +50 -0
  383. package/skills/searching-social-media/references/flucto-contract.md +37 -0
  384. package/skills/searching-social-media/references/search-workflow.md +39 -0
  385. package/skills/searching-social-media/scripts/social_search.py +431 -0
@@ -3,11 +3,51 @@ import os from 'os';
3
3
  import path from 'path';
4
4
  import zlib from 'zlib';
5
5
  import { pipeline } from 'stream/promises';
6
+ import { Readable, Transform } from 'stream';
6
7
  import { createRequire } from 'module';
8
+ import { createHash } from 'crypto';
9
+ import { spawn } from 'child_process';
7
10
  import { execa } from '../spawn.js';
11
+ import { ytDlpRuntimeSources } from './ytDlpRuntimeSources.js';
8
12
  import { resolveCliBinaries } from './binaryResolver.js';
9
13
  const require = createRequire(import.meta.url);
10
14
  const AdmZip = require('adm-zip');
15
+ const tar = require('tar');
16
+ const MAX_ARCHIVE_BYTES = 512 * 1024 * 1024;
17
+ const MAX_DECOMPRESSED_TAR_BYTES = 1024 * 1024 * 1024;
18
+ const MAX_EXECUTABLE_BYTES = 256 * 1024 * 1024;
19
+ const GYAN_WIN_X64 = {
20
+ url: 'https://github.com/GyanD/codexffmpeg/releases/download/8.1.2/ffmpeg-8.1.2-essentials_build.zip',
21
+ sha256: 'db580001caa24ac104c8cb856cd113a87b0a443f7bdf47d8c12b1d740584a2ec',
22
+ };
23
+ const BTBN_LINUX = {
24
+ x64: { url: 'https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-11-16-15-29/ffmpeg-N-128959-g4dbee3b241-linux64-gpl.tar.xz', sha256: '098bdc14d7a5a62d7f5a1452e748a192cef66e045146e869a15ae20d1ab50544' },
25
+ arm64: { url: 'https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2026-11-16-15-29/ffmpeg-N-128959-g4dbee3b241-linuxarm64-gpl.tar.xz', sha256: '59c27c4fbf895c12fa2e2add1847e90ade02582ace8dd58bda07089407033633' },
26
+ };
27
+ const MARTIN_MAC = {
28
+ x64: {
29
+ ffmpeg: { url: 'https://ffmpeg.martin-riedl.de/download/macos/amd64/1789931006_9.0.2/ffmpeg.zip', sha256: '7c6b4125b191cbf773832dc51f424cf2b6bb7da43007d1e066f95909e47cacd4' },
30
+ ffprobe: { url: 'https://ffmpeg.martin-riedl.de/download/macos/amd64/1789931006_9.0.2/ffprobe.zip', sha256: '2322438ed2f6319a691291b247d09c69dcaa3a982460d1f269a7e1af335cfdfd' },
31
+ },
32
+ arm64: {
33
+ ffmpeg: { url: 'https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffmpeg.zip', sha256: 'c8ed4c4e6978a03c485edbfe4e0a5dc2380f8a30bba5150531b31b094492d924' },
34
+ ffprobe: { url: 'https://ffmpeg.martin-riedl.de/download/macos/arm64/1789931890_9.0.2/ffprobe.zip', sha256: 'fcbe839537485eaee7a7a8bc5cbc0f90d53617e80943e8a5b2e31cb851197ea6' },
35
+ },
36
+ };
37
+ export const pinnedAvSourceFor = (name, platform, arch) => {
38
+ if (platform === 'win32' && arch === 'x64')
39
+ return GYAN_WIN_X64;
40
+ if (platform === 'linux' && BTBN_LINUX[arch])
41
+ return BTBN_LINUX[arch];
42
+ if (platform === 'darwin' && MARTIN_MAC[arch])
43
+ return MARTIN_MAC[arch][name];
44
+ throw new Error(`No pinned ${name} source for ${platform}/${arch}`);
45
+ };
46
+ export const verifySha256 = (bytes, expected) => {
47
+ const actual = (awaitlessCreateHash(bytes));
48
+ return actual === expected.toLowerCase();
49
+ };
50
+ const awaitlessCreateHash = (bytes) => createHash('sha256').update(bytes).digest('hex');
11
51
  const YT_DLP_VERSION = 'latest';
12
52
  const FFMPEG_RELEASE = '7.0.2';
13
53
  const executableExtension = process.platform === 'win32' ? '.exe' : '';
@@ -42,41 +82,8 @@ export const ytDlpUrlFor = (platform = currentPlatform(), arch = process.arch) =
42
82
  }
43
83
  throw new Error(`No yt-dlp download source for platform ${platform}`);
44
84
  };
45
- export const ffmpegDownloadUrlsFor = (platform = currentPlatform(), arch = process.arch) => {
46
- if (platform === 'win32') {
47
- return [
48
- 'https://github.com/GyanD/codexffmpeg/releases/download/8.1.2/ffmpeg-8.1.2-essentials_build.zip',
49
- 'https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip',
50
- ];
51
- }
52
- if (platform === 'darwin') {
53
- return arch === 'arm64'
54
- ? [
55
- 'https://ffmpeg.martin-riedl.de/redirect/latest/macos/arm64/release/ffmpeg.zip',
56
- 'https://github.com/eugeneware/ffmpeg-static/releases/latest/download/ffmpeg-darwin-arm64.gz',
57
- ]
58
- : [
59
- 'https://evermeet.cx/ffmpeg/getrelease/zip',
60
- 'https://ffmpeg.martin-riedl.de/redirect/latest/macos/amd64/release/ffmpeg.zip',
61
- 'https://github.com/eugeneware/ffmpeg-static/releases/latest/download/ffmpeg-darwin-x64.gz',
62
- ];
63
- }
64
- if (platform === 'linux') {
65
- if (arch === 'arm64' || arch === 'arm' || arch === 'ia32') {
66
- const archSlug = arch === 'arm64' ? 'arm64' : arch === 'arm' ? 'armhf' : 'i686';
67
- const urls = [`https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-${archSlug}-static.tar.xz`];
68
- if (arch === 'arm64') {
69
- urls.push('https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linuxarm64-gpl.tar.xz');
70
- }
71
- return urls;
72
- }
73
- return [
74
- 'https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz',
75
- 'https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz',
76
- ];
77
- }
78
- throw new Error(`No FFmpeg download source for platform ${platform}`);
79
- };
85
+ export const ffmpegDownloadUrlsFor = (platform = currentPlatform(), arch = process.arch) => [pinnedAvSourceFor('ffmpeg', platform, arch).url];
86
+ export const ffprobeDownloadUrlsFor = (platform = currentPlatform(), arch = process.arch) => [pinnedAvSourceFor('ffprobe', platform, arch).url];
80
87
  export const utilitySpecs = () => {
81
88
  return [
82
89
  {
@@ -91,6 +98,15 @@ export const utilitySpecs = () => {
91
98
  versionArgs: ['-version'],
92
99
  downloadUrls: ffmpegDownloadUrlsFor(),
93
100
  archiveMember: executableName('ffmpeg'),
101
+ archiveSha256: pinnedAvSourceFor('ffmpeg', currentPlatform(), process.arch).sha256,
102
+ },
103
+ {
104
+ name: 'ffprobe',
105
+ executableName: executableName('ffprobe'),
106
+ versionArgs: ['-version'],
107
+ downloadUrls: ffprobeDownloadUrlsFor(),
108
+ archiveMember: executableName('ffprobe'),
109
+ archiveSha256: pinnedAvSourceFor('ffprobe', currentPlatform(), process.arch).sha256,
94
110
  },
95
111
  ];
96
112
  };
@@ -112,6 +128,7 @@ const normalizeYtDlpVersion = (value) => {
112
128
  export const fetchLatestYtDlpVersion = async () => {
113
129
  try {
114
130
  const response = await fetch('https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest', {
131
+ signal: AbortSignal.timeout(15000),
115
132
  headers: {
116
133
  'user-agent': `Flucto/${YT_DLP_VERSION}`,
117
134
  accept: 'application/vnd.github+json',
@@ -126,63 +143,197 @@ export const fetchLatestYtDlpVersion = async () => {
126
143
  return null;
127
144
  }
128
145
  };
129
- export const versionFor = async (filePath, args) => {
146
+ export const versionFor = async (filePath, args, timeoutMs = 15000) => {
130
147
  if (!isExecutable(filePath))
131
148
  return null;
132
- const result = await execa(filePath, args, { reject: false });
149
+ const result = await execa(filePath, args, { reject: false, timeoutMs });
133
150
  if (result.failed)
134
151
  return null;
135
152
  return (result.stdout || result.stderr).split(/\r?\n/).find((line) => line.trim())?.trim() ?? null;
136
153
  };
137
- const downloadFile = async (url, destination) => {
138
- const response = await fetch(url, { headers: { 'user-agent': `Flucto/${YT_DLP_VERSION} (${FFMPEG_RELEASE})` } });
139
- if (!response.ok) {
154
+ const downloadFile = async (url, destination, fetchImpl = fetch) => {
155
+ const response = await fetchImpl(url, { headers: { 'user-agent': `Flucto/${YT_DLP_VERSION} (${FFMPEG_RELEASE})` }, signal: AbortSignal.timeout(120000) });
156
+ if (!response.ok)
140
157
  throw new Error(`Failed to download ${url}: HTTP ${response.status}`);
158
+ const contentLength = Number(response.headers.get('content-length'));
159
+ if (Number.isFinite(contentLength) && contentLength > MAX_ARCHIVE_BYTES)
160
+ throw new Error('Downloaded archive exceeds size limit');
161
+ if (!response.body)
162
+ throw new Error('Download response has no body');
163
+ let total = 0;
164
+ const limiter = new Transform({ transform(chunk, _encoding, callback) {
165
+ total += chunk.length;
166
+ callback(total > MAX_ARCHIVE_BYTES ? new Error('Downloaded archive exceeds size limit') : null, chunk);
167
+ } });
168
+ await pipeline(Readable.fromWeb(response.body), limiter, fs.createWriteStream(destination, { flags: 'wx' }));
169
+ };
170
+ const normalizeArchivePath = (name) => {
171
+ const value = name.replace(/\\/g, '/');
172
+ if (!value || value.startsWith('/') || /^[A-Za-z]:/.test(value) || value.split('/').some((part) => part === '..')) {
173
+ throw new Error(`Unsafe archive member path: ${name}`);
141
174
  }
142
- await fs.promises.mkdir(path.dirname(destination), { recursive: true });
143
- await fs.promises.writeFile(destination, Buffer.from(await response.arrayBuffer()));
175
+ return value.replace(/^\.\//, '');
144
176
  };
145
- const extractZipMember = async (archivePath, memberName, destination) => {
177
+ export const extractZipMember = async (archivePath, memberName, destination) => {
178
+ const archiveStat = await fs.promises.stat(archivePath);
179
+ if (archiveStat.size > MAX_ARCHIVE_BYTES)
180
+ throw new Error('ZIP archive exceeds size limit');
146
181
  const archive = new AdmZip(archivePath);
147
- const normalizedMember = memberName.replace(/\\/g, '/');
148
- const entry = archive.getEntries().find((candidate) => candidate.entryName.replace(/\\/g, '/').endsWith(`/${normalizedMember}`) || candidate.entryName === normalizedMember);
149
- if (!entry)
150
- throw new Error(`Archive member not found: ${memberName}`);
151
- await fs.promises.mkdir(path.dirname(destination), { recursive: true });
152
- await fs.promises.writeFile(destination, entry.getData());
182
+ const entries = archive.getEntries();
183
+ for (const entry of entries) {
184
+ normalizeArchivePath(entry.entryName);
185
+ const mode = entry.header?.attr ?? 0;
186
+ if (((mode >>> 16) & 0xf000) === 0xa000)
187
+ throw new Error(`Archive contains a symbolic link: ${entry.entryName}`);
188
+ }
189
+ const candidates = entries.filter((entry) => {
190
+ const normalized = normalizeArchivePath(entry.entryName);
191
+ return normalized === memberName || normalized.endsWith(`/${memberName}`);
192
+ });
193
+ if (candidates.length !== 1)
194
+ throw new Error(candidates.length ? `Ambiguous archive member: ${memberName}` : `Archive member not found: ${memberName}`);
195
+ const declared = candidates[0].header;
196
+ const compressedSize = declared?.compressedSize;
197
+ const size = declared?.size;
198
+ if (typeof size !== 'number' || size < 0 || size > MAX_EXECUTABLE_BYTES)
199
+ throw new Error('ZIP member exceeds size limit or has invalid size');
200
+ if (typeof compressedSize !== 'number' || compressedSize < 0 || size / Math.max(1, compressedSize) > 1000)
201
+ throw new Error('ZIP member compression ratio exceeds limit');
202
+ const data = candidates[0].getData();
203
+ if (data.length !== size || data.length > MAX_EXECUTABLE_BYTES)
204
+ throw new Error('ZIP member actual size does not match declared size');
205
+ await fs.promises.writeFile(destination, data);
153
206
  };
154
- const extractTarMember = async (archivePath, memberName, destination) => {
155
- const tempDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'flucto-bin-'));
207
+ export const extractTarMember = async (archivePath, memberName, destination) => {
208
+ const stat = await fs.promises.stat(archivePath);
209
+ if (stat.size > MAX_DECOMPRESSED_TAR_BYTES)
210
+ throw new Error('TAR archive exceeds size limit');
211
+ const extractDir = await fs.promises.mkdtemp(path.join(path.dirname(destination), '.flucto-tar-'));
212
+ let expectedCount = 0;
213
+ let validationError = null;
214
+ const expectedMembers = new Set();
215
+ const filter = (rawPath, entry) => {
216
+ let normalized;
217
+ try {
218
+ normalized = normalizeArchivePath(rawPath);
219
+ }
220
+ catch (error) {
221
+ validationError = error instanceof Error ? error : new Error(String(error));
222
+ return false;
223
+ }
224
+ if (entry.type && !['File', 'Directory'].includes(entry.type)) {
225
+ validationError = new Error(`TAR links/special entries are rejected: ${rawPath}`);
226
+ return false;
227
+ }
228
+ const isCandidate = normalized === memberName || normalized.endsWith(`/${memberName}`);
229
+ if (isCandidate) {
230
+ expectedCount += 1;
231
+ if (expectedCount > 1)
232
+ throw new Error(`Ambiguous TAR member: ${memberName}`);
233
+ if (entry.type !== 'File') {
234
+ validationError = new Error(`Expected regular TAR file: ${rawPath}`);
235
+ return false;
236
+ }
237
+ if (typeof entry.size !== 'number' || entry.size > MAX_EXECUTABLE_BYTES) {
238
+ validationError = new Error('TAR executable exceeds size limit');
239
+ return false;
240
+ }
241
+ expectedMembers.add(normalized);
242
+ return true;
243
+ }
244
+ if (entry.type === 'Directory')
245
+ return true;
246
+ return false;
247
+ };
156
248
  try {
157
- const result = await execa('tar', ['-xf', archivePath, '-C', tempDir], { reject: false });
158
- if (result.failed)
159
- throw new Error(result.stderr || 'tar extraction failed');
160
- const found = findFileNamed(tempDir, memberName);
161
- if (!found)
162
- throw new Error(`Archive member not found: ${memberName}`);
163
- await fs.promises.mkdir(path.dirname(destination), { recursive: true });
249
+ await tar.x({ file: archivePath, cwd: extractDir, strict: true, filter });
250
+ if (validationError)
251
+ throw validationError;
252
+ if (expectedCount !== 1 || expectedMembers.size !== 1)
253
+ throw new Error(`TAR member not found: ${memberName}`);
254
+ const found = path.join(extractDir, ...[...expectedMembers][0].split('/'));
255
+ if (!fs.existsSync(found))
256
+ throw new Error(`TAR member not extracted: ${memberName}`);
257
+ const extracted = await fs.promises.stat(found);
258
+ if (!extracted.isFile() || extracted.size > MAX_EXECUTABLE_BYTES)
259
+ throw new Error('Extracted TAR member exceeds size limit');
164
260
  await fs.promises.copyFile(found, destination);
165
261
  }
166
262
  finally {
167
- await fs.promises.rm(tempDir, { recursive: true, force: true });
263
+ await fs.promises.rm(extractDir, { recursive: true, force: true });
264
+ }
265
+ };
266
+ const decompressXz = async (source, destination) => {
267
+ const child = spawn('xz', ['-dc', '--', source], { stdio: ['ignore', 'pipe', 'pipe'], shell: false, windowsHide: true });
268
+ let stderr = '';
269
+ let spawnError = null;
270
+ child.stderr.setEncoding('utf8');
271
+ child.stderr.on('data', (chunk) => { stderr = (stderr + chunk).slice(-8192); });
272
+ const exited = new Promise((resolve) => {
273
+ child.once('error', (error) => { spawnError = error; });
274
+ child.once('close', resolve);
275
+ });
276
+ let total = 0;
277
+ const limiter = new Transform({ transform(chunk, _encoding, callback) {
278
+ total += chunk.length;
279
+ callback(total > MAX_DECOMPRESSED_TAR_BYTES ? new Error('Decompressed TAR exceeds size limit') : null, chunk);
280
+ } });
281
+ let timedOut = false;
282
+ let forceKillTimer;
283
+ const timeout = setTimeout(() => {
284
+ timedOut = true;
285
+ child.kill('SIGTERM');
286
+ forceKillTimer = setTimeout(() => child.kill('SIGKILL'), 5000);
287
+ }, 120000);
288
+ const stopChild = async () => {
289
+ if (child.exitCode !== null || child.signalCode !== null)
290
+ return;
291
+ child.kill('SIGTERM');
292
+ const closed = await Promise.race([
293
+ exited.then(() => true),
294
+ new Promise((resolve) => setTimeout(() => resolve(false), 2000)),
295
+ ]);
296
+ if (!closed && child.exitCode === null && child.signalCode === null)
297
+ child.kill('SIGKILL');
298
+ if (!closed)
299
+ await exited;
300
+ };
301
+ try {
302
+ await Promise.all([
303
+ pipeline(child.stdout, limiter, fs.createWriteStream(destination, { flags: 'wx' })),
304
+ exited.then((code) => {
305
+ if (spawnError)
306
+ throw spawnError;
307
+ if (timedOut)
308
+ throw new Error('xz decompression timed out');
309
+ if (code !== 0)
310
+ throw new Error(`xz decompression failed (${code}): ${stderr}`);
311
+ }),
312
+ ]);
313
+ }
314
+ catch (error) {
315
+ await stopChild();
316
+ await fs.promises.rm(destination, { force: true });
317
+ throw error;
318
+ }
319
+ finally {
320
+ clearTimeout(timeout);
321
+ if (forceKillTimer)
322
+ clearTimeout(forceKillTimer);
168
323
  }
169
324
  };
170
325
  const extractGzipMember = async (archivePath, destination) => {
171
- await fs.promises.mkdir(path.dirname(destination), { recursive: true });
172
- await pipeline(fs.createReadStream(archivePath), zlib.createGunzip(), fs.createWriteStream(destination));
326
+ let total = 0;
327
+ const limiter = new Transform({ transform(chunk, _encoding, callback) {
328
+ total += chunk.length;
329
+ callback(total > MAX_EXECUTABLE_BYTES ? new Error('Gzip executable exceeds size limit') : null, chunk);
330
+ } });
331
+ await pipeline(fs.createReadStream(archivePath), zlib.createGunzip(), limiter, fs.createWriteStream(destination, { flags: 'wx' }));
173
332
  };
174
- const findFileNamed = (directory, filename) => {
175
- for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
176
- const candidate = path.join(directory, entry.name);
177
- if (entry.isFile() && entry.name === filename)
178
- return candidate;
179
- if (entry.isDirectory()) {
180
- const nested = findFileNamed(candidate, filename);
181
- if (nested)
182
- return nested;
183
- }
184
- }
185
- return null;
333
+ const replacePreservingOld = async (staged, target) => {
334
+ // Same-filesystem rename is atomic on POSIX. On platforms that reject
335
+ // replacement (notably Windows with a target in use), fail without moving it.
336
+ await fs.promises.rename(staged, target);
186
337
  };
187
338
  const isZipArchive = async (filePath) => {
188
339
  if (filePath.toLowerCase().endsWith('.zip'))
@@ -197,52 +348,174 @@ const isZipArchive = async (filePath) => {
197
348
  await file.close();
198
349
  }
199
350
  };
200
- const provisionUtilityFromUrl = async (spec, url, targetPath, onStatus) => {
201
- const tempDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'flucto-download-'));
351
+ const extractValidateUtility = async (spec, archivePath, stagedPath, tempDir, decompressedTarCache = new Map()) => {
352
+ if (spec.name === 'yt-dlp')
353
+ await fs.promises.copyFile(archivePath, stagedPath);
354
+ else {
355
+ const lower = archivePath.toLowerCase();
356
+ const member = spec.archiveMember ?? spec.executableName;
357
+ if (await isZipArchive(archivePath))
358
+ await extractZipMember(archivePath, member, stagedPath);
359
+ else if (lower.endsWith('.gz') && !lower.endsWith('.tar.gz'))
360
+ await extractGzipMember(archivePath, stagedPath);
361
+ else if (lower.endsWith('.tar.xz')) {
362
+ let tarPath = decompressedTarCache.get(archivePath);
363
+ if (!tarPath) {
364
+ tarPath = path.join(tempDir, `archive-${decompressedTarCache.size}.decompressed.tar`);
365
+ await decompressXz(archivePath, tarPath);
366
+ decompressedTarCache.set(archivePath, tarPath);
367
+ }
368
+ await extractTarMember(tarPath, member, stagedPath);
369
+ }
370
+ else
371
+ await extractTarMember(archivePath, member, stagedPath);
372
+ }
373
+ if (process.platform !== 'win32')
374
+ await fs.promises.chmod(stagedPath, 0o755);
375
+ if (!await versionFor(stagedPath, spec.versionArgs))
376
+ throw new Error(`${spec.name} staged executable failed version validation`);
377
+ };
378
+ const provisionUtilityFromUrl = async (spec, url, targetPath, onStatus, fetchImpl = fetch) => {
379
+ await fs.promises.mkdir(path.dirname(targetPath), { recursive: true });
380
+ const tempDir = await fs.promises.mkdtemp(path.join(path.dirname(targetPath), '.flucto-download-'));
202
381
  const archivePath = path.join(tempDir, path.basename(new URL(url).pathname) || `${spec.name}.download`);
382
+ const stagedPath = path.join(tempDir, spec.executableName);
203
383
  try {
204
384
  onStatus?.(`Downloading ${spec.name}...`);
205
- await downloadFile(url, archivePath);
206
- if (spec.name === 'yt-dlp') {
207
- // yt-dlp assets are bare executables, never archives.
208
- await fs.promises.copyFile(archivePath, targetPath);
209
- }
210
- else {
211
- // Pick the extractor from the archive format, not the host platform:
212
- // macOS sources ship both .zip (vendor builds) and .gz (ffmpeg-static).
213
- const lower = archivePath.toLowerCase();
214
- const member = spec.archiveMember ?? spec.executableName;
215
- if (await isZipArchive(archivePath)) {
216
- await extractZipMember(archivePath, member, targetPath);
217
- }
218
- else if (lower.endsWith('.gz') && !lower.endsWith('.tar.gz')) {
219
- await extractGzipMember(archivePath, targetPath);
220
- }
221
- else {
222
- await extractTarMember(archivePath, member, targetPath);
223
- }
224
- }
225
- if (process.platform !== 'win32')
226
- await fs.promises.chmod(targetPath, 0o755);
385
+ await downloadFile(url, archivePath, fetchImpl);
386
+ if (spec.archiveSha256 && !verifySha256(await fs.promises.readFile(archivePath), spec.archiveSha256))
387
+ throw new Error(`${spec.name} archive SHA-256 mismatch`);
388
+ await extractValidateUtility(spec, archivePath, stagedPath, tempDir);
389
+ await replacePreservingOld(stagedPath, targetPath);
227
390
  }
228
391
  finally {
229
392
  await fs.promises.rm(tempDir, { recursive: true, force: true });
230
393
  }
231
394
  };
232
- export const provisionUtility = async (spec, targetPath, onStatus) => {
395
+ export const provisionUtility = async (spec, targetPath, onStatus, fetchImpl = fetch) => {
233
396
  const errors = [];
234
- for (const url of spec.downloadUrls) {
397
+ const sources = spec.name === 'yt-dlp'
398
+ ? await ytDlpRuntimeSources(spec.downloadUrls)
399
+ : spec.downloadUrls;
400
+ for (const url of sources) {
235
401
  try {
236
- await provisionUtilityFromUrl(spec, url, targetPath, onStatus);
402
+ await provisionUtilityFromUrl(spec, url, targetPath, onStatus, fetchImpl);
237
403
  return;
238
404
  }
239
405
  catch (error) {
240
406
  errors.push(error instanceof Error ? error.message : String(error));
241
407
  }
242
408
  }
243
- throw new Error(`Failed to provision ${spec.name}: ${errors.join(' | ')}`);
409
+ throw new Error(`Failed to provision ${spec.name}: ${errors.length ? errors.join(' | ') : 'no verified download source is configured'}`);
244
410
  };
245
411
  const managedTargetPath = (binDir, name) => path.join(binDir, executableName(name));
412
+ const expectedAvVersionIdentity = (platform) => platform === 'win32' ? '8.1.2' : platform === 'darwin' ? '9.0.2' : 'N-128959-g4dbee3b241';
413
+ const versionIdentity = (value) => value?.match(/version ([^ ]+)/)?.[1] ?? null;
414
+ const versionsMatch = (left, right) => {
415
+ const leftIdentity = versionIdentity(left);
416
+ const rightIdentity = versionIdentity(right);
417
+ return leftIdentity !== null && rightIdentity !== null && leftIdentity === rightIdentity;
418
+ };
419
+ export const replaceManagedAvPair = async (pairs, binDir, operations = {}) => {
420
+ const rename = operations.rename ?? fs.promises.rename.bind(fs.promises);
421
+ const remove = operations.remove ?? fs.promises.rm.bind(fs.promises);
422
+ const backupDir = await fs.promises.mkdtemp(path.join(binDir, '.av-backup-'));
423
+ const backups = [];
424
+ const installed = [];
425
+ try {
426
+ for (const [i, pair] of pairs.entries()) {
427
+ try {
428
+ await fs.promises.access(pair.target);
429
+ const backup = path.join(backupDir, `${i}-${path.basename(pair.target)}`);
430
+ await rename(pair.target, backup);
431
+ backups.push({ target: pair.target, backup });
432
+ }
433
+ catch (error) {
434
+ if (error.code !== 'ENOENT')
435
+ throw error;
436
+ }
437
+ }
438
+ for (const pair of pairs) {
439
+ await rename(pair.staged, pair.target);
440
+ installed.push(pair.target);
441
+ }
442
+ await remove(backupDir, { recursive: true, force: true });
443
+ backups.length = 0;
444
+ }
445
+ catch (error) {
446
+ const rollbackErrors = [];
447
+ for (const target of installed.reverse()) {
448
+ try {
449
+ await remove(target, { force: true });
450
+ }
451
+ catch (rollbackError) {
452
+ rollbackErrors.push(rollbackError);
453
+ }
454
+ }
455
+ for (const item of backups.reverse()) {
456
+ try {
457
+ await rename(item.backup, item.target);
458
+ }
459
+ catch (rollbackError) {
460
+ rollbackErrors.push(rollbackError);
461
+ }
462
+ }
463
+ if (rollbackErrors.length)
464
+ throw new AggregateError([error, ...rollbackErrors], `FFmpeg/FFprobe replacement rollback incomplete; backups preserved in ${backupDir}`);
465
+ throw error;
466
+ }
467
+ finally {
468
+ if (!backups.some((item) => fs.existsSync(item.backup)))
469
+ await remove(backupDir, { recursive: true, force: true });
470
+ }
471
+ };
472
+ export const downloadUniquePinnedAvArchives = async (specs, directory, fetchImpl = fetch) => {
473
+ const archives = new Map();
474
+ for (const spec of specs) {
475
+ const url = spec.downloadUrls[0];
476
+ if (!url)
477
+ throw new Error(`No pinned source for ${spec.name}`);
478
+ if (!archives.has(url)) {
479
+ const archivePath = path.join(directory, `archive-${archives.size}-${path.basename(new URL(url).pathname)}`);
480
+ await downloadFile(url, archivePath, fetchImpl);
481
+ if (!spec.archiveSha256 || !verifySha256(await fs.promises.readFile(archivePath), spec.archiveSha256))
482
+ throw new Error(`${spec.name} archive SHA-256 mismatch`);
483
+ archives.set(url, archivePath);
484
+ }
485
+ else {
486
+ const shared = archives.get(url);
487
+ if (!spec.archiveSha256 || !verifySha256(await fs.promises.readFile(shared), spec.archiveSha256))
488
+ throw new Error(`${spec.name} shared archive SHA-256 mismatch`);
489
+ }
490
+ }
491
+ return archives;
492
+ };
493
+ const provisionManagedAvPair = async (ffmpegSpec, ffprobeSpec, binDir, force, onStatus, fetchImpl = fetch) => {
494
+ const expected = expectedAvVersionIdentity(process.platform);
495
+ const targets = [managedTargetPath(binDir, 'ffmpeg'), managedTargetPath(binDir, 'ffprobe')];
496
+ const installedMatches = await Promise.all(targets.map(async (target) => (await versionFor(target, ['-version']))?.includes(expected) ?? false));
497
+ if (!force && installedMatches.every(Boolean))
498
+ return false;
499
+ const stageDir = await fs.promises.mkdtemp(path.join(binDir, '.av-stage-'));
500
+ try {
501
+ const specs = [ffmpegSpec, ffprobeSpec];
502
+ const stagePaths = specs.map((spec) => path.join(stageDir, spec.executableName));
503
+ onStatus?.('Downloading pinned FFmpeg/FFprobe archives...');
504
+ const archives = await downloadUniquePinnedAvArchives(specs, stageDir, fetchImpl);
505
+ const decompressedTarCache = new Map();
506
+ for (let index = 0; index < specs.length; index += 1) {
507
+ await extractValidateUtility(specs[index], archives.get(specs[index].downloadUrls[0]), stagePaths[index], stageDir, decompressedTarCache);
508
+ }
509
+ const versions = await Promise.all([versionFor(stagePaths[0], ffmpegSpec.versionArgs), versionFor(stagePaths[1], ffprobeSpec.versionArgs)]);
510
+ if (!versions[0]?.includes(expected) || !versions[1]?.includes(expected))
511
+ throw new Error('Staged FFmpeg/FFprobe pair does not match the pinned build identity');
512
+ await replaceManagedAvPair(stagePaths.map((staged, i) => ({ staged, target: targets[i] })), binDir);
513
+ return true;
514
+ }
515
+ finally {
516
+ await fs.promises.rm(stageDir, { recursive: true, force: true });
517
+ }
518
+ };
246
519
  export const setupUtilities = async (options = {}) => {
247
520
  const env = options.env ?? process.env;
248
521
  const cwd = options.cwd ?? process.cwd();
@@ -250,19 +523,57 @@ export const setupUtilities = async (options = {}) => {
250
523
  const utilities = [];
251
524
  if (!options.checkOnly)
252
525
  await fs.promises.mkdir(binDir, { recursive: true });
253
- const specs = options.only?.length
254
- ? utilitySpecs().filter((spec) => options.only?.includes(spec.name))
255
- : utilitySpecs();
526
+ const allSpecs = utilitySpecs();
527
+ const specs = options.only?.length ? allSpecs.filter((spec) => options.only?.includes(spec.name)) : allSpecs;
528
+ const selectedAvPair = specs.some((spec) => spec.name === 'ffmpeg' || spec.name === 'ffprobe');
529
+ const customFfmpeg = options.ffmpegPath ?? env.FLUCTO_FFMPEG_PATH;
530
+ let avPairProvisioned = false;
531
+ let avPairError;
532
+ if (options.checkOnly && selectedAvPair) {
533
+ const ffmpegPath = customFfmpeg ? path.resolve(customFfmpeg) : managedTargetPath(binDir, 'ffmpeg');
534
+ const ffprobePath = customFfmpeg ? path.join(path.dirname(ffmpegPath), executableName('ffprobe')) : managedTargetPath(binDir, 'ffprobe');
535
+ const ffmpegVersion = await versionFor(ffmpegPath, ['-version']);
536
+ const ffprobeVersion = await versionFor(ffprobePath, ['-version']);
537
+ const identitiesMatch = versionsMatch(ffmpegVersion, ffprobeVersion);
538
+ const expectedMatch = customFfmpeg || (versionIdentity(ffmpegVersion) === expectedAvVersionIdentity(process.platform) && versionIdentity(ffprobeVersion) === expectedAvVersionIdentity(process.platform));
539
+ if (!identitiesMatch || !expectedMatch)
540
+ avPairError = customFfmpeg
541
+ ? `Explicit FFmpeg/adjacent FFprobe pair is missing or version-incompatible (${ffmpegPath}, ${ffprobePath}).`
542
+ : 'Managed FFmpeg/FFprobe pair is missing, stale, or version-mismatched for the pinned build.';
543
+ }
544
+ if (!options.checkOnly && selectedAvPair && !customFfmpeg) {
545
+ try {
546
+ avPairProvisioned = await provisionManagedAvPair(allSpecs.find((spec) => spec.name === 'ffmpeg'), allSpecs.find((spec) => spec.name === 'ffprobe'), binDir, Boolean(options.force), options.onStatus, options.fetchImpl);
547
+ }
548
+ catch (error) {
549
+ avPairError = error instanceof Error ? error.message : String(error);
550
+ }
551
+ }
256
552
  for (const spec of specs) {
257
- const explicitPath = spec.name === 'yt-dlp' ? options.ytDlpPath ?? env.FLUCTO_YT_DLP_PATH : options.ffmpegPath ?? env.FLUCTO_FFMPEG_PATH;
258
- const targetPath = explicitPath ? path.resolve(explicitPath) : managedTargetPath(binDir, spec.name);
553
+ const explicitPath = spec.name === 'yt-dlp'
554
+ ? options.ytDlpPath ?? env.FLUCTO_YT_DLP_PATH
555
+ : spec.name === 'ffmpeg' ? options.ffmpegPath ?? env.FLUCTO_FFMPEG_PATH : undefined;
556
+ const configuredFfmpegPath = options.ffmpegPath ?? env.FLUCTO_FFMPEG_PATH;
557
+ if (selectedAvPair && !customFfmpeg && !options.checkOnly && (spec.name === 'ffmpeg' || spec.name === 'ffprobe')) {
558
+ const target = managedTargetPath(binDir, spec.name);
559
+ const version = avPairError ? null : await versionFor(target, spec.versionArgs);
560
+ utilities.push({ name: spec.name, path: target, status: avPairError ? 'failed' : avPairProvisioned ? 'downloaded' : 'present', version, error: avPairError });
561
+ continue;
562
+ }
563
+ const targetPath = explicitPath
564
+ ? path.resolve(explicitPath)
565
+ : spec.name === 'ffprobe' && configuredFfmpegPath
566
+ ? path.join(path.dirname(path.resolve(configuredFfmpegPath)), executableName('ffprobe'))
567
+ : managedTargetPath(binDir, spec.name);
259
568
  const present = isExecutable(targetPath);
260
569
  if (options.checkOnly) {
570
+ const isAv = spec.name === 'ffmpeg' || spec.name === 'ffprobe';
261
571
  utilities.push({
262
572
  name: spec.name,
263
573
  path: targetPath,
264
- status: present ? 'present' : 'missing',
574
+ status: isAv && avPairError ? 'failed' : present ? 'present' : 'missing',
265
575
  version: present ? await versionFor(targetPath, spec.versionArgs) : null,
576
+ error: isAv ? avPairError : undefined,
266
577
  });
267
578
  continue;
268
579
  }
@@ -276,7 +587,15 @@ export const setupUtilities = async (options = {}) => {
276
587
  });
277
588
  continue;
278
589
  }
279
- if (present && !options.force) {
590
+ const ffprobeBesideExplicitFfmpeg = spec.name === 'ffprobe' && Boolean(configuredFfmpegPath);
591
+ if (ffprobeBesideExplicitFfmpeg) {
592
+ const ffmpegVersion = await versionFor(path.resolve(configuredFfmpegPath), ['-version']);
593
+ const ffprobeVersion = await versionFor(targetPath, spec.versionArgs);
594
+ const compatible = versionsMatch(ffmpegVersion, ffprobeVersion);
595
+ utilities.push({ name: spec.name, path: targetPath, status: compatible ? 'present' : 'failed', version: ffprobeVersion, error: compatible ? undefined : `Explicit FFmpeg/adjacent FFprobe pair is missing or version-incompatible (${configuredFfmpegPath}, ${targetPath}).` });
596
+ continue;
597
+ }
598
+ if (present && (!options.force || ffprobeBesideExplicitFfmpeg)) {
280
599
  const installedVersion = await versionFor(targetPath, spec.versionArgs);
281
600
  if (spec.name === 'yt-dlp') {
282
601
  const latestVersion = await fetchLatestYtDlpVersion();