Skip to content

CAMEL-24566: Auto-discover GenAI dependencies in Camel CLI - #26055

Merged
davsclaus merged 5 commits into
apache:mainfrom
atiaomar1978-hub:feature/CAMEL-24566-genai-dependency-auto-discovery
Sep 5, 2026
Merged

CAMEL-24566: Auto-discover GenAI dependencies in Camel CLI#26055
davsclaus merged 5 commits into
apache:mainfrom
atiaomar1978-hub:feature/CAMEL-24566-genai-dependency-auto-discovery

Conversation

@atiaomar1978-hub

@atiaomar1978-hub atiaomar1978-hub commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Auto-generated by Cursor Agent on behalf of atiaomar1978-hub

Implements CAMEL-24566: Camel JBang auto-discovers GenAI-related dependencies when running or exporting routes.

Approach

GenAI component and LangChain4j provider JARs are resolved by the existing silent-run pipeline (DependencyDownloaderComponentResolver, KnownDependenciesResolver) — not by scanning route source.

GenAiDependencyHelper only adds optional camel:ai-observability using the same settings-driven approach as OpenTelemetry and LRA.

Changes

  • GenAiDependencyHelper — adds camel:ai-observability when GenAI artifacts are already in the dependency set and --observe or camel.aiObservability.enabled=true
  • Run.java / ExportBaseCommand — call helper after silent-run dependency resolution
  • camel-main-known-dependencies.properties — LangChain4j provider mappings + GenAiObservabilityImpl / camel.aiObservability entries for runtime download

Behavior

Trigger Dependency added
Route uses GenAI component (silent-run + catalog) camel:<scheme>
Bean/import references LangChain4j provider package mvn:dev.langchain4j:langchain4j-*:…
GenAI artifacts present + --observe or camel.aiObservability.enabled=true camel:ai-observability (catalog ≥ 4.23)

camel.aiObservability.enabled=false opts out. Observability is not added without --observe or an explicit property.

Review fixes (054c4fd)

  • mvn: GenAI detection — uses CamelCatalog.modelFromMavenGAV() + catalog ai label instead of artifact-id string heuristics
  • camel-ai-observability exclusion — explicit observability dep no longer counts as a GenAI route dependency or gets duplicated in Run.java's ArrayList
  • AI_OBSERVABILITY_ENABLED — narrowed to package-private
  • camel.aiObservability known-deps entry — documented (same pattern as camel.opentelemetry)
  • Tests — real DefaultCamelCatalog instead of Mockito; duplicate-guard coverage added

Tests

  • GenAiDependencyHelperTest — 9 unit tests
  • ExportTest.shouldExportGenAiRouteWithObservability — export integration with --observe

Related

Add GenAiDependencyDiscovery to scan route URIs and LangChain4j provider
classes for camel-jbang run, export, dependency list and dependency update.

- Add camel:ai-observability when GenAI routes are detected (unless disabled)
- Add LangChain4j provider JAR mappings to known-dependencies.properties
- Integrate discovery into Run and ExportBaseCommand.resolveDependencies

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
- Make ai-observability opt-in via --observe or camel.aiObservability.enabled=true
- Load LangChain4j provider mappings from known-dependencies (package keys)
- Scope URI extraction by file type and ignore YAML comments/false positives
- Fix settings file scanning for export dependency resolution

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
@cursor
cursor Bot force-pushed the feature/CAMEL-24566-genai-dependency-auto-discovery branch from aedcb7f to 023e9c6 Compare September 2, 2026 23:05
@atiaomar1978-hub
atiaomar1978-hub marked this pull request as ready for review September 2, 2026 23:56

@davsclaus davsclaus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we should not scan the code, we need to find another way that is more similar to what we already do

…ncy resolution

Remove GenAiDependencyDiscovery regex scanning of YAML/XML/Java routes.
GenAI components and LangChain4j providers are resolved through the
existing silent-run download pipeline (DependencyDownloaderComponentResolver
and KnownDependenciesResolver), matching OpenTelemetry and LRA handling.

- Add GenAiDependencyHelper to conditionally add camel:ai-observability
  from settings/profile when GenAI artifacts are already present
- Map GenAiObservabilityImpl in camel-main-known-dependencies.properties
- Replace unit tests with GenAiDependencyHelperTest

Co-authored-by: Cursor <cursoragent@cursor.com>
@atiaomar1978-hub

