@socketsecurity/lib 6.0.6 → 6.0.8

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 (619) hide show
  1. package/CHANGELOG.md +46 -1
  2. package/README.md +1 -1
  3. package/dist/ai/agent-context.d.mts +103 -0
  4. package/dist/ai/agent-context.js +157 -0
  5. package/dist/ai/backends.d.mts +83 -0
  6. package/dist/ai/backends.js +173 -0
  7. package/dist/ai/credentials.d.mts +49 -0
  8. package/dist/ai/credentials.js +82 -0
  9. package/dist/ai/discover.d.mts +6 -2
  10. package/dist/ai/discover.js +4 -3
  11. package/dist/ai/exec.d.mts +52 -0
  12. package/dist/ai/exec.js +92 -0
  13. package/dist/ai/http.d.mts +132 -0
  14. package/dist/ai/http.js +130 -0
  15. package/dist/ai/profiles.d.mts +41 -6
  16. package/dist/ai/profiles.js +52 -10
  17. package/dist/ai/route.d.mts +69 -0
  18. package/dist/ai/route.js +156 -0
  19. package/dist/ai/spawn.d.mts +10 -2
  20. package/dist/ai/spawn.js +56 -31
  21. package/dist/ai/subagent-status.d.mts +48 -0
  22. package/dist/ai/subagent-status.js +57 -0
  23. package/dist/ai/tier.d.mts +60 -0
  24. package/dist/ai/tier.js +53 -0
  25. package/dist/ai/types.d.mts +31 -6
  26. package/dist/ai/worktree.d.mts +6 -6
  27. package/dist/ai/worktree.js +5 -1
  28. package/dist/ansi/strip.d.ts +1 -1
  29. package/dist/ansi/strip.js +0 -2
  30. package/dist/archives/_internal.js +7 -9
  31. package/dist/archives/extract.js +1 -1
  32. package/dist/archives/tar.js +7 -7
  33. package/dist/archives/zip.js +5 -7
  34. package/dist/argv/flag-predicates.d.ts +12 -12
  35. package/dist/argv/flag-predicates.js +17 -17
  36. package/dist/argv/flag-types.d.ts +18 -18
  37. package/dist/argv/flag-types.js +4 -4
  38. package/dist/argv/parse.d.ts +20 -3
  39. package/dist/argv/parse.js +1 -1
  40. package/dist/arrays/_internal.js +11 -12
  41. package/dist/arrays/chunk.js +0 -1
  42. package/dist/arrays/join.d.ts +37 -3
  43. package/dist/arrays/join.js +47 -7
  44. package/dist/arrays/unique.js +0 -1
  45. package/dist/bin/_internal.d.ts +1 -1
  46. package/dist/bin/_internal.js +1 -1
  47. package/dist/bin/exec.js +2 -3
  48. package/dist/bin/find.js +17 -17
  49. package/dist/bin/prim.cjs +36175 -35861
  50. package/dist/bin/resolve.js +13 -14
  51. package/dist/bin/which.js +8 -8
  52. package/dist/cache/ttl/store.js +6 -6
  53. package/dist/checks/primordials-defaults.d.ts +3 -3
  54. package/dist/checks/primordials-defaults.js +3 -3
  55. package/dist/checks/primordials.js +4 -3
  56. package/dist/{bin → cli}/check-primordials.d.ts +18 -13
  57. package/dist/{bin → cli}/check-primordials.js +58 -55
  58. package/dist/{bin → cli}/check.js +3 -3
  59. package/dist/{bin → cli}/socket-lib.d.ts +1 -1
  60. package/dist/{bin → cli}/socket-lib.js +4 -4
  61. package/dist/colors/socket-palette.js +7 -9
  62. package/dist/compression/_internal.d.ts +12 -12
  63. package/dist/compression/_internal.js +18 -18
  64. package/dist/compression/brotli.d.ts +26 -27
  65. package/dist/compression/brotli.js +39 -35
  66. package/dist/compression/gzip.d.ts +23 -23
  67. package/dist/compression/gzip.js +46 -42
  68. package/dist/constants/agents.d.ts +3 -1
  69. package/dist/constants/agents.js +15 -11
  70. package/dist/constants/licenses.js +3 -3
  71. package/dist/constants/node.d.ts +23 -0
  72. package/dist/constants/node.js +47 -15
  73. package/dist/constants/packages.d.ts +3 -0
  74. package/dist/constants/packages.js +24 -29
  75. package/dist/constants/platform.d.ts +30 -3
  76. package/dist/constants/platform.js +72 -12
  77. package/dist/constants/runtime.d.ts +22 -0
  78. package/dist/constants/runtime.js +32 -0
  79. package/dist/constants/socket.d.ts +2 -6
  80. package/dist/constants/socket.js +12 -14
  81. package/dist/cover/code.js +10 -10
  82. package/dist/cover/formatters.js +5 -5
  83. package/dist/crypto/hash.d.ts +30 -2
  84. package/dist/crypto/hash.js +47 -13
  85. package/dist/debug/_internal.js +4 -6
  86. package/dist/debug/caller-info.js +3 -4
  87. package/dist/debug/namespace.d.ts +7 -0
  88. package/dist/debug/namespace.js +21 -12
  89. package/dist/debug/output.js +21 -24
  90. package/dist/debug/types.d.ts +4 -4
  91. package/dist/dlx/arborist.js +18 -8
  92. package/dist/dlx/binary-cache.js +15 -15
  93. package/dist/dlx/binary-download.d.ts +1 -1
  94. package/dist/dlx/binary-download.js +11 -11
  95. package/dist/dlx/binary-resolution.js +17 -15
  96. package/dist/dlx/binary-types.d.ts +5 -5
  97. package/dist/dlx/binary.js +5 -5
  98. package/dist/dlx/cache.js +1 -1
  99. package/dist/dlx/detect.d.ts +42 -25
  100. package/dist/dlx/detect.js +86 -77
  101. package/dist/dlx/dir.js +2 -2
  102. package/dist/dlx/firewall.d.ts +9 -1
  103. package/dist/dlx/firewall.js +1 -1
  104. package/dist/dlx/lockfile.d.ts +19 -18
  105. package/dist/dlx/lockfile.js +19 -16
  106. package/dist/dlx/manifest.d.ts +6 -6
  107. package/dist/dlx/manifest.js +5 -5
  108. package/dist/dlx/package.d.ts +10 -10
  109. package/dist/dlx/package.js +20 -16
  110. package/dist/dlx/packages.js +4 -4
  111. package/dist/dlx/paths.js +7 -7
  112. package/dist/dlx/spec.js +1 -1
  113. package/dist/dlx/types.d.ts +28 -27
  114. package/dist/eco/cargo/parse-lockfile.d.ts +2 -3
  115. package/dist/eco/cargo/parse-lockfile.js +5 -5
  116. package/dist/eco/manifest/analyze-lockfile.js +2 -2
  117. package/dist/eco/manifest/detect-format.js +5 -5
  118. package/dist/eco/manifest/find-packages.js +2 -2
  119. package/dist/eco/manifest/get-package-versions.js +2 -2
  120. package/dist/eco/manifest/get-package.js +2 -2
  121. package/dist/eco/manifest/parse-lockfile.js +2 -2
  122. package/dist/eco/manifest/parse-manifest.js +2 -2
  123. package/dist/eco/manifest/parse.js +2 -2
  124. package/dist/eco/npm/npm/exec.js +2 -2
  125. package/dist/eco/npm/npm/flags.js +7 -12
  126. package/dist/eco/npm/npm/parse-lockfile.d.ts +17 -18
  127. package/dist/eco/npm/npm/parse-lockfile.js +4 -4
  128. package/dist/eco/npm/parse-package-json.d.ts +11 -0
  129. package/dist/eco/npm/parse-package-json.js +3 -3
  130. package/dist/eco/npm/pnpm/exec.d.ts +1 -1
  131. package/dist/eco/npm/pnpm/exec.js +5 -5
  132. package/dist/eco/npm/pnpm/flags.js +0 -3
  133. package/dist/eco/npm/pnpm/parse-lockfile.d.ts +6 -4
  134. package/dist/eco/npm/pnpm/parse-lockfile.js +7 -7
  135. package/dist/eco/npm/script.js +9 -6
  136. package/dist/eco/npm/yarnpkg/yarn/exec.js +4 -4
  137. package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.d.ts +3 -4
  138. package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +9 -9
  139. package/dist/effects/pulse-frames.d.ts +3 -1
  140. package/dist/effects/shimmer-keyframes.d.ts +1 -1
  141. package/dist/effects/shimmer-terminal.d.ts +1 -1
  142. package/dist/env/boolean.js +0 -1
  143. package/dist/env/ci.js +0 -1
  144. package/dist/env/debug.js +0 -1
  145. package/dist/env/github-status.d.ts +51 -0
  146. package/dist/env/github-status.js +90 -0
  147. package/dist/env/github.js +0 -8
  148. package/dist/env/home.js +0 -1
  149. package/dist/env/locale.js +0 -3
  150. package/dist/env/node-auth-token.js +0 -1
  151. package/dist/env/node-env.js +0 -1
  152. package/dist/env/node-version-managers.d.ts +53 -0
  153. package/dist/env/node-version-managers.js +90 -0
  154. package/dist/env/npm.js +0 -5
  155. package/dist/env/number.js +0 -1
  156. package/dist/env/package-manager.js +3 -6
  157. package/dist/env/path.js +0 -1
  158. package/dist/env/pre-commit.js +1 -2
  159. package/dist/env/proxy.js +1 -1
  160. package/dist/env/rewire.d.ts +8 -6
  161. package/dist/env/rewire.js +16 -17
  162. package/dist/env/shell.js +0 -1
  163. package/dist/env/socket-cli.js +5 -18
  164. package/dist/env/socket-mcp.d.ts +114 -0
  165. package/dist/env/socket-mcp.js +146 -0
  166. package/dist/env/socket.d.ts +8 -109
  167. package/dist/env/socket.js +22 -167
  168. package/dist/env/string.js +0 -1
  169. package/dist/env/temp-dir.js +0 -3
  170. package/dist/env/term.js +0 -1
  171. package/dist/env/test.js +3 -6
  172. package/dist/env/windows.js +0 -4
  173. package/dist/env/xdg.js +0 -3
  174. package/dist/errors/predicates.js +1 -1
  175. package/dist/events/exit/_internal.d.ts +11 -9
  176. package/dist/events/exit/_internal.js +31 -35
  177. package/dist/events/exit/handler.js +3 -4
  178. package/dist/events/exit/intercept.js +4 -6
  179. package/dist/events/exit/lifecycle.js +16 -18
  180. package/dist/events/exit/signals.js +1 -2
  181. package/dist/events/exit/types.d.ts +6 -5
  182. package/dist/external/@npmcli/package-json.js +2 -2
  183. package/dist/external/@npmcli/promise-spawn.js +3 -1
  184. package/dist/external/npm-pack.js +2 -2
  185. package/dist/external/pico-pack.js +4 -2
  186. package/dist/external/which.js +3 -1
  187. package/dist/external-tools/bazel/asset-names.d.ts +1 -1
  188. package/dist/external-tools/bazel/asset-names.js +5 -2
  189. package/dist/external-tools/bazel/from-download.d.ts +1 -1
  190. package/dist/external-tools/bazel/from-download.js +5 -2
  191. package/dist/external-tools/bazel/read-bazel-version-file.js +1 -1
  192. package/dist/external-tools/bazel/resolve-bazel-version.js +4 -0
  193. package/dist/external-tools/bazel/resolve.d.ts +3 -3
  194. package/dist/external-tools/bazel/resolve.js +16 -8
  195. package/dist/external-tools/bazel/types.d.ts +1 -1
  196. package/dist/external-tools/cdxgen/asset-names.d.ts +1 -1
  197. package/dist/external-tools/cdxgen/asset-names.js +5 -2
  198. package/dist/external-tools/cdxgen/from-download.d.ts +1 -1
  199. package/dist/external-tools/cdxgen/from-download.js +7 -4
  200. package/dist/external-tools/cdxgen/from-vfs.js +1 -1
  201. package/dist/external-tools/cdxgen/resolve.d.ts +3 -3
  202. package/dist/external-tools/cdxgen/resolve.js +16 -8
  203. package/dist/external-tools/cdxgen/types.d.ts +1 -1
  204. package/dist/external-tools/from-download.d.ts +3 -3
  205. package/dist/external-tools/from-download.js +12 -6
  206. package/dist/external-tools/from-pip-venv.d.ts +1 -1
  207. package/dist/external-tools/from-pip-venv.js +12 -5
  208. package/dist/external-tools/janus/asset-names.d.ts +1 -1
  209. package/dist/external-tools/janus/asset-names.js +5 -2
  210. package/dist/external-tools/janus/from-download.d.ts +1 -1
  211. package/dist/external-tools/janus/from-download.js +5 -2
  212. package/dist/external-tools/janus/from-vfs.js +1 -1
  213. package/dist/external-tools/janus/resolve.d.ts +3 -3
  214. package/dist/external-tools/janus/resolve.js +16 -8
  215. package/dist/external-tools/janus/types.d.ts +1 -1
  216. package/dist/external-tools/jre/asset-names.d.ts +1 -1
  217. package/dist/external-tools/jre/asset-names.js +5 -2
  218. package/dist/external-tools/jre/detect-platform-arch.d.ts +10 -6
  219. package/dist/external-tools/jre/detect-platform-arch.js +29 -14
  220. package/dist/external-tools/jre/from-download.d.ts +1 -1
  221. package/dist/external-tools/jre/from-download.js +7 -4
  222. package/dist/external-tools/jre/from-java-home.js +2 -2
  223. package/dist/external-tools/jre/from-vfs.js +3 -3
  224. package/dist/external-tools/jre/resolve.d.ts +3 -3
  225. package/dist/external-tools/jre/resolve.js +16 -8
  226. package/dist/external-tools/jre/types.d.ts +1 -1
  227. package/dist/external-tools/manifest.d.ts +25 -7
  228. package/dist/external-tools/manifest.js +13 -13
  229. package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
  230. package/dist/external-tools/opengrep/asset-names.js +5 -2
  231. package/dist/external-tools/opengrep/from-download.d.ts +1 -1
  232. package/dist/external-tools/opengrep/from-download.js +5 -2
  233. package/dist/external-tools/opengrep/from-vfs.js +1 -1
  234. package/dist/external-tools/opengrep/resolve.d.ts +3 -3
  235. package/dist/external-tools/opengrep/resolve.js +16 -8
  236. package/dist/external-tools/opengrep/types.d.ts +1 -1
  237. package/dist/external-tools/python/asset-names.d.ts +76 -0
  238. package/dist/external-tools/python/asset-names.js +111 -0
  239. package/dist/external-tools/python/dlx.d.ts +80 -0
  240. package/dist/external-tools/python/dlx.js +98 -0
  241. package/dist/external-tools/python/from-download.d.ts +53 -0
  242. package/dist/external-tools/python/from-download.js +75 -0
  243. package/dist/external-tools/python/from-path.d.ts +7 -0
  244. package/dist/external-tools/python/from-path.js +23 -0
  245. package/dist/external-tools/python/pin.d.ts +121 -0
  246. package/dist/external-tools/python/pin.js +176 -0
  247. package/dist/external-tools/python/pip-install.d.ts +75 -0
  248. package/dist/external-tools/python/pip-install.js +142 -0
  249. package/dist/external-tools/python/resolve.d.ts +42 -0
  250. package/dist/external-tools/python/resolve.js +66 -0
  251. package/dist/external-tools/python/types.d.ts +49 -0
  252. package/dist/external-tools/sbt/asset-names.d.ts +1 -1
  253. package/dist/external-tools/sbt/asset-names.js +5 -2
  254. package/dist/external-tools/sbt/from-download.d.ts +1 -1
  255. package/dist/external-tools/sbt/from-download.js +5 -2
  256. package/dist/external-tools/sbt/from-vfs.js +1 -1
  257. package/dist/external-tools/sbt/resolve.d.ts +3 -3
  258. package/dist/external-tools/sbt/resolve.js +16 -8
  259. package/dist/external-tools/sbt/types.d.ts +1 -1
  260. package/dist/external-tools/skillspector/from-dlx.d.ts +1 -1
  261. package/dist/external-tools/skillspector/from-dlx.js +10 -3
  262. package/dist/external-tools/skillspector/from-path.js +3 -5
  263. package/dist/external-tools/skillspector/from-vfs.js +1 -1
  264. package/dist/external-tools/skillspector/resolve.d.ts +2 -2
  265. package/dist/external-tools/skillspector/resolve.js +14 -6
  266. package/dist/external-tools/synp/asset-names.d.ts +1 -1
  267. package/dist/external-tools/synp/asset-names.js +6 -2
  268. package/dist/external-tools/synp/from-download.d.ts +1 -1
  269. package/dist/external-tools/synp/from-download.js +7 -4
  270. package/dist/external-tools/synp/from-vfs.js +1 -1
  271. package/dist/external-tools/synp/resolve.d.ts +3 -3
  272. package/dist/external-tools/synp/resolve.js +16 -8
  273. package/dist/external-tools/trivy/asset-names.d.ts +1 -1
  274. package/dist/external-tools/trivy/asset-names.js +5 -2
  275. package/dist/external-tools/trivy/from-download.d.ts +1 -1
  276. package/dist/external-tools/trivy/from-download.js +7 -4
  277. package/dist/external-tools/trivy/from-vfs.js +1 -1
  278. package/dist/external-tools/trivy/resolve.d.ts +3 -3
  279. package/dist/external-tools/trivy/resolve.js +16 -8
  280. package/dist/external-tools/trivy/types.d.ts +1 -1
  281. package/dist/external-tools/trufflehog/asset-names.d.ts +1 -1
  282. package/dist/external-tools/trufflehog/asset-names.js +5 -2
  283. package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
  284. package/dist/external-tools/trufflehog/from-download.js +7 -4
  285. package/dist/external-tools/trufflehog/from-vfs.js +1 -1
  286. package/dist/external-tools/trufflehog/resolve.d.ts +3 -3
  287. package/dist/external-tools/trufflehog/resolve.js +16 -8
  288. package/dist/external-tools/trufflehog/types.d.ts +1 -1
  289. package/dist/fs/_internal.d.ts +1 -1
  290. package/dist/fs/_internal.js +7 -7
  291. package/dist/fs/access.js +5 -9
  292. package/dist/fs/allowed-dirs-cache.d.ts +47 -0
  293. package/dist/fs/allowed-dirs-cache.js +69 -0
  294. package/dist/fs/encoding.js +5 -7
  295. package/dist/fs/{find-up.js → find.js} +12 -14
  296. package/dist/fs/inspect.js +7 -13
  297. package/dist/fs/read-dir.js +7 -10
  298. package/dist/fs/read-file.js +8 -14
  299. package/dist/fs/read-json-cache.d.ts +13 -4
  300. package/dist/fs/read-json-cache.js +9 -6
  301. package/dist/fs/read-json.js +4 -6
  302. package/dist/fs/resolve-module.js +7 -3
  303. package/dist/fs/safe.d.ts +1 -1
  304. package/dist/fs/safe.js +13 -14
  305. package/dist/fs/unique.js +4 -5
  306. package/dist/fs/validate.js +1 -2
  307. package/dist/fs/write-json.js +4 -5
  308. package/dist/git/_internal.js +11 -11
  309. package/dist/git/changed.js +4 -4
  310. package/dist/git/repo.js +5 -7
  311. package/dist/git/staged.js +12 -4
  312. package/dist/git/tracked.d.ts +84 -0
  313. package/dist/git/tracked.js +163 -0
  314. package/dist/git/unstaged.js +12 -4
  315. package/dist/github/ghsa.js +2 -2
  316. package/dist/github/refs-cache.d.ts +1 -1
  317. package/dist/github/refs-cache.js +5 -5
  318. package/dist/github/refs-graphql.js +4 -0
  319. package/dist/github/refs-rest.js +9 -5
  320. package/dist/github/refs.js +15 -10
  321. package/dist/github/{fetch.js → request.js} +13 -2
  322. package/dist/github/token.js +1 -1
  323. package/dist/github/types.d.ts +1 -1
  324. package/dist/globs/_internal.js +8 -10
  325. package/dist/globs/match.js +13 -7
  326. package/dist/globs/matcher.d.ts +3 -3
  327. package/dist/globs/matcher.js +16 -14
  328. package/dist/globs/stream.js +1 -2
  329. package/dist/globs/types.d.ts +24 -24
  330. package/dist/http-request/_internal.d.ts +1 -1
  331. package/dist/http-request/browser.js +10 -4
  332. package/dist/http-request/checksum-file.d.ts +55 -0
  333. package/dist/http-request/checksum-file.js +95 -0
  334. package/dist/http-request/download-types.d.ts +15 -23
  335. package/dist/http-request/download.js +3 -3
  336. package/dist/http-request/{browser-fetch.d.ts → fetch/browser.d.ts} +2 -2
  337. package/dist/http-request/{browser-fetch.js → fetch/browser.js} +4 -4
  338. package/dist/http-request/headers.js +1 -2
  339. package/dist/http-request/request-attempt.js +38 -34
  340. package/dist/http-request/request-types.d.ts +2 -2
  341. package/dist/http-request/request.js +1 -1
  342. package/dist/http-request/user-agent.js +4 -5
  343. package/dist/integrity.d.ts +92 -18
  344. package/dist/integrity.js +125 -30
  345. package/dist/ipc/directory.js +2 -2
  346. package/dist/ipc/paths.js +1 -1
  347. package/dist/ipc/write.js +1 -1
  348. package/dist/ipc-cli/get.js +12 -12
  349. package/dist/json/edit.js +51 -44
  350. package/dist/json/format.js +1 -1
  351. package/dist/json/parse.d.ts +1 -1
  352. package/dist/json/parse.js +3 -7
  353. package/dist/logger/_internal.d.ts +4 -4
  354. package/dist/logger/_internal.js +3 -3
  355. package/dist/logger/colors.js +4 -3
  356. package/dist/logger/console-methods.d.ts +132 -0
  357. package/dist/logger/console-methods.js +169 -0
  358. package/dist/logger/console.d.ts +12 -0
  359. package/dist/logger/console.js +42 -11
  360. package/dist/logger/indentation-methods.d.ts +81 -0
  361. package/dist/logger/indentation-methods.js +121 -0
  362. package/dist/logger/node.d.ts +16 -338
  363. package/dist/logger/node.js +75 -608
  364. package/dist/logger/options.d.ts +39 -0
  365. package/dist/logger/options.js +47 -0
  366. package/dist/logger/semantic-methods.d.ts +63 -0
  367. package/dist/logger/semantic-methods.js +108 -0
  368. package/dist/logger/stream-methods.d.ts +63 -0
  369. package/dist/logger/stream-methods.js +101 -0
  370. package/dist/logger/stream.d.ts +37 -0
  371. package/dist/logger/stream.js +42 -0
  372. package/dist/logger/symbols-builder.js +9 -9
  373. package/dist/logger/symbols.d.ts +2 -25
  374. package/dist/logger/symbols.js +53 -74
  375. package/dist/logger/types.d.ts +1 -1
  376. package/dist/memo/types.d.ts +6 -6
  377. package/dist/native-messaging/host.d.ts +20 -0
  378. package/dist/native-messaging/host.js +120 -0
  379. package/dist/native-messaging/index.d.ts +5 -0
  380. package/dist/native-messaging/index.js +22 -0
  381. package/dist/native-messaging/install.d.ts +60 -0
  382. package/dist/native-messaging/install.js +144 -0
  383. package/dist/native-messaging/rate-limit.d.ts +69 -0
  384. package/dist/native-messaging/rate-limit.js +119 -0
  385. package/dist/native-messaging/run.d.ts +10 -0
  386. package/dist/native-messaging/run.js +17 -0
  387. package/dist/node/async-hooks.js +4 -3
  388. package/dist/node/child-process.js +4 -3
  389. package/dist/node/crypto.js +4 -3
  390. package/dist/node/events.js +4 -3
  391. package/dist/node/fs-promises.js +4 -3
  392. package/dist/node/fs.d.ts +22 -6
  393. package/dist/node/fs.js +17 -3
  394. package/dist/node/http.js +4 -3
  395. package/dist/node/https.js +4 -3
  396. package/dist/node/module.js +10 -6
  397. package/dist/node/os.d.ts +10 -2
  398. package/dist/node/os.js +12 -4
  399. package/dist/node/path.d.ts +11 -2
  400. package/dist/node/path.js +18 -4
  401. package/dist/node/timers-promises.js +4 -3
  402. package/dist/node/url.js +4 -3
  403. package/dist/node/util.js +4 -3
  404. package/dist/objects/getters.js +6 -8
  405. package/dist/objects/inspect.js +1 -4
  406. package/dist/objects/mutate.js +4 -5
  407. package/dist/objects/predicates.js +1 -5
  408. package/dist/objects/sort.js +3 -7
  409. package/dist/packages/edit-class.d.ts +2 -3
  410. package/dist/packages/edit-class.js +53 -48
  411. package/dist/packages/edit.js +12 -14
  412. package/dist/packages/exports.js +15 -21
  413. package/dist/packages/fetch.d.ts +16 -0
  414. package/dist/packages/fetch.js +81 -0
  415. package/dist/packages/find.d.ts +55 -0
  416. package/dist/packages/find.js +65 -0
  417. package/dist/packages/isolation.js +14 -14
  418. package/dist/packages/licenses.js +18 -18
  419. package/dist/packages/manifest.js +16 -19
  420. package/dist/packages/metadata-extensions.d.ts +14 -0
  421. package/dist/packages/metadata-extensions.js +43 -0
  422. package/dist/packages/normalize.js +6 -10
  423. package/dist/packages/provenance.js +17 -19
  424. package/dist/packages/read.d.ts +29 -0
  425. package/dist/packages/read.js +66 -0
  426. package/dist/packages/specs.d.ts +48 -1
  427. package/dist/packages/specs.js +75 -12
  428. package/dist/packages/tarball.d.ts +24 -0
  429. package/dist/packages/tarball.js +81 -0
  430. package/dist/packages/types.d.ts +22 -22
  431. package/dist/packages/validation.js +0 -3
  432. package/dist/paths/_internal.d.ts +2 -1
  433. package/dist/paths/_internal.js +7 -19
  434. package/dist/paths/conversion.js +5 -9
  435. package/dist/paths/dirnames.d.ts +1 -0
  436. package/dist/paths/dirnames.js +2 -0
  437. package/dist/paths/filenames.d.ts +0 -1
  438. package/dist/paths/filenames.js +0 -2
  439. package/dist/paths/normalize.js +4 -5
  440. package/dist/paths/packages.js +4 -7
  441. package/dist/paths/predicates.js +9 -16
  442. package/dist/paths/resolve.js +17 -25
  443. package/dist/paths/rewire.d.ts +5 -0
  444. package/dist/paths/rewire.js +3 -3
  445. package/dist/paths/socket.d.ts +74 -111
  446. package/dist/paths/socket.js +106 -139
  447. package/dist/paths/walk.d.ts +1 -1
  448. package/dist/paths/walk.js +4 -4
  449. package/dist/perf/report.js +2 -2
  450. package/dist/perf/types.d.ts +1 -1
  451. package/dist/pkg-ext/data.js +1 -1
  452. package/dist/primordials/array.js +9 -9
  453. package/dist/primordials/date.js +2 -2
  454. package/dist/primordials/error.js +3 -3
  455. package/dist/primordials/headers.d.ts +10 -0
  456. package/dist/primordials/headers.js +23 -0
  457. package/dist/primordials/intl.d.ts +13 -0
  458. package/dist/primordials/intl.js +26 -0
  459. package/dist/primordials/math.js +33 -33
  460. package/dist/primordials/number.js +9 -9
  461. package/dist/primordials/object.js +5 -5
  462. package/dist/primordials/process.d.ts +88 -0
  463. package/dist/primordials/process.js +132 -0
  464. package/dist/primordials/string.d.ts +2 -2
  465. package/dist/primordials/string.js +6 -6
  466. package/dist/primordials/symbol.js +3 -3
  467. package/dist/primordials/uncurry.d.ts +1 -2
  468. package/dist/primordials/uncurry.js +9 -9
  469. package/dist/process/abort.js +3 -3
  470. package/dist/process/lock-manager.js +8 -8
  471. package/dist/process/spawn/_internal.js +6 -8
  472. package/dist/process/spawn/child.js +20 -14
  473. package/dist/process/spawn/errors.js +3 -5
  474. package/dist/process/spawn/kill-tree.d.ts +53 -0
  475. package/dist/process/spawn/kill-tree.js +85 -0
  476. package/dist/process/spawn/stdio.js +0 -1
  477. package/dist/process/spawn/types.d.ts +5 -5
  478. package/dist/process/transient.js +2 -2
  479. package/dist/promises/_internal.d.ts +2 -1
  480. package/dist/promises/_internal.js +2 -6
  481. package/dist/promises/iterate.js +11 -15
  482. package/dist/promises/options.js +3 -6
  483. package/dist/promises/retry.js +4 -5
  484. package/dist/promises/timers.d.ts +30 -0
  485. package/dist/promises/timers.js +48 -0
  486. package/dist/regexps/spec.js +1 -1
  487. package/dist/releases/github-archives.d.ts +6 -6
  488. package/dist/releases/github-archives.js +3 -3
  489. package/dist/releases/github-asset-url.d.ts +1 -1
  490. package/dist/releases/github-asset-url.js +5 -5
  491. package/dist/releases/github-downloads.d.ts +1 -1
  492. package/dist/releases/github-downloads.js +3 -3
  493. package/dist/releases/github-listing.d.ts +12 -4
  494. package/dist/releases/github-listing.js +20 -7
  495. package/dist/releases/github-retry-config.js +1 -1
  496. package/dist/releases/github-types.d.ts +6 -6
  497. package/dist/releases/socket-btm-binary-naming.d.ts +107 -0
  498. package/dist/releases/socket-btm-binary-naming.js +155 -0
  499. package/dist/releases/socket-btm.d.ts +8 -115
  500. package/dist/releases/socket-btm.js +16 -159
  501. package/dist/schema/types.d.ts +4 -5
  502. package/dist/schema/validate.js +1 -1
  503. package/dist/sea/detect.js +6 -6
  504. package/dist/secrets/_internal.d.ts +2 -2
  505. package/dist/secrets/_internal.js +2 -2
  506. package/dist/secrets/compare.d.ts +45 -0
  507. package/dist/secrets/compare.js +61 -0
  508. package/dist/secrets/find.d.ts +2 -2
  509. package/dist/secrets/find.js +10 -4
  510. package/dist/secrets/keychain.d.ts +1 -1
  511. package/dist/secrets/keychain.js +6 -4
  512. package/dist/secrets/linux.js +40 -52
  513. package/dist/secrets/macos.d.ts +2 -3
  514. package/dist/secrets/macos.js +24 -33
  515. package/dist/secrets/rc.d.ts +4 -4
  516. package/dist/secrets/rc.js +27 -17
  517. package/dist/secrets/socket-api-token.d.ts +4 -4
  518. package/dist/secrets/socket-api-token.js +26 -9
  519. package/dist/secrets/windows.js +32 -37
  520. package/dist/shadow/skip.js +2 -2
  521. package/dist/shell/parse.d.ts +32 -0
  522. package/dist/shell/parse.js +60 -0
  523. package/dist/smol/detect.js +9 -10
  524. package/dist/smol/http.js +6 -7
  525. package/dist/smol/https.js +6 -7
  526. package/dist/smol/manifest.d.ts +1 -1
  527. package/dist/smol/manifest.js +6 -7
  528. package/dist/smol/path.d.ts +1 -1
  529. package/dist/smol/path.js +7 -8
  530. package/dist/smol/primordial.d.ts +4 -0
  531. package/dist/smol/primordial.js +6 -7
  532. package/dist/smol/purl.d.ts +1 -1
  533. package/dist/smol/purl.js +7 -8
  534. package/dist/smol/versions.js +6 -7
  535. package/dist/smol/vfs.js +6 -7
  536. package/dist/sorts/_internal.js +6 -8
  537. package/dist/sorts/natural.js +10 -12
  538. package/dist/sorts/semver.js +1 -2
  539. package/dist/sorts/strings.js +0 -1
  540. package/dist/sorts/types.d.ts +1 -1
  541. package/dist/spinner/create-spinner-class.d.ts +38 -0
  542. package/dist/spinner/create-spinner-class.js +302 -0
  543. package/dist/spinner/default.js +8 -9
  544. package/dist/spinner/spinner-internals.d.ts +36 -0
  545. package/dist/spinner/spinner-internals.js +105 -0
  546. package/dist/spinner/spinner-shimmer-methods.d.ts +54 -0
  547. package/dist/spinner/spinner-shimmer-methods.js +143 -0
  548. package/dist/spinner/spinner-status-methods.d.ts +40 -0
  549. package/dist/spinner/spinner-status-methods.js +133 -0
  550. package/dist/spinner/spinner.d.ts +8 -5
  551. package/dist/spinner/spinner.js +19 -706
  552. package/dist/spinner/types.d.ts +3 -1
  553. package/dist/spinner/with.d.ts +10 -0
  554. package/dist/spinner/with.js +16 -2
  555. package/dist/stdio/divider.js +1 -1
  556. package/dist/stdio/footer.js +3 -3
  557. package/dist/stdio/header.js +4 -4
  558. package/dist/stdio/progress.js +10 -6
  559. package/dist/stdio/prompts.d.ts +7 -5
  560. package/dist/stdio/prompts.js +7 -8
  561. package/dist/stdio/stdout.js +3 -3
  562. package/dist/streams/parallel.js +3 -5
  563. package/dist/streams/transform.js +2 -3
  564. package/dist/strings/format.js +2 -6
  565. package/dist/strings/predicates.js +0 -2
  566. package/dist/strings/search.js +1 -2
  567. package/dist/strings/transform.js +0 -3
  568. package/dist/strings/width.js +9 -10
  569. package/dist/tables/bordered.js +4 -3
  570. package/dist/tables/padding.js +1 -1
  571. package/dist/tables/simple.js +8 -5
  572. package/dist/temporal/instant.js +1 -1
  573. package/dist/temporal/slots.js +6 -6
  574. package/dist/temporal/system.js +9 -9
  575. package/dist/themes/context.d.ts +3 -2
  576. package/dist/themes/context.js +4 -5
  577. package/dist/themes/themes.js +15 -15
  578. package/dist/themes/types.d.ts +3 -3
  579. package/dist/url/assert-safe.d.ts +29 -0
  580. package/dist/url/assert-safe.js +54 -0
  581. package/dist/url/parse.js +0 -2
  582. package/dist/url/predicates.d.ts +31 -1
  583. package/dist/url/predicates.js +43 -3
  584. package/dist/url/search-params.js +3 -9
  585. package/dist/url/types.d.ts +9 -5
  586. package/dist/versions/_internal.js +3 -3
  587. package/dist/words/article.js +0 -1
  588. package/dist/words/capitalize.js +0 -1
  589. package/dist/words/pluralize.js +15 -5
  590. package/package.json +419 -216
  591. package/dist/external-tools/uv/asset-names.d.ts +0 -36
  592. package/dist/external-tools/uv/asset-names.js +0 -70
  593. package/dist/external-tools/uv/from-download.d.ts +0 -17
  594. package/dist/external-tools/uv/from-download.js +0 -47
  595. package/dist/external-tools/uv/from-path.d.ts +0 -5
  596. package/dist/external-tools/uv/from-path.js +0 -22
  597. package/dist/external-tools/uv/from-vfs.d.ts +0 -7
  598. package/dist/external-tools/uv/from-vfs.js +0 -26
  599. package/dist/external-tools/uv/resolve.d.ts +0 -25
  600. package/dist/external-tools/uv/resolve.js +0 -53
  601. package/dist/external-tools/uv/types.d.ts +0 -24
  602. package/dist/fs/path-cache.d.ts +0 -21
  603. package/dist/fs/path-cache.js +0 -34
  604. package/dist/http-request/checksums.d.ts +0 -69
  605. package/dist/http-request/checksums.js +0 -108
  606. package/dist/http-request/http-request.d.ts +0 -12
  607. package/dist/http-request/http-request.js +0 -11
  608. package/dist/packages/operations.d.ts +0 -113
  609. package/dist/packages/operations.js +0 -304
  610. package/dist/ssri/convert.d.ts +0 -48
  611. package/dist/ssri/convert.js +0 -69
  612. package/dist/ssri/parse.d.ts +0 -27
  613. package/dist/ssri/parse.js +0 -41
  614. package/dist/ssri/validate.d.ts +0 -41
  615. package/dist/ssri/validate.js +0 -56
  616. /package/dist/{bin → cli}/check.d.ts +0 -0
  617. /package/dist/external-tools/{uv → python}/types.js +0 -0
  618. /package/dist/fs/{find-up.d.ts → find.d.ts} +0 -0
  619. /package/dist/github/{fetch.d.ts → request.d.ts} +0 -0
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with rolldown */
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../../_virtual/_rolldown/runtime.js');
5
+ const require_paths_socket = require('../../paths/socket.js');
6
+ const require_external_tools_from_download = require('../from-download.js');
7
+ const require_external_tools_python_asset_names = require('./asset-names.js');
8
+ let node_process = require("node:process");
9
+ node_process = require_runtime.__toESM(node_process);
10
+ let node_path = require("node:path");
11
+ node_path = require_runtime.__toESM(node_path);
12
+
13
+ //#region src/external-tools/python/from-download.ts
14
+ /**
15
+ * @file `pythonFromDownload()` — fetches a python-build-standalone CPython into
16
+ * the DLX cache and returns a `ResolvedPython` pointing at the interpreter.
17
+ * The `install_only` tarball extracts to a `python/` subdirectory, so the
18
+ * interpreter lands at `<extractedDir>/python/bin/python3` (or
19
+ * `python/python.exe` on Windows) — no strip.
20
+ */
21
+ /**
22
+ * Return the absolute path to the interpreter inside an extracted
23
+ * python-build-standalone tree. The layout follows the TARGET arch, not the
24
+ * host: a Windows target nests the interpreter at `python/python.exe`, every
25
+ * other target at `python/bin/python3`. Keying off `process.platform` would be
26
+ * wrong when cross-resolving (e.g. a Windows host downloading a linux-x64
27
+ * build). `arch` is a platform-arch key like `win-x64` / `linux-x64`; omit it
28
+ * to fall back to the host platform.
29
+ */
30
+ function pythonBinPath(extractedDir, arch) {
31
+ if (arch ? arch.startsWith("win-") : node_process.default.platform === "win32") return node_path.default.join(extractedDir, "python", "python.exe");
32
+ return node_path.default.join(extractedDir, "python", "bin", "python3");
33
+ }
34
+ /**
35
+ * Default DLX cache directory for a python build pin.
36
+ */
37
+ function pythonCacheDir(version, tag, arch) {
38
+ return node_path.default.join(require_paths_socket.getSocketDlxDir(), "python", `${version}-${tag}-${arch}`);
39
+ }
40
+ async function pythonFromDownload(options) {
41
+ options = {
42
+ __proto__: null,
43
+ ...options
44
+ };
45
+ const { cacheDir, downloader, integrity, tag, version } = {
46
+ __proto__: null,
47
+ ...options
48
+ };
49
+ const arch = options.arch ?? require_external_tools_python_asset_names.getPythonArch();
50
+ if (!arch) return;
51
+ const asset = require_external_tools_python_asset_names.pythonAsset({
52
+ version,
53
+ tag,
54
+ arch
55
+ });
56
+ if (!asset) return;
57
+ const extractedDir = cacheDir ?? pythonCacheDir(version, tag, arch);
58
+ const archive = await require_external_tools_from_download.downloadAndExtractTool({
59
+ url: asset.url,
60
+ name: `python-${version}-${tag}-${arch}.tar.gz`,
61
+ integrity,
62
+ extractedDir,
63
+ downloader
64
+ });
65
+ return {
66
+ path: pythonBinPath(extractedDir, arch),
67
+ source: "download",
68
+ integrity: archive.integrity
69
+ };
70
+ }
71
+
72
+ //#endregion
73
+ exports.pythonBinPath = pythonBinPath;
74
+ exports.pythonCacheDir = pythonCacheDir;
75
+ exports.pythonFromDownload = pythonFromDownload;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @file `pythonFromPath()` — looks for a CPython interpreter on the system
3
+ * PATH. Tries `python3` first (the POSIX convention), then `python` (the
4
+ * Windows convention / some minimal images). Returns the first hit.
5
+ */
6
+ import type { ResolvedPython } from './types';
7
+ export declare function pythonFromPath(): Promise<ResolvedPython | undefined>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with rolldown */
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_bin_which = require('../../bin/which.js');
5
+
6
+ //#region src/external-tools/python/from-path.ts
7
+ /**
8
+ * @file `pythonFromPath()` — looks for a CPython interpreter on the system
9
+ * PATH. Tries `python3` first (the POSIX convention), then `python` (the
10
+ * Windows convention / some minimal images). Returns the first hit.
11
+ */
12
+ async function pythonFromPath() {
13
+ for (const bin of ["python3", "python"]) {
14
+ const onPath = await require_bin_which.which(bin, { nothrow: true });
15
+ if (typeof onPath === "string") return {
16
+ path: onPath,
17
+ source: "path"
18
+ };
19
+ }
20
+ }
21
+
22
+ //#endregion
23
+ exports.pythonFromPath = pythonFromPath;
@@ -0,0 +1,121 @@
1
+ /**
2
+ * @file `resolvePipPackagePin()` — the Python mirror of
3
+ * `resolveNpmPackagePin()` (dlx/lockfile). Resolves a pip spec and its full
4
+ * dependency closure WITHOUT installing into the interpreter, then returns
5
+ * everything needed to pin a reproducible, hash-verified install:
6
+ *
7
+ * - the resolved top-level name + version,
8
+ * - the top-level artifact's hashes (sha512 SRI + sha256 hex), and
9
+ * - a fully-hashed `requirements.txt` body (`name==version --hash=sha256:<hex>`
10
+ * for every artifact in the closure) ready to feed back to
11
+ * `downloadPipPackage` / `pip install --require-hashes`. Engine: `pip
12
+ * download --dest <scratch> <spec>` downloads the spec + its resolved
13
+ * closure as wheels/sdists into a scratch dir (no install, no venv), each
14
+ * file is hashed, then the scratch dir is torn down. This is pip's own
15
+ * recipe for producing hashed requirements — `pip-tools` is NOT required.
16
+ * Contrast `resolveNpmPackagePin` (dlx/lockfile): same contract, npm engine
17
+ * (Arborist lockfile-only + pacote), emits a `package-lock.json`. The pip
18
+ * side emits a hashed `requirements.txt` because that — not a lockfile — is
19
+ * what `pip install --require-hashes` consumes. NOTE on the soak window:
20
+ * `resolveNpmPackagePin` applies a min-release-age cutoff via Arborist's
21
+ * `before` date. pip has no native release-age gate, so this generator does
22
+ * NOT enforce one — callers that need a soak must vet the resolved versions
23
+ * out of band. The spec itself remains the primary pin: `==<version>` (PyPI
24
+ * is immutable per version) or `@<full-sha>` (git is content-addressed).
25
+ */
26
+ import type { ComputedHashes } from '../../integrity';
27
+ export interface ResolvePipPackagePinOptions {
28
+ /**
29
+ * Absolute path to the Python interpreter used to run `pip download`,
30
+ * typically from `resolvePython()`. The interpreter is NOT modified.
31
+ */
32
+ readonly pythonBin: string;
33
+ /**
34
+ * Directory `pip download` resolves the closure into. Defaults to a unique
35
+ * scratch dir under the OS temp dir, removed before returning.
36
+ */
37
+ readonly scratchDir?: string | undefined;
38
+ /**
39
+ * Pip spec to pin: `<pkg>==<version>` (PyPI exact pin) or
40
+ * `git+https://<url>@<sha>` (git-SHA pin).
41
+ */
42
+ readonly spec: string;
43
+ }
44
+ export interface PipArtifactPin {
45
+ /**
46
+ * Sha256 hex of the artifact, the `--hash=sha256:<hex>` value pip expects.
47
+ */
48
+ readonly checksum: string;
49
+ /**
50
+ * Downloaded artifact filename, e.g. `is_odd-3.0.1-py3-none-any.whl`.
51
+ */
52
+ readonly file: string;
53
+ /**
54
+ * Distribution name parsed from the filename, e.g. `is-odd`.
55
+ */
56
+ readonly name: string;
57
+ /**
58
+ * Distribution version parsed from the filename, e.g. `3.0.1`.
59
+ */
60
+ readonly version: string;
61
+ }
62
+ export interface PipPackagePin {
63
+ /**
64
+ * Per-artifact pins for the full resolved closure (top-level + transitive).
65
+ */
66
+ readonly artifacts: readonly PipArtifactPin[];
67
+ /**
68
+ * Hashes of the top-level artifact (sha512 SRI + sha256 hex). The Python
69
+ * analog of `NpmPackagePin.hash`.
70
+ */
71
+ readonly hash: ComputedHashes;
72
+ /**
73
+ * Resolved top-level distribution name.
74
+ */
75
+ readonly name: string;
76
+ /**
77
+ * Fully-hashed `requirements.txt` content, ready to write to disk and feed to
78
+ * `pip install --require-hashes -r <file>`. The Python analog of
79
+ * `NpmPackagePin.lockfile`.
80
+ */
81
+ readonly requirements: string;
82
+ /**
83
+ * Resolved top-level distribution version.
84
+ */
85
+ readonly version: string;
86
+ }
87
+ /**
88
+ * Thrown when `pip download` produces no artifacts or a filename can't be
89
+ * parsed into a name + version.
90
+ */
91
+ export declare class PipPackagePinError extends Error {
92
+ constructor(message: string, options?: {
93
+ cause?: unknown | undefined;
94
+ } | undefined);
95
+ }
96
+ /**
97
+ * Normalize a PEP 503 distribution name: lowercase, runs of `_ . -` collapse to
98
+ * a single `-`. Wheel filenames use `_`; requirements/PyPI use `-`.
99
+ */
100
+ export declare function normalizeDistName(name: string): string;
101
+ /**
102
+ * Parse `<name>-<version>` out of a wheel (`name-ver-...whl`) or sdist
103
+ * (`name-ver.tar.gz` / `name-ver.zip`) filename. Returns undefined when the
104
+ * shape isn't recognized.
105
+ */
106
+ export declare function parseArtifactFilename(file: string): {
107
+ name: string;
108
+ version: string;
109
+ } | undefined;
110
+ /**
111
+ * Generate a vendorable, hash-pinned closure for a pip spec without installing
112
+ * it. Mirrors `resolveNpmPackagePin`. Throws `PipPackagePinError` on an empty
113
+ * download or an unparseable artifact filename.
114
+ */
115
+ export declare function resolvePipPackagePin(options: ResolvePipPackagePinOptions): Promise<PipPackagePin>;
116
+ /**
117
+ * Best-effort distribution name from a pip spec for matching the top-level
118
+ * artifact: strips a `==`/`>=`/etc. version and a `git+...#egg=<name>`
119
+ * fragment. Falls back to the raw spec when neither is present.
120
+ */
121
+ export declare function specDistName(spec: string): string;
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with rolldown */
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../../_virtual/_rolldown/runtime.js');
5
+ const require_integrity = require('../../integrity.js');
6
+ const require_constants_platform = require('../../constants/platform.js');
7
+ const require_process_spawn_child = require('../../process/spawn/child.js');
8
+ const require_fs_safe = require('../../fs/safe.js');
9
+ let node_fs = require("node:fs");
10
+ let node_process = require("node:process");
11
+ node_process = require_runtime.__toESM(node_process);
12
+ let node_path = require("node:path");
13
+ node_path = require_runtime.__toESM(node_path);
14
+ let node_os = require("node:os");
15
+ node_os = require_runtime.__toESM(node_os);
16
+
17
+ //#region src/external-tools/python/pin.ts
18
+ /**
19
+ * @file `resolvePipPackagePin()` — the Python mirror of
20
+ * `resolveNpmPackagePin()` (dlx/lockfile). Resolves a pip spec and its full
21
+ * dependency closure WITHOUT installing into the interpreter, then returns
22
+ * everything needed to pin a reproducible, hash-verified install:
23
+ *
24
+ * - the resolved top-level name + version,
25
+ * - the top-level artifact's hashes (sha512 SRI + sha256 hex), and
26
+ * - a fully-hashed `requirements.txt` body (`name==version --hash=sha256:<hex>`
27
+ * for every artifact in the closure) ready to feed back to
28
+ * `downloadPipPackage` / `pip install --require-hashes`. Engine: `pip
29
+ * download --dest <scratch> <spec>` downloads the spec + its resolved
30
+ * closure as wheels/sdists into a scratch dir (no install, no venv), each
31
+ * file is hashed, then the scratch dir is torn down. This is pip's own
32
+ * recipe for producing hashed requirements — `pip-tools` is NOT required.
33
+ * Contrast `resolveNpmPackagePin` (dlx/lockfile): same contract, npm engine
34
+ * (Arborist lockfile-only + pacote), emits a `package-lock.json`. The pip
35
+ * side emits a hashed `requirements.txt` because that — not a lockfile — is
36
+ * what `pip install --require-hashes` consumes. NOTE on the soak window:
37
+ * `resolveNpmPackagePin` applies a min-release-age cutoff via Arborist's
38
+ * `before` date. pip has no native release-age gate, so this generator does
39
+ * NOT enforce one — callers that need a soak must vet the resolved versions
40
+ * out of band. The spec itself remains the primary pin: `==<version>` (PyPI
41
+ * is immutable per version) or `@<full-sha>` (git is content-addressed).
42
+ */
43
+ /**
44
+ * Thrown when `pip download` produces no artifacts or a filename can't be
45
+ * parsed into a name + version.
46
+ */
47
+ var PipPackagePinError = class extends Error {
48
+ constructor(message, options) {
49
+ super(message, options);
50
+ this.name = "PipPackagePinError";
51
+ }
52
+ };
53
+ /**
54
+ * Normalize a PEP 503 distribution name: lowercase, runs of `_ . -` collapse to
55
+ * a single `-`. Wheel filenames use `_`; requirements/PyPI use `-`.
56
+ */
57
+ function normalizeDistName(name) {
58
+ return name.toLowerCase().replace(/[-_.]+/g, "-");
59
+ }
60
+ /**
61
+ * Parse `<name>-<version>` out of a wheel (`name-ver-...whl`) or sdist
62
+ * (`name-ver.tar.gz` / `name-ver.zip`) filename. Returns undefined when the
63
+ * shape isn't recognized.
64
+ */
65
+ function parseArtifactFilename(file) {
66
+ if (file.endsWith(".whl")) {
67
+ const parts = file.slice(0, -4).split("-");
68
+ if (parts.length < 2) return;
69
+ return {
70
+ name: normalizeDistName(parts[0]),
71
+ version: parts[1]
72
+ };
73
+ }
74
+ const ext = [
75
+ ".tar.gz",
76
+ ".tar.bz2",
77
+ ".zip",
78
+ ".tgz"
79
+ ].find((e) => file.endsWith(e));
80
+ if (!ext) return;
81
+ const stem = file.slice(0, -ext.length);
82
+ const dashIdx = stem.lastIndexOf("-");
83
+ if (dashIdx <= 0) return;
84
+ return {
85
+ name: normalizeDistName(stem.slice(0, dashIdx)),
86
+ version: stem.slice(dashIdx + 1)
87
+ };
88
+ }
89
+ /**
90
+ * Generate a vendorable, hash-pinned closure for a pip spec without installing
91
+ * it. Mirrors `resolveNpmPackagePin`. Throws `PipPackagePinError` on an empty
92
+ * download or an unparseable artifact filename.
93
+ */
94
+ async function resolvePipPackagePin(options) {
95
+ const { pythonBin, spec } = {
96
+ __proto__: null,
97
+ ...options
98
+ };
99
+ if (typeof spec !== "string" || spec.length === 0) throw new PipPackagePinError("resolvePipPackagePin requires a package spec");
100
+ const scratch = options.scratchDir ?? node_path.default.join(node_os.default.tmpdir(), `socket-lib-pip-pin-${node_process.default.pid}-${Date.now()}`);
101
+ await require_fs_safe.safeMkdir(scratch, { recursive: true });
102
+ try {
103
+ await require_process_spawn_child.spawn(pythonBin, [
104
+ "-m",
105
+ "pip",
106
+ "download",
107
+ "--no-input",
108
+ "--quiet",
109
+ "--dest",
110
+ scratch,
111
+ spec
112
+ ], {
113
+ shell: require_constants_platform.WIN32,
114
+ stdio: "inherit"
115
+ });
116
+ const files = (await node_fs.promises.readdir(scratch)).filter((f) => f.endsWith(".whl") || f.endsWith(".tar.gz") || f.endsWith(".tar.bz2") || f.endsWith(".zip") || f.endsWith(".tgz"));
117
+ if (!files.length) throw new PipPackagePinError(`resolvePipPackagePin: pip download ${spec} produced no artifacts in ${scratch}`);
118
+ const artifacts = [];
119
+ const targetName = normalizeDistName(specDistName(spec));
120
+ let top;
121
+ for (const file of files.toSorted()) {
122
+ const hash = require_integrity.computeHashes(await node_fs.promises.readFile(node_path.default.join(scratch, file)));
123
+ const parsed = parseArtifactFilename(file);
124
+ if (!parsed) throw new PipPackagePinError(`resolvePipPackagePin: could not parse name/version from artifact ${file}`);
125
+ artifacts.push({
126
+ checksum: hash.checksum,
127
+ file,
128
+ name: parsed.name,
129
+ version: parsed.version
130
+ });
131
+ if (!top && parsed.name === targetName) top = {
132
+ hash,
133
+ name: parsed.name,
134
+ version: parsed.version
135
+ };
136
+ }
137
+ if (!top) {
138
+ const first = artifacts[0];
139
+ top = {
140
+ hash: require_integrity.computeHashes(await node_fs.promises.readFile(node_path.default.join(scratch, first.file))),
141
+ name: first.name,
142
+ version: first.version
143
+ };
144
+ }
145
+ const requirements = artifacts.map((a) => `${a.name}==${a.version} --hash=sha256:${a.checksum}`).join("\n") + "\n";
146
+ return {
147
+ artifacts,
148
+ hash: top.hash,
149
+ name: top.name,
150
+ requirements,
151
+ version: top.version
152
+ };
153
+ } finally {
154
+ try {
155
+ await require_fs_safe.safeDelete(scratch, { force: true });
156
+ } catch {}
157
+ }
158
+ }
159
+ /**
160
+ * Best-effort distribution name from a pip spec for matching the top-level
161
+ * artifact: strips a `==`/`>=`/etc. version and a `git+...#egg=<name>`
162
+ * fragment. Falls back to the raw spec when neither is present.
163
+ */
164
+ function specDistName(spec) {
165
+ const eggIdx = spec.indexOf("#egg=");
166
+ if (eggIdx !== -1) return spec.slice(eggIdx + 5);
167
+ const match = /^([A-Za-z0-9._-]+)\s*(?:@|[=<>!~]=?)/.exec(spec);
168
+ return match ? match[1] : spec;
169
+ }
170
+
171
+ //#endregion
172
+ exports.PipPackagePinError = PipPackagePinError;
173
+ exports.normalizeDistName = normalizeDistName;
174
+ exports.parseArtifactFilename = parseArtifactFilename;
175
+ exports.resolvePipPackagePin = resolvePipPackagePin;
176
+ exports.specDistName = specDistName;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * @file `downloadPipPackage()` — the Python mirror of `dlx/package.ts`'s
3
+ * `downloadNpmPackage()`. Installs a pip spec into a content-addressed dlx
4
+ * directory (`pip install --target <dir>`), leaving the interpreter pristine:
5
+ * the package + its deps land in
6
+ * `~/.socket/_dlx/<cacheKey(spec)>/site-packages`, the exact analog of how
7
+ * `downloadNpmPackage` installs npm deps into
8
+ * `<dlxDir>/<hash>/node_modules/`. This is the bundle-safe / SEA-VFS-safe
9
+ * model:
10
+ *
11
+ * - No venv → no symlinks, no `pyvenv.cfg` with an absolute `home=`.
12
+ * - The target dir is plain files → embeddable in a SEA's VFS, relocatable at
13
+ * runtime.
14
+ * - One shared Python serves N isolated package dirs (true per-tool isolation
15
+ * without a venv) — exactly the `node_modules`-per-cacheKey shape. Run the
16
+ * installed tool with the package dir on `PYTHONPATH`: spawn(pythonBin,
17
+ * ['-m', '<module>', ...args], { env: { ...process.env, PYTHONPATH:
18
+ * packageDir } }) `spec` is a PyPI pin (`<pkg>==<version>`) or a git-SHA
19
+ * pin (`git+https://…@<sha>`). A TOCTOU lock guards concurrent installs; an
20
+ * existing non-empty package dir makes the call idempotent. Contrast
21
+ * `createPipVenv` (external-tools/from-pip-venv): venv with a
22
+ * `bin/<entryPoint>` — convenient but symlink + absolute-`home`-dependent,
23
+ * so DLX-only and NOT bundleable.
24
+ */
25
+ /**
26
+ * Install `spec` into a content-addressed dlx dir via `pip install --target`.
27
+ * Lock-guarded + idempotent. Throws on a failed pip install or if the lock
28
+ * can't be acquired after MAX_RETRIES. Mirrors `downloadNpmPackage`.
29
+ */
30
+ export declare function downloadPipPackage(options: DownloadPipPackageOptions, retryCount?: number): Promise<DownloadPipPackageResult>;
31
+ export declare function isAlreadyInstalled(packageDir: string): Promise<boolean>;
32
+ export declare function isStaleLock(pid: number): boolean;
33
+ export interface DownloadPipPackageOptions {
34
+ /**
35
+ * Optional sha256 hash (`sha256:<hex>` or bare `<hex>`) of the top-level
36
+ * artifact, the Python analog of `downloadNpmPackage`'s `hash`. When set, pip
37
+ * runs with `--require-hashes` and `--hash=sha256:<hex>`, which fails closed
38
+ * unless EVERY resolved artifact (the spec and its full dependency closure)
39
+ * carries a matching hash — so it only fits specs pip can hash-verify (a
40
+ * pinned `==<version>` or a direct wheel/sdist URL) with a hash-pinned
41
+ * closure. Omit it and rely on the immutable spec as the pin: `==<version>`
42
+ * (PyPI is immutable per version) or `@<full-sha>` (git is
43
+ * content-addressed).
44
+ */
45
+ readonly hash?: string | undefined;
46
+ /**
47
+ * Absolute path to the Python interpreter used to run pip (and later the
48
+ * tool). The interpreter is NOT modified — packages go to the dlx package
49
+ * dir. Typically from `resolvePython()`.
50
+ */
51
+ readonly pythonBin: string;
52
+ /**
53
+ * Pip install spec: `<pkg>==<version>` (PyPI exact pin) or
54
+ * `git+https://<url>@<sha>` (git-SHA pin).
55
+ */
56
+ readonly spec: string;
57
+ }
58
+ export interface DownloadPipPackageResult {
59
+ /**
60
+ * `true` when this call ran pip; `false` when an existing install was reused.
61
+ */
62
+ readonly installed: boolean;
63
+ /**
64
+ * Directory the package was installed into. Put this on `PYTHONPATH` to run
65
+ * the tool: `python -m <module>`. The Python analog of
66
+ * `DownloadNpmPackageResult.packageDir`.
67
+ */
68
+ readonly packageDir: string;
69
+ }
70
+ /**
71
+ * Content-addressed install dir for a spec:
72
+ * `~/.socket/_dlx/<cacheKey>/site-packages`. The Python analog of
73
+ * `downloadNpmPackage`'s `<hash>/node_modules`.
74
+ */
75
+ export declare function pipPackageDir(spec: string): string;
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with rolldown */
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../../_virtual/_rolldown/runtime.js');
5
+ const require_constants_platform = require('../../constants/platform.js');
6
+ const require_process_spawn_child = require('../../process/spawn/child.js');
7
+ const require_paths_socket = require('../../paths/socket.js');
8
+ const require_fs_safe = require('../../fs/safe.js');
9
+ const require_dlx_cache = require('../../dlx/cache.js');
10
+ let node_fs = require("node:fs");
11
+ let node_process = require("node:process");
12
+ node_process = require_runtime.__toESM(node_process);
13
+ let node_path = require("node:path");
14
+ node_path = require_runtime.__toESM(node_path);
15
+
16
+ //#region src/external-tools/python/pip-install.ts
17
+ /**
18
+ * @file `downloadPipPackage()` — the Python mirror of `dlx/package.ts`'s
19
+ * `downloadNpmPackage()`. Installs a pip spec into a content-addressed dlx
20
+ * directory (`pip install --target <dir>`), leaving the interpreter pristine:
21
+ * the package + its deps land in
22
+ * `~/.socket/_dlx/<cacheKey(spec)>/site-packages`, the exact analog of how
23
+ * `downloadNpmPackage` installs npm deps into
24
+ * `<dlxDir>/<hash>/node_modules/`. This is the bundle-safe / SEA-VFS-safe
25
+ * model:
26
+ *
27
+ * - No venv → no symlinks, no `pyvenv.cfg` with an absolute `home=`.
28
+ * - The target dir is plain files → embeddable in a SEA's VFS, relocatable at
29
+ * runtime.
30
+ * - One shared Python serves N isolated package dirs (true per-tool isolation
31
+ * without a venv) — exactly the `node_modules`-per-cacheKey shape. Run the
32
+ * installed tool with the package dir on `PYTHONPATH`: spawn(pythonBin,
33
+ * ['-m', '<module>', ...args], { env: { ...process.env, PYTHONPATH:
34
+ * packageDir } }) `spec` is a PyPI pin (`<pkg>==<version>`) or a git-SHA
35
+ * pin (`git+https://…@<sha>`). A TOCTOU lock guards concurrent installs; an
36
+ * existing non-empty package dir makes the call idempotent. Contrast
37
+ * `createPipVenv` (external-tools/from-pip-venv): venv with a
38
+ * `bin/<entryPoint>` — convenient but symlink + absolute-`home`-dependent,
39
+ * so DLX-only and NOT bundleable.
40
+ */
41
+ const MAX_RETRIES = 3;
42
+ const WAIT_TICKS = 30;
43
+ /**
44
+ * Install `spec` into a content-addressed dlx dir via `pip install --target`.
45
+ * Lock-guarded + idempotent. Throws on a failed pip install or if the lock
46
+ * can't be acquired after MAX_RETRIES. Mirrors `downloadNpmPackage`.
47
+ */
48
+ async function downloadPipPackage(options, retryCount = 0) {
49
+ const { hash, pythonBin, spec } = {
50
+ __proto__: null,
51
+ ...options
52
+ };
53
+ const packageDir = pipPackageDir(spec);
54
+ if (retryCount >= MAX_RETRIES) throw new Error(`downloadPipPackage: could not acquire install lock after ${MAX_RETRIES} retries for ${packageDir}; a peer may be stuck or the lock is stale — remove it and retry`);
55
+ if (await isAlreadyInstalled(packageDir)) return {
56
+ installed: false,
57
+ packageDir
58
+ };
59
+ const lockDir = node_path.default.dirname(packageDir);
60
+ await require_fs_safe.safeMkdir(lockDir, { recursive: true });
61
+ const lockFile = node_path.default.join(lockDir, ".installing");
62
+ try {
63
+ await node_fs.promises.writeFile(lockFile, node_process.default.pid.toString(), { flag: "wx" });
64
+ } catch (e) {
65
+ if (e.code !== "EEXIST") throw e;
66
+ let stale = false;
67
+ try {
68
+ stale = isStaleLock(Number.parseInt((await node_fs.promises.readFile(lockFile, "utf8")).trim(), 10));
69
+ } catch {
70
+ stale = true;
71
+ }
72
+ if (stale) {
73
+ await require_fs_safe.safeDelete(lockFile, { force: true });
74
+ return downloadPipPackage(options, retryCount + 1);
75
+ }
76
+ for (let i = 0; i < WAIT_TICKS; i += 1) {
77
+ await new Promise((resolve) => {
78
+ setTimeout(resolve, 1e3);
79
+ });
80
+ if (await isAlreadyInstalled(packageDir)) return {
81
+ installed: false,
82
+ packageDir
83
+ };
84
+ }
85
+ return downloadPipPackage(options, retryCount + 1);
86
+ }
87
+ try {
88
+ await require_fs_safe.safeMkdir(packageDir, { recursive: true });
89
+ const normalizedHash = hash ? hash.startsWith("sha256:") ? hash : `sha256:${hash}` : void 0;
90
+ await require_process_spawn_child.spawn(pythonBin, [
91
+ "-m",
92
+ "pip",
93
+ "install",
94
+ "--no-input",
95
+ "--quiet",
96
+ "--target",
97
+ packageDir,
98
+ ...normalizedHash ? ["--require-hashes", `--hash=${normalizedHash}`] : [],
99
+ spec
100
+ ], {
101
+ shell: require_constants_platform.WIN32,
102
+ stdio: "inherit"
103
+ });
104
+ if (!await isAlreadyInstalled(packageDir)) throw new Error(`downloadPipPackage: pip install --target ${packageDir} ${spec} reported success but the target is still empty`);
105
+ return {
106
+ installed: true,
107
+ packageDir
108
+ };
109
+ } finally {
110
+ await require_fs_safe.safeDelete(lockFile, { force: true });
111
+ }
112
+ }
113
+ async function isAlreadyInstalled(packageDir) {
114
+ try {
115
+ return (await node_fs.promises.readdir(packageDir)).length > 0;
116
+ } catch {
117
+ return false;
118
+ }
119
+ }
120
+ function isStaleLock(pid) {
121
+ if (Number.isNaN(pid) || pid <= 0) return true;
122
+ try {
123
+ node_process.default.kill(pid, 0);
124
+ return false;
125
+ } catch (e) {
126
+ return e.code !== "EPERM";
127
+ }
128
+ }
129
+ /**
130
+ * Content-addressed install dir for a spec:
131
+ * `~/.socket/_dlx/<cacheKey>/site-packages`. The Python analog of
132
+ * `downloadNpmPackage`'s `<hash>/node_modules`.
133
+ */
134
+ function pipPackageDir(spec) {
135
+ return node_path.default.join(require_paths_socket.getSocketDlxDir(), require_dlx_cache.generateCacheKey(spec), "site-packages");
136
+ }
137
+
138
+ //#endregion
139
+ exports.downloadPipPackage = downloadPipPackage;
140
+ exports.isAlreadyInstalled = isAlreadyInstalled;
141
+ exports.isStaleLock = isStaleLock;
142
+ exports.pipPackageDir = pipPackageDir;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @file `resolvePython()` — CPython resolution entry point. Tries each source
3
+ * in order:
4
+ *
5
+ * 1. PATH — `python3` / `python` on the system PATH.
6
+ * 2. download — python-build-standalone CPython into the DLX cache (only when
7
+ * `downloadIfMissing` is passed). Returns `undefined` if all enabled
8
+ * sources miss. Memoized per option-shape so repeated calls in one process
9
+ * don't re-probe / re-download. NOTE: unlike the JRE / removed-uv
10
+ * resolvers there is no VFS tier here — a CPython runtime is not embedded
11
+ * in the smol Node binary. Add a `from-vfs` tier here if that changes.
12
+ */
13
+ import type { BinaryDownloader } from '../from-download';
14
+ import type { HashSpec } from '../../integrity';
15
+ import type { ResolvedPython } from './types';
16
+ export interface ResolvePythonOptions {
17
+ /**
18
+ * Prefer a downloaded python-build-standalone over a PATH interpreter. Use
19
+ * when you need an exact, reproducible CPython (the host `python3` may be the
20
+ * wrong version). Default false: PATH wins when present.
21
+ */
22
+ preferDownload?: boolean | undefined;
23
+ /**
24
+ * When set, fall back to downloading python-build-standalone if no PATH
25
+ * interpreter is found (or always, with `preferDownload`).
26
+ */
27
+ downloadIfMissing?: {
28
+ version: string;
29
+ tag: string;
30
+ /**
31
+ * Omit to auto-detect the current host via {@link getPythonArch}.
32
+ */
33
+ arch?: string | undefined;
34
+ integrity?: HashSpec | undefined;
35
+ cacheDir?: string | undefined;
36
+ downloader?: BinaryDownloader | undefined;
37
+ } | undefined;
38
+ }
39
+ export declare function cacheKey(options: ResolvePythonOptions | undefined): string;
40
+ export declare function doResolvePython(options?: ResolvePythonOptions | undefined): Promise<ResolvedPython | undefined>;
41
+ export declare function resetPythonResolution(): void;
42
+ export declare function resolvePython(options?: ResolvePythonOptions | undefined): Promise<ResolvedPython | undefined>;