You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "lburgazzoli (via GitHub)" <gi...@apache.org> on 2024/03/07 11:45:38 UTC

[PR] feat(jbang): camel-k agent sub-command [camel]

lburgazzoli opened a new pull request, #13408:
URL: https://github.com/apache/camel/pull/13408

   # Description
   
   <!--
   - Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   -->
   
   # Target
   
   - [ ] I checked that the commit is targeting the correct branch (note that Camel 3 uses `camel-3.x`, whereas Camel 4 uses the `main` branch)
   
   # Tracking
   - [ ] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).
   
   <!--
   # *Note*: trivial changes like, typos, minor documentation fixes and other small items do not require a JIRA issue. In this case your pull request should address just this issue, without pulling in other changes.
   -->
   
   # Apache Camel coding standards and style
   
   - [ ] I checked that each commit in the pull request has a meaningful subject line and body.
   
   <!--
   If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
   -->
   
   - [ ] I have run `mvn clean install -DskipTests` locally and I have committed all auto-generated changes
   
   <!--
   You can run the aforementioned command in your module so that the build auto-formats your code. This will also be verified as part of the checks and your PR may be rejected if if there are uncommited changes after running `mvn clean install -DskipTests`.
   
   You can learn more about the contribution guidelines at https://github.com/apache/camel/blob/main/CONTRIBUTING.md
   -->
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "lburgazzoli (via GitHub)" <gi...@apache.org>.
lburgazzoli commented on PR #13408:
URL: https://github.com/apache/camel/pull/13408#issuecomment-2011604738

   @apupier @davsclaus, can I merge this ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #13408:
URL: https://github.com/apache/camel/pull/13408#issuecomment-2007089287

   Yeah sure its good to get something in 4.5 and can get more feedback for upcoming versions


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "lburgazzoli (via GitHub)" <gi...@apache.org>.
lburgazzoli commented on code in PR #13408:
URL: https://github.com/apache/camel/pull/13408#discussion_r1533498189