Copy link
Copy Markdown
Contributor Author

Addressed review feedback in 04413ce — removed route source scanning entirely.

New approach (aligned with existing JBang patterns):

  1. GenAI components — resolved by the existing silent-run pipeline: routes load in stub context → DependencyDownloaderComponentResolver downloads from catalog → dependency= lines captured in run settings (same as any other component).

  2. LangChain4j provider JARs — resolved via KnownDependenciesResolver when bean types / imports are loaded (dev.langchain4j.model.* mappings already in camel-main-known-dependencies.properties).

  3. camel-ai-observability — added by GenAiDependencyHelper using profile/settings rules (like OpenTelemetry/LRA): only when --observe or camel.aiObservability.enabled=true and GenAI artifacts are already in the dependency set from silent run. Also mapped GenAiObservabilityImpl in known-deps for runtime download.

Removed GenAiDependencyDiscovery (315 lines of regex scanning). Tests pass.

Cursor Agent on behalf of atiaomar1978-hub

@atiaomar1978-hub atiaomar1978-hub left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @davsclaus — agreed, route source scanning is removed in 04413ce. GenAI dependencies now use the same silent-run + catalog + known-deps pipeline as other components. Only camel-ai-observability uses a small settings helper (OpenTelemetry/LRA style).

Cursor Agent on behalf of atiaomar1978-hub

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

✅ Generated files are up to date

An earlier CI run reported uncommitted generated changes; the latest run no longer does.

@github-actions github-actions Bot removed the catalog label Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • dsl/camel-jbang/camel-jbang-core
  • dsl/camel-kamelet-main

🔬 Scalpel shadow comparison — Scalpel: 8 tested, 8 compile-only — current: 6 all tested

Maveniverse Scalpel detected 16 affected modules (current approach: 6).

⚠️ Modules only in Scalpel (10)
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • coverage

Skip-tests mode would test 8 modules (2 direct + 6 downstream), skip tests for 8 (generated code, meta-modules)

Modules Scalpel would test (8)
  • camel-jbang-core
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-kamelet-main
  • camel-launcher-container
Modules with tests skipped (8)
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-launcher
  • coverage

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • dsl/camel-jbang/camel-jbang-core: 1 test(s) disabled on GitHub Actions

💡 Manual integration tests recommended:

You modified dsl/camel-jbang/camel-jbang-core. The related integration tests in dsl/camel-jbang/camel-jbang-it are excluded from CI. Consider running them manually:

mvn verify -f dsl/camel-jbang/camel-jbang-it -Djbang-it-test
All tested modules (16 modules)
  • Camel :: Coverage
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container

⚙️ View full build and test results

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the current diff (after the 04413ce rework that removed route source scanning). The approach now correctly relies on the existing silent-run + catalog + KnownDependenciesResolver pipeline for GenAI components/providers, with GenAiDependencyHelper only handling the camel-ai-observability opt-in — consistent with how OpenTelemetry and LRA are handled. A few observations below.

This review was generated by an AI agent, Hermès, on behalf of @gnodet.

Use catalog modelFromMavenGAV for mvn: GenAI detection instead of
artifact-id heuristics, exclude camel-ai-observability from triggering
duplicate observability deps, narrow AI_OBSERVABILITY_ENABLED visibility,
and document camel.aiObservability known-deps entry.

Co-authored-by: Cursor <cursoragent@cursor.com>
@atiaomar1978-hub

Copy link
Copy Markdown
Contributor Author

Addressed all @gnodet review comments in 054c4fd:

  1. camel-ai-observability self-reference — excluded from hasGenAiDependency(); alreadyHasAiObservability() prevents duplicate entries in Run.java's ArrayList
  2. Broad -ai- heuristics — replaced with CamelCatalog.modelFromMavenGAV() + catalog ai label
  3. camel.aiObservability known-deps entry — documented inline (same pattern as camel.opentelemetry)
  4. AI_OBSERVABILITY_ENABLED visibility — narrowed to package-private
  5. Mockito in tests — replaced with real DefaultCamelCatalog

All 9 GenAiDependencyHelperTest tests pass locally.

Cursor Agent on behalf of atiaomar1978-hub

@davsclaus davsclaus added this to the 4.23.0 milestone Sep 5, 2026
@davsclaus davsclaus added the enhancement New feature or request label Sep 5, 2026
@davsclaus
davsclaus merged commit f5463f1 into apache:main Sep 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dsl enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants