@socketsecurity/lib 6.0.6 → 6.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (619) hide show
  1. package/CHANGELOG.md +46 -1
  2. package/README.md +1 -1
  3. package/dist/ai/agent-context.d.mts +103 -0
  4. package/dist/ai/agent-context.js +157 -0
  5. package/dist/ai/backends.d.mts +83 -0
  6. package/dist/ai/backends.js +173 -0
  7. package/dist/ai/credentials.d.mts +49 -0
  8. package/dist/ai/credentials.js +82 -0
  9. package/dist/ai/discover.d.mts +6 -2
  10. package/dist/ai/discover.js +4 -3
  11. package/dist/ai/exec.d.mts +52 -0
  12. package/dist/ai/exec.js +92 -0
  13. package/dist/ai/http.d.mts +132 -0
  14. package/dist/ai/http.js +130 -0
  15. package/dist/ai/profiles.d.mts +41 -6
  16. package/dist/ai/profiles.js +52 -10
  17. package/dist/ai/route.d.mts +69 -0
  18. package/dist/ai/route.js +156 -0
  19. package/dist/ai/spawn.d.mts +10 -2
  20. package/dist/ai/spawn.js +56 -31
  21. package/dist/ai/subagent-status.d.mts +48 -0
  22. package/dist/ai/subagent-status.js +57 -0
  23. package/dist/ai/tier.d.mts +60 -0
  24. package/dist/ai/tier.js +53 -0
  25. package/dist/ai/types.d.mts +31 -6
  26. package/dist/ai/worktree.d.mts +6 -6
  27. package/dist/ai/worktree.js +5 -1
  28. package/dist/ansi/strip.d.ts +1 -1
  29. package/dist/ansi/strip.js +0 -2
  30. package/dist/archives/_internal.js +7 -9
  31. package/dist/archives/extract.js +1 -1
  32. package/dist/archives/tar.js +7 -7
  33. package/dist/archives/zip.js +5 -7
  34. package/dist/argv/flag-predicates.d.ts +12 -12
  35. package/dist/argv/flag-predicates.js +17 -17
  36. package/dist/argv/flag-types.d.ts +18 -18
  37. package/dist/argv/flag-types.js +4 -4
  38. package/dist/argv/parse.d.ts +20 -3
  39. package/dist/argv/parse.js +1 -1
  40. package/dist/arrays/_internal.js +11 -12
  41. package/dist/arrays/chunk.js +0 -1
  42. package/dist/arrays/join.d.ts +37 -3
  43. package/dist/arrays/join.js +47 -7
  44. package/dist/arrays/unique.js +0 -1
  45. package/dist/bin/_internal.d.ts +1 -1
  46. package/dist/bin/_internal.js +1 -1
  47. package/dist/bin/exec.js +2 -3
  48. package/dist/bin/find.js +17 -17
  49. package/dist/bin/prim.cjs +36175 -35861
  50. package/dist/bin/resolve.js +13 -14
  51. package/dist/bin/which.js +8 -8
  52. package/dist/cache/ttl/store.js +6 -6
  53. package/dist/checks/primordials-defaults.d.ts +3 -3
  54. package/dist/checks/primordials-defaults.js +3 -3
  55. package/dist/checks/primordials.js +4 -3
  56. package/dist/{bin → cli}/check-primordials.d.ts +18 -13
  57. package/dist/{bin → cli}/check-primordials.js +58 -55
  58. package/dist/{bin → cli}/check.js +3 -3
  59. package/dist/{bin → cli}/socket-lib.d.ts +1 -1
  60. package/dist/{bin → cli}/socket-lib.js +4 -4
  61. package/dist/colors/socket-palette.js +7 -9
  62. package/dist/compression/_internal.d.ts +12 -12
  63. package/dist/compression/_internal.js +18 -18
  64. package/dist/compression/brotli.d.ts +26 -27
  65. package/dist/compression/brotli.js +39 -35
  66. package/dist/compression/gzip.d.ts +23 -23
  67. package/dist/compression/gzip.js +46 -42
  68. package/dist/constants/agents.d.ts +3 -1
  69. package/dist/constants/agents.js +15 -11
  70. package/dist/constants/licenses.js +3 -3
  71. package/dist/constants/node.d.ts +23 -0
  72. package/dist/constants/node.js +47 -15
  73. package/dist/constants/packages.d.ts +3 -0
  74. package/dist/constants/packages.js +24 -29
  75. package/dist/constants/platform.d.ts +30 -3
  76. package/dist/constants/platform.js +72 -12
  77. package/dist/constants/runtime.d.ts +22 -0
  78. package/dist/constants/runtime.js +32 -0
  79. package/dist/constants/socket.d.ts +2 -6
  80. package/dist/constants/socket.js +12 -14
  81. package/dist/cover/code.js +10 -10
  82. package/dist/cover/formatters.js +5 -5
  83. package/dist/crypto/hash.d.ts +30 -2
  84. package/dist/crypto/hash.js +47 -13
  85. package/dist/debug/_internal.js +4 -6
  86. package/dist/debug/caller-info.js +3 -4
  87. package/dist/debug/namespace.d.ts +7 -0
  88. package/dist/debug/namespace.js +21 -12
  89. package/dist/debug/output.js +21 -24
  90. package/dist/debug/types.d.ts +4 -4
  91. package/dist/dlx/arborist.js +18 -8
  92. package/dist/dlx/binary-cache.js +15 -15
  93. package/dist/dlx/binary-download.d.ts +1 -1
  94. package/dist/dlx/binary-download.js +11 -11
  95. package/dist/dlx/binary-resolution.js +17 -15
  96. package/dist/dlx/binary-types.d.ts +5 -5
  97. package/dist/dlx/binary.js +5 -5
  98. package/dist/dlx/cache.js +1 -1
  99. package/dist/dlx/detect.d.ts +42 -25
  100. package/dist/dlx/detect.js +86 -77
  101. package/dist/dlx/dir.js +2 -2
  102. package/dist/dlx/firewall.d.ts +9 -1
  103. package/dist/dlx/firewall.js +1 -1
  104. package/dist/dlx/lockfile.d.ts +19 -18
  105. package/dist/dlx/lockfile.js +19 -16
  106. package/dist/dlx/manifest.d.ts +6 -6
  107. package/dist/dlx/manifest.js +5 -5
  108. package/dist/dlx/package.d.ts +10 -10
  109. package/dist/dlx/package.js +20 -16
  110. package/dist/dlx/packages.js +4 -4
  111. package/dist/dlx/paths.js +7 -7
  112. package/dist/dlx/spec.js +1 -1
  113. package/dist/dlx/types.d.ts +28 -27
  114. package/dist/eco/cargo/parse-lockfile.d.ts +2 -3
  115. package/dist/eco/cargo/parse-lockfile.js +5 -5
  116. package/dist/eco/manifest/analyze-lockfile.js +2 -2
  117. package/dist/eco/manifest/detect-format.js +5 -5
  118. package/dist/eco/manifest/find-packages.js +2 -2
  119. package/dist/eco/manifest/get-package-versions.js +2 -2
  120. package/dist/eco/manifest/get-package.js +2 -2
  121. package/dist/eco/manifest/parse-lockfile.js +2 -2
  122. package/dist/eco/manifest/parse-manifest.js +2 -2
  123. package/dist/eco/manifest/parse.js +2 -2
  124. package/dist/eco/npm/npm/exec.js +2 -2
  125. package/dist/eco/npm/npm/flags.js +7 -12
  126. package/dist/eco/npm/npm/parse-lockfile.d.ts +17 -18
  127. package/dist/eco/npm/npm/parse-lockfile.js +4 -4
  128. package/dist/eco/npm/parse-package-json.d.ts +11 -0
  129. package/dist/eco/npm/parse-package-json.js +3 -3
  130. package/dist/eco/npm/pnpm/exec.d.ts +1 -1
  131. package/dist/eco/npm/pnpm/exec.js +5 -5
  132. package/dist/eco/npm/pnpm/flags.js +0 -3
  133. package/dist/eco/npm/pnpm/parse-lockfile.d.ts +6 -4
  134. package/dist/eco/npm/pnpm/parse-lockfile.js +7 -7
  135. package/dist/eco/npm/script.js +9 -6
  136. package/dist/eco/npm/yarnpkg/yarn/exec.js +4 -4
  137. package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.d.ts +3 -4
  138. package/dist/eco/npm/yarnpkg/yarn/parse-lockfile.js +9 -9
  139. package/dist/effects/pulse-frames.d.ts +3 -1
  140. package/dist/effects/shimmer-keyframes.d.ts +1 -1
  141. package/dist/effects/shimmer-terminal.d.ts +1 -1
  142. package/dist/env/boolean.js +0 -1
  143. package/dist/env/ci.js +0 -1
  144. package/dist/env/debug.js +0 -1
  145. package/dist/env/github-status.d.ts +51 -0
  146. package/dist/env/github-status.js +90 -0
  147. package/dist/env/github.js +0 -8
  148. package/dist/env/home.js +0 -1
  149. package/dist/env/locale.js +0 -3
  150. package/dist/env/node-auth-token.js +0 -1
  151. package/dist/env/node-env.js +0 -1
  152. package/dist/env/node-version-managers.d.ts +53 -0
  153. package/dist/env/node-version-managers.js +90 -0
  154. package/dist/env/npm.js +0 -5
  155. package/dist/env/number.js +0 -1
  156. package/dist/env/package-manager.js +3 -6
  157. package/dist/env/path.js +0 -1
  158. package/dist/env/pre-commit.js +1 -2
  159. package/dist/env/proxy.js +1 -1
  160. package/dist/env/rewire.d.ts +8 -6
  161. package/dist/env/rewire.js +16 -17
  162. package/dist/env/shell.js +0 -1
  163. package/dist/env/socket-cli.js +5 -18
  164. package/dist/env/socket-mcp.d.ts +114 -0
  165. package/dist/env/socket-mcp.js +146 -0
  166. package/dist/env/socket.d.ts +8 -109
  167. package/dist/env/socket.js +22 -167
  168. package/dist/env/string.js +0 -1
  169. package/dist/env/temp-dir.js +0 -3
  170. package/dist/env/term.js +0 -1
  171. package/dist/env/test.js +3 -6
  172. package/dist/env/windows.js +0 -4
  173. package/dist/env/xdg.js +0 -3
  174. package/dist/errors/predicates.js +1 -1
  175. package/dist/events/exit/_internal.d.ts +11 -9
  176. package/dist/events/exit/_internal.js +31 -35
  177. package/dist/events/exit/handler.js +3 -4
  178. package/dist/events/exit/intercept.js +4 -6
  179. package/dist/events/exit/lifecycle.js +16 -18
  180. package/dist/events/exit/signals.js +1 -2
  181. package/dist/events/exit/types.d.ts +6 -5
  182. package/dist/external/@npmcli/package-json.js +2 -2
  183. package/dist/external/@npmcli/promise-spawn.js +3 -1
  184. package/dist/external/npm-pack.js +2 -2
  185. package/dist/external/pico-pack.js +4 -2
  186. package/dist/external/which.js +3 -1
  187. package/dist/external-tools/bazel/asset-names.d.ts +1 -1
  188. package/dist/external-tools/bazel/asset-names.js +5 -2
  189. package/dist/external-tools/bazel/from-download.d.ts +1 -1
  190. package/dist/external-tools/bazel/from-download.js +5 -2
  191. package/dist/external-tools/bazel/read-bazel-version-file.js +1 -1
  192. package/dist/external-tools/bazel/resolve-bazel-version.js +4 -0
  193. package/dist/external-tools/bazel/resolve.d.ts +3 -3
  194. package/dist/external-tools/bazel/resolve.js +16 -8
  195. package/dist/external-tools/bazel/types.d.ts +1 -1
  196. package/dist/external-tools/cdxgen/asset-names.d.ts +1 -1
  197. package/dist/external-tools/cdxgen/asset-names.js +5 -2
  198. package/dist/external-tools/cdxgen/from-download.d.ts +1 -1
  199. package/dist/external-tools/cdxgen/from-download.js +7 -4
  200. package/dist/external-tools/cdxgen/from-vfs.js +1 -1
  201. package/dist/external-tools/cdxgen/resolve.d.ts +3 -3
  202. package/dist/external-tools/cdxgen/resolve.js +16 -8
  203. package/dist/external-tools/cdxgen/types.d.ts +1 -1
  204. package/dist/external-tools/from-download.d.ts +3 -3
  205. package/dist/external-tools/from-download.js +12 -6
  206. package/dist/external-tools/from-pip-venv.d.ts +1 -1
  207. package/dist/external-tools/from-pip-venv.js +12 -5
  208. package/dist/external-tools/janus/asset-names.d.ts +1 -1
  209. package/dist/external-tools/janus/asset-names.js +5 -2
  210. package/dist/external-tools/janus/from-download.d.ts +1 -1
  211. package/dist/external-tools/janus/from-download.js +5 -2
  212. package/dist/external-tools/janus/from-vfs.js +1 -1
  213. package/dist/external-tools/janus/resolve.d.ts +3 -3
  214. package/dist/external-tools/janus/resolve.js +16 -8
  215. package/dist/external-tools/janus/types.d.ts +1 -1
  216. package/dist/external-tools/jre/asset-names.d.ts +1 -1
  217. package/dist/external-tools/jre/asset-names.js +5 -2
  218. package/dist/external-tools/jre/detect-platform-arch.d.ts +10 -6
  219. package/dist/external-tools/jre/detect-platform-arch.js +29 -14
  220. package/dist/external-tools/jre/from-download.d.ts +1 -1
  221. package/dist/external-tools/jre/from-download.js +7 -4
  222. package/dist/external-tools/jre/from-java-home.js +2 -2
  223. package/dist/external-tools/jre/from-vfs.js +3 -3
  224. package/dist/external-tools/jre/resolve.d.ts +3 -3
  225. package/dist/external-tools/jre/resolve.js +16 -8
  226. package/dist/external-tools/jre/types.d.ts +1 -1
  227. package/dist/external-tools/manifest.d.ts +25 -7
  228. package/dist/external-tools/manifest.js +13 -13
  229. package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
  230. package/dist/external-tools/opengrep/asset-names.js +5 -2
  231. package/dist/external-tools/opengrep/from-download.d.ts +1 -1
  232. package/dist/external-tools/opengrep/from-download.js +5 -2
  233. package/dist/external-tools/opengrep/from-vfs.js +1 -1
  234. package/dist/external-tools/opengrep/resolve.d.ts +3 -3
  235. package/dist/external-tools/opengrep/resolve.js +16 -8
  236. package/dist/external-tools/opengrep/types.d.ts +1 -1
  237. package/dist/external-tools/python/asset-names.d.ts +76 -0
  238. package/dist/external-tools/python/asset-names.js +111 -0
  239. package/dist/external-tools/python/dlx.d.ts +80 -0
  240. package/dist/external-tools/python/dlx.js +98 -0
  241. package/dist/external-tools/python/from-download.d.ts +53 -0
  242. package/dist/external-tools/python/from-download.js +75 -0
  243. package/dist/external-tools/python/from-path.d.ts +7 -0
  244. package/dist/external-tools/python/from-path.js +23 -0
  245. package/dist/external-tools/python/pin.d.ts +121 -0
  246. package/dist/external-tools/python/pin.js +176 -0
  247. package/dist/external-tools/python/pip-install.d.ts +75 -0
  248. package/dist/external-tools/python/pip-install.js +142 -0
  249. package/dist/external-tools/python/resolve.d.ts +42 -0
  250. package/dist/external-tools/python/resolve.js +66 -0
  251. package/dist/external-tools/python/types.d.ts +49 -0
  252. package/dist/external-tools/sbt/asset-names.d.ts +1 -1
  253. package/dist/external-tools/sbt/asset-names.js +5 -2
  254. package/dist/external-tools/sbt/from-download.d.ts +1 -1
  255. package/dist/external-tools/sbt/from-download.js +5 -2
  256. package/dist/external-tools/sbt/from-vfs.js +1 -1
  257. package/dist/external-tools/sbt/resolve.d.ts +3 -3
  258. package/dist/external-tools/sbt/resolve.js +16 -8
  259. package/dist/external-tools/sbt/types.d.ts +1 -1
  260. package/dist/external-tools/skillspector/from-dlx.d.ts +1 -1
  261. package/dist/external-tools/skillspector/from-dlx.js +10 -3
  262. package/dist/external-tools/skillspector/from-path.js +3 -5
  263. package/dist/external-tools/skillspector/from-vfs.js +1 -1
  264. package/dist/external-tools/skillspector/resolve.d.ts +2 -2
  265. package/dist/external-tools/skillspector/resolve.js +14 -6
  266. package/dist/external-tools/synp/asset-names.d.ts +1 -1
  267. package/dist/external-tools/synp/asset-names.js +6 -2
  268. package/dist/external-tools/synp/from-download.d.ts +1 -1
  269. package/dist/external-tools/synp/from-download.js +7 -4
  270. package/dist/external-tools/synp/from-vfs.js +1 -1
  271. package/dist/external-tools/synp/resolve.d.ts +3 -3
  272. package/dist/external-tools/synp/resolve.js +16 -8
  273. package/dist/external-tools/trivy/asset-names.d.ts +1 -1
  274. package/dist/external-tools/trivy/asset-names.js +5 -2
  275. package/dist/external-tools/trivy/from-download.d.ts +1 -1
  276. package/dist/external-tools/trivy/from-download.js +7 -4
  277. package/dist/external-tools/trivy/from-vfs.js +1 -1
  278. package/dist/external-tools/trivy/resolve.d.ts +3 -3
  279. package/dist/external-tools/trivy/resolve.js +16 -8
  280. package/dist/external-tools/trivy/types.d.ts +1 -1
  281. package/dist/external-tools/trufflehog/asset-names.d.ts +1 -1
  282. package/dist/external-tools/trufflehog/asset-names.js +5 -2
  283. package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
  284. package/dist/external-tools/trufflehog/from-download.js +7 -4
  285. package/dist/external-tools/trufflehog/from-vfs.js +1 -1
  286. package/dist/external-tools/trufflehog/resolve.d.ts +3 -3
  287. package/dist/external-tools/trufflehog/resolve.js +16 -8
  288. package/dist/external-tools/trufflehog/types.d.ts +1 -1
  289. package/dist/fs/_internal.d.ts +1 -1
  290. package/dist/fs/_internal.js +7 -7
  291. package/dist/fs/access.js +5 -9
  292. package/dist/fs/allowed-dirs-cache.d.ts +47 -0
  293. package/dist/fs/allowed-dirs-cache.js +69 -0
  294. package/dist/fs/encoding.js +5 -7
  295. package/dist/fs/{find-up.js → find.js} +12 -14
  296. package/dist/fs/inspect.js +7 -13
  297. package/dist/fs/read-dir.js +7 -10
  298. package/dist/fs/read-file.js +8 -14
  299. package/dist/fs/read-json-cache.d.ts +13 -4
  300. package/dist/fs/read-json-cache.js +9 -6
  301. package/dist/fs/read-json.js +4 -6
  302. package/dist/fs/resolve-module.js +7 -3
  303. package/dist/fs/safe.d.ts +1 -1
  304. package/dist/fs/safe.js +13 -14
  305. package/dist/fs/unique.js +4 -5
  306. package/dist/fs/validate.js +1 -2
  307. package/dist/fs/write-json.js +4 -5
  308. package/dist/git/_internal.js +11 -11
  309. package/dist/git/changed.js +4 -4
  310. package/dist/git/repo.js +5 -7
  311. package/dist/git/staged.js +12 -4
  312. package/dist/git/tracked.d.ts +84 -0
  313. package/dist/git/tracked.js +163 -0
  314. package/dist/git/unstaged.js +12 -4
  315. package/dist/github/ghsa.js +2 -2
  316. package/dist/github/refs-cache.d.ts +1 -1
  317. package/dist/github/refs-cache.js +5 -5
  318. package/dist/github/refs-graphql.js +4 -0
  319. package/dist/github/refs-rest.js +9 -5
  320. package/dist/github/refs.js +15 -10
  321. package/dist/github/{fetch.js → request.js} +13 -2
  322. package/dist/github/token.js +1 -1
  323. package/dist/github/types.d.ts +1 -1
  324. package/dist/globs/_internal.js +8 -10
  325. package/dist/globs/match.js +13 -7
  326. package/dist/globs/matcher.d.ts +3 -3
  327. package/dist/globs/matcher.js +16 -14
  328. package/dist/globs/stream.js +1 -2
  329. package/dist/globs/types.d.ts +24 -24
  330. package/dist/http-request/_internal.d.ts +1 -1
  331. package/dist/http-request/browser.js +10 -4
  332. package/dist/http-request/checksum-file.d.ts +55 -0
  333. package/dist/http-request/checksum-file.js +95 -0
  334. package/dist/http-request/download-types.d.ts +15 -23
  335. package/dist/http-request/download.js +3 -3
  336. package/dist/http-request/{browser-fetch.d.ts → fetch/browser.d.ts} +2 -2
  337. package/dist/http-request/{browser-fetch.js → fetch/browser.js} +4 -4
  338. package/dist/http-request/headers.js +1 -2
  339. package/dist/http-request/request-attempt.js +38 -34
  340. package/dist/http-request/request-types.d.ts +2 -2
  341. package/dist/http-request/request.js +1 -1
  342. package/dist/http-request/user-agent.js +4 -5
  343. package/dist/integrity.d.ts +92 -18
  344. package/dist/integrity.js +125 -30
  345. package/dist/ipc/directory.js +2 -2
  346. package/dist/ipc/paths.js +1 -1
  347. package/dist/ipc/write.js +1 -1
  348. package/dist/ipc-cli/get.js +12 -12
  349. package/dist/json/edit.js +51 -44
  350. package/dist/json/format.js +1 -1
  351. package/dist/json/parse.d.ts +1 -1
  352. package/dist/json/parse.js +3 -7
  353. package/dist/logger/_internal.d.ts +4 -4
  354. package/dist/logger/_internal.js +3 -3
  355. package/dist/logger/colors.js +4 -3
  356. package/dist/logger/console-methods.d.ts +132 -0
  357. package/dist/logger/console-methods.js +169 -0
  358. package/dist/logger/console.d.ts +12 -0
  359. package/dist/logger/console.js +42 -11
  360. package/dist/logger/indentation-methods.d.ts +81 -0
  361. package/dist/logger/indentation-methods.js +121 -0
  362. package/dist/logger/node.d.ts +16 -338
  363. package/dist/logger/node.js +75 -608
  364. package/dist/logger/options.d.ts +39 -0
  365. package/dist/logger/options.js +47 -0
  366. package/dist/logger/semantic-methods.d.ts +63 -0
  367. package/dist/logger/semantic-methods.js +108 -0
  368. package/dist/logger/stream-methods.d.ts +63 -0
  369. package/dist/logger/stream-methods.js +101 -0
  370. package/dist/logger/stream.d.ts +37 -0
  371. package/dist/logger/stream.js +42 -0
  372. package/dist/logger/symbols-builder.js +9 -9
  373. package/dist/logger/symbols.d.ts +2 -25
  374. package/dist/logger/symbols.js +53 -74
  375. package/dist/logger/types.d.ts +1 -1
  376. package/dist/memo/types.d.ts +6 -6
  377. package/dist/native-messaging/host.d.ts +20 -0
  378. package/dist/native-messaging/host.js +120 -0
  379. package/dist/native-messaging/index.d.ts +5 -0
  380. package/dist/native-messaging/index.js +22 -0
  381. package/dist/native-messaging/install.d.ts +60 -0
  382. package/dist/native-messaging/install.js +144 -0
  383. package/dist/native-messaging/rate-limit.d.ts +69 -0
  384. package/dist/native-messaging/rate-limit.js +119 -0
  385. package/dist/native-messaging/run.d.ts +10 -0
  386. package/dist/native-messaging/run.js +17 -0
  387. package/dist/node/async-hooks.js +4 -3
  388. package/dist/node/child-process.js +4 -3
  389. package/dist/node/crypto.js +4 -3
  390. package/dist/node/events.js +4 -3
  391. package/dist/node/fs-promises.js +4 -3
  392. package/dist/node/fs.d.ts +22 -6
  393. package/dist/node/fs.js +17 -3
  394. package/dist/node/http.js +4 -3
  395. package/dist/node/https.js +4 -3
  396. package/dist/node/module.js +10 -6
  397. package/dist/node/os.d.ts +10 -2
  398. package/dist/node/os.js +12 -4
  399. package/dist/node/path.d.ts +11 -2
  400. package/dist/node/path.js +18 -4
  401. package/dist/node/timers-promises.js +4 -3
  402. package/dist/node/url.js +4 -3
  403. package/dist/node/util.js +4 -3
  404. package/dist/objects/getters.js +6 -8
  405. package/dist/objects/inspect.js +1 -4
  406. package/dist/objects/mutate.js +4 -5
  407. package/dist/objects/predicates.js +1 -5
  408. package/dist/objects/sort.js +3 -7
  409. package/dist/packages/edit-class.d.ts +2 -3
  410. package/dist/packages/edit-class.js +53 -48
  411. package/dist/packages/edit.js +12 -14
  412. package/dist/packages/exports.js +15 -21
  413. package/dist/packages/fetch.d.ts +16 -0
  414. package/dist/packages/fetch.js +81 -0
  415. package/dist/packages/find.d.ts +55 -0
  416. package/dist/packages/find.js +65 -0
  417. package/dist/packages/isolation.js +14 -14
  418. package/dist/packages/licenses.js +18 -18
  419. package/dist/packages/manifest.js +16 -19
  420. package/dist/packages/metadata-extensions.d.ts +14 -0
  421. package/dist/packages/metadata-extensions.js +43 -0
  422. package/dist/packages/normalize.js +6 -10
  423. package/dist/packages/provenance.js +17 -19
  424. package/dist/packages/read.d.ts +29 -0
  425. package/dist/packages/read.js +66 -0
  426. package/dist/packages/specs.d.ts +48 -1
  427. package/dist/packages/specs.js +75 -12
  428. package/dist/packages/tarball.d.ts +24 -0
  429. package/dist/packages/tarball.js +81 -0
  430. package/dist/packages/types.d.ts +22 -22
  431. package/dist/packages/validation.js +0 -3
  432. package/dist/paths/_internal.d.ts +2 -1
  433. package/dist/paths/_internal.js +7 -19
  434. package/dist/paths/conversion.js +5 -9
  435. package/dist/paths/dirnames.d.ts +1 -0
  436. package/dist/paths/dirnames.js +2 -0
  437. package/dist/paths/filenames.d.ts +0 -1
  438. package/dist/paths/filenames.js +0 -2
  439. package/dist/paths/normalize.js +4 -5
  440. package/dist/paths/packages.js +4 -7
  441. package/dist/paths/predicates.js +9 -16
  442. package/dist/paths/resolve.js +17 -25
  443. package/dist/paths/rewire.d.ts +5 -0
  444. package/dist/paths/rewire.js +3 -3
  445. package/dist/paths/socket.d.ts +74 -111
  446. package/dist/paths/socket.js +106 -139
  447. package/dist/paths/walk.d.ts +1 -1
  448. package/dist/paths/walk.js +4 -4
  449. package/dist/perf/report.js +2 -2
  450. package/dist/perf/types.d.ts +1 -1
  451. package/dist/pkg-ext/data.js +1 -1
  452. package/dist/primordials/array.js +9 -9
  453. package/dist/primordials/date.js +2 -2
  454. package/dist/primordials/error.js +3 -3
  455. package/dist/primordials/headers.d.ts +10 -0
  456. package/dist/primordials/headers.js +23 -0
  457. package/dist/primordials/intl.d.ts +13 -0
  458. package/dist/primordials/intl.js +26 -0
  459. package/dist/primordials/math.js +33 -33
  460. package/dist/primordials/number.js +9 -9
  461. package/dist/primordials/object.js +5 -5
  462. package/dist/primordials/process.d.ts +88 -0
  463. package/dist/primordials/process.js +132 -0
  464. package/dist/primordials/string.d.ts +2 -2
  465. package/dist/primordials/string.js +6 -6
  466. package/dist/primordials/symbol.js +3 -3
  467. package/dist/primordials/uncurry.d.ts +1 -2
  468. package/dist/primordials/uncurry.js +9 -9
  469. package/dist/process/abort.js +3 -3
  470. package/dist/process/lock-manager.js +8 -8
  471. package/dist/process/spawn/_internal.js +6 -8
  472. package/dist/process/spawn/child.js +20 -14
  473. package/dist/process/spawn/errors.js +3 -5
  474. package/dist/process/spawn/kill-tree.d.ts +53 -0
  475. package/dist/process/spawn/kill-tree.js +85 -0
  476. package/dist/process/spawn/stdio.js +0 -1
  477. package/dist/process/spawn/types.d.ts +5 -5
  478. package/dist/process/transient.js +2 -2
  479. package/dist/promises/_internal.d.ts +2 -1
  480. package/dist/promises/_internal.js +2 -6
  481. package/dist/promises/iterate.js +11 -15
  482. package/dist/promises/options.js +3 -6
  483. package/dist/promises/retry.js +4 -5
  484. package/dist/promises/timers.d.ts +30 -0
  485. package/dist/promises/timers.js +48 -0
  486. package/dist/regexps/spec.js +1 -1
  487. package/dist/releases/github-archives.d.ts +6 -6
  488. package/dist/releases/github-archives.js +3 -3
  489. package/dist/releases/github-asset-url.d.ts +1 -1
  490. package/dist/releases/github-asset-url.js +5 -5
  491. package/dist/releases/github-downloads.d.ts +1 -1
  492. package/dist/releases/github-downloads.js +3 -3
  493. package/dist/releases/github-listing.d.ts +12 -4
  494. package/dist/releases/github-listing.js +20 -7
  495. package/dist/releases/github-retry-config.js +1 -1
  496. package/dist/releases/github-types.d.ts +6 -6
  497. package/dist/releases/socket-btm-binary-naming.d.ts +107 -0
  498. package/dist/releases/socket-btm-binary-naming.js +155 -0
  499. package/dist/releases/socket-btm.d.ts +8 -115
  500. package/dist/releases/socket-btm.js +16 -159
  501. package/dist/schema/types.d.ts +4 -5
  502. package/dist/schema/validate.js +1 -1
  503. package/dist/sea/detect.js +6 -6
  504. package/dist/secrets/_internal.d.ts +2 -2
  505. package/dist/secrets/_internal.js +2 -2
  506. package/dist/secrets/compare.d.ts +45 -0
  507. package/dist/secrets/compare.js +61 -0
  508. package/dist/secrets/find.d.ts +2 -2
  509. package/dist/secrets/find.js +10 -4
  510. package/dist/secrets/keychain.d.ts +1 -1
  511. package/dist/secrets/keychain.js +6 -4
  512. package/dist/secrets/linux.js +40 -52
  513. package/dist/secrets/macos.d.ts +2 -3
  514. package/dist/secrets/macos.js +24 -33
  515. package/dist/secrets/rc.d.ts +4 -4
  516. package/dist/secrets/rc.js +27 -17
  517. package/dist/secrets/socket-api-token.d.ts +4 -4
  518. package/dist/secrets/socket-api-token.js +26 -9
  519. package/dist/secrets/windows.js +32 -37
  520. package/dist/shadow/skip.js +2 -2
  521. package/dist/shell/parse.d.ts +32 -0
  522. package/dist/shell/parse.js +60 -0
  523. package/dist/smol/detect.js +9 -10
  524. package/dist/smol/http.js +6 -7
  525. package/dist/smol/https.js +6 -7
  526. package/dist/smol/manifest.d.ts +1 -1
  527. package/dist/smol/manifest.js +6 -7
  528. package/dist/smol/path.d.ts +1 -1
  529. package/dist/smol/path.js +7 -8
  530. package/dist/smol/primordial.d.ts +4 -0
  531. package/dist/smol/primordial.js +6 -7
  532. package/dist/smol/purl.d.ts +1 -1
  533. package/dist/smol/purl.js +7 -8
  534. package/dist/smol/versions.js +6 -7
  535. package/dist/smol/vfs.js +6 -7
  536. package/dist/sorts/_internal.js +6 -8
  537. package/dist/sorts/natural.js +10 -12
  538. package/dist/sorts/semver.js +1 -2
  539. package/dist/sorts/strings.js +0 -1
  540. package/dist/sorts/types.d.ts +1 -1
  541. package/dist/spinner/create-spinner-class.d.ts +38 -0
  542. package/dist/spinner/create-spinner-class.js +302 -0
  543. package/dist/spinner/default.js +8 -9
  544. package/dist/spinner/spinner-internals.d.ts +36 -0
  545. package/dist/spinner/spinner-internals.js +105 -0
  546. package/dist/spinner/spinner-shimmer-methods.d.ts +54 -0
  547. package/dist/spinner/spinner-shimmer-methods.js +143 -0
  548. package/dist/spinner/spinner-status-methods.d.ts +40 -0
  549. package/dist/spinner/spinner-status-methods.js +133 -0
  550. package/dist/spinner/spinner.d.ts +8 -5
  551. package/dist/spinner/spinner.js +19 -706
  552. package/dist/spinner/types.d.ts +3 -1
  553. package/dist/spinner/with.d.ts +10 -0
  554. package/dist/spinner/with.js +16 -2
  555. package/dist/stdio/divider.js +1 -1
  556. package/dist/stdio/footer.js +3 -3
  557. package/dist/stdio/header.js +4 -4
  558. package/dist/stdio/progress.js +10 -6
  559. package/dist/stdio/prompts.d.ts +7 -5
  560. package/dist/stdio/prompts.js +7 -8
  561. package/dist/stdio/stdout.js +3 -3
  562. package/dist/streams/parallel.js +3 -5
  563. package/dist/streams/transform.js +2 -3
  564. package/dist/strings/format.js +2 -6
  565. package/dist/strings/predicates.js +0 -2
  566. package/dist/strings/search.js +1 -2
  567. package/dist/strings/transform.js +0 -3
  568. package/dist/strings/width.js +9 -10
  569. package/dist/tables/bordered.js +4 -3
  570. package/dist/tables/padding.js +1 -1
  571. package/dist/tables/simple.js +8 -5
  572. package/dist/temporal/instant.js +1 -1
  573. package/dist/temporal/slots.js +6 -6
  574. package/dist/temporal/system.js +9 -9
  575. package/dist/themes/context.d.ts +3 -2
  576. package/dist/themes/context.js +4 -5
  577. package/dist/themes/themes.js +15 -15
  578. package/dist/themes/types.d.ts +3 -3
  579. package/dist/url/assert-safe.d.ts +29 -0
  580. package/dist/url/assert-safe.js +54 -0
  581. package/dist/url/parse.js +0 -2
  582. package/dist/url/predicates.d.ts +31 -1
  583. package/dist/url/predicates.js +43 -3
  584. package/dist/url/search-params.js +3 -9
  585. package/dist/url/types.d.ts +9 -5
  586. package/dist/versions/_internal.js +3 -3
  587. package/dist/words/article.js +0 -1
  588. package/dist/words/capitalize.js +0 -1
  589. package/dist/words/pluralize.js +15 -5
  590. package/package.json +419 -216
  591. package/dist/external-tools/uv/asset-names.d.ts +0 -36
  592. package/dist/external-tools/uv/asset-names.js +0 -70
  593. package/dist/external-tools/uv/from-download.d.ts +0 -17
  594. package/dist/external-tools/uv/from-download.js +0 -47
  595. package/dist/external-tools/uv/from-path.d.ts +0 -5
  596. package/dist/external-tools/uv/from-path.js +0 -22
  597. package/dist/external-tools/uv/from-vfs.d.ts +0 -7
  598. package/dist/external-tools/uv/from-vfs.js +0 -26
  599. package/dist/external-tools/uv/resolve.d.ts +0 -25
  600. package/dist/external-tools/uv/resolve.js +0 -53
  601. package/dist/external-tools/uv/types.d.ts +0 -24
  602. package/dist/fs/path-cache.d.ts +0 -21
  603. package/dist/fs/path-cache.js +0 -34
  604. package/dist/http-request/checksums.d.ts +0 -69
  605. package/dist/http-request/checksums.js +0 -108
  606. package/dist/http-request/http-request.d.ts +0 -12
  607. package/dist/http-request/http-request.js +0 -11
  608. package/dist/packages/operations.d.ts +0 -113
  609. package/dist/packages/operations.js +0 -304
  610. package/dist/ssri/convert.d.ts +0 -48
  611. package/dist/ssri/convert.js +0 -69
  612. package/dist/ssri/parse.d.ts +0 -27
  613. package/dist/ssri/parse.js +0 -41
  614. package/dist/ssri/validate.d.ts +0 -41
  615. package/dist/ssri/validate.js +0 -56
  616. /package/dist/{bin → cli}/check.d.ts +0 -0
  617. /package/dist/external-tools/{uv → python}/types.js +0 -0
  618. /package/dist/fs/{find-up.d.ts → find.d.ts} +0 -0
  619. /package/dist/github/{fetch.d.ts → request.d.ts} +0 -0
