@socketsecurity/lib 6.0.8 → 6.0.10

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 (396) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +8 -9
  3. package/dist/abort/signal.d.ts +1 -1
  4. package/dist/abort/signal.js +1 -1
  5. package/dist/ai/agent-context.d.mts +1 -1
  6. package/dist/ai/agent-context.js +3 -2
  7. package/dist/ai/backends.d.mts +3 -3
  8. package/dist/ai/backends.js +2 -2
  9. package/dist/ai/billing-context.d.mts +74 -0
  10. package/dist/ai/billing-context.js +129 -0
  11. package/dist/ai/credentials.d.mts +39 -5
  12. package/dist/ai/credentials.js +61 -6
  13. package/dist/ai/discover.d.mts +4 -0
  14. package/dist/ai/discover.js +4 -0
  15. package/dist/ai/exec.d.mts +1 -1
  16. package/dist/ai/exec.js +1 -1
  17. package/dist/ai/http.d.mts +8 -8
  18. package/dist/ai/http.js +6 -6
  19. package/dist/ai/profiles.d.mts +9 -10
  20. package/dist/ai/profiles.js +0 -5
  21. package/dist/ai/role.d.mts +58 -0
  22. package/dist/ai/role.js +96 -0
  23. package/dist/ai/route-heuristic.d.mts +177 -0
  24. package/dist/ai/route-heuristic.js +194 -0
  25. package/dist/ai/route.d.mts +31 -17
  26. package/dist/ai/route.js +35 -19
  27. package/dist/ai/spawn.d.mts +34 -1
  28. package/dist/ai/spawn.js +115 -3
  29. package/dist/ai/subagent-status.d.mts +2 -0
  30. package/dist/ai/subagent-status.js +2 -0
  31. package/dist/ai/tier.d.mts +1 -1
  32. package/dist/ai/types.d.mts +19 -2
  33. package/dist/ai/worktree.d.mts +1 -1
  34. package/dist/ai/worktree.js +3 -2
  35. package/dist/argv/parse.d.ts +2 -0
  36. package/dist/argv/parse.js +2 -0
  37. package/dist/bin/_internal.d.ts +1 -1
  38. package/dist/bin/_internal.js +1 -1
  39. package/dist/bin/prim.cjs +19253 -13937
  40. package/dist/bin/resolve.js +1 -1
  41. package/dist/bin/shadow.js +2 -1
  42. package/dist/bin/which.d.ts +28 -3
  43. package/dist/bin/which.js +45 -3
  44. package/dist/cacache/_internal.d.ts +10 -2
  45. package/dist/cacache/_internal.js +6 -10
  46. package/dist/cache/ttl/_internal.d.ts +33 -0
  47. package/dist/cache/ttl/_internal.js +68 -0
  48. package/dist/cache/ttl/browser.d.ts +56 -0
  49. package/dist/cache/ttl/browser.js +257 -0
  50. package/dist/cache/ttl/store.js +11 -34
  51. package/dist/cache/ttl/types.d.ts +46 -3
  52. package/dist/checks/primordials-defaults.d.ts +5 -5
  53. package/dist/checks/primordials-defaults.js +5 -5
  54. package/dist/checks/primordials.d.ts +1 -1
  55. package/dist/checks/primordials.js +25 -17
  56. package/dist/cli/check-primordials.d.ts +6 -1
  57. package/dist/cli/check-primordials.js +14 -5
  58. package/dist/cli/check.js +1 -1
  59. package/dist/cli/socket-lib.d.ts +1 -1
  60. package/dist/cli/socket-lib.js +3 -3
  61. package/dist/colors/socket-palette.d.ts +1 -1
  62. package/dist/compression/brotli.d.ts +6 -2
  63. package/dist/compression/brotli.js +5 -1
  64. package/dist/compression/gzip.d.ts +6 -2
  65. package/dist/compression/gzip.js +7 -2
  66. package/dist/config/layers.d.ts +53 -0
  67. package/dist/config/layers.js +83 -0
  68. package/dist/constants/agents.d.ts +3 -0
  69. package/dist/constants/agents.js +3 -0
  70. package/dist/constants/node.d.ts +14 -0
  71. package/dist/constants/node.js +14 -0
  72. package/dist/constants/package-default-node-range.js +1 -5
  73. package/dist/constants/packages.d.ts +5 -0
  74. package/dist/constants/packages.js +5 -0
  75. package/dist/constants/platform.d.ts +1 -1
  76. package/dist/constants/platform.js +1 -1
  77. package/dist/constants/socket.js +1 -1
  78. package/dist/constants/typescript.d.ts +5 -0
  79. package/dist/constants/typescript.js +5 -0
  80. package/dist/debug/_internal.d.ts +22 -7
  81. package/dist/debug/_internal.js +33 -15
  82. package/dist/debug/caller-info.js +1 -1
  83. package/dist/debug/namespace.js +11 -8
  84. package/dist/debug/output.d.ts +12 -1
  85. package/dist/debug/output.js +33 -16
  86. package/dist/dlx/binary-cache.js +1 -1
  87. package/dist/dlx/binary-resolution.js +8 -5
  88. package/dist/dlx/firewall.js +1 -1
  89. package/dist/dlx/lockfile.js +1 -1
  90. package/dist/eco/npm/npm/parse-lockfile.js +3 -2
  91. package/dist/eco/npm/vlt/exec.d.ts +1 -1
  92. package/dist/eco/npm/vlt/exec.js +1 -1
  93. package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +1 -1
  94. package/dist/env/agents.d.ts +6 -0
  95. package/dist/env/agents.js +29 -0
  96. package/dist/env/flags.d.ts +12 -0
  97. package/dist/env/flags.js +23 -0
  98. package/dist/env/github-status.js +2 -2
  99. package/dist/env/providers.d.ts +6 -0
  100. package/dist/env/providers.js +23 -0
  101. package/dist/env/proxy.js +1 -1
  102. package/dist/env/rewire.d.ts +37 -3
  103. package/dist/env/rewire.js +60 -29
  104. package/dist/env/runtimes.d.ts +9 -0
  105. package/dist/env/runtimes.js +53 -0
  106. package/dist/env/socket-cli.d.ts +5 -2
  107. package/dist/env/socket-cli.js +6 -3
  108. package/dist/env/xdg.d.ts +17 -0
  109. package/dist/env/xdg.js +21 -1
  110. package/dist/errors/predicates.d.ts +3 -2
  111. package/dist/errors/predicates.js +5 -3
  112. package/dist/events/exit/_internal.d.ts +1 -23
  113. package/dist/external/@npmcli/package-json.js +3570 -4905
  114. package/dist/external/@npmcli/promise-spawn.js +2 -2
  115. package/dist/external/@sinclair/typebox/value.js +5 -4
  116. package/dist/external/@socketregistry/yocto-spinner.js +3 -3
  117. package/dist/external/@yarnpkg/extensions.js +1 -1
  118. package/dist/external/adm-zip.d.ts +82 -0
  119. package/dist/external/adm-zip.js +2 -2
  120. package/dist/external/cacache.d.ts +87 -0
  121. package/dist/external/debug.d.ts +22 -0
  122. package/dist/external/debug.js +11 -4
  123. package/dist/external/del.d.ts +1 -0
  124. package/dist/external/external-pack.d.ts +12 -0
  125. package/dist/external/external-pack.js +42 -35
  126. package/dist/external/fast-glob.d.ts +8 -0
  127. package/dist/external/fast-sort.d.ts +1 -0
  128. package/dist/external/get-east-asian-width.d.ts +5 -0
  129. package/dist/external/get-east-asian-width.js +8 -1
  130. package/dist/external/has-flag.d.ts +1 -0
  131. package/dist/external/inquirer-pack.d.ts +18 -0
  132. package/dist/external/libnpmexec.d.ts +35 -0
  133. package/dist/external/libnpmpack.d.ts +1 -0
  134. package/dist/external/make-fetch-happen.d.ts +13 -0
  135. package/dist/external/normalize-package-data.d.ts +4 -0
  136. package/dist/external/npm-core.d.ts +14 -0
  137. package/dist/external/npm-pack.d.ts +24 -0
  138. package/dist/external/npm-pack.js +28934 -31885
  139. package/dist/external/npm-package-arg.d.ts +4 -0
  140. package/dist/external/p-map.js +8 -1
  141. package/dist/external/pacote.d.ts +15 -0
  142. package/dist/external/pico-pack.d.ts +16 -0
  143. package/dist/external/pico-pack.js +38 -23
  144. package/dist/external/picomatch.d.ts +96 -0
  145. package/dist/external/pony-cause.d.ts +14 -0
  146. package/dist/external/semver.d.ts +60 -0
  147. package/dist/external/semver.js +1459 -4
  148. package/dist/external/shell-quote.d.ts +51 -0
  149. package/dist/external/shell-quote.js +55 -15
  150. package/dist/external/signal-exit.d.ts +1 -0
  151. package/dist/external/spdx-correct.d.ts +4 -0
  152. package/dist/external/spdx-expression-parse.d.ts +4 -0
  153. package/dist/external/spdx-pack.d.ts +10 -0
  154. package/dist/external/std-env.d.ts +284 -0
  155. package/dist/external/std-env.js +323 -0
  156. package/dist/external/streaming-iterables.d.ts +11 -0
  157. package/dist/external/supports-color.d.ts +1 -0
  158. package/dist/external/tar-fs.d.ts +31 -0
  159. package/dist/external/tar-fs.js +63 -16
  160. package/dist/external/validate-npm-package-name.d.ts +4 -0
  161. package/dist/external/which.d.ts +25 -0
  162. package/dist/external/which.js +2 -2
  163. package/dist/external/yargs-parser.d.ts +2 -0
  164. package/dist/external/yargs-parser.js +11 -3
  165. package/dist/external/yoctocolors-cjs.d.ts +51 -0
  166. package/dist/external-tools/bazel/asset-names.d.ts +1 -1
  167. package/dist/external-tools/bazel/from-download.d.ts +1 -1
  168. package/dist/external-tools/bazel/resolve.d.ts +3 -0
  169. package/dist/external-tools/bazel/resolve.js +3 -0
  170. package/dist/external-tools/cdxgen/asset-names.d.ts +5 -5
  171. package/dist/external-tools/cdxgen/asset-names.js +3 -3
  172. package/dist/external-tools/cdxgen/from-download.d.ts +2 -2
  173. package/dist/external-tools/cdxgen/from-download.js +1 -1
  174. package/dist/external-tools/cdxgen/resolve.d.ts +4 -1
  175. package/dist/external-tools/cdxgen/resolve.js +4 -1
  176. package/dist/external-tools/cdxgen/types.d.ts +1 -1
  177. package/dist/external-tools/from-download.d.ts +2 -2
  178. package/dist/external-tools/from-download.js +1 -1
  179. package/dist/external-tools/janus/asset-names.d.ts +4 -1
  180. package/dist/external-tools/janus/asset-names.js +3 -0
  181. package/dist/external-tools/janus/from-download.d.ts +3 -3
  182. package/dist/external-tools/janus/from-download.js +2 -2
  183. package/dist/external-tools/janus/resolve.d.ts +3 -0
  184. package/dist/external-tools/janus/resolve.js +3 -0
  185. package/dist/external-tools/jre/asset-names.d.ts +3 -1
  186. package/dist/external-tools/jre/asset-names.js +2 -0
  187. package/dist/external-tools/jre/detect-platform-arch.js +1 -1
  188. package/dist/external-tools/jre/from-download.d.ts +1 -1
  189. package/dist/external-tools/manifest.d.ts +5 -3
  190. package/dist/external-tools/manifest.js +5 -3
  191. package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
  192. package/dist/external-tools/opengrep/resolve.d.ts +3 -0
  193. package/dist/external-tools/opengrep/resolve.js +3 -0
  194. package/dist/external-tools/python/asset-names.d.ts +3 -1
  195. package/dist/external-tools/python/asset-names.js +8 -4
  196. package/dist/external-tools/python/pin.js +3 -1
  197. package/dist/external-tools/python/resolve.d.ts +3 -0
  198. package/dist/external-tools/python/resolve.js +3 -0
  199. package/dist/external-tools/python/uv-install.d.ts +89 -0
  200. package/dist/external-tools/python/uv-install.js +165 -0
  201. package/dist/external-tools/sbt/resolve.d.ts +3 -0
  202. package/dist/external-tools/sbt/resolve.js +3 -0
  203. package/dist/external-tools/skillspector/from-uv.d.ts +30 -0
  204. package/dist/external-tools/skillspector/from-uv.js +56 -0
  205. package/dist/external-tools/skillspector/resolve.d.ts +18 -3
  206. package/dist/external-tools/skillspector/resolve.js +21 -8
  207. package/dist/external-tools/skillspector/types.d.ts +3 -1
  208. package/dist/external-tools/synp/resolve.d.ts +3 -0
  209. package/dist/external-tools/synp/resolve.js +3 -0
  210. package/dist/external-tools/trivy/asset-names.d.ts +1 -1
  211. package/dist/external-tools/trivy/resolve.d.ts +3 -0
  212. package/dist/external-tools/trivy/resolve.js +3 -0
  213. package/dist/external-tools/trufflehog/asset-names.d.ts +4 -1
  214. package/dist/external-tools/trufflehog/asset-names.js +3 -0
  215. package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
  216. package/dist/external-tools/trufflehog/resolve.d.ts +3 -0
  217. package/dist/external-tools/trufflehog/resolve.js +3 -0
  218. package/dist/external-tools/uv/asset-names.d.ts +36 -0
  219. package/dist/external-tools/uv/asset-names.js +73 -0
  220. package/dist/external-tools/uv/from-download.d.ts +17 -0
  221. package/dist/external-tools/uv/from-download.js +50 -0
  222. package/dist/external-tools/uv/from-path.d.ts +5 -0
  223. package/dist/external-tools/uv/from-path.js +22 -0
  224. package/dist/external-tools/uv/from-vfs.d.ts +7 -0
  225. package/dist/external-tools/uv/from-vfs.js +26 -0
  226. package/dist/external-tools/uv/resolve.d.ts +28 -0
  227. package/dist/external-tools/uv/resolve.js +64 -0
  228. package/dist/external-tools/uv/types.d.ts +24 -0
  229. package/dist/external-tools/uv/types.js +2 -0
  230. package/dist/fleet/repo-config.d.ts +55 -0
  231. package/dist/fleet/repo-config.js +81 -0
  232. package/dist/fs/_internal.d.ts +1 -1
  233. package/dist/fs/_internal.js +1 -1
  234. package/dist/fs/access.d.ts +2 -0
  235. package/dist/fs/access.js +2 -0
  236. package/dist/fs/copy.d.ts +88 -0
  237. package/dist/fs/copy.js +89 -0
  238. package/dist/fs/find.js +1 -2
  239. package/dist/fs/inspect.d.ts +2 -2
  240. package/dist/fs/read-file.js +3 -4
  241. package/dist/fs/safe.js +2 -2
  242. package/dist/git/_internal.js +7 -3
  243. package/dist/github/commit.d.ts +92 -0
  244. package/dist/github/commit.js +113 -0
  245. package/dist/github/ghsa.js +1 -1
  246. package/dist/github/refs-graphql.js +1 -1
  247. package/dist/github/refs.js +10 -15
  248. package/dist/github/request.js +1 -1
  249. package/dist/github/token.d.ts +5 -2
  250. package/dist/github/token.js +6 -4
  251. package/dist/github/workflow-runs.d.ts +107 -0
  252. package/dist/github/workflow-runs.js +98 -0
  253. package/dist/globs/_internal.js +1 -1
  254. package/dist/http-request/_internal.d.ts +1 -1
  255. package/dist/http-request/browser.d.ts +6 -0
  256. package/dist/http-request/browser.js +4 -3
  257. package/dist/http-request/checksum-file.js +1 -1
  258. package/dist/http-request/download.js +2 -0
  259. package/dist/http-request/headers.d.ts +1 -1
  260. package/dist/http-request/headers.js +2 -2
  261. package/dist/http-request/request-attempt.js +6 -3
  262. package/dist/http-request/request-types.d.ts +10 -1
  263. package/dist/http-request/request.js +2 -2
  264. package/dist/http-request/user-agent.d.ts +23 -2
  265. package/dist/http-request/user-agent.js +48 -6
  266. package/dist/integrity.d.ts +127 -78
  267. package/dist/integrity.js +170 -84
  268. package/dist/json/format.js +4 -1
  269. package/dist/logger/_internal.d.ts +13 -15
  270. package/dist/logger/_internal.js +21 -21
  271. package/dist/logger/colors.d.ts +10 -5
  272. package/dist/logger/colors.js +7 -14
  273. package/dist/logger/console-methods.js +2 -2
  274. package/dist/logger/console.d.ts +1 -0
  275. package/dist/logger/console.js +9 -9
  276. package/dist/logger/node.js +2 -1
  277. package/dist/logger/symbols-builder.js +7 -8
  278. package/dist/logger/symbols.js +8 -8
  279. package/dist/native-messaging/install.js +1 -1
  280. package/dist/native-messaging/rate-limit.d.ts +4 -1
  281. package/dist/native-messaging/rate-limit.js +4 -1
  282. package/dist/node/events.d.ts +3 -0
  283. package/dist/node/events.js +3 -0
  284. package/dist/node/fs.d.ts +1 -1
  285. package/dist/node/module.d.ts +73 -2
  286. package/dist/node/module.js +97 -12
  287. package/dist/node/timers-promises.d.ts +3 -0
  288. package/dist/node/timers-promises.js +3 -0
  289. package/dist/node/url.d.ts +3 -0
  290. package/dist/node/url.js +3 -0
  291. package/dist/npm/meta-cache.d.ts +183 -0
  292. package/dist/npm/meta-cache.js +318 -0
  293. package/dist/npm/meta-slice.d.ts +27 -0
  294. package/dist/npm/meta-slice.js +68 -0
  295. package/dist/npm/meta-types.d.ts +282 -0
  296. package/dist/npm/meta-types.js +2 -0
  297. package/dist/npm/meta.d.ts +125 -0
  298. package/dist/npm/meta.js +347 -0
  299. package/dist/npm/registry.d.ts +212 -0
  300. package/dist/npm/registry.js +284 -0
  301. package/dist/objects/getters.d.ts +1 -1
  302. package/dist/objects/getters.js +1 -1
  303. package/dist/objects/predicates.js +1 -1
  304. package/dist/packages/exports.js +2 -2
  305. package/dist/packages/isolation.js +1 -1
  306. package/dist/packages/manifest.d.ts +29 -0
  307. package/dist/packages/manifest.js +44 -9
  308. package/dist/packages/metadata-extensions.js +2 -4
  309. package/dist/packages/normalize.js +1 -1
  310. package/dist/packages/provenance.d.ts +8 -0
  311. package/dist/packages/provenance.js +10 -2
  312. package/dist/packages/specs.js +1 -1
  313. package/dist/packages/tarball.js +1 -2
  314. package/dist/packages/validation.d.ts +0 -10
  315. package/dist/packages/validation.js +0 -14
  316. package/dist/paths/_internal.d.ts +1 -7
  317. package/dist/paths/_internal.js +9 -15
  318. package/dist/paths/conversion.js +1 -1
  319. package/dist/paths/exts.d.ts +30 -0
  320. package/dist/paths/exts.js +30 -0
  321. package/dist/paths/filenames.d.ts +6 -0
  322. package/dist/paths/filenames.js +6 -0
  323. package/dist/paths/globs.d.ts +6 -0
  324. package/dist/paths/globs.js +6 -0
  325. package/dist/paths/normalize.js +1 -1
  326. package/dist/paths/predicates.js +2 -1
  327. package/dist/paths/resolve.js +19 -14
  328. package/dist/paths/socket.d.ts +81 -30
  329. package/dist/paths/socket.js +102 -28
  330. package/dist/perf/metrics.js +1 -1
  331. package/dist/perf/report.js +5 -3
  332. package/dist/pkg-ext/data.js +0 -2
  333. package/dist/primordials/globals.d.ts +1 -1
  334. package/dist/primordials/globals.js +1 -1
  335. package/dist/primordials/headers.d.ts +13 -1
  336. package/dist/primordials/headers.js +13 -1
  337. package/dist/primordials/process.d.ts +1 -1
  338. package/dist/primordials/process.js +1 -1
  339. package/dist/primordials/url.d.ts +18 -0
  340. package/dist/primordials/url.js +18 -0
  341. package/dist/process/spawn/child.js +3 -5
  342. package/dist/promises/_internal.d.ts +1 -1
  343. package/dist/promises/_internal.js +1 -2
  344. package/dist/promises/options.js +3 -3
  345. package/dist/regexps/spec.js +1 -1
  346. package/dist/releases/socket-btm-binary-naming.js +12 -1
  347. package/dist/schema/validate.js +1 -1
  348. package/dist/secrets/_internal.d.ts +1 -1
  349. package/dist/secrets/_internal.js +1 -1
  350. package/dist/secrets/broker.d.ts +35 -0
  351. package/dist/secrets/broker.js +72 -0
  352. package/dist/secrets/find.d.ts +8 -6
  353. package/dist/secrets/find.js +17 -3
  354. package/dist/secrets/keychain.d.ts +10 -1
  355. package/dist/secrets/keychain.js +10 -1
  356. package/dist/secrets/rc.js +1 -1
  357. package/dist/secrets/socket-api-token.d.ts +1 -1
  358. package/dist/secrets/socket-api-token.js +1 -1
  359. package/dist/secrets/types.d.ts +1 -1
  360. package/dist/smol/detect.js +1 -1
  361. package/dist/smol/http.d.ts +2 -0
  362. package/dist/smol/http.js +3 -1
  363. package/dist/smol/https.d.ts +2 -0
  364. package/dist/smol/https.js +3 -1
  365. package/dist/smol/manifest.js +1 -1
  366. package/dist/smol/path.js +1 -1
  367. package/dist/smol/primordial.js +1 -1
  368. package/dist/smol/purl.js +1 -1
  369. package/dist/smol/versions.js +1 -1
  370. package/dist/smol/vfs.js +1 -1
  371. package/dist/sorts/_internal.d.ts +2 -4
  372. package/dist/sorts/_internal.js +1 -7
  373. package/dist/sorts/semver.js +2 -2
  374. package/dist/spinner/create-spinner-class.js +1 -1
  375. package/dist/spinner/format.js +2 -4
  376. package/dist/stdio/footer.js +8 -7
  377. package/dist/stdio/progress.js +1 -1
  378. package/dist/stdio/prompts.d.ts +8 -23
  379. package/dist/stdio/prompts.js +28 -52
  380. package/dist/strings/format.js +1 -1
  381. package/dist/strings/predicates.d.ts +2 -2
  382. package/dist/strings/search.js +2 -2
  383. package/dist/strings/types.d.ts +4 -0
  384. package/dist/strings/width.d.ts +1 -0
  385. package/dist/strings/width.js +17 -8
  386. package/dist/themes/context.d.ts +18 -3
  387. package/dist/themes/context.js +28 -14
  388. package/dist/versions/_internal.d.ts +43 -13
  389. package/dist/versions/_internal.js +27 -15
  390. package/dist/versions/compare.d.ts +16 -10
  391. package/dist/versions/compare.js +36 -16
  392. package/dist/versions/parse.js +1 -1
  393. package/dist/versions/range.js +3 -2
  394. package/dist/words/pluralize.js +4 -1
  395. package/llms.txt +63 -0
  396. package/package.json +271 -40
