@socketsecurity/lib 6.0.9 → 6.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +8 -9
- package/dist/abort/signal.d.ts +1 -1
- package/dist/abort/signal.js +1 -1
- package/dist/ai/agent-context.d.mts +1 -1
- package/dist/ai/agent-context.js +3 -2
- package/dist/ai/backends.d.mts +3 -3
- package/dist/ai/backends.js +2 -2
- package/dist/ai/billing-context.d.mts +74 -0
- package/dist/ai/billing-context.js +129 -0
- package/dist/ai/credentials.d.mts +39 -5
- package/dist/ai/credentials.js +61 -6
- package/dist/ai/discover.d.mts +4 -0
- package/dist/ai/discover.js +4 -0
- package/dist/ai/exec.d.mts +1 -1
- package/dist/ai/exec.js +1 -1
- package/dist/ai/http.d.mts +8 -8
- package/dist/ai/http.js +6 -6
- package/dist/ai/profiles.d.mts +9 -10
- package/dist/ai/profiles.js +0 -5
- package/dist/ai/role.d.mts +58 -0
- package/dist/ai/role.js +96 -0
- package/dist/ai/route-heuristic.d.mts +177 -0
- package/dist/ai/route-heuristic.js +194 -0
- package/dist/ai/route.d.mts +10 -9
- package/dist/ai/route.js +14 -13
- package/dist/ai/spawn.d.mts +2 -1
- package/dist/ai/spawn.js +25 -2
- package/dist/ai/subagent-status.d.mts +2 -0
- package/dist/ai/subagent-status.js +2 -0
- package/dist/ai/tier.d.mts +1 -1
- package/dist/ai/types.d.mts +9 -2
- package/dist/ai/worktree.d.mts +1 -1
- package/dist/ai/worktree.js +3 -2
- package/dist/argv/parse.d.ts +2 -0
- package/dist/argv/parse.js +2 -0
- package/dist/bin/_internal.d.ts +1 -1
- package/dist/bin/_internal.js +1 -1
- package/dist/bin/prim.cjs +446 -300
- package/dist/bin/shadow.js +2 -1
- package/dist/bin/which.d.ts +28 -3
- package/dist/bin/which.js +45 -3
- package/dist/cacache/_internal.d.ts +10 -2
- package/dist/cacache/_internal.js +6 -10
- package/dist/cache/ttl/_internal.d.ts +33 -0
- package/dist/cache/ttl/_internal.js +68 -0
- package/dist/cache/ttl/browser.d.ts +56 -0
- package/dist/cache/ttl/browser.js +257 -0
- package/dist/cache/ttl/store.js +10 -33
- package/dist/cache/ttl/types.d.ts +46 -3
- package/dist/checks/primordials-defaults.d.ts +5 -5
- package/dist/checks/primordials-defaults.js +5 -5
- package/dist/checks/primordials.d.ts +1 -1
- package/dist/checks/primordials.js +25 -17
- package/dist/cli/check-primordials.d.ts +6 -1
- package/dist/cli/check-primordials.js +14 -5
- package/dist/cli/check.js +1 -1
- package/dist/cli/socket-lib.d.ts +1 -1
- package/dist/cli/socket-lib.js +3 -3
- package/dist/colors/socket-palette.d.ts +1 -1
- package/dist/compression/brotli.d.ts +6 -2
- package/dist/compression/brotli.js +4 -0
- package/dist/compression/gzip.d.ts +6 -2
- package/dist/compression/gzip.js +6 -1
- package/dist/config/layers.d.ts +4 -4
- package/dist/config/layers.js +4 -4
- package/dist/constants/agents.d.ts +3 -0
- package/dist/constants/agents.js +3 -0
- package/dist/constants/node.d.ts +14 -0
- package/dist/constants/node.js +14 -0
- package/dist/constants/package-default-node-range.js +1 -5
- package/dist/constants/packages.d.ts +5 -0
- package/dist/constants/packages.js +5 -0
- package/dist/constants/platform.d.ts +1 -1
- package/dist/constants/platform.js +1 -1
- package/dist/constants/socket.js +1 -1
- package/dist/constants/typescript.d.ts +5 -0
- package/dist/constants/typescript.js +5 -0
- package/dist/debug/_internal.d.ts +22 -7
- package/dist/debug/_internal.js +33 -15
- package/dist/debug/namespace.js +11 -8
- package/dist/debug/output.d.ts +12 -1
- package/dist/debug/output.js +33 -16
- package/dist/dlx/binary-resolution.js +7 -4
- package/dist/eco/npm/npm/parse-lockfile.js +2 -1
- package/dist/eco/npm/vlt/exec.d.ts +1 -1
- package/dist/eco/npm/vlt/exec.js +1 -1
- package/dist/env/agents.d.ts +6 -0
- package/dist/env/agents.js +29 -0
- package/dist/env/flags.d.ts +12 -0
- package/dist/env/flags.js +23 -0
- package/dist/env/github-status.js +2 -2
- package/dist/env/providers.d.ts +6 -0
- package/dist/env/providers.js +23 -0
- package/dist/env/proxy.js +1 -1
- package/dist/env/rewire.d.ts +32 -0
- package/dist/env/rewire.js +55 -23
- package/dist/env/runtimes.d.ts +9 -0
- package/dist/env/runtimes.js +53 -0
- package/dist/env/socket-cli.d.ts +5 -2
- package/dist/env/socket-cli.js +6 -3
- package/dist/errors/predicates.d.ts +3 -2
- package/dist/errors/predicates.js +5 -3
- package/dist/errors/stack.js +2 -1
- package/dist/events/exit/_internal.d.ts +1 -23
- package/dist/external/@npmcli/package-json.js +179 -88
- package/dist/external/@npmcli/promise-spawn.js +2 -2
- package/dist/external/@sinclair/typebox/value.js +5 -4
- package/dist/external/@socketregistry/yocto-spinner.js +3 -3
- package/dist/external/adm-zip.d.ts +82 -0
- package/dist/external/adm-zip.js +2 -2
- package/dist/external/cacache.d.ts +87 -0
- package/dist/external/debug.d.ts +22 -0
- package/dist/external/debug.js +11 -4
- package/dist/external/del.d.ts +1 -0
- package/dist/external/external-pack.d.ts +12 -0
- package/dist/external/external-pack.js +41 -34
- package/dist/external/fast-glob.d.ts +8 -0
- package/dist/external/fast-sort.d.ts +1 -0
- package/dist/external/get-east-asian-width.d.ts +5 -0
- package/dist/external/get-east-asian-width.js +8 -1
- package/dist/external/has-flag.d.ts +1 -0
- package/dist/external/inquirer-pack.d.ts +18 -0
- package/dist/external/libnpmexec.d.ts +35 -0
- package/dist/external/libnpmpack.d.ts +1 -0
- package/dist/external/make-fetch-happen.d.ts +13 -0
- package/dist/external/normalize-package-data.d.ts +4 -0
- package/dist/external/npm-core.d.ts +14 -0
- package/dist/external/npm-pack.d.ts +24 -0
- package/dist/external/npm-pack.js +1551 -1867
- package/dist/external/npm-package-arg.d.ts +4 -0
- package/dist/external/p-map.js +8 -1
- package/dist/external/pacote.d.ts +15 -0
- package/dist/external/pico-pack.d.ts +16 -0
- package/dist/external/pico-pack.js +38 -23
- package/dist/external/picomatch.d.ts +96 -0
- package/dist/external/pony-cause.d.ts +14 -0
- package/dist/external/semver.d.ts +60 -0
- package/dist/external/semver.js +1459 -4
- package/dist/external/shell-quote.d.ts +51 -0
- package/dist/external/shell-quote.js +55 -15
- package/dist/external/signal-exit.d.ts +1 -0
- package/dist/external/spdx-correct.d.ts +4 -0
- package/dist/external/spdx-expression-parse.d.ts +4 -0
- package/dist/external/spdx-pack.d.ts +10 -0
- package/dist/external/std-env.d.ts +284 -0
- package/dist/external/std-env.js +323 -0
- package/dist/external/streaming-iterables.d.ts +11 -0
- package/dist/external/supports-color.d.ts +1 -0
- package/dist/external/tar-fs.d.ts +31 -0
- package/dist/external/validate-npm-package-name.d.ts +4 -0
- package/dist/external/which.d.ts +25 -0
- package/dist/external/which.js +2 -2
- package/dist/external/yargs-parser.d.ts +2 -0
- package/dist/external/yargs-parser.js +11 -3
- package/dist/external/yoctocolors-cjs.d.ts +51 -0
- package/dist/external-tools/bazel/asset-names.d.ts +1 -1
- package/dist/external-tools/bazel/from-download.d.ts +1 -1
- package/dist/external-tools/bazel/resolve.d.ts +3 -0
- package/dist/external-tools/bazel/resolve.js +3 -0
- package/dist/external-tools/cdxgen/asset-names.d.ts +5 -5
- package/dist/external-tools/cdxgen/asset-names.js +3 -3
- package/dist/external-tools/cdxgen/from-download.d.ts +2 -2
- package/dist/external-tools/cdxgen/from-download.js +1 -1
- package/dist/external-tools/cdxgen/resolve.d.ts +4 -1
- package/dist/external-tools/cdxgen/resolve.js +4 -1
- package/dist/external-tools/cdxgen/types.d.ts +1 -1
- package/dist/external-tools/from-download.d.ts +2 -2
- package/dist/external-tools/from-download.js +1 -1
- package/dist/external-tools/janus/asset-names.d.ts +4 -1
- package/dist/external-tools/janus/asset-names.js +3 -0
- package/dist/external-tools/janus/from-download.d.ts +3 -3
- package/dist/external-tools/janus/from-download.js +2 -2
- package/dist/external-tools/janus/resolve.d.ts +3 -0
- package/dist/external-tools/janus/resolve.js +3 -0
- package/dist/external-tools/jre/asset-names.d.ts +3 -1
- package/dist/external-tools/jre/asset-names.js +2 -0
- package/dist/external-tools/jre/from-download.d.ts +1 -1
- package/dist/external-tools/manifest.d.ts +5 -3
- package/dist/external-tools/manifest.js +4 -2
- package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
- package/dist/external-tools/opengrep/resolve.d.ts +3 -0
- package/dist/external-tools/opengrep/resolve.js +3 -0
- package/dist/external-tools/python/asset-names.d.ts +3 -1
- package/dist/external-tools/python/asset-names.js +7 -3
- package/dist/external-tools/python/pin.js +3 -1
- package/dist/external-tools/python/resolve.d.ts +3 -0
- package/dist/external-tools/python/resolve.js +3 -0
- package/dist/external-tools/sbt/resolve.d.ts +3 -0
- package/dist/external-tools/sbt/resolve.js +3 -0
- package/dist/external-tools/skillspector/from-uv.d.ts +1 -1
- package/dist/external-tools/synp/resolve.d.ts +3 -0
- package/dist/external-tools/synp/resolve.js +3 -0
- package/dist/external-tools/trivy/asset-names.d.ts +1 -1
- package/dist/external-tools/trivy/resolve.d.ts +3 -0
- package/dist/external-tools/trivy/resolve.js +3 -0
- package/dist/external-tools/trufflehog/asset-names.d.ts +4 -1
- package/dist/external-tools/trufflehog/asset-names.js +3 -0
- package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
- package/dist/external-tools/trufflehog/resolve.d.ts +3 -0
- package/dist/external-tools/trufflehog/resolve.js +3 -0
- package/dist/external-tools/uv/asset-names.d.ts +1 -1
- package/dist/external-tools/uv/resolve.d.ts +3 -0
- package/dist/external-tools/uv/resolve.js +3 -0
- package/dist/fleet/repo-config.d.ts +8 -6
- package/dist/fleet/repo-config.js +8 -6
- package/dist/fs/_internal.d.ts +1 -1
- package/dist/fs/_internal.js +1 -1
- package/dist/fs/access.d.ts +2 -0
- package/dist/fs/access.js +2 -0
- package/dist/fs/allowed-dirs-cache.js +5 -3
- package/dist/fs/find.js +1 -2
- package/dist/fs/inspect.d.ts +2 -2
- package/dist/fs/read-file.js +3 -4
- package/dist/fs/safe.js +1 -1
- package/dist/git/_internal.js +5 -1
- package/dist/github/commit.d.ts +92 -0
- package/dist/github/commit.js +113 -0
- package/dist/github/ghsa.js +1 -1
- package/dist/github/refs-graphql.js +1 -1
- package/dist/github/request.js +1 -1
- package/dist/github/token.d.ts +5 -2
- package/dist/github/token.js +6 -4
- package/dist/github/workflow-runs.d.ts +107 -0
- package/dist/github/workflow-runs.js +98 -0
- package/dist/http-request/_internal.d.ts +1 -1
- package/dist/http-request/browser.d.ts +6 -0
- package/dist/http-request/browser.js +3 -2
- package/dist/http-request/download.js +2 -0
- package/dist/http-request/headers.d.ts +1 -1
- package/dist/http-request/headers.js +1 -1
- package/dist/http-request/request-attempt.js +6 -3
- package/dist/http-request/request-types.d.ts +10 -1
- package/dist/http-request/request.js +2 -2
- package/dist/http-request/user-agent.d.ts +23 -2
- package/dist/http-request/user-agent.js +48 -6
- package/dist/integrity.d.ts +3 -1
- package/dist/integrity.js +3 -1
- package/dist/json/format.js +4 -1
- package/dist/logger/_internal.d.ts +13 -15
- package/dist/logger/_internal.js +21 -21
- package/dist/logger/colors.d.ts +9 -3
- package/dist/logger/colors.js +6 -13
- package/dist/logger/console-methods.js +2 -2
- package/dist/logger/console.d.ts +1 -0
- package/dist/logger/console.js +9 -9
- package/dist/logger/node.js +2 -1
- package/dist/native-messaging/install.js +1 -1
- package/dist/native-messaging/rate-limit.d.ts +4 -1
- package/dist/native-messaging/rate-limit.js +4 -1
- package/dist/node/events.d.ts +3 -0
- package/dist/node/events.js +3 -0
- package/dist/node/fs.d.ts +1 -1
- package/dist/node/timers-promises.d.ts +3 -0
- package/dist/node/timers-promises.js +3 -0
- package/dist/node/url.d.ts +3 -0
- package/dist/node/url.js +3 -0
- package/dist/npm/meta-cache.d.ts +183 -0
- package/dist/npm/meta-cache.js +318 -0
- package/dist/npm/meta-slice.d.ts +27 -0
- package/dist/npm/meta-slice.js +68 -0
- package/dist/npm/meta-types.d.ts +282 -0
- package/dist/npm/meta-types.js +2 -0
- package/dist/npm/meta.d.ts +125 -0
- package/dist/npm/meta.js +347 -0
- package/dist/npm/registry.d.ts +212 -0
- package/dist/npm/registry.js +284 -0
- package/dist/objects/getters.d.ts +1 -1
- package/dist/objects/getters.js +1 -1
- package/dist/packages/manifest.js +6 -7
- package/dist/packages/metadata-extensions.js +2 -4
- package/dist/packages/provenance.d.ts +8 -0
- package/dist/packages/provenance.js +8 -0
- package/dist/packages/tarball.js +1 -2
- package/dist/packages/validation.d.ts +0 -10
- package/dist/packages/validation.js +0 -14
- package/dist/paths/exts.d.ts +30 -0
- package/dist/paths/exts.js +30 -0
- package/dist/paths/filenames.d.ts +6 -0
- package/dist/paths/filenames.js +6 -0
- package/dist/paths/globs.d.ts +6 -0
- package/dist/paths/globs.js +6 -0
- package/dist/paths/resolve.js +19 -14
- package/dist/paths/socket.d.ts +8 -8
- package/dist/paths/socket.js +8 -8
- package/dist/perf/report.js +4 -2
- package/dist/pkg-ext/data.js +0 -2
- package/dist/primordials/globals.d.ts +1 -1
- package/dist/primordials/globals.js +1 -1
- package/dist/primordials/headers.d.ts +13 -1
- package/dist/primordials/headers.js +13 -1
- package/dist/primordials/process.d.ts +1 -1
- package/dist/primordials/process.js +1 -1
- package/dist/primordials/url.d.ts +18 -0
- package/dist/primordials/url.js +18 -0
- package/dist/process/spawn/child.js +3 -5
- package/dist/promises/_internal.d.ts +1 -1
- package/dist/promises/_internal.js +1 -2
- package/dist/promises/options.js +3 -3
- package/dist/releases/socket-btm-binary-naming.js +12 -1
- package/dist/secrets/_internal.d.ts +1 -1
- package/dist/secrets/_internal.js +1 -1
- package/dist/secrets/find.d.ts +2 -2
- package/dist/secrets/find.js +2 -2
- package/dist/secrets/keychain.d.ts +10 -1
- package/dist/secrets/keychain.js +10 -1
- package/dist/secrets/socket-api-token.d.ts +1 -1
- package/dist/secrets/socket-api-token.js +1 -1
- package/dist/secrets/types.d.ts +1 -1
- package/dist/smol/http.d.ts +2 -0
- package/dist/smol/http.js +2 -0
- package/dist/smol/https.d.ts +2 -0
- package/dist/smol/https.js +2 -0
- package/dist/sorts/_internal.d.ts +2 -3
- package/dist/sorts/_internal.js +1 -3
- package/dist/spinner/format.js +2 -4
- package/dist/stdio/footer.js +8 -7
- package/dist/stdio/prompts.d.ts +8 -15
- package/dist/stdio/prompts.js +18 -29
- package/dist/strings/predicates.d.ts +2 -2
- package/dist/strings/search.js +1 -1
- package/dist/strings/types.d.ts +4 -0
- package/dist/strings/width.d.ts +1 -0
- package/dist/strings/width.js +17 -8
- package/dist/themes/context.d.ts +13 -0
- package/dist/themes/context.js +23 -8
- package/dist/versions/_internal.d.ts +43 -13
- package/dist/versions/_internal.js +27 -15
- package/dist/versions/compare.d.ts +16 -10
- package/dist/versions/compare.js +36 -16
- package/dist/versions/parse.js +1 -1
- package/dist/versions/range.js +3 -2
- package/dist/words/pluralize.js +4 -1
- package/llms.txt +63 -750
- package/package.json +200 -35
package/dist/ai/route.js
CHANGED
|
@@ -12,15 +12,16 @@ const require_ai_tier = require('./tier.js');
|
|
|
12
12
|
* credential for it is resolvable; otherwise the resolver walks a
|
|
13
13
|
* cross-engine equivalence ladder (Claude → Codex → an open-weight provider
|
|
14
14
|
* via opencode) and returns the best available equivalent. Why gate on
|
|
15
|
-
* existence: a
|
|
16
|
-
* expired Claude key, or neither plus an opencode/synthetic seat.
|
|
17
|
-
* `fable` then fails at spawn time; routing here degrades
|
|
18
|
-
* tells the caller WHY (the `reason`), so a skill can log
|
|
19
|
-
* gpt-5.5 (claude unavailable)" instead of crashing. Pure
|
|
20
|
-
* availability/keyed context — no I/O — so callers fan out their
|
|
21
|
-
* credential probes once and pass the result in. Pairs with
|
|
22
|
-
* `spawn.mts`: a Fable candidate carries `effort: undefined`
|
|
23
|
-
* adaptive-thinking-only and the spawn layer omits
|
|
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-
|
|
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-
|
|
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.
|
|
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.
|
|
118
|
+
model: "synthetic/hf:moonshotai/Kimi-K2.6",
|
|
118
119
|
provider: "synthetic"
|
|
119
120
|
}
|
|
120
121
|
]
|
package/dist/ai/spawn.d.mts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* permissionMode / no-session-persistence). The helper enforces this at the
|
|
6
6
|
* type level (`SpawnAiAgentOptions` requires the relevant fields) AND at the
|
|
7
7
|
* spawn site (per-agent flag translator). Why CLI subprocess instead of an
|
|
8
|
-
* SDK call:
|
|
8
|
+
* SDK call: Socket's contract matches what the local user sees when
|
|
9
9
|
* invoking the CLI — same auth config, same model availability, same tool
|
|
10
10
|
* permissions. SDK calls would diverge on auth handling and force per-agent
|
|
11
11
|
* SDK installs. Retry: 3 attempts on overload (HTTP 529 / "Overloaded"), exp.
|
|
@@ -35,6 +35,7 @@ export declare function buildArgs(agent: AiAgentName, options: SpawnAiAgentOptio
|
|
|
35
35
|
export declare function isAdaptiveOnlyModel(model: string): boolean;
|
|
36
36
|
export declare function isModelUnavailable(stdout: string, stderr: string): boolean;
|
|
37
37
|
export declare function isOverloaded(stdout: string, stderr: string): boolean;
|
|
38
|
+
export declare function isQuotaExhausted(stdout: string, stderr: string): boolean;
|
|
38
39
|
export declare function pickAgent(requested: AiAgentName | undefined, cwd: string): Promise<AiAgentName>;
|
|
39
40
|
/**
|
|
40
41
|
* Spawn an AI agent CLI subprocess with the locked-down flag set.
|
package/dist/ai/spawn.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.js');
|
|
4
5
|
const require_primordials_error = require('../primordials/error.js');
|
|
5
6
|
const require_primordials_object = require('../primordials/object.js');
|
|
6
7
|
const require_primordials_date = require('../primordials/date.js');
|
|
@@ -10,6 +11,8 @@ const require_process_spawn_child = require('../process/spawn/child.js');
|
|
|
10
11
|
const require_ai_discover = require('./discover.js');
|
|
11
12
|
const require_primordials_promise = require('../primordials/promise.js');
|
|
12
13
|
const require_ai_route = require('./route.js');
|
|
14
|
+
let node_process = require("node:process");
|
|
15
|
+
node_process = require_runtime.__toESM(node_process, 1);
|
|
13
16
|
|
|
14
17
|
//#region src/ai/spawn.mts
|
|
15
18
|
/**
|
|
@@ -19,7 +22,7 @@ const require_ai_route = require('./route.js');
|
|
|
19
22
|
* permissionMode / no-session-persistence). The helper enforces this at the
|
|
20
23
|
* type level (`SpawnAiAgentOptions` requires the relevant fields) AND at the
|
|
21
24
|
* spawn site (per-agent flag translator). Why CLI subprocess instead of an
|
|
22
|
-
* SDK call:
|
|
25
|
+
* SDK call: Socket's contract matches what the local user sees when
|
|
23
26
|
* invoking the CLI — same auth config, same model availability, same tool
|
|
24
27
|
* permissions. SDK calls would diverge on auth handling and force per-agent
|
|
25
28
|
* SDK installs. Retry: 3 attempts on overload (HTTP 529 / "Overloaded"), exp.
|
|
@@ -157,6 +160,21 @@ function isOverloaded(stdout, stderr) {
|
|
|
157
160
|
const re = /API Error: 529|Overloaded/i;
|
|
158
161
|
return re.test(stdout) || re.test(stderr);
|
|
159
162
|
}
|
|
163
|
+
const QUOTA_EXHAUSTED_PHRASES = [
|
|
164
|
+
"exceeded your current quota",
|
|
165
|
+
"insufficient_quota",
|
|
166
|
+
"quota exceeded",
|
|
167
|
+
"rate limit",
|
|
168
|
+
"rate-limited",
|
|
169
|
+
"rate_limit_error",
|
|
170
|
+
"usage limit"
|
|
171
|
+
];
|
|
172
|
+
function isQuotaExhausted(stdout, stderr) {
|
|
173
|
+
const text = `${stdout}\n${stderr}`.toLowerCase();
|
|
174
|
+
if (/\bapi error:\s*429\b/.test(text) || text.includes("429 too many requests")) return true;
|
|
175
|
+
for (let i = 0, { length } = QUOTA_EXHAUSTED_PHRASES; i < length; i += 1) if (text.includes(QUOTA_EXHAUSTED_PHRASES[i])) return true;
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
160
178
|
async function pickAgent(requested, cwd) {
|
|
161
179
|
const discovered = await require_ai_discover.discoverAiAgents({ repoRoot: cwd });
|
|
162
180
|
if (requested) {
|
|
@@ -212,6 +230,10 @@ async function spawnAiAgent(options) {
|
|
|
212
230
|
try {
|
|
213
231
|
const child = require_process_spawn_child.spawn(agent, args, {
|
|
214
232
|
cwd: options.cwd,
|
|
233
|
+
...options.env ? { env: {
|
|
234
|
+
...node_process.default.env,
|
|
235
|
+
...options.env
|
|
236
|
+
} } : {},
|
|
215
237
|
stdio: "pipe",
|
|
216
238
|
stdioString: true,
|
|
217
239
|
timeout: options.timeoutMs
|
|
@@ -277,7 +299,7 @@ async function spawnTierWithFallback(tier, ctx, options) {
|
|
|
277
299
|
candidate,
|
|
278
300
|
result
|
|
279
301
|
};
|
|
280
|
-
if (!result.unavailable) return {
|
|
302
|
+
if (!result.unavailable && !isQuotaExhausted(result.stdout, result.stderr)) return {
|
|
281
303
|
candidate,
|
|
282
304
|
fellOver,
|
|
283
305
|
result
|
|
@@ -297,6 +319,7 @@ exports.buildArgs = buildArgs;
|
|
|
297
319
|
exports.isAdaptiveOnlyModel = isAdaptiveOnlyModel;
|
|
298
320
|
exports.isModelUnavailable = isModelUnavailable;
|
|
299
321
|
exports.isOverloaded = isOverloaded;
|
|
322
|
+
exports.isQuotaExhausted = isQuotaExhausted;
|
|
300
323
|
exports.pickAgent = pickAgent;
|
|
301
324
|
exports.spawnAiAgent = spawnAiAgent;
|
|
302
325
|
exports.spawnTierWithFallback = spawnTierWithFallback;
|
|
@@ -44,5 +44,7 @@ export declare const SUBAGENT_STATUSES: readonly SubagentStatus[];
|
|
|
44
44
|
export declare function escalationFor(status: SubagentStatus): SubagentEscalation;
|
|
45
45
|
/**
|
|
46
46
|
* True when `value` names a status in the contract.
|
|
47
|
+
*
|
|
48
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
47
49
|
*/
|
|
48
50
|
export declare function isSubagentStatus(value: string): value is SubagentStatus;
|
|
@@ -46,6 +46,8 @@ function escalationFor(status) {
|
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* True when `value` names a status in the contract.
|
|
49
|
+
*
|
|
50
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
49
51
|
*/
|
|
50
52
|
function isSubagentStatus(value) {
|
|
51
53
|
return SUBAGENT_STATUSES.includes(value);
|
package/dist/ai/tier.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Canonical model + reasoning-effort ladder for AI orchestrators. The
|
|
3
|
-
*
|
|
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
|
package/dist/ai/types.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Shared types for the locked-down AI agent surface.
|
|
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.
|
|
16
|
+
* Permission mode passed to the agent's CLI. Socket's rule (CLAUDE.md
|
|
17
17
|
* "Programmatic Claude calls") requires every headless call to set one of these
|
|
18
18
|
* explicitly — never the agent's default.
|
|
19
19
|
*
|
|
@@ -103,6 +103,13 @@ export interface SpawnAiAgentOptions {
|
|
|
103
103
|
* claude-specific — other agents ignore it.
|
|
104
104
|
*/
|
|
105
105
|
readonly effort?: AiEffort | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Extra environment variables for the spawned agent process, merged over the
|
|
108
|
+
* inherited env. Gated off by default (inherit-only when absent). Used by
|
|
109
|
+
* egress-containment callers to inject `HTTP_PROXY` / `NODE_OPTIONS`; no
|
|
110
|
+
* effect when omitted.
|
|
111
|
+
*/
|
|
112
|
+
readonly env?: Readonly<Record<string, string>> | undefined;
|
|
106
113
|
/**
|
|
107
114
|
* Override the agent's flag list (rare; for one-off advanced cases).
|
|
108
115
|
*/
|
package/dist/ai/worktree.d.mts
CHANGED
|
@@ -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.
|
|
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
|
package/dist/ai/worktree.js
CHANGED
|
@@ -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.
|
|
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
|
-
|
|
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()));
|
package/dist/argv/parse.d.ts
CHANGED
|
@@ -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
|
/**
|
package/dist/argv/parse.js
CHANGED
|
@@ -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: {
|
package/dist/bin/_internal.d.ts
CHANGED
|
@@ -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/
|
|
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
|
package/dist/bin/_internal.js
CHANGED
|
@@ -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/
|
|
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
|