Skip to content

Commit 53cf216

Browse files
committed
wip
1 parent ddedb2b commit 53cf216

28 files changed

+4007
-205
lines changed

docs/webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/user_documentation.md

Lines changed: 3751 additions & 0 deletions
Large diffs are not rendered by default.

webui/src/main/kotlin/com/simiacryptus/skyenet/apps/general/AutoPlanChatApp.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ open class AutoPlanChatApp(
348348
agent = coordinator.copy(
349349
planSettings = coordinator.planSettings.copy(
350350
taskSettings = coordinator.planSettings.taskSettings.toList().toTypedArray().toMap().toMutableMap().apply {
351-
this["TaskPlanning"] = TaskSettings(enabled = false, model = null)
351+
this["TaskPlanning"] = TaskSettingsBase(task_type = TaskType.TaskPlanning.name ,enabled = false, model = null)
352352
}
353353
)
354354
),
@@ -427,7 +427,7 @@ open class AutoPlanChatApp(
427427
null
428428
} else {
429429
TaskType.getImpl(coordinator.planSettings, task)
430-
})?.planTask
430+
})?.taskConfig
431431
}
432432
if (tasks.isNullOrEmpty()) {
433433
log.info("No tasks selected from: ${tasks?.map { it.first }}")

webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/AbstractTask.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import java.nio.file.Path
1111

1212
abstract class AbstractTask<T : TaskConfigBase>(
1313
val planSettings: PlanSettings,
14-
val planTask: T?
14+
val taskConfig: T?
1515
) {
1616
var state: TaskState? = TaskState.Pending
1717
protected val codeFiles = mutableMapOf<Path, String>()
@@ -27,7 +27,7 @@ abstract class AbstractTask<T : TaskConfigBase>(
2727
}
2828

2929
open fun getPriorCode(planProcessingState: PlanProcessingState) =
30-
planTask?.task_dependencies?.joinToString("\n\n\n") { dependency ->
30+
taskConfig?.task_dependencies?.joinToString("\n\n\n") { dependency ->
3131
"""
3232
|# $dependency
3333
|

webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/CommandAutoFixTask.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ ${planSettings.commandAutoFixCommands?.joinToString("\n") { " * ${File(it).na
6767
var retryable: Retryable? = null
6868
retryable = Retryable(agent.ui, task = task) {
6969
val task = agent.ui.newTask(false).apply { it.append(placeholder) }
70-
this.planTask?.commands?.forEachIndexed { index, commandWithDir ->
70+
this.taskConfig?.commands?.forEachIndexed { index, commandWithDir ->
7171
val alias = commandWithDir.command.firstOrNull()
7272
val commandAutoFixCommands = agent.planSettings.commandAutoFixCommands
7373
val cmds = commandAutoFixCommands
@@ -94,7 +94,7 @@ ${planSettings.commandAutoFixCommands?.joinToString("\n") { " * ${File(it).na
9494
),
9595
api = api,
9696
files = agent.files,
97-
model = agent.planSettings.getTaskSettings(TaskType.valueOf(planTask.task_type!!)).model
97+
model = agent.planSettings.getTaskSettings(TaskType.valueOf(taskConfig.task_type!!)).model
9898
?: agent.planSettings.defaultModel,
9999
).run(
100100
ui = agent.ui,

webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/CommandSessionTask.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,30 +113,30 @@ class CommandSessionTask(
113113
api2: OpenAIClient,
114114
planSettings: PlanSettings
115115
) {
116-
requireNotNull(planTask) { "CommandSessionTaskData is required" }
116+
requireNotNull(taskConfig) { "CommandSessionTaskData is required" }
117117
var process: Process? = null
118118
try {
119119
cleanupInactiveSessions()
120-
if (activeSessions.size >= MAX_SESSIONS && planTask.sessionId == null) {
120+
if (activeSessions.size >= MAX_SESSIONS && taskConfig.sessionId == null) {
121121
throw IllegalStateException("Maximum number of concurrent sessions ($MAX_SESSIONS) reached")
122122
}
123123

124-
process = planTask.sessionId?.let { id -> activeSessions[id] }
125-
?: ProcessBuilder(planTask.command)
124+
process = taskConfig.sessionId?.let { id -> activeSessions[id] }
125+
?: ProcessBuilder(taskConfig.command)
126126
.redirectErrorStream(true)
127127
.start()
128128
.also { newProcess ->
129-
planTask.sessionId?.let { id -> activeSessions[id] = newProcess }
129+
taskConfig.sessionId?.let { id -> activeSessions[id] = newProcess }
130130
}
131131

132132
val reader = BufferedReader(InputStreamReader(process?.inputStream))
133133
val writer = PrintWriter(process?.outputStream, true)
134134

135-
val results = planTask.inputs.map { input ->
135+
val results = taskConfig.inputs.map { input ->
136136
try {
137137
writer.println(input)
138138
val output = StringBuilder()
139-
val endTime = System.currentTimeMillis() + planTask.timeout
139+
val endTime = System.currentTimeMillis() + taskConfig.timeout
140140
while (System.currentTimeMillis() < endTime) {
141141
if (reader.ready()) {
142142
val line = reader.readLine()
@@ -152,19 +152,19 @@ class CommandSessionTask(
152152
}
153153
}
154154

155-
val result = formatResults(planTask, results)
155+
val result = formatResults(taskConfig, results)
156156
task.add(result)
157157
resultFn(result)
158158

159159
} finally {
160-
if ((planTask.sessionId == null || planTask.closeSession) && process != null) {
160+
if ((taskConfig.sessionId == null || taskConfig.closeSession) && process != null) {
161161
try {
162162
process.destroy()
163163
if (!process.waitFor(5, TimeUnit.SECONDS)) {
164164
process.destroyForcibly()
165165
}
166-
if (planTask.sessionId != null) {
167-
activeSessions.remove(planTask.sessionId)
166+
if (taskConfig.sessionId != null) {
167+
activeSessions.remove(taskConfig.sessionId)
168168
}
169169
} catch (e: Exception) {
170170
log.error("Error closing process", e)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package com.simiacryptus.skyenet.apps.plan
22

3-
class DisabledTaskException(taskType: TaskType<*>) : Exception("Task type $taskType is disabled")
3+
class DisabledTaskException(taskType: TaskType<*, *>) : Exception("Task type $taskType is disabled")

webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/ForeachTask.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ ForeachTask - Execute a task for each item in a list
4848
) {
4949
val userMessage = messages.joinToString("\n")
5050
val items =
51-
planTask?.foreach_items ?: throw RuntimeException("No items specified for ForeachTask")
52-
val subTasks = planTask.foreach_subplan ?: throw RuntimeException("No subTasks specified for ForeachTask")
51+
taskConfig?.foreach_items ?: throw RuntimeException("No items specified for ForeachTask")
52+
val subTasks = taskConfig.foreach_subplan ?: throw RuntimeException("No subTasks specified for ForeachTask")
5353
val subPlanTask = agent.ui.newTask(false)
5454
task.add(subPlanTask.placeholder)
5555

webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/GitHubSearchTask.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ GitHubSearch - Search GitHub for code, commits, issues, repositories, topics, or
6464

6565
private fun performGitHubSearch(planSettings: PlanSettings): String {
6666
val client = HttpClient.newBuilder().build()
67-
val uriBuilder = StringBuilder("https://api.github.com/search/${planTask?.search_type}?q=${planTask?.search_query}&per_page=${planTask?.per_page}")
68-
planTask?.sort?.let { uriBuilder.append("&sort=$it") }
69-
planTask?.order?.let { uriBuilder.append("&order=$it") }
67+
val uriBuilder = StringBuilder("https://api.github.com/search/${taskConfig?.search_type}?q=${taskConfig?.search_query}&per_page=${taskConfig?.per_page}")
68+
taskConfig?.sort?.let { uriBuilder.append("&sort=$it") }
69+
taskConfig?.order?.let { uriBuilder.append("&order=$it") }
7070
val request = HttpRequest.newBuilder()
7171
.uri(URI.create(uriBuilder.toString()))
7272
.header("Accept", "application/vnd.github+json")
@@ -94,7 +94,7 @@ GitHubSearch - Search GitHub for code, commits, issues, repositories, topics, or
9494
appendLine()
9595
val items = searchResults["items"] as List<Map<String, Any>>
9696
items.take(10).forEach { item ->
97-
when (planTask?.search_type) {
97+
when (taskConfig?.search_type) {
9898
"repositories" -> formatRepositoryResult(item)
9999
"code" -> formatCodeResult(item)
100100
"commits" -> formatCommitResult(item)

webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/GoogleSearchTask.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ GoogleSearch - Search Google for web results
5757

5858
private fun performGoogleSearch(planSettings: PlanSettings): String {
5959
val client = HttpClient.newBuilder().build()
60-
val encodedQuery = URLEncoder.encode(planTask?.search_query, "UTF-8")
60+
val encodedQuery = URLEncoder.encode(taskConfig?.search_query, "UTF-8")
6161
val uriBuilder =
62-
"https://www.googleapis.com/customsearch/v1?key=${planSettings.googleApiKey}&cx=${planSettings.googleSearchEngineId}&q=$encodedQuery&num=${planTask?.num_results}"
62+
"https://www.googleapis.com/customsearch/v1?key=${planSettings.googleApiKey}&cx=${planSettings.googleSearchEngineId}&q=$encodedQuery&num=${taskConfig?.num_results}"
6363
val request = HttpRequest.newBuilder().uri(URI.create(uriBuilder)).GET().build()
6464
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
6565
if (response.statusCode() != 200) {

webui/src/main/kotlin/com/simiacryptus/skyenet/apps/plan/PlanSettings.kt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,15 @@ import com.simiacryptus.skyenet.apps.plan.file.FileModificationTask.FileModifica
1212
import com.simiacryptus.skyenet.core.actors.ParsedActor
1313

1414

15-
data class TaskSettings(
16-
var enabled: Boolean = false,
17-
var model: ChatModel? = null
18-
)
19-
2015
open class PlanSettings(
2116
var defaultModel: ChatModel,
2217
var parsingModel: ChatModel,
2318
val command: List<String> = listOf(if (isWindows) "powershell" else "bash"),
2419
var temperature: Double = 0.2,
2520
val budget: Double = 2.0,
26-
val taskSettings: MutableMap<String, TaskSettings> = TaskType.values().associateWith { taskType ->
27-
TaskSettings(
21+
val taskSettings: MutableMap<String, TaskSettingsBase> = TaskType.values().associateWith { taskType ->
22+
TaskSettingsBase(
23+
taskType.name,
2824
when (taskType) {
2925
TaskType.FileModification, TaskType.Inquiry -> true
3026
else -> false
@@ -42,10 +38,10 @@ open class PlanSettings(
4238
var googleSearchEngineId: String? = null,
4339
) {
4440

45-
fun getTaskSettings(taskType: TaskType<*>): TaskSettings =
46-
taskSettings[taskType.name] ?: TaskSettings()
41+
fun getTaskSettings(taskType: TaskType<*, *>): TaskSettingsBase =
42+
taskSettings[taskType.name] ?: TaskSettingsBase(taskType.name)
4743

48-
fun setTaskSettings(taskType: TaskType<*>, settings: TaskSettings) {
44+
fun setTaskSettings(taskType: TaskType<*, *>, settings: TaskSettingsBase) {
4945
taskSettings[taskType.name] = settings
5046
}
5147

@@ -55,7 +51,7 @@ open class PlanSettings(
5551
command: List<String> = this.command,
5652
temperature: Double = this.temperature,
5753
budget: Double = this.budget,
58-
taskSettings: MutableMap<String, TaskSettings> = this.taskSettings,
54+
taskSettings: MutableMap<String, TaskSettingsBase> = this.taskSettings,
5955
autoFix: Boolean = this.autoFix,
6056
allowBlocking: Boolean = this.allowBlocking,
6157
commandAutoFixCommands: List<String>? = this.commandAutoFixCommands,

0 commit comments

Comments
 (0)