@@ -4,6 +4,35 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
5
  //#region src/ai/profiles.mts
6
6
  /**
7
+ * Composable Bash-allowlist building blocks. Each group is a frozen list of
8
+ * `Bash(<cmd>:*)` glob entries; the profiles below compose tiers from them, and
9
+ * callers can mix their own (`allow: [...BASH_ALLOW.test, 'Bash(make:*)']`)
10
+ * without rewriting a whole tier's literal.
11
+ *
12
+ * - `gitRead` — non-mutating inspection (`status` / `diff` / `log`).
13
+ * - `gitWrite` — mutating (`add` / `commit`). The bright line between `verify`
14
+ * (may NOT land) and `full` (may land).
15
+ * - `node` — run a `.mts` / `.js` directly (tests, check scripts, codegen).
16
+ * - `test` — `pnpm test` / `pnpm run <script>` (the verify surface).
17
+ * - `pkgExec` — `pnpm exec` (run a workspace bin); broader, full-tier only.
18
+ */
19
+ const BASH_ALLOW = {
20
+ gitRead: [
21
+ "Bash(git status:*)",
22
+ "Bash(git diff:*)",
23
+ "Bash(git log:*)"
24
+ ],
25
+ gitWrite: ["Bash(git add:*)", "Bash(git commit:*)"],
26
+ node: ["Bash(node:*)"],
27
+ pkgExec: ["Bash(pnpm exec:*)"],
28
+ test: ["Bash(pnpm run:*)", "Bash(pnpm test:*)"]
29
+ };
30
+ const VERIFY_BASH_ALLOW = [
31
+ ...BASH_ALLOW.gitRead,
32
+ ...BASH_ALLOW.node,
33
+ ...BASH_ALLOW.test
34
+ ];
35
+ /**
7
36
  * Capability ladder of lockdown profiles, ordered least → most capable. Key
8
37
  * order documents the ladder; each tier is a strict superset of the previous
9
38
  * tier's tool surface.
@@ -63,17 +92,29 @@ const AI_PROFILE = {
63
92
  "Write"
64
93
  ]
65
94
  },
95
+ verify: {
96
+ allow: [...VERIFY_BASH_ALLOW],
97
+ disallow: [
98
+ "Agent",
99
+ "WebFetch",
100
+ "WebSearch"
101
+ ],
102
+ permissionMode: "acceptEdits",
103
+ tools: [
104
+ "Bash",
105
+ "Edit",
106
+ "Glob",
107
+ "Grep",
108
+ "MultiEdit",
109
+ "Read",
110
+ "Write"
111
+ ]
112
+ },
66
113
  full: {
67
114
  allow: [
68
- "Bash(git status:*)",
69
- "Bash(git diff:*)",
70
- "Bash(git log:*)",
71
- "Bash(git add:*)",
72
- "Bash(git commit:*)",
73
- "Bash(node:*)",
74
- "Bash(pnpm exec:*)",
75
- "Bash(pnpm run:*)",
76
- "Bash(pnpm test:*)"
115
+ ...VERIFY_BASH_ALLOW,
116
+ ...BASH_ALLOW.gitWrite,
117
+ ...BASH_ALLOW.pkgExec
77
118
  ],
78
119
  disallow: [
79
120
  "Agent",
@@ -94,4 +135,5 @@ const AI_PROFILE = {
94
135
  };
95
136
 
96
137
  //#endregion
97
- exports.AI_PROFILE = AI_PROFILE;
138
+ exports.AI_PROFILE = AI_PROFILE;
139
+ exports.BASH_ALLOW = BASH_ALLOW;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @file Availability-gated tier routing. `tier.mts` says which model+effort is
3
+ * the "perfect" choice for a unit of work; this module turns that hint into a
4
+ * concrete spawn target that ACTUALLY EXISTS on the machine. A tier resolves
5
+ * to its preferred engine only when that engine's CLI is installed AND a
6
+ * credential for it is resolvable; otherwise the resolver walks a
7
+ * cross-engine equivalence ladder (Claude → Codex → an open-weight provider
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.
18
+ */
19
+ import type { CredentialProvider } from './credentials.mts';
20
+ import type { AiAgentName, AiEffort } from './types.mts';
21
+ import type { AiTier } from './tier.mts';
22
+ /**
23
+ * A concrete, spawnable target: which CLI engine to run, the model id, the
24
+ * reasoning effort to pass (undefined when the model ignores effort, e.g.
25
+ * Fable), and the credential provider whose key gates it.
26
+ */
27
+ export interface TierCandidate {
28
+ readonly effort: AiEffort | undefined;
29
+ readonly engine: AiAgentName;
30
+ readonly model: string;
31
+ readonly provider: CredentialProvider;
32
+ }
33
+ /**
34
+ * 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).
38
+ */
39
+ export type TierResolveReason = 'fellback' | 'preferred';
40
+ export interface TierResolution {
41
+ readonly candidate: TierCandidate;
42
+ readonly reason: TierResolveReason;
43
+ readonly from?: AiTier | undefined;
44
+ }
45
+ /**
46
+ * The context a caller probes once and passes in: which engine CLIs exist, and
47
+ * which credential providers have a resolvable key. Both are sets so the
48
+ * resolver stays pure (no `which` / keychain I/O of its own).
49
+ */
50
+ export interface RouteContext {
51
+ readonly available: ReadonlySet<AiAgentName>;
52
+ readonly keyed: ReadonlySet<CredentialProvider>;
53
+ }
54
+ export declare const TIER_CHAINS: Readonly<Record<AiTier, readonly TierCandidate[]>>;
55
+ /**
56
+ * A candidate is usable when its engine CLI exists AND a credential for its
57
+ * provider is resolvable. Both gates matter: an installed Claude with an
58
+ * expired key is as unusable as a missing CLI.
59
+ */
60
+ export declare function isCandidateUsable(candidate: TierCandidate, ctx: RouteContext): boolean;
61
+ /**
62
+ * Resolve a tier to the best available concrete target. Prefers the tier's
63
+ * first-choice (Claude) candidate; if its engine is missing or unkeyed, walks
64
+ * 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.
68
+ */
69
+ export declare function resolveTier(tier: AiTier, ctx: RouteContext): TierResolution | undefined;
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with rolldown */
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_ai_tier = require('./tier.js');
5
+
6
+ //#region src/ai/route.mts
7
+ /**
8
+ * @file Availability-gated tier routing. `tier.mts` says which model+effort is
9
+ * the "perfect" choice for a unit of work; this module turns that hint into a
10
+ * concrete spawn target that ACTUALLY EXISTS on the machine. A tier resolves
11
+ * to its preferred engine only when that engine's CLI is installed AND a
12
+ * credential for it is resolvable; otherwise the resolver walks a
13
+ * cross-engine equivalence ladder (Claude → Codex → an open-weight provider
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.
24
+ */
25
+ /**
26
+ * Per-tier preference chain, most-preferred-first. The head is the "perfect"
27
+ * Claude choice from `AI_TIER`; the tail is the cross-engine equivalent ladder
28
+ * (Codex, then an open-weight provider reached through opencode). Effort is the
29
+ * shared `AiEffort` vocab; `buildArgs` translates per engine (codex clamps
30
+ * `max`→`xhigh`, Fable drops effort entirely).
31
+ *
32
+ * The Claude head reuses `AI_TIER` so a model-generation bump stays a single
33
+ * edit there. Fable's head carries `effort: undefined` — it is adaptive-only.
34
+ */
35
+ const FABLE = require_ai_tier.AI_TIER.fable;
36
+ const OPUS = require_ai_tier.AI_TIER.opus;
37
+ const SONNET = require_ai_tier.AI_TIER.sonnet;
38
+ const HAIKU = require_ai_tier.AI_TIER.haiku;
39
+ const TIER_CHAINS = {
40
+ __proto__: null,
41
+ fable: [
42
+ {
43
+ effort: void 0,
44
+ engine: "claude",
45
+ model: FABLE.model,
46
+ provider: "anthropic"
47
+ },
48
+ {
49
+ effort: "xhigh",
50
+ engine: "codex",
51
+ model: "gpt-5.5",
52
+ provider: "openai"
53
+ },
54
+ {
55
+ effort: "xhigh",
56
+ engine: "opencode",
57
+ model: "fireworks-ai/accounts/fireworks/models/glm-5p1",
58
+ provider: "fireworks"
59
+ }
60
+ ],
61
+ opus: [
62
+ {
63
+ effort: OPUS.effort,
64
+ engine: "claude",
65
+ model: OPUS.model,
66
+ provider: "anthropic"
67
+ },
68
+ {
69
+ effort: "high",
70
+ engine: "codex",
71
+ model: "gpt-5.5",
72
+ provider: "openai"
73
+ },
74
+ {
75
+ effort: "high",
76
+ engine: "opencode",
77
+ model: "fireworks-ai/accounts/fireworks/models/glm-5p1",
78
+ provider: "fireworks"
79
+ }
80
+ ],
81
+ sonnet: [
82
+ {
83
+ effort: SONNET.effort,
84
+ engine: "claude",
85
+ model: SONNET.model,
86
+ provider: "anthropic"
87
+ },
88
+ {
89
+ effort: "medium",
90
+ engine: "codex",
91
+ model: "gpt-5.5",
92
+ provider: "openai"
93
+ },
94
+ {
95
+ effort: "medium",
96
+ engine: "opencode",
97
+ model: "synthetic/hf:moonshotai/Kimi-K2.5",
98
+ provider: "synthetic"
99
+ }
100
+ ],
101
+ haiku: [
102
+ {
103
+ effort: HAIKU.effort,
104
+ engine: "claude",
105
+ model: HAIKU.model,
106
+ provider: "anthropic"
107
+ },
108
+ {
109
+ effort: "low",
110
+ engine: "codex",
111
+ model: "gpt-5.5",
112
+ provider: "openai"
113
+ },
114
+ {
115
+ effort: "low",
116
+ engine: "opencode",
117
+ model: "synthetic/hf:moonshotai/Kimi-K2.5",
118
+ provider: "synthetic"
119
+ }
120
+ ]
121
+ };
122
+ /**
123
+ * A candidate is usable when its engine CLI exists AND a credential for its
124
+ * provider is resolvable. Both gates matter: an installed Claude with an
125
+ * expired key is as unusable as a missing CLI.
126
+ */
127
+ function isCandidateUsable(candidate, ctx) {
128
+ return ctx.available.has(candidate.engine) && ctx.keyed.has(candidate.provider);
129
+ }
130
+ /**
131
+ * Resolve a tier to the best available concrete target. Prefers the tier's
132
+ * first-choice (Claude) candidate; if its engine is missing or unkeyed, walks
133
+ * 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.
137
+ */
138
+ function resolveTier(tier, ctx) {
139
+ const chain = TIER_CHAINS[tier] ?? TIER_CHAINS.sonnet;
140
+ for (let i = 0, { length } = chain; i < length; i += 1) {
141
+ const candidate = chain[i];
142
+ if (isCandidateUsable(candidate, ctx)) return i === 0 ? {
143
+ candidate,
144
+ reason: "preferred"
145
+ } : {
146
+ candidate,
147
+ from: tier,
148
+ reason: "fellback"
149
+ };
150
+ }
151
+ }
152
+
153
+ //#endregion
154
+ exports.TIER_CHAINS = TIER_CHAINS;
155
+ exports.isCandidateUsable = isCandidateUsable;
156
+ exports.resolveTier = resolveTier;
@@ -22,7 +22,15 @@ export declare function backoffFor(attempt: number): number;
22
22
  * Update sites (when an agent changes its flag surface): 1. The relevant case
