@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
@@ -6,15 +6,16 @@
6
6
  * credential for it is resolvable; otherwise the resolver walks a
7
7
  * cross-engine equivalence ladder (Claude → Codex → an open-weight provider
8
8
  * via opencode) and returns the best available equivalent. Why gate on
9
- * existence: a fleet machine may have Claude but no Codex, or Codex but an
10
- * expired Claude key, or neither plus an opencode/synthetic seat. Hard-coding
11
- * `fable` then fails at spawn time; routing here degrades gracefully and
12
- * tells the caller WHY (the `reason`), so a skill can log "fell back to codex
13
- * gpt-5.5 (claude unavailable)" instead of crashing. Pure given an
14
- * availability/keyed context — no I/O — so callers fan out their `which` +
15
- * credential probes once and pass the result in. Pairs with `buildArgs` in
16
- * `spawn.mts`: a Fable candidate carries `effort: undefined` because Fable is
17
- * adaptive-thinking-only and the spawn layer omits `--effort` for it anyway.
9
+ * existence: a Socket dev machine may have Claude but no Codex, or Codex but
10
+ * an expired Claude key, or neither plus an opencode/synthetic seat.
11
+ * Hard-coding `fable` then fails at spawn time; routing here degrades
12
+ * gracefully and tells the caller WHY (the `reason`), so a skill can log
13
+ * "fell back to codex gpt-5.5 (claude unavailable)" instead of crashing. Pure
14
+ * given an availability/keyed context — no I/O — so callers fan out their
15
+ * `which` + credential probes once and pass the result in. Pairs with
16
+ * `buildArgs` in `spawn.mts`: a Fable candidate carries `effort: undefined`
17
+ * because Fable is adaptive-thinking-only and the spawn layer omits
18
+ * `--effort` for it anyway.
18
19
  */
19
20
  import type { CredentialProvider } from './credentials.mts';
20
21
  import type { AiAgentName, AiEffort } from './types.mts';
@@ -32,15 +33,16 @@ export interface TierCandidate {
32
33
  }
33
34
  /**
34
35
  * Why the resolver returned what it did. - `preferred` — the tier's
35
- * first-choice engine was available + keyed. - `fellback` — the preferred
36
- * engine was missing/unkeyed; an equivalent on another engine was used (`from`
37
- * names the original tier).
36
+ * first-choice engine was available + keyed. - `fell-over` — the preferred
37
+ * engine was missing/unkeyed; an equivalent on another engine was used
38
+ * (`requestedTier` names the tier originally asked for). Matches the
39
+ * `fellOver` vocabulary `spawnTierWithFallback` (spawn.mts) reports.
38
40
  */
39
- export type TierResolveReason = 'fellback' | 'preferred';
41
+ export type TierResolveReason = 'fell-over' | 'preferred';
40
42
  export interface TierResolution {
41
43
  readonly candidate: TierCandidate;
42
44
  readonly reason: TierResolveReason;
43
- readonly from?: AiTier | undefined;
45
+ readonly requestedTier?: AiTier | undefined;
44
46
  }
45
47
  /**
46
48
  * The context a caller probes once and passes in: which engine CLIs exist, and
@@ -62,8 +64,20 @@ export declare function isCandidateUsable(candidate: TierCandidate, ctx: RouteCo
62
64
  * Resolve a tier to the best available concrete target. Prefers the tier's
63
65
  * first-choice (Claude) candidate; if its engine is missing or unkeyed, walks
64
66
  * the cross-engine equivalence ladder and returns the first usable equivalent,
65
- * tagging the result `fellback` with the original tier in `from`. Returns
66
- * `undefined` only when NOTHING in the chain is usable — the caller then skips
67
- * the work or surfaces a "no AI engine available" message.
67
+ * tagging the result `fell-over` with the original tier in `requestedTier`.
68
+ * Returns `undefined` only when NOTHING in the chain is usable — the caller
69
+ * then skips the work or surfaces a "no AI engine available" message.
68
70
  */
69
71
  export declare function resolveTier(tier: AiTier, ctx: RouteContext): TierResolution | undefined;
72
+ /**
73
+ * The ORDERED list of usable candidates for a tier — the runtime-fallback
74
+ * sequence. `resolveTier` returns only the single best pick (good when you
75
+ * trust it will work); this returns every usable candidate in preference order
76
+ * so a caller can advance to the next when one fails AT RUNTIME — e.g. the
77
+ * preferred model is installed + keyed (so it passes `isCandidateUsable`) yet
78
+ * its CLI reports it offline at spawn ("Claude Fable 5 is currently
79
+ * unavailable"). The static check can't predict an outage; only the spawn
80
+ * result can, so the caller walks this list until a spawn returns without the
81
+ * `unavailable` flag. Empty when nothing in the chain is usable.
82
+ */
83
+ export declare function usableTierCandidates(tier: AiTier, ctx: RouteContext): TierCandidate[];
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
  ]