@@ -1,19 +1,18 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.js');
4
+ const require_constants_runtime = require('../constants/runtime.js');
5
5
  const require_primordials_array = require('../primordials/array.js');
6
6
  const require_primordials_date = require('../primordials/date.js');
7
7
  const require_primordials_reflect = require('../primordials/reflect.js');
8
8
  const require_strings_format = require('../strings/format.js');
9
+ const require_logger_default = require('../logger/default.js');
9
10
  const require_env_socket = require('../env/socket.js');
10
11
  const require_node_util = require('../node/util.js');
11
12
  const require_debug__internal = require('./_internal.js');
12
13
  const require_debug_namespace = require('./namespace.js');
13
14
  const require_spinner_default = require('../spinner/default.js');
14
15
  const require_debug_caller_info = require('./caller-info.js');
15
- let src_external_debug = require("../external/debug");
16
- src_external_debug = require_runtime.__toESM(src_external_debug);
17
16
 
18
17
  //#region src/debug/output.ts
19
18
  /**
@@ -43,7 +42,8 @@ function debugCache(operation, key, meta) {
43
42
  if (!require_env_socket.getSocketDebug()) return;
44
43
  const prefix = `[CACHE] ${require_debug_caller_info.getCallerInfo(3) || "cache"} ${require_debug__internal.getPointingTriangle()} ${operation}: ${key}`;
45
44
  const args = meta !== void 0 ? [prefix, meta] : [prefix];
46
- require_primordials_reflect.ReflectApply(require_debug__internal.logger.info, require_debug__internal.logger, args);
45
+ const logger = require_logger_default.getDefaultLogger();
46
+ require_primordials_reflect.ReflectApply(logger.info, logger, args);
47
47
  }
48
48
  /**
49
49
  * Debug output for cache operations with caller info. First argument is the
@@ -56,10 +56,11 @@ function debugCacheNs(namespacesOrOpts, operation, key, meta) {
56
56
  if (!require_debug_namespace.isEnabled(namespaces)) return;
57
57
  const prefix = `[CACHE] ${require_debug_caller_info.getCallerInfo(4) || "cache"} ${require_debug__internal.getPointingTriangle()} ${operation}: ${key}`;
58
58
  const logArgs = meta !== void 0 ? [prefix, meta] : [prefix];
59
- const spinnerInstance = options.spinner || require_spinner_default.getDefaultSpinner();
59
+ const spinnerInstance = options.spinner || getSpinner();
60
60
  const wasSpinning = spinnerInstance?.isSpinning;
61
61
  spinnerInstance?.stop();
62
- require_primordials_reflect.ReflectApply(require_debug__internal.logger.info, require_debug__internal.logger, logArgs);
62
+ const logger = require_logger_default.getDefaultLogger();
63
+ require_primordials_reflect.ReflectApply(logger.info, logger, logArgs);
63
64
  if (wasSpinning) spinnerInstance?.start();
64
65
  }
65
66
  /**
@@ -81,9 +82,9 @@ function debugDirNs(namespacesOrOpts, obj, inspectOpts) {
81
82
  /* c8 ignore stop */
