@socketsecurity/lib 6.0.9 → 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 (335) hide show
  1. package/CHANGELOG.md +6 -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 +10 -9
  26. package/dist/ai/route.js +14 -13
  27. package/dist/ai/spawn.d.mts +2 -1
  28. package/dist/ai/spawn.js +25 -2
  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 +9 -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 +446 -300
  40. package/dist/bin/shadow.js +2 -1
  41. package/dist/bin/which.d.ts +28 -3
  42. package/dist/bin/which.js +45 -3
  43. package/dist/cacache/_internal.d.ts +10 -2
  44. package/dist/cacache/_internal.js +6 -10
  45. package/dist/cache/ttl/_internal.d.ts +33 -0
  46. package/dist/cache/ttl/_internal.js +68 -0
  47. package/dist/cache/ttl/browser.d.ts +56 -0
  48. package/dist/cache/ttl/browser.js +257 -0
  49. package/dist/cache/ttl/store.js +10 -33
  50. package/dist/cache/ttl/types.d.ts +46 -3
  51. package/dist/checks/primordials-defaults.d.ts +5 -5
  52. package/dist/checks/primordials-defaults.js +5 -5
  53. package/dist/checks/primordials.d.ts +1 -1
  54. package/dist/checks/primordials.js +25 -17
  55. package/dist/cli/check-primordials.d.ts +6 -1
  56. package/dist/cli/check-primordials.js +14 -5
  57. package/dist/cli/check.js +1 -1
  58. package/dist/cli/socket-lib.d.ts +1 -1
  59. package/dist/cli/socket-lib.js +3 -3
  60. package/dist/colors/socket-palette.d.ts +1 -1
  61. package/dist/compression/brotli.d.ts +6 -2
  62. package/dist/compression/brotli.js +4 -0
  63. package/dist/compression/gzip.d.ts +6 -2
  64. package/dist/compression/gzip.js +6 -1
  65. package/dist/config/layers.d.ts +4 -4
  66. package/dist/config/layers.js +4 -4
  67. package/dist/constants/agents.d.ts +3 -0
  68. package/dist/constants/agents.js +3 -0
  69. package/dist/constants/node.d.ts +14 -0
  70. package/dist/constants/node.js +14 -0
  71. package/dist/constants/package-default-node-range.js +1 -5
  72. package/dist/constants/packages.d.ts +5 -0
  73. package/dist/constants/packages.js +5 -0
  74. package/dist/constants/platform.d.ts +1 -1
  75. package/dist/constants/platform.js +1 -1
  76. package/dist/constants/socket.js +1 -1
  77. package/dist/constants/typescript.d.ts +5 -0
  78. package/dist/constants/typescript.js +5 -0
  79. package/dist/debug/_internal.d.ts +22 -7
  80. package/dist/debug/_internal.js +33 -15
  81. package/dist/debug/namespace.js +11 -8
  82. package/dist/debug/output.d.ts +12 -1
  83. package/dist/debug/output.js +33 -16
  84. package/dist/dlx/binary-resolution.js +7 -4
  85. package/dist/eco/npm/npm/parse-lockfile.js +2 -1
  86. package/dist/eco/npm/vlt/exec.d.ts +1 -1
  87. package/dist/eco/npm/vlt/exec.js +1 -1
  88. package/dist/env/agents.d.ts +6 -0
  89. package/dist/env/agents.js +29 -0
  90. package/dist/env/flags.d.ts +12 -0
  91. package/dist/env/flags.js +23 -0
  92. package/dist/env/github-status.js +2 -2
  93. package/dist/env/providers.d.ts +6 -0
  94. package/dist/env/providers.js +23 -0
  95. package/dist/env/proxy.js +1 -1
  96. package/dist/env/rewire.d.ts +32 -0
  97. package/dist/env/rewire.js +55 -23
  98. package/dist/env/runtimes.d.ts +9 -0
  99. package/dist/env/runtimes.js +53 -0
  100. package/dist/env/socket-cli.d.ts +5 -2
  101. package/dist/env/socket-cli.js +6 -3
  102. package/dist/errors/predicates.d.ts +3 -2
  103. package/dist/errors/predicates.js +5 -3
  104. package/dist/errors/stack.js +2 -1
  105. package/dist/events/exit/_internal.d.ts +1 -23
  106. package/dist/external/@npmcli/package-json.js +179 -88
  107. package/dist/external/@npmcli/promise-spawn.js +2 -2
  108. package/dist/external/@sinclair/typebox/value.js +5 -4
  109. package/dist/external/@socketregistry/yocto-spinner.js +3 -3
  110. package/dist/external/adm-zip.d.ts +82 -0
  111. package/dist/external/adm-zip.js +2 -2
  112. package/dist/external/cacache.d.ts +87 -0
  113. package/dist/external/debug.d.ts +22 -0
  114. package/dist/external/debug.js +11 -4
  115. package/dist/external/del.d.ts +1 -0
  116. package/dist/external/external-pack.d.ts +12 -0
  117. package/dist/external/external-pack.js +41 -34
  118. package/dist/external/fast-glob.d.ts +8 -0
  119. package/dist/external/fast-sort.d.ts +1 -0
  120. package/dist/external/get-east-asian-width.d.ts +5 -0
  121. package/dist/external/get-east-asian-width.js +8 -1
  122. package/dist/external/has-flag.d.ts +1 -0
  123. package/dist/external/inquirer-pack.d.ts +18 -0
  124. package/dist/external/libnpmexec.d.ts +35 -0
  125. package/dist/external/libnpmpack.d.ts +1 -0
  126. package/dist/external/make-fetch-happen.d.ts +13 -0
  127. package/dist/external/normalize-package-data.d.ts +4 -0
  128. package/dist/external/npm-core.d.ts +14 -0
  129. package/dist/external/npm-pack.d.ts +24 -0
  130. package/dist/external/npm-pack.js +1551 -1867
  131. package/dist/external/npm-package-arg.d.ts +4 -0
  132. package/dist/external/p-map.js +8 -1
  133. package/dist/external/pacote.d.ts +15 -0
  134. package/dist/external/pico-pack.d.ts +16 -0
  135. package/dist/external/pico-pack.js +38 -23
  136. package/dist/external/picomatch.d.ts +96 -0
  137. package/dist/external/pony-cause.d.ts +14 -0
  138. package/dist/external/semver.d.ts +60 -0
  139. package/dist/external/semver.js +1459 -4
  140. package/dist/external/shell-quote.d.ts +51 -0
  141. package/dist/external/shell-quote.js +55 -15
  142. package/dist/external/signal-exit.d.ts +1 -0
  143. package/dist/external/spdx-correct.d.ts +4 -0
  144. package/dist/external/spdx-expression-parse.d.ts +4 -0
  145. package/dist/external/spdx-pack.d.ts +10 -0
  146. package/dist/external/std-env.d.ts +284 -0
  147. package/dist/external/std-env.js +323 -0
  148. package/dist/external/streaming-iterables.d.ts +11 -0
  149. package/dist/external/supports-color.d.ts +1 -0
  150. package/dist/external/tar-fs.d.ts +31 -0
  151. package/dist/external/validate-npm-package-name.d.ts +4 -0
  152. package/dist/external/which.d.ts +25 -0
  153. package/dist/external/which.js +2 -2
  154. package/dist/external/yargs-parser.d.ts +2 -0
  155. package/dist/external/yargs-parser.js +11 -3
  156. package/dist/external/yoctocolors-cjs.d.ts +51 -0
  157. package/dist/external-tools/bazel/asset-names.d.ts +1 -1
  158. package/dist/external-tools/bazel/from-download.d.ts +1 -1
  159. package/dist/external-tools/bazel/resolve.d.ts +3 -0
  160. package/dist/external-tools/bazel/resolve.js +3 -0
  161. package/dist/external-tools/cdxgen/asset-names.d.ts +5 -5
  162. package/dist/external-tools/cdxgen/asset-names.js +3 -3
  163. package/dist/external-tools/cdxgen/from-download.d.ts +2 -2
  164. package/dist/external-tools/cdxgen/from-download.js +1 -1
  165. package/dist/external-tools/cdxgen/resolve.d.ts +4 -1
  166. package/dist/external-tools/cdxgen/resolve.js +4 -1
  167. package/dist/external-tools/cdxgen/types.d.ts +1 -1
  168. package/dist/external-tools/from-download.d.ts +2 -2
  169. package/dist/external-tools/from-download.js +1 -1
  170. package/dist/external-tools/janus/asset-names.d.ts +4 -1
  171. package/dist/external-tools/janus/asset-names.js +3 -0
  172. package/dist/external-tools/janus/from-download.d.ts +3 -3
  173. package/dist/external-tools/janus/from-download.js +2 -2
  174. package/dist/external-tools/janus/resolve.d.ts +3 -0
  175. package/dist/external-tools/janus/resolve.js +3 -0
  176. package/dist/external-tools/jre/asset-names.d.ts +3 -1
  177. package/dist/external-tools/jre/asset-names.js +2 -0
  178. package/dist/external-tools/jre/from-download.d.ts +1 -1
  179. package/dist/external-tools/manifest.d.ts +5 -3
  180. package/dist/external-tools/manifest.js +4 -2
  181. package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
  182. package/dist/external-tools/opengrep/resolve.d.ts +3 -0
  183. package/dist/external-tools/opengrep/resolve.js +3 -0
  184. package/dist/external-tools/python/asset-names.d.ts +3 -1
  185. package/dist/external-tools/python/asset-names.js +7 -3
  186. package/dist/external-tools/python/pin.js +3 -1
  187. package/dist/external-tools/python/resolve.d.ts +3 -0
  188. package/dist/external-tools/python/resolve.js +3 -0
  189. package/dist/external-tools/sbt/resolve.d.ts +3 -0
  190. package/dist/external-tools/sbt/resolve.js +3 -0
  191. package/dist/external-tools/skillspector/from-uv.d.ts +1 -1
  192. package/dist/external-tools/synp/resolve.d.ts +3 -0
  193. package/dist/external-tools/synp/resolve.js +3 -0
  194. package/dist/external-tools/trivy/asset-names.d.ts +1 -1
  195. package/dist/external-tools/trivy/resolve.d.ts +3 -0
  196. package/dist/external-tools/trivy/resolve.js +3 -0
  197. package/dist/external-tools/trufflehog/asset-names.d.ts +4 -1
  198. package/dist/external-tools/trufflehog/asset-names.js +3 -0
  199. package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
  200. package/dist/external-tools/trufflehog/resolve.d.ts +3 -0
  201. package/dist/external-tools/trufflehog/resolve.js +3 -0
  202. package/dist/external-tools/uv/asset-names.d.ts +1 -1
  203. package/dist/external-tools/uv/resolve.d.ts +3 -0
  204. package/dist/external-tools/uv/resolve.js +3 -0
  205. package/dist/fleet/repo-config.d.ts +8 -6
  206. package/dist/fleet/repo-config.js +8 -6
  207. package/dist/fs/_internal.d.ts +1 -1
  208. package/dist/fs/_internal.js +1 -1
  209. package/dist/fs/access.d.ts +2 -0
  210. package/dist/fs/access.js +2 -0
  211. package/dist/fs/allowed-dirs-cache.js +5 -3
  212. package/dist/fs/find.js +1 -2
  213. package/dist/fs/inspect.d.ts +2 -2
  214. package/dist/fs/read-file.js +3 -4
  215. package/dist/fs/safe.js +1 -1
  216. package/dist/git/_internal.js +5 -1
  217. package/dist/github/commit.d.ts +92 -0
  218. package/dist/github/commit.js +113 -0
  219. package/dist/github/ghsa.js +1 -1
  220. package/dist/github/refs-graphql.js +1 -1
  221. package/dist/github/request.js +1 -1
  222. package/dist/github/token.d.ts +5 -2
  223. package/dist/github/token.js +6 -4
  224. package/dist/github/workflow-runs.d.ts +107 -0
  225. package/dist/github/workflow-runs.js +98 -0
  226. package/dist/http-request/_internal.d.ts +1 -1
  227. package/dist/http-request/browser.d.ts +6 -0
  228. package/dist/http-request/browser.js +3 -2
  229. package/dist/http-request/download.js +2 -0
  230. package/dist/http-request/headers.d.ts +1 -1
  231. package/dist/http-request/headers.js +1 -1
  232. package/dist/http-request/request-attempt.js +6 -3
  233. package/dist/http-request/request-types.d.ts +10 -1
  234. package/dist/http-request/request.js +2 -2
  235. package/dist/http-request/user-agent.d.ts +23 -2
  236. package/dist/http-request/user-agent.js +48 -6
  237. package/dist/integrity.d.ts +3 -1
  238. package/dist/integrity.js +3 -1
  239. package/dist/json/format.js +4 -1
  240. package/dist/logger/_internal.d.ts +13 -15
  241. package/dist/logger/_internal.js +21 -21
  242. package/dist/logger/colors.d.ts +9 -3
  243. package/dist/logger/colors.js +6 -13
  244. package/dist/logger/console-methods.js +2 -2
  245. package/dist/logger/console.d.ts +1 -0
  246. package/dist/logger/console.js +9 -9
  247. package/dist/logger/node.js +2 -1
  248. package/dist/native-messaging/install.js +1 -1
  249. package/dist/native-messaging/rate-limit.d.ts +4 -1
  250. package/dist/native-messaging/rate-limit.js +4 -1
  251. package/dist/node/events.d.ts +3 -0
  252. package/dist/node/events.js +3 -0
  253. package/dist/node/fs.d.ts +1 -1
  254. package/dist/node/timers-promises.d.ts +3 -0
  255. package/dist/node/timers-promises.js +3 -0
  256. package/dist/node/url.d.ts +3 -0
  257. package/dist/node/url.js +3 -0
  258. package/dist/npm/meta-cache.d.ts +183 -0
  259. package/dist/npm/meta-cache.js +318 -0
  260. package/dist/npm/meta-slice.d.ts +27 -0
  261. package/dist/npm/meta-slice.js +68 -0
  262. package/dist/npm/meta-types.d.ts +282 -0
  263. package/dist/npm/meta-types.js +2 -0
  264. package/dist/npm/meta.d.ts +125 -0
  265. package/dist/npm/meta.js +347 -0
  266. package/dist/npm/registry.d.ts +212 -0
  267. package/dist/npm/registry.js +284 -0
  268. package/dist/objects/getters.d.ts +1 -1
  269. package/dist/objects/getters.js +1 -1
  270. package/dist/packages/manifest.js +6 -7
  271. package/dist/packages/metadata-extensions.js +2 -4
  272. package/dist/packages/provenance.d.ts +8 -0
  273. package/dist/packages/provenance.js +8 -0
  274. package/dist/packages/tarball.js +1 -2
  275. package/dist/packages/validation.d.ts +0 -10
  276. package/dist/packages/validation.js +0 -14
  277. package/dist/paths/exts.d.ts +30 -0
  278. package/dist/paths/exts.js +30 -0
  279. package/dist/paths/filenames.d.ts +6 -0
  280. package/dist/paths/filenames.js +6 -0
  281. package/dist/paths/globs.d.ts +6 -0
  282. package/dist/paths/globs.js +6 -0
  283. package/dist/paths/resolve.js +19 -14
  284. package/dist/paths/socket.d.ts +8 -8
  285. package/dist/paths/socket.js +8 -8
  286. package/dist/perf/report.js +4 -2
  287. package/dist/pkg-ext/data.js +0 -2
  288. package/dist/primordials/globals.d.ts +1 -1
  289. package/dist/primordials/globals.js +1 -1
  290. package/dist/primordials/headers.d.ts +13 -1
  291. package/dist/primordials/headers.js +13 -1
  292. package/dist/primordials/process.d.ts +1 -1
  293. package/dist/primordials/process.js +1 -1
  294. package/dist/primordials/url.d.ts +18 -0
  295. package/dist/primordials/url.js +18 -0
  296. package/dist/process/spawn/child.js +3 -5
  297. package/dist/promises/_internal.d.ts +1 -1
  298. package/dist/promises/_internal.js +1 -2
  299. package/dist/promises/options.js +3 -3
  300. package/dist/releases/socket-btm-binary-naming.js +12 -1
  301. package/dist/secrets/_internal.d.ts +1 -1
  302. package/dist/secrets/_internal.js +1 -1
  303. package/dist/secrets/find.d.ts +2 -2
  304. package/dist/secrets/find.js +2 -2
  305. package/dist/secrets/keychain.d.ts +10 -1
  306. package/dist/secrets/keychain.js +10 -1
  307. package/dist/secrets/socket-api-token.d.ts +1 -1
  308. package/dist/secrets/socket-api-token.js +1 -1
  309. package/dist/secrets/types.d.ts +1 -1
  310. package/dist/smol/http.d.ts +2 -0
  311. package/dist/smol/http.js +2 -0
  312. package/dist/smol/https.d.ts +2 -0
  313. package/dist/smol/https.js +2 -0
  314. package/dist/sorts/_internal.d.ts +2 -3
  315. package/dist/sorts/_internal.js +1 -3
  316. package/dist/spinner/format.js +2 -4
  317. package/dist/stdio/footer.js +8 -7
  318. package/dist/stdio/prompts.d.ts +8 -15
  319. package/dist/stdio/prompts.js +18 -29
  320. package/dist/strings/predicates.d.ts +2 -2
  321. package/dist/strings/search.js +1 -1
  322. package/dist/strings/types.d.ts +4 -0
  323. package/dist/strings/width.d.ts +1 -0
  324. package/dist/strings/width.js +17 -8
  325. package/dist/themes/context.d.ts +13 -0
  326. package/dist/themes/context.js +23 -8
  327. package/dist/versions/_internal.d.ts +43 -13
  328. package/dist/versions/_internal.js +27 -15
  329. package/dist/versions/compare.d.ts +16 -10
  330. package/dist/versions/compare.js +36 -16
  331. package/dist/versions/parse.js +1 -1
  332. package/dist/versions/range.js +3 -2
  333. package/dist/words/pluralize.js +4 -1
  334. package/llms.txt +63 -750
  335. package/package.json +200 -35
