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.ApiModel
import com.simiacryptus.skyenet.TabbedDisplay
import com.simiacryptus.skyenet.apps.coding.CodingAgent
import com.simiacryptus.skyenet.core.actors.CodingActor
import com.simiacryptus.skyenet.core.actors.ParsedResponse
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(
settings: Settings,
task: PlanCoordinator.Task
) : AbstractTask(settings, task) {
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 settings.env,
"workingDir" to File(settings.workingDir).absolutePath,
"language" to settings.language,
"command" to settings.command,
),
model = settings.model,
temperature = settings.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
""".trimMargin()
}
override fun run(
agent: PlanCoordinator,
taskId: String,
userMessage: String,
plan: ParsedResponse,
genState: PlanCoordinator.GenState,
task: SessionTask,
taskTabs: TabbedDisplay
) {
if (!agent.settings.shellCommandTaskEnabled) throw RuntimeException("Shell command task is disabled")
val semaphore = Semaphore(0)
object : CodingAgent(
api = agent.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(
"""
|