82
83
  const pointingTriangle = require_debug__internal.getPointingTriangle();
83
84
  let opts = inspectOpts;
84
- /* c8 ignore start */
85
+ /* c8 ignore start - inspectOpts fallback needs DEBUG_INSPECT_OPTIONS env */
85
86
  if (opts === void 0) {
86
- const debugOpts = src_external_debug.default.inspectOpts;
87
+ const debugOpts = require_debug__internal.getDebugJs().inspectOpts;
87
88
  if (debugOpts) opts = {
88
89
  ...debugOpts,
89
90
  showHidden: debugOpts.showHidden === null ? void 0 : debugOpts.showHidden,
@@ -91,11 +92,12 @@ function debugDirNs(namespacesOrOpts, obj, inspectOpts) {
91
92
  };
92
93
  }
93
94
  /* c8 ignore stop */
94
- const spinnerInstance = options.spinner || require_spinner_default.getDefaultSpinner();
95
+ const spinnerInstance = options.spinner || getSpinner();
95
96
  const wasSpinning = spinnerInstance?.isSpinning;
96
97
  spinnerInstance?.stop();
97
- require_debug__internal.logger.info(`[DEBUG] ${callerName} ${pointingTriangle} object inspection:`);
98
- require_debug__internal.logger.dir(obj, inspectOpts);
98
+ const logger = require_logger_default.getDefaultLogger();
99
+ logger.info(`[DEBUG] ${callerName} ${pointingTriangle} object inspection:`);
100
+ logger.dir(obj, inspectOpts);
99
101
  if (wasSpinning) spinnerInstance?.start();
100
102
  }