package/dist/ai/route.js CHANGED
@@ -12,15 +12,16 @@ const require_ai_tier = require('./tier.js');
12
12
  * credential for it is resolvable; otherwise the resolver walks a
13
13
  * cross-engine equivalence ladder (Claude → Codex → an open-weight provider
14
14
  * via opencode) and returns the best available equivalent. Why gate on
15
- * existence: a fleet machine may have Claude but no Codex, or Codex but an
16
- * expired Claude key, or neither plus an opencode/synthetic seat. Hard-coding
17
- * `fable` then fails at spawn time; routing here degrades gracefully and
18
- * tells the caller WHY (the `reason`), so a skill can log "fell back to codex
19
- * gpt-5.5 (claude unavailable)" instead of crashing. Pure given an
20
- * availability/keyed context — no I/O — so callers fan out their `which` +
21
- * credential probes once and pass the result in. Pairs with `buildArgs` in
22
- * `spawn.mts`: a Fable candidate carries `effort: undefined` because Fable is
23
- * adaptive-thinking-only and the spawn layer omits `--effort` for it anyway.
15
+ * existence: a Socket dev machine may have Claude but no Codex, or Codex but
16
+ * an expired Claude key, or neither plus an opencode/synthetic seat.
17
+ * Hard-coding `fable` then fails at spawn time; routing here degrades
18
+ * gracefully and tells the caller WHY (the `reason`), so a skill can log
19
+ * "fell back to codex gpt-5.5 (claude unavailable)" instead of crashing. Pure
20
+ * given an availability/keyed context — no I/O — so callers fan out their
21
+ * `which` + credential probes once and pass the result in. Pairs with
22
+ * `buildArgs` in `spawn.mts`: a Fable candidate carries `effort: undefined`
23
+ * because Fable is adaptive-thinking-only and the spawn layer omits
24
+ * `--effort` for it anyway.
24
25
  */