@@ -131,9 +132,9 @@ function isCandidateUsable(candidate, ctx) {
131
132
  * Resolve a tier to the best available concrete target. Prefers the tier's
132
133
  * first-choice (Claude) candidate; if its engine is missing or unkeyed, walks
133
134
  * the cross-engine equivalence ladder and returns the first usable equivalent,
134
- * tagging the result `fellback` with the original tier in `from`. Returns
135
- * `undefined` only when NOTHING in the chain is usable — the caller then skips
136
- * the work or surfaces a "no AI engine available" message.
135
+ * tagging the result `fell-over` with the original tier in `requestedTier`.
136
+ * Returns `undefined` only when NOTHING in the chain is usable — the caller
137
+ * then skips the work or surfaces a "no AI engine available" message.
137
138
  */
138
139
  function resolveTier(tier, ctx) {
139
140
  const chain = TIER_CHAINS[tier] ?? TIER_CHAINS.sonnet;
@@ -144,13 +145,28 @@ function resolveTier(tier, ctx) {
144
145
  reason: "preferred"
145
146
  } : {
146
147
  candidate,
147
- from: tier,
148
- reason: "fellback"
148
+ requestedTier: tier,
149
+ reason: "fell-over"
149
150
  };
150
151
  }
151
152
  }
153
+ /**
154
+ * The ORDERED list of usable candidates for a tier — the runtime-fallback
155
+ * sequence. `resolveTier` returns only the single best pick (good when you
156
+ * trust it will work); this returns every usable candidate in preference order
157
+ * so a caller can advance to the next when one fails AT RUNTIME — e.g. the
158
+ * preferred model is installed + keyed (so it passes `isCandidateUsable`) yet
159
+ * its CLI reports it offline at spawn ("Claude Fable 5 is currently
160
+ * unavailable"). The static check can't predict an outage; only the spawn
161
+ * result can, so the caller walks this list until a spawn returns without the
162
+ * `unavailable` flag. Empty when nothing in the chain is usable.
163
+ */
164
+ function usableTierCandidates(tier, ctx) {
165
+ return (TIER_CHAINS[tier] ?? TIER_CHAINS.sonnet).filter((c) => isCandidateUsable(c, ctx));
166
+ }
152
167
 
153
168
  //#endregion
154
169
  exports.TIER_CHAINS = TIER_CHAINS;
155
170
  exports.isCandidateUsable = isCandidateUsable;
156
- exports.resolveTier = resolveTier;
171
+ exports.resolveTier = resolveTier;
172
+ exports.usableTierCandidates = usableTierCandidates;
@@ -5,12 +5,14 @@
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.
12
12
  * backoff (5s / 15s / 45s). Each retry is a fresh subprocess.
13
13
  */
14
+ import type { RouteContext, TierCandidate } from './route.mts';
15
+ import type { AiTier } from './tier.mts';
14
16
  import type { AgentSpawnResult, AiAgentName, SpawnAiAgentOptions } from './types.mts';
15
17
  export declare function backoffFor(attempt: number): number;
16
18
  /**
@@ -31,7 +33,9 @@ export declare function buildArgs(agent: AiAgentName, options: SpawnAiAgentOptio
31
33
  * shapes (`fable`, `claude-fable-5`, `mythos`, `claude-mythos-5`).
32
34
  */
33
35
  export declare function isAdaptiveOnlyModel(model: string): boolean;
36
+ export declare function isModelUnavailable(stdout: string, stderr: string): boolean;
34
37
  export declare function isOverloaded(stdout: string, stderr: string): boolean;
38
+ export declare function isQuotaExhausted(stdout: string, stderr: string): boolean;
35
39
  export declare function pickAgent(requested: AiAgentName | undefined, cwd: string): Promise<AiAgentName>;
36
40
  /**
37
41
  * Spawn an AI agent CLI subprocess with the locked-down flag set.
@@ -55,3 +59,32 @@ export declare function pickAgent(requested: AiAgentName | undefined, cwd: strin
55
59
  * is requested, when none of the known agents are on PATH).
56
60
  */
57
61
  export declare function spawnAiAgent(options: SpawnAiAgentOptions): Promise<AgentSpawnResult>;