23
23
  * below. 2. The agent's docs link (cited inline).
24
24
  */
25
- export declare function buildArgs(agent: AiAgentName, opts: SpawnAiAgentOptions): string[];
25
+ export declare function buildArgs(agent: AiAgentName, options: SpawnAiAgentOptions): string[];
26
+ /**
27
+ * Fable and Mythos run adaptive thinking only — thinking is always on and there
28
+ * is no manual thinking-budget knob. The effort dial does not apply the way it
29
+ * does on Opus, so the spawn layer drops `--effort` for these models rather
30
+ * than passing a level they should ignore. Matches both alias and full-id
31
+ * shapes (`fable`, `claude-fable-5`, `mythos`, `claude-mythos-5`).
32
+ */
33
+ export declare function isAdaptiveOnlyModel(model: string): boolean;
26
34
  export declare function isOverloaded(stdout: string, stderr: string): boolean;
27
35
  export declare function pickAgent(requested: AiAgentName | undefined, cwd: string): Promise<AiAgentName>;
28
36
  /**
@@ -46,4 +54,4 @@ export declare function pickAgent(requested: AiAgentName | undefined, cwd: strin
46
54
  * Throws when the requested agent isn't on PATH (or, when no agent
47
55
  * is requested, when none of the known agents are on PATH).
48
56
  */