25
26
  /**
26
27
  * Per-tier preference chain, most-preferred-first. The head is the "perfect"
@@ -54,7 +55,7 @@ const TIER_CHAINS = {
54
55
  {
55
56
  effort: "xhigh",
56
57
  engine: "opencode",
57
- model: "fireworks-ai/accounts/fireworks/models/glm-5p1",
58
+ model: "fireworks-ai/accounts/fireworks/models/glm-5p2",
58
59
  provider: "fireworks"
59
60
  }
60
61
  ],
@@ -74,7 +75,7 @@ const TIER_CHAINS = {
74
75
  {
75
76
  effort: "high",
76
77
  engine: "opencode",
77
- model: "fireworks-ai/accounts/fireworks/models/glm-5p1",
78
+ model: "fireworks-ai/accounts/fireworks/models/glm-5p2",
78
79
  provider: "fireworks"
79
80
  }
80
81
  ],
@@ -94,7 +95,7 @@ const TIER_CHAINS = {
94
95
  {
95
96
  effort: "medium",
96
97
  engine: "opencode",
97
- model: "synthetic/hf:moonshotai/Kimi-K2.5",
98
+ model: "synthetic/hf:moonshotai/Kimi-K2.6",
98
99
  provider: "synthetic"
99
100
  }
100
101
  ],
@@ -114,7 +115,7 @@ const TIER_CHAINS = {
114
115
  {
115
116
  effort: "low",
116
117
  engine: "opencode",
117
- model: "synthetic/hf:moonshotai/Kimi-K2.5",
118
+ model: "synthetic/hf:moonshotai/Kimi-K2.6",
118
119
  provider: "synthetic"
119
120
  }
120
121
  ]
@@ -5,7 +5,7 @@
5
5
  * permissionMode / no-session-persistence). The helper enforces this at the
6
6
  * type level (`SpawnAiAgentOptions` requires the relevant fields) AND at the
7
7
  * spawn site (per-agent flag translator). Why CLI subprocess instead of an
8
- * SDK call: the fleet's contract matches what the local user sees when
8
+ * SDK call: Socket's contract matches what the local user sees when
9
9
  * invoking the CLI — same auth config, same model availability, same tool
10
10
  * permissions. SDK calls would diverge on auth handling and force per-agent
11
11
  * SDK installs. Retry: 3 attempts on overload (HTTP 529 / "Overloaded"), exp.
@@ -35,6 +35,7 @@ export declare function buildArgs(agent: AiAgentName, options: SpawnAiAgentOptio
35
35
  export declare function isAdaptiveOnlyModel(model: string): boolean;
36
36
  export declare function isModelUnavailable(stdout: string, stderr: string): boolean;
37
37
  export declare function isOverloaded(stdout: string, stderr: string): boolean;
38
+ export declare function isQuotaExhausted(stdout: string, stderr: string): boolean;
38
39
  export declare function pickAgent(requested: AiAgentName | undefined, cwd: string): Promise<AiAgentName>;
39
40
  /**
40
41
  * Spawn an AI agent CLI subprocess with the locked-down flag set.
package/dist/ai/spawn.js CHANGED
@@ -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_runtime = require('../_virtual/_rolldown/runtime.js');
4
5
  const require_primordials_error = require('../primordials/error.js');
5
6
  const require_primordials_object = require('../primordials/object.js');
6
7
  const require_primordials_date = require('../primordials/date.js');
@@ -10,6 +11,8 @@ const require_process_spawn_child = require('../process/spawn/child.js');
10
11
  const require_ai_discover = require('./discover.js');
11
12
  const require_primordials_promise = require('../primordials/promise.js');
12
13
  const require_ai_route = require('./route.js');
14
+ let node_process = require("node:process");
15
+ node_process = require_runtime.__toESM(node_process, 1);
13
16
 
14
17
  //#region src/ai/spawn.mts
15
18
  /**
@@ -19,7 +22,7 @@ const require_ai_route = require('./route.js');
19
22
  * permissionMode / no-session-persistence). The helper enforces this at the
20
23
  * type level (`SpawnAiAgentOptions` requires the relevant fields) AND at the
21
24
  * spawn site (per-agent flag translator). Why CLI subprocess instead of an
22
- * SDK call: the fleet's contract matches what the local user sees when
25
+ * SDK call: Socket's contract matches what the local user sees when
23
26
  * invoking the CLI — same auth config, same model availability, same tool
24
27
  * permissions. SDK calls would diverge on auth handling and force per-agent
25
28
  * SDK installs. Retry: 3 attempts on overload (HTTP 529 / "Overloaded"), exp.
@@ -157,6 +160,21 @@ function isOverloaded(stdout, stderr) {
157
160
  const re = /API Error: 529|Overloaded/i;
158
161
  return re.test(stdout) || re.test(stderr);
159
162
  }
163
+ const QUOTA_EXHAUSTED_PHRASES = [
164
+ "exceeded your current quota",
165
+ "insufficient_quota",
166
+ "quota exceeded",
167
+ "rate limit",
168
+ "rate-limited",
169
+ "rate_limit_error",
170
+ "usage limit"
171
+ ];
172
+ function isQuotaExhausted(stdout, stderr) {
173
+ const text = `${stdout}\n${stderr}`.toLowerCase();
174
+ if (/\bapi error:\s*429\b/.test(text) || text.includes("429 too many requests")) return true;
175
+ for (let i = 0, { length } = QUOTA_EXHAUSTED_PHRASES; i < length; i += 1) if (text.includes(QUOTA_EXHAUSTED_PHRASES[i])) return true;
176
+ return false;
177
+ }
160
178
  async function pickAgent(requested, cwd) {
161
179
  const discovered = await require_ai_discover.discoverAiAgents({ repoRoot: cwd });
162
180
  if (requested) {
@@ -212,6 +230,10 @@ async function spawnAiAgent(options) {
212
230
  try {
213
231
  const child = require_process_spawn_child.spawn(agent, args, {
214
232
  cwd: options.cwd,
233
+ ...options.env ? { env: {
234
+ ...node_process.default.env,
235
+ ...options.env
236
+ } } : {},
215
237
  stdio: "pipe",
216
238
  stdioString: true,
217
239
  timeout: options.timeoutMs
@@ -277,7 +299,7 @@ async function spawnTierWithFallback(tier, ctx, options) {
277
299
  candidate,
278
300
  result
279
301
  };
280
- if (!result.unavailable) return {
302
+ if (!result.unavailable && !isQuotaExhausted(result.stdout, result.stderr)) return {
281
303
  candidate,
282
304
  fellOver,
283
305
  result
@@ -297,6 +319,7 @@ exports.buildArgs = buildArgs;
297
319
  exports.isAdaptiveOnlyModel = isAdaptiveOnlyModel;
298
320
  exports.isModelUnavailable = isModelUnavailable;
299
321
  exports.isOverloaded = isOverloaded;
322
+ exports.isQuotaExhausted = isQuotaExhausted;
300
323
  exports.pickAgent = pickAgent;
301
324
  exports.spawnAiAgent = spawnAiAgent;
302
325
  exports.spawnTierWithFallback = spawnTierWithFallback;
@@ -44,5 +44,7 @@ export declare const SUBAGENT_STATUSES: readonly SubagentStatus[];
44
44
  export declare function escalationFor(status: SubagentStatus): SubagentEscalation;
45
45
  /**
46
46
  * True when `value` names a status in the contract.
47
+ *
48
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
47
49
  */