101
103
  /**
@@ -117,10 +119,11 @@ function debugLogNs(namespacesOrOpts, ...args) {
117
119
  const pointingTriangle = require_debug__internal.getPointingTriangle();
118
120
  const text = require_primordials_array.ArrayPrototypeAt(args, 0);
119
121
  const logArgs = typeof text === "string" ? [require_strings_format.applyLinePrefix(`${callerName} ${pointingTriangle} ${text}`, { prefix: "[DEBUG] " }), ...require_primordials_array.ArrayPrototypeSlice(args, 1)] : [`[DEBUG] ${callerName} ${pointingTriangle}`, ...args];
120
- const spinnerInstance = options.spinner || require_spinner_default.getDefaultSpinner();
122
+ const spinnerInstance = options.spinner || getSpinner();
121
123
  const wasSpinning = spinnerInstance?.isSpinning;
122
124
  spinnerInstance?.stop();
123
- require_primordials_reflect.ReflectApply(require_debug__internal.logger.info, require_debug__internal.logger, logArgs);
125
+ const logger = require_logger_default.getDefaultLogger();
126
+ require_primordials_reflect.ReflectApply(logger.info, logger, logArgs);
124
127
  if (wasSpinning) spinnerInstance?.start();
125
128
  }
126
129
  /**
@@ -136,10 +139,11 @@ function debugNs(namespacesOrOpts, ...args) {
136
139
  const pointingTriangle = require_debug__internal.getPointingTriangle();
137
140
  const text = require_primordials_array.ArrayPrototypeAt(args, 0);
138
141
  const logArgs = typeof text === "string" ? [require_strings_format.applyLinePrefix(`${name} ${pointingTriangle} ${text}`, { prefix: "[DEBUG] " }), ...require_primordials_array.ArrayPrototypeSlice(args, 1)] : args;
139
- const spinnerInstance = options.spinner || require_spinner_default.getDefaultSpinner();
142
+ const spinnerInstance = options.spinner || getSpinner();
140
143
  const wasSpinning = spinnerInstance?.isSpinning;
141
144
  spinnerInstance?.stop();
142
- require_primordials_reflect.ReflectApply(require_debug__internal.logger.info, require_debug__internal.logger, logArgs);
145
+ const logger = require_logger_default.getDefaultLogger();
146
+ require_primordials_reflect.ReflectApply(logger.info, logger, logArgs);
143
147
  if (wasSpinning) spinnerInstance?.start();
144
148
  }
145
149
  /**
@@ -176,6 +180,18 @@ function debugtime(label) {
176
180
  };
177
181
  return impl;
178
182
  }
183
+ /**
184
+ * Resolve the default spinner on Node; off Node (browser bundles) there is no
185
+ * spinner — callers no-op through their optional chains. Construction is
186
+ * deferred to first debug write (every call site sits behind the `isEnabled`
187
+ * / `getSocketDebug` gates), so a browser bundle never constructs the
188
+ * node-bound spinner even when debug output is force-enabled.
189
+ *
190
+ * @private
191
+ */
192
+ function getSpinner() {
193
+ return require_constants_runtime.IS_NODE ? require_spinner_default.getDefaultSpinner() : void 0;
194
+ }
179
195
 
