Skip to content

fix(deps): move CLI provider adapters + ffmpeg-static to optionalDependencies#131

Open
AtelyPham wants to merge 1 commit into
mainfrom
tin/optional-provider-deps
Open

fix(deps): move CLI provider adapters + ffmpeg-static to optionalDependencies#131
AtelyPham wants to merge 1 commit into
mainfrom
tin/optional-provider-deps

Conversation

@AtelyPham

Copy link
Copy Markdown
Contributor

Summary

Move the CLI-backed provider adapters and ffmpeg-static from dependencies to optionalDependencies, and make a missing optional dependency degrade with an actionable error instead of a raw ERR_MODULE_NOT_FOUND.

Why

@tangle-network/browser-agent-driver bundles ~300 MB of platform-native binaries that most consumers never use on the default --provider openai path:

dep pulls size
ai-sdk-provider-codex-cli @openai/codex (Codex CLI binary) ~177 MB
ai-sdk-provider-claude-code @anthropic-ai/claude-agent-sdk (ripgrep ×5 platforms) ~69 MB
ffmpeg-static static ffmpeg binary (used only by bad showcase) ~49 MB

Slim sandbox runtime images (e.g. agent-thin, which only ever runs --provider openai) want to drop these. Today the only way is a post-install rm -rf in the image build (see agent-dev-container #3369). Declaring them optionalDependencies lets those consumers use the standard npm install --omit=optional instead.

Change

  • package.json: the three deps move to optionalDependencies. Default installs are unchanged — optional dependencies still install by default, so the full provider + showcase surface works out of the box.
  • Graceful degrade: the five dynamic import() sites for the two providers (brain/model-client.ts, supervisor/critic.ts) now go through loadOptionalModule(), which maps a missing module to a clear message: "The 'codex-cli' provider requires the optional package "…", which is not installed. Reinstall … without --omit=optional … or use --provider openai." This matters because the keyless default resolves to claude-code; on an --omit=optional install a bare bad run <url> now explains itself instead of crashing with a module-resolution stack trace.
  • ffmpeg-static already degrades gracefully (lazy require in try/catch → system ffmpeg → skip video), and the postinstall provider-patch step already fs.existsSync-guards the patched file, so --omit=optional never breaks install.

Tests

tests/optional-dependency.test.ts covers loadOptionalModule: resolves a present module, maps ERR_MODULE_NOT_FOUND to the actionable message, and passes unrelated errors through.

Notes

  • Non-breaking → patch. No API/CLI surface change; default install footprint is identical.
  • Downstream: agent-dev-container's agent-thin image (#3369) can switch its manual provider/ffmpeg rm to npm install --omit=optional once this releases.

…ndencies

The codex-cli / claude-code provider adapters and ffmpeg-static pull ~300 MB of
platform-native binaries (@openai/codex, @anthropic-ai/claude-agent-sdk ripgrep,
static ffmpeg) that the default --provider openai path never uses. Declaring
them optionalDependencies lets slim consumers (e.g. sandbox runtime images)
install with `npm install --omit=optional` instead of a post-install rm. Default
installs are unchanged — optional deps still install by default.

Route the five dynamic provider imports (brain/model-client.ts, supervisor/
critic.ts) through loadOptionalModule(), which maps a missing optional module to
an actionable "reinstall without --omit=optional" error instead of a raw
ERR_MODULE_NOT_FOUND. The keyless default resolves to claude-code, so a bare
`bad run` on a lean install now explains itself.
@AtelyPham AtelyPham self-assigned this Jul 9, 2026
@AtelyPham AtelyPham marked this pull request as ready for review July 10, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant