Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.simiacryptus.skyenet.apps.plan
import com.simiacryptus.jopenai.API
import com.simiacryptus.jopenai.ApiModel
import com.simiacryptus.jopenai.util.JsonUtil
import com.simiacryptus.skyenet.apps.coding.CodingAgent
import com.simiacryptus.skyenet.apps.plan.PlanningTask.TaskBreakdownInterface
import com.simiacryptus.skyenet.core.actors.CodingActor
import com.simiacryptus.skyenet.interpreter.ProcessInterpreter
import com.simiacryptus.skyenet.webui.session.SessionTask
import org.slf4j.LoggerFactory
import java.io.File
import java.util.concurrent.Semaphore
import kotlin.reflect.KClass
class RunShellCommandTask(
planSettings: PlanSettings,
planTask: PlanningTask.PlanTask
) : AbstractTask(planSettings, planTask) {
val shellCommandActor by lazy {
CodingActor(
name = "RunShellCommand",
interpreterClass = ProcessInterpreter::class,
details = """
|Execute the following shell command(s) and provide the output. Ensure to handle any errors or exceptions gracefully.
|
|Note: This task is for running simple and safe commands. Avoid executing commands that can cause harm to the system or compromise security.
""".trimMargin(),
symbols = mapOf(
"env" to (planSettings.env ?: emptyMap()),
"workingDir" to (planTask.execution_task?.workingDir?.let { File(it).absolutePath } ?: File(planSettings.workingDir).absolutePath),
"language" to (planSettings.language ?: "bash"),
"command" to planSettings.command,
),
model = planSettings.getTaskSettings(planTask.task_type!!).model ?: planSettings.defaultModel,
temperature = planSettings.temperature,
)
}
override fun promptSegment(): String {
return """
|RunShellCommand - Execute shell commands and provide the output
| ** Specify the command to be executed, or describe the task to be performed
| ** List input files/tasks to be examined when writing the command
| ** Optionally specify a working directory for the command execution
""".trimMargin()
}
override fun run(
agent: PlanCoordinator,
taskId: String,
userMessage: String,
plan: TaskBreakdownInterface,
planProcessingState: PlanProcessingState,
task: SessionTask,
api: API
) {
val semaphore = Semaphore(0)
object : CodingAgent(
api = api,
dataStorage = agent.dataStorage,
session = agent.session,
user = agent.user,
ui = agent.ui,
interpreter = shellCommandActor.interpreterClass as KClass,
symbols = shellCommandActor.symbols,
temperature = shellCommandActor.temperature,
details = shellCommandActor.details,
model = shellCommandActor.model,
mainTask = task,
) {
override fun displayFeedback(
task: SessionTask,
request: CodingActor.CodeRequest,
response: CodingActor.CodeResult
) {
val formText = StringBuilder()
var formHandle: StringBuilder? = null
formHandle = task.add(
"""