180
196
  //#endregion
181
197
  exports.debug = debug;
@@ -187,4 +203,5 @@ exports.debugLog = debugLog;
187
203
  exports.debugLogNs = debugLogNs;
188
204
  exports.debugNs = debugNs;
189
205
  exports.debuglog = debuglog;
190
- exports.debugtime = debugtime;
206
+ exports.debugtime = debugtime;
207
+ exports.getSpinner = getSpinner;
@@ -2,8 +2,8 @@
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_runtime = require('../_virtual/_rolldown/runtime.js');
5
- const require_objects_predicates = require('../objects/predicates.js');
6
5
  const require_primordials_string = require('../primordials/string.js');
6
+ const require_objects_predicates = require('../objects/predicates.js');
7
7
  const require_primordials_array = require('../primordials/array.js');
8
8
  const require_node_fs = require('../node/fs.js');
9
9
  const require_node_path = require('../node/path.js');
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_runtime = require('../_virtual/_rolldown/runtime.js');
5
5
  const require_primordials_error = require('../primordials/error.js');
6
- const require_constants_platform = require('../constants/platform.js');
7
6
  const require_primordials_object = require('../primordials/object.js');
7
+ const require_constants_platform = require('../constants/platform.js');
8
8
  const require_paths_normalize = require('../paths/normalize.js');
9
9
  const require_node_fs = require('../node/fs.js');
10
10
  const require_node_path = require('../node/path.js');