62
+ /**
63
+ * Result of a tier spawn that may have fallen over one or more offline models.
64
+ * `result` is the spawn that actually ran (the first whose model was not
65
+ * `unavailable`, or the last attempt if every candidate was down). `candidate`
66
+ * is the engine/model that produced it. `fellOver` lists the candidates that
67
+ * reported their model offline before this one — empty on a first-try success.
68
+ */
69
+ export interface TierSpawnResult {
70
+ readonly candidate: TierCandidate;
71
+ readonly fellOver: readonly TierCandidate[];
72
+ readonly result: AgentSpawnResult;
73
+ }
74
+ /**
75
+ * Spawn a tier's work, automatically FALLING OVER to the next agent when a
76
+ * model is offline. Walks the tier's usable candidates (Claude → Codex →
77
+ * open-weight) in order; if a spawn comes back with `unavailable` (the model is
78
+ * down or gated — e.g. "Claude Fable 5 is currently unavailable"), it advances
79
+ * to the next candidate instead of failing. This is the runtime complement to
80
+ * `route.mts`'s static availability check: that check can't predict an outage,
81
+ * so the live spawn result drives the fallback.
82
+ *
83
+ * Returns the first non-`unavailable` spawn (success OR a genuine work failure
84
+ * on a model that WAS reachable — a real failure shouldn't silently retry on a
85
+ * weaker model). If every candidate is offline, returns the last attempt with
86
+ * its `unavailable` flag set, so the caller can report "all models down".
87
+ * Throws only when the tier has no usable candidate at all (nothing installed +
88
+ * keyed) — same contract as `resolveTier` returning undefined.
89
+ */
90
+ export declare function spawnTierWithFallback(tier: AiTier, ctx: RouteContext, options: Omit<SpawnAiAgentOptions, 'agent' | 'effort' | 'model'>): Promise<TierSpawnResult>;
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');
@@ -9,6 +10,9 @@ const require_process_spawn_errors = require('../process/spawn/errors.js');
9
10
  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');
13
+ const require_ai_route = require('./route.js');
14
+ let node_process = require("node:process");
15
+ node_process = require_runtime.__toESM(node_process, 1);
12
16
 
13
17
  //#region src/ai/spawn.mts
14
18
  /**
@@ -18,7 +22,7 @@ const require_primordials_promise = require('../primordials/promise.js');
18
22
  * permissionMode / no-session-persistence). The helper enforces this at the
19
23
  * type level (`SpawnAiAgentOptions` requires the relevant fields) AND at the
20
24
  * spawn site (per-agent flag translator). Why CLI subprocess instead of an
21
- * 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
22
26
  * invoking the CLI — same auth config, same model availability, same tool
23
27
  * permissions. SDK calls would diverge on auth handling and force per-agent
24
28
  * SDK installs. Retry: 3 attempts on overload (HTTP 529 / "Overloaded"), exp.
@@ -113,10 +117,64 @@ function buildArgs(agent, options) {
113
117
  function isAdaptiveOnlyModel(model) {
114
118
  return /\b(?:fable|mythos)\b/i.test(model) || /claude-(?:fable|mythos)/i.test(model);
115
119
  }
120
+ const MODEL_UNAVAILABLE_PHRASES = [
121
+ "access denied",
122
+ "currently unavailable",
123
+ "forbidden",
124
+ "have access",
125
+ "is unavailable",
126
+ "isn’t available",
127
+ "isn't available",
128
+ "may not exist",
129
+ "no access to",
130
+ "no such model",
131
+ "not authorized",
132
+ "not authorised",
133
+ "not available",
134
+ "permission denied",
135
+ "permission_denied",
136
+ "temporarily unavailable",
137
+ "unauthorized",
138
+ "unauthorised"
139
+ ];
140
+ const MODEL_EXISTENCE_PHRASES = [
141
+ "does not exist",
142
+ "doesn't exist",
143
+ "no such",
144
+ "not exist",
145
+ "not found",
146
+ "unavailable",
147
+ "unknown",
148
+ "unreachable"
149
+ ];
150
+ function isModelUnavailable(stdout, stderr) {
151
+ const text = `${stdout}\n${stderr}`.toLowerCase();
152
+ for (let i = 0, { length } = MODEL_UNAVAILABLE_PHRASES; i < length; i += 1) if (text.includes(MODEL_UNAVAILABLE_PHRASES[i])) return true;
153
+ if (/\bmodel[_-]?not[_-]?found\b/i.test(text) || /\bapi error:\s*(?:403|404)\b/i.test(text)) return true;
154
+ if (text.includes("model")) {
155
+ for (let i = 0, { length } = MODEL_EXISTENCE_PHRASES; i < length; i += 1) if (text.includes(MODEL_EXISTENCE_PHRASES[i])) return true;
156
+ }
157
+ return false;
158
+ }
116
159
  function isOverloaded(stdout, stderr) {
117
160
  const re = /API Error: 529|Overloaded/i;
118
161
  return re.test(stdout) || re.test(stderr);
119
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
+ }
120
178
  async function pickAgent(requested, cwd) {
121
179
  const discovered = await require_ai_discover.discoverAiAgents({ repoRoot: cwd });
122
180
  if (requested) {
@@ -172,6 +230,10 @@ async function spawnAiAgent(options) {
172
230
  try {
173
231
  const child = require_process_spawn_child.spawn(agent, args, {
174
232
  cwd: options.cwd,
233
+ ...options.env ? { env: {
234
+ ...node_process.default.env,
235
+ ...options.env
236
+ } } : {},
175
237
  stdio: "pipe",
176
238
  stdioString: true,
177
239
  timeout: options.timeoutMs
@@ -200,7 +262,54 @@ async function spawnAiAgent(options) {
200
262
  exitCode,
201
263
  overloaded: isOverloaded(stdout, stderr),
202
264
  stderr,
203
- stdout
265
+ stdout,
266
+ unavailable: isModelUnavailable(stdout, stderr)
267
+ };
268
+ }
269
+ /**
270
+ * Spawn a tier's work, automatically FALLING OVER to the next agent when a
271
+ * model is offline. Walks the tier's usable candidates (Claude → Codex →
272
+ * open-weight) in order; if a spawn comes back with `unavailable` (the model is
273
+ * down or gated — e.g. "Claude Fable 5 is currently unavailable"), it advances
274
+ * to the next candidate instead of failing. This is the runtime complement to
275
+ * `route.mts`'s static availability check: that check can't predict an outage,
276
+ * so the live spawn result drives the fallback.
277
+ *
278
+ * Returns the first non-`unavailable` spawn (success OR a genuine work failure
279
+ * on a model that WAS reachable — a real failure shouldn't silently retry on a
280
+ * weaker model). If every candidate is offline, returns the last attempt with
281
+ * its `unavailable` flag set, so the caller can report "all models down".
282
+ * Throws only when the tier has no usable candidate at all (nothing installed +
283
+ * keyed) — same contract as `resolveTier` returning undefined.
284
+ */
285
+ async function spawnTierWithFallback(tier, ctx, options) {
286
+ const candidates = require_ai_route.usableTierCandidates(tier, ctx);
287
+ if (candidates.length === 0) throw new require_primordials_error.ErrorCtor(`spawnTierWithFallback: no usable agent for tier "${tier}". No candidate engine is both installed and keyed (checked: ${candidates.length}). Install/authenticate one of the tier's engines, or pick a different tier.`);
288
+ const fellOver = [];
289
+ let last;
290
+ for (let i = 0, { length } = candidates; i < length; i += 1) {
291
+ const candidate = candidates[i];
292
+ const result = await spawnAiAgent({
293
+ ...options,
294
+ agent: candidate.engine,
295
+ effort: candidate.effort,
296
+ model: candidate.model
297
+ });
298
+ last = {
299
+ candidate,
300
+ result
301
+ };
302
+ if (!result.unavailable && !isQuotaExhausted(result.stdout, result.stderr)) return {
303
+ candidate,
304
+ fellOver,
305
+ result
306
+ };
307
+ fellOver.push(candidate);
308
+ }
309
+ return {
310
+ candidate: last.candidate,
311
+ fellOver: fellOver.slice(0, -1),
312
+ result: last.result
204
313
  };
205
314
  }
