From 70ff89ba757ba6e7674b517bc6a4dcd36d422e3b Mon Sep 17 00:00:00 2001 From: Fu Cheng Date: Fri, 4 Oct 2024 20:01:39 +1300 Subject: [PATCH] refactor ktor --- .../cli/command/BuildCommand.kt | 5 ++-- .../launcher/ktor/server/AppMain.kt | 1 - .../launcher/ktor/server/models/Artifact.kt | 11 -------- .../server/models/GetAgentTask404Response.kt | 13 +--------- .../launcher/ktor/server/models/Pagination.kt | 13 +--------- .../launcher/ktor/server/models/Step.kt | 26 +++++-------------- .../ktor/server/models/StepRequestBody.kt | 11 -------- .../launcher/ktor/server/models/Task.kt | 15 +---------- .../models/TaskArtifactsListResponse.kt | 20 +++----------- .../ktor/server/models/TaskListResponse.kt | 20 +++----------- .../ktor/server/models/TaskRequestBody.kt | 11 -------- .../server/models/TaskStepsListResponse.kt | 20 +++----------- .../ktor/src/main/resources/application.conf | 12 --------- 13 files changed, 21 insertions(+), 157 deletions(-) delete mode 100644 launchers/ktor/src/main/resources/application.conf diff --git a/cli/src/main/kotlin/io/github/llmagentbuilder/cli/command/BuildCommand.kt b/cli/src/main/kotlin/io/github/llmagentbuilder/cli/command/BuildCommand.kt index 75a0bf2..c9ae26b 100644 --- a/cli/src/main/kotlin/io/github/llmagentbuilder/cli/command/BuildCommand.kt +++ b/cli/src/main/kotlin/io/github/llmagentbuilder/cli/command/BuildCommand.kt @@ -43,8 +43,9 @@ class BuildCommand : Callable { val args = arrayOf("package") val result = CommandHelper.runMavenCli(args, projectDir) if (result == 0) { - val outputPath = - (outputDir?.toPath() ?: Path.of(".")).resolve("agent.jar") + val outputDir = (outputDir?.toPath() ?: Path.of(".")) + Files.createDirectories(outputDir) + val outputPath = outputDir.resolve("agent.jar") Files.copy( projectDir.resolve("target") .resolve("agent-jar-with-dependencies.jar"), diff --git a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/AppMain.kt b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/AppMain.kt index 8d25524..cf52d24 100644 --- a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/AppMain.kt +++ b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/AppMain.kt @@ -12,7 +12,6 @@ import io.ktor.server.plugins.defaultheaders.* import io.ktor.server.resources.* import io.ktor.server.routing.* - object KtorLauncher { fun launch(chatAgent: ChatAgent) { embeddedServer( diff --git a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Artifact.kt b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Artifact.kt index de1edda..fc2f301 100644 --- a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Artifact.kt +++ b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Artifact.kt @@ -1,14 +1,3 @@ -/** -* Agent Protocol -* Specification of the API protocol for communication with an agent. -* -* The version of the OpenAPI document: v1 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ package io.github.llmagentbuilder.launcher.ktor.server.models diff --git a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/GetAgentTask404Response.kt b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/GetAgentTask404Response.kt index 82a5383..e092bd3 100644 --- a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/GetAgentTask404Response.kt +++ b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/GetAgentTask404Response.kt @@ -1,19 +1,8 @@ -/** -* Agent Protocol -* Specification of the API protocol for communication with an agent. -* -* The version of the OpenAPI document: v1 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ package io.github.llmagentbuilder.launcher.ktor.server.models /** - * + * * @param message Message stating the entity was not found */ data class GetAgentTask404Response( diff --git a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Pagination.kt b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Pagination.kt index e97c2bc..2c1f437 100644 --- a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Pagination.kt +++ b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Pagination.kt @@ -1,19 +1,8 @@ -/** -* Agent Protocol -* Specification of the API protocol for communication with an agent. -* -* The version of the OpenAPI document: v1 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ package io.github.llmagentbuilder.launcher.ktor.server.models /** - * + * * @param totalItems Total number of items. * @param totalPages Total number of pages. * @param currentPage Current_page page number. diff --git a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Step.kt b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Step.kt index acf63f8..d577a49 100644 --- a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Step.kt +++ b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Step.kt @@ -1,20 +1,7 @@ -/** -* Agent Protocol -* Specification of the API protocol for communication with an agent. -* -* The version of the OpenAPI document: v1 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ package io.github.llmagentbuilder.launcher.ktor.server.models -import io.github.llmagentbuilder.launcher.ktor.server.models.Artifact - /** - * + * * @param taskId The ID of the task this step belongs to. * @param stepId The ID of the task step. * @param status The status of the task step. @@ -47,13 +34,12 @@ data class Step( val output: kotlin.String? = null, /* Output that the task step has produced. Any value is allowed. */ val additionalOutput: kotlin.Any? = null -) -{ +) { /** - * The status of the task step. - * Values: created,running,completed - */ - enum class Status(val value: kotlin.String){ + * The status of the task step. + * Values: created,running,completed + */ + enum class Status(val value: kotlin.String) { created("created"), running("running"), completed("completed"); diff --git a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/StepRequestBody.kt b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/StepRequestBody.kt index 86d4321..5d20ac1 100644 --- a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/StepRequestBody.kt +++ b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/StepRequestBody.kt @@ -1,14 +1,3 @@ -/** -* Agent Protocol -* Specification of the API protocol for communication with an agent. -* -* The version of the OpenAPI document: v1 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ package io.github.llmagentbuilder.launcher.ktor.server.models diff --git a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Task.kt b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Task.kt index 3c0105c..5e3ce56 100644 --- a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Task.kt +++ b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/Task.kt @@ -1,20 +1,7 @@ -/** -* Agent Protocol -* Specification of the API protocol for communication with an agent. -* -* The version of the OpenAPI document: v1 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ package io.github.llmagentbuilder.launcher.ktor.server.models -import io.github.llmagentbuilder.launcher.ktor.server.models.Artifact - /** - * + * * @param taskId The ID of the task. * @param artifacts A list of artifacts that the task has produced. * @param input Input prompt for the task. diff --git a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskArtifactsListResponse.kt b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskArtifactsListResponse.kt index a94d05b..b0996c4 100644 --- a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskArtifactsListResponse.kt +++ b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskArtifactsListResponse.kt @@ -1,23 +1,9 @@ -/** -* Agent Protocol -* Specification of the API protocol for communication with an agent. -* -* The version of the OpenAPI document: v1 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ package io.github.llmagentbuilder.launcher.ktor.server.models -import io.github.llmagentbuilder.launcher.ktor.server.models.Artifact -import io.github.llmagentbuilder.launcher.ktor.server.models.Pagination - /** - * - * @param artifacts - * @param pagination + * + * @param artifacts + * @param pagination */ data class TaskArtifactsListResponse( val artifacts: kotlin.collections.List, diff --git a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskListResponse.kt b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskListResponse.kt index a6d19e4..a2fdbe0 100644 --- a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskListResponse.kt +++ b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskListResponse.kt @@ -1,23 +1,9 @@ -/** -* Agent Protocol -* Specification of the API protocol for communication with an agent. -* -* The version of the OpenAPI document: v1 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ package io.github.llmagentbuilder.launcher.ktor.server.models -import io.github.llmagentbuilder.launcher.ktor.server.models.Pagination -import io.github.llmagentbuilder.launcher.ktor.server.models.Task - /** - * - * @param tasks - * @param pagination + * + * @param tasks + * @param pagination */ data class TaskListResponse( val tasks: kotlin.collections.List, diff --git a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskRequestBody.kt b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskRequestBody.kt index 95fd10d..1be1676 100644 --- a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskRequestBody.kt +++ b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskRequestBody.kt @@ -1,14 +1,3 @@ -/** -* Agent Protocol -* Specification of the API protocol for communication with an agent. -* -* The version of the OpenAPI document: v1 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ package io.github.llmagentbuilder.launcher.ktor.server.models diff --git a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskStepsListResponse.kt b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskStepsListResponse.kt index fefa87d..f1f153b 100644 --- a/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskStepsListResponse.kt +++ b/launchers/ktor/src/main/kotlin/io/github/llmagentbuilder/launcher/ktor/server/models/TaskStepsListResponse.kt @@ -1,23 +1,9 @@ -/** -* Agent Protocol -* Specification of the API protocol for communication with an agent. -* -* The version of the OpenAPI document: v1 -* -* -* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -* https://openapi-generator.tech -* Do not edit the class manually. -*/ package io.github.llmagentbuilder.launcher.ktor.server.models -import io.github.llmagentbuilder.launcher.ktor.server.models.Pagination -import io.github.llmagentbuilder.launcher.ktor.server.models.Step - /** - * - * @param steps - * @param pagination + * + * @param steps + * @param pagination */ data class TaskStepsListResponse( val steps: kotlin.collections.List, diff --git a/launchers/ktor/src/main/resources/application.conf b/launchers/ktor/src/main/resources/application.conf deleted file mode 100644 index 96d81fa..0000000 --- a/launchers/ktor/src/main/resources/application.conf +++ /dev/null @@ -1,12 +0,0 @@ -ktor { - deployment { - environment = development - port = 8080 - autoreload = true - watch = [ io.github.llmagentbuilder.launcher.ktor.server ] - } - - application { - modules = [ io.github.llmagentbuilder.launcher.ktor.server.AppMainKt.main ] - } -}