48
50
  export declare function isSubagentStatus(value: string): value is SubagentStatus;
@@ -46,6 +46,8 @@ function escalationFor(status) {
46
46
  }
47
47
  /**
48
48
  * True when `value` names a status in the contract.
49
+ *
50
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
49
51
  */
50
52
  function isSubagentStatus(value) {
51
53
  return SUBAGENT_STATUSES.includes(value);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file Canonical model + reasoning-effort ladder for AI orchestrators. The
3
- * fleet's AI-fix / AI-codify orchestrators pick a capability TIER per unit of
3
+ * Socket AI-fix / AI-codify orchestrators pick a capability TIER per unit of
4
4
  * work (a lint rule, a hook, a doc edit) and resolve it to a concrete `{
5
5
  * model, effort }` pair. Before this module each orchestrator redefined the
6
6
  * same three-row table, so a model-generation bump (Sonnet 4.6 → 5.0, Opus
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file Shared types for the locked-down AI agent surface. The fleet runs
2
+ * @file Shared types for the locked-down AI agent surface. Socket runs
3
3
  * Claude / Codex / OpenCode / Gemini through CLI subprocesses, never via SDK
4
4
  * calls. These types model the cross- agent contract: a permission mode, a
5
5
  * tool allowlist, a tool denylist, a prompt, a working directory. Per-agent
@@ -13,7 +13,7 @@
13
13
  */
14
14
  export type AiAgentName = 'claude' | 'codex' | 'gemini' | 'opencode';
15
15
  /**
16
- * Permission mode passed to the agent's CLI. The fleet rule (CLAUDE.md
16
+ * Permission mode passed to the agent's CLI. Socket's rule (CLAUDE.md
17
17
  * "Programmatic Claude calls") requires every headless call to set one of these
18
18
  * explicitly — never the agent's default.
19
19
  *
@@ -103,6 +103,13 @@ export interface SpawnAiAgentOptions {
103
103
  * claude-specific — other agents ignore it.
104
104
  */
105
105
  readonly effort?: AiEffort | undefined;
106
+ /**
107
+ * Extra environment variables for the spawned agent process, merged over the
108
+ * inherited env. Gated off by default (inherit-only when absent). Used by
109
+ * egress-containment callers to inject `HTTP_PROXY` / `NODE_OPTIONS`; no
110
+ * effect when omitted.
111
+ */
112
+ readonly env?: Readonly<Record<string, string>> | undefined;
106
113
  /**
107
114
  * Override the agent's flag list (rare; for one-off advanced cases).
108
115
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file Run AI agents in parallel, each in its own git worktree, and merge
3
- * results back to the base branch. The fleet's CLAUDE.md "Parallel Claude
3
+ * results back to the base branch. Socket's CLAUDE.md "Parallel Claude
4
4
  * sessions" rule mandates worktree isolation when multiple agents touch the
5
5
  * same checkout. This helper enforces that contract: each item gets a fresh
6
6
  * worktree branched from the base, the per-item function runs inside it, then
@@ -17,7 +17,7 @@ node_path = require_runtime.__toESM(node_path, 1);
17
17
  //#region src/ai/worktree.mts
18
18
  /**
19
19
  * @file Run AI agents in parallel, each in its own git worktree, and merge
20
- * results back to the base branch. The fleet's CLAUDE.md "Parallel Claude
20
+ * results back to the base branch. Socket's CLAUDE.md "Parallel Claude
21
21
  * sessions" rule mandates worktree isolation when multiple agents touch the
22
22
  * same checkout. This helper enforces that contract: each item gets a fresh
23
23
  * worktree branched from the base, the per-item function runs inside it, then
@@ -152,7 +152,8 @@ async function spawnAiAgentsInWorktrees(items, fn, options) {
152
152
  cursor += 1;
153
153
  if (idx >= items.length) return;
154
154
  const item = items[idx];
155
- settled[idx] = await runOne(item, idx, `${namePrefix}-${idx}-${require_primordials_date.DateNow()}`, node_path.default.join(worktreeRoot, `${namePrefix}-${idx}`), baseRepo, branch, cleanup, fn);
155
+ const result = await runOne(item, idx, `${namePrefix}-${idx}-${require_primordials_date.DateNow()}`, node_path.default.join(worktreeRoot, `${namePrefix}-${idx}`), baseRepo, branch, cleanup, fn);
156
+ settled[idx] = result;
156
157
  }
157
158
  }
158
159
  await require_primordials_promise.PromiseAll(require_primordials_array.ArrayFrom({ length: concurrency }, () => worker()));
@@ -61,6 +61,8 @@ export interface ParsedArgs<T = Record<string, unknown>> {
61
61
  }
62
62
  /**
63
63
  * Common parseArgs configuration for Socket registry scripts.
64
+ *
65
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
64
66
  */
65
67
  export declare const commonParseArgsConfig: ParseArgsConfig;
66
68
  /**
@@ -18,6 +18,8 @@ src_external_yargs_parser = require_runtime.__toESM(src_external_yargs_parser);
18
18
  */
19
19
  /**
20
20
  * Common parseArgs configuration for Socket registry scripts.
21
+ *
22
+ * @unused No internal or Socket consumers (exercised only by its unit tests).
21
23
  */
22
24
  const commonParseArgsConfig = {
23
25
  options: {
@@ -2,7 +2,7 @@
2
2
  * @file Private internals for `bin/*` modules — lazy `fs` / `path` accessors
3
3
  * and the binary-resolution caches. Underscore prefix keeps this file out of
4
4
  * the public exports map (see the `dist/<dir>/_<file>` ignore in
5
- * scripts/post-build/make-package-exports.mts). Two caches:
5
+ * scripts/fleet/make-package-exports.mts). Two caches:
6
6
  *
7
7
  * 1. `binPathCache` — maps a binary name to its first resolved path. Validated
8
8
  * with `existsSync` before reuse so a stale cache doesn't survive a tool
@@ -10,7 +10,7 @@ const require_node_path = require('../node/path.js');
10
10
  * @file Private internals for `bin/*` modules — lazy `fs` / `path` accessors
11
11
  * and the binary-resolution caches. Underscore prefix keeps this file out of
12
12
  * the public exports map (see the `dist/<dir>/_<file>` ignore in
13
- * scripts/post-build/make-package-exports.mts). Two caches:
13
+ * scripts/fleet/make-package-exports.mts). Two caches:
14
14
  *
15
15
  * 1. `binPathCache` — maps a binary name to its first resolved path. Validated
16
16
  * with `existsSync` before reuse so a stale cache doesn't survive a tool