206
315
 
@@ -208,6 +317,9 @@ async function spawnAiAgent(options) {
208
317
  exports.backoffFor = backoffFor;
209
318
  exports.buildArgs = buildArgs;
210
319
  exports.isAdaptiveOnlyModel = isAdaptiveOnlyModel;
320
+ exports.isModelUnavailable = isModelUnavailable;
211
321
  exports.isOverloaded = isOverloaded;
322
+ exports.isQuotaExhausted = isQuotaExhausted;
212
323
  exports.pickAgent = pickAgent;
213
- exports.spawnAiAgent = spawnAiAgent;
324
+ exports.spawnAiAgent = spawnAiAgent;
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
  *
@@ -56,6 +56,16 @@ export interface AgentSpawnResult {
56
56
  readonly overloaded: boolean;
57
57
  readonly stderr: string;
58
58
  readonly stdout: string;
59
+ /**
60
+ * True when the selected MODEL could not serve the request — it is offline
61
+ * (e.g. "Claude Fable 5 is currently unavailable") or gated/absent for this
62
+ * account ("issue with the selected model … may not exist or you may not have
63
+ * access"). Distinct from `overloaded`: the model is not coming back within a
64
+ * retry window, so the right response is to FALL OVER to the next agent in
65
+ * the tier chain rather than retry the same one. Both surface as a non-zero
66
+ * `exitCode`; this flag is how a caller knows to route elsewhere.
67
+ */
68
+ readonly unavailable: boolean;
59
69
  }
60
70
  /**
61
71
  * Inputs to a single agent spawn.
@@ -93,6 +103,13 @@ export interface SpawnAiAgentOptions {
93
103
  * claude-specific — other agents ignore it.
94
104
  */
95
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;
96
113
  /**
97
114
  * Override the agent's flag list (rare; for one-off advanced cases).
98
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