##########
dsl/camel-jbang/camel-jbang-plugin-k/src/main/java/org/apache/camel/dsl/jbang/core/commands/k/Agent.java:
##########
@@ -0,0 +1,424 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.k;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.CountDownLatch;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.Route;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.component.kamelet.KameletEndpoint;
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.dsl.jbang.core.commands.k.support.Capability;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeType;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeTypeConverter;
+import org.apache.camel.dsl.jbang.core.commands.k.support.SourceMetadata;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubComponentResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubDataFormatResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubLanguageResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubTransformerResolver;
+import org.apache.camel.dsl.jbang.core.common.CatalogLoader;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultModelReifierFactory;
+import org.apache.camel.model.CircuitBreakerDefinition;
+import org.apache.camel.model.FromDefinition;
+import org.apache.camel.model.Model;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.reifier.DisabledReifier;
+import org.apache.camel.reifier.ProcessorReifier;
+import org.apache.camel.spi.ComponentResolver;
+import org.apache.camel.spi.DataFormatResolver;
+import org.apache.camel.spi.LanguageResolver;
+import org.apache.camel.spi.TransformerResolver;
+import org.apache.camel.support.PluginHelper;
+import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.tooling.model.BaseModel;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.DataFormatModel;
+import org.apache.camel.tooling.model.EntityRef;
+import org.apache.camel.tooling.model.Kind;
+import org.apache.camel.tooling.model.LanguageModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+
+@CommandLine.Command(name = Agent.ID, description = "TODO", sortOptions = false)
+public class Agent extends CamelCommand {
+    private static final Logger LOGGER = LoggerFactory.getLogger(Agent.class);
+
+    private static final ObjectMapper MAPPER = new ObjectMapper()
+            .setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+
+    private static final Map<String, BiConsumer<CamelCatalog, SourceMetadata>> COMPONENT_CUSTOMIZERS;
+
+    public static final String ID = "agent";
+    public static final String STUB_PATTERN = "*";
+    public static final String MIME_TYPE_JSON = "application/json";
+    public static final String CONTENT_TYPE_HEADER = "Content-Type";
+
+    static {
+        // the core CircuitBreaker reifier fails as it depends on a specific implementation provided by
+        // a dedicated component/module, but as we are orly inspecting the route to determine its capabilities,
+        // we can safely disable the EIP with a disabled/stub reifier.
+        ProcessorReifier.registerReifier(CircuitBreakerDefinition.class, DisabledReifier::new);
+
+        COMPONENT_CUSTOMIZERS = new HashMap<>();
+        COMPONENT_CUSTOMIZERS.put("platform-http", (catalog, meta) -> {
+            meta.capabilities.put(
+                    Capability.PlatformHttp,
+                    catalog
+                            .findCapabilityRef(Capability.PlatformHttp.getValue())
+                            .orElseGet(() -> new EntityRef(null, null)));
+        });
+
+    }
+
+    @CommandLine.Option(
+                        names = { "--listen-host" },
+                        description = "")
+    String host = "localhost";
+
+    @CommandLine.Option(
+                        names = { "--listen-port" },
+                        description = "")
+    int port = 8081;
+
+    @CommandLine.Option(
+                        names = { "--runtime-version" },
+                        description = "To use a different runtime version than the default version")
+    String runtimeVersion;
+
+    @CommandLine.Option(
+                        names = { "--runtime" },
+                        converter = RuntimeTypeConverter.class,
+                        description = "Runtime (spring-boot, quarkus, camel-main)")
+    RuntimeType runtimeType = RuntimeType.camelMain;
+
+    @CommandLine.Option(
+                        names = { "--repos" },
+                        description = "Comma separated list of additional maven repositories")
+    String repos;
+
+    public Agent(CamelJBangMain main) {
+        super(main);
+    }
+
+    @Override
+    public Integer doCall() throws Exception {
+        Vertx vertx = null;
+        HttpServer server = null;
+
+        try {
+            CountDownLatch latch = new CountDownLatch(1);
+
+            vertx = Vertx.vertx();
+            server = serve(vertx).toCompletableFuture().get();
+
+            latch.await();

Review Comment:
   yeah, it is to keep the server up as in fact the servers does not block 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #13408:
URL: https://github.com/apache/camel/pull/13408#discussion_r1533473572


##########
dsl/camel-jbang/camel-jbang-plugin-k/src/main/java/org/apache/camel/dsl/jbang/core/commands/k/Agent.java:
##########
@@ -0,0 +1,424 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.k;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.CountDownLatch;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.Route;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.component.kamelet.KameletEndpoint;
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.dsl.jbang.core.commands.k.support.Capability;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeType;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeTypeConverter;
+import org.apache.camel.dsl.jbang.core.commands.k.support.SourceMetadata;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubComponentResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubDataFormatResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubLanguageResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubTransformerResolver;
+import org.apache.camel.dsl.jbang.core.common.CatalogLoader;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultModelReifierFactory;
+import org.apache.camel.model.CircuitBreakerDefinition;
+import org.apache.camel.model.FromDefinition;
+import org.apache.camel.model.Model;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.reifier.DisabledReifier;
+import org.apache.camel.reifier.ProcessorReifier;
+import org.apache.camel.spi.ComponentResolver;
+import org.apache.camel.spi.DataFormatResolver;
+import org.apache.camel.spi.LanguageResolver;
+import org.apache.camel.spi.TransformerResolver;
+import org.apache.camel.support.PluginHelper;
+import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.tooling.model.BaseModel;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.DataFormatModel;
+import org.apache.camel.tooling.model.EntityRef;
+import org.apache.camel.tooling.model.Kind;
+import org.apache.camel.tooling.model.LanguageModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+
+@CommandLine.Command(name = Agent.ID, description = "TODO", sortOptions = false)
+public class Agent extends CamelCommand {
+    private static final Logger LOGGER = LoggerFactory.getLogger(Agent.class);
+
+    private static final ObjectMapper MAPPER = new ObjectMapper()
+            .setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+
+    private static final Map<String, BiConsumer<CamelCatalog, SourceMetadata>> COMPONENT_CUSTOMIZERS;
+
+    public static final String ID = "agent";
+    public static final String STUB_PATTERN = "*";
+    public static final String MIME_TYPE_JSON = "application/json";
+    public static final String CONTENT_TYPE_HEADER = "Content-Type";
+
+    static {
+        // the core CircuitBreaker reifier fails as it depends on a specific implementation provided by
+        // a dedicated component/module, but as we are orly inspecting the route to determine its capabilities,
+        // we can safely disable the EIP with a disabled/stub reifier.
+        ProcessorReifier.registerReifier(CircuitBreakerDefinition.class, DisabledReifier::new);
+
+        COMPONENT_CUSTOMIZERS = new HashMap<>();
+        COMPONENT_CUSTOMIZERS.put("platform-http", (catalog, meta) -> {
+            meta.capabilities.put(
+                    Capability.PlatformHttp,
+                    catalog
+                            .findCapabilityRef(Capability.PlatformHttp.getValue())
+                            .orElseGet(() -> new EntityRef(null, null)));
+        });
+
+    }
+
+    @CommandLine.Option(

Review Comment:
   Maybe format these nicer, ie move next line up ...



##########
dsl/camel-jbang/camel-jbang-plugin-k/src/main/java/org/apache/camel/dsl/jbang/core/commands/k/Agent.java:
##########
@@ -0,0 +1,424 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.k;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.CountDownLatch;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.Route;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.component.kamelet.KameletEndpoint;
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.dsl.jbang.core.commands.k.support.Capability;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeType;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeTypeConverter;
+import org.apache.camel.dsl.jbang.core.commands.k.support.SourceMetadata;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubComponentResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubDataFormatResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubLanguageResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubTransformerResolver;
+import org.apache.camel.dsl.jbang.core.common.CatalogLoader;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultModelReifierFactory;
+import org.apache.camel.model.CircuitBreakerDefinition;
+import org.apache.camel.model.FromDefinition;
+import org.apache.camel.model.Model;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.reifier.DisabledReifier;
+import org.apache.camel.reifier.ProcessorReifier;
+import org.apache.camel.spi.ComponentResolver;
+import org.apache.camel.spi.DataFormatResolver;
+import org.apache.camel.spi.LanguageResolver;
+import org.apache.camel.spi.TransformerResolver;
+import org.apache.camel.support.PluginHelper;
+import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.tooling.model.BaseModel;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.DataFormatModel;
+import org.apache.camel.tooling.model.EntityRef;
+import org.apache.camel.tooling.model.Kind;
+import org.apache.camel.tooling.model.LanguageModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+
+@CommandLine.Command(name = Agent.ID, description = "TODO", sortOptions = false)

Review Comment:
   There is a TODO here



##########
dsl/camel-jbang/camel-jbang-plugin-k/src/main/java/org/apache/camel/dsl/jbang/core/commands/k/Agent.java:
##########
@@ -0,0 +1,424 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.k;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.CountDownLatch;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.Route;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.component.kamelet.KameletEndpoint;
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.dsl.jbang.core.commands.k.support.Capability;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeType;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeTypeConverter;
+import org.apache.camel.dsl.jbang.core.commands.k.support.SourceMetadata;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubComponentResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubDataFormatResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubLanguageResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubTransformerResolver;
+import org.apache.camel.dsl.jbang.core.common.CatalogLoader;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultModelReifierFactory;
+import org.apache.camel.model.CircuitBreakerDefinition;
+import org.apache.camel.model.FromDefinition;
+import org.apache.camel.model.Model;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.reifier.DisabledReifier;
+import org.apache.camel.reifier.ProcessorReifier;
+import org.apache.camel.spi.ComponentResolver;
+import org.apache.camel.spi.DataFormatResolver;
+import org.apache.camel.spi.LanguageResolver;
+import org.apache.camel.spi.TransformerResolver;
+import org.apache.camel.support.PluginHelper;
+import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.tooling.model.BaseModel;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.DataFormatModel;
+import org.apache.camel.tooling.model.EntityRef;
+import org.apache.camel.tooling.model.Kind;
+import org.apache.camel.tooling.model.LanguageModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+
+@CommandLine.Command(name = Agent.ID, description = "TODO", sortOptions = false)
+public class Agent extends CamelCommand {
+    private static final Logger LOGGER = LoggerFactory.getLogger(Agent.class);
+
+    private static final ObjectMapper MAPPER = new ObjectMapper()
+            .setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+
+    private static final Map<String, BiConsumer<CamelCatalog, SourceMetadata>> COMPONENT_CUSTOMIZERS;
+
+    public static final String ID = "agent";
+    public static final String STUB_PATTERN = "*";
+    public static final String MIME_TYPE_JSON = "application/json";
+    public static final String CONTENT_TYPE_HEADER = "Content-Type";
+
+    static {
+        // the core CircuitBreaker reifier fails as it depends on a specific implementation provided by
+        // a dedicated component/module, but as we are orly inspecting the route to determine its capabilities,
+        // we can safely disable the EIP with a disabled/stub reifier.
+        ProcessorReifier.registerReifier(CircuitBreakerDefinition.class, DisabledReifier::new);
+
+        COMPONENT_CUSTOMIZERS = new HashMap<>();
+        COMPONENT_CUSTOMIZERS.put("platform-http", (catalog, meta) -> {
+            meta.capabilities.put(
+                    Capability.PlatformHttp,
+                    catalog
+                            .findCapabilityRef(Capability.PlatformHttp.getValue())
+                            .orElseGet(() -> new EntityRef(null, null)));
+        });
+
+    }
+
+    @CommandLine.Option(
+                        names = { "--listen-host" },
+                        description = "")

Review Comment:
   Add description to these options



##########
dsl/camel-jbang/camel-jbang-plugin-k/src/main/java/org/apache/camel/dsl/jbang/core/commands/k/Agent.java:
##########
@@ -0,0 +1,424 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.k;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.CountDownLatch;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.Route;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.component.kamelet.KameletEndpoint;
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.dsl.jbang.core.commands.k.support.Capability;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeType;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeTypeConverter;
+import org.apache.camel.dsl.jbang.core.commands.k.support.SourceMetadata;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubComponentResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubDataFormatResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubLanguageResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubTransformerResolver;
+import org.apache.camel.dsl.jbang.core.common.CatalogLoader;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultModelReifierFactory;
+import org.apache.camel.model.CircuitBreakerDefinition;
+import org.apache.camel.model.FromDefinition;
+import org.apache.camel.model.Model;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.reifier.DisabledReifier;
+import org.apache.camel.reifier.ProcessorReifier;
+import org.apache.camel.spi.ComponentResolver;
+import org.apache.camel.spi.DataFormatResolver;
+import org.apache.camel.spi.LanguageResolver;
+import org.apache.camel.spi.TransformerResolver;
+import org.apache.camel.support.PluginHelper;
+import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.tooling.model.BaseModel;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.DataFormatModel;
+import org.apache.camel.tooling.model.EntityRef;
+import org.apache.camel.tooling.model.Kind;
+import org.apache.camel.tooling.model.LanguageModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+
+@CommandLine.Command(name = Agent.ID, description = "TODO", sortOptions = false)
+public class Agent extends CamelCommand {
+    private static final Logger LOGGER = LoggerFactory.getLogger(Agent.class);
+
+    private static final ObjectMapper MAPPER = new ObjectMapper()
+            .setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+
+    private static final Map<String, BiConsumer<CamelCatalog, SourceMetadata>> COMPONENT_CUSTOMIZERS;
+
+    public static final String ID = "agent";
+    public static final String STUB_PATTERN = "*";
+    public static final String MIME_TYPE_JSON = "application/json";
+    public static final String CONTENT_TYPE_HEADER = "Content-Type";
+
+    static {
+        // the core CircuitBreaker reifier fails as it depends on a specific implementation provided by
+        // a dedicated component/module, but as we are orly inspecting the route to determine its capabilities,
+        // we can safely disable the EIP with a disabled/stub reifier.
+        ProcessorReifier.registerReifier(CircuitBreakerDefinition.class, DisabledReifier::new);
+
+        COMPONENT_CUSTOMIZERS = new HashMap<>();
+        COMPONENT_CUSTOMIZERS.put("platform-http", (catalog, meta) -> {
+            meta.capabilities.put(
+                    Capability.PlatformHttp,
+                    catalog
+                            .findCapabilityRef(Capability.PlatformHttp.getValue())
+                            .orElseGet(() -> new EntityRef(null, null)));
+        });
+
+    }
+
+    @CommandLine.Option(
+                        names = { "--listen-host" },
+                        description = "")
+    String host = "localhost";
+
+    @CommandLine.Option(
+                        names = { "--listen-port" },
+                        description = "")
+    int port = 8081;
+
+    @CommandLine.Option(
+                        names = { "--runtime-version" },
+                        description = "To use a different runtime version than the default version")
+    String runtimeVersion;
+
+    @CommandLine.Option(
+                        names = { "--runtime" },
+                        converter = RuntimeTypeConverter.class,
+                        description = "Runtime (spring-boot, quarkus, camel-main)")
+    RuntimeType runtimeType = RuntimeType.camelMain;
+
+    @CommandLine.Option(
+                        names = { "--repos" },
+                        description = "Comma separated list of additional maven repositories")
+    String repos;
+
+    public Agent(CamelJBangMain main) {
+        super(main);
+    }
+
+    @Override
+    public Integer doCall() throws Exception {
+        Vertx vertx = null;
+        HttpServer server = null;
+
+        try {
+            CountDownLatch latch = new CountDownLatch(1);
+
+            vertx = Vertx.vertx();
+            server = serve(vertx).toCompletableFuture().get();
+
+            latch.await();
+        } finally {
+            if (server != null) {
+                server.close();
+            }
+            if (vertx != null) {
+                vertx.close();
+            }
+        }
+
+        return 0;
+    }
+
+    // Visible for testing
+    CompletionStage<HttpServer> serve(Vertx vertx) {
+        HttpServer server = vertx.createHttpServer();
+        Router router = Router.router(vertx);
+
+        router.route()
+                .handler(BodyHandler.create())
+                .failureHandler(this::handleFailure);
+
+        router.route(HttpMethod.GET, "/catalog/model/:kind/:name")
+                .produces(MIME_TYPE_JSON)
+                .blockingHandler(this::handleCatalogModel);
+
+        router.route(HttpMethod.GET, "/catalog/capability/:name")
+                .produces(MIME_TYPE_JSON)
+                .blockingHandler(this::handleCatalogCapability);
+
+        router.route(HttpMethod.POST, "/inspect/:location")
+                .produces(MIME_TYPE_JSON)
+                .blockingHandler(this::handleInspect);
+
+        return server.requestHandler(router).listen(port, host).toCompletionStage();
+    }
+
+    private void handleFailure(RoutingContext ctx) {
+        LOGGER.info("", ctx.failure());
+        ctx.response()
+                .setStatusCode(400)

Review Comment:
   is it not 5xx when its internal server error



##########
dsl/camel-jbang/camel-jbang-plugin-k/src/main/java/org/apache/camel/dsl/jbang/core/commands/k/Agent.java:
##########
@@ -0,0 +1,424 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.k;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.CountDownLatch;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.Route;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.component.kamelet.KameletEndpoint;
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.dsl.jbang.core.commands.k.support.Capability;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeType;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeTypeConverter;
+import org.apache.camel.dsl.jbang.core.commands.k.support.SourceMetadata;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubComponentResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubDataFormatResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubLanguageResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubTransformerResolver;
+import org.apache.camel.dsl.jbang.core.common.CatalogLoader;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultModelReifierFactory;
+import org.apache.camel.model.CircuitBreakerDefinition;
+import org.apache.camel.model.FromDefinition;
+import org.apache.camel.model.Model;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.reifier.DisabledReifier;
+import org.apache.camel.reifier.ProcessorReifier;
+import org.apache.camel.spi.ComponentResolver;
+import org.apache.camel.spi.DataFormatResolver;
+import org.apache.camel.spi.LanguageResolver;
+import org.apache.camel.spi.TransformerResolver;
+import org.apache.camel.support.PluginHelper;
+import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.tooling.model.BaseModel;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.DataFormatModel;
+import org.apache.camel.tooling.model.EntityRef;
+import org.apache.camel.tooling.model.Kind;
+import org.apache.camel.tooling.model.LanguageModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+
+@CommandLine.Command(name = Agent.ID, description = "TODO", sortOptions = false)
+public class Agent extends CamelCommand {
+    private static final Logger LOGGER = LoggerFactory.getLogger(Agent.class);
+
+    private static final ObjectMapper MAPPER = new ObjectMapper()
+            .setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+
+    private static final Map<String, BiConsumer<CamelCatalog, SourceMetadata>> COMPONENT_CUSTOMIZERS;
+
+    public static final String ID = "agent";
+    public static final String STUB_PATTERN = "*";
+    public static final String MIME_TYPE_JSON = "application/json";
+    public static final String CONTENT_TYPE_HEADER = "Content-Type";
+
+    static {
+        // the core CircuitBreaker reifier fails as it depends on a specific implementation provided by
+        // a dedicated component/module, but as we are orly inspecting the route to determine its capabilities,
+        // we can safely disable the EIP with a disabled/stub reifier.
+        ProcessorReifier.registerReifier(CircuitBreakerDefinition.class, DisabledReifier::new);
+
+        COMPONENT_CUSTOMIZERS = new HashMap<>();
+        COMPONENT_CUSTOMIZERS.put("platform-http", (catalog, meta) -> {
+            meta.capabilities.put(
+                    Capability.PlatformHttp,
+                    catalog
+                            .findCapabilityRef(Capability.PlatformHttp.getValue())
+                            .orElseGet(() -> new EntityRef(null, null)));
+        });
+
+    }
+
+    @CommandLine.Option(
+                        names = { "--listen-host" },
+                        description = "")
+    String host = "localhost";
+
+    @CommandLine.Option(
+                        names = { "--listen-port" },
+                        description = "")
+    int port = 8081;
+
+    @CommandLine.Option(
+                        names = { "--runtime-version" },
+                        description = "To use a different runtime version than the default version")
+    String runtimeVersion;
+
+    @CommandLine.Option(
+                        names = { "--runtime" },
+                        converter = RuntimeTypeConverter.class,
+                        description = "Runtime (spring-boot, quarkus, camel-main)")
+    RuntimeType runtimeType = RuntimeType.camelMain;
+
+    @CommandLine.Option(
+                        names = { "--repos" },
+                        description = "Comma separated list of additional maven repositories")
+    String repos;
+
+    public Agent(CamelJBangMain main) {
+        super(main);
+    }
+
+    @Override
+    public Integer doCall() throws Exception {
+        Vertx vertx = null;
+        HttpServer server = null;
+
+        try {
+            CountDownLatch latch = new CountDownLatch(1);
+
+            vertx = Vertx.vertx();
+            server = serve(vertx).toCompletableFuture().get();
+
+            latch.await();
+        } finally {
+            if (server != null) {
+                server.close();
+            }
+            if (vertx != null) {
+                vertx.close();
+            }
+        }
+
+        return 0;
+    }
+
+    // Visible for testing
+    CompletionStage<HttpServer> serve(Vertx vertx) {
+        HttpServer server = vertx.createHttpServer();
+        Router router = Router.router(vertx);
+
+        router.route()
+                .handler(BodyHandler.create())
+                .failureHandler(this::handleFailure);
+
+        router.route(HttpMethod.GET, "/catalog/model/:kind/:name")
+                .produces(MIME_TYPE_JSON)
+                .blockingHandler(this::handleCatalogModel);
+
+        router.route(HttpMethod.GET, "/catalog/capability/:name")
+                .produces(MIME_TYPE_JSON)
+                .blockingHandler(this::handleCatalogCapability);
+
+        router.route(HttpMethod.POST, "/inspect/:location")
+                .produces(MIME_TYPE_JSON)
+                .blockingHandler(this::handleInspect);
+
+        return server.requestHandler(router).listen(port, host).toCompletionStage();
+    }
+
+    private void handleFailure(RoutingContext ctx) {
+        LOGGER.info("", ctx.failure());
+        ctx.response()
+                .setStatusCode(400)
+                .setStatusMessage(
+                        ctx.failure().getCause() != null
+                                ? ctx.failure().getCause().getMessage()
+                                : ctx.failure().getMessage())
+                .end();
+    }
+
+    private void handleCatalogCapability(RoutingContext ctx) {
+        try {
+            final CamelCatalog catalog = loadCatalog(runtimeType, runtimeVersion);
+            final String name = ctx.pathParam("name");
+            final Optional<EntityRef> ref = catalog.findCapabilityRef(name);
+
+            if (ref.isPresent()) {
+                ctx.response()
+                        .putHeader(CONTENT_TYPE_HEADER, MIME_TYPE_JSON)
+                        .end(MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(ref.get()));
+            } else {
+                ctx.response()
+                        .setStatusCode(404)

Review Comment:
   is this not an okay response, ie 204 (no content)



##########
dsl/camel-jbang/camel-jbang-plugin-k/src/main/java/org/apache/camel/dsl/jbang/core/commands/k/Agent.java:
##########
@@ -0,0 +1,424 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.k;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.CountDownLatch;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.Route;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.component.kamelet.KameletEndpoint;
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.dsl.jbang.core.commands.k.support.Capability;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeType;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeTypeConverter;
+import org.apache.camel.dsl.jbang.core.commands.k.support.SourceMetadata;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubComponentResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubDataFormatResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubLanguageResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubTransformerResolver;
+import org.apache.camel.dsl.jbang.core.common.CatalogLoader;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultModelReifierFactory;
+import org.apache.camel.model.CircuitBreakerDefinition;
+import org.apache.camel.model.FromDefinition;
+import org.apache.camel.model.Model;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.reifier.DisabledReifier;
+import org.apache.camel.reifier.ProcessorReifier;
+import org.apache.camel.spi.ComponentResolver;
+import org.apache.camel.spi.DataFormatResolver;
+import org.apache.camel.spi.LanguageResolver;
+import org.apache.camel.spi.TransformerResolver;
+import org.apache.camel.support.PluginHelper;
+import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.tooling.model.BaseModel;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.DataFormatModel;
+import org.apache.camel.tooling.model.EntityRef;
+import org.apache.camel.tooling.model.Kind;
+import org.apache.camel.tooling.model.LanguageModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+
+@CommandLine.Command(name = Agent.ID, description = "TODO", sortOptions = false)
+public class Agent extends CamelCommand {
+    private static final Logger LOGGER = LoggerFactory.getLogger(Agent.class);
+
+    private static final ObjectMapper MAPPER = new ObjectMapper()
+            .setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+
+    private static final Map<String, BiConsumer<CamelCatalog, SourceMetadata>> COMPONENT_CUSTOMIZERS;
+
+    public static final String ID = "agent";
+    public static final String STUB_PATTERN = "*";
+    public static final String MIME_TYPE_JSON = "application/json";
+    public static final String CONTENT_TYPE_HEADER = "Content-Type";
+
+    static {
+        // the core CircuitBreaker reifier fails as it depends on a specific implementation provided by
+        // a dedicated component/module, but as we are orly inspecting the route to determine its capabilities,
+        // we can safely disable the EIP with a disabled/stub reifier.
+        ProcessorReifier.registerReifier(CircuitBreakerDefinition.class, DisabledReifier::new);
+
+        COMPONENT_CUSTOMIZERS = new HashMap<>();
+        COMPONENT_CUSTOMIZERS.put("platform-http", (catalog, meta) -> {
+            meta.capabilities.put(
+                    Capability.PlatformHttp,
+                    catalog
+                            .findCapabilityRef(Capability.PlatformHttp.getValue())
+                            .orElseGet(() -> new EntityRef(null, null)));
+        });
+
+    }
+
+    @CommandLine.Option(
+                        names = { "--listen-host" },
+                        description = "")
+    String host = "localhost";
+
+    @CommandLine.Option(
+                        names = { "--listen-port" },
+                        description = "")
+    int port = 8081;
+
+    @CommandLine.Option(
+                        names = { "--runtime-version" },
+                        description = "To use a different runtime version than the default version")
+    String runtimeVersion;
+
+    @CommandLine.Option(
+                        names = { "--runtime" },
+                        converter = RuntimeTypeConverter.class,
+                        description = "Runtime (spring-boot, quarkus, camel-main)")
+    RuntimeType runtimeType = RuntimeType.camelMain;
+
+    @CommandLine.Option(
+                        names = { "--repos" },
+                        description = "Comma separated list of additional maven repositories")
+    String repos;
+
+    public Agent(CamelJBangMain main) {
+        super(main);
+    }
+
+    @Override
+    public Integer doCall() throws Exception {
+        Vertx vertx = null;
+        HttpServer server = null;
+
+        try {
+            CountDownLatch latch = new CountDownLatch(1);
+
+            vertx = Vertx.vertx();
+            server = serve(vertx).toCompletableFuture().get();
+
+            latch.await();
+        } finally {
+            if (server != null) {
+                server.close();
+            }
+            if (vertx != null) {
+                vertx.close();
+            }
+        }
+
+        return 0;
+    }
+
+    // Visible for testing
+    CompletionStage<HttpServer> serve(Vertx vertx) {
+        HttpServer server = vertx.createHttpServer();
+        Router router = Router.router(vertx);
+
+        router.route()
+                .handler(BodyHandler.create())
+                .failureHandler(this::handleFailure);
+
+        router.route(HttpMethod.GET, "/catalog/model/:kind/:name")
+                .produces(MIME_TYPE_JSON)
+                .blockingHandler(this::handleCatalogModel);
+
+        router.route(HttpMethod.GET, "/catalog/capability/:name")
+                .produces(MIME_TYPE_JSON)
+                .blockingHandler(this::handleCatalogCapability);
+
+        router.route(HttpMethod.POST, "/inspect/:location")
+                .produces(MIME_TYPE_JSON)
+                .blockingHandler(this::handleInspect);
+
+        return server.requestHandler(router).listen(port, host).toCompletionStage();
+    }
+
+    private void handleFailure(RoutingContext ctx) {
+        LOGGER.info("", ctx.failure());
+        ctx.response()
+                .setStatusCode(400)
+                .setStatusMessage(
+                        ctx.failure().getCause() != null
+                                ? ctx.failure().getCause().getMessage()
+                                : ctx.failure().getMessage())
+                .end();
+    }
+
+    private void handleCatalogCapability(RoutingContext ctx) {
+        try {
+            final CamelCatalog catalog = loadCatalog(runtimeType, runtimeVersion);
+            final String name = ctx.pathParam("name");
+            final Optional<EntityRef> ref = catalog.findCapabilityRef(name);
+
+            if (ref.isPresent()) {
+                ctx.response()
+                        .putHeader(CONTENT_TYPE_HEADER, MIME_TYPE_JSON)
+                        .end(MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(ref.get()));
+            } else {
+                ctx.response()
+                        .setStatusCode(404)
+                        .end();
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private void handleCatalogModel(RoutingContext ctx) {
+        try {
+            final CamelCatalog catalog = loadCatalog(runtimeType, runtimeVersion);
+            final String kind = ctx.pathParam("kind");
+            final String name = ctx.pathParam("name");
+            final BaseModel<?> model = catalog.model(Kind.valueOf(kind), name);
+
+            if (model != null) {
+                ctx.response()
+                        .putHeader(CONTENT_TYPE_HEADER, MIME_TYPE_JSON)
+                        .end(MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(model));
+            } else {
+                ctx.response()
+                        .setStatusCode(404)

Review Comment:
   same as before, but I can see you refer to an url that does not exists, but imho empty response is also correct, could be an empty json response that would be better



##########
dsl/camel-jbang/camel-jbang-plugin-k/src/main/java/org/apache/camel/dsl/jbang/core/commands/k/Agent.java:
##########
@@ -0,0 +1,424 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.k;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.CountDownLatch;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.Route;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.component.kamelet.KameletEndpoint;
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.dsl.jbang.core.commands.k.support.Capability;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeType;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeTypeConverter;
+import org.apache.camel.dsl.jbang.core.commands.k.support.SourceMetadata;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubComponentResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubDataFormatResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubLanguageResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubTransformerResolver;
+import org.apache.camel.dsl.jbang.core.common.CatalogLoader;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultModelReifierFactory;
+import org.apache.camel.model.CircuitBreakerDefinition;
+import org.apache.camel.model.FromDefinition;
+import org.apache.camel.model.Model;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.reifier.DisabledReifier;
+import org.apache.camel.reifier.ProcessorReifier;
+import org.apache.camel.spi.ComponentResolver;
+import org.apache.camel.spi.DataFormatResolver;
+import org.apache.camel.spi.LanguageResolver;
+import org.apache.camel.spi.TransformerResolver;
+import org.apache.camel.support.PluginHelper;
+import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.tooling.model.BaseModel;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.DataFormatModel;
+import org.apache.camel.tooling.model.EntityRef;
+import org.apache.camel.tooling.model.Kind;
+import org.apache.camel.tooling.model.LanguageModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+
+@CommandLine.Command(name = Agent.ID, description = "TODO", sortOptions = false)
+public class Agent extends CamelCommand {
+    private static final Logger LOGGER = LoggerFactory.getLogger(Agent.class);
+
+    private static final ObjectMapper MAPPER = new ObjectMapper()
+            .setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+
+    private static final Map<String, BiConsumer<CamelCatalog, SourceMetadata>> COMPONENT_CUSTOMIZERS;
+
+    public static final String ID = "agent";
+    public static final String STUB_PATTERN = "*";
+    public static final String MIME_TYPE_JSON = "application/json";
+    public static final String CONTENT_TYPE_HEADER = "Content-Type";
+
+    static {
+        // the core CircuitBreaker reifier fails as it depends on a specific implementation provided by
+        // a dedicated component/module, but as we are orly inspecting the route to determine its capabilities,
+        // we can safely disable the EIP with a disabled/stub reifier.
+        ProcessorReifier.registerReifier(CircuitBreakerDefinition.class, DisabledReifier::new);
+
+        COMPONENT_CUSTOMIZERS = new HashMap<>();
+        COMPONENT_CUSTOMIZERS.put("platform-http", (catalog, meta) -> {
+            meta.capabilities.put(
+                    Capability.PlatformHttp,
+                    catalog
+                            .findCapabilityRef(Capability.PlatformHttp.getValue())
+                            .orElseGet(() -> new EntityRef(null, null)));
+        });
+
+    }
+
+    @CommandLine.Option(
+                        names = { "--listen-host" },
+                        description = "")
+    String host = "localhost";
+
+    @CommandLine.Option(
+                        names = { "--listen-port" },
+                        description = "")
+    int port = 8081;
+
+    @CommandLine.Option(
+                        names = { "--runtime-version" },
+                        description = "To use a different runtime version than the default version")
+    String runtimeVersion;
+
+    @CommandLine.Option(
+                        names = { "--runtime" },
+                        converter = RuntimeTypeConverter.class,
+                        description = "Runtime (spring-boot, quarkus, camel-main)")
+    RuntimeType runtimeType = RuntimeType.camelMain;
+
+    @CommandLine.Option(
+                        names = { "--repos" },
+                        description = "Comma separated list of additional maven repositories")
+    String repos;
+
+    public Agent(CamelJBangMain main) {
+        super(main);
+    }
+
+    @Override
+    public Integer doCall() throws Exception {
+        Vertx vertx = null;
+        HttpServer server = null;
+
+        try {
+            CountDownLatch latch = new CountDownLatch(1);
+
+            vertx = Vertx.vertx();
+            server = serve(vertx).toCompletableFuture().get();
+
+            latch.await();
+        } finally {
+            if (server != null) {
+                server.close();
+            }
+            if (vertx != null) {
+                vertx.close();
+            }
+        }
+
+        return 0;
+    }
+
+    // Visible for testing
+    CompletionStage<HttpServer> serve(Vertx vertx) {
+        HttpServer server = vertx.createHttpServer();
+        Router router = Router.router(vertx);
+
+        router.route()
+                .handler(BodyHandler.create())
+                .failureHandler(this::handleFailure);
+
+        router.route(HttpMethod.GET, "/catalog/model/:kind/:name")
+                .produces(MIME_TYPE_JSON)
+                .blockingHandler(this::handleCatalogModel);
+
+        router.route(HttpMethod.GET, "/catalog/capability/:name")
+                .produces(MIME_TYPE_JSON)
+                .blockingHandler(this::handleCatalogCapability);
+
+        router.route(HttpMethod.POST, "/inspect/:location")
+                .produces(MIME_TYPE_JSON)
+                .blockingHandler(this::handleInspect);
+
+        return server.requestHandler(router).listen(port, host).toCompletionStage();
+    }
+
+    private void handleFailure(RoutingContext ctx) {
+        LOGGER.info("", ctx.failure());

Review Comment:
   Should this be WARN ?



##########
dsl/camel-jbang/camel-jbang-plugin-k/src/main/java/org/apache/camel/dsl/jbang/core/commands/k/Agent.java:
##########
@@ -0,0 +1,424 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.k;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.CountDownLatch;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.Route;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.component.kamelet.KameletEndpoint;
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.dsl.jbang.core.commands.k.support.Capability;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeType;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeTypeConverter;
+import org.apache.camel.dsl.jbang.core.commands.k.support.SourceMetadata;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubComponentResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubDataFormatResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubLanguageResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubTransformerResolver;
+import org.apache.camel.dsl.jbang.core.common.CatalogLoader;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultModelReifierFactory;
+import org.apache.camel.model.CircuitBreakerDefinition;
+import org.apache.camel.model.FromDefinition;
+import org.apache.camel.model.Model;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.reifier.DisabledReifier;
+import org.apache.camel.reifier.ProcessorReifier;
+import org.apache.camel.spi.ComponentResolver;
+import org.apache.camel.spi.DataFormatResolver;
+import org.apache.camel.spi.LanguageResolver;
+import org.apache.camel.spi.TransformerResolver;
+import org.apache.camel.support.PluginHelper;
+import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.tooling.model.BaseModel;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.DataFormatModel;
+import org.apache.camel.tooling.model.EntityRef;
+import org.apache.camel.tooling.model.Kind;
+import org.apache.camel.tooling.model.LanguageModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+
+@CommandLine.Command(name = Agent.ID, description = "TODO", sortOptions = false)
+public class Agent extends CamelCommand {
+    private static final Logger LOGGER = LoggerFactory.getLogger(Agent.class);
+
+    private static final ObjectMapper MAPPER = new ObjectMapper()
+            .setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+
+    private static final Map<String, BiConsumer<CamelCatalog, SourceMetadata>> COMPONENT_CUSTOMIZERS;
+
+    public static final String ID = "agent";
+    public static final String STUB_PATTERN = "*";
+    public static final String MIME_TYPE_JSON = "application/json";
+    public static final String CONTENT_TYPE_HEADER = "Content-Type";
+
+    static {
+        // the core CircuitBreaker reifier fails as it depends on a specific implementation provided by
+        // a dedicated component/module, but as we are orly inspecting the route to determine its capabilities,
+        // we can safely disable the EIP with a disabled/stub reifier.
+        ProcessorReifier.registerReifier(CircuitBreakerDefinition.class, DisabledReifier::new);
+
+        COMPONENT_CUSTOMIZERS = new HashMap<>();
+        COMPONENT_CUSTOMIZERS.put("platform-http", (catalog, meta) -> {
+            meta.capabilities.put(
+                    Capability.PlatformHttp,
+                    catalog
+                            .findCapabilityRef(Capability.PlatformHttp.getValue())
+                            .orElseGet(() -> new EntityRef(null, null)));
+        });
+
+    }
+
+    @CommandLine.Option(
+                        names = { "--listen-host" },
+                        description = "")
+    String host = "localhost";
+
+    @CommandLine.Option(
+                        names = { "--listen-port" },
+                        description = "")
+    int port = 8081;
+
+    @CommandLine.Option(
+                        names = { "--runtime-version" },
+                        description = "To use a different runtime version than the default version")
+    String runtimeVersion;
+
+    @CommandLine.Option(
+                        names = { "--runtime" },
+                        converter = RuntimeTypeConverter.class,
+                        description = "Runtime (spring-boot, quarkus, camel-main)")
+    RuntimeType runtimeType = RuntimeType.camelMain;
+
+    @CommandLine.Option(
+                        names = { "--repos" },
+                        description = "Comma separated list of additional maven repositories")
+    String repos;
+
+    public Agent(CamelJBangMain main) {
+        super(main);
+    }
+
+    @Override
+    public Integer doCall() throws Exception {
+        Vertx vertx = null;
+        HttpServer server = null;
+
+        try {
+            CountDownLatch latch = new CountDownLatch(1);
+
+            vertx = Vertx.vertx();
+            server = serve(vertx).toCompletableFuture().get();
+
+            latch.await();

Review Comment:
   What triggers this latch to complete, it seems its a local latch only



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "lburgazzoli (via GitHub)" <gi...@apache.org>.
lburgazzoli commented on PR #13408:
URL: https://github.com/apache/camel/pull/13408#issuecomment-2006390393

   @christophd @claudio4j @davsclaus do you think this is a good enough initial version  ? if so I'd like to get it merged


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #13408:
URL: https://github.com/apache/camel/pull/13408#issuecomment-2007090635

   Just wonder why the aws-xray dependency was added? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "lburgazzoli (via GitHub)" <gi...@apache.org>.
lburgazzoli commented on PR #13408:
URL: https://github.com/apache/camel/pull/13408#issuecomment-1983688129

   > is this Camel K specific? I wonder if this could go into the core Camel JBang instead of the k plugin?
   
   I do not know, at this stage I'm mainly focus to be able to replicate what camel-k needs so I added this to the camel-k subcommand, but could become more generic at some point.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "claudio4j (via GitHub)" <gi...@apache.org>.
claudio4j commented on PR #13408:
URL: https://github.com/apache/camel/pull/13408#issuecomment-2007033159

   Sure, this is good, can be enhanced later for additional services.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "lburgazzoli (via GitHub)" <gi...@apache.org>.
lburgazzoli commented on PR #13408:
URL: https://github.com/apache/camel/pull/13408#issuecomment-2007202238

   > And are you use rest-assured for runtime or testing only, it may need scope=test
   
   it was a mistake


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #13408:
URL: https://github.com/apache/camel/pull/13408#issuecomment-2011615874

   Yeah sure. Though I would maybe call it `standalone` or `camelMain` as the runtime instead of `vanilla`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #13408:
URL: https://github.com/apache/camel/pull/13408#discussion_r1533501960


##########
dsl/camel-jbang/camel-jbang-plugin-k/src/main/java/org/apache/camel/dsl/jbang/core/commands/k/Agent.java:
##########
@@ -0,0 +1,424 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands.k;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.CountDownLatch;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.vertx.core.Vertx;
+import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServer;
+import io.vertx.ext.web.Router;
+import io.vertx.ext.web.RoutingContext;
+import io.vertx.ext.web.handler.BodyHandler;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.Route;
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.component.kamelet.KameletEndpoint;
+import org.apache.camel.dsl.jbang.core.commands.CamelCommand;
+import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
+import org.apache.camel.dsl.jbang.core.commands.k.support.Capability;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeType;
+import org.apache.camel.dsl.jbang.core.commands.k.support.RuntimeTypeConverter;
+import org.apache.camel.dsl.jbang.core.commands.k.support.SourceMetadata;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubComponentResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubDataFormatResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubLanguageResolver;
+import org.apache.camel.dsl.jbang.core.commands.k.support.StubTransformerResolver;
+import org.apache.camel.dsl.jbang.core.common.CatalogLoader;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultModelReifierFactory;
+import org.apache.camel.model.CircuitBreakerDefinition;
+import org.apache.camel.model.FromDefinition;
+import org.apache.camel.model.Model;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.reifier.DisabledReifier;
+import org.apache.camel.reifier.ProcessorReifier;
+import org.apache.camel.spi.ComponentResolver;
+import org.apache.camel.spi.DataFormatResolver;
+import org.apache.camel.spi.LanguageResolver;
+import org.apache.camel.spi.TransformerResolver;
+import org.apache.camel.support.PluginHelper;
+import org.apache.camel.support.ResourceHelper;
+import org.apache.camel.tooling.model.BaseModel;
+import org.apache.camel.tooling.model.ComponentModel;
+import org.apache.camel.tooling.model.DataFormatModel;
+import org.apache.camel.tooling.model.EntityRef;
+import org.apache.camel.tooling.model.Kind;
+import org.apache.camel.tooling.model.LanguageModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+
+@CommandLine.Command(name = Agent.ID, description = "TODO", sortOptions = false)
+public class Agent extends CamelCommand {
+    private static final Logger LOGGER = LoggerFactory.getLogger(Agent.class);
+
+    private static final ObjectMapper MAPPER = new ObjectMapper()
+            .setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
+
+    private static final Map<String, BiConsumer<CamelCatalog, SourceMetadata>> COMPONENT_CUSTOMIZERS;
+
+    public static final String ID = "agent";
+    public static final String STUB_PATTERN = "*";
+    public static final String MIME_TYPE_JSON = "application/json";
+    public static final String CONTENT_TYPE_HEADER = "Content-Type";
+
+    static {
+        // the core CircuitBreaker reifier fails as it depends on a specific implementation provided by
+        // a dedicated component/module, but as we are orly inspecting the route to determine its capabilities,
+        // we can safely disable the EIP with a disabled/stub reifier.
+        ProcessorReifier.registerReifier(CircuitBreakerDefinition.class, DisabledReifier::new);
+
+        COMPONENT_CUSTOMIZERS = new HashMap<>();
+        COMPONENT_CUSTOMIZERS.put("platform-http", (catalog, meta) -> {
+            meta.capabilities.put(
+                    Capability.PlatformHttp,
+                    catalog
+                            .findCapabilityRef(Capability.PlatformHttp.getValue())
+                            .orElseGet(() -> new EntityRef(null, null)));
+        });
+
+    }
+
+    @CommandLine.Option(
+                        names = { "--listen-host" },
+                        description = "")
+    String host = "localhost";
+
+    @CommandLine.Option(
+                        names = { "--listen-port" },
+                        description = "")
+    int port = 8081;
+
+    @CommandLine.Option(
+                        names = { "--runtime-version" },
+                        description = "To use a different runtime version than the default version")
+    String runtimeVersion;
+
+    @CommandLine.Option(
+                        names = { "--runtime" },
+                        converter = RuntimeTypeConverter.class,
+                        description = "Runtime (spring-boot, quarkus, camel-main)")
+    RuntimeType runtimeType = RuntimeType.camelMain;
+
+    @CommandLine.Option(
+                        names = { "--repos" },
+                        description = "Comma separated list of additional maven repositories")
+    String repos;
+
+    public Agent(CamelJBangMain main) {
+        super(main);
+    }
+
+    @Override
+    public Integer doCall() throws Exception {
+        Vertx vertx = null;
+        HttpServer server = null;
+
+        try {
+            CountDownLatch latch = new CountDownLatch(1);
+
+            vertx = Vertx.vertx();
+            server = serve(vertx).toCompletableFuture().get();
+
+            latch.await();

Review Comment:
   okay maybe add a code comment about that, and if the server is asked to terminate via SIGTERM then it will just hang wont it? You may need to do like camel-main and have a jvm shutdown hook, but that can be done in another PR later.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "claudio4j (via GitHub)" <gi...@apache.org>.
claudio4j commented on code in PR #13408:
URL: https://github.com/apache/camel/pull/13408#discussion_r1516287383


##########
dsl/camel-jbang/camel-jbang-plugin-k/src/main/java/org/apache/camel/dsl/jbang/core/commands/k/support/SourceHelper.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.dsl.jbang.core.commands.k.support;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.camel.main.KameletMain;
+
+public final class SourceHelper {
+
+    private SourceHelper() {
+        //prevent instantiation of utility class.
+    }
+
+    public static Set<String> dependencies(List<Source> sources) throws Exception {
+        List<String> files = new ArrayList<>();
+
+        for (Source s : sources) {
+            if (s.local() && !s.path().startsWith("classpath:")) {
+                // get the absolute path for a local file
+                files.add("file://" + new File(s.path()).getAbsolutePath());
+            } else {
+                files.add(s.path());
+            }
+        }
+
+        KameletMain main = new KameletMain();
+        DependenciesDownloadListener downloadListener = new DependenciesDownloadListener(sources);

Review Comment:
   just a note, there is a [PR to revert](https://github.com/apache/camel/pull/13404) this.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "lburgazzoli (via GitHub)" <gi...@apache.org>.
lburgazzoli commented on code in PR #13408:
URL: https://github.com/apache/camel/pull/13408#discussion_r1516294071


##########
dsl/camel-jbang/camel-jbang-plugin-k/src/main/java/org/apache/camel/dsl/jbang/core/commands/k/support/SourceHelper.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.dsl.jbang.core.commands.k.support;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.camel.main.KameletMain;
+
+public final class SourceHelper {
+
+    private SourceHelper() {
+        //prevent instantiation of utility class.
+    }
+
+    public static Set<String> dependencies(List<Source> sources) throws Exception {
+        List<String> files = new ArrayList<>();
+
+        for (Source s : sources) {
+            if (s.local() && !s.path().startsWith("classpath:")) {
+                // get the absolute path for a local file
+                files.add("file://" + new File(s.path()).getAbsolutePath());
+            } else {
+                files.add(s.path());
+            }
+        }
+
+        KameletMain main = new KameletMain();
+        DependenciesDownloadListener downloadListener = new DependenciesDownloadListener(sources);

Review Comment:
   thx, this is pretty much a leftover that I was supposed to remove, Initially I did try to use the download listeners but realized that in fact we do no need to download anything to perform route inspection.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "lburgazzoli (via GitHub)" <gi...@apache.org>.
lburgazzoli commented on PR #13408:
URL: https://github.com/apache/camel/pull/13408#issuecomment-1983349599

   This PR is mainly aimed as exploring a possible came-k sub command to inspect routes and provide insight to the camel-k operator. The goal is to use this as a sidecar so the sub-command starts a simple http server (based on vertx).
   
   The result of the inspection is something like:
   
   ```json
   {
       "capabilities": [
           "platform-http",
           "circuit-breaker"
       ],
       "dependencies": [
           "mvn:org.apache.camel/camel-core-languages/4.5.0-SNAPSHOT",
           "mvn:org.apache.camel/camel-jackson/4.5.0-SNAPSHOT",
           "mvn:org.apache.camel/camel-kafka/4.5.0-SNAPSHOT",
           "mvn:org.apache.camel/camel-knative/4.5.0-SNAPSHOT",
           "mvn:org.apache.camel/camel-log/4.5.0-SNAPSHOT",
           "mvn:org.apache.camel/camel-platform-http/4.5.0-SNAPSHOT"
       ],
       "endpoints": {
           "from": [
               "platform-http:///foo"
           ],
           "to": [
               "kafka://topic",
               "knative://event/foo?apiVersion=eventing.knavine.dev/v1alpha1&kind=Channel&name=bar",
               "log://info"
           ]
       },
       "resourcs": {
           "components": [
               "kafka",
               "knative",
               "log",
               "platform-http"
           ],
           "dataformats": [
               "jackson"
           ],
           "languages": [
               "constant",
               "simple"
           ]
       }
   }
   ```
   
   NOTES:
   1. there are code duplication and custom logic inspired by other camel-jbang subcommand that may be refactored at some point, but I didn't want to go that far as this stage
   2. the code is still a work in progress and not all the possible cases have been taken into account
   3. some enhancement on the camel-catalog, like having the option to add some metadata would be very welcome
   4. there is the potential to get rid of the camel-k specific catalog and rely on the camel's one in the future 
   
   
   @davsclaus I would really appreciate your feedback


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #13408:
URL: https://github.com/apache/camel/pull/13408#discussion_r1533424295


##########
dsl/camel-jbang/camel-jbang-plugin-k/pom.xml:
##########
@@ -72,6 +72,15 @@
             <version>${kubernetes-client-version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-aws-xray</artifactId>

Review Comment:
   Is this JAR needed?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "lburgazzoli (via GitHub)" <gi...@apache.org>.
lburgazzoli commented on code in PR #13408:
URL: https://github.com/apache/camel/pull/13408#discussion_r1533428368


##########
dsl/camel-jbang/camel-jbang-plugin-k/pom.xml:
##########
@@ -72,6 +72,15 @@
             <version>${kubernetes-client-version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-aws-xray</artifactId>

Review Comment:
   damn, I messed up things, let me fix it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "christophd (via GitHub)" <gi...@apache.org>.
christophd commented on PR #13408:
URL: https://github.com/apache/camel/pull/13408#issuecomment-1983528779

   is this Camel K specific? I wonder if this could go into the core Camel JBang instead of the k plugin?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #13408:
URL: https://github.com/apache/camel/pull/13408#issuecomment-2007092139

   And are you use rest-assured for runtime or testing only, it may need <scope>test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "lburgazzoli (via GitHub)" <gi...@apache.org>.
lburgazzoli commented on code in PR #13408:
URL: https://github.com/apache/camel/pull/13408#discussion_r1530385279


##########
dsl/camel-jbang/camel-jbang-plugin-k/pom.xml:
##########
@@ -72,6 +72,15 @@
             <version>${kubernetes-client-version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-aws-xray</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.rest-assured</groupId>
+            <artifactId>rest-assured</artifactId>
+            <version>${rest-assured-version}</version>
+        </dependency>

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "lburgazzoli (via GitHub)" <gi...@apache.org>.
lburgazzoli merged PR #13408:
URL: https://github.com/apache/camel/pull/13408


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "apupier (via GitHub)" <gi...@apache.org>.
apupier commented on code in PR #13408:
URL: https://github.com/apache/camel/pull/13408#discussion_r1530325494


##########
dsl/camel-jbang/camel-jbang-plugin-k/pom.xml:
##########
@@ -72,6 +72,15 @@
             <version>${kubernetes-client-version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-aws-xray</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.rest-assured</groupId>
+            <artifactId>rest-assured</artifactId>
+            <version>${rest-assured-version}</version>
+        </dependency>

Review Comment:
   i think that the scope test is missing



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "lburgazzoli (via GitHub)" <gi...@apache.org>.
lburgazzoli commented on PR #13408:
URL: https://github.com/apache/camel/pull/13408#issuecomment-2011670345

   @davsclaus mind a review ? sorry, I overridden my previous changes by mistake ... 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on PR #13408:
URL: https://github.com/apache/camel/pull/13408#issuecomment-2011707564

   A little bit to polish.
   
   Then I wonder if returning 404 vs 204 with empty json is better or not. Though maybe 404 is not harsh and okay.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "lburgazzoli (via GitHub)" <gi...@apache.org>.
lburgazzoli commented on PR #13408:
URL: https://github.com/apache/camel/pull/13408#issuecomment-2011625012

   > Yeah sure. Though I would maybe call it `standalone` or `camelMain` as the runtime instead of `vanilla`.
   
   done


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(jbang): camel-k agent sub-command [camel]

Posted by "lburgazzoli (via GitHub)" <gi...@apache.org>.
lburgazzoli commented on PR #13408:
URL: https://github.com/apache/camel/pull/13408#issuecomment-2011739075

   @davsclaus hopefuly I fixed the findings :) 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org