From d1506021c297adccc9989b7842f5481b08afdbcd Mon Sep 17 00:00:00 2001 From: Andrew Charneski Date: Tue, 19 Nov 2024 09:05:19 -0500 Subject: [PATCH] 1.2.21 (#122) --- gradle.properties | 2 +- .../skyenet/apps/general/AutoPlanChatApp.kt | 170 +++++++++++++----- .../skyenet/apps/general/CmdPatchApp.kt | 4 +- .../skyenet/apps/general/PatchApp.kt | 9 +- .../skyenet/apps/general/PlanChatApp.kt | 7 +- .../skyenet/apps/plan/AbstractTask.kt | 2 +- .../skyenet/apps/plan/CommandAutoFixTask.kt | 14 +- .../skyenet/apps/plan/CommandSessionTask.kt | 11 +- .../skyenet/apps/plan/ForeachTask.kt | 22 +-- .../skyenet/apps/plan/GitHubSearchTask.kt | 8 +- .../skyenet/apps/plan/GoogleSearchTask.kt | 8 +- .../skyenet/apps/plan/PlanCoordinator.kt | 36 ++-- .../skyenet/apps/plan/PlanProcessingState.kt | 14 +- .../skyenet/apps/plan/PlanSettings.kt | 12 +- .../skyenet/apps/plan/PlanUtil.kt | 14 +- .../simiacryptus/skyenet/apps/plan/Planner.kt | 4 +- .../skyenet/apps/plan/PlanningTask.kt | 14 +- .../skyenet/apps/plan/RunShellCommandTask.kt | 10 +- .../skyenet/apps/plan/SearchTask.kt | 8 +- .../skyenet/apps/plan/SeleniumSessionTask.kt | 10 +- .../apps/plan/TaskBreakdownWithPrompt.kt | 2 +- .../skyenet/apps/plan/TaskType.kt | 92 +++++----- .../apps/plan/WebFetchAndTransformTask.kt | 8 +- .../apps/plan/file/AbstractAnalysisTask.kt | 2 +- .../apps/plan/file/AbstractFileTask.kt | 10 +- .../apps/plan/file/CodeOptimizationTask.kt | 10 +- .../skyenet/apps/plan/file/CodeReviewTask.kt | 10 +- .../apps/plan/file/DocumentationTask.kt | 10 +- .../apps/plan/file/FileModificationTask.kt | 56 +++--- .../skyenet/apps/plan/file/InquiryTask.kt | 8 +- .../apps/plan/file/PerformanceAnalysisTask.kt | 10 +- .../skyenet/apps/plan/file/RefactorTask.kt | 10 +- .../apps/plan/file/SecurityAuditTask.kt | 10 +- .../apps/plan/file/TestGenerationTask.kt | 10 +- .../plan/knowledge/EmbeddingSearchTask.kt | 8 +- .../plan/knowledge/KnowledgeIndexingTask.kt | 8 +- .../plan/knowledge/WebSearchAndIndexTask.kt | 10 +- 37 files changed, 372 insertions(+), 281 deletions(-) diff --git a/gradle.properties b/gradle.properties index 672f52c3..3f04f7a2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Gradle Releases -> https://github.com/gradle/gradle/releases libraryGroup=com.simiacryptus.skyenet -libraryVersion=1.2.20 +libraryVersion=1.2.21 gradleVersion=7.6.1 kotlin.daemon.jvmargs=-Xmx4g diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/AutoPlanChatApp.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/AutoPlanChatApp.kt index 0978feae..f1a1557f 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/AutoPlanChatApp.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/AutoPlanChatApp.kt @@ -3,14 +3,11 @@ package com.simiacryptus.skyenet.apps.general import com.simiacryptus.jopenai.API import com.simiacryptus.jopenai.ChatClient import com.simiacryptus.jopenai.OpenAIClient +import com.simiacryptus.jopenai.describe.Description import com.simiacryptus.jopenai.models.ChatModel import com.simiacryptus.skyenet.TabbedDisplay -import com.simiacryptus.skyenet.apps.plan.PlanCoordinator -import com.simiacryptus.skyenet.apps.plan.PlanSettings -import com.simiacryptus.skyenet.apps.plan.PlanTaskBase -import com.simiacryptus.skyenet.apps.plan.TaskSettings -import com.simiacryptus.skyenet.apps.plan.TaskType -import com.simiacryptus.skyenet.apps.plan.file.FileModificationTask.FileModificationTaskData +import com.simiacryptus.skyenet.apps.plan.* +import com.simiacryptus.skyenet.apps.plan.file.FileModificationTask.FileModificationTaskConfigData import com.simiacryptus.skyenet.core.actors.ParsedActor import com.simiacryptus.skyenet.core.platform.Session import com.simiacryptus.skyenet.core.platform.model.User @@ -20,8 +17,7 @@ import com.simiacryptus.skyenet.webui.application.ApplicationInterface import com.simiacryptus.skyenet.webui.session.SessionTask import com.simiacryptus.util.JsonUtil import java.io.File -import java.util.Date -import java.util.UUID +import java.util.* import java.util.concurrent.Future import java.util.concurrent.atomic.AtomicReference @@ -56,49 +52,77 @@ open class AutoPlanChatApp( private val log = org.slf4j.LoggerFactory.getLogger(AutoPlanChatApp::class.java) } + private fun logDebug(message: String, data: Any? = null) { + if (data != null) { + log.debug("$message: ${JsonUtil.toJson(data)}") + } else { + log.debug(message) + } + } + + @Description("The current thinking status of the AI assistant.") data class ThinkingStatus( + @Description("The original user prompt or request that initiated the conversation.") var initialPrompt: String? = null, + @Description("The hierarchical goals structure defining both immediate and long-term objectives.") val goals: Goals? = null, + @Description("The accumulated knowledge, facts, and uncertainties gathered during the conversation.") val knowledge: Knowledge? = null, + @Description("The operational context including task history, current state, and planned actions.") val executionContext: ExecutionContext? = null ) + @Description("The goals of the AI assistant.") data class Goals( + @Description("Immediate objectives that need to be accomplished in the current iteration.") val shortTerm: MutableList? = null, + @Description("Overall objectives that span multiple iterations or the entire conversation.") val longTerm: MutableList? = null ) + @Description("The knowledge base of the AI assistant.") data class Knowledge( + @Description("Verified information and concrete data gathered from task results and user input.") val facts: MutableList? = null, + @Description("Tentative conclusions and working assumptions that need verification.") val hypotheses: MutableList? = null, + @Description("Unresolved questions and areas requiring further investigation or clarification.") val openQuestions: MutableList? = null ) + @Description("The execution context of the AI assistant.") data class ExecutionContext( + @Description("History of successfully executed tasks and their outcomes.") val completedTasks: MutableList? = null, + @Description("Details of the task currently in progress, if any.") val currentTask: CurrentTask? = null, + @Description("Planned future actions and their expected outcomes.") val nextSteps: MutableList? = null ) + @Description("The current task being executed.") data class CurrentTask( + @Description("Unique identifier for tracking and referencing the task.") val taskId: String? = null, + @Description("Detailed description of the task's objectives and requirements.") val description: String? = null ) data class ExecutionRecord( val time: Date? = Date(), - val task: PlanTaskBase? = null, + val task: TaskConfigBase? = null, val result: String? = null ) data class Tasks( - val tasks: MutableList? = null + val tasks: MutableList? = null ) private val currentUserMessage = AtomicReference(null) private var isRunning = false val executionRecords = mutableListOf() + override fun userMessage( session: Session, user: User?, @@ -107,13 +131,13 @@ open class AutoPlanChatApp( api: API ) { try { - log.info("Received user message: $userMessage") + logDebug("Received user message", userMessage) if (!isRunning) { isRunning = true - log.info("Starting new auto plan chat") + logDebug("Starting new auto plan chat session") startAutoPlanChat(session, user, userMessage, ui, api) } else { - log.info("Injecting user message into ongoing chat") + logDebug("Injecting user message into ongoing chat", userMessage) val userMessageTask = ui.newTask() userMessageTask.echo(renderMarkdown("User: $userMessage", ui = ui)) currentUserMessage.set(userMessage) @@ -131,12 +155,14 @@ open class AutoPlanChatApp( ui: ApplicationInterface, api: API ) { + logDebug("Starting auto plan chat with initial message", userMessage) val thinkingStatus = AtomicReference(null); val task = ui.newTask(true) val api = (api as ChatClient).getChildClient().apply { val createFile = task.createFile(".logs/api-${UUID.randomUUID()}.log") createFile.second?.apply { logStreams += this.outputStream().buffered() + logDebug("Created API log file", this) task.verbose("API log: $this") } } @@ -146,10 +172,12 @@ open class AutoPlanChatApp( var continueLoop = true executor.execute { try { + logDebug("Starting main execution loop") ui.newTask(false).let { task -> tabbedDisplay["Controls"] = task.placeholder lateinit var stopLink: StringBuilder stopLink = task.add(ui.hrefLink("Stop") { + logDebug("Stop button clicked - terminating execution") continueLoop = false executor.shutdown() stopLink.set("Stopped") @@ -158,11 +186,11 @@ open class AutoPlanChatApp( } tabbedDisplay.update() task.complete() - val initialPromptTask = ui.newTask(false) initialPromptTask.add(renderMarkdown("Starting Auto Plan Chat for prompt: $userMessage")) tabbedDisplay["Initial Prompt"] = initialPromptTask.placeholder val planSettings = getSettings(session, user, PlanSettings::class.java) ?: planSettings.copy(allowBlocking = false) + logDebug("Initialized plan settings", planSettings) api.budget = planSettings.budget val coordinator = PlanCoordinator( user = user, @@ -172,19 +200,23 @@ open class AutoPlanChatApp( root = planSettings.workingDir?.let { File(it).toPath() } ?: dataStorage.getDataDir(user, session).toPath(), planSettings = planSettings ) - val initialStatus = initThinking(planSettings, userMessage) + logDebug("Created plan coordinator") + val initialStatus = initThinking(planSettings, userMessage, api) + logDebug("Initialized thinking status", initialStatus) initialStatus.initialPrompt = userMessage thinkingStatus.set(initialStatus) initialPromptTask.complete(renderMarkdown("Initial Thinking Status:\n${formatThinkingStatus(thinkingStatus.get()!!)}")) var iteration = 0 while (iteration++ < maxIterations && continueLoop) { + logDebug("Starting iteration $iteration") task.complete() val task = ui.newTask(false).apply { tabbedDisplay["Iteration $iteration"] = placeholder } val api = api.getChildClient().apply { val createFile = task.createFile(".logs/api-${UUID.randomUUID()}.log") createFile.second?.apply { logStreams += this.outputStream().buffered() + logDebug("Created iteration API log file", this) task.verbose("API log: $this") } } @@ -199,6 +231,7 @@ open class AutoPlanChatApp( formatThinkingStatus(thinkingStatus.get()!!).let { add(renderMarkdown(it)) } } val nextTask = try { + logDebug("Getting next task") getNextTask(api, planSettings, coordinator, userMessage, thinkingStatus.get()) } catch (e: Exception) { log.error("Error choosing next task", e) @@ -206,13 +239,16 @@ open class AutoPlanChatApp( break } if (nextTask?.isEmpty() != false) { + logDebug("No more tasks to execute") task.add(renderMarkdown("No more tasks to execute. Finishing Auto Plan Chat.")) break } + logDebug("Retrieved next tasks", nextTask) - val taskResults = mutableListOf>>() + val taskResults = mutableListOf>>() for ((index, currentTask) in nextTask.withIndex()) { val currentTaskId = "task_${index + 1}" + logDebug("Executing task $currentTaskId", currentTask) val taskExecutionTask = ui.newTask(false) taskExecutionTask.add( renderMarkdown( @@ -235,6 +271,7 @@ open class AutoPlanChatApp( } val completedTasks = taskResults.map { (task, future) -> val result = future.get() + logDebug("Task completed", mapOf("task" to task, "result" to result)) ExecutionRecord( time = Date(), task = task, @@ -244,16 +281,20 @@ open class AutoPlanChatApp( executionRecords.addAll(completedTasks) val thinkingStatusTask = ui.newTask(false).apply { tabbedDisplay["Thinking Status"] = placeholder } + logDebug("Updating thinking status") thinkingStatus.set( updateThinking(api, planSettings, thinkingStatus.get(), completedTasks) ) + logDebug("Updated thinking status", thinkingStatus.get()) thinkingStatusTask.complete(renderMarkdown("Updated Thinking Status:\n${formatThinkingStatus(thinkingStatus.get()!!)}")) } + logDebug("Main execution loop completed") task.complete("Auto Plan Chat completed.") } catch (e: Throwable) { task.error(ui, e) log.error("Error in startAutoPlanChat", e) } finally { + logDebug("Finalizing auto plan chat") val summaryTask = ui.newTask(false).apply { tabbedDisplay["Summary"] = placeholder } summaryTask.add( renderMarkdown( @@ -273,7 +314,7 @@ open class AutoPlanChatApp( api2: OpenAIClient, task: SessionTask, coordinator: PlanCoordinator, - currentTask: PlanTaskBase, + currentTask: TaskConfigBase, currentTaskId: String, userMessage: String, taskExecutionTask: SessionTask, @@ -286,7 +327,7 @@ open class AutoPlanChatApp( task.verbose("API log: $this") } } - val taskImpl = TaskType.Companion.getImpl(coordinator.planSettings, currentTask) + val taskImpl = TaskType.getImpl(coordinator.planSettings, currentTask) val result = StringBuilder() taskImpl.run( agent = coordinator.copy( @@ -315,25 +356,25 @@ open class AutoPlanChatApp( coordinator: PlanCoordinator, userMessage: String, thinkingStatus: ThinkingStatus? - ): List? { + ): List? { val describer1 = planSettings.describer() val tasks = ParsedActor( name = "SingleTaskChooser", resultClass = Tasks::class.java, exampleInstance = Tasks( listOf( - FileModificationTaskData( + FileModificationTaskConfigData( task_description = "Modify the file 'example.txt' to include the given input." ) - ).toMutableList() + ).toMutableList() ), prompt = """ Given the following input, choose up to ${maxTasksPerIteration} tasks to execute. Do not create a full plan, just select the most appropriate task types for the given input. Available task types: ${ - TaskType.Companion.getAvailableTaskTypes(coordinator.planSettings).joinToString>("\n") { taskType -> - "* ${TaskType.Companion.getImpl(coordinator.planSettings, taskType).promptSegment()}" + TaskType.getAvailableTaskTypes(coordinator.planSettings).joinToString("\n") { taskType -> + "* ${TaskType.getImpl(coordinator.planSettings, taskType).promptSegment()}" } } @@ -347,7 +388,7 @@ open class AutoPlanChatApp( Task Subtype Schema: ${ - TaskType.Companion.getAvailableTaskTypes(coordinator.planSettings).joinToString>("\n\n") { taskType -> + TaskType.getAvailableTaskTypes(coordinator.planSettings).joinToString("\n\n") { taskType -> """ ${taskType.name}: ${describer1.describe(taskType.taskDataClass).replace("\n", "\n ")} @@ -369,7 +410,7 @@ open class AutoPlanChatApp( task to (if (task.task_type == null) { null } else { - TaskType.Companion.getImpl(coordinator.planSettings, task) + TaskType.getImpl(coordinator.planSettings, task) })?.planTask } if (tasks.isNullOrEmpty()) { @@ -392,21 +433,49 @@ open class AutoPlanChatApp( name = "UpdateQuestionsActor", resultClass = ThinkingStatus::class.java, exampleInstance = ThinkingStatus( - initialPrompt = "Example prompt", + initialPrompt = "Create a Python script to analyze log files and generate a summary report", goals = Goals( - shortTerm = mutableListOf("Analyze task results"), - longTerm = mutableListOf("Complete the user's request") + shortTerm = mutableListOf( + "Understand log file format requirements", + "Define report structure", + "Plan implementation approach" + ), + longTerm = mutableListOf( + "Deliver working Python script", + "Ensure robust error handling", + "Provide documentation" + ) ), knowledge = Knowledge( facts = mutableListOf( - "Initial Context: User's request received", - "Task 1 Result: Analyzed user's request" + "Project requires Python programming", + "Output format needs to be a summary report", + "Input consists of log files" ), - openQuestions = mutableListOf("What is the next task?", "Are there any remaining tasks?") + hypotheses = mutableListOf( + "Log files might be in different formats", + "Performance optimization may be needed for large files" + ), + openQuestions = mutableListOf( + "What is the specific log file format?", + "Are there any performance requirements?", + "What specific metrics should be included in the report?" + ) ), executionContext = ExecutionContext( - completedTasks = mutableListOf("task_1"), - nextSteps = mutableListOf("Analyze task results", "Determine next action"), + completedTasks = mutableListOf( + "Initial requirements analysis", + "Project scope definition" + ), + currentTask = CurrentTask( + taskId = "TASK_003", + description = "Design log parsing algorithm" + ), + nextSteps = mutableListOf( + "Implement log file reader", + "Create report generator", + "Add error handling" + ) ) ), prompt = """ @@ -429,9 +498,9 @@ open class AutoPlanChatApp( "Completed task: ${record.task?.task_description}", "Task result: ${record.result}" ) - } + (currentUserMessage.get()?.let> { listOf("User message: $it") } ?: listOf()), + } + (currentUserMessage.get()?.let { listOf("User message: $it") } ?: listOf()), api - ).obj.apply { + ).obj.apply { this@AutoPlanChatApp.currentUserMessage.set(null) knowledge?.facts?.apply { this.addAll(completedTasks.mapIndexed { index, (task, result) -> @@ -442,7 +511,8 @@ open class AutoPlanChatApp( protected open fun initThinking( planSettings: PlanSettings, - userMessage: String + userMessage: String, + api: ChatClient ): ThinkingStatus { val initialStatus = ParsedActor( name = "ThinkingStatusInitializer", @@ -462,18 +532,30 @@ open class AutoPlanChatApp( ) ), prompt = """ - Given the user's initial prompt, initialize the thinking status for an AI assistant. - Set short-term and long-term goals. - Generate relevant open questions and hypotheses to guide the planning process. - Initialize the knowledge base with any relevant information from the initial prompt. - Set up the execution context with initial next steps, progress (0-100), estimated time remaining, and confidence level (0-100). - Identify potential challenges and available resources. - """.trimIndent(), + Initialize a comprehensive thinking status for an AI assistant based on the user's prompt. + Goals: + 1. Short-term goals: Define immediate objectives that can be accomplished in 1-2 iterations + 2. Long-term goals: Outline the overall project objectives and desired end state + Knowledge Base: + 1. Facts: Extract concrete information and requirements from the prompt + 2. Hypotheses: Form initial assumptions that need validation + 3. Open Questions: List critical uncertainties and information gaps + Execution Context: + 1. Next Steps: Plan initial 2-3 concrete actions + 2. Potential Challenges: Identify possible obstacles and constraints + 3. Available Resources: List tools and capabilities at disposal + Analysis Guidelines: + * Break down complex requirements into manageable components + * Consider both technical and non-technical aspects + * Identify dependencies and prerequisites + * Maintain alignment between short-term actions and long-term goals + * Ensure scalability and maintainability of the approach + """.trimIndent(), model = planSettings.defaultModel, parsingModel = planSettings.parsingModel, temperature = planSettings.temperature, describer = planSettings.describer() - ).answer(listOf(userMessage) + contextData(), this.api!!).obj + ).answer(listOf(userMessage) + contextData(), api).obj return initialStatus } diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/CmdPatchApp.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/CmdPatchApp.kt index 6b15f918..f47df08b 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/CmdPatchApp.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/CmdPatchApp.kt @@ -4,7 +4,6 @@ package com.simiacryptus.skyenet.apps.general import com.simiacryptus.diff.FileValidationUtils import com.simiacryptus.jopenai.ChatClient import com.simiacryptus.jopenai.models.ChatModel -import com.simiacryptus.jopenai.models.TextModel import com.simiacryptus.skyenet.core.platform.Session import com.simiacryptus.skyenet.set import com.simiacryptus.skyenet.webui.session.SessionTask @@ -98,8 +97,7 @@ class CmdPatchApp( } override fun output(task: SessionTask): OutputResult = run { - val command = - listOf(settings.executable.absolutePath) + settings.arguments.split(" ").filter(String::isNotBlank) + val command = listOf(settings.executable.absolutePath) + settings.arguments.split(" ").filter(String::isNotBlank) val processBuilder = ProcessBuilder(command).directory(settings.workingDirectory) // Pass the current environment to the subprocess processBuilder.environment().putAll(System.getenv()) diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/PatchApp.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/PatchApp.kt index a8f48f35..71db5c66 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/PatchApp.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/PatchApp.kt @@ -57,14 +57,19 @@ abstract class PatchApp( val socketManager = super.newSession(user, session) val ui = (socketManager as ApplicationSocketManager).applicationInterface val task = ui.newTask() - Retryable( + lateinit var retry : Retryable + var retries = 3 + retry = Retryable( ui = ui, task = task, process = { content -> val newTask = ui.newTask(false) newTask.add("Running Command") Thread { - run(ui, newTask) + val result = run(ui, newTask) + if (result.exitCode != 0 && retries-- > 0) { + retry.retry() + } }.start() newTask.placeholder } diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/PlanChatApp.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/PlanChatApp.kt index c8fd2c16..41eb083a 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/PlanChatApp.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/PlanChatApp.kt @@ -4,9 +4,8 @@ import com.simiacryptus.jopenai.API import com.simiacryptus.jopenai.ChatClient import com.simiacryptus.jopenai.OpenAIClient import com.simiacryptus.jopenai.models.ChatModel -import com.simiacryptus.jopenai.models.TextModel import com.simiacryptus.skyenet.apps.plan.* -import com.simiacryptus.skyenet.apps.plan.file.InquiryTask.InquiryTaskData +import com.simiacryptus.skyenet.apps.plan.file.InquiryTask.InquiryTaskConfigData import com.simiacryptus.skyenet.core.platform.Session import com.simiacryptus.skyenet.core.platform.model.User import com.simiacryptus.skyenet.util.MarkdownUtil @@ -143,11 +142,11 @@ open class PlanChatApp( } - protected open fun addRespondToChatTask(plan: Map): Map { + protected open fun addRespondToChatTask(plan: Map): Map { val tasksByID = plan?.toMutableMap() ?: mutableMapOf() val respondTaskId = "respond_to_chat" - tasksByID[respondTaskId] = InquiryTaskData( + tasksByID[respondTaskId] = InquiryTaskConfigData( task_description = "Respond to the user's chat message based on the executed plan", task_dependencies = tasksByID.keys.toList() ) diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/AbstractTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/AbstractTask.kt index adfe1519..e0f8bdac 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/AbstractTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/AbstractTask.kt @@ -9,7 +9,7 @@ import java.io.File import java.nio.file.Path -abstract class AbstractTask( +abstract class AbstractTask( val planSettings: PlanSettings, val planTask: T? ) { diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/CommandAutoFixTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/CommandAutoFixTask.kt index 45afc49d..6d9fe39e 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/CommandAutoFixTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/CommandAutoFixTask.kt @@ -6,7 +6,7 @@ import com.simiacryptus.jopenai.describe.Description import com.simiacryptus.skyenet.Retryable import com.simiacryptus.skyenet.apps.general.CmdPatchApp import com.simiacryptus.skyenet.apps.general.PatchApp -import com.simiacryptus.skyenet.apps.plan.CommandAutoFixTask.CommandAutoFixTaskData +import com.simiacryptus.skyenet.apps.plan.CommandAutoFixTask.CommandAutoFixTaskConfigData import com.simiacryptus.skyenet.util.MarkdownUtil import com.simiacryptus.skyenet.webui.session.SessionTask import org.slf4j.LoggerFactory @@ -16,16 +16,16 @@ import java.util.concurrent.atomic.AtomicBoolean class CommandAutoFixTask( planSettings: PlanSettings, - planTask: CommandAutoFixTaskData? -) : AbstractTask(planSettings, planTask) { + planTask: CommandAutoFixTaskConfigData? +) : AbstractTask(planSettings, planTask) { - class CommandAutoFixTaskData( + class CommandAutoFixTaskConfigData( @Description("The commands to be executed with their respective working directories") val commands: List? = null, task_description: String? = null, task_dependencies: List? = null, state: TaskState? = null - ) : PlanTaskBase( + ) : TaskConfigBase( task_type = TaskType.CommandAutoFix.name, task_description = task_description, task_dependencies = task_dependencies, @@ -64,7 +64,7 @@ ${planSettings.commandAutoFixCommands?.joinToString("\n") { " * ${File(it).na val semaphore = Semaphore(0) val hasError = AtomicBoolean(false) val onComplete = { semaphore.release() } - lateinit var retryable: Retryable + var retryable: Retryable? = null retryable = Retryable(agent.ui, task = task) { val task = agent.ui.newTask(false).apply { it.append(placeholder) } this.planTask?.commands?.forEachIndexed { index, commandWithDir -> @@ -137,7 +137,7 @@ ${planSettings.commandAutoFixCommands?.joinToString("\n") { " * ${File(it).na ) { onComplete() } - if(autoRetries-- > 0) retryable.retry() + if(autoRetries-- > 0) retryable?.retry() s }) task.placeholder diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/CommandSessionTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/CommandSessionTask.kt index 8c7c87c9..8e35b177 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/CommandSessionTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/CommandSessionTask.kt @@ -3,7 +3,6 @@ package com.simiacryptus.skyenet.apps.plan import com.simiacryptus.jopenai.ChatClient import com.simiacryptus.jopenai.OpenAIClient import com.simiacryptus.jopenai.describe.Description -import com.simiacryptus.skyenet.core.platform.ApplicationServices import com.simiacryptus.skyenet.webui.session.SessionTask import org.slf4j.LoggerFactory import java.io.BufferedReader @@ -14,8 +13,8 @@ import java.util.concurrent.TimeUnit class CommandSessionTask( planSettings: PlanSettings, - planTask: CommandSessionTaskData? -) : AbstractTask(planSettings, planTask) { + planTask: CommandSessionTaskConfigData? +) : AbstractTask(planSettings, planTask) { companion object { private val log = LoggerFactory.getLogger(CommandSessionTask::class.java) private val activeSessions = ConcurrentHashMap() @@ -68,7 +67,7 @@ class CommandSessionTask( fun getActiveSessionCount(): Int = activeSessions.size } - class CommandSessionTaskData( + class CommandSessionTaskConfigData( @Description("The command to start the interactive session") val command: List, @Description("Commands to send to the interactive session") @@ -82,7 +81,7 @@ class CommandSessionTask( task_description: String? = null, task_dependencies: List? = null, state: TaskState? = null, - ) : PlanTaskBase( + ) : TaskConfigBase( task_type = TaskType.CommandSession.name, task_description = task_description, task_dependencies = task_dependencies, @@ -175,7 +174,7 @@ class CommandSessionTask( } private fun formatResults( - planTask: CommandSessionTaskData, + planTask: CommandSessionTaskConfigData, results: List ): String = buildString { appendLine("## Command Session Results") diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/ForeachTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/ForeachTask.kt index adb409d7..3bd8e56b 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/ForeachTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/ForeachTask.kt @@ -3,7 +3,7 @@ package com.simiacryptus.skyenet.apps.plan import com.simiacryptus.jopenai.ChatClient import com.simiacryptus.jopenai.OpenAIClient import com.simiacryptus.jopenai.describe.Description -import com.simiacryptus.skyenet.apps.plan.ForeachTask.ForeachTaskData +import com.simiacryptus.skyenet.apps.plan.ForeachTask.ForeachTaskConfigData import com.simiacryptus.skyenet.apps.plan.PlanUtil.diagram import com.simiacryptus.skyenet.apps.plan.PlanUtil.executionOrder import com.simiacryptus.skyenet.webui.session.SessionTask @@ -11,18 +11,18 @@ import org.slf4j.LoggerFactory class ForeachTask( planSettings: PlanSettings, - planTask: ForeachTaskData? -) : AbstractTask(planSettings, planTask) { + planTask: ForeachTaskConfigData? +) : AbstractTask(planSettings, planTask) { - class ForeachTaskData( - @Description("A list of items over which the ForEach task will iterate. (Only applicable for ForeachTask tasks) Can be used to process outputs from previous tasks.") + class ForeachTaskConfigData( + @Description("A list of items over which the ForEach task will iterate. (Only applicable for ForeachTask tasks) Can be used to process outputs from previous tasks.") val foreach_items: List? = null, - @Description("A map of sub-task IDs to PlanTask objects to be executed for each item. (Only applicable for ForeachTask tasks) Allows for complex task dependencies and information flow within iterations.") - val foreach_subplan: Map? = null, - task_description: String? = null, - task_dependencies: List? = null, - state: TaskState? = null, - ) : PlanTaskBase( + @Description("A map of sub-task IDs to PlanTask objects to be executed for each item. (Only applicable for ForeachTask tasks) Allows for complex task dependencies and information flow within iterations.") + val foreach_subplan: Map? = null, + task_description: String? = null, + task_dependencies: List? = null, + state: TaskState? = null, + ) : TaskConfigBase( task_type = TaskType.ForeachTask.name, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/GitHubSearchTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/GitHubSearchTask.kt index 3a071ca8..3cb3b977 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/GitHubSearchTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/GitHubSearchTask.kt @@ -15,9 +15,9 @@ import java.net.http.HttpResponse class GitHubSearchTask( planSettings: PlanSettings, - planTask: GitHubSearchTaskData? -) : AbstractTask(planSettings, planTask) { - class GitHubSearchTaskData( + planTask: GitHubSearchTaskConfigData? +) : AbstractTask(planSettings, planTask) { + class GitHubSearchTaskConfigData( @Description("The search query to use for GitHub search") val search_query: String, @Description("The type of GitHub search to perform (code, commits, issues, repositories, topics, users)") @@ -31,7 +31,7 @@ class GitHubSearchTask( task_description: String? = null, task_dependencies: List? = null, state: TaskState? = null, - ) : PlanTaskBase( + ) : TaskConfigBase( task_type = TaskType.GitHubSearch.name, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/GoogleSearchTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/GoogleSearchTask.kt index 74a4aa66..dca2d560 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/GoogleSearchTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/GoogleSearchTask.kt @@ -17,9 +17,9 @@ import java.net.http.HttpResponse class GoogleSearchTask( planSettings: PlanSettings, - planTask: GoogleSearchTaskData? -) : AbstractTask(planSettings, planTask) { - class GoogleSearchTaskData( + planTask: GoogleSearchTaskConfigData? +) : AbstractTask(planSettings, planTask) { + class GoogleSearchTaskConfigData( @Description("The search query to use for Google search") val search_query: String, @Description("The number of results to return (max 10)") @@ -27,7 +27,7 @@ class GoogleSearchTask( task_description: String? = null, task_dependencies: List? = null, state: TaskState? = null, - ) : PlanTaskBase( + ) : TaskConfigBase( task_type = TaskType.GoogleSearch.name, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanCoordinator.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanCoordinator.kt index 0cc5f131..428c65f8 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanCoordinator.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanCoordinator.kt @@ -86,11 +86,11 @@ class PlanCoordinator( } fun executePlan( - plan: Map, - task: SessionTask, - userMessage: String, - api: API, - api2: OpenAIClient, + plan: Map, + task: SessionTask, + userMessage: String, + api: API, + api2: OpenAIClient, ): PlanProcessingState { val api = (api as ChatClient).getChildClient().apply { val createFile = task.createFile(".logs/api-${UUID.randomUUID()}.log") @@ -127,24 +127,24 @@ class PlanCoordinator( return planProcessingState } - private fun newState(plan: Map) = + private fun newState(plan: Map) = PlanProcessingState( - subTasks = (filterPlan { plan }?.entries?.toTypedArray>() + subTasks = (filterPlan { plan }?.entries?.toTypedArray>() ?.associate { it.key to it.value } ?: mapOf()).toMutableMap() ) fun executePlan( - task: SessionTask, - diagramBuffer: StringBuilder?, - subTasks: Map, - diagramTask: SessionTask, - planProcessingState: PlanProcessingState, - taskIdProcessingQueue: MutableList, - pool: ThreadPoolExecutor, - userMessage: String, - plan: Map, - api: API, - api2: OpenAIClient, + task: SessionTask, + diagramBuffer: StringBuilder?, + subTasks: Map, + diagramTask: SessionTask, + planProcessingState: PlanProcessingState, + taskIdProcessingQueue: MutableList, + pool: ThreadPoolExecutor, + userMessage: String, + plan: Map, + api: API, + api2: OpenAIClient, ) { val sessionTask = ui.newTask(false).apply { task.add(placeholder) } val api = (api as ChatClient).getChildClient().apply { diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanProcessingState.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanProcessingState.kt index 700cd3f7..d31b71fc 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanProcessingState.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanProcessingState.kt @@ -4,12 +4,12 @@ import com.simiacryptus.skyenet.webui.session.SessionTask import java.util.concurrent.Future data class PlanProcessingState( - val subTasks: Map, - val tasksByDescription: MutableMap = subTasks.entries.toTypedArray() + val subTasks: Map, + val tasksByDescription: MutableMap = subTasks.entries.toTypedArray() .associate { it.value.task_description to it.value }.toMutableMap(), - val taskIdProcessingQueue: MutableList = PlanUtil.executionOrder(subTasks).toMutableList(), - val taskResult: MutableMap = mutableMapOf(), - val completedTasks: MutableList = mutableListOf(), - val taskFutures: MutableMap> = mutableMapOf(), - val uitaskMap: MutableMap = mutableMapOf() + val taskIdProcessingQueue: MutableList = PlanUtil.executionOrder(subTasks).toMutableList(), + val taskResult: MutableMap = mutableMapOf(), + val completedTasks: MutableList = mutableListOf(), + val taskFutures: MutableMap> = mutableMapOf(), + val uitaskMap: MutableMap = mutableMapOf() ) \ No newline at end of file diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanSettings.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanSettings.kt index 525c1e85..ec8de8ad 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanSettings.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanSettings.kt @@ -2,13 +2,13 @@ package com.simiacryptus.skyenet.apps.plan import com.simiacryptus.jopenai.describe.AbbrevWhitelistYamlDescriber import com.simiacryptus.jopenai.models.ChatModel -import com.simiacryptus.skyenet.apps.plan.CommandAutoFixTask.CommandAutoFixTaskData +import com.simiacryptus.skyenet.apps.plan.CommandAutoFixTask.CommandAutoFixTaskConfigData import com.simiacryptus.skyenet.apps.plan.PlanUtil.isWindows -import com.simiacryptus.skyenet.apps.plan.PlanningTask.PlanningTaskData +import com.simiacryptus.skyenet.apps.plan.PlanningTask.PlanningTaskConfigData import com.simiacryptus.skyenet.apps.plan.PlanningTask.TaskBreakdownResult import com.simiacryptus.skyenet.apps.plan.TaskType.Companion.getAvailableTaskTypes import com.simiacryptus.skyenet.apps.plan.TaskType.Companion.getImpl -import com.simiacryptus.skyenet.apps.plan.file.FileModificationTask.FileModificationTaskData +import com.simiacryptus.skyenet.apps.plan.file.FileModificationTask.FileModificationTaskConfigData import com.simiacryptus.skyenet.core.actors.ParsedActor @@ -144,7 +144,7 @@ ${taskType.name}: companion object { var exampleInstance = TaskBreakdownResult( tasksByID = mapOf( - "1" to CommandAutoFixTaskData( + "1" to CommandAutoFixTaskConfigData( task_description = "Task 1", task_dependencies = listOf(), commands = listOf( @@ -154,13 +154,13 @@ ${taskType.name}: ) ) ), - "2" to FileModificationTaskData( + "2" to FileModificationTaskConfigData( task_description = "Task 2", task_dependencies = listOf("1"), input_files = listOf("input2.txt"), output_files = listOf("output2.txt"), ), - "3" to PlanningTaskData( + "3" to PlanningTaskConfigData( task_description = "Task 3", task_dependencies = listOf("2"), ) diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanUtil.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanUtil.kt index 4cfcbaeb..330fb5f6 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanUtil.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanUtil.kt @@ -13,7 +13,7 @@ object PlanUtil { fun diagram( ui: ApplicationInterface, - taskMap: Map + taskMap: Map ) = MarkdownUtil.renderMarkdown( """ |## Sub-Plan Task Dependency Graph @@ -44,7 +44,7 @@ object PlanUtil { ) ) - fun executionOrder(tasks: Map): List { + fun executionOrder(tasks: Map): List { val taskIds: MutableList = mutableListOf() val taskMap = tasks.toMutableMap() while (taskMap.isNotEmpty()) { @@ -81,7 +81,7 @@ object PlanUtil { private val mermaidGraphCache = ConcurrentHashMap() private val mermaidExceptionCache = ConcurrentHashMap() - fun buildMermaidGraph(subTasks: Map): String { + fun buildMermaidGraph(subTasks: Map): String { // Generate a unique key based on the subTasks map val cacheKey = JsonUtil.toJson(subTasks) // Return cached result if available @@ -121,7 +121,7 @@ object PlanUtil { } } - fun filterPlan(retries: Int = 3, fn: () -> Map?): Map? { + fun filterPlan(retries: Int = 3, fn: () -> Map?): Map? { val obj = fn() ?: emptyMap() val tasksByID = obj.filter { (k, v) -> when { @@ -160,9 +160,9 @@ object PlanUtil { } fun getAllDependencies( - subPlanTask: PlanTaskBase, - subTasks: Map, - visited: MutableSet + subPlanTask: TaskConfigBase, + subTasks: Map, + visited: MutableSet ): List { val dependencies = subPlanTask.task_dependencies?.toMutableList() ?: mutableListOf() subPlanTask.task_dependencies?.forEach { dep -> diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/Planner.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/Planner.kt index 0ae84425..a1a7cb5c 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/Planner.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/Planner.kt @@ -92,13 +92,13 @@ open class Planner { api: API, planSettings: PlanSettings, inStrings: List - ): ParsedResponse> { + ): ParsedResponse> { val planningActor = planSettings.planningActor() return planningActor.respond( messages = planningActor.chatMessages(inStrings), input = inStrings, api = api - ).map(Map::class.java) { it.tasksByID ?: emptyMap() } as ParsedResponse> + ).map(Map::class.java) { it.tasksByID ?: emptyMap() } as ParsedResponse> } diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanningTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanningTask.kt index 5333bc06..75abee6a 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanningTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanningTask.kt @@ -12,7 +12,7 @@ import com.simiacryptus.skyenet.apps.plan.PlanUtil.diagram import com.simiacryptus.skyenet.apps.plan.PlanUtil.executionOrder import com.simiacryptus.skyenet.apps.plan.PlanUtil.filterPlan import com.simiacryptus.skyenet.apps.plan.PlanUtil.render -import com.simiacryptus.skyenet.apps.plan.PlanningTask.PlanningTaskData +import com.simiacryptus.skyenet.apps.plan.PlanningTask.PlanningTaskConfigData import com.simiacryptus.skyenet.core.actors.ParsedResponse import com.simiacryptus.skyenet.webui.application.ApplicationInterface import com.simiacryptus.skyenet.webui.session.SessionTask @@ -21,14 +21,14 @@ import org.slf4j.LoggerFactory class PlanningTask( planSettings: PlanSettings, - planTask: PlanningTaskData? -) : AbstractTask(planSettings, planTask) { + planTask: PlanningTaskConfigData? +) : AbstractTask(planSettings, planTask) { - class PlanningTaskData( + class PlanningTaskConfigData( task_description: String? = null, task_dependencies: List? = null, state: TaskState? = TaskState.Pending, - ) : PlanTaskBase( + ) : TaskConfigBase( task_type = TaskType.TaskPlanning.name, task_description = task_description, task_dependencies = task_dependencies, @@ -37,7 +37,7 @@ class PlanningTask( data class TaskBreakdownResult( @Description("A map where each task ID is associated with its corresponding PlanTask object. Crucial for defining task relationships and information flow.") - val tasksByID: Map? = null, + val tasksByID: Map? = null, ) override fun promptSegment(): String { @@ -123,7 +123,7 @@ class PlanningTask( private fun executeSubTasks( coordinator: PlanCoordinator, userMessage: String, - subPlan: Map, + subPlan: Map, parentTask: SessionTask, api: API, api2: OpenAIClient, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/RunShellCommandTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/RunShellCommandTask.kt index 15ae187c..09f01af4 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/RunShellCommandTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/RunShellCommandTask.kt @@ -5,7 +5,7 @@ import com.simiacryptus.jopenai.OpenAIClient import com.simiacryptus.jopenai.describe.Description import com.simiacryptus.jopenai.models.ApiModel import com.simiacryptus.skyenet.apps.code.CodingAgent -import com.simiacryptus.skyenet.apps.plan.RunShellCommandTask.RunShellCommandTaskData +import com.simiacryptus.skyenet.apps.plan.RunShellCommandTask.RunShellCommandTaskConfigData import com.simiacryptus.skyenet.core.actors.CodingActor import com.simiacryptus.skyenet.interpreter.ProcessInterpreter import com.simiacryptus.skyenet.webui.session.SessionTask @@ -16,10 +16,10 @@ import kotlin.reflect.KClass class RunShellCommandTask( planSettings: PlanSettings, - planTask: RunShellCommandTaskData? -) : AbstractTask(planSettings, planTask) { + planTask: RunShellCommandTaskConfigData? +) : AbstractTask(planSettings, planTask) { - class RunShellCommandTaskData( + class RunShellCommandTaskConfigData( @Description("The shell command to be executed") val command: String? = null, @Description("The relative file path of the working directory") @@ -27,7 +27,7 @@ class RunShellCommandTask( task_description: String? = null, task_dependencies: List? = null, state: TaskState? = null - ) : PlanTaskBase( + ) : TaskConfigBase( task_type = TaskType.RunShellCommand.name, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/SearchTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/SearchTask.kt index 2f079d9d..96f704fd 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/SearchTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/SearchTask.kt @@ -14,9 +14,9 @@ import kotlin.streams.asSequence class SearchTask( planSettings: PlanSettings, - planTask: SearchTaskData? -) : AbstractTask(planSettings, planTask) { - class SearchTaskData( + planTask: SearchTaskConfigData? +) : AbstractTask(planSettings, planTask) { + class SearchTaskConfigData( @Description("The search pattern (substring or regex) to look for in the files") val search_pattern: String, @Description("Whether the search pattern is a regex (true) or a substring (false)") @@ -28,7 +28,7 @@ class SearchTask( task_description: String? = null, task_dependencies: List? = null, state: TaskState? = null, - ) : PlanTaskBase( + ) : TaskConfigBase( task_type = TaskType.Search.name, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/SeleniumSessionTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/SeleniumSessionTask.kt index 5ad8942a..66089787 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/SeleniumSessionTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/SeleniumSessionTask.kt @@ -11,8 +11,8 @@ import java.util.concurrent.ConcurrentHashMap class SeleniumSessionTask( planSettings: PlanSettings, - planTask: SeleniumSessionTaskData? -) : AbstractTask(planSettings, planTask) { + planTask: SeleniumSessionTaskConfigData? +) : AbstractTask(planSettings, planTask) { companion object { private val log = LoggerFactory.getLogger(SeleniumSessionTask::class.java) private val activeSessions = ConcurrentHashMap() @@ -75,7 +75,7 @@ class SeleniumSessionTask( } } - class SeleniumSessionTaskData( + class SeleniumSessionTaskConfigData( @Description("The URL to navigate to") val url: String, @Description("JavaScript commands to execute") @@ -89,7 +89,7 @@ class SeleniumSessionTask( task_description: String? = null, task_dependencies: List? = null, state: TaskState? = null, - ) : PlanTaskBase( + ) : TaskConfigBase( task_type = TaskType.SeleniumSession.name, task_description = task_description, task_dependencies = task_dependencies, @@ -186,7 +186,7 @@ class SeleniumSessionTask( } private fun formatResults( - planTask: SeleniumSessionTaskData, + planTask: SeleniumSessionTaskConfigData, selenium: Selenium, results: List ): String = buildString(capacity = 16384) { // Pre-allocate buffer for better performance diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/TaskBreakdownWithPrompt.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/TaskBreakdownWithPrompt.kt index 48e0dd62..a5bad29b 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/TaskBreakdownWithPrompt.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/TaskBreakdownWithPrompt.kt @@ -2,6 +2,6 @@ package com.simiacryptus.skyenet.apps.plan data class TaskBreakdownWithPrompt( val prompt: String, - val plan: Map, + val plan: Map, val planText: String ) \ No newline at end of file diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/TaskType.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/TaskType.kt index 68443dd9..41721751 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/TaskType.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/TaskType.kt @@ -8,21 +8,21 @@ import com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver import com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase import com.simiacryptus.jopenai.describe.Description import com.simiacryptus.skyenet.apps.plan.AbstractTask.TaskState -import com.simiacryptus.skyenet.apps.plan.CommandAutoFixTask.CommandAutoFixTaskData -import com.simiacryptus.skyenet.apps.plan.ForeachTask.ForeachTaskData -import com.simiacryptus.skyenet.apps.plan.GoogleSearchTask.GoogleSearchTaskData -import com.simiacryptus.skyenet.apps.plan.PlanningTask.PlanningTaskData -import com.simiacryptus.skyenet.apps.plan.RunShellCommandTask.RunShellCommandTaskData +import com.simiacryptus.skyenet.apps.plan.CommandAutoFixTask.CommandAutoFixTaskConfigData +import com.simiacryptus.skyenet.apps.plan.ForeachTask.ForeachTaskConfigData +import com.simiacryptus.skyenet.apps.plan.GoogleSearchTask.GoogleSearchTaskConfigData +import com.simiacryptus.skyenet.apps.plan.PlanningTask.PlanningTaskConfigData +import com.simiacryptus.skyenet.apps.plan.RunShellCommandTask.RunShellCommandTaskConfigData import com.simiacryptus.skyenet.apps.plan.file.* -import com.simiacryptus.skyenet.apps.plan.file.CodeOptimizationTask.CodeOptimizationTaskData -import com.simiacryptus.skyenet.apps.plan.file.CodeReviewTask.CodeReviewTaskData -import com.simiacryptus.skyenet.apps.plan.file.DocumentationTask.DocumentationTaskData -import com.simiacryptus.skyenet.apps.plan.file.FileModificationTask.FileModificationTaskData -import com.simiacryptus.skyenet.apps.plan.file.InquiryTask.InquiryTaskData -import com.simiacryptus.skyenet.apps.plan.file.PerformanceAnalysisTask.PerformanceAnalysisTaskData -import com.simiacryptus.skyenet.apps.plan.file.RefactorTask.RefactorTaskData -import com.simiacryptus.skyenet.apps.plan.file.SecurityAuditTask.SecurityAuditTaskData -import com.simiacryptus.skyenet.apps.plan.file.TestGenerationTask.TestGenerationTaskData +import com.simiacryptus.skyenet.apps.plan.file.CodeOptimizationTask.CodeOptimizationTaskConfigData +import com.simiacryptus.skyenet.apps.plan.file.CodeReviewTask.CodeReviewTaskConfigData +import com.simiacryptus.skyenet.apps.plan.file.DocumentationTask.DocumentationTaskConfigData +import com.simiacryptus.skyenet.apps.plan.file.FileModificationTask.FileModificationTaskConfigData +import com.simiacryptus.skyenet.apps.plan.file.InquiryTask.InquiryTaskConfigData +import com.simiacryptus.skyenet.apps.plan.file.PerformanceAnalysisTask.PerformanceAnalysisTaskConfigData +import com.simiacryptus.skyenet.apps.plan.file.RefactorTask.RefactorTaskConfigData +import com.simiacryptus.skyenet.apps.plan.file.SecurityAuditTask.SecurityAuditTaskConfigData +import com.simiacryptus.skyenet.apps.plan.file.TestGenerationTask.TestGenerationTaskConfigData import com.simiacryptus.skyenet.apps.plan.knowledge.EmbeddingSearchTask import com.simiacryptus.skyenet.apps.plan.knowledge.KnowledgeIndexingTask import com.simiacryptus.skyenet.apps.plan.knowledge.WebSearchAndIndexTask @@ -32,37 +32,37 @@ import com.simiacryptus.util.DynamicEnumSerializer @JsonDeserialize(using = TaskTypeDeserializer::class) @JsonSerialize(using = TaskTypeSerializer::class) -class TaskType( +class TaskType( name: String, val taskDataClass: Class ) : DynamicEnum>(name) { companion object { private val taskConstructors = - mutableMapOf, (PlanSettings, PlanTaskBase?) -> AbstractTask>() - - val TaskPlanning = TaskType("TaskPlanning", PlanningTaskData::class.java) - val Inquiry = TaskType("Inquiry", InquiryTaskData::class.java) - val Search = TaskType("Search", SearchTask.SearchTaskData::class.java) - val EmbeddingSearch = TaskType("EmbeddingSearch", EmbeddingSearchTask.EmbeddingSearchTaskData::class.java) - val FileModification = TaskType("FileModification", FileModificationTaskData::class.java) - val Documentation = TaskType("Documentation", DocumentationTaskData::class.java) - val CodeReview = TaskType("CodeReview", CodeReviewTaskData::class.java) - val TestGeneration = TaskType("TestGeneration", TestGenerationTaskData::class.java) - val Optimization = TaskType("Optimization", CodeOptimizationTaskData::class.java) - val SecurityAudit = TaskType("SecurityAudit", SecurityAuditTaskData::class.java) - val PerformanceAnalysis = TaskType("PerformanceAnalysis", PerformanceAnalysisTaskData::class.java) - val RefactorTask = TaskType("RefactorTask", RefactorTaskData::class.java) - val RunShellCommand = TaskType("RunShellCommand", RunShellCommandTaskData::class.java) - val CommandAutoFix = TaskType("CommandAutoFix", CommandAutoFixTaskData::class.java) - val ForeachTask = TaskType("ForeachTask", ForeachTaskData::class.java) - val GitHubSearch = TaskType("GitHubSearch", GitHubSearchTask.GitHubSearchTaskData::class.java) - val GoogleSearch = TaskType("GoogleSearch", GoogleSearchTaskData::class.java) - val WebFetchAndTransform = TaskType("WebFetchAndTransform", WebFetchAndTransformTask.WebFetchAndTransformTaskData::class.java) - val KnowledgeIndexing = TaskType("KnowledgeIndexing", KnowledgeIndexingTask.KnowledgeIndexingTaskData::class.java) - val WebSearchAndIndex = TaskType("WebSearchAndIndex", WebSearchAndIndexTask.WebSearchAndIndexTaskData::class.java) - val SeleniumSession = TaskType("SeleniumSession", SeleniumSessionTask.SeleniumSessionTaskData::class.java) - val CommandSession = TaskType("CommandSession", CommandSessionTask.CommandSessionTaskData::class.java) + mutableMapOf, (PlanSettings, TaskConfigBase?) -> AbstractTask>() + + val TaskPlanning = TaskType("TaskPlanning", PlanningTaskConfigData::class.java) + val Inquiry = TaskType("Inquiry", InquiryTaskConfigData::class.java) + val Search = TaskType("Search", SearchTask.SearchTaskConfigData::class.java) + val EmbeddingSearch = TaskType("EmbeddingSearch", EmbeddingSearchTask.EmbeddingSearchTaskConfigData::class.java) + val FileModification = TaskType("FileModification", FileModificationTaskConfigData::class.java) + val Documentation = TaskType("Documentation", DocumentationTaskConfigData::class.java) + val CodeReview = TaskType("CodeReview", CodeReviewTaskConfigData::class.java) + val TestGeneration = TaskType("TestGeneration", TestGenerationTaskConfigData::class.java) + val Optimization = TaskType("Optimization", CodeOptimizationTaskConfigData::class.java) + val SecurityAudit = TaskType("SecurityAudit", SecurityAuditTaskConfigData::class.java) + val PerformanceAnalysis = TaskType("PerformanceAnalysis", PerformanceAnalysisTaskConfigData::class.java) + val RefactorTask = TaskType("RefactorTask", RefactorTaskConfigData::class.java) + val RunShellCommand = TaskType("RunShellCommand", RunShellCommandTaskConfigData::class.java) + val CommandAutoFix = TaskType("CommandAutoFix", CommandAutoFixTaskConfigData::class.java) + val ForeachTask = TaskType("ForeachTask", ForeachTaskConfigData::class.java) + val GitHubSearch = TaskType("GitHubSearch", GitHubSearchTask.GitHubSearchTaskConfigData::class.java) + val GoogleSearch = TaskType("GoogleSearch", GoogleSearchTaskConfigData::class.java) + val WebFetchAndTransform = TaskType("WebFetchAndTransform", WebFetchAndTransformTask.WebFetchAndTransformTaskConfigData::class.java) + val KnowledgeIndexing = TaskType("KnowledgeIndexing", KnowledgeIndexingTask.KnowledgeIndexingTaskConfigData::class.java) + val WebSearchAndIndex = TaskType("WebSearchAndIndex", WebSearchAndIndexTask.WebSearchAndIndexTaskConfigData::class.java) + val SeleniumSession = TaskType("SeleniumSession", SeleniumSessionTask.SeleniumSessionTaskConfigData::class.java) + val CommandSession = TaskType("CommandSession", CommandSessionTask.CommandSessionTaskConfigData::class.java) init { registerConstructor(CommandAutoFix) { settings, task -> CommandAutoFixTask(settings, task) } @@ -89,11 +89,11 @@ class TaskType( registerConstructor(CommandSession) { settings, task -> CommandSessionTask(settings, task) } } - private fun registerConstructor( + private fun registerConstructor( taskType: TaskType, constructor: (PlanSettings, T?) -> AbstractTask ) { - taskConstructors[taskType] = { settings: PlanSettings, task: PlanTaskBase? -> + taskConstructors[taskType] = { settings: PlanSettings, task: TaskConfigBase? -> constructor(settings, task as T?) } register(taskType) @@ -102,14 +102,14 @@ class TaskType( fun values() = values(TaskType::class.java) fun getImpl( planSettings: PlanSettings, - planTask: PlanTaskBase? + planTask: TaskConfigBase? ) = getImpl(planSettings, planTask?.task_type?.let { valueOf(it) } ?: throw RuntimeException("Task type not specified"), planTask) fun getImpl( planSettings: PlanSettings, taskType: TaskType<*>, - planTask: PlanTaskBase? = null - ): AbstractTask { + planTask: TaskConfigBase? = null + ): AbstractTask { if (!planSettings.getTaskSettings(taskType).enabled) { throw DisabledTaskException(taskType) } @@ -129,7 +129,7 @@ class TaskType( @JsonTypeIdResolver(PlanTaskTypeIdResolver::class) @JsonTypeInfo(use = JsonTypeInfo.Id.CUSTOM, property = "task_type") -abstract class PlanTaskBase( +abstract class TaskConfigBase( @Description("An enumeration indicating the type of task to be executed. Must be a single value from the TaskType enum.") val task_type: String? = null, @Description("A detailed description of the specific task to be performed, including its role in the overall plan and its dependencies on other tasks.") @@ -142,7 +142,7 @@ abstract class PlanTaskBase( class PlanTaskTypeIdResolver : TypeIdResolverBase() { override fun idFromValue(value: Any) = when (value) { - is PlanTaskBase -> if (value.task_type != null) { + is TaskConfigBase -> if (value.task_type != null) { value.task_type } else { throw IllegalArgumentException("Unknown task type") diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/WebFetchAndTransformTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/WebFetchAndTransformTask.kt index 48ba78a1..e62dc629 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/WebFetchAndTransformTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/WebFetchAndTransformTask.kt @@ -16,9 +16,9 @@ import org.slf4j.LoggerFactory open class WebFetchAndTransformTask( planSettings: PlanSettings, - planTask: WebFetchAndTransformTaskData? -) : AbstractTask(planSettings, planTask) { - class WebFetchAndTransformTaskData( + planTask: WebFetchAndTransformTaskConfigData? +) : AbstractTask(planSettings, planTask) { + class WebFetchAndTransformTaskConfigData( @Description("The URL to fetch") val url: String, @Description("The desired format or focus for the transformation") @@ -26,7 +26,7 @@ open class WebFetchAndTransformTask( task_description: String? = null, task_dependencies: List? = null, state: TaskState? = null, - ) : PlanTaskBase( + ) : TaskConfigBase( task_type = TaskType.WebFetchAndTransform.name, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/AbstractAnalysisTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/AbstractAnalysisTask.kt index ae970291..5f7dbdc0 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/AbstractAnalysisTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/AbstractAnalysisTask.kt @@ -11,7 +11,7 @@ import com.simiacryptus.skyenet.webui.session.SessionTask import org.slf4j.LoggerFactory import java.io.File -abstract class AbstractAnalysisTask( +abstract class AbstractAnalysisTask( planSettings: PlanSettings, planTask: T? ) : AbstractFileTask(planSettings, planTask) { diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/AbstractFileTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/AbstractFileTask.kt index 50d69bf7..46ab6372 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/AbstractFileTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/AbstractFileTask.kt @@ -4,18 +4,18 @@ import com.simiacryptus.diff.FileValidationUtils import com.simiacryptus.jopenai.describe.Description import com.simiacryptus.skyenet.apps.plan.AbstractTask import com.simiacryptus.skyenet.apps.plan.PlanSettings -import com.simiacryptus.skyenet.apps.plan.PlanTaskBase -import com.simiacryptus.skyenet.apps.plan.file.AbstractFileTask.FileTaskBase +import com.simiacryptus.skyenet.apps.plan.TaskConfigBase +import com.simiacryptus.skyenet.apps.plan.file.AbstractFileTask.FileTaskConfigBase import java.nio.file.FileSystems import java.nio.file.Files import kotlin.streams.asSequence -abstract class AbstractFileTask( +abstract class AbstractFileTask( planSettings: PlanSettings, planTask: T? ) : AbstractTask(planSettings, planTask) { - open class FileTaskBase( + open class FileTaskConfigBase( task_type: String, task_description: String? = null, task_dependencies: List? = null, @@ -24,7 +24,7 @@ abstract class AbstractFileTask( @Description("The relative file paths to be generated as output for the task") val output_files: List? = null, state: TaskState? = TaskState.Pending, - ) : PlanTaskBase( + ) : TaskConfigBase( task_type = task_type, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/CodeOptimizationTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/CodeOptimizationTask.kt index 0930858a..b1d30153 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/CodeOptimizationTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/CodeOptimizationTask.kt @@ -3,15 +3,15 @@ package com.simiacryptus.skyenet.apps.plan.file import com.simiacryptus.jopenai.describe.Description import com.simiacryptus.skyenet.apps.plan.PlanSettings import com.simiacryptus.skyenet.apps.plan.TaskType -import com.simiacryptus.skyenet.apps.plan.file.CodeOptimizationTask.CodeOptimizationTaskData +import com.simiacryptus.skyenet.apps.plan.file.CodeOptimizationTask.CodeOptimizationTaskConfigData import org.slf4j.LoggerFactory class CodeOptimizationTask( planSettings: PlanSettings, - planTask: CodeOptimizationTaskData? -) : AbstractAnalysisTask(planSettings, planTask) { + planTask: CodeOptimizationTaskConfigData? +) : AbstractAnalysisTask(planSettings, planTask) { - class CodeOptimizationTaskData( + class CodeOptimizationTaskConfigData( @Description("Files to be optimized") val filesToOptimize: List? = null, @Description("Specific areas of focus for the optimization") @@ -21,7 +21,7 @@ class CodeOptimizationTask( input_files: List? = null, output_files: List? = null, state: TaskState? = null - ) : FileTaskBase( + ) : FileTaskConfigBase( task_type = TaskType.Optimization.name, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/CodeReviewTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/CodeReviewTask.kt index 42c66a74..fd1851c6 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/CodeReviewTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/CodeReviewTask.kt @@ -3,14 +3,14 @@ package com.simiacryptus.skyenet.apps.plan.file import com.simiacryptus.jopenai.describe.Description import com.simiacryptus.skyenet.apps.plan.PlanSettings import com.simiacryptus.skyenet.apps.plan.TaskType -import com.simiacryptus.skyenet.apps.plan.file.CodeReviewTask.CodeReviewTaskData +import com.simiacryptus.skyenet.apps.plan.file.CodeReviewTask.CodeReviewTaskConfigData import org.slf4j.LoggerFactory class CodeReviewTask( planSettings: PlanSettings, - planTask: CodeReviewTaskData? -) : AbstractAnalysisTask(planSettings, planTask) { - class CodeReviewTaskData( + planTask: CodeReviewTaskConfigData? +) : AbstractAnalysisTask(planSettings, planTask) { + class CodeReviewTaskConfigData( @Description("List of files to be reviewed") val filesToReview: List? = null, @Description("Specific areas of focus for the review (optional)") @@ -20,7 +20,7 @@ class CodeReviewTask( input_files: List? = null, output_files: List? = null, state: TaskState? = null - ) : FileTaskBase( + ) : FileTaskConfigBase( task_type = TaskType.CodeReview.name, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/DocumentationTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/DocumentationTask.kt index 5546391b..5013053d 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/DocumentationTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/DocumentationTask.kt @@ -6,7 +6,7 @@ import com.simiacryptus.jopenai.OpenAIClient import com.simiacryptus.jopenai.describe.Description import com.simiacryptus.skyenet.Retryable import com.simiacryptus.skyenet.apps.plan.* -import com.simiacryptus.skyenet.apps.plan.file.DocumentationTask.DocumentationTaskData +import com.simiacryptus.skyenet.apps.plan.file.DocumentationTask.DocumentationTaskConfigData import com.simiacryptus.skyenet.core.actors.SimpleActor import com.simiacryptus.skyenet.util.MarkdownUtil import com.simiacryptus.skyenet.webui.session.SessionTask @@ -15,9 +15,9 @@ import java.util.concurrent.Semaphore class DocumentationTask( planSettings: PlanSettings, - planTask: DocumentationTaskData? -) : AbstractFileTask(planSettings, planTask) { - class DocumentationTaskData( + planTask: DocumentationTaskConfigData? +) : AbstractFileTask(planSettings, planTask) { + class DocumentationTaskConfigData( @Description("List topics to document") val topics: List? = null, task_description: String? = null, @@ -25,7 +25,7 @@ class DocumentationTask( input_files: List? = null, output_files: List? = null, state: TaskState? = null - ) : FileTaskBase( + ) : FileTaskConfigBase( task_type = TaskType.Documentation.name, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/FileModificationTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/FileModificationTask.kt index a4514e59..45d4e493 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/FileModificationTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/FileModificationTask.kt @@ -6,7 +6,7 @@ import com.simiacryptus.jopenai.OpenAIClient import com.simiacryptus.jopenai.describe.Description import com.simiacryptus.skyenet.Retryable import com.simiacryptus.skyenet.apps.plan.* -import com.simiacryptus.skyenet.apps.plan.file.FileModificationTask.FileModificationTaskData +import com.simiacryptus.skyenet.apps.plan.file.FileModificationTask.FileModificationTaskConfigData import com.simiacryptus.skyenet.core.actors.SimpleActor import com.simiacryptus.skyenet.util.MarkdownUtil.renderMarkdown import com.simiacryptus.skyenet.webui.session.SessionTask @@ -15,9 +15,9 @@ import java.util.concurrent.Semaphore class FileModificationTask( planSettings: PlanSettings, - planTask: FileModificationTaskData? -) : AbstractFileTask(planSettings, planTask) { - class FileModificationTaskData( + planTask: FileModificationTaskConfigData? +) : AbstractFileTask(planSettings, planTask) { + class FileModificationTaskConfigData( input_files: List? = null, output_files: List? = null, @Description("Specific modifications to be made to the files") @@ -25,7 +25,7 @@ class FileModificationTask( task_description: String? = null, task_dependencies: List? = null, state: TaskState? = null - ) : FileTaskBase( + ) : FileTaskConfigBase( task_type = TaskType.FileModification.name, task_description = task_description, task_dependencies = task_dependencies, @@ -103,11 +103,16 @@ class FileModificationTask( api2: OpenAIClient, planSettings: PlanSettings ) { - if (((planTask?.input_files ?: listOf()) + (planTask?.output_files ?: listOf())).isEmpty()) { + val defaultFile = if (((planTask?.input_files ?: listOf()) + (planTask?.output_files ?: listOf())).isEmpty()) { task.complete("CONFIGURATION ERROR: No input files specified") resultFn("CONFIGURATION ERROR: No input files specified") return + } else if(((planTask?.input_files ?: listOf()) + (planTask?.output_files ?: listOf())).distinct().size == 1) { + ((planTask?.input_files ?: listOf()) + (planTask?.output_files ?: listOf())).first() + } else { + null } + val semaphore = Semaphore(0) val onComplete = { semaphore.release() } val process = { sb: StringBuilder -> @@ -119,27 +124,29 @@ class FileModificationTask( ) resultFn(codeResult) if (agent.planSettings.autoFix) { - val diffLinks = agent.ui.socketManager!!.addApplyFileDiffLinks( - root = agent.root, - response = codeResult, - handle = { newCodeMap -> - newCodeMap.forEach { (path, newCode) -> - task.complete("$path Updated") - } - }, - ui = agent.ui, - api = api, - shouldAutoApply = { agent.planSettings.autoFix }, - model = planSettings.getTaskSettings(TaskType.FileModification).model ?: planSettings.defaultModel, - ) task.complete() onComplete() - renderMarkdown(diffLinks + "\n\n## Auto-applied changes", ui = agent.ui) + renderMarkdown(codeResult, ui = agent.ui) { + agent.ui.socketManager!!.addApplyFileDiffLinks( + root = agent.root, + response = it, + handle = { newCodeMap -> + newCodeMap.forEach { (path, newCode) -> + task.complete("$path Updated") + } + }, + ui = agent.ui, + api = api, + shouldAutoApply = { agent.planSettings.autoFix }, + model = planSettings.getTaskSettings(TaskType.FileModification).model ?: planSettings.defaultModel, + defaultFile = defaultFile + ) + "\n\n## Auto-applied changes" + } } else { - renderMarkdown( + renderMarkdown(codeResult, ui = agent.ui) { agent.ui.socketManager!!.addApplyFileDiffLinks( root = agent.root, - response = codeResult, + response = it, handle = { newCodeMap -> newCodeMap.forEach { (path, newCode) -> task.complete("$path Updated") @@ -148,11 +155,12 @@ class FileModificationTask( ui = agent.ui, api = api, model = planSettings.getTaskSettings(TaskType.FileModification).model ?: planSettings.defaultModel, + defaultFile = defaultFile, ) + acceptButtonFooter(agent.ui) { task.complete() onComplete() - }, ui = agent.ui - ) + } + } } } Retryable(agent.ui, task = task, process = process) diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/InquiryTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/InquiryTask.kt index af882ddb..a3f2fe06 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/InquiryTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/InquiryTask.kt @@ -22,9 +22,9 @@ import kotlin.streams.asSequence class InquiryTask( planSettings: PlanSettings, - planTask: InquiryTaskData? -) : AbstractTask(planSettings, planTask) { - class InquiryTaskData( + planTask: InquiryTaskConfigData? +) : AbstractTask(planSettings, planTask) { + class InquiryTaskConfigData( @Description("The specific questions or topics to be addressed in the inquiry") val inquiry_questions: List? = null, @Description("The goal or purpose of the inquiry") @@ -34,7 +34,7 @@ class InquiryTask( task_description: String? = null, task_dependencies: List? = null, state: TaskState? = null, - ) : PlanTaskBase( + ) : TaskConfigBase( task_type = TaskType.Inquiry.name, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/PerformanceAnalysisTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/PerformanceAnalysisTask.kt index 932419d2..7d40ae0e 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/PerformanceAnalysisTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/PerformanceAnalysisTask.kt @@ -3,14 +3,14 @@ package com.simiacryptus.skyenet.apps.plan.file import com.simiacryptus.jopenai.describe.Description import com.simiacryptus.skyenet.apps.plan.PlanSettings import com.simiacryptus.skyenet.apps.plan.TaskType -import com.simiacryptus.skyenet.apps.plan.file.PerformanceAnalysisTask.PerformanceAnalysisTaskData +import com.simiacryptus.skyenet.apps.plan.file.PerformanceAnalysisTask.PerformanceAnalysisTaskConfigData import org.slf4j.LoggerFactory class PerformanceAnalysisTask( planSettings: PlanSettings, - planTask: PerformanceAnalysisTaskData? -) : AbstractAnalysisTask(planSettings, planTask) { - class PerformanceAnalysisTaskData( + planTask: PerformanceAnalysisTaskConfigData? +) : AbstractAnalysisTask(planSettings, planTask) { + class PerformanceAnalysisTaskConfigData( @Description("Files to be analyzed for performance issues") val files_to_analyze: List? = null, @Description("Specific areas of focus for the analysis (e.g., time complexity, memory usage, I/O operations)") @@ -20,7 +20,7 @@ class PerformanceAnalysisTask( input_files: List? = null, output_files: List? = null, state: TaskState? = null, - ) : FileTaskBase( + ) : FileTaskConfigBase( task_type = TaskType.PerformanceAnalysis.name, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/RefactorTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/RefactorTask.kt index c6a4a397..4cf23c7a 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/RefactorTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/RefactorTask.kt @@ -3,14 +3,14 @@ package com.simiacryptus.skyenet.apps.plan.file import com.simiacryptus.jopenai.describe.Description import com.simiacryptus.skyenet.apps.plan.PlanSettings import com.simiacryptus.skyenet.apps.plan.TaskType -import com.simiacryptus.skyenet.apps.plan.file.RefactorTask.RefactorTaskData +import com.simiacryptus.skyenet.apps.plan.file.RefactorTask.RefactorTaskConfigData import org.slf4j.LoggerFactory class RefactorTask( planSettings: PlanSettings, - planTask: RefactorTaskData? -) : AbstractAnalysisTask(planSettings, planTask) { - class RefactorTaskData( + planTask: RefactorTaskConfigData? +) : AbstractAnalysisTask(planSettings, planTask) { + class RefactorTaskConfigData( @Description("List of files to be refactored") val filesToRefactor: List? = null, @Description("Specific areas of focus for the refactoring (e.g., modularity, design patterns, naming conventions)") @@ -20,7 +20,7 @@ class RefactorTask( input_files: List? = null, output_files: List? = null, state: TaskState? = null - ) : FileTaskBase( + ) : FileTaskConfigBase( task_type = TaskType.RefactorTask.name, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/SecurityAuditTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/SecurityAuditTask.kt index def64593..a67f97b7 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/SecurityAuditTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/SecurityAuditTask.kt @@ -3,16 +3,16 @@ package com.simiacryptus.skyenet.apps.plan.file import com.simiacryptus.jopenai.describe.Description import com.simiacryptus.skyenet.apps.plan.PlanSettings import com.simiacryptus.skyenet.apps.plan.TaskType -import com.simiacryptus.skyenet.apps.plan.file.SecurityAuditTask.SecurityAuditTaskData +import com.simiacryptus.skyenet.apps.plan.file.SecurityAuditTask.SecurityAuditTaskConfigData import org.slf4j.LoggerFactory class SecurityAuditTask( planSettings: PlanSettings, - planTask: SecurityAuditTaskData? -) : AbstractAnalysisTask(planSettings, planTask) { + planTask: SecurityAuditTaskConfigData? +) : AbstractAnalysisTask(planSettings, planTask) { - class SecurityAuditTaskData( + class SecurityAuditTaskConfigData( @Description("List of files to be audited") val filesToAudit: List? = null, @Description("Specific areas of focus for the security audit") @@ -22,7 +22,7 @@ class SecurityAuditTask( input_files: List? = null, output_files: List? = null, state: TaskState? = null - ) : FileTaskBase( + ) : FileTaskConfigBase( task_type = TaskType.SecurityAudit.name, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/TestGenerationTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/TestGenerationTask.kt index 22780afd..14527cdb 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/TestGenerationTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/file/TestGenerationTask.kt @@ -3,15 +3,15 @@ package com.simiacryptus.skyenet.apps.plan.file import com.simiacryptus.jopenai.describe.Description import com.simiacryptus.skyenet.apps.plan.PlanSettings import com.simiacryptus.skyenet.apps.plan.TaskType -import com.simiacryptus.skyenet.apps.plan.file.TestGenerationTask.TestGenerationTaskData +import com.simiacryptus.skyenet.apps.plan.file.TestGenerationTask.TestGenerationTaskConfigData import org.slf4j.LoggerFactory class TestGenerationTask( planSettings: PlanSettings, - planTask: TestGenerationTaskData? -) : AbstractAnalysisTask(planSettings, planTask) { + planTask: TestGenerationTaskConfigData? +) : AbstractAnalysisTask(planSettings, planTask) { - class TestGenerationTaskData( + class TestGenerationTaskConfigData( @Description("List of files for which tests should be generated") val filesToTest: List? = null, @Description("List of input files or tasks to be examined when generating tests") @@ -21,7 +21,7 @@ class TestGenerationTask( input_files: List? = null, output_files: List? = null, state: TaskState? = null - ) : FileTaskBase( + ) : FileTaskConfigBase( task_type = TaskType.TestGeneration.name, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/knowledge/EmbeddingSearchTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/knowledge/EmbeddingSearchTask.kt index 0a0a287b..d110616f 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/knowledge/EmbeddingSearchTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/knowledge/EmbeddingSearchTask.kt @@ -21,9 +21,9 @@ import kotlin.streams.asSequence class EmbeddingSearchTask( planSettings: PlanSettings, - planTask: EmbeddingSearchTaskData? -) : AbstractTask(planSettings, planTask) { - class EmbeddingSearchTaskData( + planTask: EmbeddingSearchTaskConfigData? +) : AbstractTask(planSettings, planTask) { + class EmbeddingSearchTaskConfigData( @Description("The positive search queries to look for in the embeddings") val positive_queries: List, @Description("The negative search queries to avoid in the embeddings") @@ -39,7 +39,7 @@ class EmbeddingSearchTask( task_description: String? = null, task_dependencies: List? = null, state: TaskState? = null, - ) : PlanTaskBase( + ) : TaskConfigBase( task_type = "EmbeddingSearch", task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/knowledge/KnowledgeIndexingTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/knowledge/KnowledgeIndexingTask.kt index bbecb88b..f07c309a 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/knowledge/KnowledgeIndexingTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/knowledge/KnowledgeIndexingTask.kt @@ -16,10 +16,10 @@ import java.util.concurrent.Executors class KnowledgeIndexingTask( planSettings: PlanSettings, - planTask: KnowledgeIndexingTaskData? -) : AbstractTask(planSettings, planTask) { + planTask: KnowledgeIndexingTaskConfigData? +) : AbstractTask(planSettings, planTask) { - class KnowledgeIndexingTaskData( + class KnowledgeIndexingTaskConfigData( @Description("The file paths to process and index") val file_paths: List, @Description("The type of parsing to use (document, code)") @@ -29,7 +29,7 @@ class KnowledgeIndexingTask( task_description: String? = null, task_dependencies: List? = null, state: TaskState? = null, - ) : PlanTaskBase( + ) : TaskConfigBase( task_type = TaskType.KnowledgeIndexing.name, task_description = task_description, task_dependencies = task_dependencies, diff --git a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/knowledge/WebSearchAndIndexTask.kt b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/knowledge/WebSearchAndIndexTask.kt index a14cf4d4..2486536b 100644 --- a/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/knowledge/WebSearchAndIndexTask.kt +++ b/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/knowledge/WebSearchAndIndexTask.kt @@ -7,7 +7,7 @@ import com.simiacryptus.skyenet.apps.parse.DocumentRecord import com.simiacryptus.skyenet.apps.plan.AbstractTask import com.simiacryptus.skyenet.apps.plan.PlanCoordinator import com.simiacryptus.skyenet.apps.plan.PlanSettings -import com.simiacryptus.skyenet.apps.plan.PlanTaskBase +import com.simiacryptus.skyenet.apps.plan.TaskConfigBase import com.simiacryptus.skyenet.webui.session.SessionTask import com.simiacryptus.util.JsonUtil import org.apache.commons.io.FileUtils @@ -30,10 +30,10 @@ import kotlin.text.trimMargin class WebSearchAndIndexTask( planSettings: PlanSettings, - planTask: WebSearchAndIndexTaskData? -) : AbstractTask(planSettings, planTask) { + planTask: WebSearchAndIndexTaskConfigData? +) : AbstractTask(planSettings, planTask) { - class WebSearchAndIndexTaskData( + class WebSearchAndIndexTaskConfigData( @Description("The search query to use for web search") val search_query: String, @Description("The number of search results to process (max 10)") @@ -43,7 +43,7 @@ class WebSearchAndIndexTask( task_description: String? = null, task_dependencies: List? = null, state: TaskState? = null, - ) : PlanTaskBase( + ) : TaskConfigBase( task_type = "WebSearchAndIndex", task_description = task_description, task_dependencies = task_dependencies,