@socketsecurity/lib 6.0.5 → 6.0.6

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 (210) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/ai/discover.js +3 -2
  3. package/dist/ai/spawn.js +8 -5
  4. package/dist/ai/worktree.js +11 -6
  5. package/dist/ansi/strip.js +2 -2
  6. package/dist/archives/_internal.js +4 -4
  7. package/dist/archives/zip.js +1 -1
  8. package/dist/arrays/_internal.js +2 -2
  9. package/dist/arrays/chunk.js +1 -1
  10. package/dist/arrays/join.js +2 -2
  11. package/dist/arrays/unique.js +1 -1
  12. package/dist/bin/acorn-bindgen.cjs +769 -0
  13. package/dist/bin/acorn.wasm +0 -0
  14. package/dist/bin/check-primordials.js +3 -2
  15. package/dist/bin/check.js +3 -2
  16. package/dist/bin/exec.js +1 -1
  17. package/dist/bin/prim.cjs +39064 -0
  18. package/dist/bin/resolve.js +1 -1
  19. package/dist/colors/socket-palette.js +2 -2
  20. package/dist/compression/_internal.js +3 -2
  21. package/dist/compression/brotli.js +5 -12
  22. package/dist/compression/gzip.js +5 -13
  23. package/dist/constants/agents.js +4 -4
  24. package/dist/constants/packages.js +6 -6
  25. package/dist/constants/socket.js +1 -1
  26. package/dist/crypto/hash.js +2 -2
  27. package/dist/debug/_internal.js +2 -2
  28. package/dist/debug/caller-info.js +1 -1
  29. package/dist/debug/namespace.js +5 -5
  30. package/dist/debug/output.js +3 -3
  31. package/dist/dlx/binary-download.js +3 -2
  32. package/dist/eco/npm/npm/flags.js +5 -5
  33. package/dist/eco/npm/pnpm/flags.js +3 -3
  34. package/dist/env/boolean.js +1 -1
  35. package/dist/env/ci.js +1 -1
  36. package/dist/env/debug.js +1 -1
  37. package/dist/env/github.js +8 -8
  38. package/dist/env/home.js +1 -1
  39. package/dist/env/locale.js +3 -3
  40. package/dist/env/node-auth-token.js +1 -1
  41. package/dist/env/node-env.js +1 -1
  42. package/dist/env/npm.js +5 -5
  43. package/dist/env/number.js +1 -1
  44. package/dist/env/package-manager.js +3 -3
  45. package/dist/env/path.js +1 -1
  46. package/dist/env/pre-commit.js +1 -1
  47. package/dist/env/rewire.js +2 -2
  48. package/dist/env/shell.js +1 -1
  49. package/dist/env/socket-cli.js +13 -13
  50. package/dist/env/socket.js +33 -32
  51. package/dist/env/string.js +1 -1
  52. package/dist/env/temp-dir.js +3 -3
  53. package/dist/env/term.js +1 -1
  54. package/dist/env/test.js +3 -3
  55. package/dist/env/windows.js +4 -4
  56. package/dist/env/xdg.js +3 -3
  57. package/dist/events/exit/_internal.js +5 -5
  58. package/dist/events/exit/handler.js +1 -1
  59. package/dist/events/exit/intercept.js +2 -2
  60. package/dist/events/exit/lifecycle.js +3 -3
  61. package/dist/events/exit/signals.js +1 -1
  62. package/dist/external/@sinclair/typebox/value.js +5 -1
  63. package/dist/external/@sinclair/typebox.js +5 -1
  64. package/dist/external/@socketregistry/packageurl-js.js +27 -0
  65. package/dist/external-tools/bazel/resolve.js +2 -1
  66. package/dist/external-tools/cdxgen/resolve.js +2 -1
  67. package/dist/external-tools/from-pip-venv.d.ts +73 -0
  68. package/dist/external-tools/from-pip-venv.js +98 -0
  69. package/dist/external-tools/janus/asset-names.js +1 -1
  70. package/dist/external-tools/janus/from-download.js +3 -5
  71. package/dist/external-tools/janus/resolve.js +2 -1
  72. package/dist/external-tools/jre/from-download.js +2 -1
  73. package/dist/external-tools/jre/resolve.js +2 -1
  74. package/dist/external-tools/manifest.js +7 -5
  75. package/dist/external-tools/opengrep/resolve.js +2 -1
  76. package/dist/external-tools/sbt/resolve.js +2 -1
  77. package/dist/external-tools/skillspector/from-dlx.d.ts +24 -0
  78. package/dist/external-tools/skillspector/from-dlx.js +41 -0
  79. package/dist/external-tools/skillspector/from-path.d.ts +8 -0
  80. package/dist/external-tools/skillspector/from-path.js +32 -0
  81. package/dist/external-tools/skillspector/from-vfs.d.ts +8 -0
  82. package/dist/external-tools/skillspector/from-vfs.js +27 -0
  83. package/dist/external-tools/skillspector/resolve.d.ts +34 -0
  84. package/dist/external-tools/skillspector/resolve.js +53 -0
  85. package/dist/external-tools/skillspector/types.d.ts +24 -0
  86. package/dist/external-tools/skillspector/types.js +2 -0
  87. package/dist/external-tools/synp/resolve.js +2 -1
  88. package/dist/external-tools/trivy/resolve.js +2 -1
  89. package/dist/external-tools/trufflehog/resolve.js +2 -1
  90. package/dist/external-tools/uv/resolve.js +2 -1
  91. package/dist/fs/access.js +4 -4
  92. package/dist/fs/encoding.js +2 -2
  93. package/dist/fs/find-up.js +2 -2
  94. package/dist/fs/inspect.js +6 -6
  95. package/dist/fs/read-dir.js +3 -3
  96. package/dist/fs/read-file.js +6 -6
  97. package/dist/fs/read-json.js +2 -2
  98. package/dist/fs/safe.js +2 -2
  99. package/dist/fs/unique.js +1 -1
  100. package/dist/fs/validate.js +1 -1
  101. package/dist/fs/write-json.js +1 -1
  102. package/dist/git/_internal.js +2 -1
  103. package/dist/globs/_internal.js +4 -4
  104. package/dist/globs/match.js +4 -3
  105. package/dist/globs/matcher.js +2 -2
  106. package/dist/globs/stream.js +1 -1
  107. package/dist/http-request/browser.js +17 -11
  108. package/dist/http-request/download.js +1 -1
  109. package/dist/http-request/headers.d.ts +32 -3
  110. package/dist/http-request/headers.js +42 -13
  111. package/dist/http-request/request-attempt.js +1 -0
  112. package/dist/http-request/request-types.d.ts +5 -0
  113. package/dist/http-request/request.js +32 -15
  114. package/dist/http-request/response-reader.d.ts +12 -1
  115. package/dist/http-request/response-reader.js +22 -2
  116. package/dist/http-request/user-agent.js +1 -1
  117. package/dist/json/edit.js +1 -1
  118. package/dist/json/parse.js +4 -4
  119. package/dist/logger/colors.js +2 -2
  120. package/dist/logger/console.js +1 -1
  121. package/dist/logger/symbols.js +1 -1
  122. package/dist/node/async-hooks.js +2 -2
  123. package/dist/node/child-process.js +2 -2
  124. package/dist/node/crypto.js +2 -2
  125. package/dist/node/events.js +2 -2
  126. package/dist/node/fs-promises.js +2 -2
  127. package/dist/node/fs.js +2 -2
  128. package/dist/node/http.js +2 -2
  129. package/dist/node/https.js +2 -2
  130. package/dist/node/module.js +3 -3
  131. package/dist/node/os.js +2 -2
  132. package/dist/node/path.js +2 -2
  133. package/dist/node/timers-promises.js +2 -2
  134. package/dist/node/url.js +2 -2
  135. package/dist/node/util.js +2 -2
  136. package/dist/objects/getters.js +2 -2
  137. package/dist/objects/inspect.js +3 -3
  138. package/dist/objects/mutate.js +1 -1
  139. package/dist/objects/predicates.js +4 -4
  140. package/dist/objects/sort.js +4 -4
  141. package/dist/packages/edit-class.js +1 -1
  142. package/dist/packages/edit.js +2 -2
  143. package/dist/packages/exports.js +6 -6
  144. package/dist/packages/licenses.js +8 -8
  145. package/dist/packages/manifest.js +3 -3
  146. package/dist/packages/normalize.js +4 -4
  147. package/dist/packages/operations.js +11 -11
  148. package/dist/packages/provenance.d.ts +6 -0
  149. package/dist/packages/provenance.js +12 -3
  150. package/dist/packages/specs.js +5 -5
  151. package/dist/packages/validation.js +3 -3
  152. package/dist/paths/_internal.js +3 -3
  153. package/dist/paths/conversion.js +4 -4
  154. package/dist/paths/normalize.js +3 -1
  155. package/dist/paths/packages.js +3 -3
  156. package/dist/paths/predicates.js +7 -7
  157. package/dist/paths/resolve.js +3 -3
  158. package/dist/process/spawn/_internal.js +3 -3
  159. package/dist/process/spawn/errors.js +2 -2
  160. package/dist/process/spawn/stdio.js +1 -1
  161. package/dist/promises/_internal.js +1 -1
  162. package/dist/promises/iterate.js +5 -5
  163. package/dist/promises/options.js +3 -3
  164. package/dist/promises/retry.js +1 -1
  165. package/dist/secrets/_internal.js +3 -2
  166. package/dist/secrets/keychain.js +5 -4
  167. package/dist/secrets/linux.js +6 -4
  168. package/dist/secrets/macos.js +5 -3
  169. package/dist/secrets/rc.js +9 -6
  170. package/dist/secrets/windows.js +7 -4
  171. package/dist/shell/parse.d.ts +108 -1
  172. package/dist/shell/parse.js +168 -2
  173. package/dist/smol/detect.js +1 -1
  174. package/dist/smol/http.js +1 -1
  175. package/dist/smol/https.js +1 -1
  176. package/dist/smol/manifest.js +1 -1
  177. package/dist/smol/path.js +1 -1
  178. package/dist/smol/primordial.js +1 -1
  179. package/dist/smol/purl.js +1 -1
  180. package/dist/smol/versions.js +1 -1
  181. package/dist/smol/vfs.js +1 -1
  182. package/dist/sorts/_internal.js +4 -4
  183. package/dist/sorts/natural.js +3 -3
  184. package/dist/sorts/semver.js +1 -1
  185. package/dist/sorts/strings.js +1 -1
  186. package/dist/spinner/default.js +1 -1
  187. package/dist/spinner/spinner.js +1 -1
  188. package/dist/ssri/convert.js +2 -2
  189. package/dist/ssri/parse.js +1 -1
  190. package/dist/ssri/validate.js +2 -2
  191. package/dist/stdio/prompts.js +1 -1
  192. package/dist/streams/parallel.js +2 -2
  193. package/dist/streams/transform.js +1 -1
  194. package/dist/strings/format.js +4 -4
  195. package/dist/strings/predicates.js +2 -2
  196. package/dist/strings/search.js +1 -1
  197. package/dist/strings/transform.js +3 -3
  198. package/dist/strings/width.js +2 -2
  199. package/dist/temporal/instant.js +4 -2
  200. package/dist/temporal/slots.js +3 -2
  201. package/dist/themes/context.js +2 -2
  202. package/dist/url/parse.js +2 -2
  203. package/dist/url/predicates.js +1 -1
  204. package/dist/url/search-params.js +6 -6
  205. package/dist/words/article.js +1 -1
  206. package/dist/words/capitalize.js +1 -1
  207. package/dist/words/pluralize.d.ts +24 -2
  208. package/dist/words/pluralize.js +37 -2
  209. package/dist/words/types.d.ts +25 -2
  210. package/package.json +44 -4