@@ -70,10 +70,13 @@ function findBinaryPath(packageDir, packageName, binaryName) {
70
70
  packageName.split("/").pop() ?? packageName,
71
71
  packageName.replace(/^@[^/]+\//, "")
72
72
  ].filter(Boolean);
73
- for (const candidate of candidates) if (candidate && binObj[candidate]) {
74
- binName = candidate;
75
- binPath = binObj[candidate];
76
- break;
73
+ for (let i = 0, { length } = candidates; i < length; i += 1) {
74
+ const candidate = candidates[i];
75
+ if (candidate && binObj[candidate]) {
76
+ binName = candidate;
77
+ binPath = binObj[candidate];
78
+ break;
79
+ }
77
80
  }
78
81
  if (!binPath && binKeys.length > 0) {
79
82
  binName = binKeys[0];
@@ -2,8 +2,8 @@
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_primordials_error = require('../primordials/error.js');
5
- const require_primordials_map_set = require('../primordials/map-set.js');
6
5
  const require_primordials_string = require('../primordials/string.js');
6
+ const require_primordials_map_set = require('../primordials/map-set.js');
7
7
  const require_primordials_promise = require('../primordials/promise.js');
8
8
  const require_http_request_user_agent = require('../http-request/user-agent.js');
9
9
  const require_http_request_node = require('../http-request/node.js');
@@ -2,8 +2,8 @@
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_runtime = require('../_virtual/_rolldown/runtime.js');
5
- const require_integrity = require('../integrity.js');
6
5
  const require_primordials_string = require('../primordials/string.js');
6
+ const require_integrity = require('../integrity.js');
7
7
  const require_node_fs = require('../node/fs.js');
8
8
  const require_node_path = require('../node/path.js');
9
9
  const require_primordials_date = require('../primordials/date.js');
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_primordials_error = require('../../../primordials/error.js');
5
5
  const require_primordials_object = require('../../../primordials/object.js');
6
- const require_primordials_map_set = require('../../../primordials/map-set.js');
7
6
  const require_primordials_string = require('../../../primordials/string.js');
7
+ const require_primordials_map_set = require('../../../primordials/map-set.js');
8
8
  const require_primordials_array = require('../../../primordials/array.js');
9
9
  const require_primordials_json = require('../../../primordials/json.js');
10
10
  const require_errors_message = require('../../../errors/message.js');
@@ -134,7 +134,8 @@ function parseV1(data, rootDeps) {
134
134
  const key = `${name}@${typeof pkg.version === "string" ? pkg.version : "0.0.0"}`;
135
135
  if (visited.has(key)) continue;
136
136
  if (packageIndex[name] === void 0) {
137
- require_primordials_array.ArrayPrototypePush(packages, buildPackageRef(name, pkg));
137
+ const ref = buildPackageRef(name, pkg);
138
+ require_primordials_array.ArrayPrototypePush(packages, ref);
138
139
  packageIndex[name] = packages.length - 1;
139
140
  }
140
141
  if (pkg.dependencies && typeof pkg.dependencies === "object") {
@@ -3,7 +3,7 @@
3
3
  * The dir exists so downstream code can import from a stable canonical path;
4
4
  * populate when first concrete need arrives. vlt lockfile is `vlt-lock.json`.
5
5
  * Reference: socket-sdxgen/src/parsers/vlt/. vlt does not support overrides,
6
- * so fleet code that needs override support should branch around it (see
6
+ * so Socket code that needs override support should branch around it (see
7
7
  * socket-cli/packages/cli/src/commands/optimize/ for the canonical pattern of
8
8
  * agent-conditional logic).
9
9
  */
@@ -9,7 +9,7 @@ const require_primordials_error = require('../../../primordials/error.js');
9
9
  * The dir exists so downstream code can import from a stable canonical path;
10
10
  * populate when first concrete need arrives. vlt lockfile is `vlt-lock.json`.
11
11
  * Reference: socket-sdxgen/src/parsers/vlt/. vlt does not support overrides,
12
- * so fleet code that needs override support should branch around it (see
12
+ * so Socket code that needs override support should branch around it (see
13
13
  * socket-cli/packages/cli/src/commands/optimize/ for the canonical pattern of
14
14
  * agent-conditional logic).
15
15
  */
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_primordials_math = require('../../../../primordials/math.js');
5
4
  const require_primordials_object = require('../../../../primordials/object.js');
6
5
  const require_primordials_string = require('../../../../primordials/string.js');
6
+ const require_primordials_math = require('../../../../primordials/math.js');
7
7
  const require_primordials_array = require('../../../../primordials/array.js');
8
8
  const require_smol_manifest = require('../../../../smol/manifest.js');
9
9
  const require_eco_npm_yarnpkg_yarn_parse_yarn_descriptor = require('./parse-yarn-descriptor.js');
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @file AI coding-agent detection, re-exported from std-env — not
3
+ * reimplemented. std-env is a devDependency, inlined by the bundler.
4
+ */
5
+ export { agent, agentInfo, detectAgent, isAgent } from '../external/std-env';
6
+ export type { AgentInfo, AgentName } from '../external/std-env';
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with rolldown */
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ let src_external_std_env = require("../external/std-env");
5
+
6
+ Object.defineProperty(exports, 'agent', {
7
+ enumerable: true,
8
+ get: function () {
9
+ return src_external_std_env.agent;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, 'agentInfo', {
13
+ enumerable: true,
14
+ get: function () {
15
+ return src_external_std_env.agentInfo;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, 'detectAgent', {
19
+ enumerable: true,
20
+ get: function () {
21
+ return src_external_std_env.detectAgent;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, 'isAgent', {
25
+ enumerable: true,
26
+ get: function () {
27
+ return src_external_std_env.isAgent;
28
+ }
29
+ });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @file Environment flag booleans, re-exported from std-env — not
3
+ * reimplemented. std-env is a devDependency; the bundler inlines it, so dist
4
+ * carries the logic with no runtime std-env import.
5
+ * Only the flags socket-lib does NOT already own live here. CI, DEBUG,
6
+ * NODE_ENV, test, platform, and Node-version detection are handled by
7
+ * socket-lib's own rewire-aware getters and constants (`env/ci` `getCI`,
8
+ * `env/debug` `getDebug`, `env/node-env` `getNodeEnv`, `env/test` `isTest`,
9
+ * `constants/platform`, `constants/node`, `constants/runtime`), so std-env's
10
+ * overlapping flags are intentionally not re-exported.
11
+ */
12
+ export { hasTTY, isColorSupported, isMinimal } from '../external/std-env';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with rolldown */
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ let src_external_std_env = require("../external/std-env");
5
+
6
+ Object.defineProperty(exports, 'hasTTY', {
7
+ enumerable: true,
8
+ get: function () {
9
+ return src_external_std_env.hasTTY;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, 'isColorSupported', {
13
+ enumerable: true,
14
+ get: function () {
15
+ return src_external_std_env.isColorSupported;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, 'isMinimal', {
19
+ enumerable: true,
20
+ get: function () {
21
+ return src_external_std_env.isMinimal;
22
+ }
23
+ });
@@ -13,12 +13,12 @@ const require_http_request_node = require('../http-request/node.js');
13
13
  * most 8 seconds to startup (configurable timeout) and fails open on network
14
14
  * error so a down status page never blocks a healthy workflow.
15
15
  */
16
- const MONITORED_COMPONENT_IDS = new Map([
16
+ const MONITORED_COMPONENT_IDS = /* @__PURE__ */ new Map([
17
17
  ["br0l2tvcx85d", "Actions"],
18
18
  ["8l4ygp009s5s", "Git Operations"],
19
19
  ["brv1bkgrwx7q", "API Requests"]
20
20
  ]);
21
- const SEVERITY = new Map([
21
+ const SEVERITY = /* @__PURE__ */ new Map([
22
22
  ["major_outage", 4],
23
23
  ["partial_outage", 3],
24
24
  ["degraded_performance", 2],
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @file CI/host provider detection, re-exported from std-env — not
3
+ * reimplemented. std-env is a devDependency, inlined by the bundler.
4
+ */
5
+ export { detectProvider, provider, providerInfo } from '../external/std-env';
6
+ export type { ProviderInfo, ProviderName } from '../external/std-env';
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with rolldown */
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ let src_external_std_env = require("../external/std-env");
5
+
6
+ Object.defineProperty(exports, 'detectProvider', {
7
+ enumerable: true,
8
+ get: function () {
9
+ return src_external_std_env.detectProvider;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, 'provider', {
13
+ enumerable: true,
14
+ get: function () {
15
+ return src_external_std_env.provider;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, 'providerInfo', {
19
+ enumerable: true,
20
+ get: function () {
21
+ return src_external_std_env.providerInfo;
22
+ }
23
+ });
package/dist/env/proxy.js CHANGED
@@ -86,7 +86,7 @@ function createEnvProxy(base, overrides) {
86
86
  return lookupEnvValue(prop);
87
87
  },
88
88
  ownKeys(_target) {
89
- return [...new Set([...require_primordials_object.ObjectKeys(base), ...overrides ? require_primordials_object.ObjectKeys(overrides) : []])];
89
+ return [.../* @__PURE__ */ new Set([...require_primordials_object.ObjectKeys(base), ...overrides ? require_primordials_object.ObjectKeys(overrides) : []])];
90
90
  },
91
91
  getOwnPropertyDescriptor(_target, prop) {
92
92
  if (typeof prop !== "string") return;
@@ -8,7 +8,8 @@
8
8
  * - Compatible with vi.stubEnv() - reads from process.env as final fallback
9
9
  * - Thread-safe for concurrent test execution
10
10
  */
11
- import type * as asyncHooksModule from 'node:async_hooks';
11
+ import type { AsyncLocalStorage } from 'node:async_hooks';
12
+ import { getNodeAsyncHooks } from '../node/async-hooks';
12
13
  export type EnvOverrides = Map<string, string | undefined>;
13
14
  /**
14
15
  * Clear a specific environment variable override.
@@ -25,11 +26,13 @@ export type EnvOverrides = Map<string, string | undefined>;
25
26
  */
26
27
  export declare function clearEnv(key: string): void;
27
28
  /**
28
- * Lazily load the async_hooks module to avoid Webpack errors.
29
+ * Lazily load the async_hooks module. Aliases the canonical `node/async-hooks`
30
+ * accessor (single owner of the bundler-safe require); kept as an export so
31
+ * this module's surface is unchanged.
29
32
  *
30
33
  * @private
31
34
  */
32
- export declare function getAsyncHooks(): typeof asyncHooksModule;
35
+ export declare const getAsyncHooks: typeof getNodeAsyncHooks;
33
36
  /**
34
37
  * Get an environment variable value, checking overrides first.
35
38
  *
@@ -48,6 +51,27 @@ export declare function getAsyncHooks(): typeof asyncHooksModule;
48
51
  * @internal Used by env getters to support test rewiring
49
52
  */
50
53
  export declare function getEnvValue(key: string): string | undefined;
54
+ /**
55
+ * Get the current isolated-override map, or undefined when none is active.
56
+ * Off Node (browser bundles) there is no AsyncLocalStorage and no isolated
57
+ * context — env getters fall straight through to the other tiers.
58
+ *
59
+ * @private
60
+ */
61
+ export declare function getIsolatedOverrides(): EnvOverrides | undefined;
62
+ /**
63
+ * Get the process-scoped AsyncLocalStorage used for nested env overrides
64
+ * (withEnv/withEnvSync).
65
+ *
66
+ * Constructed LAZILY (memoized) rather than at module-eval: an
67
+ * AsyncLocalStorage holds a live native handle, and constructing it at import
68
+ * time pins that handle into every module transitively importing this leaf —
69
+ * aborting V8 --build-snapshot serialization. Deferring to first use keeps the
70
+ * single-store semantics while leaving module import snapshot-safe.
71
+ *
72
+ * @private
73
+ */
74
+ export declare function getIsolatedOverridesStorage(): AsyncLocalStorage<EnvOverrides>;
51
75
  /**
52
76
  * Check if an environment variable has been overridden.
53
77
  *
@@ -98,6 +122,16 @@ export declare function isInEnv(key: string): boolean;
98
122
  * ```
99
123
  */
100
124
  export declare function resetEnv(): void;
125
+ /**
126
+ * Read `process.env` without assuming a real Node `process`. Probes the
127
+ * GLOBAL `process` via `typeof` (no `node:process` import — webpack throws
128
+ * UnhandledSchemeError on `node:` specifiers before the `browser`-field stubs
129
+ * apply), so browser bundles load this leaf cleanly and env getters read as
130
+ * unset instead of throwing.
131
+ *
132
+ * @private
133
+ */
134
+ export declare function safeProcessEnv(): Record<string, string | undefined> | undefined;
101
135
  /**
102
136
  * Set an environment variable override for testing. This does not modify
103
137
  * process.env, only affects env getters.
@@ -1,31 +1,18 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.js');
4
+ const require_constants_runtime = require('../constants/runtime.js');
5
5
  const require_primordials_object = require('../primordials/object.js');
6
6
  const require_objects_predicates = require('../objects/predicates.js');
7
7
  const require_env_boolean = require('./boolean.js');
8
+ const require_node_async_hooks = require('../node/async-hooks.js');
8
9
  const require_primordials_map_set = require('../primordials/map-set.js');
9
- let node_process = require("node:process");
10
- node_process = require_runtime.__toESM(node_process);
11
10
 
12
11
  //#region src/env/rewire.ts
13
- /**
14
- * @file Environment variable rewiring utilities for testing. Uses
15
- * AsyncLocalStorage for context-isolated overrides that work with concurrent
16
- * tests. Features:
17
- *
18
- * - Context-isolated overrides via withEnv() for advanced use cases
19
- * - Test-friendly setEnv/clearEnv/resetEnv that work in beforeEach/afterEach
20
- * - Compatible with vi.stubEnv() - reads from process.env as final fallback
21
- * - Thread-safe for concurrent test execution
22
- */
23
- let asyncHooks;
24
- const { AsyncLocalStorage } = getAsyncHooks();
25
- const isolatedOverridesStorage = new AsyncLocalStorage();
12
+ let isolatedOverridesStorage;
26
13
  const sharedOverridesSymbol = Symbol.for("@socketsecurity/lib/env/rewire/test-overrides");
27
14
  const globalThisRef = globalThis;
28
- if (require_env_boolean.envAsBoolean(node_process.default.env["VITEST"]) && !globalThisRef[sharedOverridesSymbol]) globalThisRef[sharedOverridesSymbol] = new require_primordials_map_set.MapCtor();
15
+ if (require_env_boolean.envAsBoolean(safeProcessEnv()?.["VITEST"]) && !globalThisRef[sharedOverridesSymbol]) globalThisRef[sharedOverridesSymbol] = new require_primordials_map_set.MapCtor();
29
16
  const sharedOverrides = globalThisRef[sharedOverridesSymbol];
30
17
  /**
31
18
  * Clear a specific environment variable override.
@@ -44,14 +31,13 @@ function clearEnv(key) {
44
31
  sharedOverrides?.delete(key);
45
32
  }
46
33
  /**
47
- * Lazily load the async_hooks module to avoid Webpack errors.
34
+ * Lazily load the async_hooks module. Aliases the canonical `node/async-hooks`
35
+ * accessor (single owner of the bundler-safe require); kept as an export so
36
+ * this module's surface is unchanged.
48
37
  *
49
38
  * @private
50
39
  */
51
- function getAsyncHooks() {
52
- if (asyncHooks === void 0) asyncHooks = /*@__PURE__*/ require("node:async_hooks");
53
- return asyncHooks;
54
- }
40
+ const getAsyncHooks = require_node_async_hooks.getNodeAsyncHooks;
55
41
  /**
56
42
  * Get an environment variable value, checking overrides first.
57
43
  *
@@ -70,10 +56,39 @@ function getAsyncHooks() {
70
56
  * @internal Used by env getters to support test rewiring
71
57
  */
72
58
  function getEnvValue(key) {
73
- const isolatedOverrides = isolatedOverridesStorage.getStore();
59
+ const isolatedOverrides = getIsolatedOverrides();
74
60
  if (isolatedOverrides?.has(key)) return isolatedOverrides.get(key);
75
61
  if (sharedOverrides?.has(key)) return sharedOverrides.get(key);
76
- return node_process.default.env[key];
62
+ return safeProcessEnv()?.[key];
63
+ }
64
+ /**
65
+ * Get the current isolated-override map, or undefined when none is active.
66
+ * Off Node (browser bundles) there is no AsyncLocalStorage and no isolated
67
+ * context — env getters fall straight through to the other tiers.
68
+ *
69
+ * @private
70
+ */
71
+ function getIsolatedOverrides() {
72
+ return require_constants_runtime.IS_NODE ? getIsolatedOverridesStorage().getStore() : void 0;
73
+ }
74
+ /**
75
+ * Get the process-scoped AsyncLocalStorage used for nested env overrides
76
+ * (withEnv/withEnvSync).
77
+ *
78
+ * Constructed LAZILY (memoized) rather than at module-eval: an
79
+ * AsyncLocalStorage holds a live native handle, and constructing it at import
80
+ * time pins that handle into every module transitively importing this leaf —
81
+ * aborting V8 --build-snapshot serialization. Deferring to first use keeps the
82
+ * single-store semantics while leaving module import snapshot-safe.
83
+ *
84
+ * @private
85
+ */
86
+ function getIsolatedOverridesStorage() {
87
+ if (isolatedOverridesStorage === void 0) {
88
+ const { AsyncLocalStorage } = require_node_async_hooks.getNodeAsyncHooks();
89
+ isolatedOverridesStorage = new AsyncLocalStorage();
90
+ }
91
+ return isolatedOverridesStorage;
77
92
  }
78
93
  /**
79
94
  * Check if an environment variable has been overridden.
@@ -92,7 +107,7 @@ function getEnvValue(key) {
92
107
  * @returns `true` if the variable has been overridden, `false` otherwise
93
108
  */
94
109
  function hasOverride(key) {
95
- return !!(isolatedOverridesStorage.getStore()?.has(key) || sharedOverrides?.has(key));
110
+ return !!(getIsolatedOverrides()?.has(key) || sharedOverrides?.has(key));
96
111
  }
97
112
  /**
98
113
  * Check if an environment variable exists (has a key), checking overrides
@@ -113,9 +128,10 @@ function hasOverride(key) {
113
128
  * @internal Used by env getters to check for key presence (not value truthiness)
114
129
  */
115
130
  function isInEnv(key) {
116
- if (isolatedOverridesStorage.getStore()?.has(key)) return true;
131
+ if (getIsolatedOverrides()?.has(key)) return true;
117
132
  if (sharedOverrides?.has(key)) return true;
118
- return require_objects_predicates.hasOwn(node_process.default.env, key);
133
+ const env = safeProcessEnv();
134
+ return env ? require_objects_predicates.hasOwn(env, key) : false;
119
135
  }
120
136
  /**
121
137
  * Clear all environment variable overrides. Useful in afterEach hooks to ensure
@@ -134,6 +150,18 @@ function resetEnv() {
134
150
  sharedOverrides?.clear();
135
151
  }
136
152
  /**
153
+ * Read `process.env` without assuming a real Node `process`. Probes the
154
+ * GLOBAL `process` via `typeof` (no `node:process` import — webpack throws
155
+ * UnhandledSchemeError on `node:` specifiers before the `browser`-field stubs
156
+ * apply), so browser bundles load this leaf cleanly and env getters read as
157
+ * unset instead of throwing.
158
+ *
159
+ * @private
160
+ */
161
+ function safeProcessEnv() {
162
+ return typeof process !== "undefined" && process ? process.env : void 0;
163
+ }
164
+ /**
137
165
  * Set an environment variable override for testing. This does not modify
138
166
  * process.env, only affects env getters.
139
167
  *
@@ -194,7 +222,7 @@ function setEnv(key, value) {
194
222
  */
195
223
  async function withEnv(overrides, fn) {
196
224
  const map = new require_primordials_map_set.MapCtor(require_primordials_object.ObjectEntries(overrides));
197
- return await isolatedOverridesStorage.run(map, fn);
225
+ return await getIsolatedOverridesStorage().run(map, fn);
198
226
  }
199
227
  /**
200
228
  * Synchronous version of withEnv for non-async code.
@@ -212,16 +240,19 @@ async function withEnv(overrides, fn) {
212
240
  */
213
241
  function withEnvSync(overrides, fn) {
214
242
  const map = new require_primordials_map_set.MapCtor(require_primordials_object.ObjectEntries(overrides));
215
- return isolatedOverridesStorage.run(map, fn);
243
+ return getIsolatedOverridesStorage().run(map, fn);
216
244
  }
217
245
 
218
246
  //#endregion
219
247
  exports.clearEnv = clearEnv;
220
248
  exports.getAsyncHooks = getAsyncHooks;
221
249
  exports.getEnvValue = getEnvValue;
250
+ exports.getIsolatedOverrides = getIsolatedOverrides;
251
+ exports.getIsolatedOverridesStorage = getIsolatedOverridesStorage;
222
252
  exports.hasOverride = hasOverride;
223
253
  exports.isInEnv = isInEnv;
224
254
  exports.resetEnv = resetEnv;
255
+ exports.safeProcessEnv = safeProcessEnv;
225
256
  exports.setEnv = setEnv;
226
257
  exports.withEnv = withEnv;
227
258
  exports.withEnvSync = withEnvSync;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @file JS runtime detection, re-exported from std-env — not reimplemented.
3
+ * std-env is a devDependency, inlined by the bundler.
4
+ * `isNode` is omitted: socket-lib's `constants/runtime` `IS_NODE` (a
5
+ * typeof-safe global probe) already owns Node detection. The edge/alt-runtime
6
+ * flags below have no socket-lib equivalent.
7
+ */
8
+ export { isBun, isDeno, isEdgeLight, isFastly, isNetlify, isWorkerd, runtime, runtimeInfo, } from '../external/std-env';
9
+ export type { RuntimeInfo, RuntimeName } from '../external/std-env';