49
- export declare function spawnAiAgent(opts: SpawnAiAgentOptions): Promise<AgentSpawnResult>;
57
+ export declare function spawnAiAgent(options: SpawnAiAgentOptions): Promise<AgentSpawnResult>;
package/dist/ai/spawn.js CHANGED
@@ -2,12 +2,12 @@
2
2
  /* Socket Lib - Built with rolldown */
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  const require_primordials_error = require('../primordials/error.js');
5
- const require_primordials_date = require('../primordials/date.js');
6
5
  const require_primordials_object = require('../primordials/object.js');
6
+ const require_primordials_date = require('../primordials/date.js');
7
7
  const require_errors_message = require('../errors/message.js');
8
- const require_ai_discover = require('./discover.js');
9
8
  const require_process_spawn_errors = require('../process/spawn/errors.js');
10
9
  const require_process_spawn_child = require('../process/spawn/child.js');
10
+ const require_ai_discover = require('./discover.js');
11
11
  const require_primordials_promise = require('../primordials/promise.js');
12
12
 
13
13
  //#region src/ai/spawn.mts
@@ -38,62 +38,81 @@ function backoffFor(attempt) {
38
38
  * Update sites (when an agent changes its flag surface): 1. The relevant case
39
39
  * below. 2. The agent's docs link (cited inline).
40
40
  */
41
- function buildArgs(agent, opts) {
42
- const allAllowed = [...opts.tools, ...opts.allow ?? []];
41
+ function buildArgs(agent, options) {
42
+ options = {
43
+ __proto__: null,
44
+ ...options
45
+ };
46
+ const allAllowed = [...options.tools, ...options.allow ?? []];
43
47
  switch (agent) {
44
48
  case "claude": {
45
49
  const args = [
46
50
  "--print",
47
51
  "--no-session-persistence",
48
52
  "--permission-mode",
49
- opts.permissionMode,
53
+ options.permissionMode,
50
54
  "--add-dir",
51
- opts.cwd
55
+ options.cwd
52
56
  ];
53
- for (const dir of opts.addDirs ?? []) args.push("--add-dir", dir);
54
- if (opts.model) args.push("--model", opts.model);
57
+ for (const dir of options.addDirs ?? []) args.push("--add-dir", dir);
58
+ if (options.model) args.push("--model", options.model);
59
+ if (options.effort && !isAdaptiveOnlyModel(options.model ?? "")) args.push("--effort", options.effort);
55
60
  if (allAllowed.length > 0) args.push("--allowedTools", ...allAllowed);
56
- if (opts.disallow.length > 0) args.push("--disallowedTools", ...opts.disallow);
57
- if (opts.extraArgs) args.push(...opts.extraArgs);
61
+ if (options.disallow.length > 0) args.push("--disallowedTools", ...options.disallow);
62
+ if (options.extraArgs) args.push(...options.extraArgs);
58
63
  return args;
59
64
  }
60
65
  case "codex": {
61
66
  const args = ["--print"];
62
- if (opts.permissionMode === "plan") args.push("--read-only");
63
- if (opts.model) args.push("--model", opts.model);
67
+ if (options.permissionMode === "plan") args.push("--read-only");
68
+ if (options.model) args.push("--model", options.model);
69
+ if (options.effort) {
70
+ const codexEffort = options.effort === "max" ? "xhigh" : options.effort;
71
+ args.push("-c", `model_reasoning_effort=${codexEffort}`);
72
+ }
64
73
  if (allAllowed.length > 0) args.push("--tools", allAllowed.join(","));
65
- if (opts.disallow.length > 0) args.push("--disallow-tools", opts.disallow.join(","));
66
- args.push("--cwd", opts.cwd);
67
- if (opts.extraArgs) args.push(...opts.extraArgs);
74
+ if (options.disallow.length > 0) args.push("--disallow-tools", options.disallow.join(","));
75
+ args.push("--cwd", options.cwd);
76
+ if (options.extraArgs) args.push(...options.extraArgs);
68
77
  return args;
69
78
  }
70
79
  case "gemini": {
71
80
  const args = [
72
81
  "--no-interactive",
73
82
  "--workspace",
74
- opts.cwd
83
+ options.cwd
75
84
  ];
76
- if (opts.model) args.push("--model", opts.model);
85
+ if (options.model) args.push("--model", options.model);
77
86
  if (allAllowed.length > 0) args.push("--allowed-tools", allAllowed.join(","));
78
- if (opts.disallow.length > 0) args.push("--denied-tools", opts.disallow.join(","));
79
- if (opts.permissionMode === "plan") args.push("--read-only");
80
- if (opts.extraArgs) args.push(...opts.extraArgs);
87
+ if (options.disallow.length > 0) args.push("--denied-tools", options.disallow.join(","));
88
+ if (options.permissionMode === "plan") args.push("--read-only");
89
+ if (options.extraArgs) args.push(...options.extraArgs);
81
90
  return args;
82
91
  }
83
92
  case "opencode": {
84
93
  const args = [
85
94
  "--print",
86
95
  "--cwd",
87
- opts.cwd
96
+ options.cwd
88
97
  ];
89
- if (opts.model) args.push("--model", opts.model);
98
+ if (options.model) args.push("--model", options.model);
90
99
  if (allAllowed.length > 0) args.push("--tools", allAllowed.join(","));
91
- if (opts.disallow.length > 0) args.push("--no-tools", opts.disallow.join(","));
92
- if (opts.extraArgs) args.push(...opts.extraArgs);
100
+ if (options.disallow.length > 0) args.push("--no-tools", options.disallow.join(","));
101
+ if (options.extraArgs) args.push(...options.extraArgs);
93
102
  return args;
94
103
  }
95
104
  }
96
105
  }
106
+ /**
107
+ * Fable and Mythos run adaptive thinking only — thinking is always on and there
108
+ * is no manual thinking-budget knob. The effort dial does not apply the way it
109
+ * does on Opus, so the spawn layer drops `--effort` for these models rather
110
+ * than passing a level they should ignore. Matches both alias and full-id
111
+ * shapes (`fable`, `claude-fable-5`, `mythos`, `claude-mythos-5`).
112
+ */
113
+ function isAdaptiveOnlyModel(model) {
114
+ return /\b(?:fable|mythos)\b/i.test(model) || /claude-(?:fable|mythos)/i.test(model);
115
+ }
97
116
  function isOverloaded(stdout, stderr) {
98
117
  const re = /API Error: 529|Overloaded/i;
99
118
  return re.test(stdout) || re.test(stderr);
@@ -133,9 +152,13 @@ async function pickAgent(requested, cwd) {
133
152
  * Throws when the requested agent isn't on PATH (or, when no agent
134
153
  * is requested, when none of the known agents are on PATH).
135
154
  */
136
- async function spawnAiAgent(opts) {
137
- const agent = await pickAgent(opts.agent, opts.cwd);
138
- const args = buildArgs(agent, opts);
155
+ async function spawnAiAgent(options) {
156
+ options = {
157
+ __proto__: null,
158
+ ...options
159
+ };
160
+ const agent = await pickAgent(options.agent, options.cwd);
161
+ const args = buildArgs(agent, options);
139
162
  let stdout = "";
140
163
  let stderr = "";
141
164
  let exitCode = 0;
@@ -148,18 +171,18 @@ async function spawnAiAgent(opts) {
148
171
  exitCode = 0;
149
172
  try {
150
173
  const child = require_process_spawn_child.spawn(agent, args, {
151
- cwd: opts.cwd,
174
+ cwd: options.cwd,
152
175
  stdio: "pipe",
153
176
  stdioString: true,
154
- timeout: opts.timeoutMs
177
+ timeout: options.timeoutMs
155
178
  });
156
- child.stdin?.end(opts.prompt);
179
+ child.stdin?.end(options.prompt);
157
180
  const result = await child;
158
181
  stdout = String(result.stdout ?? "");
159
182
  stderr = String(result.stderr ?? "");
160
183
  exitCode = result.code ?? 0;
161
184
  } catch (e) {
162
- if (/* @__PURE__ */ require_process_spawn_errors.isSpawnError(e)) {
185
+ if (require_process_spawn_errors.isSpawnError(e)) {
163
186
  stdout = String(e.stdout ?? "");
164
187
  stderr = String(e.stderr ?? "");
165
188
  exitCode = e.code ?? 1;
@@ -175,6 +198,7 @@ async function spawnAiAgent(opts) {
175
198
  attempts,
176
199
  durationMs: require_primordials_date.DateNow() - start,
177
200
  exitCode,
201
+ overloaded: isOverloaded(stdout, stderr),
178
202
  stderr,
179
203
  stdout
180
204
  };
@@ -183,6 +207,7 @@ async function spawnAiAgent(opts) {
183
207
  //#endregion
184
208
  exports.backoffFor = backoffFor;
185
209
  exports.buildArgs = buildArgs;
210
+ exports.isAdaptiveOnlyModel = isAdaptiveOnlyModel;
186
211
  exports.isOverloaded = isOverloaded;
187
212
  exports.pickAgent = pickAgent;
188
213
  exports.spawnAiAgent = spawnAiAgent;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @file The terminal-status contract a delegated subagent returns to its
3
+ * orchestrator. Subagent-driven development depends on a SMALL, fixed status
4
+ * vocabulary so the orchestrator can route deterministically instead of
5
+ * parsing free-form prose: a subagent that "sort of finished but has a worry"
6
+ * must be distinguishable from one that is genuinely blocked, because they
7
+ * escalate differently. The four states and their escalation paths are the
8
+ * contract; `escalationFor` is the single place that maps a state to what the
9
+ * orchestrator does next. Encoding it as a typed union + map (rather than a
10
+ * doc convention) is the code-is-law surface: a stray status string fails the
11
+ * guard, and `agent-delegation.md` is checked against this union so the prose
12
+ * can't drift from the code.
13
+ */
14
+ /**
15
+ * A subagent's terminal status.
16
+ *
17
+ * - `done` — work complete, no reservations; the orchestrator advances.
18
+ * - `done-with-concerns` — work complete but the subagent flagged a risk or
19
+ * follow-up the orchestrator should surface before advancing.
20
+ * - `needs-context` — the subagent lacks information it cannot obtain itself; the
21
+ * orchestrator supplies it and re-dispatches (a fresh attempt, not the same
22
+ * model retrying blind).
23
+ * - `blocked` — the work cannot proceed without a decision or action only the
24
+ * user can provide; the orchestrator escalates to the user and stops.
25
+ */
26
+ export type SubagentStatus = 'blocked' | 'done' | 'done-with-concerns' | 'needs-context';
27
+ /**
28
+ * What the orchestrator does for each terminal status. `advance` continues to
29
+ * the next unit of work; `surface` advances but raises the concern first;
30
+ * `redispatch` re-runs the unit with the missing context added; `escalate`
31
+ * stops and hands the decision to the user.
32
+ */
33
+ export type SubagentEscalation = 'advance' | 'escalate' | 'redispatch' | 'surface';
34
+ /**
35
+ * The canonical status set, sorted, for callers that need to enumerate or
36
+ * validate against the full vocabulary (the doc-parity check reads this).
37
+ */
38
+ export declare const SUBAGENT_STATUSES: readonly SubagentStatus[];
39
+ /**
40
+ * Map a terminal status to the orchestrator action it requires. A status
41
+ * outside the vocabulary is itself a contract violation, so this throws rather
42
+ * than guessing — never force a retry on an unrecognized state.
43
+ */
44
+ export declare function escalationFor(status: SubagentStatus): SubagentEscalation;
45
+ /**
46
+ * True when `value` names a status in the contract.
47
+ */
48
+ export declare function isSubagentStatus(value: string): value is SubagentStatus;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /* Socket Lib - Built with rolldown */
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_primordials_error = require('../primordials/error.js');
5
+
6
+ //#region src/ai/subagent-status.mts
7
+ /**
8
+ * @file The terminal-status contract a delegated subagent returns to its
9
+ * orchestrator. Subagent-driven development depends on a SMALL, fixed status
10
+ * vocabulary so the orchestrator can route deterministically instead of
11
+ * parsing free-form prose: a subagent that "sort of finished but has a worry"
12
+ * must be distinguishable from one that is genuinely blocked, because they
13
+ * escalate differently. The four states and their escalation paths are the
14
+ * contract; `escalationFor` is the single place that maps a state to what the
15
+ * orchestrator does next. Encoding it as a typed union + map (rather than a
16
+ * doc convention) is the code-is-law surface: a stray status string fails the
17
+ * guard, and `agent-delegation.md` is checked against this union so the prose
18
+ * can't drift from the code.
19
+ */
20
+ const ESCALATION = {
21
+ __proto__: null,
22
+ blocked: "escalate",
23
+ done: "advance",
24
+ "done-with-concerns": "surface",
25
+ "needs-context": "redispatch"
26
+ };
27
+ /**
28
+ * The canonical status set, sorted, for callers that need to enumerate or
29
+ * validate against the full vocabulary (the doc-parity check reads this).
30
+ */
31
+ const SUBAGENT_STATUSES = [
32
+ "blocked",
33
+ "done",
34
+ "done-with-concerns",
35
+ "needs-context"
36
+ ];
37
+ /**
38
+ * Map a terminal status to the orchestrator action it requires. A status
39
+ * outside the vocabulary is itself a contract violation, so this throws rather
40
+ * than guessing — never force a retry on an unrecognized state.
41
+ */
42
+ function escalationFor(status) {
43
+ const action = ESCALATION[status];
44
+ if (!action) throw new require_primordials_error.ErrorCtor(`escalationFor: unknown subagent status "${status}". Expected one of: ${SUBAGENT_STATUSES.join(", ")}. Return a status from the SubagentStatus contract.`);
45
+ return action;
46
+ }
47
+ /**
48
+ * True when `value` names a status in the contract.
49
+ */
50
+ function isSubagentStatus(value) {
51
+ return SUBAGENT_STATUSES.includes(value);
52
+ }
53
+
54
+ //#endregion
55
+ exports.SUBAGENT_STATUSES = SUBAGENT_STATUSES;
56
+ exports.escalationFor = escalationFor;
57
+ exports.isSubagentStatus = isSubagentStatus;
@@ -0,0 +1,60 @@
1
+ /**
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
4
+ * work (a lint rule, a hook, a doc edit) and resolve it to a concrete `{
5
+ * model, effort }` pair. Before this module each orchestrator redefined the
6
+ * same three-row table, so a model-generation bump (Sonnet 4.6 → 5.0, Opus
7
+ * 4.8 → 4.9) meant editing N files and risked drift. Import `AI_TIER` /
8
+ * `tierToSpawn` here instead; a generation roll is then a single edit. The
9
+ * mapping encodes the CLAUDE.md token-spend rule ("match model AND effort to
10
+ * the job"): a cheap model left on the session's default effort still burns
11
+ * reasoning a mechanical task never needs, and a premium model on low effort
12
+ * under-thinks a hard one — so effort is pinned ALONGSIDE the model per
13
+ * tier.
14
+ */
15
+ import type { AiEffort } from './types.mts';
16
+ /**
17
+ * The capability tiers, least → most capable. Orchestrators classify each unit
18
+ * of work into one of these (a regex-shaped rewrite → `haiku`; a caller-chain
19
+ * rewrite → `sonnet`; a module split / new-enforcer authoring → `opus`).
20
+ * `fable` is the apex escalation tier — reserve it for the hardest cases (a
21
+ * stuck compiler / native problem, planning + decomposition of a large task),
22
+ * never a first reach, and prefer to ask before selecting it. It is the most
23
+ * expensive model on the board (~2× opus, ~10× haiku output), so an
24
+ * orchestrator should pick the LEAST-capable tier that does the job and
25
+ * escalate to `fable` only after cheaper tiers fail.
26
+ */
27
+ export type AiTier = 'fable' | 'haiku' | 'opus' | 'sonnet';
28
+ /**
29
+ * Resolved spawn parameters for a tier — spread alongside an `AI_PROFILE` into
30
+ * a `spawnAiAgent` call (`{ ...AI_PROFILE.verify, ...tierToSpawn('opus'),
31
+ * prompt, cwd }`).
32
+ */
33
+ export interface TierSpawn {
34
+ readonly effort: AiEffort;
35
+ readonly model: string;
36
+ }
37
+ /**
38
+ * Canonical tier → { model, effort }. The single source of truth for which
39
+ * Claude model + effort each tier runs. Bump here on a model generation roll;
40
+ * every orchestrator that imports this picks it up.
41
+ *
42
+ * - `haiku` / low — deterministic, regex-shaped rewrites (identifier rename,
43
+ * null→undefined, single-token substitution).
44
+ * - `sonnet` / medium — control-flow / caller-chain reasoning (fetch→httpJson,
45
+ * sync→async), a check script, a doc edit.
46
+ * - `opus` / high — real authoring / refactoring (module split, a brand-new hook
47
+ * or lint rule with its test).
48
+ * - `fable` / xhigh — apex escalation only: a stuck compiler / native problem
49
+ * after cheaper tiers fail, or planning + decomposition of a large task whose
50
+ * chunks then run on cheaper tiers. Most expensive model on the board; never
51
+ * a default.
52
+ */
53
+ export declare const AI_TIER: Readonly<Record<AiTier, TierSpawn>>;
54
+ /**
55
+ * Resolve a tier label to its `{ model, effort }` spawn pair. A convenience
56
+ * over indexing `AI_TIER` directly; returns the `sonnet` row for an unknown
57
+ * label so a caller that hands in a stray string degrades to the safe default
58
+ * rather than producing `undefined` model/effort.
59
+ */
60
+ export declare function tierToSpawn(tier: AiTier): TierSpawn;