@@ -20,6 +20,7 @@ const require_paths_resolve = require('./resolve.js');
20
20
  * namespace preservation
21
21
  * - `msysDriveToNative` — `/c/path` → `C:/path` on Windows
22
22
  */
23
+ const DRIVE_LETTER_REGEXP = /^[A-Za-z]:$/;
23
24
  function msysDriveToNative(normalized) {
24
25
  /* c8 ignore start - Windows-only branch. */
25
26
  if (require_constants_platform.WIN32) return normalized.replace(require_paths__internal.msysDriveRegExp, (_, letter, sep) => `${letter.toUpperCase()}:${sep || "/"}`);
@@ -58,7 +59,7 @@ function msysDriveToNative(normalized) {
58
59
  * (HTTP requests, file uploads, URL parameters), you MUST validate for path traversal
59
60
  * attacks BEFORE calling this function.
60
61
  */
61
- /* @__NO_SIDE_EFFECTS__ */
62
+ /*@__NO_SIDE_EFFECTS__*/
62
63
  function normalizePath(pathLike) {
63
64
  const filepath = /* @__PURE__ */ require_paths__internal.pathLikeToString(pathLike);
64
65
  const { length } = filepath;
@@ -196,6 +197,7 @@ function normalizePath(pathLike) {
196
197
  }
197
198
  /* c8 ignore stop */
198
199
  if (collapsed.length === 0) return prefix || ".";
200
+ if (DRIVE_LETTER_REGEXP.test(collapsed) && (require_primordials_string.StringPrototypeCharCodeAt(filepath, 2) === 47 || require_primordials_string.StringPrototypeCharCodeAt(filepath, 2) === 92)) return msysDriveToNative(`${prefix}${collapsed}/`);
199
201
  return msysDriveToNative(prefix + collapsed);
200
202
  }
201
203
 
@@ -14,14 +14,14 @@ const require_node_path = require('../node/path.js');
14
14
  * POSIX and Windows-style separators so paths captured on either platform
15
15
  * classify the same regardless of the host we're running on.
16
16
  */
17
- /* @__NO_SIDE_EFFECTS__ */
17
+ /*@__NO_SIDE_EFFECTS__*/
18
18
  function isPackageJsonFile(filepath) {
19
19
  return filepath === "package.json" || require_primordials_string.StringPrototypeEndsWith(filepath, "/package.json") || require_primordials_string.StringPrototypeEndsWith(filepath, "\\package.json");
20
20
  }
21
21
  /**
22
22
  * Resolve directory path from a package.json file path.
23
23
  */
24
- /* @__NO_SIDE_EFFECTS__ */
24
+ /*@__NO_SIDE_EFFECTS__*/
25
25
  function resolvePackageJsonDirname(filepath) {
26
26
  if (/* @__PURE__ */ isPackageJsonFile(filepath)) return /* @__PURE__ */ require_paths_normalize.normalizePath((/* @__PURE__ */ require_node_path.getNodePath()).dirname(filepath));
27
27
  return /* @__PURE__ */ require_paths_normalize.normalizePath(filepath);
@@ -29,7 +29,7 @@ function resolvePackageJsonDirname(filepath) {
29
29
  /**
30
30
  * Resolve full path to package.json from a directory or file path.
31
31
  */
32
- /* @__NO_SIDE_EFFECTS__ */
32
+ /*@__NO_SIDE_EFFECTS__*/
33
33
  function resolvePackageJsonPath(filepath) {
34
34
  if (/* @__PURE__ */ isPackageJsonFile(filepath)) return /* @__PURE__ */ require_paths_normalize.normalizePath(filepath);
35
35
  return /* @__PURE__ */ require_paths_normalize.normalizePath((/* @__PURE__ */ require_node_path.getNodePath()).join(filepath, "package.json"));
@@ -34,7 +34,7 @@ const require_primordials_regexp = require('../primordials/regexp.js');
34
34
  *
35
35
  * @returns {boolean} `true` if absolute, `false` otherwise
36
36
  */
37
- /* @__NO_SIDE_EFFECTS__ */
37
+ /*@__NO_SIDE_EFFECTS__*/
38
38
  function isAbsolute(pathLike) {
39
39
  const filepath = /* @__PURE__ */ require_paths__internal.pathLikeToString(pathLike);
40
40
  const { length } = filepath;
@@ -64,7 +64,7 @@ function isAbsolute(pathLike) {
64
64
  *
65
65
  * @returns {boolean} `true` if the path contains `node_modules`
66
66
  */
67
- /* @__NO_SIDE_EFFECTS__ */
67
+ /*@__NO_SIDE_EFFECTS__*/
68
68
  function isNodeModules(pathLike) {
69
69
  return require_primordials_regexp.RegExpPrototypeTest(require_paths__internal.nodeModulesPathRegExp, /* @__PURE__ */ require_paths__internal.pathLikeToString(pathLike));
70
70
  }
@@ -87,7 +87,7 @@ function isNodeModules(pathLike) {
87
87
  *
88
88
  * @returns {boolean} `true` if the value is a valid file path
89
89
  */
90
- /* @__NO_SIDE_EFFECTS__ */
90
+ /*@__NO_SIDE_EFFECTS__*/
91
91
  function isPath(pathLike) {
92
92
  const filepath = /* @__PURE__ */ require_paths__internal.pathLikeToString(pathLike);
93
93
  if (typeof filepath !== "string" || filepath.length === 0) return false;
@@ -117,7 +117,7 @@ function isPath(pathLike) {
117
117
  *
118
118
  * @returns {boolean} `true` if separator
119
119
  */
120
- /* @__NO_SIDE_EFFECTS__ */
120
+ /*@__NO_SIDE_EFFECTS__*/
121
121
  function isPathSeparator(code) {
122
122
  return code === 47 || code === 92;
123
123
  }
@@ -137,7 +137,7 @@ function isPathSeparator(code) {
137
137
  *
138
138
  * @returns {boolean} `true` if the path is relative
139
139
  */
140
- /* @__NO_SIDE_EFFECTS__ */
140
+ /*@__NO_SIDE_EFFECTS__*/
141
141
  function isRelative(pathLike) {
142
142
  const filepath = /* @__PURE__ */ require_paths__internal.pathLikeToString(pathLike);
143
143
  /* c8 ignore start */
@@ -163,7 +163,7 @@ function isRelative(pathLike) {
163
163
  *
164
164
  * @returns {boolean} `true` if the path uses MSYS drive letter notation
165
165
  */
166
- /* @__NO_SIDE_EFFECTS__ */
166
+ /*@__NO_SIDE_EFFECTS__*/
167
167
  function isUnixPath(pathLike) {
168
168
  const filepath = /* @__PURE__ */ require_paths__internal.pathLikeToString(pathLike);
169
169
  return typeof filepath === "string" && require_primordials_regexp.RegExpPrototypeTest(require_paths__internal.msysDriveRegExp, filepath);
@@ -183,7 +183,7 @@ function isUnixPath(pathLike) {
183
183
  * @returns {boolean} `true` if valid drive-letter code
184
184
  */
185
185
  /* c8 ignore start - Only called from Windows-only branches. */
186
- /* @__NO_SIDE_EFFECTS__ */
186
+ /*@__NO_SIDE_EFFECTS__*/
187
187
  function isWindowsDeviceRoot(code) {
188
188
  return code >= 65 && code <= 90 || code >= 97 && code <= 122;
189
189
  }
@@ -38,7 +38,7 @@ const require_paths_normalize = require('./normalize.js');
38
38
  *
39
39
  * @returns {string} Relative path from `from` to `to`, or empty string if equal
40
40
  */
41
- /* @__NO_SIDE_EFFECTS__ */
41
+ /*@__NO_SIDE_EFFECTS__*/
42
42
  function relative(from, to) {
43
43
  if (from === to) return "";
44
44
  const actualFrom = /* @__PURE__ */ resolve(from);
@@ -106,7 +106,7 @@ function relative(from, to) {
106
106
  *
107
107
  * @returns {string} Normalized relative path, or empty string if equal
108
108
  */
109
- /* @__NO_SIDE_EFFECTS__ */
109
+ /*@__NO_SIDE_EFFECTS__*/
110
110
  function relativeResolve(from, to) {
111
111
  const rel = /* @__PURE__ */ relative(from, to);
112
112
  if (rel === "") return "";
@@ -131,7 +131,7 @@ function relativeResolve(from, to) {
131
131
  *
132
132
  * @returns {string} The resolved absolute path
133
133
  */
134
- /* @__NO_SIDE_EFFECTS__ */
134
+ /*@__NO_SIDE_EFFECTS__*/
135
135
  function resolve(...segments) {
136
136
  let resolvedPath = "";
137
137
  let resolvedAbsolute = false;
@@ -20,9 +20,9 @@ let _npmCliPromiseSpawn;
20
20
  * issues. Required because the upstream module uses CJS dynamic-require
21
21
  * patterns that Webpack flags.
22
22
  */
23
- /* @__NO_SIDE_EFFECTS__ */
23
+ /*@__NO_SIDE_EFFECTS__*/
24
24
  function getNpmCliPromiseSpawn() {
25
- if (_npmCliPromiseSpawn === void 0) _npmCliPromiseSpawn = /* @__PURE__ */ require("../../external/@npmcli/promise-spawn");
25
+ if (_npmCliPromiseSpawn === void 0) _npmCliPromiseSpawn = /*@__PURE__*/ require("../../external/@npmcli/promise-spawn");
26
26
  return _npmCliPromiseSpawn;
27
27
  }
28
28
  /**
@@ -33,7 +33,7 @@ function getNpmCliPromiseSpawn() {
33
33
  *
34
34
  * @returns {unknown} The modified result object
35
35
  */
36
- /* @__NO_SIDE_EFFECTS__ */
36
+ /*@__NO_SIDE_EFFECTS__*/
37
37
  function stripAnsiFromSpawnResult(result) {
38
38
  const res = result;
39
39
  const { stderr, stdout } = res;
@@ -34,7 +34,7 @@ let src_external_pony_cause = require("../../external/pony-cause");
34
34
  * }
35
35
  * ```
36
36
  */
37
- /* @__NO_SIDE_EFFECTS__ */
37
+ /*@__NO_SIDE_EFFECTS__*/
38
38
  function enhanceSpawnError(error) {
39
39
  if (error === null || typeof error !== "object") return error;
40
40
  if (!/* @__PURE__ */ isSpawnError(error)) return error;
@@ -109,7 +109,7 @@ function enhanceSpawnError(error) {
109
109
  *
110
110
  * @returns {boolean} `true` if the value has spawn error properties
111
111
  */
112
- /* @__NO_SIDE_EFFECTS__ */
112
+ /*@__NO_SIDE_EFFECTS__*/
113
113
  function isSpawnError(value) {
114
114
  if (value === null || typeof value !== "object") return false;
115
115
  const err = value;
@@ -39,7 +39,7 @@ const require_arrays_predicates = require('../../arrays/predicates.js');
39
39
  *
40
40
  * @returns {boolean} `true` if stdio matches the type or is valid
41
41
  */
42
- /* @__NO_SIDE_EFFECTS__ */
42
+ /*@__NO_SIDE_EFFECTS__*/
43
43
  function isStdioType(stdio, type) {
44
44
  if (arguments.length === 1) return typeof stdio === "string" && [
45
45
  "pipe",
@@ -24,7 +24,7 @@ const abortSignal = require_process_abort.getAbortSignal();
24
24
  *
25
25
  * @returns The Node.js timers/promises module
26
26
  */
27
- /* @__NO_SIDE_EFFECTS__ */
27
+ /*@__NO_SIDE_EFFECTS__*/
28
28
  function getTimers() {
29
29
  return require("node:timers/promises");
30
30
  }
@@ -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_promise = require('../primordials/promise.js');
4
5
  const require_promises_options = require('./options.js');
5
6
  const require_promises_retry = require('./retry.js');
6
- const require_primordials_promise = require('../primordials/promise.js');
7
7
  const require_arrays_chunk = require('../arrays/chunk.js');
8
8
 
9
9
  //#region src/promises/iterate.ts
@@ -67,7 +67,7 @@ const require_arrays_chunk = require('../arrays/chunk.js');
67
67
  *
68
68
  * @returns Promise that resolves when all items are processed
69
69
  */
70
- /* @__NO_SIDE_EFFECTS__ */
70
+ /*@__NO_SIDE_EFFECTS__*/
71
71
  async function pEach(array, callbackFn, options) {
72
72
  const { concurrency, retries, signal } = /* @__PURE__ */ require_promises_options.normalizeIterationOptions(options);
73
73
  const chunks = /* @__PURE__ */ require_arrays_chunk.arrayChunk(array, concurrency);
@@ -133,7 +133,7 @@ async function pEach(array, callbackFn, options) {
133
133
  *
134
134
  * @returns Promise that resolves when all chunks are processed
135
135
  */
136
- /* @__NO_SIDE_EFFECTS__ */
136
+ /*@__NO_SIDE_EFFECTS__*/
137
137
  async function pEachChunk(array, callbackFn, options) {
138
138
  const { chunkSize = 100, ...retryOpts } = options || {};
139
139
  const chunks = /* @__PURE__ */ require_arrays_chunk.arrayChunk(array, chunkSize);
@@ -194,7 +194,7 @@ async function pEachChunk(array, callbackFn, options) {
194
194
  *
195
195
  * @returns Promise resolving to filtered array
196
196
  */
197
- /* @__NO_SIDE_EFFECTS__ */
197
+ /*@__NO_SIDE_EFFECTS__*/
198
198
  async function pFilter(array, callbackFn, options) {
199
199
  const iterOpts = /* @__PURE__ */ require_promises_options.normalizeIterationOptions(options);
200
200
  return (await /* @__PURE__ */ pFilterChunk(/* @__PURE__ */ require_arrays_chunk.arrayChunk(array, iterOpts.concurrency), callbackFn, iterOpts.retries)).flat();
@@ -222,7 +222,7 @@ async function pFilter(array, callbackFn, options) {
222
222
  *
223
223
  * @returns Promise resolving to array of filtered chunks
224
224
  */
225
- /* @__NO_SIDE_EFFECTS__ */
225
+ /*@__NO_SIDE_EFFECTS__*/
226
226
  async function pFilterChunk(chunks, callbackFn, options) {
227
227
  const retryOpts = /* @__PURE__ */ require_promises_options.normalizeRetryOptions(options);
228
228
  const { signal } = retryOpts;
@@ -33,7 +33,7 @@ const require_promises__internal = require('./_internal.js');
33
33
  *
34
34
  * @returns Normalized options with concurrency, retries, and signal
35
35
  */
36
- /* @__NO_SIDE_EFFECTS__ */
36
+ /*@__NO_SIDE_EFFECTS__*/
37
37
  function normalizeIterationOptions(options) {
38
38
  const { concurrency = 1, retries, signal = require_promises__internal.abortSignal } = {
39
39
  __proto__: null,
@@ -70,7 +70,7 @@ function normalizeIterationOptions(options) {
70
70
  *
71
71
  * @returns Normalized retry options with all properties set
72
72
  */
73
- /* @__NO_SIDE_EFFECTS__ */
73
+ /*@__NO_SIDE_EFFECTS__*/
74
74
  function normalizeRetryOptions(options) {
75
75
  const { args = [], backoffFactor = 2, baseDelayMs = 200, jitter = true, maxDelayMs = 1e4, onRetry, onRetryCancelOnFalse = false, onRetryRethrow = false, retries = 0, signal = require_promises__internal.abortSignal } = /* @__PURE__ */ resolveRetryOptions(options);
76
76
  return {
@@ -105,7 +105,7 @@ function normalizeRetryOptions(options) {
105
105
  *
106
106
  * @returns Resolved retry options with defaults for basic properties
107
107
  */
108
- /* @__NO_SIDE_EFFECTS__ */
108
+ /*@__NO_SIDE_EFFECTS__*/
109
109
  function resolveRetryOptions(options) {
110
110
  const defaults = {
111
111
  __proto__: null,
@@ -110,7 +110,7 @@ const require_promises_options = require('./options.js');
110
110
  *
111
111
  * @throws {Error} The last error if all retry attempts fail
112
112
  */
113
- /* @__NO_SIDE_EFFECTS__ */
113
+ /*@__NO_SIDE_EFFECTS__*/
114
114
  async function pRetry(callbackFn, options) {
115
115
  const { args, backoffFactor, baseDelayMs, jitter, maxDelayMs, onRetry, onRetryCancelOnFalse, onRetryRethrow, retries, signal } = /* @__PURE__ */ require_promises_options.normalizeRetryOptions(options);
116
116
  if (signal?.aborted) return;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_primordials_map_set = require('../primordials/map-set.js');
4
5
 
5
6
  //#region src/secrets/_internal.ts
6
7
  /**
@@ -29,8 +30,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
29
30
  * undefined (entry missing), `undefined` is cached too — callers that want a
30
31
  * re-check after creating the entry must call `invalidate`.
31
32
  */
32
- const valueCache = /* @__PURE__ */ new Map();
33
- const inflight = /* @__PURE__ */ new Map();
33
+ const valueCache = new require_primordials_map_set.MapCtor();
34
+ const inflight = new require_primordials_map_set.MapCtor();
34
35
  function cacheKey(service, account) {
35
36
  return `${service} ${account}`;
36
37
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_primordials_error = require('../primordials/error.js');
4
5
  const require_secrets__internal = require('./_internal.js');
5
6
  const require_secrets_macos = require('./macos.js');
6
7
  const require_secrets_linux = require('./linux.js');
@@ -228,9 +229,9 @@ function readSecretSync({ service, account }) {
228
229
  * shouldn't show "rewrote N secrets" when nothing actually changed).
229
230
  */
230
231
  async function writeSecret({ service, account, value, label }) {
231
- if (!value || typeof value !== "string") throw new TypeError("writeSecret: value must be a non-empty string");
232
+ if (!value || typeof value !== "string") throw new require_primordials_error.TypeErrorCtor("writeSecret: value must be a non-empty string");
232
233
  const platform_ = detectPlatform();
233
- if (platform_ === "other") throw new Error(`Unsupported platform: ${(0, node_os.platform)()}. Secret storage requires macOS, Linux, or Windows.`);
234
+ if (platform_ === "other") throw new require_primordials_error.ErrorCtor(`Unsupported platform: ${(0, node_os.platform)()}. Secret storage requires macOS, Linux, or Windows.`);
234
235
  if (await readSecret({
235
236
  service,
236
237
  account
@@ -251,9 +252,9 @@ async function writeSecret({ service, account, value, label }) {
251
252
  return "written";
252
253
  }
253
254
  function writeSecretSync({ service, account, value, label }) {
254
- if (!value || typeof value !== "string") throw new TypeError("writeSecret: value must be a non-empty string");
255
+ if (!value || typeof value !== "string") throw new require_primordials_error.TypeErrorCtor("writeSecret: value must be a non-empty string");
255
256
  const platform_ = detectPlatform();
256
- if (platform_ === "other") throw new Error(`Unsupported platform: ${(0, node_os.platform)()}. Secret storage requires macOS, Linux, or Windows.`);
257
+ if (platform_ === "other") throw new require_primordials_error.ErrorCtor(`Unsupported platform: ${(0, node_os.platform)()}. Secret storage requires macOS, Linux, or Windows.`);
257
258
  if (readSecretSync({
258
259
  service,
259
260
  account
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_primordials_error = require('../primordials/error.js');
5
+ const require_primordials_promise = require('../primordials/promise.js');
4
6
  let node_child_process = require("node:child_process");
5
7
 
6
8
  //#region src/secrets/linux.ts
@@ -19,7 +21,7 @@ let node_child_process = require("node:child_process");
19
21
  */
20
22
  const SECRET_TOOL_BIN = "secret-tool";
21
23
  async function deleteLinux(service, account) {
22
- return new Promise((resolve) => {
24
+ return new require_primordials_promise.PromiseCtor((resolve) => {
23
25
  const child = (0, node_child_process.spawn)(SECRET_TOOL_BIN, [
24
26
  "clear",
25
27
  "service",
@@ -44,7 +46,7 @@ function isLinuxBackendAvailable() {
44
46
  return (0, node_child_process.spawnSync)(SECRET_TOOL_BIN, ["--version"], { stdio: "ignore" }).status === 0;
45
47
  }
46
48
  async function readLinux(service, account) {
47
- return new Promise((resolve) => {
49
+ return new require_primordials_promise.PromiseCtor((resolve) => {
48
50
  const child = (0, node_child_process.spawn)(SECRET_TOOL_BIN, [
49
51
  "lookup",
50
52
  "service",
@@ -90,7 +92,7 @@ function readLinuxSync(service, account) {
90
92
  return r.stdout.trim() || void 0;
91
93
  }
92
94
  async function writeLinux(service, account, value, label) {
93
- return new Promise((resolve, reject) => {
95
+ return new require_primordials_promise.PromiseCtor((resolve, reject) => {
94
96
  const child = (0, node_child_process.spawn)(SECRET_TOOL_BIN, [
95
97
  "store",
96
98
  `--label=${label}`,
@@ -136,7 +138,7 @@ function writeLinuxSync(service, account, value, label) {
136
138
  "pipe"
137
139
  ]
138
140
  });
139
- if (r.status !== 0) throw new Error(`secret-tool store failed (status=${r.status}, user=${account}): ${r.stderr.trim()}. Install libsecret-tools (apt install libsecret-tools / dnf install libsecret) or ensure a Secret Service provider (gnome-keyring, kwallet) is running.`);
141
+ if (r.status !== 0) throw new require_primordials_error.ErrorCtor(`secret-tool store failed (status=${r.status}, user=${account}): ${r.stderr.trim()}. Install libsecret-tools (apt install libsecret-tools / dnf install libsecret) or ensure a Secret Service provider (gnome-keyring, kwallet) is running.`);
140
142
  }
141
143
 
142
144
  //#endregion
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_primordials_error = require('../primordials/error.js');
5
+ const require_primordials_promise = require('../primordials/promise.js');
4
6
  let node_child_process = require("node:child_process");
5
7
 
6
8
  //#region src/secrets/macos.ts
@@ -78,7 +80,7 @@ function readMacOSSync(service, account) {
78
80
  return r.stdout.trim() || void 0;
79
81
  }
80
82
  function runAsync(args, opts = {}) {
81
- return new Promise((resolve) => {
83
+ return new require_primordials_promise.PromiseCtor((resolve) => {
82
84
  const child = (0, node_child_process.spawn)(SECURITY_BIN, args, { stdio: opts.stdio ?? [
83
85
  "ignore",
84
86
  "pipe",
@@ -128,7 +130,7 @@ async function writeMacOS(service, account, value, label) {
128
130
  "-l",
129
131
  label
130
132
  ]);
131
- if (r.status !== 0) throw new Error(`security(1) add-generic-password failed (status=${r.status}, account=${account}): ${r.stderr.trim()}`);
133
+ if (r.status !== 0) throw new require_primordials_error.ErrorCtor(`security(1) add-generic-password failed (status=${r.status}, account=${account}): ${r.stderr.trim()}`);
132
134
  }
133
135
  function writeMacOSSync(service, account, value, label) {
134
136
  const r = (0, node_child_process.spawnSync)(SECURITY_BIN, [
@@ -155,7 +157,7 @@ function writeMacOSSync(service, account, value, label) {
155
157
  "pipe"
156
158
  ]
157
159
  });
158
- if (r.status !== 0) throw new Error(`security(1) add-generic-password failed (status=${r.status}, account=${account}): ${r.stderr.trim()}`);
160
+ if (r.status !== 0) throw new require_primordials_error.ErrorCtor(`security(1) add-generic-password failed (status=${r.status}, account=${account}): ${r.stderr.trim()}`);
159
161
  }
160
162
 
161
163
  //#endregion
@@ -2,6 +2,9 @@
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_primordials_string = require('../primordials/string.js');
6
+ const require_primordials_regexp = require('../primordials/regexp.js');
7
+ const require_primordials_object = require('../primordials/object.js');
5
8
  const require_env_home = require('../env/home.js');
6
9
  let node_fs = require("node:fs");
7
10
  let node_path = require("node:path");
@@ -54,7 +57,7 @@ function buildBlock(opts) {
54
57
  const begin = `# BEGIN ${opts.service} env (managed)`;
55
58
  const end = `# END ${opts.service} env (managed)`;
56
59
  const noteLines = (opts.notes ?? []).map((line) => `# ${line}`);
57
- const exportLines = Object.entries(opts.exports).map(([name, value]) => `export ${name}=${shellSingleQuote(value)}`);
60
+ const exportLines = require_primordials_object.ObjectEntries(opts.exports).map(([name, value]) => `export ${name}=${shellSingleQuote(value)}`);
58
61
  const body = [...noteLines, ...exportLines].join("\n");
59
62
  return {
60
63
  begin,
@@ -79,7 +82,7 @@ function clear(service, legacySentinels = []) {
79
82
  const end = begin.replace(/\bBEGIN\b/, "END");
80
83
  const endStripped = end.replace(/\s*\(managed\)\s*$/, "");
81
84
  const endAlt = end === endStripped ? escapeRegExp(end) : `(?:${escapeRegExp(end)}|${escapeRegExp(endStripped)})`;
82
- const re = new RegExp(`\n*${escapeRegExp(begin)}[\\s\\S]*?${endAlt}\n?`, "g");
85
+ const re = new require_primordials_regexp.RegExpCtor(`\n*${escapeRegExp(begin)}[\\s\\S]*?${endAlt}\n?`, "g");
83
86
  const next = existing.replace(re, "\n");
84
87
  if (next !== existing) {
85
88
  removedAny = true;
@@ -96,7 +99,7 @@ function pickRcFile(shellOverride) {
96
99
  const home = /* @__PURE__ */ require_env_home.getHome();
97
100
  if (!home) return;
98
101
  const shellPath = node_process.default.env["SHELL"] ?? "";
99
- const shell = shellOverride ?? (shellPath.endsWith("zsh") ? "zsh" : shellPath.endsWith("bash") ? "bash" : shellPath.endsWith("fish") ? "fish" : void 0);
102
+ const shell = shellOverride ?? (require_primordials_string.StringPrototypeEndsWith(shellPath, "zsh") ? "zsh" : require_primordials_string.StringPrototypeEndsWith(shellPath, "bash") ? "bash" : require_primordials_string.StringPrototypeEndsWith(shellPath, "fish") ? "fish" : void 0);
100
103
  if (shell === "zsh") return node_path.default.join(home, ".zshenv");
101
104
  if (shell === "bash") {
102
105
  const bashrc = node_path.default.join(home, ".bashrc");
@@ -149,10 +152,10 @@ function write(opts) {
149
152
  const legacyEnd = legacyBegin.replace(/\bBEGIN\b/, "END");
150
153
  const legacyEndStripped = legacyEnd.replace(/\s*\(managed\)\s*$/, "");
151
154
  const endAlt = legacyEnd === legacyEndStripped ? escapeRegExp(legacyEnd) : `(?:${escapeRegExp(legacyEnd)}|${escapeRegExp(legacyEndStripped)})`;
152
- const legacyRe = new RegExp(`\n*${escapeRegExp(legacyBegin)}[\\s\\S]*?${endAlt}\n?`, "g");
155
+ const legacyRe = new require_primordials_regexp.RegExpCtor(`\n*${escapeRegExp(legacyBegin)}[\\s\\S]*?${endAlt}\n?`, "g");
153
156
  working = working.replace(legacyRe, "\n");
154
157
  }
155
- const match = new RegExp(`${escapeRegExp(begin)}[\\s\\S]*?${escapeRegExp(end)}`).exec(working);
158
+ const match = new require_primordials_regexp.RegExpCtor(`${escapeRegExp(begin)}[\\s\\S]*?${escapeRegExp(end)}`).exec(working);
156
159
  if (match) {
157
160
  if (match[0] === desiredBlock && working === onDisk) return {
158
161
  rcPath,
@@ -164,7 +167,7 @@ function write(opts) {
164
167
  outcome: "updated"
165
168
  };
166
169
  }
167
- const prefix = working.length > 0 && !working.endsWith("\n\n") ? working.endsWith("\n") ? "\n" : "\n\n" : "";
170
+ const prefix = working.length > 0 && !require_primordials_string.StringPrototypeEndsWith(working, "\n\n") ? require_primordials_string.StringPrototypeEndsWith(working, "\n") ? "\n" : "\n\n" : "";
168
171
  writeRcFile(rcPath, `${working}${prefix}${desiredBlock}\n`.replace(/\n{3,}/g, "\n\n"));
169
172
  return {
170
173
  rcPath,
@@ -2,6 +2,9 @@
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_primordials_error = require('../primordials/error.js');
6
+ const require_primordials_json = require('../primordials/json.js');
7
+ const require_primordials_promise = require('../primordials/promise.js');
5
8
  let node_fs = require("node:fs");
6
9
  let node_path = require("node:path");
7
10
  node_path = require_runtime.__toESM(node_path);
@@ -125,7 +128,7 @@ function readWindowsSync(service, account) {
125
128
  return readDpapiSync(getDpapiFilePath(service, account));
126
129
  }
127
130
  function runPsAsync(script, input) {
128
- return new Promise((resolve) => {
131
+ return new require_primordials_promise.PromiseCtor((resolve) => {
129
132
  const child = (0, node_child_process.spawn)(POWERSHELL_BIN, [
130
133
  "-NoProfile",
131
134
  "-Command",
@@ -189,7 +192,7 @@ function runPsSync(script, input) {
189
192
  * identifiers (e.g. `socket-cli`, `SOCKET_API_KEY`), not paths.
190
193
  */
191
194
  function validateKeychainComponent(value, name) {
192
- if (/[\\/]/.test(value) || value.includes("..") || value.includes("\0") || value === "" || value === ".") throw new Error(`secrets/windows: ${name} contains path-traversal characters: ${JSON.stringify(value)}. Use a plain identifier (no \\\\, /, .., or NUL).`);
195
+ if (/[\\/]/.test(value) || value.includes("..") || value.includes("\0") || value === "" || value === ".") throw new require_primordials_error.ErrorCtor(`secrets/windows: ${name} contains path-traversal characters: ${require_primordials_json.JSONStringify(value)}. Use a plain identifier (no \\\\, /, .., or NUL).`);
193
196
  }
194
197
  async function writeDpapi(filePath, value) {
195
198
  const dir = node_path.default.dirname(filePath);
@@ -201,7 +204,7 @@ async function writeDpapi(filePath, value) {
201
204
  $protected = [System.Security.Cryptography.ProtectedData]::Protect($bytes, $null, 'CurrentUser')
202
205
  [Convert]::ToBase64String($protected) | Set-Content -Path ${quotePs(filePath)} -NoNewline
203
206
  `, value);
204
- if (r.status !== 0) throw new Error(`DPAPI file write failed: ${r.stderr.trim()}. Install the CredentialManager PowerShell module (\`Install-Module CredentialManager -Scope CurrentUser\`) for a cleaner storage path.`);
207
+ if (r.status !== 0) throw new require_primordials_error.ErrorCtor(`DPAPI file write failed: ${r.stderr.trim()}. Install the CredentialManager PowerShell module (\`Install-Module CredentialManager -Scope CurrentUser\`) for a cleaner storage path.`);
205
208
  }
206
209
  function writeDpapiSync(filePath, value) {
207
210
  const dir = node_path.default.dirname(filePath);
@@ -213,7 +216,7 @@ function writeDpapiSync(filePath, value) {
213
216
  $protected = [System.Security.Cryptography.ProtectedData]::Protect($bytes, $null, 'CurrentUser')
214
217
  [Convert]::ToBase64String($protected) | Set-Content -Path ${quotePs(filePath)} -NoNewline
215
218
  `, value);
216
- if (r.status !== 0) throw new Error(`DPAPI file write failed: ${r.stderr.trim()}. Install the CredentialManager PowerShell module (\`Install-Module CredentialManager -Scope CurrentUser\`) for a cleaner storage path.`);
219
+ if (r.status !== 0) throw new require_primordials_error.ErrorCtor(`DPAPI file write failed: ${r.stderr.trim()}. Install the CredentialManager PowerShell module (\`Install-Module CredentialManager -Scope CurrentUser\`) for a cleaner storage path.`);
217
220
  }
218
221
  async function writeWindows(service, account, value, _label) {
219
222
  if ((await runPsAsync(`
@@ -8,10 +8,100 @@
8
8
  * against `env`; unresolved ones collapse to an empty string.
9
9
  */
10
10
  import type { ParseEntry } from '../external/shell-quote';
11
+ /**
12
+ * Visit each simple command in `cmd` in order. A "simple command" is the
13
+ * POSIX-grammar term for a run of bare-string tokens between shell
14
+ * control-operator boundaries (`&&`, `;`, `||`, `|`) — e.g. in `sudo apt && rm
15
+ * -rf /`, the two simple commands are `['sudo', 'apt']` and `['rm', '-rf',
16
+ * '/']`. Glob and comment tokens are ignored.
17
+ *
18
+ * The visitor receives each simple command's tokens as a `readonly string[]`;
19
+ * returning `true` short-circuits the walk so callers like `hasBinCall` /
20
+ * `findBinCall` can bail on the first match without finishing the parse.
21
+ *
22
+ * Public so consumers can write their own per-command matchers without
23
+ * re-parsing the command line. Used internally by `findBinCall` /
24
+ * `findBinCalls` / `hasBinCall`.
25
+ *
26
+ * Shell-quote is permissive (partial parses don't throw); the walk tolerates
27
+ * any shape it returns.
28
+ *
29
+ * @example
30
+ * eachSimpleCommand('sudo apt && rm -rf /', tokens => {
31
+ * console.log(tokens)
32
+ * // → ['sudo', 'apt']
33
+ * // → ['rm', '-rf', '/']
34
+ * })
35
+ *
36
+ * // Short-circuit on first match:
37
+ * eachSimpleCommand('a ; b ; c', tokens => {
38
+ * if (tokens[0] === 'b') {
39
+ * return true // stop the walk
40
+ * }
41
+ * })
42
+ */
43
+ export declare function eachSimpleCommand(cmd: string, visit: (tokens: readonly string[]) => boolean | void): void;
44
+ /**
45
+ * Walk a parsed shell command and return the args of the FIRST binary call
46
+ * whose leading tokens match `prefix` (e.g. `['sudo']`, `['gh', 'auth',
47
+ * 'refresh']`). Returns `undefined` when no call matches.
48
+ *
49
+ * Short-circuits on the first match — does NOT materialize every match. Use
50
+ * this when "did any call match, and what were its args?" is enough. For audit
51
+ * / counting use cases where every match matters, use `findBinCalls`.
52
+ *
53
+ * @example
54
+ * findBinCall('sudo apt update && sudo -k', ['sudo'])
55
+ * // → ['apt', 'update']
56
+ *
57
+ * findBinCall('echo "sudo foo"', ['sudo'])
58
+ * // → undefined
59
+ */
60
+ export declare function findBinCall(cmd: string, prefix: readonly string[]): readonly string[] | undefined;
61
+ /**
62
+ * Walk a parsed shell command and return the args of every binary call whose
63
+ * leading tokens match `prefix` (e.g. `['sudo']`, `['gh', 'auth', 'refresh']`).
64
+ * Returns an empty array when no call matches.
65
+ *
66
+ * Segments split at op tokens (`&&`, `;`, `||`, `|`) so each chained command is
67
+ * scanned independently. Each match's args are returned as a `string[]` slice
68
+ * positioned after the matched prefix — useful for caller-side `.some(...)`
69
+ * over flag/value pairs.
70
+ *
71
+ * The AST walk means embedded args (`echo "sudo foo"`), variable substitutions
72
+ * (`$gh`), and command substitution (`$(...)`) don't trip the matcher — only
73
+ * actual calls do.
74
+ *
75
+ * @example
76
+ * findBinCalls('sudo apt update && sudo -k', ['sudo'])
77
+ * // → [['apt', 'update'], ['-k']]
78
+ *
79
+ * findBinCalls('gh auth refresh -s workflow', ['gh', 'auth', 'refresh'])
80
+ * // → [['-s', 'workflow']]
81
+ *
82
+ * findBinCalls('echo "sudo foo"', ['sudo'])
83
+ * // → []
84
+ */
85
+ export declare function findBinCalls(cmd: string, prefix: readonly string[]): readonly string[][];
86
+ /**
87
+ * Convenience: does `cmd` contain at least one binary call matching the
88
+ * leading-tokens `prefix`? The most common audit-pattern shape.
89
+ *
90
+ * Short-circuits on the first match — walks the parsed entries once and returns
91
+ * `true` as soon as a simple command matches. No intermediate match list or
92
+ * args slices are allocated.
93
+ *
94
+ * @example
95
+ * hasBinCall('echo hi && sudo rm', ['sudo']) // → true
96
+ * hasBinCall('echo "sudo foo"', ['sudo']) // → false
97
+ * hasBinCall('gh auth refresh -s workflow', ['gh', 'auth', 'refresh']) // → true
98
+ */
99
+ export declare function hasBinCall(cmd: string, prefix: readonly string[]): boolean;
11
100
  export type { ParseEntry, ShellComment, ShellGlob, ShellOp, } from '../external/shell-quote';
12
101
  /**
13
102
  * Tokenize `cmd` into `ParseEntry` items, preserving operators and comments.
14
- * Throws on unterminated quotes.
103
+ * `shell-quote` is permissive — an unterminated quote does not throw; the
104
+ * parser drops the opening quote and returns the rest as plain tokens.
15
105
  *
16
106
  * @example
17
107
  * parseShell('git commit -m "hello world"')
@@ -24,3 +114,20 @@ export type { ParseEntry, ShellComment, ShellGlob, ShellOp, } from '../external/
24
114
  * // → ['echo', '/root']
25
115
  */
26
116
  export declare function parseShell(cmd: string, env?: Record<string, string> | ((key: string) => string | undefined) | undefined): ParseEntry[];
117
+ /**
118
+ * Does the simple command represented by `tokens` start with `prefix`? The
119
+ * natural companion to `eachSimpleCommand` — the visitor callback uses this to
120
+ * test whether a simple command is a call to a specific binary or command-line
121
+ * prefix.
122
+ *
123
+ * @example
124
+ * simpleCommandStartsWith(['sudo', 'apt', 'update'], ['sudo'])
125
+ * // → true
126
+ *
127
+ * simpleCommandStartsWith(
128
+ * ['gh', 'auth', 'status'],
129
+ * ['gh', 'auth', 'refresh'],
130
+ * )
131
+ * // → false
132
+ */
133
+ export declare function simpleCommandStartsWith(tokens: readonly string[], prefix: readonly string[]): boolean;